source: owl.h @ cf83b7a

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