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 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#ifndef _WSPIAPI_H_
#define _WSPIAPI_H_
#include <stdio.h> // sprintf()
#include <stdlib.h> // calloc(), strtoul()
#include <malloc.h> // calloc()
#include <string.h> // strlen(), strcmp(), strstr()
#if defined(__GOT_SECURE_LIB__) && __GOT_SECURE_LIB__ >= 200402L
#define _WSPIAPI_STRCPY_S strcpy_s
#define _WSPIAPI_STRCAT_S strcat_s
#define _WSPIAPI_STRNCPY_S strncpy_s
#define _WSPIAPI_SPRINTF_S_1 sprintf_s
#else
#define _WSPIAPI_STRCPY_S(_Dst, _Size, _Src) strcpy((_Dst), (_Src))
#define _WSPIAPI_STRCAT_S(_Dst, _Size, _Src) strcat((_Dst), (_Src))
#define _WSPIAPI_STRNCPY_S(_Dst, _Size, _Src, _Count) strncpy((_Dst), (_Src), (_Count)); (_Dst)[(_Size) - 1] = 0
#define _WSPIAPI_SPRINTF_S_1(_Dst, _Size, _Format, _Arg1) sprintf((_Dst), (_Format), (_Arg1))
#endif // defined(__GOT_SECURE_LIB__) && __GOT_SECURE_LIB__ >= 200402L
#if !defined(_WSPIAPI_COUNTOF)
#if !defined(__cplusplus)
#define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#else
template < typename __CountofType, size_t _N >
char (&__wspiapi_countof_helper(__CountofType (&_Array)[_N]))[_N];
#define _WSPIAPI_COUNTOF(_Array) sizeof(__wspiapi_countof_helper(_Array))
#endif
#endif
#define WspiapiMalloc(tSize) calloc(1, (tSize))
#define WspiapiFree(p) free(p)
#define WspiapiSwap(a, b, c) { (c) = (a); (a) = (b); (b) = (c); }
#define getaddrinfo WspiapiGetAddrInfo
#define getnameinfo WspiapiGetNameInfo
#define freeaddrinfo WspiapiFreeAddrInfo
typedef int (WINAPI *WSPIAPI_PGETADDRINFO) (
IN const char *nodename,
IN const char *servname,
IN const struct addrinfo *hints,
OUT struct addrinfo **res);
typedef int (WINAPI *WSPIAPI_PGETNAMEINFO) (
IN const struct sockaddr *sa,
IN socklen_t salen,
OUT char *host,
IN size_t hostlen,
OUT char *serv,
IN size_t servlen,
IN int flags);
typedef void (WINAPI *WSPIAPI_PFREEADDRINFO) (
IN struct addrinfo *ai);
#ifdef __cplusplus
extern "C"{
#endif.
.
.
.
.
#ifdef __cplusplus
}
#endif
#endif // _WSPIAPI_H_
|
Partager