source: owl.h @ 79a0e82

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