Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
tcp/http/httpsend.c
- Committer:
- andrewboyson
- Date:
- 2019-05-12
- Revision:
- 144:6bd5c54efc7d
- Parent:
- 140:9000ea70b220
File content as of revision 144:6bd5c54efc7d:
#include <time.h>
#include "tcpbuf.h"
int HttpGetLength() { return TcpBufLength(); }
void HttpAddChar (char c) { TcpBufAddChar(c); }
void HttpFillChar (char c, int length) { TcpBufFillChar(c, length); }
int HttpAddText (const char* text) { return TcpBufAddText(text); }
int HttpAddV (char *fmt, va_list argptr) { return TcpBufAddV(fmt, argptr); }
int HttpAddF (char *fmt, ...)
{
va_list argptr;
va_start(argptr, fmt);
int size = TcpBufAddV(fmt, argptr);
va_end(argptr);
return size;
}
void HttpAddData (const char* data, int length) { TcpBufAddData(data, length); }
void HttpAddStream(void (*startFunction)(void), int (*enumerateFunction)(void)) { TcpBufAddStream(startFunction, enumerateFunction);}
void HttpAddNibbleAsHex(int nibble)
{
nibble &= 0x0F;
char c;
if (nibble < 0x0A) c = nibble + '0';
else if (nibble < 0x10) c = nibble - 0xA + 'A';
else c = '0';
HttpAddChar(c);
}
void HttpAddByteAsHex(int value)
{
HttpAddNibbleAsHex(value >> 4);
HttpAddNibbleAsHex(value >> 0);
}
void HttpAddInt12AsHex(int value)
{
HttpAddNibbleAsHex(value >> 8);
HttpAddNibbleAsHex(value >> 4);
HttpAddNibbleAsHex(value >> 0);
}
void HttpAddInt16AsHex(int value)
{
HttpAddNibbleAsHex(value >> 12);
HttpAddNibbleAsHex(value >> 8);
HttpAddNibbleAsHex(value >> 4);
HttpAddNibbleAsHex(value >> 0);
}
void HttpAddInt32AsHex(int value)
{
HttpAddNibbleAsHex(value >> 28);
HttpAddNibbleAsHex(value >> 24);
HttpAddNibbleAsHex(value >> 20);
HttpAddNibbleAsHex(value >> 16);
HttpAddNibbleAsHex(value >> 12);
HttpAddNibbleAsHex(value >> 8);
HttpAddNibbleAsHex(value >> 4);
HttpAddNibbleAsHex(value >> 0);
}
void HttpAddInt64AsHex(int64_t value)
{
HttpAddNibbleAsHex(value >> 60);
HttpAddNibbleAsHex(value >> 56);
HttpAddNibbleAsHex(value >> 52);
HttpAddNibbleAsHex(value >> 48);
HttpAddNibbleAsHex(value >> 44);
HttpAddNibbleAsHex(value >> 40);
HttpAddNibbleAsHex(value >> 36);
HttpAddNibbleAsHex(value >> 32);
HttpAddNibbleAsHex(value >> 28);
HttpAddNibbleAsHex(value >> 24);
HttpAddNibbleAsHex(value >> 20);
HttpAddNibbleAsHex(value >> 16);
HttpAddNibbleAsHex(value >> 12);
HttpAddNibbleAsHex(value >> 8);
HttpAddNibbleAsHex(value >> 4);
HttpAddNibbleAsHex(value >> 0);
}
void HttpAddTm(struct tm* ptm)
{
HttpAddF("%d-%02d-%02d ", ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday);
switch(ptm->tm_wday)
{
case 0: HttpAddText("Sun"); break;
case 1: HttpAddText("Mon"); break;
case 2: HttpAddText("Tue"); break;
case 3: HttpAddText("Wed"); break;
case 4: HttpAddText("Thu"); break;
case 5: HttpAddText("Fri"); break;
case 6: HttpAddText("Sat"); break;
default: HttpAddText("???"); break;
}
HttpAddF(" %02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
if (ptm->tm_isdst > 0) HttpAddText(" BST");
else if (ptm->tm_isdst == 0) HttpAddText(" GMT");
else HttpAddText(" UTC");
}