Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
IoIntf.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: IoIntf.h 5978 2026-09-11 16:13:48Z 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
41#ifndef __IoIntf_h
42#define __IoIntf_h
43
44#include "GenPrimT.h"
45#include "ThreadLib.h"
46
55#define IOINTF_OK 0
56
59#define IOINTF_EOF 1
60
61
65#define IOINTF_INVALIDNAME -11
66
69#define IOINTF_NOTFOUND -12
70
73#define IOINTF_EXIST -13
74
77#define IOINTF_ENOENT -14
78
81#define IOINTF_NOACCESS -15
82
85#define IOINTF_NOTEMPTY -16
86
89#define IOINTF_NOSPACE -17
90
93#define IOINTF_IOERROR -18
94
97#define IOINTF_MEM -19
98
99#define IOINTF_LOCKED -20
100
101
104#define IOINTF_NOIMPLEMENTATION -50
105
108#define IOINTF_BUFTOOSMALL -51
109
110
113#define IOINTF_NOZIPLIB -100
114
118#define IOINTF_NOTCOMPRESSED -101
119
122#define IOINTF_ZIPERROR -102
123
124
125
129#define IOINTF_NOAESLIB -200
130
133#define IOINTF_AES_NO_SUPPORT -201
136#define IOINTF_NO_PASSWORD -202
137
140#define IOINTF_WRONG_PASSWORD -203
141
146#define IOINTF_AES_WRONG_AUTH -204
147
153#define IOINTF_AES_COMPROMISED -205
154
155/* (Forward) Declarations
156 */
157
158#ifndef __DOXYGEN__
159struct IoIntf;
160typedef struct IoIntf* IoIntfPtr;
161struct DirIntf;
162typedef struct DirIntf* DirIntfPtr;
163struct ResIntf;
164typedef struct ResIntf* ResIntfPtr;
165#endif
166
169typedef struct
170{
177} IoStat;
178
180#define OpenRes_READ 1
181
183#define OpenRes_WRITE 2
184
186#define OpenRes_APPEND 4
187
188
189
190
191#ifdef __cplusplus
192extern "C" {
193#endif
194
206 IoIntfPtr o, const char* password, size_t passwordLen);
207
208
220 IoIntfPtr o, BaBool passwordRequired, BaBool passwordBin);
221
231BA_API char* IoIntf_getAbspath(IoIntfPtr o, const char* path);
232
233
243BA_API int IoIntf_getType(IoIntfPtr o,const char** type,const char** platform);
244
253 IoIntfPtr o,const char* name,BaBool* isEncrypted);
254
255
262BA_API void IoIntf_destructor(IoIntfPtr o);
263
264
274typedef ResIntfPtr (*IoIntf_InflateGzip)(
275 IoIntfPtr io, const char* name, int* status, const char** ecode);
276
277
291typedef ResIntfPtr (*IoIntf_DeflateGzip)(
292 ResIntfPtr resPtr, const char* name, ThreadMutex* m,
293 BaFileSize* size, BaBool* isCompressed);
294
295
296#ifdef __cplusplus
297}
298#endif
299
300/* Required API methods
301 */
302
328typedef int (*IoIntf_Property)(IoIntfPtr o,const char* name,void* a,void* b);
329
340typedef DirIntfPtr (*IoIntf_OpenDir)(IoIntfPtr o, const char* dirname,
341 int* status, const char** ecode);
342
349typedef int (*IoIntf_Stat)(IoIntfPtr o, const char* name, IoStat* st);
350
379typedef ResIntfPtr (*IoIntf_OpenRes)(IoIntfPtr o, const char* name,
380 U32 mode, int* status,
381 const char** ecode);
382
390typedef int (*IoIntf_CloseDir)(IoIntfPtr o, DirIntfPtr* dirIntf);
391
406typedef ResIntfPtr (*IoIntf_OpenResGzip)(IoIntfPtr o, const char* name,
407 ThreadMutex* m, BaFileSize* size,
408 int* status, const char** ecode);
409
418typedef int (*IoIntf_MkDir)(IoIntfPtr o, const char* name, const char** ecode);
419
429typedef int (*IoIntf_Rename)(IoIntfPtr o, const char* from, const char* to,
430 const char** ecode);
439typedef int (*IoIntf_Remove)(IoIntfPtr o,const char* name, const char** ecode);
440
449typedef int (*IoIntf_RmDir)(IoIntfPtr o, const char* name, const char** ecode);
450
461typedef int (*IoIntf_SeekAndRead)(
462 ResIntfPtr super, BaFileSize offset,void* buf,size_t maxSize,size_t* size);
463
464/* Called by I/O when terminating if property:attach is set */
471typedef void (*IoIntf_OnTerminate)(IoIntfPtr o, IoIntfPtr io);
472
481typedef struct IoIntf
482{
486
490
494
498
502
506
510
514
518
522
523 /* Called by I/O when terminating if property:attach is set */
524 struct IoIntf* attachedIo;
525 IoIntf_OnTerminate onTerminate;
527
528
529/* Constructor for Read And Write resource collections.
530 */
546#define IoIntf_constructorRW(o, property, closeDir, mkDir, rename,\
547 openDir, openRes, openResGzip, rm,\
548 rmDir, st) do {\
549 (o)->propertyFp=property;\
550 (o)->closeDirFp=closeDir;\
551 (o)->mkDirFp=mkDir;\
552 (o)->renameFp=rename;\
553 (o)->openDirFp=openDir;\
554 (o)->openResFp=openRes;\
555 (o)->openResGzipFp=openResGzip;\
556 (o)->removeFp=rm;\
557 (o)->rmDirFp=rmDir;\
558 (o)->statFp=st;\
559 (o)->attachedIo=0;\
560 (o)->onTerminate=0;\
561} while(0)
562
563
564
565/* Constructor for Read Only resource collections.
566 */
578#define IoIntf_constructorR(o, property, closeDir, openDir,\
579 openRes, openResGzip, st) do {\
580 (o)->propertyFp=property;\
581 (o)->closeDirFp=closeDir;\
582 (o)->mkDirFp=0;\
583 (o)->renameFp=0;\
584 (o)->openDirFp=openDir;\
585 (o)->openResFp=openRes;\
586 (o)->openResGzipFp=openResGzip;\
587 (o)->removeFp=0;\
588 (o)->rmDirFp=0;\
589 (o)->statFp=st;\
590 (o)->attachedIo=0;\
591 (o)->onTerminate=0;\
592} while(0)
593
594
595
602typedef int (*DirIntf_Read)(DirIntfPtr o);
603
609typedef const char* (*DirIntf_GetName)(DirIntfPtr o);
610
616typedef int (*DirIntf_Stat)(DirIntfPtr o, IoStat* st);
617
642typedef struct DirIntf
643{
652
653
661#define DirIntf_constructor(o, read, getName, st) do {\
662 (o)->readFp=read;\
663 (o)->getNameFp=getName;\
664 (o)->statFp=st;\
665}while(0)
666
677typedef int (*ResIntf_Read)(
678 ResIntfPtr o, void* buf, size_t maxSize, size_t* size);
686typedef int (*ResIntf_Write)(ResIntfPtr o, const void* buf, size_t size);
693typedef int (*ResIntf_Seek)(ResIntfPtr o, BaFileSize offset);
699typedef int (*ResIntf_Flush)(ResIntfPtr o);
705typedef int (*ResIntf_Close)(ResIntfPtr o);
706
707
710typedef struct ResIntf
711{
723
733#define ResIntf_constructor(o, read, write, seek, flush, close) do {\
734 (o)->readFp=read;\
735 (o)->writeFp=write;\
736 (o)->seekFp=seek;\
737 (o)->flushFp=flush;\
738 (o)->closeFp=close;\
739}while(0)
740 /* end of IO */
742
743#endif
ResIntfPtr(* IoIntf_InflateGzip)(IoIntfPtr io, const char *name, int *status, const char **ecode)
Open a destination that accepts gzip bytes and stores decompressed data.
Definition: IoIntf.h:274
int(* IoIntf_Stat)(IoIntfPtr o, const char *name, IoStat *st)
Fetch metadata for a file or directory.
Definition: IoIntf.h:349
int(* ResIntf_Write)(ResIntfPtr o, const void *buf, size_t size)
Write binary bytes at the current resource position.
Definition: IoIntf.h:686
int(* ResIntf_Close)(ResIntfPtr o)
Close and consume a resource handle.
Definition: IoIntf.h:705
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)
Rename or move a resource within this filesystem.
Definition: IoIntf.h:429
int(* ResIntf_Seek)(ResIntfPtr o, BaFileSize offset)
Set the resource position relative to its beginning.
Definition: IoIntf.h:693
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:379
int(* IoIntf_SeekAndRead)(ResIntfPtr super, BaFileSize offset, void *buf, size_t maxSize, size_t *size)
Perform a combined seek and read on a resource.
Definition: IoIntf.h:461
void(* IoIntf_OnTerminate)(IoIntfPtr o, IoIntfPtr io)
Notify a filesystem attachment of termination/replacement.
Definition: IoIntf.h:471
int(* IoIntf_MkDir)(IoIntfPtr o, const char *name, const char **ecode)
Create a directory.
Definition: IoIntf.h:418
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)
Remove an empty directory.
Definition: IoIntf.h:449
int(* IoIntf_Remove)(IoIntfPtr o, const char *name, const char **ecode)
Remove a file.
Definition: IoIntf.h:439
ResIntfPtr(* IoIntf_OpenResGzip)(IoIntfPtr o, const char *name, ThreadMutex *m, BaFileSize *size, int *status, const char **ecode)
Open a gzip representation for reading when supported.
Definition: IoIntf.h:406
int(* DirIntf_Read)(DirIntfPtr o)
Advance to the next directory entry, including the first after open.
Definition: IoIntf.h:602
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.
int(* ResIntf_Flush)(ResIntfPtr o)
Flush buffered writes through the implementation.
Definition: IoIntf.h:699
ResIntfPtr(* IoIntf_DeflateGzip)(ResIntfPtr resPtr, const char *name, ThreadMutex *m, BaFileSize *size, BaBool *isCompressed)
Optionally compress an open resource or range into temporary gzip storage.
Definition: IoIntf.h:291
const char *(* DirIntf_GetName)(DirIntfPtr o)
Access the current entry name after successful readFp.
Definition: IoIntf.h:609
struct ResIntf ResIntf
Resource handle for a file opened with IoIntf_OpenRes.
BA_API void IoIntf_destructor(IoIntfPtr o)
Invoke the implementation's "destructor" property.
int(* DirIntf_Stat)(DirIntfPtr o, IoStat *st)
Fetch metadata for the current entry after successful readFp.
Definition: IoIntf.h:616
int(* ResIntf_Read)(ResIntfPtr o, void *buf, size_t maxSize, size_t *size)
Read binary bytes at the current resource position.
Definition: IoIntf.h:677
BA_API int IoIntf_isEncrypted(IoIntfPtr o, const char *name, BaBool *isEncrypted)
wrapper for IoIntf_Property: 'aes'.
int(* IoIntf_CloseDir)(IoIntfPtr o, DirIntfPtr *dirIntf)
Consume and close a directory iterator.
Definition: IoIntf.h:390
DirIntfPtr(* IoIntf_OpenDir)(IoIntfPtr o, const char *dirname, int *status, const char **ecode)
Open a directory iterator before its first entry.
Definition: IoIntf.h:340
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)
Implementation-specific property operation.
Definition: IoIntf.h:328
BA_API int IoIntf_getType(IoIntfPtr o, const char **type, const char **platform)
Query the implementation's type property.
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:103
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
U32 BaFileSize
Unsigned file size or position in bytes; 32 bits without BA_FILESIZE64.
Definition: GenPrimT.h:136
Directory handle for a directory opened with IoIntf_OpenDir.
Definition: IoIntf.h:643
DirIntf_Read readFp
Iterate the resources in the file system.
Definition: IoIntf.h:646
DirIntf_GetName getNameFp
Get resource name.
Definition: IoIntf.h:648
DirIntf_Stat statFp
Get resource information.
Definition: IoIntf.h:650
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:482
IoIntf_Rename renameFp
Rename resource.
Definition: IoIntf.h:497
IoIntf_RmDir rmDirFp
Remove directory.
Definition: IoIntf.h:517
IoIntf_OpenDir openDirFp
Open directory.
Definition: IoIntf.h:501
IoIntf_OpenResGzip openResGzipFp
Open file as a compressed gzip file.
Definition: IoIntf.h:509
IoIntf_Property propertyFp
Set or get property.
Definition: IoIntf.h:485
IoIntf_Remove removeFp
Remove file.
Definition: IoIntf.h:513
IoIntf_OpenRes openResFp
Open resource.
Definition: IoIntf.h:505
IoIntf_Stat statFp
Get resource information.
Definition: IoIntf.h:521
IoIntf_MkDir mkDirFp
Make directory.
Definition: IoIntf.h:493
IoIntf_CloseDir closeDirFp
Close directory.
Definition: IoIntf.h:489
Resource information.
Definition: IoIntf.h:170
BaFileSize size
File size in bytes.
Definition: IoIntf.h:174
BaTime lastModified
Last modification time in Unix seconds; availability and precision depend on the filesystem.
Definition: IoIntf.h:172
BaBool isDir
TRUE for a directory, FALSE for a file.
Definition: IoIntf.h:176
Resource handle for a file opened with IoIntf_OpenRes.
Definition: IoIntf.h:711
ResIntf_Seek seekFp
Seek to position in resource.
Definition: IoIntf.h:717
ResIntf_Close closeFp
Close the resource and release any data.
Definition: IoIntf.h:721
ResIntf_Flush flushFp
Flush resource.
Definition: IoIntf.h:719
ResIntf_Read readFp
Read from resource.
Definition: IoIntf.h:713
ResIntf_Write writeFp
Write to resource.
Definition: IoIntf.h:715
A mutual exclusion class.
Definition: ThreadLib.h:196