#include #include #include #include #include #include "owl.h" /* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */ #define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \ { name, summary, usage, description, ctx, \ NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL } /* fn is "void foo(void)" */ #define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \ { name, summary, usage, description, ctx, \ NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL } /* fn is "void foo(int)" */ #define OWLCMD_INT(name, fn, ctx, summary, usage, description) \ { name, summary, usage, description, ctx, \ NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL } #define OWLCMD_ALIAS(name, actualname) \ { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \ actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL } /* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */ #define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \ { name, summary, usage, description, ctx, \ NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL } /* fn is "void foo(void)" */ #define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \ { name, summary, usage, description, ctx, \ NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL } /* fn is "void foo(int)" */ #define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \ { name, summary, usage, description, ctx, \ NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL } const owl_cmd commands_to_init[] = { OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY, "send a login or logout notification", "zlog in [tty]\nzlog out", "zlog in will send a login notification, zlog out will send a\n" "logout notification. By default a login notification is sent\n" "when owl is started and a logout notification is sent when owl\n" "is exited. This behavior can be changed with the 'startuplogin'\n" "and 'shutdownlogout' variables. If a tty is specified for zlog in\n" "then the owl variable 'tty' will be set to that string, causing\n" "it to be used as the zephyr location tty.\n"), OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY, "exit owl", "", "Exit owl and run any shutdown activities."), OWLCMD_ALIAS("exit", "quit"), OWLCMD_ALIAS("q", "quit"), OWLCMD_ARGS("term", owl_command_term, OWL_CTX_ANY, "control the terminal", "term raise\n" "term deiconify\n", ""), OWLCMD_VOID("nop", owl_command_nop, OWL_CTX_ANY, "do nothing", "", ""), OWLCMD_ARGS("start-command", owl_command_start_command, OWL_CTX_INTERACTIVE, "prompts the user to enter a command", "start-command [initial-value]", "Initializes the command field to initial-value."), OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY, "creates a command alias", "alias ", "Creates a command alias from new_command to old_command.\n" "Any arguments passed to will be appended to\n" " before it is executed.\n"), OWLCMD_ARGS("bindkey", owl_command_bindkey, OWL_CTX_ANY, "creates a binding in a keymap", "bindkey command ", "(Note: There is a literal word \"command\" between \n" " and .)\n" "Binds a key sequence to a command within a keymap.\n" "Use 'show keymaps' to see the existing keymaps.\n" "Key sequences may be things like M-C-t or NPAGE.\n\n" "Ex.: bindkey recv C-b command zwrite -c barnowl\n" "Ex.: bindkey recv m command start-command zwrite -c my-class -i \n\n" "SEE ALSO: unbindkey, start-command"), OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY, "removes a binding in a keymap", "bindkey ", "Removes a binding of a key sequence within a keymap.\n" "Use 'show keymaps' to see the existing keymaps.\n" "Ex.: unbindkey recv H\n\n" "SEE ALSO: bindkey"), OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE, "send a zephyr", "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcode] [ ...] [-m ]", "Zwrite send a zephyr to the one or more users specified.\n\n" "The following options are available:\n\n" "-m Specifies a message to send without prompting.\n" " Note that this does not yet log an outgoing message.\n" " This must be the last argument.\n\n" "-n Do not send a ping message.\n\n" "-C If the message is sent to more than one user include a\n" " \"cc:\" line in the text\n\n" "-c class\n" " Send to the specified zephyr class\n\n" "-i instance\n" " Send to the specified zephyr instance\n\n" "-r realm\n" " Send to a foreign realm\n" "-O opcode\n" " Send to the specified opcode\n"), OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE, "send an AIM message", "aimwrite [-m ]", "Send an aim message to a user.\n\n" "The following options are available:\n\n" "-m Specifies a message to send without prompting.\n"), OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE, "send a loopback message", "loopwrite", "Send a local message.\n"), OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE, "send an encrypted zephyr", "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcode] [-m ]\n", "Behaves like zwrite but uses encryption. Not for use with\n" "personal messages\n"), OWLCMD_ARGS("reply", owl_command_reply, OWL_CTX_INTERACTIVE, "reply to the current message", "reply [-e] [ sender | all | zaway ]", "If -e is specified, the zwrite command line is presented to\n" "allow editing.\n\n" "If 'sender' is specified, reply to the sender.\n\n" "If 'all' or no args are specified, reply publicly to the\n" "same class/instance for non-personal messages and to the\n" "sender for personal messages.\n\n" "If 'zaway' is specified, replies with a zaway message.\n\n"), OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY, "set a variable value", "set [-q] [] []\n" "set", "Set the named variable to the specified value. If no\n" "arguments are given, print the value of all variables.\n" "If the value is unspecified and the variable is a boolean, it will be\n" "set to 'on'. If -q is used, set is silent and does not print a\n" "message.\n"), OWLCMD_ARGS("unset", owl_command_unset, OWL_CTX_ANY, "unset a boolean variable value", "unset [-q] \n" "unset", "Set the named boolean variable to off.\n" "If -q is specified, is silent and doesn't print a message.\n"), OWLCMD_ARGS("print", owl_command_print, OWL_CTX_ANY, "print a variable value", "print \n" "print", "Print the value of the named variable. If no arguments\n" "are used print the value of all variables.\n"), OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY, "run a command and set it to be run at every Owl startup", "startup ...", "Everything on the command line after the startup command\n" "is executed as a normal owl command and is also placed in\n" "a file so that the command is executed every time owl\n" "is started"), OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY, "remove a command from the list of those to be run at Owl startup", "unstartup ...", ""), OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY, "print the version of the running owl", "", ""), OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY, "subscribe to a zephyr class, instance, recipient", "subscribe [-t] [instance [recipient]]", "Subscribe to the specified class and instance. If the\n" "instance or recipient is not listed on the command\n" "line they default to * (the wildcard recipient).\n" "If the -t option is present the subscription will\n" "only be temporary, i.e., it will not be written to\n" "the subscription file and will therefore not be\n" "present the next time owl is started.\n"), OWLCMD_ALIAS("sub", "subscribe"), OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY, "unsubscribe from a zephyr class, instance, recipient", "unsubscribe [-t] [instance [recipient]]", "Unsubscribe from the specified class and instance. If the\n" "instance or recipient is not listed on the command\n" "line they default to * (the wildcard recipient).\n" "If the -t option is present the unsubscription will\n" "only be temporary, i.e., it will not be updated in\n" "the subscription file and will therefore not be\n" "in effect the next time owl is started.\n"), OWLCMD_ALIAS("unsub", "unsubscribe"), OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY, "unsubscribe from all zephyrs", "", ""), OWLCMD_VOID("getsubs", owl_command_getsubs, OWL_CTX_ANY, "print all current subscriptions", "getsubs", "getsubs retrieves the current subscriptions from the server\n" "and displays them.\n"), OWLCMD_ARGS("dump", owl_command_dump, OWL_CTX_ANY, "dump messages to a file", "dump ", "Dump messages in current view to the named file."), OWLCMD_ARGS("source", owl_command_source, OWL_CTX_ANY, "execute owl commands from a file", "source ", "Execute the owl commands in .\n"), OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE, "AIM specific commands", "aim search ", ""), OWLCMD_ARGS("addbuddy", owl_command_addbuddy, OWL_CTX_INTERACTIVE, "add a buddy to a buddylist", "addbuddy ", "Add the named buddy to your buddylist. can be aim or zephyr\n"), OWLCMD_ARGS("delbuddy", owl_command_delbuddy, OWL_CTX_INTERACTIVE, "delete a buddy from a buddylist", "delbuddy ", "Delete the named buddy from your buddylist. can be aim or zephyr\n"), OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE, "join a chat group", "join aim [exchange]", "Join the AIM chatroom with 'groupname'.\n"), OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE, "creates a zpunt based on the current message", "smartzpunt [-i | --instance]", "Starts a zpunt command based on the current message's class\n" "(and instance if -i is specified).\n"), OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY, "suppress a given zephyr triplet", "zpunt [recipient]\n" "zpunt ", "The zpunt command will suppress messages to the specified\n" "zephyr triplet. In the second usage messages are suppressed\n" "for class MESSAGE and the named instance.\n\n" "SEE ALSO: zunpunt, show zpunts\n"), OWLCMD_ARGS("zunpunt", owl_command_zunpunt, OWL_CTX_ANY, "undo a previous zpunt", "zunpunt [recipient]\n" "zunpunt ", "The zunpunt command will allow messages that were previously\n" "suppressed to be received again.\n\n" "SEE ALSO: zpunt, show zpunts\n"), OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY, "suppress an arbitrary filter", "punt ", "punt \n" "The punt command will suppress messages to the specified\n" "filter\n\n" "SEE ALSO: unpunt, zpunt, show zpunts\n"), OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY, "remove an entry from the punt list", "zpunt \n" "zpunt \n" "zpunt \n", "The unpunt command will remove an entry from the puntlist.\n" "The first two forms correspond to the first two forms of the :punt\n" "command. The latter allows you to remove a specific entry from the\n" "the list (see :show zpunts)\n\n" "SEE ALSO: punt, zpunt, zunpunt, show zpunts\n"), OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE, "display detailed information about the current message", "", ""), OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE, "display help on using owl", "help [command]", ""), OWLCMD_ARGS("zlist", owl_command_zlist, OWL_CTX_INTERACTIVE, "List users logged in", "znol [-f file]", "Print a znol-style listing of users logged in"), OWLCMD_VOID("alist", owl_command_alist, OWL_CTX_INTERACTIVE, "List AIM users logged in", "alist", "Print a listing of AIM users logged in"), OWLCMD_VOID("blist", owl_command_blist, OWL_CTX_INTERACTIVE, "List all buddies logged in", "blist", "Print a listing of buddies logged in, regardless of protocol."), OWLCMD_VOID("toggle-oneline", owl_command_toggleoneline, OWL_CTX_INTERACTIVE, "Toggle the style between oneline and the default style", "toggle-oneline", ""), OWLCMD_ARGS("recv:getshift", owl_command_get_shift, OWL_CTX_INTERACTIVE, "gets position of receive window scrolling", "", ""), OWLCMD_INT("recv:setshift", owl_command_set_shift, OWL_CTX_INTERACTIVE, "scrolls receive window to specified position", "", ""), OWLCMD_VOID("recv:pagedown", owl_function_mainwin_pagedown, OWL_CTX_INTERACTIVE, "scrolls down by a page", "", ""), OWLCMD_VOID("recv:pageup", owl_function_mainwin_pageup, OWL_CTX_INTERACTIVE, "scrolls up by a page", "", ""), OWLCMD_VOID("recv:mark", owl_function_mark_message, OWL_CTX_INTERACTIVE, "mark the current message", "", ""), OWLCMD_VOID("recv:swapmark", owl_function_swap_cur_marked, OWL_CTX_INTERACTIVE, "swap the positions of the pointer and the mark", "", ""), OWLCMD_INT ("recv:scroll", owl_function_page_curmsg, OWL_CTX_INTERACTIVE, "scrolls current message up or down", "recv:scroll ", "Scrolls the current message up or down by .\n" "Scrolls up if is negative, else scrolls down.\n"), OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE, "move the pointer to the next message", "recv:next [ --filter ] [ --skip-deleted ] [ --last-if-none ]\n" " [ --smart-filter | --smart-filter-instance ]", "Moves the pointer to the next message in the current view.\n" "If --filter is specified, will only consider messages in\n" "the filter .\n" "If --smart-filter or --smart-filter-instance is specified,\n" "goes to the next message that is similar to the current message.\n" "If --skip-deleted is specified, deleted messages will\n" "be skipped.\n" "If --last-if-none is specified, will stop at last message\n" "in the view if no other suitable messages are found.\n"), OWLCMD_ALIAS("recv:next", "next"), OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE, "move the pointer to the previous message", "recv:prev [ --filter ] [ --skip-deleted ] [ --first-if-none ]\n" " [ --smart-filter | --smart-filter-instance ]", "Moves the pointer to the next message in the current view.\n" "If --filter is specified, will only consider messages in\n" "the filter .\n" "If --smart-filter or --smart-filter-instance is specified,\n" "goes to the previous message that is similar to the current message.\n" "If --skip-deleted is specified, deleted messages will\n" "be skipped.\n" "If --first-if-none is specified, will stop at first message\n" "in the view if no other suitable messages are found.\n"), OWLCMD_ALIAS("recv:prev", "prev"), OWLCMD_ALIAS("recv:next-notdel", "recv:next --skip-deleted --last-if-none"), OWLCMD_ALIAS("next-notdel", "recv:next --skip-deleted --last-if-none"), OWLCMD_ALIAS("recv:prev-notdel", "recv:prev --skip-deleted --first-if-none"), OWLCMD_ALIAS("prev-notdel", "recv:prev --skip-deleted --first-if-none"), OWLCMD_ALIAS("recv:next-personal", "recv:next --filter personal"), OWLCMD_ALIAS("recv:prev-personal", "recv:prev --filter personal"), OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE, "move the pointer to the first message", "", ""), OWLCMD_ALIAS("recv:first", "first"), OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE, "move the pointer to the last message", "", "Moves the pointer to the last message in the view.\n" "If we are already at the last message in the view,\n" "blanks the screen and moves just past the end of the view\n" "so that new messages will appear starting at the top\n" "of the screen.\n"), OWLCMD_ALIAS("recv:last", "last"), OWLCMD_VOID("expunge", owl_command_expunge, OWL_CTX_INTERACTIVE, "remove all messages marked for deletion", "", ""), OWLCMD_VOID("resize", owl_command_resize, OWL_CTX_ANY, "resize the window to the current screen size", "", ""), OWLCMD_VOID("redisplay", owl_command_redisplay, OWL_CTX_ANY, "redraw the entire window", "", ""), OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY, "suspend owl", "", ""), OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY, "pops up a message in popup window", "echo [args .. ]\n\n", ""), OWLCMD_ARGS("exec", owl_command_exec, OWL_CTX_ANY, "run a command from the shell", "exec [args .. ]", ""), OWLCMD_ARGS("aexec", owl_command_aexec, OWL_CTX_INTERACTIVE, "run a command from the shell and display in an admin message", "aexec [args .. ]", ""), OWLCMD_ARGS("pexec", owl_command_pexec, OWL_CTX_INTERACTIVE, "run a command from the shell and display in a popup window", "pexec [args .. ]", ""), OWLCMD_ARGS("perl", owl_command_perl, OWL_CTX_ANY, "run a perl expression", "perl [args .. ]", ""), OWLCMD_ARGS("aperl", owl_command_aperl, OWL_CTX_INTERACTIVE, "run a perl expression and display in an admin message", "aperl [args .. ]", ""), OWLCMD_ARGS("pperl", owl_command_pperl, OWL_CTX_INTERACTIVE, "run a perl expression and display in a popup window", "pperl [args .. ]", ""), OWLCMD_ARGS("multi", owl_command_multi, OWL_CTX_ANY, "runs multiple ;-separated commands", "multi ( ; )*\n", "Runs multiple semicolon-separated commands in order.\n" "Note quoting isn't supported here yet.\n" "If you want to do something fancy, use perl.\n"), OWLCMD_ARGS("(", owl_command_multi, OWL_CTX_ANY, "runs multiple ;-separated commands", "'(' ( ; )* ')'\n", "Runs multiple semicolon-separated commands in order.\n" "You must have a space before the final ')'\n" "Note quoting isn't supported here yet.\n" "If you want to do something fancy, use perl.\n"), OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN, "pops up a message in a window", "", ""), OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE, "Set, enable or disable zephyr away message", "zaway [ on | off | toggle ]\n" "zaway ", "Turn on or off a zaway message. If 'message' is\n" "specified turn on zaway with that message, otherwise\n" "use the default.\n"), OWLCMD_ARGS("aaway", owl_command_aaway, OWL_CTX_INTERACTIVE, "Set, enable or disable AIM away message", "aaway [ on | off | toggle ]\n" "aaway ", "Turn on or off the AIM away message. If 'message' is\n" "specified turn on aaway with that message, otherwise\n" "use the default.\n"), OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE, "Set, enable or disable both AIM and zephyr away messages", "away [ on | off | toggle ]\n" "away ", "Turn on or off the AIM and zephyr away message. If\n" "'message' is specified turn them on with that message,\n" "otherwise use the default.\n" "\n" "This command really just runs the 'aaway' and 'zaway'\n" "commands together\n" "\n" "SEE ALSO: aaway, zaway"), OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY, "load subscriptions from a file", "load-subs \n", ""), OWLCMD_ARGS("loadsubs", owl_command_loadsubs, OWL_CTX_ANY, "load subscriptions from a file", "loadsubs \n", ""), OWLCMD_ARGS("loadloginsubs", owl_command_loadloginsubs, OWL_CTX_ANY, "load login subscriptions from a file", "loadloginsubs \n", "The file should contain a list of usernames, one per line."), OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE, "print information about owl", "", ""), OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY, "print status information about the running owl", "", ""), OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE, "locate a user", "zlocate [-d] ...", "Performs a zlocate on one ore more users and puts the result\n" "int a popwin. If -d is specified, does not authenticate\n" "the lookup request.\n"), OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY, "create a message filter", "filter [ -c fgcolor ] [ -b bgcolor ] [ ... ]", "The filter command creates a filter with the specified name,\n" "or if one already exists it is replaced. Example filter\n" "syntax would be:\n\n" " filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )\n\n" "Valid matching fields are:\n" " sender - sender\n" " recipient - recipient\n" " class - zephyr class name\n" " instance - zephyr instance name\n" " opcode - zephyr opcode\n" " realm - zephyr realm\n" " body - message body\n" " hostname - hostname of sending host\n" " type - message type (zephyr, aim, admin)\n" " direction - either 'in' 'out' or 'none'\n" " login - either 'login' 'logout' or 'none'\n" "Also you may match on the validity of another filter:\n" " filter \n" "Also you may pass the message to a perl function returning 0 or 1,\n" "where 1 indicates that the function matches the filter:\n" " perl \n" "Valid operators are:\n" " and\n" " or\n" " not\n" "And additionally you may use the static values:\n" " true\n" " false\n" "Spaces must be present before and after parentheses. If the\n" "optional color arguments are used they specifies the colors that\n" "messages matching this filter should be displayed in.\n\n" "SEE ALSO: view, viewclass, viewuser\n"), OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE, "change the colors on the current filter", "colorview []", "The colors of messages in the current filter will be changed\n" "to ,. Use the 'show colors' command for a list\n" "of valid colors.\n\n" "SEE ALSO: 'show colors'\n"), OWLCMD_ARGS("colorclass", owl_command_colorclass, OWL_CTX_INTERACTIVE, "create a filter to color messages of the given class name", "colorclass []", "A filter will be created to color messages in " "in ,. Use the 'show colors' command for a list\n" "of valid colors.\n\n" "SEE ALSO: 'show colors'\n"), OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE, "view messages matching a filter", "view [] [-f | --home | -r ] [-s