minor fix to return E_USAGE on -V instead of exit(0);
[oss-qm-packages.git] / lib / netrom_gr.c
blobadf54b206a563fc9755c12cf0a310d2c5baee947
1 /*
2 * lib/netrom_gr.c This file contains an implementation of the NET/ROM
3 * route support functions.
5 * Version: $Id: netrom_gr.c,v 1.5 2000/10/08 01:00:44 ecki Exp $
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>
11 * Changes:
12 * 980701 {0.02} Arnaldo Carvalho de Melo GNU gettext instead of catgets
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.
21 #include "config.h"
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"
31 /* UGLY */
33 int NETROM_rprint(int options)
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; */
42 f1 = fopen(_PATH_PROCNET_NR_NODES, "r");
43 if (!f1) perror(_PATH_PROCNET_NR_NODES);
44 f2 = fopen(_PATH_PROCNET_NR_NEIGH, "r");
45 if (!f2) perror(_PATH_PROCNET_NR_NEIGH);
47 if (f1 == NULL || f2 == NULL) {
48 printf(_("NET/ROM not configured in this system.\n"));
49 return 1;
51 printf(_("Kernel NET/ROM routing table\n"));
52 printf(_("Destination Mnemonic Quality Neighbour Iface\n"));
53 fgets(buffer, 256, f1);
54 while (fgets(buffer, 256, f1)) {
55 buffer[9] = 0;
56 buffer[17] = 0;
57 w = atoi(buffer + 19) - 1;
58 printf("%-9s %-7s ",
59 buffer, buffer + 10);
60 qual = atoi(buffer + 24 + 15 * w);
61 n = atoi(buffer + 32 + 15 * w);
62 rewind(f2);
63 fgets(buffer, 256, f2);
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;
74 fclose(f1);
75 fclose(f2);
76 return 0;
79 #endif /* HAVE_AFNETROM */