source: commands.c @ 03ad7b2

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