5 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_LUA_EXTENSIONS_BASED_ON_RPMLIB)
11 #define _MIRE_INTERNAL
23 #define _RPMLUA_INTERNAL
41 static int rpmluaext_vercmp(lua_State *
L)
48 if (lua_isstring(L, 1))
49 version1 = lua_tostring(L, 1);
51 (void)luaL_argerror(L, 1,
"first version string");
54 if (lua_isstring(L, 2))
55 version2 = lua_tostring(L, 2);
57 (void)luaL_argerror(L, 2,
"second version string");
65 lua_pushinteger(L, rc);
75 static int rpmluaext_digest(lua_State *L)
80 const char *digest = NULL;
81 size_t digest_len = 0;
87 if (lua_isstring(L, 1)) {
89 (void)luaL_argerror(L, 1,
"digest type");
94 (void)luaL_argerror(L, 1,
"digest type");
97 if (lua_isstring(L, 2))
98 filename = lua_tostring(L, 2);
100 (void)luaL_argerror(L, 2,
"data file");
105 fd =
Fopen(filename,
"r.fdio");
106 if (fd == NULL ||
Ferror(fd)) {
107 luaL_error(L,
"failed to create transaction");
113 while ((nb =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), fd)) > 0)
116 if (digest == NULL || digest[0] ==
'\0') {
117 luaL_error(L,
"failed to calculate digest");
125 lua_pushstring(L, digest);
137 static int rpmluaext_signature(lua_State *L)
147 if (lua_isstring(L, 1))
148 fn_data = lua_tostring(L, 1);
150 (void)luaL_argerror(L, 1,
"filename of data file");
153 if (lua_isstring(L, 2))
154 fn_sig = lua_tostring(L, 2);
157 if (lua_isstring(L, 3))
158 fn_pkey = lua_tostring(L, 3);
161 if (lua_isstring(L, 4))
162 fp = lua_tostring(L, 4);
168 luaL_error(L,
"failed to create transaction");
188 lua_State *L = (lua_State *)data;
194 luaL_checktype(L, -1, LUA_TTABLE);
195 n = lua_objlen(L, -1);
196 lua_pushinteger(L, n + 1);
197 lua_pushstring(L, msg);
211 static int rpmluaext_query(lua_State *L)
221 if ((qva = (
QVA_t)malloc(
sizeof(*qva))) == NULL) {
222 luaL_error(L,
"failed to allocate query configuration");
225 memset(qva,
'\0',
sizeof(*qva));
226 if (!lua_isstring(L, 1)) {
227 (void)luaL_argerror(L, 1,
"query format");
233 if (!lua_isboolean(L, 2)) {
234 (void)luaL_argerror(L, 1,
"query all flag");
237 if (lua_toboolean(L, 2)) {
242 if (lua_isstring(L, 3)) {
243 argv[0] = lua_tostring(L, 3);
249 luaL_error(L,
"failed to create transaction");
275 static const luaL_reg rpmluaext_registry[] = {
276 {
"vercmp", rpmluaext_vercmp },
277 {
"digest", rpmluaext_digest },
278 {
"signature", rpmluaext_signature },
279 {
"query", rpmluaext_query },
286 lua_pushvalue(lua->L, LUA_GLOBALSINDEX);
287 luaL_openlib(lua->L,
"rpm", rpmluaext_registry, 0);
const char bson_timestamp_t * ts
int rpmcliQuery(rpmts ts, QVA_t qva, const char **argv)
Display package information.
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data)
Set rpmlog callback function.
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
Initialize digest context.
void * rpmlogCallbackData
int(* rpmvercmp)(const char *a, const char *b)
Segmented string compare vector.
enum pgpHashAlgo_e pgpHashAlgo
9.4.
rpmlogLvl rpmlogRecPriority(rpmlogRec rec)
Retrieve log priority from rpmlog record.
void rpmlogGetCallback(rpmlogCallback *cb, rpmlogCallbackData *data)
Get rpmlog callback function and data.
Command line option information.
Yet Another syslog(3) API clone.
int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
Update context with next plain text buffer.
rpmRC rpmnsProbeSignature(void *_ts, const char *fn, const char *sigfn, const char *pubfn, const char *pubid, int flags)
Verify OpenPGP signature on a file.
struct rpmlogRec_s * rpmlogRec
const char const bson * data
int(* rpmlogCallback)(rpmlogRec rec, rpmlogCallbackData data)
Structure(s) used for dependency tag sets.
The FD_t File Handle data structure.
const char * qva_queryFormat
pgpHashAlgo pgpHashAlgoStringToNumber(const char *name, size_t name_len)
Convert a hash algorithm "foo" to the internal PGPHASHALGO_FOO number.
size_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd)
fread(3) clone.
int Fclose(FD_t fd)
fclose(3) clone.
enum rpmRC_e rpmRC
RPM return codes.
int Ferror(FD_t fd)
ferror(3) clone.
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
rpmts rpmtsCreate(void)
Create an empty transaction set.
struct rpmts_s * rpmts
The RPM Transaction Set.
void rpmluaextActivate(rpmlua lua)
Add RPM library based Lua extension.
int rpmtsOpenDB(rpmts ts, int dbmode)
Open the database used by the transaction.
int rpmDigestFinal(DIGEST_CTX ctx, void *datap, size_t *lenp, int asAscii)
Return digest and destroy context.
const char * rpmlogRecMessage(rpmlogRec rec)
Retrieve log message string from rpmlog record.