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

Function file

tools/ndp/ndp.c:387–420  ·  view source on GitHub ↗

* Process a file to set standard ndp entries */

Source from the content-addressed store, hash-verified

385 * Process a file to set standard ndp entries
386 */
387static int
388file(char *name)
389{
390 FILE *fp;
391 int i, retval;
392 char line[100], arg[5][50], *args[5], *p;
393
394 if ((fp = fopen(name, "r")) == NULL)
395 err(1, "cannot open %s", name);
396 args[0] = &arg[0][0];
397 args[1] = &arg[1][0];
398 args[2] = &arg[2][0];
399 args[3] = &arg[3][0];
400 args[4] = &arg[4][0];
401 retval = 0;
402 while (fgets(line, sizeof(line), fp) != NULL) {
403 if ((p = strchr(line, '#')) != NULL)
404 *p = '\0';
405 for (p = line; isblank(*p); p++);
406 if (*p == '\n' || *p == '\0')
407 continue;
408 i = sscanf(line, "%49s %49s %49s %49s %49s",
409 arg[0], arg[1], arg[2], arg[3], arg[4]);
410 if (i < 2) {
411 warnx("bad line: %s", line);
412 retval = 1;
413 continue;
414 }
415 if (set(i, args))
416 retval = 1;
417 }
418 fclose(fp);
419 return (retval);
420}
421
422static void
423getsocket()

Callers 1

mainFunction · 0.70

Calls 4

strchrFunction · 0.85
isblankFunction · 0.85
sscanfFunction · 0.85
setFunction · 0.70

Tested by

no test coverage detected