8
#include <rpmio_internal.h>
14
/*@access StringBuf @*/
16
char * rpmPermsString(int mode)
18
char *perms = xstrdup("----------");
22
else if (S_ISLNK(mode))
24
else if (S_ISFIFO(mode))
26
else if (S_ISSOCK(mode))
28
else if (S_ISCHR(mode))
30
else if (S_ISBLK(mode))
34
if (mode & S_IRUSR) perms[1] = 'r';
35
if (mode & S_IWUSR) perms[2] = 'w';
36
if (mode & S_IXUSR) perms[3] = 'x';
38
if (mode & S_IRGRP) perms[4] = 'r';
39
if (mode & S_IWGRP) perms[5] = 'w';
40
if (mode & S_IXGRP) perms[6] = 'x';
42
if (mode & S_IROTH) perms[7] = 'r';
43
if (mode & S_IWOTH) perms[8] = 'w';
44
if (mode & S_IXOTH) perms[9] = 'x';
47
perms[3] = ((mode & S_IXUSR) ? 's' : 'S');
50
perms[6] = ((mode & S_IXGRP) ? 's' : 'S');
53
perms[9] = ((mode & S_IXOTH) ? 't' : 'T');
59
/**@todo Infinite loops through manifest files exist, operator error for now. */
60
int rpmReadPackageManifest(FD_t fd, int * argcPtr, const char *** argvPtr)
62
StringBuf sb = newStringBuf();
66
const char ** av = NULL;
67
int argc = (argcPtr ? *argcPtr : 0);
68
const char ** argv = (argvPtr ? *argvPtr : NULL);
69
FILE * f = fdGetFp(fd);
78
s = fgets(line, sizeof(line) - 1, f);
80
/* XXX Ferror check needed */
85
if ((se = strchr(s, '#')) != NULL) *se = '\0';
87
/* Trim white space. */
89
while (se > s && (se[-1] == '\n' || se[-1] == '\r'))
91
while (*s && strchr(" \f\n\r\t\v", *s) != NULL)
93
if (*s == '\0') continue;
95
/* Insure that file contains only ASCII */
101
/* Concatenate next line in buffer. */
104
appendStringBuf(sb, s);
107
if (s == NULL) /* XXX always true */
108
s = getStringBuf(sb);
115
/* Glob manifest items. */
116
rc = rpmGlob(s, &ac, &av);
119
/* Find 1st existing unprocessed arg. */
120
for (i = 0; i < argc; i++)
121
if (argv && argv[i]) break;
123
/* Concatenate existing unprocessed args after manifest contents. */
124
if (argv && i < argc) {
125
int nac = ac + (argc - i);
126
const char ** nav = xcalloc((nac + 1), sizeof(*nav));
129
memcpy(nav, av, ac * sizeof(*nav));
131
memcpy(nav + ac, argv + i, (argc - i) * sizeof(*nav));
135
*argvPtr = argv = _free(argv);
141
/* Save new argc/argv list. */
143
*argvPtr = _free(*argvPtr);
150
if (argvPtr == NULL || (rc != 0 && av)) {
152
for (i = 0; i < ac; i++)
153
/*@-unqualifiedtrans@*/av[i] = _free(av[i]); /*@=unqualifiedtrans@*/
154
/*@-dependenttrans@*/ av = _free(av); /*@=dependenttrans@*/
156
sb = freeStringBuf(sb);