Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / nsprpub / lib / tests / getopt.c
blob52b971989a32678c26d61c3cb05d492e17ff7638
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
5 #include "nspr.h"
6 #include "plgetopt.h"
10 static const PLLongOpt optArray[] = {
11 { "longa", 'a' , PR_TRUE },
12 { "longb", 'b' , PR_TRUE },
13 { "longc", 'c' , PR_FALSE },
14 { "longd", 'd' | 0x100, PR_TRUE },
15 { "longe", 'e' | 0x100, PR_FALSE },
16 { NULL, }
19 int
20 main(int argc, char **argv)
22 PLOptState *opt;
23 PLOptStatus ostat;
25 opt = PL_CreateLongOptState(argc, argv, "a:b:c", optArray);
27 while (PL_OPT_OK == (ostat = PL_GetNextOpt(opt))) {
28 if (opt->option == 0 && opt->longOptIndex < 0)
29 printf("Positional parameter: \"%s\"\n", opt->value);
30 else
31 printf("%s option: %x (\'%c\', index %d), argument: \"%s\"\n",
32 (ostat == PL_OPT_BAD) ? "BAD" : "GOOD",
33 opt->longOption, opt->option ? opt->option : ' ',
34 opt->longOptIndex, opt->value);
37 printf("last result was %s\n", (ostat == PL_OPT_BAD) ? "BAD" : "EOL");
38 PL_DestroyOptState(opt);
39 return 0;