1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/*
* Perl interface to rpmlib
*
* $Id: rpm.xs,v 1.5 2000/02/10 22:13:48 jbj Exp $
*/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "rpmlib.h"
#include "rpmio.h"
#include "dbindex.h"
#include "header.h"
#include "popt.h"
/*
* External functions
*/
extern double constant(char *name, int arg);
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(package)
const char * package
PREINIT:
FD_t file_desc = NULL;
int rc;
int isSource;
int had_error = 0;
CODE:
/* 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);
if (rc != 0) {
had_error++;
}
if (file_desc != NULL) {
fdClose(file_desc);
}
} else {
had_error++;
}
ST(0) = sv_newmortal();
if (had_error) {
ST(0) = &PL_sv_undef;
} else {
sv_setref_pv(ST(0), "Header", (void*)RETVAL);
}
rpmTransactionSet
Transaction(header)
Header header
CODE:
ST(0) = sv_newmortal();
ST(0) = &PL_sv_undef;
rpmdb
dbOpen(root = "", forWrite = 0)
const char * root
int forWrite
PREINIT:
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);
}
int
dbInit(root = NULL)
char * root
CODE:
RETVAL = rpmdbInit(root, 0);
OUTPUT:
RETVAL
int
dbRebuild(root = NULL)
char * root
CODE:
RETVAL = rpmdbRebuild(root);
OUTPUT:
RETVAL
int
Error()
CODE:
RETVAL = rpmErrorCode();
OUTPUT:
RETVAL
void
Debug(enable = 1)
int enable
CODE:
if (enable) {
rpmSetVerbosity(RPMMESS_DEBUG);
} else {
rpmSetVerbosity(RPMMESS_QUIET);
}
char *
GetVar(var)
int var
CODE:
RETVAL = rpmGetVar(var);
OUTPUT:
RETVAL
void
SetVar(var, value)
int var
char * value
CODE:
rpmSetVar(var, value);
INCLUDE: db.xs
INCLUDE: header.xs
INCLUDE: transaction.xs
|