source: owl.h @ f933403

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