Mercurial > msvpvf
comparison src/main.c @ 9:d2cd8c5672fa
Increase filename limit
256 bytes is enough for anybody
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Wed, 26 Jan 2022 23:12:41 -0500 |
| parents | 9d862edfd3cc |
| children | a4e604789e2e |
comparison
equal
deleted
inserted
replaced
| 8:9d862edfd3cc | 9:d2cd8c5672fa |
|---|---|
| 71 int main(int argc, char *argv[]) { | 71 int main(int argc, char *argv[]) { |
| 72 int c, option_index = 0; | 72 int c, option_index = 0; |
| 73 unsigned char magic[16]; | 73 unsigned char magic[16]; |
| 74 FILE* outfile; | 74 FILE* outfile; |
| 75 struct arguments { | 75 struct arguments { |
| 76 char input[128]; | 76 char input[256]; |
| 77 char output[128]; | 77 char output[256]; |
| 78 int version; | 78 int version; |
| 79 char type[128]; | 79 char type[256]; |
| 80 } args; | 80 } args; |
| 81 strcpy(args.input, " "); | 81 strcpy(args.input, " "); |
| 82 strcpy(args.output, " "); | 82 strcpy(args.output, " "); |
| 83 args.version = -1; | 83 args.version = -1; |
| 84 strcpy(args.type, " "); | 84 strcpy(args.type, " "); |
| 145 fflush(stdout); | 145 fflush(stdout); |
| 146 scanf("%3s", args.type); | 146 scanf("%3s", args.type); |
| 147 } | 147 } |
| 148 fflush(stdout); | 148 fflush(stdout); |
| 149 if (strcmp(args.output, " ") == 0) { /* string manipulation hell */ | 149 if (strcmp(args.output, " ") == 0) { /* string manipulation hell */ |
| 150 char temp[128] = {'V'}; | 150 char temp[256] = {'V'}; |
| 151 char str_version[16] = {}; | 151 char str_version[16] = {}; |
| 152 sprintf(str_version, "%d", args.version); | 152 sprintf(str_version, "%d", args.version); |
| 153 strncat(temp, str_version, 2); | 153 strncat(temp, str_version, 2); |
| 154 strncat(temp, "_", 1); | 154 strncat(temp, "_", 1); |
| 155 strncat(temp, args.input, 120); | 155 strncat(temp, args.input, 248); |
| 156 strcpy(temp, strremove(temp, strrchr(args.input, ('.')))); /* remove file extension */ | 156 strcpy(temp, strremove(temp, strrchr(args.input, ('.')))); /* remove file extension */ |
| 157 strncat(temp, ".", 1); | 157 strncat(temp, ".", 1); |
| 158 strncat(temp, args.type, 3); | 158 strncat(temp, args.type, 3); |
| 159 strncpy(args.output, temp, 127); | 159 strncpy(args.output, temp, 255); |
| 160 } | 160 } |
| 161 if (strcmp(args.type, "veg") == 0) { | 161 if (strcmp(args.type, "veg") == 0) { |
| 162 const unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A}; | 162 const unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A}; |
| 163 for (option_index = 0; option_index <= 15; option_index++) { | 163 for (option_index = 0; option_index <= 15; option_index++) { |
| 164 magic[option_index] = T[option_index]; | 164 magic[option_index] = T[option_index]; |
