ftpsrvr.h 5.34 KB
Newer Older
1
2
3
4
5
6
/* Synchronet FTP server */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
7
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *																			*
 * This program is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU General Public License				*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU General Public License for more details: gpl.txt or			*
 * http://www.fsf.org/copyleft/gpl.html										*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/

22
23
24
#ifndef _FTPSRVR_H_
#define _FTPSRVR_H_

25
#include "startup.h"
26
27
28
29
30
31

typedef struct {

	DWORD	size;				/* sizeof(ftp_startup_t) */
	WORD	port;
	WORD	max_clients;
32
#define FTP_DEFAULT_MAX_CLIENTS		10
33
	WORD	max_inactivity;
34
#define FTP_DEFAULT_MAX_INACTIVITY	300
35
	WORD	qwk_timeout;
36
#define FTP_DEFAULT_QWK_TIMEOUT		600
37
	WORD	sem_chk_freq;		/* semaphore file checking frequency (in seconds) */
deuce's avatar
deuce committed
38
39
	struct in_addr outgoing4;
	struct in6_addr	outgoing6;
40
    str_list_t	interfaces;
deuce's avatar
deuce committed
41
42
	struct in_addr pasv_ip_addr;
	struct in6_addr	pasv_ip6_addr;
43
44
	WORD	pasv_port_low;
	WORD	pasv_port_high;
45
    DWORD	options;			/* See FTP_OPT definitions */
46
47
	uint64_t	min_fsize;		/* Minimum file size accepted for upload */
	uint64_t	max_fsize;		/* Maximum file size accepted for upload (0=unlimited) */
48
49
50
51

	void*	cbdata;				/* Private data passed to callbacks */ 

	/* Callbacks (NULL if unused) */
52
53
	int 	(*lputs)(void*, int level, const char* msg);
	void	(*errormsg)(void*, int level, const char* msg);
54
	void	(*status)(void*, const char*);
55
    void	(*started)(void*);
56
	void	(*recycle)(void*);
57
58
59
60
61
    void	(*terminated)(void*, int code);
    void	(*clients)(void*, int active);
    void	(*thread_up)(void*, BOOL up, BOOL setuid);
	void	(*socket_open)(void*, BOOL open);
    void	(*client_on)(void*, BOOL on, int sock, client_t*, BOOL update);
62
    BOOL	(*seteuid)(BOOL user);
63
    BOOL	(*setuid)(BOOL force);
64
65

	/* Paths */
66
    char    ctrl_dir[128];
67
    char	index_file_name[64];
rswindell's avatar
rswindell committed
68
    char	temp_dir[128];
69
70
	char	answer_sound[128];
	char	hangup_sound[128];
71
    char	hack_sound[128];
72
	char	ini_fname[128];
73
74

	/* Misc */
75
    char	host_name[128];
76
	BOOL	recycle_now;
77
	BOOL	shutdown_now;
78
	int		log_level;
79
80
	uint	bind_retry_count;		/* Number of times to retry bind() calls */
	uint	bind_retry_delay;		/* Time to wait between each bind() retry */
81

82
	/* Login Attempt parameters */
rswindell's avatar
rswindell committed
83
	struct login_attempt_settings login_attempt;
84
85
	link_list_t* login_attempt_list;

86
87
	uint	max_concurrent_connections;

88
89
} ftp_startup_t;

90
/* startup options that requires re-initialization/recycle when changed */
91
#if defined(STARTUP_INIT_FIELD_TABLES)
92
93
static struct init_field ftp_init_fields[] = { 
	 OFFSET_AND_SIZE(ftp_startup_t,port)
deuce's avatar
deuce committed
94
	,OFFSET_AND_SIZE(ftp_startup_t,interfaces)
95
96
97
98
	,OFFSET_AND_SIZE(ftp_startup_t,ctrl_dir)
	,OFFSET_AND_SIZE(ftp_startup_t,temp_dir)
	,{ 0,0 }	/* terminator */
};
99
#endif
100

101
102
#define FTP_OPT_DEBUG_RX			(1<<0)
#define FTP_OPT_DEBUG_DATA			(1<<1)
103
#define FTP_OPT_INDEX_FILE			(1<<2)	/* Auto-generate ASCII Index files */
104
105
106
107
#define FTP_OPT_DEBUG_TX			(1<<3)
#define FTP_OPT_ALLOW_QWK			(1<<4)
#define FTP_OPT_NO_LOCAL_FSYS		(1<<5)
#define FTP_OPT_DIR_FILES			(1<<6)	/* Allow access to files in dir but not in database */
108
#define FTP_OPT_KEEP_TEMP_FILES		(1<<7)	/* Don't delete temp files (for debugging) */
109
#define FTP_OPT_LOOKUP_PASV_IP		(1<<9)	/* resolve public IP address for PASV response */
110
#define FTP_OPT_NO_HOST_LOOKUP		(1<<11)
111
#define FTP_OPT_NO_RECYCLE			(1<<27)	/* Disable recycling of server		*/
112
#define FTP_OPT_MUTE				(1<<31)
113

114
/* ftp_startup_t.options bits that require re-init/recycle when changed */
115
#define FTP_INIT_OPTS	(0)
116

117
#if defined(STARTUP_INI_BITDESC_TABLES)
118
119
120
121
122
123
124
125
126
127
static ini_bitdesc_t ftp_options[] = {

	{ FTP_OPT_DEBUG_RX				,"DEBUG_RX"				},
	{ FTP_OPT_DEBUG_DATA			,"DEBUG_DATA"			},	
	{ FTP_OPT_INDEX_FILE			,"INDEX_FILE"			},
	{ FTP_OPT_DEBUG_TX				,"DEBUG_TX"				},
	{ FTP_OPT_ALLOW_QWK				,"ALLOW_QWK"			},
	{ FTP_OPT_NO_LOCAL_FSYS			,"NO_LOCAL_FSYS"		},
	{ FTP_OPT_DIR_FILES				,"DIR_FILES"			},
	{ FTP_OPT_KEEP_TEMP_FILES		,"KEEP_TEMP_FILES"		},
128
	{ FTP_OPT_LOOKUP_PASV_IP		,"LOOKUP_PASV_IP"		},
129
130
131
132
	{ FTP_OPT_NO_HOST_LOOKUP		,"NO_HOST_LOOKUP"		},
	{ FTP_OPT_NO_RECYCLE			,"NO_RECYCLE"			},
	{ FTP_OPT_MUTE					,"MUTE"					},
	/* terminator */										
133
	{ 0 							,NULL					}
134
};
135
#endif
136

137
138
139
140
141
142
143
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif

rswindell's avatar
rswindell committed
144
#ifdef _WIN32
145
	#ifdef FTPSRVR_EXPORTS
146
147
148
149
150
		#define DLLEXPORT __declspec(dllexport)
	#else
		#define DLLEXPORT __declspec(dllimport)
	#endif
	#ifdef __BORLANDC__
151
		#define DLLCALL
152
	#else
153
		#define DLLCALL
154
	#endif
155
156
157
#else
	#define DLLEXPORT
	#define DLLCALL
rswindell's avatar
rswindell committed
158
#endif
159
160
161
162
163

#ifdef __cplusplus
extern "C" {
#endif
/* arg is pointer to static ftp_startup_t */
164
165
166
DLLEXPORT void			DLLCALL ftp_server(void* arg);
DLLEXPORT void			DLLCALL ftp_terminate(void);
DLLEXPORT const char*	DLLCALL ftp_ver(void);
167
168
#ifdef __cplusplus
}
169
170
#endif

171
#endif /* Don't add anything after this line */