[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 | |
---|
[6249a88f] | 12 | #include <config.h> |
---|
[691d012] | 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 |
---|
[67e5ba36] | 20 | #include <ncursesw/curses.h> |
---|
| 21 | #include <ncursesw/panel.h> |
---|
[1bdffcb] | 22 | #endif |
---|
[7d4fbcd] | 23 | #include <sys/param.h> |
---|
[f271129] | 24 | #include <sys/types.h> |
---|
| 25 | #include <ctype.h> |
---|
| 26 | #include <errno.h> |
---|
[7d4fbcd] | 27 | #include <EXTERN.h> |
---|
[f271129] | 28 | #include <fcntl.h> |
---|
[7d4fbcd] | 29 | #include <netdb.h> |
---|
| 30 | #include <regex.h> |
---|
[d09e5a1] | 31 | #include <time.h> |
---|
[c9e72d1] | 32 | #include <signal.h> |
---|
[f271129] | 33 | #include <stdlib.h> |
---|
| 34 | #include <string.h> |
---|
[8232149] | 35 | #include <termios.h> |
---|
[f271129] | 36 | #include <unistd.h> |
---|
[731dd1e] | 37 | #include "libfaim/aim.h" |
---|
[dd24b6a] | 38 | #include <wchar.h> |
---|
[f271129] | 39 | #include <glib.h> |
---|
[be0a79f] | 40 | #ifdef HAVE_LIBZEPHYR |
---|
[373b7e7] | 41 | #include <zephyr/zephyr.h> |
---|
[be0a79f] | 42 | #endif |
---|
[e6449bc] | 43 | #ifdef HAVE_COM_ERR_H |
---|
| 44 | #include <com_err.h> |
---|
| 45 | #endif |
---|
| 46 | |
---|
[6922edd] | 47 | /* Perl and curses don't play nice. */ |
---|
| 48 | #ifdef OWL_PERL |
---|
[c42a8d1] | 49 | typedef struct _owl_fake_WINDOW WINDOW; |
---|
| 50 | typedef struct _owl_fake_PANEL PANEL; |
---|
[18e28a4] | 51 | /* logout is defined in FreeBSD. */ |
---|
| 52 | #define logout logout_ |
---|
[88dc766] | 53 | #define HAS_BOOL |
---|
[6922edd] | 54 | #include <perl.h> |
---|
[120291c] | 55 | #include "owl_perl.h" |
---|
[18e28a4] | 56 | #undef logout |
---|
[6922edd] | 57 | #include "XSUB.h" |
---|
| 58 | #else |
---|
[c42a8d1] | 59 | typedef struct _owl_fake_SV SV; |
---|
| 60 | typedef struct _owl_fake_AV AV; |
---|
| 61 | typedef struct _owl_fake_HV HV; |
---|
[6922edd] | 62 | #endif |
---|
| 63 | |
---|
[e96b4ce] | 64 | #include "window.h" |
---|
| 65 | |
---|
[ca1fb26a] | 66 | extern const char *version; |
---|
[2a2bb60] | 67 | |
---|
| 68 | /* Feature that is being tested to redirect stderr through a pipe. |
---|
| 69 | * There may still be some portability problems with this. */ |
---|
| 70 | #define OWL_STDERR_REDIR 1 |
---|
[7d4fbcd] | 71 | |
---|
| 72 | #define OWL_DEBUG 0 |
---|
[26ad412] | 73 | #define OWL_DEBUG_FILE "/var/tmp/barnowl-debug" |
---|
[7d4fbcd] | 74 | |
---|
[bd3f232] | 75 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
[38cf544c] | 76 | |
---|
[7d4fbcd] | 77 | #define OWL_FMTEXT_ATTR_NONE 0 |
---|
| 78 | #define OWL_FMTEXT_ATTR_BOLD 1 |
---|
| 79 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
---|
| 80 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
---|
| 81 | |
---|
[9866c3a] | 82 | #define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/ |
---|
| 83 | #define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 ) |
---|
| 84 | #define OWL_FMTEXT_UC_ATTR_MASK 0x7 |
---|
| 85 | #define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 ) |
---|
| 86 | #define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE |
---|
| 87 | #define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 ) |
---|
| 88 | #define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100 |
---|
| 89 | #define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 90 | #define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 91 | #define OWL_FMTEXT_UC_COLOR_MASK 0xFF |
---|
| 92 | #define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200) |
---|
| 93 | #define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4' |
---|
| 94 | |
---|
[7d4fbcd] | 95 | #define OWL_COLOR_BLACK 0 |
---|
| 96 | #define OWL_COLOR_RED 1 |
---|
| 97 | #define OWL_COLOR_GREEN 2 |
---|
| 98 | #define OWL_COLOR_YELLOW 3 |
---|
| 99 | #define OWL_COLOR_BLUE 4 |
---|
| 100 | #define OWL_COLOR_MAGENTA 5 |
---|
| 101 | #define OWL_COLOR_CYAN 6 |
---|
| 102 | #define OWL_COLOR_WHITE 7 |
---|
[c2c5c77] | 103 | #define OWL_COLOR_DEFAULT -1 |
---|
[601733d] | 104 | #define OWL_COLOR_INVALID -2 |
---|
[7d4fbcd] | 105 | |
---|
[2b83ad6] | 106 | #define OWL_TAB_WIDTH 8 |
---|
| 107 | |
---|
[7d4fbcd] | 108 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
---|
| 109 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
---|
| 110 | |
---|
[f4d0975] | 111 | #define OWL_PROTOCOL_ZEPHYR 0 |
---|
| 112 | #define OWL_PROTOCOL_AIM 1 |
---|
| 113 | #define OWL_PROTOCOL_JABBER 2 |
---|
| 114 | #define OWL_PROTOCOL_ICQ 3 |
---|
| 115 | #define OWL_PROTOCOL_YAHOO 4 |
---|
| 116 | #define OWL_PROTOCOL_MSN 5 |
---|
| 117 | |
---|
[4b464a4] | 118 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
| 119 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
| 120 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
[7d4fbcd] | 121 | |
---|
| 122 | #define OWL_DIRECTION_NONE 0 |
---|
| 123 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
| 124 | #define OWL_DIRECTION_UPWARDS 2 |
---|
| 125 | |
---|
[12c35df] | 126 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
---|
| 127 | #define OWL_LOGGING_DIRECTION_IN 1 |
---|
| 128 | #define OWL_LOGGING_DIRECTION_OUT 2 |
---|
| 129 | |
---|
[88736cb] | 130 | #define OWL_SCROLLMODE_NORMAL 0 |
---|
| 131 | #define OWL_SCROLLMODE_TOP 1 |
---|
| 132 | #define OWL_SCROLLMODE_NEARTOP 2 |
---|
| 133 | #define OWL_SCROLLMODE_CENTER 3 |
---|
| 134 | #define OWL_SCROLLMODE_PAGED 4 |
---|
[aa2f33b3] | 135 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
| 136 | |
---|
[7d4fbcd] | 137 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
---|
| 138 | #define OWL_TABSTR " " |
---|
| 139 | #define OWL_MSGTAB 7 |
---|
| 140 | #define OWL_TYPWIN_SIZE 8 |
---|
| 141 | #define OWL_HISTORYSIZE 50 |
---|
| 142 | |
---|
| 143 | /* Indicate current state, as well as what is allowed */ |
---|
| 144 | #define OWL_CTX_ANY 0xffff |
---|
| 145 | /* Only one of these may be active at a time... */ |
---|
| 146 | #define OWL_CTX_MODE_BITS 0x000f |
---|
| 147 | #define OWL_CTX_STARTUP 0x0001 |
---|
| 148 | #define OWL_CTX_READCONFIG 0x0002 |
---|
| 149 | #define OWL_CTX_INTERACTIVE 0x0004 |
---|
| 150 | /* Only one of these may be active at a time... */ |
---|
| 151 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
---|
| 152 | #define OWL_CTX_POPWIN 0x00f0 |
---|
| 153 | #define OWL_CTX_POPLESS 0x0010 |
---|
| 154 | #define OWL_CTX_RECWIN 0x0f00 |
---|
| 155 | #define OWL_CTX_RECV 0x0100 |
---|
| 156 | #define OWL_CTX_TYPWIN 0xf000 |
---|
[cf83b7a] | 157 | #define OWL_CTX_EDIT 0x7000 |
---|
[7d4fbcd] | 158 | #define OWL_CTX_EDITLINE 0x1000 |
---|
| 159 | #define OWL_CTX_EDITMULTI 0x2000 |
---|
[cf83b7a] | 160 | #define OWL_CTX_EDITRESPONSE 0x4000 |
---|
[7d4fbcd] | 161 | |
---|
| 162 | #define OWL_VARIABLE_OTHER 0 |
---|
| 163 | #define OWL_VARIABLE_INT 1 |
---|
| 164 | #define OWL_VARIABLE_BOOL 2 |
---|
| 165 | #define OWL_VARIABLE_STRING 3 |
---|
| 166 | |
---|
[7ba9e0de] | 167 | #define OWL_OUTPUT_RETURN 0 |
---|
| 168 | #define OWL_OUTPUT_POPUP 1 |
---|
| 169 | #define OWL_OUTPUT_ADMINMSG 2 |
---|
| 170 | |
---|
[7d4fbcd] | 171 | #define OWL_FILTER_MAX_DEPTH 300 |
---|
| 172 | |
---|
[4b464a4] | 173 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
[7d4fbcd] | 174 | |
---|
[b13daa0] | 175 | #define OWL_KEYBINDING_NOOP 0 /* dummy binding that does nothing */ |
---|
[4b464a4] | 176 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
| 177 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
[7d4fbcd] | 178 | |
---|
[4b464a4] | 179 | #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] | 180 | #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] | 181 | |
---|
[1c7a4e0] | 182 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
[7d4fbcd] | 183 | |
---|
[1522e5d] | 184 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon/webzephyr.mit.edu" |
---|
[1d3e925] | 185 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
| 186 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
[e7cc1c3] | 187 | |
---|
[9d21120] | 188 | #define OWL_ZEPHYR_NOSTRIP_HOST "host/" |
---|
| 189 | #define OWL_ZEPHYR_NOSTRIP_RCMD "rcmd." |
---|
| 190 | #define OWL_ZEPHYR_NOSTRIP_DAEMON5 "daemon/" |
---|
| 191 | #define OWL_ZEPHYR_NOSTRIP_DAEMON4 "daemon." |
---|
| 192 | |
---|
[41f0cf3] | 193 | #define OWL_REGEX_QUOTECHARS "!+*.?[]^\\${}()|" |
---|
[bc08664] | 194 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
| 195 | |
---|
[0435c7d] | 196 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
[c86a35c] | 197 | #define OWL_ENABLE_ZCRYPT 1 |
---|
[c269e22] | 198 | #endif |
---|
| 199 | |
---|
[6829afc] | 200 | /* Annotate functions in which the caller owns the return value and is |
---|
| 201 | * responsible for ensuring it is freed. */ |
---|
| 202 | #define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT |
---|
| 203 | |
---|
[62fdd29] | 204 | #define OWL_META(key) ((key)|010000) |
---|
[f87c490] | 205 | /* OWL_CTRL is definied in kepress.c */ |
---|
[7d4fbcd] | 206 | |
---|
[712caac] | 207 | #ifdef HAVE_LIBZEPHYR |
---|
[6337cb5] | 208 | /* libzephyr doesn't use const, so we appease the type system with this kludge. |
---|
| 209 | * This just casts const char * to char * in a way that doesn't yield a warning |
---|
| 210 | * from gcc -Wcast-qual. */ |
---|
[712caac] | 211 | static inline char *zstr(const char *str) |
---|
| 212 | { |
---|
[6337cb5] | 213 | union { char *rw; const char *ro; } u; |
---|
| 214 | u.ro = str; |
---|
| 215 | return u.rw; |
---|
[712caac] | 216 | } |
---|
| 217 | #endif |
---|
| 218 | |
---|
[e19eb97] | 219 | /* Convert char *const * into const char *const *. This conversion is safe, |
---|
[c529ac8] | 220 | * and implicit in C++ (conv.qual 4) but for some reason not in C. */ |
---|
[e19eb97] | 221 | static inline const char *const *strs(char *const *pstr) |
---|
[c529ac8] | 222 | { |
---|
[e19eb97] | 223 | return (const char *const *)pstr; |
---|
[c529ac8] | 224 | } |
---|
| 225 | |
---|
[7d4fbcd] | 226 | typedef struct _owl_variable { |
---|
| 227 | char *name; |
---|
| 228 | int type; /* OWL_VARIABLE_* */ |
---|
[353719a] | 229 | char *default_str; /* the default value as a string */ |
---|
[5001a3d] | 230 | char *validsettings; /* documentation of valid settings */ |
---|
[06e04a9] | 231 | char *summary; /* summary of usage */ |
---|
| 232 | char *description; /* detailed description */ |
---|
[3b9ca71] | 233 | bool takes_on_off; /* allow passing on/off in argument-less set/unset */ |
---|
[353719a] | 234 | GClosure *set_fromstring_fn; |
---|
[06e04a9] | 235 | /* sets the variable to a value |
---|
[bbc31e4] | 236 | * of the appropriate type. |
---|
| 237 | * unless documented, this |
---|
| 238 | * should make a copy. |
---|
| 239 | * returns 0 on success. */ |
---|
[353719a] | 240 | GClosure *get_tostring_fn; |
---|
| 241 | /* converts val to a string; |
---|
[bbc31e4] | 242 | * caller must free the result */ |
---|
[353719a] | 243 | |
---|
| 244 | /* These are only valid for OWL_VARIABLE_{INT,BOOL,STRING} */ |
---|
[69f74c2] | 245 | GValue val; /* current value, if default get_fn/set_fn */ |
---|
| 246 | |
---|
[353719a] | 247 | GCallback get_fn; |
---|
[bbc31e4] | 248 | /* returns a reference to the current value. |
---|
| 249 | * WARNING: this approach is hard to make |
---|
| 250 | * thread-safe... */ |
---|
[353719a] | 251 | GCallback validate_fn; |
---|
| 252 | /* returns 1 if newval is valid */ |
---|
| 253 | GCallback set_fn; |
---|
[06e04a9] | 254 | /* sets the variable to a value |
---|
[bbc31e4] | 255 | * of the appropriate type. |
---|
| 256 | * unless documented, this |
---|
| 257 | * should make a copy. |
---|
| 258 | * returns 0 on success. */ |
---|
[06e04a9] | 259 | } owl_variable; |
---|
| 260 | |
---|
[7d4fbcd] | 261 | |
---|
[428834d] | 262 | typedef struct _owl_input { |
---|
| 263 | int ch; |
---|
| 264 | gunichar uch; |
---|
| 265 | } owl_input; |
---|
| 266 | |
---|
[7d4fbcd] | 267 | typedef struct _owl_fmtext { |
---|
[7e111f4] | 268 | GString *buff; |
---|
[7d4fbcd] | 269 | } owl_fmtext; |
---|
| 270 | |
---|
| 271 | typedef struct _owl_dict_el { |
---|
| 272 | char *k; /* key */ |
---|
| 273 | void *v; /* value */ |
---|
| 274 | } owl_dict_el; |
---|
| 275 | |
---|
| 276 | typedef struct _owl_dict { |
---|
| 277 | int size; |
---|
| 278 | int avail; |
---|
| 279 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
| 280 | } owl_dict; |
---|
| 281 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
| 282 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
| 283 | |
---|
| 284 | typedef struct _owl_context { |
---|
| 285 | int mode; |
---|
| 286 | void *data; /* determined by mode */ |
---|
[a999d9e] | 287 | char *keymap; |
---|
[07b59ea] | 288 | owl_window *cursor; |
---|
[1d74663] | 289 | void (*deactivate_cb)(struct _owl_context*); |
---|
| 290 | void (*delete_cb)(struct _owl_context*); |
---|
[fc5eef4] | 291 | void *cbdata; |
---|
[7d4fbcd] | 292 | } owl_context; |
---|
| 293 | |
---|
| 294 | typedef struct _owl_cmd { /* command */ |
---|
| 295 | char *name; |
---|
| 296 | |
---|
| 297 | char *summary; /* one line summary of command */ |
---|
| 298 | char *usage; /* usage synopsis */ |
---|
| 299 | char *description; /* long description of command */ |
---|
| 300 | |
---|
| 301 | int validctx; /* bitmask of valid contexts */ |
---|
| 302 | |
---|
| 303 | /* we should probably have a type here that says which of |
---|
| 304 | * the following is valid, and maybe make the below into a union... */ |
---|
| 305 | |
---|
| 306 | /* Only one of these may be non-NULL ... */ |
---|
| 307 | |
---|
| 308 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
| 309 | |
---|
| 310 | /* These don't take any context */ |
---|
[2560529] | 311 | CALLER_OWN char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); |
---|
[7d4fbcd] | 312 | /* takes argv and the full command as buff. |
---|
| 313 | * caller must free return value if !NULL */ |
---|
| 314 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
| 315 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
| 316 | |
---|
| 317 | /* The following also take the active context if it's valid */ |
---|
[2560529] | 318 | CALLER_OWN char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); |
---|
[7d4fbcd] | 319 | /* takes argv and the full command as buff. |
---|
| 320 | * caller must free return value if !NULL */ |
---|
| 321 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
| 322 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
[6922edd] | 323 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
[7d4fbcd] | 324 | } owl_cmd; |
---|
| 325 | |
---|
| 326 | |
---|
| 327 | typedef struct _owl_zwrite { |
---|
[987cf3f] | 328 | char *cmd; |
---|
[24ccc01] | 329 | char *zwriteline; |
---|
[ce7db4d] | 330 | char *class; |
---|
| 331 | char *inst; |
---|
| 332 | char *realm; |
---|
| 333 | char *opcode; |
---|
[56330ff] | 334 | char *zsig; |
---|
[ce7db4d] | 335 | char *message; |
---|
[12294d2] | 336 | GPtrArray *recips; |
---|
[7d4fbcd] | 337 | int cc; |
---|
| 338 | int noping; |
---|
| 339 | } owl_zwrite; |
---|
| 340 | |
---|
[d0d65df] | 341 | typedef struct _owl_pair { |
---|
[e19eb97] | 342 | const char *key; |
---|
[de1c8a5] | 343 | char *value; |
---|
[d0d65df] | 344 | } owl_pair; |
---|
| 345 | |
---|
[a387d12e] | 346 | struct _owl_fmtext_cache; |
---|
| 347 | |
---|
[7d4fbcd] | 348 | typedef struct _owl_message { |
---|
| 349 | int id; |
---|
[4b464a4] | 350 | int direction; |
---|
[be0a79f] | 351 | #ifdef HAVE_LIBZEPHYR |
---|
[b9517cf] | 352 | bool has_notice; |
---|
[7d4fbcd] | 353 | ZNotice_t notice; |
---|
[be0a79f] | 354 | #endif |
---|
[a387d12e] | 355 | struct _owl_fmtext_cache * fmtext; |
---|
[7d4fbcd] | 356 | int delete; |
---|
[e19eb97] | 357 | const char *hostname; |
---|
[f9df2f0] | 358 | GPtrArray *attributes; /* this is a list of pairs */ |
---|
[25dd31a] | 359 | char *timestr; |
---|
| 360 | time_t time; |
---|
[7d4fbcd] | 361 | } owl_message; |
---|
| 362 | |
---|
[a387d12e] | 363 | #define OWL_FMTEXT_CACHE_SIZE 1000 |
---|
| 364 | /* We cache the saved fmtexts for the last bunch of messages we |
---|
| 365 | rendered */ |
---|
| 366 | typedef struct _owl_fmtext_cache { |
---|
| 367 | owl_message * message; |
---|
| 368 | owl_fmtext fmtext; |
---|
| 369 | } owl_fmtext_cache; |
---|
| 370 | |
---|
[bd3f232] | 371 | typedef struct _owl_style { |
---|
| 372 | char *name; |
---|
[120291c] | 373 | SV *perlobj; |
---|
[bd3f232] | 374 | } owl_style; |
---|
| 375 | |
---|
[7d4fbcd] | 376 | typedef struct _owl_mainwin { |
---|
| 377 | int curtruncated; |
---|
[f2e36b5] | 378 | int lasttruncated; |
---|
[7d4fbcd] | 379 | int lastdisplayed; |
---|
[40d1eef] | 380 | owl_window *window; |
---|
[7d4fbcd] | 381 | } owl_mainwin; |
---|
| 382 | |
---|
[60c1386] | 383 | typedef struct _owl_editwin owl_editwin; |
---|
| 384 | typedef struct _owl_editwin_excursion owl_editwin_excursion; |
---|
| 385 | |
---|
[7d4fbcd] | 386 | typedef struct _owl_viewwin { |
---|
| 387 | owl_fmtext fmtext; |
---|
| 388 | int textlines; |
---|
| 389 | int topline; |
---|
| 390 | int rightshift; |
---|
[68f63a2] | 391 | owl_window *window; |
---|
[afbf668] | 392 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
| 393 | void *onclose_hook_data; |
---|
[60c1386] | 394 | |
---|
| 395 | gulong sig_resize_id; |
---|
| 396 | owl_window *content; |
---|
| 397 | gulong sig_content_redraw_id; |
---|
| 398 | owl_window *status; |
---|
| 399 | gulong sig_status_redraw_id; |
---|
[09ceee3] | 400 | owl_window *cmdwin; |
---|
[7d4fbcd] | 401 | } owl_viewwin; |
---|
| 402 | |
---|
| 403 | typedef struct _owl_popwin { |
---|
[68f63a2] | 404 | owl_window *border; |
---|
| 405 | owl_window *content; |
---|
[b3b1b05] | 406 | gulong sig_redraw_id; |
---|
| 407 | gulong sig_resize_id; |
---|
[7d4fbcd] | 408 | } owl_popwin; |
---|
[d70f45f] | 409 | |
---|
| 410 | typedef struct _owl_msgwin { |
---|
| 411 | char *msg; |
---|
| 412 | owl_window *window; |
---|
| 413 | gulong redraw_id; |
---|
| 414 | } owl_msgwin; |
---|
[7d4fbcd] | 415 | |
---|
| 416 | typedef struct _owl_messagelist { |
---|
[fc8a87a] | 417 | GPtrArray *list; |
---|
[7d4fbcd] | 418 | } owl_messagelist; |
---|
| 419 | |
---|
| 420 | typedef struct _owl_regex { |
---|
| 421 | int negate; |
---|
| 422 | char *string; |
---|
| 423 | regex_t re; |
---|
| 424 | } owl_regex; |
---|
| 425 | |
---|
| 426 | typedef struct _owl_filterelement { |
---|
[bd65108] | 427 | int (*match_message)(const struct _owl_filterelement *fe, const owl_message *m); |
---|
[cb769bb] | 428 | /* Append a string representation of the filterelement onto buf*/ |
---|
[bd65108] | 429 | void (*print_elt)(const struct _owl_filterelement *fe, GString *buf); |
---|
[cb769bb] | 430 | /* Operands for and,or,not*/ |
---|
| 431 | struct _owl_filterelement *left, *right; |
---|
| 432 | /* For regex filters*/ |
---|
[7d4fbcd] | 433 | owl_regex re; |
---|
[cb769bb] | 434 | /* Used by regexes, filter references, and perl */ |
---|
| 435 | char *field; |
---|
[7d4fbcd] | 436 | } owl_filterelement; |
---|
| 437 | |
---|
| 438 | typedef struct _owl_filter { |
---|
| 439 | char *name; |
---|
[cb769bb] | 440 | owl_filterelement * root; |
---|
[8fa9562] | 441 | int fgcolor; |
---|
| 442 | int bgcolor; |
---|
[7d4fbcd] | 443 | } owl_filter; |
---|
| 444 | |
---|
| 445 | typedef struct _owl_view { |
---|
[c3ab155] | 446 | char *name; |
---|
[7d4fbcd] | 447 | owl_filter *filter; |
---|
[219f52c] | 448 | owl_messagelist *ml; |
---|
[1fdab04] | 449 | const owl_style *style; |
---|
[c3a47c9] | 450 | int cachedmsgid; |
---|
[7d4fbcd] | 451 | } owl_view; |
---|
| 452 | |
---|
| 453 | typedef struct _owl_history { |
---|
[95b52d1] | 454 | GQueue hist; |
---|
| 455 | GList *cur; |
---|
[b470451] | 456 | bool partial; |
---|
[7d4fbcd] | 457 | } owl_history; |
---|
| 458 | |
---|
[d2a4534] | 459 | typedef struct _owl_mainpanel { |
---|
| 460 | owl_window *panel; |
---|
| 461 | owl_window *typwin; |
---|
| 462 | owl_window *sepwin; |
---|
| 463 | owl_window *msgwin; |
---|
| 464 | owl_window *recwin; |
---|
| 465 | int recwinlines; |
---|
| 466 | } owl_mainpanel; |
---|
| 467 | |
---|
[7d4fbcd] | 468 | typedef struct _owl_keybinding { |
---|
[e1b136bf] | 469 | int *keys; /* keypress stack */ |
---|
| 470 | int len; /* length of stack */ |
---|
[7d4fbcd] | 471 | int type; /* command or function? */ |
---|
| 472 | char *desc; /* description (or "*user*") */ |
---|
| 473 | char *command; /* command, if of type command */ |
---|
| 474 | void (*function_fn)(void); /* function ptr, if of type function */ |
---|
| 475 | } owl_keybinding; |
---|
| 476 | |
---|
| 477 | typedef struct _owl_keymap { |
---|
| 478 | char *name; /* name of keymap */ |
---|
| 479 | char *desc; /* description */ |
---|
[e4d7cb6] | 480 | GPtrArray *bindings; /* key bindings */ |
---|
[44cc9ab] | 481 | const struct _owl_keymap *parent; /* parent */ |
---|
[428834d] | 482 | void (*default_fn)(owl_input j); /* default action (takes a keypress) */ |
---|
| 483 | void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ |
---|
| 484 | void (*postalways_fn)(owl_input j); /* always called after keypress is processed */ |
---|
[7d4fbcd] | 485 | } owl_keymap; |
---|
| 486 | |
---|
| 487 | typedef struct _owl_keyhandler { |
---|
| 488 | owl_dict keymaps; /* dictionary of keymaps */ |
---|
[afa200a] | 489 | const owl_keymap *active; /* currently active keymap */ |
---|
[7d4fbcd] | 490 | int in_esc; /* escape pressed? */ |
---|
| 491 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
---|
| 492 | int kpstackpos; /* location in stack (-1 = none) */ |
---|
| 493 | } owl_keyhandler; |
---|
| 494 | |
---|
[f4d0975] | 495 | typedef struct _owl_buddy { |
---|
| 496 | int proto; |
---|
| 497 | char *name; |
---|
| 498 | int isidle; |
---|
| 499 | int idlesince; |
---|
| 500 | } owl_buddy; |
---|
| 501 | |
---|
[aa5f725] | 502 | typedef struct _owl_buddylist { |
---|
[d191f45] | 503 | GPtrArray *buddies; |
---|
[aa5f725] | 504 | } owl_buddylist; |
---|
| 505 | |
---|
[5a95b69] | 506 | typedef struct _owl_zbuddylist { |
---|
[7ed9bc6] | 507 | GPtrArray *zusers; |
---|
[5a95b69] | 508 | } owl_zbuddylist; |
---|
| 509 | |
---|
[ec6ff52] | 510 | typedef struct _owl_errqueue { |
---|
[eb897c6] | 511 | GPtrArray *errlist; |
---|
[ec6ff52] | 512 | } owl_errqueue; |
---|
| 513 | |
---|
[8fa9562] | 514 | typedef struct _owl_colorpair_mgr { |
---|
[99c7549] | 515 | int next; |
---|
[c2c5c77] | 516 | short **pairs; |
---|
[099597c] | 517 | bool overflow; |
---|
[8fa9562] | 518 | } owl_colorpair_mgr; |
---|
| 519 | |
---|
[40c6657] | 520 | typedef struct _owl_popexec { |
---|
| 521 | int refcount; |
---|
| 522 | owl_viewwin *vwin; |
---|
| 523 | int winactive; |
---|
[0e5afa2] | 524 | pid_t pid; /* or 0 if it has terminated */ |
---|
[a6a9ddb] | 525 | guint io_watch; |
---|
[40c6657] | 526 | } owl_popexec; |
---|
| 527 | |
---|
[7d4fbcd] | 528 | typedef struct _owl_global { |
---|
[ab88b05] | 529 | owl_mainwin *mw; |
---|
[03ca005] | 530 | owl_popwin *pw; |
---|
[d70f45f] | 531 | owl_msgwin msgwin; |
---|
[10b866d] | 532 | owl_history cmdhist; /* command history */ |
---|
| 533 | owl_history msghist; /* outgoing message history */ |
---|
[7d4fbcd] | 534 | owl_keyhandler kh; |
---|
[129e609] | 535 | owl_dict filters; |
---|
| 536 | GList *filterlist; |
---|
[e6d7e4e] | 537 | GPtrArray *puntlist; |
---|
[7d4fbcd] | 538 | owl_vardict vars; |
---|
| 539 | owl_cmddict cmds; |
---|
[a999d9e] | 540 | GList *context_stack; |
---|
[ec6ff52] | 541 | owl_errqueue errqueue; |
---|
[7d4fbcd] | 542 | int lines, cols; |
---|
[bd783db] | 543 | int curmsg, topmsg; |
---|
[70110286] | 544 | int markedmsgid; /* for finding the marked message when it has moved. */ |
---|
[7d4fbcd] | 545 | int curmsg_vert_offset; |
---|
| 546 | owl_view current_view; |
---|
[219f52c] | 547 | owl_messagelist *msglist; |
---|
[0881cdd] | 548 | WINDOW *input_pad; |
---|
[d2a4534] | 549 | owl_mainpanel mainpanel; |
---|
[f6fae8d] | 550 | gulong typwin_erase_id; |
---|
[7d4fbcd] | 551 | int rightshift; |
---|
[3535a6e] | 552 | bool resizepending; |
---|
[a8938c7] | 553 | char *homedir; |
---|
[b363d83] | 554 | char *confdir; |
---|
| 555 | char *startupfile; |
---|
[7d4fbcd] | 556 | int direction; |
---|
| 557 | int haveconfig; |
---|
| 558 | int config_format; |
---|
[a556caa] | 559 | owl_editwin *tw; |
---|
[9eb38bb] | 560 | owl_viewwin *vw; |
---|
[7d4fbcd] | 561 | void *perl; |
---|
| 562 | int debug; |
---|
[7f792c1] | 563 | time_t starttime; |
---|
| 564 | time_t lastinputtime; |
---|
[120dac7] | 565 | time_t last_wakeup_time; |
---|
[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; |
---|
[cb124fc6] | 593 | #if GLIB_CHECK_VERSION(2, 31, 0) |
---|
| 594 | GMutex interrupt_lock; |
---|
| 595 | #else |
---|
[47128d9] | 596 | GMutex *interrupt_lock; |
---|
[cb124fc6] | 597 | #endif |
---|
[7d4fbcd] | 598 | } owl_global; |
---|
| 599 | |
---|
| 600 | /* globals */ |
---|
[b2b0773] | 601 | extern owl_global g; |
---|
[7d4fbcd] | 602 | |
---|
[6249a88f] | 603 | #include <owl_prototypes.h> |
---|
[7d4fbcd] | 604 | |
---|
[d127638] | 605 | /* These were missing from the Zephyr includes before Zephyr 3. */ |
---|
| 606 | #if defined HAVE_LIBZEPHYR && defined ZCONST |
---|
[7d4fbcd] | 607 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
| 608 | int ZGetLocations(ZLocations_t *,int *); |
---|
[be0a79f] | 609 | #endif |
---|
[7d4fbcd] | 610 | |
---|
[06e04a9] | 611 | /* We have to dynamically bind these ourselves */ |
---|
| 612 | extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv); |
---|
| 613 | extern SV * (*sv_from_gvalue) (const GValue * value); |
---|
| 614 | extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap); |
---|
| 615 | |
---|
| 616 | |
---|
[06adc25] | 617 | #endif /* INC_BARNOWL_OWL_H */ |
---|