Skip to content
Permalink
Browse files
[svn] More testparse tweakage.
--HG--
branch : trunk
  • Loading branch information
icculus committed Mar 28, 2008
1 parent bd6637a commit c04c29eb738367ad605adc00fa19a00ec092f01f
Showing with 17 additions and 14 deletions.
  1. +17 −14 testparse.c
@@ -42,50 +42,53 @@ static const char *shader_type(const MOJOSHADER_shaderType s)
} // shader_type


static void do_parse(unsigned char *buf, int len, const char *prof)
static void do_parse(const unsigned char *buf, const int len, const char *prof)
{
const MOJOSHADER_parseData *pd;

pd = MOJOSHADER_parse(prof, buf, len, Malloc, Free);
printf("PROFILE: %s\n", prof);
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);
if (pd->error != NULL)
printf("ERROR: %s\n", pd->error);
if (pd->output != NULL)
printf("OUTPUT:\n%s\n", pd->output);
else
{
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);
if (pd->output != NULL)
printf("OUTPUT:\n%s\n", pd->output);
} // else
printf("\n\n");
MOJOSHADER_freeParseData(pd);
} // do_parse


int main(int argc, char **argv)
{
int i;

printf("MojoShader testparse\n");
printf("Compiled against version %d\n", MOJOSHADER_VERSION);
printf("Linked against version %d\n", MOJOSHADER_version());
printf("\n");

if (argc == 1)
printf("No files specified.\n");
if (argc <= 2)
printf("\n\nUSAGE: %s <profile> [file1] ... [fileN]\n\n", argv[0]);
else
{
for (i = 1; i < argc; i++)
const char *profile = argv[1];
int i;

for (i = 2; i < argc; i++)
{
FILE *io = fopen(argv[i], "rb");
printf("FILE: %s\n", argv[i]);
if (io == NULL)
printf("fopen('%s') failed.\n", argv[i]);
printf(" ... fopen('%s') failed.\n", argv[i]);
else
{
unsigned char *buf = (unsigned char *) malloc(1000000);
int rc = fread(buf, 1, 1000000, io);
fclose(io);
do_parse(buf, rc, MOJOSHADER_PROFILE_D3D);
do_parse(buf, rc, MOJOSHADER_PROFILE_GLSL);
do_parse(buf, rc, profile);
free(buf);
} // else
} // for

0 comments on commit c04c29e

Please sign in to comment.