lib/rpmcli.h

Go to the documentation of this file.
00001 #ifndef H_RPMCLI
00002 #define H_RPMCLI
00003 
00008 #include "rpmlib.h"
00009 #include "rpmurl.h"
00010 #include "rpmmacro.h"
00011 #include "argv.h"
00012 
00016 /*@-redecl@*/
00017 /*@unchecked@*/
00018 extern int _noDirTokens;
00019 /*@=redecl@*/
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00028 /*@unchecked@*/
00029 extern struct poptOption                rpmcliAllPoptTable[];
00030 
00031 /*@unchecked@*/
00032 extern int ftsOpts;
00033 
00034 /*@unchecked@*/
00035 extern struct poptOption                rpmcliFtsPoptTable[];
00036 
00037 /*@unchecked@*/ /*@observer@*/ /*@null@*/
00038 extern const char * rpmcliPipeOutput;
00039 
00040 /*@unchecked@*/ /*@observer@*/ /*@null@*/
00041 extern const char * rpmcliRcfile;
00042 
00043 /*@unchecked@*/ /*@observer@*/ /*@null@*/
00044 extern const char * rpmcliRootDir;
00045 
00053 /*@null@*/
00054 poptContext
00055 rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable)
00056         /*@globals rpmCLIMacroContext, rpmGlobalMacroContext, h_errno, stderr, 
00057                 fileSystem, internalState @*/
00058         /*@modifies rpmCLIMacroContext, rpmGlobalMacroContext, stderr, 
00059                 fileSystem, internalState @*/;
00060 
00065 /*@mayexit@*/
00066 void rpmcliConfigured(void)
00067         /*@globals rpmCLIMacroContext, rpmGlobalMacroContext, h_errno,
00068                 fileSystem, internalState @*/
00069         /*@modifies rpmCLIMacroContext, rpmGlobalMacroContext,
00070                 fileSystem, internalState @*/;
00071 
00077 poptContext
00078 rpmcliFini(/*@only@*/ /*@null@*/ poptContext optCon)
00079         /*@modifies optCon @*/;
00080 
00084 #define RPMCLI_POPT_NODEPS              -1025
00085 #define RPMCLI_POPT_FORCE               -1026
00086 #define RPMCLI_POPT_NOMD5               -1027
00087 #define RPMCLI_POPT_NOSCRIPTS           -1028
00088 #define RPMCLI_POPT_NOSIGNATURE         -1029
00089 #define RPMCLI_POPT_NODIGEST            -1030
00090 #define RPMCLI_POPT_NOHDRCHK            -1031
00091 #define RPMCLI_POPT_NOCONTEXTS          -1032
00092 
00093 /* ==================================================================== */
00096 
00101 typedef enum rpmQVSources_e {
00102     RPMQV_PACKAGE = 0,  
00103     RPMQV_PATH,         
00104     RPMQV_ALL,          
00105     RPMQV_RPM,          
00106     RPMQV_GROUP,        
00107     RPMQV_WHATPROVIDES, 
00108     RPMQV_WHATREQUIRES, 
00109     RPMQV_TRIGGEREDBY,  
00110     RPMQV_DBOFFSET,     
00111     RPMQV_SPECFILE,     
00112     RPMQV_PKGID,        
00113     RPMQV_HDRID,        
00114     RPMQV_FILEID,       
00115     RPMQV_TID,          
00116     RPMQV_HDLIST,       
00117     RPMQV_FTSWALK       
00118 } rpmQVSources;
00119 
00123 typedef enum rpmVerifyAttrs_e {
00124     RPMVERIFY_NONE      = 0,            
00125     RPMVERIFY_MD5       = (1 << 0),     
00126     RPMVERIFY_FILESIZE  = (1 << 1),     
00127     RPMVERIFY_LINKTO    = (1 << 2),     
00128     RPMVERIFY_USER      = (1 << 3),     
00129     RPMVERIFY_GROUP     = (1 << 4),     
00130     RPMVERIFY_MTIME     = (1 << 5),     
00131     RPMVERIFY_MODE      = (1 << 6),     
00132     RPMVERIFY_RDEV      = (1 << 7),     
00133         /* bits 8-14 unused, reserved for rpmVerifyAttrs */
00134     RPMVERIFY_CONTEXTS  = (1 << 15),    
00135         /* bits 16-22 used in rpmVerifyFlags */
00136         /* bits 23-27 used in rpmQueryFlags */
00137     RPMVERIFY_READLINKFAIL= (1 << 28),  
00138     RPMVERIFY_READFAIL  = (1 << 29),    
00139     RPMVERIFY_LSTATFAIL = (1 << 30),    
00140     RPMVERIFY_LGETFILECONFAIL   = (1 << 31)     
00141 } rpmVerifyAttrs;
00142 #define RPMVERIFY_ALL           ~(RPMVERIFY_NONE)
00143 #define RPMVERIFY_FAILURES      \
00144   (RPMVERIFY_LSTATFAIL|RPMVERIFY_READFAIL|RPMVERIFY_READLINKFAIL|RPMVERIFY_LGETFILECONFAIL)
00145 
00150 typedef enum rpmQueryFlags_e {
00151 /*@-enummemuse@*/
00152     QUERY_FOR_DEFAULT   = 0,            
00153     QUERY_MD5           = (1 << 0),     
00154     QUERY_SIZE          = (1 << 1),     
00155     QUERY_LINKTO        = (1 << 2),     
00156     QUERY_USER          = (1 << 3),     
00157     QUERY_GROUP         = (1 << 4),     
00158     QUERY_MTIME         = (1 << 5),     
00159     QUERY_MODE          = (1 << 6),     
00160     QUERY_RDEV          = (1 << 7),     
00161         /* bits 8-14 unused, reserved for rpmVerifyAttrs */
00162     QUERY_CONTEXTS      = (1 << 15),    
00163     QUERY_FILES         = (1 << 16),    
00164     QUERY_DEPS          = (1 << 17),    
00165     QUERY_SCRIPT        = (1 << 18),    
00166     QUERY_DIGEST        = (1 << 19),    
00167     QUERY_SIGNATURE     = (1 << 20),    
00168     QUERY_PATCHES       = (1 << 21),    
00169     QUERY_HDRCHK        = (1 << 22),    
00170 /*@=enummemuse@*/
00171     QUERY_FOR_LIST      = (1 << 23),    
00172     QUERY_FOR_STATE     = (1 << 24),    
00173     QUERY_FOR_DOCS      = (1 << 25),    
00174     QUERY_FOR_CONFIG    = (1 << 26),    
00175     QUERY_FOR_DUMPFILES = (1 << 27)     
00176 } rpmQueryFlags;
00177 
00178 #define _QUERY_FOR_BITS \
00179    (QUERY_FOR_LIST|QUERY_FOR_STATE|QUERY_FOR_DOCS|QUERY_FOR_CONFIG|\
00180     QUERY_FOR_DUMPFILES)
00181 
00185 /*@unchecked@*/
00186 extern rpmQueryFlags rpmcliQueryFlags;
00187 
00192 typedef enum rpmVerifyFlags_e {
00193 /*@-enummemuse@*/
00194     VERIFY_DEFAULT      = 0,            
00195 /*@=enummemuse@*/
00196     VERIFY_MD5          = (1 << 0),     
00197     VERIFY_SIZE         = (1 << 1),     
00198     VERIFY_LINKTO       = (1 << 2),     
00199     VERIFY_USER         = (1 << 3),     
00200     VERIFY_GROUP        = (1 << 4),     
00201     VERIFY_MTIME        = (1 << 5),     
00202     VERIFY_MODE         = (1 << 6),     
00203     VERIFY_RDEV         = (1 << 7),     
00204         /* bits 8-14 unused, reserved for rpmVerifyAttrs */
00205     VERIFY_CONTEXTS     = (1 << 15),    
00206     VERIFY_FILES        = (1 << 16),    
00207     VERIFY_DEPS         = (1 << 17),    
00208     VERIFY_SCRIPT       = (1 << 18),    
00209     VERIFY_DIGEST       = (1 << 19),    
00210     VERIFY_SIGNATURE    = (1 << 20),    
00211     VERIFY_PATCHES      = (1 << 21),    
00212     VERIFY_HDRCHK       = (1 << 22),    
00213 /*@-enummemuse@*/
00214     VERIFY_FOR_LIST     = (1 << 23),    
00215     VERIFY_FOR_STATE    = (1 << 24),    
00216     VERIFY_FOR_DOCS     = (1 << 25),    
00217     VERIFY_FOR_CONFIG   = (1 << 26),    
00218     VERIFY_FOR_DUMPFILES= (1 << 27)     
00219 /*@=enummemuse@*/
00220         /* bits 28-31 used in rpmVerifyAttrs */
00221 } rpmVerifyFlags;
00222 
00223 #define VERIFY_ATTRS    \
00224   ( VERIFY_MD5 | VERIFY_SIZE | VERIFY_LINKTO | VERIFY_USER | VERIFY_GROUP | \
00225     VERIFY_MTIME | VERIFY_MODE | VERIFY_RDEV | VERIFY_CONTEXTS )
00226 #define VERIFY_ALL      \
00227   ( VERIFY_ATTRS | VERIFY_FILES | VERIFY_DEPS | VERIFY_SCRIPT | VERIFY_DIGEST |\
00228     VERIFY_SIGNATURE | VERIFY_HDRCHK )
00229 
00232 typedef struct rpmQVKArguments_s * QVA_t;
00233 
00242 typedef int (*QVF_t) (QVA_t qva, rpmts ts, Header h)
00243         /*@globals fileSystem @*/
00244         /*@modifies qva, ts, fileSystem @*/;
00245 
00254 typedef int (*QSpecF_t) (rpmts ts, QVA_t qva, const char * arg)
00255         /*@globals rpmGlobalMacroContext, h_errno,
00256                 fileSystem, internalState @*/
00257         /*@modifies ts, qva, rpmGlobalMacroContext,
00258                 fileSystem, internalState @*/;
00259 
00263 struct rpmQVKArguments_s {
00264     rpmQVSources qva_source;    
00265     int         qva_sourceCount;
00266     rpmQueryFlags qva_flags;    
00267     rpmfileAttrs qva_fflags;    
00268 /*@only@*/ /*@null@*/
00269     rpmdbMatchIterator qva_mi;  
00270 /*@refccounted@*/ /*@relnull@*/
00271     rpmgi qva_gi;               
00272     rpmRC qva_rc;               
00274 /*@null@*/
00275     QVF_t qva_showPackage;      
00276 /*@null@*/
00277     QSpecF_t qva_specQuery;     
00278 /*@unused@*/
00279     int qva_verbose;            
00280 /*@only@*/ /*@null@*/
00281     const char * qva_queryFormat;
00282     int sign;                   
00283     int trust;                  
00284 /*@observer@*/
00285     const char * passPhrase;    
00286 /*@observer@*/ /*@null@*/
00287     const char * qva_prefix;    
00288     char        qva_mode;
00298     char        qva_char;       
00299 };
00300 
00303 /*@unchecked@*/
00304 extern struct rpmQVKArguments_s rpmQVKArgs;
00305 
00308 /*@unchecked@*/
00309 extern struct poptOption rpmQVSourcePoptTable[];
00310 
00313 /*@unchecked@*/
00314 extern int specedit;
00315 
00318 /*@unchecked@*/
00319 extern struct poptOption rpmQueryPoptTable[];
00320 
00323 /*@unchecked@*/
00324 extern struct poptOption rpmVerifyPoptTable[];
00325 
00337 int rpmcliShowMatches(QVA_t qva, rpmts ts)
00338         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00339         /*@modifies qva, rpmGlobalMacroContext, fileSystem, internalState @*/;
00340 
00345 void rpmDisplayQueryTags(FILE * fp)
00346         /*@globals fileSystem @*/
00347         /*@modifies *fp, fileSystem @*/;
00348 
00361 int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
00362         /*@globals rpmGlobalMacroContext, h_errno,
00363                 fileSystem, internalState @*/
00364         /*@modifies qva, ts, rpmGlobalMacroContext,
00365                 fileSystem, internalState @*/;
00366 
00375 int showQueryPackage(QVA_t qva, rpmts ts, Header h)
00376         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00377         /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
00378 
00386 int rpmcliArgIter(rpmts ts, QVA_t qva, /*@null@*/ ARGV_t argv)
00387         /*@globals ftsOpts, rpmGlobalMacroContext, h_errno,
00388                 fileSystem, internalState @*/
00389         /*@modifies ts, qva, ftsOpts, rpmGlobalMacroContext,
00390                 fileSystem, internalState @*/;
00391 
00400 int rpmcliQuery(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv)
00401         /*@globals rpmGlobalMacroContext, h_errno,
00402                 fileSystem, internalState @*/
00403         /*@modifies ts, qva, rpmGlobalMacroContext,
00404                 fileSystem, internalState @*/;
00405 
00415 /*@-incondefs@*/
00416 int rpmVerifyFile(const rpmts ts, rpmfi fi,
00417                 /*@out@*/ rpmVerifyAttrs * res, rpmVerifyAttrs omitMask)
00418         /*@globals h_errno, fileSystem, internalState @*/
00419         /*@modifies ts, fi, *res, fileSystem, internalState @*/
00420         /*@requires maxSet(res) >= 0 @*/;
00421 /*@=incondefs@*/
00422 
00430 int showVerifyPackage(QVA_t qva, rpmts ts, Header h)
00431         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00432         /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
00433 
00442 int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd, const char * fn)
00443         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00444         /*@modifies qva, ts, fd, rpmGlobalMacroContext, h_errno,
00445                 fileSystem, internalState @*/;
00446 
00455 int rpmcliVerify(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv)
00456         /*@globals rpmGlobalMacroContext, h_errno,
00457                 fileSystem, internalState @*/
00458         /*@modifies ts, qva, rpmGlobalMacroContext,
00459                 fileSystem, internalState @*/;
00460 
00462 /* ==================================================================== */
00465 
00469 struct rpmBuildArguments_s {
00470     rpmQueryFlags qva_flags;    
00471     int buildAmount;            
00472 /*@null@*/
00473     const char * buildRootOverride; 
00474 /*@null@*/
00475     char * targets;             
00476 /*@observer@*/
00477     const char * passPhrase;    
00478 /*@only@*/ /*@null@*/
00479     const char * cookie;        
00480     int force;                  
00481     int noBuild;                
00482     int noDeps;                 
00483     int noLang;                 
00484     int shortCircuit;           
00485     int sign;                   
00486     int useCatalog;             
00487     char buildMode;             
00488     char buildChar;             
00489 /*@observer@*/ /*@null@*/
00490     const char * rootdir;
00491 };
00492 
00495 typedef struct rpmBuildArguments_s *    BTA_t;
00496 
00499 /*@unchecked@*/
00500 extern struct rpmBuildArguments_s       rpmBTArgs;
00501 
00504 /*@unchecked@*/
00505 extern struct poptOption                rpmBuildPoptTable[];
00506 
00508 /* ==================================================================== */
00511 /* --- install/upgrade/erase modes */
00512 
00513 /*@unchecked@*/
00514 extern int rpmcliPackagesTotal;
00515 /*@unchecked@*/
00516 extern int rpmcliHashesCurrent;
00517 /*@unchecked@*/
00518 extern int rpmcliHashesTotal;
00519 /*@unchecked@*/
00520 extern int rpmcliProgressCurrent;
00521 /*@unchecked@*/
00522 extern int rpmcliProgressTotal;
00523 
00538 /*@null@*/
00539 void * rpmShowProgress(/*@null@*/ const void * arg,
00540                 const rpmCallbackType what,
00541                 const unsigned long amount,
00542                 const unsigned long total,
00543                 /*@null@*/ fnpyKey key,
00544                 /*@null@*/ void * data)
00545         /*@globals rpmcliHashesCurrent,
00546                 rpmcliProgressCurrent, rpmcliProgressTotal,
00547                 h_errno, fileSystem, internalState @*/
00548         /*@modifies rpmcliHashesCurrent,
00549                 rpmcliProgressCurrent, rpmcliProgressTotal,
00550                 fileSystem, internalState @*/;
00551 
00560 int rpmInstallSource(rpmts ts, const char * arg,
00561                 /*@null@*/ /*@out@*/ const char ** specFilePtr,
00562                 /*@null@*/ /*@out@*/ const char ** cookie)
00563         /*@globals rpmGlobalMacroContext, h_errno,
00564                 fileSystem, internalState@*/
00565         /*@modifies ts, *specFilePtr, *cookie, rpmGlobalMacroContext,
00566                 fileSystem, internalState @*/;
00567 
00571 struct rpmInstallArguments_s {
00572     rpmtransFlags transFlags;
00573     rpmprobFilterFlags probFilter;
00574     rpmInstallInterfaceFlags installInterfaceFlags;
00575     rpmEraseInterfaceFlags eraseInterfaceFlags;
00576     rpmQueryFlags qva_flags;    
00577     uint_32 rbtid;              
00578     int numRelocations;
00579     int noDeps;
00580     int incldocs;
00581 /*@owned@*/ /*@null@*/
00582     rpmRelocation * relocations;
00583 /*@null@*/
00584     const char * prefix;
00585 /*@observer@*/ /*@null@*/
00586     const char * rootdir;
00587 };
00588 
00596 int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia,
00597                 /*@null@*/ const char ** fileArgv)
00598         /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
00599                 fileSystem, internalState@*/
00600         /*@modifies ts, ia, rpmcliPackagesTotal, rpmGlobalMacroContext,
00601                 fileSystem, internalState @*/;
00602 
00610 int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
00611                 /*@null@*/ const char ** argv)
00612         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00613         /*@modifies ts, ia, rpmGlobalMacroContext,
00614                 fileSystem, internalState @*/;
00615 
00619 /*@-fielduse@*/
00620 typedef /*@abstract@*/ struct IDT_s {
00621     unsigned int instance;      
00622 /*@owned@*/ /*@null@*/
00623     const char * key;           
00624     Header h;                   
00625     union {
00626         uint_32 u32;            
00627     } val;
00628 } * IDT;
00629 /*@=fielduse@*/
00630 
00634 typedef /*@abstract@*/ struct IDTindex_s {
00635     int delta;                  
00636     int size;                   
00637     int alloced;                
00638     int nidt;                   
00639 /*@only@*/ /*@null@*/
00640     IDT idt;                    
00641 } * IDTX;
00642 
00648 /*@null@*/
00649 IDTX IDTXfree(/*@only@*/ /*@null@*/ IDTX idtx)
00650         /*@modifies idtx @*/;
00651 
00656 /*@only@*/
00657 IDTX IDTXnew(void)
00658         /*@*/;
00659 
00666 /*@only@*/ /*@null@*/
00667 IDTX IDTXgrow(/*@only@*/ /*@null@*/ IDTX idtx, int need)
00668         /*@modifies idtx @*/;
00669 
00675 /*@only@*/ /*@null@*/
00676 IDTX IDTXsort(/*@only@*/ /*@null@*/ IDTX idtx)
00677         /*@modifies idtx @*/;
00678 
00685 /*@only@*/ /*@null@*/
00686 IDTX IDTXload(rpmts ts, rpmTag tag)
00687         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00688         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState  @*/;
00689 
00697 /*@only@*/ /*@null@*/
00698 IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
00699         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00700         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
00701 
00709 int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia,
00710                 /*@null@*/ const char ** argv)
00711         /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
00712                 fileSystem, internalState @*/
00713         /*@modifies ts, ia, rpmcliPackagesTotal, rpmGlobalMacroContext,
00714                 fileSystem, internalState @*/;
00715 
00718 /*@unchecked@*/
00719 extern struct rpmInstallArguments_s rpmIArgs;
00720 
00723 /*@unchecked@*/
00724 extern struct poptOption rpmInstallPoptTable[];
00725 
00727 /* ==================================================================== */
00730 /* --- database modes */
00731 
00735 struct rpmDatabaseArguments_s {
00736     int init;                   
00737     int rebuild;                
00738     int verify;                 
00739 };
00740 
00743 /*@unchecked@*/
00744 extern struct rpmDatabaseArguments_s rpmDBArgs;
00745 
00748 /*@unchecked@*/
00749 extern struct poptOption rpmDatabasePoptTable[];
00750 
00752 /* ==================================================================== */
00755 
00764 rpmRC rpmcliImportPubkey(const rpmts ts,
00765                 const unsigned char * pkt, ssize_t pktlen)
00766         /*@globals RPMVERSION, rpmGlobalMacroContext, h_errno,
00767                 fileSystem, internalState @*/
00768         /*@modifies ts, rpmGlobalMacroContext,
00769                 fileSystem, internalState @*/;
00770 
00774 /*@-typeuse@*/
00775 typedef enum rpmSignFlags_e {
00776     RPMSIGN_NONE                = 0,
00777     RPMSIGN_CHK_SIGNATURE       = 'K',  
00778     RPMSIGN_NEW_SIGNATURE       = 'R',  
00779     RPMSIGN_ADD_SIGNATURE       = 'A',  
00780     RPMSIGN_DEL_SIGNATURE       = 'D',  
00781     RPMSIGN_IMPORT_PUBKEY       = 'I',  
00782 } rpmSignFlags;
00783 /*@=typeuse@*/
00784 
00787 /*@unchecked@*/
00788 extern struct poptOption rpmSignPoptTable[];
00789 
00797 int rpmcliSign(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv)
00798         /*@globals RPMVERSION, rpmGlobalMacroContext, h_errno,
00799                 fileSystem, internalState @*/
00800         /*@modifies ts, qva, rpmGlobalMacroContext,
00801                 fileSystem, internalState @*/;
00802 
00805 #ifdef __cplusplus
00806 }
00807 #endif
00808 
00809 #endif  /* H_RPMCLI */

Generated on Fri Oct 12 08:44:53 2007 for rpm by  doxygen 1.5.2