5 static struct ReqComp {
9 { "<=", RPMSENSE_LESS | RPMSENSE_EQUAL},
10 { "<=S", RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
11 { "=<", RPMSENSE_LESS | RPMSENSE_EQUAL},
12 { "=<S", RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
13 { "<", RPMSENSE_LESS},
14 { "<S", RPMSENSE_LESS | RPMSENSE_SERIAL},
16 { "=", RPMSENSE_EQUAL},
17 { "=S", RPMSENSE_EQUAL | RPMSENSE_SERIAL},
19 { ">=", RPMSENSE_GREATER | RPMSENSE_EQUAL},
20 { ">=S", RPMSENSE_GREATER | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
21 { "=>", RPMSENSE_GREATER | RPMSENSE_EQUAL},
22 { "=>S", RPMSENSE_GREATER | RPMSENSE_EQUAL | RPMSENSE_SERIAL},
23 { ">", RPMSENSE_GREATER},
24 { ">S", RPMSENSE_GREATER | RPMSENSE_SERIAL},
28 #define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
29 #define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
31 int parseRCPOT(Spec spec, Package pkg, const char *field, int tag, int index)
33 const char *r, *re, *v, *ve;
40 flags = RPMSENSE_PROVIDES;
43 case RPMTAG_OBSOLETES:
44 flags = RPMSENSE_OBSOLETES;
47 case RPMTAG_CONFLICTFLAGS:
48 flags = RPMSENSE_CONFLICTS;
51 case RPMTAG_BUILDCONFLICTS:
52 flags = RPMSENSE_CONFLICTS;
53 h = spec->buildRestrictions;
56 flags = RPMSENSE_PREREQ;
59 case RPMTAG_BUILDPREREQ:
60 flags = RPMSENSE_PREREQ;
61 h = spec->buildRestrictions;
63 case RPMTAG_TRIGGERIN:
64 flags = RPMSENSE_TRIGGERIN;
67 case RPMTAG_TRIGGERPOSTUN:
68 flags = RPMSENSE_TRIGGERPOSTUN;
71 case RPMTAG_TRIGGERUN:
72 flags = RPMSENSE_TRIGGERUN;
75 case RPMTAG_BUILDREQUIRES:
77 h = spec->buildRestrictions;
80 case RPMTAG_REQUIREFLAGS:
86 for (r = field; *r; r = re) {
91 /* Tokens must begin with alphanumeric, _, or / */
92 if (!(isalnum(r[0]) || r[0] == '_' || r[0] == '/')) {
93 rpmError(RPMERR_BADSPEC,
94 _("line %d: Dependency tokens must begin with alpha-numeric, '_' or '/': %s"),
95 spec->lineNum, spec->line);
96 return RPMERR_BADSPEC;
99 /* Don't permit file names as args for certain tags */
101 case RPMTAG_OBSOLETES:
102 case RPMTAG_CONFLICTFLAGS:
103 case RPMTAG_BUILDCONFLICTS:
105 rpmError(RPMERR_BADSPEC,_("line %d: File name not permitted: %s"),
106 spec->lineNum, spec->line);
107 return RPMERR_BADSPEC;
116 req = malloc((re-r) + 1);
117 strncpy(req, r, (re-r));
126 re = v; /* ==> next token (if no version found) starts here */
128 /* Check for possible logical operator */
131 for (rc = ReqComparisons; rc->token != NULL; rc++) {
132 if (strncmp(v, rc->token, (ve-v)))
136 rpmError(RPMERR_BADSPEC,
137 _("line %d: Versioned file name not permitted: %s"),
138 spec->lineNum, spec->line);
139 return RPMERR_BADSPEC;
142 case RPMTAG_PROVIDES:
143 case RPMTAG_OBSOLETES:
144 case RPMTAG_BUILDPREREQ:
146 rpmError(RPMERR_BADSPEC,
147 _("line %d: Version not permitted: %s"),
148 spec->lineNum, spec->line);
149 return RPMERR_BADSPEC;
156 /* now parse version */
165 if (flags & RPMSENSE_SENSEMASK) {
166 if (*v == '\0' || ve == v) {
167 rpmError(RPMERR_BADSPEC, _("line %d: Version required: %s"),
168 spec->lineNum, spec->line);
169 return RPMERR_BADSPEC;
171 version = malloc((ve-v) + 1);
172 strncpy(version, v, (ve-v));
173 version[ve-v] = '\0';
174 re = ve; /* ==> next token after version string starts here */
178 addReqProv(spec, h, flags, req, version, index);
181 if (version) free(version);