diff options
author | Aaron Marcher <info@nulltime.net> | 2016-06-10 15:53:07 +0200 |
---|---|---|
committer | Aaron Marcher (drkhsh) <info@nulltime.net> | 2016-06-10 15:53:07 +0200 |
commit | 2e72b212d3019a23accfd9d001bcec5d3ee5ab46 (patch) | |
tree | 2af43dcdc530b5e43c23520f8cf23283eeca0771 /slstatus.c | |
parent | 67203c66600113259f4f25b1021c6395f3a62dd6 (diff) |
hostname function
Diffstat (limited to 'slstatus.c')
-rw-r--r-- | slstatus.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -208,6 +208,29 @@ entropy(const char *null) return smprintf("%d", entropy); } +/* hostname */ +char * +hostname(const char *null) +{ + char *hostname = ""; + FILE *fp; + + /* open hostname file */ + if (!(fp = fopen("/proc/sys/kernel/hostname", "r"))) { + fprintf(stderr, "Could not open hostname file.\n"); + return smprintf("n/a"); + } + + /* extract hostname */ + fscanf(fp, "%s", hostname); + + /* close hostname file */ + fclose(fp); + + /* return entropy */ + return smprintf("%s", hostname); +} + /* ip address */ char * ip(const char *interface) |