Eneboo - Documentación para desarrolladores
src/libpq/include/getaddrinfo.h
Ir a la documentación de este archivo.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * getaddrinfo.h
00004  *        Support getaddrinfo() on platforms that don't have it.
00005  *
00006  * Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO,
00007  * whether or not the library routine getaddrinfo() can be found.  This
00008  * policy is needed because on some platforms a manually installed libbind.a
00009  * may provide getaddrinfo(), yet the system headers may not provide the
00010  * struct definitions needed to call it.  To avoid conflict with the libbind
00011  * definition in such cases, we rename our routines to pg_xxx() via macros.
00012  *
00013  * This code will also work on platforms where struct addrinfo is defined
00014  * in the system headers but no getaddrinfo() can be located.
00015  *
00016  * Copyright (c) 2003-2005, PostgreSQL Global Development Group
00017  *
00018  * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.17.2.1 2005/12/08 17:52:20 momjian Exp $
00019  *
00020  *-------------------------------------------------------------------------
00021  */
00022 #ifndef GETADDRINFO_H
00023 #define GETADDRINFO_H
00024 
00025 #ifndef WIN32_CLIENT_ONLY
00026 #include <sys/socket.h>
00027 #include <netdb.h>
00028 #endif
00029 
00030 
00031 /* Various macros that ought to be in <netdb.h>, but might not be */
00032 
00033 #ifndef EAI_FAIL
00034 #ifndef WIN32
00035 #define EAI_BADFLAGS    (-1)
00036 #define EAI_NONAME              (-2)
00037 #define EAI_AGAIN               (-3)
00038 #define EAI_FAIL                (-4)
00039 #define EAI_FAMILY              (-6)
00040 #define EAI_SOCKTYPE    (-7)
00041 #define EAI_SERVICE             (-8)
00042 #define EAI_MEMORY              (-10)
00043 #define EAI_SYSTEM              (-11)
00044 #else                                                   /* WIN32 */
00045 #if defined(WIN32_CLIENT_ONLY)
00046 #define WSA_NOT_ENOUGH_MEMORY   (WSAENOBUFS)
00047 #define WSATYPE_NOT_FOUND       (WSABASEERR+109)
00048 #endif
00049 #define EAI_AGAIN               WSATRY_AGAIN
00050 #define EAI_BADFLAGS    WSAEINVAL
00051 #define EAI_FAIL                WSANO_RECOVERY
00052 #define EAI_FAMILY              WSAEAFNOSUPPORT
00053 #define EAI_MEMORY              WSA_NOT_ENOUGH_MEMORY
00054 #define EAI_NODATA              WSANO_DATA
00055 #define EAI_NONAME              WSAHOST_NOT_FOUND
00056 #define EAI_SERVICE             WSATYPE_NOT_FOUND
00057 #define EAI_SOCKTYPE    WSAESOCKTNOSUPPORT
00058 #endif   /* !WIN32 */
00059 #endif   /* !EAI_FAIL */
00060 
00061 #ifndef AI_PASSIVE
00062 #define AI_PASSIVE              0x0001
00063 #endif
00064 
00065 #ifndef AI_NUMERICHOST
00066 /*
00067  * some platforms don't support AI_NUMERICHOST; define as zero if using
00068  * the system version of getaddrinfo...
00069  */
00070 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
00071 #define AI_NUMERICHOST  0
00072 #else
00073 #define AI_NUMERICHOST  0x0004
00074 #endif
00075 #endif
00076 
00077 #ifndef NI_NUMERICHOST
00078 #define NI_NUMERICHOST  1
00079 #endif
00080 #ifndef NI_NUMERICSERV
00081 #define NI_NUMERICSERV  2
00082 #endif
00083 
00084 #ifndef NI_MAXHOST
00085 #define NI_MAXHOST      1025
00086 #endif
00087 #ifndef NI_MAXSERV
00088 #define NI_MAXSERV      32
00089 #endif
00090 
00091 
00092 #ifndef HAVE_STRUCT_ADDRINFO
00093 
00094 struct addrinfo
00095 {
00096         int                     ai_flags;
00097         int                     ai_family;
00098         int                     ai_socktype;
00099         int                     ai_protocol;
00100         size_t          ai_addrlen;
00101         struct sockaddr *ai_addr;
00102         char       *ai_canonname;
00103         struct addrinfo *ai_next;
00104 };
00105 #endif   /* HAVE_STRUCT_ADDRINFO */
00106 
00107 
00108 #ifndef HAVE_GETADDRINFO
00109 
00110 /* Rename private copies per comments above */
00111 #ifdef getaddrinfo
00112 #undef getaddrinfo
00113 #endif
00114 #define getaddrinfo pg_getaddrinfo
00115 
00116 #ifdef freeaddrinfo
00117 #undef freeaddrinfo
00118 #endif
00119 #define freeaddrinfo pg_freeaddrinfo
00120 
00121 #ifdef gai_strerror
00122 #undef gai_strerror
00123 #endif
00124 #define gai_strerror pg_gai_strerror
00125 
00126 #ifdef getnameinfo
00127 #undef getnameinfo
00128 #endif
00129 #define getnameinfo pg_getnameinfo
00130 
00131 extern int getaddrinfo(const char *node, const char *service,
00132                         const struct addrinfo * hints, struct addrinfo ** res);
00133 extern void freeaddrinfo(struct addrinfo * res);
00134 extern const char *gai_strerror(int errcode);
00135 extern int getnameinfo(const struct sockaddr * sa, int salen,
00136                         char *node, int nodelen,
00137                         char *service, int servicelen, int flags);
00138 #endif   /* HAVE_GETADDRINFO */
00139 
00140 #endif   /* GETADDRINFO_H */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'