Update contrib.
1 /***************************************************************************
3 * cmdopt.h - declarations of helper functions for the processing
4 * of command line options
6 * $Id: cmdopt.h 278860 2005-09-05 21:47:23Z sebor $
8 ************************************************************************
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
21 **************************************************************************/
23 #ifndef RW_CMDOPT_H_INCLUDED
24 #define RW_CMDOPT_H_INCLUDED
27 #include <testdefs.h> // for test config macros
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.
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:
38 * <optspec> ::= <opt> [ ':' | '=' | '#' ]
41 * <opt> ::= <sopt> [ '|' <lopt>]
44 * <lopt> ::= '-' char char*
45 * <char> ::= 'A' - 'Z', 'a'-'z', '0' - '9', '_'
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 ('-').
52 * A short option name (<sopt>) consits of a single alphanumeric
53 * character or an underscore ('_').
55 * A long name (<lopt>) starts with a hyphen ('-') followed by
56 * one or more aphanumeric characters or underscores.
58 * The name of the command line option is followd by one or more
59 * special characters with the following meaning:
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
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.
78 * @return On success, returns the number of command line options
79 * currently defined for the process, negative value on error.
82 rw_setopts (const char *optspec, ...);
86 * Processes the set of command line options and arguments specified by
87 * the function arguments (usually the same arguments as those passed to
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.
94 * @return Returns the status of last evaluated command line option handler.
97 rw_runopts (int argc, char *argv[]);
101 * Processes the set of command line options and arguments specified by
102 * the function argument (usually the value of an environment variable).
104 * @param argvstr A character string of command line options and arguments
105 * separated by one or more spaces.
107 * @return Returns the status of last evaluated command line option handler.
110 rw_runopts (const char *argvstr);
114 * Determines whether a feature is enabled.
116 * @param name The name of a feature.
118 * @return Returns a non-zero value if the named feature is enabled,
122 rw_enabled (const char *name);
126 * Determines whether a case (or line) is enabled.
128 * @param name The case (or line) number
130 * @return Returns a non-zero value if the case (line) is enabled,
134 rw_enabled (int line);
137 #endif // RW_CMDOPT_H_INCLUDED