Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

module.h

Go to the documentation of this file.
00001 
00023 #ifndef _LIBPACKMAN_MODULE_H_
00024 #define _LIBPACKMAN_MODULE_H_
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 typedef enum   _PmModuleType  PmModuleType;   
00031 typedef struct _PmDatabaseOps PmDatabaseOps;  
00032 typedef struct _PmPackageOps  PmPackageOps;   
00033 typedef struct _PmModule      PmModule;       
00035 #include <libpackman/package.h>
00036 #include <libpackman/db.h>
00037 #include <libpackman/script.h>
00038 
00042 #ifdef STATIC_MODULE
00043 # define PM_INIT_DB_MODULE(modname, initfunc, dbops) \
00044     PmModule *init_##modname##_db_module(void) { \
00045         initfunc(PM_MODULE_DATABASE); \
00046         return pmRegisterModule(#modname, &(dbops), PM_MODULE_DATABASE); \
00047     }
00048 # define PM_INIT_PKG_MODULE(modname, initfunc, pkgops) \
00049     PmModule *init_##modname##_pkg_module(void) { \
00050         initfunc(PM_MODULE_PACKAGE); \
00051         return pmRegisterModule(#modname, &(pkgops), PM_MODULE_PACKAGE); \
00052     }
00053 #else /* if !STATIC_MODULE */
00054 # define PM_INIT_DB_MODULE(modname, initfunc, dbops) \
00055     PmModule *initPackmanModule(void) { \
00056         initfunc(PM_MODULE_DATABASE); \
00057         return pmRegisterModule(#modname, &(dbops), PM_MODULE_DATABASE); \
00058     }
00059 # define PM_INIT_PKG_MODULE(modname, initfunc, pkgops) \
00060     PmModule *initPackmanModule(void) { \
00061         initfunc(PM_MODULE_PACKAGE); \
00062         return pmRegisterModule(#modname, &(pkgops), PM_MODULE_PACKAGE); \
00063     }
00064 #endif
00065 
00071 enum _PmModuleType
00072 {
00073     PM_MODULE_PACKAGE,  
00074     PM_MODULE_DATABASE  
00075 };
00076 
00084 struct _PmDatabaseOps
00085 {
00095     PmStatus (*open)(PmDatabase *db);
00096 
00106     PmStatus (*create)(PmDatabase *db);
00107 
00117     PmStatus (*close)(PmDatabase *db);
00118 
00128     PmStatus (*rebuild)(PmDatabase *db);
00129 
00139     unsigned long (*getPackageCount)(PmDatabase *db);
00140 
00154     PmStatus (*addPackage)(PmDatabase *db, PmPackage *pkg);
00155     
00169     PmStatus (*removePackage)(PmDatabase *db, PmPackage *package);
00170     
00182     PmStatus (*findByName)(PmDatabase *db, const char *name,
00183                            PmMatches *matches);
00184 
00196     PmStatus (*findByGroup)(PmDatabase *db, const char *group,
00197                             PmMatches *matches);
00198 
00210     PmStatus (*findByFile)(PmDatabase *db, const char *file,
00211                            PmMatches *matches);
00212 
00224     PmStatus (*findByRequires)(PmDatabase *db, const char *requires,
00225                                PmMatches *matches);
00226 
00238     PmStatus (*findByProvides)(PmDatabase *db, const char *provides,
00239                                PmMatches *matches);
00240 
00252     PmStatus (*findByConflicts)(PmDatabase *db, const char *conflicts,
00253                                 PmMatches *matches);
00254 
00265     PmStatus (*getAllPackages)(PmDatabase *db, PmMatches *matches);
00266 
00277     PmPackage *(*firstPackage)(PmDatabase *db, PmMatches *matches);
00278 
00289     PmPackage *(*nextPackage)(PmDatabase *db, PmMatches *matches);
00290 
00296     PmStatus (*destroyMatches)(PmMatches *matches);
00297 
00303     void (*destroyPkgData)(void *data);
00304 
00312     void (*getFiles)(PmDatabase *db, PmPackage *pkg);
00313 
00321     void (*getRequiredDeps)(PmDatabase *db, PmPackage *pkg);
00322 
00330     void (*getProvidedDeps)(PmDatabase *db, PmPackage *pkg);
00331 
00345     char *(*getScript)(PmDatabase *db, PmPackage *package, PmScriptType type,
00346                        PmScriptEvent event, const char *trigger);
00347 };
00348 
00349 
00357 struct _PmPackageOps
00358 {
00369     PmStatus (*open)(PmPackage *package, const char *filename);
00370 
00378     PmStatus (*close)(PmPackage *package);
00379 
00388     int (*handlesFileType)(const char *filename);
00389 
00399     PmStatus (*extractFile)(PmPackage *package, const char *archivePath,
00400                             const char *fsPath);
00401 
00409     PmStatus (*extractAll)(PmPackage *package);
00410 
00423     char *(*getScript)(PmPackage *package, PmScriptType type,
00424                        PmScriptEvent event, const char *trigger);
00425 };
00426 
00427 
00437 struct _PmModule
00438 {
00439     PmModuleType type;             
00441     char *filename;                
00442     char *name;                    
00444     void *handle;                  
00446     unsigned int refCount;         
00448     union
00449     {
00450         PmDatabaseOps *db;         
00451         PmPackageOps  *package;    
00453     } ops;                         
00455     PmModule *prev;                
00456     PmModule *next;                
00457 };
00458 
00468 PmModule *pmRegisterModule(const char *name, void *ops, PmModuleType type);
00469 
00481 PmModule *pmLoadModule(const char *name, PmModuleType type);
00482 
00490 void pmUnloadModule(PmModule *module);
00491 
00504 PmModule *pmGetModule(const char *name, PmModuleType type);
00505 
00515 void pmLinkModule(PmModule **ptr);
00516 
00526 void pmUnlinkModule(PmModule **ptr);
00527 
00539 PmModule *pmGetFirstModule(PmModuleType type);
00540 
00551 void pmCleanupModules(void);
00552 
00563 void pmCleanup(void);
00564 
00565 #ifdef __cplusplus
00566 }
00567 #endif
00568 
00569 #endif /* _LIBPACKMAN_MODULE_H_ */

Generated on Tue Jul 2 03:15:23 2002 for libpackman by doxygen1.2.15-20020430