From f2918a6d876c330ac62e7f4167db6796be141580 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 17 Sep 2011 11:32:55 +0000 Subject: Enable loading formats from client --- vchat-commands.c | 32 +++++++++++++++++++++++++++++++- vchat.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/vchat-commands.c b/vchat-commands.c index 0c8ca26..5499948 100755 --- a/vchat-commands.c +++ b/vchat-commands.c @@ -59,6 +59,7 @@ static void command_user ( char *tail); static void command_pm ( char *tail); static void command_action ( char *tail); static void command_help ( char *tail); +static void command_format ( char *tail); static void command_flt ( char *tail); static void command_lsflt ( char *tail); static void command_clflt ( char *tail); @@ -80,6 +81,7 @@ commandtable[] = { { COMMAND_CLFLT, "CLFLT", 5, command_clflt, NULL, LONG_HELPTEXT_CLFLT }, { COMMAND_HELP, "HELP", 4, command_help, SHORT_HELPTEXT_HELP, LONG_HELPTEXT_HELP }, { COMMAND_FILTERS, "FILTERS", 7, command_help, SHORT_HELPTEXT_FILTERS, LONG_HELPTEXT_FILTERS }, +{ COMMAND_FORMAT, "FORMAT", 6, command_format, NULL, NULL }, { COMMAND_RECONNECT, "RECONNECT", 9, command_reconnect, SHORT_HELPTEXT_RECONNECT, LONG_HELPTEXT_RECONNECT }, { COMMAND_KEYS, "KEYS", 4, command_help, SHORT_HELPTEXT_KEYS, LONG_HELPTEXT_KEYS }, { COMMAND_QUERY, "QUERY", 5, command_query, NULL, NULL }, @@ -294,7 +296,35 @@ command_pm (char *tail) { privatemessagetx( tail ); } - + +static void +command_format(char *line) { + struct stat testexist; + char * tildex = NULL; + + flushout(); + while( *line==' ') line++; + if(file) { + tildex = tilde_expand( file ); + if(tildex && !stat(file, &testexist )) + loadformats(file); + else { +#define BUFSIZE 4096 + char buf[BUFSIZE]; + snprintf( buf, BUFSIZE, "~/.vchat/sample-%s.fmt", file ); + free(tildex); + tildex = tilde_expand( file ); + if(tildex && !stat(file, &testexist )) + loadformats(file); + } + + } else { + writeout(" Forgot to specify format file. "); + } + free(tildex); + showout(); +} + /* handle a help request */ static void command_help (char *line) { diff --git a/vchat.h b/vchat.h index 5e2bff9..1b29155 100755 --- a/vchat.h +++ b/vchat.h @@ -90,6 +90,7 @@ extern unsigned int loggedin; extern char errstr[]; extern char *vchat_cl_version; void loadcfg (char *file,void (*lineparser) (char *)); +void loadformats (char *file); void cleanup(int signal); /* configuration helper funktions from vchat-client.c */ -- cgit v1.2.3