source: commands.c @ 6e400cc

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