| 1 | /* Copyright (c) 2004 James Kretchmar. All rights reserved. |
|---|
| 2 | * |
|---|
| 3 | * Redistribution and use in source and binary forms, with or without |
|---|
| 4 | * modification, are permitted provided that the following conditions are |
|---|
| 5 | * met: |
|---|
| 6 | * |
|---|
| 7 | * * Redistributions of source code must retain the above copyright |
|---|
| 8 | * notice, this list of conditions and the following disclaimer. |
|---|
| 9 | * |
|---|
| 10 | * * Redistributions in binary form must reproduce the above copyright |
|---|
| 11 | * notice, this list of conditions and the following disclaimer in |
|---|
| 12 | * the documentation and/or other materials provided with the |
|---|
| 13 | * distribution. |
|---|
| 14 | * |
|---|
| 15 | * * Redistributions in any form must be accompanied by information on |
|---|
| 16 | * how to obtain complete source code for the Owl software and any |
|---|
| 17 | * accompanying software that uses the Owl software. The source code |
|---|
| 18 | * must either be included in the distribution or be available for no |
|---|
| 19 | * more than the cost of distribution plus a nominal fee, and must be |
|---|
| 20 | * freely redistributable under reasonable conditions. For an |
|---|
| 21 | * executable file, complete source code means the source code for |
|---|
| 22 | * all modules it contains. It does not include source code for |
|---|
| 23 | * modules or files that typically accompany the major components of |
|---|
| 24 | * the operating system on which the executable file runs. |
|---|
| 25 | * |
|---|
| 26 | * |
|---|
| 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|---|
| 28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|---|
| 29 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
|---|
| 30 | * NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE |
|---|
| 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|---|
| 34 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|---|
| 35 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
|---|
| 36 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
|---|
| 37 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | #ifndef INC_OWL_H |
|---|
| 41 | #define INC_OWL_H |
|---|
| 42 | |
|---|
| 43 | #include <sys/param.h> |
|---|
| 44 | #include <EXTERN.h> |
|---|
| 45 | #include <netdb.h> |
|---|
| 46 | #include <regex.h> |
|---|
| 47 | #include <time.h> |
|---|
| 48 | #include <signal.h> |
|---|
| 49 | #include <termios.h> |
|---|
| 50 | #include <libfaim/aim.h> |
|---|
| 51 | #include "config.h" |
|---|
| 52 | #ifdef HAVE_LIBZEPHYR |
|---|
| 53 | #include <zephyr/zephyr.h> |
|---|
| 54 | #endif |
|---|
| 55 | #ifdef HAVE_COM_ERR_H |
|---|
| 56 | #include <com_err.h> |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | /* Perl and curses don't play nice. */ |
|---|
| 60 | #ifdef OWL_PERL |
|---|
| 61 | typedef void WINDOW; |
|---|
| 62 | #include <perl.h> |
|---|
| 63 | #include "XSUB.h" |
|---|
| 64 | #else |
|---|
| 65 | #include <curses.h> |
|---|
| 66 | typedef void SV; |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | static const char owl_h_fileIdent[] = "$Id$"; |
|---|
| 70 | |
|---|
| 71 | #define OWL_VERSION 2.1.11 |
|---|
| 72 | #define OWL_VERSION_STRING "2.1.11-doh" |
|---|
| 73 | |
|---|
| 74 | /* Feature that is being tested to redirect stderr through a pipe. |
|---|
| 75 | * There may still be some portability problems with this. */ |
|---|
| 76 | #define OWL_STDERR_REDIR 1 |
|---|
| 77 | |
|---|
| 78 | #define OWL_DEBUG 0 |
|---|
| 79 | #define OWL_DEBUG_FILE "/var/tmp/owldebug" |
|---|
| 80 | |
|---|
| 81 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
|---|
| 82 | #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ |
|---|
| 83 | |
|---|
| 84 | #define OWL_FMTEXT_ATTR_NONE 0 |
|---|
| 85 | #define OWL_FMTEXT_ATTR_BOLD 1 |
|---|
| 86 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
|---|
| 87 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
|---|
| 88 | |
|---|
| 89 | #define OWL_COLOR_BLACK 0 |
|---|
| 90 | #define OWL_COLOR_RED 1 |
|---|
| 91 | #define OWL_COLOR_GREEN 2 |
|---|
| 92 | #define OWL_COLOR_YELLOW 3 |
|---|
| 93 | #define OWL_COLOR_BLUE 4 |
|---|
| 94 | #define OWL_COLOR_MAGENTA 5 |
|---|
| 95 | #define OWL_COLOR_CYAN 6 |
|---|
| 96 | #define OWL_COLOR_WHITE 7 |
|---|
| 97 | #define OWL_COLOR_DEFAULT 8 |
|---|
| 98 | |
|---|
| 99 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
|---|
| 100 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
|---|
| 101 | |
|---|
| 102 | #define OWL_PROTOCOL_ZEPHYR 0 |
|---|
| 103 | #define OWL_PROTOCOL_AIM 1 |
|---|
| 104 | #define OWL_PROTOCOL_JABBER 2 |
|---|
| 105 | #define OWL_PROTOCOL_ICQ 3 |
|---|
| 106 | #define OWL_PROTOCOL_YAHOO 4 |
|---|
| 107 | #define OWL_PROTOCOL_MSN 5 |
|---|
| 108 | |
|---|
| 109 | #define OWL_MESSAGE_TYPE_ADMIN 0 |
|---|
| 110 | #define OWL_MESSAGE_TYPE_GENERIC 1 |
|---|
| 111 | #define OWL_MESSAGE_TYPE_ZEPHYR 2 |
|---|
| 112 | #define OWL_MESSAGE_TYPE_AIM 3 |
|---|
| 113 | #define OWL_MESSAGE_TYPE_JABBER 4 |
|---|
| 114 | #define OWL_MESSAGE_TYPE_ICQ 5 |
|---|
| 115 | #define OWL_MESSAGE_TYPE_YAHOO 6 |
|---|
| 116 | #define OWL_MESSAGE_TYPE_MSN 7 |
|---|
| 117 | #define OWL_MESSAGE_TYPE_LOOPBACK 8 |
|---|
| 118 | |
|---|
| 119 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
|---|
| 120 | #define OWL_MESSAGE_DIRECTION_IN 1 |
|---|
| 121 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
|---|
| 122 | |
|---|
| 123 | #define OWL_MUX_READ 1 |
|---|
| 124 | #define OWL_MUX_WRITE 2 |
|---|
| 125 | #define OWL_MUX_EXCEPT 4 |
|---|
| 126 | |
|---|
| 127 | #define OWL_DIRECTION_NONE 0 |
|---|
| 128 | #define OWL_DIRECTION_DOWNWARDS 1 |
|---|
| 129 | #define OWL_DIRECTION_UPWARDS 2 |
|---|
| 130 | |
|---|
| 131 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
|---|
| 132 | #define OWL_LOGGING_DIRECTION_IN 1 |
|---|
| 133 | #define OWL_LOGGING_DIRECTION_OUT 2 |
|---|
| 134 | |
|---|
| 135 | #define OWL_SCROLLMODE_NORMAL 0 |
|---|
| 136 | #define OWL_SCROLLMODE_TOP 1 |
|---|
| 137 | #define OWL_SCROLLMODE_NEARTOP 2 |
|---|
| 138 | #define OWL_SCROLLMODE_CENTER 3 |
|---|
| 139 | #define OWL_SCROLLMODE_PAGED 4 |
|---|
| 140 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
|---|
| 141 | |
|---|
| 142 | #define OWL_STYLE_TYPE_INTERNAL 0 |
|---|
| 143 | #define OWL_STYLE_TYPE_PERL 1 |
|---|
| 144 | |
|---|
| 145 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
|---|
| 146 | #define OWL_TABSTR " " |
|---|
| 147 | #define OWL_MSGTAB 7 |
|---|
| 148 | #define OWL_TYPWIN_SIZE 8 |
|---|
| 149 | #define OWL_HISTORYSIZE 50 |
|---|
| 150 | |
|---|
| 151 | /* Indicate current state, as well as what is allowed */ |
|---|
| 152 | #define OWL_CTX_ANY 0xffff |
|---|
| 153 | /* Only one of these may be active at a time... */ |
|---|
| 154 | #define OWL_CTX_MODE_BITS 0x000f |
|---|
| 155 | #define OWL_CTX_STARTUP 0x0001 |
|---|
| 156 | #define OWL_CTX_READCONFIG 0x0002 |
|---|
| 157 | #define OWL_CTX_INTERACTIVE 0x0004 |
|---|
| 158 | /* Only one of these may be active at a time... */ |
|---|
| 159 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
|---|
| 160 | #define OWL_CTX_POPWIN 0x00f0 |
|---|
| 161 | #define OWL_CTX_POPLESS 0x0010 |
|---|
| 162 | #define OWL_CTX_RECWIN 0x0f00 |
|---|
| 163 | #define OWL_CTX_RECV 0x0100 |
|---|
| 164 | #define OWL_CTX_TYPWIN 0xf000 |
|---|
| 165 | #define OWL_CTX_EDIT 0x7000 |
|---|
| 166 | #define OWL_CTX_EDITLINE 0x1000 |
|---|
| 167 | #define OWL_CTX_EDITMULTI 0x2000 |
|---|
| 168 | #define OWL_CTX_EDITRESPONSE 0x4000 |
|---|
| 169 | |
|---|
| 170 | #define OWL_USERCLUE_NONE 0 |
|---|
| 171 | #define OWL_USERCLUE_CLASSES 1 |
|---|
| 172 | #define OWL_USERCLUE_FOOBAR 2 |
|---|
| 173 | #define OWL_USERCLUE_BAZ 4 |
|---|
| 174 | |
|---|
| 175 | #define OWL_WEBBROWSER_NONE 0 |
|---|
| 176 | #define OWL_WEBBROWSER_NETSCAPE 1 |
|---|
| 177 | #define OWL_WEBBROWSER_GALEON 2 |
|---|
| 178 | #define OWL_WEBBROWSER_OPERA 3 |
|---|
| 179 | |
|---|
| 180 | #define OWL_VARIABLE_OTHER 0 |
|---|
| 181 | #define OWL_VARIABLE_INT 1 |
|---|
| 182 | #define OWL_VARIABLE_BOOL 2 |
|---|
| 183 | #define OWL_VARIABLE_STRING 3 |
|---|
| 184 | |
|---|
| 185 | #define OWL_FILTER_MAX_DEPTH 300 |
|---|
| 186 | |
|---|
| 187 | #define OWL_KEYMAP_MAXSTACK 20 |
|---|
| 188 | |
|---|
| 189 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
|---|
| 190 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
|---|
| 191 | |
|---|
| 192 | #define OWL_DEFAULT_ZAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n" |
|---|
| 193 | #define OWL_DEFAULT_AAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n" |
|---|
| 194 | |
|---|
| 195 | #define OWL_INCLUDE_REG_TESTS 1 /* whether to build in regression tests */ |
|---|
| 196 | |
|---|
| 197 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
|---|
| 198 | |
|---|
| 199 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr" |
|---|
| 200 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
|---|
| 201 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
|---|
| 202 | |
|---|
| 203 | #define OWL_REGEX_QUOTECHARS "+*.?[]^\\" |
|---|
| 204 | #define OWL_REGEX_QUOTEWITH "\\" |
|---|
| 205 | |
|---|
| 206 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
|---|
| 207 | #define OWL_ENABLE_ZCRYPT 1 |
|---|
| 208 | #endif |
|---|
| 209 | |
|---|
| 210 | #define OWL_META(key) ((key)|0200) |
|---|
| 211 | /* OWL_CTRL is definied in kepress.c */ |
|---|
| 212 | |
|---|
| 213 | #define LINE 2048 |
|---|
| 214 | |
|---|
| 215 | typedef struct _owl_variable { |
|---|
| 216 | char *name; |
|---|
| 217 | int type; /* OWL_VARIABLE_* */ |
|---|
| 218 | void *pval_default; /* for types other and string */ |
|---|
| 219 | int ival_default; /* for types int and bool */ |
|---|
| 220 | char *validsettings; /* documentation of valid settings */ |
|---|
| 221 | char *summary; /* summary of usage */ |
|---|
| 222 | char *description; /* detailed description */ |
|---|
| 223 | void *val; /* current value */ |
|---|
| 224 | int (*validate_fn)(struct _owl_variable *v, void *newval); |
|---|
| 225 | /* returns 1 if newval is valid */ |
|---|
| 226 | int (*set_fn)(struct _owl_variable *v, void *newval); |
|---|
| 227 | /* sets the variable to a value |
|---|
| 228 | * of the appropriate type. |
|---|
| 229 | * unless documented, this |
|---|
| 230 | * should make a copy. |
|---|
| 231 | * returns 0 on success. */ |
|---|
| 232 | int (*set_fromstring_fn)(struct _owl_variable *v, char *newval); |
|---|
| 233 | /* sets the variable to a value |
|---|
| 234 | * of the appropriate type. |
|---|
| 235 | * unless documented, this |
|---|
| 236 | * should make a copy. |
|---|
| 237 | * returns 0 on success. */ |
|---|
| 238 | void *(*get_fn)(struct _owl_variable *v); |
|---|
| 239 | /* returns a reference to the current value. |
|---|
| 240 | * WARNING: this approach is hard to make |
|---|
| 241 | * thread-safe... */ |
|---|
| 242 | int (*get_tostring_fn)(struct _owl_variable *v, |
|---|
| 243 | char *buf, int bufsize, void *val); |
|---|
| 244 | /* converts val to a string |
|---|
| 245 | * and puts into buf */ |
|---|
| 246 | void (*free_fn)(struct _owl_variable *v); |
|---|
| 247 | /* frees val as needed */ |
|---|
| 248 | } owl_variable; |
|---|
| 249 | |
|---|
| 250 | typedef struct _owl_fmtext { |
|---|
| 251 | int textlen; |
|---|
| 252 | char *textbuff; |
|---|
| 253 | char *fmbuff; |
|---|
| 254 | char *colorbuff; |
|---|
| 255 | } owl_fmtext; |
|---|
| 256 | |
|---|
| 257 | typedef struct _owl_list { |
|---|
| 258 | int size; |
|---|
| 259 | int avail; |
|---|
| 260 | void **list; |
|---|
| 261 | } owl_list; |
|---|
| 262 | |
|---|
| 263 | typedef struct _owl_dict_el { |
|---|
| 264 | char *k; /* key */ |
|---|
| 265 | void *v; /* value */ |
|---|
| 266 | } owl_dict_el; |
|---|
| 267 | |
|---|
| 268 | typedef struct _owl_dict { |
|---|
| 269 | int size; |
|---|
| 270 | int avail; |
|---|
| 271 | owl_dict_el *els; /* invariant: sorted by k */ |
|---|
| 272 | } owl_dict; |
|---|
| 273 | typedef owl_dict owl_vardict; /* dict of variables */ |
|---|
| 274 | typedef owl_dict owl_cmddict; /* dict of commands */ |
|---|
| 275 | |
|---|
| 276 | typedef struct _owl_context { |
|---|
| 277 | int mode; |
|---|
| 278 | void *data; /* determined by mode */ |
|---|
| 279 | } owl_context; |
|---|
| 280 | |
|---|
| 281 | typedef struct _owl_cmd { /* command */ |
|---|
| 282 | char *name; |
|---|
| 283 | |
|---|
| 284 | char *summary; /* one line summary of command */ |
|---|
| 285 | char *usage; /* usage synopsis */ |
|---|
| 286 | char *description; /* long description of command */ |
|---|
| 287 | |
|---|
| 288 | int validctx; /* bitmask of valid contexts */ |
|---|
| 289 | |
|---|
| 290 | /* we should probably have a type here that says which of |
|---|
| 291 | * the following is valid, and maybe make the below into a union... */ |
|---|
| 292 | |
|---|
| 293 | /* Only one of these may be non-NULL ... */ |
|---|
| 294 | |
|---|
| 295 | char *cmd_aliased_to; /* what this command is aliased to... */ |
|---|
| 296 | |
|---|
| 297 | /* These don't take any context */ |
|---|
| 298 | char *(*cmd_args_fn)(int argc, char **argv, char *buff); |
|---|
| 299 | /* takes argv and the full command as buff. |
|---|
| 300 | * caller must free return value if !NULL */ |
|---|
| 301 | void (*cmd_v_fn)(void); /* takes no args */ |
|---|
| 302 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
|---|
| 303 | |
|---|
| 304 | /* The following also take the active context if it's valid */ |
|---|
| 305 | char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); |
|---|
| 306 | /* takes argv and the full command as buff. |
|---|
| 307 | * caller must free return value if !NULL */ |
|---|
| 308 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
|---|
| 309 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
|---|
| 310 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
|---|
| 311 | } owl_cmd; |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | typedef struct _owl_zwrite { |
|---|
| 315 | char *class; |
|---|
| 316 | char *inst; |
|---|
| 317 | char *realm; |
|---|
| 318 | char *opcode; |
|---|
| 319 | char *zsig; |
|---|
| 320 | char *message; |
|---|
| 321 | owl_list recips; |
|---|
| 322 | int cc; |
|---|
| 323 | int noping; |
|---|
| 324 | } owl_zwrite; |
|---|
| 325 | |
|---|
| 326 | typedef struct _owl_pair { |
|---|
| 327 | void *key; |
|---|
| 328 | void *value; |
|---|
| 329 | } owl_pair; |
|---|
| 330 | |
|---|
| 331 | typedef struct _owl_message { |
|---|
| 332 | int id; |
|---|
| 333 | int type; |
|---|
| 334 | int direction; |
|---|
| 335 | #ifdef HAVE_LIBZEPHYR |
|---|
| 336 | ZNotice_t notice; |
|---|
| 337 | #endif |
|---|
| 338 | owl_fmtext fmtext; /* this is now only a CACHED copy */ |
|---|
| 339 | int invalid_format; /* indicates whether fmtext needs to be regenerated */ |
|---|
| 340 | int delete; |
|---|
| 341 | char *hostname; |
|---|
| 342 | owl_list attributes; /* this is a list of pairs */ |
|---|
| 343 | char *timestr; |
|---|
| 344 | time_t time; |
|---|
| 345 | char *zwriteline; |
|---|
| 346 | } owl_message; |
|---|
| 347 | |
|---|
| 348 | typedef struct _owl_style { |
|---|
| 349 | char *name; |
|---|
| 350 | char *description; |
|---|
| 351 | int type; |
|---|
| 352 | char *perlfuncname; |
|---|
| 353 | void (*formatfunc) (owl_fmtext *fm, owl_message *m); |
|---|
| 354 | } owl_style; |
|---|
| 355 | |
|---|
| 356 | typedef struct _owl_mainwin { |
|---|
| 357 | int curtruncated; |
|---|
| 358 | int lasttruncated; |
|---|
| 359 | int lastdisplayed; |
|---|
| 360 | } owl_mainwin; |
|---|
| 361 | |
|---|
| 362 | typedef struct _owl_viewwin { |
|---|
| 363 | owl_fmtext fmtext; |
|---|
| 364 | int textlines; |
|---|
| 365 | int topline; |
|---|
| 366 | int rightshift; |
|---|
| 367 | int winlines, wincols; |
|---|
| 368 | WINDOW *curswin; |
|---|
| 369 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
|---|
| 370 | void *onclose_hook_data; |
|---|
| 371 | } owl_viewwin; |
|---|
| 372 | |
|---|
| 373 | typedef struct _owl_popwin { |
|---|
| 374 | WINDOW *borderwin; |
|---|
| 375 | WINDOW *popwin; |
|---|
| 376 | int lines; |
|---|
| 377 | int cols; |
|---|
| 378 | int active; |
|---|
| 379 | int needsfirstrefresh; |
|---|
| 380 | void (*handler) (int ch); |
|---|
| 381 | } owl_popwin; |
|---|
| 382 | |
|---|
| 383 | typedef struct _owl_popexec { |
|---|
| 384 | int refcount; |
|---|
| 385 | owl_viewwin *vwin; |
|---|
| 386 | int winactive; |
|---|
| 387 | int pid; /* or 0 if it has terminated */ |
|---|
| 388 | int rfd; |
|---|
| 389 | } owl_popexec; |
|---|
| 390 | |
|---|
| 391 | typedef struct _owl_messagelist { |
|---|
| 392 | owl_list list; |
|---|
| 393 | } owl_messagelist; |
|---|
| 394 | |
|---|
| 395 | typedef struct _owl_regex { |
|---|
| 396 | int negate; |
|---|
| 397 | char *string; |
|---|
| 398 | regex_t re; |
|---|
| 399 | } owl_regex; |
|---|
| 400 | |
|---|
| 401 | typedef struct _owl_filterelement { |
|---|
| 402 | int type; |
|---|
| 403 | char *field; |
|---|
| 404 | owl_regex re; |
|---|
| 405 | char *filtername; /* for maching on another filter */ |
|---|
| 406 | } owl_filterelement; |
|---|
| 407 | |
|---|
| 408 | typedef struct _owl_filter { |
|---|
| 409 | char *name; |
|---|
| 410 | int polarity; |
|---|
| 411 | owl_list fes; /* filterelements */ |
|---|
| 412 | int color; |
|---|
| 413 | int cachedmsgid; /* cached msgid: should move into view eventually */ |
|---|
| 414 | } owl_filter; |
|---|
| 415 | |
|---|
| 416 | typedef struct _owl_view { |
|---|
| 417 | char *name; |
|---|
| 418 | owl_filter *filter; |
|---|
| 419 | owl_messagelist ml; |
|---|
| 420 | owl_style *style; |
|---|
| 421 | } owl_view; |
|---|
| 422 | |
|---|
| 423 | typedef struct _owl_history { |
|---|
| 424 | owl_list hist; |
|---|
| 425 | int cur; |
|---|
| 426 | int touched; |
|---|
| 427 | int partial; |
|---|
| 428 | int repeats; |
|---|
| 429 | } owl_history; |
|---|
| 430 | |
|---|
| 431 | typedef struct _owl_editwin { |
|---|
| 432 | char *buff; |
|---|
| 433 | owl_history *hist; |
|---|
| 434 | int bufflen; |
|---|
| 435 | int allocated; |
|---|
| 436 | int buffx, buffy; |
|---|
| 437 | int topline; |
|---|
| 438 | int winlines, wincols, fillcol, wrapcol; |
|---|
| 439 | WINDOW *curswin; |
|---|
| 440 | int style; |
|---|
| 441 | int lock; |
|---|
| 442 | int dotsend; |
|---|
| 443 | int echochar; |
|---|
| 444 | } owl_editwin; |
|---|
| 445 | |
|---|
| 446 | typedef struct _owl_mux { |
|---|
| 447 | int handle; /* for referencing this */ |
|---|
| 448 | int active; /* has this been deleted? */ |
|---|
| 449 | int fd; |
|---|
| 450 | int eventmask; /* bitmask of OWL_MUX_* */ |
|---|
| 451 | void (*handler_fn)(int handle, int fd, int eventmask, void *data); |
|---|
| 452 | void *data; /* data reference to pass to callback */ |
|---|
| 453 | } owl_mux; |
|---|
| 454 | typedef owl_list owl_muxevents; |
|---|
| 455 | |
|---|
| 456 | typedef struct _owl_keybinding { |
|---|
| 457 | int *j; /* keypress stack (0-terminated) */ |
|---|
| 458 | int type; /* command or function? */ |
|---|
| 459 | char *desc; /* description (or "*user*") */ |
|---|
| 460 | char *command; /* command, if of type command */ |
|---|
| 461 | void (*function_fn)(void); /* function ptr, if of type function */ |
|---|
| 462 | } owl_keybinding; |
|---|
| 463 | |
|---|
| 464 | typedef struct _owl_keymap { |
|---|
| 465 | char *name; /* name of keymap */ |
|---|
| 466 | char *desc; /* description */ |
|---|
| 467 | owl_list bindings; /* key bindings */ |
|---|
| 468 | struct _owl_keymap *submap; /* submap */ |
|---|
| 469 | void (*default_fn)(int j); /* default action (takes a keypress) */ |
|---|
| 470 | void (*prealways_fn)(int j); /* always called before a keypress is received */ |
|---|
| 471 | void (*postalways_fn)(int j); /* always called after keypress is processed */ |
|---|
| 472 | } owl_keymap; |
|---|
| 473 | |
|---|
| 474 | typedef struct _owl_keyhandler { |
|---|
| 475 | owl_dict keymaps; /* dictionary of keymaps */ |
|---|
| 476 | owl_keymap *active; /* currently active keymap */ |
|---|
| 477 | int in_esc; /* escape pressed? */ |
|---|
| 478 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
|---|
| 479 | int kpstackpos; /* location in stack (-1 = none) */ |
|---|
| 480 | } owl_keyhandler; |
|---|
| 481 | |
|---|
| 482 | typedef struct _owl_buddy { |
|---|
| 483 | int proto; |
|---|
| 484 | char *name; |
|---|
| 485 | int isidle; |
|---|
| 486 | int idlesince; |
|---|
| 487 | } owl_buddy; |
|---|
| 488 | |
|---|
| 489 | typedef struct _owl_buddylist { |
|---|
| 490 | owl_list buddies; |
|---|
| 491 | } owl_buddylist; |
|---|
| 492 | |
|---|
| 493 | typedef struct _owl_zbuddylist { |
|---|
| 494 | owl_list zusers; |
|---|
| 495 | } owl_zbuddylist; |
|---|
| 496 | |
|---|
| 497 | typedef struct _owl_timer { |
|---|
| 498 | int direction; |
|---|
| 499 | time_t starttime; |
|---|
| 500 | int start; |
|---|
| 501 | } owl_timer; |
|---|
| 502 | |
|---|
| 503 | typedef struct _owl_errqueue { |
|---|
| 504 | owl_list errlist; |
|---|
| 505 | } owl_errqueue; |
|---|
| 506 | |
|---|
| 507 | typedef struct _owl_global { |
|---|
| 508 | owl_mainwin mw; |
|---|
| 509 | owl_popwin pw; |
|---|
| 510 | owl_history cmdhist; /* command history */ |
|---|
| 511 | owl_history msghist; /* outgoing message history */ |
|---|
| 512 | owl_keyhandler kh; |
|---|
| 513 | owl_list filterlist; |
|---|
| 514 | owl_list puntlist; |
|---|
| 515 | owl_muxevents muxevents; /* fds to dispatch on */ |
|---|
| 516 | owl_vardict vars; |
|---|
| 517 | owl_cmddict cmds; |
|---|
| 518 | owl_context ctx; |
|---|
| 519 | owl_errqueue errqueue; |
|---|
| 520 | int lines, cols; |
|---|
| 521 | int curmsg, topmsg; |
|---|
| 522 | int curmsg_vert_offset; |
|---|
| 523 | owl_view current_view; |
|---|
| 524 | owl_messagelist msglist; |
|---|
| 525 | WINDOW *recwin, *sepwin, *msgwin, *typwin; |
|---|
| 526 | int needrefresh; |
|---|
| 527 | int rightshift; |
|---|
| 528 | int resizepending; |
|---|
| 529 | int recwinlines; |
|---|
| 530 | int typwinactive; |
|---|
| 531 | char *thishost; |
|---|
| 532 | char *homedir; |
|---|
| 533 | int direction; |
|---|
| 534 | int zaway; |
|---|
| 535 | char *cur_zaway_msg; |
|---|
| 536 | int haveconfig; |
|---|
| 537 | int config_format; |
|---|
| 538 | char *buffercommand; |
|---|
| 539 | void (*buffercallback)(char *cmd, char *msg); |
|---|
| 540 | owl_editwin tw; |
|---|
| 541 | owl_viewwin vw; |
|---|
| 542 | void *perl; |
|---|
| 543 | int debug; |
|---|
| 544 | int starttime; |
|---|
| 545 | char *startupargs; |
|---|
| 546 | int userclue; |
|---|
| 547 | int nextmsgid; |
|---|
| 548 | int hascolors; |
|---|
| 549 | int colorpairs; |
|---|
| 550 | int searchactive; |
|---|
| 551 | int newmsgproc_pid; |
|---|
| 552 | int malloced, freed; |
|---|
| 553 | char *searchstring; |
|---|
| 554 | owl_filterelement fe_true; |
|---|
| 555 | owl_filterelement fe_false; |
|---|
| 556 | owl_filterelement fe_null; |
|---|
| 557 | aim_session_t aimsess; |
|---|
| 558 | aim_conn_t bosconn; |
|---|
| 559 | owl_timer aim_noop_timer; |
|---|
| 560 | owl_timer aim_ignorelogin_timer; |
|---|
| 561 | owl_timer aim_buddyinfo_timer; |
|---|
| 562 | int aim_loggedin; /* true if currently logged into AIM */ |
|---|
| 563 | int aim_doprocessing; /* true if we should process AIM events (like pending login) */ |
|---|
| 564 | char *aim_screenname; /* currently logged in AIM screen name */ |
|---|
| 565 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
|---|
| 566 | owl_list messagequeue; /* for queueing up aim and other messages */ |
|---|
| 567 | owl_dict styledict; /* global dictionary of available styles */ |
|---|
| 568 | char *response; /* response to the last question asked */ |
|---|
| 569 | int havezephyr; |
|---|
| 570 | int haveaim; |
|---|
| 571 | int got_err_signal; /* 1 if we got an unexpected signal */ |
|---|
| 572 | siginfo_t err_signal_info; |
|---|
| 573 | owl_zbuddylist zbuddies; |
|---|
| 574 | owl_timer zephyr_buddycheck_timer; |
|---|
| 575 | struct termios startup_tio; |
|---|
| 576 | } owl_global; |
|---|
| 577 | |
|---|
| 578 | /* globals */ |
|---|
| 579 | extern owl_global g; |
|---|
| 580 | |
|---|
| 581 | #include "owl_prototypes.h" |
|---|
| 582 | |
|---|
| 583 | /* these are missing from the zephyr includes for some reason */ |
|---|
| 584 | #ifdef HAVE_LIBZEPHYR |
|---|
| 585 | int ZGetSubscriptions(ZSubscription_t *, int *); |
|---|
| 586 | int ZGetLocations(ZLocations_t *,int *); |
|---|
| 587 | #endif |
|---|
| 588 | |
|---|
| 589 | #endif /* INC_OWL_H */ |
|---|