[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 | |
---|
[f8074e9] | 12 | #include <stdbool.h> |
---|
[1bdffcb] | 13 | #ifndef OWL_PERL |
---|
| 14 | #include <curses.h> |
---|
[be1ae91] | 15 | #include <panel.h> |
---|
[1bdffcb] | 16 | #endif |
---|
[7d4fbcd] | 17 | #include <sys/param.h> |
---|
| 18 | #include <EXTERN.h> |
---|
| 19 | #include <netdb.h> |
---|
| 20 | #include <regex.h> |
---|
[d09e5a1] | 21 | #include <time.h> |
---|
[c9e72d1] | 22 | #include <signal.h> |
---|
[8232149] | 23 | #include <termios.h> |
---|
[731dd1e] | 24 | #include "libfaim/aim.h" |
---|
[dd24b6a] | 25 | #include <wchar.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; |
---|
[be1ae91] | 38 | typedef void PANEL; |
---|
[18e28a4] | 39 | /* logout is defined in FreeBSD. */ |
---|
| 40 | #define logout logout_ |
---|
[88dc766] | 41 | #define HAS_BOOL |
---|
[6922edd] | 42 | #include <perl.h> |
---|
[120291c] | 43 | #include "owl_perl.h" |
---|
[18e28a4] | 44 | #undef logout |
---|
[6922edd] | 45 | #include "XSUB.h" |
---|
| 46 | #else |
---|
| 47 | typedef void SV; |
---|
[68c572a] | 48 | typedef void AV; |
---|
| 49 | typedef void HV; |
---|
[6922edd] | 50 | #endif |
---|
| 51 | |
---|
[8df704f] | 52 | #ifdef GIT_VERSION |
---|
| 53 | #define stringify(x) __stringify(x) |
---|
| 54 | #define __stringify(x) #x |
---|
| 55 | #define OWL_VERSION_STRING stringify(GIT_VERSION) |
---|
| 56 | #else |
---|
[37f27bc] | 57 | #define OWL_VERSION_STRING PACKAGE_VERSION |
---|
[8df704f] | 58 | #endif |
---|
[2a2bb60] | 59 | |
---|
| 60 | /* Feature that is being tested to redirect stderr through a pipe. |
---|
| 61 | * There may still be some portability problems with this. */ |
---|
| 62 | #define OWL_STDERR_REDIR 1 |
---|
[7d4fbcd] | 63 | |
---|
| 64 | #define OWL_DEBUG 0 |
---|
| 65 | #define OWL_DEBUG_FILE "/var/tmp/owldebug" |
---|
| 66 | |
---|
[bd3f232] | 67 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
[38cf544c] | 68 | #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ |
---|
| 69 | |
---|
[7d4fbcd] | 70 | #define OWL_FMTEXT_ATTR_NONE 0 |
---|
| 71 | #define OWL_FMTEXT_ATTR_BOLD 1 |
---|
| 72 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
---|
| 73 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
---|
| 74 | |
---|
[9866c3a] | 75 | #define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/ |
---|
| 76 | #define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 ) |
---|
| 77 | #define OWL_FMTEXT_UC_ATTR_MASK 0x7 |
---|
| 78 | #define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 ) |
---|
| 79 | #define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE |
---|
| 80 | #define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 ) |
---|
| 81 | #define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100 |
---|
| 82 | #define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 83 | #define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 84 | #define OWL_FMTEXT_UC_COLOR_MASK 0xFF |
---|
| 85 | #define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200) |
---|
| 86 | #define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4' |
---|
| 87 | |
---|
| 88 | #define OWL_FMTEXT_UTF8_ATTR_NONE "\xf4\x80\xa0\x80" |
---|
| 89 | #define OWL_FMTEXT_UTF8_FGDEFAULT "\xf4\x80\x94\x80" |
---|
[6f6330b] | 90 | #define OWL_FMTEXT_UTF8_BGDEFAULT "\xf4\x80\x9C\x80" |
---|
[9866c3a] | 91 | |
---|
[7d4fbcd] | 92 | #define OWL_COLOR_BLACK 0 |
---|
| 93 | #define OWL_COLOR_RED 1 |
---|
| 94 | #define OWL_COLOR_GREEN 2 |
---|
| 95 | #define OWL_COLOR_YELLOW 3 |
---|
| 96 | #define OWL_COLOR_BLUE 4 |
---|
| 97 | #define OWL_COLOR_MAGENTA 5 |
---|
| 98 | #define OWL_COLOR_CYAN 6 |
---|
| 99 | #define OWL_COLOR_WHITE 7 |
---|
[c2c5c77] | 100 | #define OWL_COLOR_DEFAULT -1 |
---|
[601733d] | 101 | #define OWL_COLOR_INVALID -2 |
---|
[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 | |
---|
[df0138f] | 117 | #define OWL_IO_READ 1 |
---|
| 118 | #define OWL_IO_WRITE 2 |
---|
| 119 | #define OWL_IO_EXCEPT 4 |
---|
[afbf668] | 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 | |
---|
[1c7a4e0] | 186 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
[7d4fbcd] | 187 | |
---|
[e7cc1c3] | 188 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr" |
---|
[1d3e925] | 189 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
| 190 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
[e7cc1c3] | 191 | |
---|
[80e54a7] | 192 | #define OWL_REGEX_QUOTECHARS "+*.?[]^\\${}()" |
---|
[bc08664] | 193 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
| 194 | |
---|
[0435c7d] | 195 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
[c86a35c] | 196 | #define OWL_ENABLE_ZCRYPT 1 |
---|
[c269e22] | 197 | #endif |
---|
| 198 | |
---|
[62fdd29] | 199 | #define OWL_META(key) ((key)|010000) |
---|
[f87c490] | 200 | /* OWL_CTRL is definied in kepress.c */ |
---|
[7d4fbcd] | 201 | |
---|
| 202 | #define LINE 2048 |
---|
| 203 | |
---|
[712caac] | 204 | #ifdef HAVE_LIBZEPHYR |
---|
[6337cb5] | 205 | /* libzephyr doesn't use const, so we appease the type system with this kludge. |
---|
| 206 | * This just casts const char * to char * in a way that doesn't yield a warning |
---|
| 207 | * from gcc -Wcast-qual. */ |
---|
[712caac] | 208 | static inline char *zstr(const char *str) |
---|
| 209 | { |
---|
[6337cb5] | 210 | union { char *rw; const char *ro; } u; |
---|
| 211 | u.ro = str; |
---|
| 212 | return u.rw; |
---|
[712caac] | 213 | } |
---|
| 214 | #endif |
---|
| 215 | |
---|
[e19eb97] | 216 | /* Convert char *const * into const char *const *. This conversion is safe, |
---|
[c529ac8] | 217 | * and implicit in C++ (conv.qual 4) but for some reason not in C. */ |
---|
[e19eb97] | 218 | static inline const char *const *strs(char *const *pstr) |
---|
[c529ac8] | 219 | { |
---|
[e19eb97] | 220 | return (const char *const *)pstr; |
---|
[c529ac8] | 221 | } |
---|
| 222 | |
---|
[7d4fbcd] | 223 | typedef struct _owl_variable { |
---|
| 224 | char *name; |
---|
| 225 | int type; /* OWL_VARIABLE_* */ |
---|
| 226 | void *pval_default; /* for types other and string */ |
---|
| 227 | int ival_default; /* for types int and bool */ |
---|
| 228 | char *validsettings; /* documentation of valid settings */ |
---|
[aa2f33b3] | 229 | char *summary; /* summary of usage */ |
---|
| 230 | char *description; /* detailed description */ |
---|
[7d4fbcd] | 231 | void *val; /* current value */ |
---|
[64735f0] | 232 | int (*validate_fn)(const struct _owl_variable *v, const void *newval); |
---|
[7d4fbcd] | 233 | /* returns 1 if newval is valid */ |
---|
[e19eb97] | 234 | int (*set_fn)(struct _owl_variable *v, const void *newval); |
---|
[7d4fbcd] | 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. */ |
---|
[e19eb97] | 240 | int (*set_fromstring_fn)(struct _owl_variable *v, const char *newval); |
---|
[7d4fbcd] | 241 | /* sets the variable to a value |
---|
| 242 | * of the appropriate type. |
---|
| 243 | * unless documented, this |
---|
| 244 | * should make a copy. |
---|
| 245 | * returns 0 on success. */ |
---|
[64735f0] | 246 | const void *(*get_fn)(const struct _owl_variable *v); |
---|
[7d4fbcd] | 247 | /* returns a reference to the current value. |
---|
| 248 | * WARNING: this approach is hard to make |
---|
| 249 | * thread-safe... */ |
---|
[64735f0] | 250 | int (*get_tostring_fn)(const struct _owl_variable *v, |
---|
[e19eb97] | 251 | char *buf, int bufsize, const void *val); |
---|
[7d4fbcd] | 252 | /* converts val to a string |
---|
| 253 | * and puts into buf */ |
---|
[bbd74a9] | 254 | void (*delete_fn)(struct _owl_variable *v); |
---|
[7d4fbcd] | 255 | /* frees val as needed */ |
---|
| 256 | } owl_variable; |
---|
| 257 | |
---|
[428834d] | 258 | typedef struct _owl_input { |
---|
| 259 | int ch; |
---|
| 260 | gunichar uch; |
---|
| 261 | } owl_input; |
---|
| 262 | |
---|
[7d4fbcd] | 263 | typedef struct _owl_fmtext { |
---|
| 264 | int textlen; |
---|
[a387d12e] | 265 | int bufflen; |
---|
[7d4fbcd] | 266 | char *textbuff; |
---|
[9866c3a] | 267 | char default_attrs; |
---|
| 268 | short default_fgcolor; |
---|
| 269 | short default_bgcolor; |
---|
[7d4fbcd] | 270 | } owl_fmtext; |
---|
| 271 | |
---|
| 272 | typedef struct _owl_list { |
---|
| 273 | int size; |
---|
| 274 | int avail; |
---|
| 275 | void **list; |
---|
| 276 | } owl_list; |
---|
| 277 | |
---|
| 278 | typedef struct _owl_dict_el { |
---|
| 279 | char *k; /* key */ |
---|
| 280 | void *v; /* value */ |
---|
| 281 | } owl_dict_el; |
---|
| 282 | |
---|
| 283 | typedef struct _owl_dict { |
---|
| 284 | int size; |
---|
| 285 | int avail; |
---|
| 286 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
| 287 | } owl_dict; |
---|
| 288 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
| 289 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
| 290 | |
---|
| 291 | typedef struct _owl_context { |
---|
| 292 | int mode; |
---|
| 293 | void *data; /* determined by mode */ |
---|
[a999d9e] | 294 | char *keymap; |
---|
[7d4fbcd] | 295 | } owl_context; |
---|
| 296 | |
---|
| 297 | typedef struct _owl_cmd { /* command */ |
---|
| 298 | char *name; |
---|
| 299 | |
---|
| 300 | char *summary; /* one line summary of command */ |
---|
| 301 | char *usage; /* usage synopsis */ |
---|
| 302 | char *description; /* long description of command */ |
---|
| 303 | |
---|
| 304 | int validctx; /* bitmask of valid contexts */ |
---|
| 305 | |
---|
| 306 | /* we should probably have a type here that says which of |
---|
| 307 | * the following is valid, and maybe make the below into a union... */ |
---|
| 308 | |
---|
| 309 | /* Only one of these may be non-NULL ... */ |
---|
| 310 | |
---|
| 311 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
| 312 | |
---|
| 313 | /* These don't take any context */ |
---|
[e19eb97] | 314 | char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); |
---|
[7d4fbcd] | 315 | /* takes argv and the full command as buff. |
---|
| 316 | * caller must free return value if !NULL */ |
---|
| 317 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
| 318 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
| 319 | |
---|
| 320 | /* The following also take the active context if it's valid */ |
---|
[e19eb97] | 321 | char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); |
---|
[7d4fbcd] | 322 | /* takes argv and the full command as buff. |
---|
| 323 | * caller must free return value if !NULL */ |
---|
| 324 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
| 325 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
[6922edd] | 326 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
[7d4fbcd] | 327 | } owl_cmd; |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | typedef struct _owl_zwrite { |
---|
[24ccc01] | 331 | char *zwriteline; |
---|
[ce7db4d] | 332 | char *class; |
---|
| 333 | char *inst; |
---|
| 334 | char *realm; |
---|
| 335 | char *opcode; |
---|
[56330ff] | 336 | char *zsig; |
---|
[ce7db4d] | 337 | char *message; |
---|
[7d4fbcd] | 338 | owl_list recips; |
---|
| 339 | int cc; |
---|
| 340 | int noping; |
---|
| 341 | } owl_zwrite; |
---|
| 342 | |
---|
[d0d65df] | 343 | typedef struct _owl_pair { |
---|
[e19eb97] | 344 | const char *key; |
---|
[de1c8a5] | 345 | char *value; |
---|
[d0d65df] | 346 | } owl_pair; |
---|
| 347 | |
---|
[a387d12e] | 348 | struct _owl_fmtext_cache; |
---|
| 349 | |
---|
[7d4fbcd] | 350 | typedef struct _owl_message { |
---|
| 351 | int id; |
---|
[4b464a4] | 352 | int direction; |
---|
[be0a79f] | 353 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 354 | ZNotice_t notice; |
---|
[be0a79f] | 355 | #endif |
---|
[a387d12e] | 356 | struct _owl_fmtext_cache * fmtext; |
---|
[7d4fbcd] | 357 | int delete; |
---|
[e19eb97] | 358 | const char *hostname; |
---|
[65ad073] | 359 | owl_list attributes; /* this is a list of pairs */ |
---|
[25dd31a] | 360 | char *timestr; |
---|
| 361 | time_t time; |
---|
[7d4fbcd] | 362 | } owl_message; |
---|
| 363 | |
---|
[a387d12e] | 364 | #define OWL_FMTEXT_CACHE_SIZE 1000 |
---|
| 365 | /* We cache the saved fmtexts for the last bunch of messages we |
---|
| 366 | rendered */ |
---|
| 367 | typedef struct _owl_fmtext_cache { |
---|
| 368 | owl_message * message; |
---|
| 369 | owl_fmtext fmtext; |
---|
| 370 | } owl_fmtext_cache; |
---|
| 371 | |
---|
[bd3f232] | 372 | typedef struct _owl_style { |
---|
| 373 | char *name; |
---|
[120291c] | 374 | SV *perlobj; |
---|
[bd3f232] | 375 | } owl_style; |
---|
| 376 | |
---|
[7d4fbcd] | 377 | typedef struct _owl_mainwin { |
---|
| 378 | int curtruncated; |
---|
[f2e36b5] | 379 | int lasttruncated; |
---|
[7d4fbcd] | 380 | int lastdisplayed; |
---|
| 381 | } owl_mainwin; |
---|
| 382 | |
---|
| 383 | typedef struct _owl_viewwin { |
---|
| 384 | owl_fmtext fmtext; |
---|
| 385 | int textlines; |
---|
| 386 | int topline; |
---|
| 387 | int rightshift; |
---|
| 388 | int winlines, wincols; |
---|
| 389 | WINDOW *curswin; |
---|
[afbf668] | 390 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
| 391 | void *onclose_hook_data; |
---|
[7d4fbcd] | 392 | } owl_viewwin; |
---|
| 393 | |
---|
| 394 | typedef struct _owl_popwin { |
---|
[8ae2de9] | 395 | PANEL *borderpanel; |
---|
| 396 | PANEL *poppanel; |
---|
[7d4fbcd] | 397 | int lines; |
---|
| 398 | int cols; |
---|
| 399 | int active; |
---|
| 400 | } owl_popwin; |
---|
| 401 | |
---|
| 402 | typedef struct _owl_messagelist { |
---|
| 403 | owl_list list; |
---|
| 404 | } owl_messagelist; |
---|
| 405 | |
---|
| 406 | typedef struct _owl_regex { |
---|
| 407 | int negate; |
---|
| 408 | char *string; |
---|
| 409 | regex_t re; |
---|
| 410 | } owl_regex; |
---|
| 411 | |
---|
| 412 | typedef struct _owl_filterelement { |
---|
[bd65108] | 413 | int (*match_message)(const struct _owl_filterelement *fe, const owl_message *m); |
---|
[cb769bb] | 414 | /* Append a string representation of the filterelement onto buf*/ |
---|
[bd65108] | 415 | void (*print_elt)(const struct _owl_filterelement *fe, GString *buf); |
---|
[cb769bb] | 416 | /* Operands for and,or,not*/ |
---|
| 417 | struct _owl_filterelement *left, *right; |
---|
| 418 | /* For regex filters*/ |
---|
[7d4fbcd] | 419 | owl_regex re; |
---|
[cb769bb] | 420 | /* Used by regexes, filter references, and perl */ |
---|
| 421 | char *field; |
---|
[7d4fbcd] | 422 | } owl_filterelement; |
---|
| 423 | |
---|
| 424 | typedef struct _owl_filter { |
---|
| 425 | char *name; |
---|
[cb769bb] | 426 | owl_filterelement * root; |
---|
[8fa9562] | 427 | int fgcolor; |
---|
| 428 | int bgcolor; |
---|
[7d4fbcd] | 429 | } owl_filter; |
---|
| 430 | |
---|
| 431 | typedef struct _owl_view { |
---|
[c3ab155] | 432 | char *name; |
---|
[7d4fbcd] | 433 | owl_filter *filter; |
---|
| 434 | owl_messagelist ml; |
---|
[1fdab04] | 435 | const owl_style *style; |
---|
[c3a47c9] | 436 | int cachedmsgid; |
---|
[7d4fbcd] | 437 | } owl_view; |
---|
| 438 | |
---|
| 439 | typedef struct _owl_history { |
---|
| 440 | owl_list hist; |
---|
| 441 | int cur; |
---|
| 442 | int touched; |
---|
| 443 | int partial; |
---|
[12c35df] | 444 | int repeats; |
---|
[7d4fbcd] | 445 | } owl_history; |
---|
| 446 | |
---|
[a556caa] | 447 | typedef struct _owl_editwin owl_editwin; |
---|
[a88f35a] | 448 | typedef struct _owl_editwin_excursion owl_editwin_excursion; |
---|
[10b866d] | 449 | |
---|
[7d4fbcd] | 450 | typedef struct _owl_keybinding { |
---|
[e1b136bf] | 451 | int *keys; /* keypress stack */ |
---|
| 452 | int len; /* length of stack */ |
---|
[7d4fbcd] | 453 | int type; /* command or function? */ |
---|
| 454 | char *desc; /* description (or "*user*") */ |
---|
| 455 | char *command; /* command, if of type command */ |
---|
| 456 | void (*function_fn)(void); /* function ptr, if of type function */ |
---|
| 457 | } owl_keybinding; |
---|
| 458 | |
---|
| 459 | typedef struct _owl_keymap { |
---|
| 460 | char *name; /* name of keymap */ |
---|
| 461 | char *desc; /* description */ |
---|
| 462 | owl_list bindings; /* key bindings */ |
---|
[afa200a] | 463 | const struct _owl_keymap *submap; /* submap */ |
---|
[428834d] | 464 | void (*default_fn)(owl_input j); /* default action (takes a keypress) */ |
---|
| 465 | void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ |
---|
| 466 | void (*postalways_fn)(owl_input j); /* always called after keypress is processed */ |
---|
[7d4fbcd] | 467 | } owl_keymap; |
---|
| 468 | |
---|
| 469 | typedef struct _owl_keyhandler { |
---|
| 470 | owl_dict keymaps; /* dictionary of keymaps */ |
---|
[afa200a] | 471 | const owl_keymap *active; /* currently active keymap */ |
---|
[7d4fbcd] | 472 | int in_esc; /* escape pressed? */ |
---|
| 473 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
---|
| 474 | int kpstackpos; /* location in stack (-1 = none) */ |
---|
| 475 | } owl_keyhandler; |
---|
| 476 | |
---|
[f4d0975] | 477 | typedef struct _owl_buddy { |
---|
| 478 | int proto; |
---|
| 479 | char *name; |
---|
| 480 | int isidle; |
---|
| 481 | int idlesince; |
---|
| 482 | } owl_buddy; |
---|
| 483 | |
---|
[aa5f725] | 484 | typedef struct _owl_buddylist { |
---|
| 485 | owl_list buddies; |
---|
| 486 | } owl_buddylist; |
---|
| 487 | |
---|
[5a95b69] | 488 | typedef struct _owl_zbuddylist { |
---|
| 489 | owl_list zusers; |
---|
| 490 | } owl_zbuddylist; |
---|
| 491 | |
---|
[6a415e9] | 492 | typedef struct _owl_timer { |
---|
[b7bb454] | 493 | time_t time; |
---|
| 494 | int interval; |
---|
| 495 | void (*callback)(struct _owl_timer *, void *); |
---|
[c675b39] | 496 | void (*destroy)(struct _owl_timer *); |
---|
[b7bb454] | 497 | void *data; |
---|
[6a415e9] | 498 | } owl_timer; |
---|
[aa5f725] | 499 | |
---|
[ec6ff52] | 500 | typedef struct _owl_errqueue { |
---|
| 501 | owl_list errlist; |
---|
| 502 | } owl_errqueue; |
---|
| 503 | |
---|
[8fa9562] | 504 | typedef struct _owl_colorpair_mgr { |
---|
[99c7549] | 505 | int next; |
---|
[c2c5c77] | 506 | short **pairs; |
---|
[8fa9562] | 507 | } owl_colorpair_mgr; |
---|
| 508 | |
---|
[124aebc] | 509 | typedef struct _owl_obarray { |
---|
| 510 | owl_list strings; |
---|
| 511 | } owl_obarray; |
---|
| 512 | |
---|
[df0138f] | 513 | typedef struct _owl_io_dispatch { |
---|
| 514 | int fd; /* FD to watch for dispatch. */ |
---|
| 515 | int mode; |
---|
[1895c29] | 516 | int needs_gc; |
---|
[df0138f] | 517 | void (*callback)(const struct _owl_io_dispatch *, void *); /* C function to dispatch to. */ |
---|
| 518 | void (*destroy)(const struct _owl_io_dispatch *); /* Destructor */ |
---|
[f36cd97] | 519 | void *data; |
---|
[df0138f] | 520 | } owl_io_dispatch; |
---|
[9c7a701] | 521 | |
---|
[4f2166b] | 522 | typedef struct _owl_ps_action { |
---|
| 523 | int needs_gc; |
---|
| 524 | int (*callback)(struct _owl_ps_action *, void *); |
---|
| 525 | void (*destroy)(struct _owl_ps_action *); |
---|
| 526 | void *data; |
---|
| 527 | } owl_ps_action; |
---|
| 528 | |
---|
[40c6657] | 529 | typedef struct _owl_popexec { |
---|
| 530 | int refcount; |
---|
| 531 | owl_viewwin *vwin; |
---|
| 532 | int winactive; |
---|
[0e5afa2] | 533 | pid_t pid; /* or 0 if it has terminated */ |
---|
[18fdd5f9] | 534 | const owl_io_dispatch *dispatch; |
---|
[40c6657] | 535 | } owl_popexec; |
---|
| 536 | |
---|
[7d4fbcd] | 537 | typedef struct _owl_global { |
---|
| 538 | owl_mainwin mw; |
---|
| 539 | owl_popwin pw; |
---|
[10b866d] | 540 | owl_history cmdhist; /* command history */ |
---|
| 541 | owl_history msghist; /* outgoing message history */ |
---|
[7d4fbcd] | 542 | owl_keyhandler kh; |
---|
[129e609] | 543 | owl_dict filters; |
---|
| 544 | GList *filterlist; |
---|
[7d4fbcd] | 545 | owl_list puntlist; |
---|
| 546 | owl_vardict vars; |
---|
| 547 | owl_cmddict cmds; |
---|
[a999d9e] | 548 | GList *context_stack; |
---|
[ec6ff52] | 549 | owl_errqueue errqueue; |
---|
[7d4fbcd] | 550 | int lines, cols; |
---|
[bd783db] | 551 | int curmsg, topmsg; |
---|
[70110286] | 552 | int markedmsgid; /* for finding the marked message when it has moved. */ |
---|
[7d4fbcd] | 553 | int curmsg_vert_offset; |
---|
| 554 | owl_view current_view; |
---|
| 555 | owl_messagelist msglist; |
---|
[8ae2de9] | 556 | PANEL *recpan, *seppan, *msgpan, *typpan; |
---|
[7d4fbcd] | 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; |
---|
[a556caa] | 572 | owl_editwin *tw; |
---|
[7d4fbcd] | 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; |
---|
[0e5afa2] | 584 | pid_t newmsgproc_pid; |
---|
[8262340] | 585 | int malloced, freed; |
---|
[41c9a96] | 586 | owl_regex search_re; |
---|
[d09e5a1] | 587 | aim_session_t aimsess; |
---|
[c15bbfb] | 588 | aim_conn_t bosconn; |
---|
[6a415e9] | 589 | owl_timer aim_noop_timer; |
---|
| 590 | owl_timer aim_ignorelogin_timer; |
---|
[bd3f232] | 591 | int aim_loggedin; /* true if currently logged into AIM */ |
---|
[a352335c] | 592 | int aim_doprocessing; /* true if we should process AIM events (like pending login) */ |
---|
[bd3f232] | 593 | char *aim_screenname; /* currently logged in AIM screen name */ |
---|
[81655f8] | 594 | char *aim_screenname_for_filters; /* currently logged in AIM screen name */ |
---|
[bd3f232] | 595 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
---|
| 596 | owl_list messagequeue; /* for queueing up aim and other messages */ |
---|
[f1e629d] | 597 | owl_dict styledict; /* global dictionary of available styles */ |
---|
[cf83b7a] | 598 | char *response; /* response to the last question asked */ |
---|
[09489b89] | 599 | int havezephyr; |
---|
| 600 | int haveaim; |
---|
[b7bb454] | 601 | int ignoreaimlogin; |
---|
[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; |
---|
[f25812b] | 606 | GList *zaldlist; |
---|
| 607 | int pseudologin_notify; |
---|
[8232149] | 608 | struct termios startup_tio; |
---|
[8e401cae] | 609 | owl_obarray obarray; |
---|
[df0138f] | 610 | owl_list io_dispatch_list; |
---|
[4f2166b] | 611 | owl_list psa_list; |
---|
[58d1f8a] | 612 | GList *timerlist; |
---|
[b7bb454] | 613 | owl_timer *aim_nop_timer; |
---|
[52a0f14] | 614 | int load_initial_subs; |
---|
[adee9cc] | 615 | int interrupted; |
---|
[7d4fbcd] | 616 | } owl_global; |
---|
| 617 | |
---|
| 618 | /* globals */ |
---|
[b2b0773] | 619 | extern owl_global g; |
---|
[7d4fbcd] | 620 | |
---|
| 621 | #include "owl_prototypes.h" |
---|
| 622 | |
---|
| 623 | /* these are missing from the zephyr includes for some reason */ |
---|
[be0a79f] | 624 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 625 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
| 626 | int ZGetLocations(ZLocations_t *,int *); |
---|
[be0a79f] | 627 | #endif |
---|
[7d4fbcd] | 628 | |
---|
| 629 | #endif /* INC_OWL_H */ |
---|