MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_set_options_simple

Function xo_set_options_simple

tools/libxo/libxo/libxo.c:2214–2250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2212}
2213
2214static int
2215xo_set_options_simple (xo_handle_t *xop, const char *input)
2216{
2217 xo_xof_flags_t new_flag;
2218 char *cp, *ep, *vp, *np, *bp;
2219 ssize_t len = strlen(input) + 1;
2220
2221 bp = alloca(len);
2222 memcpy(bp, input, len);
2223
2224 for (cp = bp, ep = cp + len - 1; cp && cp < ep; cp = np) {
2225 np = strchr(cp, ',');
2226 if (np)
2227 *np++ = '\0';
2228
2229 vp = strchr(cp, '=');
2230 if (vp)
2231 *vp++ = '\0';
2232
2233 if (xo_streq("colors", cp)) {
2234 xo_set_color_map(xop, vp);
2235 continue;
2236 }
2237
2238 new_flag = xo_name_lookup(xo_xof_simple_names, cp, -1);
2239 if (new_flag != 0) {
2240 XOF_SET(xop, new_flag);
2241 } else if (xo_streq(cp, "no-color")) {
2242 XOF_CLEAR(xop, XOF_COLOR_ALLOWED);
2243 } else {
2244 xo_failure(xop, "unknown simple option: %s", cp);
2245 return -1;
2246 }
2247 }
2248
2249 return 0;
2250}
2251
2252/**
2253 * Set the options for a handle using a string of options

Callers 1

xo_default_initFunction · 0.85

Calls 6

strchrFunction · 0.85
xo_streqFunction · 0.85
xo_set_color_mapFunction · 0.85
xo_name_lookupFunction · 0.85
xo_failureFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected