downloadertools: remove check_adler, check_md5, check_crc

Tools to check hashes are readily available from thirdparty sources; there is no good reason why a 3D engine should provide them.
This commit is contained in:
rdb 2019-09-06 11:55:17 +02:00
parent 13e91135e5
commit 2e198fd2ef
5 changed files with 1 additions and 227 deletions

View File

@ -4603,23 +4603,7 @@ if PkgSkip("OPENAL") == 0 and not RUNTIME:
#
if (PkgSkip("OPENSSL")==0 and not RTDIST and not RUNTIME and PkgSkip("DEPLOYTOOLS")==0):
OPTS=['DIR:panda/src/downloadertools', 'OPENSSL', 'ZLIB', 'ADVAPI', 'WINSOCK2', 'WINSHELL', 'WINGDI', 'WINUSER']
if not PkgSkip("ZLIB"):
TargetAdd('check_adler_check_adler.obj', opts=OPTS, input='check_adler.cxx')
TargetAdd('check_adler.exe', input=['check_adler_check_adler.obj'])
TargetAdd('check_adler.exe', input=COMMON_PANDA_LIBS)
TargetAdd('check_adler.exe', opts=OPTS)
TargetAdd('check_crc_check_crc.obj', opts=OPTS, input='check_crc.cxx')
TargetAdd('check_crc.exe', input=['check_crc_check_crc.obj'])
TargetAdd('check_crc.exe', input=COMMON_PANDA_LIBS)
TargetAdd('check_crc.exe', opts=OPTS)
TargetAdd('check_md5_check_md5.obj', opts=OPTS, input='check_md5.cxx')
TargetAdd('check_md5.exe', input=['check_md5_check_md5.obj'])
TargetAdd('check_md5.exe', input=COMMON_PANDA_LIBS)
TargetAdd('check_md5.exe', opts=OPTS)
OPTS=['DIR:panda/src/downloadertools', 'OPENSSL', 'ADVAPI', 'WINSOCK2', 'WINSHELL', 'WINGDI', 'WINUSER']
TargetAdd('pdecrypt_pdecrypt.obj', opts=OPTS, input='pdecrypt.cxx')
TargetAdd('pdecrypt.exe', input=['pdecrypt_pdecrypt.obj'])

View File

@ -2080,12 +2080,9 @@
</Filter>
<Filter Name="downloadertools">
<File RelativePath="..\panda\src\downloadertools\pencrypt.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\check_adler.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\pdecrypt.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\pzip.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\multify.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\check_md5.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\check_crc.cxx"></File>
<File RelativePath="..\panda\src\downloadertools\punzip.cxx"></File>
</Filter>
<Filter Name="gles2gsg">

View File

@ -1,26 +0,0 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file check_adler.cxx
*/
#include "download_utils.h"
int
main(int argc, char *argv[]) {
if (argc < 2) {
std::cerr << "Usage: check_adler <file>" << std::endl;
return 1;
}
Filename source_file = argv[1];
std::cout << check_adler(source_file);
return 0;
}

View File

@ -1,26 +0,0 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file check_crc.cxx
*/
#include "download_utils.h"
int
main(int argc, char *argv[]) {
if (argc < 2) {
std::cerr << "Usage: check_crc <file>" << std::endl;
return 1;
}
Filename source_file = argv[1];
std::cout << check_crc(source_file);
return 0;
}

View File

@ -1,155 +0,0 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file check_md5.cxx
*/
#include "pandabase.h"
#include "hashVal.h"
#include "filename.h"
#include "panda_getopt.h"
#include "preprocess_argv.h"
using std::cerr;
using std::cout;
bool output_decimal = false;
bool suppress_filename = false;
pofstream binary_output;
void
usage() {
cerr <<
"\n"
"Usage:\n\n"
"check_md5 [-q] [-d] [-b filename] [-i \"input string\"] [file1 file2 ...]\n"
"check_md5 -h\n\n";
}
void
help() {
usage();
cerr <<
"This program outputs the MD5 hash of one or more files (or of a string\n"
"passed on the command line with -i).\n\n"
"An MD5 hash is a 128-bit value. The output is presented as a 32-digit\n"
"hexadecimal string by default, but with -d, it is presented as four\n"
"big-endian unsigned 32-bit decimal integers. Normally the filename\n"
"of each file is printed along with the hash; -q suppresses this.\n\n"
"To write the 16 bytes (per input file) of the output directly to a\n"
"binary file, use -b with the name of the file to receive the output.\n";
}
void
output_hash(const std::string &filename, const HashVal &hash) {
if (!suppress_filename && !filename.empty()) {
cout << filename << " ";
}
if (output_decimal) {
hash.output_dec(cout);
} else {
hash.output_hex(cout);
}
cout << "\n";
// Also output to the binary_output file if it is open. No sweat if it's
// not.
hash.output_binary(binary_output);
}
int
main(int argc, char **argv) {
extern char *optarg;
extern int optind;
const char *optstr = "i:db:qh";
bool got_input_string = false;
std::string input_string;
Filename binary_output_filename;
preprocess_argv(argc, argv);
int flag = getopt(argc, argv, optstr);
while (flag != EOF) {
switch (flag) {
case 'i':
got_input_string = true;
input_string = optarg;
break;
case 'd':
output_decimal = true;
break;
case 'b':
binary_output_filename = Filename::binary_filename(std::string(optarg));
break;
case 'q':
suppress_filename = true;
break;
case 'h':
help();
exit(1);
default:
exit(1);
}
flag = getopt(argc, argv, optstr);
}
argc -= (optind-1);
argv += (optind-1);
if (argc < 2 && !got_input_string) {
usage();
exit(1);
}
if (!binary_output_filename.empty()) {
if (!binary_output_filename.open_write(binary_output)) {
cerr << "Unable to open " << binary_output_filename << ".\n";
exit(1);
}
}
if (got_input_string) {
HashVal hash;
hash.hash_string(input_string);
output_hash("", hash);
}
bool okflag = true;
for (int i = 1; i < argc; i++) {
Filename source_file = Filename::from_os_specific(argv[i]);
if (!source_file.exists()) {
cerr << source_file << " not found!\n";
okflag = false;
} else {
HashVal hash;
if (!hash.hash_file(source_file)) {
cerr << "Unable to read " << source_file << "\n";
okflag = false;
} else {
output_hash(source_file.get_basename(), hash);
}
}
}
if (!okflag) {
exit(1);
}
return 0;
}