I am creating a string pointer and passing it through a structure to dynamically pass different progam names for each program.
This is fine for many languages that are not C/C++.
For C/C++, this can be done in a cleaner and more efficient way.
The extern type can be declared in the main project and use that.
Then, the final binary is the only case where the actual implementation of the extern variable must exist.
That means each program (init and controller) will define their own program name string.
No extra memory in the structure needs to be used.
This is cleaner, simpler, and more maintainable.
data.program.output.custom = (void *) &data;
data.program.warning.custom = (void *) &data;
- data.setting.program_name = &controller_controller_program_name_s;
- data.setting.program_name_long = &controller_controller_program_name_long_s;
-
f_console_parameter_t parameters[] = controller_console_parameter_t_initialize;
data.program.parameters.array = parameters;
extern "C" {
#endif
-#ifndef _di_controller_controller_program_name_s_
- const f_string_static_t controller_controller_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_controller_program_name_s, 0, CONTROLLER_controller_program_name_s_length);
- const f_string_static_t controller_controller_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_controller_program_name_long_s, 0, CONTROLLER_controller_program_name_long_s_length);
-#endif // _di_controller_controller_program_name_s_
+#ifndef _di_controller_program_name_s_
+ const f_string_static_t controller_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_name_s, 0, CONTROLLER_program_name_s_length);
+ const f_string_static_t controller_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_name_long_s, 0, CONTROLLER_program_name_long_s_length);
+#endif // _di_controller_program_name_s_
#ifdef __cplusplus
} // extern "C"
/**
* The program name.
*/
-#ifndef _di_controller_controller_program_name_s_
- #define CONTROLLER_controller_program_name_s "controller"
- #define CONTROLLER_controller_program_name_long_s "Controller"
+#ifndef _di_controller_program_name_s_
+ #define CONTROLLER_program_name_s "controller"
+ #define CONTROLLER_program_name_long_s "Controller"
- #define CONTROLLER_controller_program_name_s_length 10
- #define CONTROLLER_controller_program_name_long_s_length 10
-
- extern const f_string_static_t controller_controller_program_name_s;
- extern const f_string_static_t controller_controller_program_name_long_s;
-#endif // _di_controller_controller_program_name_s_
+ #define CONTROLLER_program_name_s_length 10
+ #define CONTROLLER_program_name_long_s_length 10
+#endif // _di_controller_program_name_s_
#ifdef __cplusplus
} // extern "C"
data.program.output.custom = (void *) &data;
data.program.warning.custom = (void *) &data;
- data.setting.program_name = &controller_init_program_name_s;
- data.setting.program_name_long = &controller_init_program_name_long_s;
-
f_console_parameter_t parameters[] = controller_console_parameter_t_initialize;
data.program.parameters.array = parameters;
extern "C" {
#endif
-#ifndef _di_controller_init_program_name_s_
- const f_string_static_t controller_init_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_init_program_name_s, 0, CONTROLLER_init_program_name_s_length);
- const f_string_static_t controller_init_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_init_program_name_long_s, 0, CONTROLLER_init_program_name_long_s_length);
-#endif // _di_controller_init_program_name_s_
+#ifndef _di_controller_program_name_s_
+ const f_string_static_t controller_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_name_s, 0, CONTROLLER_program_name_s_length);
+ const f_string_static_t controller_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_name_long_s, 0, CONTROLLER_program_name_long_s_length);
+#endif // _di_controller_program_name_s_
#ifdef __cplusplus
} // extern "C"
/**
* The program name.
*/
-#ifndef _di_controller_init_program_name_s_
- #define CONTROLLER_init_program_name_s "init"
- #define CONTROLLER_init_program_name_long_s "Init"
+#ifndef _di_controller_program_name_s_
+ #define CONTROLLER_program_name_s "init"
+ #define CONTROLLER_program_name_long_s "Init"
- #define CONTROLLER_init_program_name_s_length 4
- #define CONTROLLER_init_program_name_long_s_length 4
-
- extern const f_string_static_t controller_init_program_name_s;
- extern const f_string_static_t controller_init_program_name_long_s;
-#endif // _di_controller_init_program_name_s_
+ #define CONTROLLER_program_name_s_length 4
+ #define CONTROLLER_program_name_long_s_length 4
+#endif // _di_controller_program_name_s_
#ifdef __cplusplus
} // extern "C"
#endif // _di_controller_program_version_s_
/**
+ * The program name.
+ *
+ * The implementation for this is defined within the individual programs.
+ */
+#ifndef _di_controller_program_name_s_
+ extern const f_string_static_t controller_program_name_s;
+ extern const f_string_static_t controller_program_name_long_s;
+#endif // _di_controller_program_name_s_
+
+/**
* The main program parameters.
*/
#ifndef _di_controller_parameter_s_
*
* status_signal: A status used eclusively by the threaded signal handler.
* state: The state data used when processing the FSS data.
- *
- * program_name: The short program name.
- * program_name_long: The long program name.
*/
#ifndef _di_controller_setting_t_
typedef struct {
f_status_t status_signal;
f_state_t state;
-
- const f_string_static_t *program_name;
- const f_string_static_t *program_name_long;
} controller_setting_t;
#define controller_setting_t_initialize \
controller_main_flag_none_e, \
F_okay, \
f_state_t_initialize, \
- 0, \
- 0, \
}
#endif // _di_controller_setting_t_
f_file_stream_lock(print->to);
- fll_program_print_help_header(print, *main->setting.program_name_long, controller_program_version_s);
+ fll_program_print_help_header(print, controller_program_name_long_s, controller_program_version_s);
fll_program_print_help_option_standard(print);
f_print_dynamic_raw(f_string_eol_s, print->to);
- fll_program_print_help_usage(print, *main->setting.program_name, f_string_empty_s);
+ fll_program_print_help_usage(print, controller_program_name_s, f_string_empty_s);
fl_print_format("%r When both the %[%r%r%] parameter and the", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, controller_long_simulate_s, print->set->notable);
fl_print_format(" %[%r%r%] parameter are specified, then additional information on each would be executed rule is printed but no simulation is performed.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, controller_long_validate_s, print->set->notable, f_string_eol_s, f_string_eol_s);