| 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"cxx . . $ `<file>/mojoshader.h`/ |
| 13 | |
| 14 | static int do_parsecxx . . $ do_parse(9e12eedfec41b13a).(const unsigned char *buf, const int len, const char *prof) |
| 15 | { |
| 16 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd; |
| 17 | int retval = 0; |
| 18 | |
| 19 | pd = MOJOSHADER_parsecxx . . $ MOJOSHADER_parse(ff0909865cf9979a).(prof, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, buf, len, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 20 | if (pd->error_countcxx . . $ MOJOSHADER_parseData#error_count. > 0) |
| 21 | { |
| 22 | int i; |
| 23 | for (i = 0; i < pd->error_countcxx . . $ MOJOSHADER_parseData#error_count.; i++) |
| 24 | { |
| 25 | printfcxx . . $ printf(581fddd72a8db8fc).("%s:%d: ERROR: %s\n", |
| 26 | pd->errorscxx . . $ MOJOSHADER_parseData#errors.[i].filenamecxx . . $ MOJOSHADER_error#filename. ? pd->errorscxx . . $ MOJOSHADER_parseData#errors.[i].filenamecxx . . $ MOJOSHADER_error#filename. : "???", |
| 27 | pd->errorscxx . . $ MOJOSHADER_parseData#errors.[i].error_positioncxx . . $ MOJOSHADER_error#error_position., |
| 28 | pd->errorscxx . . $ MOJOSHADER_parseData#errors.[i].errorcxx . . $ MOJOSHADER_error#error.); |
| 29 | } // for |
| 30 | } // if |
| 31 | else |
| 32 | { |
| 33 | retval = 1; |
| 34 | if (pd->outputcxx . . $ MOJOSHADER_parseData#output. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 35 | { |
| 36 | int i; |
| 37 | for (i = 0; i < pd->output_lencxx . . $ MOJOSHADER_parseData#output_len.; i++) |
| 38 | putcharcxx . . $ putchar(7864480464b09eea).((int) pd->outputcxx . . $ MOJOSHADER_parseData#output.[i]); |
| 39 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 40 | } // if |
| 41 | } // else |
| 42 | printfcxx . . $ printf(581fddd72a8db8fc).("\n\n"); |
| 43 | MOJOSHADER_freeParseDatacxx . . $ MOJOSHADER_freeParseData(c292f651a0772a1d).(pd); |
| 44 | |
| 45 | return retval; |
| 46 | } // do_parse |
| 47 | |
| 48 | |
| 49 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 50 | { |
| 51 | int retval = 0; |
| 52 | |
| 53 | if (argc <= 2) |
| 54 | printfcxx . . $ printf(581fddd72a8db8fc).("\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 | FILEcxx . . $ FILE# *io = fopencxx . . $ fopen(82ec0787cd37e0a3).(argv[i], "rb"); |
| 63 | if (io == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 64 | printfcxx . . $ printf(581fddd72a8db8fc).(" ... fopen('%s') failed.\n", argv[i]); |
| 65 | else |
| 66 | { |
| 67 | unsigned char *buf = (unsigned char *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(1000000); |
| 68 | int rc = freadcxx . . $ fread(738fc8ac1d711e58).(buf, 1, 1000000, io); |
| 69 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(io); |
| 70 | if (!do_parsecxx . . $ do_parse(9e12eedfec41b13a).(buf, rc, profile)) |
| 71 | retval = 1; |
| 72 | freecxx . . $ free(5d22bdacc48458e8).(buf); |
| 73 | } // else |
| 74 | } // for |
| 75 | } // else |
| 76 | |
| 77 | return retval; |
| 78 | } // main |
| 79 | |
| 80 | // end of testoutput.c ... |
| 81 |