~roger-booth/mysql-proxy/laminator

« back to all changes in this revision

Viewing changes to src/network-address-lua.c

  • Committer: Kay Roepke
  • Date: 2009-06-11 21:16:12 UTC
  • Revision ID: kay@sun.com-20090611211612-wyk8bg73vkx9u1qp
add internal libevent build cmake files
fix inet_ntop usage on pre-vista windows
don't blindly #define socklen_t on win32
correct cmake check for g_thread_init
copy lua dll on windows

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 $%ENDLICENSE%$ */
18
18
 
 
19
#include "config.h"
19
20
#include <lua.h>
20
21
 
 
22
#ifdef WIN32
 
23
#include <winsock2.h>
 
24
#include <ws2tcpip.h>
 
25
#else
21
26
#include <arpa/inet.h>
 
27
#endif
22
28
 
23
29
#include "lua-env.h"
24
30
#include "glib-ext.h"
39
45
        } else if (strleq(key, keysize, C("name"))) {
40
46
                lua_pushlstring(L, S(addr->name));
41
47
        } else if (strleq(key, keysize, C("address"))) {
 
48
#ifdef HAVE_INET_NTOP
42
49
                char dst_addr[INET6_ADDRSTRLEN];
 
50
#endif
43
51
                const char *str = NULL;
44
52
 
45
53
                switch (addr->addr.common.sa_family) {
46
54
                case AF_INET:
47
 
                        str = inet_ntop(addr->addr.common.sa_family, &addr->addr.ipv4.sin_addr, dst_addr, sizeof(dst_addr));
 
55
                        str = inet_ntoa(addr->addr.ipv4.sin_addr);
48
56
                        if (!str) {
49
57
                                /* it shouldn't really fail, how about logging it ? */ 
50
58
                        }
51
59
                        break;
 
60
#ifdef HAVE_INET_NTOP
52
61
                case AF_INET6:
53
62
                        str = inet_ntop(addr->addr.common.sa_family, &addr->addr.ipv6.sin6_addr, dst_addr, sizeof(dst_addr));
54
63
                        if (!str) {
55
64
                                /* it shouldn't really fail, how about logging it ? */ 
56
65
                        }
57
66
                        break;
 
67
#endif
 
68
#ifndef WIN32
58
69
                case AF_UNIX:
59
70
                        str = addr->addr.un.sun_path;
60
71
                        break;
 
72
#endif
61
73
                default:
62
74
                        break;
63
75
                }