summaryrefslogtreecommitdiff
path: root/vchat-client.c
diff options
context:
space:
mode:
authorerdgeist <>2003-05-25 15:06:30 +0000
committererdgeist <>2003-05-25 15:06:30 +0000
commit18de21a2765f1fa33ef313fb20f5baad510cd86d (patch)
treeb351c27a6c97712540db0832dc29aea64a8022ee /vchat-client.c
parenta66217bdd998bee8cce8670b149f1bf08c1b2bdc (diff)
encoding, time, logging, params
Diffstat (limited to 'vchat-client.c')
-rwxr-xr-xvchat-client.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/vchat-client.c b/vchat-client.c
index 039301e..2fc1ea9 100755
--- a/vchat-client.c
+++ b/vchat-client.c
@@ -386,15 +386,24 @@ cleanup (int signal)
386 exit (0); 386 exit (0);
387} 387}
388 388
389static int oldseconds = 0;
390
389void calleverysecond( void ) { 391void calleverysecond( void ) {
390 /* timetriggered execution, don't rely on being called every 1000us */ 392 /* timetriggered execution, don't rely on being called every 1000us */
391 /* rather see it as a chance for being called 9 times in 10 seconds */ 393 /* rather see it as a chance for being called 9 times in 10 seconds */
392 /* so check time() */ 394 /* so check time() */
395 time_t now = time( NULL );
396 struct tm *mytime = localtime( &now );
397 if( mytime->tm_sec < oldseconds ) {
398 consoleline( NULL );
399 }
400 oldseconds = mytime->tm_sec;
393 401
394 if(quitrequest) 402 if(quitrequest)
395 quitrequest--; 403 quitrequest--;
396 if(outputcountdown && !--outputcountdown) 404 if(outputcountdown && !--outputcountdown)
397 hideout( ); 405 hideout( );
406
398} 407}
399 408
400/* this function is called in the master loop */ 409/* this function is called in the master loop */
@@ -437,19 +446,23 @@ eventloop (void)
437} 446}
438 447
439void usage(unsigned char *name) { 448void usage(unsigned char *name) {
440 printf ("usage: %s [-C config-file] [-l] [-z] [-s host] [-p port] [-c channel] [-n nickname]\n",name); 449 printf ("usage: %s [-C config-file] [-F formats] [-l] [-z] [-s host] [-p port] [-c channel] [-n nickname] [-k] [-K] [-L logfile]\n",name);
441 puts (" -C load a second config-file, overriding the first one\n"); 450 puts (" -C load a second config-file, overriding the first one");
442 puts (" -l local connect (no SSL + connects localhost:2323)\n"); 451 puts (" -F load format strings (skins) from this file");
443 puts (" -z don't use certificate files\n"); 452 puts (" -l local connect (no SSL + connects localhost:2323)");
453 puts (" -z don't use certificate files");
444 printf (" -s set server (default \"%s\")\n",getstroption(CF_SERVERHOST)); 454 printf (" -s set server (default \"%s\")\n",getstroption(CF_SERVERHOST));
445 printf (" -p set port (default %d)\n",getintoption(CF_SERVERPORT)); 455 printf (" -p set port (default %d)\n",getintoption(CF_SERVERPORT));
446 printf (" -c set channel (default %d)\n",getintoption(CF_CHANNEL)); 456 printf (" -c set channel (default %d)\n",getintoption(CF_CHANNEL));
447 if (nick) 457 if (nick)
448 printf(" -n set nickname (default \"%s\")\n",nick); 458 printf(" -n set nickname (default \"%s\")\n",nick);
449 else 459 else
450 puts (" -n set nickname\n"); 460 puts (" -n set nickname");
451 printf (" -f set from (default \"%s\")\n",getstroption(CF_FROM)); 461 printf (" -f set from (default \"%s\")\n",getstroption(CF_FROM));
452 puts (" -h gives this help\n"); 462 puts (" -k keep autolog");
463 puts (" -K don't keep autolog");
464 printf (" -L use this file as logfile (default \"%s\")\n",getstroption(CF_LOGFILE));
465 puts (" -h gives this help");
453} 466}
454 467
455/* main - d'oh */ 468/* main - d'oh */
@@ -461,12 +474,10 @@ main (int argc, char **argv)
461 474
462 loadconfig (GLOBAL_CONFIG_FILE); 475 loadconfig (GLOBAL_CONFIG_FILE);
463 loadconfig (getstroption (CF_CONFIGFILE)); 476 loadconfig (getstroption (CF_CONFIGFILE));
464 loadformats(GLOBAL_FORMAT_FILE);
465 loadformats(getstroption (CF_FORMFILE));
466 477
467 /* parse commandline */ 478 /* parse commandline */
468 while (cmdsunparsed) { 479 while (cmdsunparsed) {
469 pchar = getopt(argc,argv,"C:lzs:p:c:n:f:h"); 480 pchar = getopt(argc,argv,"C:F:lzs:p:c:n:f:kKL:h");
470#ifdef DEBUG 481#ifdef DEBUG
471 fprintf(stderr,"parse commandline: %d ('%c'): %s\n",pchar,pchar,optarg); 482 fprintf(stderr,"parse commandline: %d ('%c'): %s\n",pchar,pchar,optarg);
472#endif 483#endif
@@ -474,6 +485,7 @@ main (int argc, char **argv)
474 switch (pchar) { 485 switch (pchar) {
475 case -1 : cmdsunparsed = 0; break; 486 case -1 : cmdsunparsed = 0; break;
476 case 'C': loadconfig(optarg); break; 487 case 'C': loadconfig(optarg); break;
488 case 'F': setstroption(CF_FORMFILE,optarg); break;
477 case 'l': setintoption(CF_USESSL,0); break; 489 case 'l': setintoption(CF_USESSL,0); break;
478 case 'z': setintoption(CF_USECERT,0); break; 490 case 'z': setintoption(CF_USECERT,0); break;
479 case 's': setstroption(CF_SERVERHOST,optarg); break; 491 case 's': setstroption(CF_SERVERHOST,optarg); break;
@@ -481,6 +493,9 @@ main (int argc, char **argv)
481 case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break; 493 case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break;
482 case 'n': setstroption(CF_NICK,optarg); break; 494 case 'n': setstroption(CF_NICK,optarg); break;
483 case 'f': setstroption(CF_FROM,optarg); break; 495 case 'f': setstroption(CF_FROM,optarg); break;
496 case 'k': setintoption(CF_KEEPLOG,1); break;
497 case 'K': setintoption(CF_KEEPLOG,0); break;
498 case 'L': setstroption(CF_LOGFILE,optarg); break;
484 case 'h': usage(argv[0]); exit(0); break; 499 case 'h': usage(argv[0]); exit(0); break;
485 default : usage(argv[0]); exit(1); 500 default : usage(argv[0]); exit(1);
486 } 501 }
@@ -488,6 +503,9 @@ main (int argc, char **argv)
488 503
489 if (optind < argc) { usage(argv[0]); exit(1); } 504 if (optind < argc) { usage(argv[0]); exit(1); }
490 505
506 loadformats(GLOBAL_FORMAT_FILE);
507 loadformats(getstroption (CF_FORMFILE));
508
491 if (!getintoption(CF_USESSL)) { 509 if (!getintoption(CF_USESSL)) {
492 setstroption(CF_SERVERHOST,"localhost"); 510 setstroption(CF_SERVERHOST,"localhost");
493 setintoption(CF_SERVERPORT,2323); 511 setintoption(CF_SERVERPORT,2323);