a82c644621afec00bf2fbc503eb7f8b7c9fd3454
[jelmer/ctrlproxy.git] / src / internals.h
1 /* 
2         ctrlproxy: A modular IRC proxy
3         (c) 2002-2005 Jelmer Vernooij <jelmer@nl.linux.org>
4
5         This program is free software; you can redistribute it and/or modify
6         it under the terms of the GNU General Public License as published by
7         the Free Software Foundation; either version 3 of the License, or
8         (at your option) any later version.
9
10         This program is distributed in the hope that it will be useful,
11         but WITHOUT ANY WARRANTY; without even the implied warranty of
12         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13         GNU General Public License for more details.
14
15         You should have received a copy of the GNU General Public License
16         along with this program; if not, write to the Free Software
17         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __INTERNALS_H__
21 #define __INTERNALS_H__
22
23 #define CTRLPROXY_CORE_BUILD
24
25 #ifdef HAVE_CONFIG_H
26 #  include "config.h"
27 #endif
28 #ifdef HAVE_UNISTD_H
29 #  include <unistd.h>
30 #endif
31 #include <netdb.h>
32 #include <sys/socket.h>
33 #include <sys/types.h>
34 #include <errno.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <sys/types.h>
38 #include <string.h>
39 #include <stdarg.h>
40 #include <signal.h>
41 #include <sys/stat.h>
42 #include <fcntl.h>
43 #include "ctrlproxy.h"
44 #include "plugins.h"
45 #include "local.h"
46
47 #define DEFAULT_RECONNECT_INTERVAL      60
48 #define MIN_SILENT_TIME                         60
49 #define MAX_SILENT_TIME                         (2*MIN_SILENT_TIME)
50
51 /* server.c */
52 void fini_networks(struct global *);
53 void kill_pending_clients(const char *reason);
54 void network_set_iochannel(struct network *s, GIOChannel *ioc);
55
56 /* state.c */
57 void free_channels(struct network *s);
58 void network_nick_set_data(struct network_nick *n, const char *nick, const char *username, const char *host);
59 void log_network_state(enum log_level l, const struct network_state *st, const char *fmt, ...);
60
61 /* plugins.c */
62 gboolean init_plugins(const char *dir);
63
64 /* motd.c */
65 char **get_motd_lines(struct client *);
66
67 /* hooks.c */
68 void server_disconnected_hook_execute(struct network *);
69 void server_connected_hook_execute(struct network *);
70 gboolean new_client_hook_execute(struct client *c);
71 void lose_client_hook_execute(struct client *c);
72 gboolean run_client_filter(struct client *c, const struct line *l, enum data_direction dir);
73 gboolean run_server_filter(struct network *s, const struct line *l, enum data_direction dir);
74 gboolean run_log_filter(struct network *s, const struct line *l, enum data_direction dir);
75 gboolean run_replication_filter(struct network *s, const struct line *l, enum data_direction dir);
76
77 /* log.c */
78 gboolean init_log(const char *file);
79 void log_network_line(const struct network *n, const struct line *l, gboolean incoming);
80 void log_client_line(const struct client *c, const struct line *l, gboolean incoming);
81
82 /* redirect.c */
83 void redirect_record(const struct network *n, const struct client *c, const struct line *l);
84 gboolean redirect_response(struct network *n, struct line *l);
85 void redirect_clear(const struct network *n);
86
87 /* cache.c */
88 gboolean client_try_cache(struct client *c, struct line *l);
89
90 /* linestack.c */
91 void init_linestack(struct ctrlproxy_config *);
92
93 /* gen_config.c */
94 void network_update_config(struct network_state *ns, struct network_config *nc);
95 void channel_update_config(struct channel_state *ns, struct channel_config *nc);
96 void global_update_config(struct global *my_global);
97
98 /* repl.c */
99 void client_replicate(struct client *);
100 G_GNUC_MALLOC char *mode2string(char modes[255]);
101 void string2mode(char *modes, char ar[255]);
102
103 gboolean init_replication(void);
104
105 /* main.c */
106 void free_global(struct global *);
107 void config_load_notify(struct global *global);
108 void config_save_notify(struct global *global, const char *);
109 struct global *load_global(const char *config_dir);
110 struct global *init_global(void);
111
112 /* nickserv.c */
113 void init_nickserv(void);
114 gboolean nickserv_load(struct global *global);
115 gboolean nickserv_save(struct global *global, const char *dir);
116 void nickserv_identify_me(struct network *network, char *nick);
117
118 /* admin.c */
119 void init_admin(void);
120 gboolean admin_process_command(struct client *c, struct line *l, int cmdoffset);
121 void admin_log(enum log_level level, const struct network *n, const struct client *c, const char *data);
122 gboolean start_admin_socket(struct global *global);
123 gboolean stop_admin_socket(struct global *global);
124 gboolean admin_socket_prompt(const char *config_dir);
125
126 /* settings.c */
127 gboolean create_configuration(const char *config_dir);
128
129 /* pipes.c */
130 gboolean start_unix_socket(struct global *);
131 gboolean stop_unix_socket(struct global *);
132
133 /* log_custom.c */
134 void log_custom_load(struct log_file_config *config);
135
136 void free_listeners(struct global *global);
137
138 #endif /* __INTERNALS_H__ */