Make sure that the typedef is defined early for a later defined type.
This allows for circular use of the main, such as with callbacks.
This is being done across all of my programs.
#endif
/**
+ * Pre-define the main type so it can be used in child classes.
+ */
+#ifndef _di_kt_remove_main_t_typedef_
+ typedef struct kt_remove_main_t_ kt_remove_main_t;
+#endif // _di_kt_remove_main_t_typedef_
+
+/**
* A processed Date parameter.
*
* The start is inclusive and the stop is exclusive just like with f_range_t.
* groups: An array of Group IDs (gid_t) represented via an unsigned 32-bit integer.
* users: An array of Group IDs (uid_t) represented via an unsigned 32-bit integer.
*
- * process_help: Process help (generally printing help).
+ * print_help: Print help.
* process_normal: Process normally (data from parameters and files).
* process_operate_file: Process an individual file, returning F_done to designate handled, and F_okay for letting parent continue handling.
* process_operate_file_simulate: Simulate process of an individual file, returning F_done to designate handled, and F_okay for letting parent continue handling.
const f_string_static_t *program_name;
const f_string_static_t *program_name_long;
- f_status_t (*process_help)(void * const main);
- void (*process_normal)(void * const main);
- void (*process_operate_file)(void * const main, const f_string_static_t path, const struct stat statistics, uint8_t * const flag);
- void (*process_operate_file_simulate)(void * const main, const f_string_static_t path, const struct stat statistics, uint8_t * const flag);
+ f_status_t (*print_help)(fl_print_t * const print, const f_color_context_t context);
+ void (*process_normal)(kt_remove_main_t * const main);
+ void (*process_operate_file)(kt_remove_main_t * const main, const f_string_static_t path, const struct stat statistics, uint8_t * const flag);
+ void (*process_operate_file_simulate)(kt_remove_main_t * const main, const f_string_static_t path, const struct stat statistics, uint8_t * const flag);
} kt_remove_setting_t;
#define kt_remove_setting_t_initialize \
* setting: The settings data.
*/
#ifndef _di_kt_remove_main_t_
- typedef struct {
+ struct kt_remove_main_t_ {
fll_program_data_t program;
kt_remove_setting_t setting;
- } kt_remove_main_t;
+ };
#define kt_remove_main_t_initialize \
{ \
main->setting.state.status = F_okay;
if (main->setting.flag & kt_remove_main_flag_tree_d) {
- // @todo handle simulate for this.
+ f_range_t range = macro_f_range_t_initialize_2(path.used);
+ // @todo do backwards searches on the path.
}
// @todo call a similate fl_directory_do() or move this into the kt_remove_operate_file_directory() process.
if (main->setting.process_operate_file_simulate) {
main->setting.state.status = F_okay;
- main->setting.process_operate_file_simulate((void *) main, path, statistics, &flag);
+ main->setting.process_operate_file_simulate(main, path, statistics, &flag);
if (F_status_is_error(main->setting.state.status)) return flag;
if (main->setting.state.status == F_done) {
if (main->setting.flag & kt_remove_main_flag_version_copyright_help_d) {
if (main->setting.flag & kt_remove_main_flag_help_d) {
- if (main->setting.process_help) {
- main->setting.process_help((void *) main);
+ if (main->setting.print_help) {
+ main->setting.print_help(&main->program.output, main->program.context);
}
}
else if (main->setting.flag & kt_remove_main_flag_version_d) {
}
if (main->setting.process_normal) {
- main->setting.process_normal((void *) main);
+ main->setting.process_normal(main);
if (F_status_is_error(main->setting.state.status)) return;
}
}
#endif // _di_kt_remove_main_
-#ifndef _di_kt_remove_process_help_
- f_status_t kt_remove_process_help(void * const main) {
-
- if (!main) return F_output_not;
-
- return kt_remove_print_message_help(&((kt_remove_main_t *) main)->program.output, ((kt_remove_main_t *) main)->program.context);
- }
-#endif // _di_kt_remove_process_help_
-
-#ifndef _di_kt_remove_process_normal_
- void kt_remove_process_normal(void * const main) {
-
- if (!main) return;
-
- kt_remove_process_normal_operate(((kt_remove_main_t *) main));
- }
-#endif // _di_kt_remove_process_normal_
-
#ifndef _di_kt_remove_process_normal_operate_
void kt_remove_process_normal_operate(kt_remove_main_t * const main) {
#endif // _di_kt_remove_main_
/**
- * Process printing help.
- *
- * @param main
- * The main program and settings data.
- *
- * This must be of type kt_remove_main_t.
- *
- * Must not be NULL.
- *
- * This does not alter main.setting.state.status.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- */
-#ifndef _di_kt_remove_process_help_
- extern f_status_t kt_remove_process_help(void * const main);
-#endif // _di_kt_remove_process_help_
-
-/**
- * Process normally, writing to the output.
- *
- * @param main
- * The main program and settings data.
- *
- * This must be of type kt_remove_main_t.
- *
- * Must not be NULL.
- *
- * This alters main.setting.state.status:
- * F_okay on success.
- *
- * Errors with (error bit set) from: kt_remove_process_normal_operate()
- *
- * @see kt_remove_process_normal_operate()
- */
-#ifndef _di_kt_remove_process_normal_
- extern void kt_remove_process_normal(void * const main);
-#endif // _di_kt_remove_process_normal_
-
-/**
* Perform the normal processing.
*
* @param main
data.setting.state.data = (void *) &data;
data.setting.program_name = &kt_remove_program_name_s;
data.setting.program_name_long = &kt_remove_program_name_long_s;
- data.setting.process_help = &kt_remove_process_help;
- data.setting.process_normal = &kt_remove_process_normal;
+ data.setting.print_help = &kt_remove_print_message_help;
+ data.setting.process_normal = &kt_remove_process_normal_operate;
data.setting.recurse.action = &kt_remove_operate_file_directory_recurse_action;
data.setting.recurse.handle = &kt_remove_operate_file_directory_recurse_handle;
data.setting.recurse.depth_max = kt_remove_depth_max_d;
// Only process these when needed to avoid unnecessary operations.
if (main->callback.setting_load_send_receive && !(main->setting.flag & (kt_tacocat_main_flag_copyright_d | kt_tacocat_main_flag_version_d |kt_tacocat_main_flag_help_d))) {
- main->callback.setting_load_send_receive(arguments, (void *) main);
+ main->callback.setting_load_send_receive(arguments, main);
}
if (F_status_is_error_not(main->setting.state.status)) {
#endif // _di_kt_tacocat_setting_load_
#ifndef _di_kt_tacocat_setting_load_send_receive_
- void kt_tacocat_setting_load_send_receive(const f_console_arguments_t arguments, void * const void_main) {
+ void kt_tacocat_setting_load_send_receive(const f_console_arguments_t arguments, kt_tacocat_main_t * const main) {
- if (!void_main) return;
-
- kt_tacocat_main_t * const main = (kt_tacocat_main_t *) void_main;
+ if (!main) return;
const uint8_t parameters[] = {
kt_tacocat_parameter_receive_e,
* @param main
* The main program and settings data.
*
- * This must be of type kt_tacocat_main_t.
- *
* Must not be NULL.
*
* This alters main.setting.state.status:
* @see f_string_dynamic_append_nulless()
*/
#ifndef _di_kt_tacocat_setting_load_send_receive_
- extern void kt_tacocat_setting_load_send_receive(const f_console_arguments_t arguments, void * const main);
+ extern void kt_tacocat_setting_load_send_receive(const f_console_arguments_t arguments, kt_tacocat_main_t * const main);
#endif // _di_kt_tacocat_setting_load_send_receive_
/**
#endif
/**
+ * Pre-define the main type so it can be used in child classes.
+ */
+#ifndef _di_kt_tacocat_main_t_typedef_
+ typedef struct kt_tacocat_main_t_ kt_tacocat_main_t;
+#endif // _di_kt_tacocat_main_t_typedef_
+
+/**
* A set of all socket related properties.
*
* size_block: The size in bytes to used to represent a block when sending or receiving packets.
*/
#ifndef _di_kt_tacocat_callback_t_
typedef struct {
- void (*setting_load_send_receive)(const f_console_arguments_t arguments, void * const main);
+ void (*setting_load_send_receive)(const f_console_arguments_t arguments, kt_tacocat_main_t * const main);
} kt_tacocat_callback_t;
#define kt_tacocat_callback_t_initialize \
* thread: The program thread data.
*/
#ifndef _di_kt_tacocat_main_t_
- typedef struct {
+ struct kt_tacocat_main_t_ {
fll_program_data_t program;
kt_tacocat_setting_t setting;
kt_tacocat_callback_t callback;
kt_tacocat_thread_t thread;
kt_tacocat_cache_t cache;
- } kt_tacocat_main_t;
+ };
#define kt_tacocat_main_t_initialize \
{ \