genericopenlibs/openenvcore/libc/src/net/inet_ntoa.c
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2  * © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
       
     3  * Copyright (c) 1983, 1993
       
     4  *	The Regents of the University of California.  All rights reserved.
       
     5  *
       
     6  * Redistribution and use in source and binary forms, with or without
       
     7  * modification, are permitted provided that the following conditions
       
     8  * are met:
       
     9  * 1. Redistributions of source code must retain the above copyright
       
    10  *    notice, this list of conditions and the following disclaimer.
       
    11  * 2. Redistributions in binary form must reproduce the above copyright
       
    12  *    notice, this list of conditions and the following disclaimer in the
       
    13  *    documentation and/or other materials provided with the distribution.
       
    14  * 4. Neither the name of the University nor the names of its contributors
       
    15  *    may be used to endorse or promote products derived from this software
       
    16  *    without specific prior written permission.
       
    17  *
       
    18  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
       
    19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       
    21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
       
    22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
       
    23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
       
    24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
       
    26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
       
    27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
       
    28  * SUCH DAMAGE.
       
    29  */
       
    30 
       
    31 #if defined(LIBC_SCCS) && !defined(lint)
       
    32 static char sccsid[] = "@(#)inet_ntoa.c	8.1 (Berkeley) 6/4/93";
       
    33 #endif /* LIBC_SCCS and not lint */
       
    34 #include <sys/cdefs.h>
       
    35 #ifndef __SYMBIAN32__
       
    36 __FBSDID("$FreeBSD: src/lib/libc/net/inet_ntoa.c,v 1.6 2002/03/22 21:52:29 obrien Exp $");
       
    37 #endif
       
    38 #include <sys/types.h>
       
    39 #include <sys/socket.h>
       
    40 #include <stdapis/netinet/in.h>
       
    41 #include <stdapis/arpa/inet.h>
       
    42 #include <stdio.h>
       
    43 #include <string.h>
       
    44 
       
    45 #if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
       
    46 #include "libc_wsd_defs.h"
       
    47 #endif
       
    48 
       
    49 #ifdef EMULATOR
       
    50 
       
    51 GET_STATIC_ARRAY_FROM_TLS(ret, char)
       
    52 #define ret (GET_WSD_VAR_NAME(ret, s)())
       
    53 #endif //EMULATOR
       
    54 
       
    55 /*
       
    56  * Convert network-format internet address
       
    57  * to base 256 d.d.d.d representation.
       
    58  */
       
    59 EXPORT_C char *
       
    60 inet_ntoa(in)
       
    61 	struct in_addr in;
       
    62 {
       
    63 #define SIZEOFRET 18
       
    64 #ifndef EMULATOR
       
    65 	static char ret[18];
       
    66 #endif //EMULATOR
       
    67 
       
    68 	strcpy(ret, "[inet_ntoa error]");
       
    69 	(void) inet_ntop(AF_INET, &in, ret,SIZEOFRET );
       
    70 	return (ret);
       
    71 }
       
    72 
       
    73 /*
       
    74  * Weak aliases for applications that use certain private entry points,
       
    75  * and fail to include <arpa/inet.h>.
       
    76  */
       
    77 #ifndef __SYMBIAN32__
       
    78 #undef inet_ntoa
       
    79 __weak_reference(__inet_ntoa, inet_ntoa);
       
    80 #else
       
    81 #define inet_ntoa __inet_ntoa
       
    82 #endif//__SYMBIAN32__