errno.c 698 B

12345678910111213141516171819202122232425
  1. /* SPDX-License-Identifier: GPL-3.0+ */
  2. /*
  3. * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com>
  4. */
  5. #include <string.h>
  6. #include <errno.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */
  10. #define DESCRIPTION "Give information about error codes."
  11. #define OPERANDS "code"
  12. #include "../common/common.h"
  13. int main(int argc, char *argv[]) {
  14. long int error_code = 0;
  15. setvbuf(stdout, NULL, _IONBF, 0);
  16. if (argc == 2) {
  17. error_code = strtol(argv[1], NULL, 10);
  18. printf("errno %ld: %s\n", error_code, strerror(error_code));
  19. }
  20. else return print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION);
  21. return 0;
  22. }