Function renamed for the consistency. Incomplete coding completed.

Tested for the empty and invalid values.  Parameter is ignored in those cases.
This commit is contained in:
KORAY VATANSEVER 2022-08-09 13:06:45 +03:00
parent 22af3ea567
commit 2b91f0ad8b
2 changed files with 10 additions and 2 deletions

View File

@ -167,7 +167,7 @@ static int int_fac[]={LOG_AUTH , LOG_CRON , LOG_DAEMON ,
static int syslog_facility = 0;
static int str2facility(char *s)
static int str_to_syslog_facility(char *s)
{
int i;
for (i=0; str_fac[i]; i++) {
@ -182,8 +182,9 @@ void set_syslog_facility(char *val)
if(val == NULL){
return;
}
int tmp = str2facility(val);
int tmp = str_to_syslog_facility(val);
if(tmp == -1){
TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "WARNING: invalid syslog-facility value (%s); ignored.\n", val);
return;
}
syslog_facility = tmp;

View File

@ -991,6 +991,7 @@ static const struct myoption long_options[] = {
{ "no-rfc5780", optional_argument, NULL, NO_RFC5780 },
{ "no-stun-backward-compatibility", optional_argument, NULL, NO_STUN_BACKWARD_COMPATIBILITY_OPT },
{ "response-origin-only-with-rfc5780", optional_argument, NULL, RESPONSE_ORIGIN_ONLY_WITH_RFC5780_OPT },
{ "syslog-facility", required_argument, NULL, SYSLOG_FACILITY_OPT },
{ NULL, no_argument, NULL, 0 }
};
@ -1681,6 +1682,7 @@ static void set_option(int c, char *value)
case SIMPLE_LOG_OPT:
case NEW_LOG_TIMESTAMP_OPT:
case NEW_LOG_TIMESTAMP_FORMAT_OPT:
case SYSLOG_FACILITY_OPT:
case 'c':
case 'n':
case 'h':
@ -1811,6 +1813,8 @@ static void read_config_file(int argc, char **argv, int pass)
use_new_log_timestamp_format=1;
} else if ((pass==0) && (c==NEW_LOG_TIMESTAMP_FORMAT_OPT)) {
set_turn_log_timestamp_format(value);
} else if((pass==0) && (c==SYSLOG_FACILITY_OPT)) {
set_syslog_facility(value);
} else if((pass == 1) && (c != 'u')) {
set_option(c, value);
} else if((pass == 2) && (c == 'u')) {
@ -2297,6 +2301,9 @@ int main(int argc, char **argv)
case NEW_LOG_TIMESTAMP_FORMAT_OPT:
set_turn_log_timestamp_format(optarg);
break;
case SYSLOG_FACILITY_OPT:
set_syslog_facility(optarg);
break;
default:
;
}