Begin working on actually processing the packet from the socket file.
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);
// 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;
* 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,
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.
}; // 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
"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",
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,
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);
*
* 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.
*
typedef struct {
f_number_unsigned_t block_size;
+ f_uint16s_t flags;
f_files_t files;
f_polls_t polls;
f_sockets_t sockets;
#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, \
#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, \
* 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.
*
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);
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));
}
#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
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