このコミットが含まれているのは:
守矢諏訪子 2024-06-19 23:52:56 +09:00
コミット b6e3f6cb5d
18個のファイルの変更186行の追加412行の削除

88
main.c
ファイルの表示

@ -73,6 +73,7 @@ size_t logosize = 11;
};
#endif
const char *reset = RESET;
size_t ls = logosize <= MIN_SIZE ? MIN_SIZE : logosize;
if (issmall) {
size_t ne = sizeof(LOGO_SMALL) / sizeof(LOGO_SMALL[0]);
@ -83,45 +84,41 @@ size_t logosize = 11;
}
printf("%s ", LOGO[lc]);
printf("%s", titlecolor);
display_user_name();
printf(RESET);
printf("@");
printf("%s", titlecolor);
display_user_host();
printf(RESET);
lc++;
if (display_user_name() || display_user_host()) {
printf(
"%s%s%s@%s%s%s\n",
titlecolor, display_user_name(), reset,
titlecolor, display_user_host(), reset
);
lc++;
}
printf("%s ", LOGO[lc]);
printf("------------------\n");
lc++;
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "OS", ": ");
display_os_name();
printf(" ");
display_os_vers();
printf(" ");
display_os_arch();
printf("\n");
lc++;
if (display_os()) {
printf("%sOS%s: %s\n", color, reset, display_os());
lc++;
}
#if defined(__linux__)
if (display_distro() != NULL) {
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Distro", ": ");
printf("%s\n", display_distro());
printf("%s ", LOGO[lc]);
if (display_distro()) {
printf("%sDistro%s: %s\n", color, reset, display_distro());
lc++;
}
#endif
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Host", ": ");
printf("%s%s%s%s", color, "Host", reset, ": ");
display_host_model();
printf("\n");
lc++;
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Uptime", ": ");
printf("%s%s%s%s", color, "Uptime", reset, ": ");
display_days();
printf(", ");
display_time();
@ -130,43 +127,46 @@ size_t logosize = 11;
#if defined(__OpenBSD__)
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Recording", ": ");
printf("audio = ");
display_recording_audio();
printf(", video = ");
display_recording_video();
printf("\n");
lc++;
if (display_recording_audio() || display_recording_video()) {
printf("%sRecording%s: ", color, reset);
if (display_recording_audio()) {
printf("audio = %s", display_recording_audio());
if (display_recording_video()) printf(", ");
}
if (display_recording_video()) {
printf("video = %s", display_recording_video());
}
printf("\n");
lc++;
}
#endif
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Packages", ": ");
display_packages();
printf("\n");
lc++;
if (display_packages()) {
printf("%sPackages%s: %s\n", color, reset, display_packages());
lc++;
}
printf("%s ", LOGO[lc]);
if (display_resolution()) {
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Resolution", ": ");
printf("%s\n", display_resolution());
printf("%sResolution%s: %s\n", color, reset, display_resolution());
lc++;
}
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "CPU", ": ");
display_cpu();
printf("\n");
lc++;
if (display_cpu()) {
printf("%sCPU%s: %s\n", color, reset, display_cpu());
lc++;
}
printf("%s ", LOGO[lc]);
if (display_gpu()) {
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "GPU", ": ");
printf("%s\n", display_gpu());
printf("%sGPU%s: %s\n", color, reset, display_gpu());
lc++;
}
printf("%s ", LOGO[lc]);
printf("%s%s%s"RESET, color, "Memory", ": ");
printf("%s%s%s%s", color, "Memory", reset, ": ");
display_memory();
printf("\n");
lc++;

60
src/common.c ノーマルファイル
ファイルの表示

@ -0,0 +1,60 @@
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
long long int run_command_lld(const char *command) {
char buf[128];
long long int res = 0;
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "コマンドを実効に失敗: %s", command);
return 0;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
}
res = atoll(buf);
pclose(p);
return res;
}
const char *run_command_s(const char *command) {
char buf[128];
char *out = NULL;
size_t outsize = 0;
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "コマンドを実効に失敗: %s", command);
return NULL;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
size_t len = strlen(buf);
char *nout = realloc(out, outsize + len + 1);
if (nout == NULL) {
perror("メモリの役割に失敗");
free(out);
pclose(p);
return NULL;
}
out = nout;
memccpy(out + outsize, buf, sizeof(buf), len);
outsize += len;
out[outsize] = '\0';
}
pclose(p);
return out;
}

