logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

arch.c (595B)


  1. // utils-std: Collection of commonly available Unix tools
  2. // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: 0BSD
  4. #define _POSIX_C_SOURCE 200809L
  5. #include <errno.h>
  6. #include <stdio.h> // fprintf
  7. #include <string.h> // strerror
  8. #include <sys/utsname.h> // uname
  9. int
  10. main(void)
  11. {
  12. struct utsname name;
  13. if(uname(&name) < 0)
  14. {
  15. perror("arch: error: Failed to get system name");
  16. return 1;
  17. }
  18. if(puts(name.machine) < 0)
  19. {
  20. perror("arch: error: Failed to write machine architecture");
  21. return 1;
  22. }
  23. return 0;
  24. }