266
265
return xstrdup(path);
270
* Following part was appended by Ryusuke Konishi <ryusuke@osrg.net>
272
int find_opt(const char *opts, const char *token, void *varp)
280
opts2 = xstrdup(opts);
281
opt = strtok(opts2, ",");
284
if (sscanf(opt, token, varp) == 1) {
288
opt = strtok(NULL, ",");
291
int cmplen = strlen(token) + 1;
293
if (!strncmp(opt, token, cmplen)) {
297
opt = strtok(NULL, ",");
304
char *change_opt(const char *opts, const char *token, void *varp,
307
int ind = find_opt(opts, token, varp);
315
while (*ep != ',' && *ep != '\0')
318
if (*instead == '\0') {
324
newopts = xmalloc(ind + strlen(instead) + strlen(ep) + 1);
325
memcpy(newopts, opts, ind);
326
strcpy(newopts + ind, instead);
328
} else if (opts == NULL || *opts == '\0') {
329
newopts = xstrdup(instead);
331
newopts = xstrdup(opts);
332
if (*instead != '\0')
333
newopts = xstrconcat3(newopts, ",", instead);