Ignore:
Timestamp:
Aug 3, 2012, 7:26:43 PM (8 years ago)
Author:
wisk
Message:

add new hook for windows (CreateFileMapping?(A|W), MapViewOfFile?, ReadFileEx?), re-enable option -U, start to port network on windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf/network.c

    r4685 r4834  
    2929#   include <netinet/in.h>
    3030#   include <arpa/inet.h>
     31#elif defined HAVE_WINSOCK2_H
     32#   include <WinSock2.h>
     33#   include <WS2tcpip.h>
    3134#endif
    3235
     
    3639#include "network.h"
    3740
    38 #if defined HAVE_SYS_SOCKET_H
     41#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    3942static unsigned int get_socket_ip(int);
    4043static int host_in_list(unsigned int, unsigned int const *);
     
    5457void _zz_network_init(void)
    5558{
    56     ;
     59#ifdef HAVE_WINSOCK2_H
     60    WSADATA wsa_data;
     61    WSAStartup(MAKEWORD(2,2), &wsa_data); /* LATER: handle error */
     62#endif
    5763}
    5864
    5965void _zz_network_fini(void)
    6066{
    61 #if defined HAVE_SYS_SOCKET_H
     67#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    6268    if(ports != static_ports)
    6369        free(ports);
     
    6773        free(deny);
    6874#endif
     75
     76#if defined HAVE_WINSOCK2_H
     77    WSACleanup(); /* LATER: handle error */
     78#endif
    6979}
    7080
    7181void _zz_allow(char const *allowlist)
    7282{
    73 #if defined HAVE_SYS_SOCKET_H
     83#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    7484    allow = create_host_list(allowlist, static_allow);
    7585#endif
     
    7888void _zz_deny(char const *denylist)
    7989{
    80 #if defined HAVE_SYS_SOCKET_H
     90#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    8191    deny = create_host_list(denylist, static_deny);
    8292#endif
     
    8595void _zz_ports(char const *portlist)
    8696{
    87 #if defined HAVE_SYS_SOCKET_H
     97#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    8898    ports = _zz_allocrange(portlist, static_ports);
    8999#endif
     
    92102int _zz_portwatched(int port)
    93103{
    94 #if defined HAVE_SYS_SOCKET_H
     104#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    95105    if(!ports)
    96106        return 1;
     
    104114int _zz_hostwatched(int sock)
    105115{
    106 #if defined HAVE_SYS_SOCKET_H
     116#if defined HAVE_SYS_SOCKET_H || defined (HAVE_WINDOWS_H)
    107117    int watch = 1;
    108118    unsigned int ip;
     
    126136/* XXX: the following functions are local */
    127137
    128 #if defined HAVE_SYS_SOCKET_H
     138#if defined HAVE_SYS_SOCKET_H || defined HAVE_WINSOCK2_H
    129139static unsigned int *create_host_list(char const *list,
    130140                                      unsigned int *static_list)
     
    167177        }
    168178
    169         ret = inet_aton(buf, &addr);
     179        ret = inet_pton(AF_INET, buf, &addr);
    170180        if (ret)
    171181            iplist[i++] = addr.s_addr;
Note: See TracChangeset for help on using the changeset viewer.