michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "nspr.h" michael@0: #include "plgetopt.h" michael@0: michael@0: michael@0: michael@0: static const PLLongOpt optArray[] = { michael@0: { "longa", 'a' , PR_TRUE }, michael@0: { "longb", 'b' , PR_TRUE }, michael@0: { "longc", 'c' , PR_FALSE }, michael@0: { "longd", 'd' | 0x100, PR_TRUE }, michael@0: { "longe", 'e' | 0x100, PR_FALSE }, michael@0: { NULL, } michael@0: }; michael@0: michael@0: int michael@0: main(int argc, char **argv) michael@0: { michael@0: PLOptState *opt; michael@0: PLOptStatus ostat; michael@0: michael@0: opt = PL_CreateLongOptState(argc, argv, "a:b:c", optArray); michael@0: michael@0: while (PL_OPT_OK == (ostat = PL_GetNextOpt(opt))) { michael@0: if (opt->option == 0 && opt->longOptIndex < 0) michael@0: printf("Positional parameter: \"%s\"\n", opt->value); michael@0: else michael@0: printf("%s option: %x (\'%c\', index %d), argument: \"%s\"\n", michael@0: (ostat == PL_OPT_BAD) ? "BAD" : "GOOD", michael@0: opt->longOption, opt->option ? opt->option : ' ', michael@0: opt->longOptIndex, opt->value); michael@0: michael@0: } michael@0: printf("last result was %s\n", (ostat == PL_OPT_BAD) ? "BAD" : "EOL"); michael@0: PL_DestroyOptState(opt); michael@0: return 0; michael@0: }