OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [userland/] [route/] [lib/] [unix.c] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 745 simons
/*
2
 * lib/unix.c This file contains the general hardware types.
3
 *
4
 * Version:     $Id: unix.c,v 1.1 2002-03-17 19:58:53 simons Exp $
5
 *
6
 * Author:      Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
7
 *              Copyright 1993 MicroWalt Corporation
8
 *
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.
14
 */
15
#include "config.h"
16
 
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"
32
 
33
 
34
/* Display an UNSPEC address. */
35
static char *UNSPEC_print(unsigned char *ptr)
36
{
37
    static char buff[64];
38
    char *pos;
39
    unsigned int i;
40
 
41
    pos = buff;
42
    for (i = 0; i < sizeof(struct sockaddr); i++) {
43
        pos += sprintf(pos, "%02X-", (*ptr++ & 0377));
44
    }
45
    buff[strlen(buff) - 1] = '\0';
46
    return (buff);
47
}
48
 
49
 
50
/* Display an UNSPEC socket address. */
51
static char *UNSPEC_sprint(struct sockaddr *sap, int numeric)
52
{
53
    static char buf[64];
54
 
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));
58
}
59
 
60
 
61
#if HAVE_AFUNIX
62
 
63
/* Display a UNIX domain address. */
64
static char *UNIX_print(unsigned char *ptr)
65
{
66
    return (ptr);
67
}
68
 
69
 
70
/* Display a UNIX domain address. */
71
static char *UNIX_sprint(struct sockaddr *sap, int numeric)
72
{
73
    static char buf[64];
74
 
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));
78
}
79
 
80
 
81
struct aftype unix_aftype =
82
{
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"
88
};
89
#endif                          /* HAVE_AFUNIX */
90
 
91
 
92
struct aftype unspec_aftype =
93
{
94
    "unspec", NULL, /*"UNSPEC", */ AF_UNSPEC, 0,
95
    UNSPEC_print, UNSPEC_sprint, NULL, NULL,
96
    NULL,
97
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.