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