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