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