|
|
@@ -37,6 +37,7 @@
|
|
|
|
|
|
#include <klist.h>
|
|
|
#include <vcc/vcc.h>
|
|
|
+#include <vcc/plugin.h>
|
|
|
#include <vcc/version.h>
|
|
|
#include <vcc/pretty.h>
|
|
|
|
|
|
@@ -57,6 +58,8 @@ int do_cmd_cqd(char *);
|
|
|
int do_cmd_ban(char *);
|
|
|
int do_cmd_unban(char *);
|
|
|
int do_cmd_encry(char *);
|
|
|
+int do_cmd_pls(char *);
|
|
|
+int do_cmd_pins(char *);
|
|
|
|
|
|
int read_msg(struct vcc_request *);
|
|
|
int vcc_create_session(char *name);
|
|
|
@@ -78,11 +81,7 @@ int join_session(int sid);
|
|
|
|
|
|
int did_warn = 0;
|
|
|
|
|
|
-struct cmdtable {
|
|
|
- char *cmd;
|
|
|
- int (* do_cmd) (char *);
|
|
|
- char *help;
|
|
|
-} cmdtab[] = {
|
|
|
+struct cmdtable cmdtab[] = {
|
|
|
{ "-help", do_cmd_help, "Show information about every message. " },
|
|
|
{ "-quit", do_cmd_quit, "Disconnect to server and exit vcc. " },
|
|
|
{ "-ls", do_cmd_ls, "List all users online now. " },
|
|
|
@@ -98,6 +97,8 @@ struct cmdtable {
|
|
|
{ "-ban", do_cmd_ban, "Don't receive more messages from somebody. " },
|
|
|
{ "-unban", do_cmd_unban, "Receive more messages from somebody. " },
|
|
|
{ "-encry", do_cmd_encry, "Send an encrypted message. " },
|
|
|
+ { "-pls", do_cmd_pls, "List plugins installed (not inserted). " },
|
|
|
+ { "-pins", do_cmd_pins, "Insert a plugin. " },
|
|
|
|
|
|
{ NULL, NULL, NULL }
|
|
|
};
|
|
|
@@ -105,33 +106,63 @@ struct cmdtable {
|
|
|
#define clear_line() fprintf(stderr, "\033[2K\r")
|
|
|
#define __unused __attribute__((unused))
|
|
|
|
|
|
+typedef int (* fptr_t) (char *);
|
|
|
+
|
|
|
+static fptr_t execute_in(struct cmdtable *tab, char *s, int len) {
|
|
|
+ struct cmdtable *t;
|
|
|
+
|
|
|
+ for (t = tab; t->cmd; t++)
|
|
|
+ if (!strncmp(t->cmd, s, len))
|
|
|
+ return t->do_cmd;
|
|
|
+
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
int do_cmd(char *s) {
|
|
|
- struct cmdtable *t;
|
|
|
+ struct plugin *plg;
|
|
|
char *p;
|
|
|
- int len;
|
|
|
+ int len, i;
|
|
|
+ fptr_t f;
|
|
|
|
|
|
p = s;
|
|
|
|
|
|
for (len = 0; *p && !isspace(*p); len++)
|
|
|
p++;
|
|
|
- for (t = cmdtab; t->cmd; t++)
|
|
|
- if (!strncmp(t->cmd, s, len))
|
|
|
- return t->do_cmd(s);
|
|
|
-
|
|
|
+
|
|
|
+ if ((f = execute_in(cmdtab, s, len)))
|
|
|
+ return f(s);
|
|
|
+
|
|
|
+ for (i = 0; (plg = plugins[i]); i++)
|
|
|
+ if ((f = execute_in(plg->cmdtab, s, len)))
|
|
|
+ return f(s);
|
|
|
+
|
|
|
pretty_unknown_cmd(s);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
-int do_cmd_help(char *s) {
|
|
|
+static int __help(struct cmdtable *cmdtab) {
|
|
|
struct cmdtable *t;
|
|
|
|
|
|
- (void) s;
|
|
|
-
|
|
|
for (t = cmdtab; t->cmd; t++)
|
|
|
pretty_cmd_help(t->cmd, t->help);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+int do_cmd_help(char *s) {
|
|
|
+ struct plugin *p;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ (void) s;
|
|
|
+
|
|
|
+ __help(cmdtab);
|
|
|
+
|
|
|
+ for (i = 0; (p = plugins[i]); i++)
|
|
|
+ __help(p->cmdtab);
|
|
|
|
|
|
return 0;
|
|
|
}
|