diff options
| author | cvs2svn <admin@example.com> | 2022-05-04 18:02:08 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2022-05-04 18:02:08 +0000 |
| commit | 3c94dc45dfb15483d76c47a128ec352cc0b655ac (patch) | |
| tree | a7cfb4512c784e9518f1b1c2f4009295b8766ef4 /src/lib/libc/stdlib/getsubopt.3 | |
| parent | f32cca700e59c0fd1ddd8f1fd4b35a5401be28fe (diff) | |
| download | openbsd-tb_20220504.tar.gz openbsd-tb_20220504.tar.bz2 openbsd-tb_20220504.zip | |
This commit was manufactured by cvs2git to create tag 'tb_20220504'.tb_20220504
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/getsubopt.3 | 162 |
1 files changed, 0 insertions, 162 deletions
diff --git a/src/lib/libc/stdlib/getsubopt.3 b/src/lib/libc/stdlib/getsubopt.3 deleted file mode 100644 index e94e6395d2..0000000000 --- a/src/lib/libc/stdlib/getsubopt.3 +++ /dev/null | |||
| @@ -1,162 +0,0 @@ | |||
| 1 | .\" $OpenBSD: getsubopt.3,v 1.15 2021/09/03 16:51:47 schwarze Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 1990, 1991, 1993 | ||
| 4 | .\" The Regents of the University of California. All rights reserved. | ||
| 5 | .\" | ||
| 6 | .\" Redistribution and use in source and binary forms, with or without | ||
| 7 | .\" modification, are permitted provided that the following conditions | ||
| 8 | .\" are met: | ||
| 9 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 10 | .\" notice, this list of conditions and the following disclaimer. | ||
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 13 | .\" documentation and/or other materials provided with the distribution. | ||
| 14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 15 | .\" may be used to endorse or promote products derived from this software | ||
| 16 | .\" without specific prior written permission. | ||
| 17 | .\" | ||
| 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 28 | .\" SUCH DAMAGE. | ||
| 29 | .\" | ||
| 30 | .\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93 | ||
| 31 | .\" | ||
| 32 | .Dd $Mdocdate: September 3 2021 $ | ||
| 33 | .Dt GETSUBOPT 3 | ||
| 34 | .Os | ||
| 35 | .Sh NAME | ||
| 36 | .Nm getsubopt | ||
| 37 | .Nd get sub options from an argument | ||
| 38 | .Sh SYNOPSIS | ||
| 39 | .In stdlib.h | ||
| 40 | .Vt extern char *suboptarg; | ||
| 41 | .Ft int | ||
| 42 | .Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep" | ||
| 43 | .Sh DESCRIPTION | ||
| 44 | The | ||
| 45 | .Fn getsubopt | ||
| 46 | function parses a string containing tokens delimited by one or more | ||
| 47 | tab, space, or comma | ||
| 48 | .Pq Ql \&, | ||
| 49 | characters. | ||
| 50 | It is intended for use in parsing groups of option arguments provided | ||
| 51 | as part of a utility command line. | ||
| 52 | .Pp | ||
| 53 | The argument | ||
| 54 | .Fa optionp | ||
| 55 | is a pointer to a pointer to the string. | ||
| 56 | The argument | ||
| 57 | .Fa tokens | ||
| 58 | is a pointer to a | ||
| 59 | .Dv NULL Ns -terminated | ||
| 60 | array of pointers to strings. | ||
| 61 | .Pp | ||
| 62 | The | ||
| 63 | .Fn getsubopt | ||
| 64 | function returns the zero-based offset of the pointer in the | ||
| 65 | .Fa tokens | ||
| 66 | array referencing a string which matches the first token | ||
| 67 | in the string, or \-1 if the string contains no tokens or | ||
| 68 | .Fa tokens | ||
| 69 | does not contain a matching string. | ||
| 70 | .Pp | ||
| 71 | If the token is of the form | ||
| 72 | .Ar name Ns = Ns Ar value , | ||
| 73 | the location referenced by | ||
| 74 | .Fa valuep | ||
| 75 | will be set to point to the start of the | ||
| 76 | .Dq value | ||
| 77 | portion of the token. | ||
| 78 | .Pp | ||
| 79 | On return from | ||
| 80 | .Fn getsubopt , | ||
| 81 | .Fa optionp | ||
| 82 | will be set to point to the start of the next token in the string, | ||
| 83 | or the NUL at the end of the string if no more tokens are present. | ||
| 84 | The comma, space, or tab character ending the token just parsed, | ||
| 85 | and the equal sign separating name and value if any, are replaced | ||
| 86 | with NUL bytes in the original | ||
| 87 | .Pf * Fa optionp | ||
| 88 | input string. | ||
| 89 | The external variable | ||
| 90 | .Fa suboptarg | ||
| 91 | will be set to point to the start of the current token, or | ||
| 92 | .Dv NULL | ||
| 93 | if no tokens were present. | ||
| 94 | The argument | ||
| 95 | .Fa valuep | ||
| 96 | will be set to point to the value portion of the token, or | ||
| 97 | .Dv NULL | ||
| 98 | if no value portion was present. | ||
| 99 | .Sh EXAMPLES | ||
| 100 | .Bd -literal | ||
| 101 | char *tokens[] = { | ||
| 102 | #define ONE 0 | ||
| 103 | "one", | ||
| 104 | #define TWO 1 | ||
| 105 | "two", | ||
| 106 | NULL | ||
| 107 | }; | ||
| 108 | |||
| 109 | \&... | ||
| 110 | |||
| 111 | extern char *optarg, *suboptarg; | ||
| 112 | char *options, *value; | ||
| 113 | |||
| 114 | while ((ch = getopt(argc, argv, "ab:")) != -1) { | ||
| 115 | switch (ch) { | ||
| 116 | case 'a': | ||
| 117 | /* process "a" option */ | ||
| 118 | break; | ||
| 119 | case 'b': | ||
| 120 | options = optarg; | ||
| 121 | while (*options) { | ||
| 122 | switch (getsubopt(&options, tokens, &value)) { | ||
| 123 | case ONE: | ||
| 124 | /* process "one" sub option */ | ||
| 125 | break; | ||
| 126 | case TWO: | ||
| 127 | /* process "two" sub option */ | ||
| 128 | if (!value) | ||
| 129 | error("no value for two"); | ||
| 130 | i = atoi(value); | ||
| 131 | break; | ||
| 132 | case -1: | ||
| 133 | if (suboptarg) | ||
| 134 | error("illegal sub option %s", | ||
| 135 | suboptarg); | ||
| 136 | else | ||
| 137 | error("missing sub option"); | ||
| 138 | break; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | break; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | .Ed | ||
| 145 | .Sh SEE ALSO | ||
| 146 | .Xr getopt 3 , | ||
| 147 | .Xr strsep 3 | ||
| 148 | .Sh STANDARDS | ||
| 149 | The | ||
| 150 | .Fn getsubopt | ||
| 151 | function conforms to | ||
| 152 | .St -p1003.1-2008 . | ||
| 153 | .Pp | ||
| 154 | Allowing space and tab characters to separate tokens | ||
| 155 | and the external variable | ||
| 156 | .Va suboptarg | ||
| 157 | are extensions to that standard. | ||
| 158 | .Sh HISTORY | ||
| 159 | The | ||
| 160 | .Fn getsubopt | ||
| 161 | function first appeared in | ||
| 162 | .Bx 4.4 . | ||
