From 794dffcfe2204a6b7d92072e7af54e6e058dcbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Tue, 18 Jun 2024 14:06:43 +0900 Subject: =?UTF-8?q?=E3=83=9E=E3=82=A4=E3=82=AF=E3=81=A8=E3=82=AB=E3=83=A1?= =?UTF-8?q?=E3=83=A9=EF=BC=88OpenBSD=E3=81=AE=E3=81=BF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recording.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/recording.c (limited to 'src/recording.c') 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 +#include +#include + +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 -- cgit v1.2.3