source: owl.h @ db2dd3d

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