1 /* 2 * struct.h: header file for structures needed for prototypes 3 * 4 * Written by Scott Reynolds, based on code by Michael Sandrof 5 * 6 * Copyright(c) 1995 Scott Reynolds. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)$Id: struct.h,v 1.17 2000/05/28 14:39:43 mrg Exp $ 33 */ 34 35 #ifndef __struct_h_ 36 #define __struct_h_ 37 38 /* 39 * ctcp_entry: the format for each ctcp function. note that the function 40 * described takes 4 parameters, a pointer to the ctcp entry, who the message 41 * was from, who the message was to (nickname, channel, etc), and the rest of 42 * the ctcp message. it can return null, or it can return a malloced string 43 * that will be inserted into the oringal message at the point of the ctcp. 44 * if null is returned, nothing is added to the original message 45 */ 46 typedef struct _ctcp_entry 47 { 48 u_char *name; /* name of ctcp datatag */ 49 u_char *desc; /* description returned by ctcp clientinfo */ 50 int flag; 51 u_char *(*func) _((struct _ctcp_entry *, u_char *, u_char *, u_char *)); /* function that does the dirty deed */ 52 } CtcpEntry; 53 54 typedef struct DCC_struct 55 { 56 unsigned flags; 57 int read; 58 int write; 59 int file; 60 off_t filesize; 61 u_char *description; 62 u_char *user; 63 u_char *othername; 64 struct DCC_struct *next; 65 struct in_addr remote; 66 u_short remport; 67 off_t bytes_read; 68 off_t bytes_sent; 69 time_t lasttime; 70 time_t starttime; 71 u_char *buffer; 72 u_char talkchars[3]; 73 /* the following fields added for ninja irc */ 74 off_t resume_offset; 75 float minimum_speed; 76 } DCC_list; 77 78 /* Hold: your general doubly-linked list type structure */ 79 80 typedef struct HoldStru 81 { 82 u_char *str; 83 struct HoldStru *next; 84 struct HoldStru *prev; 85 int logged; 86 } Hold; 87 88 typedef struct lastlog_stru 89 { 90 int level; 91 u_char *msg; 92 struct lastlog_stru *next; 93 struct lastlog_stru *prev; 94 } Lastlog; 95 96 struct MenuOptionTag 97 { 98 u_char *Name; 99 u_char *Arguments; 100 void (*Func) _((u_char *)); 101 }; 102 103 typedef struct MenuOptionTag MenuOption; 104 105 struct MenuTag 106 { 107 struct MenuTag *next; 108 u_char *Name; 109 int TotalOptions; 110 MenuOption **Options; 111 }; 112 113 typedef struct MenuTag Menu; 114 115 struct ScreenStru; /* ooh! */ 116 117 struct WindowMenuTag 118 { 119 Menu *menu; 120 int lines; 121 int items_per_line; 122 int cursor; 123 }; 124 125 typedef struct WindowMenuTag WindowMenu; 126 127 /* NickList: structure for the list of nicknames of people on a channel */ 128 typedef struct nick_stru 129 { 130 struct nick_stru *next; /* pointer to next nickname entry */ 131 u_char *nick; /* nickname of person on channel */ 132 /* ninja specific fields below */ 133 int status; /* this nick's status */ 134 #define NICK_HERE 0x01 135 #define NICK_AWAY 0x02 136 #define NICK_PLACE_MASK 0x0f 137 #define NICK_CHOP 0x10 138 #define NICK_VOICE 0x20 139 #define NICK_OPER 0x40 140 #define NICK_PRIV_MASK 0xf0 141 int hops; /* how many irc server hops away */ 142 u_char *user; /* the users username */ 143 u_char *host; /* the user's host */ 144 struct in_addr ip; /* the user's IP if we happen to come accross it */ 145 u_char *realname; /* what the users real name is */ 146 u_char *server; /* what server the user is on */ 147 time_t signon_time; /* when the user signed on */ 148 u_long idle_secs; /* how long the user has been idling */ 149 } Nick; 150 151 typedef struct DisplayStru 152 { 153 u_char *line; 154 int linetype; 155 struct DisplayStru *next; 156 } Display; 157 158 typedef struct WindowStru 159 { 160 unsigned int refnum; /* the unique reference number, 161 * assigned by IRCII */ 162 u_char *name; /* window's logical name */ 163 int server; /* server index */ 164 int prev_server; /* previous server index */ 165 int top; /* The top line of the window, screen 166 * coordinates */ 167 int bottom; /* The botton line of the window, screen 168 * coordinates */ 169 int cursor; /* The cursor position in the window, window 170 * relative coordinates */ 171 int line_cnt; /* counter of number of lines displayed in 172 * window */ 173 int scroll; /* true, window scrolls... false window wraps */ 174 int display_size; /* number of lines of window - menu lines */ 175 int old_size; /* if new_size != display_size, 176 * resize_display is called */ 177 int visible; /* true, window is drawn... false window is 178 * hidden */ 179 int update; /* window needs updating flag */ 180 unsigned miscflags; /* Miscellaneous flags. */ 181 182 u_char *prompt; /* A prompt string, usually set by EXEC'd process */ 183 u_char *status_line[2]; /* The status line strings */ 184 185 int double_status; /* Display the 2nd status line ?*/ 186 187 Display *top_of_display, /* Pointer to first line of display structure */ 188 *display_ip; /* Pointer to insertiong point of display 189 * structure */ 190 191 u_char *current_channel; /* Window's current channel */ 192 u_char *bound_channel; /* Channel that belongs in this window */ 193 u_char *query_nick; /* User being QUERY'ied in this window */ 194 Nick *nicks; /* List of nicks that will go to window */ 195 int window_level; /* The LEVEL of the window, determines what 196 * messages go to it */ 197 198 /* hold stuff */ 199 int hold_mode; /* true, hold mode is on for window... 200 * false it isn't */ 201 int hold_on_next_rite; /* true, the next call to rite() will 202 * activate a hold */ 203 int held; /* true, the window is currently being 204 * held */ 205 int last_held; /* Previous value of hold flag. Used 206 * for various updating needs */ 207 Hold *hold_head, /* Pointer to first entry in hold 208 * list */ 209 *hold_tail; /* Pointer to last entry in hold list */ 210 int held_lines; /* number of lines being held */ 211 int scrolled_lines; /* number of lines scrolled back */ 212 int new_scrolled_lines; /* number of lines since scroll back 213 * keys where pressed */ 214 WindowMenu menu; /* The menu (if any) */ 215 216 /* lastlog stuff */ 217 Lastlog *lastlog_head; /* pointer to top of lastlog list */ 218 Lastlog *lastlog_tail; /* pointer to bottom of lastlog list */ 219 int lastlog_level; /* The LASTLOG_LEVEL, determines what 220 * messages go to lastlog */ 221 int lastlog_size; /* Max number of messages for the window 222 * lastlog */ 223 224 int notify_level; /* the notify level.. */ 225 226 u_char *logfile; /* window's logfile name */ 227 /* window log stuff */ 228 int log; /* true, file logging for window is on */ 229 FILE *log_fp; /* file pointer for the log file */ 230 231 struct ScreenStru *screen; 232 int server_group; /* server group number */ 233 234 struct WindowStru *next; /* pointer to next entry in window list (null 235 * is end) */ 236 struct WindowStru *prev; /* pointer to previous entry in window list 237 * (null is end) */ 238 int sticky; /* make channels stick to window when 239 changing servers ? */ 240 } Window; 241 242 /* 243 * WindowStack: The structure for the POP, PUSH, and STACK functions. A 244 * simple linked list with window refnums as the data 245 */ 246 typedef struct window_stack_stru 247 { 248 unsigned int refnum; 249 struct window_stack_stru *next; 250 } WindowStack; 251 252 typedef struct 253 { 254 int top; 255 int bottom; 256 int position; 257 } ShrinkInfo; 258 259 typedef struct PromptStru 260 { 261 u_char *prompt; 262 u_char *data; 263 int type; 264 void (*func) _((u_char *, u_char *)); 265 struct PromptStru *next; 266 } WaitPrompt; 267 268 269 typedef struct ScreenStru 270 { 271 int screennum; 272 Window *current_window; 273 unsigned int last_window_refnum; /* reference number of the 274 * window that was last 275 * the current_window */ 276 Window *window_list; /* List of all visible 277 * windows */ 278 Window *window_list_end; /* end of visible window 279 * list */ 280 Window *cursor_window; /* Last window to have 281 * something written to it */ 282 int visible_windows; /* total number of windows */ 283 WindowStack *window_stack; /* the windows here */ 284 285 int meta1_hit; /* if meta1 is hit in this 286 * screen or not */ 287 int meta2_hit; /* above, for meta2 */ 288 int meta3_hit; /* above, for meta3 */ 289 int meta4_hit; /* above, for meta4 */ 290 int meta5_hit; /* above, for meta5 */ 291 int meta6_hit; /* above, for meta6 */ 292 int meta7_hit; /* above, for meta7 */ 293 int meta8_hit; /* above, for meta8 */ 294 int quote_hit; /* true if a key bound to 295 * QUOTE_CHARACTER has been 296 * hit. */ 297 int digraph_hit; /* A digraph key has been hit */ 298 int inside_menu; /* what it says. */ 299 300 u_char digraph_first; 301 302 struct ScreenStru *prev; /* These are the Screen list */ 303 struct ScreenStru *next; /* pointers */ 304 305 FILE *fpin; /* These are the file pointers */ 306 int fdin; /* and descriptions for the */ 307 FILE *fpout; /* screen's input/output */ 308 int fdout; 309 310 u_char input_buffer[INPUT_BUFFER_SIZE+1]; /* the input buffer */ 311 int buffer_pos; /* and the positions for the */ 312 int buffer_min_pos; /* screen */ 313 314 u_char saved_input_buffer[INPUT_BUFFER_SIZE+1]; 315 int saved_buffer_pos; 316 int saved_min_buffer_pos; 317 318 WaitPrompt *promptlist; 319 320 u_char *redirect_name; 321 u_char *redirect_token; 322 int redirect_server; 323 324 u_char *tty_name; 325 int co; 326 int li; 327 328 int alive; 329 } Screen; 330 331 /* 332 * this is the structure for a ban list entry. 333 */ 334 typedef struct mode_b_stru 335 { 336 struct mode_b_stru *next; 337 u_char *ban; 338 u_char *owner; 339 time_t time; 340 } Ban; 341 342 /* 343 * this is the structure for a ban exception list entry. 344 */ 345 typedef struct mode_e_stru 346 { 347 struct mode_e_stru *next; 348 u_char *exception; 349 u_char *owner; 350 time_t time; 351 } Except; 352 353 /* 354 * this is the structure for a deny (regexp) list entry. 355 */ 356 typedef struct mode_d_stru 357 { 358 struct mode_d_stru *next; 359 u_char *regexp; 360 u_char *owner; 361 time_t time; 362 } Deny; 363 364 /* Channel: structure for an entry in the list of channels you are current on */ 365 typedef struct channel_stru 366 { 367 struct channel_stru *next; /* pointer to next channel entry */ 368 u_char *channel; /* channel name */ 369 int server; /* server index for this channel */ 370 u_long mode; /* current mode settings for channel */ 371 u_char *s_mode; /* string representation of the above */ 372 int limit; /* max users for the channel */ 373 u_char *key; /* key for this channel */ 374 int connected; /* connection status */ 375 #define CHAN_LIMBO -1 376 #define CHAN_JOINING 0 377 #define CHAN_JOINED 1 378 Window *window; /* the window that the channel is "on" */ 379 Nick *nicks; /* pointer to list of nicks on channel */ 380 int status; /* different flags */ 381 #define CHAN_CHOP 0x0001 382 #define CHAN_VOICE 0x0002 383 /* ninja uses WHO output to cache nicks, instead of names */ 384 #define CHAN_WHO 0x0004 385 #define CHAN_NAMES 0x0008 386 #define CHAN_MODE 0x0010 387 #define CHAN_START 0x0020 388 #define CHAN_BANS 0x0040 389 #define CHAN_EXCEPT 0x0080 390 #define CHAN_DENY 0x0100 391 #ifdef SHOW_JOIN_TIME 392 # define CHAN_SHOWED_TIME 0x0200 393 #endif 394 /* ninja specific fields */ 395 Ban *bans; /* channel bans */ 396 Except *excepts; /* channel ban exceptions */ 397 Deny *denys; /* channel regexp denys */ 398 #ifdef SHOW_JOIN_TIME 399 struct timeval join_time; /* when the client entered the channel */ 400 #endif 401 } Channel; 402 403 typedef struct ckey_stru 404 { 405 struct ckey_stru *next; 406 u_char *channel; 407 u_char *key; 408 } CKey; 409 410 typedef struct list_stru 411 { 412 struct list_stru *next; 413 u_char *name; 414 } List; 415 #endif /* __struct_h_ */ 416