};
+/*
+ * Hacks for simplicity. These data types aren't allowed as
+ * parameters, so we can re-use them for something else.
+ */
+//#define FR_TYPE_ALTERNATE FR_TYPE_GROUP
+//#define FR_TYPE_OPTIONAL FR_TYPE_ABINARY
+
+
/** Find a command
*
* @param head the head of the list
bool lowercase = false;
bool uppercase = false;
- if (!fr_command_valid_name(argv[i])) {
- return -1;
- }
-
- for (p = argv[i]; *p != '\0'; p++) {
- if (isupper((int) *p)) uppercase = true;
- if (islower((int) *p)) lowercase = true;
- }
-
/*
- * No alphabetical characters, that's a
- * problem, except for varargs.
+ * Check for varargs. Which MUST NOT be
+ * the first argument, and MUST be the
+ * last argument, and MUST be preceded by
+ * a known data type.
*/
- if (!uppercase && !lowercase) {
- if (strcmp(argv[i], "...") != 0) {
+ if (strcmp(argv[i], "...") == 0) {
+ if ((i == 0) || (i != (argc - 1))) {
invalid:
fr_strerror_printf("Syntax command %d does not contain alphabetical characters", i);
return -1;
}
- /*
- * Varargs MUST NOT be the first
- * one, and MUST be the last one
- * in the list.
- */
- if ((i == 0) || (i != (argc - 1))) goto invalid;
-
/*
* The thing BEFORE the varags
- * MUST be a data type.
+ * MUST be a known data type.
*/
if (types[i - 1] == FR_TYPE_INVALID) goto invalid;
varargs = true;
+ break;
+ }
+
+ if (!fr_command_valid_name(argv[i])) {
+ return -1;
+ }
+
+ types[i] = FR_TYPE_INVALID;
+
+ for (p = argv[i]; *p != '\0'; p++) {
+ if (isupper((int) *p)) uppercase = true;
+ if (islower((int) *p)) lowercase = true;
}
+ /*
+ * No alphabetical characters, that's a
+ * problem.
+ */
+ if (!uppercase && !lowercase) goto invalid;
+
/*
* Mixed case is not allowed in a syntax.
*/
}
types[i] = type;
- } else {
- types[i] = FR_TYPE_INVALID;
}
}