diff options
-rwxr-xr-x | vchat-client.c | 27 | ||||
-rwxr-xr-x | vchat-commands.c | 11 | ||||
-rwxr-xr-x | vchat-config.h | 1 | ||||
-rwxr-xr-x | vchat-protocol.c | 1 | ||||
-rwxr-xr-x | vchat.h | 2 |
5 files changed, 30 insertions, 12 deletions
diff --git a/vchat-client.c b/vchat-client.c index 56cc721..dc06015 100755 --- a/vchat-client.c +++ b/vchat-client.c | |||
@@ -37,7 +37,10 @@ char *vchat_cl_version = "$Id$"; | |||
37 | /* we're logged in */ | 37 | /* we're logged in */ |
38 | unsigned int loggedin = 0; | 38 | unsigned int loggedin = 0; |
39 | /* we run as long as this is true */ | 39 | /* we run as long as this is true */ |
40 | unsigned int status = 1; | 40 | int status = 1; |
41 | /* we set this, we WANT to quit */ | ||
42 | int ownquit = 0; | ||
43 | |||
41 | /* error string to show after exit */ | 44 | /* error string to show after exit */ |
42 | char errstr[ERRSTRSIZE] = "\0"; | 45 | char errstr[ERRSTRSIZE] = "\0"; |
43 | 46 | ||
@@ -522,9 +525,9 @@ main (int argc, char **argv) | |||
522 | /* initialize userinterface */ | 525 | /* initialize userinterface */ |
523 | initui (); | 526 | initui (); |
524 | 527 | ||
525 | /* attempt connection */ | 528 | while( status ) { |
526 | if (!vcconnect (getstroption(CF_SERVERHOST), getstroption(CF_SERVERPORT))) | 529 | /* attempt connection */ |
527 | { | 530 | if (!vcconnect (getstroption(CF_SERVERHOST), getstroption(CF_SERVERPORT))) { |
528 | snprintf (tmpstr, TMPSTRSIZE, "Could not connect to server, %s.", | 531 | snprintf (tmpstr, TMPSTRSIZE, "Could not connect to server, %s.", |
529 | sys_errlist[errno]); | 532 | sys_errlist[errno]); |
530 | strncpy(errstr,tmpstr,TMPSTRSIZE-2); | 533 | strncpy(errstr,tmpstr,TMPSTRSIZE-2); |
@@ -533,20 +536,22 @@ main (int argc, char **argv) | |||
533 | writecf (FS_ERR,tmpstr); | 536 | writecf (FS_ERR,tmpstr); |
534 | /* exit condition */ | 537 | /* exit condition */ |
535 | status = 0; | 538 | status = 0; |
536 | } | 539 | } else { |
537 | else | ||
538 | { | ||
539 | /* add stdin & server to masterdfs */ | 540 | /* add stdin & server to masterdfs */ |
540 | FD_ZERO (&masterfds); | 541 | FD_ZERO (&masterfds); |
541 | FD_SET (0, &masterfds); | 542 | FD_SET (0, &masterfds); |
542 | FD_SET (serverfd, &masterfds); | 543 | FD_SET (serverfd, &masterfds); |
543 | } | 544 | } |
544 | 545 | ||
545 | while (status) | 546 | while (status) |
546 | eventloop (); | 547 | eventloop (); |
548 | |||
549 | /* sanely close connection to server */ | ||
550 | vcdisconnect (); | ||
547 | 551 | ||
548 | /* sanely close connection to server */ | 552 | if( !ownquit && getintoption( CF_AUTORECONN ) ) |
549 | vcdisconnect (); | 553 | status = 1; |
554 | } | ||
550 | 555 | ||
551 | /* call cleanup-hook without signal */ | 556 | /* call cleanup-hook without signal */ |
552 | cleanup (0); | 557 | cleanup (0); |
diff --git a/vchat-commands.c b/vchat-commands.c index 5dc7b4f..8a4f475 100755 --- a/vchat-commands.c +++ b/vchat-commands.c | |||
@@ -27,6 +27,9 @@ | |||
27 | /* version of this module */ | 27 | /* version of this module */ |
28 | char *vchat_cm_version = "$Id$"; | 28 | char *vchat_cm_version = "$Id$"; |
29 | 29 | ||
30 | /* from vchat-client.c */ | ||
31 | extern int ownquit; | ||
32 | |||
30 | /* our "/command " table */ | 33 | /* our "/command " table */ |
31 | enum { | 34 | enum { |
32 | COMMAND_VERSION, | 35 | COMMAND_VERSION, |
@@ -228,6 +231,10 @@ handleline (char *line) | |||
228 | case 'O': | 231 | case 'O': |
229 | dothink( line + 2, line[1] ); | 232 | dothink( line + 2, line[1] ); |
230 | break; | 233 | break; |
234 | case 'x': | ||
235 | /* inform vchat-client, that the following connection | ||
236 | drop was intentional */ | ||
237 | ownquit = 1; /* fallthrough intended */ | ||
231 | default: | 238 | default: |
232 | /* generic server command, send to server, show to user */ | 239 | /* generic server command, send to server, show to user */ |
233 | snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_COMMAND), line); | 240 | snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_COMMAND), line); |
@@ -375,6 +382,10 @@ command_quit(char *tail) | |||
375 | 382 | ||
376 | /* show action in channel window */ | 383 | /* show action in channel window */ |
377 | writechan (tmpstr); | 384 | writechan (tmpstr); |
385 | |||
386 | /* Inform vchat-client, that the closing connection | ||
387 | following is intended */ | ||
388 | ownquit = 1; | ||
378 | } | 389 | } |
379 | 390 | ||
380 | /* print out version */ | 391 | /* print out version */ |
diff --git a/vchat-config.h b/vchat-config.h index eb0afc1..34866b1 100755 --- a/vchat-config.h +++ b/vchat-config.h | |||
@@ -55,6 +55,7 @@ static volatile configoption configoptions[] = { | |||
55 | {CF_SCROLLBPRIVT,CO_INT, "privscrollt",(char *) 0, (char *)-1, { NULL } }, | 55 | {CF_SCROLLBPRIVT,CO_INT, "privscrollt",(char *) 0, (char *)-1, { NULL } }, |
56 | {CF_SCROLLBACKT, CO_INT, "scrolltime", (char *) 86400, (char *)-1, { NULL } }, | 56 | {CF_SCROLLBACKT, CO_INT, "scrolltime", (char *) 86400, (char *)-1, { NULL } }, |
57 | {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } }, | 57 | {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } }, |
58 | {CF_AUTORECONN, CO_INT, "autoreconn", (char *) 0, (char *)-1, { NULL } }, | ||
58 | {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } }, | 59 | {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } }, |
59 | }; | 60 | }; |
60 | 61 | ||
diff --git a/vchat-protocol.c b/vchat-protocol.c index 274e856..af06c6a 100755 --- a/vchat-protocol.c +++ b/vchat-protocol.c | |||
@@ -243,6 +243,7 @@ serverlogin (char *message) | |||
243 | networkoutput(".e utf8"); | 243 | networkoutput(".e utf8"); |
244 | #endif | 244 | #endif |
245 | } | 245 | } |
246 | |||
246 | /* parse and handle an idle message | 247 | /* parse and handle an idle message |
247 | * format: 305 | 248 | * format: 305 |
248 | * vars: %s message */ | 249 | * vars: %s message */ |
@@ -39,7 +39,7 @@ typedef enum { CF_NIL, CF_NICK, CF_FROM, CF_SERVERHOST, CF_SERVERPORT, | |||
39 | CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGINSCRIPT, | 39 | CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGINSCRIPT, |
40 | CF_USESSL, CF_IGNSSL, CF_USECERT, CF_PRIVHEIGHT, CF_PRIVCOLLAPS, CF_HSCROLL, CF_CHANNEL, CF_USETIME, | 40 | CF_USESSL, CF_IGNSSL, CF_USECERT, CF_PRIVHEIGHT, CF_PRIVCOLLAPS, CF_HSCROLL, CF_CHANNEL, CF_USETIME, |
41 | CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT, | 41 | CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT, |
42 | CF_ENCODING, CF_BELLPRIV } confopt; | 42 | CF_ENCODING, CF_BELLPRIV, CF_AUTORECONN } confopt; |
43 | 43 | ||
44 | /* format strings */ | 44 | /* format strings */ |
45 | typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR, | 45 | typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR, |