source: owl.h @ 37eab7f

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 37eab7f was 37eab7f, checked in by James M. Kretchmar <kretch@mit.edu>, 20 years ago
Added the loopback message type Added the loopwrite command
  • Property mode set to 100644
File size: 13.2 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#if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT)
145#define OWL_ENABLE_ZCRYPT 1
146#endif
147
148#define OWL_META(key) ((key)|0200)
149/* OWL_CTRL is definied in kepress.c */
150
151#define LINE 2048
152
153typedef struct _owl_variable {
154  char *name;
155  int   type;  /* OWL_VARIABLE_* */
156  void *pval_default;  /* for types other and string */
157  int   ival_default;  /* for types int and bool     */
158  char *validsettings;          /* documentation of valid settings */
159  char *summary;                /* summary of usage */
160  char *description;            /* detailed description */
161  void *val;                    /* current value */
162  int  (*validate_fn)(struct _owl_variable *v, void *newval);
163                                /* returns 1 if newval is valid */
164  int  (*set_fn)(struct _owl_variable *v, void *newval); 
165                                /* sets the variable to a value
166                                 * of the appropriate type.
167                                 * unless documented, this
168                                 * should make a copy.
169                                 * returns 0 on success. */
170  int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
171                                /* sets the variable to a value
172                                 * of the appropriate type.
173                                 * unless documented, this
174                                 * should make a copy.
175                                 * returns 0 on success. */
176  void *(*get_fn)(struct _owl_variable *v);
177                                /* returns a reference to the current value.
178                                 * WARNING:  this approach is hard to make
179                                 * thread-safe... */
180  int  (*get_tostring_fn)(struct _owl_variable *v, 
181                          char *buf, int bufsize, void *val); 
182                                /* converts val to a string
183                                 * and puts into buf */
184  void  (*free_fn)(struct _owl_variable *v);
185                                /* frees val as needed */
186} owl_variable;
187
188typedef struct _owl_fmtext {
189  int textlen;
190  char *textbuff;
191  char *fmbuff;
192  char *colorbuff;
193} owl_fmtext;
194
195typedef struct _owl_list {
196  int size;
197  int avail;
198  void **list;
199} owl_list;
200
201typedef struct _owl_dict_el {
202  char *k;                      /* key   */
203  void *v;                      /* value */
204} owl_dict_el;
205
206typedef struct _owl_dict {
207  int size;
208  int avail;
209  owl_dict_el *els;             /* invariant: sorted by k */
210} owl_dict;
211typedef owl_dict owl_vardict;   /* dict of variables */
212typedef owl_dict owl_cmddict;   /* dict of commands */
213
214typedef struct _owl_context {
215  int   mode;
216  void *data;           /* determined by mode */
217} owl_context;
218
219typedef struct _owl_cmd {       /* command */
220  char *name;
221
222  char *summary;                /* one line summary of command */
223  char *usage;                  /* usage synopsis */
224  char *description;            /* long description of command */
225
226  int validctx;                 /* bitmask of valid contexts */
227
228  /* we should probably have a type here that says which of
229   * the following is valid, and maybe make the below into a union... */
230
231  /* Only one of these may be non-NULL ... */
232
233  char *cmd_aliased_to;         /* what this command is aliased to... */
234 
235  /* These don't take any context */
236  char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
237                                /* takes argv and the full command as buff.
238                                 * caller must free return value if !NULL */
239  void (*cmd_v_fn)(void);       /* takes no args */
240  void (*cmd_i_fn)(int i);      /* takes an int as an arg */
241
242  /* The following also take the active context if it's valid */
243  char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
244                                /* takes argv and the full command as buff.
245                                 * caller must free return value if !NULL */
246  void (*cmd_ctxv_fn)(void *ctx);               /* takes no args */
247  void (*cmd_ctxi_fn)(void *ctx, int i);        /* takes an int as an arg */
248} owl_cmd;
249
250
251typedef struct _owl_zwrite {
252  char *class;
253  char *inst;
254  char *realm;
255  char *opcode;
256  char *zsig;
257  char *message;
258  owl_list recips;
259  int cc;
260  int noping;
261} owl_zwrite;
262
263typedef struct _owl_pair {
264  void *key;
265  void *value;
266} owl_pair;
267
268typedef struct _owl_message {
269  int id;
270  int type;
271  int direction;
272#ifdef HAVE_LIBZEPHYR
273  ZNotice_t notice;
274#endif
275  owl_fmtext fmtext;              /* this is now only a CACHED copy */
276  int invalid_format;             /* indicates whether fmtext needs to be regenerated */
277  int delete;
278  char hostname[MAXHOSTNAMELEN+1];
279  owl_list attributes;            /* this is a list of pairs */
280  char *time;
281  char *zwriteline;
282} owl_message;
283
284typedef struct _owl_style {
285  char *name;
286  char *description;
287  int type;
288  char *perlfuncname;
289  void (*formatfunc) (owl_fmtext *fm, owl_message *m);
290} owl_style;
291
292typedef struct _owl_mainwin {
293  int curtruncated;
294  int lasttruncated;
295  int lastdisplayed;
296} owl_mainwin;
297
298typedef struct _owl_viewwin {
299  owl_fmtext fmtext;
300  int textlines;
301  int topline;
302  int rightshift;
303  int winlines, wincols;
304  WINDOW *curswin;
305} owl_viewwin;
306 
307typedef struct _owl_popwin {
308  WINDOW *borderwin;
309  WINDOW *popwin;
310  int lines;
311  int cols;
312  int active;
313  int needsfirstrefresh;
314  void (*handler) (int ch);
315} owl_popwin;
316
317typedef struct _owl_messagelist {
318  owl_list list;
319} owl_messagelist;
320
321typedef struct _owl_regex {
322  int negate;
323  char *string;
324  regex_t re;
325} owl_regex;
326
327typedef struct _owl_filterelement {
328  int type;
329  char *field;
330  owl_regex re;
331} owl_filterelement;
332
333typedef struct _owl_filter {
334  char *name;
335  int polarity;
336  owl_list fes; /* filterelements */
337  int color;
338  int cachedmsgid;  /* cached msgid: should move into view eventually */
339} owl_filter;
340
341typedef struct _owl_view {
342  char *name;
343  owl_filter *filter;
344  owl_messagelist ml;
345  owl_style *style;
346} owl_view;
347
348typedef struct _owl_history {
349  owl_list hist;
350  int cur;
351  int touched;
352  int partial;
353} owl_history;
354
355typedef struct _owl_editwin {
356  char *buff;
357  owl_history *hist;
358  int bufflen;
359  int allocated;
360  int buffx, buffy;
361  int topline;
362  int winlines, wincols, fillcol, wrapcol;
363  WINDOW *curswin;
364  int style;
365  int lock;
366  int dotsend;
367  int echochar;
368} owl_editwin;
369
370typedef struct _owl_keybinding {
371  int  *j;                      /* keypress stack (0-terminated) */ 
372  int   type;                   /* command or function? */
373  char *desc;                   /* description (or "*user*") */
374  char *command;                /* command, if of type command */
375  void (*function_fn)(void);    /* function ptr, if of type function */
376} owl_keybinding;
377
378typedef struct _owl_keymap {
379  char     *name;               /* name of keymap */
380  char     *desc;               /* description */
381  owl_list  bindings;           /* key bindings */
382  struct _owl_keymap *submap;   /* submap */
383  void (*default_fn)(int j);    /* default action (takes a keypress) */
384  void (*prealways_fn)(int j);  /* always called before a keypress is received */
385  void (*postalways_fn)(int j); /* always called after keypress is processed */
386} owl_keymap;
387
388typedef struct _owl_keyhandler {
389  owl_dict  keymaps;            /* dictionary of keymaps */
390  owl_keymap *active;           /* currently active keymap */
391  int       in_esc;             /* escape pressed? */
392  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
393  int       kpstackpos;         /* location in stack (-1 = none) */
394} owl_keyhandler;
395
396typedef struct _owl_buddy {
397  int proto;
398  char *name;
399  int isidle;
400  int idlesince;
401} owl_buddy;
402
403typedef struct _owl_buddylist {
404  owl_list buddies;
405} owl_buddylist;
406
407typedef struct _owl_timer {
408  int direction;
409  time_t starttime;
410  int start;
411} owl_timer;
412
413typedef struct _owl_errqueue {
414  owl_list errlist;
415} owl_errqueue;
416
417typedef struct _owl_global {
418  owl_mainwin mw;
419  owl_popwin pw;
420  owl_history cmdhist;          /* command history */
421  owl_history msghist;          /* outgoing message history */
422  owl_keyhandler kh;
423  owl_list filterlist;
424  owl_list puntlist;
425  owl_vardict vars;
426  owl_cmddict cmds;
427  owl_context ctx;
428  owl_errqueue errqueue;
429  int lines, cols;
430  int curmsg, topmsg;
431  int curmsg_vert_offset;
432  owl_view current_view;
433  owl_messagelist msglist;
434  WINDOW *recwin, *sepwin, *msgwin, *typwin;
435  int needrefresh;
436  int rightshift;
437  int resizepending;
438  int recwinlines;
439  int typwinactive;
440  char *thishost;
441  char *homedir;
442  int direction;
443  int zaway;
444  char *cur_zaway_msg;
445  int haveconfig;
446  int config_format;
447  char *buffercommand;
448  owl_editwin tw;
449  owl_viewwin vw;
450  void *perl;
451  int debug;
452  int starttime;
453  char *startupargs;
454  int userclue;
455  int nextmsgid;
456  int hascolors;
457  int colorpairs;
458  int searchactive;
459  int newmsgproc_pid;
460  int malloced, freed;
461  char *searchstring;
462  owl_filterelement fe_true;
463  owl_filterelement fe_false;
464  owl_filterelement fe_null;
465  aim_session_t aimsess;
466  aim_conn_t bosconn;
467  owl_timer aim_noop_timer;
468  owl_timer aim_ignorelogin_timer;
469  owl_timer aim_buddyinfo_timer;
470  int aim_loggedin;         /* true if currently logged into AIM */
471  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
472  char *aim_screenname;     /* currently logged in AIM screen name */
473  owl_buddylist buddylist;  /* list of logged in AIM buddies */
474  owl_list messagequeue;    /* for queueing up aim and other messages */
475  owl_dict styledict;       /* global dictionary of available styles */
476  char *response;           /* response to the last question asked */
477  int havezephyr;
478  int haveaim;
479} owl_global;
480
481/* globals */
482extern owl_global g;
483
484#include "owl_prototypes.h"
485
486/* these are missing from the zephyr includes for some reason */
487#ifdef HAVE_LIBZEPHYR
488int ZGetSubscriptions(ZSubscription_t *, int *);
489int ZGetLocations(ZLocations_t *,int *);
490#endif
491
492#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.