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