source: owl.h @ b7d13f7

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