1 /* 2 * 3 * 4 * Copyright(c) 1997-2000 - All Rights Reserved 5 * 6 * See the COPYRIGHT file. 7 */ 8 9 #include "format.h" 10 11 #define ctrl(c) ((c)-'@') 12 13 #define set_option(x, y) x[(y)/8] |= (1 << ((y) % 8)) 14 #define unset_option(x, y) x[(y)/8] &= ~(1 << ((y) % 8)) 15 #define option(x, y) (x[(y)/8] & (1 << ((y) % 8))) 16 17 /* customizable variables */ 18 enum /* boolean options */ 19 { 20 Z_SHOWALL = 0, /* DEBUG: display everything which goes to the log */ 21 Z_REJOIN, /* automaticallly rejoin channels (available at t&s levels) */ 22 Z_RECONNECT, /* automatically reconnect servers (idem) */ 23 Z_RSTATUS, /* use reverse for status bar instead of bold */ 24 Z_ETABKEY, /* enhanced tabkey (not available at the channel level) */ 25 Z_UNDEL, /* undelete mode: shows LOG_DEL entries (see ESC-u) */ 26 Z_HOLD, /* ircii like holdmode: don't automatically scroll */ 27 Z_VCOUNT, /* verbose counters: underlines the static part of the match */ 28 Z_VCTCP, /* verbose CTCPs */ 29 Z_URL, /* grab URLs */ 30 Z_IRCII, /* use ircii style attributes */ 31 Z_NOCOLOR, /* hide ^C color junk */ 32 Z_NOYOW, /* don't yow! */ 33 ZMAX 34 }; 35 36 /* must match TERM_* */ 37 #define K_UNDERLINE 0x00001 38 #define K_STANDOUT 0x00002 39 #define K_BOLD 0x00004 40 #define K_CHIDE 0x00008 41 #define K_BEEP 0x00010 /* beep when matching */ 42 #define K_NOTIFY 0x00020 /* sets W_KEYWORD for window */ 43 #define K_SPACE 0x00040 44 45 #define K_OHIGHLIGHT 0x00100 /* highlight origin (origin matching) */ 46 #define K_OIGNORE 0x00200 /* set LOG_IGNORE (origin matching) */ 47 48 #define K_HIDE 0x01000 /* set LOG_HIDE on message */ 49 #define K_IGNORE 0x02000 /* set LOG_IGNORE on message */ 50 51 #define K_REGEXP 0x10000 /* keyword is a regexp */ 52 53 struct keyword_ 54 { 55 char *kword; 56 #if defined(HAVE_REGEXP) 57 regex_t rword; 58 #endif 59 unsigned int kflag; 60 61 struct keyword_ *nextk; 62 }; 63 64 struct rewrite_ 65 { 66 char type; /* 0: stop on match, 1: keep going */ 67 unsigned int fmt; 68 char *match; 69 char *new; 70 71 #if defined(HAVE_REGEXP) 72 regex_t preg; 73 #endif 74 75 struct rewrite_ *nextr; 76 }; 77 78 struct custom_ 79 { 80 unsigned char zopt_on[(ZMAX + 7)/8]; 81 unsigned char zopt_off[(ZMAX + 7)/8]; 82 83 char **format; /* format strings */ 84 char **numerics; /* format strings for numerics */ 85 unsigned int mask_on[11], mask_off[11]; /* filter masks */ 86 87 struct keyword_ *keywords; 88 struct rewrite_ *rules; 89 90 FILE *log; 91 char logfilter; 92 }; 93 94 /* different log levels */ 95 /* junk, typically not logged by other clients */ 96 #define LOG_DEBUG 0x00000001 /* debug messages */ 97 #define LOG_ISNIF 0x00000002 /* incoming traffic */ 98 #define LOG_OSNIF 0x00000004 /* outgoing traffic */ 99 #define LOG_INPUT 0x00000008 /* typed by the user */ 100 /* source */ 101 #define LOG_SERVER 0x00000010 /* sent by a server */ 102 #define LOG_SERVICE 0x00000020 /* sent by a service */ 103 #define LOG_USER 0x00000040 /* sent by a user */ 104 #define LOG_CLIENT 0x00000080 /* junk displayed by the client */ 105 /* destination scope */ 106 #define LOG_PUBLIC 0x00000100 /* public */ 107 #define LOG_BROADCAST 0x00000200 /* broadcast */ 108 #define LOG_PRIVATE 0x00000400 /* private */ 109 #define LOG_MULTICAST 0x00000800 /* QUIT/NICK type of message 110 used internally ONLY */ 111 /* type */ 112 #define LOG_MSG 0x00001000 /* message */ 113 #define LOG_NOTICE 0x00002000 /* notice */ 114 #define LOG_DCC 0x00004000 /* dcc chat messages */ 115 #define LOG_CRAP 0x00008000 /* what's left */ 116 /* join part quit topic mode hmm */ 117 118 #define LOG_UQUIT 0x00010000 /* regular user quit */ 119 #define LOG_SQUIT 0x00020000 /* user splitting */ 120 #define LOG_SPLIT 0x00040000 /* smart split handling */ 121 122 #define LOG_HIGHLIGHT 0x01000000 /* origin based highlight */ 123 #define LOG_KEYWORD 0x02000000 /* contains a keyword */ 124 125 #define LOG_HIDE 0x10000000 /* hide */ 126 #define LOG_IGNORE 0x20000000 /* origin based ignore */ 127 #define LOG_LASTLOG 0x40000000 /* output from /lastlog */ 128 #define LOG_DEL 0x80000000 /* entry was /clear'ed */ 129 130 #define LOG_ALL 0x0003F7FF 131 #define LOG_DEFAULT 0x0003F7F0 132 #define LOG_QUICKDEL 0x0000000F 133 134 struct log_ 135 { 136 struct log_ *nextl; 137 struct log_ *prevl; 138 /* window???? */ 139 unsigned int flags; 140 char *origin; /* NULL if self */ 141 char *cmd; 142 signed char fmt; 143 char *dest; /* NULL if self -- hmm is this wise? 144 it eventually screws up formatting? */ 145 char *para; 146 time_t ts; /* time stamp */ 147 time_t delts; /* when /clear'ed */ 148 char *prefix; /* optional prefix for the string */ 149 int plen; /* length of the prefix string */ 150 int len; /* length of the formatted string */ 151 char *formatted; /* string as it should appear */ 152 u_char *attributes; /* character attriibutes (optional) */ 153 }; 154 155 enum /* windows options */ 156 { 157 W_DEFAULT = 0, /* hmpf */ 158 W_DCC, /* where all DCC go */ 159 W_MCAST, /* QUIT/NICK */ 160 W_ACTIVITY, /* activity */ 161 W_KEYWORD, /* keyword */ 162 W_NOPREFIX, /* hide prefix */ 163 WMAX 164 }; 165 166 struct window_ 167 { 168 unsigned char ref; 169 170 unsigned char wopt[(WMAX + 7)/8]; 171 172 struct custom_ custw; 173 unsigned char fnb; /* filter number 0-9 */ 174 char *searchstr; /* current search string */ 175 176 struct channel_ *defchan; /* default channel */ 177 char query[10]; 178 179 struct server_ *via, *lasts; /* current and last server */ 180 181 struct log_ *llog, /* last logged line */ 182 *flog, /* first logged line */ 183 *ldisp; /* last line displayed */ 184 unsigned char ltrunc; /* truncation: how many lines not displayed */ 185 186 char *split; 187 time_t split_t; 188 189 struct window_ *nextw; 190 }; 191 192 enum /* server options */ 193 { 194 S_DEFAULT = 0, 195 S_CONFIG, /* configuration file read */ 196 S_DNS, /* waiting for DNS lookup to give IP address */ 197 S_NOTCONNECTED, /* not connected (irc wise: tcp conn might be up) */ 198 S_CONNECTING, /* connecting (tcp wise) */ 199 S_CONNECTED, /* connected (tcp wise) */ 200 S_RECONNECT, /* reconnect after timer expires */ 201 S_QUIT, /* user initiated quit -> don't reconnect */ 202 S_DCC, /* DCC */ 203 S_SEND, /* DCC send */ 204 S_LISTEN, /* waiting for DCC */ 205 S_MOTD, /* set upon 001, removed when receiving motd */ 206 S_PING, /* PING sent */ 207 SMAX 208 }; 209 210 #define P_IRC 1 /* IRC */ 211 #define P_E 2 /* EFnet */ 212 #define P_U 3 /* Undernet */ 213 #define P_D 4 /* Dalnet */ 214 215 #define P_MAX 4 216 217 struct server_ 218 { 219 char *sname; 220 char *ip; 221 #if defined(HAVE_GETADDRINFO) 222 struct addrinfo *addrip; 223 struct addrinfo *address; 224 #endif 225 char *pass; /* also used for DCC filenames */ 226 int port; 227 char *nick; 228 char *uname; /* user name */ 229 char *rname; /* real name */ 230 unsigned char protocol; /* protocol type */ 231 char umode[32]; 232 int fd; 233 char readbuf[520]; 234 unsigned long size, read, sent; /* DCC file size */ 235 int readf; /* incoming file */ 236 int sendf; /* outgoing file */ 237 unsigned char sopt[(SMAX + 7)/8]; 238 239 time_t lastr, ts; 240 241 struct custom_ custs; 242 243 struct server_ *nexts; 244 }; 245 246 enum /* channel options */ 247 { 248 C_DEFAULT = 0, /* default channel for the window */ 249 C_JOINING, /* JOIN sent to server: one and one only 250 * can't issue a PART when this is set 251 */ 252 C_JOINED, /* on channel 253 * can't issue a JOIN when this is set 254 */ 255 C_REJOIN, /* auto rejoin */ 256 C_REJOINED, /* rejoined (already attempted) */ 257 C_CHOP, /* channel operator status */ 258 C_PART, /* user requested part: won't try to rejoin */ 259 C_DEL, /* marked for deletion */ 260 C_NAMES, /* got a complete RPL_NAMES */ 261 CMAX 262 }; 263 264 struct member_ 265 { 266 char *nick; 267 struct member_ *next; 268 }; 269 270 struct channel_ 271 { 272 char *chname; 273 char *chkey; 274 struct window_ *on; 275 unsigned char copt[(CMAX + 7)/8]; 276 277 struct custom_ custc; 278 279 time_t rejoin; 280 281 struct member_ *members; 282 unsigned int member_cnt; 283 284 struct channel_ *nextc; 285 }; 286