1.fp 5 CW 2.de Af 3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2 4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 5.. 6.de aF 7.ie \\$3 .ft \\$1 8.el \{\ 9.ds ;G \& 10.nr ;G \\n(.f 11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 12\\*(;G 13.ft \\n(;G \} 14.. 15.de L 16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 17.. 18.de LR 19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 20.. 21.de RL 22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 23.. 24.de EX \" start example 25.ta 1i 2i 3i 4i 5i 6i 26.PP 27.RS 28.PD 0 29.ft 5 30.nf 31.. 32.de EE \" end example 33.fi 34.ft 35.PD 36.RE 37.PP 38.. 39.TH STROPT 3 40.SH NAME 41stropt \- table driven option expression evaluator 42.SH SYNOPSIS 43.L "#include <namval.h>" 44.br 45.L "int stropt(char* s, struct namval* tab, 46.br 47.L " int (*fun)(void* a, struct namval* p, int n, char* v)," 48.br 49.L " void* a)" 50.SH DESCRIPTION 51.I stropt 52parses option expressions in the nul-terminated string 53.I s 54using the option names in 55.IR tab . 56.I tab 57is an array of 58.B "struct namval" 59name value pairs: 60.EX 61char* name; 62int value; 63.EE 64The last entry must be followed by a sentinel with 65.B name 66set to 0. 67.PP 68An option expression contains 0 or more of [\fBno\fP]\fIname\fP[=\fIvalue\fP] 69separate by 70.B space 71or 72.BR tab , 73where 74.I name 75must be one of the option names in 76.IR tab , 77.I value 78is an optional value, and 79.B no 80is for Boolean options. 81Each option is passed to 82.I fun 83for processing. 84.I a 85is the 86.L void* 87pointer that is passed from the 88.I stropt 89call but is otherwise not interpreted. 90.I p 91points to the option name value pair from 92.IR tab . 93.I n 94is 0 if 95.B no 96preceded the option 97.I name 98and 99.I v 100points to the beginning of the option 101.I value 102in 103.IR s . 104and 105If 106.I name 107is not found in 108.I tab 109then 110.I fun 111is called with 112.I p 113pointing to an internal 114.I namval 115entry with 116.I p\->name 117pointing to the unknown option and 118.I p\->value 119set to the 120.I value 121of the sentinel entry in 122.IR tab . 123.PP 124If 125.I fun 126returns non-zero then this value is returned and no further 127options are processed. 128Otherwise 129.I stropt 130returns 0 after processing all options. 131