source: commands.c @ 0982901

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