10 static char * permsFormat(int_32 type, const void * data,
11 char * formatPrefix, int padding, int element);
12 static char * depflagsFormat(int_32 type, const void * data,
13 char * formatPrefix, int padding, int element);
14 static char * fflagsFormat(int_32 type, const void * data,
15 char * formatPrefix, int padding, int element);
16 static int fsnamesTag(Header h, int_32 * type, void ** data, int_32 * count,
18 static char * permsString(int mode);
20 const struct headerSprintfExtension rpmHeaderFormats[] = {
21 { HEADER_EXT_TAG, "RPMTAG_FSNAMES", { fsnamesTag } },
22 { HEADER_EXT_FORMAT, "depflags", { depflagsFormat } },
23 { HEADER_EXT_FORMAT, "fflags", { fflagsFormat } },
24 { HEADER_EXT_FORMAT, "perms", { permsFormat } },
25 { HEADER_EXT_FORMAT, "permissions", { permsFormat } },
26 { HEADER_EXT_MORE, NULL, { (void *) headerDefaultFormats } }
29 static char * permsString(int mode) {
30 char * perms = malloc(11);
32 strcpy(perms, "-----------");
34 if (mode & S_ISVTX) perms[10] = 't';
36 if (mode & S_IRUSR) perms[1] = 'r';
37 if (mode & S_IWUSR) perms[2] = 'w';
38 if (mode & S_IXUSR) perms[3] = 'x';
40 if (mode & S_IRGRP) perms[4] = 'r';
41 if (mode & S_IWGRP) perms[5] = 'w';
42 if (mode & S_IXGRP) perms[6] = 'x';
44 if (mode & S_IROTH) perms[7] = 'r';
45 if (mode & S_IWOTH) perms[8] = 'w';
46 if (mode & S_IXOTH) perms[9] = 'x';
64 else if (S_ISLNK(mode)) {
67 else if (S_ISFIFO(mode))
69 else if (S_ISSOCK(mode))
71 else if (S_ISCHR(mode)) {
73 } else if (S_ISBLK(mode)) {
80 static char * permsFormat(int_32 type, const void * data,
81 char * formatPrefix, int padding, int element) {
85 if (type != RPM_INT32_TYPE) {
87 strcpy(val, "(not a number)");
89 val = malloc(15 + padding);
90 strcat(formatPrefix, "s");
91 buf = permsString(*((int_32 *) data));
92 sprintf(val, formatPrefix, buf);
99 static char * fflagsFormat(int_32 type, const void * data,
100 char * formatPrefix, int padding, int element) {
103 int anint = *((int_32 *) data);
105 if (type != RPM_INT32_TYPE) {
107 strcpy(val, "(not a number)");
110 if (anint & RPMFILE_DOC)
112 if (anint & RPMFILE_CONFIG)
115 val = malloc(5 + padding);
116 strcat(formatPrefix, "s");
117 sprintf(val, formatPrefix, buf);
123 static char * depflagsFormat(int_32 type, const void * data,
124 char * formatPrefix, int padding, int element) {
127 int anint = *((int_32 *) data);
129 if (type != RPM_INT32_TYPE) {
131 strcpy(val, "(not a number)");
135 if (anint & RPMSENSE_LESS)
137 if (anint & RPMSENSE_GREATER)
139 if (anint & RPMSENSE_EQUAL)
141 if (anint & RPMSENSE_SERIAL)
144 val = malloc(5 + padding);
145 strcat(formatPrefix, "s");
146 sprintf(val, formatPrefix, buf);
152 static int fsnamesTag(Header h, int_32 * type, void ** data, int_32 * count,
157 if (rpmGetFilesystemList(&list)) {
161 *type = RPM_STRING_ARRAY_TYPE;
162 *((char ***) data) = list;
164 for (i = 0; list[i]; i++) ;