2
Fork 0

feat: Add argument to check library

This mode allows checking if the DLL can be found, without having to
create any kind of dummy data or parse stderr.
This commit is contained in:
Lucas Schwiderski 2022-10-20 17:43:14 +02:00
parent 7c74a3e786
commit a615ae0354
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -30,6 +30,7 @@ void usage() {
"\n" "\n"
"Options:\n" "Options:\n"
" -v Increase Oodle's verbosity. May be specified up to three times.\n" " -v Increase Oodle's verbosity. May be specified up to three times.\n"
" -c Only check if the library can be found and used.\n"
"\n" "\n"
"The following environmental variables are recognized:\n" "The following environmental variables are recognized:\n"
" DLL_SEARCH_PATH: A color (':') separated list of directories to search for the Oodle library. May be relative to the current working directory.\n"; " DLL_SEARCH_PATH: A color (':') separated list of directories to search for the Oodle library. May be relative to the current working directory.\n";
@ -38,6 +39,7 @@ void usage() {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int verbosity = 0; int verbosity = 0;
bool check_lib = FALSE;
int i = 1; int i = 1;
for (; i < argc; i++) { for (; i < argc; i++) {
@ -51,6 +53,9 @@ int main(int argc, char* argv[])
usage(); usage();
return 0; return 0;
} }
else if (strcmp(arg, "-c") == 0) {
check_lib = TRUE;
}
else if (strcmp(arg, "-v") == 0) { else if (strcmp(arg, "-v") == 0) {
verbosity++; verbosity++;
} }
@ -96,12 +101,16 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
auto decompress = (decltype(OodleLZ_Decompress)*)GetProcAddress((HMODULE)hDLL, "OodleLZ_Decompress"); auto decompress = reinterpret_cast<decompress_func>(GetProcAddress((HMODULE)hDLL, "OodleLZ_Decompress"));
if (decompress == NULL) { if (decompress == NULL) {
std::cerr << "ERROR: The library is incompatible!\n"; std::cerr << "ERROR: The library is incompatible!\n";
return 1; return 1;
} }
if (check_lib) {
std::cout << "INFO: '" << LIB_FILE << "' found and loaded.\n";
return 0;
}
if (argc - i < 3) { if (argc - i < 3) {
std::cerr << "ERROR: Arguments missing!\n\n"; std::cerr << "ERROR: Arguments missing!\n\n";