Package: manpages-dev
Version: 2.28-1
Severity: wishlist
Tags: upstream patch

Included is a page documenting getsubopt; please consider including
it.

.\" Copyright (C) 2006 Justin Pryzby <[EMAIL PROTECTED]>
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation the rights to use, copy, modify, merge, publish,
.\" distribute, sublicense, and/or sell copies of the Software, and to
.\" permit persons to whom the Software is furnished to do so, subject to
.\" the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be
.\" included in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" References:
.\"   glibc manual and source
.\"   posix getopt page
.TH GETSUBOPT 3 "2006-05-26" GNU
.
.SH NAME
getsubopt \- parse comma-separated commandline parameters
.
.SH SYNOPSIS
\fB#define _XOPEN_SOURCE 500

\fB#include <stdlib.h>

\fBint getsubopt(char **\fIoptionp\fP, char * const *\fPtokens\fP, char 
**\fPvaluep\fP);
.
.SH DESCRIPTION
\fBgetsubopt\fP() parses \fPmount\fP(1)-style commandline arguments.
An argument is defined as a list of comma-separated parameters with
optional values:
.sp
.RS
.B cat,bat=baz,rat,vat
.RE

\fIoptionp\fP is a pointer to the input string; \fItokens\fP is a
\fBNULL\fP-terminated list of accepted parameters.

The first equal sign in a parameter (if any) is interpreted as a
separator between the name and the value of that parameter.  The value
extends to the next comma, or (for the last parameter) to the end of
the string.  If the name of the parameter matches a known name from
\fItokens\fP, and a value string was found, \fBgetsubopt\fP() stores
to \fI*valuep\fP the address of that string.  The first comma in
\fIoptionp\fP is overwritten with a null byte, so \fI*valuep\fP is
precisely the "value string" for that parameter.

If the parameter is known, but no value string was found,
\fI*valuep\fP is set to \fBNULL\fP.

When \fBgetsubopt\fP() returns, \fIoptionp\fP points to the next
suboption, or the null character at the end of the string if the last
suboption was just processed.
.
.SH "RETURN VALUE"
If the first parameter in \fIoptionp\fP is known, \fBgetsubopt\fP()
returns the index into \fItokens\fP of that parameter.  Otherwise, \-1
is returned and \fI*valuep\fP is the entire
.IB name [= value ]
string.

Since \fI*optionp\fP is changed, the first parameter before
\fBgetsubopt\fP() is not (necessarily) the same as the first parameter
after \fBgetsubopt\fP().
.
.SH "CONFORMING TO"
\fBgetsubopt\fP() is specified by XPG4v2.
.
.SH NOTES
The tokens should be distinct, null-terminated strings containing at
least one character, with no embedded equal signs or commas.

Since \fBgetsubopt\fP() overwrites any commas it finds in
\fI*optionp\fP, that variable must be writable; it cannot be a string
constant.
.
.SH SEE ALSO
.BR getopt (3),
.BR mount (1)


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to