1 /* 2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <SupportDefs.h> 8 9 #include <stdio.h> 10 #include <string.h> 11 #include <stdlib.h> 12 13 14 extern const char *__progname; 15 16 struct error_pair { 17 status_t value; 18 const char *name; 19 } kErrorNames[] = { 20 #define E(e) { e, #e } 21 // generated by: 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 ")," }' 23 E(B_ALREADY_RUNNING), 24 E(B_AMBIGUOUS_APP_LAUNCH), 25 E(B_APP_ERROR_BASE), 26 E(B_BAD_ADDRESS), 27 E(B_BAD_DATA), 28 E(B_BAD_HANDLER), 29 E(B_BAD_IMAGE_ID), 30 E(B_BAD_INDEX), 31 E(B_BAD_MIME_SNIFFER_RULE), 32 E(B_BAD_PORT_ID), 33 E(B_BAD_REPLY), 34 E(B_BAD_SCRIPT_SYNTAX), 35 E(B_BAD_SEM_ID), 36 E(B_BAD_SUBSCRIBER), 37 E(B_BAD_TEAM_ID), 38 E(B_BAD_THREAD_ID), 39 E(B_BAD_THREAD_STATE), 40 E(B_BAD_TYPE), 41 E(B_BAD_VALUE), 42 E(B_BUFFER_NOT_AVAILABLE), 43 #ifdef B_BUFFER_OVERFLOW 44 E(B_BUFFER_OVERFLOW), 45 #endif 46 E(B_BUSTED_PIPE), 47 E(B_BUSY), 48 E(B_CANCELED), 49 E(B_CROSS_DEVICE_LINK), 50 E(B_DEBUGGER_ALREADY_INSTALLED), 51 E(B_DEVICE_ERROR_BASE), 52 E(B_DEVICE_FULL), 53 #ifdef B_DEVICE_NOT_FOUND 54 E(B_DEVICE_NOT_FOUND), 55 #endif 56 E(B_DEV_BAD_DRIVE_NUM), 57 E(B_DEV_BAD_PID), 58 E(B_DEV_CONFIGURATION_ERROR), 59 E(B_DEV_CRC_ERROR), 60 E(B_DEV_DATA_OVERRUN), 61 E(B_DEV_DATA_UNDERRUN), 62 E(B_DEV_DISABLED_BY_USER), 63 E(B_DEV_DOOR_OPEN), 64 E(B_DEV_FIFO_OVERRUN), 65 E(B_DEV_FIFO_UNDERRUN), 66 E(B_DEV_FORMAT_ERROR), 67 E(B_DEV_ID_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), 73 E(B_DEV_NOT_READY), 74 E(B_DEV_NO_MEDIA), 75 E(B_DEV_NO_MEMORY), 76 E(B_DEV_PENDING), 77 E(B_DEV_READ_ERROR), 78 E(B_DEV_RECALIBRATE_ERROR), 79 E(B_DEV_RESOURCE_CONFLICT), 80 E(B_DEV_SEEK_ERROR), 81 E(B_DEV_STALLED), 82 E(B_DEV_TIMEOUT), 83 E(B_DEV_TOO_LATE), 84 E(B_DEV_UNEXPECTED_PID), 85 E(B_DEV_UNREADABLE), 86 E(B_DEV_WRITE_ERROR), 87 E(B_DIRECTORY_NOT_EMPTY), 88 E(B_DONT_DO_THAT), 89 E(B_DUPLICATE_REPLY), 90 E(B_ENTRY_NOT_FOUND), 91 E(B_ERROR), 92 E(B_ERRORS_END), 93 E(B_FILE_ERROR), 94 E(B_FILE_EXISTS), 95 #ifdef _BEOS_R5_COMPATIBLE_ 96 #define B_FILE_NOT_FOUND (B_STORAGE_ERROR_BASE + 1) 97 E(B_FILE_NOT_FOUND), 98 #endif 99 E(B_FILE_TOO_LARGE), 100 E(B_GENERAL_ERROR_BASE), 101 E(B_INTERFACE_ERROR_BASE), 102 E(B_INTERRUPTED), 103 E(B_IO_ERROR), 104 E(B_IS_A_DIRECTORY), 105 E(B_LAST_BUFFER_ERROR), 106 E(B_LAUNCH_FAILED), 107 E(B_LAUNCH_FAILED_APP_IN_TRASH), 108 E(B_LAUNCH_FAILED_APP_NOT_FOUND), 109 E(B_LAUNCH_FAILED_EXECUTABLE), 110 E(B_LAUNCH_FAILED_FILES_APP_NOT_FOUND), 111 E(B_LAUNCH_FAILED_NO_PREFERRED_APP), 112 E(B_LAUNCH_FAILED_NO_RESOLVE_LINK), 113 E(B_LINK_LIMIT), 114 E(B_MAIL_ACCESS_ERROR), 115 E(B_MAIL_ERROR_BASE), 116 E(B_MAIL_INVALID_MAIL), 117 E(B_MAIL_NO_DAEMON), 118 E(B_MAIL_NO_RECIPIENT), 119 E(B_MAIL_UNKNOWN_FIELD), 120 E(B_MAIL_UNKNOWN_HOST), 121 E(B_MAIL_UNKNOWN_USER), 122 E(B_MAIL_WRONG_PASSWORD), 123 E(B_MEDIA_ERROR_BASE), 124 E(B_MESSAGE_TO_SELF), 125 E(B_MIDI_ERROR_BASE), 126 E(B_MISMATCHED_VALUES), 127 E(B_MISSING_LIBRARY), 128 E(B_MISSING_SYMBOL), 129 E(B_NAME_IN_USE), 130 E(B_NAME_NOT_FOUND), 131 E(B_NAME_TOO_LONG), 132 E(B_NOT_ALLOWED), 133 E(B_NOT_AN_EXECUTABLE), 134 E(B_NOT_A_DIRECTORY), 135 E(B_NOT_A_MESSAGE), 136 #ifdef B_NOT_SUPPORTED 137 E(B_NOT_SUPPORTED), 138 #endif 139 E(B_NO_ERROR), 140 E(B_NO_INIT), 141 E(B_NO_MEMORY), 142 E(B_NO_MORE_FDS), 143 E(B_NO_MORE_PORTS), 144 E(B_NO_MORE_SEMS), 145 E(B_NO_MORE_TEAMS), 146 E(B_NO_MORE_THREADS), 147 E(B_NO_PRINT_SERVER), 148 E(B_OK), 149 E(B_OS_ERROR_BASE), 150 E(B_PARTIAL_READ), 151 E(B_PARTIAL_WRITE), 152 E(B_PARTITION_TOO_SMALL), 153 E(B_PERMISSION_DENIED), 154 E(B_POSIX_ERROR_BASE), 155 E(B_PRINT_ERROR_BASE), 156 E(B_READ_ONLY_DEVICE), 157 E(B_RESOURCE_NOT_FOUND), 158 E(B_RESOURCE_UNAVAILABLE), 159 #ifdef B_RESULT_NOT_REPRESENTABLE 160 E(B_RESULT_NOT_REPRESENTABLE), 161 #endif 162 E(B_SERVER_NOT_FOUND), 163 #ifdef B_SHUTDOWN_CANCELLED 164 E(B_SHUTDOWN_CANCELLED), 165 #endif 166 #ifdef B_SHUTTING_DOWN 167 E(B_SHUTTING_DOWN), 168 #endif 169 E(B_STORAGE_ERROR_BASE), 170 E(B_STREAM_NOT_FOUND), 171 E(B_SUBSCRIBER_NOT_ENTERED), 172 E(B_TIMED_OUT), 173 #ifdef B_TOO_MANY_ARGS 174 E(B_TOO_MANY_ARGS), 175 #endif 176 E(B_TRANSLATION_ERROR_BASE), 177 E(B_UNKNOWN_MIME_TYPE), 178 E(B_UNSUPPORTED), 179 E(B_WOULD_BLOCK), 180 E(E2BIG), 181 E(EACCES), 182 E(EADDRINUSE), 183 E(EADDRNOTAVAIL), 184 E(EAFNOSUPPORT), 185 E(EAGAIN), 186 E(EALREADY), 187 E(EBADF), 188 #ifdef EBADMSG 189 E(EBADMSG), 190 #endif 191 E(EBUSY), 192 #ifdef ECANCELED 193 E(ECANCELED), 194 #endif 195 E(ECHILD), 196 E(ECONNABORTED), 197 E(ECONNREFUSED), 198 E(ECONNRESET), 199 E(EDEADLK), 200 #ifdef EDESTADDRREQ 201 E(EDESTADDRREQ), 202 #endif 203 E(EDOM), 204 #ifdef EDQUOT 205 E(EDQUOT), 206 #endif 207 E(EEXIST), 208 E(EFAULT), 209 E(EFBIG), 210 E(EFPOS), 211 #ifdef EHOSTDOWN 212 E(EHOSTDOWN), 213 #endif 214 E(EHOSTUNREACH), 215 #ifdef EIDRM 216 E(EIDRM), 217 #endif 218 E(EILSEQ), 219 E(EINPROGRESS), 220 E(EINTR), 221 E(EINVAL), 222 E(EIO), 223 E(EISCONN), 224 E(EISDIR), 225 E(ELOOP), 226 E(EMFILE), 227 E(EMLINK), 228 E(EMSGSIZE), 229 #ifdef EMULTIHOP 230 E(EMULTIHOP), 231 #endif 232 E(ENAMETOOLONG), 233 E(ENETDOWN), 234 E(ENETRESET), 235 E(ENETUNREACH), 236 E(ENFILE), 237 E(ENOBUFS), 238 #ifdef ENODATA 239 E(ENODATA), 240 #endif 241 E(ENODEV), 242 E(ENOENT), 243 E(ENOEXEC), 244 E(ENOLCK), 245 #ifdef ENOLINK 246 E(ENOLINK), 247 #endif 248 E(ENOMEM), 249 E(ENOMSG), 250 E(ENOPROTOOPT), 251 E(ENOSPC), 252 #ifdef ENOSR 253 E(ENOSR), 254 #endif 255 #ifdef ENOSTR 256 E(ENOSTR), 257 #endif 258 E(ENOSYS), 259 E(ENOTCONN), 260 E(ENOTDIR), 261 E(ENOTEMPTY), 262 E(ENOTSOCK), 263 #ifdef ENOTSUP 264 E(ENOTSUP), 265 #endif 266 E(ENOTTY), 267 E(ENXIO), 268 E(EOPNOTSUPP), 269 E(EOVERFLOW), 270 E(EPERM), 271 E(EPFNOSUPPORT), 272 E(EPIPE), 273 #ifdef EPROTO 274 E(EPROTO), 275 #endif 276 E(EPROTONOSUPPORT), 277 E(EPROTOTYPE), 278 E(ERANGE), 279 E(EROFS), 280 E(ESHUTDOWN), 281 E(ESIGPARM), 282 E(ESPIPE), 283 E(ESRCH), 284 E(ESTALE), 285 #ifdef ETIME 286 E(ETIME), 287 #endif 288 E(ETIMEDOUT), 289 #ifdef ETXTBSY 290 E(ETXTBSY), 291 #endif 292 E(ENOATTR), 293 #ifdef ENOTRECOVERABLE 294 E(ENOTRECOVERABLE), 295 #endif 296 #ifdef EOWNERDEAD 297 E(EOWNERDEAD), 298 #endif 299 E(EWOULDBLOCK), 300 E(EXDEV), 301 { 0, NULL } 302 }; 303 304 305 static void 306 usage(void) 307 { 308 fprintf(stderr, "usage: %s <error number>\n" 309 "Prints clear text error messages for given error numbers.\n", __progname); 310 exit(-1); 311 } 312 313 314 static void 315 print_error(char *number) 316 { 317 char *end; 318 int32 error = (int32)strtoll(number, &end, 0); 319 // strtol() cuts off hex numbers that have the highest bit set 320 321 if (end[0]) { 322 // not a number, check names 323 struct error_pair *p = kErrorNames; 324 while (p->name && strcmp(p->name, number)) 325 p++; 326 if (!p->name) { 327 fprintf(stderr, "%s: invalid number (%s)\n", __progname, number); 328 exit(1); 329 } 330 error = p->value; 331 } 332 333 printf("0x%" B_PRIx32 ": %s\n", error, strerror(error)); 334 } 335 336 337 int 338 main(int argc, char *argv[]) 339 { 340 int32 i; 341 342 if (argc < 2) 343 usage(); 344 345 for (i = 1; i < argc; i++) { 346 print_error(argv[i]); 347 } 348 349 return 0; 350 } 351