]> git.cworth.org Git - mnemon/blobdiff - main.c
Remove the enumeration of challenge types.
[mnemon] / main.c
diff --git a/main.c b/main.c
index b583d394b7010724862b8f33a803b90b29652268..819878919690335901fa2b9d58d9e02a74d55fe8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -84,13 +84,13 @@ xasprintf (char **strp, const char *fmt, ...)
 
 static void
 _show_challenge (mnemon_t *mnemon,
-                challenge_type_t challenge_type,
+                const char *challenge_type,
                 const char *challenge)
 {
     const char *program;
     char *command;
 
-    if (challenge_type == CHALLENGE_TYPE_TEXT) {
+    if (strcmp (challenge_type, "text") == 0) {
        printf ("%s\n", challenge);
        return;
     }
@@ -100,22 +100,18 @@ _show_challenge (mnemon_t *mnemon,
      * have a custom external program that accepts image filenames on
      * stdin.
      */
-    switch (challenge_type) {
-    case CHALLENGE_TYPE_TEXT:
-       ASSERT_NOT_REACHED;
-       break;
-    case CHALLENGE_TYPE_IMAGE:
+    if (strcmp (challenge_type, "image") == 0) {
        program = "xli -gamma 2.2";
-       break;
-    case CHALLENGE_TYPE_AUDIO:
+    } else if (strcmp (challenge_type, "audio") == 0) {
        program = "play";
-       break;
-    case CHALLENGE_TYPE_MIDI:
+    } else if (strcmp (challenge_type, "midi") == 0) {
        program = "timidity -Os";
-       break;
-    case CHALLENGE_TYPE_TEXT_TO_SPEECH:
+    } else if (strcmp (challenge_type, "text-to-speech") == 0) {
        program = "mnemon-tts";
-       break;
+    } else {
+       fprintf (stderr, "Error: unsupported challenge type: %s\n",
+                challenge_type);
+       exit (1);
     }
 
     xasprintf (&command, "%s %s/%s >/dev/null 2>&1 &",
@@ -128,11 +124,11 @@ _show_challenge (mnemon_t *mnemon,
 
 static void
 _hide_challenge (unused (mnemon_t *mnemon),
-                challenge_type_t challenge_type)
+                const char *challenge_type)
 {
     char * command;
 
-    if (challenge_type != CHALLENGE_TYPE_IMAGE)
+    if (strcmp (challenge_type, "image"))
        return;
 
     /* XXX: And this is just embarrassing (obviously wrong in several