logo

utils-std

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

arch.c (576B)


  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 <stdio.h> // fprintf
  6. #include <string.h> // strerror
  7. #include <sys/utsname.h> // uname
  8. int
  9. main(void)
  10. {
  11. struct utsname name;
  12. if(uname(&name) < 0)
  13. {
  14. perror("arch: error: Failed to get system name");
  15. return 1;
  16. }
  17. if(puts(name.machine) < 0)
  18. {
  19. perror("arch: error: Failed to write machine architecture");
  20. return 1;
  21. }
  22. return 0;
  23. }