7 /* These have to be global scope to make up for *stupid* compilers */
10 static struct poptOption optionsTable[] = {
11 { NULL, 'n', POPT_ARG_STRING, &name, 'n' },
12 { NULL, 'f', POPT_ARG_STRING, &file, 'f' },
16 int parseFiles(Spec spec)
23 int flag = PART_SUBNAME;
24 poptContext optCon = NULL;
28 if ((rc = poptParseArgvString(spec->line, &argc, &argv))) {
29 rpmError(RPMERR_BADSPEC, _("line %d: Error parsing %%files: %s"),
30 spec->lineNum, poptStrerror(rc));
31 return RPMERR_BADSPEC;
34 optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
35 while ((arg = poptGetNextOpt(optCon)) > 0) {
42 rpmError(RPMERR_BADSPEC, _("line %d: Bad option %s: %s"),
44 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
47 poptFreeContext(optCon);
48 return RPMERR_BADSPEC;
51 if (poptPeekArg(optCon)) {
53 name = poptGetArg(optCon);
55 if (poptPeekArg(optCon)) {
56 rpmError(RPMERR_BADSPEC, _("line %d: Too many names: %s"),
60 poptFreeContext(optCon);
61 return RPMERR_BADSPEC;
65 if (lookupPackage(spec, name, flag, &pkg)) {
66 rpmError(RPMERR_BADSPEC, _("line %d: Package does not exist: %s"),
67 spec->lineNum, spec->line);
69 poptFreeContext(optCon);
70 return RPMERR_BADSPEC;
73 if (pkg->fileList != NULL) {
74 rpmError(RPMERR_BADSPEC, _("line %d: Second %%files list"),
77 poptFreeContext(optCon);
78 return RPMERR_BADSPEC;
82 pkg->fileFile = strdup(file);
84 pkg->fileList = newStringBuf();
86 if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
92 while (! (nextPart = isPart(spec->line))) {
93 appendStringBuf(pkg->fileList, spec->line);
94 if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
105 poptFreeContext(optCon);