source: owl.h @ cb78880

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