source: owl.h @ e173507

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