1 | /* Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved. |
---|
2 | * Copyright (c) 2004 James Kretchmar. All rights reserved. |
---|
3 | * |
---|
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. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef INC_BARNOWL_OWL_H |
---|
10 | #define INC_BARNOWL_OWL_H |
---|
11 | |
---|
12 | #include "config.h" |
---|
13 | |
---|
14 | #include "compat/compat.h" |
---|
15 | |
---|
16 | #include <stdbool.h> |
---|
17 | |
---|
18 | #ifndef OWL_PERL |
---|
19 | #define NCURSES_ENABLE_STDBOOL_H 1 |
---|
20 | #include <ncursesw/curses.h> |
---|
21 | #include <ncursesw/panel.h> |
---|
22 | #endif |
---|
23 | #include <sys/param.h> |
---|
24 | #include <EXTERN.h> |
---|
25 | #include <netdb.h> |
---|
26 | #include <regex.h> |
---|
27 | #include <time.h> |
---|
28 | #include <signal.h> |
---|
29 | #include <termios.h> |
---|
30 | #include "libfaim/aim.h" |
---|
31 | #include <wchar.h> |
---|
32 | #include "glib.h" |
---|
33 | #ifdef HAVE_LIBZEPHYR |
---|
34 | #include <zephyr/zephyr.h> |
---|
35 | #endif |
---|
36 | #ifdef HAVE_COM_ERR_H |
---|
37 | #include <com_err.h> |
---|
38 | #endif |
---|
39 | |
---|
40 | /* Perl and curses don't play nice. */ |
---|
41 | #ifdef OWL_PERL |
---|
42 | typedef void WINDOW; |
---|
43 | typedef void PANEL; |
---|
44 | /* logout is defined in FreeBSD. */ |
---|
45 | #define logout logout_ |
---|
46 | #define HAS_BOOL |
---|
47 | #include <perl.h> |
---|
48 | #include "owl_perl.h" |
---|
49 | #undef logout |
---|
50 | #include "XSUB.h" |
---|
51 | #else |
---|
52 | typedef void SV; |
---|
53 | typedef void AV; |
---|
54 | typedef void HV; |
---|
55 | #endif |
---|
56 | |
---|
57 | #include "window.h" |
---|
58 | |
---|
59 | #ifndef OWL_VERSION_STRING |
---|
60 | #ifdef GIT_VERSION |
---|
61 | #define stringify(x) __stringify(x) |
---|
62 | #define __stringify(x) #x |
---|
63 | #define OWL_VERSION_STRING stringify(GIT_VERSION) |
---|
64 | #else |
---|
65 | #define OWL_VERSION_STRING PACKAGE_VERSION |
---|
66 | #endif |
---|
67 | #endif /* !OWL_VERSION_STRING */ |
---|
68 | |
---|
69 | /* Feature that is being tested to redirect stderr through a pipe. |
---|
70 | * There may still be some portability problems with this. */ |
---|
71 | #define OWL_STDERR_REDIR 1 |
---|
72 | |
---|
73 | #define OWL_DEBUG 0 |
---|
74 | #define OWL_DEBUG_FILE "/var/tmp/barnowl-debug" |
---|
75 | |
---|
76 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
77 | |
---|
78 | #define OWL_FMTEXT_ATTR_NONE 0 |
---|
79 | #define OWL_FMTEXT_ATTR_BOLD 1 |
---|
80 | #define OWL_FMTEXT_ATTR_REVERSE 2 |
---|
81 | #define OWL_FMTEXT_ATTR_UNDERLINE 4 |
---|
82 | |
---|
83 | #define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/ |
---|
84 | #define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 ) |
---|
85 | #define OWL_FMTEXT_UC_ATTR_MASK 0x7 |
---|
86 | #define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 ) |
---|
87 | #define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE |
---|
88 | #define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 ) |
---|
89 | #define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100 |
---|
90 | #define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
91 | #define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR ) |
---|
92 | #define OWL_FMTEXT_UC_COLOR_MASK 0xFF |
---|
93 | #define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200) |
---|
94 | #define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4' |
---|
95 | |
---|
96 | #define OWL_COLOR_BLACK 0 |
---|
97 | #define OWL_COLOR_RED 1 |
---|
98 | #define OWL_COLOR_GREEN 2 |
---|
99 | #define OWL_COLOR_YELLOW 3 |
---|
100 | #define OWL_COLOR_BLUE 4 |
---|
101 | #define OWL_COLOR_MAGENTA 5 |
---|
102 | #define OWL_COLOR_CYAN 6 |
---|
103 | #define OWL_COLOR_WHITE 7 |
---|
104 | #define OWL_COLOR_DEFAULT -1 |
---|
105 | #define OWL_COLOR_INVALID -2 |
---|
106 | |
---|
107 | #define OWL_TAB_WIDTH 8 |
---|
108 | |
---|
109 | #define OWL_EDITWIN_STYLE_MULTILINE 0 |
---|
110 | #define OWL_EDITWIN_STYLE_ONELINE 1 |
---|
111 | |
---|
112 | #define OWL_PROTOCOL_ZEPHYR 0 |
---|
113 | #define OWL_PROTOCOL_AIM 1 |
---|
114 | #define OWL_PROTOCOL_JABBER 2 |
---|
115 | #define OWL_PROTOCOL_ICQ 3 |
---|
116 | #define OWL_PROTOCOL_YAHOO 4 |
---|
117 | #define OWL_PROTOCOL_MSN 5 |
---|
118 | |
---|
119 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
120 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
121 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
122 | |
---|
123 | #define OWL_DIRECTION_NONE 0 |
---|
124 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
125 | #define OWL_DIRECTION_UPWARDS 2 |
---|
126 | |
---|
127 | #define OWL_LOGGING_DIRECTION_BOTH 0 |
---|
128 | #define OWL_LOGGING_DIRECTION_IN 1 |
---|
129 | #define OWL_LOGGING_DIRECTION_OUT 2 |
---|
130 | |
---|
131 | #define OWL_SCROLLMODE_NORMAL 0 |
---|
132 | #define OWL_SCROLLMODE_TOP 1 |
---|
133 | #define OWL_SCROLLMODE_NEARTOP 2 |
---|
134 | #define OWL_SCROLLMODE_CENTER 3 |
---|
135 | #define OWL_SCROLLMODE_PAGED 4 |
---|
136 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
137 | |
---|
138 | #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ |
---|
139 | #define OWL_TABSTR " " |
---|
140 | #define OWL_MSGTAB 7 |
---|
141 | #define OWL_TYPWIN_SIZE 8 |
---|
142 | #define OWL_HISTORYSIZE 50 |
---|
143 | |
---|
144 | /* Indicate current state, as well as what is allowed */ |
---|
145 | #define OWL_CTX_ANY 0xffff |
---|
146 | /* Only one of these may be active at a time... */ |
---|
147 | #define OWL_CTX_MODE_BITS 0x000f |
---|
148 | #define OWL_CTX_STARTUP 0x0001 |
---|
149 | #define OWL_CTX_READCONFIG 0x0002 |
---|
150 | #define OWL_CTX_INTERACTIVE 0x0004 |
---|
151 | /* Only one of these may be active at a time... */ |
---|
152 | #define OWL_CTX_ACTIVE_BITS 0xfff0 |
---|
153 | #define OWL_CTX_POPWIN 0x00f0 |
---|
154 | #define OWL_CTX_POPLESS 0x0010 |
---|
155 | #define OWL_CTX_RECWIN 0x0f00 |
---|
156 | #define OWL_CTX_RECV 0x0100 |
---|
157 | #define OWL_CTX_TYPWIN 0xf000 |
---|
158 | #define OWL_CTX_EDIT 0x7000 |
---|
159 | #define OWL_CTX_EDITLINE 0x1000 |
---|
160 | #define OWL_CTX_EDITMULTI 0x2000 |
---|
161 | #define OWL_CTX_EDITRESPONSE 0x4000 |
---|
162 | |
---|
163 | #define OWL_VARIABLE_OTHER 0 |
---|
164 | #define OWL_VARIABLE_INT 1 |
---|
165 | #define OWL_VARIABLE_BOOL 2 |
---|
166 | #define OWL_VARIABLE_STRING 3 |
---|
167 | |
---|
168 | #define OWL_OUTPUT_RETURN 0 |
---|
169 | #define OWL_OUTPUT_POPUP 1 |
---|
170 | #define OWL_OUTPUT_ADMINMSG 2 |
---|
171 | |
---|
172 | #define OWL_FILTER_MAX_DEPTH 300 |
---|
173 | |
---|
174 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
175 | |
---|
176 | #define OWL_KEYBINDING_NOOP 0 /* dummy binding that does nothing */ |
---|
177 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
178 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
179 | |
---|
180 | #define OWL_DEFAULT_ZAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n" |
---|
181 | #define OWL_DEFAULT_AAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n" |
---|
182 | |
---|
183 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
184 | |
---|
185 | #define OWL_WEBZEPHYR_PRINCIPAL "daemon/webzephyr.mit.edu" |
---|
186 | #define OWL_WEBZEPHYR_CLASS "webzephyr" |
---|
187 | #define OWL_WEBZEPHYR_OPCODE "webzephyr" |
---|
188 | |
---|
189 | #define OWL_ZEPHYR_NOSTRIP_HOST "host/" |
---|
190 | #define OWL_ZEPHYR_NOSTRIP_RCMD "rcmd." |
---|
191 | #define OWL_ZEPHYR_NOSTRIP_DAEMON5 "daemon/" |
---|
192 | #define OWL_ZEPHYR_NOSTRIP_DAEMON4 "daemon." |
---|
193 | |
---|
194 | #define OWL_REGEX_QUOTECHARS "!+*.?[]^\\${}()|" |
---|
195 | #define OWL_REGEX_QUOTEWITH "\\" |
---|
196 | |
---|
197 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT) |
---|
198 | #define OWL_ENABLE_ZCRYPT 1 |
---|
199 | #endif |
---|
200 | |
---|
201 | /* Annotate functions in which the caller owns the return value and is |
---|
202 | * responsible for ensuring it is freed. */ |
---|
203 | #define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT |
---|
204 | |
---|
205 | #define OWL_META(key) ((key)|010000) |
---|
206 | /* OWL_CTRL is definied in kepress.c */ |
---|
207 | |
---|
208 | #ifdef HAVE_LIBZEPHYR |
---|
209 | /* libzephyr doesn't use const, so we appease the type system with this kludge. |
---|
210 | * This just casts const char * to char * in a way that doesn't yield a warning |
---|
211 | * from gcc -Wcast-qual. */ |
---|
212 | static inline char *zstr(const char *str) |
---|
213 | { |
---|
214 | union { char *rw; const char *ro; } u; |
---|
215 | u.ro = str; |
---|
216 | return u.rw; |
---|
217 | } |
---|
218 | #endif |
---|
219 | |
---|
220 | /* Convert char *const * into const char *const *. This conversion is safe, |
---|
221 | * and implicit in C++ (conv.qual 4) but for some reason not in C. */ |
---|
222 | static inline const char *const *strs(char *const *pstr) |
---|
223 | { |
---|
224 | return (const char *const *)pstr; |
---|
225 | } |
---|
226 | |
---|
227 | typedef struct _owl_variable { |
---|
228 | char *name; |
---|
229 | int type; /* OWL_VARIABLE_* */ |
---|
230 | void *pval_default; /* for types other and string */ |
---|
231 | int ival_default; /* for types int and bool */ |
---|
232 | const char *validsettings; /* documentation of valid settings */ |
---|
233 | char *summary; /* summary of usage */ |
---|
234 | char *description; /* detailed description */ |
---|
235 | void *val; /* current value */ |
---|
236 | int (*validate_fn)(const struct _owl_variable *v, const void *newval); |
---|
237 | /* returns 1 if newval is valid */ |
---|
238 | int (*set_fn)(struct _owl_variable *v, const void *newval); |
---|
239 | /* sets the variable to a value |
---|
240 | * of the appropriate type. |
---|
241 | * unless documented, this |
---|
242 | * should make a copy. |
---|
243 | * returns 0 on success. */ |
---|
244 | int (*set_fromstring_fn)(struct _owl_variable *v, const char *newval); |
---|
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 | const void *(*get_fn)(const struct _owl_variable *v); |
---|
251 | /* returns a reference to the current value. |
---|
252 | * WARNING: this approach is hard to make |
---|
253 | * thread-safe... */ |
---|
254 | CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val); |
---|
255 | /* converts val to a string; |
---|
256 | * caller must free the result */ |
---|
257 | void (*delete_fn)(struct _owl_variable *v); |
---|
258 | /* frees val as needed */ |
---|
259 | } owl_variable; |
---|
260 | |
---|
261 | typedef struct _owl_input { |
---|
262 | int ch; |
---|
263 | gunichar uch; |
---|
264 | } owl_input; |
---|
265 | |
---|
266 | typedef struct _owl_fmtext { |
---|
267 | GString *buff; |
---|
268 | } owl_fmtext; |
---|
269 | |
---|
270 | typedef struct _owl_dict_el { |
---|
271 | char *k; /* key */ |
---|
272 | void *v; /* value */ |
---|
273 | } owl_dict_el; |
---|
274 | |
---|
275 | typedef struct _owl_dict { |
---|
276 | int size; |
---|
277 | int avail; |
---|
278 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
279 | } owl_dict; |
---|
280 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
281 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
282 | |
---|
283 | typedef struct _owl_context { |
---|
284 | int mode; |
---|
285 | void *data; /* determined by mode */ |
---|
286 | char *keymap; |
---|
287 | owl_window *cursor; |
---|
288 | void (*deactivate_cb)(struct _owl_context*); |
---|
289 | void (*delete_cb)(struct _owl_context*); |
---|
290 | void *cbdata; |
---|
291 | } owl_context; |
---|
292 | |
---|
293 | typedef struct _owl_cmd { /* command */ |
---|
294 | char *name; |
---|
295 | |
---|
296 | char *summary; /* one line summary of command */ |
---|
297 | char *usage; /* usage synopsis */ |
---|
298 | char *description; /* long description of command */ |
---|
299 | |
---|
300 | int validctx; /* bitmask of valid contexts */ |
---|
301 | |
---|
302 | /* we should probably have a type here that says which of |
---|
303 | * the following is valid, and maybe make the below into a union... */ |
---|
304 | |
---|
305 | /* Only one of these may be non-NULL ... */ |
---|
306 | |
---|
307 | char *cmd_aliased_to; /* what this command is aliased to... */ |
---|
308 | |
---|
309 | /* These don't take any context */ |
---|
310 | CALLER_OWN char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); |
---|
311 | /* takes argv and the full command as buff. |
---|
312 | * caller must free return value if !NULL */ |
---|
313 | void (*cmd_v_fn)(void); /* takes no args */ |
---|
314 | void (*cmd_i_fn)(int i); /* takes an int as an arg */ |
---|
315 | |
---|
316 | /* The following also take the active context if it's valid */ |
---|
317 | CALLER_OWN char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); |
---|
318 | /* takes argv and the full command as buff. |
---|
319 | * caller must free return value if !NULL */ |
---|
320 | void (*cmd_ctxv_fn)(void *ctx); /* takes no args */ |
---|
321 | void (*cmd_ctxi_fn)(void *ctx, int i); /* takes an int as an arg */ |
---|
322 | SV *cmd_perl; /* Perl closure that takes a list of args */ |
---|
323 | } owl_cmd; |
---|
324 | |
---|
325 | |
---|
326 | typedef struct _owl_zwrite { |
---|
327 | char *cmd; |
---|
328 | char *zwriteline; |
---|
329 | char *class; |
---|
330 | char *inst; |
---|
331 | char *realm; |
---|
332 | char *opcode; |
---|
333 | char *zsig; |
---|
334 | char *message; |
---|
335 | GPtrArray *recips; |
---|
336 | int cc; |
---|
337 | int noping; |
---|
338 | } owl_zwrite; |
---|
339 | |
---|
340 | typedef struct _owl_pair { |
---|
341 | const char *key; |
---|
342 | char *value; |
---|
343 | } owl_pair; |
---|
344 | |
---|
345 | struct _owl_fmtext_cache; |
---|
346 | |
---|
347 | typedef struct _owl_message { |
---|
348 | int id; |
---|
349 | int direction; |
---|
350 | #ifdef HAVE_LIBZEPHYR |
---|
351 | ZNotice_t notice; |
---|
352 | #endif |
---|
353 | struct _owl_fmtext_cache * fmtext; |
---|
354 | int delete; |
---|
355 | const char *hostname; |
---|
356 | GPtrArray *attributes; /* this is a list of pairs */ |
---|
357 | char *timestr; |
---|
358 | time_t time; |
---|
359 | } owl_message; |
---|
360 | |
---|
361 | #define OWL_FMTEXT_CACHE_SIZE 1000 |
---|
362 | /* We cache the saved fmtexts for the last bunch of messages we |
---|
363 | rendered */ |
---|
364 | typedef struct _owl_fmtext_cache { |
---|
365 | owl_message * message; |
---|
366 | owl_fmtext fmtext; |
---|
367 | } owl_fmtext_cache; |
---|
368 | |
---|
369 | typedef struct _owl_style { |
---|
370 | char *name; |
---|
371 | SV *perlobj; |
---|
372 | } owl_style; |
---|
373 | |
---|
374 | typedef struct _owl_mainwin { |
---|
375 | int curtruncated; |
---|
376 | int lasttruncated; |
---|
377 | int lastdisplayed; |
---|
378 | owl_window *window; |
---|
379 | } owl_mainwin; |
---|
380 | |
---|
381 | typedef struct _owl_editwin owl_editwin; |
---|
382 | typedef struct _owl_editwin_excursion owl_editwin_excursion; |
---|
383 | |
---|
384 | typedef struct _owl_viewwin { |
---|
385 | owl_fmtext fmtext; |
---|
386 | int textlines; |
---|
387 | int topline; |
---|
388 | int rightshift; |
---|
389 | owl_window *window; |
---|
390 | void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); |
---|
391 | void *onclose_hook_data; |
---|
392 | |
---|
393 | gulong sig_resize_id; |
---|
394 | owl_window *content; |
---|
395 | gulong sig_content_redraw_id; |
---|
396 | owl_window *status; |
---|
397 | gulong sig_status_redraw_id; |
---|
398 | owl_window *cmdwin; |
---|
399 | } owl_viewwin; |
---|
400 | |
---|
401 | typedef struct _owl_popwin { |
---|
402 | owl_window *border; |
---|
403 | owl_window *content; |
---|
404 | gulong sig_redraw_id; |
---|
405 | gulong sig_resize_id; |
---|
406 | } owl_popwin; |
---|
407 | |
---|
408 | typedef struct _owl_msgwin { |
---|
409 | char *msg; |
---|
410 | owl_window *window; |
---|
411 | gulong redraw_id; |
---|
412 | } owl_msgwin; |
---|
413 | |
---|
414 | typedef struct _owl_messagelist { |
---|
415 | GPtrArray *list; |
---|
416 | } owl_messagelist; |
---|
417 | |
---|
418 | typedef struct _owl_regex { |
---|
419 | int negate; |
---|
420 | char *string; |
---|
421 | regex_t re; |
---|
422 | } owl_regex; |
---|
423 | |
---|
424 | typedef struct _owl_filterelement { |
---|
425 | int (*match_message)(const struct _owl_filterelement *fe, const owl_message *m); |
---|
426 | /* Append a string representation of the filterelement onto buf*/ |
---|
427 | void (*print_elt)(const struct _owl_filterelement *fe, GString *buf); |
---|
428 | /* Operands for and,or,not*/ |
---|
429 | struct _owl_filterelement *left, *right; |
---|
430 | /* For regex filters*/ |
---|
431 | owl_regex re; |
---|
432 | /* Used by regexes, filter references, and perl */ |
---|
433 | char *field; |
---|
434 | } owl_filterelement; |
---|
435 | |
---|
436 | typedef struct _owl_filter { |
---|
437 | char *name; |
---|
438 | owl_filterelement * root; |
---|
439 | int fgcolor; |
---|
440 | int bgcolor; |
---|
441 | } owl_filter; |
---|
442 | |
---|
443 | typedef struct _owl_view { |
---|
444 | char *name; |
---|
445 | owl_filter *filter; |
---|
446 | owl_messagelist ml; |
---|
447 | const owl_style *style; |
---|
448 | int cachedmsgid; |
---|
449 | } owl_view; |
---|
450 | |
---|
451 | typedef struct _owl_history { |
---|
452 | GQueue hist; |
---|
453 | GList *cur; |
---|
454 | bool partial; |
---|
455 | } owl_history; |
---|
456 | |
---|
457 | typedef struct _owl_mainpanel { |
---|
458 | owl_window *panel; |
---|
459 | owl_window *typwin; |
---|
460 | owl_window *sepwin; |
---|
461 | owl_window *msgwin; |
---|
462 | owl_window *recwin; |
---|
463 | int recwinlines; |
---|
464 | } owl_mainpanel; |
---|
465 | |
---|
466 | typedef struct _owl_keybinding { |
---|
467 | int *keys; /* keypress stack */ |
---|
468 | int len; /* length of stack */ |
---|
469 | int type; /* command or function? */ |
---|
470 | char *desc; /* description (or "*user*") */ |
---|
471 | char *command; /* command, if of type command */ |
---|
472 | void (*function_fn)(void); /* function ptr, if of type function */ |
---|
473 | } owl_keybinding; |
---|
474 | |
---|
475 | typedef struct _owl_keymap { |
---|
476 | char *name; /* name of keymap */ |
---|
477 | char *desc; /* description */ |
---|
478 | GPtrArray *bindings; /* key bindings */ |
---|
479 | const struct _owl_keymap *parent; /* parent */ |
---|
480 | void (*default_fn)(owl_input j); /* default action (takes a keypress) */ |
---|
481 | void (*prealways_fn)(owl_input j); /* always called before a keypress is received */ |
---|
482 | void (*postalways_fn)(owl_input j); /* always called after keypress is processed */ |
---|
483 | } owl_keymap; |
---|
484 | |
---|
485 | typedef struct _owl_keyhandler { |
---|
486 | owl_dict keymaps; /* dictionary of keymaps */ |
---|
487 | const owl_keymap *active; /* currently active keymap */ |
---|
488 | int in_esc; /* escape pressed? */ |
---|
489 | int kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */ |
---|
490 | int kpstackpos; /* location in stack (-1 = none) */ |
---|
491 | } owl_keyhandler; |
---|
492 | |
---|
493 | typedef struct _owl_buddy { |
---|
494 | int proto; |
---|
495 | char *name; |
---|
496 | int isidle; |
---|
497 | int idlesince; |
---|
498 | } owl_buddy; |
---|
499 | |
---|
500 | typedef struct _owl_buddylist { |
---|
501 | GPtrArray *buddies; |
---|
502 | } owl_buddylist; |
---|
503 | |
---|
504 | typedef struct _owl_zbuddylist { |
---|
505 | GPtrArray *zusers; |
---|
506 | } owl_zbuddylist; |
---|
507 | |
---|
508 | typedef struct _owl_errqueue { |
---|
509 | GPtrArray *errlist; |
---|
510 | } owl_errqueue; |
---|
511 | |
---|
512 | typedef struct _owl_colorpair_mgr { |
---|
513 | int next; |
---|
514 | short **pairs; |
---|
515 | bool overflow; |
---|
516 | } owl_colorpair_mgr; |
---|
517 | |
---|
518 | typedef struct _owl_popexec { |
---|
519 | int refcount; |
---|
520 | owl_viewwin *vwin; |
---|
521 | int winactive; |
---|
522 | pid_t pid; /* or 0 if it has terminated */ |
---|
523 | guint io_watch; |
---|
524 | } owl_popexec; |
---|
525 | |
---|
526 | typedef struct _owl_global { |
---|
527 | owl_mainwin mw; |
---|
528 | owl_popwin *pw; |
---|
529 | owl_msgwin msgwin; |
---|
530 | owl_history cmdhist; /* command history */ |
---|
531 | owl_history msghist; /* outgoing message history */ |
---|
532 | owl_keyhandler kh; |
---|
533 | owl_dict filters; |
---|
534 | GList *filterlist; |
---|
535 | GPtrArray *puntlist; |
---|
536 | owl_vardict vars; |
---|
537 | owl_cmddict cmds; |
---|
538 | GList *context_stack; |
---|
539 | owl_errqueue errqueue; |
---|
540 | int lines, cols; |
---|
541 | int curmsg, topmsg; |
---|
542 | int markedmsgid; /* for finding the marked message when it has moved. */ |
---|
543 | int curmsg_vert_offset; |
---|
544 | owl_view current_view; |
---|
545 | owl_messagelist msglist; |
---|
546 | WINDOW *input_pad; |
---|
547 | owl_mainpanel mainpanel; |
---|
548 | gulong typwin_erase_id; |
---|
549 | int rightshift; |
---|
550 | bool resizepending; |
---|
551 | char *homedir; |
---|
552 | char *confdir; |
---|
553 | char *startupfile; |
---|
554 | int direction; |
---|
555 | int haveconfig; |
---|
556 | int config_format; |
---|
557 | owl_editwin *tw; |
---|
558 | owl_viewwin *vw; |
---|
559 | void *perl; |
---|
560 | int debug; |
---|
561 | time_t starttime; |
---|
562 | time_t lastinputtime; |
---|
563 | char *startupargs; |
---|
564 | int nextmsgid; |
---|
565 | owl_colorpair_mgr cpmgr; |
---|
566 | pid_t newmsgproc_pid; |
---|
567 | owl_regex search_re; |
---|
568 | aim_session_t aimsess; |
---|
569 | aim_conn_t bosconn; |
---|
570 | int aim_loggedin; /* true if currently logged into AIM */ |
---|
571 | GSource *aim_event_source; /* where we get our AIM events from */ |
---|
572 | char *aim_screenname; /* currently logged in AIM screen name */ |
---|
573 | char *aim_screenname_for_filters; /* currently logged in AIM screen name */ |
---|
574 | owl_buddylist buddylist; /* list of logged in AIM buddies */ |
---|
575 | GQueue *messagequeue; /* for queueing up aim and other messages */ |
---|
576 | owl_dict styledict; /* global dictionary of available styles */ |
---|
577 | char *response; /* response to the last question asked */ |
---|
578 | int havezephyr; |
---|
579 | int haveaim; |
---|
580 | int ignoreaimlogin; |
---|
581 | owl_zbuddylist zbuddies; |
---|
582 | GList *zaldlist; |
---|
583 | int pseudologin_notify; |
---|
584 | struct termios startup_tio; |
---|
585 | guint aim_nop_timer; |
---|
586 | int load_initial_subs; |
---|
587 | FILE *debug_file; |
---|
588 | char *kill_buffer; |
---|
589 | int interrupt_count; |
---|
590 | GMutex *interrupt_lock; |
---|
591 | } owl_global; |
---|
592 | |
---|
593 | /* globals */ |
---|
594 | extern owl_global g; |
---|
595 | |
---|
596 | #include "owl_prototypes.h" |
---|
597 | |
---|
598 | /* These were missing from the Zephyr includes before Zephyr 3. */ |
---|
599 | #if defined HAVE_LIBZEPHYR && defined ZCONST |
---|
600 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
601 | int ZGetLocations(ZLocations_t *,int *); |
---|
602 | #endif |
---|
603 | |
---|
604 | #endif /* INC_BARNOWL_OWL_H */ |
---|