sic

simple irc client
git clone git://git.suckless.org/sic
Log | Files | Refs | README | LICENSE

commit 516c1cafaf1bf0165117caf47e987071c126d51c
parent 3a24553892e2c680ebbf9ef2c4883691590a5fe5
Author: Anselm R. Garbe <arg@10kloc.org>
Date:   Mon,  9 Oct 2006 07:26:24 +0200

fixed arg processing
Diffstat:
sic.c | 31++++++++++++-------------------
1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/sic.c b/sic.c @@ -231,32 +231,25 @@ main(int argc, char *argv[]) { fd_set rd; nick = fullname = getenv("USER"); - for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) - switch (argv[i][1]) { - default: - fputs("usage: sic [-s server] [-p port] [-n nick]" - " [-k keyword] [-f fullname] [-v]\n", stderr); - exit(EXIT_FAILURE); - break; - case 's': + for(i = 1; i < argc; i++) + if(!strncmp(argv[i], "-s", 3)) server = argv[++i]; - break; - case 'p': + else if(!strncmp(argv[i], "-p", 3)) port = (unsigned short)atoi(argv[++i]); - break; - case 'n': + else if(!strncmp(argv[i], "-n", 3)) nick = argv[++i]; - break; - case 'k': + else if(!strncmp(argv[i], "-k", 3)) password = argv[++i]; - break; - case 'f': + else if(!strncmp(argv[i], "-f", 3)) fullname = argv[++i]; - break; - case 'v': + else if(!strncmp(argv[i], "-v", 3)) { fputs("sic-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); exit(EXIT_SUCCESS); - break; + } + else { + fputs("usage: sic [-s server] [-p port] [-n nick]" + " [-k keyword] [-f fullname] [-v]\n", stderr); + exit(EXIT_FAILURE); } /* init */