Barracuda Application Server C/C++ Reference
NO
CspRunTm.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: CspRunTm.h 5670 2025-10-06 21:06:24Z 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 */
38#ifndef __CspRunTm_h
39#define __CspRunTm_h
40
41#include "HttpServer.h"
42#ifndef SharkSslStandalone
43#include "CspCompileCommon.h"
44#endif
45
46/* Struct for building a minimum GZIP header. See RFC 1952 for GZIP format.
47 * We do not need FLG.FEXTRA, FLG.FNAME, FLG.FCOMMENT & FLG.FHCRC
48 *
49 * <--------------- GZIP header ---------->
50 * +---+---+---+---+---+---+---+---+---+---+=============+--4--+---4--+
51 * |ID1|ID2|CM |FLG| MTIME |XFL|OS | compr block | crc | size |
52 * +---+---+---+---+---+---+---+---+---+---+=============+--4--+------+
53 */
54#ifndef __DOXYGEN__
55struct GzipHeader
56{
57 U8 id1;
58 U8 id2;
59 U8 compressionMethod;
60 U8 flags;
61 U8 unixTime[4];
62 U8 extraflag; /* Compression type */
63 U8 operatingSystem;
64}
65#ifdef __GNUC__
66__attribute__((__packed__))
67#endif
68;
69
70typedef struct GzipHeader GzipHeader;
71#endif
72
73#define FLG_FTEXT ( 1 << 0 )
74#define FLG_FHCRC ( 1 << 1 )
75#define FLG_FEXTRA ( 1 << 2 )
76#define FLG_FNAME ( 1 << 3 )
77#define FLG_FCOMMENT ( 1 << 4 )
78
79#ifndef __DOXYGEN__
80struct GzipTrailer
81{
82 U8 crc[4];
83 U8 uncompressedSize[4];
84}
85#ifdef __GNUC__
86__attribute__((__packed__))
87#endif
88;
89
90typedef struct GzipTrailer GzipTrailer;
91#endif
92
93struct CspReader;
94
95
107typedef int (*CspReader_Read)(
108 struct CspReader* o, void* data, U32 offset, U32 size, int blockStart);
109
110#define CspReader_validFlag 0xA503
111
117typedef struct CspReader
118{
119#ifdef __cplusplus
120 void *operator new(size_t s) { return ::baMalloc(s); }
121 void operator delete(void* d) { if(d) ::baFree(d); }
122 void *operator new(size_t, void *place) { return place; }
123 void operator delete(void*, void *) { }
124
126 bool isValid();
127 int read(void* data, U32 offset, U32 size, bool blockStart);
128 void setIsValid() { validFlag=CspReader_validFlag; }
129 private:
130#endif
131 CspReader_Read readCB;
132 U16 validFlag;
133} CspReader;
134
135#ifdef __cplusplus
136extern "C" {
137#endif
138#define CspReader_constructor(o, httpDiskRead) do {\
139 (o)->readCB = httpDiskRead; \
140 (o)->validFlag = (U16)~CspReader_validFlag; \
141}while(0)
142
143#define CspReader_isValid(o) (((CspReader*)o)->readCB != 0 && \
144 ((CspReader*)o)->validFlag == CspReader_validFlag)
145#define CspReader_setIsValid(o) ((CspReader*)o)->validFlag=CspReader_validFlag
146#define CspReader_read(httpData, data, offset, size, blockStart) \
147 (*((CspReader*)httpData)->readCB)((CspReader*)httpData, data, \
148 offset, size, blockStart)
149#ifdef __cplusplus
150}
151inline bool CspReader::isValid() {
152 return CspReader_isValid(this) ? true : false;
153}
154inline int CspReader::read(void* data, U32 offset, U32 size, bool blockStart) {
155 return CspReader_read(this, data, offset, size, blockStart);
156}
157#endif
158
159#ifndef SharkSslStandalone
160
161#ifndef __DOXYGEN__
162typedef struct HttpStaticMemPage
163{
164 HttpPage page;
165 CspReader* data;
166 U32 time;
167 HttpDiskBlock mimeBlock;
168 HttpDiskBlock payloadBlock;
169 char isCompressed;
170} HttpStaticMemPage;
171#endif
172
173#ifdef __cplusplus
174extern "C" {
175#endif
176BA_API int httpWriteSection(
177 CspReader* data, HttpResponse* reply,U32 offset,U32 size);
178BA_API int httpUnzipAndWrite(CspReader* data,
179 HttpResponse* response,
180 U32 offset,
181 U32 size,
182 GzipHeader* gzipH);
183BA_API void httpRawWrite(CspReader* data,
184 HttpRequest* request,
185 HttpResponse* response,
186 U32 time,
187 U32 offset,
188 U32 size,
189 GzipHeader* gzipH,
190 GzipTrailer* gzipT);
191
192BA_API int cspCheckCondition(HttpRequest* request, HttpResponse* response);
193
194BA_API void HttpStaticMemPage_loadAndInit(HttpStaticMemPage* o,
195 CspReader* data, U32 time,
196 U32 nameOffset, U32 nameSize,
197 U32 mimeOffset, U32 mimeSize,
198 U32 payloadOffset, U32 payloadSize,
199 char isCompressed, HttpDir* parent);
200
201BA_API void HttpDynamicMemPage_loadAndInit(
202 HttpPage* o, CspReader* data, U32 size,
203 HttpPage_Service fptr,
204 U32 nameOffset, U32 nameSize);
205#ifdef __cplusplus
206}
207#endif
208
209#endif
210
211#endif /* __CspRunTm_h */
212
213
214
215
216
int(* CspReader_Read)(struct CspReader *o, void *data, U32 offset, U32 size, int blockStart)
Prototype for the CspReader callback function.
Definition: CspRunTm.h:107
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.
void(* HttpPage_Service)(struct HttpPage *page, HttpRequest *request, HttpResponse *response)
The HttpPage service function.
Definition: HttpServer.h:2190
Abstract interface class for reading the "dat" file generated by HttpLink.
Definition: CspRunTm.h:118
bool isValid()
Returns true if the reader object is valid.
Definition: CspRunTm.h:151
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2364
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2256
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:808
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1178