1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/cmdopt.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,137 @@
1.4 +/***************************************************************************
1.5 + *
1.6 + * cmdopt.h - declarations of helper functions for the processing
1.7 + * of command line options
1.8 + *
1.9 + * $Id: cmdopt.h 278860 2005-09-05 21:47:23Z sebor $
1.10 + *
1.11 + ************************************************************************
1.12 + *
1.13 + * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
1.14 + * Software division. Licensed under the Apache License, Version 2.0 (the
1.15 + * "License"); you may not use this file except in compliance with the
1.16 + * License. You may obtain a copy of the License at
1.17 + * http://www.apache.org/licenses/LICENSE-2.0. Unless required by
1.18 + * applicable law or agreed to in writing, software distributed under
1.19 + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1.20 + * CONDITIONS OF ANY KIND, either express or implied. See the License
1.21 + * for the specific language governing permissions and limitations under
1.22 + * the License.
1.23 + *
1.24 + **************************************************************************/
1.25 +
1.26 +#ifndef RW_CMDOPT_H_INCLUDED
1.27 +#define RW_CMDOPT_H_INCLUDED
1.28 +
1.29 +
1.30 +#include <testdefs.h> // for test config macros
1.31 +
1.32 +
1.33 +/**
1.34 + * Appends a set of command line options and their handlers to the global
1.35 + * list of command line option handlers for the current process.
1.36 + *
1.37 + * @param optspec A string of command line option specifiers describing
1.38 + * the names and parameters of the command line options and their
1.39 + * handlers. The string has the following syntax:
1.40 + *
1.41 + * <optspec> ::= <opt> [ ':' | '=' | '#' ]
1.42 + * [ @N | @* | '!' ]
1.43 + * [ <opts> ]
1.44 + * <opt> ::= <sopt> [ '|' <lopt>]
1.45 + * ::= '|' <lopt>
1.46 + * <sopt> ::= char
1.47 + * <lopt> ::= '-' char char*
1.48 + * <char> ::= 'A' - 'Z', 'a'-'z', '0' - '9', '_'
1.49 + *
1.50 + * Each command line option may have a short name, a long name,
1.51 + * or both. When referenced (either on the command line or in
1.52 + * the environment), the name of command line option is
1.53 + * introduced by a hyphen ('-').
1.54 + *
1.55 + * A short option name (<sopt>) consits of a single alphanumeric
1.56 + * character or an underscore ('_').
1.57 + *
1.58 + * A long name (<lopt>) starts with a hyphen ('-') followed by
1.59 + * one or more aphanumeric characters or underscores.
1.60 + *
1.61 + * The name of the command line option is followd by one or more
1.62 + * special characters with the following meaning:
1.63 + *
1.64 + * ':' the option takes an optional argument
1.65 + * '=' the option takes a required argument that must immediately
1.66 + * follow the equals sign
1.67 + * '#' the handler for this option is not a function but rather
1.68 + * a pointer to an signed integer that rw_runopts() sets to
1.69 + * a non-zero value if the option appears on the command line
1.70 + * @N the option handler will be invoked for the first N
1.71 + * occurrences of the option name on the command line
1.72 + * @* the option handler will be invoked for every occurrence
1.73 + * of the option name on the command line
1.74 + * ! the option handler will be invoked only if the option name
1.75 + * does not appear on the command line
1.76 + *
1.77 + * @param ... A list of zero or more command line option handlers whose
1.78 + * type is either int (*)(int, char**) or int*, the latter
1.79 + * corresponding to options denoted with the '#' special character.
1.80 + *
1.81 + * @return On success, returns the number of command line options
1.82 + * currently defined for the process, negative value on error.
1.83 + */
1.84 +_TEST_EXPORT int
1.85 +rw_setopts (const char *optspec, ...);
1.86 +
1.87 +
1.88 +/**
1.89 + * Processes the set of command line options and arguments specified by
1.90 + * the function arguments (usually the same arguments as those passed to
1.91 + * main()).
1.92 + *
1.93 + * @param argc The number of non-zero elements of the argv vector.
1.94 + * @param argv An array of pointers to command line options and arguments
1.95 + * whose the last element, argv [argc], has the value 0.
1.96 + *
1.97 + * @return Returns the status of last evaluated command line option handler.
1.98 + */
1.99 +_TEST_EXPORT int
1.100 +rw_runopts (int argc, char *argv[]);
1.101 +
1.102 +
1.103 +/**
1.104 + * Processes the set of command line options and arguments specified by
1.105 + * the function argument (usually the value of an environment variable).
1.106 + *
1.107 + * @param argvstr A character string of command line options and arguments
1.108 + * separated by one or more spaces.
1.109 + *
1.110 + * @return Returns the status of last evaluated command line option handler.
1.111 + */
1.112 +_TEST_EXPORT int
1.113 +rw_runopts (const char *argvstr);
1.114 +
1.115 +
1.116 +/**
1.117 + * Determines whether a feature is enabled.
1.118 + *
1.119 + * @param name The name of a feature.
1.120 + *
1.121 + * @return Returns a non-zero value if the named feature is enabled,
1.122 + * otherwise 0.
1.123 + */
1.124 +_TEST_EXPORT int
1.125 +rw_enabled (const char *name);
1.126 +
1.127 +
1.128 +/**
1.129 + * Determines whether a case (or line) is enabled.
1.130 + *
1.131 + * @param name The case (or line) number
1.132 + *
1.133 + * @return Returns a non-zero value if the case (line) is enabled,
1.134 + * otherwise 0.
1.135 + */
1.136 +_TEST_EXPORT int
1.137 +rw_enabled (int line);
1.138 +
1.139 +
1.140 +#endif // RW_CMDOPT_H_INCLUDED