source: commands.c @ 944004c

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 944004c was 944004c, checked in by Matthew S. Goldstein <austein@mit.edu>, 16 years ago
added -m flag to aimwrite
  • Property mode set to 100644
File size: 80.1 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include "owl.h"
6
7static const char fileIdent[] = "$Id$";
8
9/* fn is "char *foo(int argc, char **argv, char *buff)" */
10#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
11        { name, summary, usage, description, ctx, \
12          NULL, fn, NULL, NULL, NULL, NULL, NULL }
13
14/* fn is "void foo(void)" */
15#define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \
16        { name, summary, usage, description, ctx, \
17          NULL, NULL, fn, NULL, NULL, NULL, NULL }
18
19/* fn is "void foo(int)" */
20#define OWLCMD_INT(name, fn, ctx, summary, usage, description) \
21        { name, summary, usage, description, ctx, \
22          NULL, NULL, NULL, fn, NULL, NULL, NULL }
23
24#define OWLCMD_ALIAS(name, actualname) \
25        { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \
26          actualname, NULL, NULL, NULL, NULL, NULL, NULL }
27
28/* fn is "char *foo(void *ctx, int argc, char **argv, char *buff)" */
29#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
30        { name, summary, usage, description, ctx, \
31          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,char**,char*))fn), NULL, NULL }
32
33/* fn is "void foo(void)" */
34#define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \
35        { name, summary, usage, description, ctx, \
36          NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL }
37
38/* fn is "void foo(int)" */
39#define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \
40        { name, summary, usage, description, ctx, \
41          NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn) }
42
43
44owl_cmd commands_to_init[]
45  = {
46  OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY,
47              "send a login or logout notification",
48              "zlog in [tty]\nzlog out",
49              "zlog in will send a login notification, zlog out will send a\n"
50              "logout notification.  By default a login notification is sent\n"
51              "when owl is started and a logout notification is sent when owl\n"
52              "is exited.  This behavior can be changed with the 'startuplogin'\n"
53              "and 'shudownlogout' variables.  If a tty is specified for zlog in\n"
54              "then the owl variable 'tty' will be set to that string, causing\n"
55              "it to be used as the zephyr location tty.\n"),
56
57  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
58              "exit owl",
59              "",
60              "Exit owl and run any shutdown activities."),
61  OWLCMD_ALIAS("exit", "quit"),
62  OWLCMD_ALIAS("q",    "quit"),
63
64  OWLCMD_ARGS("term", owl_command_term, OWL_CTX_ANY,
65              "control the terminal",
66              "term raise\n"
67              "term deiconify\n",
68              ""),
69
70  OWLCMD_VOID("nop", owl_command_nop, OWL_CTX_ANY,
71              "do nothing",
72              "",
73              ""),
74 
75  OWLCMD_ARGS("start-command", owl_command_start_command, OWL_CTX_INTERACTIVE,
76              "prompts the user to enter a command",
77              "start-command [initial-value]",
78              "Initializes the command field to initial-value."),
79
80  OWLCMD_ARGS("start-question", owl_command_start_question, OWL_CTX_INTERACTIVE,
81              "prompts the user to enter a response to some question",
82              "start-command <question>",
83              ""),
84
85  OWLCMD_ARGS("start-password", owl_command_start_password, OWL_CTX_INTERACTIVE,
86              "prompts the user to enter a password",
87              "start-password <question>",
88              ""),
89
90  OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY,
91              "creates a command alias",
92              "alias <new_command> <old_command>",
93              "Creates a command alias from new_command to old_command.\n"
94              "Any arguments passed to <new_command> will be appended to\n"
95              "<old_command> before it is executed.\n"),
96
97  OWLCMD_ARGS("bindkey", owl_command_bindkey, OWL_CTX_ANY,
98              "creates a binding in a keymap",
99              "bindkey <keymap> <keyseq> command <command>",
100              "Binds a key sequence to a command within a keymap.\n"
101              "Use 'show keymaps' to see the existing keymaps.\n"
102              "Key sequences may be things like M-C-t or NPAGE.\n"),
103
104  OWLCMD_ARGS("style", owl_command_style, OWL_CTX_ANY,
105              "creates a new style",
106              "style <name> perl <function_name>",
107              "Creates a new style for formatting messages.\n"
108              "A style named <name> will be created that will\n"
109              "format messages using the perl function <function_name>.\n\n"
110              "SEE ALSO: show styles, view -s, filter -s\n"),
111
112  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
113              "send a zephyr",
114              "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] [-m <message...>]",
115              "Zwrite send a zephyr to the one or more users specified.\n\n"
116              "The following options are available:\n\n"
117              "-m    Specifies a message to send without prompting.\n"
118              "      Note that this does not yet log an outgoing message.\n"
119              "      This must be the last argument.\n\n"
120              "-n    Do not send a ping message.\n\n"
121              "-C    If the message is sent to more than one user include a\n"
122              "      \"cc:\" line in the text\n\n"
123              "-c class\n"
124              "      Send to the specified zephyr class\n\n"
125              "-i instance\n"
126              "      Send to the specified zephyr instance\n\n"
127              "-r realm\n"
128              "      Send to a foreign realm\n"
129              "-O opcode\n"
130              "      Send to the specified opcode\n"),
131
132  OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE,
133              "send an AIM message",
134              "aimzwrite <user> [-m <message...>]",
135              "Send an aim message to a user.\n\n" 
136              "The following options are available:\n\n"
137              "-m    Specifies a message to send without prompting.\n"
138              "      Note that this does not yet log an outgoing message.\n"
139              "      or display the sent message.\n"),
140
141  OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE,
142              "send a loopback message",
143              "loopwrite",
144              "Send a local message.\n"),
145
146  OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE,
147              "send an encrypted zephyr",
148              "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [-m <message...>]\n",
149              "Behaves like zwrite but uses encryption.  Not for use with\n"
150              "personal messages\n"),
151 
152  OWLCMD_ARGS("reply", owl_command_reply,  OWL_CTX_INTERACTIVE,
153              "reply to the current message",
154              "reply [-e] [ sender | all | zaway ]",
155              "If -e is specified, the zwrite command line is presented to\n"
156              "allow editing.\n\n"
157              "If 'sender' is specified, reply to the sender.\n\n"
158              "If 'all' or no args are specified, reply publically to the\n"
159              "same class/instance for non-personal messages and to the\n"
160              "sender for personal messages.\n\n"
161              "If 'zaway' is specified, replies with a zaway message.\n\n"),
162
163  OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY,
164              "set a variable value",
165              "set [-q] [<variable>] [<value>]\n"
166              "set",
167              "Set the named variable to the specified value.  If no\n"
168              "arguments are given, print the value of all variables.\n"
169              "If the value is unspecified and the variable is a boolean, it will be\n"
170              "set to 'on'.  If -q is used, set is silent and does not print a\n"
171              "message.\n"),
172
173  OWLCMD_ARGS("unset", owl_command_unset, OWL_CTX_ANY,
174              "unset a boolean variable value",
175              "set [-q] <variable>\n"
176              "set",
177              "Set the named boolean variable to off.\n"
178              "If -q is specified, is silent and doesn't print a message.\n"),
179
180  OWLCMD_ARGS("print", owl_command_print, OWL_CTX_ANY,
181              "print a variable value",
182              "print <variable>\n"
183              "print",
184              "Print the value of the named variable.  If no arugments\n"
185              "are used print the value of all variables.\n"),
186
187  OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY,
188              "run a command and set it to be run at every Owl startup",
189              "startup <commands> ...",
190              "Everything on the command line after the startup command\n"
191              "is executed as a normal owl command and is also placed in\n"
192              "a file so that the command is executed every time owl\n"
193              "is started"),
194
195  OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY,
196              "remove a command from the list of those to be run at Owl startup",
197              "unstartup <commands> ...",
198              ""),
199
200  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
201              "print the version of the running owl", "", ""),
202
203  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
204              "subscribe to a zephyr class, instance, recipient",
205              "subscribe [-t] <class> <instance> [recipient]",
206              "Subscribe the specified class and instance.  If the recipient\n"
207              "is not listed on the command line it defaults\n"
208              "to * (the wildcard recipient).  If the -t option is present\n"
209              "the subscription will only be temporary, i.e., it will not\n"
210              "be written to the subscription file and will therefore not\n"
211              "be present the next time owl is started.\n"),
212  OWLCMD_ALIAS("sub", "subscribe"),
213
214  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
215              "unsubscribe from a zephyr class, instance, recipient",
216              "unsubscribe [-t] <class> <instance> [recipient]",
217              "Unsubscribe from the specified class and instance.  If the\n"
218              "recipient is not listed on the command line it defaults\n"
219              "to * (the wildcard recipient).  If the -t option is present\n"
220              "the unsubscription will only be temporary, i.e., it will not\n"
221              "be updated in the subscription file and will therefore not\n"
222              "be in effect the next time owl is started.\n"),
223  OWLCMD_ALIAS("unsub", "unsubscribe"),
224
225  OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY,
226              "unsubscribe from all zephyrs", "", ""),
227 
228  OWLCMD_VOID("getsubs", owl_command_getsubs, OWL_CTX_ANY,
229              "print all current subscriptions",
230              "getsubs",
231              "getsubs retrieves the current subscriptions from the server\n"
232              "and displays them.\n"),
233
234  OWLCMD_ARGS("dump", owl_command_dump, OWL_CTX_ANY,
235              "dump messages to a file",
236              "dump <filename>",
237              "Dump messages in current view to the named file."),
238
239  OWLCMD_ARGS("source", owl_command_source, OWL_CTX_ANY,
240              "execute owl commands from a file",
241              "source <filename>",
242              "Execute the owl commands in <filename>.\n"),
243
244  OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE,
245              "AIM specific commands",
246              "aim search <email>",
247              ""),
248
249  OWLCMD_ARGS("addbuddy", owl_command_addbuddy, OWL_CTX_INTERACTIVE,
250              "add a buddy to a buddylist",
251              "addbuddy <protocol> <screenname>",
252              "Add the named buddy to your buddylist.  <protocol> can be aim or zephyr\n"),
253
254  OWLCMD_ARGS("delbuddy", owl_command_delbuddy, OWL_CTX_INTERACTIVE,
255              "delete a buddy from a buddylist",
256              "delbuddy <protocol> <screenname>",
257              "Delete the named buddy to your buddylist.  <protocol< can be aim or zephyr\n"),
258
259  OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE,
260              "join a chat group",
261              "join aim <groupname> [exchange]",
262              "Join the AIM chatroom with 'groupname'.\n"),
263
264  OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
265              "creates a zpunt based on the current message",
266              "smartzpunt [-i | --instance]",
267              "Starts a zpunt command based on the current message's class\n"
268              "(and instance if -i is specified).\n"),
269
270  OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY,
271              "suppress a given zephyr triplet",
272              "zpunt <class> <instance> [recipient]\n"
273              "zpunt <instance>",
274              "The zpunt command will supress message to the specified\n"
275              "zephyr triplet.  In the second usage messages as supressed\n"
276              "for class MESSAGE and the named instance.\n\n"
277              "SEE ALSO:  zunpunt, show zpunts\n"),
278
279  OWLCMD_ARGS("zunpunt", owl_command_zunpunt, OWL_CTX_ANY,
280              "undo a previous zpunt",
281              "zunpunt <class> <instance> [recipient]\n"
282              "zunpunt <instance>",
283              "The zunpunt command will allow messages that were previosly\n"
284              "suppressed to be received again.\n\n"
285              "SEE ALSO:  zpunt, show zpunts\n"),
286
287  OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY,
288              "suppress an arbitrary filter",
289              "punt <filter-name>",
290              "punt <filter-text (multiple words)>\n"
291              "The punt command will supress message to the specified\n"
292              "filter\n\n"
293              "SEE ALSO:  unpunt, zpunt, show zpunts\n"),
294
295  OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY,
296              "remove an entry from the punt list",
297              "zpunt <filter-name>\n"
298              "zpunt <filter-text>\n"
299              "zpunt <number>\n",
300              "The unpunt command will remove an entry from the puntlist.\n"
301              "The first two forms correspond to the first two forms of the :punt\n"
302              "command. The latter allows you to remove a specific entry from the\n"
303              "the list (see :show zpunts)\n\n"
304              "SEE ALSO:  punt, zpunt, zunpunt, show zpunts\n"),
305
306  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
307              "display detailed information about the current message",
308              "", ""),
309 
310  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
311              "display help on using owl",
312              "help [command]", ""),
313
314  OWLCMD_ARGS("zlist", owl_command_zlist, OWL_CTX_INTERACTIVE,
315              "List users logged in",
316              "znol [-f file]",
317              "Print a znol-style listing of users logged in"),
318
319  OWLCMD_ARGS("alist", owl_command_alist, OWL_CTX_INTERACTIVE,
320              "List AIM users logged in",
321              "alist",
322              "Print a listing of AIM users logged in"),
323
324  OWLCMD_ARGS("blist", owl_command_blist, OWL_CTX_INTERACTIVE,
325              "List all buddies logged in",
326              "blist",
327              "Print a listing of buddies logged in, regardless of protocol."),
328
329  OWLCMD_ARGS("toggle-oneline", owl_command_toggleoneline, OWL_CTX_INTERACTIVE,
330              "Toggle the style between oneline and the default style",
331              "toggle-oneline",
332              ""),
333
334  OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE,
335              "scrolls receive window to the left", "", ""),
336
337  OWLCMD_VOID("recv:shiftright", owl_command_shift_right, OWL_CTX_INTERACTIVE,
338              "scrolls receive window to the left", "", ""),
339
340  OWLCMD_VOID("recv:pagedown", owl_function_mainwin_pagedown, 
341              OWL_CTX_INTERACTIVE,
342              "scrolls down by a page", "", ""),
343
344  OWLCMD_VOID("recv:pageup", owl_function_mainwin_pageup, OWL_CTX_INTERACTIVE,
345              "scrolls up by a page", "", ""),
346
347  OWLCMD_INT ("recv:scroll", owl_function_page_curmsg, OWL_CTX_INTERACTIVE,
348              "scrolls current message up or down", 
349              "recv:scroll <numlines>", 
350              "Scrolls the current message up or down by <numlines>.\n"
351              "Scrolls up if <numlines> is negative, else scrolls down.\n"),
352
353  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
354              "move the pointer to the next message",
355              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]\n"
356              "          [ --smart-filter | --smart-filter-instance ]",
357              "Moves the pointer to the next message in the current view.\n"
358              "If --filter is specified, will only consider messages in\n"
359              "the filter <name>.\n"
360              "If --smart-filter or --smart-filter-instance is specified,\n"
361              "goes to the next message that is similar to the current message.\n"
362              "If --skip-deleted is specified, deleted messages will\n"
363              "be skipped.\n"
364              "If --last-if-none is specified, will stop at last message\n"
365              "in the view if no other suitable messages are found.\n"),
366  OWLCMD_ALIAS("recv:next", "next"),
367
368  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
369              "move the pointer to the previous message",
370              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]\n"
371              "          [ --smart-filter | --smart-filter-instance ]",
372              "Moves the pointer to the next message in the current view.\n"
373              "If --filter is specified, will only consider messages in\n"
374              "the filter <name>.\n"
375              "If --smart-filter or --smart-filter-instance is specified,\n"
376              "goes to the previous message that is similar to the current message.\n"
377              "If --skip-deleted is specified, deleted messages will\n"
378              "be skipped.\n"
379              "If --first-if-none is specified, will stop at first message\n"
380              "in the view if no other suitable messages are found.\n"),
381  OWLCMD_ALIAS("recv:prev", "prev"),
382
383  OWLCMD_ALIAS("recv:next-notdel", "recv:next --skip-deleted --last-if-none"),
384  OWLCMD_ALIAS("next-notdel",      "recv:next --skip-deleted --last-if-none"),
385
386  OWLCMD_ALIAS("recv:prev-notdel", "recv:prev --skip-deleted --first-if-none"),
387  OWLCMD_ALIAS("prev-notdel",      "recv:prev --skip-deleted --first-if-none"),
388
389  OWLCMD_ALIAS("recv:next-personal", "recv:next --filter personal"),
390
391  OWLCMD_ALIAS("recv:prev-personal", "recv:prev --filter personal"),
392
393  OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE,
394              "move the pointer to the first message", "", ""),
395  OWLCMD_ALIAS("recv:first", "first"),
396
397  OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE,
398              "move the pointer to the last message", "", 
399              "Moves the pointer to the last message in the view.\n"
400              "If we are already at the last message in the view,\n"
401              "blanks the screen and moves just past the end of the view\n"
402              "so that new messages will appear starting at the top\n"
403              "of the screen.\n"),
404  OWLCMD_ALIAS("recv:last", "last"),
405
406  OWLCMD_VOID("expunge", owl_command_expunge, OWL_CTX_INTERACTIVE,
407              "remove all messages marked for deletion", "", ""),
408
409  OWLCMD_VOID("resize", owl_command_resize, OWL_CTX_ANY,
410              "resize the window to the current screen size", "", ""),
411
412  OWLCMD_VOID("redisplay", owl_command_redisplay, OWL_CTX_ANY,
413              "redraw the entire window", "", ""),
414
415  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
416              "suspend owl", "", ""),
417
418  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
419              "pops up a message in popup window",
420              "echo [args .. ]\n\n", ""),
421
422  OWLCMD_ARGS("exec", owl_command_exec, OWL_CTX_ANY,
423              "run a command from the shell",
424              "exec [args .. ]", ""),
425
426  OWLCMD_ARGS("aexec", owl_command_aexec, OWL_CTX_INTERACTIVE,
427              "run a command from the shell and display in an admin message",
428              "aexec [args .. ]", ""),
429
430  OWLCMD_ARGS("pexec", owl_command_pexec, OWL_CTX_INTERACTIVE,
431              "run a command from the shell and display in a popup window",
432              "pexec [args .. ]", ""),
433
434  OWLCMD_ARGS("perl", owl_command_perl, OWL_CTX_ANY,
435              "run a perl expression",
436              "perl [args .. ]", ""),
437
438  OWLCMD_ARGS("aperl", owl_command_aperl, OWL_CTX_INTERACTIVE,
439              "run a perl expression and display in an admin message",
440              "aperl [args .. ]", ""),
441
442  OWLCMD_ARGS("pperl", owl_command_pperl, OWL_CTX_INTERACTIVE,
443              "run a perl expression and display in a popup window",
444              "pperl [args .. ]", ""),
445
446  OWLCMD_ARGS("multi", owl_command_multi, OWL_CTX_ANY,
447              "runs multiple ;-separated commands",
448              "multi <command1> ( ; <command2> )*\n",
449              "Runs multiple semicolon-separated commands in order.\n"
450              "Note quoting isn't supported here yet.\n"
451              "If you want to do something fancy, use perl.\n"),
452
453  OWLCMD_ARGS("(", owl_command_multi, OWL_CTX_ANY,
454              "runs multiple ;-separated commands",
455              "'(' <command1> ( ; <command2> )* ')'\n",
456              "Runs multiple semicolon-separated commands in order.\n"
457              "You must have a space before the final ')'\n"
458              "Note quoting isn't supported here yet.\n"
459              "If you want to do something fancy, use perl.\n"),
460
461  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
462              "pops up a message in a window", "", ""),
463
464  OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE,
465              "opens up a URL from the current message",
466              "", 
467              "Uses the 'webbrowser' variable to determine\n"
468              "which browser to use.  Currently, 'netscape'\n"
469              "and 'galeon' are supported.\n"),
470
471  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
472              "Set, enable or disable zephyr away message",
473              "zaway [ on | off | toggle ]\n"
474              "zaway <message>",
475              "Turn on or off a zaway message.  If 'message' is\n"
476              "specified turn on zaway with that message, otherwise\n"
477              "use the default.\n"),
478
479  OWLCMD_ARGS("aaway", owl_command_aaway, OWL_CTX_INTERACTIVE,
480              "Set, enable or disable AIM away message",
481              "aaway [ on | off | toggle ]\n"
482              "aaway <message>",
483              "Turn on or off the AIM away message.  If 'message' is\n"
484              "specified turn on aaway with that message, otherwise\n"
485              "use the default.\n"),
486
487  OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE,
488              "Set, enable or disable both AIM and zephyr away messages",
489              "away [ on | off | toggle ]\n"
490              "away <message>",
491              "Turn on or off the AIM and zephyr away message.  If\n"
492              "'message' is specified turn them on with that message,\n"
493              "otherwise use the default.\n"
494              "\n"
495              "This command really just runs the 'aaway' and 'zaway'\n"
496              "commands together\n"
497              "\n"
498              "SEE ALSO: aaway, zaway"),
499
500  OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY,
501              "load subscriptions from a file",
502              "load-subs <file>\n", ""),
503
504  OWLCMD_ARGS("loadsubs", owl_command_loadsubs, OWL_CTX_ANY,
505              "load subscriptions from a file",
506              "loadsubs <file>\n", ""),
507
508  OWLCMD_ARGS("loadloginsubs", owl_command_loadloginsubs, OWL_CTX_ANY,
509              "load login subscriptions from a file",
510              "loadloginsubs <file>\n",
511              "The file should contain a list of usernames, one per line."),
512
513  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
514              "print information about owl", "", ""),
515
516  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
517              "print status information about the running owl", "", ""),
518 
519  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
520              "locate a user",
521              "zlocate [-d] <user> ...", 
522              "Performs a zlocate on one ore more users and puts the result\n"
523              "int a popwin.  If -d is specified, does not authenticate\n"
524              "the lookup request.\n"),
525 
526  OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY,
527              "create a message filter",
528              "filter <name> [ -c fgcolor ] [ -b bgcolor ] [ <expression> ... ]",
529              "The filter command creates a filter with the specified name,\n"
530              "or if one already exists it is replaced.  Example filter\n"
531              "syntax would be:\n\n"
532              "     filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )\n\n"
533              "Valid matching fields are:\n"
534              "    sender     -  sender\n"
535              "    recipient  -  recipient\n"
536              "    class      -  zephyr class name\n"
537              "    instance   -  zephyr instance name\n"
538              "    opcode     -  zephyr opcode\n"
539              "    realm      -  zephyr realm\n"
540              "    body       -  message body\n"
541              "    hostname   -  hostname of sending host\n"
542              "    type       -  message type (zephyr, aim, admin)\n"
543              "    direction  -  either 'in' 'out' or 'none'\n"
544              "    login      -  either 'login' 'logout' or 'none'\n"
545              "Also you may match on the validity of another filter:\n"
546              "    filter <filtername>\n"
547              "Also you may pass the message to a perl function returning 0 or 1,\n"
548              "where 1 indicates that the function matches the filter:\n"
549              "    perl <subname>\n"
550              "Valid operators are:\n"
551              "    and\n"
552              "    or\n"
553              "    not\n"
554              "And additionally you may use the static values:\n"
555              "    true\n"
556              "    false\n"
557              "Spaces must be present before and after parenthesis.  If the\n"
558              "optional color arguments are used they specifies the colors that\n"
559              "messages matching this filter should be displayed in.\n\n"
560              "SEE ALSO: view, viewclass, viewuser\n"),
561
562  OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE,
563              "change the colors on the current filter",
564              "colorview <fgcolor> [<bgcolor>]",
565              "The colors of messages in the current filter will be changed\n"
566              "to <fgcolor>,<bgcolor>.  Use the 'show colors' command for a list\n"
567              "of valid colors.\n\n"
568              "SEE ALSO: 'show colors'\n"),
569
570  OWLCMD_ARGS("colorclass", owl_command_colorclass, OWL_CTX_INTERACTIVE,
571              "create a filter to color messages of the given class name",
572              "colorclass <class> <fgcolor> [<bgcolor>]",
573              "A filter will be created to color messages in <class>"
574              "in <fgcolor>,<bgcolor>.  Use the 'show colors' command for a list\n"
575              "of valid colors.\n\n"
576              "SEE ALSO: 'show colors'\n"),
577
578  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
579              "view messages matching a filter",
580              "view [<viewname>] [-f <filter> | --home | -r ] [-s <style>]\n"
581              "view <filter>\n"
582              "view -d <expression>\n"
583              "view --home",
584              "The view command sets information associated with a particular view,\n"
585              "such as view's filter or style.  In the first general usage listed\n"
586              "above <viewname> is the name of the view to be changed.  If not\n"
587              "specified the default view 'main' will be used.  A filter can be set\n"
588              "for the view by listing a named filter after the -f argument.  If\n"
589              "the --home argument is used the filter will be set to the filter named\n"
590              "by the\n 'view_home' variable.  The style can be set by listing the\n"
591              "name style after the -s argument.\n"
592              "\n"
593              "The other usages listed above are abbreivated forms that simply set\n"
594              "the filter of the current view. The -d option allows you to write a\n"
595              "filter expression that will be dynamically created by owl and then\n"
596              "applied as the view's filter\n"
597              "SEE ALSO: filter, viewclass, viewuser\n"),
598
599  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
600              "view only messages similar to the current message",
601              "smartnarrow [-i | --instance]",
602              "If the curmsg is a personal message narrow\n"
603              "   to the converstaion with that user.\n"
604              "If the curmsg is a class message, instance foo, recip *\n"
605              "   message, narrow to the class, inst.\n"
606              "If the curmsg is a class message then narrow\n"
607              "    to the class.\n"
608              "If the curmsg is a class message and '-i' is specied\n"
609              "    then narrow to the class, instance\n"),
610
611  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
612              "returns the name of a filter based on the current message",
613              "smartfilter [-i | --instance]",
614              "If the curmsg is a personal message, the filter is\n"
615              "   the converstaion with that user.\n"
616              "If the curmsg is a class message, instance foo, recip *\n"
617              "   message, the filter is the class, inst.\n"
618              "If the curmsg is a class message, the filter is that class.\n"
619              "If the curmsg is a class message and '-i' is specied\n"
620              "    the filter is that <class,instance> pair\n"),
621
622  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
623              "view messages matching a particular class",
624              "viewclass <class>",
625              "The viewclass command will automatically create a filter\n"
626              "matching the specified class and switch the current view\n"
627              "to it.\n\n"
628              "SEE ALSO: filter, view, viewuser\n"),
629  OWLCMD_ALIAS("vc", "viewclass"),
630
631  OWLCMD_ARGS("viewuser", owl_command_viewuser, OWL_CTX_INTERACTIVE,
632              "view messages matching a particular user",
633              "viewuser <user>",
634              "The viewuser command will automatically create a filter\n"
635              "matching the specified user and switch the current\n"
636              "view to it.\n\n"
637              "SEE ALSO: filter, view, viewclass\n"),
638  OWLCMD_ALIAS("vu", "viewuser"),
639
640  OWLCMD_ARGS("show", owl_command_show, OWL_CTX_INTERACTIVE,
641              "show information",
642              "show colors\n"
643              "show commands\n"
644              "show command <command>\n"
645              "show errors\n"
646              "show filters\n"
647              "show filter <filter>\n"
648              "show keymaps\n"
649              "show keymap <keymap>\n"
650              "show license\n"
651              "show startup\n"
652              "show status\n"
653              "show styles\n"
654              "show subscriptions / show subs\n"
655              "show terminal\n"
656              "show variables\n"
657              "show variable <variable>\n"
658              "show version\n"
659              "show view [<view>]\n"
660              "show zpunts\n",
661
662              "Show colors will display a list of valid colors for the\n"
663              "     terminal."
664              "Show filters will list the names of all filters.\n"
665              "Show filter <filter> will show the definition of a particular\n"
666              "     filter.\n\n"
667              "Show startup will display the custom startup config\n\n"
668              "Show zpunts will show the active zpunt filters.\n\n"
669              "Show keymaps will list the names of all keymaps.\n"
670              "Show keymap <keymap> will show the key bindings in a keymap.\n\n"
671              "Show commands will list the names of all keymaps.\n"
672              "Show command <command> will provide information about a command.\n\n"
673              "Show styles will list the names of all styles available\n"
674              "for formatting messages.\n\n"
675              "Show variables will list the names of all variables.\n\n"
676              "Show errors will show a list of errors ecountered by Owl.\n\n"
677              "SEE ALSO: filter, view, alias, bindkey, help\n"),
678 
679  OWLCMD_ARGS("delete", owl_command_delete, OWL_CTX_INTERACTIVE,
680              "mark a message for deletion",
681              "delete [ -id msgid ] [ --no-move ]\n"
682              "delete view\n"
683              "delete trash",
684              "If no message id is specified the current message is marked\n"
685              "for deletion.  Otherwise the message with the given message\n"
686              "id is marked for deltion.\n"
687              "If '--no-move' is specified, don't move after deletion.\n"
688              "If 'trash' is specified, deletes all trash/auto messages\n"
689              "in the current view.\n"
690              "If 'view' is specified, deletes all messages in the\n"
691              "current view.\n"),
692  OWLCMD_ALIAS("del", "delete"),
693
694  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
695              "unmark a message for deletion",
696              "undelete [ -id msgid ] [ --no-move ]\n"
697              "undelete view",
698              "If no message id is specified the current message is\n"
699              "unmarked for deletion.  Otherwise the message with the\n"
700              "given message id is marked for undeltion.\n"
701              "If '--no-move' is specified, don't move after deletion.\n"
702              "If 'view' is specified, undeletes all messages\n"
703              "in the current view.\n"),
704  OWLCMD_ALIAS("undel", "undelete"),
705
706  OWLCMD_VOID("beep", owl_command_beep, OWL_CTX_ANY,
707              "ring the terminal bell",
708              "beep",
709              "Beep will ring the terminal bell.\n"
710              "If the variable 'bell' has been\n"
711              "set to 'off' this command does nothing.\n"),
712
713  OWLCMD_ARGS("debug", owl_command_debug, OWL_CTX_ANY,
714              "prints a message into the debug log",
715              "debug <message>", ""),
716
717  OWLCMD_ARGS("getview", owl_command_getview, OWL_CTX_INTERACTIVE,
718              "returns the name of the filter for the current view",
719              "", ""),
720
721  OWLCMD_ARGS("getvar", owl_command_getvar, OWL_CTX_INTERACTIVE,
722              "returns the value of a variable",
723              "getvar <varname>", ""),
724
725  OWLCMD_ARGS("getstyle", owl_command_getstyle, OWL_CTX_INTERACTIVE,
726              "returns the name of the style for the current view",
727              "", ""),
728
729  OWLCMD_ARGS("search", owl_command_search, OWL_CTX_INTERACTIVE,
730              "search messages for a particular string",
731              "search [-r] [<string>]",
732              "The search command will find messages that contain the\n"
733              "specified string and move the cursor there.  If no string\n"
734              "argument is supplied then the previous one is used.  By\n"
735              "default searches are done fowards, if -r is used the search\n"
736              "is performed backwards"),
737
738  OWLCMD_ARGS("setsearch", owl_command_setsearch, OWL_CTX_INTERACTIVE,
739              "set the search highlight string without searching",
740              "setsearch <string>",
741              "The setsearch command highlights all occurences of its\n"
742          "argument and makes it the default argument for future\n"
743          "search commands, but does not move the cursor.  With\n"
744          "no argument, it makes search inactive."),
745
746  OWLCMD_ARGS("aimlogin", owl_command_aimlogin, OWL_CTX_ANY,
747              "login to an AIM account",
748              "aimlogin <screenname> [<password>]\n",
749              ""),
750
751  OWLCMD_ARGS("aimlogout", owl_command_aimlogout, OWL_CTX_ANY,
752              "logout from AIM",
753              "aimlogout\n",
754              ""),
755
756  OWLCMD_ARGS("error", owl_command_error, OWL_CTX_ANY,
757              "Display an error message",
758              "error <message>",
759              ""),
760
761  OWLCMD_ARGS("message", owl_command_message, OWL_CTX_ANY,
762              "Display an informatative message",
763              "message <message>",
764              ""),
765
766  OWLCMD_VOID("yes", owl_command_yes, OWL_CTX_RECV,
767              "Answer yes to a question",
768              "yes",
769              ""),
770
771  OWLCMD_VOID("no", owl_command_no, OWL_CTX_RECV,
772              "Answer no to a question",
773              "no",
774              ""),
775
776  /****************************************************************/
777  /************************* EDIT-SPECIFIC ************************/
778  /****************************************************************/
779
780  OWLCMD_VOID_CTX("edit:move-next-word", owl_editwin_move_to_nextword, 
781                  OWL_CTX_EDIT,
782                  "moves cursor forward a word",
783                  "", ""),
784
785  OWLCMD_VOID_CTX("edit:move-prev-word", owl_editwin_move_to_previousword, 
786                  OWL_CTX_EDIT,
787                  "moves cursor backwards a word",
788                  "", ""),
789
790  OWLCMD_VOID_CTX("edit:move-to-buffer-start", owl_editwin_move_to_top,
791                  OWL_CTX_EDIT,
792                  "moves cursor to the top left (start) of the buffer",
793                  "", ""),
794
795  OWLCMD_VOID_CTX("edit:move-to-buffer-end", owl_editwin_move_to_end, 
796                  OWL_CTX_EDIT,
797                  "moves cursor to the bottom right (end) of the buffer",
798                  "", ""),
799
800  OWLCMD_VOID_CTX("edit:move-to-line-end", owl_editwin_move_to_line_end, 
801                  OWL_CTX_EDIT,
802                  "moves cursor to the end of the line",
803                  "", ""),
804
805  OWLCMD_VOID_CTX("edit:move-to-line-start", owl_editwin_move_to_line_start, 
806                  OWL_CTX_EDIT,
807                  "moves cursor to the beginning of the line",
808                  "", ""),
809
810  OWLCMD_VOID_CTX("edit:move-left", owl_editwin_key_left, 
811                  OWL_CTX_EDIT,
812                  "moves the cursor left by a character",
813                  "", ""),
814
815  OWLCMD_VOID_CTX("edit:move-right", owl_editwin_key_right,
816                  OWL_CTX_EDIT,
817                  "moves the cursor right by a character",
818                  "", ""),
819
820  OWLCMD_VOID_CTX("edit:delete-next-word", owl_editwin_delete_nextword,
821                  OWL_CTX_EDIT,
822                  "deletes the word to the right of the cursor",
823                  "", ""),
824
825  OWLCMD_VOID_CTX("edit:delete-prev-word", owl_editwin_delete_previousword,
826                  OWL_CTX_EDIT,
827                  "deletes the word to the left of the cursor",
828                  "", ""),
829
830  OWLCMD_VOID_CTX("edit:delete-prev-char", owl_editwin_backspace,
831                  OWL_CTX_EDIT,
832                  "deletes the character to the left of the cursor",
833                  "", ""),
834
835  OWLCMD_VOID_CTX("edit:delete-next-char", owl_editwin_delete_char, 
836                  OWL_CTX_EDIT,
837                  "deletes the character to the right of the cursor",
838                  "", ""),
839
840  OWLCMD_VOID_CTX("edit:delete-to-line-end", owl_editwin_delete_to_endofline,
841                  OWL_CTX_EDIT,
842                  "deletes from the cursor to the end of the line",
843                  "", ""),
844
845  OWLCMD_VOID_CTX("edit:delete-all", owl_editwin_clear, 
846                  OWL_CTX_EDIT,
847                  "deletes all of the contents of the buffer",
848                  "", ""),
849
850  OWLCMD_VOID_CTX("edit:transpose-chars", owl_editwin_transpose_chars,
851                  OWL_CTX_EDIT,
852                  "Interchange characters around point, moving forward one character.",
853                  "", ""),
854
855  OWLCMD_VOID_CTX("edit:fill-paragraph", owl_editwin_fill_paragraph, 
856                  OWL_CTX_EDIT,
857                  "fills the current paragraph to line-wrap well",
858                  "", ""),
859
860  OWLCMD_VOID_CTX("edit:recenter", owl_editwin_recenter, 
861                  OWL_CTX_EDIT,
862                  "recenters the buffer",
863                  "", ""),
864
865  OWLCMD_ARGS_CTX("edit:insert-text", owl_command_edit_insert_text, 
866                  OWL_CTX_EDIT,
867                  "inserts text into the buffer",
868                  "edit:insert-text <text>", ""),
869
870  OWLCMD_VOID_CTX("edit:cancel", owl_command_edit_cancel, 
871                  OWL_CTX_EDIT,
872                  "cancels the current command",
873                  "", ""),
874
875  OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next, 
876                  OWL_CTX_EDIT,
877                  "replaces the text with the previous history",
878                  "", ""),
879
880  OWLCMD_VOID_CTX("edit:history-prev", owl_command_edit_history_prev, 
881                  OWL_CTX_EDIT,
882                  "replaces the text with the previous history",
883                  "", ""),
884
885  OWLCMD_VOID_CTX("editline:done", owl_command_editline_done, 
886                  OWL_CTX_EDITLINE,
887                  "completes the command (eg, executes command being composed)",
888                  "", ""),
889
890  OWLCMD_VOID_CTX("editresponse:done", owl_command_editresponse_done, 
891                  OWL_CTX_EDITRESPONSE,
892                  "completes the response to a question",
893                  "", ""),
894
895  OWLCMD_VOID_CTX("editmulti:move-up-line", owl_editwin_key_up, 
896                  OWL_CTX_EDITMULTI,
897                  "moves the cursor up one line",
898                  "", ""),
899
900  OWLCMD_VOID_CTX("editmulti:move-down-line", owl_editwin_key_down, 
901                  OWL_CTX_EDITMULTI,
902                  "moves the cursor down one line",
903                  "", ""),
904
905  OWLCMD_VOID_CTX("editmulti:done", owl_command_editmulti_done, 
906                  OWL_CTX_EDITMULTI,
907                  "completes the command (eg, sends message being composed)",
908                  "", ""),
909
910  OWLCMD_VOID_CTX("editmulti:done-or-delete", owl_command_editmulti_done_or_delete, 
911                  OWL_CTX_EDITMULTI,
912                  "completes the command, but only if at end of message",
913                  "", 
914                  "If only whitespace is to the right of the cursor,\n"
915                  "runs 'editmulti:done'.\n"\
916                  "Otherwise runs 'edit:delete-next-char'\n"),
917
918  /****************************************************************/
919  /********************** POPLESS-SPECIFIC ************************/
920  /****************************************************************/
921
922  OWLCMD_VOID_CTX("popless:scroll-down-page", owl_viewwin_pagedown, 
923                  OWL_CTX_POPLESS,
924                  "scrolls down one page",
925                  "", ""),
926
927  OWLCMD_VOID_CTX("popless:scroll-down-line", owl_viewwin_linedown, 
928                  OWL_CTX_POPLESS,
929                  "scrolls down one line",
930                  "", ""),
931
932  OWLCMD_VOID_CTX("popless:scroll-up-page", owl_viewwin_pageup, 
933                  OWL_CTX_POPLESS,
934                  "scrolls up one page",
935                  "", ""),
936
937  OWLCMD_VOID_CTX("popless:scroll-up-line", owl_viewwin_lineup, 
938                  OWL_CTX_POPLESS,
939                  "scrolls up one line",
940                  "", ""),
941
942  OWLCMD_VOID_CTX("popless:scroll-to-top", owl_viewwin_top, 
943                  OWL_CTX_POPLESS,
944                  "scrolls to the top of the buffer",
945                  "", ""),
946
947  OWLCMD_VOID_CTX("popless:scroll-to-bottom", owl_viewwin_bottom, 
948                  OWL_CTX_POPLESS,
949                  "scrolls to the bottom of the buffer",
950                  "", ""),
951
952  OWLCMD_INT_CTX ("popless:scroll-right", owl_viewwin_right, 
953                  OWL_CTX_POPLESS,
954                  "scrolls right in the buffer",
955                  "popless:scroll-right <num-chars>", ""),
956
957  OWLCMD_INT_CTX ("popless:scroll-left", owl_viewwin_left, 
958                  OWL_CTX_POPLESS,
959                  "scrolls left in the buffer",
960                  "popless:scroll-left <num-chars>", ""),
961
962  OWLCMD_VOID_CTX("popless:quit", owl_command_popless_quit, 
963                  OWL_CTX_POPLESS,
964                  "exits the popless window",
965                  "", ""),
966
967  /* This line MUST be last! */
968  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
969
970};
971
972void owl_command_info()
973{
974  owl_function_info();
975}
976
977void owl_command_nop()
978{
979}
980
981char *owl_command_help(int argc, char **argv, char *buff)
982{
983  if (argc!=2) {
984    owl_help();
985    return NULL;
986  }
987 
988  owl_function_help_for_command(argv[1]);
989  return NULL;
990}
991
992char *owl_command_zlist(int argc, char **argv, char *buff)
993{
994  int elapsed=0, timesort=0;
995  char *file=NULL;
996
997  argc--;
998  argv++;
999  while (argc) {
1000    if (!strcmp(argv[0], "-e")) {
1001      elapsed=1;
1002      argc--;
1003      argv++;
1004    } else if (!strcmp(argv[0], "-t")) {
1005      timesort=1;
1006      argc--;
1007      argv++;
1008    } else if (!strcmp(argv[0], "-f")) {
1009      if (argc==1) {
1010        owl_function_makemsg("zlist: -f needs an argument");
1011        return(NULL);
1012      }
1013      file=argv[1];
1014      argc-=2;
1015      argv+=2;
1016    } else {
1017      owl_function_makemsg("zlist: unknown argument");
1018      return(NULL);
1019    }
1020  }
1021  owl_function_buddylist(0, 1, file);
1022  return(NULL);
1023}
1024
1025char *owl_command_alist()
1026{
1027  owl_function_buddylist(1, 0, NULL);
1028  return(NULL);
1029}
1030
1031char *owl_command_blist()
1032{
1033  owl_function_buddylist(1, 1, NULL);
1034  return(NULL);
1035}
1036
1037char *owl_command_toggleoneline()
1038{
1039  owl_function_toggleoneline();
1040  return(NULL);
1041}
1042
1043void owl_command_about()
1044{
1045  owl_function_about();
1046}
1047
1048void owl_command_version()
1049{
1050  char buff[1024];
1051
1052  sprintf(buff, "Owl version %s", OWL_VERSION_STRING);
1053  owl_function_makemsg(buff);
1054}
1055
1056char *owl_command_aim(int argc, char **argv, char *buff)
1057{
1058  if (argc<2) {
1059    owl_function_makemsg("not enough arguments to aim command");
1060    return(NULL);
1061  }
1062
1063  if (!strcmp(argv[1], "search")) {
1064    if (argc!=3) {
1065      owl_function_makemsg("not enough arguments to aim search command");
1066      return(NULL);
1067    }
1068    owl_aim_search(argv[2]);
1069  } else {
1070    owl_function_makemsg("unknown subcommand '%s' for aim command", argv[1]);
1071    return(NULL);
1072  }
1073  return(NULL);
1074}
1075
1076char *owl_command_addbuddy(int argc, char **argv, char *buff)
1077{
1078  if (argc!=3) {
1079    owl_function_makemsg("usage: addbuddy <protocol> <buddyname>");
1080    return(NULL);
1081  }
1082
1083  if (!strcasecmp(argv[1], "aim")) {
1084    if (!owl_global_is_aimloggedin(&g)) {
1085      owl_function_makemsg("addbuddy: You must be logged into aim to use this command.");
1086      return(NULL);
1087    }
1088    /*
1089    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
1090    return(NULL);
1091    */
1092    owl_aim_addbuddy(argv[2]);
1093    owl_function_makemsg("%s added as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
1094  } else if (!strcasecmp(argv[1], "zephyr")) {
1095    owl_zephyr_addbuddy(argv[2]);
1096    owl_function_makemsg("%s added as zephyr buddy", argv[2]);
1097  } else {
1098    owl_function_makemsg("addbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
1099  }
1100
1101  return(NULL);
1102}
1103
1104char *owl_command_delbuddy(int argc, char **argv, char *buff)
1105{
1106  if (argc!=3) {
1107    owl_function_makemsg("usage: delbuddy <protocol> <buddyname>");
1108    return(NULL);
1109  }
1110
1111  if (!strcasecmp(argv[1], "aim")) {
1112    if (!owl_global_is_aimloggedin(&g)) {
1113      owl_function_makemsg("delbuddy: You must be logged into aim to use this command.");
1114      return(NULL);
1115    }
1116    owl_aim_delbuddy(argv[2]);
1117    owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
1118  } else if (!strcasecmp(argv[1], "zephyr")) {
1119    owl_zephyr_delbuddy(argv[2]);
1120    owl_function_makemsg("%s deleted as zephyr buddy", argv[2]);
1121  } else {
1122    owl_function_makemsg("delbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
1123  }
1124
1125  return(NULL);
1126}
1127
1128char *owl_command_join(int argc, char **argv, char *buff)
1129{
1130  if (argc!=3 && argc!=4) {
1131    owl_function_makemsg("usage: join <protocol> <buddyname> [exchange]");
1132    return(NULL);
1133  }
1134
1135  if (!strcasecmp(argv[1], "aim")) {
1136    if (!owl_global_is_aimloggedin(&g)) {
1137      owl_function_makemsg("join aim: You must be logged into aim to use this command.");
1138      return(NULL);
1139    }
1140    if (argc==3) {
1141      owl_aim_chat_join(argv[2], 4);
1142    } else {
1143      owl_aim_chat_join(argv[2], atoi(argv[3]));
1144    }
1145    /* owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g)); */
1146  } else {
1147    owl_function_makemsg("join: currently the only supported protocol is 'aim'");
1148  }
1149  return(NULL);
1150}
1151
1152char *owl_command_startup(int argc, char **argv, char *buff)
1153{
1154  char *ptr;
1155
1156  if (argc<2) {
1157    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
1158    return(NULL);
1159  }
1160
1161  ptr=strchr(buff, ' ');
1162  if (!ptr) {
1163    owl_function_makemsg("Parse error finding command for startup");
1164    return(NULL);
1165  }
1166
1167  owl_function_command(ptr+1);
1168  owl_function_addstartup(ptr+1);
1169
1170  return(NULL);
1171}
1172
1173char *owl_command_unstartup(int argc, char **argv, char *buff)
1174{
1175  char *ptr;
1176
1177  if (argc<2) {
1178    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
1179    return(NULL);
1180  }
1181
1182  ptr=strchr(buff, ' ');
1183  if (!ptr) {
1184    owl_function_makemsg("Parse error finding command for unstartup");
1185    return(NULL);
1186  }
1187
1188  owl_function_delstartup(ptr+1);
1189
1190  return(NULL);
1191}
1192
1193char *owl_command_dump(int argc, char **argv, char *buff)
1194{
1195  char *filename;
1196 
1197  if (argc!=2) {
1198    owl_function_makemsg("usage: dump <filename>");
1199    return(NULL);
1200  }
1201  filename=owl_util_makepath(argv[1]);
1202  owl_function_dump(filename);
1203  owl_free(filename);
1204  return(NULL);
1205}
1206
1207char *owl_command_source(int argc, char **argv, char *buff)
1208{
1209  if (argc!=2) {
1210    owl_function_makemsg("usage: source <filename>");
1211    return(NULL);
1212  }
1213
1214  owl_function_source(argv[1]);
1215  return(NULL);
1216}
1217
1218char *owl_command_next(int argc, char **argv, char *buff)
1219{
1220  char *filter=NULL;
1221  int skip_deleted=0, last_if_none=0;
1222  while (argc>1) {
1223    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1224      skip_deleted=1;
1225      argc-=1; argv+=1; 
1226    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
1227      last_if_none=1;
1228      argc-=1; argv+=1; 
1229    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1230      filter = owl_strdup(argv[2]);
1231      argc-=2; argv+=2; 
1232    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1233      filter = owl_function_smartfilter(0);
1234      argc-=2; argv+=2; 
1235    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1236      filter = owl_function_smartfilter(1);
1237      argc-=2; argv+=2; 
1238    } else {
1239      owl_function_makemsg("Invalid arguments to command 'next'.");
1240      return(NULL);
1241    }
1242  }
1243  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
1244  if (filter) owl_free(filter);
1245  return(NULL);
1246}
1247
1248char *owl_command_prev(int argc, char **argv, char *buff)
1249{
1250  char *filter=NULL;
1251  int skip_deleted=0, first_if_none=0;
1252  while (argc>1) {
1253    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1254      skip_deleted=1;
1255      argc-=1; argv+=1; 
1256    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
1257      first_if_none=1;
1258      argc-=1; argv+=1; 
1259    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1260      filter = owl_strdup(argv[2]);
1261      argc-=2; argv+=2; 
1262    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1263      filter = owl_function_smartfilter(0);
1264      argc-=2; argv+=2; 
1265    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1266      filter = owl_function_smartfilter(1);
1267      argc-=2; argv+=2; 
1268   } else {
1269      owl_function_makemsg("Invalid arguments to command 'prev'.");
1270      return(NULL);
1271    }
1272  }
1273  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
1274  if (filter) owl_free(filter);
1275  return(NULL);
1276}
1277
1278char *owl_command_smartnarrow(int argc, char **argv, char *buff)
1279{
1280  char *filtname = NULL;
1281
1282  if (argc == 1) {
1283    filtname = owl_function_smartfilter(0);
1284  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1285    filtname = owl_function_smartfilter(1);
1286  } else {
1287    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1288  }
1289  if (filtname) {
1290    owl_function_change_currentview_filter(filtname);
1291    owl_free(filtname);
1292  }
1293  return NULL;
1294}
1295
1296char *owl_command_smartfilter(int argc, char **argv, char *buff)
1297{
1298  char *filtname = NULL;
1299
1300  if (argc == 1) {
1301    filtname = owl_function_smartfilter(0);
1302  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1303    filtname = owl_function_smartfilter(1);
1304  } else {
1305    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1306  }
1307  return filtname;
1308}
1309
1310void owl_command_expunge()
1311{
1312  owl_function_expunge();
1313}
1314
1315void owl_command_first()
1316{
1317  owl_global_set_rightshift(&g, 0);
1318  owl_function_firstmsg();
1319}
1320
1321void owl_command_last()
1322{
1323  owl_function_lastmsg();
1324}
1325
1326void owl_command_resize()
1327{
1328  owl_function_resize();
1329}
1330
1331void owl_command_redisplay()
1332{
1333  owl_function_full_redisplay();
1334  owl_global_set_needrefresh(&g);
1335}
1336
1337void owl_command_shift_right()
1338{
1339  owl_function_shift_right();
1340}
1341
1342void owl_command_shift_left()
1343{
1344  owl_function_shift_left();
1345}
1346
1347void owl_command_unsuball()
1348{
1349  owl_function_unsuball();
1350}
1351
1352char *owl_command_loadsubs(int argc, char **argv, char *buff)
1353{
1354  if (argc == 2) {
1355    owl_function_loadsubs(argv[1]);
1356  } else if (argc == 1) {
1357    owl_function_loadsubs(NULL);
1358  } else {
1359    owl_function_makemsg("Wrong number of arguments for load-subs.");
1360    return(NULL);
1361  }
1362  return(NULL);
1363}
1364
1365
1366char *owl_command_loadloginsubs(int argc, char **argv, char *buff)
1367{
1368  if (argc == 2) {
1369    owl_function_loadloginsubs(argv[1]);
1370  } else if (argc == 1) {
1371    owl_function_loadloginsubs(NULL);
1372  } else {
1373    owl_function_makemsg("Wrong number of arguments for load-subs.");
1374    return(NULL);
1375  }
1376  return(NULL);
1377}
1378
1379void owl_command_suspend()
1380{
1381  owl_function_suspend();
1382}
1383
1384char *owl_command_start_command(int argc, char **argv, char *buff)
1385{
1386  buff = skiptokens(buff, 1);
1387  owl_function_start_command(buff);
1388  return(NULL);
1389}
1390
1391char *owl_command_start_question(int argc, char **argv, char *buff)
1392{
1393  buff = skiptokens(buff, 1);
1394  owl_function_start_question(buff);
1395  return(NULL);
1396}
1397
1398char *owl_command_start_password(int argc, char **argv, char *buff)
1399{
1400  buff = skiptokens(buff, 1);
1401  owl_function_start_password(buff);
1402  return(NULL);
1403}
1404
1405char *owl_command_zaway(int argc, char **argv, char *buff)
1406{
1407  if ((argc==1) ||
1408      ((argc==2) && !strcmp(argv[1], "on"))) {
1409    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1410    owl_function_zaway_on();
1411    return NULL;
1412  }
1413
1414  if (argc==2 && !strcmp(argv[1], "off")) {
1415    owl_function_zaway_off();
1416    return NULL;
1417  }
1418
1419  if (argc==2 && !strcmp(argv[1], "toggle")) {
1420    owl_function_zaway_toggle();
1421    return NULL;
1422  }
1423
1424  buff = skiptokens(buff, 1);
1425  owl_global_set_zaway_msg(&g, buff);
1426  owl_function_zaway_on();
1427  return NULL;
1428}
1429
1430
1431char *owl_command_aaway(int argc, char **argv, char *buff)
1432{
1433  if ((argc==1) ||
1434      ((argc==2) && !strcmp(argv[1], "on"))) {
1435    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
1436    owl_function_aaway_on();
1437    return NULL;
1438  }
1439
1440  if (argc==2 && !strcmp(argv[1], "off")) {
1441    owl_function_aaway_off();
1442    return NULL;
1443  }
1444
1445  if (argc==2 && !strcmp(argv[1], "toggle")) {
1446    owl_function_aaway_toggle();
1447    return NULL;
1448  }
1449
1450  buff = skiptokens(buff, 1);
1451  owl_global_set_aaway_msg(&g, buff);
1452  owl_function_aaway_on();
1453  return NULL;
1454}
1455
1456
1457char *owl_command_away(int argc, char **argv, char *buff)
1458{
1459  if ((argc==1) ||
1460      ((argc==2) && !strcmp(argv[1], "on"))) {
1461    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
1462    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1463    owl_function_aaway_on();
1464    owl_function_zaway_on();
1465    owl_function_makemsg("Away messages set.", owl_global_get_aaway_msg_default(&g));
1466    return NULL;
1467  }
1468
1469  if (argc==2 && !strcmp(argv[1], "off")) {
1470    owl_function_aaway_off();
1471    owl_function_zaway_off();
1472    return NULL;
1473  }
1474
1475  if (argc==2 && !strcmp(argv[1], "toggle")) {
1476    /* if either one is on, turn it off, otherwise toggle both (turn
1477     *  them both on)
1478     */
1479    if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) {
1480      owl_function_aaway_toggle();
1481      owl_function_zaway_toggle();
1482      owl_function_makemsg("Away messages set.");
1483    } else {
1484      if (owl_global_is_zaway(&g)) owl_function_zaway_toggle();
1485      if (owl_global_is_aaway(&g)) owl_function_aaway_toggle();
1486      owl_function_makemsg("Away messages off.");
1487    }
1488    return NULL;
1489  }
1490
1491  buff = skiptokens(buff, 1);
1492  owl_global_set_aaway_msg(&g, buff);
1493  owl_global_set_zaway_msg(&g, buff);
1494  owl_function_aaway_on();
1495  owl_function_zaway_on();
1496  owl_function_makemsg("Away messages set.");
1497  return NULL;
1498}
1499
1500char *owl_command_set(int argc, char **argv, char *buff)
1501{
1502  char *var, *val;
1503  int  silent=0;
1504  int requirebool=0;
1505
1506  if (argc == 1) {
1507    owl_function_printallvars();
1508    return NULL;
1509  } 
1510
1511  if (argc > 1 && !strcmp("-q",argv[1])) {
1512    silent = 1;
1513    argc--; argv++;
1514  }
1515
1516  if (argc == 2) {
1517    var=argv[1];
1518    val="on";
1519    requirebool=1;
1520  } else if (argc == 3) {
1521    var=argv[1];
1522    val=argv[2];
1523  } else {
1524    owl_function_makemsg("Wrong number of arguments for set command");
1525    return NULL;
1526  }
1527  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
1528  return NULL;
1529}
1530
1531char *owl_command_unset(int argc, char **argv, char *buff)
1532{
1533  char *var, *val;
1534  int  silent=0;
1535
1536  if (argc > 1 && !strcmp("-q",argv[1])) {
1537    silent = 1;
1538    argc--; argv++;
1539  }
1540  if (argc == 2) {
1541    var=argv[1];
1542    val="off";
1543  } else {
1544    owl_function_makemsg("Wrong number of arguments for unset command");
1545    return NULL;
1546  }
1547  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
1548  return NULL;
1549}
1550
1551char *owl_command_print(int argc, char **argv, char *buff)
1552{
1553  char *var;
1554  char valbuff[1024];
1555
1556  if (argc==1) {
1557    owl_function_printallvars();
1558    return NULL;
1559  } else if (argc!=2) {
1560    owl_function_makemsg("Wrong number of arguments for print command");
1561    return NULL;
1562  }
1563
1564  var=argv[1];
1565   
1566  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
1567                                     var, valbuff, 1024)) {
1568    owl_function_makemsg("%s = '%s'", var, valbuff);
1569  } else {
1570    owl_function_makemsg("Unknown variable '%s'.", var);
1571  }
1572  return NULL;
1573}
1574
1575
1576char *owl_command_exec(int argc, char **argv, char *buff)
1577{
1578  return owl_function_exec(argc, argv, buff, 0);
1579}
1580
1581char *owl_command_pexec(int argc, char **argv, char *buff)
1582{
1583  return owl_function_exec(argc, argv, buff, 1);
1584}
1585
1586char *owl_command_aexec(int argc, char **argv, char *buff)
1587{
1588  return owl_function_exec(argc, argv, buff, 2);
1589}
1590
1591char *owl_command_perl(int argc, char **argv, char *buff)
1592{
1593  return owl_function_perl(argc, argv, buff, 0);
1594}
1595
1596char *owl_command_pperl(int argc, char **argv, char *buff)
1597{
1598  return owl_function_perl(argc, argv, buff, 1);
1599}
1600
1601char *owl_command_aperl(int argc, char **argv, char *buff)
1602{
1603  return owl_function_perl(argc, argv, buff, 2);
1604}
1605
1606char *owl_command_multi(int argc, char **argv, char *buff)
1607{
1608  char *lastrv = NULL, *dupbuff, *newbuff;
1609  char **commands;
1610  int  ncommands, i;
1611  if (argc < 2) {
1612    owl_function_makemsg("Invalid arguments to 'multi' command.");   
1613    return NULL;
1614  }
1615  dupbuff = owl_strdup(buff);
1616  newbuff = skiptokens(dupbuff, 1);
1617  if (!strcmp(argv[0], "(")) {
1618    for (i=strlen(newbuff)-1; i>=0; i--) {
1619      if (newbuff[i] == ')') {
1620        newbuff[i] = '\0';
1621        break;
1622      } else if (newbuff[i] != ' ') {
1623        owl_function_makemsg("Invalid arguments to 'multi' command.");   
1624        owl_free(newbuff);
1625        return NULL;
1626      }
1627    }
1628  }
1629  commands = atokenize(newbuff, ";", &ncommands);
1630  for (i=0; i<ncommands; i++) {
1631    if (lastrv) {
1632      owl_free(lastrv);
1633    }
1634    lastrv = owl_function_command(commands[i]);
1635  }
1636  owl_free(dupbuff);
1637  atokenize_free(commands, ncommands);
1638  return lastrv;
1639}
1640
1641
1642char *owl_command_alias(int argc, char **argv, char *buff)
1643{
1644  if (argc < 3) {
1645    owl_function_makemsg("Invalid arguments to 'alias' command.");
1646    return NULL;
1647  }
1648  buff = skiptokens(buff, 2);
1649  owl_function_command_alias(argv[1], buff);
1650  return (NULL);
1651}
1652
1653
1654char *owl_command_bindkey(int argc, char **argv, char *buff)
1655{
1656  owl_keymap *km;
1657  int ret;
1658
1659  if (argc < 5 || strcmp(argv[3], "command")) {
1660    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>");
1661    return NULL;
1662  }
1663  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
1664  if (!km) {
1665    owl_function_makemsg("No such keymap '%s'", argv[1]);
1666    return NULL;
1667  }
1668  buff = skiptokens(buff, 4);
1669  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
1670  if (ret!=0) {
1671    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
1672                         argv[2], argv[1], buff);
1673    return NULL;
1674  }
1675  return NULL;
1676}
1677
1678char *owl_command_style(int argc, char **argv, char *buff) {
1679  owl_style *s;
1680
1681  /* Usage: style <name> perl <function> */
1682  if (argc != 4 || strcmp(argv[2], "perl")) {
1683    owl_function_makemsg("Usage: style <name> perl <function>");
1684    return NULL;
1685  }
1686  if (!owl_perlconfig_is_function(argv[3])) {
1687    owl_function_makemsg("Unable to create style '%s': no perl function '%s'",
1688                         argv[1], argv[3]);
1689    return NULL;
1690  }
1691  s=owl_malloc(sizeof(owl_style));
1692  owl_style_create_perl(s, argv[1], argv[3], NULL);
1693  owl_global_add_style(&g, s);
1694
1695  return NULL;
1696}
1697
1698
1699void owl_command_quit()
1700{
1701  owl_function_quit();
1702}
1703
1704char *owl_command_debug(int argc, char **argv, char *buff)
1705{
1706  if (argc<2) {
1707    owl_function_makemsg("Need at least one argument to debug command");
1708    return(NULL);
1709  }
1710
1711  if (!owl_global_is_debug_fast(&g)) {
1712    owl_function_makemsg("Debugging is not turned on");
1713    return(NULL);
1714  }
1715
1716  owl_function_debugmsg(argv[1]);
1717  return(NULL);
1718}
1719
1720char *owl_command_term(int argc, char **argv, char *buff)
1721{
1722  if (argc<2) {
1723    owl_function_makemsg("Need at least one argument to the term command");
1724    return(NULL);
1725  }
1726
1727  if (!strcmp(argv[1], "raise")) {
1728    owl_function_xterm_raise();
1729  } else if (!strcmp(argv[1], "deiconify")) {
1730    owl_function_xterm_deiconify();
1731  } else {
1732    owl_function_makemsg("Unknown terminal subcommand");
1733  }
1734  return(NULL);
1735}
1736
1737char *owl_command_zlog(int argc, char **argv, char *buff)
1738{
1739  if ((argc<2) || (argc>3)) {
1740    owl_function_makemsg("Wrong number of arguments for zlog command");
1741    return(NULL);
1742  }
1743
1744  if (!strcmp(argv[1], "in")) {
1745    if (argc>2) {
1746      owl_global_set_tty(&g, argv[2]);
1747    }
1748    owl_zephyr_zlog_in();
1749  } else if (!strcmp(argv[1], "out")) {
1750    if (argc!=2) {
1751      owl_function_makemsg("Wrong number of arguments for zlog command");
1752      return(NULL);
1753    }
1754    owl_zephyr_zlog_out();
1755  } else {
1756    owl_function_makemsg("Invalid subcommand for zlog");
1757  }
1758  return(NULL);
1759}
1760
1761
1762void owl_command_zlog_out(void)
1763{
1764  owl_zephyr_zlog_out();
1765}
1766
1767
1768char *owl_command_subscribe(int argc, char **argv, char *buff)
1769{
1770  char *recip="";
1771  int temp=0;
1772 
1773  if (argc<3) {
1774    owl_function_makemsg("Not enough arguments to the subscribe command");
1775    return(NULL);
1776  }
1777  argc--;
1778  argv++;
1779
1780  if (!strcmp(argv[0], "-t")) {
1781    temp=1;
1782    argc--;
1783    argv++;
1784  }
1785  if (argc<2) {
1786    owl_function_makemsg("Not enough arguments to the subscribe command");
1787    return(NULL);
1788  }
1789
1790  if (argc>3) {
1791    owl_function_makemsg("Too many arguments to the subscribe command");
1792    return(NULL);
1793  }
1794
1795  if (argc==2) {
1796    recip="";
1797  } else if (argc==3) {
1798    recip=argv[2];
1799  }
1800
1801  owl_function_subscribe(argv[0], argv[1], recip);
1802  if (!temp) {
1803    owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
1804  }
1805  return(NULL);
1806}
1807
1808
1809char *owl_command_unsubscribe(int argc, char **argv, char *buff)
1810{
1811  char *recip="";
1812  int temp=0;
1813
1814  if (argc<3) {
1815    owl_function_makemsg("Not enough arguments to the unsubscribe command");
1816    return(NULL);
1817  }
1818  argc--;
1819  argv++;
1820
1821  if (!strcmp(argv[0], "-t")) {
1822    temp=1;
1823    argc--;
1824    argv++;
1825  }
1826  if (argc<2) {
1827    owl_function_makemsg("Not enough arguments to the subscribe command");
1828    return(NULL);
1829  }
1830
1831  if (argc>3) {
1832    owl_function_makemsg("Too many arguments to the unsubscribe command");
1833    return(NULL);
1834  }
1835
1836  if (argc==2) {
1837    recip="";
1838  } else if (argc==3) {
1839    recip=argv[2];
1840  }
1841
1842  owl_function_unsubscribe(argv[0], argv[1], recip);
1843  if (!temp) {
1844    owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
1845  }
1846  return(NULL);
1847}
1848
1849char *owl_command_echo(int argc, char **argv, char *buff)
1850{
1851  buff = skiptokens(buff, 1);
1852  owl_function_popless_text(buff);
1853  return NULL;
1854}
1855
1856void owl_command_getsubs(void)
1857{
1858  owl_function_getsubs();
1859}
1860
1861void owl_command_status(void)
1862{
1863  owl_function_status();
1864}
1865
1866char *owl_command_zwrite(int argc, char **argv, char *buff)
1867{
1868  owl_zwrite z;
1869
1870  if (!owl_global_is_havezephyr(&g)) {
1871    owl_function_makemsg("Zephyr is not available");
1872    return(NULL);
1873  }
1874  /* check for a zwrite -m */
1875  owl_zwrite_create_from_line(&z, buff);
1876  if (owl_zwrite_is_message_set(&z)) {
1877    owl_function_zwrite(buff, NULL);
1878    owl_zwrite_free(&z);
1879    return (NULL);
1880  }
1881
1882  if (argc < 2) {
1883    owl_function_makemsg("Not enough arguments to the zwrite command.");
1884  } else {
1885    owl_function_zwrite_setup(buff);
1886  }
1887  return(NULL);
1888}
1889
1890char *owl_command_aimwrite(int argc, char **argv, char *buff)
1891{
1892  char *newbuff, *recip, **myargv;
1893  int i, j, myargc;
1894 
1895  if (!owl_global_is_aimloggedin(&g)) {
1896    owl_function_makemsg("You are not logged in to AIM.");
1897    return(NULL);
1898  }
1899
1900  if (argc < 2) {
1901    owl_function_makemsg("Not enough arguments to the aimwrite command.");
1902    return(NULL);
1903  }
1904
1905  myargv=argv;
1906  if (argc<0) {
1907    owl_function_error("Unbalanced quotes in aimwrite");
1908    return(NULL);
1909  }
1910  myargc=argc;
1911  if (myargc && *(myargv[0])!='-') {
1912    myargc--;
1913    myargv++;
1914  }
1915  while (myargc) {
1916    if (!strcmp(myargv[0], "-m")) {
1917      if (myargc<2) {
1918        break;
1919      }
1920
1921      /* Once we have -m, gobble up everything else on the line */
1922      myargv++;
1923      myargc--;
1924      newbuff=owl_malloc(1);
1925      newbuff=owl_strdup("");
1926      while (myargc) {
1927        newbuff=realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5);
1928        strcat(newbuff, myargv[0]);
1929        strcat(newbuff, " ");
1930        myargc--;
1931        myargv++;
1932      }
1933      newbuff[strlen(newbuff)-1]='\0'; /* remove last space */
1934
1935      recip=owl_malloc(strlen(argv[0])+5);
1936      sprintf(recip, "%s ", argv[1]);
1937      owl_aim_send_im(recip, newbuff);
1938      owl_free(recip);
1939      owl_free(newbuff);
1940      return(NULL);
1941    } else {
1942      /* we don't care */
1943      myargv++;
1944      myargc--;
1945    }
1946  }
1947
1948  /* squish arguments together to make one screenname w/o spaces for now */
1949  newbuff=owl_malloc(strlen(buff)+5);
1950  sprintf(newbuff, "%s ", argv[0]);
1951  j=argc-1;
1952  for (i=0; i<j; i++) {
1953    strcat(newbuff, argv[i+1]);
1954  }
1955   
1956  owl_function_aimwrite_setup(newbuff);
1957  owl_free(newbuff);
1958  return(NULL);
1959}
1960
1961char *owl_command_loopwrite(int argc, char **argv, char *buff)
1962{
1963  owl_function_loopwrite_setup();
1964  return(NULL);
1965}
1966
1967char *owl_command_zcrypt(int argc, char **argv, char *buff)
1968{
1969#ifdef OWL_ENABLE_ZCRYPT
1970  owl_zwrite z;
1971
1972  if (!owl_global_is_havezephyr(&g)) {
1973    owl_function_makemsg("Zephyr is not available");
1974    return(NULL);
1975  }
1976  /* check for a zcrypt -m */
1977  owl_zwrite_create_from_line(&z, buff);
1978  if (owl_zwrite_is_message_set(&z)) {
1979    owl_function_zcrypt(buff, NULL);
1980    owl_zwrite_free(&z);
1981    return (NULL);
1982  }
1983
1984  if (argc < 2) {
1985    owl_function_makemsg("Not enough arguments to the zcrypt command.");
1986  } else {
1987    owl_function_zwrite_setup(buff);
1988  }
1989  return(NULL);
1990#else
1991  owl_function_makemsg("This Owl does not support zcrypt");
1992#endif
1993}
1994
1995char *owl_command_reply(int argc, char **argv, char *buff)
1996{
1997  int edit=0;
1998 
1999  if (argc>=2 && !strcmp("-e", argv[1])) {
2000    edit=1;
2001    argv++;
2002    argc--;
2003  }
2004
2005  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
2006    owl_function_reply(0, !edit);
2007  } else if (argc==2 && !strcmp(argv[1], "sender")) {
2008    owl_function_reply(1, !edit);
2009  } else if (argc==2 && !strcmp(argv[1], "zaway")) {
2010    owl_message *m;
2011    owl_view    *v;
2012    v = owl_global_get_current_view(&g);   
2013    m = owl_view_get_element(v, owl_global_get_curmsg(&g));
2014    if (m) owl_zephyr_zaway(m);
2015  } else {
2016    owl_function_makemsg("Invalid arguments to the reply command.");
2017  }
2018  return NULL;
2019}
2020
2021char *owl_command_filter(int argc, char **argv, char *buff)
2022{
2023  owl_function_create_filter(argc, argv);
2024  return NULL;
2025}
2026
2027char *owl_command_zlocate(int argc, char **argv, char *buff)
2028{
2029  int auth;
2030 
2031  if (argc<2) {
2032    owl_function_makemsg("Too few arguments for zlocate command");
2033    return NULL;
2034  }
2035
2036  auth=1;
2037  if (!strcmp(argv[1], "-d")) {
2038    if (argc>2) {
2039      auth=0;
2040      argc--;
2041      argv++;
2042    } else {
2043      owl_function_makemsg("Missing arguments for zlocate command");
2044      return NULL;
2045    }
2046  }
2047
2048  argc--;
2049  argv++;
2050  owl_function_zlocate(argc, argv, auth);
2051  return NULL;
2052}
2053
2054
2055/* Backwards compatability has made this kind of complicated:
2056 * view [<viewname>] [-f <filter> | -d <expression> | --home | -r ] [-s <style>]
2057 * view <filter>
2058 * view -d <expression>
2059 * view --home
2060 */
2061char *owl_command_view(int argc, char **argv, char *buff)
2062{
2063  /* First take the 'view --home' and 'view -r' cases */
2064  if (argc == 2) {
2065    if (!strcmp(argv[1], "--home")) {
2066      owl_function_change_currentview_filter(owl_global_get_view_home(&g));
2067      return(NULL);
2068    } else if (!strcmp(argv[1], "-r")) {
2069      char *foo;
2070      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
2071      owl_function_change_currentview_filter(foo);
2072      owl_free(foo);
2073      return(NULL);
2074    }
2075  }
2076
2077  /* Now look for 'view <filter>' */
2078  if (argc==2) {
2079    owl_function_change_currentview_filter(argv[1]);
2080    return(NULL);
2081  }
2082
2083  /* Now get 'view -d <expression>' */
2084  if (argc>=3 && !strcmp(argv[1], "-d")) {
2085    char **myargv;
2086    int i;
2087
2088    myargv=owl_malloc((argc*sizeof(char *))+50);
2089    myargv[0]="";
2090    myargv[1]="owl-dynamic";
2091    for (i=2; i<argc; i++) {
2092      myargv[i]=argv[i];
2093    }
2094    owl_function_create_filter(argc, myargv);
2095    owl_function_change_currentview_filter("owl-dynamic");
2096    owl_free(myargv);
2097    return NULL;
2098  }
2099
2100  /* Finally handle the general case */
2101  if (argc<3) {
2102    owl_function_makemsg("Too few arguments to the view command.");
2103    return(NULL);
2104  }
2105  argc--;
2106  argv++;
2107  if (strcmp(argv[0], "-f") &&
2108      strcmp(argv[0], "-d") &&
2109      strcmp(argv[0], "--home") &&
2110      strcmp(argv[0], "-s") &&
2111      strcmp(argv[0], "-r")) {
2112    if (strcmp(argv[0], "main")) {
2113      owl_function_makemsg("No view named '%s'", argv[0]);
2114      return(NULL);
2115    }
2116    argc--;
2117    argv++;
2118  }
2119  while (argc) {
2120    if (!strcmp(argv[0], "-f")) {
2121      if (argc<2) {
2122        owl_function_makemsg("Too few argments to the view command");
2123        return(NULL);
2124      }
2125      owl_function_change_currentview_filter(argv[1]);
2126      argc-=2;
2127      argv+=2;
2128    } else if (!strcmp(argv[0], "--home")) {
2129      owl_function_change_currentview_filter(owl_global_get_view_home(&g));
2130      argc--;
2131      argv++;
2132    } else if (!strcmp(argv[0], "-r")) {
2133      char *foo;
2134      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
2135      owl_function_change_currentview_filter(foo);
2136    } else if (!strcmp(argv[0], "-s")) {
2137      if (argc<2) {
2138        owl_function_makemsg("Too few argments to the view command");
2139        return(NULL);
2140      }
2141      owl_function_change_style(owl_global_get_current_view(&g), argv[1]);
2142      argc-=2;
2143      argv+=2;
2144    } else {
2145      owl_function_makemsg("Too few argments to the view command");
2146      return(NULL);
2147    }
2148   
2149  }
2150  return(NULL);
2151}
2152
2153char *owl_command_show(int argc, char **argv, char *buff)
2154{
2155  if (argc<2) {
2156    owl_function_help_for_command("show");
2157    return NULL;
2158  }
2159
2160  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
2161    if (argc==2) {
2162      owl_function_show_filters();
2163    } else {
2164      owl_function_show_filter(argv[2]);
2165    }
2166  } else if (argc==2 
2167             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
2168    owl_function_show_zpunts();
2169  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
2170    if (argc==2) {
2171      owl_function_show_commands();
2172    } else {
2173      owl_function_show_command(argv[2]);
2174    }
2175  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
2176    if (argc==2) {
2177      owl_function_show_variables();
2178    } else {
2179      owl_function_show_variable(argv[2]);
2180    }
2181  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
2182    if (argc==2) {
2183      owl_function_show_keymaps();
2184    } else {
2185      owl_function_show_keymap(argv[2]);
2186    }
2187  } else if (!strcmp(argv[1], "view")) {
2188    if (argc==3) {
2189      owl_function_show_view(argv[2]);
2190    } else {
2191      owl_function_show_view(NULL);
2192    }
2193  } else if (!strcmp(argv[1], "colors")) {
2194    owl_function_show_colors();
2195  } else if (!strcmp(argv[1], "styles")) {
2196    owl_function_show_styles();
2197  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
2198    owl_function_getsubs();
2199  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
2200    owl_function_show_term();
2201  } else if (!strcmp(argv[1], "version")) {
2202    owl_function_about();
2203  } else if (!strcmp(argv[1], "status")) {
2204    owl_function_status();
2205  } else if (!strcmp(argv[1], "license")) {
2206    owl_function_show_license();
2207  } else if (!strcmp(argv[1], "startup")) {
2208    char *filename;
2209   
2210    filename=owl_global_get_startupfile(&g);
2211    owl_function_popless_file(filename);
2212  } else if (!strcmp(argv[1], "errors")) {
2213    owl_function_showerrs();
2214  } else {
2215    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
2216    return NULL;
2217  }
2218  return NULL;
2219}
2220
2221char *owl_command_viewclass(int argc, char **argv, char *buff)
2222{
2223  char *filtname;
2224  if (argc!=2) {
2225    owl_function_makemsg("Wrong number of arguments to viewclass command");
2226    return NULL;
2227  }
2228  filtname = owl_function_classinstfilt(argv[1], NULL);
2229  owl_function_change_currentview_filter(filtname);
2230  owl_free(filtname);
2231  return NULL;
2232}
2233
2234char *owl_command_viewuser(int argc, char **argv, char *buff)
2235{
2236  char *filtname;
2237  if (argc!=2) {
2238    owl_function_makemsg("Wrong number of arguments to viewuser command");
2239    return NULL;
2240  }
2241  filtname=owl_function_zuserfilt(argv[1]);
2242  owl_function_change_currentview_filter(filtname);
2243  owl_free(filtname);
2244  return NULL;
2245}
2246
2247
2248void owl_command_pop_message(void)
2249{
2250  owl_function_curmsg_to_popwin();
2251}
2252
2253void owl_command_openurl(void)
2254{
2255  owl_function_openurl();
2256}
2257
2258char *owl_command_delete(int argc, char **argv, char *buff)
2259{
2260  int move_after = 1;
2261
2262  if (argc>1 && !strcmp(argv[1], "--no-move")) {
2263    move_after = 0;
2264    argc--; 
2265    argv++;
2266  }
2267
2268  if (argc==1) {
2269    owl_function_deletecur(move_after);
2270    return NULL;
2271  }
2272
2273  if (argc==2 && !strcmp(argv[1], "view")) {
2274    owl_function_delete_curview_msgs(1);
2275    return NULL;
2276  }
2277
2278  if (argc==2 && !strcmp(argv[1], "trash")) {
2279    owl_function_delete_automsgs();
2280    return NULL;
2281  }
2282
2283  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
2284    owl_function_delete_by_id(atoi(argv[2]), 1);
2285    return NULL;
2286  }
2287
2288  owl_function_makemsg("Unknown arguments to delete command");
2289  return NULL;
2290}
2291
2292char *owl_command_undelete(int argc, char **argv, char *buff)
2293{
2294  int move_after = 1;
2295
2296  if (argc>1 && !strcmp(argv[1], "--no-move")) {
2297    move_after = 0;
2298    argc--; 
2299    argv++;
2300  }
2301
2302  if (argc==1) {
2303    owl_function_undeletecur(move_after);
2304    return NULL;
2305  }
2306
2307  if (argc==2 && !strcmp(argv[1], "view")) {
2308    owl_function_delete_curview_msgs(0);
2309    return NULL;
2310  }
2311
2312  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
2313    owl_function_delete_by_id(atoi(argv[2]), 0);
2314    return NULL;
2315  }
2316
2317  owl_function_makemsg("Unknown arguments to delete command");
2318  return NULL;
2319}
2320
2321void owl_command_beep()
2322{
2323  owl_function_beep();
2324}
2325
2326char *owl_command_colorview(int argc, char **argv, char *buff)
2327{
2328  if (argc < 2 || argc > 3) {
2329    owl_function_makemsg("Wrong number of arguments to colorview command");
2330    return NULL;
2331  }
2332  owl_function_color_current_filter(argv[1], (argc == 3 ? argv[2] : NULL));
2333  return NULL;
2334}
2335
2336char *owl_command_colorclass(int argc, char **argv, char *buff)
2337{
2338  char *filtname;
2339 
2340  if (argc < 3 || argc > 4) {
2341    owl_function_makemsg("Wrong number of arguments to colorclass command");
2342    return NULL;
2343  }
2344
2345  filtname=owl_function_classinstfilt(argv[1], NULL);
2346  (void) owl_function_color_filter(filtname, argv[2], (argc == 4 ? argv[3] : NULL));
2347  return NULL;
2348}
2349
2350char *owl_command_zpunt(int argc, char **argv, char *buff)
2351{
2352  owl_command_zpunt_and_zunpunt(argc, argv, 0);
2353  return NULL;
2354}
2355
2356char *owl_command_zunpunt(int argc, char **argv, char *buff)
2357{
2358  owl_command_zpunt_and_zunpunt(argc, argv, 1);
2359  return NULL;
2360}
2361
2362void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type)
2363{
2364  /* if type==0 then zpunt
2365   * if type==1 then zunpunt
2366   */
2367  char *class, *inst, *recip;
2368
2369  class="message";
2370  inst="";
2371  recip="*";
2372
2373  if (argc==1) {
2374    /* show current punt filters */
2375    owl_function_show_zpunts();
2376    return;
2377  } else if (argc==2) {
2378    inst=argv[1];
2379  } else if (argc==3) {
2380    class=argv[1];
2381    inst=argv[2];
2382  } else if (argc==4) {
2383    class=argv[1];
2384    inst=argv[2];
2385    recip=argv[3];
2386  } else {
2387    owl_function_makemsg("Wrong number of arguments to the zpunt command");
2388    return;
2389  }
2390
2391  owl_function_zpunt(class, inst, recip, type);
2392  if (type==0) {
2393    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
2394  } else if (type==1) {
2395    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
2396  }
2397}
2398
2399char *owl_command_smartzpunt(int argc, char **argv, char *buff)
2400{
2401  if (argc == 1) {
2402    owl_function_smartzpunt(0);
2403  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
2404    owl_function_smartzpunt(1);
2405  } else {
2406    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
2407  }
2408  return NULL;
2409}
2410
2411char *owl_command_punt(int argc, char **argv, char *buff)
2412{
2413  owl_command_punt_unpunt(argc, argv, buff, 0);
2414  return NULL;
2415}
2416
2417char *owl_command_unpunt(int argc, char **argv, char *buff)
2418{
2419  owl_command_punt_unpunt(argc, argv, buff, 1);
2420  return NULL;
2421}
2422
2423void owl_command_punt_unpunt(int argc, char ** argv, char *buff, int unpunt)
2424{
2425  owl_list * fl;
2426  owl_filter * f;
2427  char * text;
2428  int i;
2429
2430  fl = owl_global_get_puntlist(&g);
2431  if(argc == 1) {
2432    owl_function_show_zpunts();
2433  }
2434
2435  if(argc == 2) {
2436    /* Handle :unpunt <number> */
2437    if(unpunt && (i=atoi(argv[1])) !=0) {
2438      i--;      /* Accept 1-based indexing */
2439      if(i < owl_list_get_size(fl)) {
2440        f = (owl_filter*)owl_list_get_element(fl, i);
2441        owl_list_remove_element(fl, i);
2442        owl_filter_free(f);
2443        return;
2444      } else {
2445        owl_function_error("No such filter number: %d", i+1);
2446      }
2447    }
2448    text = owl_sprintf("filter %s", argv[1]);
2449  } else {
2450    text = skiptokens(buff, 1);
2451  }
2452
2453  owl_function_punt(text, unpunt);
2454}
2455
2456
2457char *owl_command_getview(int argc, char **argv, char *buff)
2458{
2459  char *filtname;
2460  if (argc != 1) {
2461    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2462    return NULL;
2463  }
2464  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
2465  if (filtname) filtname = owl_strdup(filtname);
2466  return filtname;
2467}
2468
2469char *owl_command_getvar(int argc, char **argv, char *buff)
2470{
2471  char tmpbuff[1024];
2472  if (argc != 2) {
2473    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2474    return NULL;
2475  }
2476  if (owl_variable_get_tostring(owl_global_get_vardict(&g), 
2477                                argv[1], tmpbuff, 1024)) {
2478    return NULL;
2479  }
2480  return owl_strdup(tmpbuff); 
2481}
2482
2483char *owl_command_search(int argc, char **argv, char *buff)
2484{
2485  int direction;
2486  char *buffstart;
2487
2488  direction=OWL_DIRECTION_DOWNWARDS;
2489  buffstart=skiptokens(buff, 1);
2490  if (argc>1 && !strcmp(argv[1], "-r")) {
2491    direction=OWL_DIRECTION_UPWARDS;
2492    buffstart=skiptokens(buff, 2);
2493  }
2494   
2495  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
2496    owl_function_search_continue(direction);
2497  } else {
2498    owl_function_search_start(buffstart, direction);
2499  }
2500 
2501  return(NULL);
2502}
2503
2504char *owl_command_setsearch(int argc, char **argv, char *buff)
2505{
2506  char *buffstart;
2507
2508  buffstart=skiptokens(buff, 1);
2509
2510  owl_global_set_search_active(&g, buffstart);
2511
2512  if (!*buffstart) {
2513    owl_global_set_search_inactive(&g);
2514  }
2515
2516  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
2517 
2518  return(NULL);
2519}
2520
2521char *owl_command_aimlogin(int argc, char **argv, char *buff)
2522{
2523  if ((argc<2) || (argc>3)) {
2524    owl_function_makemsg("Wrong number of arguments to aimlogin command");
2525    return(NULL);
2526  }
2527
2528  /* if we get two arguments, ask for the password */
2529  if (argc==2) {
2530    owl_global_set_buffercommand(&g, argv[1]);
2531    owl_global_set_buffercallback(&g, &owl_callback_aimlogin);
2532    owl_function_start_password("AIM Password: ");
2533    return(NULL);
2534  } else {
2535    owl_function_aimlogin(argv[1], argv[2]);
2536  }
2537
2538  /* this is a test */
2539  return(NULL);
2540}
2541
2542char *owl_command_aimlogout(int argc, char **argv, char *buff)
2543{
2544  /* clear the buddylist */
2545  owl_buddylist_clear(owl_global_get_buddylist(&g));
2546
2547  owl_aim_logout();
2548  return(NULL);
2549}
2550
2551char *owl_command_getstyle(int argc, char **argv, char *buff)
2552{
2553  char *stylename;
2554  if (argc != 1) {
2555    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2556    return NULL;
2557  }
2558  stylename = owl_view_get_style_name(owl_global_get_current_view(&g));
2559  if (stylename) stylename = owl_strdup(stylename);
2560  return stylename;
2561}
2562
2563char *owl_command_error(int argc, char **argv, char *buff)
2564{
2565    buff = skiptokens(buff, 1);
2566    owl_function_error(buff);
2567    return NULL;
2568}
2569
2570char *owl_command_message(int argc, char **argv, char *buff)
2571{
2572    buff = skiptokens(buff, 1);
2573    owl_function_makemsg(buff);
2574    return NULL;
2575}
2576
2577void owl_command_yes(void)
2578{
2579  owl_message *m;
2580  owl_view *v;
2581  char *cmd;
2582
2583  v = owl_global_get_current_view(&g);
2584
2585  /* bail if there's no current message */
2586  if (owl_view_get_size(v) < 1) {
2587    owl_function_error("No current message.");
2588    return;
2589  }
2590
2591  m = owl_view_get_element(v, owl_global_get_curmsg(&g));
2592  if(!owl_message_is_question(m)) {
2593    owl_function_error("That message isn't a question.");
2594    return;
2595  }
2596  if(owl_message_is_answered(m)) {
2597    owl_function_error("You already answered that question.");
2598    return;
2599  }
2600  cmd = owl_message_get_attribute_value(m, "yescommand");
2601  if(!cmd) {
2602    owl_function_error("No yes command!");
2603    return;
2604  }
2605
2606  owl_function_command_norv(cmd);
2607  owl_message_set_isanswered(m);
2608  return;
2609}
2610
2611void owl_command_no(void)
2612{
2613  owl_message *m;
2614  owl_view *v;
2615  char *cmd;
2616
2617  v = owl_global_get_current_view(&g);
2618
2619  /* bail if there's no current message */
2620  if (owl_view_get_size(v) < 1) {
2621    owl_function_error("No current message.");
2622    return;
2623  }
2624
2625  m = owl_view_get_element(v, owl_global_get_curmsg(&g));
2626  if(!owl_message_is_question(m)) {
2627    owl_function_error("That message isn't a question.");
2628    return;
2629  }
2630  if(owl_message_is_answered(m)) {
2631    owl_function_error("You already answered that question.");
2632    return;
2633  }
2634  cmd = owl_message_get_attribute_value(m, "nocommand");
2635  if(!cmd) {
2636    owl_function_error("No no command!");
2637    return;
2638  }
2639
2640  owl_function_command_norv(cmd);
2641  owl_message_set_isanswered(m);
2642  return;
2643}
2644
2645/*********************************************************************/
2646/************************** EDIT SPECIFIC ****************************/
2647/*********************************************************************/
2648
2649void owl_command_edit_cancel(owl_editwin *e)
2650{
2651  owl_history *hist;
2652
2653  owl_function_makemsg("Command cancelled.");
2654
2655  hist=owl_editwin_get_history(e);
2656  owl_history_store(hist, owl_editwin_get_text(e));
2657  owl_history_reset(hist);
2658
2659  owl_editwin_fullclear(e);
2660  owl_global_set_needrefresh(&g);
2661  wnoutrefresh(owl_editwin_get_curswin(e));
2662  owl_global_set_typwin_inactive(&g);
2663  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2664
2665  owl_function_activate_keymap("recv");
2666}
2667
2668void owl_command_edit_history_prev(owl_editwin *e)
2669{
2670  owl_history *hist;
2671  char *ptr;
2672
2673  hist=owl_editwin_get_history(e);
2674  if (!owl_history_is_touched(hist)) {
2675    owl_history_store(hist, owl_editwin_get_text(e));
2676    owl_history_set_partial(hist);
2677  }
2678  ptr=owl_history_get_prev(hist);
2679  if (ptr) {
2680    owl_editwin_clear(e);
2681    owl_editwin_insert_string(e, ptr);
2682    owl_editwin_redisplay(e, 0);
2683    owl_global_set_needrefresh(&g);
2684  } else {
2685    owl_function_beep();
2686  }
2687}
2688
2689void owl_command_edit_history_next(owl_editwin *e)
2690{
2691  owl_history *hist;
2692  char *ptr;
2693
2694  hist=owl_editwin_get_history(e);
2695  ptr=owl_history_get_next(hist);
2696  if (ptr) {
2697    owl_editwin_clear(e);
2698    owl_editwin_insert_string(e, ptr);
2699    owl_editwin_redisplay(e, 0);
2700    owl_global_set_needrefresh(&g);
2701  } else {
2702    owl_function_beep();
2703  }
2704}
2705
2706char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff)
2707{
2708  buff = skiptokens(buff, 1);
2709  owl_editwin_insert_string(e, buff);
2710  owl_editwin_redisplay(e, 0);
2711  owl_global_set_needrefresh(&g); 
2712  return NULL;
2713}
2714
2715void owl_command_editline_done(owl_editwin *e)
2716{
2717  owl_history *hist=owl_editwin_get_history(e);
2718  char *rv, *cmd;
2719
2720  owl_history_store(hist, owl_editwin_get_text(e));
2721  owl_history_reset(hist);
2722  owl_global_set_typwin_inactive(&g);
2723  cmd = owl_strdup(owl_editwin_get_text(e));
2724  owl_editwin_fullclear(e);
2725  rv = owl_function_command(cmd);
2726  owl_free(cmd);
2727
2728  wnoutrefresh(owl_editwin_get_curswin(e));
2729  owl_global_set_needrefresh(&g);
2730
2731  if (rv) {
2732    owl_function_makemsg("%s", rv);
2733    owl_free(rv);
2734  }
2735}
2736
2737
2738void owl_command_editresponse_done(owl_editwin *e)
2739{
2740  owl_function_run_buffercommand();
2741
2742  owl_global_set_typwin_inactive(&g);
2743  owl_editwin_fullclear(e);
2744  wnoutrefresh(owl_editwin_get_curswin(e));
2745  owl_global_set_needrefresh(&g);
2746}
2747
2748
2749void owl_command_editmulti_done(owl_editwin *e)
2750{
2751  owl_history *hist=owl_editwin_get_history(e);
2752
2753  owl_history_store(hist, owl_editwin_get_text(e));
2754  owl_history_reset(hist);
2755
2756  owl_function_run_buffercommand();
2757  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2758  owl_editwin_fullclear(e);
2759  owl_global_set_typwin_inactive(&g);
2760  owl_global_set_needrefresh(&g);
2761  wnoutrefresh(owl_editwin_get_curswin(e));
2762}
2763
2764void owl_command_editmulti_done_or_delete(owl_editwin *e)
2765{
2766  if (owl_editwin_is_at_end(e)) {
2767    owl_command_editmulti_done(e);
2768  } else {
2769    owl_editwin_delete_char(e);
2770  }
2771}
2772
2773
2774/*********************************************************************/
2775/*********************** POPLESS SPECIFIC ****************************/
2776/*********************************************************************/
2777
2778void owl_command_popless_quit(owl_viewwin *vw)
2779{
2780  owl_popwin_close(owl_global_get_popwin(&g));
2781  owl_viewwin_free(vw);
2782  owl_global_set_needrefresh(&g);
2783}
Note: See TracBrowser for help on using the repository browser.