Compare commits
1 commit
synthxex-0
...
main
Author | SHA1 | Date | |
---|---|---|---|
ea64ac981c |
1 changed files with 77 additions and 76 deletions
61
src/main.c
61
src/main.c
|
@ -164,13 +164,13 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
static struct option longOptions[] =
|
static struct option longOptions[] =
|
||||||
{
|
{
|
||||||
{ "help", no_argument, 0, 0 },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ "version", no_argument, 0, 0 },
|
{ "version", no_argument, 0, 'v' },
|
||||||
{ "libs", no_argument, 0, 0 },
|
{ "libs", no_argument, 0, 'l' },
|
||||||
{ "skip-machine-check", no_argument, 0, 0 },
|
{ "skip-machine-check", no_argument, 0, 's' },
|
||||||
{ "input", required_argument, 0, 0 },
|
{ "input", required_argument, 0, 'i' },
|
||||||
{ "output", required_argument, 0, 0 },
|
{ "output", required_argument, 0, 'o' },
|
||||||
{ "type", required_argument, 0, 0 },
|
{ "type", required_argument, 0, 't' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,34 +202,26 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
while((option = getopt_long(argc, argv, "hvlsi:o:t:", longOptions, &optIndex)) != -1)
|
while((option = getopt_long(argc, argv, "hvlsi:o:t:", longOptions, &optIndex)) != -1)
|
||||||
{
|
{
|
||||||
if(option == 'h' || option == '?' || (option == 0 && strcmp(longOptions[optIndex].name, "help") == 0))
|
switch(option)
|
||||||
{
|
|
||||||
dispHelp(argv);
|
|
||||||
freeAllMainStructs(&offsets, &xexHeader, &secInfoHeader, &peData,
|
|
||||||
&optHeaderEntries, &optHeaders);
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
else if(option == 'v' || (option == 0 && strcmp(longOptions[optIndex].name, "version") == 0))
|
|
||||||
{
|
{
|
||||||
|
case 'v':
|
||||||
dispVer();
|
dispVer();
|
||||||
freeAllMainStructs(&offsets, &xexHeader, &secInfoHeader, &peData,
|
freeAllMainStructs(&offsets, &xexHeader, &secInfoHeader, &peData,
|
||||||
&optHeaderEntries, &optHeaders);
|
&optHeaderEntries, &optHeaders);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
|
||||||
else if(option == 'l' || (option == 0 && strcmp(longOptions[optIndex].name, "libs") == 0))
|
case 'l':
|
||||||
{
|
|
||||||
dispLibs();
|
dispLibs();
|
||||||
freeAllMainStructs(&offsets, &xexHeader, &secInfoHeader, &peData,
|
freeAllMainStructs(&offsets, &xexHeader, &secInfoHeader, &peData,
|
||||||
&optHeaderEntries, &optHeaders);
|
&optHeaderEntries, &optHeaders);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
|
||||||
else if(option == 's' || (option == 0 && strcmp(longOptions[optIndex].name, "skip-machine-check") == 0))
|
case 's':
|
||||||
{
|
|
||||||
printf("%s WARNING: Skipping machine ID check.\n", SYNTHXEX_PRINT_STEM);
|
printf("%s WARNING: Skipping machine ID check.\n", SYNTHXEX_PRINT_STEM);
|
||||||
skipMachineCheck = true;
|
skipMachineCheck = true;
|
||||||
}
|
break;
|
||||||
else if(option == 'i' || (option == 0 && strcmp(longOptions[optIndex].name, "input") == 0))
|
|
||||||
{
|
case 'i':
|
||||||
gotInput = true;
|
gotInput = true;
|
||||||
pePath = malloc(strlen(optarg) + 1);
|
pePath = malloc(strlen(optarg) + 1);
|
||||||
|
|
||||||
|
@ -243,9 +235,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pePath, optarg);
|
strcpy(pePath, optarg);
|
||||||
}
|
break;
|
||||||
else if(option == 'o' || (option == 0 && strcmp(longOptions[optIndex].name, "output") == 0))
|
|
||||||
{
|
case 'o':
|
||||||
gotOutput = true;
|
gotOutput = true;
|
||||||
xexfilePath = malloc(strlen(optarg) + 1);
|
xexfilePath = malloc(strlen(optarg) + 1);
|
||||||
|
|
||||||
|
@ -259,9 +251,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(xexfilePath, optarg);
|
strcpy(xexfilePath, optarg);
|
||||||
}
|
break;
|
||||||
else if(option == 't' || (option == 0 && strcmp(longOptions[optIndex].name, "type") == 0))
|
|
||||||
{
|
case 't':
|
||||||
if(strcmp(optarg, "title") == 0)
|
if(strcmp(optarg, "title") == 0)
|
||||||
{ xexHeader->moduleFlags = XEX_MOD_FLAG_TITLE; }
|
{ xexHeader->moduleFlags = XEX_MOD_FLAG_TITLE; }
|
||||||
else if(strcmp(optarg, "titledll") == 0)
|
else if(strcmp(optarg, "titledll") == 0)
|
||||||
|
@ -281,6 +273,15 @@ int main(int argc, char **argv)
|
||||||
&optHeaderEntries, &optHeaders);
|
&optHeaderEntries, &optHeaders);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
default:
|
||||||
|
dispHelp(argv);
|
||||||
|
freeAllMainStructs(&offsets, &xexHeader, &secInfoHeader, &peData,
|
||||||
|
&optHeaderEntries, &optHeaders);
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue