source: owl.h @ 9cd7e6a

owl
Last change on this file since 9cd7e6a was c34d788, checked in by James M. Kretchmar <kretch@mit.edu>, 15 years ago
versions to 2.1.12 to prepare for release
  • Property mode set to 100644
File size: 15.5 KB
Line 
1/* Copyright (c) 2002,2003,2004,2009 James M. Kretchmar
2 *
3 * This file is part of Owl.
4 *
5 * Owl is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * Owl is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Owl.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 * ---------------------------------------------------------------
19 *
20 * As of Owl version 2.1.12 there are patches contributed by
21 * developers of the the branched BarnOwl project, Copyright (c)
22 * 2006-2008 The BarnOwl Developers. All rights reserved.
23 */
24
25#ifndef INC_OWL_H
26#define INC_OWL_H
27
28#include <curses.h>
29#include <sys/param.h>
30#include <EXTERN.h>
31#include <netdb.h>
32#include <regex.h>
33#include <time.h>
34#include <signal.h>
35#include <termios.h>
36#include <libfaim/aim.h>
37#include "config.h"
38#ifdef HAVE_LIBZEPHYR
39#include <zephyr/zephyr.h>
40#endif
41#ifdef HAVE_COM_ERR_H
42#include <com_err.h>
43#endif
44
45static const char owl_h_fileIdent[] = "$Id$";
46
47#define OWL_VERSION         2.1.12
48#define OWL_VERSION_STRING "2.1.12"
49
50/* Feature that is being tested to redirect stderr through a pipe.
51 * There may still be some portability problems with this. */
52#define OWL_STDERR_REDIR 1
53
54#define OWL_DEBUG 0
55#define OWL_DEBUG_FILE "/var/tmp/owldebug"
56
57#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
58#define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
59
60#define OWL_FMTEXT_ATTR_NONE      0
61#define OWL_FMTEXT_ATTR_BOLD      1
62#define OWL_FMTEXT_ATTR_REVERSE   2
63#define OWL_FMTEXT_ATTR_UNDERLINE 4
64
65#define OWL_COLOR_BLACK     0
66#define OWL_COLOR_RED       1
67#define OWL_COLOR_GREEN     2
68#define OWL_COLOR_YELLOW    3
69#define OWL_COLOR_BLUE      4
70#define OWL_COLOR_MAGENTA   5
71#define OWL_COLOR_CYAN      6
72#define OWL_COLOR_WHITE     7
73#define OWL_COLOR_DEFAULT   8
74
75#define OWL_EDITWIN_STYLE_MULTILINE 0
76#define OWL_EDITWIN_STYLE_ONELINE   1
77
78#define OWL_PROTOCOL_ZEPHYR         0
79#define OWL_PROTOCOL_AIM            1
80#define OWL_PROTOCOL_JABBER         2
81#define OWL_PROTOCOL_ICQ            3
82#define OWL_PROTOCOL_YAHOO          4
83#define OWL_PROTOCOL_MSN            5
84
85#define OWL_MESSAGE_TYPE_ADMIN      0
86#define OWL_MESSAGE_TYPE_GENERIC    1
87#define OWL_MESSAGE_TYPE_ZEPHYR     2
88#define OWL_MESSAGE_TYPE_AIM        3
89#define OWL_MESSAGE_TYPE_JABBER     4
90#define OWL_MESSAGE_TYPE_ICQ        5
91#define OWL_MESSAGE_TYPE_YAHOO      6
92#define OWL_MESSAGE_TYPE_MSN        7
93#define OWL_MESSAGE_TYPE_LOOPBACK   8
94
95#define OWL_MESSAGE_DIRECTION_NONE  0
96#define OWL_MESSAGE_DIRECTION_IN    1
97#define OWL_MESSAGE_DIRECTION_OUT   2
98
99#define OWL_MUX_READ   1
100#define OWL_MUX_WRITE  2
101#define OWL_MUX_EXCEPT 4
102
103#define OWL_DIRECTION_NONE      0
104#define OWL_DIRECTION_DOWNWARDS 1
105#define OWL_DIRECTION_UPWARDS   2
106
107#define OWL_LOGGING_DIRECTION_BOTH 0
108#define OWL_LOGGING_DIRECTION_IN   1
109#define OWL_LOGGING_DIRECTION_OUT  2
110
111#define OWL_SCROLLMODE_NORMAL      0
112#define OWL_SCROLLMODE_TOP         1
113#define OWL_SCROLLMODE_NEARTOP     2
114#define OWL_SCROLLMODE_CENTER      3
115#define OWL_SCROLLMODE_PAGED       4
116#define OWL_SCROLLMODE_PAGEDCENTER 5
117
118#define OWL_STYLE_TYPE_INTERNAL  0
119#define OWL_STYLE_TYPE_PERL      1
120
121#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
122#define OWL_TABSTR        "   "
123#define OWL_MSGTAB            7
124#define OWL_TYPWIN_SIZE       8
125#define OWL_HISTORYSIZE       50
126
127/* Indicate current state, as well as what is allowed */
128#define OWL_CTX_ANY          0xffff
129/* Only one of these may be active at a time... */
130#define OWL_CTX_MODE_BITS    0x000f
131#define OWL_CTX_STARTUP      0x0001
132#define OWL_CTX_READCONFIG   0x0002
133#define OWL_CTX_INTERACTIVE  0x0004
134/* Only one of these may be active at a time... */
135#define OWL_CTX_ACTIVE_BITS  0xfff0
136#define OWL_CTX_POPWIN       0x00f0
137#define OWL_CTX_POPLESS      0x0010
138#define OWL_CTX_RECWIN       0x0f00
139#define OWL_CTX_RECV         0x0100
140#define OWL_CTX_TYPWIN       0xf000
141#define OWL_CTX_EDIT         0x7000
142#define OWL_CTX_EDITLINE     0x1000
143#define OWL_CTX_EDITMULTI    0x2000
144#define OWL_CTX_EDITRESPONSE 0x4000
145
146#define OWL_USERCLUE_NONE       0
147#define OWL_USERCLUE_CLASSES    1
148#define OWL_USERCLUE_FOOBAR     2
149#define OWL_USERCLUE_BAZ        4
150
151#define OWL_WEBBROWSER_NONE     0
152#define OWL_WEBBROWSER_NETSCAPE 1
153#define OWL_WEBBROWSER_GALEON   2
154#define OWL_WEBBROWSER_OPERA    3
155
156#define OWL_VARIABLE_OTHER      0
157#define OWL_VARIABLE_INT        1
158#define OWL_VARIABLE_BOOL       2
159#define OWL_VARIABLE_STRING     3
160
161#define OWL_FILTER_MAX_DEPTH    300
162
163#define OWL_KEYMAP_MAXSTACK     20
164
165#define OWL_KEYBINDING_COMMAND  1   /* command string */
166#define OWL_KEYBINDING_FUNCTION 2   /* function taking no args */
167
168#define OWL_DEFAULT_ZAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
169#define OWL_DEFAULT_AAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
170
171#define OWL_INCLUDE_REG_TESTS   1  /* whether to build in regression tests */
172
173#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
174
175#define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr"
176#define OWL_WEBZEPHYR_CLASS     "webzephyr"
177#define OWL_WEBZEPHYR_OPCODE    "webzephyr"
178
179#define OWL_REGEX_QUOTECHARS    "+*.?[]^\\${}()"
180#define OWL_REGEX_QUOTEWITH     "\\"
181
182#if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT)
183#define OWL_ENABLE_ZCRYPT 1
184#endif
185
186#define OWL_META(key) ((key)|0200)
187/* OWL_CTRL is definied in kepress.c */
188
189#define LINE 2048
190
191typedef struct _owl_variable {
192  char *name;
193  int   type;  /* OWL_VARIABLE_* */
194  void *pval_default;  /* for types other and string */
195  int   ival_default;  /* for types int and bool     */
196  char *validsettings;          /* documentation of valid settings */
197  char *summary;                /* summary of usage */
198  char *description;            /* detailed description */
199  void *val;                    /* current value */
200  int  (*validate_fn)(struct _owl_variable *v, void *newval);
201                                /* returns 1 if newval is valid */
202  int  (*set_fn)(struct _owl_variable *v, void *newval); 
203                                /* sets the variable to a value
204                                 * of the appropriate type.
205                                 * unless documented, this
206                                 * should make a copy.
207                                 * returns 0 on success. */
208  int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
209                                /* sets the variable to a value
210                                 * of the appropriate type.
211                                 * unless documented, this
212                                 * should make a copy.
213                                 * returns 0 on success. */
214  void *(*get_fn)(struct _owl_variable *v);
215                                /* returns a reference to the current value.
216                                 * WARNING:  this approach is hard to make
217                                 * thread-safe... */
218  int  (*get_tostring_fn)(struct _owl_variable *v, 
219                          char *buf, int bufsize, void *val); 
220                                /* converts val to a string
221                                 * and puts into buf */
222  void  (*free_fn)(struct _owl_variable *v);
223                                /* frees val as needed */
224} owl_variable;
225
226typedef struct _owl_fmtext {
227  int textlen;
228  char *textbuff;
229  char *fmbuff;
230  char *colorbuff;
231} owl_fmtext;
232
233typedef struct _owl_list {
234  int size;
235  int avail;
236  void **list;
237} owl_list;
238
239typedef struct _owl_dict_el {
240  char *k;                      /* key   */
241  void *v;                      /* value */
242} owl_dict_el;
243
244typedef struct _owl_dict {
245  int size;
246  int avail;
247  owl_dict_el *els;             /* invariant: sorted by k */
248} owl_dict;
249typedef owl_dict owl_vardict;   /* dict of variables */
250typedef owl_dict owl_cmddict;   /* dict of commands */
251
252typedef struct _owl_context {
253  int   mode;
254  void *data;           /* determined by mode */
255} owl_context;
256
257typedef struct _owl_cmd {       /* command */
258  char *name;
259
260  char *summary;                /* one line summary of command */
261  char *usage;                  /* usage synopsis */
262  char *description;            /* long description of command */
263
264  int validctx;                 /* bitmask of valid contexts */
265
266  /* we should probably have a type here that says which of
267   * the following is valid, and maybe make the below into a union... */
268
269  /* Only one of these may be non-NULL ... */
270
271  char *cmd_aliased_to;         /* what this command is aliased to... */
272 
273  /* These don't take any context */
274  char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
275                                /* takes argv and the full command as buff.
276                                 * caller must free return value if !NULL */
277  void (*cmd_v_fn)(void);       /* takes no args */
278  void (*cmd_i_fn)(int i);      /* takes an int as an arg */
279
280  /* The following also take the active context if it's valid */
281  char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
282                                /* takes argv and the full command as buff.
283                                 * caller must free return value if !NULL */
284  void (*cmd_ctxv_fn)(void *ctx);               /* takes no args */
285  void (*cmd_ctxi_fn)(void *ctx, int i);        /* takes an int as an arg */
286} owl_cmd;
287
288
289typedef struct _owl_zwrite {
290  char *class;
291  char *inst;
292  char *realm;
293  char *opcode;
294  char *zsig;
295  char *message;
296  owl_list recips;
297  int cc;
298  int noping;
299} owl_zwrite;
300
301typedef struct _owl_pair {
302  void *key;
303  void *value;
304} owl_pair;
305
306typedef struct _owl_message {
307  int id;
308  int type;
309  int direction;
310#ifdef HAVE_LIBZEPHYR
311  ZNotice_t notice;
312#endif
313  owl_fmtext fmtext;              /* this is now only a CACHED copy */
314  int invalid_format;             /* indicates whether fmtext needs to be regenerated */
315  int delete;
316  char *hostname;
317  owl_list attributes;            /* this is a list of pairs */
318  char *timestr;
319  time_t time;
320  char *zwriteline;
321} owl_message;
322
323typedef struct _owl_style {
324  char *name;
325  char *description;
326  int type;
327  char *perlfuncname;
328  void (*formatfunc) (owl_fmtext *fm, owl_message *m);
329} owl_style;
330
331typedef struct _owl_mainwin {
332  int curtruncated;
333  int lasttruncated;
334  int lastdisplayed;
335} owl_mainwin;
336
337typedef struct _owl_viewwin {
338  owl_fmtext fmtext;
339  int textlines;
340  int topline;
341  int rightshift;
342  int winlines, wincols;
343  WINDOW *curswin;
344  void (*onclose_hook) (struct _owl_viewwin *vwin, void *data);
345  void *onclose_hook_data;
346} owl_viewwin;
347 
348typedef struct _owl_popwin {
349  WINDOW *borderwin;
350  WINDOW *popwin;
351  int lines;
352  int cols;
353  int active;
354  int needsfirstrefresh;
355  void (*handler) (int ch);
356} owl_popwin;
357
358typedef struct _owl_dispatch {
359  int fd;                                 /* FD to watch for dispatch. */
360  int needs_gc;
361  void (*cfunc)(struct _owl_dispatch*);   /* C function to dispatch to. */
362  void (*destroy)(struct _owl_dispatch*); /* Destructor */
363  void *data;
364} owl_dispatch;
365
366typedef struct _owl_popexec {
367  int refcount;
368  owl_viewwin *vwin;
369  int winactive;
370  int pid;                      /* or 0 if it has terminated */
371  owl_dispatch dispatch;
372} owl_popexec;
373
374typedef struct _owl_messagelist {
375  owl_list list;
376} owl_messagelist;
377
378typedef struct _owl_regex {
379  int negate;
380  char *string;
381  regex_t re;
382} owl_regex;
383
384typedef struct _owl_filterelement {
385  int type;
386  char *field;
387  owl_regex re;
388  char *filtername;  /* for maching on another filter */
389} owl_filterelement;
390
391typedef struct _owl_filter {
392  char *name;
393  int polarity;
394  owl_list fes; /* filterelements */
395  int color;
396  int cachedmsgid;  /* cached msgid: should move into view eventually */
397} owl_filter;
398
399typedef struct _owl_view {
400  char *name;
401  owl_filter *filter;
402  owl_messagelist ml;
403  owl_style *style;
404} owl_view;
405
406typedef struct _owl_history {
407  owl_list hist;
408  int cur;
409  int touched;
410  int partial;
411  int repeats;
412} owl_history;
413
414typedef struct _owl_editwin {
415  char *buff;
416  owl_history *hist;
417  int bufflen;
418  int allocated;
419  int buffx, buffy;
420  int topline;
421  int winlines, wincols, fillcol, wrapcol;
422  WINDOW *curswin;
423  int style;
424  int lock;
425  int dotsend;
426  int echochar;
427} owl_editwin;
428
429typedef struct _owl_keybinding {
430  int  *j;                      /* keypress stack (0-terminated) */ 
431  int   type;                   /* command or function? */
432  char *desc;                   /* description (or "*user*") */
433  char *command;                /* command, if of type command */
434  void (*function_fn)(void);    /* function ptr, if of type function */
435} owl_keybinding;
436
437typedef struct _owl_keymap {
438  char     *name;               /* name of keymap */
439  char     *desc;               /* description */
440  owl_list  bindings;           /* key bindings */
441  struct _owl_keymap *submap;   /* submap */
442  void (*default_fn)(int j);    /* default action (takes a keypress) */
443  void (*prealways_fn)(int j);  /* always called before a keypress is received */
444  void (*postalways_fn)(int j); /* always called after keypress is processed */
445} owl_keymap;
446
447typedef struct _owl_keyhandler {
448  owl_dict  keymaps;            /* dictionary of keymaps */
449  owl_keymap *active;           /* currently active keymap */
450  int       in_esc;             /* escape pressed? */
451  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
452  int       kpstackpos;         /* location in stack (-1 = none) */
453} owl_keyhandler;
454
455typedef struct _owl_buddy {
456  int proto;
457  char *name;
458  int isidle;
459  int idlesince;
460} owl_buddy;
461
462typedef struct _owl_buddylist {
463  owl_list buddies;
464} owl_buddylist;
465
466typedef struct _owl_zbuddylist {
467  owl_list zusers;
468} owl_zbuddylist;
469
470typedef struct _owl_timer {
471  int direction;
472  time_t starttime;
473  int start;
474} owl_timer;
475
476typedef struct _owl_errqueue {
477  owl_list errlist;
478} owl_errqueue;
479
480typedef struct _owl_global {
481  owl_mainwin mw;
482  owl_popwin pw;
483  owl_history cmdhist;          /* command history */
484  owl_history msghist;          /* outgoing message history */
485  owl_keyhandler kh;
486  owl_list filterlist;
487  owl_list puntlist;
488  owl_vardict vars;
489  owl_cmddict cmds;
490  owl_context ctx;
491  owl_errqueue errqueue;
492  int lines, cols;
493  int curmsg, topmsg;
494  int curmsg_vert_offset;
495  owl_view current_view;
496  owl_messagelist msglist;
497  WINDOW *recwin, *sepwin, *msgwin, *typwin;
498  int needrefresh;
499  int rightshift;
500  int resizepending;
501  int recwinlines;
502  int typwinactive;
503  char *thishost;
504  char *homedir;
505  int direction;
506  int zaway;
507  char *cur_zaway_msg;
508  int haveconfig;
509  int config_format;
510  char *buffercommand;
511  owl_editwin tw;
512  owl_viewwin vw;
513  void *perl;
514  int debug;
515  int starttime;
516  char *startupargs;
517  int userclue;
518  int nextmsgid;
519  int hascolors;
520  int colorpairs;
521  int searchactive;
522  int newmsgproc_pid;
523  int malloced, freed;
524  char *searchstring;
525  owl_filterelement fe_true;
526  owl_filterelement fe_false;
527  owl_filterelement fe_null;
528  aim_session_t aimsess;
529  aim_conn_t bosconn;
530  owl_timer aim_noop_timer;
531  owl_timer aim_ignorelogin_timer;
532  owl_timer aim_buddyinfo_timer;
533  int aim_loggedin;         /* true if currently logged into AIM */
534  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
535  char *aim_screenname;     /* currently logged in AIM screen name */
536  owl_buddylist buddylist;  /* list of logged in AIM buddies */
537  owl_list messagequeue;    /* for queueing up aim and other messages */
538  owl_dict styledict;       /* global dictionary of available styles */
539  char *response;           /* response to the last question asked */
540  int havezephyr;
541  int haveaim;
542  int got_err_signal;       /* 1 if we got an unexpected signal */
543  siginfo_t err_signal_info;
544  owl_zbuddylist zbuddies;
545  owl_timer zephyr_buddycheck_timer;
546  struct termios startup_tio;
547  owl_list dispatchlist;
548} owl_global;
549
550/* globals */
551extern owl_global g;
552
553#include "owl_prototypes.h"
554
555/* these are missing from the zephyr includes for some reason */
556#ifdef HAVE_LIBZEPHYR
557int ZGetSubscriptions(ZSubscription_t *, int *);
558int ZGetLocations(ZLocations_t *,int *);
559#endif
560
561#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.