+ /* Parse options */
+ while (1) {
+ char *name, *equal, *value;
+
+ /* Ignore blank lines */
+ READ_LINE;
+ if (*line == '\0')
+ continue;
+
+ /* An initial digit means we hit an item. Trigger the
+ * spaghetti machine. */
+ if ((*line >= '0' && *line <= '9') || *line == '-')
+ goto PARSE_BIN;
+
+ equal = strchr (line, '=');
+ if (equal == NULL) {
+ fprintf (stderr, "Malformed option, (expected name=value): \"%s\" at %s:%d\n",
+ line, path, line_count);
+ exit (1);
+ }
+
+ value = equal + 1;
+ name = line;
+ *equal = '\0';
+
+ name = trim_space (name);
+ value = trim_space (value);
+
+ if (strcmp (name, "order") == 0) {
+ if (strcmp (value, "sequential") == 0) {
+ category->order = CATEGORY_ORDER_SEQUENTIAL;
+ } else if (strcmp (value, "random") == 0) {
+ category->order = CATEGORY_ORDER_RANDOM;
+ } else {
+ fprintf (stderr, "Unknown value for \"order\" option \"%s\" at %s:%d\n",
+ value, path, line_count);
+ exit (1);
+ }
+ } else if (strcmp (name, "time") == 0) {
+ double limit;
+ char *end;
+ limit = strtod (value, &end);
+ while (isspace (*end))
+ end++;
+ if (*end == '\0') {
+ category->time_limit = limit;
+ } else {
+ fprintf (stderr, "Failed to parse time value: %s at %s:%d\n",
+ value, path, line_count);
+ exit (1);
+ }
+ } else if (strcmp (name, "challenge") == 0) {
+ if (strcmp (value, "text") == 0) {
+ category->challenge_type = CHALLENGE_TYPE_TEXT;
+ } else if (strcmp (value, "image") == 0) {
+ category->challenge_type = CHALLENGE_TYPE_IMAGE;
+ } else if (strcmp (value, "audio") == 0) {
+ category->challenge_type = CHALLENGE_TYPE_AUDIO;
+ } else if (strcmp (value, "midi") == 0) {
+ category->challenge_type = CHALLENGE_TYPE_MIDI;
+ } else if (strcmp (value, "text-to-speech") == 0) {
+ category->challenge_type = CHALLENGE_TYPE_TEXT_TO_SPEECH;
+ } else {
+ fprintf (stderr, "Unknown value for \"challenge\" option \"%s\" at %s:%d\n",
+ value, path, line_count);
+ exit (1);
+ }
+ } else if (strcmp (name, "repeat") == 0) {
+ if (strcmp (value, "0") == 0)
+ category->repeat = 0;
+ else
+ category->repeat = 1;
+ } else {
+ fprintf (stderr, "Unknown option %s at %s:%d\n",
+ name, path, line_count);
+ exit (1);
+ }
+ }
+
+ /* Parse items */