source: owl.h @ 5ca5f8e

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 5ca5f8e was 5ca5f8e, checked in by James M. Kretchmar <kretch@mit.edu>, 20 years ago
Added licence
  • Property mode set to 100644
File size: 15.9 KB
Line 
1/*  Copyright (c) 2004 James Kretchmar. All rights reserved.
2 *
3 *  Redistribution and use in source and binary forms, with or without
4 *  modification, are permitted provided that the following conditions are
5 *  met:
6 * 
7 *    * Redistributions of source code must retain the above copyright
8 *      notice, this list of conditions and the following disclaimer.
9 * 
10 *    * Redistributions in binary form must reproduce the above copyright
11 *      notice, this list of conditions and the following disclaimer in
12 *      the documentation and/or other materials provided with the
13 *      distribution.
14 * 
15 *    * Redistributions in any form must be accompanied by information on
16 *      how to obtain complete source code for the Owl software and any
17 *      accompanying software that uses the Owl software. The source code
18 *      must either be included in the distribution or be available for no
19 *      more than the cost of distribution plus a nominal fee, and must be
20 *      freely redistributable under reasonable conditions. For an
21 *      executable file, complete source code means the source code for
22 *      all modules it contains. It does not include source code for
23 *      modules or files that typically accompany the major components of
24 *      the operating system on which the executable file runs.
25 * 
26 *
27 *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28 *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29 *  WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
30 *  NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
31 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
34 *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35 *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
36 *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
37 *  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifndef INC_OWL_H
41#define INC_OWL_H
42
43#include <curses.h>
44#include <sys/param.h>
45#include <EXTERN.h>
46#include <netdb.h>
47#include <regex.h>
48#include <time.h>
49#include <signal.h>
50#include <libfaim/aim.h>
51#include "config.h"
52#ifdef HAVE_LIBZEPHYR
53#include <zephyr/zephyr.h>
54#endif
55#ifdef HAVE_COM_ERR_H
56#include <com_err.h>
57#endif
58
59static const char owl_h_fileIdent[] = "$Id$";
60
61#define OWL_VERSION         2.1.5-pre-1
62#define OWL_VERSION_STRING "2.1.5-pre-1"
63
64/* Feature that is being tested to redirect stderr through a pipe.
65 * There may still be some portability problems with this. */
66#define OWL_STDERR_REDIR 1
67
68#define OWL_DEBUG 0
69#define OWL_DEBUG_FILE "/var/tmp/owldebug"
70
71#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
72#define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
73
74#define OWL_FMTEXT_ATTR_NONE      0
75#define OWL_FMTEXT_ATTR_BOLD      1
76#define OWL_FMTEXT_ATTR_REVERSE   2
77#define OWL_FMTEXT_ATTR_UNDERLINE 4
78
79#define OWL_COLOR_BLACK     0
80#define OWL_COLOR_RED       1
81#define OWL_COLOR_GREEN     2
82#define OWL_COLOR_YELLOW    3
83#define OWL_COLOR_BLUE      4
84#define OWL_COLOR_MAGENTA   5
85#define OWL_COLOR_CYAN      6
86#define OWL_COLOR_WHITE     7
87#define OWL_COLOR_DEFAULT   8
88
89#define OWL_EDITWIN_STYLE_MULTILINE 0
90#define OWL_EDITWIN_STYLE_ONELINE   1
91
92#define OWL_PROTOCOL_ZEPHYR         0
93#define OWL_PROTOCOL_AIM            1
94#define OWL_PROTOCOL_JABBER         2
95#define OWL_PROTOCOL_ICQ            3
96#define OWL_PROTOCOL_YAHOO          4
97#define OWL_PROTOCOL_MSN            5
98
99#define OWL_MESSAGE_TYPE_ADMIN      0
100#define OWL_MESSAGE_TYPE_GENERIC    1
101#define OWL_MESSAGE_TYPE_ZEPHYR     2
102#define OWL_MESSAGE_TYPE_AIM        3
103#define OWL_MESSAGE_TYPE_JABBER     4
104#define OWL_MESSAGE_TYPE_ICQ        5
105#define OWL_MESSAGE_TYPE_YAHOO      6
106#define OWL_MESSAGE_TYPE_MSN        7
107#define OWL_MESSAGE_TYPE_LOOPBACK   8
108
109#define OWL_MESSAGE_DIRECTION_NONE  0
110#define OWL_MESSAGE_DIRECTION_IN    1
111#define OWL_MESSAGE_DIRECTION_OUT   2
112
113#define OWL_DIRECTION_NONE      0
114#define OWL_DIRECTION_DOWNWARDS 1
115#define OWL_DIRECTION_UPWARDS   2
116
117#define OWL_LOGGING_DIRECTION_BOTH 0
118#define OWL_LOGGING_DIRECTION_IN   1
119#define OWL_LOGGING_DIRECTION_OUT  2
120
121#define OWL_SCROLLMODE_NORMAL      0
122#define OWL_SCROLLMODE_TOP         1
123#define OWL_SCROLLMODE_NEARTOP     2
124#define OWL_SCROLLMODE_CENTER      3
125#define OWL_SCROLLMODE_PAGED       4
126#define OWL_SCROLLMODE_PAGEDCENTER 5
127
128#define OWL_STYLE_TYPE_INTERNAL  0
129#define OWL_STYLE_TYPE_PERL      1
130
131#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
132#define OWL_TABSTR        "   "
133#define OWL_MSGTAB            7
134#define OWL_TYPWIN_SIZE       8
135#define OWL_HISTORYSIZE       50
136
137/* Indicate current state, as well as what is allowed */
138#define OWL_CTX_ANY          0xffff
139/* Only one of these may be active at a time... */
140#define OWL_CTX_MODE_BITS    0x000f
141#define OWL_CTX_STARTUP      0x0001
142#define OWL_CTX_READCONFIG   0x0002
143#define OWL_CTX_INTERACTIVE  0x0004
144/* Only one of these may be active at a time... */
145#define OWL_CTX_ACTIVE_BITS  0xfff0
146#define OWL_CTX_POPWIN       0x00f0
147#define OWL_CTX_POPLESS      0x0010
148#define OWL_CTX_RECWIN       0x0f00
149#define OWL_CTX_RECV         0x0100
150#define OWL_CTX_TYPWIN       0xf000
151#define OWL_CTX_EDIT         0x7000
152#define OWL_CTX_EDITLINE     0x1000
153#define OWL_CTX_EDITMULTI    0x2000
154#define OWL_CTX_EDITRESPONSE 0x4000
155
156#define OWL_USERCLUE_NONE       0
157#define OWL_USERCLUE_CLASSES    1
158#define OWL_USERCLUE_FOOBAR     2
159#define OWL_USERCLUE_BAZ        4
160
161#define OWL_WEBBROWSER_NONE     0
162#define OWL_WEBBROWSER_NETSCAPE 1
163#define OWL_WEBBROWSER_GALEON   2
164#define OWL_WEBBROWSER_OPERA    3
165
166#define OWL_VARIABLE_OTHER      0
167#define OWL_VARIABLE_INT        1
168#define OWL_VARIABLE_BOOL       2
169#define OWL_VARIABLE_STRING     3
170
171#define OWL_FILTER_MAX_DEPTH    300
172
173#define OWL_KEYMAP_MAXSTACK     20
174
175#define OWL_KEYBINDING_COMMAND  1   /* command string */
176#define OWL_KEYBINDING_FUNCTION 2   /* function taking no args */
177
178#define OWL_DEFAULT_ZAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
179#define OWL_DEFAULT_AAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
180
181#define OWL_INCLUDE_REG_TESTS   1  /* whether to build in regression tests */
182
183#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
184
185#define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr"
186#define OWL_WEBZEPHYR_CLASS     "webzephyr"
187#define OWL_WEBZEPHYR_OPCODE    "webzephyr"
188
189#define OWL_REGEX_QUOTECHARS    "+*.?[]^\\"
190#define OWL_REGEX_QUOTEWITH     "\\"
191
192#if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT)
193#define OWL_ENABLE_ZCRYPT 1
194#endif
195
196#define OWL_META(key) ((key)|0200)
197/* OWL_CTRL is definied in kepress.c */
198
199#define LINE 2048
200
201typedef struct _owl_variable {
202  char *name;
203  int   type;  /* OWL_VARIABLE_* */
204  void *pval_default;  /* for types other and string */
205  int   ival_default;  /* for types int and bool     */
206  char *validsettings;          /* documentation of valid settings */
207  char *summary;                /* summary of usage */
208  char *description;            /* detailed description */
209  void *val;                    /* current value */
210  int  (*validate_fn)(struct _owl_variable *v, void *newval);
211                                /* returns 1 if newval is valid */
212  int  (*set_fn)(struct _owl_variable *v, void *newval); 
213                                /* sets the variable to a value
214                                 * of the appropriate type.
215                                 * unless documented, this
216                                 * should make a copy.
217                                 * returns 0 on success. */
218  int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
219                                /* sets the variable to a value
220                                 * of the appropriate type.
221                                 * unless documented, this
222                                 * should make a copy.
223                                 * returns 0 on success. */
224  void *(*get_fn)(struct _owl_variable *v);
225                                /* returns a reference to the current value.
226                                 * WARNING:  this approach is hard to make
227                                 * thread-safe... */
228  int  (*get_tostring_fn)(struct _owl_variable *v, 
229                          char *buf, int bufsize, void *val); 
230                                /* converts val to a string
231                                 * and puts into buf */
232  void  (*free_fn)(struct _owl_variable *v);
233                                /* frees val as needed */
234} owl_variable;
235
236typedef struct _owl_fmtext {
237  int textlen;
238  char *textbuff;
239  char *fmbuff;
240  char *colorbuff;
241} owl_fmtext;
242
243typedef struct _owl_list {
244  int size;
245  int avail;
246  void **list;
247} owl_list;
248
249typedef struct _owl_dict_el {
250  char *k;                      /* key   */
251  void *v;                      /* value */
252} owl_dict_el;
253
254typedef struct _owl_dict {
255  int size;
256  int avail;
257  owl_dict_el *els;             /* invariant: sorted by k */
258} owl_dict;
259typedef owl_dict owl_vardict;   /* dict of variables */
260typedef owl_dict owl_cmddict;   /* dict of commands */
261
262typedef struct _owl_context {
263  int   mode;
264  void *data;           /* determined by mode */
265} owl_context;
266
267typedef struct _owl_cmd {       /* command */
268  char *name;
269
270  char *summary;                /* one line summary of command */
271  char *usage;                  /* usage synopsis */
272  char *description;            /* long description of command */
273
274  int validctx;                 /* bitmask of valid contexts */
275
276  /* we should probably have a type here that says which of
277   * the following is valid, and maybe make the below into a union... */
278
279  /* Only one of these may be non-NULL ... */
280
281  char *cmd_aliased_to;         /* what this command is aliased to... */
282 
283  /* These don't take any context */
284  char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
285                                /* takes argv and the full command as buff.
286                                 * caller must free return value if !NULL */
287  void (*cmd_v_fn)(void);       /* takes no args */
288  void (*cmd_i_fn)(int i);      /* takes an int as an arg */
289
290  /* The following also take the active context if it's valid */
291  char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
292                                /* takes argv and the full command as buff.
293                                 * caller must free return value if !NULL */
294  void (*cmd_ctxv_fn)(void *ctx);               /* takes no args */
295  void (*cmd_ctxi_fn)(void *ctx, int i);        /* takes an int as an arg */
296} owl_cmd;
297
298
299typedef struct _owl_zwrite {
300  char *class;
301  char *inst;
302  char *realm;
303  char *opcode;
304  char *zsig;
305  char *message;
306  owl_list recips;
307  int cc;
308  int noping;
309} owl_zwrite;
310
311typedef struct _owl_pair {
312  void *key;
313  void *value;
314} owl_pair;
315
316typedef struct _owl_message {
317  int id;
318  int type;
319  int direction;
320#ifdef HAVE_LIBZEPHYR
321  ZNotice_t notice;
322#endif
323  owl_fmtext fmtext;              /* this is now only a CACHED copy */
324  int invalid_format;             /* indicates whether fmtext needs to be regenerated */
325  int delete;
326  char hostname[MAXHOSTNAMELEN+1];
327  owl_list attributes;            /* this is a list of pairs */
328  char *timestr;
329  time_t time;
330  char *zwriteline;
331} owl_message;
332
333typedef struct _owl_style {
334  char *name;
335  char *description;
336  int type;
337  char *perlfuncname;
338  void (*formatfunc) (owl_fmtext *fm, owl_message *m);
339} owl_style;
340
341typedef struct _owl_mainwin {
342  int curtruncated;
343  int lasttruncated;
344  int lastdisplayed;
345} owl_mainwin;
346
347typedef struct _owl_viewwin {
348  owl_fmtext fmtext;
349  int textlines;
350  int topline;
351  int rightshift;
352  int winlines, wincols;
353  WINDOW *curswin;
354} owl_viewwin;
355 
356typedef struct _owl_popwin {
357  WINDOW *borderwin;
358  WINDOW *popwin;
359  int lines;
360  int cols;
361  int active;
362  int needsfirstrefresh;
363  void (*handler) (int ch);
364} owl_popwin;
365
366typedef struct _owl_messagelist {
367  owl_list list;
368} owl_messagelist;
369
370typedef struct _owl_regex {
371  int negate;
372  char *string;
373  regex_t re;
374} owl_regex;
375
376typedef struct _owl_filterelement {
377  int type;
378  char *field;
379  owl_regex re;
380  char *filtername;  /* for maching on another filter */
381} owl_filterelement;
382
383typedef struct _owl_filter {
384  char *name;
385  int polarity;
386  owl_list fes; /* filterelements */
387  int color;
388  int cachedmsgid;  /* cached msgid: should move into view eventually */
389} owl_filter;
390
391typedef struct _owl_view {
392  char *name;
393  owl_filter *filter;
394  owl_messagelist ml;
395  owl_style *style;
396} owl_view;
397
398typedef struct _owl_history {
399  owl_list hist;
400  int cur;
401  int touched;
402  int partial;
403  int repeats;
404} owl_history;
405
406typedef struct _owl_editwin {
407  char *buff;
408  owl_history *hist;
409  int bufflen;
410  int allocated;
411  int buffx, buffy;
412  int topline;
413  int winlines, wincols, fillcol, wrapcol;
414  WINDOW *curswin;
415  int style;
416  int lock;
417  int dotsend;
418  int echochar;
419} owl_editwin;
420
421typedef struct _owl_keybinding {
422  int  *j;                      /* keypress stack (0-terminated) */ 
423  int   type;                   /* command or function? */
424  char *desc;                   /* description (or "*user*") */
425  char *command;                /* command, if of type command */
426  void (*function_fn)(void);    /* function ptr, if of type function */
427} owl_keybinding;
428
429typedef struct _owl_keymap {
430  char     *name;               /* name of keymap */
431  char     *desc;               /* description */
432  owl_list  bindings;           /* key bindings */
433  struct _owl_keymap *submap;   /* submap */
434  void (*default_fn)(int j);    /* default action (takes a keypress) */
435  void (*prealways_fn)(int j);  /* always called before a keypress is received */
436  void (*postalways_fn)(int j); /* always called after keypress is processed */
437} owl_keymap;
438
439typedef struct _owl_keyhandler {
440  owl_dict  keymaps;            /* dictionary of keymaps */
441  owl_keymap *active;           /* currently active keymap */
442  int       in_esc;             /* escape pressed? */
443  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
444  int       kpstackpos;         /* location in stack (-1 = none) */
445} owl_keyhandler;
446
447typedef struct _owl_buddy {
448  int proto;
449  char *name;
450  int isidle;
451  int idlesince;
452} owl_buddy;
453
454typedef struct _owl_buddylist {
455  owl_list buddies;
456} owl_buddylist;
457
458typedef struct _owl_zbuddylist {
459  owl_list zusers;
460} owl_zbuddylist;
461
462typedef struct _owl_timer {
463  int direction;
464  time_t starttime;
465  int start;
466} owl_timer;
467
468typedef struct _owl_errqueue {
469  owl_list errlist;
470} owl_errqueue;
471
472typedef struct _owl_global {
473  owl_mainwin mw;
474  owl_popwin pw;
475  owl_history cmdhist;          /* command history */
476  owl_history msghist;          /* outgoing message history */
477  owl_keyhandler kh;
478  owl_list filterlist;
479  owl_list puntlist;
480  owl_vardict vars;
481  owl_cmddict cmds;
482  owl_context ctx;
483  owl_errqueue errqueue;
484  int lines, cols;
485  int curmsg, topmsg;
486  int curmsg_vert_offset;
487  owl_view current_view;
488  owl_messagelist msglist;
489  WINDOW *recwin, *sepwin, *msgwin, *typwin;
490  int needrefresh;
491  int rightshift;
492  int resizepending;
493  int recwinlines;
494  int typwinactive;
495  char *thishost;
496  char *homedir;
497  int direction;
498  int zaway;
499  char *cur_zaway_msg;
500  int haveconfig;
501  int config_format;
502  char *buffercommand;
503  owl_editwin tw;
504  owl_viewwin vw;
505  void *perl;
506  int debug;
507  int starttime;
508  char *startupargs;
509  int userclue;
510  int nextmsgid;
511  int hascolors;
512  int colorpairs;
513  int searchactive;
514  int newmsgproc_pid;
515  int malloced, freed;
516  char *searchstring;
517  owl_filterelement fe_true;
518  owl_filterelement fe_false;
519  owl_filterelement fe_null;
520  aim_session_t aimsess;
521  aim_conn_t bosconn;
522  owl_timer aim_noop_timer;
523  owl_timer aim_ignorelogin_timer;
524  owl_timer aim_buddyinfo_timer;
525  int aim_loggedin;         /* true if currently logged into AIM */
526  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
527  char *aim_screenname;     /* currently logged in AIM screen name */
528  owl_buddylist buddylist;  /* list of logged in AIM buddies */
529  owl_list messagequeue;    /* for queueing up aim and other messages */
530  owl_dict styledict;       /* global dictionary of available styles */
531  char *response;           /* response to the last question asked */
532  int havezephyr;
533  int haveaim;
534  int got_err_signal;       /* 1 if we got an unexpected signal */
535  siginfo_t err_signal_info;
536  owl_zbuddylist zbuddies;
537  owl_timer zephyr_buddycheck_timer;
538} owl_global;
539
540/* globals */
541extern owl_global g;
542
543#include "owl_prototypes.h"
544
545/* these are missing from the zephyr includes for some reason */
546#ifdef HAVE_LIBZEPHYR
547int ZGetSubscriptions(ZSubscription_t *, int *);
548int ZGetLocations(ZLocations_t *,int *);
549#endif
550
551#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.