summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xvchat-client.c6
-rwxr-xr-xvchat-commands.c72
-rwxr-xr-xvchat-help.h26
-rwxr-xr-xvchat.h2
4 files changed, 63 insertions, 43 deletions
diff --git a/vchat-client.c b/vchat-client.c
index dc06015..f521432 100755
--- a/vchat-client.c
+++ b/vchat-client.c
@@ -40,6 +40,8 @@ unsigned int loggedin = 0;
40int status = 1; 40int status = 1;
41/* we set this, we WANT to quit */ 41/* we set this, we WANT to quit */
42int ownquit = 0; 42int ownquit = 0;
43/* we set this, we DONT want to quit */
44int wantreconnect = 0;
43 45
44/* error string to show after exit */ 46/* error string to show after exit */
45char errstr[ERRSTRSIZE] = "\0"; 47char errstr[ERRSTRSIZE] = "\0";
@@ -549,8 +551,10 @@ main (int argc, char **argv)
549 /* sanely close connection to server */ 551 /* sanely close connection to server */
550 vcdisconnect (); 552 vcdisconnect ();
551 553
552 if( !ownquit && getintoption( CF_AUTORECONN ) ) 554 if( !ownquit && ( getintoption( CF_AUTORECONN ) || wantreconnect ) )
553 status = 1; 555 status = 1;
556
557 wantreconnect = 0;
554 } 558 }
555 559
556 /* call cleanup-hook without signal */ 560 /* call cleanup-hook without signal */
diff --git a/vchat-commands.c b/vchat-commands.c
index 8a4f475..651878c 100755
--- a/vchat-commands.c
+++ b/vchat-commands.c
@@ -29,6 +29,8 @@ char *vchat_cm_version = "$Id$";
29 29
30/* from vchat-client.c */ 30/* from vchat-client.c */
31extern int ownquit; 31extern int ownquit;
32extern int wantreconnect;
33extern int status;
32 34
33/* our "/command " table */ 35/* our "/command " table */
34enum { 36enum {
@@ -48,21 +50,23 @@ COMMAND_PMSHORT,
48COMMAND_QUERY, 50COMMAND_QUERY,
49COMMAND_QUITSHORT, 51COMMAND_QUITSHORT,
50COMMAND_PLAIN, 52COMMAND_PLAIN,
53COMMAND_RECONNECT,
51COMMAND_NONE 54COMMAND_NONE
52}; 55};
53 56
54static void command_quit ( char *tail); 57static void command_quit ( char *tail);
55static void command_user ( char *tail); 58static void command_user ( char *tail);
56static void command_pm ( char *tail); 59static void command_pm ( char *tail);
57static void command_action ( char *tail); 60static void command_action ( char *tail);
58static void command_help ( char *tail); 61static void command_help ( char *tail);
59static void command_flt ( char *tail); 62static void command_flt ( char *tail);
60static void command_lsflt ( char *tail); 63static void command_lsflt ( char *tail);
61static void command_clflt ( char *tail); 64static void command_clflt ( char *tail);
62static void command_rmflt ( char *tail); 65static void command_rmflt ( char *tail);
63 void command_version ( char *tail); 66 void command_version ( char *tail);
64static void command_none ( char *line); 67static void command_none ( char *line);
65static void command_query ( char *tail); 68static void command_query ( char *tail);
69static void command_reconnect ( char *tail);
66 70
67static void output_default ( char *tail); 71static void output_default ( char *tail);
68 72
@@ -70,23 +74,24 @@ static void output_default ( char *tail);
70 74
71static commandentry 75static commandentry
72commandtable[] = { 76commandtable[] = {
73{ COMMAND_VERSION, "VERSION", 7, command_version, SHORT_HELPTEXT_VERSION, LONG_HELPTEXT_VERSION }, 77{ COMMAND_VERSION, "VERSION", 7, command_version, SHORT_HELPTEXT_VERSION, LONG_HELPTEXT_VERSION },
74{ COMMAND_LSFLT, "LSFLT", 5, command_lsflt, NULL, LONG_HELPTEXT_LSFLT }, 78{ COMMAND_LSFLT, "LSFLT", 5, command_lsflt, NULL, LONG_HELPTEXT_LSFLT },
75{ COMMAND_RMFLT, "RMFLT", 5, command_rmflt, NULL, LONG_HELPTEXT_RMFLT }, 79{ COMMAND_RMFLT, "RMFLT", 5, command_rmflt, NULL, LONG_HELPTEXT_RMFLT },
76{ COMMAND_CLFLT, "CLFLT", 5, command_clflt, NULL, LONG_HELPTEXT_CLFLT }, 80{ COMMAND_CLFLT, "CLFLT", 5, command_clflt, NULL, LONG_HELPTEXT_CLFLT },
77{ COMMAND_HELP, "HELP", 4, command_help, SHORT_HELPTEXT_HELP, LONG_HELPTEXT_HELP }, 81{ COMMAND_HELP, "HELP", 4, command_help, SHORT_HELPTEXT_HELP, LONG_HELPTEXT_HELP },
78{ COMMAND_FILTERS, "FILTERS", 7, command_help, SHORT_HELPTEXT_FILTERS, LONG_HELPTEXT_FILTERS }, 82{ COMMAND_FILTERS, "FILTERS", 7, command_help, SHORT_HELPTEXT_FILTERS, LONG_HELPTEXT_FILTERS },
79{ COMMAND_KEYS, "KEYS", 4, command_help, SHORT_HELPTEXT_KEYS, LONG_HELPTEXT_KEYS }, 83{ COMMAND_RECONNECT, "RECONNECT", 9, command_reconnect, SHORT_HELPTEXT_RECONNECT, LONG_HELPTEXT_RECONNECT },
80{ COMMAND_QUERY, "QUERY", 5, command_query, NULL, NULL }, 84{ COMMAND_KEYS, "KEYS", 4, command_help, SHORT_HELPTEXT_KEYS, LONG_HELPTEXT_KEYS },
81{ COMMAND_QUIT, "QUIT", 4, command_quit, SHORT_HELPTEXT_QUIT, LONG_HELPTEXT_QUIT }, 85{ COMMAND_QUERY, "QUERY", 5, command_query, NULL, NULL },
82{ COMMAND_USER, "USER", 4, command_user, SHORT_HELPTEXT_USER, LONG_HELPTEXT_USER }, 86{ COMMAND_QUIT, "QUIT", 4, command_quit, SHORT_HELPTEXT_QUIT, LONG_HELPTEXT_QUIT },
83{ COMMAND_FLT, "FLT", 3, command_flt, NULL, LONG_HELPTEXT_FLT }, 87{ COMMAND_USER, "USER", 4, command_user, SHORT_HELPTEXT_USER, LONG_HELPTEXT_USER },
84{ COMMAND_PM, "MSG", 3, command_pm, SHORT_HELPTEXT_MSG, LONG_HELPTEXT_MSG }, 88{ COMMAND_FLT, "FLT", 3, command_flt, NULL, LONG_HELPTEXT_FLT },
85{ COMMAND_ACTION, "ME", 2, command_action, SHORT_HELPTEXT_ME, LONG_HELPTEXT_ME }, 89{ COMMAND_PM, "MSG", 3, command_pm, SHORT_HELPTEXT_MSG, LONG_HELPTEXT_MSG },
86{ COMMAND_PMSHORT, "M", 1, command_pm, NULL, SHORT_HELPTEXT_MSG }, 90{ COMMAND_ACTION, "ME", 2, command_action, SHORT_HELPTEXT_ME, LONG_HELPTEXT_ME },
87{ COMMAND_QUITSHORT,"Q", 1, command_quit, SHORT_HELPTEXT_QUIT, LONG_HELPTEXT_QUIT }, 91{ COMMAND_PMSHORT, "M", 1, command_pm, NULL, SHORT_HELPTEXT_MSG },
88{ COMMAND_PLAIN, "/", 1, output_default, NULL, NULL }, 92{ COMMAND_QUITSHORT, "Q", 1, command_quit, SHORT_HELPTEXT_QUIT, LONG_HELPTEXT_QUIT },
89{ COMMAND_NONE, "", 0, command_none, NULL, NULL } 93{ COMMAND_PLAIN, "/", 1, output_default, NULL, NULL },
94{ COMMAND_NONE, "", 0, command_none, NULL, NULL }
90}; 95};
91 96
92/* parse "/command" */ 97/* parse "/command" */
@@ -372,6 +377,15 @@ command_action(char *tail)
372 doaction( tail); 377 doaction( tail);
373} 378}
374 379
380/* handle a "/reconnect" request */
381static void
382command_reconnect(char *tail)
383{
384 status = 0;
385 wantreconnect = 1;
386 ownquit = 0;
387}
388
375/* handle a "/quit " exit */ 389/* handle a "/quit " exit */
376static void 390static void
377command_quit(char *tail) 391command_quit(char *tail)
diff --git a/vchat-help.h b/vchat-help.h
index 9cfe04b..aec0fcf 100755
--- a/vchat-help.h
+++ b/vchat-help.h
@@ -51,16 +51,18 @@
51 ^X - switch off message window or\n\ 51 ^X - switch off message window or\n\
52 toggle private window\n\ 52 toggle private window\n\
53 TAB - nick completion" 53 TAB - nick completion"
54#define SHORT_HELPTEXT_QUIT "/QUIT [REASON] Leave the chat for reason Reason" 54#define SHORT_HELPTEXT_QUIT "/QUIT [REASON] Leave the chat for reason Reason"
55#define LONG_HELPTEXT_QUIT NULL 55#define LONG_HELPTEXT_QUIT NULL
56#define SHORT_HELPTEXT_USER "/USER REGEX Lists all users matching regex REGEX" 56#define SHORT_HELPTEXT_USER "/USER REGEX Lists all users matching regex REGEX"
57#define LONG_HELPTEXT_USER NULL 57#define LONG_HELPTEXT_USER NULL
58#define SHORT_HELPTEXT_MSG "/M[SG] USER MESSAGE Send private message to user USER" 58#define SHORT_HELPTEXT_MSG "/M[SG] USER MESSAGE Send private message to user USER"
59#define LONG_HELPTEXT_MSG NULL 59#define LONG_HELPTEXT_MSG NULL
60#define SHORT_HELPTEXT_ME "/ME ACTION Let the user do an action" 60#define SHORT_HELPTEXT_ME "/ME ACTION Let the user do an action"
61#define LONG_HELPTEXT_ME NULL 61#define LONG_HELPTEXT_ME NULL
62#define SHORT_HELPTEXT_M SHORT_HELPTEXT_MSG 62#define SHORT_HELPTEXT_M SHORT_HELPTEXT_MSG
63#define LONG_HELPTEXT_M LONG_HELPTEXT_MSG 63#define LONG_HELPTEXT_M LONG_HELPTEXT_MSG
64#define SHORT_HELPTEXT_FILTERS "/HELP FILTERS Show summary of filter commands" 64#define SHORT_HELPTEXT_FILTERS "/HELP FILTERS Show summary of filter commands"
65#define LONG_HELPTEXT_FILTERS SHORT_HELPTEXT_FLT "\n" SHORT_HELPTEXT_RMFLT "\n" SHORT_HELPTEXT_LSFLT "\n" SHORT_HELPTEXT_CLFLT 65#define LONG_HELPTEXT_FILTERS SHORT_HELPTEXT_FLT "\n" SHORT_HELPTEXT_RMFLT "\n" SHORT_HELPTEXT_LSFLT "\n" SHORT_HELPTEXT_CLFLT
66#define LONG_HELPTEXT_RECONNECT NULL
67#define SHORT_HELPTEXT_RECONNECT "/RECONNECT Forces client to reconnect"
66 68
diff --git a/vchat.h b/vchat.h
index 613c0cd..d8054bd 100755
--- a/vchat.h
+++ b/vchat.h
@@ -204,7 +204,7 @@ void handleline (char *);
204/* struct for defining "/command" handlers */ 204/* struct for defining "/command" handlers */
205typedef struct { 205typedef struct {
206 int number; 206 int number;
207 char name[8]; 207 char name[10];
208 int len; 208 int len;
209 void (*handler)(char *); 209 void (*handler)(char *);
210 char *short_help; 210 char *short_help;