source: owl.h @ 6bf73ce

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