cli.c (672B)
1 /* 2 * cli.c -- cli 3 */ 4 5 #include <stdio.h> 6 #include <string.h> 7 #include <unistd.h> /* for getopt() */ 8 9 #include "cli.h" 10 #include "state.h" 11 12 const char* opts = "hvc:"; 13 14 void cli(int argc, char** argv) 15 { 16 int c; 17 18 while ((c = getopt(argc, argv, opts)) != -1) 19 { 20 switch (c) 21 { 22 case 'h': 23 printf("%s: usage: %s [-h] [-v] [-c file]\n", argv[0], argv[0]); 24 puts("See the s-httpd(8) manual page for more."); 25 break; 26 case 'v': 27 printf("s-httpd version %s\n", VERSION); 28 break; 29 case 'c': 30 strncpy(conffile, optarg, sizeof(conffile) - 1); 31 conffile[sizeof(conffile) - 1] = '\0'; /* null-terminate */ 32 33 break; 34 /* getopt() handles the rest :) */ 35 } 36 } 37 } 38