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