source: owl.h @ f87c490

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