* Process a file to set standard ndp entries */
| 385 | * Process a file to set standard ndp entries |
| 386 | */ |
| 387 | static int |
| 388 | file(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 | |
| 422 | static void |
| 423 | getsocket() |