diff options
| author | David M. Syzdek <david.syzdek@acsalaska.com> | 2020-02-10 12:52:45 -0900 |
|---|---|---|
| committer | David M. Syzdek <david.syzdek@acsalaska.com> | 2020-02-10 12:52:45 -0900 |
| commit | 4746c843a0155ef4a59ed2d97bb16f6b9a7dd585 (patch) | |
| tree | d1b6d266e4d299c10d9214b6b15575ad7cd6bdaf /src | |
| parent | 70231679b1c10d79895199ea89474e9023ca65fb (diff) | |
| download | akcom-udpecho-4746c843a0155ef4a59ed2d97bb16f6b9a7dd585.tar.gz akcom-udpecho-4746c843a0155ef4a59ed2d97bb16f6b9a7dd585.tar.bz2 akcom-udpecho-4746c843a0155ef4a59ed2d97bb16f6b9a7dd585.tar.xz akcom-udpecho-4746c843a0155ef4a59ed2d97bb16f6b9a7dd585.zip | |
akcom-udpechod: replacing facility struct member with static variable
Diffstat (limited to 'src')
| -rw-r--r-- | src/akcom-udpechod.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/akcom-udpechod.c b/src/akcom-udpechod.c index 46532b8..d45cbc0 100644 --- a/src/akcom-udpechod.c +++ b/src/akcom-udpechod.c | |||
| @@ -148,7 +148,6 @@ static int should_stop = 0; | |||
| 148 | 148 | ||
| 149 | struct app_config | 149 | struct app_config |
| 150 | { | 150 | { |
| 151 | int facility; // syslog facility | ||
| 152 | int dont_fork; | 151 | int dont_fork; |
| 153 | const char * listen; // IP address to listen for requests | 152 | const char * listen; // IP address to listen for requests |
| 154 | uid_t uid; // setuid | 153 | uid_t uid; // setuid |
| @@ -156,7 +155,6 @@ struct app_config | |||
| 156 | }; | 155 | }; |
| 157 | static struct app_config cnf = | 156 | static struct app_config cnf = |
| 158 | { | 157 | { |
| 159 | .facility = LOG_DAEMON, | ||
| 160 | .dont_fork = 0, | 158 | .dont_fork = 0, |
| 161 | .listen = NULL, | 159 | .listen = NULL, |
| 162 | .uid = 0, | 160 | .uid = 0, |
| @@ -169,6 +167,7 @@ static int cnf_echoplus = 0; | |||
| 169 | static int cnf_drop_perct = 0; | 167 | static int cnf_drop_perct = 0; |
| 170 | static useconds_t cnf_delay = 0; // Delay range in microseconds | 168 | static useconds_t cnf_delay = 0; // Delay range in microseconds |
| 171 | static int32_t cnf_verbose = 0; // runtime verbosity | 169 | static int32_t cnf_verbose = 0; // runtime verbosity |
| 170 | static int cnf_facility = LOG_DAEMON; // syslog facility | ||
| 172 | 171 | ||
| 173 | 172 | ||
| 174 | ////////////////// | 173 | ////////////////// |
| @@ -282,23 +281,23 @@ int main(int argc, char * argv[]) | |||
| 282 | break; | 281 | break; |
| 283 | 282 | ||
| 284 | case 'f': | 283 | case 'f': |
| 285 | if (!(strcasecmp(optarg, "auth"))) { cnf.facility = LOG_AUTH; } | 284 | if (!(strcasecmp(optarg, "auth"))) { cnf_facility = LOG_AUTH; } |
| 286 | else if (!(strcasecmp(optarg, "cron"))) { cnf.facility = LOG_CRON; } | 285 | else if (!(strcasecmp(optarg, "cron"))) { cnf_facility = LOG_CRON; } |
| 287 | else if (!(strcasecmp(optarg, "daemon"))) { cnf.facility = LOG_DAEMON; } | 286 | else if (!(strcasecmp(optarg, "daemon"))) { cnf_facility = LOG_DAEMON; } |
| 288 | else if (!(strcasecmp(optarg, "ftp"))) { cnf.facility = LOG_FTP; } | 287 | else if (!(strcasecmp(optarg, "ftp"))) { cnf_facility = LOG_FTP; } |
| 289 | else if (!(strcasecmp(optarg, "local0"))) { cnf.facility = LOG_LOCAL0; } | 288 | else if (!(strcasecmp(optarg, "local0"))) { cnf_facility = LOG_LOCAL0; } |
| 290 | else if (!(strcasecmp(optarg, "local1"))) { cnf.facility = LOG_LOCAL1; } | 289 | else if (!(strcasecmp(optarg, "local1"))) { cnf_facility = LOG_LOCAL1; } |
| 291 | else if (!(strcasecmp(optarg, "local2"))) { cnf.facility = LOG_LOCAL2; } | 290 | else if (!(strcasecmp(optarg, "local2"))) { cnf_facility = LOG_LOCAL2; } |
| 292 | else if (!(strcasecmp(optarg, "local3"))) { cnf.facility = LOG_LOCAL3; } | 291 | else if (!(strcasecmp(optarg, "local3"))) { cnf_facility = LOG_LOCAL3; } |
| 293 | else if (!(strcasecmp(optarg, "local4"))) { cnf.facility = LOG_LOCAL4; } | 292 | else if (!(strcasecmp(optarg, "local4"))) { cnf_facility = LOG_LOCAL4; } |
| 294 | else if (!(strcasecmp(optarg, "local5"))) { cnf.facility = LOG_LOCAL5; } | 293 | else if (!(strcasecmp(optarg, "local5"))) { cnf_facility = LOG_LOCAL5; } |
| 295 | else if (!(strcasecmp(optarg, "local6"))) { cnf.facility = LOG_LOCAL6; } | 294 | else if (!(strcasecmp(optarg, "local6"))) { cnf_facility = LOG_LOCAL6; } |
| 296 | else if (!(strcasecmp(optarg, "local7"))) { cnf.facility = LOG_LOCAL7; } | 295 | else if (!(strcasecmp(optarg, "local7"))) { cnf_facility = LOG_LOCAL7; } |
| 297 | else if (!(strcasecmp(optarg, "lpr"))) { cnf.facility = LOG_LPR; } | 296 | else if (!(strcasecmp(optarg, "lpr"))) { cnf_facility = LOG_LPR; } |
| 298 | else if (!(strcasecmp(optarg, "mail"))) { cnf.facility = LOG_MAIL; } | 297 | else if (!(strcasecmp(optarg, "mail"))) { cnf_facility = LOG_MAIL; } |
| 299 | else if (!(strcasecmp(optarg, "news"))) { cnf.facility = LOG_NEWS; } | 298 | else if (!(strcasecmp(optarg, "news"))) { cnf_facility = LOG_NEWS; } |
| 300 | else if (!(strcasecmp(optarg, "uucp"))) { cnf.facility = LOG_UUCP; } | 299 | else if (!(strcasecmp(optarg, "uucp"))) { cnf_facility = LOG_UUCP; } |
| 301 | else if (!(strcasecmp(optarg, "user"))) { cnf.facility = LOG_USER; } | 300 | else if (!(strcasecmp(optarg, "user"))) { cnf_facility = LOG_USER; } |
| 302 | else | 301 | else |
| 303 | { | 302 | { |
| 304 | my_usage_error("invalid or unsupported syslog facility -- `%s'", optarg); | 303 | my_usage_error("invalid or unsupported syslog facility -- `%s'", optarg); |
| @@ -675,7 +674,7 @@ int my_daemonize(void) | |||
| 675 | close(fd); | 674 | close(fd); |
| 676 | 675 | ||
| 677 | // opens syslog | 676 | // opens syslog |
| 678 | openlog(prog_name, LOG_PID | (((cnf.dont_fork)) ? LOG_PERROR : 0), cnf.facility); | 677 | openlog(prog_name, LOG_PID | (((cnf.dont_fork)) ? LOG_PERROR : 0), cnf_facility); |
| 679 | syslog(LOG_NOTICE, "%s v%s", PROGRAM_NAME, PACKAGE_VERSION); | 678 | syslog(LOG_NOTICE, "%s v%s", PROGRAM_NAME, PACKAGE_VERSION); |
| 680 | syslog(LOG_NOTICE, "echo plus enabled: %s", ((cnf_echoplus)) ? "yes" : "no"); | 679 | syslog(LOG_NOTICE, "echo plus enabled: %s", ((cnf_echoplus)) ? "yes" : "no"); |
| 681 | syslog(LOG_NOTICE, "random delay: %u us", cnf_delay); | 680 | syslog(LOG_NOTICE, "random delay: %u us", cnf_delay); |
