category->order = CATEGORY_ORDER_RANDOM;
category->time_limit = 0.0;
category->bin_zero_head = 0;
- category->challenge_type = CHALLENGE_TYPE_TEXT;
+ category->challenge_type = xstrdup("");
category->repeat = 0;
}
static void
category_fini (category_t *category)
{
- int i;
+ unsigned int i;
for (i = 0; i < category->num_items; i++)
item_fini (&category->items[i]);
free (category->items);
free (category->name);
+
+ free (category->challenge_type);
}
static void
static item_t *
category_next_bin_zero_item (category_t *category)
{
- int *i = &category->bin_zero_head;
+ unsigned int *i = &category->bin_zero_head;
for ( ; *i < category->num_items; *i = *i + 1)
if (category->items[*i].score == 0)
category_print (category_t *category,
FILE *file)
{
- int i;
+ unsigned int i;
item_t *item;
fprintf (file, "order = %s\n\n",
fprintf (file, "time = %f\n\n",
category->time_limit);
- fprintf (file, "challenge = ");
- switch (category->challenge_type) {
- case CHALLENGE_TYPE_TEXT:
- fprintf (file, "text");
- break;
- case CHALLENGE_TYPE_IMAGE:
- fprintf (file, "image");
- break;
- case CHALLENGE_TYPE_AUDIO:
- fprintf (file, "audio");
- break;
- case CHALLENGE_TYPE_MIDI:
- fprintf (file, "midi");
- break;
- case CHALLENGE_TYPE_TEXT_TO_SPEECH:
- fprintf (file, "text-to-speech");
- break;
- }
- fprintf (file, "\n\n");
+ fprintf (file, "challenge = %s\n\n", category->challenge_type);
fprintf (file, "repeat = %d\n\n", category->repeat);
bin_item_index (bin_t *bin,
item_t *item)
{
- int i;
+ unsigned int i;
for (i = 0; i < bin->num_items; i++)
if (bin->items[i] == item)
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);
- }
+ /* XXX: Need to switch to talloc here. */
+ free (category->challenge_type);
+ category->challenge_type = xstrdup (value);
} else if (strcmp (name, "repeat") == 0) {
if (strcmp (value, "0") == 0)
category->repeat = 0;