source: owl.h @ bc08664

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