Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include <stdio.h>
6 #include <string.h>
7 #include <stdlib.h>
9 #include "nspr.h"
10 #include "plgetopt.h"
14 static const PLLongOpt optArray[] = {
15 { "longa", 'a' , PR_TRUE },
16 { "longb", 'b' , PR_TRUE },
17 { "longc", 'c' , PR_FALSE },
18 { "longd", 'd' | 0x100, PR_TRUE },
19 { "longe", 'e' | 0x100, PR_FALSE },
20 { NULL, }
21 };
23 int
24 main(int argc, char **argv)
25 {
26 PLOptState *opt;
27 PLOptStatus ostat;
29 opt = PL_CreateLongOptState(argc, argv, "a:b:c", optArray);
31 while (PL_OPT_OK == (ostat = PL_GetNextOpt(opt))) {
32 if (opt->option == 0 && opt->longOptIndex < 0)
33 printf("Positional parameter: \"%s\"\n", opt->value);
34 else
35 printf("%s option: %x (\'%c\', index %d), argument: \"%s\"\n",
36 (ostat == PL_OPT_BAD) ? "BAD" : "GOOD",
37 opt->longOption, opt->option ? opt->option : ' ',
38 opt->longOptIndex, opt->value);
40 }
41 printf("last result was %s\n", (ostat == PL_OPT_BAD) ? "BAD" : "EOL");
42 PL_DestroyOptState(opt);
43 return 0;
44 }