From: Fred T. Hamster Date: Sun, 15 Feb 2026 02:03:23 +0000 (-0500) Subject: cromp decoder and test cromp client compiling X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=8ac194fa63043a1e0279a9a9c2a00e430dad73b6;p=feisty_meow.git cromp decoder and test cromp client compiling --- diff --git a/octopi/library/tests_cromp/cromp_decoder.cpp b/octopi/library/tests_cromp/cromp_decoder.cpp index 6e9ff9e6..1355f9ba 100644 --- a/octopi/library/tests_cromp/cromp_decoder.cpp +++ b/octopi/library/tests_cromp/cromp_decoder.cpp @@ -12,25 +12,43 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ -#include +#include +#include +#include #include -#include -#include +#include #include #include -#include +#include #include -#include +#include +#include +#include #include -#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s) -#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger(), s) +using namespace application; +using namespace basis; +using namespace configuration; +using namespace cromp; +using namespace mathematics; +using namespace filesystem; +using namespace loggers; +using namespace octopi; +using namespace processes; +using namespace sockets; +using namespace structures; +using namespace textual; +using namespace timely; +using namespace unit_test; + +#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s)) +#define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger::get(), astring(s)) const int MAX_LINE = 2048; // the longest line we'll bother to try to process. -class cromp_decoder : public application_shell +class cromp_decoder : virtual public unit_base, virtual public application_shell { public: cromp_decoder(); @@ -38,12 +56,12 @@ public: virtual int execute(); - IMPLEMENT_CLASS_NAME("cromp_decoder"); + DEFINE_CLASS_NAME("cromp_decoder"); }; -//////////////////////////////////////////////////////////////////////////// +////////////// -cromp_decoder::cromp_decoder() : application_shell(class_name()) {} +cromp_decoder::cromp_decoder() : application_shell() {} cromp_decoder::~cromp_decoder() {} @@ -56,12 +74,12 @@ This application will decode a cromp entity and report the different values"); BASE_LOG("\ that are encoded into it."); - istring buffer; // we'll read input from the user into this. + astring buffer; // we'll read input from the user into this. while (true) { BASE_LOG("Please enter the entity (or hit just enter to exit).") - buffer = istring('\0', MAX_LINE + 10); // reset the buffer. + buffer = astring('\0', MAX_LINE + 10); // reset the buffer. char *buf2 = fgets(buffer.s(), MAX_LINE, stdin); if (buf2 != buffer.s()) { deadly_error(class_name(), func, @@ -69,7 +87,7 @@ that are encoded into it."); } buffer.shrink(); - buffer.strip("\r\n", istring::FROM_END); + buffer.strip("\r\n", astring::FROM_END); if (!buffer.length()) break; // make sure they didn't actually give us a request id. @@ -87,26 +105,26 @@ that are encoded into it."); BASE_LOG(""); BASE_LOG("Entity contains:"); BASE_LOG(""); - BASE_LOG(isprintf("\tProcess ID=%d", ent.process_id())); - BASE_LOG(isprintf("\tSequencer=%d", ent.sequencer())); - BASE_LOG(isprintf("\tChaotic Addin=%d", ent.add_in())); + BASE_LOG(a_sprintf("\tProcess ID=%d", ent.process_id())); + BASE_LOG(a_sprintf("\tSequencer=%d", ent.sequencer())); + BASE_LOG(a_sprintf("\tChaotic Addin=%d", ent.add_in())); - istring host; + astring host; machine_uid machine; bool worked = cromp_common::decode_host(ent.hostname(), host, machine); if (!worked) { BASE_LOG("Failed to decode the hostname! Was it a valid entity?"); continue; } - BASE_LOG(istring("\tPartial Hostname=") + host); - BASE_LOG(istring("\tMachine UID=") + machine.text_form()); + BASE_LOG(astring("\tPartial Hostname=") + host); + BASE_LOG(astring("\tMachine UID=") + machine.text_form()); BASE_LOG(""); } return 0; } -//////////////////////////////////////////////////////////////////////////// +////////////// HOOPLE_MAIN(cromp_decoder, ) diff --git a/octopi/library/tests_cromp/crompish_pax.h b/octopi/library/tests_cromp/crompish_pax.h index 5634e591..03b35fa5 100644 --- a/octopi/library/tests_cromp/crompish_pax.h +++ b/octopi/library/tests_cromp/crompish_pax.h @@ -20,19 +20,16 @@ \*****************************************************************************/ #include -#include #include #include #include #include -using namespace geometric; - class bubble : public octopi::infoton { public: - bubble(int data_segment_size = 0, const screen_rectangle &boundaries - = screen_rectangle(), int color = 0) + bubble(int data_segment_size = 0, const structures::string_array &boundaries + = structures::string_array(), int color = 0) // constructs a bubble within the "boundaries" that has "color" and a data // segment size specified by "data_segment_size". the color definitions // reside elsewhere. @@ -45,7 +42,7 @@ public: return barray; } - void reset(int data_segment_size, const screen_rectangle &boundaries, + void reset(int data_segment_size, const structures::string_array &boundaries, int color) { _color = color; _bounds = boundaries; @@ -86,7 +83,7 @@ public: } private: - screen_rectangle _bounds; + structures::string_array _bounds; int _color; basis::byte_array _data; }; diff --git a/octopi/library/tests_cromp/makefile b/octopi/library/tests_cromp/makefile index a359a61e..48a19848 100644 --- a/octopi/library/tests_cromp/makefile +++ b/octopi/library/tests_cromp/makefile @@ -6,9 +6,9 @@ PROJECT = test_cromp TYPE = test TARGETS = test_cromp_client.exe test_cromp_server.exe test_many_cromp.exe LAST_TARGETS = create_decoder_ring -LOCAL_LIBS_USED = unit_test application configuration filesystem loggers \ - mathematics nodes octopi processes sockets structures textual timely \ - structures basis +LOCAL_LIBS_USED = unit_test crypto application configuration filesystem loggers \ + mathematics nodes processes sockets structures textual timely octopus cromp \ + tentacles structures basis USE_SSL = t #RUN_TARGETS = $(ACTUAL_TARGETS) diff --git a/octopi/library/tests_cromp/makefile.decoder b/octopi/library/tests_cromp/makefile.decoder index 564d3b33..82d48d01 100644 --- a/octopi/library/tests_cromp/makefile.decoder +++ b/octopi/library/tests_cromp/makefile.decoder @@ -5,7 +5,9 @@ include cpp/variables.def PROJECT = decoder_ring TYPE = application TARGETS = cromp_decoder.exe -LOCAL_LIBS_USED = basis +LOCAL_LIBS_USED = unit_test octopus cromp crypto application configuration filesystem loggers \ + mathematics nodes processes sockets structures textual timely \ + tentacles structures basis USE_SSL = t RUN_TARGETS = $(ACTUAL_TARGETS) diff --git a/octopi/library/tests_cromp/test_cromp_client.cpp b/octopi/library/tests_cromp/test_cromp_client.cpp index b8ed2613..b0bc262e 100644 --- a/octopi/library/tests_cromp/test_cromp_client.cpp +++ b/octopi/library/tests_cromp/test_cromp_client.cpp @@ -516,10 +516,13 @@ void cromp_client_tester::bite_server(structures::set &ids, double overall_sent = 0; +//hmmm: not very interesting boundaries below, non-randomized and identical in both places. + const char *bounds_init[] = { "0", "120", "220", "280" }; + string_array boundish(4, bounds_init); + // this computes the size of the exchange object with no extra data attached. byte_array temp; - bubble test_size(_dataseg_size, screen_rectangle(0, 120, 220, 280), - 238843); + bubble test_size(_dataseg_size, boundish, 238843); test_size.data().reset(); // set the data segment to zero length. test_size.pack(temp); @@ -531,8 +534,7 @@ void cromp_client_tester::bite_server(structures::set &ids, time_stamp start; // record when our testing started. for (int sends = 1; sends <= _send_count; sends++) { - bubble to_send(_dataseg_size, screen_rectangle(0, 120, 220, 280), - 238843); + bubble to_send(_dataseg_size, boundish, 238843); int curr_sending = to_send.data_length() + base_length * 2; overall_sent += curr_sending; // we compute the overall sent by what's sent in the request (which is diff --git a/octopi/library/tests_cromp/test_cromp_server.cpp b/octopi/library/tests_cromp/test_cromp_server.cpp index e2a5da92..be3db71b 100644 --- a/octopi/library/tests_cromp/test_cromp_server.cpp +++ b/octopi/library/tests_cromp/test_cromp_server.cpp @@ -15,23 +15,37 @@ #include "crompish_pax.h" #include -#include -#include -#include -#include +#include +#include #include -#include +#include #include -#include -#include +#include +#include #include #include -#include -#include +#include +#include #include #include - -#define LOG(a) CLASS_EMERGENCY_LOG(program_wide_logger(), a) +#include + +using namespace application; +using namespace basis; +using namespace configuration; +using namespace cromp; +using namespace mathematics; +using namespace filesystem; +using namespace loggers; +using namespace octopi; +using namespace processes; +using namespace sockets; +using namespace structures; +using namespace textual; +using namespace timely; +using namespace unit_test; + +#define LOG(a) CLASS_EMERGENCY_LOG(program_wide_logger::get(), a) const int REPORTING_INTERVAL = 28 * SECOND_ms; // how often to squawk. @@ -46,7 +60,7 @@ const bool SUPPORT_BACKGROUNDING = false; //const bool IMMEDIATE_EVALUATION = true; const bool IMMEDIATE_EVALUATION = false; -//////////////////////////////////////////////////////////////////////////// +////////////// // forward. class cromp_server_tester; @@ -60,15 +74,15 @@ public: ~our_cromp_server() {} - IMPLEMENT_CLASS_NAME("our_cromp_server"); + DEFINE_CLASS_NAME("our_cromp_server"); private: cromp_server_tester &_parent; }; -//////////////////////////////////////////////////////////////////////////// +////////////// -class cromp_server_tester : public application_shell +class cromp_server_tester : virtual public unit_base, virtual public application_shell { public: bool _saw_clients; // true if we ever got a connection. @@ -78,7 +92,7 @@ public: virtual int execute(); - IMPLEMENT_CLASS_NAME("cromp_server_tester"); + DEFINE_CLASS_NAME("cromp_server_tester"); private: our_cromp_server *_uplink; @@ -88,7 +102,7 @@ private: internet_address c_address; }; -//////////////////////////////////////////////////////////////////////////// +////////////// class real_bubbles_tentacle : public bubbles_tentacle { @@ -114,12 +128,13 @@ private: cromp_server_tester &_parent; }; -//////////////////////////////////////////////////////////////////////////// +////////////// cromp_server_tester::cromp_server_tester() -: application_shell("cromp_server_tester"), +: application_shell(), +///"cromp_server_tester"), _saw_clients(false), - _uplink(NIL), + _uplink(NULL_POINTER), _leave_when_no_clients(false), _encryption(false) { @@ -128,12 +143,12 @@ cromp_server_tester::cromp_server_tester() LOG(""); LOG(""); - command_line args(__argc, __argv); + command_line args(application::_global_argc, application::_global_argv); // check for a port on the command line. - istring port_text; + astring port_text; int port = 5678; if (args.get_value("port", port_text, false)) { - LOG(istring("using port: ") + port_text); + LOG(astring("using port: ") + port_text); port = port_text.convert(5678); } int posn = 0; @@ -145,15 +160,15 @@ cromp_server_tester::cromp_server_tester() //hmmm:normalize host so this can take either name or IP. // check for a hostname on the command line. - istring hostname("local"); - istring host_temp; + astring hostname("local"); + astring host_temp; if (args.get_value("host", host_temp, false)) { - LOG(istring("using host: ") + host_temp); + LOG(astring("using host: ") + host_temp); hostname = host_temp; } strcpy(c_address.hostname, hostname.s()); -//LOG(istring("here's the command line:") + log_base::platform_ending() + args.text_form()); +//LOG(astring("here's the command line:") + parser_bits::platform_eol_to_chars() + args.text_form()); int indy = 0; if (args.find("encrypt", indy) || (args.find('e', indy)) ) { @@ -196,7 +211,7 @@ int cromp_server_tester::execute() if (client_count == 1) verb = "is"; const char *ending = "s"; if (client_count == 1) ending = ""; - LOG(isprintf("There %s %d client%s.", verb, client_count, ending)); + LOG(a_sprintf("There %s %d client%s.", verb, client_count, ending)); next_report.reset(REPORTING_INTERVAL); } @@ -209,12 +224,12 @@ _uplink->add_tentacle(new real_bubbles_tentacle(*this, SUPPORT_BACKGROUNDING)); _uplink->enable_servers(_encryption); } - portable::sleep_ms(100); + time_control::sleep_ms(100); } return 0; } -//////////////////////////////////////////////////////////////////////////// +////////////// HOOPLE_MAIN(cromp_server_tester, )