5 /* These have to be global scope to make up for *stupid* compilers */
6 /*@observer@*/ /*@null@*/ static char *name;
7 /*@observer@*/ /*@null@*/ static char *file;
8 static struct poptOption optionsTable[] = {
9 { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL},
10 { NULL, 'f', POPT_ARG_STRING, &file, 'f', NULL, NULL},
11 { 0, 0, 0, 0, 0, NULL, NULL}
14 int parseFiles(Spec spec)
21 int flag = PART_SUBNAME;
22 poptContext optCon = NULL;
26 if ((rc = poptParseArgvString(spec->line, &argc, &argv))) {
27 rpmError(RPMERR_BADSPEC, _("line %d: Error parsing %%files: %s"),
28 spec->lineNum, poptStrerror(rc));
29 return RPMERR_BADSPEC;
32 optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
33 while ((arg = poptGetNextOpt(optCon)) > 0) {
40 rpmError(RPMERR_BADSPEC, _("line %d: Bad option %s: %s"),
42 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
45 poptFreeContext(optCon);
46 return RPMERR_BADSPEC;
49 if (poptPeekArg(optCon)) {
51 name = poptGetArg(optCon);
53 if (poptPeekArg(optCon)) {
54 rpmError(RPMERR_BADSPEC, _("line %d: Too many names: %s"),
58 poptFreeContext(optCon);
59 return RPMERR_BADSPEC;
63 if (lookupPackage(spec, name, flag, &pkg)) {
64 rpmError(RPMERR_BADSPEC, _("line %d: Package does not exist: %s"),
65 spec->lineNum, spec->line);
67 poptFreeContext(optCon);
68 return RPMERR_BADSPEC;
71 if (pkg->fileList != NULL) {
72 rpmError(RPMERR_BADSPEC, _("line %d: Second %%files list"),
75 poptFreeContext(optCon);
76 return RPMERR_BADSPEC;
80 pkg->fileFile = xstrdup(file);
82 pkg->fileList = newStringBuf();
84 if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
90 while (! (nextPart = isPart(spec->line))) {
91 appendStringBuf(pkg->fileList, spec->line);
92 if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
103 poptFreeContext(optCon);