00001 /*****************************************************************************\ 00002 * * 00003 * Name : show_versions * 00004 * Author : Chris Koeritz * 00005 * * 00006 * Purpose: * 00007 * * 00008 * Accepts a directory location on the command line and shows the versions * 00009 * of all executables and dynamic libraries in that directory. * 00010 * * 00011 ******************************************************************************* 00012 * Copyright (c) 2001-$now By Author. This program is free software; you can * 00013 * redistribute it and/or modify it under the terms of the GNU General Public * 00014 * License as published by the Free Software Foundation; either version 2 of * 00015 * the License or (at your option) any later version. This is online at: * 00016 * http://www.fsf.org/copyleft/gpl.html * 00017 * Please send any updates to: fred@gruntose.com * 00018 \*****************************************************************************/ 00019 00020 #include <basis/istring.h> 00021 #include <basis/string_array.h> 00022 #include <basis/version_checker.h> 00023 #include <basis/version_record.h> 00024 #include <loggers/console_logger.h> 00025 #include <opsystem/directory.h> 00026 #include <opsystem/filename.h> 00027 #include <data_struct/static_memory_gremlin.h> 00028 00029 HOOPLE_STARTUP_CODE; 00030 00031 console_logger out; 00032 00033 int instruct(const char *program_name) 00034 { 00035 out.log(filename(program_name).rootname() + " usage:\n\ 00036 The first parameter is taken as a directory to show versions in.\n\ 00037 That directory must exist for the utility to work properly.\n\ 00038 If there is a second parameter, it is taken as a version that\n\ 00039 is expected for all files in the directory. Any that are showing\n\ 00040 the wrong version are reported."); 00041 return 1; 00042 } 00043 00044 int main(int argc, char *argv[]) 00045 { 00046 #ifdef __WIN32__ 00047 if (argc < 2) return instruct(argv[0]); 00048 directory the_files(argv[1]); 00049 if (!the_files.good()) return instruct(argv[0]); 00050 version compare_with; 00051 if (argc >= 3) 00052 compare_with = version::from_text(argv[2]); 00053 if (!compare_with.bogus()) { 00054 out.log("Bad Version Report"); 00055 out.log("=================="); 00056 } 00057 bool any_bad = false; 00058 for (int i = 0; i < the_files.files().length(); i++) { 00059 const istring &curr = the_files.files()[i]; 00060 int len = curr.length(); 00061 istring end = curr.substring(len - 3, len - 1).lower(); 00062 if ( (end == "dll") || (end == "exe") ) { 00063 filename full(argv[1], curr); 00064 version found = version_checker::get_version(full); 00065 if (compare_with.bogus()) { 00066 // just print out all the versions. 00067 out.log(full.raw() + " -- " + found.text_form()); 00068 } else { 00069 // only flag versions that are erroneous. 00070 if (compare_with != found) { 00071 out.log(full.raw() + " has version " + found.text_form() + "!"); 00072 any_bad = true; 00073 } 00074 } 00075 } 00076 } 00077 if (!compare_with.bogus() && !any_bad) { 00078 out.log(" zero bad versions detected."); 00079 } 00080 #else 00081 char *arg2 = argv[argc-1]; 00082 if (arg2) {} 00083 #endif 00084 return 0; 00085 } 00086 00087 #ifdef __BUILD_STATIC_APPLICATION__ 00088 // static dependencies found by buildor_gen_deps.sh: 00089 #include <basis/array.cpp> 00090 #include <basis/byte_array.cpp> 00091 #include <basis/callstack_tracker.cpp> 00092 #include <basis/chaos.cpp> 00093 #include <basis/convert_utf.cpp> 00094 #include <basis/definitions.cpp> 00095 #include <basis/earth_time.cpp> 00096 #include <basis/guards.cpp> 00097 #include <basis/istring.cpp> 00098 #include <basis/log_base.cpp> 00099 #include <basis/memory_checker.cpp> 00100 #include <basis/mutex.cpp> 00101 #include <basis/object_base.cpp> 00102 #include <basis/outcome.cpp> 00103 #include <basis/packable.cpp> 00104 #include <basis/portable.cpp> 00105 #include <basis/sequence.cpp> 00106 #include <basis/set.cpp> 00107 #include <basis/utility.cpp> 00108 #include <basis/version_checker.cpp> 00109 #include <basis/version_record.cpp> 00110 #include <data_struct/amorph.cpp> 00111 #include <data_struct/bit_vector.cpp> 00112 #include <data_struct/byte_hasher.cpp> 00113 #include <data_struct/configurator.cpp> 00114 #include <data_struct/hash_table.cpp> 00115 #include <data_struct/pointer_hash.cpp> 00116 #include <data_struct/stack.cpp> 00117 #include <data_struct/static_memory_gremlin.cpp> 00118 #include <data_struct/string_hash.cpp> 00119 #include <data_struct/string_hasher.cpp> 00120 #include <data_struct/string_table.cpp> 00121 #include <data_struct/symbol_table.cpp> 00122 #include <data_struct/table_configurator.cpp> 00123 #include <loggers/console_logger.cpp> 00124 #include <loggers/file_logger.cpp> 00125 #include <loggers/locked_logger.cpp> 00126 #include <loggers/null_logger.cpp> 00127 #include <loggers/program_wide_logger.cpp> 00128 #include <opsystem/byte_filer.cpp> 00129 #include <opsystem/command_line.cpp> 00130 #include <opsystem/critical_events.cpp> 00131 #include <opsystem/directory.cpp> 00132 #include <opsystem/filename.cpp> 00133 #include <opsystem/ini_config.cpp> 00134 #include <opsystem/ini_parser.cpp> 00135 #include <opsystem/path_configuration.cpp> 00136 #include <opsystem/rendezvous.cpp> 00137 #include <textual/byte_format.cpp> 00138 #include <textual/parser_bits.cpp> 00139 #include <textual/string_manipulation.cpp> 00140 #include <textual/tokenizer.cpp> 00141 #endif // __BUILD_STATIC_APPLICATION__ 00142
1.5.1