arp.c (44acbc1adc9779fbb120bc619d3ecb7a863d7e14) | arp.c (3adcd04299800018511122fd4e07ffc94ff1ee98) |
---|---|
1/* 2 * Copyright (c) 1984, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Sun Microsystems, Inc. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 206 unchanged lines hidden (view full) --- 215/* 216 * Process a file to set standard arp entries 217 */ 218int 219file(char *name) 220{ 221 FILE *fp; 222 int i, retval; | 1/* 2 * Copyright (c) 1984, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Sun Microsystems, Inc. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 206 unchanged lines hidden (view full) --- 215/* 216 * Process a file to set standard arp entries 217 */ 218int 219file(char *name) 220{ 221 FILE *fp; 222 int i, retval; |
223 char line[100], arg[5][50], *args[5], *s; | 223 char line[100], arg[5][50], *args[5], *p; |
224 225 if ((fp = fopen(name, "r")) == NULL) 226 errx(1, "cannot open %s", name); 227 args[0] = &arg[0][0]; 228 args[1] = &arg[1][0]; 229 args[2] = &arg[2][0]; 230 args[3] = &arg[3][0]; 231 args[4] = &arg[4][0]; 232 retval = 0; 233 while(fgets(line, 100, fp) != NULL) { | 224 225 if ((fp = fopen(name, "r")) == NULL) 226 errx(1, "cannot open %s", name); 227 args[0] = &arg[0][0]; 228 args[1] = &arg[1][0]; 229 args[2] = &arg[2][0]; 230 args[3] = &arg[3][0]; 231 args[4] = &arg[4][0]; 232 retval = 0; 233 while(fgets(line, 100, fp) != NULL) { |
234 if ((s = strchr(line, '#')) != NULL) 235 *s = '\0'; 236 for (s = line; isblank(*s); s++); 237 if (*s == '\0') | 234 if ((p = strchr(line, '#')) != NULL) 235 *p = '\0'; 236 for (p = line; isblank(*p); p++); 237 if (*p == '\0') |
238 continue; | 238 continue; |
239 i = sscanf(s, "%49s %49s %49s %49s %49s", arg[0], arg[1], | 239 i = sscanf(p, "%49s %49s %49s %49s %49s", arg[0], arg[1], |
240 arg[2], arg[3], arg[4]); 241 if (i < 2) { 242 warnx("bad line: %s", line); 243 retval = 1; 244 continue; 245 } 246 if (set(i, args)) 247 retval = 1; --- 519 unchanged lines hidden --- | 240 arg[2], arg[3], arg[4]); 241 if (i < 2) { 242 warnx("bad line: %s", line); 243 retval = 1; 244 continue; 245 } 246 if (set(i, args)) 247 retval = 1; --- 519 unchanged lines hidden --- |