MCPcopy Create free account
hub / github.com/cppla/ServerStatus / argparse_long_opt

Function argparse_long_opt

server/src/argparse.c:130–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static int
131argparse_long_opt(struct argparse *this_, const struct argparse_option *options)
132{
133 for (; options->type != ARGPARSE_OPT_END; options++) {
134 const char *rest;
135 int opt_flags = 0;
136 if (!options->long_name)
137 continue;
138
139 rest = prefix_skip(this_->argv[0] + 2, options->long_name);
140 if (!rest) {
141 // Negation allowed?
142 if (options->flags & OPT_NONEG) {
143 continue;
144 }
145 // Only boolean/bit allow negation.
146 if (options->type != ARGPARSE_OPT_BOOLEAN && options->type != ARGPARSE_OPT_BIT) {
147 continue;
148 }
149
150 if (!prefix_cmp(this_->argv[0] + 2, "no-")) {
151 rest = prefix_skip(this_->argv[0] + 2 + 3, options->long_name);
152 if (!rest)
153 continue;
154 opt_flags |= OPT_UNSET;
155 } else {
156 continue;
157 }
158 }
159 if (*rest) {
160 if (*rest != '=')
161 continue;
162 this_->optvalue = rest + 1;
163 }
164 return argparse_getvalue(this_, options, opt_flags);
165 }
166 return -2;
167}
168
169int
170argparse_init(struct argparse *this_, struct argparse_option *options,

Callers 1

argparse_parseFunction · 0.85

Calls 3

prefix_skipFunction · 0.85
prefix_cmpFunction · 0.85
argparse_getvalueFunction · 0.85

Tested by

no test coverage detected