diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2024-10-23 10:04:58 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2024-10-23 10:04:58 +0200 |
| commit | 31cd2a3450eafbe0d22af41449276a90ea3dcb28 (patch) | |
| tree | dea69f12b776a3aad0c0d86649d1307deae91f88 /cmd/statrep/generic.ha | |
| parent | 0235e95c72181c640c9f19b1c134cc171fb435f9 (diff) | |
| download | statusdaemon-31cd2a3450eafbe0d22af41449276a90ea3dcb28.tar.gz | |
Diffstat (limited to 'cmd/statrep/generic.ha')
| -rw-r--r-- | cmd/statrep/generic.ha | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/cmd/statrep/generic.ha b/cmd/statrep/generic.ha deleted file mode 100644 index fb61ab0..0000000 --- a/cmd/statrep/generic.ha +++ /dev/null @@ -1,41 +0,0 @@ -use os::exec; -use shlex; -use strings; -use io; -use os; - -type generic = struct { - section: section, - cmd: str, - value: str, -}; - -fn buildgeneric(cmd: str) generic = { - let gen = generic { - section = section { - label = "generic: ", - }, - cmd = cmd, - ... - }; - updategeneric(&gen)!; - return gen; -}; - -fn updategeneric(gen: *generic) (void | shlex::syntaxerr | exec::error) = { - const spl = shlex::split(gen.cmd)?; - const cmd = exec::cmd(spl[0], spl[1..]...)?; - let pipe = exec::pipe(); - exec::addfile(&cmd, os::stdout_file, pipe.1); - let proc = exec::start(&cmd)?; - io::close(pipe.1)!; - let data = io::drain(pipe.0)!; - defer free(data); - io::close(pipe.0)!; - exec::wait(&proc)!; - gen.value = strings::dup(strings::trim(strings::fromutf8(data)!)); -}; - -fn finishgeneric(gen: *generic) void = { - free(gen.value); -}; |
