man/pt_BR/ifconfig.8: remove untranslated paragraph
[platform/upstream/net-tools.git] / lib / netrom_gr.c
1 /*
2  * lib/netrom_gr.c    This file contains an implementation of the NET/ROM
3  *                      route support functions.
4  *
5  * Version:     $Id: netrom_gr.c,v 1.5 2000/10/08 01:00:44 ecki Exp $
6  *
7  * Author:      Bernd Eckenfels, <ecki@lina.inka.de>
8  *              Copyright 1999 Bernd Eckenfels, Germany
9  *              base on Code from Jonathan Naylor <jsn@Cs.Nott.AC.UK>
10  *
11  * Changes:
12  * 980701 {0.02} Arnaldo Carvalho de Melo   GNU gettext instead of catgets
13  * 
14  *
15  *              This program is free software; you can redistribute it
16  *              and/or  modify it under  the terms of  the GNU General
17  *              Public  License as  published  by  the  Free  Software
18  *              Foundation;  either  version 2 of the License, or  (at
19  *              your option) any later version.
20  */
21 #include "config.h"
22
23 #if HAVE_AFNETROM
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <unistd.h>
27 #include "net-support.h"
28 #include "pathnames.h"
29 #include "intl.h"
30
31 /* UGLY */
32
33 int NETROM_rprint(int options)
34 {
35     FILE *f1 = fopen(_PATH_PROCNET_NR_NODES, "r");
36     FILE *f2 = fopen(_PATH_PROCNET_NR_NEIGH, "r");
37     char buffer[256];
38     int qual, n, w;
39     /*int ext = options & FLAG_EXT;
40        int numeric = options & FLAG_NUM_HOST; */
41
42     if (!f1) perror(_PATH_PROCNET_NR_NODES);
43     if (!f2) perror(_PATH_PROCNET_NR_NEIGH);
44
45     if (f1 == NULL || f2 == NULL) {
46         printf(_("NET/ROM not configured in this system.\n"));
47         return 1;
48     }
49     printf(_("Kernel NET/ROM routing table\n"));
50     printf(_("Destination  Mnemonic  Quality  Neighbour  Iface\n"));
51     if (fgets(buffer, 256, f1))
52         /* eat line */;
53     while (fgets(buffer, 256, f1)) {
54         buffer[9] = 0;
55         buffer[17] = 0;
56         w = atoi(buffer + 19) - 1;
57         printf("%-9s    %-7s   ",
58                buffer, buffer + 10);
59         qual = atoi(buffer + 24 + 15 * w);
60         n = atoi(buffer + 32 + 15 * w);
61         rewind(f2);
62         if (fgets(buffer, 256, f2))
63             /* eat line */;
64         while (fgets(buffer, 256, f2)) {
65             if (atoi(buffer) == n) {
66                 buffer[15] = 0;
67                 buffer[20] = 0;
68                 printf("%3d      %-9s  %s\n",
69                        qual, buffer + 6, buffer + 16);
70                 break;
71             }
72         }
73     }
74     fclose(f1);
75     fclose(f2);
76     return 0;
77 }
78
79 #endif                          /* HAVE_AFNETROM */