Merged with Irssi 0.8.6.
[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 #define DEFAULT_SERVER_ADD_PORT 706
15
16 #ifdef HAVE_CONFIG_H
17 #include "config.h"
18 #endif
19
20 #include <stdio.h>
21 #include <stddef.h>
22 #include <stdarg.h>
23 #include <ctype.h>
24 #  ifdef HAVE_STRING_H
25 #include <string.h>
26 #endif
27 #ifdef HAVE_STDLIB_H
28 #  include <stdlib.h>
29 #endif
30 #include <errno.h>
31 #include <time.h>
32
33 #include <sys/types.h>
34 #ifdef HAVE_SYS_TIME_H
35 #  include <sys/time.h>
36 #endif
37 #include <sys/stat.h>
38
39 #ifdef HAVE_UNISTD_H
40 #  include <unistd.h>
41 #endif
42 #ifdef HAVE_DIRENT_H
43 #  include <dirent.h>
44 #endif
45 #include <fcntl.h>
46 #ifdef WIN32
47 #  include <win32-compat.h>
48 #endif
49
50 #include <glib.h>
51 #ifdef HAVE_GMODULE
52 #  include <gmodule.h>
53 #endif
54
55 #if defined (UOFF_T_INT)
56 typedef unsigned int uoff_t;
57 #elif defined (UOFF_T_LONG)
58 typedef unsigned long uoff_t;
59 #elif defined (UOFF_T_LONGLONG)
60 typedef unsigned long long uoff_t;
61 #else
62 #  error uoff_t size not set
63 #endif
64
65 /* input functions */
66 #define G_INPUT_READ    (1 << 0)
67 #define G_INPUT_WRITE   (1 << 1)
68
69 typedef void (*GInputFunction) (void *data, GIOChannel *source, int condition);
70
71 int g_input_add(GIOChannel *source, int condition,
72                 GInputFunction function, void *data);
73 int g_input_add_full(GIOChannel *source, int priority, int condition,
74                      GInputFunction function, void *data);
75
76 /* return full path for ~/.irssi */
77 const char *get_irssi_dir(void);
78 /* return full path for ~/.irssi/config */
79 const char *get_irssi_config(void);
80
81 /* max. size for %d */
82 #define MAX_INT_STRLEN ((sizeof(int) * CHAR_BIT + 2) / 3 + 1)
83
84 #define g_free_not_null(a) g_free(a)
85
86 #define g_free_and_null(a) \
87         G_STMT_START { \
88           if (a) { g_free(a); (a) = NULL; } \
89         } G_STMT_END
90
91 /* ctype.h isn't safe with chars, use our own instead */
92 #define i_toupper(x) toupper((int) (unsigned char) (x))
93 #define i_tolower(x) tolower((int) (unsigned char) (x))
94 #define i_isalnum(x) isalnum((int) (unsigned char) (x))
95 #define i_isalpha(x) isalpha((int) (unsigned char) (x))
96 #define i_isascii(x) isascii((int) (unsigned char) (x))
97 #define i_isblank(x) isblank((int) (unsigned char) (x))
98 #define i_iscntrl(x) iscntrl((int) (unsigned char) (x))
99 #define i_isdigit(x) isdigit((int) (unsigned char) (x))
100 #define i_isgraph(x) isgraph((int) (unsigned char) (x))
101 #define i_islower(x) islower((int) (unsigned char) (x))
102 #define i_isprint(x) isprint((int) (unsigned char) (x))
103 #define i_ispunct(x) ispunct((int) (unsigned char) (x))
104 #define i_isspace(x) isspace((int) (unsigned char) (x))
105 #define i_isupper(x) isupper((int) (unsigned char) (x))
106 #define i_isxdigit(x) isxdigit((int) (unsigned char) (x))
107
108 typedef struct _IPADDR IPADDR;
109 typedef struct _CONFIG_REC CONFIG_REC;
110 typedef struct _CONFIG_NODE CONFIG_NODE;
111
112 typedef struct _LINEBUF_REC LINEBUF_REC;
113 typedef struct _NET_SENDBUF_REC NET_SENDBUF_REC;
114 typedef struct _RAWLOG_REC RAWLOG_REC;
115
116 typedef struct _CHAT_PROTOCOL_REC CHAT_PROTOCOL_REC;
117 typedef struct _CHATNET_REC CHATNET_REC;
118 typedef struct _SERVER_REC SERVER_REC;
119 typedef struct _WI_ITEM_REC WI_ITEM_REC;
120 typedef struct _CHANNEL_REC CHANNEL_REC;
121 typedef struct _QUERY_REC QUERY_REC;
122 typedef struct _NICK_REC NICK_REC;
123
124 typedef struct _SERVER_CONNECT_REC SERVER_CONNECT_REC;
125 typedef struct _SERVER_SETUP_REC SERVER_SETUP_REC;
126 typedef struct _CHANNEL_SETUP_REC CHANNEL_SETUP_REC;
127
128 typedef struct _WINDOW_REC WINDOW_REC;
129
130 #endif