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
132 
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__
157 struct IoIntf;
158 typedef struct IoIntf* IoIntfPtr;
159 struct DirIntf;
160 typedef struct DirIntf* DirIntfPtr;
161 struct ResIntf;
162 typedef struct ResIntf* ResIntfPtr;
163 #endif
164 
167 typedef 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
190 extern "C" {
191 #endif
192 
202  IoIntfPtr o, const char* password, size_t passwordLen);
203 
204 
216  IoIntfPtr o, BaBool passwordRequired, BaBool passwordBin);
217 
227 BA_API char* IoIntf_getAbspath(IoIntfPtr o, const char* path);
228 
229 
236 BA_API int IoIntf_getType(IoIntfPtr o,const char** type,const char** platform);
237 
245  IoIntfPtr o,const char* name,BaBool* isEncrypted);
246 
247 
251 BA_API void IoIntf_destructor(IoIntfPtr o);
252 
253 
260 typedef ResIntfPtr (*IoIntf_InflateGzip)(
261  IoIntfPtr io, const char* name, int* status, const char** ecode);
262 
263 
269 typedef 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 
302 typedef int (*IoIntf_Property)(IoIntfPtr o,const char* name,void* a,void* b);
303 
307 typedef DirIntfPtr (*IoIntf_OpenDir)(IoIntfPtr o, const char* dirname,
308  int* status, const char** ecode);
309 
312 typedef int (*IoIntf_Stat)(IoIntfPtr o, const char* name, IoStat* st);
313 
332 typedef ResIntfPtr (*IoIntf_OpenRes)(IoIntfPtr o, const char* name,
333  U32 mode, int* status,
334  const char** ecode);
335 
338 typedef int (*IoIntf_CloseDir)(IoIntfPtr o, DirIntfPtr* dirIntf);
339 
342 typedef ResIntfPtr (*IoIntf_OpenResGzip)(IoIntfPtr o, const char* name,
343  ThreadMutex* m, BaFileSize* size,
344  int* status, const char** ecode);
345 
348 typedef int (*IoIntf_MkDir)(IoIntfPtr o, const char* name, const char** ecode);
349 
352 typedef int (*IoIntf_Rename)(IoIntfPtr o, const char* from, const char* to,
353  const char** ecode);
356 typedef int (*IoIntf_Remove)(IoIntfPtr o,const char* name, const char** ecode);
357 
360 typedef int (*IoIntf_RmDir)(IoIntfPtr o, const char* name, const char** ecode);
361 
362 typedef 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 */
366 typedef void (*IoIntf_OnTerminate)(IoIntfPtr o, IoIntfPtr io);
367 
376 typedef 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 
467 typedef int (*DirIntf_Read)(DirIntfPtr o);
468 
471 typedef const char* (*DirIntf_GetName)(DirIntfPtr o);
472 
475 typedef int (*DirIntf_Stat)(DirIntfPtr o, IoStat* st);
476 
494 typedef 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 
514 typedef int (*ResIntf_Read)(
515  ResIntfPtr o, void* buf, size_t maxSize, size_t* size);
516 typedef int (*ResIntf_Write)(ResIntfPtr o, const void* buf, size_t size);
517 typedef int (*ResIntf_Seek)(ResIntfPtr o, BaFileSize offset);
518 typedef int (*ResIntf_Flush)(ResIntfPtr o);
519 typedef int (*ResIntf_Close)(ResIntfPtr o);
520 
521 
524 typedef 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
IoIntf_isEncrypted
BA_API int IoIntf_isEncrypted(IoIntfPtr o, const char *name, BaBool *isEncrypted)
wrapper for IoIntf_Property: 'aes'.
IoIntf_Stat
int(* IoIntf_Stat)(IoIntfPtr o, const char *name, IoStat *st)
Fetch resource information.
Definition: IoIntf.h:312
IoIntf_MkDir
int(* IoIntf_MkDir)(IoIntfPtr o, const char *name, const char **ecode)
Create a new directory.
Definition: IoIntf.h:348
IoIntf_RmDir
int(* IoIntf_RmDir)(IoIntfPtr o, const char *name, const char **ecode)
delete an empty directory.
Definition: IoIntf.h:360
IoIntf::openResFp
IoIntf_OpenRes openResFp
Open resource.
Definition: IoIntf.h:400
IoIntf::mkDirFp
IoIntf_MkDir mkDirFp
Make directory.
Definition: IoIntf.h:388
IoIntf_setPassword
BA_API int IoIntf_setPassword(IoIntfPtr o, const char *password, size_t passwordLen)
wrapper for IoIntf_Property: 'pl'.
IoIntf
struct IoIntf IoIntf
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
ResIntf::readFp
ResIntf_Read readFp
Read from resource.
Definition: IoIntf.h:527
IoIntf::renameFp
IoIntf_Rename renameFp
Rename resource.
Definition: IoIntf.h:392
DirIntf
Directory handle for a directory opened with IoIntf_OpenDir.
Definition: IoIntf.h:495
DirIntf_Stat
int(* DirIntf_Stat)(DirIntfPtr o, IoStat *st)
Returns resource information.
Definition: IoIntf.h:475
IoIntf_setPasswordProp
BA_API int IoIntf_setPasswordProp(IoIntfPtr o, BaBool passwordRequired, BaBool passwordBin)
wrapper for IoIntf_Property: 'pp'.
IoIntf::openResGzipFp
IoIntf_OpenResGzip openResGzipFp
Open file as a compressed gzip file.
Definition: IoIntf.h:404
IoIntf_getType
BA_API int IoIntf_getType(IoIntfPtr o, const char **type, const char **platform)
wrapper for IoIntf_Property: 'type'.
IoIntf_CloseDir
int(* IoIntf_CloseDir)(IoIntfPtr o, DirIntfPtr *dirIntf)
Close an open directory iterator.
Definition: IoIntf.h:338
IoStat::size
BaFileSize size
Get size.
Definition: IoIntf.h:172
BaTime
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
IoIntf_getAbspath
BA_API char * IoIntf_getAbspath(IoIntfPtr o, const char *path)
wrapper for IoIntf_Property: 'abs'.
IoIntf_OpenResGzip
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
IoIntf_destructor
BA_API void IoIntf_destructor(IoIntfPtr o)
Virtual destructor.
DirIntf::readFp
DirIntf_Read readFp
Iterate the resources in the file system.
Definition: IoIntf.h:498
IoIntf_Remove
int(* IoIntf_Remove)(IoIntfPtr o, const char *name, const char **ecode)
Delete a file.
Definition: IoIntf.h:356
IoIntf_Rename
int(* IoIntf_Rename)(IoIntfPtr o, const char *from, const char *to, const char **ecode)
Close an open directory iterator.
Definition: IoIntf.h:352
ResIntf::closeFp
ResIntf_Close closeFp
Close the resource and release any data.
Definition: IoIntf.h:535
ResIntf::writeFp
ResIntf_Write writeFp
Write to resource.
Definition: IoIntf.h:529
IoStat::isDir
BaBool isDir
Resource type.
Definition: IoIntf.h:174
IoIntf_OpenRes
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
ResIntf::flushFp
ResIntf_Flush flushFp
Flush resource.
Definition: IoIntf.h:533
ResIntf
struct ResIntf ResIntf
Resource handle for a directory opened with IoIntf_OpenRes.
IoIntf
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:377
IoIntf::propertyFp
IoIntf_Property propertyFp
Set or get property.
Definition: IoIntf.h:380
IoIntf::openDirFp
IoIntf_OpenDir openDirFp
Open directory.
Definition: IoIntf.h:396
IoIntf_Property
int(* IoIntf_Property)(IoIntfPtr o, const char *name, void *a, void *b)
Set or get properties.
Definition: IoIntf.h:302
IoIntf_DeflateGzip
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
IoIntf_InflateGzip
ResIntfPtr(* IoIntf_InflateGzip)(IoIntfPtr io, const char *name, int *status, const char **ecode)
Open a file for writing.
Definition: IoIntf.h:260
IoIntf_OpenDir
DirIntfPtr(* IoIntf_OpenDir)(IoIntfPtr o, const char *dirname, int *status, const char **ecode)
Open a directory for reading.
Definition: IoIntf.h:307
ResIntf_Read
int(* ResIntf_Read)(ResIntfPtr o, void *buf, size_t maxSize, size_t *size)
Abstract Resource Interface.
Definition: IoIntf.h:514
IoIntf::statFp
IoIntf_Stat statFp
Get resource information.
Definition: IoIntf.h:416
DirIntf_Read
int(* DirIntf_Read)(DirIntfPtr o)
Iterate to next resource in directory.
Definition: IoIntf.h:467
DirIntf::statFp
DirIntf_Stat statFp
Get resource information.
Definition: IoIntf.h:502
ResIntf
Resource handle for a directory opened with IoIntf_OpenRes.
Definition: IoIntf.h:525
IoStat::lastModified
BaTime lastModified
Get lastModified time.
Definition: IoIntf.h:170
IoIntf::removeFp
IoIntf_Remove removeFp
Remove file.
Definition: IoIntf.h:408
DirIntf_GetName
const char *(* DirIntf_GetName)(DirIntfPtr o)
Returns the resource name.
Definition: IoIntf.h:471
ThreadMutex
A mutual exclusion class.
Definition: ThreadLib.h:186
ResIntf::seekFp
ResIntf_Seek seekFp
Seek to position in resource.
Definition: IoIntf.h:531
IoStat
Resource information.
Definition: IoIntf.h:168
DirIntf
struct DirIntf DirIntf
Directory handle for a directory opened with IoIntf_OpenDir.
IoIntf::closeDirFp
IoIntf_CloseDir closeDirFp
Close directory.
Definition: IoIntf.h:384
IoIntf::rmDirFp
IoIntf_RmDir rmDirFp
Remove directory.
Definition: IoIntf.h:412
DirIntf::getNameFp
DirIntf_GetName getNameFp
Get resource name.
Definition: IoIntf.h:500