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