Mercurial > msvpvf
comparison src/main.c @ 16:8bcb6a2d3def
CLI version: use switch statement instead of generic if else... may give us performance benefit??
| author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
|---|---|
| date | Fri, 11 Mar 2022 03:41:20 -0500 |
| parents | a4e604789e2e |
| children | d873a04165f9 |
comparison
equal
deleted
inserted
replaced
| 15:69e9cd8817a7 | 16:8bcb6a2d3def |
|---|---|
| 18 }; | 18 }; |
| 19 | 19 |
| 20 char* strremove(char* str, const char* sub) { | 20 char* strremove(char* str, const char* sub) { |
| 21 size_t len = strlen(sub); | 21 size_t len = strlen(sub); |
| 22 if (len > 0) { | 22 if (len > 0) { |
| 23 char *p = str; | 23 char* p = str; |
| 24 while ((p = strstr(p, sub)) != NULL) { | 24 while ((p = strstr(p, sub)) != NULL) { |
| 25 memmove(p, p + len, strlen(p + len) + 1); | 25 memmove(p, p + len, strlen(p + len) + 1); |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 return str; | 28 return str; |
| 122 fseek(input_file, 0x46, SEEK_SET); | 122 fseek(input_file, 0x46, SEEK_SET); |
| 123 printf("Input file version: %d\n", fgetc(input_file)); | 123 printf("Input file version: %d\n", fgetc(input_file)); |
| 124 fseek(input_file, 0x18, SEEK_SET); | 124 fseek(input_file, 0x18, SEEK_SET); |
| 125 int file_version = fgetc(input_file); | 125 int file_version = fgetc(input_file); |
| 126 printf("Input file type: "); | 126 printf("Input file type: "); |
| 127 if (file_version == 0xEF) { | 127 switch (file_version) { |
| 128 printf("VEGAS Pro\n\n"); | 128 case 0xEF: |
| 129 } else if (file_version == 0xF6) { | 129 printf("VEGAS Pro\n\n"); |
| 130 printf("Movie Studio\n\n"); | 130 break; |
| 131 } else { | 131 case 0xF6: |
| 132 printf("Unknown\n\n"); | 132 printf("Movie Studio\n\n"); |
| 133 break; | |
| 134 default: | |
| 135 printf("Unknown\n\n"); | |
| 136 break; | |
| 133 } | 137 } |
| 134 int* ptr = &args.version; | 138 int* ptr = &args.version; |
| 135 if (args.version == -1) { | 139 if (args.version == -1) { |
| 136 printf("What version of VEGAS would you like to spoof to?: "); | 140 printf("What version of VEGAS would you like to spoof to?: "); |
| 137 fflush(stdout); | 141 fflush(stdout); |
| 155 strncat(temp, args.type, 3); | 159 strncat(temp, args.type, 3); |
| 156 strncpy(args.output, temp, 255); | 160 strncpy(args.output, temp, 255); |
| 157 } | 161 } |
| 158 if (strcmp(args.type, "veg") == 0) { | 162 if (strcmp(args.type, "veg") == 0) { |
| 159 const unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A}; | 163 const unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A}; |
| 160 for (option_index = 0; option_index <= 15; option_index++) { | 164 for (option_index = 0; option_index <= 15; option_index++) { /* this line is repeated, but it's probably best to just leave it be. */ |
| 161 magic[option_index] = T[option_index]; | 165 magic[option_index] = T[option_index]; |
| 162 } | 166 } |
| 163 } else if (strcmp(args.type, "vf") == 0) { | 167 } else if (strcmp(args.type, "vf") == 0) { |
| 164 const unsigned char T[] = {0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43, 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F}; | 168 const unsigned char T[] = {0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43, 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F}; |
| 165 for (option_index = 0; option_index <= 15; option_index++) { | 169 for (option_index = 0; option_index <= 15; option_index++) { |
| 168 } else { | 172 } else { |
| 169 fprintf(stderr, "Type %s is invalid!", args.type); | 173 fprintf(stderr, "Type %s is invalid!", args.type); |
| 170 return 1; | 174 return 1; |
| 171 } | 175 } |
| 172 copy_file(args.input, args.output); | 176 copy_file(args.input, args.output); |
| 173 #ifdef _WIN32 | 177 #ifdef _WIN32 /* disallowed characters in filenames */ |
| 174 if (strcspn(args.input, "<>:\"/\\|?*") == strlen(args.input)+1) { | 178 if (strcspn(args.input, "<>:\"/\\|?*") == strlen(args.input)+1) { |
| 175 #elif defined(__unix__) | 179 #elif defined(__unix__) |
| 176 if (strcspn(args.input, "/") == strlen(args.input)+1) { | 180 if (strcspn(args.input, "/") == strlen(args.input)+1) { |
| 177 #else | 181 #else |
| 178 if (NULL) { | 182 if (NULL) { |
