simple patch from Ajax <ajax@firest0rm.org> (corrected) to print DDP
[oss-qm-packages.git] / lib / econet.c
blob1229a2896e36005bb11b0491894c158d4e3a477a
1 /*
2 * lib/econet.c This file contains an implementation of the Econet
3 * support functions for the net-tools.
4 * (NET-3 base distribution).
6 * Version: $Id: econet.c,v 1.11 2000/05/27 17:36:16 pb Exp $
8 * Author: Philip Blundell <philb@gnu.org>
10 * Modified:
12 * This program is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU General
14 * Public License as published by the Free Software
15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version.
19 #include "config.h"
21 #if HAVE_AFECONET
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <stdio.h>
26 #include <neteconet/ec.h>
28 #include "version.h"
29 #include "net-support.h"
30 #include "pathnames.h"
31 #include "intl.h"
34 /* Display an Econet address */
35 static char *
36 ec_print(unsigned char *ptr)
38 static char buff[64];
39 struct ec_addr *ec = (struct ec_addr *) ptr;
40 sprintf(buff, "%d.%d", ec->net, ec->station);
41 return buff;
45 /* Display an Econet socket address */
46 static char *
47 ec_sprint(struct sockaddr *sap, int numeric)
49 struct sockaddr_ec *sec = (struct sockaddr_ec *) sap;
51 if (sap->sa_family != AF_ECONET)
52 return _("[NONE SET]");
54 return ec_print((unsigned char *) &sec->addr);
57 static int
58 ec_input(int type, char *bufp, struct sockaddr *sap)
60 struct sockaddr_ec *sec = (struct sockaddr_ec *) sap;
61 int net, stn;
62 switch (sscanf(bufp, "%d.%d", &net, &stn)) {
63 case 2:
64 sec->addr.station = stn;
65 sec->addr.net = net;
66 return 0;
67 case 1:
68 if (sscanf(bufp, "%d", &stn) == 1) {
69 sec->addr.net = 0;
70 sec->addr.station = stn;
71 return 0;
74 return -1;
77 struct aftype ec_aftype =
79 "ec", NULL, AF_ECONET, 0,
80 ec_print, ec_sprint, ec_input, NULL,
81 NULL, NULL, NULL,
82 -1,
83 "/proc/sys/net/econet"
86 #endif /* HAVE_AFECONET */