7
src/common.h ノーマルファイル
ファイルの表示

@ -0,0 +1,7 @@
#ifndef COMMON_H
#define COMMON_H
long long int run_command_lld(const char *command);
const char *run_command_s(const char *command);
#endif

ファイルの表示

@ -1,37 +1,17 @@
#include "cpu.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void run_cpu_command(const char *command) {
char buf[128];
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "CPUコマンドを実効に失敗: %s", command);
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", buf);
}
pclose(p);
}
void display_cpu() {
const char *display_cpu() {
#if defined(__NetBSD__)
run_cpu_command("sysctl -n machdep.cpu_brand | sed 's/(R)//' | "
return run_command_s("sysctl -n machdep.cpu_brand | sed 's/(R)//' | "
"sed 's/(TM)//' | sed 's/CPU //' | sed 's/Processor//'");
run_cpu_command("echo \" (\" && sysctl -n hw.ncpu && echo \" core)\"");
return run_command_s("echo \" (\" && sysctl -n hw.ncpu && echo \" core)\"");
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
run_cpu_command("sysctl -n hw.model | sed 's/(R)//' | "
return run_command_s("sysctl -n hw.model | sed 's/(R)//' | "
"sed 's/(TM)//' | sed 's/CPU //' | sed 's/Processor//'");
run_cpu_command("echo \" (\" && sysctl -n hw.ncpu && echo \" core)\"");
return run_command_s("echo \" (\" && sysctl -n hw.ncpu && echo \" core)\"");
#elif defined(__linux__)
run_cpu_command("cat /proc/cpuinfo | awk -F '\\\\s*: | @' "
return run_command_s("cat /proc/cpuinfo | awk -F '\\\\s*: | @' "
"'/model name|Hardware|Processor|^cpu model|chip type|^cpu type/ { "
"cpu=$2; if ($1 == \"Hardware\") exit } END { print cpu }' | "
"sed 's/(R)//' | sed 's/(TM)//' | sed 's/CPU //' | sed 's/ Processor//' | "
@ -62,6 +42,6 @@ void display_cpu() {
}
fclose(fp);
run_cpu_command("echo \"GHz (\" && nproc && echo \" core)\"");
return run_command_s("echo \"GHz (\" && nproc && echo \" core)\"");
#endif
}

ファイルの表示

@ -1,6 +1,6 @@
#ifndef CPU_H
#define CPU_H
void display_cpu();
const char *display_cpu();
#endif

ファイルの表示

@ -1,59 +1,25 @@
#include "gpu.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) &&\
!defined(__linux__) && !defined(__DragonFly__)
#include <unistd.h>
const char *run_gpu_command(const char *command) {
char buf[128];
char *out = NULL;
size_t outsize = 0;
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "GPUコマンドを実効に失敗: %s", command);
return NULL;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
size_t len = strlen(buf);
char *nout = realloc(out, outsize + len + 1);
if (nout == NULL) {
perror("メモリの役割に失敗");
free(out);
pclose(p);
return NULL;
}
out = nout;
memccpy(out + outsize, buf, sizeof(buf), len);
outsize += len;
out[outsize] = '\0';
}
pclose(p);
return out;
}
#endif
const char *display_gpu() {
#if defined(__OpenBSD__)
return run_gpu_command("dmesg | grep -i graphics | sed 's/^.* \"//' | "
return run_command_s("dmesg | grep -i graphics | sed 's/^.* \"//' | "
"sed 's/\".*$//'");
#elif defined(__NetBSD__)
return run_gpu_command("dmesg | grep -i graphics | sed 's/^.*: //' | "
return run_command_s("dmesg | grep -i graphics | sed 's/^.*: //' | "
"sed 's/ (.*$//'");
#elif defined(__FreeBSD__) || defined(__DragonFly__)
return run_gpu_command("pciconf -lv | grep -B 4 -F \"VGA\" | "
return run_command_s("pciconf -lv | grep -B 4 -F \"VGA\" | "
"grep -F \"device\" | sed 's/^.* device//' | "
"sed \"s/^.* '//\" | sed \"s/'//\" | tail -1 | "
"sed 's/ Core Processor Integrated Graphics Controller//'");
#elif defined(__linux__)
return run_gpu_command("lspci | grep VGA | sed 's/^.*: //' | "
return run_command_s("lspci | grep VGA | sed 's/^.*: //' | "
"sed 's/Corporation //' | sed 's/ (.*$//' | "
"sed 's/Advanced Micro Devices//' | "
"sed 's/, Inc. //' | sed 's/Navi [0-9]* //' | "
@ -67,7 +33,7 @@ const char *display_gpu() {
access("/usr/X11R7/bin/glxinfo", F_OK) == -1 &&
access("/usr/pkg/bin/glxinfo", F_OK) == -1
) return NULL;
return run_gpu_command("glxinfo -B | grep -F 'OpenGL renderer string' | "
return run_command_s("glxinfo -B | grep -F 'OpenGL renderer string' | "
"sed 's/OpenGL renderer string: //' | sed 's/Mesa //' | "
"sed 's/DRI //' | sed 's/(R)//' | sed 's/(.*$//'");
#endif

ファイルの表示

@ -6,8 +6,6 @@
#if defined(__linux__)
#include <unistd.h>
int skip = 0;
#endif
const char *run_host_command(const char *command) {
@ -38,8 +36,7 @@ const char *run_host_command(const char *command) {
strstr(buf, "INVALID") != NULL ||
strstr(buf, "All Series") != NULL
) {
skip = 1;
break;
return NULL;
}
#endif
@ -113,7 +110,7 @@ void display_host_model() {
if (cmd2) {
const char *model = run_host_command(cmd2);
if (!skip) printf(" %s", model);
if (model) printf(" %s", model);
}
#elif defined(__APPLE__)
printf("%s", run_host_command("sysctl -n hw.model"));

ファイルの表示

@ -1,60 +1,39 @@
#include "memory.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
long long int run_mem_command(const char *command) {
char buf[128];
long long int res = 0;
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "メモリコマンドを実効に失敗: %s", command);
return 0;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
}
res = atoll(buf);
pclose(p);
return res;
}
void display_memory() {
long long int memused = 0;
long long int memtotal = 0;
#if defined(__OpenBSD__)
memused = run_mem_command("vmstat | awk 'END {printf $3}' | sed 's/M//'");
memtotal = run_mem_command("sysctl -n hw.physmem") / 1024LL / 1024LL;
memused = run_command_lld("vmstat | awk 'END {printf $3}' | sed 's/M//'");
memtotal = run_command_lld("sysctl -n hw.physmem") / 1024LL / 1024LL;
#elif defined(__FreeBSD__) || defined(__DragonFly__)
// 13M Active, 200M Inact, 184M Laundry,
long long int used1 = run_mem_command("top | grep \"Mem:\" | awk '{print $2}' | "
long long int used1 = run_command_lld("top | grep \"Mem:\" | awk '{print $2}' | "
"sed 's/M//'");
long long int used2 = run_mem_command("top | grep \"Mem:\" | awk '{print $4}' | "
long long int used2 = run_command_lld("top | grep \"Mem:\" | awk '{print $4}' | "
"sed 's/M//'");
long long int used3 = run_mem_command("top | grep \"Mem:\" | awk '{print $6}' | "
long long int used3 = run_command_lld("top | grep \"Mem:\" | awk '{print $6}' | "
"sed 's/M//'");
long long int used4 = run_mem_command("top | grep \"ARC:\" | awk '{print $6}' | "
long long int used4 = run_command_lld("top | grep \"ARC:\" | awk '{print $6}' | "
"sed 's/M//'");
memused = used1 + used2 + used3 + used4;
memtotal = run_mem_command("sysctl -n hw.physmem") / 1024LL / 1024LL;
memtotal = run_command_lld("sysctl -n hw.physmem") / 1024LL / 1024LL;
#elif defined(__NetBSD__)
memused = run_mem_command("top | grep \"Memory:\" | awk '{print $2}' | "
memused = run_command_lld("top | grep \"Memory:\" | awk '{print $2}' | "
"sed 's/M//'");
memtotal = run_mem_command("sysctl -n hw.physmem64") / 1024LL / 1024LL;
memtotal = run_command_lld("sysctl -n hw.physmem64") / 1024LL / 1024LL;
#elif defined(__minix)
memtotal = run_mem_command("sysctl -n hw.physmem") / 1024LL / 1024LL;
memtotal = run_command_lld("sysctl -n hw.physmem") / 1024LL / 1024LL;
#elif defined(__linux__)
long long int memaval = run_mem_command("cat /proc/meminfo | grep MemAvailable | "
long long int memaval = run_command_lld("cat /proc/meminfo | grep MemAvailable | "
"awk '{print $2}'") / 1024LL;
memtotal = run_mem_command("cat /proc/meminfo | grep MemTotal | "
memtotal = run_command_lld("cat /proc/meminfo | grep MemTotal | "
"awk '{print $2}'") / 1024LL;
memused = memtotal - memaval;
/* memused = run_mem_command("cat /proc/meminfo | grep MemFree | "
/* memused = run_command_lld("cat /proc/meminfo | grep MemFree | "
"awk '{print $2}'") / 1024LL; */
#endif

ファイルの表示

@ -1,52 +1,7 @@
#include "os.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
void display_os_name() {
char buf[64];
FILE *p = popen("uname -s", "r");
if (!p) {
fprintf(stderr, "「uname」コマンドを実効に失敗");
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", buf);
}
pclose(p);
}
void display_os_vers() {
char buf[16];
FILE *p = popen("uname -r", "r");
if (!p) {
fprintf(stderr, "「uname」コマンドを実効に失敗");
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", buf);
}
pclose(p);
}
void display_os_arch() {
char buf[16];
FILE *p = popen("uname -m", "r");
if (!p) {
fprintf(stderr, "「uname」コマンドを実効に失敗");
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", buf);
}
pclose(p);
const char *display_os() {
return run_command_s("uname -s && echo \" \" && uname -r && "
"echo \" \" && uname -m");
}

ファイルの表示

@ -1,8 +1,6 @@
#ifndef OS_H
#define OS_H
void display_os_name();
void display_os_vers();
void display_os_arch();
const char *display_os();
#endif

ファイルの表示

@ -1,65 +1,22 @@
#include "packages.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#if defined(__linux__)
#include "distro.h"
#include <unistd.h>
/*const char *distroname;*/
#include "distro.h"
#endif
const char *run_package_command(const char *command) {
char buf[64];
char *out = NULL;
size_t outsize = 0;
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "パッケージコマンドを実効に失敗: %s", command);
return NULL;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
size_t len = strlen(buf);
char *nout = realloc(out, outsize + len + 1);
if (nout == NULL) {
perror("メモリの役割に失敗");
free(out);
pclose(p);
return NULL;
}
out = nout;
memccpy(out + outsize, buf, sizeof(buf), len);
outsize += len;
out[outsize] = '\0';
}
pclose(p);
return out;
}
void display_packages() {
const char *display_packages() {
#if defined(__OpenBSD__) || defined(__NetBSD__)
printf("%s (pkg_info)", run_package_command("pkg_info -a | wc -l | "
"sed \"s/ //g\""));
return run_command_s("pkg_info -a | wc -l | sed \"s/ //g\"");
#elif defined(__FreeBSD__) || defined(__DragonFly__)
printf("%s (pkg)", run_package_command("pkg info -a | wc -l | "
"sed \"s/ //g\""));
return run_command_s("pkg info -a | wc -l | sed \"s/ //g\"");
#elif defined(__linux__)
if (access("/bin/xbps-query", F_OK) != -1) {
printf("%s (xbps-query)", run_package_command("xbps-query -l | wc -l | "
"sed \"s/ //g\""));
return run_command_s("xbps-query -l | wc -l | sed \"s/ //g\"");
} else if (access("/usr/bin/dpkg-query", F_OK) != -1) {
printf("%s (dpkg)", run_package_command("dpkg-query -f '.\n' -W | wc -l | "
"sed \"s/ //g\""));
return run_command_s("dpkg-query -f '.\n' -W | wc -l | sed \"s/ //g\"");
}
#endif
}

ファイルの表示

@ -1,6 +1,6 @@
#ifndef PACKAGES_H
#define PACKAGES_H
void display_packages();
const char *display_packages();
#endif

ファイルの表示

@ -1,32 +1,12 @@
#if defined(__OpenBSD__)
#include "recording.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
void run_rec_command(const char *command) {
char buf[128];
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "録画コマンドを実効に失敗: %s", command);
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", strncmp(buf, "0", strlen(buf)) ? "off" : "on");
}
pclose(p);
const char *display_recording_audio() {
return run_command_s("sysctl -n kern.audio.record");
}
void display_recording_audio() {
run_rec_command("sysctl -n kern.audio.record");
}
void display_recording_video() {
run_rec_command("sysctl -n kern.video.record");
const char *display_recording_video() {
return run_command_s("sysctl -n kern.video.record");
}
#endif

ファイルの表示

@ -2,8 +2,8 @@
#ifndef RECORDING_H
#define RECORDING_H
void display_recording_audio();
void display_recording_video();
const char *display_recording_audio();
const char *display_recording_video();
#endif
#endif

ファイルの表示

@ -1,49 +1,10 @@
#include "resolution.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
const char *run_res_command(const char *command) {
char buf[128];
char *out = NULL;
size_t outsize = 0;
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "解像度コマンドを実効に失敗: %s", command);
return NULL;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
size_t len = strlen(buf);
char *nout = realloc(out, outsize + len + 1);
if (nout == NULL) {
perror("メモリの役割に失敗");
free(out);
pclose(p);
return NULL;
}
out = nout;
memccpy(out + outsize, buf, sizeof(buf), len);
outsize += len;
out[outsize] = '\0';
}
pclose(p);
return out;
}
#include "common.h"
const char *display_resolution() {
return run_res_command("xrandr --nograb --current | "
"awk -F 'connected |\\\\+|\\\\(' '/ "
"connected.*[0-9]+x[0-9]+\\+/ && $2 {printf $2 "
"\", \"}' | sed 's/primary //' | "
"sed 's/,\\([^,]*\\)$/\\1/'");
return run_command_s("xrandr --nograb --current | "
"awk -F 'connected |\\\\+|\\\\(' '/ "
"connected.*[0-9]+x[0-9]+\\+/ && $2 {printf $2 "
"\", \"}' | sed 's/primary //' | "
"sed 's/,\\([^,]*\\)$/\\1/'");
}

ファイルの表示

@ -1,33 +1,13 @@
#include "uptime.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void run_uptime_command(const char *command) {
char buf[128];
FILE *p = popen(command, "r");
if (!p) {
fprintf(stderr, "起動時間コマンドを実効に失敗: %s", command);
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", buf);
}
pclose(p);
}
void display_days() {
run_uptime_command("uptime | awk '{print $3}' && echo \" days\"");
printf("%s", run_command_s("uptime | awk '{print $3}' && echo \" days\""));
}
void display_time() {
/* run_uptime_command("uptime | awk '{print $3}' | sed 's/,//' | " */
/* "sed 's/:/ hours, /' && echo \" mins\""); */
run_uptime_command("uptime | awk '{print $5}' | sed 's/,//' | "
"sed 's/:/ hours, /' && echo \" mins\"");
printf("%s", run_command_s("uptime | awk '{print $5}' | sed 's/,//' | "
"sed 's/:/ hours, /' && echo \" mins\""));
}

ファイルの表示

@ -1,64 +1,18 @@
#include "user.h"
#include "common.h"
#include <stdio.h>
#include <string.h>
void run_user_command(const char *command) {
char buf[64];
#if defined(__NetBSD__) || defined(__FreeBSD__)
FILE *p = popen(command, "r");
if (!p) {
snprintf(buf, sizeof(buf), "「%s」コマンドを見つけられません。", command);
perror(buf);
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
printf("%s", buf);
}
pclose(p);
//
#else
FILE *f = fopen(command, "r");
if (!f) {
snprintf(buf, sizeof(buf), "「%s」ファイルを見つけられません。", command);
perror(buf);
return;
}
while (fgets(buf, sizeof(buf), f) != NULL) {
printf("%s", buf);
}
fclose(f);
#endif
const char *display_user_name() {
return run_command_s("whoami");
}
void display_user_name() {
char buf[128];
FILE *p = popen("whoami", "r");
if (!p) {
fprintf(stderr, "「whoami」コマンドを実効に失敗");
return;
}
while (fgets(buf, sizeof(buf), p) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
printf("%s", buf);
}
pclose(p);
}
void display_user_host() {
const char *display_user_host() {
#if defined(__OpenBSD__)
run_user_command("/etc/myname");
return run_command_s("cat /etc/myname");
#elif defined(__NetBSD__)
run_user_command("hostname");
return run_command_s("hostname");
#elif defined(__FreeBSD__)
run_user_command("sysctl -n kern.hostname");
return run_command_s("sysctl -n kern.hostname");
#else
run_user_command("/etc/hostname");
return run_command_s("cat /etc/hostname");
#endif
}

ファイルの表示

@ -1,7 +1,7 @@
#ifndef USER_H
#define USER_H
void display_user_name();
void display_user_host();
const char *display_user_name();
const char *display_user_host();
#endif