source: commands.c @ 658dc2f

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 658dc2f was 658dc2f, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
Don't allow sending to AIM users with spaces
  • 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    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  char *newbuff;
1549  int i, j;
1550 
1551  if (!owl_global_is_aimloggedin(&g)) {
1552    owl_function_makemsg("You are not logged in to AIM.");
1553    return(NULL);
1554  }
1555
1556  if (argc < 2) {
1557    owl_function_makemsg("Not enough arguments to the aimwrite command.");
1558    return(NULL);
1559  }
1560
1561  /* squish arguments together to make one screenname w/o spaces for now */
1562  newbuff=owl_malloc(strlen(buff)+5);
1563  sprintf(newbuff, "%s ", argv[0]);
1564  j=argc-1;
1565  for (i=0; i<j; i++) {
1566    strcat(newbuff, argv[i+1]);
1567  }
1568   
1569  owl_function_aimwrite_setup(newbuff);
1570  owl_global_set_buffercommand(&g, newbuff);
1571  owl_free(newbuff);
1572  return(NULL);
1573}
1574
1575char *owl_command_zcrypt(int argc, char **argv, char *buff) {
1576  owl_zwrite z;
1577
1578  /* check for a zwrite -m */
1579  owl_zwrite_create_from_line(&z, buff);
1580  if (owl_zwrite_is_message_set(&z)) {
1581    owl_zwrite_send_message(&z);
1582    owl_function_make_outgoing_zephyr(owl_zwrite_get_message(&z), buff, owl_zwrite_get_zsig(&z));
1583    owl_zwrite_free(&z);
1584    return (NULL);
1585  }
1586
1587  if (argc < 2) {
1588    owl_function_makemsg("Not enough arguments to the zcrypt command.");
1589  } else {
1590    owl_function_zwrite_setup(buff);
1591    owl_global_set_buffercommand(&g, buff);
1592  }
1593  return(NULL);
1594}
1595
1596char *owl_command_reply(int argc, char **argv, char *buff) {
1597  int edit=0;
1598 
1599  if (argc>=2 && !strcmp("-e", argv[1])) {
1600    edit=1;
1601    argv++;
1602    argc--;
1603  }
1604
1605  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1606    owl_function_reply(0, !edit);
1607  } else if (argc==2 && !strcmp(argv[1], "sender")) {
1608    owl_function_reply(1, !edit);
1609  } else if (argc==2 && !strcmp(argv[1], "zaway")) {
1610    owl_message *m;
1611    owl_view    *v;
1612    v = owl_global_get_current_view(&g);   
1613    m = owl_view_get_element(v, owl_global_get_curmsg(&g));
1614    if (m) owl_zephyr_zaway(m);
1615  } else {
1616    owl_function_makemsg("Invalid arguments to the reply command.");
1617  }
1618  return NULL;
1619}
1620
1621char *owl_command_filter(int argc, char **argv, char *buff) {
1622  owl_function_create_filter(argc, argv);
1623  return NULL;
1624}
1625
1626char *owl_command_zlocate(int argc, char **argv, char *buff) {
1627  int auth;
1628 
1629  if (argc<2) {
1630    owl_function_makemsg("Too few arguments for zlocate command");
1631    return NULL;
1632  }
1633
1634  auth=1;
1635  if (!strcmp(argv[1], "-d")) {
1636    if (argc>2) {
1637      auth=0;
1638      argc--;
1639      argv++;
1640    } else {
1641      owl_function_makemsg("Missing arguments for zlocate command");
1642      return NULL;
1643    }
1644  }
1645
1646  argc--;
1647  argv++;
1648  owl_function_zlocate(argc, argv, auth);
1649  return NULL;
1650}
1651
1652char *owl_command_view(int argc, char **argv, char *buff) {
1653
1654  /* Backwards compatability has made this kind of complicated:
1655   * view [<viewname>] [-f <filter> | -d <expression> | --home ] [-s <style>]
1656   * view <filter>
1657   * view -d <expression>
1658   * view --home
1659   */
1660
1661  /* First take the 'view --home' case */
1662  if (argc == 2 && !strcmp(argv[1], "--home")) {
1663    owl_function_change_view(owl_global_get_view_home(&g));
1664    return(NULL);
1665  }
1666
1667  /* Now look for 'view <filter>' */
1668  if (argc==2) {
1669    owl_function_change_view(argv[1]);
1670    return(NULL);
1671  }
1672
1673  /* Now get 'view -d <expression>' */
1674  if (argc==3 && !strcmp(argv[1], "-d")) {
1675    char **myargv;
1676    int i;
1677
1678    myargv=owl_malloc((argc*sizeof(char *))+50);
1679    myargv[0]="";
1680    myargv[1]="owl-dynamic";
1681    for (i=2; i<argc; i++) {
1682      myargv[i]=argv[i];
1683    }
1684    owl_function_create_filter(argc, myargv);
1685    owl_function_change_view("owl-dynamic");
1686    owl_free(myargv);
1687    return NULL;
1688  }
1689
1690  /* Finally handle the general case */
1691  if (argc<3) {
1692    owl_function_makemsg("Too few arguments to the view command.");
1693    return(NULL);
1694  }
1695  argc--;
1696  argv++;
1697  if (strcmp(argv[0], "-f") && strcmp(argv[0], "-d") && strcmp(argv[0], "--home") && strcmp(argv[0], "-s")) {
1698    if (strcmp(argv[0], "main")) {
1699      owl_function_makemsg("No view named '%s'", argv[0]);
1700      return(NULL);
1701    }
1702    argc--;
1703    argv++;
1704  }
1705  while (argc) {
1706    if (!strcmp(argv[0], "-f")) {
1707      if (argc<2) {
1708        owl_function_makemsg("Too few argments to the view command");
1709        return(NULL);
1710      }
1711      owl_function_change_view(argv[1]);
1712      argc-=2;
1713      argv+=2;
1714    } else if (!strcmp(argv[0], "--home")) {
1715      owl_function_change_view(owl_global_get_view_home(&g));
1716      argc--;
1717      argv++;
1718    } else if (!strcmp(argv[0], "-s")) {
1719      if (argc<2) {
1720        owl_function_makemsg("Too few argments to the view command");
1721        return(NULL);
1722      }
1723      owl_function_change_style(owl_global_get_current_view(&g), argv[1]);
1724      argc-=2;
1725      argv+=2;
1726    } else {
1727      owl_function_makemsg("Too few argments to the view command");
1728      return(NULL);
1729    }
1730   
1731  }
1732  return(NULL);
1733}
1734
1735
1736char *owl_command_show(int argc, char **argv, char *buff) {
1737
1738  if (argc<2) {
1739    owl_function_help_for_command("show");
1740    return NULL;
1741  }
1742
1743  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
1744    if (argc==2) {
1745      owl_function_show_filters();
1746    } else {
1747      owl_function_show_filter(argv[2]);
1748    }
1749  } else if (argc==2 
1750             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
1751    owl_function_show_zpunts();
1752  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
1753    if (argc==2) {
1754      owl_function_show_commands();
1755    } else {
1756      owl_function_show_command(argv[2]);
1757    }
1758  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
1759    if (argc==2) {
1760      owl_function_show_variables();
1761    } else {
1762      owl_function_show_variable(argv[2]);
1763    }
1764  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
1765    if (argc==2) {
1766      owl_function_show_keymaps();
1767    } else {
1768      owl_function_show_keymap(argv[2]);
1769    }
1770  } else if (!strcmp(argv[1], "view")) {
1771    if (argc==3) {
1772      owl_function_show_view(argv[2]);
1773    } else {
1774      owl_function_show_view(NULL);
1775    }
1776  } else if (!strcmp(argv[1], "colors")) {
1777    owl_function_show_colors();
1778  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
1779    owl_function_getsubs();
1780  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
1781    owl_function_show_term();
1782  } else if (!strcmp(argv[1], "version")) {
1783    owl_function_about();
1784  } else if (!strcmp(argv[1], "status")) {
1785    owl_function_status();
1786  } else {
1787    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
1788    return NULL;
1789  }
1790  return NULL;
1791}
1792
1793char *owl_command_viewclass(int argc, char **argv, char *buff) {
1794  char *filtname;
1795  if (argc!=2) {
1796    owl_function_makemsg("Wrong number of arguments to viewclass command");
1797    return NULL;
1798  }
1799  filtname = owl_function_classinstfilt(argv[1], NULL);
1800  owl_function_change_view(filtname);
1801  owl_free(filtname);
1802  return NULL;
1803}
1804
1805char *owl_command_viewuser(int argc, char **argv, char *buff) {
1806  char *filtname;
1807  if (argc!=2) {
1808    owl_function_makemsg("Wrong number of arguments to viewuser command");
1809    return NULL;
1810  }
1811  filtname=owl_function_zuserfilt(argv[1]);
1812  owl_function_change_view(filtname);
1813  owl_free(filtname);
1814  return NULL;
1815}
1816
1817
1818void owl_command_pop_message(void) {
1819  owl_function_curmsg_to_popwin();
1820}
1821
1822void owl_command_openurl(void) {
1823  owl_function_openurl();
1824}
1825
1826char *owl_command_delete(int argc, char **argv, char *buff) {
1827  int move_after = 1;
1828
1829  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1830    move_after = 0;
1831    argc--; 
1832    argv++;
1833  }
1834
1835  if (argc==1) {
1836    owl_function_deletecur(move_after);
1837    return NULL;
1838  }
1839
1840  if (argc==2 && !strcmp(argv[1], "view")) {
1841    owl_function_delete_curview_msgs(1);
1842    return NULL;
1843  }
1844
1845  if (argc==2 && !strcmp(argv[1], "trash")) {
1846    owl_function_delete_automsgs();
1847    return NULL;
1848  }
1849
1850  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1851    owl_function_delete_by_id(atoi(argv[2]), 1);
1852    return NULL;
1853  }
1854
1855  owl_function_makemsg("Unknown arguments to delete command");
1856  return NULL;
1857}
1858
1859char *owl_command_undelete(int argc, char **argv, char *buff) {
1860  int move_after = 1;
1861
1862  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1863    move_after = 0;
1864    argc--; 
1865    argv++;
1866  }
1867
1868  if (argc==1) {
1869    owl_function_undeletecur(move_after);
1870    return NULL;
1871  }
1872
1873  if (argc==2 && !strcmp(argv[1], "view")) {
1874    owl_function_delete_curview_msgs(0);
1875    return NULL;
1876  }
1877
1878  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1879    owl_function_delete_by_id(atoi(argv[2]), 0);
1880    return NULL;
1881  }
1882
1883  owl_function_makemsg("Unknown arguments to delete command");
1884  return NULL;
1885}
1886
1887void owl_command_beep() {
1888  owl_function_beep();
1889}
1890
1891char *owl_command_colorview(int argc, char **argv, char *buff) {
1892  if (argc!=2) {
1893    owl_function_makemsg("Wrong number of arguments to colorview command");
1894    return NULL;
1895  }
1896  owl_function_color_current_filter(argv[1]);
1897  return NULL;
1898}
1899
1900char *owl_command_zpunt(int argc, char **argv, char *buff) {
1901  owl_command_zpunt_and_zunpunt(argc, argv, 0);
1902  return NULL;
1903}
1904
1905char *owl_command_zunpunt(int argc, char **argv, char *buff) {
1906  owl_command_zpunt_and_zunpunt(argc, argv, 1);
1907  return NULL;
1908}
1909
1910
1911void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type) {
1912  /* if type==0 then zpunt
1913   * if type==1 then zunpunt
1914   */
1915  char *class, *inst, *recip;
1916
1917  class="message";
1918  inst="";
1919  recip="*";
1920
1921  if (argc==1) {
1922    /* show current punt filters */
1923    owl_function_show_zpunts();
1924    return;
1925  } else if (argc==2) {
1926    inst=argv[1];
1927  } else if (argc==3) {
1928    class=argv[1];
1929    inst=argv[2];
1930  } else if (argc==4) {
1931    class=argv[1];
1932    inst=argv[2];
1933    recip=argv[3];
1934  } else {
1935    owl_function_makemsg("Wrong number of arguments to the zpunt command");
1936    return;
1937  }
1938
1939  owl_function_zpunt(class, inst, recip, type);
1940  if (type==0) {
1941    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
1942  } else if (type==1) {
1943    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
1944  }
1945}
1946
1947char *owl_command_smartzpunt(int argc, char **argv, char *buff) {
1948  if (argc == 1) {
1949    owl_function_smartzpunt(0);
1950  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1951    owl_function_smartzpunt(1);
1952  } else {
1953    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1954  }
1955  return NULL;
1956}
1957
1958char *owl_command_getview(int argc, char **argv, char *buff) {
1959  char *filtname;
1960  if (argc != 1) {
1961    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
1962    return NULL;
1963  }
1964  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
1965  if (filtname) filtname = owl_strdup(filtname);
1966  return filtname;
1967}
1968
1969char *owl_command_getvar(int argc, char **argv, char *buff) {
1970  char tmpbuff[1024];
1971  if (argc != 2) {
1972    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
1973    return NULL;
1974  }
1975  if (owl_variable_get_tostring(owl_global_get_vardict(&g), 
1976                                argv[1], tmpbuff, 1024)) {
1977    return NULL;
1978  }
1979  return owl_strdup(tmpbuff); 
1980}
1981
1982char *owl_command_search(int argc, char **argv, char *buff) {
1983  int direction;
1984  char *buffstart;
1985
1986  direction=OWL_DIRECTION_DOWNWARDS;
1987  buffstart=skiptokens(buff, 1);
1988  if (argc>1 && !strcmp(argv[1], "-r")) {
1989    direction=OWL_DIRECTION_UPWARDS;
1990    buffstart=skiptokens(buff, 2);
1991  }
1992   
1993  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
1994    owl_function_search_continue(direction);
1995  } else {
1996    owl_function_search_start(buffstart, direction);
1997  }
1998 
1999  return(NULL);
2000}
2001
2002char *owl_command_aimlogin(int argc, char **argv, char *buff) {
2003  int ret;
2004 
2005  if (argc!=3) {
2006    owl_function_makemsg("Wrong number of arguments to aimlogin command");
2007    return(NULL);
2008  }
2009
2010  /* clear the buddylist */
2011  owl_buddylist_clear(owl_global_get_buddylist(&g));
2012
2013  /* try to login */
2014  ret=owl_aim_login(argv[1], argv[2]);
2015  if (!ret) {
2016    owl_function_makemsg("%s logged in.\n", argv[1]);
2017
2018    /* start the ingorelogin timer */
2019    owl_timer_reset_newstart(owl_global_get_aim_login_timer(&g),
2020                             owl_global_get_aim_ignorelogin_timer(&g));
2021   
2022    return(NULL);
2023  }
2024 
2025  owl_function_makemsg("Warning: login for %s failed.\n");
2026  return(NULL);
2027}
2028
2029char *owl_command_aimlogout(int argc, char **argv, char *buff) {
2030  /* clear the buddylist */
2031  owl_buddylist_clear(owl_global_get_buddylist(&g));
2032
2033  owl_aim_logout();
2034  return(NULL);
2035}
2036
2037/*********************************************************************/
2038/************************** EDIT SPECIFIC ****************************/
2039/*********************************************************************/
2040
2041void owl_command_edit_cancel(owl_editwin *e) {
2042  owl_history *hist;
2043
2044  owl_function_makemsg("Command cancelled.");
2045
2046  hist=owl_editwin_get_history(e);
2047  owl_history_store(hist, owl_editwin_get_text(e));
2048  owl_history_reset(hist);
2049
2050  owl_editwin_fullclear(e);
2051  owl_global_set_needrefresh(&g);
2052  wnoutrefresh(owl_editwin_get_curswin(e));
2053  owl_global_set_typwin_inactive(&g);
2054  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2055}
2056
2057void owl_command_edit_history_prev(owl_editwin *e) {
2058  owl_history *hist;
2059  char *ptr;
2060
2061  hist=owl_editwin_get_history(e);
2062  if (!owl_history_is_touched(hist)) {
2063    owl_history_store(hist, owl_editwin_get_text(e));
2064    owl_history_set_partial(hist);
2065  }
2066  ptr=owl_history_get_prev(hist);
2067  if (ptr) {
2068    owl_editwin_clear(e);
2069    owl_editwin_insert_string(e, ptr);
2070    owl_editwin_redisplay(e, 0);
2071    owl_global_set_needrefresh(&g);
2072  } else {
2073    owl_function_beep();
2074  }
2075}
2076
2077void owl_command_edit_history_next(owl_editwin *e) {
2078  owl_history *hist;
2079  char *ptr;
2080
2081  hist=owl_editwin_get_history(e);
2082  ptr=owl_history_get_next(hist);
2083  if (ptr) {
2084    owl_editwin_clear(e);
2085    owl_editwin_insert_string(e, ptr);
2086    owl_editwin_redisplay(e, 0);
2087    owl_global_set_needrefresh(&g);
2088  } else {
2089    owl_function_beep();
2090  }
2091}
2092
2093char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff) {
2094  buff = skiptokens(buff, 1);
2095  owl_editwin_insert_string(e, buff);
2096  owl_editwin_redisplay(e, 0);
2097  owl_global_set_needrefresh(&g); 
2098  return NULL;
2099}
2100
2101void owl_command_editline_done(owl_editwin *e) {
2102  owl_history *hist=owl_editwin_get_history(e);
2103  char *rv, *cmd;
2104
2105  owl_history_store(hist, owl_editwin_get_text(e));
2106  owl_history_reset(hist);
2107  owl_global_set_typwin_inactive(&g);
2108  cmd = owl_strdup(owl_editwin_get_text(e));
2109  owl_editwin_fullclear(e);
2110  rv = owl_function_command(cmd);
2111  owl_free(cmd);
2112
2113  wnoutrefresh(owl_editwin_get_curswin(e));
2114  owl_global_set_needrefresh(&g);
2115
2116  if (rv) {
2117    owl_function_makemsg("%s", rv);
2118    owl_free(rv);
2119  }
2120}
2121
2122void owl_command_editmulti_done(owl_editwin *e) {
2123  owl_history *hist=owl_editwin_get_history(e);
2124
2125  owl_history_store(hist, owl_editwin_get_text(e));
2126  owl_history_reset(hist);
2127
2128  owl_function_run_buffercommand();
2129  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2130  owl_editwin_fullclear(e);
2131  owl_global_set_typwin_inactive(&g);
2132  owl_global_set_needrefresh(&g);
2133  wnoutrefresh(owl_editwin_get_curswin(e));
2134}
2135
2136void owl_command_editmulti_done_or_delete(owl_editwin *e) {
2137  if (owl_editwin_is_at_end(e)) {
2138    owl_command_editmulti_done(e);
2139  } else {
2140    owl_editwin_delete_char(e);
2141  }
2142}
2143
2144
2145/*********************************************************************/
2146/*********************** POPLESS SPECIFIC ****************************/
2147/*********************************************************************/
2148
2149void owl_command_popless_quit(owl_viewwin *vw) {
2150  owl_popwin_close(owl_global_get_popwin(&g));
2151  owl_viewwin_free(vw);
2152  owl_global_set_needrefresh(&g);
2153}
Note: See TracBrowser for help on using the repository browser.