diff options
Diffstat (limited to 'errno.c')
-rw-r--r-- | errno.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-3.0+ */ +/* + * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> + */ +#include <string.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define DESCRIPTION "Give information about error codes." +#define OPERANDS "code" +#include "common.h" + +#ifdef FASESBOX +int errno_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif + long int error_code = 0; + setvbuf(stdout, NULL, _IONBF, 0); + if (argc == 2) { + error_code = strtol(argv[1], NULL, 10); + printf("errno %ld: %s\n", error_code, strerror(error_code)); + } + else return print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION); + return 0; +} |