From: nishi Date: Fri, 26 Jan 2024 02:22:11 +0000 (+0000) Subject: w3b update X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=98ab396df44c077fb2b584df4ba38fb7890e7425;p=libw3.git w3b update git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@74 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Example/W3B/w3b.c b/Example/W3B/w3b.c index 7ab55b1..d42f454 100644 --- a/Example/W3B/w3b.c +++ b/Example/W3B/w3b.c @@ -5,16 +5,52 @@ */ #include +#include /* It has some useful functions, you know */ #include #include +#include +#include int main(int argc, char** argv) { int i; + char* url = NULL; for(i = 1; i < argc; i++){ if(strcmp(argv[i], "--version") == 0){ printf("LibW3 %s\n", LIBW3_VERSION); return 0; + }else if(argv[i][0] == '-'){ + fprintf(stderr, "%s: unknown option: %s\n", argv[0], argv[i]); + return 1; + }else{ + if(url != NULL){ + free(url); + fprintf(stderr, "%s: garbage argument found\n", argv[0]); + return 1; + } + url = __W3_Strdup(argv[i]); } } + int phase = url == NULL ? 0 : 1; + char c = 0; + while(true){ /* Loop */ + if(phase == 0){ + if(c != '\n' && c != '\r'){ + printf("(O)pen, (Q)uit? "); + fflush(stdout); + } + scanf("%c", &c); + switch(tolower(c)){ + case 'q': + goto exitnow; + case '\n': + case '\r': + break; + default: + printf("What do you mean?\n"); + break; + } + } + } +exitnow:; }