logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

sname.c (702B)


  1. // Collection of Unix tools, comparable to coreutils
  2. // SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
  4. #include <stdio.h> // printf(), perror()
  5. #include <sys/utsname.h> // utsname, uname()
  6. int
  7. main()
  8. {
  9. struct utsname name;
  10. if(uname(&name) != 0)
  11. {
  12. perror("uname");
  13. return 1;
  14. }
  15. int ret = printf("sysname=%s\nnodename=%s\nrelease=%s\nversion=%s\nmachine=%s\n",
  16. name.sysname,
  17. name.nodename,
  18. name.release,
  19. name.version,
  20. name.machine);
  21. if(ret < 0)
  22. {
  23. perror("sname");
  24. return 1;
  25. }
  26. return 0;
  27. }