Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getsubopt(3) — Digital UNIX 3.2c

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getopt(3)

getsubopt(3)  —  Subroutines

NAME

getsubopt - Parses suboptions from a command line

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

int getsubopt (
char ∗∗optionp,
char ∗tokens[],
char ∗∗valuep );

PARAMETERS

optionpSpecifies the address of a pointer to the option string. 

tokens[]Specifies an array of possible suboption tokens. 

valuepSpecifies the address of a value string pointer. 

DESCRIPTION

The getsubopt() function parses command line suboptions.  A suboption, is defined as a comma separated list of tokens or token-value pairs.  Tokens are separated from their values with an equal sign.  An example of this syntax is found in the mount command.  The following example contains three suboptions: ro, nosuid, and rsize.  The rsize suboption is a token-value pair with a value of 8192. 

mount -o ro,nosuid,rsize=8192 paradox:/u2 /u2

Because commas and equal signs are used to separate suboptions, and token-value pairs, neither is allowed to be part of the suboption. 

When a suboption is found in the ∗optionp string that matches a string in the token array, the index of the matching string in the array is returned.  If no match is found, then a -1 is returned.  After each match, the ∗optionp string is updated to point past the matched suboption to the next suboption in the list.  If the suboption matched is the last in the string, ∗optionp is set to the null pointer.  If the suboption matched is a token-value pair, then ∗valuep is set to point to the value.  If there is no value, then ∗valuep is to the null pointer. 

The token array is a list of pointers to strings.  The end of the array is signified by a NULL pointer. 

RETURN VALUES

Upon successful completion, the getsubopt() function returns the index of the token or suboption that matches the suboption in the input string.  Otherwise, if no match is found, it returns a value of -1. 

ERRORS

No errors are defined for this routine. 

RELATED INFORMATION

Functions: getopt(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026