Function wmain
LZNV SDK DLL Tester Main Function
LZNV SDK DLL Tester Main Function
wmain is a sample function that performs command line parameter manipulation.
int wmain(int argc, wchar_t **argv)
{
int32_t _res = 0;
#if(!defined _DEBUG)
if (SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS))
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
}
#endif
wprintf(L"\n LZNV DLL Tester v2.15!");
wprintf(L"\n Copyright (C) 2009-2029 ZAXAO CORPORATION TX, USA");
wprintf(L"\n Copyright (C) 2009-2029 NetLUP Xtreme Technologies srl");
wprintf(L"\n Designed, developed and implemented in TX, USA by ZAXAO CORPORATION\n");
wprintf(L"\n Visit us at https://www.zaxao.com");
wprintf(L"\n\n Running in 64bit mode");
if (argc < 2)
{
wprintf(L"\n\n USAGE: LZNV DLL Tester v2.15c <command> <memory> <options> file_in file_out");
wprintf(L"\n\t command: e/d = encode/decode");
wprintf(L"\n\t memory: -t0..6 = memory level | 0=256KiB, 1=512KiB, 2=1MiB, 3=2MiB, 4=4MiB, 5=8MiB, 6=16MiB");
wprintf(L"\n\t options: -m0..3 = compression method | 0=HyperFast, 1=SuperFast, 2=Fast, 3=Normal\n\n");
return 1;
}
uint8_t encode = 0x00;
uint8_t decode = 0x00;
uint8_t test = 0x00; // performs encoding and decoding
uint8_t _encoding_method = 0x00;
uint8_t _tbl_size = 0x00;
uint8_t _ultraFast = 0x00;
uint8_t _lz_verification = 0x00; // performs internal verification
uint8_t _exe_compression = 0x00;
uint8_t _solid_compression = 0x01;
int64_t fileSize = 0x00ULL;
int32_t _argc = 1;
while (_argc < argc)
{
if ((argv[_argc][0] == 'e') && (argv[_argc][1] == 0))
{
encode = 1;
++_argc;
continue;
}
else
if ((argv[_argc][0] == 'd') && (argv[_argc][1] == 0))
{
decode = 1;
++_argc;
continue;
}
else
if ((argv[_argc][0] == 't') && (argv[_argc][1] == 0))
{
test = 1;
++_argc;
continue;
}
else
if (argv[_argc][0] == '-')
{
if (argv[_argc][1] == 't')
{
_tbl_size = (int8_t)(argv[_argc][2] - '0');
++_argc;
continue;
}
if (argv[_argc][1] == 'm')
{
if(((argv[_argc][2] - '0') < _LZNV_MAX_LZ_ALGORITHMS) && ((argv[_argc][2] - '0') >= _LZNV_ULTRAFAST_COMPRESSION)) {
_encoding_method = _LZNV_ULTRAFAST_COMPRESSION + (int8_t)(argv[_argc][2] - '0');
++_argc;
continue;
}
else
if(((argv[_argc][2] - 'a') < _LZNV_MAX_ENTROPY_ALGORITHMS) && ((argv[_argc][2] - 'a') >= 0)) {
_encoding_method = _LZNV_COMPRESSION_STORE + (int8_t)(argv[_argc][2] - 'a');
++_argc;
continue;
}
wprintf(L"\n Unknown compression method '%s'! Exiting!\n", argv[_argc]);
return 1;
}
if (argv[_argc][1] == 'v')
{
_lz_verification = 0x01;
++_argc;
continue;
}
}
else
{
break;
}
++_argc;
}
_res = _loadDLL();
if (NO_ERROR != _res)
{
return 1;
}
_test_encode_decode_buffer();
if ((encode == 0) && (decode == 0))
{
wprintf(L"\n USAGE: LZNV DLL Tester v2.9315c. Parsing folder: %s", argv[1]);
if(NO_ERROR == _register_folder_recursively(argv[1]))
{
_test_recursively();
}
}
else
{
const wchar_t* _wchr_file_in = argv[_argc];
const wchar_t* _wchr_file_out = argv[_argc + 1];
ASSERT(_wchr_file_in);
ASSERT(_wchr_file_out);
if (!_wchr_file_in || !_wchr_file_out) {
wprintf(L"\n Unable to open input or output file(s)! Please check...\n Exiting!\n\n");
return 1;
}
if(encode)
{
_res = LZNV_Encode_File(_encoding_method, _tbl_size % _MAX_TABLE_SIZES_, _wchr_file_in, _wchr_file_out);
_res = LZNV_Encode_File_wBuffer(_encoding_method, _tbl_size % _MAX_TABLE_SIZES_, 0, _wchr_file_in, L"_tmppp.lznv_buffer");
// Now compare the files
_res = _compare_files(_wchr_file_out, L"_tmppp.lznv_buffer");
}
if(decode)
{
_res = LZNV_Decode_File(_encoding_method, _wchr_file_in, _wchr_file_out);
_res = LZNV_Decode_File_wBuffer(_wchr_file_in, LZNV_TMP_BUFFER_ORIG);
// Now compare the files
_res = _compare_files(_wchr_file_in, LZNV_TMP_BUFFER_ORIG);
}
}
_unLoadDLL();
wprintf(L"\n Done!\nThank you for using LZNV DLL Tester!\n\n");
return _res;
}