MCPcopy Index your code
hub / github.com/RsyncProject/rsync / poptGetContext

Function poptGetContext

popt/popt.c:154–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154poptContext poptGetContext(const char * name, int argc, const char ** argv,
155 const struct poptOption * options, unsigned int flags)
156{
157 poptContext con = malloc(sizeof(*con));
158
159 if (con == NULL) return NULL; /* XXX can't happen */
160 memset(con, 0, sizeof(*con));
161
162 con->os = con->optionStack;
163 con->os->argc = argc;
164 con->os->argv = argv;
165 con->os->argb = NULL;
166
167 if (!(flags & POPT_CONTEXT_KEEP_FIRST))
168 con->os->next = 1; /* skip argv[0] */
169
170 con->leftovers = calloc( (size_t)(argc + 1), sizeof(*con->leftovers) );
171 con->allocLeftovers = argc + 1;
172 con->options = options;
173 con->aliases = NULL;
174 con->numAliases = 0;
175 con->flags = flags;
176 con->execs = NULL;
177 con->numExecs = 0;
178 con->execFail = NULL;
179 con->finalArgvAlloced = argc * 2;
180 con->finalArgv = calloc( (size_t)con->finalArgvAlloced, sizeof(*con->finalArgv) );
181 con->execAbsolute = 1;
182 con->arg_strip = NULL;
183
184 if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER"))
185 con->flags |= POPT_CONTEXT_POSIXMEHARDER;
186
187 if (name)
188 con->appName = xstrdup(name);
189
190 invokeCallbacksPRE(con, con->options);
191
192 return con;
193}
194
195static void cleanOSE(struct optionStackEntry *os)
196{

Callers 4

parse_argumentsFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
poptInitFunction · 0.85

Calls 1

invokeCallbacksPREFunction · 0.85

Tested by 1

mainFunction · 0.68