[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" |
---|
| 120 | #define OWL_FMTEXT_UTF8_BGDEFAULT "\xf4\x80\x96\x80" |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
[7d4fbcd] | 125 | #define OWL_COLOR_BLACK 0 |
---|
| 126 | #define OWL_COLOR_RED 1 |
---|
| 127 | #define OWL_COLOR_GREEN 2 |
---|
| 128 | #define OWL_COLOR_YELLOW 3 |
---|
| 129 | #define OWL_COLOR_BLUE 4 |
---|
| 130 | #define OWL_COLOR_MAGENTA 5 |
---|
| 131 | #define OWL_COLOR_CYAN 6 |
---|
| 132 | #define OWL_COLOR_WHITE 7 |
---|
[c2c5c77] | 133 | #define OWL_COLOR_DEFAULT -1 |
---|
[7d4fbcd] | 134 | |
---|
| 135 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
---|
| 136 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
---|
| 137 | |
---|
[f4d0975] | 138 | #define OWL_PROTOCOL_ZEPHYR 0 |
---|
| 139 | #define OWL_PROTOCOL_AIM 1 |
---|
| 140 | #define OWL_PROTOCOL_JABBER 2 |
---|
| 141 | #define OWL_PROTOCOL_ICQ 3 |
---|
| 142 | #define OWL_PROTOCOL_YAHOO 4 |
---|
| 143 | #define OWL_PROTOCOL_MSN 5 |
---|
| 144 | |
---|
[4b464a4] | 145 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
| 146 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
| 147 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
[7d4fbcd] | 148 | |
---|
[afbf668] | 149 | #define OWL_MUX_READ 1 |
---|
| 150 | #define OWL_MUX_WRITE 2 |
---|
| 151 | #define OWL_MUX_EXCEPT 4 |
---|
| 152 | |
---|
[7d4fbcd] | 153 | #define OWL_DIRECTION_NONE 0 |
---|
| 154 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
| 155 | #define OWL_DIRECTION_UPWARDS 2 |
---|
| 156 | |
---|
[12c35df] | 157 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
---|
| 158 | #define OWL_LOGGING_DIRECTION_IN 1 |
---|
| 159 | #define OWL_LOGGING_DIRECTION_OUT 2 |
---|
| 160 | |
---|
[88736cb] | 161 | #define OWL_SCROLLMODE_NORMAL 0 |
---|
| 162 | #define OWL_SCROLLMODE_TOP 1 |
---|
| 163 | #define OWL_SCROLLMODE_NEARTOP 2 |
---|
| 164 | #define OWL_SCROLLMODE_CENTER 3 |
---|
| 165 | #define OWL_SCROLLMODE_PAGED 4 |
---|
[aa2f33b3] | 166 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
| 167 | |
---|
[bd3f232] | 168 | #define OWL_STYLE_TYPE_INTERNAL 0 |
---|
| 169 | #define OWL_STYLE_TYPE_PERL 1 |
---|
| 170 | |
---|
[7d4fbcd] | 171 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
---|
| 172 | #define OWL_TABSTR " " |
---|
| 173 | #define OWL_MSGTAB 7 |
---|
| 174 | #define OWL_TYPWIN_SIZE 8 |
---|
| 175 | #define OWL_HISTORYSIZE 50 |
---|
| 176 | |
---|
| 177 | /* Indicate current state, as well as what is allowed */ |
---|
| 178 | #define OWL_CTX_ANY 0xffff |
---|
| 179 | /* Only one of these may be active at a time... */ |
---|
| 180 | #define OWL_CTX_MODE_BITS 0x000f |
---|
| 181 | #define OWL_CTX_STARTUP 0x0001 |
---|
| 182 | #define OWL_CTX_READCONFIG 0x0002 |
---|
| 183 | #define OWL_CTX_INTERACTIVE 0x0004 |
---|
| 184 | /* Only one of these may be active at a time... */ |
---|
| 185 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
---|
| 186 | #define OWL_CTX_POPWIN 0x00f0 |
---|
| 187 | #define OWL_CTX_POPLESS 0x0010 |
---|
| 188 | #define OWL_CTX_RECWIN 0x0f00 |
---|
| 189 | #define OWL_CTX_RECV 0x0100 |
---|
| 190 | #define OWL_CTX_TYPWIN 0xf000 |
---|
[cf83b7a] | 191 | #define OWL_CTX_EDIT 0x7000 |
---|
[7d4fbcd] | 192 | #define OWL_CTX_EDITLINE 0x1000 |
---|
| 193 | #define OWL_CTX_EDITMULTI 0x2000 |
---|
[cf83b7a] | 194 | #define OWL_CTX_EDITRESPONSE 0x4000 |
---|
[7d4fbcd] | 195 | |
---|
| 196 | #define OWL_USERCLUE_NONE 0 |
---|
| 197 | #define OWL_USERCLUE_CLASSES 1 |
---|
| 198 | #define OWL_USERCLUE_FOOBAR 2 |
---|
| 199 | #define OWL_USERCLUE_BAZ 4 |
---|
| 200 | |
---|
| 201 | #define OWL_WEBBROWSER_NONE 0 |
---|
| 202 | #define OWL_WEBBROWSER_NETSCAPE 1 |
---|
| 203 | #define OWL_WEBBROWSER_GALEON 2 |
---|
[ae9e6be] | 204 | #define OWL_WEBBROWSER_OPERA 3 |
---|
[7d4fbcd] | 205 | |
---|
| 206 | #define OWL_VARIABLE_OTHER 0 |
---|
| 207 | #define OWL_VARIABLE_INT 1 |
---|
| 208 | #define OWL_VARIABLE_BOOL 2 |
---|
| 209 | #define OWL_VARIABLE_STRING 3 |
---|
| 210 | |
---|
| 211 | #define OWL_FILTER_MAX_DEPTH 300 |
---|
| 212 | |
---|
[4b464a4] | 213 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
[7d4fbcd] | 214 | |
---|
[4b464a4] | 215 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
| 216 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
[7d4fbcd] | 217 | |
---|
[4b464a4] | 218 | #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] | 219 | #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] | 220 | |
---|
[4b464a4] | 221 | #define OWL_INCLUDE_REG_TESTS 1 /* whether to build in regression tests */ |
---|
[7d4fbcd] | 222 | |
---|
[1c7a4e0] | 223 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
[7d4fbcd] | 224 | |
---|
[e7cc1c3] | 225 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr" |
---|
[1d3e925] | 226 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
| 227 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
[e7cc1c3] | 228 | |
---|
[80e54a7] | 229 | #define OWL_REGEX_QUOTECHARS "+*.?[]^\\${}()" |
---|
[bc08664] | 230 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
| 231 | |
---|
[0435c7d] | 232 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
[c86a35c] | 233 | #define OWL_ENABLE_ZCRYPT 1 |
---|
[c269e22] | 234 | #endif |
---|
| 235 | |
---|
[62fdd29] | 236 | #define OWL_META(key) ((key)|010000) |
---|
[f87c490] | 237 | /* OWL_CTRL is definied in kepress.c */ |
---|
[7d4fbcd] | 238 | |
---|
| 239 | #define LINE 2048 |
---|
| 240 | |
---|
| 241 | typedef struct _owl_variable { |
---|
| 242 | char *name; |
---|
| 243 | int type; /* OWL_VARIABLE_* */ |
---|
| 244 | void *pval_default; /* for types other and string */ |
---|
| 245 | int ival_default; /* for types int and bool */ |
---|
| 246 | char *validsettings; /* documentation of valid settings */ |
---|
[aa2f33b3] | 247 | char *summary; /* summary of usage */ |
---|
| 248 | char *description; /* detailed description */ |
---|
[7d4fbcd] | 249 | void *val; /* current value */ |
---|
| 250 | int (*validate_fn)(struct _owl_variable *v, void *newval); |
---|
| 251 | /* returns 1 if newval is valid */ |
---|
| 252 | int (*set_fn)(struct _owl_variable *v, void *newval); |
---|
| 253 | /* sets the variable to a value |
---|
| 254 | * of the appropriate type. |
---|
| 255 | * unless documented, this |
---|
| 256 | * should make a copy. |
---|
| 257 | * returns 0 on success. */ |
---|
| 258 | int (*set_fromstring_fn)(struct _owl_variable *v, char *newval); |
---|
| 259 | /* sets the variable to a value |
---|
| 260 | * of the appropriate type. |
---|
| 261 | * unless documented, this |
---|
| 262 | * should make a copy. |
---|
| 263 | * returns 0 on success. */ |
---|
| 264 | void *(*get_fn)(struct _owl_variable *v); |
---|
| 265 | /* returns a reference to the current value. |
---|
| 266 | * WARNING: this approach is hard to make |
---|
| 267 | * thread-safe... */ |
---|
| 268 | int (*get_tostring_fn)(struct _owl_variable *v, |
---|
| 269 | char *buf, int bufsize, void *val); |
---|
| 270 | /* converts val to a string |
---|
| 271 | * and puts into buf */ |
---|
| 272 | void (*free_fn)(struct _owl_variable *v); |
---|
| 273 | /* frees val as needed */ |
---|
| 274 | } owl_variable; |
---|
| 275 | |
---|
[428834d] | 276 | typedef struct _owl_input { |
---|
| 277 | int ch; |
---|
| 278 | gunichar uch; |
---|
| 279 | } owl_input; |
---|
| 280 | |
---|
[7d4fbcd] | 281 | typedef struct _owl_fmtext { |
---|
| 282 | int textlen; |
---|
[a387d12e] | 283 | int bufflen; |
---|
[7d4fbcd] | 284 | char *textbuff; |
---|
[9866c3a] | 285 | char default_attrs; |
---|
| 286 | short default_fgcolor; |
---|
| 287 | short default_bgcolor; |
---|
[7d4fbcd] | 288 | } owl_fmtext; |
---|
| 289 | |
---|
| 290 | typedef struct _owl_list { |
---|
| 291 | int size; |
---|
| 292 | int avail; |
---|
| 293 | void **list; |
---|
| 294 | } owl_list; |
---|
| 295 | |
---|
| 296 | typedef struct _owl_dict_el { |
---|
| 297 | char *k; /* key */ |
---|
| 298 | void *v; /* value */ |
---|
| 299 | } owl_dict_el; |
---|
| 300 | |
---|
| 301 | typedef struct _owl_dict { |
---|
| 302 | int size; |
---|
| 303 | int avail; |
---|
| 304 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
| 305 | } owl_dict; |
---|
| 306 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
| 307 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
| 308 | |
---|
| 309 | typedef struct _owl_context { |
---|
| 310 | int mode; |
---|
| 311 | void *data; /* determined by mode */ |
---|
| 312 | } owl_context; |
---|
| 313 | |
---|
| 314 | typedef struct _owl_cmd { /* command */ |
---|
| 315 | char *name; |
---|
| 316 | |
---|
| 317 | char *summary; /* one line summary of command */ |
---|
| 318 | char *usage; /* usage synopsis */ |
---|
| 319 | char *description; /* long description of command */ |
---|
| 320 | |
---|
| 321 | int validctx; /* bitmask of valid contexts */ |
---|
| 322 | |
---|
| 323 | /* we should probably have a type here that says which of |
---|
| 324 | * the following is valid, and maybe make the below into a union... */ |
---|
| 325 | |
---|
| 326 | /* Only one of these may be non-NULL ... */ |
---|
| 327 | |
---|
| 328 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
| 329 | |
---|
| 330 | /* These don't take any context */ |
---|
| 331 | char *(*cmd_args_fn)(int argc, char **argv, char *buff); |
---|
| 332 | /* takes argv and the full command as buff. |
---|
| 333 | * caller must free return value if !NULL */ |
---|
| 334 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
| 335 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
| 336 | |
---|
| 337 | /* The following also take the active context if it's valid */ |
---|
| 338 | char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); |
---|
| 339 | /* takes argv and the full command as buff. |
---|
| 340 | * caller must free return value if !NULL */ |
---|
| 341 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
| 342 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
[6922edd] | 343 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
[7d4fbcd] | 344 | } owl_cmd; |
---|
| 345 | |
---|
| 346 | |
---|
| 347 | typedef struct _owl_zwrite { |
---|
[ce7db4d] | 348 | char *class; |
---|
| 349 | char *inst; |
---|
| 350 | char *realm; |
---|
| 351 | char *opcode; |
---|
[56330ff] | 352 | char *zsig; |
---|
[ce7db4d] | 353 | char *message; |
---|
[7d4fbcd] | 354 | owl_list recips; |
---|
| 355 | int cc; |
---|
| 356 | int noping; |
---|
| 357 | } owl_zwrite; |
---|
| 358 | |
---|
[d0d65df] | 359 | typedef struct _owl_pair { |
---|
| 360 | void *key; |
---|
| 361 | void *value; |
---|
| 362 | } owl_pair; |
---|
| 363 | |
---|
[a387d12e] | 364 | struct _owl_fmtext_cache; |
---|
| 365 | |
---|
[7d4fbcd] | 366 | typedef struct _owl_message { |
---|
| 367 | int id; |
---|
[4b464a4] | 368 | int direction; |
---|
[be0a79f] | 369 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 370 | ZNotice_t notice; |
---|
[be0a79f] | 371 | #endif |
---|
[a387d12e] | 372 | struct _owl_fmtext_cache * fmtext; |
---|
[7d4fbcd] | 373 | int delete; |
---|
[8298425] | 374 | char *hostname; |
---|
[65ad073] | 375 | owl_list attributes; /* this is a list of pairs */ |
---|
[25dd31a] | 376 | char *timestr; |
---|
| 377 | time_t time; |
---|
[7d4fbcd] | 378 | char *zwriteline; |
---|
| 379 | } owl_message; |
---|
| 380 | |
---|
[a387d12e] | 381 | #define OWL_FMTEXT_CACHE_SIZE 1000 |
---|
| 382 | /* We cache the saved fmtexts for the last bunch of messages we |
---|
| 383 | rendered */ |
---|
| 384 | typedef struct _owl_fmtext_cache { |
---|
| 385 | owl_message * message; |
---|
| 386 | owl_fmtext fmtext; |
---|
| 387 | } owl_fmtext_cache; |
---|
| 388 | |
---|
[bd3f232] | 389 | typedef struct _owl_style { |
---|
| 390 | char *name; |
---|
[f1e629d] | 391 | char *description; |
---|
[bd3f232] | 392 | int type; |
---|
| 393 | char *perlfuncname; |
---|
| 394 | void (*formatfunc) (owl_fmtext *fm, owl_message *m); |
---|
| 395 | } owl_style; |
---|
| 396 | |
---|
[7d4fbcd] | 397 | typedef struct _owl_mainwin { |
---|
| 398 | int curtruncated; |
---|
[f2e36b5] | 399 | int lasttruncated; |
---|
[7d4fbcd] | 400 | int lastdisplayed; |
---|
| 401 | } owl_mainwin; |
---|
| 402 | |
---|
| 403 | typedef struct _owl_viewwin { |
---|
| 404 | owl_fmtext fmtext; |
---|
| 405 | int textlines; |
---|
| 406 | int topline; |
---|
| 407 | int rightshift; |
---|
| 408 | int winlines, wincols; |
---|
| 409 | WINDOW *curswin; |
---|
[afbf668] | 410 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
| 411 | void *onclose_hook_data; |
---|
[7d4fbcd] | 412 | } owl_viewwin; |
---|
| 413 | |
---|
| 414 | typedef struct _owl_popwin { |
---|
| 415 | WINDOW *borderwin; |
---|
| 416 | WINDOW *popwin; |
---|
| 417 | int lines; |
---|
| 418 | int cols; |
---|
| 419 | int active; |
---|
| 420 | int needsfirstrefresh; |
---|
| 421 | void (*handler) (int ch); |
---|
| 422 | } owl_popwin; |
---|
| 423 | |
---|
[afbf668] | 424 | typedef struct _owl_popexec { |
---|
| 425 | int refcount; |
---|
| 426 | owl_viewwin *vwin; |
---|
| 427 | int winactive; |
---|
| 428 | int pid; /* or 0 if it has terminated */ |
---|
| 429 | int rfd; |
---|
| 430 | } owl_popexec; |
---|
| 431 | |
---|
[7d4fbcd] | 432 | typedef struct _owl_messagelist { |
---|
| 433 | owl_list list; |
---|
| 434 | } owl_messagelist; |
---|
| 435 | |
---|
| 436 | typedef struct _owl_regex { |
---|
| 437 | int negate; |
---|
| 438 | char *string; |
---|
| 439 | regex_t re; |
---|
| 440 | } owl_regex; |
---|
| 441 | |
---|
| 442 | typedef struct _owl_filterelement { |
---|
[cb769bb] | 443 | int (*match_message)(struct _owl_filterelement *fe, owl_message *m); |
---|
| 444 | /* Append a string representation of the filterelement onto buf*/ |
---|
| 445 | void (*print_elt)(struct _owl_filterelement *fe, char * buf); |
---|
| 446 | /* Operands for and,or,not*/ |
---|
| 447 | struct _owl_filterelement *left, *right; |
---|
| 448 | /* For regex filters*/ |
---|
[7d4fbcd] | 449 | owl_regex re; |
---|
[cb769bb] | 450 | /* Used by regexes, filter references, and perl */ |
---|
| 451 | char *field; |
---|
[7d4fbcd] | 452 | } owl_filterelement; |
---|
| 453 | |
---|
| 454 | typedef struct _owl_filter { |
---|
| 455 | char *name; |
---|
| 456 | int polarity; |
---|
[cb769bb] | 457 | owl_filterelement * root; |
---|
[8fa9562] | 458 | int fgcolor; |
---|
| 459 | int bgcolor; |
---|
[59cf91c] | 460 | int cachedmsgid; /* cached msgid: should move into view eventually */ |
---|
[7d4fbcd] | 461 | } owl_filter; |
---|
| 462 | |
---|
| 463 | typedef struct _owl_view { |
---|
[c3ab155] | 464 | char *name; |
---|
[7d4fbcd] | 465 | owl_filter *filter; |
---|
| 466 | owl_messagelist ml; |
---|
[c3ab155] | 467 | owl_style *style; |
---|
[7d4fbcd] | 468 | } owl_view; |
---|
| 469 | |
---|
| 470 | typedef struct _owl_history { |
---|
| 471 | owl_list hist; |
---|
| 472 | int cur; |
---|
| 473 | int touched; |
---|
| 474 | int partial; |
---|
[12c35df] | 475 | int repeats; |
---|
[7d4fbcd] | 476 | } owl_history; |
---|
| 477 | |
---|
[10b866d] | 478 | typedef struct _owl_editwin { |
---|
| 479 | char *buff; |
---|
| 480 | owl_history *hist; |
---|
| 481 | int bufflen; |
---|
| 482 | int allocated; |
---|
| 483 | int buffx, buffy; |
---|
| 484 | int topline; |
---|
| 485 | int winlines, wincols, fillcol, wrapcol; |
---|
| 486 | WINDOW *curswin; |
---|
| 487 | int style; |
---|
| 488 | int lock; |
---|
| 489 | int dotsend; |
---|
[c9334b1] | 490 | int echochar; |
---|
[1b6b2f3] | 491 | |
---|
| 492 | char *command; |
---|
| 493 | void (*callback)(struct _owl_editwin*); |
---|
| 494 | void *cbdata; |
---|
[10b866d] | 495 | } owl_editwin; |
---|
| 496 | |
---|
[afbf668] | 497 | typedef struct _owl_mux { |
---|
| 498 | int handle; /* for referencing this */ |
---|
| 499 | int active; /* has this been deleted? */ |
---|
| 500 | int fd; |
---|
| 501 | int eventmask; /* bitmask of OWL_MUX_* */ |
---|
| 502 | void (*handler_fn)(int handle, int fd, int eventmask, void *data); |
---|
| 503 | void *data; /* data reference to pass to callback */ |
---|
| 504 | } owl_mux; |
---|
| 505 | typedef owl_list owl_muxevents; |
---|
| 506 | |
---|
[7d4fbcd] | 507 | typedef struct _owl_keybinding { |
---|
| 508 | int *j; /* keypress stack (0-terminated) */ |
---|
| 509 | int type; /* command or function? */ |
---|
| 510 | char *desc; /* description (or "*user*") */ |
---|
| 511 | char *command; /* command, if of type command */ |
---|
| 512 | void (*function_fn)(void); /* function ptr, if of type function */ |
---|
| 513 | } owl_keybinding; |
---|
| 514 | |
---|
| 515 | typedef struct _owl_keymap { |
---|
| 516 | char *name; /* name of keymap */ |
---|
| 517 | char *desc; /* description */ |
---|
| 518 | owl_list bindings; /* key bindings */ |
---|
| 519 | struct _owl_keymap *submap; /* submap */ |
---|
[428834d] | 520 | void (*default_fn)(owl_input j); /* default action (takes a keypress) */ |
---|
| 521 | void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ |
---|
| 522 | void (*postalways_fn)(owl_input j); /* always called after keypress is processed */ |
---|
[7d4fbcd] | 523 | } owl_keymap; |
---|
| 524 | |
---|
| 525 | typedef struct _owl_keyhandler { |
---|
| 526 | owl_dict keymaps; /* dictionary of keymaps */ |
---|
| 527 | owl_keymap *active; /* currently active keymap */ |
---|
| 528 | int in_esc; /* escape pressed? */ |
---|
| 529 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
---|
| 530 | int kpstackpos; /* location in stack (-1 = none) */ |
---|
| 531 | } owl_keyhandler; |
---|
| 532 | |
---|
[f4d0975] | 533 | typedef struct _owl_buddy { |
---|
| 534 | int proto; |
---|
| 535 | char *name; |
---|
| 536 | int isidle; |
---|
| 537 | int idlesince; |
---|
| 538 | } owl_buddy; |
---|
| 539 | |
---|
[aa5f725] | 540 | typedef struct _owl_buddylist { |
---|
| 541 | owl_list buddies; |
---|
| 542 | } owl_buddylist; |
---|
| 543 | |
---|
[5a95b69] | 544 | typedef struct _owl_zbuddylist { |
---|
| 545 | owl_list zusers; |
---|
| 546 | } owl_zbuddylist; |
---|
| 547 | |
---|
[6a415e9] | 548 | typedef struct _owl_timer { |
---|
| 549 | int direction; |
---|
| 550 | time_t starttime; |
---|
| 551 | int start; |
---|
| 552 | } owl_timer; |
---|
[aa5f725] | 553 | |
---|
[ec6ff52] | 554 | typedef struct _owl_errqueue { |
---|
| 555 | owl_list errlist; |
---|
| 556 | } owl_errqueue; |
---|
| 557 | |
---|
[8fa9562] | 558 | typedef struct _owl_colorpair_mgr { |
---|
[99c7549] | 559 | int next; |
---|
[c2c5c77] | 560 | short **pairs; |
---|
[8fa9562] | 561 | } owl_colorpair_mgr; |
---|
| 562 | |
---|
[124aebc] | 563 | typedef struct _owl_obarray { |
---|
| 564 | owl_list strings; |
---|
| 565 | } owl_obarray; |
---|
| 566 | |
---|
[7d4fbcd] | 567 | typedef struct _owl_global { |
---|
| 568 | owl_mainwin mw; |
---|
| 569 | owl_popwin pw; |
---|
[10b866d] | 570 | owl_history cmdhist; /* command history */ |
---|
| 571 | owl_history msghist; /* outgoing message history */ |
---|
[7d4fbcd] | 572 | owl_keyhandler kh; |
---|
| 573 | owl_list filterlist; |
---|
| 574 | owl_list puntlist; |
---|
[afbf668] | 575 | owl_muxevents muxevents; /* fds to dispatch on */ |
---|
[7d4fbcd] | 576 | owl_vardict vars; |
---|
| 577 | owl_cmddict cmds; |
---|
| 578 | owl_context ctx; |
---|
[ec6ff52] | 579 | owl_errqueue errqueue; |
---|
[7d4fbcd] | 580 | int lines, cols; |
---|
| 581 | int curmsg, topmsg; |
---|
| 582 | int curmsg_vert_offset; |
---|
| 583 | owl_view current_view; |
---|
| 584 | owl_messagelist msglist; |
---|
| 585 | WINDOW *recwin, *sepwin, *msgwin, *typwin; |
---|
| 586 | int needrefresh; |
---|
| 587 | int rightshift; |
---|
| 588 | int resizepending; |
---|
| 589 | int recwinlines; |
---|
| 590 | int typwinactive; |
---|
[a8938c7] | 591 | char *thishost; |
---|
| 592 | char *homedir; |
---|
[b363d83] | 593 | char *confdir; |
---|
| 594 | char *startupfile; |
---|
[7d4fbcd] | 595 | int direction; |
---|
| 596 | int zaway; |
---|
| 597 | char *cur_zaway_msg; |
---|
| 598 | int haveconfig; |
---|
| 599 | int config_format; |
---|
[1b6b2f3] | 600 | void *buffercbdata; |
---|
[7d4fbcd] | 601 | owl_editwin tw; |
---|
| 602 | owl_viewwin vw; |
---|
| 603 | void *perl; |
---|
| 604 | int debug; |
---|
[7f792c1] | 605 | time_t starttime; |
---|
| 606 | time_t lastinputtime; |
---|
[a8938c7] | 607 | char *startupargs; |
---|
[7d4fbcd] | 608 | int userclue; |
---|
| 609 | int nextmsgid; |
---|
| 610 | int hascolors; |
---|
| 611 | int colorpairs; |
---|
[8fa9562] | 612 | owl_colorpair_mgr cpmgr; |
---|
[1fd0b25] | 613 | int searchactive; |
---|
[700c712] | 614 | int newmsgproc_pid; |
---|
[8262340] | 615 | int malloced, freed; |
---|
[1fd0b25] | 616 | char *searchstring; |
---|
[d09e5a1] | 617 | aim_session_t aimsess; |
---|
[c15bbfb] | 618 | aim_conn_t bosconn; |
---|
[6a415e9] | 619 | owl_timer aim_noop_timer; |
---|
| 620 | owl_timer aim_ignorelogin_timer; |
---|
[de03334] | 621 | owl_timer aim_buddyinfo_timer; |
---|
[bd3f232] | 622 | int aim_loggedin; /* true if currently logged into AIM */ |
---|
[a352335c] | 623 | int aim_doprocessing; /* true if we should process AIM events (like pending login) */ |
---|
[bd3f232] | 624 | char *aim_screenname; /* currently logged in AIM screen name */ |
---|
| 625 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
---|
| 626 | owl_list messagequeue; /* for queueing up aim and other messages */ |
---|
[f1e629d] | 627 | owl_dict styledict; /* global dictionary of available styles */ |
---|
[cf83b7a] | 628 | char *response; /* response to the last question asked */ |
---|
[09489b89] | 629 | int havezephyr; |
---|
| 630 | int haveaim; |
---|
[c9e72d1] | 631 | int got_err_signal; /* 1 if we got an unexpected signal */ |
---|
[5a95b69] | 632 | siginfo_t err_signal_info; |
---|
| 633 | owl_zbuddylist zbuddies; |
---|
| 634 | owl_timer zephyr_buddycheck_timer; |
---|
[8232149] | 635 | struct termios startup_tio; |
---|
[8e401cae] | 636 | owl_obarray obarray; |
---|
[7d4fbcd] | 637 | } owl_global; |
---|
| 638 | |
---|
| 639 | /* globals */ |
---|
[b2b0773] | 640 | extern owl_global g; |
---|
[7d4fbcd] | 641 | |
---|
| 642 | #include "owl_prototypes.h" |
---|
| 643 | |
---|
| 644 | /* these are missing from the zephyr includes for some reason */ |
---|
[be0a79f] | 645 | #ifdef HAVE_LIBZEPHYR |
---|
[7d4fbcd] | 646 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
| 647 | int ZGetLocations(ZLocations_t *,int *); |
---|
[be0a79f] | 648 | #endif |
---|
[7d4fbcd] | 649 | |
---|
| 650 | #endif /* INC_OWL_H */ |
---|