ZenLib
HTTPClientWrapper.h
Go to the documentation of this file.
1 
2 #ifndef HTTP_CLIENT_WRAPPER
3 #define HTTP_CLIENT_WRAPPER
4 
5 // Compilation mode
6 #define _HTTP_BUILD_WIN32 // Set Windows Build flag
7 
8 ///////////////////////////////////////////////////////////////////////////////
9 //
10 // Section : Microsoft Windows Support
11 // Last updated : 01/09/2005
12 //
13 ///////////////////////////////////////////////////////////////////////////////
14 
15 #ifdef _HTTP_BUILD_WIN32
16 
17 #if defined(_MSC_VER)
18  #pragma warning (disable: 4996) // 'function': was declared deprecated (VS 2005)
19 #endif
20 #include <stdlib.h>
21 #include <string.h>
22 #include <memory.h>
23 #include <stdio.h>
24 #include <ctype.h>
25 #include <time.h>
26 #if defined(_WIN32) || defined(WIN32)
27  #ifdef WINDOWS_UWP
28  #include <winsock2.h>
29  #else
30  #include <winsock.h>
31  #endif
32 #endif
33 
34 // Generic types
35 typedef unsigned int UINT32;
36 typedef int INT32;
37 
38 // Sockets (Winsock wrapper)
39 #define HTTP_ECONNRESET (WSAECONNRESET)
40 #define HTTP_EINPROGRESS (WSAEINPROGRESS)
41 #define HTTP_EWOULDBLOCK (WSAEWOULDBLOCK)
42 #endif
43 
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 //
47 // Section : Functions that are not supported by the AMT stdc framework
48 // So they had to be specificaly added.
49 // Last updated : 01/09/2005
50 //
51 ///////////////////////////////////////////////////////////////////////////////
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56  // STDC Wrapper implimentation
57  int HTTPWrapperIsAscii (int c);
58  int HTTPWrapperToUpper (int c);
59  int HTTPWrapperToLower (int c);
60  int HTTPWrapperIsAlpha (int c);
61  int HTTPWrapperIsAlNum (int c);
62  char* HTTPWrapperItoa (char *buff,int i);
67  unsigned long HTTPWrapperGetHostByName (char *name,unsigned long *address);
68  int HTTPWrapperShutDown (int s,int in);
69  // SSL Wrapper prototypes
70  int HTTPWrapperSSLConnect (int s,const struct sockaddr *name,int namelen,char *hostname);
71  int HTTPWrapperSSLNegotiate (int s,const struct sockaddr *name,int namelen,char *hostname);
72  int HTTPWrapperSSLSend (int s,char *buf, int len,int flags);
73  int HTTPWrapperSSLRecv (int s,char *buf, int len,int flags);
74  int HTTPWrapperSSLClose (int s);
76  // Global wrapper Functions
77 #define IToA HTTPWrapperItoa
78 #define GetUpTime HTTPWrapperGetUpTime
79 #define SocketGetErr HTTPWrapperGetSocketError
80 #define HostByName HTTPWrapperGetHostByName
81 #define InitRandomeNumber HTTPWrapperInitRandomeNumber
82 #define GetRandomeNumber HTTPWrapperGetRandomeNumber
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 ///////////////////////////////////////////////////////////////////////////////
89 //
90 // Section : Global type definitions
91 // Last updated : 01/09/2005
92 //
93 ///////////////////////////////////////////////////////////////////////////////
94 
95 #define VOID void
96 #ifndef NULL
97 #define NULL 0
98 #endif
99 #define TRUE 1
100 #define FALSE 0
101 typedef char CHAR;
102 typedef unsigned short UINT16;
103 typedef int BOOL;
104 typedef unsigned long ULONG;
105 
106 // Global socket structures and definitions
107 #define HTTP_INVALID_SOCKET (-1)
108 typedef struct sockaddr_in HTTP_SOCKADDR_IN;
109 typedef struct timeval HTTP_TIMEVAL;
110 typedef struct hostent HTTP_HOSTNET;
111 typedef struct sockaddr HTTP_SOCKADDR;
112 typedef struct in_addr HTTP_INADDR;
113 
114 
115 #endif // HTTP_CLIENT_WRAPPER
HTTPWrapperToLower
int HTTPWrapperToLower(int c)
HTTPWrapperSSLConnect
int HTTPWrapperSSLConnect(int s, const struct sockaddr *name, int namelen, char *hostname)
HTTPWrapperGetHostByName
unsigned long HTTPWrapperGetHostByName(char *name, unsigned long *address)
HTTPWrapperInitRandomeNumber
void HTTPWrapperInitRandomeNumber()
UINT32
unsigned int UINT32
Definition: HTTPClientWrapper.h:35
HTTPWrapperSSLRecv
int HTTPWrapperSSLRecv(int s, char *buf, int len, int flags)
HTTP_SOCKADDR
struct sockaddr HTTP_SOCKADDR
Definition: HTTPClientWrapper.h:111
HTTPWrapperIsAscii
int HTTPWrapperIsAscii(int c)
HTTPWrapperSSLSend
int HTTPWrapperSSLSend(int s, char *buf, int len, int flags)
UINT16
unsigned short UINT16
Definition: HTTPClientWrapper.h:102
HTTPWrapperToUpper
int HTTPWrapperToUpper(int c)
HTTPWrapperGetRandomeNumber
int HTTPWrapperGetRandomeNumber()
HTTPWrapperIsAlpha
int HTTPWrapperIsAlpha(int c)
HTTP_SOCKADDR_IN
struct sockaddr_in HTTP_SOCKADDR_IN
Definition: HTTPClientWrapper.h:108
HTTPWrapperGetSocketError
int HTTPWrapperGetSocketError(int s)
HTTP_HOSTNET
struct hostent HTTP_HOSTNET
Definition: HTTPClientWrapper.h:110
HTTPWrapperShutDown
int HTTPWrapperShutDown(int s, int in)
HTTPWrapperSSLNegotiate
int HTTPWrapperSSLNegotiate(int s, const struct sockaddr *name, int namelen, char *hostname)
HTTPWrapperSSLClose
int HTTPWrapperSSLClose(int s)
HTTPWrapperIsAlNum
int HTTPWrapperIsAlNum(int c)
INT32
int INT32
Definition: HTTPClientWrapper.h:36
HTTPWrapperSSLRecvPending
int HTTPWrapperSSLRecvPending(int s)
CHAR
char CHAR
Definition: HTTPClientWrapper.h:101
HTTP_TIMEVAL
struct timeval HTTP_TIMEVAL
Definition: HTTPClientWrapper.h:109
BOOL
int BOOL
Definition: HTTPClientWrapper.h:103
ULONG
unsigned long ULONG
Definition: HTTPClientWrapper.h:104
HTTP_INADDR
struct in_addr HTTP_INADDR
Definition: HTTPClientWrapper.h:112
HTTPWrapperItoa
char * HTTPWrapperItoa(char *buff, int i)
HTTPWrapperGetUpTime
long HTTPWrapperGetUpTime()