Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
CspRunTm.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: CspRunTm.h 5978 2026-09-11 16:13:48Z wini $
15 *
16 * COPYRIGHT: Real Time Logic, 2006 - 2023
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 */
40#ifndef __CspRunTm_h
41#define __CspRunTm_h
42
43#include "HttpServer.h"
44#ifndef SharkSslStandalone
45#include "CspCompileCommon.h"
46#endif
47
48/* Struct for building a minimum GZIP header. See RFC 1952 for GZIP format.
49 * We do not need FLG.FEXTRA, FLG.FNAME, FLG.FCOMMENT & FLG.FHCRC
50 *
51 * <--------------- GZIP header ---------->
52 * +---+---+---+---+---+---+---+---+---+---+=============+--4--+---4--+
53 * |ID1|ID2|CM |FLG| MTIME |XFL|OS | compr block | crc | size |
54 * +---+---+---+---+---+---+---+---+---+---+=============+--4--+------+
55 */
56#ifndef __DOXYGEN__
57struct GzipHeader
58{
59 U8 id1;
60 U8 id2;
61 U8 compressionMethod;
62 U8 flags;
63 U8 unixTime[4];
64 U8 extraflag; /* Compression type */
65 U8 operatingSystem;
66}
67#ifdef __GNUC__
68__attribute__((__packed__))
69#endif
70;
71
72typedef struct GzipHeader GzipHeader;
73#endif
74
75#define FLG_FTEXT ( 1 << 0 )
76#define FLG_FHCRC ( 1 << 1 )
77#define FLG_FEXTRA ( 1 << 2 )
78#define FLG_FNAME ( 1 << 3 )
79#define FLG_FCOMMENT ( 1 << 4 )
80
81#ifndef __DOXYGEN__
82struct GzipTrailer
83{
84 U8 crc[4];
85 U8 uncompressedSize[4];
86}
87#ifdef __GNUC__
88__attribute__((__packed__))
89#endif
90;
91
92typedef struct GzipTrailer GzipTrailer;
93#endif
94
95struct CspReader;
96
97
115typedef int (*CspReader_Read)(
116 struct CspReader* o, void* data, U32 offset, U32 size, int blockStart);
117
118#define CspReader_validFlag 0xA503
119
125typedef struct CspReader
126{
127#ifdef __cplusplus
128 void *operator new(size_t s) { return ::baMalloc(s); }
129 void operator delete(void* d) { if(d) ::baFree(d); }
130 void *operator new(size_t, void *place) { return place; }
131 void operator delete(void*, void *) { }
132
136 bool isValid();
144 int read(void* data, U32 offset, U32 size, bool blockStart);
147 void setIsValid() { validFlag=CspReader_validFlag; }
148 private:
149#endif
150 CspReader_Read readCB;
151 U16 validFlag;
153
154#ifdef __cplusplus
155extern "C" {
156#endif
162#define CspReader_constructor(o, httpDiskRead) do {\
163 (o)->readCB = httpDiskRead; \
164 (o)->validFlag = (U16)~CspReader_validFlag; \
165}while(0)
166
170#define CspReader_isValid(o) (((CspReader*)o)->readCB != 0 && \
171 ((CspReader*)o)->validFlag == CspReader_validFlag)
175#define CspReader_setIsValid(o) ((CspReader*)o)->validFlag=CspReader_validFlag
179#define CspReader_read(httpData, data, offset, size, blockStart) \
180 (*((CspReader*)httpData)->readCB)((CspReader*)httpData, data, \
181 offset, size, blockStart)
182#ifdef __cplusplus
183}
184inline bool CspReader::isValid() {
185 return CspReader_isValid(this) ? true : false;
186}
187inline int CspReader::read(void* data, U32 offset, U32 size, bool blockStart) {
188 return CspReader_read(this, data, offset, size, blockStart);
189}
190#endif
191
192#ifndef SharkSslStandalone
193
194#ifndef __DOXYGEN__
195typedef struct HttpStaticMemPage
196{
197 HttpPage page;
198 CspReader* data;
199 U32 time;
200 HttpDiskBlock mimeBlock;
201 HttpDiskBlock payloadBlock;
202 char isCompressed;
203} HttpStaticMemPage;
204#endif
205
206#ifdef __cplusplus
207extern "C" {
208#endif
209BA_API int httpWriteSection(
210 CspReader* data, HttpResponse* reply,U32 offset,U32 size);
211BA_API int httpUnzipAndWrite(CspReader* data,
212 HttpResponse* response,
213 U32 offset,
214 U32 size,
215 GzipHeader* gzipH);
216BA_API void httpRawWrite(CspReader* data,
217 HttpRequest* request,
218 HttpResponse* response,
219 U32 time,
220 U32 offset,
221 U32 size,
222 GzipHeader* gzipH,
223 GzipTrailer* gzipT);
224
225BA_API int cspCheckCondition(HttpRequest* request, HttpResponse* response);
226
227BA_API void HttpStaticMemPage_loadAndInit(HttpStaticMemPage* o,
228 CspReader* data, U32 time,
229 U32 nameOffset, U32 nameSize,
230 U32 mimeOffset, U32 mimeSize,
231 U32 payloadOffset, U32 payloadSize,
232 char isCompressed, HttpDir* parent);
233
234BA_API void HttpDynamicMemPage_loadAndInit(
235 HttpPage* o, CspReader* data, U32 size,
236 HttpPage_Service fptr,
237 U32 nameOffset, U32 nameSize);
238#ifdef __cplusplus
239}
240#endif
241
242#endif
243
244#endif /* __CspRunTm_h */
245
246
247
248
249
#define CspReader_isValid(o)
Definition: CspRunTm.h:170
struct CspReader CspReader
Abstract interface class for reading the "dat" file generated by HttpLink.
#define CspReader_read(httpData, data, offset, size, blockStart)
Invoke the installed CspReader_Read callback synchronously.
Definition: CspRunTm.h:179
int(* CspReader_Read)(struct CspReader *o, void *data, U32 offset, U32 size, int blockStart)
Prototype for the CspReader callback function.
Definition: CspRunTm.h:115
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
void(* HttpPage_Service)(struct HttpPage *page, HttpRequest *request, HttpResponse *response)
The HttpPage service function.
Definition: HttpServer.h:2589
uint16_t U16
Unsigned 16-bit integer.
Definition: GenPrimT.h:91
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
Abstract interface class for reading the "dat" file generated by HttpLink.
Definition: CspRunTm.h:126
void setIsValid()
Mark the implementation initialized after opening/checking its data.
Definition: CspRunTm.h:147
bool isValid()
Definition: CspRunTm.h:184
int read(void *data, U32 offset, U32 size, bool blockStart)
Invoke the installed CspReader_Read callback synchronously.
Definition: CspRunTm.h:187
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2777
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2656
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:950
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1379