}
static int init_hostname(void) {
- const char *str;
-
- struct addrinfo *ai_list;
- int status;
+ const char *str = global_option_get("Hostname");
+ if ((str != NULL) && (str[0] != 0)) {
+ hostname_set(str);
+ return 0;
+ }
long hostname_len = sysconf(_SC_HOST_NAME_MAX);
if (hostname_len == -1) {
}
char hostname[hostname_len];
- str = global_option_get("Hostname");
- if ((str != NULL) && (str[0] != 0)) {
- hostname_set(str);
- return 0;
- }
-
if (gethostname(hostname, hostname_len) != 0) {
fprintf(stderr, "`gethostname' failed and no "
"hostname was configured.\n");
return -1;
}
+ hostname_set(hostname);
+
str = global_option_get("FQDNLookup");
if (IS_FALSE(str))
return 0;
+ struct addrinfo *ai_list;
struct addrinfo ai_hints = {.ai_flags = AI_CANONNAME};
- status = getaddrinfo(hostname, NULL, &ai_hints, &ai_list);
+ int status = getaddrinfo(hostname, NULL, &ai_hints, &ai_list);
if (status != 0) {
ERROR("Looking up \"%s\" failed. You have set the "
"\"FQDNLookup\" option, but I cannot resolve "
/* read options */
while (1) {
int c;
- c = getopt(argc, argv,
- "htTC:"
+ c = getopt(argc, argv, "htTC:"
#if COLLECT_DAEMON
- "fP:"
+ "fP:"
#endif
- );
+ );
if (c == -1)
break;
int exit_status = 0;
struct cmdline_config config = {
- .daemonize = 1,
- .create_basedir = 1,
- .configfile = CONFIGFILE,
+ .daemonize = 1, .create_basedir = 1, .configfile = CONFIGFILE,
};
read_cmdline(argc, argv, &config);
#ifdef KERNEL_LINUX
&& notify_upstart() == 0 && notify_systemd() == 0
#endif
- ) {
+ ) {
int status;
if ((pid = fork()) == -1) {