Added sanity checking to kernel vnsprintf
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / commandline.c
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  */
5 #include "common.h"
6 #include <string.h>
7
8 // === PROTOTYPES ===
9 void    ShowUsage(char *ProgName);
10 void    ShowHelp(char *ProgName);
11
12 // === CODE ===
13 void ParseCommandline(int argc, char *argv[])
14 {
15          int    i;
16         char    *arg;
17         
18         for( i = 1; i < argc; i++ )
19         {
20                 arg = argv[i];
21                 if(arg[0] == '-')
22                 {
23                         if( arg[1] == '-' )
24                         {
25                                 if( strcmp(&arg[2], "help") == 0 ) {
26                                         ShowHelp(argv[0]);
27                                         exit(EXIT_SUCCESS);
28                                 }
29                                 else {
30                                         ShowUsage(argv[0]);
31                                         exit(EXIT_FAILURE);
32                                 }
33                         }
34                         else
35                         {
36                                 while( *++arg )
37                                 {
38                                         switch(*arg)
39                                         {
40                                         case 'h':
41                                         case '?':
42                                                 ShowHelp(argv[0]);
43                                                 exit(EXIT_SUCCESS);
44                                                 break;
45                                         }
46                                 }
47                         }
48                 }
49         }
50 }
51
52 void ShowUsage(char *ProgName)
53 {
54         fprintf(stderr, "Usage: %s [-h|--help]\n", ProgName);
55 }
56
57 void ShowHelp(char *ProgName)
58 {
59         ShowUsage(ProgName);
60         fprintf(stderr, "\n");
61         fprintf(stderr, "\t--help\tShow this message\n");
62 }

UCC git Repository :: git.ucc.asn.au