]> Nishi Git Mirror - libw3.git/commitdiff
w3b update
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Fri, 26 Jan 2024 02:22:11 +0000 (02:22 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Fri, 26 Jan 2024 02:22:11 +0000 (02:22 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@74 d27a3e52-49c5-7645-884c-6793ebffc270

Example/W3B/w3b.c

index 7ab55b1056faf501153c70658e30f469bb456e2c..d42f4542957c943be517c0411cea1e64bbf3226d 100644 (file)
@@ -5,16 +5,52 @@
  */
 
 #include <W3Core.h>
+#include <W3Util.h> /* It has some useful functions, you know */
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
 
 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:;
 }