source: commands.c @ ce7db4d

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since ce7db4d was ce7db4d, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
zwrite -m now logs and displays an outgoing message zwrite -s now works
  • Property mode set to 100644
File size: 64.5 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    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
925    return(NULL);
926    owl_aim_addbuddy(argv[2]);
927    owl_function_makemsg("%s added as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
928  } else if (!strcasecmp(argv[1], "zephyr")) {
929    owl_zephyr_addbuddy(argv[2]);
930    owl_function_makemsg("%s added as zephyr buddy", argv[2]);
931  } else {
932    owl_function_makemsg("addbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
933  }
934
935  return(NULL);
936}
937
938char *owl_command_delbuddy(int argc, char **argv, char *buff)
939{
940  if (argc!=3) {
941    owl_function_makemsg("usage: delbuddy <protocol> <buddyname>");
942    return(NULL);
943  }
944
945  if (!strcasecmp(argv[1], "aim")) {
946    if (!owl_global_is_aimloggedin(&g)) {
947      owl_function_makemsg("delbuddy: You must be logged into aim to use this command.");
948      return(NULL);
949    }
950    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
951    return(NULL);
952    owl_aim_delbuddy(argv[2]);
953    owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
954  } else if (!strcasecmp(argv[1], "zephyr")) {
955    owl_zephyr_delbuddy(argv[2]);
956    owl_function_makemsg("%s deleted as zephyr buddy", argv[2]);
957  } else {
958    owl_function_makemsg("delbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
959  }
960
961
962  return(NULL);
963}
964
965char *owl_command_startup(int argc, char **argv, char *buff)
966{
967  char *ptr;
968
969  if (argc<2) {
970    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
971    return(NULL);
972  }
973
974  /* we'll be pedantic here, just in case this command gets another name
975   *  (or is aliased) start after the first space on the line
976   */
977  ptr=strchr(buff, ' ');
978  if (!ptr) {
979    owl_function_makemsg("Parse error finding command for startup");
980    return(NULL);
981  }
982
983  owl_function_command(ptr+1);
984  owl_function_addstartup(ptr+1);
985
986  return(NULL);
987}
988
989char *owl_command_unstartup(int argc, char **argv, char *buff)
990{
991  char *ptr;
992
993  if (argc<2) {
994    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
995    return(NULL);
996  }
997
998  /* we'll be pedantic here, just in case this command gets another name
999   *  (or is aliased) start after the first space on the line
1000   */
1001  ptr=strchr(buff, ' ');
1002  if (!ptr) {
1003    owl_function_makemsg("Parse error finding command for unstartup");
1004    return(NULL);
1005  }
1006
1007  owl_function_delstartup(ptr+1);
1008
1009  return(NULL);
1010}
1011
1012char *owl_command_dump(int argc, char **argv, char *buff) {
1013  if (argc!=2) {
1014    owl_function_makemsg("usage: dump <filename>");
1015    return(NULL);
1016  }
1017
1018  owl_function_dump(argv[1]);
1019  return(NULL);
1020}
1021
1022char *owl_command_next(int argc, char **argv, char *buff) {
1023  char *filter=NULL;
1024  int skip_deleted=0, last_if_none=0;
1025  while (argc>1) {
1026    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1027      skip_deleted=1;
1028      argc-=1; argv+=1; 
1029    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
1030      last_if_none=1;
1031      argc-=1; argv+=1; 
1032    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1033      filter = owl_strdup(argv[2]);
1034      argc-=2; argv+=2; 
1035    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1036      filter = owl_function_smartfilter(0);
1037      argc-=2; argv+=2; 
1038    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1039      filter = owl_function_smartfilter(1);
1040      argc-=2; argv+=2; 
1041    } else {
1042      owl_function_makemsg("Invalid arguments to command 'next'.");
1043      return(NULL);
1044    }
1045  }
1046  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
1047  if (filter) owl_free(filter);
1048  return(NULL);
1049}
1050
1051char *owl_command_prev(int argc, char **argv, char *buff) {
1052  char *filter=NULL;
1053  int skip_deleted=0, first_if_none=0;
1054  while (argc>1) {
1055    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1056      skip_deleted=1;
1057      argc-=1; argv+=1; 
1058    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
1059      first_if_none=1;
1060      argc-=1; argv+=1; 
1061    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1062      filter = owl_strdup(argv[2]);
1063      argc-=2; argv+=2; 
1064    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1065      filter = owl_function_smartfilter(0);
1066      argc-=2; argv+=2; 
1067    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1068      filter = owl_function_smartfilter(1);
1069      argc-=2; argv+=2; 
1070   } else {
1071      owl_function_makemsg("Invalid arguments to command 'prev'.");
1072      return(NULL);
1073    }
1074  }
1075  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
1076  if (filter) owl_free(filter);
1077  return(NULL);
1078}
1079
1080char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
1081  char *filtname = NULL;
1082
1083  if (argc == 1) {
1084    filtname = owl_function_smartfilter(0);
1085  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1086    filtname = owl_function_smartfilter(1);
1087  } else {
1088    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1089  }
1090  if (filtname) {
1091    owl_function_change_view(filtname);
1092    owl_free(filtname);
1093  }
1094  return NULL;
1095}
1096
1097char *owl_command_smartfilter(int argc, char **argv, char *buff) {
1098  char *filtname = NULL;
1099
1100  if (argc == 1) {
1101    filtname = owl_function_smartfilter(0);
1102  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1103    filtname = owl_function_smartfilter(1);
1104  } else {
1105    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1106  }
1107  return filtname;
1108}
1109
1110void owl_command_expunge() {
1111  owl_function_expunge();
1112}
1113
1114void owl_command_first() {
1115  owl_global_set_rightshift(&g, 0);
1116  owl_function_firstmsg();
1117}
1118
1119void owl_command_last() {
1120  owl_function_lastmsg();
1121}
1122
1123void owl_command_resize() {
1124  owl_function_resize();
1125}
1126
1127void owl_command_redisplay() {
1128  owl_function_full_redisplay();
1129  owl_global_set_needrefresh(&g);
1130}
1131
1132void owl_command_shift_right() {
1133  owl_function_shift_right();
1134}
1135
1136void owl_command_shift_left() {
1137  owl_function_shift_left();
1138}
1139
1140void owl_command_unsuball() {
1141  owl_function_unsuball();
1142}
1143
1144char *owl_command_loadsubs(int argc, char **argv, char *buff) {
1145  if (argc == 2) {
1146    owl_function_loadsubs(argv[1]);
1147  } else if (argc == 1) {
1148    owl_function_loadsubs(NULL);
1149  } else {
1150    owl_function_makemsg("Wrong number of arguments for load-subs.");
1151    return(NULL);
1152  }
1153  return(NULL);
1154}
1155
1156
1157char *owl_command_loadloginsubs(int argc, char **argv, char *buff) {
1158  if (argc == 2) {
1159    owl_function_loadloginsubs(argv[1]);
1160  } else if (argc == 1) {
1161    owl_function_loadloginsubs(NULL);
1162  } else {
1163    owl_function_makemsg("Wrong number of arguments for load-subs.");
1164    return(NULL);
1165  }
1166  return(NULL);
1167}
1168
1169void owl_command_suspend() {
1170  owl_function_suspend();
1171}
1172
1173char *owl_command_start_command(int argc, char **argv, char *buff) {
1174  buff = skiptokens(buff, 1);
1175  owl_function_start_command(buff);
1176  return NULL;
1177}
1178
1179char *owl_command_zaway(int argc, char **argv, char *buff) {
1180 
1181  if ((argc==1) ||
1182      ((argc==2) && !strcmp(argv[1], "on"))) {
1183    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1184    owl_function_zaway_on();
1185    return NULL;
1186  }
1187
1188  if (argc==2 && !strcmp(argv[1], "off")) {
1189    owl_function_zaway_off();
1190    return NULL;
1191  }
1192
1193  if (argc==2 && !strcmp(argv[1], "toggle")) {
1194    owl_function_zaway_toggle();
1195    return NULL;
1196  }
1197
1198  buff = skiptokens(buff, 1);
1199  owl_global_set_zaway_msg(&g, buff);
1200  owl_function_zaway_on();
1201  return NULL;
1202}
1203
1204
1205char *owl_command_set(int argc, char **argv, char *buff) {
1206  char *var, *val;
1207  int  silent=0;
1208  int requirebool=0;
1209
1210  if (argc == 1) {
1211    owl_function_printallvars();
1212    return NULL;
1213  } 
1214
1215  if (argc > 1 && !strcmp("-q",argv[1])) {
1216    silent = 1;
1217    argc--; argv++;
1218  }
1219
1220  if (argc == 2) {
1221    var=argv[1];
1222    val="on";
1223    requirebool=1;
1224  } else if (argc == 3) {
1225    var=argv[1];
1226    val=argv[2];
1227  } else {
1228    owl_function_makemsg("Wrong number of arguments for set command");
1229    return NULL;
1230  }
1231  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
1232  return NULL;
1233}
1234
1235char *owl_command_unset(int argc, char **argv, char *buff) {
1236  char *var, *val;
1237  int  silent=0;
1238
1239  if (argc > 1 && !strcmp("-q",argv[1])) {
1240    silent = 1;
1241    argc--; argv++;
1242  }
1243  if (argc == 2) {
1244    var=argv[1];
1245    val="off";
1246  } else {
1247    owl_function_makemsg("Wrong number of arguments for unset command");
1248    return NULL;
1249  }
1250  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
1251  return NULL;
1252}
1253
1254char *owl_command_print(int argc, char **argv, char *buff) {
1255  char *var;
1256  char valbuff[1024];
1257
1258  if (argc==1) {
1259    owl_function_printallvars();
1260    return NULL;
1261  } else if (argc!=2) {
1262    owl_function_makemsg("Wrong number of arguments for print command");
1263    return NULL;
1264  }
1265
1266  var=argv[1];
1267   
1268  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
1269                                     var, valbuff, 1024)) {
1270    owl_function_makemsg("%s = '%s'", var, valbuff);
1271  } else {
1272    owl_function_makemsg("Unknown variable '%s'.", var);
1273  }
1274  return NULL;
1275}
1276
1277
1278char *owl_command_exec(int argc, char **argv, char *buff) {
1279  return owl_function_exec(argc, argv, buff, 0);
1280}
1281
1282char *owl_command_pexec(int argc, char **argv, char *buff) {
1283  return owl_function_exec(argc, argv, buff, 1);
1284}
1285
1286char *owl_command_aexec(int argc, char **argv, char *buff) {
1287  return owl_function_exec(argc, argv, buff, 2);
1288}
1289
1290char *owl_command_perl(int argc, char **argv, char *buff) {
1291  return owl_function_perl(argc, argv, buff, 0);
1292}
1293
1294char *owl_command_pperl(int argc, char **argv, char *buff) {
1295  return owl_function_perl(argc, argv, buff, 1);
1296}
1297
1298char *owl_command_aperl(int argc, char **argv, char *buff) {
1299  return owl_function_perl(argc, argv, buff, 2);
1300}
1301
1302char *owl_command_multi(int argc, char **argv, char *buff) {
1303  char *lastrv = NULL, *newbuff;
1304  char **commands;
1305  int  ncommands, i;
1306  if (argc < 2) {
1307    owl_function_makemsg("Invalid arguments to 'multi' command.");   
1308    return NULL;
1309  }
1310  newbuff = owl_strdup(buff);
1311  newbuff = skiptokens(newbuff, 1);
1312  if (!strcmp(argv[0], "(")) {
1313    for (i=strlen(newbuff)-1; i>=0; i--) {
1314      if (newbuff[i] == ')') {
1315        newbuff[i] = '\0';
1316        break;
1317      } else if (newbuff[i] != ' ') {
1318        owl_function_makemsg("Invalid arguments to 'multi' command.");   
1319        owl_free(newbuff);
1320        return NULL;
1321      }
1322    }
1323  }
1324  commands = atokenize(newbuff, ";", &ncommands);
1325  for (i=0; i<ncommands; i++) {
1326    if (lastrv) {
1327      owl_free(lastrv);
1328    }
1329    lastrv = owl_function_command(commands[i]);
1330  }
1331  atokenize_free(commands, ncommands);
1332  return lastrv;
1333}
1334
1335
1336char *owl_command_alias(int argc, char **argv, char *buff) {
1337  if (argc < 3) {
1338    owl_function_makemsg("Invalid arguments to 'alias' command.");
1339    return NULL;
1340  }
1341  buff = skiptokens(buff, 2);
1342  owl_function_command_alias(argv[1], buff);
1343  return (NULL);
1344}
1345
1346
1347char *owl_command_bindkey(int argc, char **argv, char *buff) {
1348  owl_keymap *km;
1349  int ret;
1350
1351  if (argc < 5 || strcmp(argv[3], "command")) {
1352    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>", argv[3], argc);
1353    return NULL;
1354  }
1355  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
1356  if (!km) {
1357    owl_function_makemsg("No such keymap '%s'", argv[1]);
1358    return NULL;
1359  }
1360  buff = skiptokens(buff, 4);
1361  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
1362  if (ret!=0) {
1363    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
1364                         argv[2], argv[1], buff);
1365    return NULL;
1366  }
1367  return NULL;
1368}
1369
1370void owl_command_quit() {
1371  owl_function_quit();
1372}
1373
1374char *owl_command_debug(int argc, char **argv, char *buff) {
1375  if (argc<2) {
1376    owl_function_makemsg("Need at least one argument to debug command");
1377    return(NULL);
1378  }
1379
1380  if (!owl_global_is_debug_fast(&g)) {
1381    owl_function_makemsg("Debugging is not turned on");
1382    return(NULL);
1383  }
1384
1385  owl_function_debugmsg(argv[1]);
1386  return(NULL);
1387}
1388
1389char *owl_command_term(int argc, char **argv, char *buff) {
1390  if (argc<2) {
1391    owl_function_makemsg("Need at least one argument to the term command");
1392    return(NULL);
1393  }
1394
1395  if (!strcmp(argv[1], "raise")) {
1396    owl_function_xterm_raise();
1397  } else if (!strcmp(argv[1], "deiconify")) {
1398    owl_function_xterm_deiconify();
1399  } else {
1400    owl_function_makemsg("Unknown terminal subcommand");
1401  }
1402  return(NULL);
1403}
1404
1405char *owl_command_zlog(int argc, char **argv, char *buff) {
1406  if ((argc<2) || (argc>3)) {
1407    owl_function_makemsg("Wrong number of arguments for zlog command");
1408    return(NULL);
1409  }
1410
1411  if (!strcmp(argv[1], "in")) {
1412    if (argc>2) {
1413      owl_global_set_tty(&g, argv[2]);
1414    }
1415    owl_zephyr_zlog_in();
1416  } else if (!strcmp(argv[1], "out")) {
1417    if (argc!=2) {
1418      owl_function_makemsg("Wrong number of arguments for zlog command");
1419      return(NULL);
1420    }
1421    owl_zephyr_zlog_out();
1422  } else {
1423    owl_function_makemsg("Invalid subcommand for zlog");
1424  }
1425  return(NULL);
1426}
1427
1428
1429void owl_command_zlog_out(void) {
1430  owl_zephyr_zlog_out();
1431}
1432
1433
1434char *owl_command_subscribe(int argc, char **argv, char *buff) {
1435  char *recip="";
1436  int temp=0;
1437 
1438  if (argc<3) {
1439    owl_function_makemsg("Not enough arguments to the subscribe command");
1440    return(NULL);
1441  }
1442  argc--;
1443  argv++;
1444
1445  if (!strcmp(argv[0], "-t")) {
1446    temp=1;
1447    argc--;
1448    argv++;
1449  }
1450  if (argc<2) {
1451    owl_function_makemsg("Not enough arguments to the subscribe command");
1452    return(NULL);
1453  }
1454
1455  if (argc>3) {
1456    owl_function_makemsg("Too many arguments to the subscribe command");
1457    return(NULL);
1458  }
1459
1460  if (argc==2) {
1461    recip="";
1462  } else if (argc==3) {
1463    recip=argv[2];
1464  }
1465
1466  owl_function_subscribe(argv[0], argv[1], recip);
1467  if (!temp) {
1468    owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
1469  }
1470  return(NULL);
1471}
1472
1473
1474char *owl_command_unsubscribe(int argc, char **argv, char *buff) {
1475  char *recip="";
1476  int temp=0;
1477
1478  if (argc<3) {
1479    owl_function_makemsg("Not enough arguments to the unsubscribe command");
1480    return(NULL);
1481  }
1482  argc--;
1483  argv++;
1484
1485  if (!strcmp(argv[0], "-t")) {
1486    temp=1;
1487    argc--;
1488    argv++;
1489  }
1490  if (argc<2) {
1491    owl_function_makemsg("Not enough arguments to the subscribe command");
1492    return(NULL);
1493  }
1494
1495  if (argc>3) {
1496    owl_function_makemsg("Too many arguments to the unsubscribe command");
1497    return(NULL);
1498  }
1499
1500  if (argc==2) {
1501    recip="";
1502  } else if (argc==3) {
1503    recip=argv[2];
1504  }
1505
1506  owl_function_unsubscribe(argv[0], argv[1], recip);
1507  if (!temp) {
1508    owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
1509  }
1510  return(NULL);
1511}
1512
1513char *owl_command_echo(int argc, char **argv, char *buff) {
1514  buff = skiptokens(buff, 1);
1515  owl_function_popless_text(buff);
1516  return NULL;
1517}
1518
1519void owl_command_getsubs() {
1520  owl_function_getsubs();
1521}
1522
1523void owl_command_status() {
1524  owl_function_status();
1525}
1526
1527char *owl_command_zwrite(int argc, char **argv, char *buff) {
1528  owl_zwrite z;
1529
1530  /* check for a zwrite -m */
1531  owl_zwrite_create_from_line(&z, buff);
1532  if (owl_zwrite_is_message_set(&z)) {
1533    owl_function_zwrite(buff, NULL);
1534    owl_zwrite_free(&z);
1535    return (NULL);
1536  }
1537
1538  if (argc < 2) {
1539    owl_function_makemsg("Not enough arguments to the zwrite command.");
1540  } else {
1541    owl_function_zwrite_setup(buff);
1542    owl_global_set_buffercommand(&g, buff);
1543  }
1544  return(NULL);
1545}
1546
1547char *owl_command_aimwrite(int argc, char **argv, char *buff) {
1548  if (!owl_global_is_aimloggedin(&g)) {
1549    owl_function_makemsg("You are not logged in to AIM.");
1550    return(NULL);
1551  }
1552
1553  if (argc < 2) {
1554    owl_function_makemsg("Not enough arguments to the aimwrite command.");
1555    return(NULL);
1556  }
1557
1558  owl_function_aimwrite_setup(buff);
1559  owl_global_set_buffercommand(&g, buff);
1560  return(NULL);
1561}
1562
1563char *owl_command_zcrypt(int argc, char **argv, char *buff) {
1564  owl_zwrite z;
1565
1566  /* check for a zwrite -m */
1567  owl_zwrite_create_from_line(&z, buff);
1568  if (owl_zwrite_is_message_set(&z)) {
1569    owl_zwrite_send_message(&z);
1570    owl_function_make_outgoing_zephyr(owl_zwrite_get_message(&z), buff, owl_zwrite_get_zsig(&z));
1571    owl_zwrite_free(&z);
1572    return (NULL);
1573  }
1574
1575  if (argc < 2) {
1576    owl_function_makemsg("Not enough arguments to the zcrypt command.");
1577  } else {
1578    owl_function_zwrite_setup(buff);
1579    owl_global_set_buffercommand(&g, buff);
1580  }
1581  return(NULL);
1582}
1583
1584char *owl_command_reply(int argc, char **argv, char *buff) {
1585  int edit=0;
1586 
1587  if (argc>=2 && !strcmp("-e", argv[1])) {
1588    edit=1;
1589    argv++;
1590    argc--;
1591  }
1592
1593  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1594    owl_function_reply(0, !edit);
1595  } else if (argc==2 && !strcmp(argv[1], "sender")) {
1596    owl_function_reply(1, !edit);
1597  } else if (argc==2 && !strcmp(argv[1], "zaway")) {
1598    owl_message *m;
1599    owl_view    *v;
1600    v = owl_global_get_current_view(&g);   
1601    m = owl_view_get_element(v, owl_global_get_curmsg(&g));
1602    if (m) owl_zephyr_zaway(m);
1603  } else {
1604    owl_function_makemsg("Invalid arguments to the reply command.");
1605  }
1606  return NULL;
1607}
1608
1609char *owl_command_filter(int argc, char **argv, char *buff) {
1610  owl_function_create_filter(argc, argv);
1611  return NULL;
1612}
1613
1614char *owl_command_zlocate(int argc, char **argv, char *buff) {
1615  int auth;
1616 
1617  if (argc<2) {
1618    owl_function_makemsg("Too few arguments for zlocate command");
1619    return NULL;
1620  }
1621
1622  auth=1;
1623  if (!strcmp(argv[1], "-d")) {
1624    if (argc>2) {
1625      auth=0;
1626      argc--;
1627      argv++;
1628    } else {
1629      owl_function_makemsg("Missing arguments for zlocate command");
1630      return NULL;
1631    }
1632  }
1633
1634  argc--;
1635  argv++;
1636  owl_function_zlocate(argc, argv, auth);
1637  return NULL;
1638}
1639
1640char *owl_command_view(int argc, char **argv, char *buff) {
1641
1642  /* Backwards compatability has made this kind of complicated:
1643   * view [<viewname>] [-f <filter> | -d <expression> | --home ] [-s <style>]
1644   * view <filter>
1645   * view -d <expression>
1646   * view --home
1647   */
1648
1649  /* First take the 'view --home' case */
1650  if (argc == 2 && !strcmp(argv[1], "--home")) {
1651    owl_function_change_view(owl_global_get_view_home(&g));
1652    return(NULL);
1653  }
1654
1655  /* Now look for 'view <filter>' */
1656  if (argc==2) {
1657    owl_function_change_view(argv[1]);
1658    return(NULL);
1659  }
1660
1661  /* Now get 'view -d <expression>' */
1662  if (argc==3 && !strcmp(argv[1], "-d")) {
1663    char **myargv;
1664    int i;
1665
1666    myargv=owl_malloc((argc*sizeof(char *))+50);
1667    myargv[0]="";
1668    myargv[1]="owl-dynamic";
1669    for (i=2; i<argc; i++) {
1670      myargv[i]=argv[i];
1671    }
1672    owl_function_create_filter(argc, myargv);
1673    owl_function_change_view("owl-dynamic");
1674    owl_free(myargv);
1675    return NULL;
1676  }
1677
1678  /* Finally handle the general case */
1679  if (argc<3) {
1680    owl_function_makemsg("Too few arguments to the view command.");
1681    return(NULL);
1682  }
1683  argc--;
1684  argv++;
1685  if (strcmp(argv[0], "-f") && strcmp(argv[0], "-d") && strcmp(argv[0], "--home") && strcmp(argv[0], "-s")) {
1686    if (strcmp(argv[0], "main")) {
1687      owl_function_makemsg("No view named '%s'", argv[0]);
1688      return(NULL);
1689    }
1690    argc--;
1691    argv++;
1692  }
1693  while (argc) {
1694    if (!strcmp(argv[0], "-f")) {
1695      if (argc<2) {
1696        owl_function_makemsg("Too few argments to the view command");
1697        return(NULL);
1698      }
1699      owl_function_change_view(argv[1]);
1700      argc-=2;
1701      argv+=2;
1702    } else if (!strcmp(argv[0], "--home")) {
1703      owl_function_change_view(owl_global_get_view_home(&g));
1704      argc--;
1705      argv++;
1706    } else if (!strcmp(argv[0], "-s")) {
1707      if (argc<2) {
1708        owl_function_makemsg("Too few argments to the view command");
1709        return(NULL);
1710      }
1711      owl_function_change_style(owl_global_get_current_view(&g), argv[1]);
1712      argc-=2;
1713      argv+=2;
1714    } else {
1715      owl_function_makemsg("Too few argments to the view command");
1716      return(NULL);
1717    }
1718   
1719  }
1720  return(NULL);
1721}
1722
1723
1724char *owl_command_show(int argc, char **argv, char *buff) {
1725
1726  if (argc<2) {
1727    owl_function_help_for_command("show");
1728    return NULL;
1729  }
1730
1731  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
1732    if (argc==2) {
1733      owl_function_show_filters();
1734    } else {
1735      owl_function_show_filter(argv[2]);
1736    }
1737  } else if (argc==2 
1738             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
1739    owl_function_show_zpunts();
1740  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
1741    if (argc==2) {
1742      owl_function_show_commands();
1743    } else {
1744      owl_function_show_command(argv[2]);
1745    }
1746  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
1747    if (argc==2) {
1748      owl_function_show_variables();
1749    } else {
1750      owl_function_show_variable(argv[2]);
1751    }
1752  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
1753    if (argc==2) {
1754      owl_function_show_keymaps();
1755    } else {
1756      owl_function_show_keymap(argv[2]);
1757    }
1758  } else if (!strcmp(argv[1], "view")) {
1759    if (argc==3) {
1760      owl_function_show_view(argv[2]);
1761    } else {
1762      owl_function_show_view(NULL);
1763    }
1764  } else if (!strcmp(argv[1], "colors")) {
1765    owl_function_show_colors();
1766  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
1767    owl_function_getsubs();
1768  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
1769    owl_function_show_term();
1770  } else if (!strcmp(argv[1], "version")) {
1771    owl_function_about();
1772  } else if (!strcmp(argv[1], "status")) {
1773    owl_function_status();
1774  } else {
1775    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
1776    return NULL;
1777  }
1778  return NULL;
1779}
1780
1781char *owl_command_viewclass(int argc, char **argv, char *buff) {
1782  char *filtname;
1783  if (argc!=2) {
1784    owl_function_makemsg("Wrong number of arguments to viewclass command");
1785    return NULL;
1786  }
1787  filtname = owl_function_classinstfilt(argv[1], NULL);
1788  owl_function_change_view(filtname);
1789  owl_free(filtname);
1790  return NULL;
1791}
1792
1793char *owl_command_viewuser(int argc, char **argv, char *buff) {
1794  char *filtname;
1795  if (argc!=2) {
1796    owl_function_makemsg("Wrong number of arguments to viewuser command");
1797    return NULL;
1798  }
1799  filtname=owl_function_zuserfilt(argv[1]);
1800  owl_function_change_view(filtname);
1801  owl_free(filtname);
1802  return NULL;
1803}
1804
1805
1806void owl_command_pop_message(void) {
1807  owl_function_curmsg_to_popwin();
1808}
1809
1810void owl_command_openurl(void) {
1811  owl_function_openurl();
1812}
1813
1814char *owl_command_delete(int argc, char **argv, char *buff) {
1815  int move_after = 1;
1816
1817  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1818    move_after = 0;
1819    argc--; 
1820    argv++;
1821  }
1822
1823  if (argc==1) {
1824    owl_function_deletecur(move_after);
1825    return NULL;
1826  }
1827
1828  if (argc==2 && !strcmp(argv[1], "view")) {
1829    owl_function_delete_curview_msgs(1);
1830    return NULL;
1831  }
1832
1833  if (argc==2 && !strcmp(argv[1], "trash")) {
1834    owl_function_delete_automsgs();
1835    return NULL;
1836  }
1837
1838  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1839    owl_function_delete_by_id(atoi(argv[2]), 1);
1840    return NULL;
1841  }
1842
1843  owl_function_makemsg("Unknown arguments to delete command");
1844  return NULL;
1845}
1846
1847char *owl_command_undelete(int argc, char **argv, char *buff) {
1848  int move_after = 1;
1849
1850  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1851    move_after = 0;
1852    argc--; 
1853    argv++;
1854  }
1855
1856  if (argc==1) {
1857    owl_function_undeletecur(move_after);
1858    return NULL;
1859  }
1860
1861  if (argc==2 && !strcmp(argv[1], "view")) {
1862    owl_function_delete_curview_msgs(0);
1863    return NULL;
1864  }
1865
1866  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1867    owl_function_delete_by_id(atoi(argv[2]), 0);
1868    return NULL;
1869  }
1870
1871  owl_function_makemsg("Unknown arguments to delete command");
1872  return NULL;
1873}
1874
1875void owl_command_beep() {
1876  owl_function_beep();
1877}
1878
1879char *owl_command_colorview(int argc, char **argv, char *buff) {
1880  if (argc!=2) {
1881    owl_function_makemsg("Wrong number of arguments to colorview command");
1882    return NULL;
1883  }
1884  owl_function_color_current_filter(argv[1]);
1885  return NULL;
1886}
1887
1888char *owl_command_zpunt(int argc, char **argv, char *buff) {
1889  owl_command_zpunt_and_zunpunt(argc, argv, 0);
1890  return NULL;
1891}
1892
1893char *owl_command_zunpunt(int argc, char **argv, char *buff) {
1894  owl_command_zpunt_and_zunpunt(argc, argv, 1);
1895  return NULL;
1896}
1897
1898
1899void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type) {
1900  /* if type==0 then zpunt
1901   * if type==1 then zunpunt
1902   */
1903  char *class, *inst, *recip;
1904
1905  class="message";
1906  inst="";
1907  recip="*";
1908
1909  if (argc==1) {
1910    /* show current punt filters */
1911    owl_function_show_zpunts();
1912    return;
1913  } else if (argc==2) {
1914    inst=argv[1];
1915  } else if (argc==3) {
1916    class=argv[1];
1917    inst=argv[2];
1918  } else if (argc==4) {
1919    class=argv[1];
1920    inst=argv[2];
1921    recip=argv[3];
1922  } else {
1923    owl_function_makemsg("Wrong number of arguments to the zpunt command");
1924    return;
1925  }
1926
1927  owl_function_zpunt(class, inst, recip, type);
1928  if (type==0) {
1929    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
1930  } else if (type==1) {
1931    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
1932  }
1933}
1934
1935char *owl_command_smartzpunt(int argc, char **argv, char *buff) {
1936  if (argc == 1) {
1937    owl_function_smartzpunt(0);
1938  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1939    owl_function_smartzpunt(1);
1940  } else {
1941    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1942  }
1943  return NULL;
1944}
1945
1946char *owl_command_getview(int argc, char **argv, char *buff) {
1947  char *filtname;
1948  if (argc != 1) {
1949    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
1950    return NULL;
1951  }
1952  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
1953  if (filtname) filtname = owl_strdup(filtname);
1954  return filtname;
1955}
1956
1957char *owl_command_getvar(int argc, char **argv, char *buff) {
1958  char tmpbuff[1024];
1959  if (argc != 2) {
1960    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
1961    return NULL;
1962  }
1963  if (owl_variable_get_tostring(owl_global_get_vardict(&g), 
1964                                argv[1], tmpbuff, 1024)) {
1965    return NULL;
1966  }
1967  return owl_strdup(tmpbuff); 
1968}
1969
1970char *owl_command_search(int argc, char **argv, char *buff) {
1971  int direction;
1972  char *buffstart;
1973
1974  direction=OWL_DIRECTION_DOWNWARDS;
1975  buffstart=skiptokens(buff, 1);
1976  if (argc>1 && !strcmp(argv[1], "-r")) {
1977    direction=OWL_DIRECTION_UPWARDS;
1978    buffstart=skiptokens(buff, 2);
1979  }
1980   
1981  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
1982    owl_function_search_continue(direction);
1983  } else {
1984    owl_function_search_start(buffstart, direction);
1985  }
1986 
1987  return(NULL);
1988}
1989
1990char *owl_command_aimlogin(int argc, char **argv, char *buff) {
1991  int ret;
1992 
1993  if (argc!=3) {
1994    owl_function_makemsg("Wrong number of arguments to aimlogin command");
1995    return(NULL);
1996  }
1997
1998  /* clear the buddylist */
1999  owl_buddylist_clear(owl_global_get_buddylist(&g));
2000
2001  /* try to login */
2002  ret=owl_aim_login(argv[1], argv[2]);
2003  if (!ret) {
2004    owl_function_makemsg("%s logged in.\n", argv[1]);
2005
2006    /* start the ingorelogin timer */
2007    owl_timer_reset_newstart(owl_global_get_aim_login_timer(&g),
2008                             owl_global_get_aim_ignorelogin_timer(&g));
2009   
2010    return(NULL);
2011  }
2012 
2013  owl_function_makemsg("Warning: login for %s failed.\n");
2014  return(NULL);
2015}
2016
2017char *owl_command_aimlogout(int argc, char **argv, char *buff) {
2018  /* clear the buddylist */
2019  owl_buddylist_clear(owl_global_get_buddylist(&g));
2020
2021  owl_aim_logout();
2022  return(NULL);
2023}
2024
2025/*********************************************************************/
2026/************************** EDIT SPECIFIC ****************************/
2027/*********************************************************************/
2028
2029void owl_command_edit_cancel(owl_editwin *e) {
2030  owl_history *hist;
2031
2032  owl_function_makemsg("Command cancelled.");
2033
2034  hist=owl_editwin_get_history(e);
2035  owl_history_store(hist, owl_editwin_get_text(e));
2036  owl_history_reset(hist);
2037
2038  owl_editwin_fullclear(e);
2039  owl_global_set_needrefresh(&g);
2040  wnoutrefresh(owl_editwin_get_curswin(e));
2041  owl_global_set_typwin_inactive(&g);
2042  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2043}
2044
2045void owl_command_edit_history_prev(owl_editwin *e) {
2046  owl_history *hist;
2047  char *ptr;
2048
2049  hist=owl_editwin_get_history(e);
2050  if (!owl_history_is_touched(hist)) {
2051    owl_history_store(hist, owl_editwin_get_text(e));
2052    owl_history_set_partial(hist);
2053  }
2054  ptr=owl_history_get_prev(hist);
2055  if (ptr) {
2056    owl_editwin_clear(e);
2057    owl_editwin_insert_string(e, ptr);
2058    owl_editwin_redisplay(e, 0);
2059    owl_global_set_needrefresh(&g);
2060  } else {
2061    owl_function_beep();
2062  }
2063}
2064
2065void owl_command_edit_history_next(owl_editwin *e) {
2066  owl_history *hist;
2067  char *ptr;
2068
2069  hist=owl_editwin_get_history(e);
2070  ptr=owl_history_get_next(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
2081char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff) {
2082  buff = skiptokens(buff, 1);
2083  owl_editwin_insert_string(e, buff);
2084  owl_editwin_redisplay(e, 0);
2085  owl_global_set_needrefresh(&g); 
2086  return NULL;
2087}
2088
2089void owl_command_editline_done(owl_editwin *e) {
2090  owl_history *hist=owl_editwin_get_history(e);
2091  char *rv, *cmd;
2092
2093  owl_history_store(hist, owl_editwin_get_text(e));
2094  owl_history_reset(hist);
2095  owl_global_set_typwin_inactive(&g);
2096  cmd = owl_strdup(owl_editwin_get_text(e));
2097  owl_editwin_fullclear(e);
2098  rv = owl_function_command(cmd);
2099  owl_free(cmd);
2100
2101  wnoutrefresh(owl_editwin_get_curswin(e));
2102  owl_global_set_needrefresh(&g);
2103
2104  if (rv) {
2105    owl_function_makemsg("%s", rv);
2106    owl_free(rv);
2107  }
2108}
2109
2110void owl_command_editmulti_done(owl_editwin *e) {
2111  owl_history *hist=owl_editwin_get_history(e);
2112
2113  owl_history_store(hist, owl_editwin_get_text(e));
2114  owl_history_reset(hist);
2115
2116  owl_function_run_buffercommand();
2117  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2118  owl_editwin_fullclear(e);
2119  owl_global_set_typwin_inactive(&g);
2120  owl_global_set_needrefresh(&g);
2121  wnoutrefresh(owl_editwin_get_curswin(e));
2122}
2123
2124void owl_command_editmulti_done_or_delete(owl_editwin *e) {
2125  if (owl_editwin_is_at_end(e)) {
2126    owl_command_editmulti_done(e);
2127  } else {
2128    owl_editwin_delete_char(e);
2129  }
2130}
2131
2132
2133/*********************************************************************/
2134/*********************** POPLESS SPECIFIC ****************************/
2135/*********************************************************************/
2136
2137void owl_command_popless_quit(owl_viewwin *vw) {
2138  owl_popwin_close(owl_global_get_popwin(&g));
2139  owl_viewwin_free(vw);
2140  owl_global_set_needrefresh(&g);
2141}
Note: See TracBrowser for help on using the repository browser.