[b03c714] | 1 | /* Copyright (c) 2006-2011 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 | |
---|
[f8074e9] | 16 | #include <stdbool.h> |
---|
[75b0adb] | 17 | |
---|
[1bdffcb] | 18 | #ifndef OWL_PERL |
---|
[fe73d0c] | 19 | #define NCURSES_ENABLE_STDBOOL_H 1 |
---|
[1bdffcb] | 20 | #include <curses.h> |
---|
[be1ae91] | 21 | #include <panel.h> |
---|
[1bdffcb] | 22 | #endif |
---|
[7d4fbcd] | 23 | #include <sys/param.h> |
---|
| 24 | #include <EXTERN.h> |
---|
| 25 | #include <netdb.h> |
---|
| 26 | #include <regex.h> |
---|
[d09e5a1] | 27 | #include <time.h> |
---|
[c9e72d1] | 28 | #include <signal.h> |
---|
[8232149] | 29 | #include <termios.h> |
---|
[731dd1e] | 30 | #include "libfaim/aim.h" |
---|
[dd24b6a] | 31 | #include <wchar.h> |
---|
[34509d5] | 32 | #include "glib.h" |
---|
[be0a79f] | 33 | #ifdef HAVE_LIBZEPHYR |
---|
[373b7e7] | 34 | #include <zephyr/zephyr.h> |
---|
[be0a79f] | 35 | #endif |
---|
[e6449bc] | 36 | #ifdef HAVE_COM_ERR_H |
---|
| 37 | #include <com_err.h> |
---|
| 38 | #endif |
---|
| 39 | |
---|
[6922edd] | 40 | /* Perl and curses don't play nice. */ |
---|
| 41 | #ifdef OWL_PERL |
---|
| 42 | typedef void WINDOW; |
---|
[be1ae91] | 43 | typedef void PANEL; |
---|
[18e28a4] | 44 | /* logout is defined in FreeBSD. */ |
---|
| 45 | #define logout logout_ |
---|
[88dc766] | 46 | #define HAS_BOOL |
---|
[6922edd] | 47 | #include <perl.h> |
---|
[120291c] | 48 | #include "owl_perl.h" |
---|
[18e28a4] | 49 | #undef logout |
---|
[6922edd] | 50 | #include "XSUB.h" |
---|
| 51 | #else |
---|
| 52 | typedef void SV; |
---|
[68c572a] | 53 | typedef void AV; |
---|
| 54 | typedef void HV; |
---|
[6922edd] | 55 | #endif |
---|
| 56 | |
---|
[e96b4ce] | 57 | #include "window.h" |
---|
| 58 | |
---|
[ede073c] | 59 | #ifndef OWL_VERSION_STRING |
---|
[8df704f] | 60 | #ifdef GIT_VERSION |
---|
| 61 | #define stringify(x) __stringify(x) |
---|
| 62 | #define __stringify(x) #x |
---|
| 63 | #define OWL_VERSION_STRING stringify(GIT_VERSION) |
---|
| 64 | #else |
---|
[37f27bc] | 65 | #define OWL_VERSION_STRING PACKAGE_VERSION |
---|
[8df704f] | 66 | #endif |
---|
[ede073c] | 67 | #endif /* !OWL_VERSION_STRING */ |
---|
[2a2bb60] | 68 | |
---|
| 69 | /* Feature that is being tested to redirect stderr through a pipe. |
---|
| 70 | * There may still be some portability problems with this. */ |
---|
| 71 | #define OWL_STDERR_REDIR 1 |
---|
[7d4fbcd] | 72 | |
---|
| 73 | #define OWL_DEBUG 0 |
---|
[26ad412] | 74 | #define OWL_DEBUG_FILE "/var/tmp/barnowl-debug" |
---|
[7d4fbcd] | 75 | |
---|
[bd3f232] | 76 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
[38cf544c] | 77 | #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ |
---|
| 78 | |
---|
[7d4fbcd] | 79 | #define OWL_FMTEXT_ATTR_NONE 0 |
---|
| 80 | #define OWL_FMTEXT_ATTR_BOLD 1 |
---|
| 81 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
---|
| 82 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
---|
| 83 | |
---|
[9866c3a] | 84 | #define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/ |
---|
| 85 | #define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 ) |
---|
| 86 | #define OWL_FMTEXT_UC_ATTR_MASK 0x7 |
---|
| 87 | #define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 ) |
---|
| 88 | #define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE |
---|
| 89 | #define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 ) |
---|
| 90 | #define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100 |
---|
| 91 | #define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 92 | #define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 93 | #define OWL_FMTEXT_UC_COLOR_MASK 0xFF |
---|
| 94 | #define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200) |
---|
| 95 | #define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4' |
---|
| 96 | |
---|
[7d4fbcd] | 97 | #define OWL_COLOR_BLACK 0 |
---|
| 98 | #define OWL_COLOR_RED 1 |
---|
| 99 | #define OWL_COLOR_GREEN 2 |
---|
| 100 | #define OWL_COLOR_YELLOW 3 |
---|
| 101 | #define OWL_COLOR_BLUE 4 |
---|
| 102 | #define OWL_COLOR_MAGENTA 5 |
---|
| 103 | #define OWL_COLOR_CYAN 6 |
---|
| 104 | #define OWL_COLOR_WHITE 7 |
---|
[c2c5c77] | 105 | #define OWL_COLOR_DEFAULT -1 |
---|
[601733d] | 106 | #define OWL_COLOR_INVALID -2 |
---|
[7d4fbcd] | 107 | |
---|
[2b83ad6] | 108 | #define OWL_TAB_WIDTH 8 |
---|
| 109 | |
---|
[7d4fbcd] | 110 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
---|
| 111 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
---|
| 112 | |
---|
[f4d0975] | 113 | #define OWL_PROTOCOL_ZEPHYR 0 |
---|
| 114 | #define OWL_PROTOCOL_AIM 1 |
---|
| 115 | #define OWL_PROTOCOL_JABBER 2 |
---|
| 116 | #define OWL_PROTOCOL_ICQ 3 |
---|
| 117 | #define OWL_PROTOCOL_YAHOO 4 |
---|
| 118 | #define OWL_PROTOCOL_MSN 5 |
---|
| 119 | |
---|
[4b464a4] | 120 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
| 121 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
| 122 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
[7d4fbcd] | 123 | |
---|
| 124 | #define OWL_DIRECTION_NONE 0 |
---|
| 125 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
| 126 | #define OWL_DIRECTION_UPWARDS 2 |
---|
| 127 | |
---|
[12c35df] | 128 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
---|
| 129 | #define OWL_LOGGING_DIRECTION_IN 1 |
---|
| 130 | #define OWL_LOGGING_DIRECTION_OUT 2 |
---|
| 131 | |
---|
[88736cb] | 132 | #define OWL_SCROLLMODE_NORMAL 0 |
---|
| 133 | #define OWL_SCROLLMODE_TOP 1 |
---|
| 134 | #define OWL_SCROLLMODE_NEARTOP 2 |
---|
| 135 | #define OWL_SCROLLMODE_CENTER 3 |
---|
| 136 | #define OWL_SCROLLMODE_PAGED 4 |
---|
[aa2f33b3] | 137 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
| 138 | |
---|
[7d4fbcd] | 139 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
---|
| 140 | #define OWL_TABSTR " " |
---|
| 141 | #define OWL_MSGTAB 7 |
---|
| 142 | #define OWL_TYPWIN_SIZE 8 |
---|
| 143 | #define OWL_HISTORYSIZE 50 |
---|
| 144 | |
---|
| 145 | /* Indicate current state, as well as what is allowed */ |
---|
| 146 | #define OWL_CTX_ANY 0xffff |
---|
| 147 | /* Only one of these may be active at a time... */ |
---|
| 148 | #define OWL_CTX_MODE_BITS 0x000f |
---|
| 149 | #define OWL_CTX_STARTUP 0x0001 |
---|
| 150 | #define OWL_CTX_READCONFIG 0x0002 |
---|
| 151 | #define OWL_CTX_INTERACTIVE 0x0004 |
---|
| 152 | /* Only one of these may be active at a time... */ |
---|
| 153 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
---|
| 154 | #define OWL_CTX_POPWIN 0x00f0 |
---|
| 155 | #define OWL_CTX_POPLESS 0x0010 |
---|
| 156 | #define OWL_CTX_RECWIN 0x0f00 |
---|
| 157 | #define OWL_CTX_RECV 0x0100 |
---|
| 158 | #define OWL_CTX_TYPWIN 0xf000 |
---|
[cf83b7a] | 159 | #define OWL_CTX_EDIT 0x7000 |
---|
[7d4fbcd] | 160 | #define OWL_CTX_EDITLINE 0x1000 |
---|
| 161 | #define OWL_CTX_EDITMULTI 0x2000 |
---|
[cf83b7a] | 162 | #define OWL_CTX_EDITRESPONSE 0x4000 |
---|
[7d4fbcd] | 163 | |
---|
| 164 | #define OWL_VARIABLE_OTHER 0 |
---|
| 165 | #define OWL_VARIABLE_INT 1 |
---|
| 166 | #define OWL_VARIABLE_BOOL 2 |
---|
| 167 | #define OWL_VARIABLE_STRING 3 |
---|
| 168 | |
---|
[7ba9e0de] | 169 | #define OWL_OUTPUT_RETURN 0 |
---|
| 170 | #define OWL_OUTPUT_POPUP 1 |
---|
| 171 | #define OWL_OUTPUT_ADMINMSG 2 |
---|
| 172 | |
---|
[7d4fbcd] | 173 | #define OWL_FILTER_MAX_DEPTH 300 |
---|
| 174 | |
---|
[4b464a4] | 175 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
[7d4fbcd] | 176 | |
---|
[b13daa0] | 177 | #define OWL_KEYBINDING_NOOP 0 /* dummy binding that does nothing */ |
---|
[4b464a4] | 178 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
| 179 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
[7d4fbcd] | 180 | |
---|
[4b464a4] | 181 | #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] | 182 | #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] | 183 | |
---|
[1c7a4e0] | 184 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
[7d4fbcd] | 185 | |
---|
[1522e5d] | 186 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon/webzephyr.mit.edu" |
---|
[1d3e925] | 187 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
| 188 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
[e7cc1c3] | 189 | |
---|
[9d21120] | 190 | #define OWL_ZEPHYR_NOSTRIP_HOST "host/" |
---|
| 191 | #define OWL_ZEPHYR_NOSTRIP_RCMD "rcmd." |
---|
| 192 | #define OWL_ZEPHYR_NOSTRIP_DAEMON5 "daemon/" |
---|
| 193 | #define OWL_ZEPHYR_NOSTRIP_DAEMON4 "daemon." |
---|
| 194 | |
---|
[41f0cf3] | 195 | #define OWL_REGEX_QUOTECHARS "!+*.?[]^\\${}()|" |
---|
[bc08664] | 196 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
| 197 | |
---|
[0435c7d] | 198 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
[c86a35c] | 199 | #define OWL_ENABLE_ZCRYPT 1 |
---|
[c269e22] | 200 | #endif |
---|
| 201 | |
---|
[6829afc] | 202 | /* Annotate functions in which the caller owns the return value and is |
---|
| 203 | * responsible for ensuring it is freed. */ |
---|
| 204 | #define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT |
---|
| 205 | |
---|
[62fdd29] | 206 | #define OWL_META(key) ((key)|010000) |
---|
[f87c490] | 207 | /* OWL_CTRL is definied in kepress.c */ |
---|
[7d4fbcd] | 208 | |
---|
| 209 | #define LINE 2048 |
---|
| 210 | |
---|
[712caac] | 211 | #ifdef HAVE_LIBZEPHYR |
---|
[6337cb5] | 212 | /* libzephyr doesn't use const, so we appease the type system with this kludge. |
---|
| 213 | * This just casts const char * to char * in a way that doesn't yield a warning |
---|
| 214 | * from gcc -Wcast-qual. */ |
---|
[712caac] | 215 | static inline char *zstr(const char *str) |
---|
| 216 | { |
---|
[6337cb5] | 217 | union { char *rw; const char *ro; } u; |
---|
| 218 | u.ro = str; |
---|
| 219 | return u.rw; |
---|
[712caac] | 220 | } |
---|
| 221 | #endif |
---|
| 222 | |
---|
[e19eb97] | 223 | /* Convert char *const * into const char *const *. This conversion is safe, |
---|
[c529ac8] | 224 | * and implicit in C++ (conv.qual 4) but for some reason not in C. */ |
---|
[e19eb97] | 225 | static inline const char *const *strs(char *const *pstr) |
---|
[c529ac8] | 226 | { |
---|
[e19eb97] | 227 | return (const char *const *)pstr; |
---|
[c529ac8] | 228 | } |
---|
| 229 | |
---|
[7d4fbcd] | 230 | typedef struct _owl_variable { |
---|
| 231 | char *name; |
---|
| 232 | int type; /* OWL_VARIABLE_* */ |
---|
| 233 | void *pval_default; /* for types other and string */ |
---|
| 234 | int ival_default; /* for types int and bool */ |
---|
[24a791f] | 235 | const char *validsettings; /* documentation of valid settings */ |
---|
[aa2f33b3] | 236 | char *summary; /* summary of usage */ |
---|
| 237 | char *description; /* detailed description */ |
---|
[7d4fbcd] | 238 | void *val; /* current value */ |
---|
[64735f0] | 239 | int (*validate_fn)(const struct _owl_variable *v, const void *newval); |
---|
[7d4fbcd] | 240 | /* returns 1 if newval is valid */ |
---|
[e19eb97] | 241 | int (*set_fn)(struct _owl_variable *v, const void *newval); |
---|
[7d4fbcd] | 242 | /* sets the variable to a value |
---|
| 243 | * of the appropriate type. |
---|
| 244 | * unless documented, this |
---|
| 245 | * should make a copy. |
---|
| 246 | * returns 0 on success. */ |
---|
[e19eb97] | 247 | int (*set_fromstring_fn)(struct _owl_variable *v, const char *newval); |
---|
[7d4fbcd] | 248 | /* sets the variable to a value |
---|
| 249 | * of the appropriate type. |
---|
| 250 | * unless documented, this |
---|
| 251 | * should make a copy. |
---|
| 252 | * returns 0 on success. */ |
---|
[64735f0] | 253 | const void *(*get_fn)(const struct _owl_variable *v); |
---|
[7d4fbcd] | 254 | /* returns a reference to the current value. |
---|
| 255 | * WARNING: this approach is hard to make |
---|
| 256 | * thread-safe... */ |
---|
[2560529] | 257 | CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val); |
---|
[010a951] | 258 | /* converts val to a string; |
---|
| 259 | * caller must free the result */ |
---|
[bbd74a9] | 260 | void (*delete_fn)(struct _owl_variable *v); |
---|
[7d4fbcd] | 261 | /* frees val as needed */ |
---|
| 262 | } owl_variable; |
---|
| 263 | |
---|
[428834d] | 264 | typedef struct _owl_input { |
---|
| 265 | int ch; |
---|
| 266 | gunichar uch; |
---|
| 267 | } owl_input; |
---|
| 268 | |
---|
[7d4fbcd] | 269 | typedef struct _owl_fmtext { |
---|
[7e111f4] | 270 | GString *buff; |
---|
[7d4fbcd] | 271 | } owl_fmtext; |
---|
| 272 | |
---|
| 273 | typedef struct _owl_dict_el { |
---|
| 274 | char *k; /* key */ |
---|
| 275 | void *v; /* value */ |
---|
| 276 | } owl_dict_el; |
---|
| 277 | |
---|
| 278 | typedef struct _owl_dict { |
---|
| 279 | int size; |
---|
| 280 | int avail; |
---|
| 281 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
| 282 | } owl_dict; |
---|
| 283 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
| 284 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
| 285 | |
---|
| 286 | typedef struct _owl_context { |
---|
| 287 | int mode; |
---|
| 288 | void *data; /* determined by mode */ |
---|
[a999d9e] | 289 | char *keymap; |
---|
[07b59ea] | 290 | owl_window *cursor; |
---|
[1d74663] | 291 | void (*deactivate_cb)(struct _owl_context*); |
---|
| 292 | void (*delete_cb)(struct _owl_context*); |
---|
[fc5eef4] | 293 | void *cbdata; |
---|
[7d4fbcd] | 294 | } owl_context; |
---|
| 295 | |
---|
| 296 | typedef struct _owl_cmd { /* command */ |
---|
| 297 | char *name; |
---|
| 298 | |
---|
| 299 | char *summary; /* one line summary of command */ |
---|
| 300 | char *usage; /* usage synopsis */ |
---|
| 301 | char *description; /* long description of command */ |
---|
| 302 | |
---|
| 303 | int validctx; /* bitmask of valid contexts */ |
---|
| 304 | |
---|
| 305 | /* we should probably have a type here that says which of |
---|
| 306 | * the following is valid, and maybe make the below into a union... */ |
---|
| 307 | |
---|
| 308 | /* Only one of these may be non-NULL ... */ |
---|
| 309 | |
---|
| 310 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
| 311 | |
---|
| 312 | /* These don't take any context */ |
---|
[2560529] | 313 | CALLER_OWN char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); |
---|
[7d4fbcd] | 314 | /* takes argv and the full command as buff. |
---|
| 315 | * caller must free return value if !NULL */ |
---|
| 316 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
| 317 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
| 318 | |
---|
| 319 | /* The following also take the active context if it's valid */ |
---|
[2560529] | 320 | CALLER_OWN char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); |
---|
[7d4fbcd] | 321 | /* takes argv and the full command as buff. |
---|
| 322 | * caller must free return value if !NULL */ |
---|
| 323 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
| 324 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
[6922edd] | 325 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
[7d4fbcd] | 326 | } owl_cmd; |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | typedef struct _owl_zwrite { |
---|
[987cf3f] | 330 | char *cmd; |
---|
[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; |
---|
[12294d2] | 338 | GPtrArray *recips; |
---|
[7d4fbcd] | 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; |
---|
[f9df2f0] | 359 | GPtrArray *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; |
---|
[40d1eef] | 381 | owl_window *window; |
---|
[7d4fbcd] | 382 | } owl_mainwin; |
---|
| 383 | |
---|
[60c1386] | 384 | typedef struct _owl_editwin owl_editwin; |
---|
| 385 | typedef struct _owl_editwin_excursion owl_editwin_excursion; |
---|
| 386 | |
---|
[7d4fbcd] | 387 | typedef struct _owl_viewwin { |
---|
| 388 | owl_fmtext fmtext; |
---|
| 389 | int textlines; |
---|
| 390 | int topline; |
---|
| 391 | int rightshift; |
---|
[68f63a2] | 392 | owl_window *window; |
---|
[afbf668] | 393 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
| 394 | void *onclose_hook_data; |
---|
[60c1386] | 395 | |
---|
| 396 | gulong sig_resize_id; |
---|
| 397 | owl_window *content; |
---|
| 398 | gulong sig_content_redraw_id; |
---|
| 399 | owl_window *status; |
---|
| 400 | gulong sig_status_redraw_id; |
---|
[09ceee3] | 401 | owl_window *cmdwin; |
---|
[7d4fbcd] | 402 | } owl_viewwin; |
---|
| 403 | |
---|
| 404 | typedef struct _owl_popwin { |
---|
[68f63a2] | 405 | owl_window *border; |
---|
| 406 | owl_window *content; |
---|
[b3b1b05] | 407 | gulong sig_redraw_id; |
---|
| 408 | gulong sig_resize_id; |
---|
[7d4fbcd] | 409 | } owl_popwin; |
---|
[d70f45f] | 410 | |
---|
| 411 | typedef struct _owl_msgwin { |
---|
| 412 | char *msg; |
---|
| 413 | owl_window *window; |
---|
| 414 | gulong redraw_id; |
---|
| 415 | } owl_msgwin; |
---|
[7d4fbcd] | 416 | |
---|
| 417 | typedef struct _owl_messagelist { |
---|
[fc8a87a] | 418 | GPtrArray *list; |
---|
[7d4fbcd] | 419 | } owl_messagelist; |
---|
| 420 | |
---|
| 421 | typedef struct _owl_regex { |
---|
| 422 | int negate; |
---|
| 423 | char *string; |
---|
| 424 | regex_t re; |
---|
| 425 | } owl_regex; |
---|
| 426 | |
---|
| 427 | typedef struct _owl_filterelement { |
---|
[bd65108] | 428 | int (*match_message)(const struct _owl_filterelement *fe, const owl_message *m); |
---|
[cb769bb] | 429 | /* Append a string representation of the filterelement onto buf*/ |
---|
[bd65108] | 430 | void (*print_elt)(const struct _owl_filterelement *fe, GString *buf); |
---|
[cb769bb] | 431 | /* Operands for and,or,not*/ |
---|
| 432 | struct _owl_filterelement *left, *right; |
---|
| 433 | /* For regex filters*/ |
---|
[7d4fbcd] | 434 | owl_regex re; |
---|
[cb769bb] | 435 | /* Used by regexes, filter references, and perl */ |
---|
| 436 | char *field; |
---|
[7d4fbcd] | 437 | } owl_filterelement; |
---|
| 438 | |
---|
| 439 | typedef struct _owl_filter { |
---|
| 440 | char *name; |
---|
[cb769bb] | 441 | owl_filterelement * root; |
---|
[8fa9562] | 442 | int fgcolor; |
---|
| 443 | int bgcolor; |
---|
[7d4fbcd] | 444 | } owl_filter; |
---|
| 445 | |
---|
| 446 | typedef struct _owl_view { |
---|
[c3ab155] | 447 | char *name; |
---|
[7d4fbcd] | 448 | owl_filter *filter; |
---|
| 449 | owl_messagelist ml; |
---|
[1fdab04] | 450 | const owl_style *style; |
---|
[c3a47c9] | 451 | int cachedmsgid; |
---|
[7d4fbcd] | 452 | } owl_view; |
---|
| 453 | |
---|
| 454 | typedef struct _owl_history { |
---|
[95b52d1] | 455 | GQueue hist; |
---|
| 456 | GList *cur; |
---|
[b470451] | 457 | bool partial; |
---|
[7d4fbcd] | 458 | } owl_history; |
---|
| 459 | |
---|
[d2a4534] | 460 | typedef struct _owl_mainpanel { |
---|
| 461 | owl_window *panel; |
---|
| 462 | owl_window *typwin; |
---|
| 463 | owl_window *sepwin; |
---|
| 464 | owl_window *msgwin; |
---|
| 465 | owl_window *recwin; |
---|
| 466 | int recwinlines; |
---|
| 467 | } owl_mainpanel; |
---|
| 468 | |
---|
[7d4fbcd] | 469 | typedef struct _owl_keybinding { |
---|
[e1b136bf] | 470 | int *keys; /* keypress stack */ |
---|
| 471 | int len; /* length of stack */ |
---|
[7d4fbcd] | 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 */ |
---|
[e4d7cb6] | 481 | GPtrArray *bindings; /* key bindings */ |
---|
[44cc9ab] | 482 | const struct _owl_keymap *parent; /* parent */ |
---|
[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 */ |
---|
[afa200a] | 490 | const owl_keymap *active; /* currently active keymap */ |
---|
[7d4fbcd] | 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 { |
---|
[d191f45] | 504 | GPtrArray *buddies; |
---|
[aa5f725] | 505 | } owl_buddylist; |
---|
| 506 | |
---|
[5a95b69] | 507 | typedef struct _owl_zbuddylist { |
---|
[7ed9bc6] | 508 | GPtrArray *zusers; |
---|
[5a95b69] | 509 | } owl_zbuddylist; |
---|
| 510 | |
---|
[ec6ff52] | 511 | typedef struct _owl_errqueue { |
---|
[eb897c6] | 512 | GPtrArray *errlist; |
---|
[ec6ff52] | 513 | } owl_errqueue; |
---|
| 514 | |
---|
[8fa9562] | 515 | typedef struct _owl_colorpair_mgr { |
---|
[99c7549] | 516 | int next; |
---|
[c2c5c77] | 517 | short **pairs; |
---|
[099597c] | 518 | bool overflow; |
---|
[8fa9562] | 519 | } owl_colorpair_mgr; |
---|
| 520 | |
---|
[40c6657] | 521 | typedef struct _owl_popexec { |
---|
| 522 | int refcount; |
---|
| 523 | owl_viewwin *vwin; |
---|
| 524 | int winactive; |
---|
[0e5afa2] | 525 | pid_t pid; /* or 0 if it has terminated */ |
---|
[a6a9ddb] | 526 | guint io_watch; |
---|
[40c6657] | 527 | } owl_popexec; |
---|
| 528 | |
---|
[7d4fbcd] | 529 | typedef struct _owl_global { |
---|
| 530 | owl_mainwin mw; |
---|
[03ca005] | 531 | owl_popwin *pw; |
---|
[d70f45f] | 532 | owl_msgwin msgwin; |
---|
[10b866d] | 533 | owl_history cmdhist; /* command history */ |
---|
| 534 | owl_history msghist; /* outgoing message history */ |
---|
[7d4fbcd] | 535 | owl_keyhandler kh; |
---|
[129e609] | 536 | owl_dict filters; |
---|
| 537 | GList *filterlist; |
---|
[e6d7e4e] | 538 | GPtrArray *puntlist; |
---|
[7d4fbcd] | 539 | owl_vardict vars; |
---|
| 540 | owl_cmddict cmds; |
---|
[a999d9e] | 541 | GList *context_stack; |
---|
[ec6ff52] | 542 | owl_errqueue errqueue; |
---|
[7d4fbcd] | 543 | int lines, cols; |
---|
[bd783db] | 544 | int curmsg, topmsg; |
---|
[70110286] | 545 | int markedmsgid; /* for finding the marked message when it has moved. */ |
---|
[7d4fbcd] | 546 | int curmsg_vert_offset; |
---|
| 547 | owl_view current_view; |
---|
| 548 | owl_messagelist msglist; |
---|
[0881cdd] | 549 | WINDOW *input_pad; |
---|
[d2a4534] | 550 | owl_mainpanel mainpanel; |
---|
[f6fae8d] | 551 | gulong typwin_erase_id; |
---|
[7d4fbcd] | 552 | int rightshift; |
---|
[3535a6e] | 553 | bool resizepending; |
---|
[a8938c7] | 554 | char *homedir; |
---|
[b363d83] | 555 | char *confdir; |
---|
| 556 | char *startupfile; |
---|
[7d4fbcd] | 557 | int direction; |
---|
| 558 | int haveconfig; |
---|
| 559 | int config_format; |
---|
[a556caa] | 560 | owl_editwin *tw; |
---|
[9eb38bb] | 561 | owl_viewwin *vw; |
---|
[7d4fbcd] | 562 | void *perl; |
---|
| 563 | int debug; |
---|
[7f792c1] | 564 | time_t starttime; |
---|
| 565 | time_t lastinputtime; |
---|
[a8938c7] | 566 | char *startupargs; |
---|
[7d4fbcd] | 567 | int nextmsgid; |
---|
[8fa9562] | 568 | owl_colorpair_mgr cpmgr; |
---|
[0e5afa2] | 569 | pid_t newmsgproc_pid; |
---|
[41c9a96] | 570 | owl_regex search_re; |
---|
[d09e5a1] | 571 | aim_session_t aimsess; |
---|
[c15bbfb] | 572 | aim_conn_t bosconn; |
---|
[bd3f232] | 573 | int aim_loggedin; /* true if currently logged into AIM */ |
---|
[dc1edbd] | 574 | GSource *aim_event_source; /* where we get our AIM events from */ |
---|
[bd3f232] | 575 | char *aim_screenname; /* currently logged in AIM screen name */ |
---|
[81655f8] | 576 | char *aim_screenname_for_filters; /* currently logged in AIM screen name */ |
---|
[bd3f232] | 577 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
---|
[20aced3] | 578 | GQueue *messagequeue; /* for queueing up aim and other messages */ |
---|
[f1e629d] | 579 | owl_dict styledict; /* global dictionary of available styles */ |
---|
[cf83b7a] | 580 | char *response; /* response to the last question asked */ |
---|
[09489b89] | 581 | int havezephyr; |
---|
| 582 | int haveaim; |
---|
[b7bb454] | 583 | int ignoreaimlogin; |
---|
[5a95b69] | 584 | owl_zbuddylist zbuddies; |
---|
[f25812b] | 585 | GList *zaldlist; |
---|
| 586 | int pseudologin_notify; |
---|
[8232149] | 587 | struct termios startup_tio; |
---|
[6b0b4f4] | 588 | guint aim_nop_timer; |
---|
[52a0f14] | 589 | int load_initial_subs; |
---|
[d12a8c7] | 590 | FILE *debug_file; |
---|
[5f8ec6b] | 591 | char *kill_buffer; |
---|
[47128d9] | 592 | int interrupt_count; |
---|
| 593 | GMutex *interrupt_lock; |
---|
[7d4fbcd] | 594 | } owl_global; |
---|
| 595 | |
---|
| 596 | /* globals */ |
---|
[b2b0773] | 597 | extern owl_global g; |
---|
[7d4fbcd] | 598 | |
---|
| 599 | #include "owl_prototypes.h" |
---|
| 600 | |
---|
[d127638] | 601 | /* These were missing from the Zephyr includes before Zephyr 3. */ |
---|
| 602 | #if defined HAVE_LIBZEPHYR && defined ZCONST |
---|
[7d4fbcd] | 603 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
| 604 | int ZGetLocations(ZLocations_t *,int *); |
---|
[be0a79f] | 605 | #endif |
---|
[7d4fbcd] | 606 | |
---|
[06adc25] | 607 | #endif /* INC_BARNOWL_OWL_H */ |
---|