少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * \file
 * Implements missing standard socket functions.
 *
 * Author:
 *    Rodrigo Kumpera (kumpera@gmail.com)
 *
 * (C) 2015 Xamarin
 */
 
#include <mono/utils/networking.h>
#include <mono/utils/mono-compiler.h>
#include <glib.h>
 
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
 
//wasm does have inet_pton even though autoconf fails to find
#if !defined (HAVE_INET_PTON) && !defined (HOST_WASM)
 
int
inet_pton (int family, const char *address, void *inaddrp)
{
    if (family == AF_INET) {
#ifdef HAVE_INET_ATON
        struct in_addr inaddr;
        
        if (!inet_aton (address, &inaddr))
            return 0;
        
        memcpy (inaddrp, &inaddr, sizeof (struct in_addr));
        return 1;
#else
        /* assume the system has inet_addr(), if it doesn't
           have that we're pretty much screwed... */
        guint32 inaddr;
        
        if (!strcmp (address, "255.255.255.255")) {
            /* special-case hack */
            inaddr = 0xffffffff;
        } else {
            inaddr = inet_addr (address);
#ifndef INADDR_NONE
#define INADDR_NONE ((in_addr_t) -1)
#endif
            if (inaddr == INADDR_NONE)
                return 0;
        }
        
        memcpy (inaddrp, &inaddr, sizeof (guint32));
        return 1;
#endif /* HAVE_INET_ATON */
    }
    
    return -1;
}
 
#else /* !HAVE_INET_PTON */
 
MONO_EMPTY_SOURCE_FILE (networking_missing);
#endif /* !HAVE_INET_PTON */