source: owl.h @ dff8d8a

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