diff options
author | 諏訪子 <suwako@076.moe> | 2024-06-18 14:06:43 +0900 |
---|---|---|
committer | 諏訪子 <suwako@076.moe> | 2024-06-18 14:06:43 +0900 |
commit | 794dffcfe2204a6b7d92072e7af54e6e058dcbe9 (patch) | |
tree | ca289c31b554dbfa1ca211d50d877d3ec8a63475 /src | |
parent | e74aee761ae2470b2c205fefa70b2a46a4be1b0d (diff) |
マイクとカメラ(OpenBSDのみ)
Diffstat (limited to 'src')
-rw-r--r-- | src/cpu.c | 2 | ||||
-rw-r--r-- | src/recording.c | 32 | ||||
-rw-r--r-- | src/recording.h | 9 | ||||
-rw-r--r-- | src/uptime.c | 2 |
4 files changed, 43 insertions, 2 deletions
@@ -1,4 +1,4 @@ -#include "memory.h" +#include "cpu.h" #include <stdio.h> #include <string.h> diff --git a/src/recording.c b/src/recording.c new file mode 100644 index 0000000..8ed3d98 --- /dev/null +++ b/src/recording.c @@ -0,0 +1,32 @@ +#if defined(__OpenBSD__) +#include "recording.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); +} + +void display_recording_audio() { + run_rec_command("sysctl -n kern.audio.record"); +} + +void display_recording_video() { + run_rec_command("sysctl -n kern.video.record"); +} +#endif diff --git a/src/recording.h b/src/recording.h new file mode 100644 index 0000000..bf68106 --- /dev/null +++ b/src/recording.h @@ -0,0 +1,9 @@ +#if defined(__OpenBSD__) +#ifndef RECORDING_H +#define RECORDING_H + +void display_recording_audio(); +void display_recording_video(); + +#endif +#endif diff --git a/src/uptime.c b/src/uptime.c index da19270..8198669 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -1,4 +1,4 @@ -#include "memory.h" +#include "uptime.h" #include <stdio.h> #include <string.h> |