Files
Michael Sauer 1b0501179d build: W600-SDK importiert, Firmware-Build und Hello am EVK
Docker-Build mit gcc-arm-none-eabi 4.9-2014q4 (statt Homebrew-Cask) verwendet,
Dockerfile/tools/docker.sh dafür aus Task 13 vorgezogen. cmake/sdk.cmake schont
gcc 4.9 (kennt -fcommon/-Wno-error=... nicht). Zwei zusätzliche SDK-Stubs
(EarlyInit, pre_gpio_config) in src/sys/sdk_stubs.c ergänzt, siehe sdk/PATCHES.md.
2026-09-11 12:52:26 +02:00

122 lines
4.9 KiB
C

#ifndef HTTP_CLIENT_WRAPPER
#define HTTP_CLIENT_WRAPPER
#include "wm_config.h"
#include "lwip/arch.h"
#if TLS_CONFIG_HTTP_CLIENT_SECURE
#include "polarssl/config.h"
#include "polarssl/ssl.h"
#endif
// Compilation mode
//#define _HTTP_BUILD_WIN32 // Set Windows Build flag
///////////////////////////////////////////////////////////////////////////////
//
// Section : Microsoft Windows Support
// Last updated : 01/09/2005
//
///////////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <string.h>
//#include <memory.h>
#include <stdio.h>
#include <ctype.h>
//#include <time.h>
//#include <winsock.h>
#include "wm_type_def.h"
#include "wm_sockets.h"
#include "wm_http_client.h"
// Generic types
// Sockets (Winsock wrapper)
#define HTTP_ECONNRESET (ECONNRESET)
#define HTTP_EINPROGRESS (EINPROGRESS)
#define HTTP_EWOULDBLOCK (EWOULDBLOCK)
#define SOCKET_ERROR (-1)
#define SOCKET_SSL_MORE_DATA (-2)
///////////////////////////////////////////////////////////////////////////////
//
// Section : Functions that are not supported by the AMT stdc framework
// So they had to be specificaly added.
// Last updated : 01/09/2005
//
///////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif
#if TLS_CONFIG_HTTP_CLIENT_SECURE
typedef ssl_context tls_ssl_t;
#endif
// STDC Wrapper implimentation
int HTTPWrapperIsAscii (int c);
int HTTPWrapperToUpper (int c);
int HTTPWrapperToLower (int c);
int HTTPWrapperIsAlpha (int c);
int HTTPWrapperIsAlNum (int c);
char* HTTPWrapperItoa (char *buff,int i);
void HTTPWrapperInitRandomeNumber (void);
long HTTPWrapperGetUpTime (void);
int HTTPWrapperGetRandomeNumber (void);
int HTTPWrapperGetSocketError (int s);
unsigned long HTTPWrapperGetHostByName (char *name,unsigned long *address);
int HTTPWrapperShutDown (int s,int in);
// SSL Wrapper prototypes
#if TLS_CONFIG_HTTP_CLIENT_SECURE
int HTTPWrapperSSLConnect (tls_ssl_t **ssl_p,int s,const struct sockaddr *name,int namelen,char *hostname);
int HTTPWrapperSSLNegotiate (tls_http_session_handle_t pSession,int s,const struct sockaddr *name,int namelen,char *hostname);
int HTTPWrapperSSLSend (tls_ssl_t *ssl,int s,char *buf, int len,int flags);
int HTTPWrapperSSLRecv (tls_ssl_t *ssl,int s,char *buf, int len,int flags);
int HTTPWrapperSSLClose (tls_ssl_t *ssl, int s);
int HTTPWrapperSSLRecvPending (tls_ssl_t *ssl);
#endif
// Global wrapper Functions
#define IToA HTTPWrapperItoa
#define GetUpTime HTTPWrapperGetUpTime
#define SocketGetErr HTTPWrapperGetSocketError
#define HostByName HTTPWrapperGetHostByName
#define InitRandomeNumber HTTPWrapperInitRandomeNumber
#define GetRandomeNumber HTTPWrapperGetRandomeNumber
#ifdef __cplusplus
}
#endif
///////////////////////////////////////////////////////////////////////////////
//
// Section : Global type definitions
// Last updated : 01/09/2005
//
///////////////////////////////////////////////////////////////////////////////
//#ifndef NULL
//#define NULL 0
//#endif
//#define TRUE 1
//#define FALSE 0
#ifdef u_long
#undef u_long
#endif
typedef unsigned long u_long;
// Global socket structures and definitions
#define HTTP_INVALID_SOCKET (-1)
typedef struct sockaddr_in HTTP_SOCKADDR_IN;
typedef struct timeval HTTP_TIMEVAL;
typedef struct hostent HTTP_HOSTNET;
typedef struct sockaddr HTTP_SOCKADDR;
typedef struct in_addr HTTP_INADDR;
#endif // HTTP_CLIENT_WRAPPER