source: commands.c @ ec6ff52

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