summaryrefslogtreecommitdiff
path: root/src/uptime.c
diff options
context:
space:
mode:
author諏訪子 <suwako@076.moe>2024-06-19 23:52:56 +0900
committer諏訪子 <suwako@076.moe>2024-06-19 23:52:56 +0900
commitb6e3f6cb5d1051777c35988f201e6730525e3389 (patch)
tree98679f1995f7b103f3314ce54fdf0d1c76df6dbd /src/uptime.c
parent8f378429801162d690dc68c0f15b483c1d291838 (diff)
掃除
Diffstat (limited to 'src/uptime.c')
-rw-r--r--src/uptime.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/uptime.c b/src/uptime.c
index 22b8356..56ea6b7 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -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\""));
}