Barracuda Application Server C/C++ Reference
NO
BaServerLib.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: BaServerLib.h 5355 2022-11-16 10:33:45Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2002 - 2021
17 *
18 * This software is copyrighted by and is the sole property of Real
19 * Time Logic LLC. All rights, title, ownership, or other interests in
20 * the software remain the property of Real Time Logic LLC. This
21 * software may only be used in accordance with the terms and
22 * conditions stipulated in the corresponding license agreement under
23 * which the software has been supplied. Any unauthorized use,
24 * duplication, transmission, distribution, or disclosure of this
25 * software is expressly forbidden.
26 *
27 * This Copyright notice may not be removed or modified without prior
28 * written consent of Real Time Logic LLC.
29 *
30 * Real Time Logic LLC. reserves the right to modify this software
31 * without notice.
32 *
33 * http://www.realtimelogic.com
34 ****************************************************************************
35 *
36 *
37 */
38
39
40#ifndef __httpServerLib_h
41#define __httpServerLib_h
42
43#include <TargConfig.h>
44#include <AllocatorIntf.h>
45#include <ctype.h>
46#include <stddef.h>
47
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53
67#ifdef INL_baConvBin2Hex
68
69extern const char baBin2HexTable[]; /* =
70 {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
71 'a', 'b', 'c', 'd', 'e', 'f'}; */
72
73#define baConvBin2Hex(hexOutData, binIn) \
74 hexOutData[0] = baBin2HexTable[((U8)binIn) >> 4], \
75 hexOutData[1] = baBin2HexTable[((U8)binIn) & 0x0f]
76
77#else
78
79BA_API void baConvBin2Hex(void* hexOutData, U8 binIn);
80
81#endif
82
83
84BA_API U8 baConvHex2Bin( U8 c );
85BA_API void baConvU32ToHex(void* to, U32 from);
86BA_API U32 baConvHexToU32(const void* from);
87
88
92BA_API char* baStrdup(const char* str);
93
99BA_API const void* baBSearch(const void* key, const void* base, int num,
100 int size, int (*cmp)(const void*,const void*));
101
104BA_API int baStrCaseCmp(const char *a, const char *b);
105
108BA_API int baStrnCaseCmp(const char *a, const char *b, size_t len);
109
110const char* baGetToken(const char** str, const char* set);
111
116BA_API BaTime baParseDate(const char* str);
117
118
122BA_API int baB64Decode(
123 unsigned char* outStr,int outStrSize,const char* b64EncStr);
124
127BA_API int baElideDotDot(char* str);
128
129BA_API void baXmlUnescape(char* f);
130
131#if defined(_WIN32) && !defined(NDEBUG)
132/* Bug in VC++ */
133#undef bIsspace
134#define bIsspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||\
135 c == '\t' || c == '\v')
136#endif
137
138#define httpEatWhiteSpace(ptr) while(bIsspace((U8)*ptr)) (ptr)++
139#define httpEatNonWhiteSpace(ptr) while(!bIsspace((U8)*ptr)) (ptr)++
140#define httpEatCharacters(ptr, delimiter) \
141 while(*ptr && *ptr != delimiter) (ptr)++
142
148struct BaTm
149{
166
168 int nsec;
171};
172
173BA_API U8 baDaysInMonth(U16 y, U16 m);
174
179BA_API int baTime2tm(struct BaTm *tmP, BaTime t);
180BA_API int baTime2tmEx(const BaTimeEx* tex, const BaBool local, struct BaTm* tm);
181
182
187BA_API BaTime baTm2Time(struct BaTm* tmP);
188BA_API int baTm2TimeEx(struct BaTm* tm, BaBool local, BaTimeEx* tex);
189
191BA_API int baISO8601ToTime(const char *str, size_t len, BaTimeEx *tex);
192
193
195BA_API int baTime2ISO8601(const BaTimeEx* tex, char* str, size_t len);
196
197 /* end of UtilityFunctions */
199
200
201#ifdef __cplusplus
202}
203#endif
204
205
212#ifdef __DOXYGEN__
213/* For documentation only */
214
218void* baMalloc(size_t size);
219
225void* baRealloc(void* p, size_t size);
226
227
230void baFree(void* p);
231
232#endif /* __DOXYGEN__ */
233
234 /* end of DynamicMemory */
236
237#endif
void * baRealloc(void *p, size_t size)
Returns pointer to newly-allocated space for an object of size "size", initialized,...
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
void baFree(void *p)
Deallocates space to which it points.
BA_API int baElideDotDot(char *str)
Fix a path with ../ in it.
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
BA_API BaTime baParseDate(const char *str)
Parses the date string 'str' and returns the time with epoch of 1970-01-01 00:00:10 GMT.
BA_API int baB64Decode(unsigned char *outStr, int outStrSize, const char *b64EncStr)
Decodes a B64 encoded string.
BA_API char * baStrdup(const char *str)
Calls baMalloc to allocate storage space for a copy of str and then copies src to the allocated space...
BA_API int baISO8601ToTime(const char *str, size_t len, BaTimeEx *tex)
Parse ISO860 time.
BA_API BaTime baTm2Time(struct BaTm *tmP)
Convert a BaTm structure to BaTime.
BA_API int baStrCaseCmp(const char *a, const char *b)
Compare two strings, ignoring case.
BA_API const void * baBSearch(const void *key, const void *base, int num, int size, int(*cmp)(const void *, const void *))
Returns a pointer to an occurrence of key in the array pointed to by base.
BA_API int baTime2ISO8601(const BaTimeEx *tex, char *str, size_t len)
Return ISO860 encoded string.
BA_API int baStrnCaseCmp(const char *a, const char *b, size_t len)
Compare two strings with max length 'len', ignoring case.
BA_API int baTime2tm(struct BaTm *tmP, BaTime t)
Convert BaTime to a BaTm structure.
Extended BaTime with nano-seconds and timezone offset in minutes.
Definition: GenPrimT.h:98
Represents the components of calendar time.
Definition: BaServerLib.h:149
int tm_yday
days since January 1
Definition: BaServerLib.h:165
int tm_wday
days since Sunday [0,6]
Definition: BaServerLib.h:163
int tm_mon
months since January [0,11]
Definition: BaServerLib.h:159
int tm_sec
seconds after the minute [0,59]
Definition: BaServerLib.h:151
int tm_year
Years since 0000 (baTime2tmEx) or since 1900 (baTime2tm)
Definition: BaServerLib.h:161
int offset
Time zone offset in minutes.
Definition: BaServerLib.h:170
int tm_hour
hours since midnight [0,23]
Definition: BaServerLib.h:155
int tm_min
minutes after the hour [0,59]
Definition: BaServerLib.h:153
int tm_mday
day of the month [0,31]
Definition: BaServerLib.h:157
int nsec
Nano seconds.
Definition: BaServerLib.h:168