From 98ab396df44c077fb2b584df4ba38fb7890e7425 Mon Sep 17 00:00:00 2001 From: nishi Date: Fri, 26 Jan 2024 02:22:11 +0000 Subject: [PATCH] w3b update git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@74 d27a3e52-49c5-7645-884c-6793ebffc270 --- Example/W3B/w3b.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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:; } -- 2.43.0