Return a more-meaningful pass/fail error code from testparse main(). trunk
authorRyan C. Gordon <icculus@icculus.org>
Fri, 18 Apr 2008 21:26:19 -0400
branchtrunk
changeset 142 e064b4cefb4e
parent 141 997857107c39
child 143 336b3c22ba0a
Return a more-meaningful pass/fail error code from testparse main().
testparse.c
--- a/testparse.c	Fri Apr 18 01:36:28 2008 -0400
+++ b/testparse.c	Fri Apr 18 21:26:19 2008 -0400
@@ -42,9 +42,10 @@
 } // shader_type
 
 
-static void do_parse(const unsigned char *buf, const int len, const char *prof)
+static int do_parse(const unsigned char *buf, const int len, const char *prof)
 {
     const MOJOSHADER_parseData *pd;
+    int retval = 0;
 
     pd = MOJOSHADER_parse(prof, buf, len, Malloc, Free, NULL);
     printf("PROFILE: %s\n", prof);
@@ -52,6 +53,7 @@
         printf("ERROR: %s\n", pd->error);
     else
     {
+        retval = 1;
         printf("SHADER TYPE: %s\n", shader_type(pd->shader_type));
         printf("VERSION: %d.%d\n", pd->major_ver, pd->minor_ver);
         printf("INSTRUCTION COUNT: %d\n", (int) pd->instruction_count);
@@ -104,11 +106,15 @@
     } // else
     printf("\n\n");
     MOJOSHADER_freeParseData(pd);
+
+    return retval;
 } // do_parse
 
 
 int main(int argc, char **argv)
 {
+    int retval = 0;
+
     printf("MojoShader testparse\n");
     printf("Compiled against version %d\n", MOJOSHADER_VERSION);
     printf("Linked against version %d\n", MOJOSHADER_version());
@@ -132,13 +138,14 @@
                 unsigned char *buf = (unsigned char *) malloc(1000000);
                 int rc = fread(buf, 1, 1000000, io);
                 fclose(io);
-                do_parse(buf, rc, profile);
+                if (!do_parse(buf, rc, profile))
+                    retval = 1;
                 free(buf);
             } // else
         } // for
     } // else
 
-    return 0;
+    return retval;
 } // main
 
 // end of testparse.c ...