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