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