File: settings.h

package info (click to toggle)
ctrlproxy 3.0.7-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 1,668 kB
  • ctags: 2,045
  • sloc: ansic: 15,358; sh: 2,805; xml: 1,078; python: 346; makefile: 302; perl: 18
file content (235 lines) | stat: -rw-r--r-- 5,291 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
	ctrlproxy: A modular IRC proxy
	(c) 2002-2005 Jelmer Vernooij <jelmer@nl.linux.org>

	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 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CTRLPROXY_SETTINGS_H__
#define __CTRLPROXY_SETTINGS_H__

/**
 * @file
 * @brief Settings
 */

#define DEFAULT_CLIENT_CHARSET NULL

/**
 * Configuration for a particular channel
 */
struct channel_config {
	char *name;
	char *key;
	gboolean autojoin;
};

/**
 * TCP/IP server configuration
 */
struct tcp_server_config {
	/** IP Address or host. */
	char *host;
	
	/** Port number or service name. */
	char *port;

	/** Adress to bind to (or NULL for default) */
	char *bind_address;

	/** Whether SSL should be used. */
	gboolean ssl;

	/** Password to send to remote host. */
	char *password;
};

/**
 * Network configuration.
 */
struct network_config 
{
	GKeyFile *keyfile;
	/** Network name */
	char *name;
	char *nick;
	char *fullname;
	char *username;
	char *password;

	/** Whether this network was created implicitly. */
	int implicit:1;

	/** Whether to automatically connect to this network on startup. */
	int autoconnect:1;

	/** Whether the first NICK sent by clients to this network should be ignored. */
	int ignore_first_nick:1;

	/** Disable reply caching for this network. */
	int disable_cache:1;

	/** For flood protection */
	int queue_speed;

	/** After how much seconds to attempt to reconnect. */
	guint reconnect_interval;

	/** Channels that should be joined. */
	GList *channels;

	enum { 
		NETWORK_TCP, 
		NETWORK_PROGRAM, 
		NETWORK_VIRTUAL,
		NETWORK_IOCHANNEL
	} type;

	union {
		char *virtual_type;
		char *program_location;
		struct { 
			char *default_bind_address;
			GList *servers;
		} tcp;
	} type_settings; 

	/** Commands to send on connect. */
	char **autocmd;
};

/**
 * Log file configuration. Contains substitution variable for 
 * the path of the log file and for the format used for various events 
 * when logging.
 */
struct log_file_config {
	gboolean logbasedir_is_default;
	const char *logbasedir;
	const char *logfilename;
	gboolean is_irssi;
	const char *nickchange;
	const char *join;
	const char *part;
	const char *topic;
	const char *notopic;
	const char *msg;
	const char *action;
	const char *kick;
	const char *mode;
	const char *quit;
	const char *notice;
};

/**
 * Allowed user/password combination for SOCKS.
 */
struct allow_rule {
	char *username;
	char *password;
};

/**
 * Configuration for a single listener
 */
struct listener_config {
	/** Whether SSL is required */
	gboolean ssl;
	gpointer ssl_credentials;

	/** Password */
	char *password;

	/** Address to bind to. Optional. */
	char *address;

	/** Port to listen on */
	char *port;

	/** Default network this listener is connected to. Can be NULL. */
	char *network;
	GList *allow_rules;
	
	/** Whether this is the "default" listener, stored in ~/.ctrlproxy/config */
	gboolean is_default;
};

/**
 * Configuration
 */
struct ctrlproxy_config {
	char *config_dir;
	GList *networks;
	gboolean autosave;
	char *motd_file;
	char *network_socket;
	char *admin_socket;

	/** Whether to create networks that don't exist yet. */
	gboolean create_implicit;

	/** Name of replication backend, or NULL for default. */
	char *replication;

	/** Name of linestack backend, or NULL for default. */
	char *linestack_backend;

	char *client_charset;
	gboolean admin_log;
	char *admin_user;
	enum { 
		REPORT_TIME_ALWAYS,
		REPORT_TIME_NEVER,
		REPORT_TIME_REPLICATION
	} report_time;
	int report_time_offset;
	int max_who_age;
	GKeyFile *keyfile;
	GList *listeners;
	gboolean auto_listener;
	int listener_autoport;
	gboolean learn_nickserv;
	gboolean learn_network_name;
	/**
	 * Auto-away configuration.
	 */
	struct auto_away_config {
		/** Idle time after which to set /AWAY, in seconds. */
		int max_idle_time;
		gint client_limit;
		
		gboolean enabled;

		/** Away message to set. */
		char *message;

		/** Nick to change to when auto away. */
		char *nick;
	} auto_away;

	struct log_file_config *log_file;
};

/* config.c */
G_MODULE_EXPORT struct network_config *network_config_init(struct ctrlproxy_config *cfg);
G_MODULE_EXPORT void save_configuration(struct ctrlproxy_config *cfg, const char *name);
G_MODULE_EXPORT struct ctrlproxy_config *load_configuration(const char *dir);
G_MODULE_EXPORT struct ctrlproxy_config *init_configuration(void);
G_MODULE_EXPORT void free_config(struct ctrlproxy_config *);
G_MODULE_EXPORT void setup_configdir(const char *dir);
G_MODULE_EXPORT gboolean g_key_file_save_to_file(GKeyFile *kf, const gchar *file, GError **error);
G_MODULE_EXPORT void config_del_network(struct ctrlproxy_config *cfg, const char *name);

#endif /* __CTRLPROXY_SETTINGS_H__ */