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