logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: db2317e7a9b9e67b56458cde2e791dbf62f805c8
parent 67d25ca4e1c794c799f15a65ab2fe51ffa43c57c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  5 Apr 2021 06:29:00 +0200

bin/sname: New

Diffstat:

Mbin/Makefile.config4++--
Abin/sname.122++++++++++++++++++++++
Abin/sname.c19+++++++++++++++++++
3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/bin/Makefile.config b/bin/Makefile.config @@ -1,2 +1,2 @@ -EXE = args basename date dirname echo lolcat mdate pwd range sizeof xcd -MAN1 = basename.1 date.1 dirname.1 lolcat.1 +EXE = args basename date dirname echo lolcat mdate pwd range sizeof sname xcd +MAN1 = basename.1 date.1 dirname.1 lolcat.1 sname.1 diff --git a/bin/sname.1 b/bin/sname.1 @@ -0,0 +1,22 @@ +.Dd 2021-04-05 +.Dt INAME 1 +.Os +.Sh NAME +.Nm sname +.Nd Structured output of system name and info +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION +.Nm +is equivalent to +.Xr uname 1 +except it's output is structed, which allows to reuse it more easily in other programs. +.Ar string . +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr uname 3 +.Sh STANDARDS +No applicable one known. +.Sh AUTHORS +.An Haelwenn (lanodan) Monnier Aq Mt contact@hacktivis.me diff --git a/bin/sname.c b/bin/sname.c @@ -0,0 +1,19 @@ +#include <sys/utsname.h> // utsname, uname() +#include <stdio.h> // printf() + +int main() +{ + struct utsname name; + if (uname(&name) != 0) { + perror("uname"); + return 1; + } + + printf("sysname=%s\n", name.sysname); + printf("nodename=%s\n", name.nodename); + printf("release=%s\n", name.release); + printf("version=%s\n", name.version); + printf("machine=%s\n", name.machine); + + return 0; +}