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

services.h 4.68 KB
Newer Older
1 2 3 4
/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
rswindell's avatar
rswindell committed
5
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *																			*
 * 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.	*
 ****************************************************************************/

#ifndef _SERVICES_H_
#define _SERVICES_H_

23
#include "startup.h"
24 25 26

typedef struct {

27
	DWORD	size;				/* sizeof(bbs_struct_t) */
deuce's avatar
deuce committed
28 29
	struct in_addr outgoing4;
	struct in6_addr	outgoing6;
30
	str_list_t		interfaces;
31
    DWORD	options;			/* See BBS_OPT definitions */
32 33 34 35 36
	WORD	sem_chk_freq;			/* semaphore file checking frequency (in seconds) */

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

	/* Callbacks (NULL if unused) */
37 38
	int 	(*lputs)(void*, int level, const char*);		/* Log - put string */
	void	(*errormsg)(void*, int level, const char* msg);
39
	void	(*status)(void*, const char*);
40
    void	(*started)(void*);
41
	void	(*recycle)(void*);
42 43 44 45 46
    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);
47
    BOOL	(*seteuid)(BOOL user);
48
	BOOL	(*setuid)(BOOL force);
49 50

	/* Paths */
51 52 53
    char    ctrl_dir[INI_MAX_VALUE_LEN];
	char    temp_dir[INI_MAX_VALUE_LEN];
	char	ini_fname[INI_MAX_VALUE_LEN];		// sbbs.ini path/filename
54
	char	services_ini[128];	// services.ini filename
55 56

	/* Misc */
57
    char	host_name[128];
58
	BOOL	recycle_now;
59
	BOOL	shutdown_now;
60
	int		log_level;
61 62
	uint	bind_retry_count;		/* Number of times to retry bind() calls */
	uint	bind_retry_delay;		/* Time to wait between each bind() retry */
63

64 65
	struct startup_sound_settings sound;

66 67 68
	/* JavaScript operating parameters */
	js_startup_t js;

69
	/* Login Attempt parameters */
rswindell's avatar
rswindell committed
70
	struct login_attempt_settings login_attempt;
71 72
	link_list_t* login_attempt_list;

73 74
} services_startup_t;

75
#if 0
76 77
/* startup options that requires re-initialization/recycle when changed */
static struct init_field services_init_fields[] = { 
deuce's avatar
deuce committed
78 79
	 OFFSET_AND_SIZE(services_startup_t,outgoing4)
	 OFFSET_AND_SIZE(services_startup_t,outgoing6)
80 81 82
	,OFFSET_AND_SIZE(services_startup_t,ctrl_dir)
	,{ 0,0 }	/* terminator */
};
83
#endif
84

rswindell's avatar
rswindell committed
85
/* Option bit definitions	*/
86
#define SERVICE_OPT_UDP			(1<<0)	/* UDP Socket */
87 88
#define SERVICE_OPT_STATIC		(1<<1)	/* Static service (accepts client connectsions) */
#define SERVICE_OPT_STATIC_LOOP (1<<2)	/* Loop static service until terminated */
89
#define SERVICE_OPT_NATIVE		(1<<3)	/* non-JavaScript service */
90
#define SERVICE_OPT_FULL_ACCEPT	(1<<4)	/* Accept/close connections when server is full */
deuce's avatar
deuce committed
91
#define SERVICE_OPT_TLS			(1<<5)	/* Use TLS */
rswindell's avatar
rswindell committed
92

93
/* services_startup_t.options bits that require re-init/recycle when changed */
94
#define SERVICE_INIT_OPTS	(0)
95

96
#if defined(STARTUP_INI_BITDESC_TABLES) || defined(SERVICES_INI_BITDESC_TABLE)
97 98 99 100 101 102 103 104 105 106 107
static ini_bitdesc_t service_options[] = {

	{ BBS_OPT_NO_HOST_LOOKUP		,"NO_HOST_LOOKUP"		},
	{ BBS_OPT_GET_IDENT				,"GET_IDENT"			},
	{ BBS_OPT_NO_RECYCLE			,"NO_RECYCLE"			},
	{ BBS_OPT_MUTE					,"MUTE"					},
	{ SERVICE_OPT_UDP				,"UDP"					},
	{ SERVICE_OPT_STATIC			,"STATIC"				},
	{ SERVICE_OPT_STATIC_LOOP		,"LOOP"					},
	{ SERVICE_OPT_NATIVE			,"NATIVE"				},
	{ SERVICE_OPT_FULL_ACCEPT		,"FULL_ACCEPT"			},
deuce's avatar
deuce committed
108
	{ SERVICE_OPT_TLS				,"TLS"					},
109
	/* terminator */				
110
	{ 0 							,NULL					}
111
};
112
#endif
113

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
#ifdef __cplusplus
extern "C" {
#endif

#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif

#ifdef _WIN32
	#ifdef SERVICES_EXPORTS
		#define DLLEXPORT __declspec(dllexport)
	#else
		#define DLLEXPORT __declspec(dllimport)
	#endif
	#ifdef __BORLANDC__
132
		#define DLLCALL
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
	#else
		#define DLLCALL
	#endif
#else
	#define DLLEXPORT
	#define DLLCALL
#endif

/* arg is pointer to static bbs_startup_t* */
DLLEXPORT void			DLLCALL services_thread(void* arg);
DLLEXPORT void			DLLCALL services_terminate(void);
DLLEXPORT const char*	DLLCALL services_ver(void);

#ifdef __cplusplus
}
#endif

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