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 5387 2023-02-20 22:50:13Z 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
118typedef struct CspReader
119{
120#ifdef __cplusplus
121 void *operator new(size_t s) { return ::baMalloc(s); }
122 void operator delete(void* d) { if(d) ::baFree(d); }
123 void *operator new(size_t, void *place) { return place; }
124 void operator delete(void*, void *) { }
125
127 bool isValid();
128 int read(void* data, U32 offset, U32 size, bool blockStart);
129 void setIsValid() { validFlag=CspReader_validFlag; }
130 private:
131#endif
132 CspReader_Read readCB;
133 U16 validFlag;
135
136#ifdef __cplusplus
137extern "C" {
138#endif
139#define CspReader_constructor(o, httpDiskRead) do {\
140 (o)->readCB = httpDiskRead; \
141 (o)->validFlag = (U16)~CspReader_validFlag; \
142}while(0)
143
144#define CspReader_isValid(o) (((CspReader*)o)->readCB != 0 && \
145 ((CspReader*)o)->validFlag == CspReader_validFlag)
146#define CspReader_setIsValid(o) ((CspReader*)o)->validFlag=CspReader_validFlag
147#define CspReader_read(httpData, data, offset, size, blockStart) \
148 (*((CspReader*)httpData)->readCB)((CspReader*)httpData, data, \
149 offset, size, blockStart)
150#ifdef __cplusplus
151}
152inline bool CspReader::isValid() {
153 return CspReader_isValid(this) ? true : false;
154}
155inline int CspReader::read(void* data, U32 offset, U32 size, bool blockStart) {
156 return CspReader_read(this, data, offset, size, blockStart);
157}
158#endif
159
160#ifndef SharkSslStandalone
161
162#ifndef __DOXYGEN__
163typedef struct HttpStaticMemPage
164{
165 HttpPage page;
166 CspReader* data;
167 U32 time;
168 HttpDiskBlock mimeBlock;
169 HttpDiskBlock payloadBlock;
170 char isCompressed;
171} HttpStaticMemPage;
172#endif
173
174#ifdef __cplusplus
175extern "C" {
176#endif
177BA_API int httpWriteSection(
178 CspReader* data, HttpResponse* reply,U32 offset,U32 size);
179BA_API int httpUnzipAndWrite(CspReader* data,
180 HttpResponse* response,
181 U32 offset,
182 U32 size,
183 GzipHeader* gzipH);
184BA_API void httpRawWrite(CspReader* data,
185 HttpRequest* request,
186 HttpResponse* response,
187 U32 time,
188 U32 offset,
189 U32 size,
190 GzipHeader* gzipH,
191 GzipTrailer* gzipT);
192
193BA_API int cspCheckCondition(HttpRequest* request, HttpResponse* response);
194
195BA_API void HttpStaticMemPage_loadAndInit(HttpStaticMemPage* o,
196 CspReader* data, U32 time,
197 U32 nameOffset, U32 nameSize,
198 U32 mimeOffset, U32 mimeSize,
199 U32 payloadOffset, U32 payloadSize,
200 char isCompressed, HttpDir* parent);
201
202BA_API void HttpDynamicMemPage_loadAndInit(
203 HttpPage* o, CspReader* data, U32 size,
204 HttpPage_Service fptr,
205 U32 nameOffset, U32 nameSize);
206#ifdef __cplusplus
207}
208#endif
209
210#endif
211
212#endif /* __CspRunTm_h */
213
214
215
216
217
struct CspReader CspReader
Abstract interface class for reading the "dat" file generated byHttpLink.
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 byHttpLink.
Definition: CspRunTm.h:119
bool isValid()
Returns true if the reader object is valid.
Definition: CspRunTm.h:152
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2368
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