Debian Codegraph @

utils/testoutput.c

raw symbols SCIP
1 /**
2 * MojoShader; generate shader programs from bytecode of compiled
3 * Direct3D shaders.
4 *
5 * Please see the file LICENSE.txt in the source's root directory.
6 *
7 * This file written by Ryan C. Gordon.
8 */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include "mojoshader.h"
13
14 static int do_parse(const unsigned char *buf, const int len, const char *prof)
15 {
16 const MOJOSHADER_parseData *pd;
17 int retval = 0;
18
19 pd = MOJOSHADER_parse(prof, NULL, buf, len, NULL, 0, NULL, 0, NULL, NULL, NULL);
20 if (pd->error_count > 0)
21 {
22 int i;
23 for (i = 0; i < pd->error_count; i++)
24 {
25 printf("%s:%d: ERROR: %s\n",
26 pd->errors[i].filename ? pd->errors[i].filename : "???",
27 pd->errors[i].error_position,
28 pd->errors[i].error);
29 } // for
30 } // if
31 else
32 {
33 retval = 1;
34 if (pd->output != NULL)
35 {
36 int i;
37 for (i = 0; i < pd->output_len; i++)
38 putchar((int) pd->output[i]);
39 printf("\n");
40 } // if
41 } // else
42 printf("\n\n");
43 MOJOSHADER_freeParseData(pd);
44
45 return retval;
46 } // do_parse
47
48
49 int main(int argc, char **argv)
50 {
51 int retval = 0;
52
53 if (argc <= 2)
54 printf("\n\nUSAGE: %s <profile> [file1] ... [fileN]\n\n", argv[0]);
55 else
56 {
57 const char *profile = argv[1];
58 int i;
59
60 for (i = 2; i < argc; i++)
61 {
62 FILE *io = fopen(argv[i], "rb");
63 if (io == NULL)
64 printf(" ... fopen('%s') failed.\n", argv[i]);
65 else
66 {
67 unsigned char *buf = (unsigned char *) malloc(1000000);
68 int rc = fread(buf, 1, 1000000, io);
69 fclose(io);
70 if (!do_parse(buf, rc, profile))
71 retval = 1;
72 free(buf);
73 } // else
74 } // for
75 } // else
76
77 return retval;
78 } // main
79
80 // end of testoutput.c ...
81