mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-24 16:07:19 +08:00
b10ab72581
* Makefile.am: Add include files under bits sub-directory. * Makefile.in: Regenerated. * libc/sys/linux/argp/argp-fs-xinl.c: Set __OPTIMIZE__ to actual value of 1 to be compatible with newer glibc headers. * libc/sys/linux/sys/cdefs.h: Fix to be compatible with newer glibc headers. * libc/sys/linux/sys/dirent.h: Ditto. * libc/sys/linux/argp/argp-xinl.c: Ditto. * libc/sys/linux/dl/dl-runtime.c: Make sure fixup and profile_fixup routines are marked used so they won't be optimized away. * libc/sys/linux/dl/dl-cache.c: Don't use weak_extern macro to mark functions as weak. * libc/sys/linux/dl/dl-open.c: Ditto. * libc/sys/linux/iconv/gconv_open.c: Fix to obey new gcc4 rules about lvalues. * libc/sys/linux/iconv/gconv_simple.c: Ditto. * libc/sys/linux/linuxthreads/bits/libc-lock.h: Don't use weak_extern macro to mark functions as weak. Instead always use #pragma weak. * iconvdata/jis0208.h: Fix to work with gcc4. * libc/sys/linux/dl/dl-load.c: Ditto. * libc/sys/linux/dl/dl-reloc.c: Ditto. * libc/sys/linux/dl/do-rel.h: Ditto. * libc/sys/linux/dl/dynamic-link.h: Ditto. * libc/sys/linux/include/ltdl.h: Ditto. * libc/sys/linux/machine/i386/dl-machine.h: Ditto. * libc/sys/linux/machine/i386/weakalias.h: Ditto. * libc/sys/linux/net/ns_ntoa.c: Ditto. * libc/sys/linux/bits/initspin.h: New file. * libc/sys/linux/bits/libc-lock.h: Ditto. * libc/sys/linux/bits/pthreadtypes.h: Ditto. * libc/sys/linux/bits/typesizes.h: Ditto.
106 lines
3.2 KiB
C
106 lines
3.2 KiB
C
/*
|
|
* Copyright (c) 1986, 1993
|
|
* The Regents of the University of California. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by the University of
|
|
* California, Berkeley and its contributors.
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
|
static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93";
|
|
#endif /* LIBC_SCCS and not lint */
|
|
#include <sys/cdefs.h>
|
|
#include <sys/types.h>
|
|
#include <machine/endian.h>
|
|
|
|
#include <sys/param.h>
|
|
#include <arpa/inet.h>
|
|
#include <netns/ns.h>
|
|
#include <stdio.h>
|
|
|
|
static char *spectHex(char *p0);
|
|
|
|
char *
|
|
ns_ntoa(addr)
|
|
struct ns_addr addr;
|
|
{
|
|
static char obuf[40];
|
|
union { union ns_net net_e; u_long long_e; } net;
|
|
u_short port = htons(addr.x_port);
|
|
char *cp;
|
|
char *cp2;
|
|
u_char *up = addr.x_host.c_host;
|
|
u_char *uplim = up + 6;
|
|
|
|
net.net_e = addr.x_net;
|
|
sprintf(obuf, "%lx", (u_long)ntohl(net.long_e));
|
|
cp = spectHex(obuf);
|
|
cp2 = cp + 1;
|
|
while (*up==0 && up < uplim) up++;
|
|
if (up == uplim) {
|
|
if (port) {
|
|
sprintf(cp, ".0");
|
|
cp += 2;
|
|
}
|
|
} else {
|
|
sprintf(cp, ".%x", *up++);
|
|
while (up < uplim) {
|
|
while (*cp) cp++;
|
|
sprintf(cp, "%02x", *up++);
|
|
}
|
|
cp = spectHex(cp2);
|
|
}
|
|
if (port) {
|
|
sprintf(cp, ".%x", port);
|
|
spectHex(cp + 1);
|
|
}
|
|
return (obuf);
|
|
}
|
|
|
|
static char *
|
|
spectHex(p0)
|
|
char *p0;
|
|
{
|
|
int ok = 0;
|
|
int nonzero = 0;
|
|
char *p = p0;
|
|
for (; *p; p++) switch (*p) {
|
|
|
|
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
|
*p += ('A' - 'a');
|
|
/* fall into . . . */
|
|
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
|
ok = 1;
|
|
case '1': case '2': case '3': case '4': case '5':
|
|
case '6': case '7': case '8': case '9':
|
|
nonzero = 1;
|
|
}
|
|
if (nonzero && !ok) { *p++ = 'H'; *p = 0; }
|
|
return (p);
|
|
}
|