source: owl.h @ 7d4fbcd

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