| 1 |
/* |
| 2 |
* Copyright (c) 2005-2006 Atheme Development Group |
| 3 |
* Rights to this code are as documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* Defines needed by multiple header files. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef COMMON_H |
| 10 |
#define COMMON_H |
| 11 |
|
| 12 |
/* D E F I N E S */ |
| 13 |
typedef enum { |
| 14 |
PATH_LOCALE, |
| 15 |
PATH_MODULE, |
| 16 |
PATH_SHARE, |
| 17 |
PATH_CONFIG, |
| 18 |
PATH_LOG, |
| 19 |
PATH_RUN, |
| 20 |
PATH_DATA, |
| 21 |
PATH_VEC_SIZE, |
| 22 |
} path_vec_t; |
| 23 |
|
| 24 |
/* |
| 25 |
* XXX: this is very nieve. |
| 26 |
* We assume that %zu works if we're not on Windows; we know this is a lie. |
| 27 |
* Oh well... |
| 28 |
*/ |
| 29 |
#ifndef _WIN32 |
| 30 |
# define SIZE_T_FORMAT "%zu" |
| 31 |
#else |
| 32 |
# ifndef _WIN64 |
| 33 |
# define SIZE_T_FORMAT "%lu" |
| 34 |
# else |
| 35 |
# define SIZE_T_FORMAT "%llu" |
| 36 |
# endif |
| 37 |
#endif |
| 38 |
|
| 39 |
#define BUFSIZE 1024 /* maximum size of a buffer */ |
| 40 |
#define MAXMODES 4 |
| 41 |
#define MAX_IRC_OUTPUT_LINES 2000 |
| 42 |
|
| 43 |
/* lengths of buffers (string length is 1 less) */ |
| 44 |
#define HOSTLEN 64 /* seems good enough */ |
| 45 |
#define NICKLEN 32 |
| 46 |
#define PASSLEN 289 /* 32 bytes salt + 1024 bits digest + null */ |
| 47 |
#define IDLEN 10 |
| 48 |
#define CHANNELLEN 201 |
| 49 |
#define USERLEN 12 |
| 50 |
#define HOSTIPLEN 54 |
| 51 |
#define GECOSLEN 51 |
| 52 |
#define KEYLEN 24 |
| 53 |
#define EMAILLEN 255 |
| 54 |
#define MEMOLEN 300 |
| 55 |
|
| 56 |
#define MAXMSIGNORES 40 |
| 57 |
|
| 58 |
#undef DEBUG_BALLOC |
| 59 |
|
| 60 |
#ifdef LARGE_NETWORK |
| 61 |
#define HEAP_NODE 1024 |
| 62 |
#define HEAP_CHANNEL 1024 |
| 63 |
#define HEAP_CHANUSER 1024 |
| 64 |
#define HEAP_USER 1024 |
| 65 |
#define HEAP_SERVER 16 |
| 66 |
#define HEAP_CHANACS 1024 |
| 67 |
#define HASH_USER 65535 |
| 68 |
#define HASH_CHANNEL 32768 |
| 69 |
#define HASH_SERVER 128 |
| 70 |
#else |
| 71 |
#define HEAP_NODE 1024 |
| 72 |
#define HEAP_CHANNEL 64 |
| 73 |
#define HEAP_CHANUSER 128 |
| 74 |
#define HEAP_USER 128 |
| 75 |
#define HEAP_SERVER 8 |
| 76 |
#define HEAP_CHANACS 128 |
| 77 |
#define HASH_USER 1024 |
| 78 |
#define HASH_CHANNEL 512 |
| 79 |
#define HASH_SERVER 32 |
| 80 |
#endif |
| 81 |
|
| 82 |
#ifndef TIME_FORMAT |
| 83 |
#define TIME_FORMAT "%b %d %H:%M:%S %Y %z" |
| 84 |
#endif |
| 85 |
|
| 86 |
#define HASH_COMMAND 256 |
| 87 |
#define HASH_SMALL 32 |
| 88 |
#define HASH_ITRANS 128 |
| 89 |
#define HASH_TRANS 2048 |
| 90 |
|
| 91 |
#define CACHEFILE_HEAP_SIZE 32 |
| 92 |
#define CACHELINE_HEAP_SIZE 64 |
| 93 |
|
| 94 |
/* Make it possible to use pointers to these types everywhere |
| 95 |
* (for structures used in multiple header files) */ |
| 96 |
typedef struct user_ user_t; |
| 97 |
|
| 98 |
typedef struct server_ server_t; |
| 99 |
|
| 100 |
typedef struct channel_ channel_t; |
| 101 |
typedef struct chanuser_ chanuser_t; |
| 102 |
typedef struct chanban_ chanban_t; |
| 103 |
|
| 104 |
typedef struct operclass_ operclass_t; |
| 105 |
typedef struct soper_ soper_t; |
| 106 |
typedef struct myuser_ myuser_t; |
| 107 |
typedef struct mynick_ mynick_t; |
| 108 |
typedef struct mychan_ mychan_t; |
| 109 |
|
| 110 |
typedef struct service_ service_t; |
| 111 |
|
| 112 |
typedef struct sourceinfo_ sourceinfo_t; |
| 113 |
|
| 114 |
enum faultcode_ |
| 115 |
{ |
| 116 |
fault_needmoreparams = 1, |
| 117 |
fault_badparams = 2, |
| 118 |
fault_nosuch_source = 3, |
| 119 |
fault_nosuch_target = 4, |
| 120 |
fault_authfail = 5, |
| 121 |
fault_noprivs = 6, |
| 122 |
fault_nosuch_key = 7, |
| 123 |
fault_alreadyexists = 8, |
| 124 |
fault_toomany = 9, |
| 125 |
fault_emailfail = 10, |
| 126 |
fault_notverified = 11, |
| 127 |
fault_nochange = 12, |
| 128 |
fault_already_authed = 13, |
| 129 |
fault_unimplemented = 14, |
| 130 |
fault_badauthcookie = 15, |
| 131 |
fault_internalerror = 16, |
| 132 |
}; |
| 133 |
|
| 134 |
typedef enum faultcode_ cmd_faultcode_t; |
| 135 |
|
| 136 |
#if defined(__GNUC__) || defined(__INTEL_COMPILER) |
| 137 |
#define PRINTFLIKE(fmtarg, firstvararg) \ |
| 138 |
__attribute__((__format__ (__printf__, fmtarg, firstvararg))) |
| 139 |
#define SCANFLIKE(fmtarg, firstvararg) \ |
| 140 |
__attribute__((__format__ (__scanf__, fmtarg, firstvararg))) |
| 141 |
#define DEPRECATED \ |
| 142 |
__attribute__((deprecated)) |
| 143 |
#else |
| 144 |
#define PRINTFLIKE(fmtarg, firstvararg) |
| 145 |
#define SCANFLIKE(fmtarg, firstvararg) |
| 146 |
#define DEPRECATED |
| 147 |
#endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */ |
| 148 |
|
| 149 |
/* Causes a warning if value is not of type (or compatible), returning value. */ |
| 150 |
#define ENSURE_TYPE(value, type) (true ? (value) : (type)0) |
| 151 |
|
| 152 |
/* Returns the size of an array. */ |
| 153 |
#define ARRAY_SIZE(array) sizeof((array)) / sizeof(*(array)) |
| 154 |
|
| 155 |
/* Continue if an assertion fails. */ |
| 156 |
#define continue_if_fail(x) \ |
| 157 |
if (!(x)) { \ |
| 158 |
mowgli_log("critical: Assertion '%s' failed.", #x); \ |
| 159 |
continue; \ |
| 160 |
} |
| 161 |
|
| 162 |
/* strshare.c - stringref management */ |
| 163 |
typedef const char *stringref; |
| 164 |
|
| 165 |
void strshare_init(void); |
| 166 |
stringref strshare_get(const char *str); |
| 167 |
stringref strshare_ref(stringref str); |
| 168 |
void strshare_unref(stringref str); |
| 169 |
|
| 170 |
#endif |
| 171 |
|
| 172 |
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs ts=8 sw=8 noexpandtab |
| 173 |
*/ |