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