[5ca5f8e] | 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 | |
---|
[7d4fbcd] | 40 | #ifndef INC_OWL_H |
---|
| 41 | #define INC_OWL_H |
---|
| 42 | |
---|
[1bdffcb] | 43 | #ifndef OWL_PERL |
---|
| 44 | #include <curses.h> |
---|
| 45 | #endif |
---|
[7d4fbcd] | 46 | #include <sys/param.h> |
---|
| 47 | #include <EXTERN.h> |
---|
| 48 | #include <netdb.h> |
---|
| 49 | #include <regex.h> |
---|
[d09e5a1] | 50 | #include <time.h> |
---|
[c9e72d1] | 51 | #include <signal.h> |
---|
[8232149] | 52 | #include <termios.h> |
---|
[d09e5a1] | 53 | #include <libfaim/aim.h> |
---|
[7d4fbcd] | 54 | #include "config.h" |
---|
[be0a79f] | 55 | #ifdef HAVE_LIBZEPHYR |
---|
[373b7e7] | 56 | #include <zephyr/zephyr.h> |
---|
[be0a79f] | 57 | #endif |
---|
[e6449bc] | 58 | #ifdef HAVE_COM_ERR_H |
---|
| 59 | #include <com_err.h> |
---|
| 60 | #endif |
---|
| 61 | |
---|
[6922edd] | 62 | /* Perl and curses don't play nice. */ |
---|
| 63 | #ifdef OWL_PERL |
---|
| 64 | typedef void WINDOW; |
---|
| 65 | #include <perl.h> |
---|
| 66 | #include "XSUB.h" |
---|
| 67 | #else |
---|
| 68 | typedef void SV; |
---|
| 69 | #endif |
---|
| 70 | |
---|
[1aee7d9] | 71 | static const char owl_h_fileIdent[] = "$Id$"; |
---|
| 72 | |
---|
[d08162a] | 73 | #define STRINGIFY(x) _STRINGIFY(x) |
---|
| 74 | #define _STRINGIFY(x) #x |
---|
| 75 | |
---|
| 76 | #ifndef OWL_SVN_REVNO |
---|
| 77 | #define OWL_SVN_REVNO ???? |
---|
| 78 | #endif |
---|
| 79 | |
---|
| 80 | #define OWL_VERSION_STRING "r" STRINGIFY(OWL_SVN_REVNO) |
---|
| 81 | |
---|
[2a2bb60] | 82 | |
---|
| 83 | /* Feature that is being tested to redirect stderr through a pipe. |
---|
| 84 | * There may still be some portability problems with this. */ |
---|
| 85 | #define OWL_STDERR_REDIR 1 |
---|
[7d4fbcd] | 86 | |
---|
| 87 | #define OWL_DEBUG 0 |
---|
| 88 | #define OWL_DEBUG_FILE "/var/tmp/owldebug" |
---|
| 89 | |
---|
[bd3f232] | 90 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
[38cf544c] | 91 | #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ |
---|
| 92 | |
---|
[7d4fbcd] | 93 | #define OWL_FMTEXT_ATTR_NONE 0 |
---|
| 94 | #define OWL_FMTEXT_ATTR_BOLD 1 |
---|
| 95 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
---|
| 96 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
---|
| 97 | |
---|
| 98 | #define OWL_COLOR_BLACK 0 |
---|
| 99 | #define OWL_COLOR_RED 1 |
---|
| 100 | #define OWL_COLOR_GREEN 2 |
---|
| 101 | #define OWL_COLOR_YELLOW 3 |
---|
| 102 | #define OWL_COLOR_BLUE 4 |
---|
| 103 | #define OWL_COLOR_MAGENTA 5 |
---|
| 104 | #define OWL_COLOR_CYAN 6 |
---|
| 105 | #define OWL_COLOR_WHITE 7 |
---|
[c2c5c77] | 106 | #define OWL_COLOR_DEFAULT -1 |
---|
[7d4fbcd] | 107 | |
---|
| 108 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
---|
| 109 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
---|
| 110 | |
---|
[f4d0975] | 111 | #define OWL_PROTOCOL_ZEPHYR 0 |
---|
| 112 | #define OWL_PROTOCOL_AIM 1 |
---|
| 113 | #define OWL_PROTOCOL_JABBER 2 |
---|
| 114 | #define OWL_PROTOCOL_ICQ 3 |
---|
| 115 | #define OWL_PROTOCOL_YAHOO 4 |
---|
| 116 | #define OWL_PROTOCOL_MSN 5 |
---|
| 117 | |
---|
[4b464a4] | 118 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
| 119 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
| 120 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
[7d4fbcd] | 121 | |
---|
[afbf668] | 122 | #define OWL_MUX_READ 1 |
---|
| 123 | #define OWL_MUX_WRITE 2 |
---|
| 124 | #define OWL_MUX_EXCEPT 4 |
---|
| 125 | |
---|
[7d4fbcd] | 126 | #define OWL_DIRECTION_NONE 0 |
---|
| 127 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
| 128 | #define OWL_DIRECTION_UPWARDS 2 |
---|
| 129 | |
---|
[12c35df] | 130 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
---|
| 131 | #define OWL_LOGGING_DIRECTION_IN 1 |
---|
| 132 | #define OWL_LOGGING_DIRECTION_OUT 2 |
---|
| 133 | |
---|
[88736cb] | 134 | #define OWL_SCROLLMODE_NORMAL 0 |
---|
| 135 | #define OWL_SCROLLMODE_TOP 1 |
---|
| 136 | #define OWL_SCROLLMODE_NEARTOP 2 |
---|
| 137 | #define OWL_SCROLLMODE_CENTER 3 |
---|
| 138 | #define OWL_SCROLLMODE_PAGED 4 |
---|
[aa2f33b3] | 139 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
| 140 | |
---|
[bd3f232] | 141 | #define OWL_STYLE_TYPE_INTERNAL 0 |
---|
| 142 | #define OWL_STYLE_TYPE_PERL 1 |
---|
| 143 | |
---|
[7d4fbcd] | 144 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
---|
| 145 | #define OWL_TABSTR " " |
---|
| 146 | #define OWL_MSGTAB 7 |
---|
| 147 | #define OWL_TYPWIN_SIZE 8 |
---|
| 148 | #define OWL_HISTORYSIZE 50 |
---|
| 149 | |
---|
| 150 | /* Indicate current state, as well as what is allowed */ |
---|
| 151 | #define OWL_CTX_ANY 0xffff |
---|
| 152 | /* Only one of these may be active at a time... */ |
---|
| 153 | #define OWL_CTX_MODE_BITS 0x000f |
---|
| 154 | #define OWL_CTX_STARTUP 0x0001 |
---|
| 155 | #define OWL_CTX_READCONFIG 0x0002 |
---|
| 156 | #define OWL_CTX_INTERACTIVE 0x0004 |
---|
| 157 | /* Only one of these may be active at a time... */ |
---|
| 158 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
---|
| 159 | #define OWL_CTX_POPWIN 0x00f0 |
---|
| 160 | #define OWL_CTX_POPLESS 0x0010 |
---|
| 161 | #define OWL_CTX_RECWIN 0x0f00 |
---|
| 162 | #define OWL_CTX_RECV 0x0100 |
---|
| 163 | #define OWL_CTX_TYPWIN 0xf000 |
---|
[cf83b7a] | 164 | #define OWL_CTX_EDIT 0x7000 |
---|
[7d4fbcd] | 165 | #define OWL_CTX_EDITLINE 0x1000 |
---|
| 166 | #define OWL_CTX_EDITMULTI 0x2000 |
---|
[cf83b7a] | 167 | #define OWL_CTX_EDITRESPONSE 0x4000 |
---|
[7d4fbcd] | 168 | |
---|
| 169 | #define OWL_USERCLUE_NONE 0 |
---|
| 170 | #define OWL_USERCLUE_CLASSES 1 |
---|
| 171 | #define OWL_USERCLUE_FOOBAR 2 |
---|
| 172 | #define OWL_USERCLUE_BAZ 4 |
---|
| 173 | |
---|
| 174 | #define OWL_WEBBROWSER_NONE 0 |
---|
| 175 | #define OWL_WEBBROWSER_NETSCAPE 1 |
---|
| 176 | #define OWL_WEBBROWSER_GALEON 2 |
---|
[ae9e6be] | 177 | #define OWL_WEBBROWSER_OPERA 3 |
---|
[7d4fbcd] | 178 | |
---|
| 179 | #define OWL_VARIABLE_OTHER 0 |
---|
| 180 | #define OWL_VARIABLE_INT 1 |
---|
| 181 | #define OWL_VARIABLE_BOOL 2 |
---|
| 182 | #define OWL_VARIABLE_STRING 3 |
---|
| 183 | |
---|
| 184 | #define OWL_FILTER_MAX_DEPTH 300 |
---|
| 185 | |
---|
[4b464a4] | 186 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
[7d4fbcd] | 187 | |
---|
[4b464a4] | 188 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
| 189 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
[7d4fbcd] | 190 | |
---|
[4b464a4] | 191 | #define OWL_DEFAULT_ZAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n" |
---|
[4b660cc] | 192 | #define OWL_DEFAULT_AAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n" |
---|
[7d4fbcd] | 193 | |
---|
[4b464a4] | 194 | #define OWL_INCLUDE_REG_TESTS 1 /* whether to build in regression tests */ |
---|
[7d4fbcd] | 195 | |
---|
[1c7a4e0] | 196 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
[7d4fbcd] | 197 | |
---|
[e7cc1c3] | 198 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr" |
---|
[1d3e925] | 199 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
| 200 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
[e7cc1c3] | 201 | |
---|
[80e54a7] | 202 | #define OWL_REGEX_QUOTECHARS "+*.?[]^\\${}()" |
---|
[bc08664] | 203 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
| 204 | |
---|
[0435c7d] | 205 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
[c86a35c] | 206 | #define OWL_ENABLE_ZCRYPT 1 |
---|
[c269e22] | 207 | #endif |
---|
| 208 | |
---|
[f87c490] | 209 | #define OWL_META(key) ((key)|0200) |
---|
| 210 | /* OWL_CTRL is definied in kepress.c */ |
---|
[7d4fbcd] | 211 | |
---|
| 212 | #define LINE 2048 |
---|
| 213 | |
---|
| 214 | typedef struct _owl_variable { |
---|
| 215 | char *name; |
---|
| 216 | int type; /* OWL_VARIABLE_* */ |
---|
| 217 | void *pval_default; /* for types other and string */ |
---|
| 218 | int ival_default; /* for types int and bool */ |
---|
| 219 | char *validsettings; /* documentation of valid settings */ |
---|
[aa2f33b3] | 220 | char *summary; /* summary of usage */ |
---|
| 221 | char *description; /* detailed description */ |
---|
[7d4fbcd] | 222 | void *val; /* current value */ |
---|
| 223 | int (*validate_fn)(struct _owl_variable *v, void *newval); |
---|
| 224 | /* returns 1 if newval is valid */ |
---|
| 225 | int (*set_fn)(struct _owl_variable *v, void *newval); |
---|
| 226 | /* sets the variable to a value |
---|
| 227 | * of the appropriate type. |
---|
| 228 | * unless documented, this |
---|
| 229 | * should make a copy. |
---|
| 230 | * returns 0 on success. */ |
---|
| 231 | int (*set_fromstring_fn)(struct _owl_variable *v, char *newval); |
---|
| 232 | /* sets the variable to a value |
---|
| 233 | * of the appropriate type. |
---|
| 234 | * unless documented, this |
---|
| 235 | * should make a copy. |
---|
| 236 | * returns 0 on success. */ |
---|
| 237 | void *(*get_fn)(struct _owl_variable *v); |
---|
| 238 | /* returns a reference to the current value. |
---|
| 239 | * WARNING: this approach is hard to make |
---|
| 240 | * thread-safe... */ |
---|
| 241 | int (*get_tostring_fn)(struct _owl_variable *v, |
---|
| 242 | char *buf, int bufsize, void *val); |
---|
| 243 | /* converts val to a string |
---|
| 244 | * and puts into buf */ |
---|
| 245 | void (*free_fn)(struct _owl_variable *v); |
---|
| 246 | /* frees val as needed */ |
---|
| 247 | } owl_variable; |
---|
| 248 | |
---|
| 249 | typedef struct _owl_fmtext { |
---|
| 250 | int textlen; |
---|
[a387d12e] | 251 | int bufflen; |
---|
[7d4fbcd] | 252 | char *textbuff; |
---|
| 253 | char *fmbuff; |
---|
[c2c5c77] | 254 | short *fgcolorbuff; |
---|
| 255 | short *bgcolorbuff; |
---|
[7d4fbcd] | 256 | } owl_fmtext; |
---|
| 257 | |
---|
| 258 | typedef struct _owl_list { |
---|
| 259 | int size; |
---|
| 260 | int avail; |
---|
| 261 | void **list; |
---|
| 262 | } owl_list; |
---|
| 263 | |
---|
| 264 | typedef struct _owl_dict_el { |
---|
| 265 | char *k; /* key */ |
---|
| 266 | void *v; /* value */ |
---|
| 267 | } owl_dict_el; |
---|
| 268 | |
---|
| 269 | typedef struct _owl_dict { |
---|
| 270 | int size; |
---|
| 271 | int avail; |
---|
| 272 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
| 273 | } owl_dict; |
---|
| 274 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
| 275 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
| 276 | |
---|
| 277 | typedef struct _owl_context { |
---|
| 278 | int mode; |
---|
| 279 | void *data; /* determined by mode */ |
---|
| 280 | } owl_context; |
---|
| 281 | |
---|
| 282 | typedef struct _owl_cmd { /* command */ |
---|
| 283 | char *name; |
---|
| 284 | |
---|
| 285 | char *summary; /* one line summary of command */ |
---|
| 286 | char *usage; /* usage synopsis */ |
---|
| 287 | char *description; /* long description of command */ |
---|
| 288 | |
---|
| 289 | int validctx; /* bitmask of valid contexts */ |
---|
| 290 | |
---|
| 291 | /* we should probably have a type here that says which of |
---|
| 292 | * the following is valid, and maybe make the below into a union... */ |
---|
| 293 | |
---|
| 294 | /* Only one of these may be non-NULL ... */ |
---|
| 295 | |
---|
| 296 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
| 297 | |
---|
| 298 | /* These don't take any context */ |
---|
| 299 | char *(*cmd_args_fn)(int argc, char **argv, char *buff); |
---|
| 300 | /* takes argv and the full command as buff. |
---|
| 301 | * caller must free return value if !NULL */ |
---|
| 302 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
| 303 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
| 304 | |
---|
| 305 | /* The following also take the active context if it's valid */ |
---|
| 306 | char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); |
---|
| 307 | /* takes argv and the full command as buff. |
---|
| 308 | * caller must free return value if !NULL */ |
---|
| 309 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
| 310 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
[6922edd] | 311 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
[7d4fbcd] | 312 | } owl_cmd; |
---|
| 313 | |
---|
| 314 | |
---|
| 315 | typedef struct _owl_zwrite { |
---|
[ce7db4d] | 316 | char *class; |
---|
| 317 | char *inst; |
---|
| 318 | char *realm; |
---|
| 319 | char *opcode; |
---|
[56330ff] | 320 | char *zsig; |
---|
[ce7db4d] | 321 | char *message; |
---|
[7d4fbcd] | 322 | owl_list recips; |
---|
| 323 | int cc; |
---|
| 324 | int noping; |
---|
| 325 | } owl_zwrite; |
---|
| 326 | |
---|
[d0d65df] | 327 | typedef struct _owl_pair { |
---|
| 328 | void *key; |
---|
| 329 | void *value; |
---|
| 330 | } owl_pair; |
---|
| 331 | |
---|
[a387d12e] | 332 | struct _owl_fmtext_cache; |
---|
| 333 | |
---|
[7d4fbcd] | 334 | typedef struct _owl_message { |
---|
| 335 | int id; |
---|
[4b464a4] | 336 | int direction; |
---|
[be0a79f] | 337 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 338 | ZNotice_t notice; |
---|
[be0a79f] | 339 | #endif |
---|
[a387d12e] | 340 | struct _owl_fmtext_cache * fmtext; |
---|
[7d4fbcd] | 341 | int delete; |
---|
[8298425] | 342 | char *hostname; |
---|
[65ad073] | 343 | owl_list attributes; /* this is a list of pairs */ |
---|
[25dd31a] | 344 | char *timestr; |
---|
| 345 | time_t time; |
---|
[7d4fbcd] | 346 | char *zwriteline; |
---|
| 347 | } owl_message; |
---|
| 348 | |
---|
[a387d12e] | 349 | #define OWL_FMTEXT_CACHE_SIZE 1000 |
---|
| 350 | /* We cache the saved fmtexts for the last bunch of messages we |
---|
| 351 | rendered */ |
---|
| 352 | typedef struct _owl_fmtext_cache { |
---|
| 353 | owl_message * message; |
---|
| 354 | owl_fmtext fmtext; |
---|
| 355 | } owl_fmtext_cache; |
---|
| 356 | |
---|
[bd3f232] | 357 | typedef struct _owl_style { |
---|
| 358 | char *name; |
---|
[f1e629d] | 359 | char *description; |
---|
[bd3f232] | 360 | int type; |
---|
| 361 | char *perlfuncname; |
---|
| 362 | void (*formatfunc) (owl_fmtext *fm, owl_message *m); |
---|
| 363 | } owl_style; |
---|
| 364 | |
---|
[7d4fbcd] | 365 | typedef struct _owl_mainwin { |
---|
| 366 | int curtruncated; |
---|
[f2e36b5] | 367 | int lasttruncated; |
---|
[7d4fbcd] | 368 | int lastdisplayed; |
---|
| 369 | } owl_mainwin; |
---|
| 370 | |
---|
| 371 | typedef struct _owl_viewwin { |
---|
| 372 | owl_fmtext fmtext; |
---|
| 373 | int textlines; |
---|
| 374 | int topline; |
---|
| 375 | int rightshift; |
---|
| 376 | int winlines, wincols; |
---|
| 377 | WINDOW *curswin; |
---|
[afbf668] | 378 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
| 379 | void *onclose_hook_data; |
---|
[7d4fbcd] | 380 | } owl_viewwin; |
---|
| 381 | |
---|
| 382 | typedef struct _owl_popwin { |
---|
| 383 | WINDOW *borderwin; |
---|
| 384 | WINDOW *popwin; |
---|
| 385 | int lines; |
---|
| 386 | int cols; |
---|
| 387 | int active; |
---|
| 388 | int needsfirstrefresh; |
---|
| 389 | void (*handler) (int ch); |
---|
| 390 | } owl_popwin; |
---|
| 391 | |
---|
[afbf668] | 392 | typedef struct _owl_popexec { |
---|
| 393 | int refcount; |
---|
| 394 | owl_viewwin *vwin; |
---|
| 395 | int winactive; |
---|
| 396 | int pid; /* or 0 if it has terminated */ |
---|
| 397 | int rfd; |
---|
| 398 | } owl_popexec; |
---|
| 399 | |
---|
[7d4fbcd] | 400 | typedef struct _owl_messagelist { |
---|
| 401 | owl_list list; |
---|
| 402 | } owl_messagelist; |
---|
| 403 | |
---|
| 404 | typedef struct _owl_regex { |
---|
| 405 | int negate; |
---|
| 406 | char *string; |
---|
| 407 | regex_t re; |
---|
| 408 | } owl_regex; |
---|
| 409 | |
---|
| 410 | typedef struct _owl_filterelement { |
---|
[cb769bb] | 411 | int (*match_message)(struct _owl_filterelement *fe, owl_message *m); |
---|
| 412 | /* Append a string representation of the filterelement onto buf*/ |
---|
| 413 | void (*print_elt)(struct _owl_filterelement *fe, char * buf); |
---|
| 414 | /* Operands for and,or,not*/ |
---|
| 415 | struct _owl_filterelement *left, *right; |
---|
| 416 | /* For regex filters*/ |
---|
[7d4fbcd] | 417 | owl_regex re; |
---|
[cb769bb] | 418 | /* Used by regexes, filter references, and perl */ |
---|
| 419 | char *field; |
---|
[7d4fbcd] | 420 | } owl_filterelement; |
---|
| 421 | |
---|
| 422 | typedef struct _owl_filter { |
---|
| 423 | char *name; |
---|
| 424 | int polarity; |
---|
[cb769bb] | 425 | owl_filterelement * root; |
---|
[8fa9562] | 426 | int fgcolor; |
---|
| 427 | int bgcolor; |
---|
[59cf91c] | 428 | int cachedmsgid; /* cached msgid: should move into view eventually */ |
---|
[7d4fbcd] | 429 | } owl_filter; |
---|
| 430 | |
---|
| 431 | typedef struct _owl_view { |
---|
[c3ab155] | 432 | char *name; |
---|
[7d4fbcd] | 433 | owl_filter *filter; |
---|
| 434 | owl_messagelist ml; |
---|
[c3ab155] | 435 | owl_style *style; |
---|
[7d4fbcd] | 436 | } owl_view; |
---|
| 437 | |
---|
| 438 | typedef struct _owl_history { |
---|
| 439 | owl_list hist; |
---|
| 440 | int cur; |
---|
| 441 | int touched; |
---|
| 442 | int partial; |
---|
[12c35df] | 443 | int repeats; |
---|
[7d4fbcd] | 444 | } owl_history; |
---|
| 445 | |
---|
[10b866d] | 446 | typedef struct _owl_editwin { |
---|
| 447 | char *buff; |
---|
| 448 | owl_history *hist; |
---|
| 449 | int bufflen; |
---|
| 450 | int allocated; |
---|
| 451 | int buffx, buffy; |
---|
| 452 | int topline; |
---|
| 453 | int winlines, wincols, fillcol, wrapcol; |
---|
| 454 | WINDOW *curswin; |
---|
| 455 | int style; |
---|
| 456 | int lock; |
---|
| 457 | int dotsend; |
---|
[c9334b1] | 458 | int echochar; |
---|
[1b6b2f3] | 459 | |
---|
| 460 | char *command; |
---|
| 461 | void (*callback)(struct _owl_editwin*); |
---|
| 462 | void *cbdata; |
---|
[10b866d] | 463 | } owl_editwin; |
---|
| 464 | |
---|
[afbf668] | 465 | typedef struct _owl_mux { |
---|
| 466 | int handle; /* for referencing this */ |
---|
| 467 | int active; /* has this been deleted? */ |
---|
| 468 | int fd; |
---|
| 469 | int eventmask; /* bitmask of OWL_MUX_* */ |
---|
| 470 | void (*handler_fn)(int handle, int fd, int eventmask, void *data); |
---|
| 471 | void *data; /* data reference to pass to callback */ |
---|
| 472 | } owl_mux; |
---|
| 473 | typedef owl_list owl_muxevents; |
---|
| 474 | |
---|
[7d4fbcd] | 475 | typedef struct _owl_keybinding { |
---|
| 476 | int *j; /* keypress stack (0-terminated) */ |
---|
| 477 | int type; /* command or function? */ |
---|
| 478 | char *desc; /* description (or "*user*") */ |
---|
| 479 | char *command; /* command, if of type command */ |
---|
| 480 | void (*function_fn)(void); /* function ptr, if of type function */ |
---|
| 481 | } owl_keybinding; |
---|
| 482 | |
---|
| 483 | typedef struct _owl_keymap { |
---|
| 484 | char *name; /* name of keymap */ |
---|
| 485 | char *desc; /* description */ |
---|
| 486 | owl_list bindings; /* key bindings */ |
---|
| 487 | struct _owl_keymap *submap; /* submap */ |
---|
| 488 | void (*default_fn)(int j); /* default action (takes a keypress) */ |
---|
| 489 | void (*prealways_fn)(int j); /* always called before a keypress is received */ |
---|
| 490 | void (*postalways_fn)(int j); /* always called after keypress is processed */ |
---|
| 491 | } owl_keymap; |
---|
| 492 | |
---|
| 493 | typedef struct _owl_keyhandler { |
---|
| 494 | owl_dict keymaps; /* dictionary of keymaps */ |
---|
| 495 | owl_keymap *active; /* currently active keymap */ |
---|
| 496 | int in_esc; /* escape pressed? */ |
---|
| 497 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
---|
| 498 | int kpstackpos; /* location in stack (-1 = none) */ |
---|
| 499 | } owl_keyhandler; |
---|
| 500 | |
---|
[f4d0975] | 501 | typedef struct _owl_buddy { |
---|
| 502 | int proto; |
---|
| 503 | char *name; |
---|
| 504 | int isidle; |
---|
| 505 | int idlesince; |
---|
| 506 | } owl_buddy; |
---|
| 507 | |
---|
[aa5f725] | 508 | typedef struct _owl_buddylist { |
---|
| 509 | owl_list buddies; |
---|
| 510 | } owl_buddylist; |
---|
| 511 | |
---|
[5a95b69] | 512 | typedef struct _owl_zbuddylist { |
---|
| 513 | owl_list zusers; |
---|
| 514 | } owl_zbuddylist; |
---|
| 515 | |
---|
[6a415e9] | 516 | typedef struct _owl_timer { |
---|
| 517 | int direction; |
---|
| 518 | time_t starttime; |
---|
| 519 | int start; |
---|
| 520 | } owl_timer; |
---|
[aa5f725] | 521 | |
---|
[ec6ff52] | 522 | typedef struct _owl_errqueue { |
---|
| 523 | owl_list errlist; |
---|
| 524 | } owl_errqueue; |
---|
| 525 | |
---|
[8fa9562] | 526 | typedef struct _owl_colorpair_mgr { |
---|
[99c7549] | 527 | int next; |
---|
[c2c5c77] | 528 | short **pairs; |
---|
[8fa9562] | 529 | } owl_colorpair_mgr; |
---|
| 530 | |
---|
[124aebc] | 531 | typedef struct _owl_obarray { |
---|
| 532 | owl_list strings; |
---|
| 533 | } owl_obarray; |
---|
| 534 | |
---|
[7d4fbcd] | 535 | typedef struct _owl_global { |
---|
| 536 | owl_mainwin mw; |
---|
| 537 | owl_popwin pw; |
---|
[10b866d] | 538 | owl_history cmdhist; /* command history */ |
---|
| 539 | owl_history msghist; /* outgoing message history */ |
---|
[7d4fbcd] | 540 | owl_keyhandler kh; |
---|
| 541 | owl_list filterlist; |
---|
| 542 | owl_list puntlist; |
---|
[afbf668] | 543 | owl_muxevents muxevents; /* fds to dispatch on */ |
---|
[7d4fbcd] | 544 | owl_vardict vars; |
---|
| 545 | owl_cmddict cmds; |
---|
| 546 | owl_context ctx; |
---|
[ec6ff52] | 547 | owl_errqueue errqueue; |
---|
[7d4fbcd] | 548 | int lines, cols; |
---|
| 549 | int curmsg, topmsg; |
---|
| 550 | int curmsg_vert_offset; |
---|
| 551 | owl_view current_view; |
---|
| 552 | owl_messagelist msglist; |
---|
| 553 | WINDOW *recwin, *sepwin, *msgwin, *typwin; |
---|
| 554 | int needrefresh; |
---|
| 555 | int rightshift; |
---|
| 556 | int resizepending; |
---|
| 557 | int recwinlines; |
---|
| 558 | int typwinactive; |
---|
[a8938c7] | 559 | char *thishost; |
---|
| 560 | char *homedir; |
---|
[b363d83] | 561 | char *confdir; |
---|
| 562 | char *startupfile; |
---|
[7d4fbcd] | 563 | int direction; |
---|
| 564 | int zaway; |
---|
| 565 | char *cur_zaway_msg; |
---|
| 566 | int haveconfig; |
---|
| 567 | int config_format; |
---|
[1b6b2f3] | 568 | void *buffercbdata; |
---|
[7d4fbcd] | 569 | owl_editwin tw; |
---|
| 570 | owl_viewwin vw; |
---|
| 571 | void *perl; |
---|
| 572 | int debug; |
---|
[7f792c1] | 573 | time_t starttime; |
---|
| 574 | time_t lastinputtime; |
---|
[a8938c7] | 575 | char *startupargs; |
---|
[7d4fbcd] | 576 | int userclue; |
---|
| 577 | int nextmsgid; |
---|
| 578 | int hascolors; |
---|
| 579 | int colorpairs; |
---|
[8fa9562] | 580 | owl_colorpair_mgr cpmgr; |
---|
[1fd0b25] | 581 | int searchactive; |
---|
[700c712] | 582 | int newmsgproc_pid; |
---|
[8262340] | 583 | int malloced, freed; |
---|
[1fd0b25] | 584 | char *searchstring; |
---|
[d09e5a1] | 585 | aim_session_t aimsess; |
---|
[c15bbfb] | 586 | aim_conn_t bosconn; |
---|
[6a415e9] | 587 | owl_timer aim_noop_timer; |
---|
| 588 | owl_timer aim_ignorelogin_timer; |
---|
[de03334] | 589 | owl_timer aim_buddyinfo_timer; |
---|
[bd3f232] | 590 | int aim_loggedin; /* true if currently logged into AIM */ |
---|
[a352335c] | 591 | int aim_doprocessing; /* true if we should process AIM events (like pending login) */ |
---|
[bd3f232] | 592 | char *aim_screenname; /* currently logged in AIM screen name */ |
---|
| 593 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
---|
| 594 | owl_list messagequeue; /* for queueing up aim and other messages */ |
---|
[f1e629d] | 595 | owl_dict styledict; /* global dictionary of available styles */ |
---|
[cf83b7a] | 596 | char *response; /* response to the last question asked */ |
---|
[09489b89] | 597 | int havezephyr; |
---|
| 598 | int haveaim; |
---|
[c9e72d1] | 599 | int got_err_signal; /* 1 if we got an unexpected signal */ |
---|
[5a95b69] | 600 | siginfo_t err_signal_info; |
---|
| 601 | owl_zbuddylist zbuddies; |
---|
| 602 | owl_timer zephyr_buddycheck_timer; |
---|
[8232149] | 603 | struct termios startup_tio; |
---|
[8e401cae] | 604 | owl_obarray obarray; |
---|
[7d4fbcd] | 605 | } owl_global; |
---|
| 606 | |
---|
| 607 | /* globals */ |
---|
[b2b0773] | 608 | extern owl_global g; |
---|
[7d4fbcd] | 609 | |
---|
| 610 | #include "owl_prototypes.h" |
---|
| 611 | |
---|
| 612 | /* these are missing from the zephyr includes for some reason */ |
---|
[be0a79f] | 613 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 614 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
| 615 | int ZGetLocations(ZLocations_t *,int *); |
---|
[be0a79f] | 616 | #endif |
---|
[7d4fbcd] | 617 | |
---|
| 618 | #endif /* INC_OWL_H */ |
---|