aboutsummaryrefslogtreecommitdiff
path: root/extras/errno.c
blob: 050af5ba4cceb74693fc3c26117167f01559c6d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* 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/common.h */
#define DESCRIPTION "Give information about error codes."
#define OPERANDS    "code"
#include "../common/common.h"

int main(int argc, char *argv[]) {
	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;
}