From: Kevin Day Date: Sat, 15 Jul 2023 03:10:42 +0000 (-0500) Subject: Progress: Further work in TacocaT. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ef7a340b6c72e8026b812a698ee26f1e5997ee5e;p=kevux-tools Progress: Further work in TacocaT. Begin working on actually processing the packet from the socket file. --- diff --git a/sources/c/tacocat/main/common.c b/sources/c/tacocat/main/common.c index 0331b1b..d064b65 100644 --- a/sources/c/tacocat/main/common.c +++ b/sources/c/tacocat/main/common.c @@ -247,10 +247,15 @@ extern "C" { continue; } + sets[i]->flags.used = 0; sets[i]->names.used = 0; sets[i]->buffers.used = 0; sets[i]->polls.used = 0; + main->setting.state.status = f_uint16s_increase_by(main->program.parameters.array[parameters[i]].values.used / 2, &sets[i]->flags); + + macro_setting_load_handle_send_receive_error_continue_1(f_uint16s_increase_by); + main->setting.state.status = f_string_dynamics_increase_by(main->program.parameters.array[parameters[i]].values.used / 2, &sets[i]->names); macro_setting_load_handle_send_receive_error_continue_1(f_string_dynamics_increase_by); @@ -280,6 +285,7 @@ extern "C" { // First parameter value represents the network address or the socket file path. index = main->program.parameters.array[parameters[i]].values.array[j]; sets[i]->statuss.array[j] = F_none; + sets[i]->flags.array[j] = kt_tacocat_socket_flag_none_e; sets[i]->names.array[j].used = 0; sets[i]->buffers.array[j].used = 0; diff --git a/sources/c/tacocat/main/common/enumeration.h b/sources/c/tacocat/main/common/enumeration.h index a37d632..88e8858 100644 --- a/sources/c/tacocat/main/common/enumeration.h +++ b/sources/c/tacocat/main/common/enumeration.h @@ -42,7 +42,7 @@ extern "C" { * The Kevux method also supports local DNS entries ie (~/.resolution/dns/kevux.conf or ~/.resolution/host/kevux.conf). * @todo The Kevux method will be implemented in a library (project resolution and libresolution), re-introducing and expanding on the Turtle Kevux resolv.conf extensions that Kevin hacked into uClibc several years back. */ -#ifndef _di_kt_tacocat_flag_e_ +#ifndef _di_kt_tacocat_main_flag_e_ enum { kt_tacocat_main_flag_none_e = 0x0, kt_tacocat_main_flag_copyright_e = 0x1, @@ -56,7 +56,7 @@ extern "C" { kt_tacocat_main_flag_send_e = 0x100, kt_tacocat_main_flag_version_e = 0x200, }; // enum -#endif // _di_kt_tacocat_flag_e_ +#endif // _di_kt_tacocat_main_flag_e_ /** * The main program parameters. @@ -122,6 +122,22 @@ extern "C" { }; // enum #endif // _di_kt_tacocat_print_flag_e_ +/** + * Individual socket-specific flags. + * + * kt_tacocat_socket_flag_*_e: + * - none: No flags set. + * - block_control: The control block is fully read. + * - block_payload: The payload block is fully read. + */ +#ifndef _di_kt_tacocat_socket_flag_e_ + enum { + kt_tacocat_socket_flag_none_e = 0x0, + kt_tacocat_socket_flag_block_control_e = 0x1, + kt_tacocat_socket_flag_block_payload_e = 0x2, + }; // enum +#endif // _di_kt_tacocat_socket_flag_e_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/tacocat/main/common/print.c b/sources/c/tacocat/main/common/print.c index bb5cb10..8d11fa9 100644 --- a/sources/c/tacocat/main/common/print.c +++ b/sources/c/tacocat/main/common/print.c @@ -27,6 +27,7 @@ extern "C" { "f_string_dynamic_increase_by", "f_string_dynamics_increase_by", "f_thread_create", + "f_uint16s_increase_by", "fl_conversion_dynamic_to_unsigned_detect", "fll_program_parameter_process_context", "fll_program_parameter_process_verbosity", diff --git a/sources/c/tacocat/main/common/print.h b/sources/c/tacocat/main/common/print.h index c4448fe..f0e28e3 100644 --- a/sources/c/tacocat/main/common/print.h +++ b/sources/c/tacocat/main/common/print.h @@ -60,6 +60,7 @@ extern "C" { kt_tacocat_f_f_string_dynamic_increase_by_e, kt_tacocat_f_f_string_dynamics_increase_by_e, kt_tacocat_f_f_thread_create_e, + kt_tacocat_f_f_uint16s_increase_by_e, kt_tacocat_f_fl_conversion_dynamic_to_unsigned_detect_e, kt_tacocat_f_fll_program_parameter_process_context_e, kt_tacocat_f_fll_program_parameter_process_verbosity_e, diff --git a/sources/c/tacocat/main/common/type.c b/sources/c/tacocat/main/common/type.c index df227fc..3917e0f 100644 --- a/sources/c/tacocat/main/common/type.c +++ b/sources/c/tacocat/main/common/type.c @@ -38,6 +38,7 @@ extern "C" { f_socket_disconnect(&sets[i]->sockets.array[j], program.signal_received ? f_socket_close_fast_e : f_socket_close_read_write_e); } // for + f_uint16s_resize(0, &sets[i]->flags); f_files_resize(0, &sets[i]->files); f_polls_resize(0, &sets[i]->polls); f_sockets_resize(0, &sets[i]->sockets); diff --git a/sources/c/tacocat/main/common/type.h b/sources/c/tacocat/main/common/type.h index 631e25a..7abeb8e 100644 --- a/sources/c/tacocat/main/common/type.h +++ b/sources/c/tacocat/main/common/type.h @@ -21,8 +21,9 @@ extern "C" { * * block_size: The size in bytes to used to represent a block when sending or receiving packets. * + * flags: An array of flags for each socket. * files: An array of files for each socket. - * polls: An array of sockets to poll, specifically for passing to f_file_poll(). + * polls: An array of sockets to poll, specifically for passing to f_file_poll(). * sockets: An array of the network sockets. * statuss: An array of statuses for each socket. * @@ -33,6 +34,7 @@ extern "C" { typedef struct { f_number_unsigned_t block_size; + f_uint16s_t flags; f_files_t files; f_polls_t polls; f_sockets_t sockets; @@ -45,6 +47,7 @@ extern "C" { #define kt_tacocat_socket_set_t_initialize \ { \ kt_tacocat_block_size_d, \ + f_uint16s_t_initialize, \ f_files_t_initialize, \ f_polls_t_initialize, \ f_sockets_t_initialize, \ @@ -56,6 +59,7 @@ extern "C" { #define macro_kt_tacocat_setting_t_initialize_1(block_size) \ { \ block_size, \ + f_uint16s_t_initialize, \ f_files_t_initialize, \ f_polls_t_initialize, \ f_sockets_t_initialize, \ @@ -74,9 +78,9 @@ extern "C" { * flag: Flags passed to the main function. * interval: The poll interval to use. * - * status_receive: A status used eclusively by the receive thread. - * status_send: A status used eclusively by the send thread. - * status_signal: A status used eclusively by the threaded signal handler. + * status_receive: A status used exclusively by the receive thread. + * status_send: A status used exclusively by the send thread. + * status_signal: A status used exclusively by the threaded signal handler. * * state: The state data used when processing data. * diff --git a/sources/c/tacocat/main/receive.c b/sources/c/tacocat/main/receive.c index 05db49e..d3304e1 100644 --- a/sources/c/tacocat/main/receive.c +++ b/sources/c/tacocat/main/receive.c @@ -12,6 +12,7 @@ extern "C" { if (!void_main) return 0; kt_tacocat_main_t * const main = (kt_tacocat_main_t *) void_main; + f_number_unsigned_t i = 0; kt_tacocat_process_socket_set_receive(main); @@ -25,6 +26,23 @@ extern "C" { return 0; } + for (i = 0; i < main->setting.receive.polls.used; ++i) { + + if (main->setting.receive.polls.array[i].fd == -1) continue; + + // @todo figure out what f_poll_urgent_e can be. + if (main->setting.receive.polls.array[i].revents & (f_poll_read_e | f_poll_urgent_e)) { + // @todo call receive + kt_tacocat_receive_process(main, i); + + if (F_status_is_error(main->setting.state.status)) { + // @todo print error. + + continue; + } + } + } // for + // @todo handle errors } while (F_status_is_error_not(main->setting.status_receive)); @@ -42,6 +60,21 @@ extern "C" { } #endif // _di_kt_tacocat_receive_ +#ifndef _di_kt_tacocat_receive_process_ + void kt_tacocat_receive_process(kt_tacocat_main_t * const main, const f_number_unsigned_t index) { + + f_socket_t * const socket = &main->setting.receive.sockets.array[index]; + f_poll_t * const poll = &main->setting.receive.polls.array[index]; + + if (poll->revents & f_poll_urgent_e) { + // @todo then handle out of band, via f_socket_flag_out_of_band_e. + } + + // f_socket_flag_peek_e, + //f_socket_read_stream + } +#endif // _di_kt_tacocat_receive_process_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/sources/c/tacocat/main/receive.h b/sources/c/tacocat/main/receive.h index 702a93f..7662b11 100644 --- a/sources/c/tacocat/main/receive.h +++ b/sources/c/tacocat/main/receive.h @@ -31,6 +31,23 @@ extern "C" { extern void * kt_tacocat_receive(void * const main); #endif // _di_kt_tacocat_receive_ +/** + * Process the buffer, retrieving the data and writing to the file. + * + * @param main + * The main program and settings data. + * + * This alters main.setting.state.status: + * F_none on success. + * @param index + * The position within the receive arrays to process. + * + * @see f_socket_read_stream() + */ +#ifndef _di_kt_tacocat_receive_process_ + extern void kt_tacocat_receive_process(kt_tacocat_main_t * const main, const f_number_unsigned_t index); +#endif // _di_kt_tacocat_receive_process_ + #ifdef __cplusplus } // extern "C" #endif