fix weatherdaemon for new usefull_macros

This commit is contained in:
2025-06-23 11:08:39 +03:00
parent cc8e915546
commit 453a56429d
34 changed files with 2979 additions and 354 deletions

View File

@@ -29,7 +29,6 @@
* here are global parameters initialisation
*/
int help;
static glob_pars G;
// default values for Gdefault & help
#define DEFAULT_PORT "12345"
@@ -37,14 +36,12 @@ static glob_pars G;
// DEFAULTS
// default global parameters
glob_pars const Gdefault = {
static glob_pars G = {
.device = NULL,
.port = DEFAULT_PORT,
.logfile = NULL,
.verb = 0,
.tty_speed = 9600,
.rest_pars = NULL,
.rest_pars_num = 0,
.emul = 0,
.pidfile = DEFAULT_PID
};
@@ -53,7 +50,7 @@ glob_pars const Gdefault = {
* Define command line options by filling structure:
* name has_arg flag val type argptr help
*/
myoption cmdlnopts[] = {
sl_option_t cmdlnopts[] = {
// common options
{"help", NO_ARGS, NULL, 'h', arg_int, APTR(&help), _("show this help")},
{"device", NEED_ARG, NULL, 'd', arg_string, APTR(&G.device), _("serial device name (default: none)")},
@@ -75,18 +72,15 @@ myoption cmdlnopts[] = {
*/
glob_pars *parse_args(int argc, char **argv){
int i;
void *ptr;
ptr = memcpy(&G, &Gdefault, sizeof(G)); assert(ptr);
// format of help: "Usage: progname [args]\n"
change_helpstring("Usage: %s [args]\n\n\tWhere args are:\n");
sl_helpstring("Usage: %s [args]\n\n\tWhere args are:\n");
// parse arguments
parseargs(&argc, &argv, cmdlnopts);
if(help) showhelp(-1, cmdlnopts);
sl_parseargs(&argc, &argv, cmdlnopts);
if(help) sl_showhelp(-1, cmdlnopts);
if(argc > 0){
G.rest_pars_num = argc;
G.rest_pars = calloc(argc, sizeof(char*));
red("Unused parameters:\n");
for (i = 0; i < argc; i++)
G.rest_pars[i] = strdup(argv[i]);
printf("%s\n", argv[i]);
}
return &G;
}