summaryrefslogtreecommitdiffstats
path: root/src/power/globals.c
blob: 2ba50759c1b08e253279a7d47c89393ec962bad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

#include "globals.h"

#define _XOPEN_SOURCE 500

#include <stdlib.h>
#include <unistd.h>
#include "trace.h"

static char *_hostname = NULL;

const char *get_system_name()
{
    if (_hostname == NULL) {
        _hostname = malloc(256 * sizeof(char));
        if (gethostname(_hostname, 255) == -1) {
            TRACE(4, "get_hostname(): gethostname returned -1");
            free(_hostname);
            _hostname = NULL;
        }
    }
    // TODO: try to get full qualified hostname
    return _hostname;
}