Files
haiku-beta6/src/bin/error.c
T

56 lines
884 B
C
Raw Normal View History

/*
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <SupportDefs.h>
2002-10-08 17:08:23 +00:00
#include <stdio.h>
#include <string.h>
2002-10-08 17:08:23 +00:00
#include <stdlib.h>
extern const char *__progname;
2002-10-08 17:08:23 +00:00
static void
usage(void)
2002-10-08 17:08:23 +00:00
{
fprintf(stderr, "usage: %s <error number>\n"
"Prints clear text error messages for given error numbers.\n", __progname);
exit(-1);
2002-10-08 17:08:23 +00:00
}
static void
print_error(char *number)
2002-10-08 17:08:23 +00:00
{
char *end;
int32 error = (int32)strtoll(number, &end, 0);
// strtol() cuts off hex numbers that have the highest bit set
if (end[0]) {
fprintf(stderr, "%s: invalid number (%s)\n", __progname, number);
2002-10-08 17:08:23 +00:00
exit(1);
}
printf("0x%lx: %s\n", error, strerror(error));
}
int
main(int argc, char *argv[])
{
int32 i;
if (argc < 2)
usage();
for (i = 1; i < argc; i++) {
print_error(argv[i]);
2002-10-08 17:08:23 +00:00
}
return 0;
2002-10-08 17:08:23 +00:00
}