source: commands.c @ 0c502e9

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