source: owl.h @ d09e5a1

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