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);
849 assert(he->
p.
ptr != NULL);
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;
888 #if defined(HAVE_ICONV)
892 assert(buffer != NULL);
896 assert(tocode != NULL);
898 #ifdef HAVE_LANGINFO_H
900 if (fromcode == NULL)
901 fromcode = nl_langinfo (CODESET);
903 assert(fromcode != NULL);
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;
910 size_t err = iconv(fd, NULL, NULL, NULL, NULL);
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;
950 fprintf(stderr,
"warning: %s: from iconv(%s -> %s) for \"%s\" -> \"%s\"\n", strerror(_iconv_errno), fromcode, tocode, buffer, t);
968 int ix = (he->
ix > 0 ? he->
ix : 0);
999 int ix = (he->
ix > 0 ? he->
ix : 0);
1006 val =
xstrdup(
_(
"(not a string)"));
1020 int ix = (he->
ix > 0 ? he->
ix : 0);
1021 const char * xtag = NULL;
1023 const char * s = NULL;
1043 {
int cpl = b64encode_chars_per_line;
1044 b64encode_chars_per_line = 0;
1048 b64encode_chars_per_line = cpl;
1053 anint = (uint64_t)he->
p.
ui8p[ix];
1056 anint = (uint64_t)he->
p.
ui16p[ix];
1059 anint = (uint64_t)he->
p.
ui32p[ix];
1065 val =
xstrdup(
_(
"(invalid xml type)"));
1071 static int tlen = 64;
1077 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1087 nb += strlen(xtag) +
sizeof(
"\t</>");
1092 nb += 2 * strlen(xtag) +
sizeof(
"\t<></>");
1119 int element = he->
ix;
1120 int ix = (he->
ix > 0 ? he->
ix : 0);
1121 const char * xtag = NULL;
1123 const char * s = NULL;
1142 if (strchr(
"[", s[0]))
1145 while ((c = (
int) *s++) != (int)
'\0') {
1151 if (s[0] ==
' ' || s[0] ==
'\t')
1156 if (s[0] !=
' ' && s[0] !=
'\0' && s[1] !=
'"')
1168 }
else if (he->
ix < 0) {
1181 if (he->
ix < 0) lvl++;
1186 xtag = (element >= 0 ?
"- " : NULL);
1193 {
int cpl = b64encode_chars_per_line;
1194 b64encode_chars_per_line = 0;
1199 b64encode_chars_per_line = cpl;
1204 anint = (uint64_t)he->
p.
ui8p[ix];
1207 anint = (uint64_t)he->
p.
ui16p[ix];
1210 anint = (uint64_t)he->
p.
ui32p[ix];
1216 val =
xstrdup(
_(
"(invalid yaml type)"));
1222 static int tlen = 64;
1225 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1228 xtag = (element >= 0 ?
"- " : NULL);
1237 nb +=
sizeof(
" ") - 1;
1238 nb +=
sizeof(
"- ~") - 1;
1247 nb +=
sizeof(
" ") - 1;
1280 int element = he->
ix;
1281 int ix = (he->
ix > 0 ? he->
ix : 0);
1283 const char * s = NULL;
1303 {
int cpl = b64encode_chars_per_line;
1304 b64encode_chars_per_line = 0;
1307 b64encode_chars_per_line = cpl;
1310 anint = (uint64_t)he->
p.
ui8p[ix];
1313 anint = (uint64_t)he->
p.
ui16p[ix];
1316 anint = (uint64_t)he->
p.
ui32p[ix];
1322 val =
xstrdup(
_(
"(invalid json type)"));
1328 static int tlen = 64;
1330 xx =
snprintf(t, tlen,
"%llu", (
unsigned long long)anint);
1340 t = te =
alloca(nb +
sizeof(
"\"\","));
1342 if (c !=
'\0') *te++ = c;
1347 if (c !=
'\0') *te++ = c;
1372 int ix = (he->
ix > 0 ? he->
ix : 0);
1380 unsigned int pktlen = 0;
1381 unsigned int v = (
unsigned int) *pkt;
1384 unsigned int hlen = 0;
1389 plen =
pgpLen(pkt+1, &hlen);
1391 tag = (v >> 2) & 0xf;
1392 plen = (1 << (v & 0x3));
1396 pktlen = 1 + plen + hlen;
1400 val =
xstrdup(
_(
"(not an OpenPGP signature)"));
1405 const char *tempstr;
1415 if (t + 5 >= val + nb)
1420 if (t + strlen (
", ") + 1 >= val + nb)
1426 { time_t dateint =
pgpGrab(sigp->time,
sizeof(sigp->time));
1427 struct tm * tstruct = localtime(&dateint);
1429 (void) strftime(t, (nb - (t - val)),
"%c", tstruct);
1432 if (t + strlen (
", Key ID ") + 1 >= val + nb)
1434 t =
stpcpy(t,
", Key ID ");
1435 tempstr =
pgpHexStr(sigp->signid,
sizeof(sigp->signid));
1436 if (t + strlen (tempstr) > val + nb)
1457 int ix = (he->
ix > 0 ? he->
ix : 0);
1462 val =
xstrdup(
_(
"(invalid type)"));
1471 if (anint & RPMSENSE_SCRIPT_PRE)
1472 te =
stpcpy(te,
"(pre)");
1473 else if (anint & RPMSENSE_SCRIPT_POST)
1474 te =
stpcpy(te,
"(post)");
1475 else if (anint & RPMSENSE_SCRIPT_PREUN)
1476 te =
stpcpy(te,
"(preun)");
1477 else if (anint & RPMSENSE_SCRIPT_POSTUN)
1478 te =
stpcpy(te,
"(postun)");
1488 if (anint & RPMSENSE_SENSEMASK)
1509 int ix = (he->
ix > 0 ? he->
ix : 0);
1514 val =
xstrdup(
_(
"(invalid type)"));
1522 if (anint & RPMSENSE_SCRIPT_PRE)
1524 else if (anint & RPMSENSE_SCRIPT_POST)
1526 else if (anint & RPMSENSE_SCRIPT_PREUN)
1527 te =
stpcpy(te,
"preun");
1528 else if (anint & RPMSENSE_SCRIPT_POSTUN)
1529 te =
stpcpy(te,
"postun");
1530 else if (anint & RPMSENSE_SCRIPT_VERIFY)
1531 te =
stpcpy(te,
"verify");
1532 else if (anint & RPMSENSE_RPMLIB)
1533 te =
stpcpy(te,
"rpmlib");
1534 else if (anint & RPMSENSE_INTERP)
1535 te =
stpcpy(te,
"interp");
1536 else if (anint & (RPMSENSE_FIND_PROVIDES | RPMSENSE_FIND_REQUIRES))
1539 te =
stpcpy(te,
"manual");
1549 static const char * bfstring(
unsigned int x,
const char * xbf)
1551 const char * s = xbf;
1552 static char digits[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
1553 static char buf[BUFSIZ];
1558 radix = (s != NULL ? *s++ : 16);
1560 if (radix <= 1 || radix >= 32)
1565 case 8: *t++ =
'0';
break;
1566 case 16: *t++ =
'0'; *t++ =
'x';
break;
1571 do { i++; k /= radix; }
while (k);
1576 do { --
i; t[
i] = digits[k % radix]; k /= radix; }
while (k);
1581 while ((c = *s++) !=
'\0') {
1582 if (c >
' ')
continue;
1585 if (!(x & k))
continue;
1587 if (t == te) *t++ =
'=';
1594 if (t > te) *t++ =
'>';
1610 int ix = (he->
ix > 0 ? he->
ix : 0);
1615 val =
xstrdup(
_(
"(invalid type)"));
1623 if (anint & RPMSENSE_MISSINGOK)
1670 (tv->tv_usec * 10) + 0x01B21DD213814000ULL;
1682 he->
p.
ui8p[6] &= 0xf0;
1683 he->
p.
ui8p[8] &= 0xc0;
1684 he->
p.
ui8p[9] &= 0x00;
1717 tv.tv_sec = (long) he->
p.
ui32p[0];
1718 tv.tv_usec = (
long) (he->
c > 1 ? he->
p.
ui32p[1] : 0);
1810 static const char uuid_auth[] =
"%{?_uuid_auth}%{!?_uuid_auth:http://rpm5.org}";
1812 static const char uuid_path[] =
"%{?_uuid_path}%{!?_uuid_path:/package}";
1829 const char *
ns = NULL;
1831 const char * s = NULL;
1832 char * t = (val ? val :
alloca(40));
1836 if (!strcmp(
"Sigmd5", tagn))
1838 else if (!strcmp(
"Sha1header", tagn))
1849 s =
rpmGetPath(uuid_auth,
"/", uuid_path,
"/", tagn,
"/",
1887 static const char hex[] =
"0123456789abcdef";
1893 for (i = 0; i < he->
c; i++) {
1894 *te++ = hex[ (int)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
1895 *te++ = hex[ (int)((he->
p.
ui8p[i] ) & 0x0f) ];
1907 return str2uuid(he, NULL, 0, NULL);
2009 for (i = 0; i < (unsigned) he->
c; i++) {
2010 char * item, * flagsStr;
2015 for (j = 0; j < Nhe->
c; j++) {
2016 if (Ihe->
p.
ui32p[j] != i)
2024 sprintf(item,
"%s%s%s", Nhe->
p.
argv[j], flagsStr, Vhe->
p.
argv[j]);
2025 flagsStr =
_free(flagsStr);
2027 strcpy(item, Nhe->
p.
argv[j]);
2030 chptr =
xrealloc(chptr, strlen(chptr) + strlen(item) + 5);
2031 if (*chptr !=
'\0') strcat(chptr,
", ");
2032 strcat(chptr, item);
2088 numScripts = _he->
c;
2096 for (i = 0; i < (unsigned) he->
c; i++) {
2097 for (j = 0; j < (unsigned) numNames; j++) {
2098 if (indices.
ui32p[j] != i) {
2104 if (flags.
ui32p[j] & RPMSENSE_TRIGGERPREIN)
2106 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERIN)
2108 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERUN)
2110 else if (flags.
ui32p[j] & RPMSENSE_TRIGGERPOSTUN)
2128 #if defined(ENABLE_NLS)
2131 extern int _nl_msg_cat_cntr;
2150 char * dstring =
rpmExpand(_macro_i18ndomains, NULL);
2158 if (dstring && *dstring) {
2160 const char * langval;
2161 const char * msgkey;
2164 {
HE_t nhe = (
HE_t) memset(
alloca(
sizeof(*nhe)), 0,
sizeof(*nhe));
2167 size_t nb =
sizeof(
"()");
2178 if (tn) nb += strlen(tn);
2179 if (nhe->
p.
str) nb += strlen(nhe->
p.
str);
2182 (nhe->
p.
str ? nhe->
p.
str :
""), (tn ? tn :
""));
2189 langval =
getenv(language);
2190 (void)
setenv(language,
"en_US", 1);
2191 #if defined(ENABLE_NLS)
2196 for (domain = dstring; domain != NULL; domain = de) {
2197 de = strchr(domain,
':');
2198 if (de) *de++ =
'\0';
2202 if (msgid != msgkey)
break;
2207 (void)
setenv(language, langval, 1);
2210 #if defined(ENABLE_NLS)
2214 if (domain && msgid) {
2216 const char * s =
dgettext(domain, msgid);
2228 dstring =
_free(dstring);
2259 if (!rc || he->
p.
str == NULL || he->
c == 0) {
2274 {
const char ** argv;
2278 for (i = 0; i < (unsigned) he->
c; i++) {
2281 assert(he->
p.
argv[i] != NULL);
2282 l += strlen(he->
p.
argv[i]) + 1;
2284 argv =
xmalloc(he->
c *
sizeof(*argv) + l);
2285 te = (
char *)&argv[he->
c];
2286 for (i = 0; i < (unsigned) he->
c; i++) {
2423 const char * origin;
2449 const char * baseurl;
2474 const char * digest;
2539 const char * N = NULL;
2540 const char * V = NULL;
2541 const char * R = NULL;
2542 const char * A = NULL;
2547 if (N) nb += strlen(N);
2548 if (V) nb += strlen(V) + 1;
2549 if (R) nb += strlen(R) + 1;
2550 #if defined(RPM_VENDOR_OPENPKG)
2557 if (A) nb += strlen(A) + 1;
2565 #if defined(RPM_VENDOR_OPENPKG)
2623 rpmTag dirIndexesTag = 0;
2644 if (fnp) *fnp = NULL;
2653 if (xx == 0 && isSource) {
2658 dirNames.
argv[0] = (
const char *)&dirNames.
argv[2];
2666 if (fnp) *fnp = NULL;
2671 he->
tag = dirNameTag;
2675 he->
tag = dirIndexesTag;
2680 size =
sizeof(*fileNames.
argv) * count;
2681 for (i = 0; i < (unsigned)count; i++) {
2682 const char * dn = NULL;
2684 size += strlen(baseNames.
argv[i]) + strlen(dn) + 1;
2688 t = (
char *)&fileNames.
argv[count];
2689 for (i = 0; i < (unsigned)count; i++) {
2690 const char * dn = NULL;
2692 fileNames.
argv[
i] = t;
2702 *fnp = fileNames.
argv;
2706 if (fcp) *fcp = count;
2776 for (Nhe->
ix = 0; Nhe->
ix < (
int)Nhe->
c; Nhe->
ix++) {
2777 nb +=
sizeof(*he->
p.
argv);
2778 nb += strlen(Nhe->
p.
argv[Nhe->
ix]) + 1;
2779 if (*EVRhe->
p.
argv[Nhe->
ix] !=
'\0')
2780 nb += strlen(EVRhe->
p.
argv[Nhe->
ix]) + (
sizeof(
" (== )")-1);
2783 nb +=
sizeof(*he->
p.
argv);
2786 te = (
char *) &he->
p.
argv[he->
c+1];
2789 for (Nhe->
ix = 0; Nhe->
ix < (
int)Nhe->
c; Nhe->
ix++) {
2790 he->
p.
argv[he->
c++] = te;
2791 if (*EVRhe->
p.
argv[Nhe->
ix] !=
'\0') {
2792 char opstr[4], *
op = opstr;
2801 " (", opstr,
" ", EVRhe->
p.
argv[Nhe->
ix],
")", NULL);
2808 he->
p.
argv[he->
c] = NULL;
2828 HE_t EVRhe = (
HE_t) memset(
alloca(
sizeof(*EVRhe)), 0,
sizeof(*EVRhe));
2836 EVRhe->
tag = tagEVR;
2839 assert(EVRhe->
c == Nhe->
c);
2843 assert(Fhe->
c == Nhe->
c);
2919 assert(Dhe->
c == Nhe->
c);
2925 for (Dhe->
ix = 0; Dhe->
ix < (
int)Dhe->
c; Dhe->
ix++) {
2928 nb +=
sizeof(*he->
p.
argv);
2929 nb += strlen(Dhe->
p.
argv[Dhe->
ix]) +
sizeof(
" ") + strlen(Nhe->
p.
argv[Dhe->
ix]) - 1;
2932 nb +=
sizeof(*he->
p.
argv);
2935 te = (
char *) &he->
p.
argv[he->
c+1];
2938 for (Dhe->
ix = 0; Dhe->
ix < (
int)Dhe->
c; Dhe->
ix++) {
2941 he->
p.
argv[he->
c++] = te;
2947 he->
p.
argv[he->
c] = NULL;
2997 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
2998 HE_t RNhe = (
HE_t) memset(
alloca(
sizeof(*RNhe)), 0,
sizeof(*RNhe));
2999 HE_t REVRhe = (
HE_t) memset(
alloca(
sizeof(*REVRhe)), 0,
sizeof(*REVRhe));
3000 HE_t RFhe = (
HE_t) memset(
alloca(
sizeof(*RFhe)), 0,
sizeof(*RFhe));
3025 REVRhe->
tag = tagEVR;
3028 mi =
rpmmiInit(_rpmdb, tagN, key, keylen);
3034 if (PEVRhe != NULL) {
3037 assert(REVRhe->
c == RNhe->
c);
3040 assert(RFhe->
c == RNhe->
c);
3043 for (RNhe->
ix = 0; RNhe->
ix < (
int)RNhe->
c; RNhe->
ix++) {
3050 if (!(PFlags && RFlags))
3064 NVRAhe->
tag = tagNVRA;
3066 if (!(*avp != NULL &&
argvSearch(*avp, NVRAhe->
p.
str, NULL) != NULL)) {
3091 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
3092 HE_t PNhe = (
HE_t) memset(
alloca(
sizeof(*PNhe)), 0,
sizeof(*PNhe));
3093 HE_t PEVRhe = (
HE_t) memset(
alloca(
sizeof(*PEVRhe)), 0,
sizeof(*PEVRhe));
3094 HE_t PFhe = (
HE_t) memset(
alloca(
sizeof(*PFhe)), 0,
sizeof(*PFhe));
3095 HE_t FNhe = (
HE_t) memset(
alloca(
sizeof(*FNhe)), 0,
sizeof(*FNhe));
3107 assert(PEVRhe->
c == PNhe->
c);
3111 assert(PFhe->
c == PNhe->
c);
3117 NVRAhe->
tag = tagNVRA;;
3123 for (PNhe->
ix = 0; PNhe->
ix < (
int)PNhe->
c; PNhe->
ix++)
3124 (
void)
wnlookupTag(h, tagNVRA, &pkgs, &hits, PNhe, PEVRhe, PFhe);
3125 for (FNhe->
ix = 0; FNhe->
ix < (
int)FNhe->
c; FNhe->
ix++)
3126 (void)
wnlookupTag(h, tagNVRA, &pkgs, &hits, FNhe, NULL, NULL);
3136 for (i = 0; i < he->
c; i++) {
3137 nb +=
sizeof(*he->
p.
argv);
3138 nb += strlen(pkgs[i]) + 1;
3140 nb +=
sizeof(*he->
p.
argv);
3143 te = (
char *) &he->
p.
argv[he->
c+1];
3145 for (i = 0; i < he->
c; i++) {
3147 te =
stpcpy(te, pkgs[i]);
3150 he->
p.
argv[he->
c] = NULL;
3173 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
3174 HE_t PNhe = (
HE_t) memset(
alloca(
sizeof(*PNhe)), 0,
sizeof(*PNhe));
3175 HE_t PEVRhe = (
HE_t) memset(
alloca(
sizeof(*PEVRhe)), 0,
sizeof(*PEVRhe));
3176 HE_t PFhe = (
HE_t) memset(
alloca(
sizeof(*PFhe)), 0,
sizeof(*PFhe));
3202 PEVRhe->
tag = tagEVR;
3205 mi =
rpmmiInit(_rpmdb, tagN, key, keylen);
3211 if (REVRhe != NULL) {
3214 assert(PEVRhe->
c == PNhe->
c);
3217 assert(PFhe->
c == PNhe->
c);
3220 for (PNhe->
ix = 0; PNhe->
ix < (
int)PNhe->
c; PNhe->
ix++) {
3227 if (!(PFlags && RFlags))
3241 NVRAhe->
tag = tagNVRA;
3243 if (!(*avp != NULL &&
argvSearch(*avp, NVRAhe->
p.
str, NULL) != NULL)) {
3268 HE_t NVRAhe = (
HE_t) memset(
alloca(
sizeof(*NVRAhe)), 0,
sizeof(*NVRAhe));
3269 HE_t RNhe = (
HE_t) memset(
alloca(
sizeof(*RNhe)), 0,
sizeof(*RNhe));
3270 HE_t REVRhe = (
HE_t) memset(
alloca(
sizeof(*REVRhe)), 0,
sizeof(*REVRhe));
3271 HE_t RFhe = (
HE_t) memset(
alloca(
sizeof(*RFhe)), 0,
sizeof(*RFhe));
3283 assert(REVRhe->
c == RNhe->
c);
3287 assert(RFhe->
c == RNhe->
c);
3289 NVRAhe->
tag = tagNVRA;;
3295 for (RNhe->
ix = 0; RNhe->
ix < (
int)RNhe->
c; RNhe->
ix++) {
3296 if (*RNhe->
p.
argv[RNhe->
ix] ==
'/' || *REVRhe->
p.
argv[RNhe->
ix] ==
'\0')
3297 (void)
nwlookupTag(h, tagNVRA, &pkgs, &hits, RNhe, NULL, NULL);
3299 (
void)
nwlookupTag(h, tagNVRA, &pkgs, &hits, RNhe, REVRhe, RFhe);
3310 for (i = 0; i < he->
c; i++) {
3311 nb +=
sizeof(*he->
p.
argv);
3312 nb += strlen(pkgs[i]) + 1;
3314 nb +=
sizeof(*he->
p.
argv);
3317 te = (
char *) &he->
p.
argv[he->
c+1];
3319 for (i = 0; i < he->
c; i++) {
3321 te =
stpcpy(te, pkgs[i]);
3324 he->
p.
argv[he->
c] = NULL;
3346 assert(N.
argv[i] != NULL && *N.
argv[i] !=
'\0');
3349 && !(a=strcmp(N.
argv[i], N.
argv[i-1]))
3350 && !(
b=strcmp(EVR.
argv[i], EVR.
argv[i-1]))
3351 && (F.
ui32p[i] & 0x4e) == ((F.
ui32p[i-1] & 0x4e)) )
3376 if (xx == 0)
goto exit;
3382 if (xx == 0)
goto exit;
3387 if (xx == 0)
goto exit;
3390 nb =
sizeof(*he->
p.
argv);
3392 for (i = 0; i < c; i++) {
3398 nb +=
sizeof(*he->
p.
argv);
3399 nb +=
sizeof(
"<rpm:entry name=\"\"/>");
3400 if (*N.
argv[i] ==
'/')
3403 nb += strlen(N.
argv[i]);
3404 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3405 nb +=
sizeof(
" flags=\"EQ\" epoch=\"0\" ver=\"\"") - 1;
3406 nb += strlen(EVR.
argv[i]);
3407 if (strchr(EVR.
argv[i],
':') != NULL)
3409 if (strchr(EVR.
argv[i],
'-') != NULL)
3410 nb +=
sizeof(
" rel=\"\"") - 2;
3414 nb +=
sizeof(
" pre=\"1\"") - 1;
3422 t = (
char *) &he->
p.
argv[he->
c + 1];
3424 for (i = 0; i < c; i++) {
3429 he->
p.
argv[ac++] = t;
3430 t =
stpcpy(t,
"<rpm:entry");
3431 t =
stpcpy(t,
" name=\"");
3432 if (*N.
argv[i] ==
'/') {
3438 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3439 static char *Fstr[] = {
"?0",
"LT",
"GT",
"?3",
"EQ",
"LE",
"GE",
"?7" };
3441 const char *E, *V, *R;
3444 f = (
char *) EVR.
argv[i];
3445 for (fe = f; *fe !=
'\0' && *fe >=
'0' && *fe <=
'9'; fe++)
3447 if (*fe ==
':') { *fe++ =
'\0'; E = f; f = fe; }
else E = NULL;
3449 for (fe = f; *fe !=
'\0' && *fe !=
'-'; fe++)
3451 if (*fe ==
'-') { *fe++ =
'\0'; R = fe; }
else R = NULL;
3460 t =
stpcpy(t,
" pre=\"1\"");
3465 he->
p.
argv[he->
c] = NULL;
3521 spew_t spew,
int lvl)
3524 int ix = (he->
ix > 0 ? he->
ix : 0);
3529 val =
xstrdup(
_(
"(not a string)"));
3562 static char q =
'"';
3578 if (xx == 0)
goto exit;
3584 if (xx == 0)
goto exit;
3589 if (xx == 0)
goto exit;
3595 for (i = 0; i < c; i++) {
3601 nb += strlen(instance) +
sizeof(
", '', '', '', '', ''") - 1;
3603 nb +=
sizeof(
", ''") - 1;
3604 nb += strlen(N.
argv[i]);
3605 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3606 uint32_t Fx = ((F.
ui32p[
i] >> 1) & 0x7);
3609 const char * E = Revr->F[RPMEVR_E];
3610 const char * V = Revr->F[RPMEVR_V];
3612 const char * T = Revr->F[RPMEVR_T];
3614 const char * R = Revr->F[RPMEVR_R];
3616 const char * D = Revr->F[RPMEVR_D];
3619 nb += (
sizeof(
", 'EQ'")-1);
3620 nb += (
sizeof(
", ''")-1) + strlen(E);
3621 nb += (
sizeof(
", ''")-1) + strlen(V);
3623 nb += (
sizeof(
", ''")-1) + strlen(T);
3625 nb += (
sizeof(
", ''")-1) + strlen(R);
3627 nb += (
sizeof(
", ''")-1) + strlen(D);
3633 nb +=
sizeof(
"1") - 1;
3638 nb += (ac + 1) *
sizeof(*he->
p.
argv);
3644 te = (
char *) &he->
p.
argv[ac + 1];
3647 for (i = 0; i < c; i++) {
3652 he->
p.
argv[ac++] = te;
3653 te =
stpcpy(te, instance);
3654 *te++ =
','; *te++ =
' ';
3655 *te++ = q; te =
stpcpy(te, N.
argv[i]); *te++ = q;
3657 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3658 static const char *Fstr[] = {
"?0",
"LT",
"GT",
"?3",
"EQ",
"LE",
"GE",
"?7" };
3659 uint32_t Fx = ((F.
ui32p[
i] >> 1) & 0x7);
3662 const char * E = Revr->F[RPMEVR_E];
3663 const char * V = Revr->F[RPMEVR_V];
3665 const char * T = Revr->F[RPMEVR_T];
3667 const char * R = Revr->F[RPMEVR_R];
3669 const char * D = Revr->F[RPMEVR_D];
3672 *te++ =
','; *te++ =
' ';
3673 *te++ = q; te =
stpcpy(te, Fstr[Fx]); *te++ = q;
3674 *te++ =
','; *te++ =
' ';
3675 *te++ = q; te =
stpcpy(te, E); *te++ = q;
3676 *te++ =
','; *te++ =
' ';
3677 *te++ = q; te =
stpcpy(te, V); *te++ = q;
3679 *te++ =
','; *te++ =
' ';
3680 *te++ = q; te =
stpcpy(te, T); *te++ = q;
3682 *te++ =
','; *te++ =
' ';
3683 *te++ = q; te =
stpcpy(te, R); *te++ = q;
3685 *te++ =
','; *te++ =
' ';
3686 *te++ = q; te =
stpcpy(te, D); *te++ = q;
3691 *te++ =
','; *te++ =
' ';
3692 *te++ = q; *te++ = q;
3693 *te++ =
','; *te++ =
' ';
3694 *te++ = q; *te++ = q;
3695 *te++ =
','; *te++ =
' ';
3696 *te++ = q; *te++ = q;
3697 *te++ =
','; *te++ =
' ';
3698 *te++ = q; *te++ = q;
3707 he->
p.
argv[ac] = NULL;
3774 if (xx == 0)
goto exit;
3780 if (xx == 0)
goto exit;
3785 if (xx == 0)
goto exit;
3788 nb =
sizeof(*he->
p.
argv);
3790 for (i = 0; i < c; i++) {
3796 nb +=
sizeof(*he->
p.
argv);
3798 if (*N.
argv[i] ==
'/')
3801 nb += strlen(N.
argv[i]);
3802 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3803 nb +=
sizeof(
" >= ") - 1;
3804 nb += strlen(EVR.
argv[i]);
3812 t = (
char *) &he->
p.
argv[he->
c + 1];
3814 for (i = 0; i < c; i++) {
3819 he->
p.
argv[ac++] = t;
3821 if (*N.
argv[i] ==
'/') {
3826 if (EVR.
argv != NULL && EVR.
argv[i] != NULL && *EVR.
argv[i] !=
'\0') {
3827 static char *Fstr[] = {
"?0",
"<",
">",
"?3",
"=",
"<=",
">=",
"?7" };
3835 he->
p.
argv[he->
c] = NULL;
3898 size_t dnlen = strlen(dn);
3901 if (strstr(dn,
"bin/") != NULL)
3903 if (dnlen >=
sizeof(
"/etc/")-1 && !strncmp(dn,
"/etc/", dnlen))
3905 if (!strcmp(dn,
"/usr/lib/") && !strcmp(BN.
argv[i],
"sendmail"))
3931 if (xx == 0)
goto exit;
3937 if (xx == 0)
goto exit;
3942 if (xx == 0)
goto exit;
3947 if (xx == 0)
goto exit;
3952 if (xx == 0)
goto exit;
3955 nb =
sizeof(*he->
p.
argv);
3957 for (i = 0; i < c; i++) {
3958 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3961 nb +=
sizeof(*he->
p.
argv);
3962 nb +=
sizeof(
"<file></file>");
3965 if (FFLAGS.
ui32p[i] & 0x40)
3966 nb +=
sizeof(
" type=\"ghost\"") - 1;
3967 else if (S_ISDIR(FMODES.
ui16p[i])) {
3968 nb +=
sizeof(
" type=\"dir\"") - 1;
3970 nb +=
sizeof(
"/") - 1;
3979 t = (
char *) &he->
p.
argv[he->
c + 1];
3982 for (i = 0; i < c; i++) {
3983 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3985 if (FFLAGS.
ui32p[i] & 0x40)
3987 if (S_ISDIR(FMODES.
ui16p[i]))
3989 he->
p.
argv[ac++] = t;
3993 t =
stpcpy(t,
"</file>");
3996 for (i = 0; i < c; i++) {
3997 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
3999 if (FFLAGS.
ui32p[i] & 0x40)
4001 if (!S_ISDIR(FMODES.
ui16p[i]))
4003 he->
p.
argv[ac++] = t;
4004 t =
stpcpy(t,
"<file type=\"dir\">");
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 he->
p.
argv[ac++] = t;
4021 t =
stpcpy(t,
"<file type=\"ghost\">");
4024 t =
stpcpy(t,
"</file>");
4028 he->
p.
argv[he->
c] = NULL;
4084 if (xx == 0)
goto exit;
4090 if (xx == 0)
goto exit;
4095 if (xx == 0)
goto exit;
4100 if (xx == 0)
goto exit;
4105 if (xx == 0)
goto exit;
4109 nb =
sizeof(*he->
p.
argv);
4111 for (i = 0; i < c; i++) {
4112 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4115 nb +=
sizeof(*he->
p.
argv);
4116 nb += strlen(instance) +
sizeof(
", '', ''");
4118 nb += strlen(BN.
argv[i]);
4119 if (FFLAGS.
ui32p[i] & 0x40)
4120 nb +=
sizeof(
"ghost") - 1;
4121 else if (S_ISDIR(FMODES.
ui16p[i])) {
4122 nb +=
sizeof(
"dir") - 1;
4124 nb +=
sizeof(
"/") - 1;
4127 nb +=
sizeof(
"file") - 1;
4134 t = (
char *) &he->
p.
argv[he->
c + 1];
4137 for (i = 0; i < c; i++) {
4138 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4140 if (FFLAGS.
ui32p[i] & 0x40)
4142 if (S_ISDIR(FMODES.
ui16p[i]))
4144 he->
p.
argv[ac++] = t;
4146 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4147 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4148 t =
stpcpy(t,
"', 'file'");
4151 for (i = 0; i < c; i++) {
4152 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4154 if (FFLAGS.
ui32p[i] & 0x40)
4156 if (!S_ISDIR(FMODES.
ui16p[i]))
4158 he->
p.
argv[ac++] = t;
4160 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4161 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4167 t =
stpcpy(t,
"', 'dir'");
4170 for (i = 0; i < c; i++) {
4171 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4173 if (!(FFLAGS.
ui32p[i] & 0x40))
4175 he->
p.
argv[ac++] = t;
4177 t = strcpy(t, DN.
argv[DI.
ui32p[i]]); t += strlen(t);
4178 t = strcpy(t, BN.
argv[i]); t += strlen(t);
4179 t =
stpcpy(t,
"', 'ghost'");
4183 he->
p.
argv[he->
c] = NULL;
4240 if (xx == 0)
goto exit;
4246 if (xx == 0)
goto exit;
4251 if (xx == 0)
goto exit;
4256 if (xx == 0)
goto exit;
4261 if (xx == 0)
goto exit;
4264 nb =
sizeof(*he->
p.
argv);
4266 for (i = 0; i < c; i++) {
4267 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4270 nb +=
sizeof(*he->
p.
argv);
4274 if (FFLAGS.
ui32p[i] & 0x40)
4275 nb +=
sizeof(
"") - 1;
4276 else if (S_ISDIR(FMODES.
ui16p[i]))
4277 nb +=
sizeof(
"/") - 1;
4284 t = (
char *) &he->
p.
argv[he->
c + 1];
4287 for (i = 0; i < c; i++) {
4288 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4290 if (FFLAGS.
ui32p[i] & 0x40)
4292 if (S_ISDIR(FMODES.
ui16p[i]))
4294 he->
p.
argv[ac++] = t;
4301 for (i = 0; i < c; i++) {
4302 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4304 if (FFLAGS.
ui32p[i] & 0x40)
4306 if (!S_ISDIR(FMODES.
ui16p[i]))
4308 he->
p.
argv[ac++] = t;
4317 for (i = 0; i < c; i++) {
4318 if (lvl > 0 &&
FDGSkip(DN, BN, DI, i) != lvl)
4320 if (!(FFLAGS.
ui32p[i] & 0x40))
4322 he->
p.
argv[ac++] = t;
4329 he->
p.
argv[he->
c] = NULL;
4376 val =
xstrdup(
_(
"(not a string)"));
4385 assert(he->
p.
str != NULL);
4387 if ((bn = strrchr(he->
p.
str,
'/')) != NULL)
4404 typedef struct key_s {
4455 STAT_KEYS_FLAGS = (1U << 13),
4460 STAT_KEYS_FCONTEXT = (1U << 16),
4478 {
"fcontext", STAT_KEYS_FCONTEXT },
4479 {
"flags", STAT_KEYS_FLAGS },
4523 UUID_KEYS_STRING = (0U << 4),
4524 UUID_KEYS_SIV = (1U << 4),
4525 UUID_KEYS_BINARY = (2U << 4),
4526 UUID_KEYS_TEXT = (3U << 4),
4533 {
"binary", UUID_KEYS_BINARY },
4534 {
"siv", UUID_KEYS_SIV },
4535 {
"string", UUID_KEYS_STRING },
4536 {
"text", UUID_KEYS_TEXT },
4563 if (name && * name) {
4565 KEY *k = (
KEY *)bsearch(&needle, keys, nkeys,
sizeof(*keys),
keyCmp);
4581 int ix = (he->
ix > 0 ? he->
ix : 0);
4588 val =
xstrdup(
_(
"(invalid type :digest)"));
4592 ns =
sizeof(he->
p.
ui64p[0]);
4595 ns = strlen(he->
p.
str);
4602 assert(he->
p.
ptr != NULL);
4626 static const char *avdefault[] = {
"mode", NULL };
4628 const char * fn = NULL;
4629 struct stat sb, *st = &sb;
4630 int ix = (he->
ix > 0 ? he->
ix : 0);
4635 memset(st, 0,
sizeof(*st));
4641 if ((
size_t)he->
c ==
sizeof(*st)) {
4642 st = (
struct stat *)he->
p.
ptr;
4647 val =
xstrdup(
_(
"(invalid type :stat)"));
4652 if (
Lstat(fn, st) == 0)
4661 if (!(av && av[0] && *av[0]))
4663 for (i = 0; av[
i] != NULL; i++) {
4665 size_t nb =
sizeof(
b)-1;
4677 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_dev);
4680 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_ino);
4683 xx =
snprintf(b, nb,
"%06o", (
unsigned)st->st_mode);
4686 xx =
snprintf(b, nb,
"0x%ld", (
unsigned long)st->st_nlink);
4689 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_uid);
4692 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_gid);
4695 xx =
snprintf(b, nb,
"0x%lx", (
unsigned long)st->st_rdev);
4698 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_size);
4701 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_blksize);
4704 xx =
snprintf(b, nb,
"%ld", (
unsigned long)st->st_blocks);
4707 (void)
stpcpy(b, ctime((time_t *)&st->st_atime));
4710 (void)
stpcpy(b, ctime((time_t *)&st->st_ctime));
4713 (void)
stpcpy(b, ctime((time_t *)&st->st_mtime));
4716 case STAT_KEYS_FLAGS:
4720 if (fn != NULL &&
S_ISLNK(st->st_mode)) {
4723 nval =
rpmExpand(
"(Readlink:", fn,
":", strerror(
errno),
")", NULL);
4731 if (fn != NULL && S_ISREG(st->st_mode)) {
4735 if (fd == NULL ||
Ferror(fd)) {
4738 static int asAscii = 1;
4741 while (
Fread(buffer,
sizeof(buffer[0]),
sizeof(buffer), fd) > 0)
4757 {
const char * uname =
uidToUname(st->st_uid);
4761 xx =
snprintf(b, nb,
"%u", (
unsigned)st->st_uid);
4764 {
const char * gname =
gidToGname(st->st_gid);
4768 xx =
snprintf(b, nb,
"%u", (
unsigned)st->st_gid);
4798 static const char hex[] =
"0123456789abcdef";
4803 static const char *avdefault[] = {
"v5", NULL };
4805 int ix = (he->
ix > 0 ? he->
ix : 0);
4813 val =
xmalloc((128/4 + 4) + 1);
4821 val =
xstrdup(
_(
"(invalid type :uuid)"));
4829 val =
xstrdup(
_(
"(invalid tag :uuid)"));
4840 tv.tv_sec = (long) he->
p.
ui64p[0];
4841 tv.tv_usec = (
long) (he->
c > 1 ? he->
p.
ui64p[1] : 0);
4846 for (i = 0; i < nhe->
c; i++) {
4847 *te++ = hex[ (int)((nhe->
p.
ui8p[i] >> 4) & 0x0f) ];
4848 *te++ = hex[ (int)((nhe->
p.
ui8p[i] ) & 0x0f) ];
4849 if (i == 3 || i == 5 || i == 7 || i == 9)
4862 val =
xstrdup(
_(
"(invalid tag :uuid)"));
4869 for (i = 0; i < he->
c; i++) {
4870 *te++ = hex[ (int)((he->
p.
ui8p[i] >> 4) & 0x0f) ];
4871 *te++ = hex[ (int)((he->
p.
ui8p[i] ) & 0x0f) ];
4886 if (!(av && av[0] && *av[0]))
4889 for (i = 0; av[
i] != NULL; i++) {
4890 uint32_t keyval =
keyValue(keyUuids, nkeyUuids, av[i]);
4899 ix =
str2uuid(nhe, NULL, keyval, val);
4920 int64_t * stack = memset(
alloca(ac*
sizeof(*stack)), 0, (ac*
sizeof(*stack)));
4928 val =
xstrdup(
_(
"(invalid type :rpn)"));
4932 stack[ix] = he->
p.
ui64p[0];
4937 stack[ix] = strtoll(he->
p.
str, &end, 0);
4939 if (end && *end !=
'\0') {
4940 val =
xstrdup(
_(
"(invalid string :rpn)"));
4947 for (i = 0; av[
i] != NULL; i++) {
4948 const char *
arg = av[
i];
4949 size_t len = strlen(arg);
4954 }
else if (len > 1) {
4956 val =
xstrdup(
_(
"(expected number :rpn)"));
4960 val =
xstrdup(
_(
"(stack overflow :rpn)"));
4964 stack[ix] = strtoll(arg, &end, 0);
4965 if (end && *end !=
'\0') {
4966 val =
xstrdup(
_(
"(invalid number :rpn)"));
4971 val =
xstrdup(
_(
"(stack underflow :rpn)"));
4975 case '&': stack[ix] &= stack[ix+1];
break;
4976 case '|': stack[ix] |= stack[ix+1];
break;
4977 case '^': stack[ix] ^= stack[ix+1];
break;
4978 case '+': stack[ix] += stack[ix+1];
break;
4979 case '-': stack[ix] -= stack[ix+1];
break;
4980 case '*': stack[ix] *= stack[ix+1];
break;
4983 if (stack[ix+1] == 0) {
4984 val =
xstrdup(
_(
"(divide by zero :rpn)"));
4988 stack[ix] %= stack[ix+1];
4990 stack[ix] /= stack[ix+1];
4996 {
HE_t nhe = (
HE_t) memset(
alloca(
sizeof(*nhe)), 0,
sizeof(*nhe));
5027 val =
xstrdup(
_(
"(invalid type :strsub)"));
5031 if (ac < 2 || (ac % 2) != 0) {
5032 val =
xstrdup(
_(
"(invalid args :strsub)"));
5041 for (i = 0; av[
i] != NULL; i += 2)
5045 if (mires != NULL) {
5048 const char * s, * se;
5054 for (i = 0; i < nmires; i++) {
5055 miRE mire = mires +
i;
5065 while (*s !=
'\0') {
5067 if ((se = strchr(s,
'\n')) == NULL)
5072 offsets[0] = offsets[1] = -1;
5078 nb += offsets[0] + strlen(av[2*i+1]);
5080 if (xx != 0 || offsets[1] == offsets[0])
5081 nb += (se - (s + offsets[1]));
5091 if (xx != 0 || offsets[1] == offsets[0]) {
5093 te =
stpncpy(te, s, (se - s));
5115 { HEADER_EXT_TAG,
"RPMTAG_BUILDTIMEUUID",
5117 { HEADER_EXT_TAG,
"RPMTAG_CHANGELOGNAME",
5119 { HEADER_EXT_TAG,
"RPMTAG_CHANGELOGTEXT",
5121 { HEADER_EXT_TAG,
"RPMTAG_DESCRIPTION",
5123 { HEADER_EXT_TAG,
"RPMTAG_GROUP",
5125 { HEADER_EXT_TAG,
"RPMTAG_HDRUUID",
5127 { HEADER_EXT_TAG,
"RPMTAG_INSTALLPREFIX",
5129 { HEADER_EXT_TAG,
"RPMTAG_INSTALLTIDUUID",
5131 { HEADER_EXT_TAG,
"RPMTAG_INSTALLTIMEUUID",
5133 { HEADER_EXT_TAG,
"RPMTAG_ORIGINTIDUUID",
5135 { HEADER_EXT_TAG,
"RPMTAG_ORIGINTIMEUUID",
5137 { HEADER_EXT_TAG,
"RPMTAG_PKGUUID",
5139 { HEADER_EXT_TAG,
"RPMTAG_REMOVETIDUUID",
5141 { HEADER_EXT_TAG,
"RPMTAG_SOURCEPKGUUID",
5143 { HEADER_EXT_TAG,
"RPMTAG_SUMMARY",
5145 { HEADER_EXT_TAG,
"RPMTAG_TRIGGERCONDS",
5147 { HEADER_EXT_TAG,
"RPMTAG_TRIGGERTYPE",
5149 { HEADER_EXT_TAG,
"RPMTAG_DBINSTANCE",
5151 { HEADER_EXT_TAG,
"RPMTAG_HEADERSTARTOFF",
5153 { HEADER_EXT_TAG,
"RPMTAG_HEADERENDOFF",
5155 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEBASEURL",
5157 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEDIGEST",
5159 { HEADER_EXT_TAG,
"RPMTAG_PACKAGEORIGIN",
5161 { HEADER_EXT_TAG,
"RPMTAG_PACKAGESIZE",
5163 { HEADER_EXT_TAG,
"RPMTAG_PACKAGETIME",
5165 { HEADER_EXT_TAG,
"RPMTAG_NVRA",
5167 { HEADER_EXT_TAG,
"RPMTAG_FILENAMES",
5169 { HEADER_EXT_TAG,
"RPMTAG_FILEPATHS",
5171 { HEADER_EXT_TAG,
"RPMTAG_ORIGPATHS",
5173 { HEADER_EXT_TAG,
"RPMTAG_FILESTAT",
5175 { HEADER_EXT_TAG,
"RPMTAG_PROVIDEXMLENTRY",
5177 { HEADER_EXT_TAG,
"RPMTAG_REQUIREXMLENTRY",
5179 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTXMLENTRY",
5181 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETEXMLENTRY",
5183 { HEADER_EXT_TAG,
"RPMTAG_FILESXMLENTRY1",
5185 { HEADER_EXT_TAG,
"RPMTAG_FILESXMLENTRY2",
5187 { HEADER_EXT_TAG,
"RPMTAG_PROVIDEYAMLENTRY",
5189 { HEADER_EXT_TAG,
"RPMTAG_REQUIREYAMLENTRY",
5191 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTYAMLENTRY",
5193 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETEYAMLENTRY",
5195 { HEADER_EXT_TAG,
"RPMTAG_FILESYAMLENTRY1",
5197 { HEADER_EXT_TAG,
"RPMTAG_FILESYAMLENTRY2",
5199 { HEADER_EXT_TAG,
"RPMTAG_PROVIDESQLENTRY",
5201 { HEADER_EXT_TAG,
"RPMTAG_REQUIRESQLENTRY",
5203 { HEADER_EXT_TAG,
"RPMTAG_CONFLICTSQLENTRY",
5205 { HEADER_EXT_TAG,
"RPMTAG_OBSOLETESQLENTRY",
5207 { HEADER_EXT_TAG,
"RPMTAG_FILESSQLENTRY1",
5209 { HEADER_EXT_TAG,
"RPMTAG_FILESSQLENTRY2",
5211 { HEADER_EXT_TAG,
"RPMTAG_DEBCONFLICTS",
5213 { HEADER_EXT_TAG,
"RPMTAG_DEBDEPENDS",
5215 { HEADER_EXT_TAG,
"RPMTAG_DEBMD5SUMS",
5217 { HEADER_EXT_TAG,
"RPMTAG_DEBOBSOLETES",
5219 { HEADER_EXT_TAG,
"RPMTAG_DEBPROVIDES",
5221 { HEADER_EXT_TAG,
"RPMTAG_NEEDSWHAT",
5223 { HEADER_EXT_TAG,
"RPMTAG_WHATNEEDS",
5225 { HEADER_EXT_FORMAT,
"armor",
5227 { HEADER_EXT_FORMAT,
"base64",
5229 { HEADER_EXT_FORMAT,
"bncdata",
5231 { HEADER_EXT_FORMAT,
"cdata",
5233 { HEADER_EXT_FORMAT,
"depflags",
5235 { HEADER_EXT_FORMAT,
"deptype",
5237 { HEADER_EXT_FORMAT,
"digest",
5239 { HEADER_EXT_FORMAT,
"fflags",
5241 { HEADER_EXT_FORMAT,
"hint",
5243 { HEADER_EXT_FORMAT,
"iconv",
5245 { HEADER_EXT_FORMAT,
"json",
5248 { HEADER_EXT_FORMAT,
"jsonescape",
5251 { HEADER_EXT_FORMAT,
"perms",
5253 { HEADER_EXT_FORMAT,
"permissions",
5255 { HEADER_EXT_FORMAT,
"pgpsig",
5257 { HEADER_EXT_FORMAT,
"rpn",
5259 { HEADER_EXT_FORMAT,
"sqlescape",
5261 { HEADER_EXT_FORMAT,
"stat",
5263 { HEADER_EXT_FORMAT,
"strsub",
5265 { HEADER_EXT_FORMAT,
"triggertype",
5267 { HEADER_EXT_FORMAT,
"utf8",
5269 { HEADER_EXT_FORMAT,
"uuid",
5271 { HEADER_EXT_FORMAT,
"xml",
5273 { HEADER_EXT_FORMAT,
"yaml",
5275 { HEADER_EXT_MORE, NULL, { (
void *) &headerDefaultFormats } }
5284 const struct headerTagTableEntry_s * t;
5291 if (_rpmTagTable == NULL)
5295 if (_rpmHeaderFormats == NULL)
5298 for (t = _rpmTagTable; t && t->name; t++) {
5300 static const char * tagtypes[] = {
5301 "",
"char",
"uint8",
"uint16",
"uint32",
"uint64",
5302 "string",
"octets",
"argv",
"i18nstring",
5307 fprintf(fp,
"%-20s %6d", t->name + 7, t->val);
5312 fprintf(fp,
" openpgp");
5314 fprintf(fp,
" x509");
5316 fprintf(fp,
" asn1");
5318 fprintf(fp,
" opaque");
5319 fprintf(fp,
" %s", tagtypes[ttype]);
5321 fprintf(fp,
" array");
5323 fprintf(fp,
" mapping");
5325 fprintf(fp,
" probe");
5327 fprintf(fp,
" tree");
5329 fprintf(fp,
"%s", t->name + 7);
5334 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
5335 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
5337 if (ext->name == NULL || ext->type != HEADER_EXT_TAG)
5343 fprintf(fp,
"%s\n", ext->name + 7);
5349 #define PARSER_BEGIN 0
5350 #define PARSER_IN_ARRAY 1
5351 #define PARSER_IN_EXPR 2
5460 fprintf(stderr,
"\t\t\\%c\n", ch);
5463 case 'a':
return '\a';
5464 case 'b':
return '\b';
5465 case 'f':
return '\f';
5466 case 'n':
return '\n';
5467 case 'r':
return '\r';
5468 case 't':
return '\t';
5469 case 'v':
return '\v';
5485 memset(he, 0,
sizeof(*he));
5502 if (format == NULL)
return NULL;
5504 for (i = 0; i < (unsigned) num; i++) {
5505 switch (format[i].
type) {
5518 format[i].
u.
array.numTokens);
5521 format[
i].
u.
cond.ifFormat =
5523 format[i].
u.
cond.numIfTokens);
5524 format[
i].
u.
cond.elseFormat =
5526 format[i].
u.
cond.numElseTokens);
5541 format =
_free(format);
5550 static headerSprintfArgs
hsaInit( headerSprintfArgs hsa)
5577 static sprintfToken
hsaNext( headerSprintfArgs hsa)
5581 sprintfToken fmt = NULL;
5589 if (hsa != NULL && hsa->
i < hsa->
numTokens) {
5591 if (hsa->
hi == NULL) {
5615 static headerSprintfArgs
hsaFini( headerSprintfArgs hsa)
5659 static char name[128];
5666 if (s != NULL && typep != NULL)
5671 for (; tbl->name != NULL; tbl++) {
5672 if (tbl->val == val)
5675 if ((s = tbl->name) == NULL)
5677 s +=
sizeof(
"RPMTAG_") - 1;
5703 for (; tbl->name != NULL; tbl++) {
5719 static int findTag(headerSprintfArgs hsa, sprintfToken token,
const char *
name)
5733 if (!strcmp(name,
"*")) {
5738 if (strncmp(
"RPMTAG_", name,
sizeof(
"RPMTAG_")-1)) {
5739 char * t =
alloca(strlen(name) +
sizeof(
"RPMTAG_"));
5745 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
5746 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
5748 if (ext->name == NULL || ext->type != HEADER_EXT_TAG)
5751 stag->
ext = ext->u.tagFunction;
5767 stag->
tagno[0] = tagno;
5769 if (stag->
av != NULL) {
5774 for (i = 0; stag->
av[
i] != NULL; i++) {
5775 for (ext = exts; ext != NULL && ext->type != HEADER_EXT_LAST;
5776 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1))
5778 if (ext->name == NULL || ext->type != HEADER_EXT_FORMAT)
5780 if (strcmp(ext->name, stag->
av[i]+1))
5800 char *
str,
char ** endPtr)
5815 sprintfToken * formatPtr,
5816 size_t * numTokensPtr,
5817 char ** endPtr,
int state)
5823 static const char *pstates[] = {
5824 "NORMAL",
"ARRAY",
"EXPR",
"WTF?"
5826 char * chptr, * start, * next, * dst;
5827 sprintfToken format;
5836 fprintf(stderr,
"--> parseFormat(%p, \"%.20s...\", %p, %p, %p, %s)\n", hsa, str, formatPtr, numTokensPtr, endPtr, pstates[(state & 0x3)]);
5842 for (chptr = str; *chptr !=
'\0'; chptr++)
5843 if (*chptr ==
'%' || *chptr ==
'[') numTokens++;
5844 numTokens = numTokens * 2 + 1;
5846 format =
xcalloc(numTokens,
sizeof(*format));
5847 if (endPtr) *endPtr = NULL;
5854 while (*start !=
'\0') {
5858 if (*(start + 1) ==
'%') {
5860 token = format + numTokens++;
5863 dst = token->
u.
string.string = start;
5871 token = format + numTokens++;
5875 if (*start ==
'|') {
5896 while (*chptr && *chptr !=
'{' && *chptr !=
'%') chptr++;
5897 if (!*chptr || *chptr ==
'%') {
5898 hsa->
errmsg =
_(
"missing { after %");
5905 fprintf(stderr,
"\tchptr *%p = NUL\n", chptr);
5909 while (start < chptr) {
5911 i = strtoul(start, &start, 10);
5920 if (*start ==
'=') {
5923 }
else if (*start ==
'#') {
5930 while (*next && *next !=
'}') next++;
5932 hsa->
errmsg =
_(
"missing } after %{");
5938 fprintf(stderr,
"\tnext *%p = NUL\n", next);
5942 #define isSEP(_c) ((_c) == ':' || (_c) == '|')
5944 while (!(*chptr ==
'\0' ||
isSEP(*chptr))) chptr++;
5946 while (
isSEP(*chptr)) {
5947 if (chptr[1] ==
'\0' ||
isSEP(chptr[1])) {
5948 hsa->
errmsg =
_(
"empty tag format");
5953 {
char * te = chptr + 1;
5954 char * t = strchr(te,
'(');
5957 while (!(*te ==
'\0' ||
isSEP(*te))) {
5959 if (te[0] ==
'\\' && te[1] !=
'\0') te++;
5963 c = *te; *te =
'\0';
5967 if (te <= t || te[-1] !=
')') {
5969 hsa->
errmsg =
_(
"malformed parameter list");
5979 fprintf(stderr,
"\tformat \"%s\" params \"%s\"\n", chptr, (t ? t :
""));
5989 if (*start ==
'\0') {
5990 hsa->
errmsg =
_(
"empty tag name");
5998 if (
findTag(hsa, token, start)) {
5999 hsa->
errmsg =
_(
"unknown tag");
6007 fprintf(stderr,
"\tdst = start = next %p\n", dst);
6014 fprintf(stderr,
"\t%s => %s *%p = NUL\n", pstates[(state & 0x3)], pstates[
PARSER_IN_ARRAY], start);
6017 token = format + numTokens++;
6021 &token->
u.
array.numTokens,
6022 &start, PARSER_IN_ARRAY))
6029 hsa->
errmsg =
_(
"] expected at end of array");
6037 fprintf(stderr,
"\tdst = start %p\n", dst);
6045 if (state != PARSER_IN_ARRAY) {
6046 hsa->
errmsg =
_(
"unexpected ]");
6053 fprintf(stderr,
"\t<= %s %p[-1] = NUL\n", pstates[(state & 0x3)], start);
6055 if (endPtr) *endPtr = start;
6061 hsa->
errmsg =
_(
"unexpected }");
6068 fprintf(stderr,
"\t<= %s %p[-1] = NUL\n", pstates[(state & 0x3)], start);
6070 if (endPtr) *endPtr = start;
6076 token = format + numTokens++;
6079 dst = token->
u.
string.string = start;
6085 fprintf(stderr,
"\t*%p = *%p \"%.30s\"\n", dst, start, start);
6087 if (start[0] ==
'\\' && start[1] !=
'\0') {
6096 if (dst < start) *dst =
'\0';
6105 for (i = 0; i < (unsigned) numTokens; i++) {
6107 switch(token->
type) {
6116 if (numTokensPtr != NULL)
6117 *numTokensPtr = numTokens;
6118 if (formatPtr != NULL)
6119 *formatPtr = format;
6125 char *
str,
char ** endPtr)
6132 fprintf(stderr,
"--> parseExpression(%p, %p, \"%.20s...\", %p)\n", hsa, token, str, endPtr);
6137 while (*chptr && *chptr !=
'?') chptr++;
6139 if (*chptr !=
'?') {
6140 hsa->
errmsg =
_(
"? expected in expression");
6146 if (*chptr !=
'{') {
6147 hsa->
errmsg =
_(
"{ expected after ? in expression");
6158 if (!(end && *end)) {
6159 hsa->
errmsg =
_(
"} expected in expression");
6160 token->
u.
cond.ifFormat =
6166 if (*chptr !=
':' && *chptr !=
'|') {
6167 hsa->
errmsg =
_(
": expected following ? subexpression");
6168 token->
u.
cond.ifFormat =
6173 if (*chptr ==
'|') {
6177 token->
u.
cond.ifFormat =
6184 if (*chptr !=
'{') {
6185 hsa->
errmsg =
_(
"{ expected after : in expression");
6186 token->
u.
cond.ifFormat =
6198 if (!(end && *end)) {
6199 hsa->
errmsg =
_(
"} expected in expression");
6200 token->
u.
cond.ifFormat =
6206 if (*chptr !=
'|') {
6207 hsa->
errmsg =
_(
"| expected at end of expression");
6208 token->
u.
cond.ifFormat =
6210 token->
u.
cond.elseFormat =
6222 (void)
findTag(hsa, token, str);
6242 rc = fn(hsa->
h, he);
6306 val =
xstrdup(
"(unknown type)");
6307 need = strlen(val) + 1;
6310 #if defined(SUPPORT_I18NSTRING_TYPE)
6319 #if !defined(SUPPORT_I18NSTRING_TYPE)
6347 ival = he->
p.
ui64p[element];
6353 vhe->
ix = (he->
c > 1 ? 0 : -1);
6370 for (i = 0; tag->
av[
i] != NULL; i++) {
6371 headerTagFormatFunction fmt;
6373 if ((fmt = tag->
fmtfuncs[i]) == NULL)
6376 if (val != NULL && *tag->
av[i] ==
'|') {
6390 nval = fmt(vhe, av);
6394 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)"));
6399 val =
xstrdup((nval ? nval :
""));
6403 val =
rpmExpand(val, (*val !=
'\0' ?
" | " :
""), nval, NULL);
6414 assert(val != NULL);
6416 need = strlen(val) + 1;
6419 if (val && need > 0) {
6422 nb = strlen(tag->
format) +
sizeof(
"%s");
6425 nb = tag->
pad + strlen(val) + 1;
6461 sprintfTag tag = NULL;
6463 size_t condNumFormats;
6469 switch (token->
type) {
6475 if (need == 0)
break;
6492 if (token->
u.
cond.tag.ext
6495 spft = token->
u.
cond.ifFormat;
6496 condNumFormats = token->
u.
cond.numIfTokens;
6498 spft = token->
u.
cond.elseFormat;
6499 condNumFormats = token->
u.
cond.numElseTokens;
6502 need = condNumFormats * 20;
6503 if (spft == NULL || need == 0)
break;
6506 for (i = 0; i < condNumFormats; i++, spft++) {
6517 spft = token->
u.
array.format;
6518 for (i = 0; i < token->
u.
array.numTokens; i++, spft++)
6540 if (numElements == 0) {
6541 numElements = he->
c;
6544 if ((
size_t)he->
c == numElements)
6547 _(
"array iterator used with different sized arrays");
6553 if (numElements == 0)
6558 spft = token->
u.
array.format;
6560 if (numElements == 0) {
6562 need =
sizeof(
"(none)\n") - 1;
6564 te =
stpcpy(t,
"(none)\n");
6569 const char * tagN = NULL;
6572 need = numElements * token->
u.
array.numTokens;
6573 if (need == 0)
break;
6580 && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"xml"))
6583 && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"yaml"))
6586 && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"json"))
6589 if (spew == &_xml_spew) {
6590 assert(tag->
tagno != NULL);
6592 if (tag->
tagno[0] & 0x40000000) {
6596 need =
sizeof(
" <rpmTag name=\"\">\n") + strlen(tagN);
6601 if (spew == &_yaml_spew) {
6602 assert(tag->
tagno != NULL);
6604 if (tag->
tagno[0] & 0x40000000) {
6606 tagT = numElements > 1
6610 need =
sizeof(
" : - ") + strlen(tagN);
6621 if (spew == &_json_spew) {
6622 assert(tag->
tagno != NULL);
6624 if (tag->
tagno[0] & 0x40000000) {
6626 tagT = numElements > 1
6633 need =
sizeof(
" : [ ") + strlen(tagN);
6641 need = numElements * token->
u.
array.numTokens * 10;
6643 for (j = 0; j < numElements; j++) {
6644 spft = token->
u.
array.format;
6645 for (i = 0; i < token->
u.
array.numTokens; i++, spft++) {
6654 if (spew == &_xml_spew) {
6655 need =
sizeof(
" </rpmTag>\n") - 1;
6657 te =
stpcpy(te,
" </rpmTag>\n");
6660 if (spew == &_json_spew) {
6662 need =
sizeof(
" ],\n") - 1;
6664 te =
stpcpy(te,
" ],\n");
6667 need =
sizeof(
"\n") - 1;
6696 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
6697 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
6720 for (ext = exts, extNum = 0; ext != NULL && ext->type != HEADER_EXT_LAST;
6721 ext = (ext->type == HEADER_EXT_MORE ? *ext->u.more : ext+1), extNum++)
6736 sprintfToken nextfmt;
6744 fprintf(stderr,
"==> headerSprintf(%p, \"%s\", %p, %p, %p)\n", h, fmt, tags, exts, errmsg);
6781 && tag->
av != NULL && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"xml"))
6784 && tag->
av != NULL && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"yaml"))
6787 && tag->
av != NULL && tag->
av[0] != NULL && !strcmp(tag->
av[0]+1,
"json"))
6792 need = strlen(spew_init);
6794 te =
stpcpy(t, spew_init);
6796 spew_init =
_free(spew_init);
6800 while ((nextfmt =
hsaNext(hsa)) != NULL) {
6813 need = strlen(spew_fini);
6815 te =
stpcpy(t, spew_fini);
6817 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)
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).
union sprintfToken_s::@3 u
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.
const char const char size_t len
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.
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 context.
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[]
int setenv(const char *name, const char *value, int replace)
Structure(s) and routine(s) used for classifying and parsing names.
char * pgpArmorWrap(rpmuint8_t atype, const unsigned char *s, size_t ns)
Wrap a OpenPGP packets in ascii armor for transport.
headerTagFormatFunction * fmtfuncs
struct sprintfToken_s::@3::@4 array
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.
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.
const char const bson_bool_t v
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 const char * _pgpPubkeyAlgo2Name(uint32_t algo)
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.
static int origpathsTag(Header h, HE_t he)
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.
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.
const char const bson const bson * op
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.
const char const char int arg
void unsetenv(const char *name)
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)
const char const bson int mongo_write_concern int flags
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.
struct sprintfToken_s::@3::@6 cond
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.
static const char * _pgpHashAlgo2Name(uint32_t algo)
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,...)
const char const bson * key
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.
const char const char size_t size
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)
Structure(s) and routine(s) used for EVR parsing and comparison.
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)
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).
char *(* spew_strcpy)(char *t, const char *s, int lvl)
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.
const char const bson int num
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.