newlib/winsup/cygwin/libc/minires.h

67 lines
1.9 KiB
C
Raw Normal View History

/* minires.h. Stub synchronous resolver for Cygwin.
Copyright 2006, 2008, 2012 Red Hat, Inc.
Written by Pierre A. Humblet <Pierre.Humblet@ieee.org>
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/unistd.h>
In terms of network related functionality, rely on Winsock definitions as much as possible: * dtable.cc: Drop including sys/socket.h. * fhandler_procnet.cc: Change includes accordingly. * fhandler_socket.cc: Ditto. (fhandler_socket::listen): Avoid gcc error message initializing sin6. (LPFN_WSARECVMSG): Only define when building against w32api headers. * net.cc: Change includes accordingly. Define USE_SYS_TYPES_FD_SET and __WSA_ERR_MACROS_DEFINED. Define _INC_NETIOAPI temporarily and explain why. (struct _IP_ADAPTER_UNICAST_ADDRESS_LH): Only define when building against w32api headers. (struct _IP_ADAPTER_ADDRESSES_LH): Ditto. (SIO_GET_INTERFACE_LIST): Ditto. (ws_freeaddrinfo): Rename from freeaddrinfo so as not to collide with Winsock declaration. Change througout. (ws_getaddrinfo): Ditto. (ws_getnameinfo): Ditto. * select.cc: Include netdb.h after defining USE_SYS_TYPES_FD_SET. * syslog.cc: Drop including netinet/in.h. Define USE_SYS_TYPES_FD_SET and include ws2tcpip.h. * include/netdb.h (struct addrinfo): Don't define when building Cygwin. * include/cygwin/if.h: Don't declare if_xxx functions when building Cygwin. * include/cygwin/in.h: Disable most definitions when building Cygwin. * include/cygwin/socket.h: Disable sockaddr and sockaddr_storage definitions when building Cygwin. Same for MCAST_INCLUDE/MCAST_EXCLUDE. * libc/inet_addr.c: Don't define __INSIDE_CYGWIN__ nor __INSIDE_CYGWIN_NET__. * libc/inet_network.c: Ditto. * libc/minires.h: Drop redundant inclusion of netdb.h. Define __INSIDE_CYGWIN_NET__ only before including netdb.h and resolver headers.
2012-07-06 15:52:19 +02:00
#define __INSIDE_CYGWIN_NET__
#include <netdb.h>
#include <arpa/nameser.h>
#include <resolv.h>
extern in_addr_t cygwin_inet_addr (const char *);
extern int cygwin_socket (int, int, int);
extern int cygwin_bind (int, const struct sockaddr *, socklen_t);
extern int cygwin_connect (int, const struct sockaddr *, socklen_t);
extern int cygwin_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
extern int cygwin_sendto (int, const void *, size_t, int,
const struct sockaddr *, socklen_t);
extern int cygwin_recvfrom (int, void *, size_t, int, struct sockaddr *,
socklen_t *);
/* Number of elements is an array */
#define DIM(x) (sizeof(x) / sizeof(*(x)))
/* Definitions to parse the messages */
#define RD (1<<8) /* Offset in a short */
#define RA (1<<7)
#define QR (1<<7) /* Offsets in a char */
#define TC (1<<1)
#define ERR_MASK 0xF
/* Type for os specific res_lookup */
typedef int (os_query_t) (res_state, const char *, int, int, u_char *, int);
/* Special use of state elements */
#define sockfd _vcsock
#define mypid _flags
#define os_query qhook
#define use_os pfcode
#define DPRINTF(cond, format...) if (cond) minires_dprintf(format)
/* Utility functions */
void minires_dprintf(const char * format, ...);
void minires_get_search(char * string, res_state statp);
void get_dns_info(res_state statp);