00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "checkup.h"
00016
00017 #include <basis/function.h>
00018 #include <basis/guards.h>
00019 #include <basis/istring.h>
00020 #include <basis/portable.h>
00021 #include <basis/version_record.h>
00022 #include <opsystem/application_shell.h>
00023 #include <loggers/console_logger.h>
00024 #include <data_struct/static_memory_gremlin.h>
00025
00026 #include <stdio.h>
00027
00028 using namespace portable;
00029 using namespace system_checkup;
00030
00031 class checkup_on_OS : public application_shell
00032 {
00033 public:
00034 checkup_on_OS() : application_shell(static_class_name()) {}
00035 IMPLEMENT_CLASS_NAME("checkup_on_OS");
00036 virtual int execute();
00037 };
00038
00039 class burpee
00040 {
00041 public:
00042 burpee() : my_string(new istring) { *my_string = "balrog"; }
00043 virtual ~burpee() {
00044 WHACK(my_string);
00045 if (my_string) deadly_error("burpee", "whack test", "whack failed");
00046 }
00047
00048 private:
00049 istring *my_string;
00050 };
00051
00053
00054 class florba : public burpee
00055 {
00056 public:
00057 florba() : burpee(), second_string(new istring)
00058 { *second_string = "loquacious"; }
00059 virtual ~florba() {
00060 WHACK(second_string);
00061 if (second_string) deadly_error("florba", "whack test", "whack failed");
00062 }
00063
00064 private:
00065 istring *second_string;
00066 };
00067
00069
00070 struct testing_file_struct : public FILE {};
00071
00072
00073
00074
00075
00076 int checkup_on_OS::execute()
00077 {
00078
00079 log(istring("The name of this software system is: ")
00080 + software_product_name());
00081
00082
00083 log(istring("The application is called: ") + portable::application_name());
00084
00085
00086 #if 0
00087
00088 for (int q = 0; q < 19823; q++) {
00089 int treno = q;
00090 int malfoy = treno * 3;
00091 log(isprintf("%d", malfoy));
00092 }
00093
00094
00095 if (q > 19824) {
00096 log("some kind of weirdness happened.");
00097 }
00098
00099 #endif
00100
00101
00102 burpee *chunko = new burpee;
00103 florba *lorkas = new florba;
00104 burpee *alias = lorkas;
00105
00106 WHACK(chunko);
00107 WHACK(alias);
00108 if (chunko) deadly_error("chunko", "whack test", "whack failed");
00109 if (alias) deadly_error("lorkas", "whack test", "whack failed");
00110
00111 if (sizeof(testing_file_struct) != sizeof(FILE))
00112 deadly_error("test_checkup", "struct size test",
00113 "sizeof testing_file_struct and sizeof FILE differ");
00114
00115
00116 istring message;
00117 if (check_system_characteristics())
00118 message = istring(class_name()) + ":: the required characteristics "
00119 "seem present.";
00120 else
00121 message = istring(class_name()) + ":: at least one required "
00122 "characteristic is absent!!";
00123
00124 #ifdef __WIN32__
00125 known_operating_systems os = determine_OS();
00126 if (os == WIN_95)
00127 printf("This is windows 95.\n");
00128 else if (os == WIN_NT)
00129 printf("This is windows NT.\n");
00130 else if (os == WIN_2K)
00131 printf("This is windows 2000.\n");
00132 else if (os == WIN_XP)
00133 printf("This is windows XP.\n");
00134 else
00135 printf("This OS is unknown.\n");
00136 #endif
00137
00138 version os_ver = portable::get_OS_version();
00139 printf("The stated OS version number is: %s\n", os_ver.text_form().s());
00140
00141 guards::alert_message(message.s());
00142 return 0;
00143 }
00144
00145 HOOPLE_MAIN(checkup_on_OS, )
00146