source: commands.c @ afbf668

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