source: owl.h @ 2c8d62e

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