testparse.c
branchtrunk
changeset 47 49953c7cb142
parent 46 ff5a0ec44f00
child 48 86dc2c772d26
equal deleted inserted replaced
46:ff5a0ec44f00 47:49953c7cb142
    62 
    62 
    63 int main(int argc, char **argv)
    63 int main(int argc, char **argv)
    64 {
    64 {
    65     int i;
    65     int i;
    66 
    66 
       
    67     printf("MojoShader testparse\n");
    67     printf("Compiled against version %d\n", MOJOSHADER_VERSION);
    68     printf("Compiled against version %d\n", MOJOSHADER_VERSION);
    68     printf("Linked against version %d\n", MOJOSHADER_version());
    69     printf("Linked against version %d\n", MOJOSHADER_version());
       
    70     printf("\n");
    69 
    71 
    70     for (i = 1; i < argc; i++)
    72     if (argc == 1)
       
    73         printf("No files specified.\n");
       
    74     else
    71     {
    75     {
    72         FILE *io = fopen(argv[i], "rb");
    76         for (i = 1; i < argc; i++)
    73         if (io != NULL)
       
    74         {
    77         {
    75             unsigned char *buf = (unsigned char *) malloc(1000000);
    78             FILE *io = fopen(argv[i], "rb");
    76             int rc = fread(buf, 1, 1000000, io);
    79             printf("FILE: %s\n", argv[i]);
    77             fclose(io);
    80             if (io == NULL)
    78             do_parse(buf, rc, MOJOSHADER_PROFILE_D3D);
    81                 printf("fopen('%s') failed.\n", argv[i]);
    79             do_parse(buf, rc, MOJOSHADER_PROFILE_GLSL);
    82             else
    80             free(buf);
    83             {
    81         } // if
    84                 unsigned char *buf = (unsigned char *) malloc(1000000);
    82     } // if
    85                 int rc = fread(buf, 1, 1000000, io);
       
    86                 fclose(io);
       
    87                 do_parse(buf, rc, MOJOSHADER_PROFILE_D3D);
       
    88                 do_parse(buf, rc, MOJOSHADER_PROFILE_GLSL);
       
    89                 free(buf);
       
    90             } // else
       
    91         } // for
       
    92     } // else
    83 
    93 
    84     return 0;
    94     return 0;
    85 } // main
    95 } // main
    86 
    96 
    87 // end of testparse.c ...
    97 // end of testparse.c ...