1 #ifndef __COMMON_H 2 #define __COMMON_H 3 4 #define IRSSI_DIR_FULL "%s/.irssi" /* %s == g_get_home_dir() */ 5 6 #define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */ 7 #define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */ 8 9 #define IRSSI_ABI_VERSION 20 10 11 #define DEFAULT_SERVER_ADD_PORT 6667 12 #define DEFAULT_SERVER_ADD_TLS_PORT 6697 13 14 #ifdef HAVE_CONFIG_H 15 #include "irssi-config.h" 16 #endif 17 18 #include <stdio.h> 19 #include <stddef.h> 20 #include <stdarg.h> 21 #include <ctype.h> 22 #include <string.h> 23 #include <stdlib.h> 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 41 #include <glib.h> 42 #ifdef HAVE_GMODULE 43 # include <gmodule.h> 44 #endif 45 46 #if defined (UOFF_T_INT) 47 typedef unsigned int uoff_t; 48 #elif defined (UOFF_T_LONG) 49 typedef unsigned long uoff_t; 50 #elif defined (UOFF_T_LONG_LONG) 51 typedef unsigned long long uoff_t; 52 #else 53 # error uoff_t size not set 54 #endif 55 56 /* input functions */ 57 #define G_INPUT_READ (1 << 0) 58 #define G_INPUT_WRITE (1 << 1) 59 60 typedef void (*GInputFunction) (void *data, GIOChannel *source, int condition); 61 62 int g_input_add(GIOChannel *source, int condition, 63 GInputFunction function, void *data); 64 int g_input_add_full(GIOChannel *source, int priority, int condition, 65 GInputFunction function, void *data); 66 67 /* return full path for ~/.irssi */ 68 const char *get_irssi_dir(void); 69 /* return full path for ~/.irssi/config */ 70 const char *get_irssi_config(void); 71 72 /* max. size for %d */ 73 #define MAX_INT_STRLEN ((sizeof(int) * CHAR_BIT + 2) / 3 + 1) 74 75 #define g_free_not_null(a) g_free(a) 76 77 #define g_free_and_null(a) \ 78 G_STMT_START { \ 79 if (a) { g_free(a); (a) = NULL; } \ 80 } G_STMT_END 81 82 /* ctype.h isn't safe with chars, use our own instead */ 83 #define i_toupper(x) toupper((int) (unsigned char) (x)) 84 #define i_tolower(x) tolower((int) (unsigned char) (x)) 85 #define i_isalnum(x) isalnum((int) (unsigned char) (x)) 86 #define i_isalpha(x) isalpha((int) (unsigned char) (x)) 87 #define i_isascii(x) isascii((int) (unsigned char) (x)) 88 #define i_isblank(x) isblank((int) (unsigned char) (x)) 89 #define i_iscntrl(x) iscntrl((int) (unsigned char) (x)) 90 #define i_isdigit(x) isdigit((int) (unsigned char) (x)) 91 #define i_isgraph(x) isgraph((int) (unsigned char) (x)) 92 #define i_islower(x) islower((int) (unsigned char) (x)) 93 #define i_isprint(x) isprint((int) (unsigned char) (x)) 94 #define i_ispunct(x) ispunct((int) (unsigned char) (x)) 95 #define i_isspace(x) isspace((int) (unsigned char) (x)) 96 #define i_isupper(x) isupper((int) (unsigned char) (x)) 97 #define i_isxdigit(x) isxdigit((int) (unsigned char) (x)) 98 99 typedef struct _IPADDR IPADDR; 100 101 typedef struct _LINEBUF_REC LINEBUF_REC; 102 typedef struct _NET_SENDBUF_REC NET_SENDBUF_REC; 103 typedef struct _RAWLOG_REC RAWLOG_REC; 104 105 typedef struct _CHAT_PROTOCOL_REC CHAT_PROTOCOL_REC; 106 typedef struct _CHATNET_REC CHATNET_REC; 107 typedef struct _SERVER_REC SERVER_REC; 108 typedef struct _WI_ITEM_REC WI_ITEM_REC; 109 typedef struct _CHANNEL_REC CHANNEL_REC; 110 typedef struct _QUERY_REC QUERY_REC; 111 typedef struct _NICK_REC NICK_REC; 112 113 typedef struct _SERVER_CONNECT_REC SERVER_CONNECT_REC; 114 typedef struct _SERVER_SETUP_REC SERVER_SETUP_REC; 115 typedef struct _CHANNEL_SETUP_REC CHANNEL_SETUP_REC; 116 117 typedef struct _WINDOW_REC WINDOW_REC; 118 119 #endif 120