Changeset 63498 in vbox
- Timestamp:
- Aug 15, 2016 8:41:37 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/bin2c.c
r62537 r63498 53 53 fprintf(stderr, 54 54 "Syntax: %s [options] <arrayname> <binaryfile> <outname>\n" 55 " - min <n>check if <binaryfile> is not smaller than <n>KB\n"56 " - max <n>check if <binaryfile> is not bigger than <n>KB\n"57 " - mask <n>check if size of binaryfile is <n>-aligned\n"58 " - width <n>number of bytes per line (default: 16)\n"59 " - break <n>break every <n> lines (default: -1)\n"60 " - asciishow ASCII representation of binary as comment\n"61 " - exportemit DECLEXPORT\n"55 " --min <n> check if <binaryfile> is not smaller than <n>KB\n" 56 " --max <n> check if <binaryfile> is not bigger than <n>KB\n" 57 " --mask <n> check if size of binaryfile is <n>-aligned\n" 58 " --width <n> number of bytes per line (default: 16)\n" 59 " --break <n> break every <n> lines (default: -1)\n" 60 " --ascii show ASCII representation of binary as comment\n" 61 " --export emit DECLEXPORT\n" 62 62 " --append append to the output file (default: truncate)\n" 63 " --no-size Skip the size.\n" 64 " --static Static data scope.\n" 63 65 , argv0); 64 66 … … 77 79 int fAppend = 0; 78 80 int fExport = 0; 81 int fNoSize = 0; 82 int fStatic = 0; 79 83 long iBreakEvery = -1; 80 84 unsigned char abLine[32]; … … 90 94 for (iArg = 1; iArg < argc; iArg++) 91 95 { 92 if (!strcmp(argv[iArg], "- min"))96 if (!strcmp(argv[iArg], "--min") || !strcmp(argv[iArg], "-min")) 93 97 { 94 98 if (++iArg >= argc) … … 96 100 cbMin = 1024 * strtoul(argv[iArg], NULL, 0); 97 101 } 98 else if (!strcmp(argv[iArg], "- max"))102 else if (!strcmp(argv[iArg], "--max") || !strcmp(argv[iArg], "-max")) 99 103 { 100 104 if (++iArg >= argc) … … 102 106 cbMax = 1024 * strtoul(argv[iArg], NULL, 0); 103 107 } 104 else if (!strcmp(argv[iArg], "- mask"))108 else if (!strcmp(argv[iArg], "--mask") || !strcmp(argv[iArg], "-mask")) 105 109 { 106 110 if (++iArg >= argc) … … 108 112 uMask = strtoul(argv[iArg], NULL, 0); 109 113 } 110 else if (!strcmp(argv[iArg], "- ascii"))114 else if (!strcmp(argv[iArg], "--ascii") || !strcmp(argv[iArg], "-ascii")) 111 115 fAscii = 1; 112 116 else if (!strcmp(argv[iArg], "--append")) 113 117 fAppend = 1; 114 else if (!strcmp(argv[iArg], "- export"))118 else if (!strcmp(argv[iArg], "--export") || !strcmp(argv[iArg], "-export")) 115 119 fExport = 1; 116 else if (!strcmp(argv[iArg], "-width")) 120 else if (!strcmp(argv[iArg], "--no-size")) 121 fNoSize = 1; 122 else if (!strcmp(argv[iArg], "--static")) 123 fStatic = 1; 124 else if (!strcmp(argv[iArg], "--width") || !strcmp(argv[iArg], "-width")) 117 125 { 118 126 if (++iArg >= argc) … … 126 134 } 127 135 } 128 else if (!strcmp(argv[iArg], "- break"))136 else if (!strcmp(argv[iArg], "--break") || !strcmp(argv[iArg], "-break")) 129 137 { 130 138 if (++iArg >= argc) … … 176 184 "%sconst unsigned char%s g_ab%s[] =\n" 177 185 "{\n", 178 argv[iArg+1], argv[0], f Export ? "DECLEXPORT(" : "",fExport ? ")" : "", argv[iArg]);186 argv[iArg+1], argv[0], fStatic ? "static " : fExport ? "DECLEXPORT(" : "", !fStatic && fExport ? ")" : "", argv[iArg]); 179 187 180 188 /* check size restrictions */ … … 227 235 /* no errors, finish the structure. */ 228 236 fprintf(pFileOut, 229 "};\n" 230 "\n" 231 "%sconst unsigned%s g_cb%s = sizeof(g_ab%s);\n" 232 "/* end of file */\n", 233 fExport ? "DECLEXPORT(" : "", fExport ? ")" : "", argv[iArg], argv[iArg]); 237 "};\n"); 238 239 if (!fNoSize) 240 fprintf(pFileOut, 241 "\n" 242 "%sconst unsigned%s g_cb%s = sizeof(g_ab%s);\n", 243 fExport ? "DECLEXPORT(" : "", fExport ? ")" : "", argv[iArg], argv[iArg]); 244 245 fprintf(pFileOut, "/* end of file */\n"); 234 246 235 247 /* flush output and check for error. */
Note:
See TracChangeset
for help on using the changeset viewer.