[5ca5f8e] | 1 | /* Copyright (c) 2004 James Kretchmar. All rights reserved. |
---|
| 2 | * |
---|
| 3 | * Redistribution and use in source and binary forms, with or without |
---|
| 4 | * modification, are permitted provided that the following conditions are |
---|
| 5 | * met: |
---|
| 6 | * |
---|
| 7 | * * Redistributions of source code must retain the above copyright |
---|
| 8 | * notice, this list of conditions and the following disclaimer. |
---|
| 9 | * |
---|
| 10 | * * Redistributions in binary form must reproduce the above copyright |
---|
| 11 | * notice, this list of conditions and the following disclaimer in |
---|
| 12 | * the documentation and/or other materials provided with the |
---|
| 13 | * distribution. |
---|
| 14 | * |
---|
| 15 | * * Redistributions in any form must be accompanied by information on |
---|
| 16 | * how to obtain complete source code for the Owl software and any |
---|
| 17 | * accompanying software that uses the Owl software. The source code |
---|
| 18 | * must either be included in the distribution or be available for no |
---|
| 19 | * more than the cost of distribution plus a nominal fee, and must be |
---|
| 20 | * freely redistributable under reasonable conditions. For an |
---|
| 21 | * executable file, complete source code means the source code for |
---|
| 22 | * all modules it contains. It does not include source code for |
---|
| 23 | * modules or files that typically accompany the major components of |
---|
| 24 | * the operating system on which the executable file runs. |
---|
| 25 | * |
---|
| 26 | * |
---|
| 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
---|
| 28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
---|
| 29 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
---|
| 30 | * NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE |
---|
| 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
---|
| 34 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
| 35 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
---|
| 36 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
---|
| 37 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 38 | */ |
---|
| 39 | |
---|
[7d4fbcd] | 40 | #ifndef INC_OWL_H |
---|
| 41 | #define INC_OWL_H |
---|
| 42 | |
---|
[1bdffcb] | 43 | #ifndef OWL_PERL |
---|
| 44 | #include <curses.h> |
---|
| 45 | #endif |
---|
[7d4fbcd] | 46 | #include <sys/param.h> |
---|
| 47 | #include <EXTERN.h> |
---|
| 48 | #include <netdb.h> |
---|
| 49 | #include <regex.h> |
---|
[d09e5a1] | 50 | #include <time.h> |
---|
[c9e72d1] | 51 | #include <signal.h> |
---|
[8232149] | 52 | #include <termios.h> |
---|
[d09e5a1] | 53 | #include <libfaim/aim.h> |
---|
[dd24b6a] | 54 | #include <wchar.h> |
---|
[7d4fbcd] | 55 | #include "config.h" |
---|
[34509d5] | 56 | #include "glib.h" |
---|
[be0a79f] | 57 | #ifdef HAVE_LIBZEPHYR |
---|
[373b7e7] | 58 | #include <zephyr/zephyr.h> |
---|
[be0a79f] | 59 | #endif |
---|
[e6449bc] | 60 | #ifdef HAVE_COM_ERR_H |
---|
| 61 | #include <com_err.h> |
---|
| 62 | #endif |
---|
| 63 | |
---|
[6922edd] | 64 | /* Perl and curses don't play nice. */ |
---|
| 65 | #ifdef OWL_PERL |
---|
| 66 | typedef void WINDOW; |
---|
[18e28a4] | 67 | /* logout is defined in FreeBSD. */ |
---|
| 68 | #define logout logout_ |
---|
[88dc766] | 69 | /* aim.h defines bool */ |
---|
| 70 | #define HAS_BOOL |
---|
[6922edd] | 71 | #include <perl.h> |
---|
[18e28a4] | 72 | #undef logout |
---|
[6922edd] | 73 | #include "XSUB.h" |
---|
| 74 | #else |
---|
| 75 | typedef void SV; |
---|
| 76 | #endif |
---|
| 77 | |
---|
[1aee7d9] | 78 | static const char owl_h_fileIdent[] = "$Id$"; |
---|
| 79 | |
---|
[88dc766] | 80 | #define BARNOWL_STRINGIFY(x) _STRINGIFY(x) |
---|
[d08162a] | 81 | #define _STRINGIFY(x) #x |
---|
| 82 | |
---|
| 83 | #ifndef OWL_SVN_REVNO |
---|
| 84 | #define OWL_SVN_REVNO ???? |
---|
| 85 | #endif |
---|
| 86 | |
---|
[88dc766] | 87 | #define OWL_VERSION_STRING "r" BARNOWL_STRINGIFY(OWL_SVN_REVNO) |
---|
[d08162a] | 88 | |
---|
[2a2bb60] | 89 | |
---|
| 90 | /* Feature that is being tested to redirect stderr through a pipe. |
---|
| 91 | * There may still be some portability problems with this. */ |
---|
| 92 | #define OWL_STDERR_REDIR 1 |
---|
[7d4fbcd] | 93 | |
---|
| 94 | #define OWL_DEBUG 0 |
---|
| 95 | #define OWL_DEBUG_FILE "/var/tmp/owldebug" |
---|
| 96 | |
---|
[bd3f232] | 97 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
[38cf544c] | 98 | #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ |
---|
| 99 | |
---|
[7d4fbcd] | 100 | #define OWL_FMTEXT_ATTR_NONE 0 |
---|
| 101 | #define OWL_FMTEXT_ATTR_BOLD 1 |
---|
| 102 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
---|
| 103 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
---|
| 104 | |
---|
[9866c3a] | 105 | #define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/ |
---|
| 106 | #define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 ) |
---|
| 107 | #define OWL_FMTEXT_UC_ATTR_MASK 0x7 |
---|
| 108 | #define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 ) |
---|
| 109 | #define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE |
---|
| 110 | #define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 ) |
---|
| 111 | #define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100 |
---|
| 112 | #define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 113 | #define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
| 114 | #define OWL_FMTEXT_UC_COLOR_MASK 0xFF |
---|
| 115 | #define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200) |
---|
| 116 | #define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4' |
---|
| 117 | |
---|
| 118 | #define OWL_FMTEXT_UTF8_ATTR_NONE "\xf4\x80\xa0\x80" |
---|
| 119 | #define OWL_FMTEXT_UTF8_FGDEFAULT "\xf4\x80\x94\x80" |
---|
[6f6330b] | 120 | #define OWL_FMTEXT_UTF8_BGDEFAULT "\xf4\x80\x9C\x80" |
---|
[9866c3a] | 121 | |
---|
[7d4fbcd] | 122 | #define OWL_COLOR_BLACK 0 |
---|
| 123 | #define OWL_COLOR_RED 1 |
---|
| 124 | #define OWL_COLOR_GREEN 2 |
---|
| 125 | #define OWL_COLOR_YELLOW 3 |
---|
| 126 | #define OWL_COLOR_BLUE 4 |
---|
| 127 | #define OWL_COLOR_MAGENTA 5 |
---|
| 128 | #define OWL_COLOR_CYAN 6 |
---|
| 129 | #define OWL_COLOR_WHITE 7 |
---|
[c2c5c77] | 130 | #define OWL_COLOR_DEFAULT -1 |
---|
[7d4fbcd] | 131 | |
---|
| 132 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
---|
| 133 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
---|
| 134 | |
---|
[f4d0975] | 135 | #define OWL_PROTOCOL_ZEPHYR 0 |
---|
| 136 | #define OWL_PROTOCOL_AIM 1 |
---|
| 137 | #define OWL_PROTOCOL_JABBER 2 |
---|
| 138 | #define OWL_PROTOCOL_ICQ 3 |
---|
| 139 | #define OWL_PROTOCOL_YAHOO 4 |
---|
| 140 | #define OWL_PROTOCOL_MSN 5 |
---|
| 141 | |
---|
[4b464a4] | 142 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
| 143 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
| 144 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
[7d4fbcd] | 145 | |
---|
[afbf668] | 146 | #define OWL_MUX_READ 1 |
---|
| 147 | #define OWL_MUX_WRITE 2 |
---|
| 148 | #define OWL_MUX_EXCEPT 4 |
---|
| 149 | |
---|
[7d4fbcd] | 150 | #define OWL_DIRECTION_NONE 0 |
---|
| 151 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
| 152 | #define OWL_DIRECTION_UPWARDS 2 |
---|
| 153 | |
---|
[12c35df] | 154 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
---|
| 155 | #define OWL_LOGGING_DIRECTION_IN 1 |
---|
| 156 | #define OWL_LOGGING_DIRECTION_OUT 2 |
---|
| 157 | |
---|
[88736cb] | 158 | #define OWL_SCROLLMODE_NORMAL 0 |
---|
| 159 | #define OWL_SCROLLMODE_TOP 1 |
---|
| 160 | #define OWL_SCROLLMODE_NEARTOP 2 |
---|
| 161 | #define OWL_SCROLLMODE_CENTER 3 |
---|
| 162 | #define OWL_SCROLLMODE_PAGED 4 |
---|
[aa2f33b3] | 163 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
| 164 | |
---|
[bd3f232] | 165 | #define OWL_STYLE_TYPE_INTERNAL 0 |
---|
| 166 | #define OWL_STYLE_TYPE_PERL 1 |
---|
| 167 | |
---|
[7d4fbcd] | 168 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
---|
| 169 | #define OWL_TABSTR " " |
---|
| 170 | #define OWL_MSGTAB 7 |
---|
| 171 | #define OWL_TYPWIN_SIZE 8 |
---|
| 172 | #define OWL_HISTORYSIZE 50 |
---|
| 173 | |
---|
| 174 | /* Indicate current state, as well as what is allowed */ |
---|
| 175 | #define OWL_CTX_ANY 0xffff |
---|
| 176 | /* Only one of these may be active at a time... */ |
---|
| 177 | #define OWL_CTX_MODE_BITS 0x000f |
---|
| 178 | #define OWL_CTX_STARTUP 0x0001 |
---|
| 179 | #define OWL_CTX_READCONFIG 0x0002 |
---|
| 180 | #define OWL_CTX_INTERACTIVE 0x0004 |
---|
| 181 | /* Only one of these may be active at a time... */ |
---|
| 182 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
---|
| 183 | #define OWL_CTX_POPWIN 0x00f0 |
---|
| 184 | #define OWL_CTX_POPLESS 0x0010 |
---|
| 185 | #define OWL_CTX_RECWIN 0x0f00 |
---|
| 186 | #define OWL_CTX_RECV 0x0100 |
---|
| 187 | #define OWL_CTX_TYPWIN 0xf000 |
---|
[cf83b7a] | 188 | #define OWL_CTX_EDIT 0x7000 |
---|
[7d4fbcd] | 189 | #define OWL_CTX_EDITLINE 0x1000 |
---|
| 190 | #define OWL_CTX_EDITMULTI 0x2000 |
---|
[cf83b7a] | 191 | #define OWL_CTX_EDITRESPONSE 0x4000 |
---|
[7d4fbcd] | 192 | |
---|
| 193 | #define OWL_USERCLUE_NONE 0 |
---|
| 194 | #define OWL_USERCLUE_CLASSES 1 |
---|
| 195 | #define OWL_USERCLUE_FOOBAR 2 |
---|
| 196 | #define OWL_USERCLUE_BAZ 4 |
---|
| 197 | |
---|
| 198 | #define OWL_WEBBROWSER_NONE 0 |
---|
| 199 | #define OWL_WEBBROWSER_NETSCAPE 1 |
---|
| 200 | #define OWL_WEBBROWSER_GALEON 2 |
---|
[ae9e6be] | 201 | #define OWL_WEBBROWSER_OPERA 3 |
---|
[7d4fbcd] | 202 | |
---|
| 203 | #define OWL_VARIABLE_OTHER 0 |
---|
| 204 | #define OWL_VARIABLE_INT 1 |
---|
| 205 | #define OWL_VARIABLE_BOOL 2 |
---|
| 206 | #define OWL_VARIABLE_STRING 3 |
---|
| 207 | |
---|
| 208 | #define OWL_FILTER_MAX_DEPTH 300 |
---|
| 209 | |
---|
[4b464a4] | 210 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
[7d4fbcd] | 211 | |
---|
[4b464a4] | 212 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
| 213 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
[7d4fbcd] | 214 | |
---|
[4b464a4] | 215 | #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] | 216 | #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] | 217 | |
---|
[4b464a4] | 218 | #define OWL_INCLUDE_REG_TESTS 1 /* whether to build in regression tests */ |
---|
[7d4fbcd] | 219 | |
---|
[1c7a4e0] | 220 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
[7d4fbcd] | 221 | |
---|
[e7cc1c3] | 222 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr" |
---|
[1d3e925] | 223 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
| 224 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
[e7cc1c3] | 225 | |
---|
[80e54a7] | 226 | #define OWL_REGEX_QUOTECHARS "+*.?[]^\\${}()" |
---|
[bc08664] | 227 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
| 228 | |
---|
[0435c7d] | 229 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
[c86a35c] | 230 | #define OWL_ENABLE_ZCRYPT 1 |
---|
[c269e22] | 231 | #endif |
---|
| 232 | |
---|
[62fdd29] | 233 | #define OWL_META(key) ((key)|010000) |
---|
[f87c490] | 234 | /* OWL_CTRL is definied in kepress.c */ |
---|
[7d4fbcd] | 235 | |
---|
| 236 | #define LINE 2048 |
---|
| 237 | |
---|
| 238 | typedef struct _owl_variable { |
---|
| 239 | char *name; |
---|
| 240 | int type; /* OWL_VARIABLE_* */ |
---|
| 241 | void *pval_default; /* for types other and string */ |
---|
| 242 | int ival_default; /* for types int and bool */ |
---|
| 243 | char *validsettings; /* documentation of valid settings */ |
---|
[aa2f33b3] | 244 | char *summary; /* summary of usage */ |
---|
| 245 | char *description; /* detailed description */ |
---|
[7d4fbcd] | 246 | void *val; /* current value */ |
---|
| 247 | int (*validate_fn)(struct _owl_variable *v, void *newval); |
---|
| 248 | /* returns 1 if newval is valid */ |
---|
| 249 | int (*set_fn)(struct _owl_variable *v, void *newval); |
---|
| 250 | /* sets the variable to a value |
---|
| 251 | * of the appropriate type. |
---|
| 252 | * unless documented, this |
---|
| 253 | * should make a copy. |
---|
| 254 | * returns 0 on success. */ |
---|
| 255 | int (*set_fromstring_fn)(struct _owl_variable *v, char *newval); |
---|
| 256 | /* sets the variable to a value |
---|
| 257 | * of the appropriate type. |
---|
| 258 | * unless documented, this |
---|
| 259 | * should make a copy. |
---|
| 260 | * returns 0 on success. */ |
---|
| 261 | void *(*get_fn)(struct _owl_variable *v); |
---|
| 262 | /* returns a reference to the current value. |
---|
| 263 | * WARNING: this approach is hard to make |
---|
| 264 | * thread-safe... */ |
---|
| 265 | int (*get_tostring_fn)(struct _owl_variable *v, |
---|
| 266 | char *buf, int bufsize, void *val); |
---|
| 267 | /* converts val to a string |
---|
| 268 | * and puts into buf */ |
---|
| 269 | void (*free_fn)(struct _owl_variable *v); |
---|
| 270 | /* frees val as needed */ |
---|
| 271 | } owl_variable; |
---|
| 272 | |
---|
[428834d] | 273 | typedef struct _owl_input { |
---|
| 274 | int ch; |
---|
| 275 | gunichar uch; |
---|
| 276 | } owl_input; |
---|
| 277 | |
---|
[7d4fbcd] | 278 | typedef struct _owl_fmtext { |
---|
| 279 | int textlen; |
---|
[a387d12e] | 280 | int bufflen; |
---|
[7d4fbcd] | 281 | char *textbuff; |
---|
[9866c3a] | 282 | char default_attrs; |
---|
| 283 | short default_fgcolor; |
---|
| 284 | short default_bgcolor; |
---|
[7d4fbcd] | 285 | } owl_fmtext; |
---|
| 286 | |
---|
| 287 | typedef struct _owl_list { |
---|
| 288 | int size; |
---|
| 289 | int avail; |
---|
| 290 | void **list; |
---|
| 291 | } owl_list; |
---|
| 292 | |
---|
| 293 | typedef struct _owl_dict_el { |
---|
| 294 | char *k; /* key */ |
---|
| 295 | void *v; /* value */ |
---|
| 296 | } owl_dict_el; |
---|
| 297 | |
---|
| 298 | typedef struct _owl_dict { |
---|
| 299 | int size; |
---|
| 300 | int avail; |
---|
| 301 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
| 302 | } owl_dict; |
---|
| 303 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
| 304 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
| 305 | |
---|
| 306 | typedef struct _owl_context { |
---|
| 307 | int mode; |
---|
| 308 | void *data; /* determined by mode */ |
---|
| 309 | } owl_context; |
---|
| 310 | |
---|
| 311 | typedef struct _owl_cmd { /* command */ |
---|
| 312 | char *name; |
---|
| 313 | |
---|
| 314 | char *summary; /* one line summary of command */ |
---|
| 315 | char *usage; /* usage synopsis */ |
---|
| 316 | char *description; /* long description of command */ |
---|
| 317 | |
---|
| 318 | int validctx; /* bitmask of valid contexts */ |
---|
| 319 | |
---|
| 320 | /* we should probably have a type here that says which of |
---|
| 321 | * the following is valid, and maybe make the below into a union... */ |
---|
| 322 | |
---|
| 323 | /* Only one of these may be non-NULL ... */ |
---|
| 324 | |
---|
| 325 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
| 326 | |
---|
| 327 | /* These don't take any context */ |
---|
| 328 | char *(*cmd_args_fn)(int argc, char **argv, char *buff); |
---|
| 329 | /* takes argv and the full command as buff. |
---|
| 330 | * caller must free return value if !NULL */ |
---|
| 331 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
| 332 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
| 333 | |
---|
| 334 | /* The following also take the active context if it's valid */ |
---|
| 335 | char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); |
---|
| 336 | /* takes argv and the full command as buff. |
---|
| 337 | * caller must free return value if !NULL */ |
---|
| 338 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
| 339 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
[6922edd] | 340 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
[7d4fbcd] | 341 | } owl_cmd; |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | typedef struct _owl_zwrite { |
---|
[ce7db4d] | 345 | char *class; |
---|
| 346 | char *inst; |
---|
| 347 | char *realm; |
---|
| 348 | char *opcode; |
---|
[56330ff] | 349 | char *zsig; |
---|
[ce7db4d] | 350 | char *message; |
---|
[7d4fbcd] | 351 | owl_list recips; |
---|
| 352 | int cc; |
---|
| 353 | int noping; |
---|
| 354 | } owl_zwrite; |
---|
| 355 | |
---|
[d0d65df] | 356 | typedef struct _owl_pair { |
---|
| 357 | void *key; |
---|
| 358 | void *value; |
---|
| 359 | } owl_pair; |
---|
| 360 | |
---|
[a387d12e] | 361 | struct _owl_fmtext_cache; |
---|
| 362 | |
---|
[7d4fbcd] | 363 | typedef struct _owl_message { |
---|
| 364 | int id; |
---|
[4b464a4] | 365 | int direction; |
---|
[be0a79f] | 366 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 367 | ZNotice_t notice; |
---|
[be0a79f] | 368 | #endif |
---|
[a387d12e] | 369 | struct _owl_fmtext_cache * fmtext; |
---|
[7d4fbcd] | 370 | int delete; |
---|
[8298425] | 371 | char *hostname; |
---|
[65ad073] | 372 | owl_list attributes; /* this is a list of pairs */ |
---|
[25dd31a] | 373 | char *timestr; |
---|
| 374 | time_t time; |
---|
[7d4fbcd] | 375 | char *zwriteline; |
---|
| 376 | } owl_message; |
---|
| 377 | |
---|
[a387d12e] | 378 | #define OWL_FMTEXT_CACHE_SIZE 1000 |
---|
| 379 | /* We cache the saved fmtexts for the last bunch of messages we |
---|
| 380 | rendered */ |
---|
| 381 | typedef struct _owl_fmtext_cache { |
---|
| 382 | owl_message * message; |
---|
| 383 | owl_fmtext fmtext; |
---|
| 384 | } owl_fmtext_cache; |
---|
| 385 | |
---|
[bd3f232] | 386 | typedef struct _owl_style { |
---|
| 387 | char *name; |
---|
[f1e629d] | 388 | char *description; |
---|
[bd3f232] | 389 | int type; |
---|
| 390 | char *perlfuncname; |
---|
| 391 | void (*formatfunc) (owl_fmtext *fm, owl_message *m); |
---|
| 392 | } owl_style; |
---|
| 393 | |
---|
[7d4fbcd] | 394 | typedef struct _owl_mainwin { |
---|
| 395 | int curtruncated; |
---|
[f2e36b5] | 396 | int lasttruncated; |
---|
[7d4fbcd] | 397 | int lastdisplayed; |
---|
| 398 | } owl_mainwin; |
---|
| 399 | |
---|
| 400 | typedef struct _owl_viewwin { |
---|
| 401 | owl_fmtext fmtext; |
---|
| 402 | int textlines; |
---|
| 403 | int topline; |
---|
| 404 | int rightshift; |
---|
| 405 | int winlines, wincols; |
---|
| 406 | WINDOW *curswin; |
---|
[afbf668] | 407 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
| 408 | void *onclose_hook_data; |
---|
[7d4fbcd] | 409 | } owl_viewwin; |
---|
| 410 | |
---|
| 411 | typedef struct _owl_popwin { |
---|
| 412 | WINDOW *borderwin; |
---|
| 413 | WINDOW *popwin; |
---|
| 414 | int lines; |
---|
| 415 | int cols; |
---|
| 416 | int active; |
---|
| 417 | int needsfirstrefresh; |
---|
| 418 | void (*handler) (int ch); |
---|
| 419 | } owl_popwin; |
---|
| 420 | |
---|
[afbf668] | 421 | typedef struct _owl_popexec { |
---|
| 422 | int refcount; |
---|
| 423 | owl_viewwin *vwin; |
---|
| 424 | int winactive; |
---|
| 425 | int pid; /* or 0 if it has terminated */ |
---|
| 426 | int rfd; |
---|
| 427 | } owl_popexec; |
---|
| 428 | |
---|
[7d4fbcd] | 429 | typedef struct _owl_messagelist { |
---|
| 430 | owl_list list; |
---|
| 431 | } owl_messagelist; |
---|
| 432 | |
---|
| 433 | typedef struct _owl_regex { |
---|
| 434 | int negate; |
---|
| 435 | char *string; |
---|
| 436 | regex_t re; |
---|
| 437 | } owl_regex; |
---|
| 438 | |
---|
| 439 | typedef struct _owl_filterelement { |
---|
[cb769bb] | 440 | int (*match_message)(struct _owl_filterelement *fe, owl_message *m); |
---|
| 441 | /* Append a string representation of the filterelement onto buf*/ |
---|
| 442 | void (*print_elt)(struct _owl_filterelement *fe, char * buf); |
---|
| 443 | /* Operands for and,or,not*/ |
---|
| 444 | struct _owl_filterelement *left, *right; |
---|
| 445 | /* For regex filters*/ |
---|
[7d4fbcd] | 446 | owl_regex re; |
---|
[cb769bb] | 447 | /* Used by regexes, filter references, and perl */ |
---|
| 448 | char *field; |
---|
[7d4fbcd] | 449 | } owl_filterelement; |
---|
| 450 | |
---|
| 451 | typedef struct _owl_filter { |
---|
| 452 | char *name; |
---|
| 453 | int polarity; |
---|
[cb769bb] | 454 | owl_filterelement * root; |
---|
[8fa9562] | 455 | int fgcolor; |
---|
| 456 | int bgcolor; |
---|
[59cf91c] | 457 | int cachedmsgid; /* cached msgid: should move into view eventually */ |
---|
[7d4fbcd] | 458 | } owl_filter; |
---|
| 459 | |
---|
| 460 | typedef struct _owl_view { |
---|
[c3ab155] | 461 | char *name; |
---|
[7d4fbcd] | 462 | owl_filter *filter; |
---|
| 463 | owl_messagelist ml; |
---|
[c3ab155] | 464 | owl_style *style; |
---|
[7d4fbcd] | 465 | } owl_view; |
---|
| 466 | |
---|
| 467 | typedef struct _owl_history { |
---|
| 468 | owl_list hist; |
---|
| 469 | int cur; |
---|
| 470 | int touched; |
---|
| 471 | int partial; |
---|
[12c35df] | 472 | int repeats; |
---|
[7d4fbcd] | 473 | } owl_history; |
---|
| 474 | |
---|
[10b866d] | 475 | typedef struct _owl_editwin { |
---|
| 476 | char *buff; |
---|
| 477 | owl_history *hist; |
---|
| 478 | int bufflen; |
---|
| 479 | int allocated; |
---|
| 480 | int buffx, buffy; |
---|
| 481 | int topline; |
---|
| 482 | int winlines, wincols, fillcol, wrapcol; |
---|
| 483 | WINDOW *curswin; |
---|
| 484 | int style; |
---|
| 485 | int lock; |
---|
| 486 | int dotsend; |
---|
[c9334b1] | 487 | int echochar; |
---|
[1b6b2f3] | 488 | |
---|
| 489 | char *command; |
---|
| 490 | void (*callback)(struct _owl_editwin*); |
---|
| 491 | void *cbdata; |
---|
[10b866d] | 492 | } owl_editwin; |
---|
| 493 | |
---|
[afbf668] | 494 | typedef struct _owl_mux { |
---|
| 495 | int handle; /* for referencing this */ |
---|
| 496 | int active; /* has this been deleted? */ |
---|
| 497 | int fd; |
---|
| 498 | int eventmask; /* bitmask of OWL_MUX_* */ |
---|
| 499 | void (*handler_fn)(int handle, int fd, int eventmask, void *data); |
---|
| 500 | void *data; /* data reference to pass to callback */ |
---|
| 501 | } owl_mux; |
---|
| 502 | typedef owl_list owl_muxevents; |
---|
| 503 | |
---|
[7d4fbcd] | 504 | typedef struct _owl_keybinding { |
---|
| 505 | int *j; /* keypress stack (0-terminated) */ |
---|
| 506 | int type; /* command or function? */ |
---|
| 507 | char *desc; /* description (or "*user*") */ |
---|
| 508 | char *command; /* command, if of type command */ |
---|
| 509 | void (*function_fn)(void); /* function ptr, if of type function */ |
---|
| 510 | } owl_keybinding; |
---|
| 511 | |
---|
| 512 | typedef struct _owl_keymap { |
---|
| 513 | char *name; /* name of keymap */ |
---|
| 514 | char *desc; /* description */ |
---|
| 515 | owl_list bindings; /* key bindings */ |
---|
| 516 | struct _owl_keymap *submap; /* submap */ |
---|
[428834d] | 517 | void (*default_fn)(owl_input j); /* default action (takes a keypress) */ |
---|
| 518 | void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ |
---|
| 519 | void (*postalways_fn)(owl_input j); /* always called after keypress is processed */ |
---|
[7d4fbcd] | 520 | } owl_keymap; |
---|
| 521 | |
---|
| 522 | typedef struct _owl_keyhandler { |
---|
| 523 | owl_dict keymaps; /* dictionary of keymaps */ |
---|
| 524 | owl_keymap *active; /* currently active keymap */ |
---|
| 525 | int in_esc; /* escape pressed? */ |
---|
| 526 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
---|
| 527 | int kpstackpos; /* location in stack (-1 = none) */ |
---|
| 528 | } owl_keyhandler; |
---|
| 529 | |
---|
[f4d0975] | 530 | typedef struct _owl_buddy { |
---|
| 531 | int proto; |
---|
| 532 | char *name; |
---|
| 533 | int isidle; |
---|
| 534 | int idlesince; |
---|
| 535 | } owl_buddy; |
---|
| 536 | |
---|
[aa5f725] | 537 | typedef struct _owl_buddylist { |
---|
| 538 | owl_list buddies; |
---|
| 539 | } owl_buddylist; |
---|
| 540 | |
---|
[5a95b69] | 541 | typedef struct _owl_zbuddylist { |
---|
| 542 | owl_list zusers; |
---|
| 543 | } owl_zbuddylist; |
---|
| 544 | |
---|
[6a415e9] | 545 | typedef struct _owl_timer { |
---|
| 546 | int direction; |
---|
| 547 | time_t starttime; |
---|
| 548 | int start; |
---|
| 549 | } owl_timer; |
---|
[aa5f725] | 550 | |
---|
[ec6ff52] | 551 | typedef struct _owl_errqueue { |
---|
| 552 | owl_list errlist; |
---|
| 553 | } owl_errqueue; |
---|
| 554 | |
---|
[8fa9562] | 555 | typedef struct _owl_colorpair_mgr { |
---|
[99c7549] | 556 | int next; |
---|
[c2c5c77] | 557 | short **pairs; |
---|
[8fa9562] | 558 | } owl_colorpair_mgr; |
---|
| 559 | |
---|
[124aebc] | 560 | typedef struct _owl_obarray { |
---|
| 561 | owl_list strings; |
---|
| 562 | } owl_obarray; |
---|
| 563 | |
---|
[9c7a701] | 564 | typedef struct _owl_dispatch { |
---|
| 565 | int fd; /* FD to watch for dispatch. */ |
---|
| 566 | void (*cfunc)(); /* C function to dispatch to. */ |
---|
| 567 | SV *pfunc; /* Perl function to dispatch to. */ |
---|
| 568 | } owl_dispatch; |
---|
| 569 | |
---|
[7d4fbcd] | 570 | typedef struct _owl_global { |
---|
| 571 | owl_mainwin mw; |
---|
| 572 | owl_popwin pw; |
---|
[10b866d] | 573 | owl_history cmdhist; /* command history */ |
---|
| 574 | owl_history msghist; /* outgoing message history */ |
---|
[7d4fbcd] | 575 | owl_keyhandler kh; |
---|
| 576 | owl_list filterlist; |
---|
| 577 | owl_list puntlist; |
---|
[afbf668] | 578 | owl_muxevents muxevents; /* fds to dispatch on */ |
---|
[7d4fbcd] | 579 | owl_vardict vars; |
---|
| 580 | owl_cmddict cmds; |
---|
| 581 | owl_context ctx; |
---|
[ec6ff52] | 582 | owl_errqueue errqueue; |
---|
[7d4fbcd] | 583 | int lines, cols; |
---|
| 584 | int curmsg, topmsg; |
---|
| 585 | int curmsg_vert_offset; |
---|
| 586 | owl_view current_view; |
---|
| 587 | owl_messagelist msglist; |
---|
| 588 | WINDOW *recwin, *sepwin, *msgwin, *typwin; |
---|
| 589 | int needrefresh; |
---|
| 590 | int rightshift; |
---|
| 591 | int resizepending; |
---|
| 592 | int recwinlines; |
---|
| 593 | int typwinactive; |
---|
[a8938c7] | 594 | char *thishost; |
---|
| 595 | char *homedir; |
---|
[b363d83] | 596 | char *confdir; |
---|
| 597 | char *startupfile; |
---|
[7d4fbcd] | 598 | int direction; |
---|
| 599 | int zaway; |
---|
| 600 | char *cur_zaway_msg; |
---|
| 601 | int haveconfig; |
---|
| 602 | int config_format; |
---|
[1b6b2f3] | 603 | void *buffercbdata; |
---|
[7d4fbcd] | 604 | owl_editwin tw; |
---|
| 605 | owl_viewwin vw; |
---|
| 606 | void *perl; |
---|
| 607 | int debug; |
---|
[7f792c1] | 608 | time_t starttime; |
---|
| 609 | time_t lastinputtime; |
---|
[a8938c7] | 610 | char *startupargs; |
---|
[7d4fbcd] | 611 | int userclue; |
---|
| 612 | int nextmsgid; |
---|
| 613 | int hascolors; |
---|
| 614 | int colorpairs; |
---|
[8fa9562] | 615 | owl_colorpair_mgr cpmgr; |
---|
[1fd0b25] | 616 | int searchactive; |
---|
[700c712] | 617 | int newmsgproc_pid; |
---|
[8262340] | 618 | int malloced, freed; |
---|
[1fd0b25] | 619 | char *searchstring; |
---|
[d09e5a1] | 620 | aim_session_t aimsess; |
---|
[c15bbfb] | 621 | aim_conn_t bosconn; |
---|
[6a415e9] | 622 | owl_timer aim_noop_timer; |
---|
| 623 | owl_timer aim_ignorelogin_timer; |
---|
[de03334] | 624 | owl_timer aim_buddyinfo_timer; |
---|
[bd3f232] | 625 | int aim_loggedin; /* true if currently logged into AIM */ |
---|
[a352335c] | 626 | int aim_doprocessing; /* true if we should process AIM events (like pending login) */ |
---|
[bd3f232] | 627 | char *aim_screenname; /* currently logged in AIM screen name */ |
---|
| 628 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
---|
| 629 | owl_list messagequeue; /* for queueing up aim and other messages */ |
---|
[f1e629d] | 630 | owl_dict styledict; /* global dictionary of available styles */ |
---|
[cf83b7a] | 631 | char *response; /* response to the last question asked */ |
---|
[09489b89] | 632 | int havezephyr; |
---|
| 633 | int haveaim; |
---|
[c9e72d1] | 634 | int got_err_signal; /* 1 if we got an unexpected signal */ |
---|
[5a95b69] | 635 | siginfo_t err_signal_info; |
---|
| 636 | owl_zbuddylist zbuddies; |
---|
| 637 | owl_timer zephyr_buddycheck_timer; |
---|
[8232149] | 638 | struct termios startup_tio; |
---|
[8e401cae] | 639 | owl_obarray obarray; |
---|
[9c7a701] | 640 | owl_list dispatchlist; |
---|
[7d4fbcd] | 641 | } owl_global; |
---|
| 642 | |
---|
| 643 | /* globals */ |
---|
[b2b0773] | 644 | extern owl_global g; |
---|
[7d4fbcd] | 645 | |
---|
| 646 | #include "owl_prototypes.h" |
---|
| 647 | |
---|
| 648 | /* these are missing from the zephyr includes for some reason */ |
---|
[be0a79f] | 649 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 650 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
| 651 | int ZGetLocations(ZLocations_t *,int *); |
---|
[be0a79f] | 652 | #endif |
---|
[7d4fbcd] | 653 | |
---|
| 654 | #endif /* INC_OWL_H */ |
---|