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 4915 2021-12-01 18:26:55Z 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
50 extern "C" {
51 #endif
52 
53 
67 #ifdef INL_baConvBin2Hex
68 
69 extern 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 
79 BA_API void baConvBin2Hex(void* hexOutData, U8 binIn);
80 
81 #endif
82 
83 
84 BA_API U8 baConvHex2Bin( U8 c );
85 BA_API void baConvU32ToHex(void* to, U32 from);
86 BA_API U32 baConvHexToU32(const void* from);
87 
88 
92 BA_API char* baStrdup(const char* str);
93 
99 BA_API const void* baBSearch(const void* key, const void* base, int num,
100  int size, int (*cmp)(const void*,const void*));
101 
104 BA_API int baStrCaseCmp(const char *a, const char *b);
105 
108 BA_API int baStrnCaseCmp(const char *a, const char *b, size_t len);
109 
110 const char* baGetToken(const char** str, const char* set);
111 
116 BA_API BaTime baParseDate(const char* str);
117 
118 
122 BA_API int baB64Decode(
123  unsigned char* outStr,int outStrSize,const char* b64EncStr);
124 
127 BA_API int baElideDotDot(char* str);
128 
129 BA_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 
148 struct BaTm
149 {
151  int tm_sec;
153  int tm_min;
155  int tm_hour;
157  int tm_mday;
159  int tm_mon;
161  int tm_year;
163  int tm_wday;
165  int tm_yday;
166 
168  int nsec;
170  int offset;
171 };
172 
173 BA_API U8 baDaysInMonth(U16 y, U16 m);
174 
179 BA_API int baTime2tm(struct BaTm *tmP, BaTime t);
180 BA_API int baTime2tmEx(const BaTimeEx* tex, const BaBool local, struct BaTm* tm);
181 
182 
187 BA_API BaTime baTm2Time(struct BaTm* tmP);
188 BA_API int baTm2TimeEx(struct BaTm* tm, BaBool local, BaTimeEx* tex);
189 
191 BA_API int baISO8601ToTime(const char *str, size_t len, BaTimeEx *tex);
192 
193 
195 BA_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 
218 void* baMalloc(size_t size);
219 
225 void* baRealloc(void* p, size_t size);
226 
227 
230 void baFree(void* p);
231 
232 #endif /* __DOXYGEN__ */
233 
234  /* end of DynamicMemory */
236 
237 #endif
BaTimeEx
Extended BaTime with nano-seconds and timezone offset in minutes.
Definition: GenPrimT.h:98
baRealloc
void * baRealloc(void *p, size_t size)
Returns pointer to newly-allocated space for an object of size "size", initialized,...
baStrCaseCmp
BA_API int baStrCaseCmp(const char *a, const char *b)
Compare two strings, ignoring case.
BaTm::tm_year
int tm_year
Years since 0000 (baTime2tmEx) or since 1900 (baTime2tm)
Definition: BaServerLib.h:161
BaTm::tm_mday
int tm_mday
day of the month [0,31]
Definition: BaServerLib.h:157
baTime2tm
BA_API int baTime2tm(struct BaTm *tmP, BaTime t)
Convert BaTime to a BaTm structure.
baTime2ISO8601
BA_API int baTime2ISO8601(const BaTimeEx *tex, char *str, size_t len)
Return ISO860 encoded string.
baTm2Time
BA_API BaTime baTm2Time(struct BaTm *tmP)
Convert a BaTm structure to BaTime.
BaTm::tm_hour
int tm_hour
hours since midnight [0,23]
Definition: BaServerLib.h:155
BaTm
Represents the components of calendar time.
Definition: BaServerLib.h:149
baElideDotDot
BA_API int baElideDotDot(char *str)
Fix a path with ../ in it.
baStrdup
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...
BaTime
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
baISO8601ToTime
BA_API int baISO8601ToTime(const char *str, size_t len, BaTimeEx *tex)
Parse ISO860 time.
baParseDate
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.
baFree
void baFree(void *p)
Deallocates space to which it points.
baMalloc
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
BaTm::tm_sec
int tm_sec
seconds after the minute [0,59]
Definition: BaServerLib.h:151
baBSearch
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.
baB64Decode
BA_API int baB64Decode(unsigned char *outStr, int outStrSize, const char *b64EncStr)
Decodes a B64 encoded string.
BaTm::tm_mon
int tm_mon
months since January [0,11]
Definition: BaServerLib.h:159
BaTm::tm_min
int tm_min
minutes after the hour [0,59]
Definition: BaServerLib.h:153
BaTm::offset
int offset
Time zone offset in minutes.
Definition: BaServerLib.h:170
BaTm::nsec
int nsec
Nano seconds.
Definition: BaServerLib.h:168
BaTm::tm_wday
int tm_wday
days since Sunday [0,6]
Definition: BaServerLib.h:163
BaTm::tm_yday
int tm_yday
days since January 1
Definition: BaServerLib.h:165
baStrnCaseCmp
BA_API int baStrnCaseCmp(const char *a, const char *b, size_t len)
Compare two strings with max length 'len', ignoring case.