fixes for man page bugs reported by Hugh Redelmeier.
[oss-qm-packages.git] / lib / x25_gr.c
blob187fc05820daa95653b4700d2ff234ec9513b97c
1 /*
2 * lib/x25_gr.c This file contains an implementation of the "X.25"
3 * route print support functions.
5 * Version: lib/x25_gr.c 1.00 08/15/98
7 * Author: Stephane Fillod, <sfillod@charybde.gyptis.frmug.org>
8 * based on ax25_gr.c by:
9 * Bernd Eckenfels, <ecki@lina.inka.de>
10 * Copyright 1999 Bernd Eckenfels, Germany
11 * base on Code from Jonathan Naylor <jsn@Cs.Nott.AC.UK>
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General
15 * Public License as published by the Free Software
16 * Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 #include "config.h"
21 #if HAVE_AFX25
22 #if 0
23 #include <sys/types.h>
24 #include <sys/ioctl.h>
25 #include <sys/socket.h>
26 #include <linux/x25.h>
27 #include <linux/if_arp.h> /* ARPHRD_X25 */
28 #include <ctype.h>
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <string.h>
32 #include <termios.h>
33 #endif
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <string.h>
38 #include "net-support.h"
39 #include "pathnames.h"
40 #define EXTERN
41 #if 0
42 #include "net-locale.h"
43 #endif
44 #include "intl.h"
46 /* is in net/x25.h, not in the public header file linux/x25.h. Why?*/
47 #ifndef X25_ADDR_LEN
48 #define X25_ADDR_LEN 16
49 #endif
51 int X25_rprint(int options)
53 FILE *f=fopen(_PATH_PROCNET_X25_ROUTE, "r");
54 char buffer[256];
55 char *p;
56 int digits;
58 if(f==NULL)
60 printf( _("X.25 not configured in this system.\n")); /* xxx */
61 return 1;
63 printf( _("Kernel X.25 routing table\n")); /* xxx */
64 printf( _("Destination Iface\n")); /* xxx */
65 fgets(buffer,256,f);
66 while(fgets(buffer,256,f))
68 p = strchr(buffer,'\n');
69 if (p)
70 *p=0;
72 buffer[24]=0;
73 buffer[35]=0;
74 digits=atoi(buffer+17);
75 if (digits < 0 || digits > 15)
76 digits=15;
77 buffer[digits]=0;
78 if (digits == 0)
79 printf("* %-5s\n", buffer+25);
80 else
81 printf("%s/%*d %-5s\n",
82 buffer,digits-17,digits,buffer+25);
84 fclose(f);
85 return 0;
88 #endif /* HAVE_AFX25 */