6 Copyright (C) 2022 Balthasar SzczepaĆski
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 char DEFAULT_NAME[] = "data";
29 FILE *infile, *outfile;
30 uint_fast8_t in_open = 0;
31 uint_fast8_t out_open = 0;
42 int main (int argc, char **argv)
55 infile = fopen(argv[2], "rb");
64 outfile = fopen(argv[3], "wt");
74 "/* %s is autogenerated%s%s. */\n",
75 out_open ? argv[3] : "File",
76 in_open ? " from " : "",
77 in_open ? argv[2] : ""
79 fputs ("#include <stdint.h>\n", outfile);
82 "const uint8_t %s[] = {",
85 for (i=0; fread(&x, 1, 1, infile)!=0;i=(i+1)&7)
90 (i==0) ? "\n\t" : " ",
95 fputs ("\n};\n", outfile);
98 "#define %s_size %" PRIu64 "\n",