source: owl.h @ f562355

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