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 <libfaim/aim.h> |
---|
11 | #include "config.h" |
---|
12 | #ifdef HAVE_LIBZEPHYR |
---|
13 | #include <zephyr/zephyr.h> |
---|
14 | #endif |
---|
15 | |
---|
16 | |
---|
17 | static const char owl_h_fileIdent[] = "$Id$"; |
---|
18 | |
---|
19 | #define OWL_VERSION 2.0.4-pre-2 |
---|
20 | #define OWL_VERSION_STRING "2.0.4-pre-2" |
---|
21 | |
---|
22 | #define OWL_DEBUG 0 |
---|
23 | #define OWL_DEBUG_FILE "/var/tmp/owldebug" |
---|
24 | |
---|
25 | #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ |
---|
26 | #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ |
---|
27 | |
---|
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 | |
---|
46 | #define OWL_MESSAGE_TYPE_ADMIN 0 |
---|
47 | #define OWL_MESSAGE_TYPE_GENERIC 1 |
---|
48 | #define OWL_MESSAGE_TYPE_ZEPHYR 2 |
---|
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 |
---|
54 | |
---|
55 | #define OWL_MESSAGE_DIRECTION_NONE 0 |
---|
56 | #define OWL_MESSAGE_DIRECTION_IN 1 |
---|
57 | #define OWL_MESSAGE_DIRECTION_OUT 2 |
---|
58 | |
---|
59 | #define OWL_DIRECTION_NONE 0 |
---|
60 | #define OWL_DIRECTION_DOWNWARDS 1 |
---|
61 | #define OWL_DIRECTION_UPWARDS 2 |
---|
62 | |
---|
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 |
---|
68 | #define OWL_SCROLLMODE_PAGEDCENTER 5 |
---|
69 | |
---|
70 | #define OWL_STYLE_TYPE_INTERNAL 0 |
---|
71 | #define OWL_STYLE_TYPE_PERL 1 |
---|
72 | |
---|
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 |
---|
105 | #define OWL_WEBBROWSER_OPERA 3 |
---|
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 | |
---|
114 | #define OWL_KEYMAP_MAXSTACK 20 |
---|
115 | |
---|
116 | #define OWL_KEYBINDING_COMMAND 1 /* command string */ |
---|
117 | #define OWL_KEYBINDING_FUNCTION 2 /* function taking no args */ |
---|
118 | |
---|
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" |
---|
120 | |
---|
121 | #define OWL_INCLUDE_REG_TESTS 1 /* whether to build in regression tests */ |
---|
122 | |
---|
123 | #define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: " |
---|
124 | |
---|
125 | #if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT_PROTO) |
---|
126 | #define OWL_ENABLE_ZCRYPT 1 |
---|
127 | #endif |
---|
128 | |
---|
129 | #define OWL_META(key) ((key)|0200) |
---|
130 | /* OWL_CTRL is definied in kepress.c */ |
---|
131 | |
---|
132 | #define LINE 2048 |
---|
133 | |
---|
134 | typedef 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 */ |
---|
140 | char *summary; /* summary of usage */ |
---|
141 | char *description; /* detailed description */ |
---|
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 | |
---|
169 | typedef struct _owl_fmtext { |
---|
170 | int textlen; |
---|
171 | char *textbuff; |
---|
172 | char *fmbuff; |
---|
173 | char *colorbuff; |
---|
174 | } owl_fmtext; |
---|
175 | |
---|
176 | typedef struct _owl_list { |
---|
177 | int size; |
---|
178 | int avail; |
---|
179 | void **list; |
---|
180 | } owl_list; |
---|
181 | |
---|
182 | typedef struct _owl_dict_el { |
---|
183 | char *k; /* key */ |
---|
184 | void *v; /* value */ |
---|
185 | } owl_dict_el; |
---|
186 | |
---|
187 | typedef struct _owl_dict { |
---|
188 | int size; |
---|
189 | int avail; |
---|
190 | owl_dict_el *els; /* invariant: sorted by k */ |
---|
191 | } owl_dict; |
---|
192 | typedef owl_dict owl_vardict; /* dict of variables */ |
---|
193 | typedef owl_dict owl_cmddict; /* dict of commands */ |
---|
194 | |
---|
195 | typedef struct _owl_context { |
---|
196 | int mode; |
---|
197 | void *data; /* determined by mode */ |
---|
198 | } owl_context; |
---|
199 | |
---|
200 | typedef 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 | |
---|
232 | typedef struct _owl_zwrite { |
---|
233 | char class[LINE]; |
---|
234 | char inst[LINE]; |
---|
235 | char realm[LINE]; |
---|
236 | char opcode[LINE]; |
---|
237 | char *zsig; |
---|
238 | owl_list recips; |
---|
239 | int cc; |
---|
240 | int noping; |
---|
241 | } owl_zwrite; |
---|
242 | |
---|
243 | typedef struct _owl_pair { |
---|
244 | void *key; |
---|
245 | void *value; |
---|
246 | } owl_pair; |
---|
247 | |
---|
248 | typedef struct _owl_message { |
---|
249 | int id; |
---|
250 | int type; |
---|
251 | int direction; |
---|
252 | #ifdef HAVE_LIBZEPHYR |
---|
253 | ZNotice_t notice; |
---|
254 | #endif |
---|
255 | owl_fmtext fmtext; /* this is now only a CACHED copy */ |
---|
256 | int invalid_format; /* indicates whether fmtext needs to be regenerated */ |
---|
257 | int delete; |
---|
258 | char hostname[MAXHOSTNAMELEN+1]; |
---|
259 | owl_list attributes; /* this is a list of pairs */ |
---|
260 | char *time; |
---|
261 | char *zwriteline; |
---|
262 | } owl_message; |
---|
263 | |
---|
264 | typedef 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 | |
---|
271 | typedef struct _owl_mainwin { |
---|
272 | int curtruncated; |
---|
273 | int lasttruncated; |
---|
274 | int lastdisplayed; |
---|
275 | } owl_mainwin; |
---|
276 | |
---|
277 | typedef 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 | |
---|
286 | typedef 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 | |
---|
296 | typedef struct _owl_messagelist { |
---|
297 | owl_list list; |
---|
298 | } owl_messagelist; |
---|
299 | |
---|
300 | typedef struct _owl_regex { |
---|
301 | int negate; |
---|
302 | char *string; |
---|
303 | regex_t re; |
---|
304 | } owl_regex; |
---|
305 | |
---|
306 | typedef struct _owl_filterelement { |
---|
307 | int type; |
---|
308 | char *field; |
---|
309 | owl_regex re; |
---|
310 | } owl_filterelement; |
---|
311 | |
---|
312 | typedef struct _owl_filter { |
---|
313 | char *name; |
---|
314 | int polarity; |
---|
315 | owl_list fes; /* filterelements */ |
---|
316 | int color; |
---|
317 | int cachedmsgid; /* cached msgid: should move into view eventually */ |
---|
318 | } owl_filter; |
---|
319 | |
---|
320 | typedef struct _owl_view { |
---|
321 | char *name; |
---|
322 | owl_filter *filter; |
---|
323 | owl_messagelist ml; |
---|
324 | owl_style *style; |
---|
325 | } owl_view; |
---|
326 | |
---|
327 | typedef struct _owl_history { |
---|
328 | owl_list hist; |
---|
329 | int cur; |
---|
330 | int touched; |
---|
331 | int partial; |
---|
332 | } owl_history; |
---|
333 | |
---|
334 | typedef 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 | |
---|
348 | typedef 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 | |
---|
356 | typedef 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 | |
---|
366 | typedef 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 | |
---|
374 | typedef struct _owl_buddylist { |
---|
375 | owl_list buddies; |
---|
376 | } owl_buddylist; |
---|
377 | |
---|
378 | typedef struct _owl_timer { |
---|
379 | int direction; |
---|
380 | time_t starttime; |
---|
381 | int start; |
---|
382 | } owl_timer; |
---|
383 | |
---|
384 | typedef struct _owl_global { |
---|
385 | owl_mainwin mw; |
---|
386 | owl_popwin pw; |
---|
387 | owl_history cmdhist; /* command history */ |
---|
388 | owl_history msghist; /* outgoing message history */ |
---|
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; |
---|
424 | int searchactive; |
---|
425 | int newmsgproc_pid; |
---|
426 | int malloced, freed; |
---|
427 | char *searchstring; |
---|
428 | owl_filterelement fe_true; |
---|
429 | owl_filterelement fe_false; |
---|
430 | owl_filterelement fe_null; |
---|
431 | aim_session_t aimsess; |
---|
432 | aim_conn_t waitingconn; |
---|
433 | owl_timer aim_noop_timer; |
---|
434 | owl_timer aim_ignorelogin_timer; |
---|
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 */ |
---|
440 | } owl_global; |
---|
441 | |
---|
442 | /* globals */ |
---|
443 | extern owl_global g; |
---|
444 | |
---|
445 | #include "owl_prototypes.h" |
---|
446 | |
---|
447 | /* these are missing from the zephyr includes for some reason */ |
---|
448 | #ifdef HAVE_LIBZEPHYR |
---|
449 | int ZGetSubscriptions(ZSubscription_t *, int *); |
---|
450 | int ZGetLocations(ZLocations_t *,int *); |
---|
451 | #endif |
---|
452 | |
---|
453 | #endif /* INC_OWL_H */ |
---|