sl@0: /*************************************************************************** sl@0: * sl@0: * cmdopt.h - declarations of helper functions for the processing sl@0: * of command line options sl@0: * sl@0: * $Id: cmdopt.h 278860 2005-09-05 21:47:23Z sebor $ sl@0: * sl@0: ************************************************************************ sl@0: * sl@0: * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave sl@0: * Software division. Licensed under the Apache License, Version 2.0 (the sl@0: * "License"); you may not use this file except in compliance with the sl@0: * License. You may obtain a copy of the License at sl@0: * http://www.apache.org/licenses/LICENSE-2.0. Unless required by sl@0: * applicable law or agreed to in writing, software distributed under sl@0: * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR sl@0: * CONDITIONS OF ANY KIND, either express or implied. See the License sl@0: * for the specific language governing permissions and limitations under sl@0: * the License. sl@0: * sl@0: **************************************************************************/ sl@0: sl@0: #ifndef RW_CMDOPT_H_INCLUDED sl@0: #define RW_CMDOPT_H_INCLUDED sl@0: sl@0: sl@0: #include // for test config macros sl@0: sl@0: sl@0: /** sl@0: * Appends a set of command line options and their handlers to the global sl@0: * list of command line option handlers for the current process. sl@0: * sl@0: * @param optspec A string of command line option specifiers describing sl@0: * the names and parameters of the command line options and their sl@0: * handlers. The string has the following syntax: sl@0: * sl@0: * ::= [ ':' | '=' | '#' ] sl@0: * [ @N | @* | '!' ] sl@0: * [ ] sl@0: * ::= [ '|' ] sl@0: * ::= '|' sl@0: * ::= char sl@0: * ::= '-' char char* sl@0: * ::= 'A' - 'Z', 'a'-'z', '0' - '9', '_' sl@0: * sl@0: * Each command line option may have a short name, a long name, sl@0: * or both. When referenced (either on the command line or in sl@0: * the environment), the name of command line option is sl@0: * introduced by a hyphen ('-'). sl@0: * sl@0: * A short option name () consits of a single alphanumeric sl@0: * character or an underscore ('_'). sl@0: * sl@0: * A long name () starts with a hyphen ('-') followed by sl@0: * one or more aphanumeric characters or underscores. sl@0: * sl@0: * The name of the command line option is followd by one or more sl@0: * special characters with the following meaning: sl@0: * sl@0: * ':' the option takes an optional argument sl@0: * '=' the option takes a required argument that must immediately sl@0: * follow the equals sign sl@0: * '#' the handler for this option is not a function but rather sl@0: * a pointer to an signed integer that rw_runopts() sets to sl@0: * a non-zero value if the option appears on the command line sl@0: * @N the option handler will be invoked for the first N sl@0: * occurrences of the option name on the command line sl@0: * @* the option handler will be invoked for every occurrence sl@0: * of the option name on the command line sl@0: * ! the option handler will be invoked only if the option name sl@0: * does not appear on the command line sl@0: * sl@0: * @param ... A list of zero or more command line option handlers whose sl@0: * type is either int (*)(int, char**) or int*, the latter sl@0: * corresponding to options denoted with the '#' special character. sl@0: * sl@0: * @return On success, returns the number of command line options sl@0: * currently defined for the process, negative value on error. sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_setopts (const char *optspec, ...); sl@0: sl@0: sl@0: /** sl@0: * Processes the set of command line options and arguments specified by sl@0: * the function arguments (usually the same arguments as those passed to sl@0: * main()). sl@0: * sl@0: * @param argc The number of non-zero elements of the argv vector. sl@0: * @param argv An array of pointers to command line options and arguments sl@0: * whose the last element, argv [argc], has the value 0. sl@0: * sl@0: * @return Returns the status of last evaluated command line option handler. sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_runopts (int argc, char *argv[]); sl@0: sl@0: sl@0: /** sl@0: * Processes the set of command line options and arguments specified by sl@0: * the function argument (usually the value of an environment variable). sl@0: * sl@0: * @param argvstr A character string of command line options and arguments sl@0: * separated by one or more spaces. sl@0: * sl@0: * @return Returns the status of last evaluated command line option handler. sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_runopts (const char *argvstr); sl@0: sl@0: sl@0: /** sl@0: * Determines whether a feature is enabled. sl@0: * sl@0: * @param name The name of a feature. sl@0: * sl@0: * @return Returns a non-zero value if the named feature is enabled, sl@0: * otherwise 0. sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_enabled (const char *name); sl@0: sl@0: sl@0: /** sl@0: * Determines whether a case (or line) is enabled. sl@0: * sl@0: * @param name The case (or line) number sl@0: * sl@0: * @return Returns a non-zero value if the case (line) is enabled, sl@0: * otherwise 0. sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_enabled (int line); sl@0: sl@0: sl@0: #endif // RW_CMDOPT_H_INCLUDED