Barracuda Application Server C/C++ Reference
NO
IoIntf.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: IoIntf.h 4915 2021-12-01 18:26:55Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2006-2018
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#ifndef __IoIntf_h
40#define __IoIntf_h
41
42#include "GenPrimT.h"
43#include "ThreadLib.h"
44
53#define IOINTF_OK 0
54
57#define IOINTF_EOF 1
58
59
63#define IOINTF_INVALIDNAME -11
64
67#define IOINTF_NOTFOUND -12
68
71#define IOINTF_EXIST -13
72
75#define IOINTF_ENOENT -14
76
79#define IOINTF_NOACCESS -15
80
83#define IOINTF_NOTEMPTY -16
84
87#define IOINTF_NOSPACE -17
88
91#define IOINTF_IOERROR -18
92
95#define IOINTF_MEM -19
96
97#define IOINTF_LOCKED -20
98
99
102#define IOINTF_NOIMPLEMENTATION -50
103
106#define IOINTF_BUFTOOSMALL -51
107
108
111#define IOINTF_NOZIPLIB -100
112
116#define IOINTF_NOTCOMPRESSED -101
117
120#define IOINTF_ZIPERROR -102
121
122
123
127#define IOINTF_NOAESLIB -200
128
131#define IOINTF_AES_NO_SUPPORT -201
134#define IOINTF_NO_PASSWORD -202
135
138#define IOINTF_WRONG_PASSWORD -203
139
144#define IOINTF_AES_WRONG_AUTH -204
145
151#define IOINTF_AES_COMPROMISED -205
152
153/* (Forward) Declarations
154 */
155
156#ifndef __DOXYGEN__
157struct IoIntf;
158typedef struct IoIntf* IoIntfPtr;
159struct DirIntf;
160typedef struct DirIntf* DirIntfPtr;
161struct ResIntf;
162typedef struct ResIntf* ResIntfPtr;
163#endif
164
167typedef struct
168{
172 BaFileSize size;
174 BaBool isDir;
175} IoStat;
176
178#define OpenRes_READ 1
179
181#define OpenRes_WRITE 2
182
184#define OpenRes_APPEND 4
185
186
187
188
189#ifdef __cplusplus
190extern "C" {
191#endif
192
202 IoIntfPtr o, const char* password, size_t passwordLen);
203
204
216 IoIntfPtr o, BaBool passwordRequired, BaBool passwordBin);
217
227BA_API char* IoIntf_getAbspath(IoIntfPtr o, const char* path);
228
229
236BA_API int IoIntf_getType(IoIntfPtr o,const char** type,const char** platform);
237
245 IoIntfPtr o,const char* name,BaBool* isEncrypted);
246
247
251BA_API void IoIntf_destructor(IoIntfPtr o);
252
253
260typedef ResIntfPtr (*IoIntf_InflateGzip)(
261 IoIntfPtr io, const char* name, int* status, const char** ecode);
262
263
269typedef ResIntfPtr (*IoIntf_DeflateGzip)(
270 ResIntfPtr resPtr, const char* name, ThreadMutex* m,
271 BaFileSize* size, BaBool* isCompressed);
272
273
274#ifdef __cplusplus
275}
276#endif
277
278/* Required API methods
279 */
280
302typedef int (*IoIntf_Property)(IoIntfPtr o,const char* name,void* a,void* b);
303
307typedef DirIntfPtr (*IoIntf_OpenDir)(IoIntfPtr o, const char* dirname,
308 int* status, const char** ecode);
309
312typedef int (*IoIntf_Stat)(IoIntfPtr o, const char* name, IoStat* st);
313
332typedef ResIntfPtr (*IoIntf_OpenRes)(IoIntfPtr o, const char* name,
333 U32 mode, int* status,
334 const char** ecode);
335
338typedef int (*IoIntf_CloseDir)(IoIntfPtr o, DirIntfPtr* dirIntf);
339
342typedef ResIntfPtr (*IoIntf_OpenResGzip)(IoIntfPtr o, const char* name,
343 ThreadMutex* m, BaFileSize* size,
344 int* status, const char** ecode);
345
348typedef int (*IoIntf_MkDir)(IoIntfPtr o, const char* name, const char** ecode);
349
352typedef int (*IoIntf_Rename)(IoIntfPtr o, const char* from, const char* to,
353 const char** ecode);
356typedef int (*IoIntf_Remove)(IoIntfPtr o,const char* name, const char** ecode);
357
360typedef int (*IoIntf_RmDir)(IoIntfPtr o, const char* name, const char** ecode);
361
362typedef int (*IoIntf_SeekAndRead)(
363 ResIntfPtr super, BaFileSize offset,void* buf,size_t maxSize,size_t* size);
364
365/* Called by I/O when terminating if property:attach is set */
366typedef void (*IoIntf_OnTerminate)(IoIntfPtr o, IoIntfPtr io);
367
376typedef struct IoIntf
377{
381
385
389
393
397
401
405
409
413
417
418 /* Called by I/O when terminating if property:attach is set */
419 struct IoIntf* attachedIo;
420 IoIntf_OnTerminate onTerminate;
422
423
424/* Constructor for Read And Write resource collections.
425 */
426#define IoIntf_constructorRW(o, property, closeDir, mkDir, rename,\
427 openDir, openRes, openResGzip, rm,\
428 rmDir, st) do {\
429 (o)->propertyFp=property;\
430 (o)->closeDirFp=closeDir;\
431 (o)->mkDirFp=mkDir;\
432 (o)->renameFp=rename;\
433 (o)->openDirFp=openDir;\
434 (o)->openResFp=openRes;\
435 (o)->openResGzipFp=openResGzip;\
436 (o)->removeFp=rm;\
437 (o)->rmDirFp=rmDir;\
438 (o)->statFp=st;\
439 (o)->attachedIo=0;\
440 (o)->onTerminate=0;\
441} while(0)
442
443
444
445/* Constructor for Read Only resource collections.
446 */
447#define IoIntf_constructorR(o, property, closeDir, openDir,\
448 openRes, openResGzip, st) do {\
449 (o)->propertyFp=property;\
450 (o)->closeDirFp=closeDir;\
451 (o)->mkDirFp=0;\
452 (o)->renameFp=0;\
453 (o)->openDirFp=openDir;\
454 (o)->openResFp=openRes;\
455 (o)->openResGzipFp=openResGzip;\
456 (o)->removeFp=0;\
457 (o)->rmDirFp=0;\
458 (o)->statFp=st;\
459 (o)->attachedIo=0;\
460 (o)->onTerminate=0;\
461} while(0)
462
463
464
467typedef int (*DirIntf_Read)(DirIntfPtr o);
468
471typedef const char* (*DirIntf_GetName)(DirIntfPtr o);
472
475typedef int (*DirIntf_Stat)(DirIntfPtr o, IoStat* st);
476
494typedef struct DirIntf
495{
504
505
506#define DirIntf_constructor(o, read, getName, st) do {\
507 (o)->readFp=read;\
508 (o)->getNameFp=getName;\
509 (o)->statFp=st;\
510}while(0)
511
514typedef int (*ResIntf_Read)(
515 ResIntfPtr o, void* buf, size_t maxSize, size_t* size);
516typedef int (*ResIntf_Write)(ResIntfPtr o, const void* buf, size_t size);
517typedef int (*ResIntf_Seek)(ResIntfPtr o, BaFileSize offset);
518typedef int (*ResIntf_Flush)(ResIntfPtr o);
519typedef int (*ResIntf_Close)(ResIntfPtr o);
520
521
524typedef struct ResIntf
525{
529 ResIntf_Write writeFp;
531 ResIntf_Seek seekFp;
533 ResIntf_Flush flushFp;
535 ResIntf_Close closeFp;
537
538#define ResIntf_constructor(o, read, write, seek, flush, close) do {\
539 (o)->readFp=read;\
540 (o)->writeFp=write;\
541 (o)->seekFp=seek;\
542 (o)->flushFp=flush;\
543 (o)->closeFp=close;\
544}while(0)
545 /* end of IO */
547
548#endif
ResIntfPtr(* IoIntf_InflateGzip)(IoIntfPtr io, const char *name, int *status, const char **ecode)
Open a file for writing.
Definition: IoIntf.h:260
int(* IoIntf_Stat)(IoIntfPtr o, const char *name, IoStat *st)
Fetch resource information.
Definition: IoIntf.h:312
BA_API char * IoIntf_getAbspath(IoIntfPtr o, const char *path)
wrapper for IoIntf_Property: 'abs'.
int(* IoIntf_Rename)(IoIntfPtr o, const char *from, const char *to, const char **ecode)
Close an open directory iterator.
Definition: IoIntf.h:352
ResIntfPtr(* IoIntf_OpenRes)(IoIntfPtr o, const char *name, U32 mode, int *status, const char **ecode)
Open a file for reading or writing.
Definition: IoIntf.h:332
int(* IoIntf_MkDir)(IoIntfPtr o, const char *name, const char **ecode)
Create a new directory.
Definition: IoIntf.h:348
struct IoIntf IoIntf
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
int(* IoIntf_RmDir)(IoIntfPtr o, const char *name, const char **ecode)
delete an empty directory.
Definition: IoIntf.h:360
int(* IoIntf_Remove)(IoIntfPtr o, const char *name, const char **ecode)
Delete a file.
Definition: IoIntf.h:356
ResIntfPtr(* IoIntf_OpenResGzip)(IoIntfPtr o, const char *name, ThreadMutex *m, BaFileSize *size, int *status, const char **ecode)
Returns data as a compressed gzip file.
Definition: IoIntf.h:342
int(* DirIntf_Read)(DirIntfPtr o)
Iterate to next resource in directory.
Definition: IoIntf.h:467
BA_API int IoIntf_setPassword(IoIntfPtr o, const char *password, size_t passwordLen)
wrapper for IoIntf_Property: 'pl'.
struct DirIntf DirIntf
Directory handle for a directory opened with IoIntf_OpenDir.
ResIntfPtr(* IoIntf_DeflateGzip)(ResIntfPtr resPtr, const char *name, ThreadMutex *m, BaFileSize *size, BaBool *isCompressed)
Deflate a file or portion of a file to temporary storage.
Definition: IoIntf.h:269
const char *(* DirIntf_GetName)(DirIntfPtr o)
Returns the resource name.
Definition: IoIntf.h:471
struct ResIntf ResIntf
Resource handle for a directory opened with IoIntf_OpenRes.
BA_API void IoIntf_destructor(IoIntfPtr o)
Virtual destructor.
int(* DirIntf_Stat)(DirIntfPtr o, IoStat *st)
Returns resource information.
Definition: IoIntf.h:475
int(* ResIntf_Read)(ResIntfPtr o, void *buf, size_t maxSize, size_t *size)
Abstract Resource Interface.
Definition: IoIntf.h:514
BA_API int IoIntf_isEncrypted(IoIntfPtr o, const char *name, BaBool *isEncrypted)
wrapper for IoIntf_Property: 'aes'.
int(* IoIntf_CloseDir)(IoIntfPtr o, DirIntfPtr *dirIntf)
Close an open directory iterator.
Definition: IoIntf.h:338
DirIntfPtr(* IoIntf_OpenDir)(IoIntfPtr o, const char *dirname, int *status, const char **ecode)
Open a directory for reading.
Definition: IoIntf.h:307
BA_API int IoIntf_setPasswordProp(IoIntfPtr o, BaBool passwordRequired, BaBool passwordBin)
wrapper for IoIntf_Property: 'pp'.
int(* IoIntf_Property)(IoIntfPtr o, const char *name, void *a, void *b)
Set or get properties.
Definition: IoIntf.h:302
BA_API int IoIntf_getType(IoIntfPtr o, const char **type, const char **platform)
wrapper for IoIntf_Property: 'type'.
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
Directory handle for a directory opened with IoIntf_OpenDir.
Definition: IoIntf.h:495
DirIntf_Read readFp
Iterate the resources in the file system.
Definition: IoIntf.h:498
DirIntf_GetName getNameFp
Get resource name.
Definition: IoIntf.h:500
DirIntf_Stat statFp
Get resource information.
Definition: IoIntf.h:502
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:377
IoIntf_Rename renameFp
Rename resource.
Definition: IoIntf.h:392
IoIntf_RmDir rmDirFp
Remove directory.
Definition: IoIntf.h:412
IoIntf_OpenDir openDirFp
Open directory.
Definition: IoIntf.h:396
IoIntf_OpenResGzip openResGzipFp
Open file as a compressed gzip file.
Definition: IoIntf.h:404
IoIntf_Property propertyFp
Set or get property.
Definition: IoIntf.h:380
IoIntf_Remove removeFp
Remove file.
Definition: IoIntf.h:408
IoIntf_OpenRes openResFp
Open resource.
Definition: IoIntf.h:400
IoIntf_Stat statFp
Get resource information.
Definition: IoIntf.h:416
IoIntf_MkDir mkDirFp
Make directory.
Definition: IoIntf.h:388
IoIntf_CloseDir closeDirFp
Close directory.
Definition: IoIntf.h:384
Resource information.
Definition: IoIntf.h:168
BaFileSize size
Get size.
Definition: IoIntf.h:172
BaTime lastModified
Get lastModified time.
Definition: IoIntf.h:170
BaBool isDir
Resource type.
Definition: IoIntf.h:174
Resource handle for a directory opened with IoIntf_OpenRes.
Definition: IoIntf.h:525
ResIntf_Seek seekFp
Seek to position in resource.
Definition: IoIntf.h:531
ResIntf_Close closeFp
Close the resource and release any data.
Definition: IoIntf.h:535
ResIntf_Flush flushFp
Flush resource.
Definition: IoIntf.h:533
ResIntf_Read readFp
Read from resource.
Definition: IoIntf.h:527
ResIntf_Write writeFp
Write to resource.
Definition: IoIntf.h:529
A mutual exclusion class.
Definition: ThreadLib.h:186