Added support for DE200C VFD
[lcdproc-de200c.git] / contrib / interface-demo2 / unix.c
blob162efd4c83dd87cfdfb03d338b28db670c5c6771
1 /*
2 * lib/unix.c This file contains the general hardware types.
4 * Version: $Id: unix.c,v 1.1 2006/02/25 18:23:25 marschap Exp $
6 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
7 * Copyright 1993 MicroWalt Corporation
9 * This program is free software; you can redistribute it
10 * and/or modify it under the terms of the GNU General
11 * Public License as published by the Free Software
12 * Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 #include "config.h"
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #if HAVE_AFUNIX
20 #include <sys/un.h>
21 #endif
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <errno.h>
25 #include <ctype.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include "net-support.h"
29 #include "pathnames.h"
30 #include "intl.h"
31 #include "util.h"
34 /* Display an UNSPEC address. */
35 static char *UNSPEC_print(unsigned char *ptr)
37 static char buff[64];
38 char *pos;
39 unsigned int i;
41 pos = buff;
42 for (i = 0; i < sizeof(struct sockaddr); i++) {
43 pos += sprintf(pos, "%02X-", (*ptr++ & 0377));
45 buff[strlen(buff) - 1] = '\0';
46 return (buff);
50 /* Display an UNSPEC socket address. */
51 static char *UNSPEC_sprint(struct sockaddr *sap, int numeric)
53 static char buf[64];
55 if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
56 return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
57 return (UNSPEC_print(sap->sa_data));
61 #if HAVE_AFUNIX
63 /* Display a UNIX domain address. */
64 static char *UNIX_print(unsigned char *ptr)
66 return (ptr);
70 /* Display a UNIX domain address. */
71 static char *UNIX_sprint(struct sockaddr *sap, int numeric)
73 static char buf[64];
75 if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
76 return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
77 return (UNIX_print(sap->sa_data));
81 struct aftype unix_aftype =
83 "unix", NULL, /*"UNIX Domain", */ AF_UNIX, 0,
84 UNIX_print, UNIX_sprint, NULL, NULL,
85 NULL, NULL, NULL,
86 -1,
87 "/proc/net/unix"
89 #endif /* HAVE_AFUNIX */
92 struct aftype unspec_aftype =
94 "unspec", NULL, /*"UNSPEC", */ AF_UNSPEC, 0,
95 UNSPEC_print, UNSPEC_sprint, NULL, NULL,
96 NULL,