Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

ftpsrvr.h 5.28 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
	int64_t	min_fsize;			/* Minimum file size accepted for upload */
	int64_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[INI_MAX_VALUE_LEN];
67
    char	index_file_name[64];
68 69
    char	temp_dir[INI_MAX_VALUE_LEN];
	char	ini_fname[INI_MAX_VALUE_LEN];
70 71

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

79 80
	struct startup_sound_settings sound;

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

85 86
	uint	max_concurrent_connections;

87 88
} ftp_startup_t;

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

100 101
#define FTP_OPT_DEBUG_RX			(1<<0)
#define FTP_OPT_DEBUG_DATA			(1<<1)
102
#define FTP_OPT_INDEX_FILE			(1<<2)	/* Auto-generate ASCII Index files */
103 104 105 106
#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 */
107
#define FTP_OPT_KEEP_TEMP_FILES		(1<<7)	/* Don't delete temp files (for debugging) */
108
#define FTP_OPT_ALLOW_BOUNCE		(1<<8)
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_ALLOW_BOUNCE			,"ALLOW_BOUNCE"			},
129
	{ FTP_OPT_LOOKUP_PASV_IP		,"LOOKUP_PASV_IP"		},
130 131 132 133
	{ FTP_OPT_NO_HOST_LOOKUP		,"NO_HOST_LOOKUP"		},
	{ FTP_OPT_NO_RECYCLE			,"NO_RECYCLE"			},
	{ FTP_OPT_MUTE					,"MUTE"					},
	/* terminator */										
134
	{ 0 							,NULL					}
135
};
136
#endif
137

138 139 140 141
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif

rswindell's avatar
rswindell committed
142
#ifdef _WIN32
143
	#ifdef FTPSRVR_EXPORTS
144 145 146 147 148 149
		#define DLLEXPORT __declspec(dllexport)
	#else
		#define DLLEXPORT __declspec(dllimport)
	#endif
#else
	#define DLLEXPORT
rswindell's avatar
rswindell committed
150
#endif
151 152 153 154 155

#ifdef __cplusplus
extern "C" {
#endif
/* arg is pointer to static ftp_startup_t */
156 157 158
DLLEXPORT void			ftp_server(void* arg);
DLLEXPORT void			ftp_terminate(void);
DLLEXPORT const char*	ftp_ver(void);
159 160
#ifdef __cplusplus
}
161 162
#endif

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