2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 #include <SupportDefs.h>
14 extern const char *__progname
;
20 #define E(e) { e, #e }
22 // tr ' ,=\t()+' '\n\n\n\n\n\n\n' <headers/os/support/Errors.h | grep '\(^B_\|^E[A-Z0-9]\)' | sort | uniq | awk '{ print "\tE(" $1 ")," }'
24 E(B_AMBIGUOUS_APP_LAUNCH
),
31 E(B_BAD_MIME_SNIFFER_RULE
),
34 E(B_BAD_SCRIPT_SYNTAX
),
39 E(B_BAD_THREAD_STATE
),
42 E(B_BUFFER_NOT_AVAILABLE
),
43 #ifdef B_BUFFER_OVERFLOW
49 E(B_CROSS_DEVICE_LINK
),
50 E(B_DEBUGGER_ALREADY_INSTALLED
),
51 E(B_DEVICE_ERROR_BASE
),
53 #ifdef B_DEVICE_NOT_FOUND
54 E(B_DEVICE_NOT_FOUND
),
56 E(B_DEV_BAD_DRIVE_NUM
),
58 E(B_DEV_CONFIGURATION_ERROR
),
60 E(B_DEV_DATA_OVERRUN
),
61 E(B_DEV_DATA_UNDERRUN
),
62 E(B_DEV_DISABLED_BY_USER
),
64 E(B_DEV_FIFO_OVERRUN
),
65 E(B_DEV_FIFO_UNDERRUN
),
66 E(B_DEV_FORMAT_ERROR
),
68 E(B_DEV_INVALID_IOCTL
),
69 E(B_DEV_INVALID_PIPE
),
70 E(B_DEV_MEDIA_CHANGED
),
71 E(B_DEV_MEDIA_CHANGE_REQUESTED
),
72 E(B_DEV_MULTIPLE_ERRORS
),
78 E(B_DEV_RECALIBRATE_ERROR
),
79 E(B_DEV_RESOURCE_CONFLICT
),
84 E(B_DEV_UNEXPECTED_PID
),
87 E(B_DIRECTORY_NOT_EMPTY
),
96 #ifdef B_FILE_TOO_LARGE
99 E(B_GENERAL_ERROR_BASE
),
100 E(B_INTERFACE_ERROR_BASE
),
104 E(B_LAST_BUFFER_ERROR
),
106 E(B_LAUNCH_FAILED_APP_IN_TRASH
),
107 E(B_LAUNCH_FAILED_APP_NOT_FOUND
),
108 E(B_LAUNCH_FAILED_EXECUTABLE
),
109 E(B_LAUNCH_FAILED_FILES_APP_NOT_FOUND
),
110 E(B_LAUNCH_FAILED_NO_PREFERRED_APP
),
111 E(B_LAUNCH_FAILED_NO_RESOLVE_LINK
),
113 E(B_MAIL_ACCESS_ERROR
),
114 E(B_MAIL_ERROR_BASE
),
115 E(B_MAIL_INVALID_MAIL
),
117 E(B_MAIL_NO_RECIPIENT
),
118 E(B_MAIL_UNKNOWN_FIELD
),
119 E(B_MAIL_UNKNOWN_HOST
),
120 E(B_MAIL_UNKNOWN_USER
),
121 E(B_MAIL_WRONG_PASSWORD
),
122 E(B_MEDIA_ERROR_BASE
),
123 E(B_MESSAGE_TO_SELF
),
124 E(B_MIDI_ERROR_BASE
),
125 E(B_MISMATCHED_VALUES
),
126 E(B_MISSING_LIBRARY
),
132 E(B_NOT_AN_EXECUTABLE
),
133 E(B_NOT_A_DIRECTORY
),
135 #ifdef B_NOT_SUPPORTED
145 E(B_NO_MORE_THREADS
),
146 E(B_NO_PRINT_SERVER
),
151 E(B_PARTITION_TOO_SMALL
),
152 E(B_PERMISSION_DENIED
),
153 E(B_POSIX_ERROR_BASE
),
154 E(B_PRINT_ERROR_BASE
),
155 E(B_READ_ONLY_DEVICE
),
156 E(B_RESOURCE_NOT_FOUND
),
157 E(B_RESOURCE_UNAVAILABLE
),
158 #ifdef B_RESULT_NOT_REPRESENTABLE
159 E(B_RESULT_NOT_REPRESENTABLE
),
161 E(B_SERVER_NOT_FOUND
),
162 #ifdef B_SHUTDOWN_CANCELLED
163 E(B_SHUTDOWN_CANCELLED
),
165 #ifdef B_SHUTTING_DOWN
168 E(B_STORAGE_ERROR_BASE
),
169 E(B_STREAM_NOT_FOUND
),
170 E(B_SUBSCRIBER_NOT_ENTERED
),
172 #ifdef B_TOO_MANY_ARGS
175 E(B_TRANSLATION_ERROR_BASE
),
176 E(B_UNKNOWN_MIME_TYPE
),
300 fprintf(stderr
, "usage: %s <error number>\n"
301 "Prints clear text error messages for given error numbers.\n", __progname
);
307 print_error(char *number
)
310 int32 error
= (int32
)strtoll(number
, &end
, 0);
311 // strtol() cuts off hex numbers that have the highest bit set
314 // not a number, check names
315 struct error_pair
*p
= kErrorNames
;
316 while (p
->name
&& strcmp(p
->name
, number
))
319 fprintf(stderr
, "%s: invalid number (%s)\n", __progname
, number
);
325 printf("0x%" B_PRIx32
": %s\n", error
, strerror(error
));
330 main(int argc
, char *argv
[])
337 for (i
= 1; i
< argc
; i
++) {
338 print_error(argv
[i
]);