From 11e7dcb6af2e6eadd08e5d7890c5dc181844cc47 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 17 May 2022 23:58:33 +0200 Subject: [PATCH] Use PROGNAME_{DAMON,PROBE} --- src/damon-backend-app.c | 13 +++++++------ src/damon-main.c | 8 ++++---- src/damon.c | 14 +++++++------- src/probe.c | 10 +++++----- src/rrd.c | 6 +++--- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/damon-backend-app.c b/src/damon-backend-app.c index 664fe2e..85f8022 100644 --- a/src/damon-backend-app.c +++ b/src/damon-backend-app.c @@ -23,8 +23,8 @@ #include "damon.h" /* constants */ -#ifndef PROGNAME -# define PROGNAME "DaMon" +#ifndef PROGNAME_DAMON +# define PROGNAME_DAMON "DaMon" #endif #define DAMON_SEP '/' @@ -104,7 +104,8 @@ int damon_refresh(DaMon * damon) } free(rrd); if(ac != NULL) - error_set_print(PROGNAME, 1, "%s", "refresh: An error occured"); + error_set_print(PROGNAME_DAMON, 1, "%s", + "refresh: An error occured"); return 0; } @@ -114,7 +115,7 @@ static AppClient * _refresh_connect(Host * host, Event * event) return NULL; if((host->appclient = appclient_new_event(NULL, "Probe", NULL, event)) == NULL) - error_print(PROGNAME); + error_print(PROGNAME_DAMON); return host->appclient; } @@ -123,7 +124,7 @@ static int _refresh_uptime(AppClient * ac, Host * host, char * rrd) int32_t ret; if(appclient_call(ac, (void **)&ret, "uptime") != 0) - return error_print(PROGNAME); + return error_print(PROGNAME_DAMON); sprintf(rrd, "%s%c%s", host->hostname, DAMON_SEP, "uptime.rrd"); damon_update(host->damon, RRDTYPE_UNKNOWN, rrd, 1, ret); return 0; @@ -136,7 +137,7 @@ static int _refresh_load(AppClient * ac, Host * host, char * rrd) if(appclient_call(ac, (void **)&res, "load", &load[0], &load[1], &load[2]) != 0) - return error_print(PROGNAME); + return error_print(PROGNAME_DAMON); if(res != 0) return 0; sprintf(rrd, "%s%c%s", host->hostname, DAMON_SEP, "load.rrd"); diff --git a/src/damon-main.c b/src/damon-main.c index 0a77b77..ed4333f 100644 --- a/src/damon-main.c +++ b/src/damon-main.c @@ -21,8 +21,8 @@ #include "../config.h" /* constants */ -#ifndef PROGNAME -# define PROGNAME "DaMon" +#ifndef PROGNAME_DAMON +# define PROGNAME_DAMON "DaMon" #endif @@ -46,7 +46,7 @@ static int _damon(char const * config) return 1; event = damon_get_event(damon); if(event_loop(event) != 0) - error_print(PROGNAME); + error_print(PROGNAME_DAMON); damon_delete(damon); return 1; } @@ -55,7 +55,7 @@ static int _damon(char const * config) /* damon_usage */ static int _damon_usage(void) { - fputs("Usage: " PROGNAME " [-f filename]\n" + fputs("Usage: " PROGNAME_DAMON " [-f filename]\n" " -f\tConfiguration file to load\n", stderr); return 1; } diff --git a/src/damon.c b/src/damon.c index fb1b686..6bce022 100644 --- a/src/damon.c +++ b/src/damon.c @@ -35,8 +35,8 @@ #ifndef SYSCONFDIR # define SYSCONFDIR PREFIX "/etc" #endif -#ifndef PROGNAME -# define PROGNAME "DaMon" +#ifndef PROGNAME_DAMON +# define PROGNAME_DAMON "DaMon" #endif @@ -129,14 +129,14 @@ Event * damon_get_event(DaMon * damon) /* damon_error */ int damon_error(char const * message, int ret) { - return error_set_print(PROGNAME, ret, "%s", message); + return error_set_print(PROGNAME_DAMON, ret, "%s", message); } /* damon_perror */ int damon_perror(char const * message, int ret) { - return error_set_print(PROGNAME, ret, "%s%s%s", + return error_set_print(PROGNAME_DAMON, ret, "%s%s%s", (message != NULL) ? message : "", (message != NULL) ? ": " : "", strerror(errno)); } @@ -145,7 +145,7 @@ int damon_perror(char const * message, int ret) /* damon_serror */ int damon_serror(void) { - return error_print(PROGNAME); + return error_print(PROGNAME_DAMON); } @@ -214,10 +214,10 @@ static int _init_config(DaMon * damon, char const * filename) damon->hosts = NULL; damon->hosts_cnt = 0; if(filename == NULL) - filename = SYSCONFDIR "/" PROGNAME ".conf"; + filename = SYSCONFDIR "/" PROGNAME_DAMON ".conf"; if(config_load(config, filename) != 0) { - error_print(PROGNAME); + error_print(PROGNAME_DAMON); config_delete(config); return -1; } diff --git a/src/probe.c b/src/probe.c index 2414be2..b66ccbb 100644 --- a/src/probe.c +++ b/src/probe.c @@ -29,8 +29,8 @@ #include "../data/Probe.h" #include "../config.h" -#ifndef PROGNAME -# define PROGNAME PACKAGE +#ifndef PROGNAME_PROBE +# define PROGNAME_PROBE PACKAGE #endif @@ -652,7 +652,7 @@ static int _probe(AppServerOptions options) /* probe_error */ static int _probe_error(int ret) { - error_print(PROGNAME); + error_print(PROGNAME_PROBE); return ret; } @@ -660,7 +660,7 @@ static int _probe_error(int ret) /* probe_perror */ static int _probe_perror(char const * message, int ret) { - error_set_print(PROGNAME, ret, "%s%s%s", message ? message : "", + error_set_print(PROGNAME_PROBE, ret, "%s%s%s", message ? message : "", message ? ": " : "", strerror(errno)); return ret; } @@ -847,7 +847,7 @@ uint32_t Probe_volfree(Probe * probe, AppServerClient * asc, /* usage */ static int _usage(void) { - fputs("Usage: " PROGNAME " [-R]\n", stderr); + fputs("Usage: " PROGNAME_PROBE " [-R]\n", stderr); return 1; } diff --git a/src/rrd.c b/src/rrd.c index 4ffa9ec..4d13695 100644 --- a/src/rrd.c +++ b/src/rrd.c @@ -27,8 +27,8 @@ #include "rrd.h" /* constants */ -#ifndef PROGNAME -# define PROGNAME "DaMon" +#ifndef PROGNAME_DAMON +# define PROGNAME_DAMON "DaMon" #endif #ifndef RRDTOOL # define RRDTOOL "rrdtool" @@ -196,7 +196,7 @@ static int _create_directories(char const * filename) p[i] = '\0'; if(mkdir(p, 0777) != 0 && errno != EEXIST) { - error_set_print(PROGNAME, -errno, "%s: %s", p, + error_set_print(PROGNAME_DAMON, -errno, "%s: %s", p, strerror(errno)); ret = -1; break;