source: commands.c @ cdc6ff1

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