annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/tools/toolutil/uoptions.h @ 11038:20a8447c71c6

8207159: Update ICU to version 62.1 Reviewed-by: mbilla, kcr, ghb
author arajkumar
date Fri, 24 Aug 2018 15:06:40 +0530
parents fee4ef5c87df
children
rev   line source
arajkumar@11038 1 // © 2016 and later: Unicode, Inc. and others.
arajkumar@11038 2 // License & terms of use: http://www.unicode.org/copyright.html
ghb@10550 3 /*
ghb@10550 4 *******************************************************************************
ghb@10550 5 *
ghb@10550 6 * Copyright (C) 2000-2011, International Business Machines
ghb@10550 7 * Corporation and others. All Rights Reserved.
ghb@10550 8 *
ghb@10550 9 *******************************************************************************
ghb@10550 10 * file name: uoptions.h
arajkumar@11038 11 * encoding: UTF-8
ghb@10550 12 * tab size: 8 (not used)
ghb@10550 13 * indentation:4
ghb@10550 14 *
ghb@10550 15 * created on: 2000apr17
ghb@10550 16 * created by: Markus W. Scherer
ghb@10550 17 *
ghb@10550 18 * This file provides a command line argument parser.
ghb@10550 19 */
ghb@10550 20
ghb@10550 21 #ifndef __UOPTIONS_H__
ghb@10550 22 #define __UOPTIONS_H__
ghb@10550 23
ghb@10550 24 #include "unicode/utypes.h"
ghb@10550 25
ghb@10550 26 /* This should usually be called before calling u_parseArgs */
ghb@10550 27 /*#if U_PLATFORM == U_PF_OS390 && (U_CHARSET_FAMILY == U_ASCII_FAMILY)*/
ghb@10550 28 /* translate args from EBCDIC to ASCII */
ghb@10550 29 /*# define U_MAIN_INIT_ARGS(argc, argv) __argvtoascii_a(argc, argv)*/
ghb@10550 30 /*#elif defined(XP_MAC_CONSOLE)*/
ghb@10550 31 #if defined(XP_MAC_CONSOLE)
ghb@10550 32 # include <console.h>
ghb@10550 33 /* Get the arguments from the GUI, since old Macs don't have a console Window. */
ghb@10550 34 # define U_MAIN_INIT_ARGS(argc, argv) argc = ccommand((char***)&argv)
ghb@10550 35 #else
ghb@10550 36 /* Normally we do nothing. */
ghb@10550 37 # define U_MAIN_INIT_ARGS(argc, argv)
ghb@10550 38 #endif
ghb@10550 39
ghb@10550 40
ghb@10550 41
ghb@10550 42 /* forward declarations for the function declaration */
ghb@10550 43 struct UOption;
ghb@10550 44 typedef struct UOption UOption;
ghb@10550 45
ghb@10550 46 /* function to be called for a command line option */
ghb@10550 47 typedef int UOptionFn(void *context, UOption *option);
ghb@10550 48
ghb@10550 49 /* values of UOption.hasArg */
ghb@10550 50 enum { UOPT_NO_ARG, UOPT_REQUIRES_ARG, UOPT_OPTIONAL_ARG };
ghb@10550 51
ghb@10550 52 /* structure describing a command line option */
ghb@10550 53 struct UOption {
ghb@10550 54 const char *longName; /* "foo" for --foo */
ghb@10550 55 const char *value; /* output placeholder, will point to the argument string, if any */
ghb@10550 56 UOptionFn *optionFn; /* function to be called when this option occurs */
ghb@10550 57 void *context; /* parameter for the function */
ghb@10550 58 char shortName; /* 'f' for -f */
ghb@10550 59 char hasArg; /* enum value: option takes no/requires/may have argument */
ghb@10550 60 char doesOccur; /* boolean for "this one occured" */
ghb@10550 61 };
ghb@10550 62
ghb@10550 63 /* macro for an entry in a declaration of UOption[] */
ghb@10550 64 #define UOPTION_DEF(longName, shortName, hasArg) \
ghb@10550 65 { longName, NULL, NULL, NULL, shortName, hasArg, 0 }
ghb@10550 66
ghb@10550 67 /* ICU Tools option definitions */
ghb@10550 68 #define UOPTION_HELP_H UOPTION_DEF("help", 'h', UOPT_NO_ARG)
ghb@10550 69 #define UOPTION_HELP_QUESTION_MARK UOPTION_DEF("help", '?', UOPT_NO_ARG)
ghb@10550 70 #define UOPTION_VERBOSE UOPTION_DEF("verbose", 'v', UOPT_NO_ARG)
ghb@10550 71 #define UOPTION_QUIET UOPTION_DEF("quiet", 'q', UOPT_NO_ARG)
ghb@10550 72 #define UOPTION_VERSION UOPTION_DEF("version", 'V', UOPT_NO_ARG)
ghb@10550 73 #define UOPTION_COPYRIGHT UOPTION_DEF("copyright", 'c', UOPT_NO_ARG)
ghb@10550 74
ghb@10550 75 #define UOPTION_DESTDIR UOPTION_DEF("destdir", 'd', UOPT_REQUIRES_ARG)
ghb@10550 76 #define UOPTION_SOURCEDIR UOPTION_DEF("sourcedir", 's', UOPT_REQUIRES_ARG)
ghb@10550 77 #define UOPTION_ENCODING UOPTION_DEF("encoding", 'e', UOPT_REQUIRES_ARG)
ghb@10550 78 #define UOPTION_ICUDATADIR UOPTION_DEF("icudatadir", 'i', UOPT_REQUIRES_ARG)
ghb@10550 79 #define UOPTION_WRITE_JAVA UOPTION_DEF("write-java", 'j', UOPT_OPTIONAL_ARG)
ghb@10550 80 #define UOPTION_PACKAGE_NAME UOPTION_DEF("package-name", 'p', UOPT_REQUIRES_ARG)
ghb@10550 81 #define UOPTION_BUNDLE_NAME UOPTION_DEF("bundle-name", 'b', UOPT_REQUIRES_ARG)
ghb@10550 82
ghb@10550 83 /**
ghb@10550 84 * C Command line argument parser.
ghb@10550 85 *
ghb@10550 86 * This function takes the argv[argc] command line and a description of
ghb@10550 87 * the program's options in form of an array of UOption structures.
ghb@10550 88 * Each UOption defines a long and a short name (a string and a character)
ghb@10550 89 * for options like "--foo" and "-f".
ghb@10550 90 *
ghb@10550 91 * Each option is marked with whether it does not take an argument,
ghb@10550 92 * requires one, or optionally takes one. The argument may follow in
ghb@10550 93 * the same argv[] entry for short options, or it may always follow
ghb@10550 94 * in the next argv[] entry.
ghb@10550 95 *
ghb@10550 96 * An argument is in the next argv[] entry for both long and short name
ghb@10550 97 * options, except it is taken from directly behind the short name in
ghb@10550 98 * its own argv[] entry if there are characters following the option letter.
ghb@10550 99 * An argument in its own argv[] entry must not begin with a '-'
ghb@10550 100 * unless it is only the '-' itself. There is no restriction of the
ghb@10550 101 * argument format if it is part of the short name options's argv[] entry.
ghb@10550 102 *
ghb@10550 103 * The argument is stored in the value field of the corresponding
ghb@10550 104 * UOption entry, and the doesOccur field is set to 1 if the option
ghb@10550 105 * is found at all.
ghb@10550 106 *
ghb@10550 107 * Short name options without arguments can be collapsed into a single
ghb@10550 108 * argv[] entry. After an option letter takes an argument, following
ghb@10550 109 * letters will be taken as its argument.
ghb@10550 110 *
ghb@10550 111 * If the same option is found several times, then the last
ghb@10550 112 * argument value will be stored in the value field.
ghb@10550 113 *
ghb@10550 114 * For each option, a function can be called. This could be used
ghb@10550 115 * for options that occur multiple times and all arguments are to
ghb@10550 116 * be collected.
ghb@10550 117 *
ghb@10550 118 * All options are removed from the argv[] array itself. If the parser
ghb@10550 119 * is successful, then it returns the number of remaining non-option
ghb@10550 120 * strings (including argv[0]).
ghb@10550 121 * argv[0], the program name, is never read or modified.
ghb@10550 122 *
ghb@10550 123 * An option "--" ends option processing; everything after this
ghb@10550 124 * remains in the argv[] array.
ghb@10550 125 *
ghb@10550 126 * An option string "-" alone is treated as a non-option.
ghb@10550 127 *
ghb@10550 128 * If an option is not recognized or an argument missing, then
ghb@10550 129 * the parser returns with the negative index of the argv[] entry
ghb@10550 130 * where the error was detected.
ghb@10550 131 *
ghb@10550 132 * The OS/400 compiler requires that argv either be "char* argv[]",
ghb@10550 133 * or "const char* const argv[]", and it will not accept,
ghb@10550 134 * "const char* argv[]" as a definition for main().
ghb@10550 135 *
ghb@10550 136 * @param argv This parameter is modified
ghb@10550 137 * @param options This parameter is modified
ghb@10550 138 */
ghb@10550 139 U_CAPI int U_EXPORT2
ghb@10550 140 u_parseArgs(int argc, char* argv[],
ghb@10550 141 int optionCount, UOption options[]);
ghb@10550 142
ghb@10550 143 #endif