---
name: "stropt"
section: "3"
platform: "macos"
package: "ksh"
version: "42"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/stropt"
---

# stropt(3)

table driven option expression evaluator

## NAME

stropt - table driven option expression evaluator

## SYNOPSIS

$1$2#include \<namval.h\>#include \<namval.h\>#include \<namval.h\>#include \<namval.h\>#include \<namval.h\>#include \<namval.h\>#include \<namval.h\>#include \<namval.h\>\
 $1$2int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,int stropt(char\* s, struct namval\* tab,\
 $1$2           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),           int (\*fun)(void\* a, struct namval\* p, int n, char\* v),\
 $1$2           void\* a)           void\* a)           void\* a)           void\* a)           void\* a)           void\* a)           void\* a)           void\* a)

## DESCRIPTION

*stropt* parses option expressions in the nul-terminated string *s* using the option names in *tab*. *tab* is an array of **struct namval** name value pairs:

```
char*	name;
int	value;
```

The last entry must be followed by a sentinel with **name** set to 0.

An option expression contains 0 or more of \[**no**\]*name*\[=*value*\] separate by **space** or **tab**, where *name* must be one of the option names in *tab*, *value* is an optional value, and **no** is for Boolean options. Each option is passed to *fun* for processing. *a* is the $1$2void\*void\*void\*void\*void\*void\*void\*void\* pointer that is passed from the *stropt* call but is otherwise not interpreted. *p* points to the option name value pair from *tab*. *n* is 0 if **no** preceded the option *name* and *v* points to the beginning of the option *value* in *s*. and If *name* is not found in *tab* then *fun* is called with  *p* pointing to an internal *namval* entry with *p-\>name* pointing to the unknown option and *p-\>value* set to the *value* of the sentinel entry in *tab*.

If *fun* returns non-zero then this value is returned and no further options are processed. Otherwise *stropt* returns 0 after processing all options.
