Release 3.0.3.
[jelmer/ctrlproxy.git] / src / ctrlproxy.h
1 /*
2         ctrlproxy: A modular IRC proxy
3         (c) 2002 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 2 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 __CTRLPROXY_H__
21 #define __CTRLPROXY_H__
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include <time.h>
26 #include <stdarg.h>
27 #include <glib.h>
28 #include <gmodule.h>
29
30 /**
31  * @file
32  * @brief Main functions
33  */
34
35 #if defined(STRICT_MEMORY_ALLOCS) && !defined(SWIGPYTHON)
36 #define calloc(a,b) __ERROR_USE_G_NEW0__
37 #define malloc(a) __ERROR_USE_G_MALLOC_OR_G_NEW__
38 #define realloc(a,b) __ERROR_USE_G_REALLOC_OR_G_RE_NEW__
39 #define free(a) __ERROR_USE_G_FREE__
40 #undef strdup
41 #define strdup(a) __ERROR_USE_G_STRDUP__
42 #undef strndup
43 #define strndup(a) __ERROR_USE_G_STRNDUP__
44 #endif
45
46 #ifndef G_MODULE_EXPORT
47 #define G_MODULE_EXPORT 
48 #endif
49
50 #include "settings.h"
51 #include "network.h"
52 #include "client.h"
53 #include "state.h"
54 #include "linestack.h"
55 #include "hooks.h"
56 #include "repl.h"
57 #include "ctcp.h"
58 #include "admin.h"
59 #include "log.h"
60 #include "isupport.h"
61
62 /**
63  * Global information.
64  */
65 struct global {
66         struct ctrlproxy_config *config;
67         GList *new_network_notifiers;
68         GList *networks;
69         GList *nickserv_nicks;
70
71         GIOChannel *unix_incoming;
72         gint unix_incoming_id;
73 };
74
75 struct plugin_ops {
76         int version;
77         const char *name;
78         gboolean (*init) (void);
79 };
80
81 /* main.c */
82 G_MODULE_EXPORT const char *ctrlproxy_version(void);
83 G_MODULE_EXPORT const char *get_my_hostname(void);
84
85 typedef void (*config_load_notify_fn) (struct global *);
86 typedef void (*config_save_notify_fn) (struct global *, const char *);
87 G_MODULE_EXPORT void register_load_config_notify(config_load_notify_fn fn);
88 G_MODULE_EXPORT void register_save_config_notify(config_save_notify_fn fn);
89
90 /* util.c */
91 G_MODULE_EXPORT char *list_make_string(GList *);
92 G_MODULE_EXPORT int verify_client(const struct network *s, const struct client *c);
93 G_MODULE_EXPORT int str_rfc1459cmp(const char *a, const char *b);
94 G_MODULE_EXPORT int str_strictrfc1459cmp(const char *a, const char *b);
95 G_MODULE_EXPORT int str_asciicmp(const char *a, const char *b);
96 G_MODULE_EXPORT char *g_io_channel_ip_get_description(GIOChannel *ch);
97
98 /* log.c */
99 G_MODULE_EXPORT void log_network(enum log_level, const struct network *, const char *fmt, ...);
100 G_MODULE_EXPORT void log_client(enum log_level, const struct client *, const char *fmt, ...);
101 G_MODULE_EXPORT void log_global(enum log_level, const char *fmt, ...);
102 G_MODULE_EXPORT void log_network_state(enum log_level l, const struct network_state *st, const char *fmt, ...);
103
104 gboolean    rep_g_file_get_contents             (const gchar *filename,
105                                              gchar **contents,
106                                              gsize *length,
107                                              GError **error);
108 gboolean    rep_g_file_set_contents             (const gchar *filename,
109                                              const gchar *contents,
110                                              gssize length,
111                                              GError **error);
112 #if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 8
113 #define g_file_get_contents rep_g_file_get_contents
114 #define g_file_set_contents rep_g_file_set_contents
115 #endif
116
117 #endif /* __CTRLPROXY_H__ */