diff options
author | gafton <devnull@localhost> | 1999-07-16 08:44:54 +0000 |
---|---|---|
committer | gafton <devnull@localhost> | 1999-07-16 08:44:54 +0000 |
commit | 1d18d03f9d3632cea29e45db952a22a601f09fbe (patch) | |
tree | ff74f7219866ad1de394703f7e5511bd1eec13fa /perl/rpm.xs | |
parent | dfb29dcf5b7d676ca572bdb324612df4e83c480c (diff) | |
download | rpm-1d18d03f9d3632cea29e45db952a22a601f09fbe.tar.gz rpm-1d18d03f9d3632cea29e45db952a22a601f09fbe.tar.bz2 rpm-1d18d03f9d3632cea29e45db952a22a601f09fbe.zip |
Added rpmdb traversal
CVS patchset: 3173
CVS date: 1999/07/16 08:44:54
Diffstat (limited to 'perl/rpm.xs')
-rw-r--r-- | perl/rpm.xs | 300 |
1 files changed, 67 insertions, 233 deletions
diff --git a/perl/rpm.xs b/perl/rpm.xs index d4c6573f5..d0870d0df 100644 --- a/perl/rpm.xs +++ b/perl/rpm.xs @@ -1,7 +1,7 @@ /* * Perl interface to rpmlib * - * $Id: rpm.xs,v 1.3 1999/07/14 22:06:21 gafton Exp $ + * $Id: rpm.xs,v 1.4 1999/07/16 08:44:54 gafton Exp $ */ #include "EXTERN.h" @@ -18,8 +18,6 @@ #include <sys/stat.h> #include <fcntl.h> -typedef rpmTransactionSet_s * Transaction; - /* * External functions */ @@ -30,12 +28,19 @@ MODULE = rpm PACKAGE = rpm PROTOTYPES: ENABLE +BOOT: +# The following message will be printed when the +# bootstrap function executes. + if (rpmReadConfigFiles(NULL, NULL) != 0) { + XSRETURN_NO; + } + double constant(name,arg) char * name int arg -Header * +Header Header(package) const char * package PREINIT: @@ -44,10 +49,10 @@ Header(package) int isSource; int had_error = 0; CODE: - New(1,RETVAL,1,Header); + /* New(1,RETVAL,1,Header); */ file_desc = fdOpen(package, O_RDONLY, 0); if (file_desc != NULL && RETVAL != NULL) { - rc = rpmReadPackageHeader(file_desc, RETVAL, &isSource, NULL, NULL); + rc = rpmReadPackageHeader(file_desc, &RETVAL, &isSource, NULL, NULL); if (rc != 0) { had_error++; } @@ -61,255 +66,84 @@ Header(package) if (had_error) { ST(0) = &PL_sv_undef; } else { - sv_setref_pv(ST(0), "HeaderPtr", (void*)RETVAL); + sv_setref_pv(ST(0), "Header", (void*)RETVAL); } -Transaction * +rpmTransactionSet Transaction(header) - Header * header - - -MODULE = rpm PACKAGE = HeaderPtr PREFIX = Header + Header header + CODE: + ST(0) = sv_newmortal(); + ST(0) = &PL_sv_undef; -AV * -HeaderItemByValRef(header, item) - Header * header - int item +rpmdb +dbOpen(root = "", forWrite = 0) + const char * root + int forWrite PREINIT: - int_32 count, type; - int rc; - void * value; - char ** src; - AV * array; -CODE: - rc = headerGetEntry(*header, item, &type, &value, &count); - array = newAV(); - if (rc != 0) { - switch(type) { - case RPM_CHAR_TYPE: - while (count-- > 0) { - av_push(array, newSViv((char) (int) value)); - value++; - } - break; - case RPM_INT8_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_8) (int) value)); - value++; - } - break; - case RPM_INT16_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_16) (int) value)); - value++; - } - break; - case RPM_INT32_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_32)value)); - value++; - } - break; - case RPM_STRING_TYPE: - av_push(array, newSVpv((char *)value, 0)); - break; - case RPM_BIN_TYPE: - /* XXX: this looks mostly unused - how do we deal with it? */ - break; - case RPM_STRING_ARRAY_TYPE: - case RPM_I18NSTRING_TYPE: - src = (char **) value; - while (count--) { - av_push(array, newSVpv(*src++, 0)); - } - free(value); - break; - } + int retval; + CODE: + retval = rpmdbOpen(root, &RETVAL, forWrite ? O_RDWR | O_CREAT : O_RDONLY, 0644); + printf("\nretval is %d\n", retval); + ST(0) = sv_newmortal(); + if (retval != 0) { + ST(0) = &PL_sv_undef; + } else { + sv_setref_pv(ST(0), "rpmdb", (void *)RETVAL); } - RETVAL = array; + + +int +dbInit(root = NULL) + char * root + CODE: + RETVAL = rpmdbInit(root, 0); OUTPUT: RETVAL -AV * -HeaderItemByNameRef(header, tag) - Header * header - const char * tag - PREINIT: - int_32 count, type, item = -1; - int rc, i; - void * value; - char ** src; - AV * array; +int +dbRebuild(root = NULL) + char * root CODE: - /* walk first through the list of items and get the proper value */ - for (i = 0; i < rpmTagTableSize; i++) { - if (strcasecmp(tag, rpmTagTable[i].name) == 0) { - item = rpmTagTable[i].val; - break; - } - } - rc = headerGetEntry(*header, item, &type, &value, &count); - array = newAV(); - if (rc != 0) { - switch(type) { - case RPM_CHAR_TYPE: - while (count-- > 0) { - av_push(array, newSViv((char) (int) value)); - value++; - } - break; - case RPM_INT8_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_8) (int) value)); - value++; - } - break; - case RPM_INT16_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_16) (int) value)); - value++; - } - break; - case RPM_INT32_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_32)value)); - value++; - } - break; - case RPM_STRING_TYPE: - av_push(array, newSVpv((char *)value, 0)); - break; - case RPM_BIN_TYPE: - /* XXX: this looks mostly unused - how do we deal with it? */ - break; - case RPM_STRING_ARRAY_TYPE: - case RPM_I18NSTRING_TYPE: - src = (char **) value; - while (count--) { - av_push(array, newSVpv(*src++, 0)); - } - free(value); - break; - } - } - RETVAL = array; + RETVAL = rpmdbRebuild(root); OUTPUT: RETVAL -HV * -HeaderListRef(header) - Header * header - PREINIT: - HeaderIterator iterator; - int_32 tag, type, count; - void *value; +int +Error() CODE: - RETVAL = newHV(); - iterator = headerInitIterator(*header); - while (headerNextIterator(iterator, &tag, &type, &value, &count)) { - SV ** sv; - AV * array; - char ** src; - char * tagStr = tagName(tag); - array = newAV(); - switch(type) { - case RPM_CHAR_TYPE: - while (count-- > 0) { - av_push(array, newSViv((char) (int) value)); - value++; - } - break; - case RPM_INT8_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_8) (int) value)); - value++; - } - break; - case RPM_INT16_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_16) (int) value)); - value++; - } - break; - case RPM_INT32_TYPE: - while (count-- > 0) { - av_push(array, newSViv((int_32)value)); - value++; - } - break; - case RPM_STRING_TYPE: - av_push(array, newSVpv((char *)value, 0)); - break; - case RPM_BIN_TYPE: - /* XXX: this looks mostly unused - how do we deal with it? */ - break; - case RPM_STRING_ARRAY_TYPE: - case RPM_I18NSTRING_TYPE: - /* we have to build an array first */ - src = (char **) value; - while (count--) { - av_push(array, newSVpv(*src++, 0)); - } - free(value); - break; - } - sv = hv_store(RETVAL, tagStr, strlen(tagStr), newRV_inc((SV*)array), 0); - } - headerFreeIterator(iterator); + RETVAL = rpmErrorCode(); OUTPUT: RETVAL -AV * -HeaderTagsRef(header) - Header * header - PREINIT: - HeaderIterator iterator; - int_32 tag, type; - void *value; - CODE: - RETVAL = newAV(); - iterator = headerInitIterator(*header); - while (headerNextIterator(iterator, &tag, &type, &value, NULL)) { - av_push(RETVAL, newSVpv(tagName(tag), 0)); - if (type == RPM_STRING_ARRAY_TYPE || type == RPM_I18NSTRING_TYPE) - free(value); +void +Debug(enable = 1) + int enable + CODE: + if (enable) { + rpmSetVerbosity(RPMMESS_DEBUG); + } else { + rpmSetVerbosity(RPMMESS_QUIET); } - headerFreeIterator(iterator); + +char * +GetVar(var) + int var + CODE: + RETVAL = rpmGetVar(var); OUTPUT: RETVAL -MODULE = rpm PACKAGE = TransactionPtr PREFIX = Trans - -int -TransAdd(trans, header) - Transaction * trans - Header * header - -int -TransDepCheck(trans) - Transaction * trans - -int -TransRun(trans) - Transaction * trans - -Transaction * -TransOrder(trans) - Transaction *trans - -int -TransDealloc(trans) - Transaction * trans +void +SetVar(var, value) + int var + char * value + CODE: + rpmSetVar(var, value); -int -TransGetAttr(trans, name) - Transaction * trans - const char * name +INCLUDE: db.xs +INCLUDE: header.xs +INCLUDE: transaction.xs -int -TransSetAttr(trans, name, val) - Transaction * trans - const char * name - void * val |