source: owl.h @ 5a95b69

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