summaryrefslogtreecommitdiff
path: root/vchat-client.c
diff options
context:
space:
mode:
authorerdgeist <>2007-06-28 17:23:18 +0000
committererdgeist <>2007-06-28 17:23:18 +0000
commit115003bd86a50e6d84fca063ab72451e317e787a (patch)
tree492860e645ebae00dbd2269e4554c2506bd074fa /vchat-client.c
parent3c11bea99886b006ca499e1be6a3a17d225cedc7 (diff)
Auto reconnect
Diffstat (limited to 'vchat-client.c')
-rwxr-xr-xvchat-client.c27
1 files changed, 16 insertions, 11 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 */
38unsigned int loggedin = 0; 38unsigned int loggedin = 0;
39/* we run as long as this is true */ 39/* we run as long as this is true */
40unsigned int status = 1; 40int status = 1;
41/* we set this, we WANT to quit */
42int ownquit = 0;
43
41/* error string to show after exit */ 44/* error string to show after exit */
42char errstr[ERRSTRSIZE] = "\0"; 45char 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);