updates.
[silc.git] / apps / irssi / src / common.h
1 #ifndef __COMMON_H
2 #define __COMMON_H
3
4 #define IRSSI_WEBSITE "http://irssi.org/"
5 #define IRSSI_AUTHOR_EMAIL "cras@irssi.org"
6 #define IRSSI_AUTHOR "Timo Sirainen <"IRSSI_AUTHOR_EMAIL">"
7
8 #define IRSSI_DIR_SHORT "~/.silc"
9 #define IRSSI_DIR_FULL "%s/.silc" /* %s == g_get_home_dir() */
10
11 #define IRSSI_GLOBAL_CONFIG "silc.conf" /* config file name in /etc/ */
12 #define IRSSI_HOME_CONFIG "silc.conf" /* config file name in ~/.irssi/ */
13
14 #ifdef HAVE_CONFIG_H
15 #include "config.h"
16 #endif
17
18 #include <stdio.h>
19 #include <stddef.h>
20 #include <stdarg.h>
21 #include <ctype.h>
22 #  ifdef HAVE_STRING_H
23 #include <string.h>
24 #endif
25 #ifdef HAVE_STDLIB_H
26 #  include <stdlib.h>
27 #endif
28 #include <errno.h>
29 #include <time.h>
30
31 #include <sys/types.h>
32 #ifdef HAVE_SYS_TIME_H
33 #  include <sys/time.h>
34 #endif
35 #include <sys/stat.h>
36
37 #ifdef HAVE_UNISTD_H
38 #  include <unistd.h>
39 #endif
40 #ifdef HAVE_DIRENT_H
41 #  include <dirent.h>
42 #endif
43 #include <fcntl.h>
44 #ifdef WIN32
45 #  include <win32-compat.h>
46 #endif
47
48 #include <glib.h>
49 #ifdef HAVE_GMODULE
50 #  include <gmodule.h>
51 #endif
52
53 /* input functions */
54 #define G_INPUT_READ    (1 << 0)
55 #define G_INPUT_WRITE   (1 << 1)
56
57 typedef void (*GInputFunction) (void *data, GIOChannel *source, int condition);
58
59 int g_input_add(GIOChannel *source, int condition,
60                 GInputFunction function, void *data);
61 int g_input_add_full(GIOChannel *source, int priority, int condition,
62                      GInputFunction function, void *data);
63
64 /* return full path for ~/.irssi */
65 const char *get_irssi_dir(void);
66 /* return full path for ~/.irssi/config */
67 const char *get_irssi_config(void);
68
69 /* max. size for %d */
70 #define MAX_INT_STRLEN ((sizeof(int) * CHAR_BIT + 2) / 3 + 1)
71
72 #define g_free_not_null(a) g_free(a)
73
74 #define g_free_and_null(a) \
75         G_STMT_START { \
76           if (a) { g_free(a); (a) = NULL; } \
77         } G_STMT_END
78
79 /* ctype.h isn't safe with chars, use our own instead */
80 #define i_toupper(x) toupper((int) (unsigned char) (x))
81 #define i_tolower(x) tolower((int) (unsigned char) (x))
82 #define i_isalnum(x) isalnum((int) (unsigned char) (x))
83 #define i_isalpha(x) isalpha((int) (unsigned char) (x))
84 #define i_isascii(x) isascii((int) (unsigned char) (x))
85 #define i_isblank(x) isblank((int) (unsigned char) (x))
86 #define i_iscntrl(x) iscntrl((int) (unsigned char) (x))
87 #define i_isdigit(x) isdigit((int) (unsigned char) (x))
88 #define i_isgraph(x) isgraph((int) (unsigned char) (x))
89 #define i_islower(x) islower((int) (unsigned char) (x))
90 #define i_isprint(x) isprint((int) (unsigned char) (x))
91 #define i_ispunct(x) ispunct((int) (unsigned char) (x))
92 #define i_isspace(x) isspace((int) (unsigned char) (x))
93 #define i_isupper(x) isupper((int) (unsigned char) (x))
94 #define i_isxdigit(x) isxdigit((int) (unsigned char) (x))
95
96 typedef struct _IPADDR IPADDR;
97 typedef struct _CONFIG_REC CONFIG_REC;
98 typedef struct _CONFIG_NODE CONFIG_NODE;
99
100 typedef struct _LINEBUF_REC LINEBUF_REC;
101 typedef struct _NET_SENDBUF_REC NET_SENDBUF_REC;
102 typedef struct _RAWLOG_REC RAWLOG_REC;
103
104 typedef struct _CHAT_PROTOCOL_REC CHAT_PROTOCOL_REC;
105 typedef struct _CHATNET_REC CHATNET_REC;
106 typedef struct _SERVER_REC SERVER_REC;
107 typedef struct _WI_ITEM_REC WI_ITEM_REC;
108 typedef struct _CHANNEL_REC CHANNEL_REC;
109 typedef struct _QUERY_REC QUERY_REC;
110 typedef struct _NICK_REC NICK_REC;
111
112 typedef struct _SERVER_CONNECT_REC SERVER_CONNECT_REC;
113 typedef struct _SERVER_SETUP_REC SERVER_SETUP_REC;
114 typedef struct _CHANNEL_SETUP_REC CHANNEL_SETUP_REC;
115
116 typedef struct _WINDOW_REC WINDOW_REC;
117
118 #endif