summaryrefslogtreecommitdiff
path: root/src/os.c
diff options
context:
space:
mode:
author諏訪子 <suwako@076.moe>2024-06-17 22:41:46 +0900
committer諏訪子 <suwako@076.moe>2024-06-17 22:44:17 +0900
commitcf13f2d8c1622a46f6499dcb762ea2b9370d99fc (patch)
treee3a3cefd85fd1bd3d77e76f074990f8452888dc9 /src/os.c
最初コミット
Diffstat (limited to 'src/os.c')
-rw-r--r--src/os.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/os.c b/src/os.c
new file mode 100644
index 0000000..4662acd
--- /dev/null
+++ b/src/os.c
@@ -0,0 +1,52 @@
+#include "os.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);
+}