source: commands.c @ 3e328b8

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