print-atalk.c (17690) | print-atalk.c (18241) |
---|---|
1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 490 unchanged lines hidden (view full) --- 499 500 /* 501 * if this is the first call, see if there's an AppleTalk 502 * number to name map file. 503 */ 504 if (first && (first = 0, !nflag) 505 && (fp = fopen("/etc/atalk.names", "r"))) { 506 char line[256]; | 1/* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 490 unchanged lines hidden (view full) --- 499 500 /* 501 * if this is the first call, see if there's an AppleTalk 502 * number to name map file. 503 */ 504 if (first && (first = 0, !nflag) 505 && (fp = fopen("/etc/atalk.names", "r"))) { 506 char line[256]; |
507 int i1, i2, i3; | 507 int i1, i2; |
508 509 while (fgets(line, sizeof(line), fp)) { 510 if (line[0] == '\n' || line[0] == 0 || line[0] == '#') 511 continue; | 508 509 while (fgets(line, sizeof(line), fp)) { 510 if (line[0] == '\n' || line[0] == 0 || line[0] == '#') 511 continue; |
512 if (sscanf(line, "%d.%d.%d %s", &i1, &i2, &i3, 513 nambuf) == 4) | 512 if (sscanf(line, "%d.%d %s", &i1, &i2, nambuf) == 3) |
514 /* got a hostname. */ | 513 /* got a hostname. */ |
515 i3 |= ((i1 << 8) | i2) << 8; 516 else if (sscanf(line, "%d.%d %s", &i1, &i2, 517 nambuf) == 3) | 514 i2 |= (i1 << 8); 515 else if (sscanf(line, "%d %s", &i1, nambuf) == 2) |
518 /* got a net name */ | 516 /* got a net name */ |
519 i3 = (((i1 << 8) | i2) << 8) | 255; | 517 i2 = (i1 << 8) | 255; |
520 else 521 continue; 522 | 518 else 519 continue; 520 |
523 for (tp = &hnametable[i3 & (HASHNAMESIZE-1)]; | 521 for (tp = &hnametable[i2 & (HASHNAMESIZE-1)]; |
524 tp->nxt; tp = tp->nxt) 525 ; | 522 tp->nxt; tp = tp->nxt) 523 ; |
526 tp->addr = i3; | 524 tp->addr = i2; |
527 tp->nxt = newhnamemem(); 528 tp->name = savestr(nambuf); 529 } 530 fclose(fp); 531 } 532 533 for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 534 if (tp->addr == i) --- 8 unchanged lines hidden (view full) --- 543 (void)sprintf(nambuf, "%s.%d", tp2->name, athost); 544 tp->name = savestr(nambuf); 545 return (tp->name); 546 } 547 548 tp->addr = (atnet << 8) | athost; 549 tp->nxt = newhnamemem(); 550 if (athost != 255) | 525 tp->nxt = newhnamemem(); 526 tp->name = savestr(nambuf); 527 } 528 fclose(fp); 529 } 530 531 for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) 532 if (tp->addr == i) --- 8 unchanged lines hidden (view full) --- 541 (void)sprintf(nambuf, "%s.%d", tp2->name, athost); 542 tp->name = savestr(nambuf); 543 return (tp->name); 544 } 545 546 tp->addr = (atnet << 8) | athost; 547 tp->nxt = newhnamemem(); 548 if (athost != 255) |
551 (void)sprintf(nambuf, "%d.%d.%d", 552 atnet >> 8, atnet & 0xff, athost); | 549 (void)sprintf(nambuf, "%d.%d", atnet, athost); |
553 else | 550 else |
554 (void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff); | 551 (void)sprintf(nambuf, "%d", atnet); |
555 tp->name = savestr(nambuf); 556 557 return (tp->name); 558} 559 560static struct tok skt2str[] = { 561 { rtmpSkt, "rtmp" }, /* routing table maintenance */ 562 { nbpSkt, "nis" }, /* name info socket */ --- 16 unchanged lines hidden --- | 552 tp->name = savestr(nambuf); 553 554 return (tp->name); 555} 556 557static struct tok skt2str[] = { 558 { rtmpSkt, "rtmp" }, /* routing table maintenance */ 559 { nbpSkt, "nis" }, /* name info socket */ --- 16 unchanged lines hidden --- |