source: owl.h @ 507d5aa

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