source: owl.h @ 25dd31a

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