Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

module.h

Go to the documentation of this file.
00001 
00023 #ifndef _LIBCOMPREX_MODULE_H_
00024 #define _LIBCOMPREX_MODULE_H_
00025 
00026 #include <stdio.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 typedef enum   _CxModuleType CxModuleType;  
00033 typedef struct _CxArchiveOps CxArchiveOps;  
00034 typedef struct _CxSchemeOps  CxSchemeOps;   
00035 typedef struct _CxModule     CxModule;      
00037 #include <libcomprex/types.h>
00038 #include <libcomprex/fsnode.h>
00039 #include <libcomprex/fp.h>
00040 #include <libcomprex/directory.h>
00041 
00045 #ifdef STATIC_MODULE
00046 # define CX_INIT_ARCHIVE_MODULE(modname, initfunc, archiveops) \
00047     CxModule *init_##modname##_archive_module(void) { \
00048         initfunc(CX_MODULE_ARCHIVE); \
00049         return cxRegisterModule(#modname, &(archiveops), CX_MODULE_ARCHIVE); \
00050     }
00051 # define CX_INIT_SCHEME_MODULE(modname, initfunc, schemeops) \
00052     CxModule *init_##modname##_scheme_module(void) { \
00053         initfunc(CX_MODULE_SCHEME); \
00054         return cxRegisterModule(#modname, &(schemeops), CX_MODULE_SCHEME); \
00055     }
00056 #else /* if !STATIC_MODULE */
00057 # define CX_INIT_ARCHIVE_MODULE(modname, initfunc, archiveops) \
00058     CxModule *initComprexModule(void) { \
00059         initfunc(CX_MODULE_ARCHIVE); \
00060         return cxRegisterModule(#modname, &(archiveops), CX_MODULE_ARCHIVE); \
00061     }
00062 # define CX_INIT_SCHEME_MODULE(modname, initfunc, schemeops) \
00063     CxModule *initComprexModule(void) { \
00064         initfunc(CX_MODULE_SCHEME); \
00065         return cxRegisterModule(#modname, &(schemeops), CX_MODULE_SCHEME); \
00066     }
00067 #endif
00068 
00074 enum _CxModuleType
00075 {
00076     CX_MODULE_ARCHIVE, 
00077     CX_MODULE_SCHEME   
00078 };
00079 
00091 struct _CxArchiveOps
00092 {
00106     CxStatus (*readArchive)(CxArchive *archive, CxFP *fp);
00107 
00116     CxStatus (*saveArchive)(CxArchive *archive, CxFP *fp);
00117 
00123     void (*closeArchive)(CxArchive *archive);
00124 
00133     CxFP *(*openFile)(CxFile *file, CxAccessMode mode);
00134 
00140     void (*destroyFile)(CxFile *file);
00141 
00152     char (*supportsExtension)(const char *ext);
00153 };
00154 
00166 struct _CxSchemeOps
00167 {
00177     CxStatus (*get)(const char *scheme, const char *path,
00178                     const char *outFilename);
00179     
00187     char (*supports)(const char *scheme);
00188 };
00189 
00199 struct _CxModule
00200 {
00201     CxModuleType type;          
00203     char *filename;             
00204     char *name;                 
00205     void *handle;               
00207     unsigned int refCount;      
00209     union
00210     {
00211         CxArchiveOps *archive;  
00212         CxSchemeOps  *scheme;   
00214     } ops;                      
00216     CxModule *prev;             
00217     CxModule *next;             
00218 };
00219 
00229 CxModule *cxRegisterModule(const char *name, void *ops, CxModuleType type);
00230 
00242 CxModule *cxLoadModule(const char *name, CxModuleType type);
00243 
00251 void cxUnloadModule(CxModule *module);
00252 
00265 CxModule *cxGetModule(const char *name, CxModuleType type);
00266 
00276 void cxLinkModule(CxModule **ptr);
00277 
00287 void cxUnlinkModule(CxModule **ptr);
00288 
00300 CxModule *cxGetFirstModule(CxModuleType type);
00301 
00312 void cxCleanupModules();
00313 
00324 void cxCleanup(void);
00325 
00326 #ifdef __cplusplus
00327 }
00328 #endif
00329 
00330 #endif /* _LIBCOMPREX_MODULE_H_ */
00331 

Generated on Wed Mar 5 20:47:43 2003 for libcomprex by doxygen1.2.18-20021020