stdcpp/tsrc/Stdcpp_test/stdcxx/include/cmdopt.h
changeset 31 ce057bb09d0b
parent 0 e4d67989cc36
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /***************************************************************************
       
     2  *
       
     3  * cmdopt.h - declarations of helper functions for the processing
       
     4  *            of command line options
       
     5  *
       
     6  * $Id: cmdopt.h 278860 2005-09-05 21:47:23Z sebor $
       
     7  *
       
     8  ************************************************************************
       
     9  *
       
    10  * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
       
    11  * Software division. Licensed under the Apache License, Version 2.0 (the
       
    12  * "License");  you may  not use this file except  in compliance with the
       
    13  * License.    You    may   obtain   a   copy   of    the   License    at
       
    14  * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
       
    15  * applicable law  or agreed to  in writing,  software  distributed under
       
    16  * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
       
    17  * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
       
    18  * for the specific language governing permissions  and limitations under
       
    19  * the License.
       
    20  * 
       
    21  **************************************************************************/
       
    22 
       
    23 #ifndef RW_CMDOPT_H_INCLUDED
       
    24 #define RW_CMDOPT_H_INCLUDED
       
    25 
       
    26 
       
    27 #include <testdefs.h>   // for test config macros
       
    28 
       
    29 
       
    30 /**
       
    31  * Appends a set of command line options and their handlers to the global
       
    32  * list of command line option handlers for the current process.
       
    33  *
       
    34  * @param optspec  A string of command line option specifiers describing
       
    35  *        the names and parameters of the command line options and their
       
    36  *        handlers. The string has the following syntax:
       
    37  *
       
    38  *        <optspec> ::= <opt> [ ':' | '=' | '#' ]
       
    39  *                            [ @N | @* | '!' ]
       
    40  *                            [ <opts> ]
       
    41  *        <opt>     ::= <sopt> [ '|' <lopt>]
       
    42  *                  ::= '|' <lopt>
       
    43  *        <sopt>    ::= char
       
    44  *        <lopt>    ::= '-' char char*
       
    45  *        <char>    ::= 'A' - 'Z', 'a'-'z', '0' - '9', '_'
       
    46  *
       
    47  *        Each command line option may have a short name, a long name,
       
    48  *        or both. When referenced (either on the command line or in
       
    49  *        the environment), the name of command line option is
       
    50  *        introduced by a hyphen ('-').
       
    51  *
       
    52  *        A short option name (<sopt>) consits of a single alphanumeric
       
    53  *        character or an underscore ('_').
       
    54  *
       
    55  *        A long name (<lopt>) starts with a hyphen ('-') followed by
       
    56  *        one or more aphanumeric characters or underscores.
       
    57  *
       
    58  *        The name of the command line option is followd by one or more
       
    59  *        special characters with the following meaning:
       
    60  *
       
    61  *        ':'   the option takes an optional argument
       
    62  *        '='   the option takes a required argument that must immediately
       
    63  *              follow the equals sign
       
    64  *        '#'   the handler for this option is not a function but rather
       
    65  *              a pointer to an signed integer that rw_runopts() sets to
       
    66  *              a non-zero value if the option appears on the command line
       
    67  *        @N    the option handler will be invoked for the first N
       
    68  *              occurrences of the option name on the command line
       
    69  *        @*    the option handler will be invoked for every occurrence
       
    70  *              of the option name on the command line
       
    71  *        !     the option handler will be invoked only if the option name
       
    72  *              does not appear on the command line
       
    73  *
       
    74  * @param ...  A list of zero or more command line option handlers whose
       
    75  *        type is either int (*)(int, char**) or int*, the latter
       
    76  *        corresponding to options denoted with the '#' special character.
       
    77  *
       
    78  * @return  On success, returns the number of command line options
       
    79  *          currently defined for the process, negative value on error.
       
    80  */
       
    81 _TEST_EXPORT int
       
    82 rw_setopts (const char *optspec, ...);
       
    83 
       
    84 
       
    85 /**
       
    86  * Processes the set of command line options and arguments specified by
       
    87  * the function arguments (usually the same arguments as those passed to
       
    88  * main()).
       
    89  *
       
    90  * @param argc  The number of non-zero elements of the argv vector.
       
    91  * @param argv  An array of pointers to command line options and arguments
       
    92  *        whose the last element, argv [argc], has the value 0.
       
    93  *
       
    94  * @return  Returns the status of last evaluated command line option handler.
       
    95  */
       
    96 _TEST_EXPORT int
       
    97 rw_runopts (int argc, char *argv[]);
       
    98 
       
    99 
       
   100 /**
       
   101  * Processes the set of command line options and arguments specified by
       
   102  * the function argument (usually the value of an environment variable).
       
   103  *
       
   104  * @param argvstr  A character string of command line options and arguments
       
   105  *        separated by one or more spaces.
       
   106  *
       
   107  * @return  Returns the status of last evaluated command line option handler.
       
   108  */
       
   109 _TEST_EXPORT int
       
   110 rw_runopts (const char *argvstr);
       
   111 
       
   112 
       
   113 /**
       
   114  * Determines whether a feature is enabled.
       
   115  *
       
   116  * @param name  The name of a feature.
       
   117  *
       
   118  * @return  Returns a non-zero value if the named feature is enabled,
       
   119  *          otherwise 0.
       
   120  */
       
   121 _TEST_EXPORT int
       
   122 rw_enabled (const char *name);
       
   123 
       
   124 
       
   125 /**
       
   126  * Determines whether a case (or line) is enabled.
       
   127  *
       
   128  * @param name  The case (or line) number
       
   129  *
       
   130  * @return  Returns a non-zero value if the case (line) is enabled,
       
   131  *          otherwise 0.
       
   132  */
       
   133 _TEST_EXPORT int
       
   134 rw_enabled (int line);
       
   135 
       
   136 
       
   137 #endif   // RW_CMDOPT_H_INCLUDED