2 * \file lib/header_internal.c
7 #include <rpm/rpmtypes.h>
8 #include "lib/header_internal.h"
12 char ** headerGetLangs(Header h)
14 char **s, *e, **table;
18 if (!headerGetRawEntry(h, HEADER_I18NTABLE, &type, (rpm_data_t)&s, &count))
21 /* XXX xcalloc never returns NULL. */
22 if ((table = (char **)xcalloc((count+1), sizeof(char *))) == NULL)
25 for (i = 0, e = *s; i < count; i++, e += strlen(e)+1)
29 return table; /* LCL: double indirection? */
32 void headerDump(Header h, FILE *f, int flags)
39 /* First write out the length of the index (count of index entries) */
40 fprintf(f, "Entry count: %d\n", h->indexUsed);
42 /* Now write the index */
44 fprintf(f, "\n CT TAG TYPE "
46 for (i = 0; i < h->indexUsed; i++) {
47 switch (p->info.type) {
66 /*case RPM_INT64_TYPE: type = "INT64"; break;*/
70 case RPM_STRING_ARRAY_TYPE:
71 type = "STRING_ARRAY";
73 case RPM_I18NSTRING_TYPE:
81 tag = rpmTagGetName(p->info.tag);
83 fprintf(f, "Entry : %3.3d (%d)%-14s %-18s 0x%.8x %.8d\n", i,
84 p->info.tag, tag, type, (unsigned) p->info.offset,
87 if (flags & HEADER_DUMP_INLINE) {
89 int c = p->info.count;
92 /* Print the data inline */
93 switch (p->info.type) {
96 fprintf(f, " Data: %.3d 0x%08x (%d)\n", ct++,
97 (unsigned) *((int32_t *) dp),
98 (int) *((int32_t *) dp));
99 dp += sizeof(int32_t);
105 fprintf(f, " Data: %.3d 0x%04x (%d)\n", ct++,
106 (unsigned) (*((int16_t *) dp) & 0xffff),
107 (int) *((int16_t *) dp));
108 dp += sizeof(int16_t);
113 fprintf(f, " Data: %.3d 0x%02x (%d)\n", ct++,
114 (unsigned) (*((int8_t *) dp) & 0xff),
115 (int) *((int8_t *) dp));
116 dp += sizeof(int8_t);
121 fprintf(f, " Data: %.3d ", ct);
123 fprintf(f, "%02x ", (unsigned) (*(int8_t *)dp & 0xff));
125 dp += sizeof(int8_t);
135 char ch = (char) *((char *) dp);
136 fprintf(f, " Data: %.3d 0x%2x %c (%d)\n", ct++,
137 (unsigned)(ch & 0xff),
138 (isprint(ch) ? ch : ' '),
139 (int) *((char *) dp));
143 case RPM_STRING_TYPE:
144 case RPM_STRING_ARRAY_TYPE:
145 case RPM_I18NSTRING_TYPE:
147 fprintf(f, " Data: %.3d %s\n", ct++, (char *) dp);
153 fprintf(stderr, _("Data type %d not supported\n"),