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_TRIGGERTRANS) {
667 if (anint & RPMSENSE_TRIGGERPREIN)
669 else if (anint & RPMSENSE_TRIGGERIN)
671 else if (anint & RPMSENSE_TRIGGERUN)
673 else if (anint & RPMSENSE_TRIGGERPOSTUN)
678 if (anint & RPMSENSE_TRIGGERPREIN)
680 else if (anint & RPMSENSE_TRIGGERIN)
682 else if (anint & RPMSENSE_TRIGGERUN)
684 else if (anint & RPMSENSE_TRIGGERPOSTUN)
702 int ix = (he->
ix > 0 ? he->
ix : 0);
725 int ix = (he->
ix >= 0 ? he->
ix : 0);
767 int ix = (he->
ix > 0 ? he->
ix : 0);
769 const unsigned char * s;
777 s = (
unsigned char *) he->
p.
ui8p;
787 if (b64decode(enc, (
void *)&s, &ns))
792 #if defined(SUPPORT_I18NSTRING_TYPE) 800 return xstrdup(
_(
"(invalid type)"));
820 int ix = (he->
ix > 0 ? he->
ix : 0);
831 val =
xstrdup(
_(
"(invalid type :base64)"));
835 ns =
sizeof(he->
p.
ui64p[0]);
838 ns = strlen(he->
p.
str);
845 nt = ((ns + 2) / 3) * 4;
849 if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
850 lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
851 if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
853 nt += lc * strlen(b64encode_eolstr);
861 {
unsigned char * _data =
xcalloc(1, ns+1);
862 assert(he->
p.
ptr != NULL);
863 memcpy(_data, he->
p.
ptr, ns);
865 if ((enc = b64encode(_data, ns)) != NULL) {
870 _data =
_free(_data);
881 #if defined(__GLIBC__) 899 const char *s = buffer;
901 #if defined(HAVE_ICONV) 905 assert(buffer != NULL);
909 assert(tocode != NULL);
911 #ifdef HAVE_LANGINFO_H 913 if (fromcode == NULL)
914 fromcode = nl_langinfo (CODESET);
916 assert(fromcode != NULL);
918 if ((fd = iconv_open(tocode, fromcode)) != (iconv_t)-1) {
919 size_t ileft = strlen(s);
921 char * te = t =
xmalloc((nt + 1) *
sizeof(*t));
922 size_t oleft = ileft;
923 size_t err = iconv(fd, NULL, NULL, NULL, NULL);
924 const char *sprev = NULL;
925 int _iconv_errno = 0;
928 while (done == 0 && _iconv_errno == 0) {
929 err = iconv(fd, (
char **)&s, &ileft, &te, &oleft);
930 if (err == (
size_t)-1) {
933 {
size_t used = (size_t)(te - t);
935 t =
xrealloc(t, (nt + 1) *
sizeof(*t));
944 _iconv_errno =
errno;
956 _iconv_errno =
errno;
961 fprintf(stderr,
"warning: %s: from iconv(%s -> %s) for \"%s\" -> \"%s\"\n", strerror(_iconv_errno), fromcode, tocode, buffer, t);
979 int ix = (he->
ix > 0 ? he->
ix : 0);
1010 int ix = (he->
ix > 0 ? he->
ix : 0);
1017 val =
xstrdup(
_(
"(not a string)"));
1031 int ix = (he->
ix > 0 ? he->
ix : 0);
1032 const char * xtag = NULL;
1034 const char * s = NULL;
1052 {
int cpl = b64encode_chars_per_line;
1053 b64encode_chars_per_line = 0;
1057 b64encode_chars_per_line = cpl;
1062 anint = (uint64_t)he->
p.
ui8p[ix];
1065 anint = (uint64_t)he->
p.
ui16p[ix];
1068 anint = (uint64_t)he->
p.
ui32p[ix];
1074 val =
xstrdup(
_(
"(invalid xml type)"));
1080 static int tlen = 64;
1086 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1096 nb += strlen(xtag) +
sizeof(
"\t</>");
1100 nb += 2 * strlen(xtag) +
sizeof(
"\t<></>");
1126 int element = he->
ix;
1127 int ix = (he->
ix > 0 ? he->
ix : 0);
1128 const char * xtag = NULL;
1131 const char * s = NULL;
1148 if (strchr(
"[", s[0]))
1151 while ((c = (
int) *s++) != (int)
'\0') {
1157 if (s[0] ==
' ' || s[0] ==
'\t')
1162 if (s[0] !=
' ' && s[0] !=
'\0' && s[1] !=
'"')
1171 xtag =
xmalloc(strlen(
"- |##-\n") + 1);
1175 sprintf((
char *)xtag,
"- |%d-\n", lvl);
1178 if (he->
ix < 0) lvl++;
1179 sprintf((
char *)xtag,
"|%d-\n", lvl);
1188 if (he->
ix < 0) lvl++;
1192 xtag = (element >= 0 ?
"- " : NULL);
1199 {
int cpl = b64encode_chars_per_line;
1200 b64encode_chars_per_line = 0;
1205 b64encode_chars_per_line = cpl;
1210 anint = (uint64_t)he->
p.
ui8p[ix];
1213 anint = (uint64_t)he->
p.
ui16p[ix];
1216 anint = (uint64_t)he->
p.
ui32p[ix];
1222 val =
xstrdup(
_(
"(invalid yaml type)"));
1228 static int tlen = 64;
1231 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1234 xtag = (element >= 0 ?
"- " : NULL);
1243 nb +=
sizeof(
" ") - 1;
1244 nb +=
sizeof(
"- ~") - 1;
1252 nb +=
sizeof(
" ") - 1;
1288 int element = he->
ix;
1289 int ix = (he->
ix > 0 ? he->
ix : 0);
1291 const char * s = NULL;
1309 {
int cpl = b64encode_chars_per_line;
1310 b64encode_chars_per_line = 0;
1313 b64encode_chars_per_line = cpl;
1316 anint = (uint64_t)he->
p.
ui8p[ix];
1319 anint = (uint64_t)he->
p.
ui16p[ix];
1322 anint = (uint64_t)he->
p.
ui32p[ix];
1328 val =
xstrdup(
_(
"(invalid json type)"));
1334 static int tlen = 64;
1336 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1346 te = t =
alloca(nb +
sizeof(
"\"\","));
1347 if (c !=
'\0') *te++ = c;
1352 if (c !=
'\0') *te++ = c;
1377 int ix = (he->
ix > 0 ? he->
ix : 0);
1385 unsigned int pktlen = 0;
1386 unsigned int v = (
unsigned int) *pkt;
1389 unsigned int hlen = 0;
1394 plen =
pgpLen(pkt+1, &hlen);
1396 tag = (v >> 2) & 0xf;
1397 plen = (1 << (v & 0x3));
1401 pktlen = 1 + plen + hlen;
1405 val =
xstrdup(
_(
"(not an OpenPGP signature)"));
1410 const char *tempstr;
1419 switch (sigp->pubkey_algo) {
1427 (void)
snprintf(t, nb - (t - val),
"%u", (unsigned)sigp->pubkey_algo);
1431 if (t + 5 >= val + nb)
1434 switch (sigp->hash_algo) {
1442 (void)
snprintf(t, nb - (t - val),
"%u", (unsigned)sigp->hash_algo);
1446 if (t + strlen (
", ") + 1 >= val + nb)
1452 { time_t dateint =
pgpGrab(sigp->time,
sizeof(sigp->time));
1453 struct tm * tstruct = localtime(&dateint);
1455 (void) strftime(t, (nb - (t - val)),
"%c", tstruct);
1458 if (t + strlen (
", Key ID ") + 1 >= val + nb)
1460 t =
stpcpy(t,
", Key ID ");
1461 tempstr =
pgpHexStr(sigp->signid,
sizeof(sigp->signid));
1462 if (t + strlen (tempstr) > val + nb)
1483 int ix = (he->
ix > 0 ? he->
ix : 0);
1488 val =
xstrdup(
_(
"(invalid type)"));
1497 if (anint & RPMSENSE_SCRIPT_PRE)
1499 else if (anint & RPMSENSE_SCRIPT_POST)
1501 else if (anint & RPMSENSE_SCRIPT_PREUN)
1502 t =
stpcpy(t,
"(preun)");
1503 else if (anint & RPMSENSE_SCRIPT_POSTUN)
1504 t =
stpcpy(t,
"(postun)");
1514 if (anint & RPMSENSE_SENSEMASK)
1535 int ix = (he->
ix > 0 ? he->
ix : 0);
1540 val =
xstrdup(
_(
"(invalid type)"));
1548 if (anint & RPMSENSE_SCRIPT_PRE)
1550 else if (anint & RPMSENSE_SCRIPT_POST)
1552 else if (anint & RPMSENSE_SCRIPT_PREUN)
1554 else if (anint & RPMSENSE_SCRIPT_POSTUN)
1556 else if (anint & RPMSENSE_SCRIPT_VERIFY)
1558 else if (anint & RPMSENSE_RPMLIB)
1560 else if (anint & RPMSENSE_INTERP)
1562 else if (anint & (RPMSENSE_FIND_PROVIDES | RPMSENSE_FIND_REQUIRES))
1575 static const char * bfstring(
unsigned int x,
const char * xbf)
1577 const char * s = xbf;
1578 static char digits[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
1579 static char buf[BUFSIZ];
1584 radix = (s != NULL ? *s++ : 16);
1586 if (radix <= 1 || radix >= 32)
1591 case 8: *t++ =
'0';
break;
1592 case 16: *t++ =
'0'; *t++ =
'x';
break;
1597 do { i++; k /= radix; }
while (k);
1602 do { --i; t[i] = digits[k % radix]; k /= radix; }
while (k);
1607 while ((c = *s++) !=
'\0') {
1608 if (c >
' ')
continue;
1611 if (!(x & k))
continue;
1613 if (t == te) *t++ =
'=';
1620 if (t > te) *t++ =
'>';
1636 int ix = (he->
ix > 0 ? he->
ix : 0);
1641 val =
xstrdup(
_(
"(invalid type)"));
1649 if (anint & RPMSENSE_MISSINGOK)
1696 (tv->tv_usec * 10) + 0x01B21DD213814000ULL;
1708 he->
p.
ui8p[6] &= 0xf0;
1709 he->
p.
ui8p[8] &= 0xc0;
1710 he->
p.
ui8p[9] &= 0x00;
1743 tv.tv_sec = (long) he->
p.
ui32p[0];
1744 tv.tv_usec = (
long) (he->
c > 1 ? he->
p.
ui32p[1] : 0);
1836 static const char uuid_auth[] =
"%{?_uuid_auth}%{!?_uuid_auth:http://rpm5.org}";
1838 static const char uuid_path[] =
"%{?_uuid_path}%{!?_uuid_path:/package}";
1855 const char * ns = NULL;
1857 const char * s = NULL;
1858 char * t = (val ? val :
alloca(40));
1862 if (!strcmp(
"Sigmd5", tagn))
1864 else if (!strcmp(
"Sha1header", tagn))
1913 static const char hex[] =
"0123456789abcdef";
1919 for (i = 0; i < he->
c; i++) {
1920 *te++ = hex[ (int)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
1921 *te++ = hex[ (int)((he->
p.
ui8p[i] ) & 0x0f) ];
1933 return str2uuid(he, NULL, 0, NULL);
2035 for (i = 0; i < (unsigned) he->
c; i++) {
2036 char * item, * flagsStr;
2041 for (j = 0; j < Nhe->
c; j++) {
2042 if (Ihe->
p.
ui32p[j] != i)
2050 sprintf(item,
"%s%s%s", Nhe->
p.
argv[j], flagsStr, Vhe->
p.
argv[j]);
2051 flagsStr =
_free(flagsStr);
2053 strcpy(item, Nhe->
p.
argv[j]);
2056 chptr =
xrealloc(chptr, strlen(chptr) + strlen(item) + 5);
2057 if (*chptr !=
'\0') strcat(chptr,
", ");
2058 strcat(chptr, item);
2062 he->
p.
argv[i] = chptr;
2114 numScripts = _he->
c;
2122 for (i = 0; i < (unsigned) he->
c; i++) {
2123 for (j = 0; j < (unsigned) numNames; j++) {
2124 if (indices.
ui32p[j] != i) {
2125 he->
p.
argv[i] = NULL;
2130 if (flags.
ui32p[j] & RPMSENSE_TRIGGERTRANS) {
2131 if (flags.
ui32p[j] & RPMSENSE_TRIGGERPREIN)
2133 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERIN)
2135 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERUN)
2137 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERPOSTUN)
2142 if (flags.
ui32p[j] & RPMSENSE_TRIGGERPREIN)
2144 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERIN)
2146 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERUN)
2148 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERPOSTUN)
2167 #if defined(ENABLE_NLS) 2170 extern int _nl_msg_cat_cntr;
2193 const char *msgid = he->
p.
str;
2196 for (domain = dstring; domain != NULL; domain = de) {
2197 de = strchr(domain,
':');
2198 if (de) *de++ =
'\0';
2209 dstring =
_free(dstring);
2230 if (!rc || he->
p.
str == NULL || he->
c == 0) {
2245 {
const char ** argv;
2249 for (i = 0; i < (unsigned) he->
c; i++) {
2252 assert(he->
p.
argv[i] != NULL);
2253 l += strlen(he->
p.
argv[i]) + 1;
2255 argv =
xmalloc(he->
c *
sizeof(*argv) + l);
2256 te = (
char *)&argv[he->
c];
2257 for (i = 0; i < (unsigned) he->
c; i++) {
2394 const char * origin;
2420 const char * baseurl;
2445 const char * digest;
2510 const char * N = NULL;
2511 const char * V = NULL;
2512 const char * R = NULL;
2513 const char * A = NULL;
2518 if (N) nb += strlen(N);
2519 if (V) nb += strlen(V) + 1;
2520 if (R) nb += strlen(R) + 1;
2521 #if defined(RPM_VENDOR_OPENPKG) 2528 if (A) nb += strlen(A) + 1;
2536 #if defined(RPM_VENDOR_OPENPKG) 2594 rpmTag dirIndexesTag = 0;
2615 if (fnp) *fnp = NULL;
2624 if (xx == 0 && isSource) {
2629 dirNames.
argv[0] = (
const char *)&dirNames.
argv[2];
2637 if (fnp) *fnp = NULL;
2642 he->
tag = dirNameTag;
2646 he->
tag = dirIndexesTag;
2651 size =
sizeof(*fileNames.
argv) * count;
2652 for (i = 0; i < (unsigned)count; i++) {
2653 const char * dn = NULL;
2655 size += strlen(baseNames.
argv[i]) + strlen(dn) + 1;
2659 t = (
char *)&fileNames.
argv[count];
2660 for (i = 0; i < (unsigned)count; i++) {
2661 const char * dn = NULL;
2663 fileNames.
argv[i] = t;
2673 *fnp = fileNames.
argv;
2677 if (fcp) *fcp = count;
2747 for (Nhe->
ix = 0; Nhe->
ix < (
int)Nhe->
c; Nhe->
ix++) {
2748 nb +=
sizeof(*he->
p.
argv);
2749 nb += strlen(Nhe->
p.
argv[Nhe->
ix]) + 1;
2750 if (*EVRhe->
p.
argv[Nhe->
ix] !=
'\0')
2751 nb += strlen(EVRhe->
p.
argv[Nhe->
ix]) + (
sizeof(
" (== )")-1);
2754 nb +=
sizeof(*he->
p.
argv);
2757 te = (
char *) &he->
p.
argv[he->
c+1];
2760 for (Nhe->
ix = 0; Nhe->
ix < (
int)Nhe->
c; Nhe->
ix++) {
2761 he->
p.
argv[he->
c++] = te;
2762 if (*EVRhe->
p.
argv[Nhe->
ix] !=
'\0') {
2763 char opstr[4], * op = opstr;
2772 " (", opstr,
" ", EVRhe->
p.
argv[Nhe->
ix],
")", NULL);
2779 he->
p.
argv[he->
c] = NULL;
2799 HE_t EVRhe = (
HE_t) memset(
alloca(
sizeof(*EVRhe)), 0,
sizeof(*EVRhe));
2807 EVRhe->
tag = tagEVR;
2810 assert(EVRhe->
c == Nhe->
c);
2814 assert(Fhe->
c == Nhe->
c);
2890 assert(Dhe->
c == Nhe->
c);
2896 for (Dhe->
ix = 0; Dhe->
ix < (
int)Dhe->
c; Dhe->
ix++) {
2899 nb +=
sizeof(*he->
p.
argv);
2900 nb += strlen(Dhe->
p.
argv[Dhe->
ix]) +
sizeof(
" ") + strlen(Nhe->
p.
argv[Dhe->
ix]) - 1;
2903 nb +=
sizeof(*he->
p.
argv);
2906 te = (
char *) &he->
p.
argv[he->
c+1];
2909 for (Dhe->
ix = 0; Dhe->
ix < (
int)Dhe->
c; Dhe->
ix++) {
2912 he->
p.
argv[he->
c++] = te;
2918 he->
p.
argv[he->
c] = NULL;
2968 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
2969 HE_t RNhe = (
HE_t) memset(
alloca(
sizeof(*RNhe)), 0,
sizeof(*RNhe));
2970 HE_t REVRhe = (
HE_t) memset(
alloca(
sizeof(*REVRhe)), 0,
sizeof(*REVRhe));
2971 HE_t RFhe = (
HE_t) memset(
alloca(
sizeof(*RFhe)), 0,
sizeof(*RFhe));
2973 const char * key = PNhe->
p.
argv[PNhe->
ix];
2996 REVRhe->
tag = tagEVR;
2999 mi =
rpmmiInit(_rpmdb, tagN, key, keylen);
3005 if (PEVRhe != NULL) {
3008 assert(REVRhe->
c == RNhe->
c);
3011 assert(RFhe->
c == RNhe->
c);
3014 for (RNhe->
ix = 0; RNhe->
ix < (
int)RNhe->
c; RNhe->
ix++) {
3021 if (!(PFlags && RFlags))
3035 NVRAhe->
tag = tagNVRA;
3037 if (!(*avp != NULL &&
argvSearch(*avp, NVRAhe->
p.
str, NULL) != NULL)) {
3062 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
3063 HE_t PNhe = (
HE_t) memset(
alloca(
sizeof(*PNhe)), 0,
sizeof(*PNhe));
3064 HE_t PEVRhe = (
HE_t) memset(
alloca(
sizeof(*PEVRhe)), 0,
sizeof(*PEVRhe));
3065 HE_t PFhe = (
HE_t) memset(
alloca(
sizeof(*PFhe)), 0,
sizeof(*PFhe));
3066 HE_t FNhe = (
HE_t) memset(
alloca(
sizeof(*FNhe)), 0,
sizeof(*FNhe));
3078 assert(PEVRhe->
c == PNhe->
c);
3082 assert(PFhe->
c == PNhe->
c);
3088 NVRAhe->
tag = tagNVRA;;
3094 for (PNhe->
ix = 0; PNhe->
ix < (
int)PNhe->
c; PNhe->
ix++)
3095 (
void)
wnlookupTag(h, tagNVRA, &pkgs, &hits, PNhe, PEVRhe, PFhe);
3096 for (FNhe->
ix = 0; FNhe->
ix < (
int)FNhe->
c; FNhe->
ix++)
3097 (void)
wnlookupTag(h, tagNVRA, &pkgs, &hits, FNhe, NULL, NULL);
3107 for (i = 0; i < he->
c; i++) {
3108 nb +=
sizeof(*he->
p.
argv);
3109 nb += strlen(pkgs[i]) + 1;
3111 nb +=
sizeof(*he->
p.
argv);
3114 te = (
char *) &he->
p.
argv[he->
c+1];
3116 for (i = 0; i < he->
c; i++) {
3118 te =
stpcpy(te, pkgs[i]);
3121 he->
p.
argv[he->
c] = NULL;
3144 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
3145 HE_t PNhe = (
HE_t) memset(
alloca(
sizeof(*PNhe)), 0,
sizeof(*PNhe));
3146 HE_t PEVRhe = (
HE_t) memset(
alloca(
sizeof(*PEVRhe)), 0,
sizeof(*PEVRhe));
3147 HE_t PFhe = (
HE_t) memset(
alloca(
sizeof(*PFhe)), 0,
sizeof(*PFhe));
3149 const char * key = RNhe->
p.
argv[RNhe->
ix];
3173 PEVRhe->
tag = tagEVR;
3176 mi =
rpmmiInit(_rpmdb, tagN, key, keylen);
3182 if (REVRhe != NULL) {
3185 assert(PEVRhe->
c == PNhe->
c);
3188 assert(PFhe->
c == PNhe->
c);
3191 for (PNhe->
ix = 0; PNhe->
ix < (
int)PNhe->
c; PNhe->
ix++) {
3198 if (!(PFlags && RFlags))
3212 NVRAhe->
tag = tagNVRA;
3214 if (!(*avp != NULL &&
argvSearch(*avp, NVRAhe->
p.
str, NULL) != NULL)) {
3239 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
3240 HE_t RNhe = (
HE_t) memset(
alloca(
sizeof(*RNhe)), 0,
sizeof(*RNhe));
3241 HE_t REVRhe = (
HE_t) memset(
alloca(
sizeof(*REVRhe)), 0,
sizeof(*REVRhe));
3242 HE_t RFhe = (
HE_t) memset(
alloca(
sizeof(*RFhe)), 0,
sizeof(*RFhe));
3254 assert(REVRhe->
c == RNhe->
c);
3258 assert(RFhe->
c == RNhe->
c);
3260 NVRAhe->
tag = tagNVRA;;
3266 for (RNhe->
ix = 0; RNhe->
ix < (
int)RNhe->
c; RNhe->
ix++) {
3267 if (*RNhe->
p.
argv[RNhe->
ix] ==
'/' || *REVRhe->
p.
argv[RNhe->
ix] ==
'\0')
3268 (void)
nwlookupTag(h, tagNVRA, &pkgs, &hits, RNhe, NULL, NULL);
3270 (
void)
nwlookupTag(h, tagNVRA, &pkgs, &hits, RNhe, REVRhe, RFhe);
3281 for (i = 0; i < he->
c; i++) {
3282 nb +=
sizeof(*he->
p.
argv);
3283 nb += strlen(pkgs[i]) + 1;
3285 nb +=
sizeof(*he->
p.
argv);
3288 te = (
char *) &he->
p.
argv[he->
c+1];
3290 for (i = 0; i < he->
c; i++) {
3292 te =
stpcpy(te, pkgs[i]);
3295 he->
p.
argv[he->
c] = NULL;
3317 assert(N.
argv[i] != NULL && *N.
argv[i] !=
'\0');
3320 && !(a=strcmp(N.
argv[i], N.
argv[i-1]))
3321 && !(b=strcmp(EVR.
argv[i], EVR.
argv[i-1]))
3322 && (F.
ui32p[i] & 0x4e) == ((F.
ui32p[i-1] & 0x4e)) )
3347 if (xx == 0)
goto exit;
3353 if (xx == 0)
goto exit;
3358 if (xx == 0)
goto exit;
3361 nb =
sizeof(*he->
p.
argv);
3363 for (i = 0; i < c; i++) {
3369 nb +=
sizeof(*he->
p.
argv);
3370 nb +=
sizeof(
"<rpm:entry name=\"\"/>");
3371 if (*N.
argv[i] ==
'/')
3374 nb += strlen(N.
argv[i]);
3375 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3376 nb +=
sizeof(
" flags=\"EQ\" epoch=\"0\" ver=\"\"") - 1;
3377 nb += strlen(EVR.
argv[i]);
3378 if (strchr(EVR.
argv[i],
':') != NULL)
3380 if (strchr(EVR.
argv[i],
'-') != NULL)
3381 nb +=
sizeof(
" rel=\"\"") - 2;
3385 nb +=
sizeof(
" pre=\"1\"") - 1;
3393 t = (
char *) &he->
p.
argv[he->
c + 1];
3395 for (i = 0; i < c; i++) {
3400 he->
p.
argv[ac++] = t;
3401 t =
stpcpy(t,
"<rpm:entry");
3402 t =
stpcpy(t,
" name=\"");
3403 if (*N.
argv[i] ==
'/') {
3409 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3410 static char *Fstr[] = {
"?0",
"LT",
"GT",
"?3",
"EQ",
"LE",
"GE",
"?7" };
3412 const char *E, *V, *R;
3415 f = (
char *) EVR.
argv[i];
3416 for (fe = f; *fe !=
'\0' && *fe >=
'0' && *fe <=
'9'; fe++)
3418 if (*fe ==
':') { *fe++ =
'\0'; E = f; f = fe; }
else E = NULL;
3420 for (fe = f; *fe !=
'\0' && *fe !=
'-'; fe++)
3422 if (*fe ==
'-') { *fe++ =
'\0'; R = fe; }
else R = NULL;
3431 t =
stpcpy(t,
" pre=\"1\"");
3436 he->
p.
argv[he->
c] = NULL;
3492 spew_t spew,
int lvl)
3495 int ix = (he->
ix > 0 ? he->
ix : 0);
3500 val =
xstrdup(
_(
"(not a string)"));
3533 static char q =
'"';
3549 if (xx == 0)
goto exit;
3555 if (xx == 0)
goto exit;
3560 if (xx == 0)
goto exit;
3566 for (i = 0; i < c; i++) {
3572 nb += strlen(instance) +
sizeof(
", '', '', '', '', ''") - 1;
3574 nb +=
sizeof(
", ''") - 1;
3575 nb += strlen(N.
argv[i]);
3576 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3577 uint32_t Fx = ((F.
ui32p[i] >> 1) & 0x7);
3580 const char * E = Revr->F[RPMEVR_E];
3581 const char * V = Revr->F[RPMEVR_V];
3583 const char * T = Revr->F[RPMEVR_T];
3585 const char * R = Revr->F[RPMEVR_R];
3587 const char * D = Revr->F[RPMEVR_D];
3590 nb += (
sizeof(
", 'EQ'")-1);
3591 nb += (
sizeof(
", ''")-1) + strlen(E);
3592 nb += (
sizeof(
", ''")-1) + strlen(V);
3594 nb += (
sizeof(
", ''")-1) + strlen(T);
3596 nb += (
sizeof(
", ''")-1) + strlen(R);
3598 nb += (
sizeof(
", ''")-1) + strlen(D);
3604 nb +=
sizeof(
"1") - 1;
3609 nb += (ac + 1) *
sizeof(*he->
p.
argv);
3615 te = (
char *) &he->
p.
argv[ac + 1];
3618 for (i = 0; i < c; i++) {
3623 he->
p.
argv[ac++] = te;
3624 te =
stpcpy(te, instance);
3625 *te++ =
','; *te++ =
' ';
3626 *te++ = q; te =
stpcpy(te, N.
argv[i]); *te++ = q;
3628 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3629 static const char *Fstr[] = {
"?0",
"LT",
"GT",
"?3",
"EQ",
"LE",
"GE",
"?7" };
3630 uint32_t Fx = ((F.
ui32p[i] >> 1) & 0x7);
3633 const char * E = Revr->F[RPMEVR_E];
3634 const char * V = Revr->F[RPMEVR_V];
3636 const char * T = Revr->F[RPMEVR_T];
3638 const char * R = Revr->F[RPMEVR_R];
3640 const char * D = Revr->F[RPMEVR_D];
3643 *te++ =
','; *te++ =
' ';
3644 *te++ = q; te =
stpcpy(te, Fstr[Fx]); *te++ = q;
3645 *te++ =
','; *te++ =
' ';
3646 *te++ = q; te =
stpcpy(te, E); *te++ = q;
3647 *te++ =
','; *te++ =
' ';
3648 *te++ = q; te =
stpcpy(te, V); *te++ = q;
3650 *te++ =
','; *te++ =
' ';
3651 *te++ = q; te =
stpcpy(te, T); *te++ = q;
3653 *te++ =
','; *te++ =
' ';
3654 *te++ = q; te =
stpcpy(te, R); *te++ = q;
3656 *te++ =
','; *te++ =
' ';
3657 *te++ = q; te =
stpcpy(te, D); *te++ = q;
3662 *te++ =
','; *te++ =
' ';
3663 *te++ = q; *te++ = q;
3664 *te++ =
','; *te++ =
' ';
3665 *te++ = q; *te++ = q;
3666 *te++ =
','; *te++ =
' ';
3667 *te++ = q; *te++ = q;
3668 *te++ =
','; *te++ =
' ';
3669 *te++ = q; *te++ = q;
3678 he->
p.
argv[ac] = NULL;
3745 if (xx == 0)
goto exit;
3751 if (xx == 0)
goto exit;
3756 if (xx == 0)
goto exit;
3759 nb =
sizeof(*he->
p.
argv);
3761 for (i = 0; i < c; i++) {
3767 nb +=
sizeof(*he->
p.
argv);
3769 if (*N.
argv[i] ==
'/')
3772 nb += strlen(N.
argv[i]);
3773 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3774 nb +=
sizeof(
" >= ") - 1;
3775 nb += strlen(EVR.
argv[i]);
3783 t = (
char *) &he->
p.
argv[he->
c + 1];
3785 for (i = 0; i < c; i++) {
3790 he->
p.
argv[ac++] = t;
3792 if (*N.
argv[i] ==
'/') {
3797 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3798 static char *Fstr[] = {
"?0",
"<",
">",
"?3",
"=",
"<=",
">=",
"?7" };
3806 he->
p.
argv[he->
c] = NULL;
3869 size_t dnlen = strlen(dn);
3872 if (strstr(dn,
"bin/") != NULL)
3874 if (dnlen >=
sizeof(
"/etc/")-1 && !strncmp(dn,
"/etc/", dnlen))
3876 if (!strcmp(dn,
"/usr/lib/") && !strcmp(BN.
argv[i],
"sendmail"))
3902 if (xx == 0)
goto exit;
3908 if (xx == 0)
goto exit;
3913 if (xx == 0)
goto exit;
3918 if (xx == 0)
goto exit;
3923 if (xx == 0)
goto exit;
3926 nb =
sizeof(*he->
p.
argv);
3928 for (i = 0; i < c; i++) {
3929 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3932 nb +=
sizeof(*he->
p.
argv);
3933 nb +=
sizeof(
"<file></file>");
3936 if (FFLAGS.
ui32p[i] & 0x40)
3937 nb +=
sizeof(
" type=\"ghost\"") - 1;
3938 else if (S_ISDIR(FMODES.
ui16p[i])) {
3939 nb +=
sizeof(
" type=\"dir\"") - 1;
3941 nb +=
sizeof(
"/") - 1;
3950 t = (
char *) &he->
p.
argv[he->
c + 1];
3953 for (i = 0; i < c; i++) {
3954 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3956 if (FFLAGS.
ui32p[i] & 0x40)
3958 if (S_ISDIR(FMODES.
ui16p[i]))
3960 he->
p.
argv[ac++] = t;
3964 t =
stpcpy(t,
"</file>");
3967 for (i = 0; i < c; i++) {
3968 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3970 if (FFLAGS.
ui32p[i] & 0x40)
3972 if (!S_ISDIR(FMODES.
ui16p[i]))
3974 he->
p.
argv[ac++] = t;
3975 t =
stpcpy(t,
"<file type=\"dir\">");
3983 t =
stpcpy(t,
"</file>");
3986 for (i = 0; i < c; i++) {
3987 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3989 if (!(FFLAGS.
ui32p[i] & 0x40))
3991 he->
p.
argv[ac++] = t;
3992 t =
stpcpy(t,
"<file type=\"ghost\">");
3995 t =
stpcpy(t,
"</file>");
3999 he->
p.
argv[he->
c] = NULL;
4055 if (xx == 0)
goto exit;
4061 if (xx == 0)
goto exit;
4066 if (xx == 0)
goto exit;
4071 if (xx == 0)
goto exit;
4076 if (xx == 0)
goto exit;
4080 nb =
sizeof(*he->
p.
argv);
4082 for (i = 0; i < c; i++) {
4083 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4086 nb +=
sizeof(*he->
p.
argv);
4087 nb += strlen(instance) +
sizeof(
", '', ''");
4089 nb += strlen(BN.
argv[i]);
4090 if (FFLAGS.
ui32p[i] & 0x40)
4091 nb +=
sizeof(
"ghost") - 1;
4092 else if (S_ISDIR(FMODES.
ui16p[i])) {
4093 nb +=
sizeof(
"dir") - 1;
4095 nb +=
sizeof(
"/") - 1;
4098 nb +=
sizeof(
"file") - 1;
4105 t = (
char *) &he->
p.
argv[he->
c + 1];
4108 for (i = 0; i < c; i++) {
4109 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4111 if (FFLAGS.
ui32p[i] & 0x40)
4113 if (S_ISDIR(FMODES.
ui16p[i]))
4115 he->
p.
argv[ac++] = t;
4117 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4118 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4119 t =
stpcpy(t,
"', 'file'");
4122 for (i = 0; i < c; i++) {
4123 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4125 if (FFLAGS.
ui32p[i] & 0x40)
4127 if (!S_ISDIR(FMODES.
ui16p[i]))
4129 he->
p.
argv[ac++] = t;
4131 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4132 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4138 t =
stpcpy(t,
"', 'dir'");
4141 for (i = 0; i < c; i++) {
4142 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4144 if (!(FFLAGS.
ui32p[i] & 0x40))
4146 he->
p.
argv[ac++] = t;
4148 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4149 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4150 t =
stpcpy(t,
"', 'ghost'");
4154 he->
p.
argv[he->
c] = NULL;
4211 if (xx == 0)
goto exit;
4217 if (xx == 0)
goto exit;
4222 if (xx == 0)
goto exit;
4227 if (xx == 0)
goto exit;
4232 if (xx == 0)
goto exit;
4235 nb =
sizeof(*he->
p.
argv);
4237 for (i = 0; i < c; i++) {
4238 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4241 nb +=
sizeof(*he->
p.
argv);
4245 if (FFLAGS.
ui32p[i] & 0x40)
4246 nb +=
sizeof(
"") - 1;
4247 else if (S_ISDIR(FMODES.
ui16p[i]))
4248 nb +=
sizeof(
"/") - 1;
4255 t = (
char *) &he->
p.
argv[he->
c + 1];
4258 for (i = 0; i < c; i++) {
4259 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4261 if (FFLAGS.
ui32p[i] & 0x40)
4263 if (S_ISDIR(FMODES.
ui16p[i]))
4265 he->
p.
argv[ac++] = t;
4272 for (i = 0; i < c; i++) {
4273 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4275 if (FFLAGS.
ui32p[i] & 0x40)
4277 if (!S_ISDIR(FMODES.
ui16p[i]))
4279 he->
p.
argv[ac++] = t;
4288 for (i = 0; i < c; i++) {
4289 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4291 if (!(FFLAGS.
ui32p[i] & 0x40))
4293 he->
p.
argv[ac++] = t;
4300 he->
p.
argv[he->
c] = NULL;
4347 val =
xstrdup(
_(
"(not a string)"));
4356 assert(he->
p.
str != NULL);
4358 if ((bn = strrchr(he->
p.
str,
'/')) != NULL)
4375 typedef struct key_s {
4426 STAT_KEYS_FLAGS = (1U << 13),
4431 STAT_KEYS_FCONTEXT = (1U << 16),
4449 {
"fcontext", STAT_KEYS_FCONTEXT },
4450 {
"flags", STAT_KEYS_FLAGS },
4494 UUID_KEYS_STRING = (0U << 4),
4495 UUID_KEYS_SIV = (1U << 4),
4496 UUID_KEYS_BINARY = (2U << 4),
4497 UUID_KEYS_TEXT = (3U << 4),
4504 {
"binary", UUID_KEYS_BINARY },
4505 {
"siv", UUID_KEYS_SIV },
4506 {
"string", UUID_KEYS_STRING },
4507 {
"text", UUID_KEYS_TEXT },
4534 if (name && * name) {
4536 KEY *k = (
KEY *)bsearch(&needle, keys, nkeys,
sizeof(*keys),
keyCmp);
4552 int ix = (he->
ix > 0 ? he->
ix : 0);
4559 val =
xstrdup(
_(
"(invalid type :digest)"));
4563 ns =
sizeof(he->
p.
ui64p[0]);
4566 ns = strlen(he->
p.
str);
4573 assert(he->
p.
ptr != NULL);
4597 static const char *avdefault[] = {
"mode", NULL };
4599 const char * fn = NULL;
4600 struct stat sb, *st = &sb;
4601 int ix = (he->
ix > 0 ? he->
ix : 0);
4606 memset(st, 0,
sizeof(*st));
4612 if ((
size_t)he->
c ==
sizeof(*st)) {
4613 st = (
struct stat *)he->
p.
ptr;
4618 val =
xstrdup(
_(
"(invalid type :stat)"));
4623 if (
Lstat(fn, st) == 0)
4632 if (!(av && av[0] && *av[0]))
4634 for (i = 0; av[i] != NULL; i++) {
4636 size_t nb =
sizeof(b);
4648 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_dev);
4651 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_ino);
4654 xx =
snprintf(b, nb,
"%06o", (
unsigned)st->st_mode);
4657 xx =
snprintf(b, nb,
"0x%ld", (
unsigned long)st->st_nlink);
4660 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_uid);
4663 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_gid);
4666 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_rdev);
4669 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_size);
4672 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_blksize);
4675 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_blocks);
4678 (void)
stpcpy(b, ctime((time_t *)&st->st_atime));
4681 (void)
stpcpy(b, ctime((time_t *)&st->st_ctime));
4684 (void)
stpcpy(b, ctime((time_t *)&st->st_mtime));
4687 case STAT_KEYS_FLAGS:
4691 if (fn != NULL &&
S_ISLNK(st->st_mode)) {
4692 ssize_t size =
Readlink(fn, b, nb);
4694 nval =
rpmExpand(
"(Readlink:", fn,
":", strerror(
errno),
")", NULL);
4702 if (fn != NULL && S_ISREG(st->st_mode)) {
4706 if (fd == NULL ||
Ferror(fd)) {
4709 static int asAscii = 1;
4710 char buffer[16 * 1024];
4712 while (
Fread(buffer,
sizeof(buffer[0]),
sizeof(buffer), fd) > 0)
4728 {
const char * uname =
uidToUname(st->st_uid);
4732 xx =
snprintf(b, nb,
"%u", (
unsigned)st->st_uid);
4735 {
const char * gname =
gidToGname(st->st_gid);
4739 xx =
snprintf(b, nb,
"%u", (
unsigned)st->st_gid);
4769 static const char hex[] =
"0123456789abcdef";
4774 static const char *avdefault[] = {
"v5", NULL };
4776 int ix = (he->
ix > 0 ? he->
ix : 0);
4784 val =
xmalloc((128/4 + 4) + 1);
4792 val =
xstrdup(
_(
"(invalid type :uuid)"));
4800 val =
xstrdup(
_(
"(invalid tag :uuid)"));
4811 tv.tv_sec = (long) he->
p.
ui64p[0];
4812 tv.tv_usec = (
long) (he->
c > 1 ? he->
p.
ui64p[1] : 0);
4817 for (i = 0; i < nhe->
c; i++) {
4818 *te++ = hex[ (int)((nhe->
p.
ui8p[i] >> 4) & 0x0f) ];
4819 *te++ = hex[ (int)((nhe->
p.
ui8p[i] ) & 0x0f) ];
4820 if (i == 3 || i == 5 || i == 7 || i == 9)
4833 val =
xstrdup(
_(
"(invalid tag :uuid)"));
4840 for (i = 0; i < he->
c; i++) {
4841 *te++ = hex[ (int)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
4842 *te++ = hex[ (int)((he->
p.
ui8p[i] ) & 0x0f) ];
4857 if (!(av && av[0] && *av[0]))
4860 for (i = 0; av[i] != NULL; i++) {
4861 uint32_t keyval =
keyValue(keyUuids, nkeyUuids, av[i]);
4870 ix =
str2uuid(nhe, NULL, keyval, val);
4891 int64_t * stack = memset(
alloca(ac*
sizeof(*stack)), 0, (ac*
sizeof(*stack)));
4899 val =
xstrdup(
_(
"(invalid type :rpn)"));
4903 stack[ix] = he->
p.
ui64p[0];
4908 stack[ix] = strtoll(he->
p.
str, &end, 0);
4910 if (end && *end !=
'\0') {
4911 val =
xstrdup(
_(
"(invalid string :rpn)"));
4918 for (i = 0; av[i] != NULL; i++) {
4919 const char * arg = av[i];
4920 size_t len = strlen(arg);
4925 }
else if (len > 1) {
4927 val =
xstrdup(
_(
"(expected number :rpn)"));
4931 val =
xstrdup(
_(
"(stack overflow :rpn)"));
4935 stack[ix] = strtoll(arg, &end, 0);
4936 if (end && *end !=
'\0') {
4937 val =
xstrdup(
_(
"(invalid number :rpn)"));
4942 val =
xstrdup(
_(
"(stack underflow :rpn)"));
4946 case '&': stack[ix] &= stack[ix+1];
break;
4947 case '|': stack[ix] |= stack[ix+1];
break;
4948 case '^': stack[ix] ^= stack[ix+1];
break;
4949 case '+': stack[ix] += stack[ix+1];
break;
4950 case '-': stack[ix] -= stack[ix+1];
break;
4951 case '*': stack[ix] *= stack[ix+1];
break;
4954 if (stack[ix+1] == 0) {
4955 val =
xstrdup(
_(
"(divide by zero :rpn)"));
4959 stack[ix] %= stack[ix+1];
4961 stack[ix] /= stack[ix+1];
4967 {
HE_t nhe = (
HE_t) memset(
alloca(
sizeof(*nhe)), 0,
sizeof(*nhe));
4998 val =
xstrdup(
_(
"(invalid type :strsub)"));
5002 if (ac < 2 || (ac % 2) != 0) {
5003 val =
xstrdup(
_(
"(invalid args :strsub)"));
5012 for (i = 0; av[i] != NULL; i += 2)
5016 if (mires != NULL) {
5019 const char * s, * se;
5025 for (i = 0; i < nmires; i++) {
5026 miRE mire = mires + i;
5036 while (*s !=
'\0') {
5038 if ((se = strchr(s,
'\n')) == NULL)
5043 offsets[0] = offsets[1] = -1;
5049 nb += offsets[0] + strlen(av[2*i+1]);
5051 if (xx != 0 || offsets[1] == offsets[0])
5052 nb += (se - (s + offsets[1]));
5062 if (xx != 0 || offsets[1] == offsets[0]) {
5064 te =
stpncpy(te, s, (se - s));
5086 { HEADER_EXT_TAG,
"RPMTAG_BUILDTIMEUUID",
5088 { HEADER_EXT_TAG,
"RPMTAG_CHANGELOGNAME",
5090 { HEADER_EXT_TAG,
"RPMTAG_CHANGELOGTEXT",
5092 { HEADER_EXT_TAG,
"RPMTAG_DESCRIPTION",
5094 { HEADER_EXT_TAG,
"RPMTAG_GROUP",
5096 { HEADER_EXT_TAG,
"RPMTAG_HDRUUID",
5098 { HEADER_EXT_TAG,
"RPMTAG_INSTALLPREFIX",
5100 { HEADER_EXT_TAG,
"RPMTAG_INSTALLTIDUUID",
5102 { HEADER_EXT_TAG,
"RPMTAG_INSTALLTIMEUUID",
5104 { HEADER_EXT_TAG,
"RPMTAG_ORIGINTIDUUID",
5106 { HEADER_EXT_TAG,
"RPMTAG_ORIGINTIMEUUID",
5108 { HEADER_EXT_TAG,
"RPMTAG_PKGUUID",
5110 { HEADER_EXT_TAG,
"RPMTAG_REMOVETIDUUID",
5112 { HEADER_EXT_TAG,
"RPMTAG_SOURCEPKGUUID",
5114 { HEADER_EXT_TAG,
"RPMTAG_SUMMARY",
5116 { HEADER_EXT_TAG,
"RPMTAG_TRIGGERCONDS",
5118 { HEADER_EXT_TAG,
"RPMTAG_TRIGGERTYPE",
5120 { HEADER_EXT_TAG,
"RPMTAG_DBINSTANCE",
5122 { HEADER_EXT_TAG,
"RPMTAG_HEADERSTARTOFF",
5124 { HEADER_EXT_TAG,
"RPMTAG_HEADERENDOFF",
5126 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEBASEURL",
5128 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEDIGEST",
5130 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEORIGIN",
5132 { HEADER_EXT_TAG,
"RPMTAG_PACKAGESIZE",
5134 { HEADER_EXT_TAG,
"RPMTAG_PACKAGETIME",
5136 { HEADER_EXT_TAG,
"RPMTAG_NVRA",
5138 { HEADER_EXT_TAG,
"RPMTAG_FILENAMES",
5140 { HEADER_EXT_TAG,
"RPMTAG_FILEPATHS",
5142 { HEADER_EXT_TAG,
"RPMTAG_ORIGPATHS",
5144 { HEADER_EXT_TAG,
"RPMTAG_FILESTAT",
5146 { HEADER_EXT_TAG,
"RPMTAG_PROVIDEXMLENTRY",
5148 { HEADER_EXT_TAG,
"RPMTAG_REQUIREXMLENTRY",
5150 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTXMLENTRY",
5152 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETEXMLENTRY",
5154 { HEADER_EXT_TAG,
"RPMTAG_FILESXMLENTRY1",
5156 { HEADER_EXT_TAG,
"RPMTAG_FILESXMLENTRY2",
5158 { HEADER_EXT_TAG,
"RPMTAG_PROVIDEYAMLENTRY",
5160 { HEADER_EXT_TAG,
"RPMTAG_REQUIREYAMLENTRY",
5162 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTYAMLENTRY",
5164 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETEYAMLENTRY",
5166 { HEADER_EXT_TAG,
"RPMTAG_FILESYAMLENTRY1",
5168 { HEADER_EXT_TAG,
"RPMTAG_FILESYAMLENTRY2",
5170 { HEADER_EXT_TAG,
"RPMTAG_PROVIDESQLENTRY",
5172 { HEADER_EXT_TAG,
"RPMTAG_REQUIRESQLENTRY",
5174 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTSQLENTRY",
5176 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETESQLENTRY",
5178 { HEADER_EXT_TAG,
"RPMTAG_FILESSQLENTRY1",
5180 { HEADER_EXT_TAG,
"RPMTAG_FILESSQLENTRY2",
5182 { HEADER_EXT_TAG,
"RPMTAG_DEBCONFLICTS",
5184 { HEADER_EXT_TAG,
"RPMTAG_DEBDEPENDS",
5186 { HEADER_EXT_TAG,
"RPMTAG_DEBMD5SUMS",
5188 { HEADER_EXT_TAG,
"RPMTAG_DEBOBSOLETES",
5190 { HEADER_EXT_TAG,
"RPMTAG_DEBPROVIDES",
5192 { HEADER_EXT_TAG,
"RPMTAG_NEEDSWHAT",
5194 { HEADER_EXT_TAG,
"RPMTAG_WHATNEEDS",
5196 { HEADER_EXT_FORMAT,
"armor",
5198 { HEADER_EXT_FORMAT,
"base64",
5200 { HEADER_EXT_FORMAT,
"bncdata",
5202 { HEADER_EXT_FORMAT,
"cdata",
5204 { HEADER_EXT_FORMAT,
"depflags",
5206 { HEADER_EXT_FORMAT,
"deptype",
5208 { HEADER_EXT_FORMAT,
"digest",
5210 { HEADER_EXT_FORMAT,
"fflags",
5212 { HEADER_EXT_FORMAT,
"hint",
5214 { HEADER_EXT_FORMAT,
"iconv",
5216 { HEADER_EXT_FORMAT,
"json",
5219 { HEADER_EXT_FORMAT,
"jsonescape",
5222 { HEADER_EXT_FORMAT,
"perms",
5224 { HEADER_EXT_FORMAT,
"permissions",
5226 { HEADER_EXT_FORMAT,
"pgpsig",
5228 { HEADER_EXT_FORMAT,
"rpn",
5230 { HEADER_EXT_FORMAT,
"sqlescape",
5232 { HEADER_EXT_FORMAT,
"stat",
5234 { HEADER_EXT_FORMAT,
"strsub",
5236 { HEADER_EXT_FORMAT,
"triggertype",
5238 { HEADER_EXT_FORMAT,
"utf8",
5240 { HEADER_EXT_FORMAT,
"uuid",
5242 { HEADER_EXT_FORMAT,
"xml",
5244 { HEADER_EXT_FORMAT,
"yaml",
5255 const struct headerTagTableEntry_s * t;
5262 if (_rpmTagTable == NULL)
5266 if (_rpmHeaderFormats == NULL)
5269 for (t = _rpmTagTable; t && t->name; t++) {
5271 static const char * tagtypes[] = {
5272 "",
"char",
"uint8",
"uint16",
"uint32",
"uint64",
5273 "string",
"octets",
"argv",
"i18nstring",
5278 fprintf(fp,
"%-20s %6d", t->name + 7, t->val);
5283 fprintf(fp,
" openpgp");
5285 fprintf(fp,
" x509");
5287 fprintf(fp,
" asn1");
5289 fprintf(fp,
" opaque");
5290 fprintf(fp,
" %s", tagtypes[ttype]);
5292 fprintf(fp,
" array");
5294 fprintf(fp,
" mapping");
5296 fprintf(fp,
" probe");
5298 fprintf(fp,
" tree");
5300 fprintf(fp,
"%s", t->name + 7);
5305 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
5306 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
5308 if (ext->name == NULL || ext->type != HEADER_EXT_TAG)
5314 fprintf(fp,
"%s\n", ext->name + 7);
5320 #define PARSER_BEGIN 0 5321 #define PARSER_IN_ARRAY 1 5322 #define PARSER_IN_EXPR 2 5431 fprintf(stderr,
"\t\t\\%c\n", ch);
5434 case 'a':
return '\a';
5435 case 'b':
return '\b';
5436 case 'f':
return '\f';
5437 case 'n':
return '\n';
5438 case 'r':
return '\r';
5439 case 't':
return '\t';
5440 case 'v':
return '\v';
5456 memset(he, 0,
sizeof(*he));
5473 if (format == NULL)
return NULL;
5475 for (i = 0; i < (unsigned) num; i++) {
5476 switch (format[i].type) {
5487 format[i].
u.
array.format =
5489 format[i].
u.
array.numTokens);
5492 format[i].
u.
cond.ifFormat =
5494 format[i].
u.
cond.numIfTokens);
5495 format[i].
u.
cond.elseFormat =
5497 format[i].
u.
cond.numElseTokens);
5503 format[i].
u.
cond.tag.fmtfuncs =
_free(format[i].u.
cond.tag.fmtfuncs);
5512 format =
_free(format);
5521 static headerSprintfArgs
hsaInit( headerSprintfArgs hsa)
5548 static sprintfToken
hsaNext( headerSprintfArgs hsa)
5552 sprintfToken fmt = NULL;
5560 if (hsa != NULL && hsa->
i < hsa->
numTokens) {
5562 if (hsa->
hi == NULL) {
5586 static headerSprintfArgs
hsaFini( headerSprintfArgs hsa)
5630 static char name[128];
5637 if (s != NULL && typep != NULL)
5642 for (; tbl->name != NULL; tbl++) {
5643 if (tbl->val == val)
5646 if ((s = tbl->name) == NULL)
5648 s +=
sizeof(
"RPMTAG_") - 1;
5674 for (; tbl->name != NULL; tbl++) {
5690 static int findTag(headerSprintfArgs hsa, sprintfToken token,
const char *
name)
5704 if (!strcmp(name,
"*")) {
5709 if (strncmp(
"RPMTAG_", name,
sizeof(
"RPMTAG_")-1)) {
5710 char * t =
alloca(strlen(name) +
sizeof(
"RPMTAG_"));
5716 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
5717 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
5719 if (ext->name == NULL || ext->type != HEADER_EXT_TAG)
5722 stag->
ext = ext->u.tagFunction;
5738 stag->
tagno[0] = tagno;
5740 if (stag->
av != NULL) {
5745 for (i = 0; stag->
av[i] != NULL; i++) {
5746 for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST;
5747 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1))
5749 if (ext->name == NULL || ext->type != HEADER_EXT_FORMAT)
5751 if (strcmp(ext->name, stag->
av[i]+1))
5753 stag->
fmtfuncs[i] = ext->u.fmtFunction;
5771 char * str,
char ** endPtr)
5786 sprintfToken * formatPtr,
5787 size_t * numTokensPtr,
5788 char ** endPtr,
int state)
5794 static const char *pstates[] = {
5795 "NORMAL",
"ARRAY",
"EXPR",
"WTF?" 5797 char * chptr, * start, * next, * dst;
5798 sprintfToken format;
5807 fprintf(stderr,
"--> parseFormat(%p, \"%.20s...\", %p, %p, %p, %s)\n", hsa, str, formatPtr, numTokensPtr, endPtr, pstates[(state & 0x3)]);
5813 for (chptr = str; *chptr !=
'\0'; chptr++)
5814 if (*chptr ==
'%' || *chptr ==
'[') numTokens++;
5815 numTokens = numTokens * 2 + 1;
5817 format =
xcalloc(numTokens,
sizeof(*format));
5818 if (endPtr) *endPtr = NULL;
5825 while (*start !=
'\0') {
5829 if (*(start + 1) ==
'%') {
5831 token = format + numTokens++;
5834 dst = token->
u.
string.string = start;
5842 token = format + numTokens++;
5846 if (*start ==
'|') {
5867 while (*chptr && *chptr !=
'{' && *chptr !=
'%') chptr++;
5868 if (!*chptr || *chptr ==
'%') {
5869 hsa->
errmsg =
_(
"missing { after %");
5876 fprintf(stderr,
"\tchptr *%p = NUL\n", chptr);
5880 while (start < chptr) {
5882 i = strtoul(start, &start, 10);
5891 if (*start ==
'=') {
5894 }
else if (*start ==
'#') {
5901 while (*next && *next !=
'}') next++;
5903 hsa->
errmsg =
_(
"missing } after %{");
5909 fprintf(stderr,
"\tnext *%p = NUL\n", next);
5913 #define isSEP(_c) ((_c) == ':' || (_c) == '|') 5915 while (!(*chptr ==
'\0' ||
isSEP(*chptr))) chptr++;
5917 while (
isSEP(*chptr)) {
5918 if (chptr[1] ==
'\0' ||
isSEP(chptr[1])) {
5919 hsa->
errmsg =
_(
"empty tag format");
5924 {
char * te = chptr + 1;
5925 char * t = strchr(te,
'(');
5928 while (!(*te ==
'\0' ||
isSEP(*te))) {
5930 if (te[0] ==
'\\' && te[1] !=
'\0') te++;
5934 c = *te; *te =
'\0';
5938 if (te <= t || te[-1] !=
')') {
5939 hsa->
errmsg =
_(
"malformed parameter list");
5949 fprintf(stderr,
"\tformat \"%s\" params \"%s\"\n", chptr, (t ? t :
""));
5959 if (*start ==
'\0') {
5960 hsa->
errmsg =
_(
"empty tag name");
5968 if (
findTag(hsa, token, start)) {
5969 hsa->
errmsg =
_(
"unknown tag");
5977 fprintf(stderr,
"\tdst = start = next %p\n", dst);
5984 fprintf(stderr,
"\t%s => %s *%p = NUL\n", pstates[(state & 0x3)], pstates[
PARSER_IN_ARRAY], start);
5987 token = format + numTokens++;
5991 &token->
u.
array.numTokens,
5992 &start, PARSER_IN_ARRAY))
5999 hsa->
errmsg =
_(
"] expected at end of array");
6007 fprintf(stderr,
"\tdst = start %p\n", dst);
6015 if (state != PARSER_IN_ARRAY) {
6016 hsa->
errmsg =
_(
"unexpected ]");
6023 fprintf(stderr,
"\t<= %s %p[-1] = NUL\n", pstates[(state & 0x3)], start);
6025 if (endPtr) *endPtr = start;
6031 hsa->
errmsg =
_(
"unexpected }");
6038 fprintf(stderr,
"\t<= %s %p[-1] = NUL\n", pstates[(state & 0x3)], start);
6040 if (endPtr) *endPtr = start;
6046 token = format + numTokens++;
6049 dst = token->
u.
string.string = start;
6055 fprintf(stderr,
"\t*%p = *%p \"%.30s\"\n", dst, start, start);
6057 if (start[0] ==
'\\' && start[1] !=
'\0') {
6066 if (dst < start) *dst =
'\0';
6075 for (i = 0; i < (unsigned) numTokens; i++) {
6077 switch(token->
type) {
6086 if (numTokensPtr != NULL)
6087 *numTokensPtr = numTokens;
6088 if (formatPtr != NULL)
6089 *formatPtr = format;
6095 char * str,
char ** endPtr)
6102 fprintf(stderr,
"--> parseExpression(%p, %p, \"%.20s...\", %p)\n", hsa, token, str, endPtr);
6107 while (*chptr && *chptr !=
'?') chptr++;
6109 if (*chptr !=
'?') {
6110 hsa->
errmsg =
_(
"? expected in expression");
6116 if (*chptr !=
'{') {
6117 hsa->
errmsg =
_(
"{ expected after ? in expression");
6128 if (!(end && *end)) {
6129 hsa->
errmsg =
_(
"} expected in expression");
6130 token->
u.
cond.ifFormat =
6136 if (*chptr !=
':' && *chptr !=
'|') {
6137 hsa->
errmsg =
_(
": expected following ? subexpression");
6138 token->
u.
cond.ifFormat =
6143 if (*chptr ==
'|') {
6147 token->
u.
cond.ifFormat =
6154 if (*chptr !=
'{') {
6155 hsa->
errmsg =
_(
"{ expected after : in expression");
6156 token->
u.
cond.ifFormat =
6168 if (!(end && *end)) {
6169 hsa->
errmsg =
_(
"} expected in expression");
6170 token->
u.
cond.ifFormat =
6176 if (*chptr !=
'|') {
6177 hsa->
errmsg =
_(
"| expected at end of expression");
6178 token->
u.
cond.ifFormat =
6180 token->
u.
cond.elseFormat =
6192 (void)
findTag(hsa, token, str);
6212 rc = fn(hsa->
h, he);
6276 val =
xstrdup(
"(unknown type)");
6277 need = strlen(val) + 1;
6280 #if defined(SUPPORT_I18NSTRING_TYPE) 6289 #if !defined(SUPPORT_I18NSTRING_TYPE) 6317 ival = he->
p.
ui64p[element];
6323 vhe->
ix = (he->
c > 1 ? 0 : -1);
6340 for (i = 0; tag->
av[i] != NULL; i++) {
6341 headerTagFormatFunction fmt;
6343 if ((fmt = tag->
fmtfuncs[i]) == NULL)
6346 if (val != NULL && *tag->
av[i] ==
'|') {
6360 nval = fmt(vhe, av);
6364 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)"));
6369 val =
xstrdup((nval ? nval :
""));
6373 val =
rpmExpand(val, (*val !=
'\0' ?
" | " :
""), nval, NULL);
6384 assert(val != NULL);
6386 need = strlen(val) + 1;
6389 if (val && need > 0) {
6392 nb = strlen(tag->
format) +
sizeof(
"%s");
6395 nb = tag->
pad + strlen(val) + 1;
6431 sprintfTag tag = NULL;
6433 size_t condNumFormats;
6439 switch (token->
type) {
6445 if (need == 0)
break;
6462 if (token->
u.
cond.tag.ext
6465 spft = token->
u.
cond.ifFormat;
6466 condNumFormats = token->
u.
cond.numIfTokens;
6468 spft = token->
u.
cond.elseFormat;
6469 condNumFormats = token->
u.
cond.numElseTokens;
6472 need = condNumFormats * 20;
6473 if (spft == NULL || need == 0)
break;
6476 for (i = 0; i < condNumFormats; i++, spft++) {
6487 spft = token->
u.
array.format;
6488 for (i = 0; i < token->
u.
array.numTokens; i++, spft++)
6510 if (numElements == 0) {
6511 numElements = he->
c;
6514 if ((
size_t)he->
c == numElements)
6517 _(
"array iterator used with different sized arrays");
6523 if (numElements == 0)
6528 spft = token->
u.
array.format;
6530 if (numElements == 0) {
6532 need =
sizeof(
"(none)\n") - 1;
6534 te =
stpcpy(t,
"(none)\n");
6539 const char * tagN = NULL;
6542 need = numElements * token->
u.
array.numTokens;
6543 if (need == 0)
break;
6550 && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"xml"))
6553 && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"yaml"))
6556 && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"json"))
6559 if (spew == &_xml_spew) {
6560 assert(tag->
tagno != NULL);
6562 if (tag->
tagno[0] & 0x40000000) {
6566 need =
sizeof(
" <rpmTag name=\"\">\n") + strlen(tagN);
6571 if (spew == &_yaml_spew) {
6572 assert(tag->
tagno != NULL);
6574 if (tag->
tagno[0] & 0x40000000) {
6576 tagT = numElements > 1
6580 need =
sizeof(
" : - ") + strlen(tagN);
6591 if (spew == &_json_spew) {
6592 assert(tag->
tagno != NULL);
6594 if (tag->
tagno[0] & 0x40000000) {
6596 tagT = numElements > 1
6603 need =
sizeof(
" : [ ") + strlen(tagN);
6611 need = numElements * token->
u.
array.numTokens * 10;
6613 for (j = 0; j < numElements; j++) {
6614 spft = token->
u.
array.format;
6615 for (i = 0; i < token->
u.
array.numTokens; i++, spft++) {
6624 if (spew == &_xml_spew) {
6625 need =
sizeof(
" </rpmTag>\n") - 1;
6627 te =
stpcpy(te,
" </rpmTag>\n");
6630 if (spew == &_json_spew) {
6632 need =
sizeof(
" ],\n") - 1;
6634 te =
stpcpy(te,
" ],\n");
6637 need =
sizeof(
"\n") - 1;
6666 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
6667 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
6690 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
6691 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
6706 sprintfToken nextfmt;
6714 fprintf(stderr,
"==> headerSprintf(%p, \"%s\", %p, %p, %p)\n", h, fmt, tags, exts, errmsg);
6751 && tag->
av != NULL && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"xml"))
6754 && tag->
av != NULL && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"yaml"))
6757 && tag->
av != NULL && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"json"))
6762 need = strlen(spew_init);
6764 te =
stpcpy(t, spew_init);
6766 spew_init =
_free(spew_init);
6770 while ((nextfmt =
hsaNext(hsa)) != NULL) {
6783 need = strlen(spew_fini);
6785 te =
stpcpy(t, spew_fini);
6787 spew_fini =
_free(spew_fini);
enum rpmTagReturnType_e rpmTagReturnType
Identify how to return the header data type.
int rpmmiPrune(rpmmi mi, uint32_t *hdrNums, int nHdrNums, int sorted)
Remove items from set of package instances to iterate.
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 headerSprintfArgs_s * headerSprintfArgs
pgpDig pgpDigFree(pgpDig dig)
Destroy a container for parsed OpenPGP packates.
static char * rpnFormat(HE_t he, const char **av)
Return arithmetic expressions of input.
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.
const char * xstrtolocale(const char *str)
Force encoding of string.
void * mireFreeAll(miRE mire, int nmire)
Destroy compiled patterns.
static char * strdup_iconv_check(const char *buffer, const char *tocode)
static int CxmlTag(Header h, HE_t he)
static HE_t rpmecNew(const headerSprintfExtension exts, int *necp)
Create an extension cache.
static char * dayFormat(HE_t he, const char **av)
Return day formatted data.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
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
struct pgpDigParams_s * pgpDigParams
static int instprefixTag(Header h, HE_t he)
Retrieve install prefixes.
static unsigned int pgpLen(const rpmuint8_t *s, unsigned int *lenp)
Return length of an OpenPGP packet.
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
Initialize digest.
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 int headerstartoffTag(Header h, HE_t he)
Retrieve starting byte offset of header.
static unsigned int pgpGrab(const rpmuint8_t *s, size_t nbytes)
Return (native-endian) integer from big-endian representation.
static int filestatTag(Header h, HE_t he)
const struct spew_s * spew_t
static HE_t rpmecFree(const headerSprintfExtension exts, HE_t ec)
Destroy an extension cache.
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[]
char * pgpArmorWrap(rpmuint8_t atype, const unsigned char *s, size_t ns)
Wrap a OpenPGP packets in ascii armor for transport.
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.
int rpmEVRparse(const char *evrstr, EVR_t evr)
Split EVR string into epoch, version, and release components.
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.
static int debevrTag(Header h, HE_t he, rpmTag tagN, rpmTag tagEVR, rpmTag tagF)
Retrieve and return Debian formatted dependecies for –deb:control.
static void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int _flags)
Attach digest to fd.
int argiCount(ARGI_t argi)
Return no.
size_t(* spew_strlen)(const char *s, int lvl)
static headerSprintfArgs hsaInit(headerSprintfArgs hsa)
Initialize an hsa iteration.
char * headerSprintf(Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
Return formatted output string from header tags.
static char * sqlescapeFormat(HE_t he, const char **av)
static int debobsoletesTag(Header h, HE_t he)
rpmTag tagValue(const char *tagstr)
Return tag value from name.
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.
rpmmi rpmmiInit(rpmdb db, rpmTag tag, const void *keyp, size_t keylen)
Return database iterator.
static const struct spew_s _sql_spew
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)
static int removetid_uuidTag(Header h, HE_t he)
Retrieve remove tid and convert to UUIDv1.
static const char uuid_path[]
#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)
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.
int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
Update context with next plain text buffer.
static rpmuint32_t myTagValue(headerTagTableEntry tbl, const char *name)
Return tag value from name.
static struct headerSprintfExtension_s _headerCompoundFormats[]
static sprintfToken freeFormat(sprintfToken format, size_t num)
Destroy headerSprintf format array.
static char * dateFormat(HE_t he, const char **av)
Return date formatted data.
static int PyamlTag(Header h, HE_t he)
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.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
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.
static const struct spew_s _xml_spew
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.
static const struct headerTagTableEntry_s _rpmTagTable[]
unsigned long long rpmuint64_t
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 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.
pgpDigParams pgpGetSignature(pgpDig dig)
Return OpenPGP signature parameters.
static int descriptionTag(Header h, HE_t he)
Retrieve description text.
union sprintfToken_s::@2 u
static int origpathsTag(Header h, HE_t he)
static int str2uuid(HE_t he, const char **av, rpmuint32_t version, char *val)
Convert tag string to UUID.
struct sprintfToken_s * sprintfToken
static int pkgmtimeTag(Header h, HE_t he)
Retrieve *.rpm package st->st_mtime from header.
The FD_t File Handle data structure.
static void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo, void *datap, size_t *lenp, int asAscii)
static void rpmfiBuildFNames(Header h, rpmTag tagN, const char ***fnp, rpmTagCount *fcp)
Retrieve file names from header.
static int parseExpression(headerSprintfArgs hsa, sprintfToken token, char *str, char **endPtr)
Parse a headerSprintf expression.
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
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.
const struct headerSprintfExtension_s * headerSprintfExtension
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.
static const char * _macro_i18ndomains
int xstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
static int F2xmlTag(Header h, HE_t he)
static int CyamlTag(Header h, HE_t he)
Header headerFree(Header h)
Dereference a header instance.
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.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
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 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.
static int tag2uuidv5(Header h, HE_t he)
Retrieve tag and convert to UUIDv5.
char *(* spew_strcpy)(char *t, const char *s, int lvl)
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.
Header headerLink(Header h)
Reference a header instance.
EVR_t rpmEVRnew(uint32_t Flags, int initialize)
Create a new EVR container.
int Readlink(const char *path, char *buf, size_t bufsiz)
readlink(2) clone.
static const struct spew_s _yaml_spew
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.
pgpDig pgpDigNew(pgpVSFlags vsflags, pgpPubkeyAlgo pubkey_algo)
Create a container for parsed OpenPGP packates.
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.
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 rpmEVRoverlap(EVR_t a, EVR_t b)
Compare EVR containers for overlap.
char * stpcpy(char *dest, const char *src)
static char * rpmPermsString(int mode)
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.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
char * uidToUname(uid_t uid)
int headerNEVRA(Header h, const char **np, const char **ep, const char **vp, const char **rp, const char **ap)
Return name, epoch, version, release, arch strings from header.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
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.
const struct headerTagTableEntry_s * headerTagTableEntry
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 sprintfTag_s * sprintfTag
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.
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.
static rpmuint32_t keyValue(KEY *keys, size_t nkeys, const char *name)
struct sprintfToken_s::@2::@5 cond
static int keyCmp(const void *a, const void *b)
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 pgpPrtPkts(const rpmuint8_t *pkts, size_t pktlen, pgpDig dig, int printing)
Print/parse a OpenPGP packet(s).
int argvSort(ARGV_t argv, int(*compar)(ARGstr_t *, ARGstr_t *))
Sort an argv array.
static int filenamesTag(Header h, HE_t he)
int rpmDigestFinal(DIGEST_CTX ctx, void *datap, size_t *lenp, int asAscii)
Return digest and destroy context.
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)
headerSprintfExtension headerDefaultFormats
Supported default header tag output formats.
int mireAppend(rpmMireMode mode, int tag, const char *pattern, const unsigned char *table, miRE *mirep, int *nmirep)
Append pattern to array.
static int PRCOyamlTag(Header h, HE_t he, rpmTag EVRtag, rpmTag Ftag)
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.
static int PRCOxmlTag(Header h, HE_t he, rpmTag EVRtag, rpmTag Ftag)
static int F1sqlTag(Header h, HE_t he)
Access RPM indices using Berkeley DB interface(s).
static char * pgpHexStr(const rpmuint8_t *p, size_t plen)
Return hex formatted representation of bytes.
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 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 const struct spew_s _json_spew
static int F2sqlTag(Header h, HE_t he)
static int RxmlTag(Header h, HE_t he)
headerSprintfExtension headerCompoundFormats
Supported default header extension/tag output formats.
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.
static char * shescapeFormat(HE_t he, const char **av)
Return shell escape formatted data.