8 #if defined(HAVE_ICONV)
10 #if defined(__LCLINT__)
12 extern iconv_t iconv_open(
const char *__tocode,
const char *__fromcode)
15 extern size_t iconv(iconv_t __cd,
char ** __inbuf,
16 size_t * __inbytesleft,
18 size_t * __outbytesleft)
22 extern int iconv_close( iconv_t __cd)
28 #if defined(HAVE_LANGINFO_H)
30 #if defined(__LCLINT__)
32 extern char *nl_langinfo (nl_item __item)
38 #define _MIRE_INTERNAL
47 #define _RPMTAG_INTERNAL
49 #define _RPMEVR_INTERNAL
93 const char * istr =
NULL;
98 if (fmt ==
NULL || *fmt ==
'\0')
103 return xstrdup(
_(
"(not a number)"));
121 istr = he->
p.
argv[ix];
124 {
static char hex[] =
"0123456789abcdef";
125 const char *
s = he->
p.
str;
134 *
t++ = hex[ (i >> 4) & 0xf ];
135 *
t++ = hex[ (
i ) & 0xf ];
145 char myfmt[] =
"%llX";
146 myfmt[3] = ((fmt !=
NULL && *fmt !=
'\0') ? *fmt :
'd');
203 const char * strftimeFormat)
215 { time_t dateint = he->
p.
ui64p[0];
216 tstruct = localtime(&dateint);
220 (
void) strftime(buf,
sizeof(buf) - 1, strftimeFormat, tstruct);
221 buf[
sizeof(
buf) - 1] =
'\0';
275 xx =
snprintf(val, nb,
"%llu", (
unsigned long long)he->
p.
ui64p[0]);
279 const char *
s = he->
p.
str;
284 for (s = he->
p.
str; (c = (
int)*s) != 0; s++) {
292 for (s = he->
p.
str; (c = (
int)*s) != 0; s++) {
293 if (c == (
int)
'\'') {
309 { HEADER_EXT_FORMAT,
"octal",
311 { HEADER_EXT_FORMAT,
"oct",
313 { HEADER_EXT_FORMAT,
"hex",
315 { HEADER_EXT_FORMAT,
"decimal",
317 { HEADER_EXT_FORMAT,
"dec",
319 { HEADER_EXT_FORMAT,
"date",
321 { HEADER_EXT_FORMAT,
"day",
323 { HEADER_EXT_FORMAT,
"shescape",
325 { HEADER_EXT_LAST,
NULL, { NULL } }
339 char * (*spew_strcpy) (
char *
t,
const char *
s,
int lvl)
356 while ((c = (
int) *s++) != (
int)
'\0') {
359 case '>': len +=
sizeof(
"<") - 1;
break;
360 case '&': len +=
sizeof(
"&") - 1;
break;
361 default: len += 1;
break;
381 while ((c = (
int) *s++) != (
int)
'\0') {
383 case '<': te =
stpcpy(te,
"<");
break;
384 case '>': te =
stpcpy(te,
">");
break;
385 case '&': te =
stpcpy(te,
"&");
break;
386 default: *te++ = (char) c;
break;
396 .spew_init =
"<rpmHeader>\n",
397 .spew_fini =
"</rpmHeader>\n",
417 while ((c = (
int) *s++) != (
int)
'\0')
445 while ((c = (
int) *s++) != (
int)
'\0') {
448 for (i = 0; i < lvl; i++) {
465 .spew_init =
"- !!omap\n",
485 while ((c = (
int) *s++) != (
int)
'\0') {
494 default: len += 1;
break;
515 while ((c = (
int) *s++) != (
int)
'\0') {
517 case '\b': *te++ =
'\\'; *te++ =
'b';
break;
518 case '\t': *te++ =
'\\'; *te++ =
't';
break;
519 case '\n': *te++ =
'\\'; *te++ =
'n';
break;
520 case '\f': *te++ =
'\\'; *te++ =
'f';
break;
521 case '\r': *te++ =
'\\'; *te++ =
'r';
break;
522 case '"': *te++ =
'\\'; *te++ =
'"';
break;
523 case '\\': *te++ =
'\\'; *te++ =
'\\';
break;
524 default: *te++ = (char) c;
break;
536 .spew_init =
"db.%{?__mongodb_collection}%{!?__mongodb_collection:packages}.save({\n",
537 .spew_fini =
"});\n",
556 while ((c = (
int) *s++) != (
int)
'\0') {
559 default: len += 1;
break;
579 while ((c = (
int) *s++) != (
int)
'\0') {
581 case '\'': *te++ = (char) c;
582 default: *te++ = (char) c;
break;
604 char *perms =
xstrdup(
"----------");
608 else if (S_ISDIR(mode))
612 else if (S_ISFIFO(mode))
618 else if (S_ISCHR(mode))
620 else if (S_ISBLK(mode))
625 if (mode & S_IRUSR) perms[1] =
'r';
626 if (mode & S_IWUSR) perms[2] =
'w';
627 if (mode & S_IXUSR) perms[3] =
'x';
629 if (mode & S_IRGRP) perms[4] =
'r';
630 if (mode & S_IWGRP) perms[5] =
'w';
631 if (mode & S_IXGRP) perms[6] =
'x';
633 if (mode & S_IROTH) perms[7] =
'r';
634 if (mode & S_IWOTH) perms[8] =
'w';
635 if (mode & S_IXOTH) perms[9] =
'x';
638 perms[3] = ((mode & S_IXUSR) ?
's' :
'S');
641 perms[6] = ((mode & S_IXGRP) ?
's' :
'S');
644 perms[9] = ((mode & S_IXOTH) ?
't' :
'T');
658 int ix = (he->
ix > 0 ? he->
ix : 0);
666 if (anint & RPMSENSE_TRIGGERPREIN)
668 else if (anint & RPMSENSE_TRIGGERIN)
670 else if (anint & RPMSENSE_TRIGGERUN)
672 else if (anint & RPMSENSE_TRIGGERPOSTUN)
689 int ix = (he->
ix > 0 ? he->
ix : 0);
712 int ix = (he->
ix >= 0 ? he->
ix : 0);
754 int ix = (he->
ix > 0 ? he->
ix : 0);
756 const unsigned char *
s;
764 s = (
unsigned char *) he->
p.
ui8p;
774 if (b64decode(enc, (
void *)&s, &ns))
779 #if defined(SUPPORT_I18NSTRING_TYPE)
787 return xstrdup(
_(
"(invalid type)"));
807 int ix = (he->
ix > 0 ? he->
ix : 0);
818 val =
xstrdup(
_(
"(invalid type :base64)"));
822 ns =
sizeof(he->
p.
ui64p[0]);
825 ns = strlen(he->
p.
str);
832 nt = ((ns + 2) / 3) * 4;
836 if (b64encode_chars_per_line > 0 && b64encode_eolstr !=
NULL) {
837 lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
838 if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
840 nt += lc * strlen(b64encode_eolstr);
848 {
unsigned char * _data =
xcalloc(1, ns+1);
850 memcpy(_data, he->
p.
ptr, ns);
852 if ((enc = b64encode(_data, ns)) !=
NULL) {
857 _data =
_free(_data);
868 #if defined(__GLIBC__)
876 static const char * _iconv_tocode =
"UTF-8";
878 static const char * _iconv_fromcode =
NULL;
886 const char *
s = buffer;
888 #if defined(HAVE_ICONV)
898 #ifdef HAVE_LANGINFO_H
900 if (fromcode ==
NULL)
901 fromcode = nl_langinfo (CODESET);
905 if ((fd = iconv_open(tocode, fromcode)) != (iconv_t)-1) {
906 size_t ileft = strlen(s);
908 char *
te = t =
xmalloc((nt + 1) *
sizeof(*t));
909 size_t oleft = ileft;
911 const char *sprev =
NULL;
912 int _iconv_errno = 0;
915 while (done == 0 && _iconv_errno == 0) {
916 err = iconv(fd, (
char **)&s, &ileft, &te, &oleft);
917 if (err == (
size_t)-1) {
920 {
size_t used = (size_t)(te - t);
922 t =
xrealloc(t, (nt + 1) *
sizeof(*t));
931 _iconv_errno =
errno;
943 _iconv_errno =
errno;
948 fprintf(stderr,
"warning: %s: from iconv(%s -> %s) for \"%s\" -> \"%s\"\n", strerror(_iconv_errno), fromcode, tocode, buffer, t);
966 int ix = (he->
ix > 0 ? he->
ix : 0);
997 int ix = (he->
ix > 0 ? he->
ix : 0);
1004 val =
xstrdup(
_(
"(not a string)"));
1018 int ix = (he->
ix > 0 ? he->
ix : 0);
1019 const char * xtag =
NULL;
1021 const char *
s =
NULL;
1041 {
int cpl = b64encode_chars_per_line;
1042 b64encode_chars_per_line = 0;
1046 b64encode_chars_per_line = cpl;
1051 anint = (uint64_t)he->
p.
ui8p[ix];
1057 anint = (uint64_t)he->
p.
ui32p[ix];
1063 val =
xstrdup(
_(
"(invalid xml type)"));
1069 static int tlen = 64;
1075 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1085 nb += strlen(xtag) +
sizeof(
"\t</>");
1090 nb += 2 * strlen(xtag) +
sizeof(
"\t<></>");
1117 int element = he->
ix;
1118 int ix = (he->
ix > 0 ? he->
ix : 0);
1119 const char * xtag =
NULL;
1121 const char *
s =
NULL;
1140 if (strchr(
"[", s[0]))
1143 while ((c = (
int) *s++) != (
int)
'\0') {
1149 if (s[0] ==
' ' || s[0] ==
'\t')
1154 if (s[0] !=
' ' && s[0] !=
'\0' && s[1] !=
'"')
1166 }
else if (he->
ix < 0) {
1179 if (he->
ix < 0) lvl++;
1184 xtag = (element >= 0 ?
"- " :
NULL);
1191 {
int cpl = b64encode_chars_per_line;
1192 b64encode_chars_per_line = 0;
1197 b64encode_chars_per_line = cpl;
1202 anint = (uint64_t)he->
p.
ui8p[ix];
1208 anint = (uint64_t)he->
p.
ui32p[ix];
1214 val =
xstrdup(
_(
"(invalid yaml type)"));
1220 static int tlen = 64;
1223 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1226 xtag = (element >= 0 ?
"- " :
NULL);
1235 nb +=
sizeof(
" ") - 1;
1236 nb +=
sizeof(
"- ~") - 1;
1245 nb +=
sizeof(
" ") - 1;
1278 int element = he->
ix;
1279 int ix = (he->
ix > 0 ? he->
ix : 0);
1281 const char *
s =
NULL;
1301 {
int cpl = b64encode_chars_per_line;
1302 b64encode_chars_per_line = 0;
1305 b64encode_chars_per_line = cpl;
1308 anint = (uint64_t)he->
p.
ui8p[ix];
1314 anint = (uint64_t)he->
p.
ui32p[ix];
1320 val =
xstrdup(
_(
"(invalid json type)"));
1326 static int tlen = 64;
1328 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1338 t = te =
alloca(nb +
sizeof(
"\"\","));
1340 if (c !=
'\0') *te++ =
c;
1345 if (c !=
'\0') *te++ =
c;
1370 int ix = (he->
ix > 0 ? he->
ix : 0);
1379 unsigned int v = (
unsigned int) *pkt;
1382 unsigned int hlen = 0;
1387 plen =
pgpLen(pkt+1, &hlen);
1389 tag = (v >> 2) & 0xf;
1390 plen = (1 << (v & 0x3));
1394 pktlen = 1 + plen + hlen;
1398 val =
xstrdup(
_(
"(not an OpenPGP signature)"));
1403 const char *tempstr;
1412 switch (sigp->pubkey_algo) {
1424 if (t + 5 >= val + nb)
1427 switch (sigp->hash_algo) {
1439 if (t + strlen (
", ") + 1 >= val + nb)
1445 { time_t dateint =
pgpGrab(sigp->time,
sizeof(sigp->time));
1446 struct tm * tstruct = localtime(&dateint);
1448 (
void) strftime(t, (nb - (t - val)),
"%c", tstruct);
1451 if (t + strlen (
", Key ID ") + 1 >= val + nb)
1453 t =
stpcpy(t,
", Key ID ");
1454 tempstr =
pgpHexStr(sigp->signid,
sizeof(sigp->signid));
1455 if (t + strlen (tempstr) > val + nb)
1476 int ix = (he->
ix > 0 ? he->
ix : 0);
1481 val =
xstrdup(
_(
"(invalid type)"));
1490 if (anint & RPMSENSE_SCRIPT_PRE)
1491 te =
stpcpy(te,
"(pre)");
1492 else if (anint & RPMSENSE_SCRIPT_POST)
1493 te =
stpcpy(te,
"(post)");
1494 else if (anint & RPMSENSE_SCRIPT_PREUN)
1495 te =
stpcpy(te,
"(preun)");
1496 else if (anint & RPMSENSE_SCRIPT_POSTUN)
1497 te =
stpcpy(te,
"(postun)");
1507 if (anint & RPMSENSE_SENSEMASK)
1528 int ix = (he->
ix > 0 ? he->
ix : 0);
1533 val =
xstrdup(
_(
"(invalid type)"));
1541 if (anint & RPMSENSE_SCRIPT_PRE)
1543 else if (anint & RPMSENSE_SCRIPT_POST)
1545 else if (anint & RPMSENSE_SCRIPT_PREUN)
1546 te =
stpcpy(te,
"preun");
1547 else if (anint & RPMSENSE_SCRIPT_POSTUN)
1548 te =
stpcpy(te,
"postun");
1549 else if (anint & RPMSENSE_SCRIPT_VERIFY)
1550 te =
stpcpy(te,
"verify");
1551 else if (anint & RPMSENSE_RPMLIB)
1552 te =
stpcpy(te,
"rpmlib");
1553 else if (anint & RPMSENSE_INTERP)
1554 te =
stpcpy(te,
"interp");
1555 else if (anint & (RPMSENSE_FIND_PROVIDES | RPMSENSE_FIND_REQUIRES))
1558 te =
stpcpy(te,
"manual");
1568 static const char * bfstring(
unsigned int x,
const char * xbf)
1570 const char *
s = xbf;
1571 static char digits[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
1572 static char buf[BUFSIZ];
1577 radix = (s !=
NULL ? *s++ : 16);
1579 if (radix <= 1 || radix >= 32)
1584 case 8: *t++ =
'0';
break;
1585 case 16: *t++ =
'0'; *t++ =
'x';
break;
1590 do { i++; k /= radix; }
while (k);
1595 do { --
i; t[
i] = digits[k % radix]; k /= radix; }
while (k);
1600 while ((c = *s++) !=
'\0') {
1601 if (c >
' ')
continue;
1604 if (!(x & k))
continue;
1606 if (t == te) *t++ =
'=';
1613 if (t > te) *t++ =
'>';
1629 int ix = (he->
ix > 0 ? he->
ix : 0);
1634 val =
xstrdup(
_(
"(invalid type)"));
1642 if (anint & RPMSENSE_MISSINGOK)
1689 (tv->tv_usec * 10) + 0x01B21DD213814000ULL;
1701 he->
p.
ui8p[6] &= 0xf0;
1702 he->
p.
ui8p[8] &= 0xc0;
1703 he->
p.
ui8p[9] &= 0x00;
1736 tv.tv_sec = (long) he->
p.
ui32p[0];
1737 tv.tv_usec = (
long) (he->
c > 1 ? he->
p.
ui32p[1] : 0);
1829 static const char uuid_auth[] =
"%{?_uuid_auth}%{!?_uuid_auth:http://rpm5.org}";
1831 static const char uuid_path[] =
"%{?_uuid_path}%{!?_uuid_path:/package}";
1850 const char * s =
NULL;
1851 char * t = (val ? val :
alloca(40));
1855 if (!
strcmp(
"Sigmd5", tagn))
1857 else if (!
strcmp(
"Sha1header", tagn))
1868 s =
rpmGetPath(uuid_auth,
"/", uuid_path,
"/", tagn,
"/",
1906 static const char hex[] =
"0123456789abcdef";
1912 for (i = 0; i < he->
c; i++) {
1913 *te++ = hex[ (
int)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
1914 *te++ = hex[ (
int)((he->
p.
ui8p[i] ) & 0x0f) ];
2028 for (i = 0; i < (
unsigned) he->
c; i++) {
2029 char * item, * flagsStr;
2034 for (j = 0; j < Nhe->
c; j++) {
2035 if (Ihe->
p.
ui32p[j] != i)
2044 flagsStr =
_free(flagsStr);
2046 strcpy(item, Nhe->
p.
argv[j]);
2049 chptr =
xrealloc(chptr, strlen(chptr) + strlen(item) + 5);
2050 if (*chptr !=
'\0') strcat(chptr,
", ");
2051 strcat(chptr, item);
2107 numScripts = _he->
c;
2115 for (i = 0; i < (
unsigned) he->
c; i++) {
2116 for (j = 0; j < (
unsigned) numNames; j++) {
2117 if (indices.
ui32p[j] != i) {
2123 if (flags.
ui32p[j] & RPMSENSE_TRIGGERPREIN)
2125 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERIN)
2127 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERUN)
2129 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERPOSTUN)
2147 #if defined(ENABLE_NLS)
2150 extern int _nl_msg_cat_cntr;
2177 if (dstring && *dstring) {
2179 const char * langval;
2180 const char * msgkey;
2186 size_t nb =
sizeof(
"()");
2197 if (tn) nb += strlen(tn);
2198 if (nhe->
p.
str) nb += strlen(nhe->
p.
str);
2201 (nhe->
p.
str ? nhe->
p.
str :
""), (tn ? tn :
""));
2208 langval =
getenv(language);
2210 #if defined(ENABLE_NLS)
2215 for (domain = dstring; domain !=
NULL; domain = de) {
2216 de = strchr(domain,
':');
2217 if (de) *de++ =
'\0';
2221 if (msgid != msgkey)
break;
2229 #if defined(ENABLE_NLS)
2233 if (domain && msgid) {
2235 const char * s =
dgettext(domain, msgid);
2247 dstring =
_free(dstring);
2278 if (!rc || he->
p.
str ==
NULL || he->
c == 0) {
2293 {
const char **
argv;
2297 for (i = 0; i < (
unsigned) he->
c; i++) {
2301 l += strlen(he->
p.
argv[i]) + 1;
2303 argv =
xmalloc(he->
c *
sizeof(*argv) + l);
2304 te = (
char *)&argv[he->
c];
2442 const char * origin;
2468 const char * baseurl;
2558 const char *
N =
NULL;
2559 const char * V =
NULL;
2560 const char * R =
NULL;
2561 const char *
A =
NULL;
2566 if (N) nb += strlen(N);
2567 if (V) nb += strlen(V) + 1;
2568 if (R) nb += strlen(R) + 1;
2569 #if defined(RPM_VENDOR_OPENPKG)
2576 if (A) nb += strlen(A) + 1;
2584 #if defined(RPM_VENDOR_OPENPKG)
2642 rpmTag dirIndexesTag = 0;
2663 if (fnp) *fnp =
NULL;
2672 if (xx == 0 && isSource) {
2677 dirNames.
argv[0] = (
const char *)&dirNames.
argv[2];
2685 if (fnp) *fnp =
NULL;
2690 he->
tag = dirNameTag;
2694 he->
tag = dirIndexesTag;
2700 for (i = 0; i < (
unsigned)count; i++) {
2701 const char * dn =
NULL;
2703 size += strlen(baseNames.
argv[i]) + strlen(dn) + 1;
2707 t = (
char *)&fileNames.
argv[count];
2709 const char * dn =
NULL;
2721 *fnp = fileNames.
argv;
2725 if (fcp) *fcp =
count;
2795 for (Nhe->
ix = 0; Nhe->
ix < (
int)Nhe->
c; Nhe->
ix++) {
2796 nb +=
sizeof(*he->
p.
argv);
2797 nb += strlen(Nhe->
p.
argv[Nhe->
ix]) + 1;
2798 if (*EVRhe->
p.
argv[Nhe->
ix] !=
'\0')
2799 nb += strlen(EVRhe->
p.
argv[Nhe->
ix]) + (
sizeof(
" (== )")-1);
2802 nb +=
sizeof(*he->
p.
argv);
2805 te = (
char *) &he->
p.
argv[he->
c+1];
2808 for (Nhe->
ix = 0; Nhe->
ix < (
int)Nhe->
c; Nhe->
ix++) {
2810 if (*EVRhe->
p.
argv[Nhe->
ix] !=
'\0') {
2811 char opstr[4], *
op = opstr;
2820 " (", opstr,
" ", EVRhe->
p.
argv[Nhe->
ix],
")",
NULL);
2855 EVRhe->
tag = tagEVR;
2944 for (Dhe->
ix = 0; Dhe->
ix < (
int)Dhe->
c; Dhe->
ix++) {
2947 nb +=
sizeof(*he->
p.
argv);
2948 nb += strlen(Dhe->
p.
argv[Dhe->
ix]) +
sizeof(
" ") + strlen(Nhe->
p.
argv[Dhe->
ix]) - 1;
2951 nb +=
sizeof(*he->
p.
argv);
2954 te = (
char *) &he->
p.
argv[he->
c+1];
2957 for (Dhe->
ix = 0; Dhe->
ix < (
int)Dhe->
c; Dhe->
ix++) {
3044 REVRhe->
tag = tagEVR;
3047 mi =
rpmmiInit(_rpmdb, tagN, key, keylen);
3053 if (PEVRhe !=
NULL) {
3062 for (RNhe->
ix = 0; RNhe->
ix < (
int)RNhe->
c; RNhe->
ix++) {
3069 if (!(PFlags && RFlags))
3083 NVRAhe->
tag = tagNVRA;
3136 NVRAhe->
tag = tagNVRA;;
3142 for (PNhe->
ix = 0; PNhe->
ix < (
int)PNhe->
c; PNhe->
ix++)
3143 (
void)
wnlookupTag(h, tagNVRA, &pkgs, &hits, PNhe, PEVRhe, PFhe);
3144 for (FNhe->
ix = 0; FNhe->
ix < (
int)FNhe->
c; FNhe->
ix++)
3155 for (i = 0; i < he->
c; i++) {
3156 nb +=
sizeof(*he->
p.
argv);
3157 nb += strlen(pkgs[i]) + 1;
3159 nb +=
sizeof(*he->
p.
argv);
3162 te = (
char *) &he->
p.
argv[he->
c+1];
3164 for (i = 0; i < he->
c; i++) {
3166 te =
stpcpy(te, pkgs[i]);
3221 PEVRhe->
tag = tagEVR;
3224 mi =
rpmmiInit(_rpmdb, tagN, key, keylen);
3230 if (REVRhe !=
NULL) {
3239 for (PNhe->
ix = 0; PNhe->
ix < (
int)PNhe->
c; PNhe->
ix++) {
3246 if (!(PFlags && RFlags))
3260 NVRAhe->
tag = tagNVRA;
3308 NVRAhe->
tag = tagNVRA;;
3314 for (RNhe->
ix = 0; RNhe->
ix < (
int)RNhe->
c; RNhe->
ix++) {
3315 if (*RNhe->
p.
argv[RNhe->
ix] ==
'/' || *REVRhe->
p.
argv[RNhe->
ix] ==
'\0')
3318 (
void)
nwlookupTag(h, tagNVRA, &pkgs, &hits, RNhe, REVRhe, RFhe);
3329 for (i = 0; i < he->
c; i++) {
3330 nb +=
sizeof(*he->
p.
argv);
3331 nb += strlen(pkgs[i]) + 1;
3333 nb +=
sizeof(*he->
p.
argv);
3336 te = (
char *) &he->
p.
argv[he->
c+1];
3338 for (i = 0; i < he->
c; i++) {
3340 te =
stpcpy(te, pkgs[i]);
3370 && (F.
ui32p[i] & 0x4e) == ((F.
ui32p[i-1] & 0x4e)) )
3395 if (xx == 0)
goto exit;
3401 if (xx == 0)
goto exit;
3406 if (xx == 0)
goto exit;
3409 nb =
sizeof(*he->
p.
argv);
3411 for (i = 0; i <
c; i++) {
3417 nb +=
sizeof(*he->
p.
argv);
3418 nb +=
sizeof(
"<rpm:entry name=\"\"/>");
3419 if (*N.
argv[i] ==
'/')
3422 nb += strlen(N.
argv[i]);
3424 nb +=
sizeof(
" flags=\"EQ\" epoch=\"0\" ver=\"\"") - 1;
3425 nb += strlen(EVR.
argv[i]);
3426 if (strchr(EVR.
argv[i],
':') !=
NULL)
3428 if (strchr(EVR.
argv[i],
'-') !=
NULL)
3429 nb +=
sizeof(
" rel=\"\"") - 2;
3433 nb +=
sizeof(
" pre=\"1\"") - 1;
3441 t = (
char *) &he->
p.
argv[he->
c + 1];
3443 for (i = 0; i <
c; i++) {
3449 t =
stpcpy(t,
"<rpm:entry");
3450 t =
stpcpy(t,
" name=\"");
3451 if (*N.
argv[i] ==
'/') {
3458 static char *Fstr[] = {
"?0",
"LT",
"GT",
"?3",
"EQ",
"LE",
"GE",
"?7" };
3460 const char *E, *V, *R;
3463 f = (
char *) EVR.
argv[i];
3464 for (fe = f; *fe !=
'\0' && *fe >=
'0' && *fe <=
'9'; fe++)
3466 if (*fe ==
':') { *fe++ =
'\0'; E =
f; f =
fe; }
else E =
NULL;
3468 for (fe = f; *fe !=
'\0' && *fe !=
'-'; fe++)
3470 if (*fe ==
'-') { *fe++ =
'\0'; R =
fe; }
else R =
NULL;
3479 t =
stpcpy(t,
" pre=\"1\"");
3540 spew_t spew,
int lvl)
3543 int ix = (he->
ix > 0 ? he->
ix : 0);
3548 val =
xstrdup(
_(
"(not a string)"));
3581 static char q =
'"';
3597 if (xx == 0)
goto exit;
3603 if (xx == 0)
goto exit;
3608 if (xx == 0)
goto exit;
3614 for (i = 0; i <
c; i++) {
3620 nb += strlen(instance) +
sizeof(
", '', '', '', '', ''") - 1;
3622 nb +=
sizeof(
", ''") - 1;
3623 nb += strlen(N.
argv[i]);
3625 uint32_t Fx = ((F.
ui32p[
i] >> 1) & 0x7);
3628 const char * E = Revr->F[RPMEVR_E];
3629 const char * V = Revr->F[RPMEVR_V];
3631 const char * T = Revr->F[RPMEVR_T];
3633 const char * R = Revr->F[RPMEVR_R];
3635 const char * D = Revr->F[RPMEVR_D];
3638 nb += (
sizeof(
", 'EQ'")-1);
3639 nb += (
sizeof(
", ''")-1) + strlen(E);
3640 nb += (
sizeof(
", ''")-1) + strlen(V);
3642 nb += (
sizeof(
", ''")-1) + strlen(T);
3644 nb += (
sizeof(
", ''")-1) + strlen(R);
3646 nb += (
sizeof(
", ''")-1) + strlen(D);
3652 nb +=
sizeof(
"1") - 1;
3657 nb += (ac + 1) *
sizeof(*he->
p.
argv);
3663 te = (
char *) &he->
p.
argv[ac + 1];
3666 for (i = 0; i <
c; i++) {
3672 te =
stpcpy(te, instance);
3673 *te++ =
','; *te++ =
' ';
3677 static const char *Fstr[] = {
"?0",
"LT",
"GT",
"?3",
"EQ",
"LE",
"GE",
"?7" };
3678 uint32_t Fx = ((F.
ui32p[
i] >> 1) & 0x7);
3681 const char * E = Revr->F[RPMEVR_E];
3682 const char * V = Revr->F[RPMEVR_V];
3684 const char * T = Revr->F[RPMEVR_T];
3686 const char * R = Revr->F[RPMEVR_R];
3688 const char * D = Revr->F[RPMEVR_D];
3691 *te++ =
','; *te++ =
' ';
3692 *te++ =
q; te =
stpcpy(te, Fstr[Fx]); *te++ =
q;
3693 *te++ =
','; *te++ =
' ';
3694 *te++ =
q; te =
stpcpy(te, E); *te++ =
q;
3695 *te++ =
','; *te++ =
' ';
3696 *te++ =
q; te =
stpcpy(te, V); *te++ =
q;
3698 *te++ =
','; *te++ =
' ';
3699 *te++ =
q; te =
stpcpy(te, T); *te++ =
q;
3701 *te++ =
','; *te++ =
' ';
3702 *te++ =
q; te =
stpcpy(te, R); *te++ =
q;
3704 *te++ =
','; *te++ =
' ';
3705 *te++ =
q; te =
stpcpy(te, D); *te++ =
q;
3710 *te++ =
','; *te++ =
' ';
3711 *te++ =
q; *te++ =
q;
3712 *te++ =
','; *te++ =
' ';
3713 *te++ =
q; *te++ =
q;
3714 *te++ =
','; *te++ =
' ';
3715 *te++ =
q; *te++ =
q;
3716 *te++ =
','; *te++ =
' ';
3717 *te++ =
q; *te++ =
q;
3793 if (xx == 0)
goto exit;
3799 if (xx == 0)
goto exit;
3804 if (xx == 0)
goto exit;
3807 nb =
sizeof(*he->
p.
argv);
3809 for (i = 0; i <
c; i++) {
3815 nb +=
sizeof(*he->
p.
argv);
3817 if (*N.
argv[i] ==
'/')
3820 nb += strlen(N.
argv[i]);
3822 nb +=
sizeof(
" >= ") - 1;
3823 nb += strlen(EVR.
argv[i]);
3831 t = (
char *) &he->
p.
argv[he->
c + 1];
3833 for (i = 0; i <
c; i++) {
3840 if (*N.
argv[i] ==
'/') {
3846 static char *Fstr[] = {
"?0",
"<",
">",
"?3",
"=",
"<=",
">=",
"?7" };
3917 size_t dnlen = strlen(dn);
3920 if (strstr(dn,
"bin/") !=
NULL)
3922 if (dnlen >=
sizeof(
"/etc/")-1 && !strncmp(dn,
"/etc/", dnlen))
3950 if (xx == 0)
goto exit;
3956 if (xx == 0)
goto exit;
3961 if (xx == 0)
goto exit;
3966 if (xx == 0)
goto exit;
3971 if (xx == 0)
goto exit;
3974 nb =
sizeof(*he->
p.
argv);
3976 for (i = 0; i <
c; i++) {
3977 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3980 nb +=
sizeof(*he->
p.
argv);
3981 nb +=
sizeof(
"<file></file>");
3984 if (FFLAGS.
ui32p[i] & 0x40)
3985 nb +=
sizeof(
" type=\"ghost\"") - 1;
3986 else if (S_ISDIR(FMODES.
ui16p[i])) {
3987 nb +=
sizeof(
" type=\"dir\"") - 1;
3989 nb +=
sizeof(
"/") - 1;
3998 t = (
char *) &he->
p.
argv[he->
c + 1];
4001 for (i = 0; i <
c; i++) {
4002 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4004 if (FFLAGS.
ui32p[i] & 0x40)
4006 if (S_ISDIR(FMODES.
ui16p[i]))
4012 t =
stpcpy(t,
"</file>");
4015 for (i = 0; i <
c; i++) {
4016 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4018 if (FFLAGS.
ui32p[i] & 0x40)
4020 if (!S_ISDIR(FMODES.
ui16p[i]))
4023 t =
stpcpy(t,
"<file type=\"dir\">");
4031 t =
stpcpy(t,
"</file>");
4034 for (i = 0; i <
c; i++) {
4035 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4037 if (!(FFLAGS.
ui32p[i] & 0x40))
4040 t =
stpcpy(t,
"<file type=\"ghost\">");
4043 t =
stpcpy(t,
"</file>");
4103 if (xx == 0)
goto exit;
4109 if (xx == 0)
goto exit;
4114 if (xx == 0)
goto exit;
4119 if (xx == 0)
goto exit;
4124 if (xx == 0)
goto exit;
4128 nb =
sizeof(*he->
p.
argv);
4130 for (i = 0; i <
c; i++) {
4131 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4134 nb +=
sizeof(*he->
p.
argv);
4135 nb += strlen(instance) +
sizeof(
", '', ''");
4137 nb += strlen(BN.
argv[i]);
4138 if (FFLAGS.
ui32p[i] & 0x40)
4139 nb +=
sizeof(
"ghost") - 1;
4140 else if (S_ISDIR(FMODES.
ui16p[i])) {
4141 nb +=
sizeof(
"dir") - 1;
4143 nb +=
sizeof(
"/") - 1;
4146 nb +=
sizeof(
"file") - 1;
4153 t = (
char *) &he->
p.
argv[he->
c + 1];
4156 for (i = 0; i <
c; i++) {
4157 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4159 if (FFLAGS.
ui32p[i] & 0x40)
4161 if (S_ISDIR(FMODES.
ui16p[i]))
4165 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4166 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4167 t =
stpcpy(t,
"', 'file'");
4170 for (i = 0; i <
c; i++) {
4171 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4173 if (FFLAGS.
ui32p[i] & 0x40)
4175 if (!S_ISDIR(FMODES.
ui16p[i]))
4179 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4180 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4186 t =
stpcpy(t,
"', 'dir'");
4189 for (i = 0; i <
c; i++) {
4190 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4192 if (!(FFLAGS.
ui32p[i] & 0x40))
4196 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4197 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4198 t =
stpcpy(t,
"', 'ghost'");
4259 if (xx == 0)
goto exit;
4265 if (xx == 0)
goto exit;
4270 if (xx == 0)
goto exit;
4275 if (xx == 0)
goto exit;
4280 if (xx == 0)
goto exit;
4283 nb =
sizeof(*he->
p.
argv);
4285 for (i = 0; i <
c; i++) {
4286 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4289 nb +=
sizeof(*he->
p.
argv);
4293 if (FFLAGS.
ui32p[i] & 0x40)
4294 nb +=
sizeof(
"") - 1;
4295 else if (S_ISDIR(FMODES.
ui16p[i]))
4296 nb +=
sizeof(
"/") - 1;
4303 t = (
char *) &he->
p.
argv[he->
c + 1];
4306 for (i = 0; i <
c; i++) {
4307 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4309 if (FFLAGS.
ui32p[i] & 0x40)
4311 if (S_ISDIR(FMODES.
ui16p[i]))
4320 for (i = 0; i <
c; i++) {
4321 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4323 if (FFLAGS.
ui32p[i] & 0x40)
4325 if (!S_ISDIR(FMODES.
ui16p[i]))
4336 for (i = 0; i <
c; i++) {
4337 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4339 if (!(FFLAGS.
ui32p[i] & 0x40))
4395 val =
xstrdup(
_(
"(not a string)"));
4406 if ((bn = strrchr(he->
p.
str,
'/')) !=
NULL)
4423 typedef struct key_s {
4474 STAT_KEYS_FLAGS = (1U << 13),
4479 STAT_KEYS_FCONTEXT = (1U << 16),
4497 {
"fcontext", STAT_KEYS_FCONTEXT },
4498 {
"flags", STAT_KEYS_FLAGS },
4542 UUID_KEYS_STRING = (0U << 4),
4543 UUID_KEYS_SIV = (1U << 4),
4544 UUID_KEYS_BINARY = (2U << 4),
4545 UUID_KEYS_TEXT = (3U << 4),
4552 {
"binary", UUID_KEYS_BINARY },
4553 {
"siv", UUID_KEYS_SIV },
4554 {
"string", UUID_KEYS_STRING },
4555 {
"text", UUID_KEYS_TEXT },
4568 keyCmp(
const void * a,
const void *
b)
4577 keyValue(
KEY *
keys,
size_t nkeys,
const char *
name)
4582 if (name && * name) {
4584 KEY *k = (
KEY *)bsearch(&needle, keys, nkeys,
sizeof(*keys), keyCmp);
4600 int ix = (he->
ix > 0 ? he->
ix : 0);
4607 val =
xstrdup(
_(
"(invalid type :digest)"));
4611 ns =
sizeof(he->
p.
ui64p[0]);
4614 ns = strlen(he->
p.
str);
4622 {
rpmuint32_t keyval = keyValue(keyDigests, nkeyDigests, (av ? av[0] :
NULL));
4645 static const char *avdefault[] = {
"mode",
NULL };
4648 struct stat sb, *
st = &sb;
4649 int ix = (he->
ix > 0 ? he->
ix : 0);
4654 memset(st, 0,
sizeof(*st));
4660 if ((
size_t)he->
c ==
sizeof(*st)) {
4661 st = (
struct stat *)he->
p.
ptr;
4666 val =
xstrdup(
_(
"(invalid type :stat)"));
4671 if (
Lstat(fn, st) == 0)
4680 if (!(av && av[0] && *av[0]))
4682 for (i = 0; av[
i] !=
NULL; i++) {
4684 size_t nb =
sizeof(
b)-1;
4686 rpmuint32_t keyval = keyValue(keyStat, nkeyStat, av[i]);
4696 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_dev);
4699 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_ino);
4702 xx =
snprintf(b, nb,
"%06o", (
unsigned)st->st_mode);
4705 xx =
snprintf(b, nb,
"0x%ld", (
unsigned long)st->st_nlink);
4708 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_uid);
4711 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_gid);
4714 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_rdev);
4717 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_size);
4720 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_blksize);
4723 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_blocks);
4726 (
void)
stpcpy(b, ctime((time_t *)&st->st_atime));
4729 (
void)
stpcpy(b, ctime((time_t *)&st->st_ctime));
4732 (
void)
stpcpy(b, ctime((time_t *)&st->st_mtime));
4735 case STAT_KEYS_FLAGS:
4750 if (fn !=
NULL && S_ISREG(st->st_mode)) {
4751 rpmuint32_t digval = keyValue(keyDigests, nkeyDigests, av[i]);
4757 static int asAscii = 1;
4758 char buffer[16 * 1024];
4760 while (
Fread(buffer,
sizeof(buffer[0]),
sizeof(buffer), fd) > 0)
4776 {
const char * uname =
uidToUname(st->st_uid);
4780 xx =
snprintf(b, nb,
"%u", (
unsigned)st->st_uid);
4783 {
const char * gname =
gidToGname(st->st_gid);
4787 xx =
snprintf(b, nb,
"%u", (
unsigned)st->st_gid);
4817 static const char hex[] =
"0123456789abcdef";
4822 static const char *avdefault[] = {
"v5",
NULL };
4824 int ix = (he->
ix > 0 ? he->
ix : 0);
4832 val =
xmalloc((128/4 + 4) + 1);
4840 val =
xstrdup(
_(
"(invalid type :uuid)"));
4848 val =
xstrdup(
_(
"(invalid tag :uuid)"));
4859 tv.tv_sec = (long) he->
p.
ui64p[0];
4860 tv.tv_usec = (
long) (he->
c > 1 ? he->
p.
ui64p[1] : 0);
4865 for (i = 0; i < nhe->
c; i++) {
4866 *te++ = hex[ (
int)((nhe->
p.
ui8p[i] >> 4) & 0x0f) ];
4867 *te++ = hex[ (
int)((nhe->
p.
ui8p[i] ) & 0x0f) ];
4868 if (i == 3 || i == 5 || i == 7 || i == 9)
4881 val =
xstrdup(
_(
"(invalid tag :uuid)"));
4888 for (i = 0; i < he->
c; i++) {
4889 *te++ = hex[ (
int)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
4890 *te++ = hex[ (
int)((he->
p.
ui8p[i] ) & 0x0f) ];
4905 if (!(av && av[0] && *av[0]))
4908 for (i = 0; av[
i] !=
NULL; i++) {
4909 uint32_t keyval = keyValue(keyUuids, nkeyUuids, av[i]);
4939 int64_t * stack =
memset(
alloca(ac*
sizeof(*stack)), 0, (ac*
sizeof(*stack)));
4947 val =
xstrdup(
_(
"(invalid type :rpn)"));
4956 stack[
ix] = strtoll(he->
p.
str, &end, 0);
4958 if (end && *end !=
'\0') {
4959 val =
xstrdup(
_(
"(invalid string :rpn)"));
4966 for (i = 0; av[
i] !=
NULL; i++) {
4967 const char * arg = av[
i];
4968 size_t len = strlen(arg);
4973 }
else if (len > 1) {
4975 val =
xstrdup(
_(
"(expected number :rpn)"));
4979 val =
xstrdup(
_(
"(stack overflow :rpn)"));
4983 stack[
ix] = strtoll(arg, &end, 0);
4984 if (end && *end !=
'\0') {
4985 val =
xstrdup(
_(
"(invalid number :rpn)"));
4990 val =
xstrdup(
_(
"(stack underflow :rpn)"));
4994 case '&': stack[
ix] &= stack[ix+1];
break;
4995 case '|': stack[
ix] |= stack[ix+1];
break;
4996 case '^': stack[
ix] ^= stack[ix+1];
break;
4997 case '+': stack[
ix] += stack[ix+1];
break;
4998 case '-': stack[
ix] -= stack[ix+1];
break;
4999 case '*': stack[
ix] *= stack[ix+1];
break;
5002 if (stack[ix+1] == 0) {
5003 val =
xstrdup(
_(
"(divide by zero :rpn)"));
5007 stack[
ix] %= stack[ix+1];
5009 stack[
ix] /= stack[ix+1];
5046 val =
xstrdup(
_(
"(invalid type :strsub)"));
5050 if (ac < 2 || (ac % 2) != 0) {
5051 val =
xstrdup(
_(
"(invalid args :strsub)"));
5060 for (i = 0; av[
i] !=
NULL; i += 2)
5064 if (mires !=
NULL) {
5067 const char *
s, *
se;
5073 for (i = 0; i < nmires; i++) {
5074 miRE mire = mires +
i;
5084 while (*s !=
'\0') {
5086 if ((se = strchr(s,
'\n')) ==
NULL)
5091 offsets[0] = offsets[1] = -1;
5097 nb += offsets[0] + strlen(av[2*i+1]);
5099 if (xx != 0 || offsets[1] == offsets[0])
5100 nb += (se - (s + offsets[1]));
5110 if (xx != 0 || offsets[1] == offsets[0]) {
5112 te =
stpncpy(te, s, (se - s));
5134 { HEADER_EXT_TAG,
"RPMTAG_BUILDTIMEUUID",
5136 { HEADER_EXT_TAG,
"RPMTAG_CHANGELOGNAME",
5138 { HEADER_EXT_TAG,
"RPMTAG_CHANGELOGTEXT",
5140 { HEADER_EXT_TAG,
"RPMTAG_DESCRIPTION",
5142 { HEADER_EXT_TAG,
"RPMTAG_GROUP",
5144 { HEADER_EXT_TAG,
"RPMTAG_HDRUUID",
5146 { HEADER_EXT_TAG,
"RPMTAG_INSTALLPREFIX",
5148 { HEADER_EXT_TAG,
"RPMTAG_INSTALLTIDUUID",
5150 { HEADER_EXT_TAG,
"RPMTAG_INSTALLTIMEUUID",
5152 { HEADER_EXT_TAG,
"RPMTAG_ORIGINTIDUUID",
5154 { HEADER_EXT_TAG,
"RPMTAG_ORIGINTIMEUUID",
5156 { HEADER_EXT_TAG,
"RPMTAG_PKGUUID",
5158 { HEADER_EXT_TAG,
"RPMTAG_REMOVETIDUUID",
5160 { HEADER_EXT_TAG,
"RPMTAG_SOURCEPKGUUID",
5162 { HEADER_EXT_TAG,
"RPMTAG_SUMMARY",
5164 { HEADER_EXT_TAG,
"RPMTAG_TRIGGERCONDS",
5166 { HEADER_EXT_TAG,
"RPMTAG_TRIGGERTYPE",
5168 { HEADER_EXT_TAG,
"RPMTAG_DBINSTANCE",
5170 { HEADER_EXT_TAG,
"RPMTAG_HEADERSTARTOFF",
5172 { HEADER_EXT_TAG,
"RPMTAG_HEADERENDOFF",
5174 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEBASEURL",
5176 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEDIGEST",
5178 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEORIGIN",
5180 { HEADER_EXT_TAG,
"RPMTAG_PACKAGESIZE",
5182 { HEADER_EXT_TAG,
"RPMTAG_PACKAGETIME",
5184 { HEADER_EXT_TAG,
"RPMTAG_NVRA",
5186 { HEADER_EXT_TAG,
"RPMTAG_FILENAMES",
5188 { HEADER_EXT_TAG,
"RPMTAG_FILEPATHS",
5190 { HEADER_EXT_TAG,
"RPMTAG_ORIGPATHS",
5192 { HEADER_EXT_TAG,
"RPMTAG_FILESTAT",
5194 { HEADER_EXT_TAG,
"RPMTAG_PROVIDEXMLENTRY",
5196 { HEADER_EXT_TAG,
"RPMTAG_REQUIREXMLENTRY",
5198 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTXMLENTRY",
5200 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETEXMLENTRY",
5202 { HEADER_EXT_TAG,
"RPMTAG_FILESXMLENTRY1",
5204 { HEADER_EXT_TAG,
"RPMTAG_FILESXMLENTRY2",
5206 { HEADER_EXT_TAG,
"RPMTAG_PROVIDEYAMLENTRY",
5208 { HEADER_EXT_TAG,
"RPMTAG_REQUIREYAMLENTRY",
5210 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTYAMLENTRY",
5212 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETEYAMLENTRY",
5214 { HEADER_EXT_TAG,
"RPMTAG_FILESYAMLENTRY1",
5216 { HEADER_EXT_TAG,
"RPMTAG_FILESYAMLENTRY2",
5218 { HEADER_EXT_TAG,
"RPMTAG_PROVIDESQLENTRY",
5220 { HEADER_EXT_TAG,
"RPMTAG_REQUIRESQLENTRY",
5222 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTSQLENTRY",
5224 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETESQLENTRY",
5226 { HEADER_EXT_TAG,
"RPMTAG_FILESSQLENTRY1",
5228 { HEADER_EXT_TAG,
"RPMTAG_FILESSQLENTRY2",
5230 { HEADER_EXT_TAG,
"RPMTAG_DEBCONFLICTS",
5232 { HEADER_EXT_TAG,
"RPMTAG_DEBDEPENDS",
5234 { HEADER_EXT_TAG,
"RPMTAG_DEBMD5SUMS",
5236 { HEADER_EXT_TAG,
"RPMTAG_DEBOBSOLETES",
5238 { HEADER_EXT_TAG,
"RPMTAG_DEBPROVIDES",
5240 { HEADER_EXT_TAG,
"RPMTAG_NEEDSWHAT",
5242 { HEADER_EXT_TAG,
"RPMTAG_WHATNEEDS",
5244 { HEADER_EXT_FORMAT,
"armor",
5246 { HEADER_EXT_FORMAT,
"base64",
5248 { HEADER_EXT_FORMAT,
"bncdata",
5250 { HEADER_EXT_FORMAT,
"cdata",
5252 { HEADER_EXT_FORMAT,
"depflags",
5254 { HEADER_EXT_FORMAT,
"deptype",
5256 { HEADER_EXT_FORMAT,
"digest",
5258 { HEADER_EXT_FORMAT,
"fflags",
5260 { HEADER_EXT_FORMAT,
"hint",
5262 { HEADER_EXT_FORMAT,
"iconv",
5264 { HEADER_EXT_FORMAT,
"json",
5267 { HEADER_EXT_FORMAT,
"jsonescape",
5270 { HEADER_EXT_FORMAT,
"perms",
5272 { HEADER_EXT_FORMAT,
"permissions",
5274 { HEADER_EXT_FORMAT,
"pgpsig",
5276 { HEADER_EXT_FORMAT,
"rpn",
5278 { HEADER_EXT_FORMAT,
"sqlescape",
5280 { HEADER_EXT_FORMAT,
"stat",
5282 { HEADER_EXT_FORMAT,
"strsub",
5284 { HEADER_EXT_FORMAT,
"triggertype",
5286 { HEADER_EXT_FORMAT,
"utf8",
5288 { HEADER_EXT_FORMAT,
"uuid",
5290 { HEADER_EXT_FORMAT,
"xml",
5292 { HEADER_EXT_FORMAT,
"yaml",
5294 { HEADER_EXT_MORE,
NULL, { (
void *) &headerDefaultFormats } }
5303 const struct headerTagTableEntry_s *
t;
5310 if (_rpmTagTable == NULL)
5314 if (_rpmHeaderFormats == NULL)
5317 for (t = _rpmTagTable; t && t->name; t++) {
5319 static const char * tagtypes[] = {
5320 "",
"char",
"uint8",
"uint16",
"uint32",
"uint64",
5321 "string",
"octets",
"argv",
"i18nstring",
5326 fprintf(fp,
"%-20s %6d", t->name + 7, t->val);
5338 fprintf(fp,
" %s", tagtypes[ttype]);
5348 fprintf(fp,
"%s", t->name + 7);
5353 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
5354 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
5356 if (ext->name == NULL || ext->type != HEADER_EXT_TAG)
5362 fprintf(fp,
"%s\n", ext->name + 7);
5368 #define PARSER_BEGIN 0
5369 #define PARSER_IN_ARRAY 1
5370 #define PARSER_IN_EXPR 2
5479 fprintf(stderr,
"\t\t\\%c\n", ch);
5482 case 'a':
return '\a';
5483 case 'b':
return '\b';
5484 case 'f':
return '\f';
5485 case 'n':
return '\n';
5486 case 'r':
return '\r';
5487 case 't':
return '\t';
5488 case 'v':
return '\v';
5504 memset(he, 0,
sizeof(*he));
5516 freeFormat( sprintfToken
format,
size_t num)
5523 for (i = 0; i < (
unsigned) num; i++) {
5524 switch (format[i].
type) {
5536 freeFormat(format[i].
u.array.format,
5537 format[i].
u.
array.numTokens);
5540 format[
i].
u.
cond.ifFormat =
5541 freeFormat(format[i].
u.cond.ifFormat,
5542 format[i].
u.
cond.numIfTokens);
5543 format[
i].
u.
cond.elseFormat =
5544 freeFormat(format[i].
u.cond.elseFormat,
5545 format[i].
u.
cond.numElseTokens);
5547 format[
i].
u.
cond.tag.tagno =
_free(format[i].
u.cond.tag.tagno);
5551 format[
i].
u.
cond.tag.fmtfuncs =
_free(format[i].
u.cond.tag.fmtfuncs);
5569 static headerSprintfArgs
hsaInit( headerSprintfArgs hsa)
5596 static sprintfToken
hsaNext( headerSprintfArgs hsa)
5600 sprintfToken fmt =
NULL;
5608 if (hsa != NULL && hsa->
i < hsa->
numTokens) {
5610 if (hsa->
hi == NULL) {
5634 static headerSprintfArgs
hsaFini( headerSprintfArgs hsa)
5678 static char name[128];
5685 if (s != NULL && typep != NULL)
5690 for (; tbl->name !=
NULL; tbl++) {
5691 if (tbl->val == val)
5694 if ((s = tbl->name) == NULL)
5696 s +=
sizeof(
"RPMTAG_") - 1;
5722 for (; tbl->name !=
NULL; tbl++) {
5738 static int findTag(headerSprintfArgs hsa, sprintfToken token,
const char * name)
5752 if (!
strcmp(name,
"*")) {
5757 if (strncmp(
"RPMTAG_", name,
sizeof(
"RPMTAG_")-1)) {
5758 char * t =
alloca(strlen(name) +
sizeof(
"RPMTAG_"));
5764 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
5765 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
5767 if (ext->name == NULL || ext->type != HEADER_EXT_TAG)
5770 stag->
ext = ext->u.tagFunction;
5786 stag->
tagno[0] = tagno;
5788 if (stag->
av != NULL) {
5793 for (i = 0; stag->
av[
i] !=
NULL; i++) {
5794 for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST;
5795 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1))
5797 if (ext->name == NULL || ext->type != HEADER_EXT_FORMAT)
5799 if (
strcmp(ext->name, stag->
av[i]+1))
5819 char * str,
char ** endPtr)
5834 sprintfToken * formatPtr,
5835 size_t * numTokensPtr,
5836 char ** endPtr,
int state)
5842 static const char *pstates[] = {
5843 "NORMAL",
"ARRAY",
"EXPR",
"WTF?"
5845 char * chptr, * start, *
next, * dst;
5855 fprintf(stderr,
"--> parseFormat(%p, \"%.20s...\", %p, %p, %p, %s)\n", hsa, str, formatPtr, numTokensPtr, endPtr, pstates[(state & 0x3)]);
5861 for (chptr = str; *chptr !=
'\0'; chptr++)
5862 if (*chptr ==
'%' || *chptr ==
'[') numTokens++;
5863 numTokens = numTokens * 2 + 1;
5865 format =
xcalloc(numTokens,
sizeof(*format));
5866 if (endPtr) *endPtr =
NULL;
5873 while (*start !=
'\0') {
5877 if (*(start + 1) ==
'%') {
5879 token = format + numTokens++;
5882 dst = token->
u.
string.string = start;
5890 token = format + numTokens++;
5894 if (*start ==
'|') {
5900 format = freeFormat(format, numTokens);
5915 while (*chptr && *chptr !=
'{' && *chptr !=
'%') chptr++;
5916 if (!*chptr || *chptr ==
'%') {
5917 hsa->
errmsg =
_(
"missing { after %");
5918 format = freeFormat(format, numTokens);
5924 fprintf(stderr,
"\tchptr *%p = NUL\n", chptr);
5928 while (start < chptr) {
5930 i = strtoul(start, &start, 10);
5939 if (*start ==
'=') {
5942 }
else if (*start ==
'#') {
5949 while (*next && *next !=
'}') next++;
5951 hsa->
errmsg =
_(
"missing } after %{");
5952 format = freeFormat(format, numTokens);
5957 fprintf(stderr,
"\tnext *%p = NUL\n", next);
5961 #define isSEP(_c) ((_c) == ':' || (_c) == '|')
5963 while (!(*chptr ==
'\0' ||
isSEP(*chptr))) chptr++;
5965 while (
isSEP(*chptr)) {
5966 if (chptr[1] ==
'\0' ||
isSEP(chptr[1])) {
5967 hsa->
errmsg =
_(
"empty tag format");
5968 format = freeFormat(format, numTokens);
5972 {
char * te = chptr + 1;
5973 char * t = strchr(te,
'(');
5976 while (!(*te ==
'\0' ||
isSEP(*te))) {
5978 if (te[0] ==
'\\' && te[1] !=
'\0') te++;
5982 c = *
te; *te =
'\0';
5986 if (te <= t || te[-1] !=
')') {
5987 hsa->
errmsg =
_(
"malformed parameter list");
5988 format = freeFormat(format, numTokens);
5997 fprintf(stderr,
"\tformat \"%s\" params \"%s\"\n", chptr, (t ? t :
""));
6007 if (*start ==
'\0') {
6008 hsa->
errmsg =
_(
"empty tag name");
6009 format = freeFormat(format, numTokens);
6016 if (
findTag(hsa, token, start)) {
6017 hsa->
errmsg =
_(
"unknown tag");
6018 format = freeFormat(format, numTokens);
6025 fprintf(stderr,
"\tdst = start = next %p\n", dst);
6035 token = format + numTokens++;
6039 &token->
u.
array.numTokens,
6040 &start, PARSER_IN_ARRAY))
6042 format = freeFormat(format, numTokens);
6047 hsa->
errmsg =
_(
"] expected at end of array");
6048 format = freeFormat(format, numTokens);
6055 fprintf(stderr,
"\tdst = start %p\n", dst);
6063 if (state != PARSER_IN_ARRAY) {
6064 hsa->
errmsg =
_(
"unexpected ]");
6065 format = freeFormat(format, numTokens);
6071 fprintf(stderr,
"\t<= %s %p[-1] = NUL\n", pstates[(state & 0x3)], start);
6073 if (endPtr) *endPtr = start;
6079 hsa->
errmsg =
_(
"unexpected }");
6080 format = freeFormat(format, numTokens);
6086 fprintf(stderr,
"\t<= %s %p[-1] = NUL\n", pstates[(state & 0x3)], start);
6088 if (endPtr) *endPtr = start;
6094 token = format + numTokens++;
6097 dst = token->
u.
string.string = start;
6103 fprintf(stderr,
"\t*%p = *%p \"%.30s\"\n", dst, start, start);
6105 if (start[0] ==
'\\' && start[1] !=
'\0') {
6114 if (dst < start) *dst =
'\0';
6123 for (i = 0; i < (
unsigned) numTokens; i++) {
6125 switch(token->
type) {
6134 if (numTokensPtr != NULL)
6135 *numTokensPtr = numTokens;
6136 if (formatPtr != NULL)
6143 char * str,
char ** endPtr)
6150 fprintf(stderr,
"--> parseExpression(%p, %p, \"%.20s...\", %p)\n", hsa, token, str, endPtr);
6155 while (*chptr && *chptr !=
'?') chptr++;
6157 if (*chptr !=
'?') {
6158 hsa->
errmsg =
_(
"? expected in expression");
6164 if (*chptr !=
'{') {
6165 hsa->
errmsg =
_(
"{ expected after ? in expression");
6176 if (!(end && *end)) {
6177 hsa->
errmsg =
_(
"} expected in expression");
6178 token->
u.
cond.ifFormat =
6179 freeFormat(token->
u.
cond.ifFormat, token->
u.
cond.numIfTokens);
6184 if (*chptr !=
':' && *chptr !=
'|') {
6185 hsa->
errmsg =
_(
": expected following ? subexpression");
6186 token->
u.
cond.ifFormat =
6187 freeFormat(token->
u.
cond.ifFormat, token->
u.
cond.numIfTokens);
6191 if (*chptr ==
'|') {
6195 token->
u.
cond.ifFormat =
6196 freeFormat(token->
u.
cond.ifFormat, token->
u.
cond.numIfTokens);
6202 if (*chptr !=
'{') {
6203 hsa->
errmsg =
_(
"{ expected after : in expression");
6204 token->
u.
cond.ifFormat =
6205 freeFormat(token->
u.
cond.ifFormat, token->
u.
cond.numIfTokens);
6216 if (!(end && *end)) {
6217 hsa->
errmsg =
_(
"} expected in expression");
6218 token->
u.
cond.ifFormat =
6219 freeFormat(token->
u.
cond.ifFormat, token->
u.
cond.numIfTokens);
6224 if (*chptr !=
'|') {
6225 hsa->
errmsg =
_(
"| expected at end of expression");
6226 token->
u.
cond.ifFormat =
6227 freeFormat(token->
u.
cond.ifFormat, token->
u.
cond.numIfTokens);
6228 token->
u.
cond.elseFormat =
6229 freeFormat(token->
u.
cond.elseFormat, token->
u.
cond.numElseTokens);
6260 rc =
fn(hsa->
h, he);
6324 val =
xstrdup(
"(unknown type)");
6325 need = strlen(val) + 1;
6328 #if defined(SUPPORT_I18NSTRING_TYPE)
6337 #if !defined(SUPPORT_I18NSTRING_TYPE)
6365 ival = he->
p.
ui64p[element];
6371 vhe->
ix = (he->
c > 1 ? 0 : -1);
6388 for (i = 0; tag->
av[
i] !=
NULL; i++) {
6389 headerTagFormatFunction fmt;
6394 if (val != NULL && *tag->
av[i] ==
'|') {
6408 nval = fmt(vhe, av);
6412 fprintf(stderr,
"\t%s(%s) %p(%p,%p) |%s|\n", tag->
av[i], (tag->
params ? tag->
params[i] : NULL), (
void *)fmt, (
void *)vhe, (
void *)(av ? av : NULL), (nval ? nval :
"(null)"));
6417 val =
xstrdup((nval ? nval :
""));
6421 val =
rpmExpand(val, (*val !=
'\0' ?
" | " :
""), nval, NULL);
6434 need = strlen(val) + 1;
6437 if (val && need > 0) {
6440 nb = strlen(tag->
format) +
sizeof(
"%s");
6443 nb = tag->
pad + strlen(val) + 1;
6481 size_t condNumFormats;
6487 switch (token->
type) {
6493 if (need == 0)
break;
6510 if (token->
u.
cond.tag.ext
6513 spft = token->
u.
cond.ifFormat;
6514 condNumFormats = token->
u.
cond.numIfTokens;
6516 spft = token->
u.
cond.elseFormat;
6517 condNumFormats = token->
u.
cond.numElseTokens;
6520 need = condNumFormats * 20;
6521 if (spft == NULL || need == 0)
break;
6524 for (i = 0; i < condNumFormats; i++, spft++) {
6535 spft = token->
u.
array.format;
6536 for (i = 0; i < token->
u.
array.numTokens; i++, spft++)
6558 if (numElements == 0) {
6559 numElements = he->
c;
6562 if ((
size_t)he->
c == numElements)
6565 _(
"array iterator used with different sized arrays");
6571 if (numElements == 0)
6576 spft = token->
u.
array.format;
6578 if (numElements == 0) {
6580 need =
sizeof(
"(none)\n") - 1;
6582 te =
stpcpy(t,
"(none)\n");
6587 const char * tagN =
NULL;
6590 need = numElements * token->
u.
array.numTokens;
6591 if (need == 0)
break;
6598 && tag->
av[0] != NULL && !
strcmp(tag->
av[0]+1,
"xml"))
6601 && tag->
av[0] != NULL && !
strcmp(tag->
av[0]+1,
"yaml"))
6604 && tag->
av[0] != NULL && !
strcmp(tag->
av[0]+1,
"json"))
6607 if (spew == &_xml_spew) {
6610 if (tag->
tagno[0] & 0x40000000) {
6614 need =
sizeof(
" <rpmTag name=\"\">\n") + strlen(tagN);
6619 if (spew == &_yaml_spew) {
6622 if (tag->
tagno[0] & 0x40000000) {
6624 tagT = numElements > 1
6628 need =
sizeof(
" : - ") + strlen(tagN);
6639 if (spew == &_json_spew) {
6642 if (tag->
tagno[0] & 0x40000000) {
6644 tagT = numElements > 1
6651 need =
sizeof(
" : [ ") + strlen(tagN);
6659 need = numElements * token->
u.
array.numTokens * 10;
6661 for (j = 0; j < numElements; j++) {
6662 spft = token->
u.
array.format;
6663 for (i = 0; i < token->
u.
array.numTokens; i++, spft++) {
6672 if (spew == &_xml_spew) {
6673 need =
sizeof(
" </rpmTag>\n") - 1;
6675 te =
stpcpy(te,
" </rpmTag>\n");
6678 if (spew == &_json_spew) {
6680 need =
sizeof(
" ],\n") - 1;
6682 te =
stpcpy(te,
" ],\n");
6685 need =
sizeof(
"\n") - 1;
6714 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
6715 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
6738 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
6739 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
6754 sprintfToken nextfmt;
6762 fprintf(stderr,
"==> headerSprintf(%p, \"%s\", %p, %p, %p)\n", h, fmt, tags, exts, errmsg);
6786 hsa->
ec = rpmecNew(hsa->
exts, &hsa->
nec);
6799 && tag->
av != NULL && tag->
av[0] != NULL && !
strcmp(tag->
av[0]+1,
"xml"))
6802 && tag->
av != NULL && tag->
av[0] != NULL && !
strcmp(tag->
av[0]+1,
"yaml"))
6805 && tag->
av != NULL && tag->
av[0] != NULL && !
strcmp(tag->
av[0]+1,
"json"))
6810 need = strlen(spew_init);
6812 te =
stpcpy(t, spew_init);
6814 spew_init =
_free(spew_init);
6818 while ((nextfmt =
hsaNext(hsa)) != NULL) {
6831 need = strlen(spew_fini);
6833 te =
stpcpy(t, spew_fini);
6835 spew_fini =
_free(spew_fini);
6841 hsa->
ec = rpmecFree(hsa->
exts, hsa->
ec);
static void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int _flags)
Attach digest to fd.
static char * depflagsFormat(HE_t he, const char **av)
Format dependency flags for display.
static int buildtime_uuidTag(Header h, HE_t he)
Retrieve build time and convert to UUIDv1.
static char * hGetNVRA(Header h)
Return (malloc'd) header name-version-release.arch string.
int rpmuuidMake(int version, const char *ns, const char *data, char *buf_str, unsigned char *buf_bin)
Generate a Universally Unique Identifier (UUID).
static int debdependsTag(Header h, HE_t he)
struct sprintfToken_s::@2::@3 array
static char * triggertypeFormat(HE_t he, const char **av)
Identify type of trigger.
headerTagTableEntry rpmTagTable
Automatically generated table of tag name/value pairs.
int mireSetEOptions(miRE mire, int *offsets, int noffsets)
Initialize pattern execute options (PCRE only).
static char * sqlstrcpy(char *t, const char *s, int lvl)
Copy source string to target, doubling single quotes.
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
static char * rpnFormat(HE_t he, const char **av)
Return arithmetic expressions of input.
char * getenv(const char *name)
static int PRCOSkip(rpmTag tag, rpmTagData N, rpmTagData EVR, rpmTagData F, uint32_t i)
static int PxmlTag(Header h, HE_t he)
static char * cdataFormat(HE_t he, const char **av)
Encode string for use in XML CDATA.
#define RPMSENSE_SENSEMASK
static char * uuidFormat(HE_t he, const char **av)
Reformat tag string as a UUID.
ARGI_t argiFree(ARGI_t argi)
Destroy an argi array.
static int _fnTag(Header h, HE_t he, rpmTag tag)
Retrieve file paths.
void * mireFreeAll(miRE mire, int nmire)
Destroy compiled patterns.
static char * strdup_iconv_check(const char *buffer, const char *tocode)
static PyObject *int type
static int CxmlTag(Header h, HE_t he)
static char * dayFormat(HE_t he, const char **av)
Return day formatted data.
for(i=0;i< st->st_ntags;i++)
char * xstrdup(const char *str)
static int parseFormat(headerSprintfArgs hsa, char *str, sprintfToken *formatPtr, size_t *numTokensPtr, char **endPtr, int state)
Parse a headerSprintf term.
static int pkgbaseurlTag(Header h, HE_t he)
Retrieve package baseurl from header.
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
static const char * _iconv_fromcode
static int instprefixTag(Header h, HE_t he)
Retrieve install prefixes.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
keyUuids_e
Bit field enum for stat(2) keys.
Structure(s) used for file info tag sets.
static char *size_t nb
fgets(3) analogue that reads \ continuations.
static int headerstartoffTag(Header h, HE_t he)
Retrieve starting byte offset of header.
static struct headerTagTableEntry_s _rpmTagTable[]
static int filestatTag(Header h, HE_t he)
static char * octFormat(HE_t he, const char **av)
Return octal formatted data.
char * gidToGname(gid_t gid)
static int summaryTag(Header h, HE_t he)
Retrieve summary text.
static int RyamlTag(Header h, HE_t he)
#define HEADERGET_NOEXTENSION
static const char uuid_ns[]
int setenv(const char *name, const char *value, int replace)
headerTagFormatFunction * fmtfuncs
static const char * _iconv_tocode
static char * spewescapeFormat(HE_t he, const char **av, spew_t spew, int lvl)
Encode string for use by SQL/JSON markup.
static int pkguuidTag(Header h, HE_t he)
Retrieve pkgid and convert to UUIDv5.
static int localeTag(Header h, HE_t he)
Retrieve text and convert to locale.
static const char * myTagName(headerTagTableEntry tbl, rpmuint32_t val, rpmuint32_t *typep)
Return tag name from value.
static const char * language
static int sourcepkguuidTag(Header h, HE_t he)
Retrieve sourcepkgid and convert to UUIDv5.
static int triggertypeTag(Header h, HE_t he)
Retrieve trigger type info.
EVR_t rpmEVRnew(uint32_t Flags, int initialize)
Create a new EVR container.
static struct spew_s _yaml_spew
static int debevrTag(Header h, HE_t he, rpmTag tagN, rpmTag tagEVR, rpmTag tagF)
Retrieve and return Debian formatted dependecies for –deb:control.
int argiCount(ARGI_t argi)
Return no.
static headerSprintfArgs hsaInit(headerSprintfArgs hsa)
Initialize an hsa iteration.
static char * sqlescapeFormat(HE_t he, const char **av)
static int debobsoletesTag(Header h, HE_t he)
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
static PyObject *char * mode
rpmTag tagValue(const char *tagstr)
Return tag value from name.
int rpmEVRparse(const char *evrstr, EVR_t evr)
Split EVR string into epoch, version, and release components.
static char * jsonescapeFormat(HE_t he, const char **av)
static size_t sqlstrlen(const char *s, int lvl)
Return length of string represented with single quotes doubled.
sprintf(t," (%u)",(unsigned) dig->nbytes)
static char * pgpsigFormat(HE_t he, const char **av)
Display signature fingerprint and time.
static int F1xmlTag(Header h, HE_t he)
static char * jsonstrcpy(char *t, const char *s, int lvl)
Copy source string to target, doubling single quotes.
static int xtolower(int c)
static int whatneedsTag(Header h, HE_t he)
pgpDig pgpDigNew(pgpVSFlags vsflags, pgpPubkeyAlgo pubkey_algo)
Create a container for parsed OpenPGP packates.
static int removetid_uuidTag(Header h, HE_t he)
Retrieve remove tid and convert to UUIDv1.
static const char uuid_path[]
memset(_r, 0, sizeof(*_r))
#define dgettext(DomainName, Text)
static int groupTag(Header h, HE_t he)
Retrieve group text.
keyStat_e
Bit field enum for stat(2) keys.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
assert(key->size==sizeof(hdrNum))
static char * strsubFormat(HE_t he, const char **av)
Replace string values.
static char * xmlFormat(HE_t he, const char **av)
Wrap tag data in simple header xml markup.
static HE_t rpmheClean(HE_t he)
Clean a tag container, free'ing attached malloc's.
static int FDGSkip(rpmTagData DN, rpmTagData BN, rpmTagData DI, rpmuint32_t i)
static int origintime_uuidTag(Header h, HE_t he)
Retrieve origin time and convert to UUIDv1.
static rpmuint32_t myTagValue(headerTagTableEntry tbl, const char *name)
Return tag value from name.
static struct headerSprintfExtension_s _headerCompoundFormats[]
static char * dateFormat(HE_t he, const char **av)
Return date formatted data.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
static char * pgpHexStr(const rpmuint8_t *p, size_t plen)
Return hex formatted representation of bytes.
static int PyamlTag(Header h, HE_t he)
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
static size_t xmlstrlen(const char *s, int lvl)
Return length of string represented with xml characters substituted.
static int triggercondsTag(Header h, HE_t he)
Retrieve trigger info.
static int hdruuidTag(Header h, HE_t he)
Retrieve hdrid and convert to UUIDv5.
static char * xmlstrcpy(char *t, const char *s, int lvl)
Copy source string to target, substituting for xml characters.
static int nvraTag(Header h, HE_t he)
Retrieve N-V-R.A compound string from header.
static size_t jsonstrlen(const char *s, int lvl)
Return length of string represented with single quotes doubled.
unsigned int tagType(rpmTag tag)
Return tag data type from value.
static char * jsonFormat(HE_t he, const char **av)
Wrap tag data in simple header json markup.
int argvCount(const ARGV_t argv)
Return no.
char * stpncpy(char *dest, const char *src, size_t n)
int Lstat(const char *path, struct stat *st)
lstat(2) clone.
static int installtime_uuidTag(Header h, HE_t he)
Retrieve install time and convert to UUIDv1.
char * rpmPermsString(int mode)
Return ls(1)-like formatted mode string.
unsigned long long rpmuint64_t
int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
Update context with next plain text buffer.
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
static char * fflagsFormat(HE_t he, const char **av)
Format file flags for display.
static char * decFormat(HE_t he, const char **av)
Return decimal formatted data.
static struct spew_s _xml_spew
static char * armorFormat(HE_t he, const char **av)
Wrap a pubkey in ascii armor for display.
const char * tagName(rpmTag tag)
Return tag name from value.
static int descriptionTag(Header h, HE_t he)
Retrieve description text.
union sprintfToken_s::@2 u
static struct spew_s _sql_spew
pgpDigParams pgpGetSignature(pgpDig dig)
Return OpenPGP signature parameters.
static int origpathsTag(Header h, HE_t he)
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
size_t(* spew_strlen)(const char *s, int lvl)
static int str2uuid(HE_t he, const char **av, rpmuint32_t version, char *val)
Convert tag string to UUID.
static int pkgmtimeTag(Header h, HE_t he)
Retrieve *.rpm package st->st_mtime from header.
int pgpPrtPkts(const rpmuint8_t *pkts, size_t pktlen, pgpDig dig, int printing)
Print/parse a OpenPGP packet(s).
The FD_t File Handle data structure.
static void rpmfiBuildFNames(Header h, rpmTag tagN, const char ***fnp, rpmTagCount *fcp)
Retrieve file names from header.
pgpDig pgpDigFree(pgpDig dig)
Destroy a container for parsed OpenPGP packates.
static int parseExpression(headerSprintfArgs hsa, sprintfToken token, char *str, char **endPtr)
Parse a headerSprintf expression.
static int OyamlTag(Header h, HE_t he)
static int installtid_uuidTag(Header h, HE_t he)
Retrieve install tid and convert to UUIDv1.
int argvAdd(ARGV_t *argvp, ARGstr_t val)
Add a string to an argv array.
static char * bncdataFormat(HE_t he, const char **av)
Encode the basename of a string for use in XML CDATA.
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
Initialize digest.
static const char * _macro_i18ndomains
static int F2xmlTag(Header h, HE_t he)
static int CyamlTag(Header h, HE_t he)
struct headerTagTableEntry_s * headerTagTableEntry
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
static char * hsaReserve(headerSprintfArgs hsa, size_t need)
Reserve sufficient buffer space for next output value.
static int pkgsizeTag(Header h, HE_t he)
Retrieve *.rpm package st->st_size from header.
static int tag2uuidv1(Header h, HE_t he)
Retrieve time and convert to UUIDv1.
size_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd)
fread(3) clone.
void unsetenv(const char *name)
char * pgpArmorWrap(rpmuint8_t atype, const unsigned char *s, size_t ns)
Wrap a OpenPGP packets in ascii armor for transport.
int Fclose(FD_t fd)
fclose(3) clone.
static int nwlookupTag(Header h, rpmTag tagNVRA, ARGV_t *avp, ARGI_t *hitp, HE_t RNhe, HE_t REVRhe, HE_t RFhe)
static int debprovidesTag(Header h, HE_t he)
static int FDGyamlTag(Header h, HE_t he, int lvl)
static size_t yamlstrlen(const char *s, int lvl)
Return length of string represented with yaml indentation.
static unsigned int pgpLen(const rpmuint8_t *s, unsigned int *lenp)
Return length of an OpenPGP packet.
static int debmd5sumsTag(Header h, HE_t he)
Retrieve digest/path pairs for –deb:md5sums.
static char * yamlFormat(HE_t he, const char **av)
Wrap tag data in simple header yaml markup.
int rpmEVRoverlap(EVR_t a, EVR_t b)
Compare EVR containers for overlap.
static int tag2uuidv5(Header h, HE_t he)
Retrieve tag and convert to UUIDv5.
static int dbinstanceTag(Header h, HE_t he)
Retrieve db instance from header.
static int pkgdigestTag(Header h, HE_t he)
Retrieve package digest from header.
static const char *char c
Return text between pl and matching pr characters.
int Readlink(const char *path, char *buf, size_t bufsiz)
readlink(2) clone.
static int OsqlTag(Header h, HE_t he)
static int PRCOsqlTag(Header h, HE_t he, rpmTag EVRtag, rpmTag Ftag)
static char * yamlstrcpy(char *t, const char *s, int lvl)
Copy source string to target, indenting for yaml.
static int FDGsqlTag(Header h, HE_t he, int lvl)
static int pkgoriginTag(Header h, HE_t he)
Retrieve package origin from header.
int Ferror(FD_t fd)
ferror(3) clone.
static int headerendoffTag(Header h, HE_t he)
Retrieve ending byte offset of header.
static char * iconvFormat(HE_t he, const char **av)
Convert string encoding.
static int needswhatTag(Header h, HE_t he)
static char * statFormat(HE_t he, const char **av)
Return file info.
static int F1yamlTag(Header h, HE_t he)
EVR_t rpmEVRfree(EVR_t evr)
Destroy an EVR container.
return strcmp(ame->name, bme->name)
static int xisdigit(int c)
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
static int snprintf(char *buf, int nb, const char *fmt,...)
int xstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
char * stpcpy(char *dest, const char *src)
static int OxmlTag(Header h, HE_t he)
static sprintfToken hsaNext(headerSprintfArgs hsa)
Return next hsa iteration item.
static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token, size_t element)
Format a single headerSprintf item.
static int i18nTag(Header h, HE_t he)
Retrieve i18n text.
char * uidToUname(uid_t uid)
static int filepathsTag(Header h, HE_t he)
static char * realDateFormat(HE_t he, const char **av, const char *strftimeFormat)
Return strftime formatted data.
static int changelognameTag(Header h, HE_t he)
void rpmDisplayQueryTags(FILE *fp, headerTagTableEntry _rpmTagTable, headerSprintfExtension _rpmHeaderFormats)
Display list of tags that can be used in –queryformat.
static size_t nkeyDigests
static int debconflictsTag(Header h, HE_t he)
Retrieve Depends: and Conflicts: for –deb:control.
int argiAdd(ARGI_t *argip, int ix, int val)
Add an int to an argi array.
static struct headerSprintfExtension_s _headerDefaultFormats[]
static int RsqlTag(Header h, HE_t he)
struct pgpDigParams_s * pgpDigParams
int argvSplit(ARGV_t *argvp, const char *str, const char *seps)
Split a string into an argv array.
static char * hintFormat(HE_t he, const char **av)
Format dependency flags for display.
static struct spew_s _json_spew
ARGV_t argvSearch(ARGV_t argv, ARGstr_t val, int(*compar)(ARGstr_t *, ARGstr_t *))
Find an element in an argv array.
static int tv2uuidv1(Header h, HE_t he, struct timeval *tv)
Convert unix timeval to UUIDv1.
struct sprintfToken_s::@2::@5 cond
static char * permsFormat(HE_t he, const char **av)
Format file permissions for display.
static char * deptypeFormat(HE_t he, const char **av)
Format dependency type for display.
int argvSort(ARGV_t argv, int(*compar)(ARGstr_t *, ARGstr_t *))
Sort an argv array.
static int filenamesTag(Header h, HE_t he)
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
static int PsqlTag(Header h, HE_t he)
static int findTag(headerSprintfArgs hsa, sprintfToken token, const char *name)
Search extensions and tags for a name.
static headerSprintfArgs hsaFini(headerSprintfArgs hsa)
Finish an hsa iteration.
static int wnlookupTag(Header h, rpmTag tagNVRA, ARGV_t *avp, ARGI_t *hitp, HE_t PNhe, HE_t PEVRhe, HE_t PFhe)
static void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo, void *datap, size_t *lenp, int asAscii)
char * buf
Parse (and execute) macro undefinition.
int mireAppend(rpmMireMode mode, int tag, const char *pattern, const unsigned char *table, miRE *mirep, int *nmirep)
Append pattern to array.
static PyObject *unsigned char * pkt
static int PRCOyamlTag(Header h, HE_t he, rpmTag EVRtag, rpmTag Ftag)
int
Save source and expand field into target.
static unsigned int pgpGrab(const rpmuint8_t *s, size_t nbytes)
Return (native-endian) integer from big-endian representation.
static char * digestFormat(HE_t he, const char **av)
Return digest of tag data.
static int debevrfmtTag(Header h, HE_t he, HE_t Nhe, HE_t EVRhe, HE_t Fhe)
Return Debian formatted dependencies as string array.
int rpmmiPrune(rpmmi mi, uint32_t *hdrNums, int nHdrNums, int sorted)
Remove items from set of package instances to iterate.
static int PRCOxmlTag(Header h, HE_t he, rpmTag EVRtag, rpmTag Ftag)
void rpmDigestFinal(rpmDigestDup(md5ctx),&md5sum,&md5len, 0)
static int F1sqlTag(Header h, HE_t he)
Access RPM indices using Berkeley DB interface(s).
char *(* spew_strcpy)(char *t, const char *s, int lvl)
static rpmuint32_t uuid_version
static int CsqlTag(Header h, HE_t he)
static char * intFormat(HE_t he, const char **av, const char *fmt)
Convert tag data representation.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
static const char uuid_auth[]
static char escapedChar(const char ch)
static int F2yamlTag(Header h, HE_t he)
static int FDGxmlTag(Header h, HE_t he, int lvl)
static char * hexFormat(HE_t he, const char **av)
Return hex formatted data.
ARGint_t argiData(ARGI_t argi)
Return data from argi array.
static int changelogtextTag(Header h, HE_t he)
static int F2sqlTag(Header h, HE_t he)
static int RxmlTag(Header h, HE_t he)
const char * xstrtolocale(const char *str)
Force encoding of string.
rpmmi rpmmiInit(rpmdb db, rpmTag tag, const void *keyp, size_t keylen)
Return database iterator.
static int getExtension(headerSprintfArgs hsa, headerTagTagFunction fn, HE_t he, HE_t ec)
Call a header extension only once, saving results.
static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, size_t element)
Format a single item's value.
static char * base64Format(HE_t he, const char **av)
Encode binary data in base64 for display.
static int origintid_uuidTag(Header h, HE_t he)
Retrieve origin tid and convert to UUIDv1.
const unsigned char * digest
static char * shescapeFormat(HE_t he, const char **av)
Return shell escape formatted data.