1686bdd59SAxel Dörfler/*
229e8fa59SJohn Scipione * Copyright 2007-2014 Haiku, Inc. All rights reserved.
3686bdd59SAxel Dörfler * Distributed under the terms of the MIT License.
4686bdd59SAxel Dörfler */
552a38012Sejakowatz#ifndef _ERRORS_H
652a38012Sejakowatz#define _ERRORS_H
752a38012Sejakowatz
8686bdd59SAxel Dörfler
9afe886fcSDavid Reid#include <limits.h>
1052a38012Sejakowatz
1152a38012Sejakowatz
124a50aa51SAxel Dörfler/* Error baselines */
131f285441SIngo Weinhold#define B_GENERAL_ERROR_BASE		INT_MIN
14965aa03fSIngo Weinhold#define B_OS_ERROR_BASE				(B_GENERAL_ERROR_BASE + 0x1000)
15965aa03fSIngo Weinhold#define B_APP_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x2000)
16965aa03fSIngo Weinhold#define B_INTERFACE_ERROR_BASE		(B_GENERAL_ERROR_BASE + 0x3000)
17965aa03fSIngo Weinhold#define B_MEDIA_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x4000)
18965aa03fSIngo Weinhold										/* - 0x41ff */
19965aa03fSIngo Weinhold#define B_TRANSLATION_ERROR_BASE	(B_GENERAL_ERROR_BASE + 0x4800)
20965aa03fSIngo Weinhold										/* - 0x48ff */
21965aa03fSIngo Weinhold#define B_MIDI_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x5000)
22965aa03fSIngo Weinhold#define B_STORAGE_ERROR_BASE		(B_GENERAL_ERROR_BASE + 0x6000)
23965aa03fSIngo Weinhold#define B_POSIX_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x7000)
24965aa03fSIngo Weinhold#define B_MAIL_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x8000)
25965aa03fSIngo Weinhold#define B_PRINT_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x9000)
26965aa03fSIngo Weinhold#define B_DEVICE_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0xa000)
2752a38012Sejakowatz
284a50aa51SAxel Dörfler/* Developer-defined errors start at (B_ERRORS_END+1) */
29965aa03fSIngo Weinhold#define B_ERRORS_END				(B_GENERAL_ERROR_BASE + 0xffff)
3052a38012Sejakowatz
314a50aa51SAxel Dörfler/* General Errors */
32965aa03fSIngo Weinhold#define B_NO_MEMORY					(B_GENERAL_ERROR_BASE + 0)
33965aa03fSIngo Weinhold#define B_IO_ERROR					(B_GENERAL_ERROR_BASE + 1)
34965aa03fSIngo Weinhold#define B_PERMISSION_DENIED			(B_GENERAL_ERROR_BASE + 2)
35965aa03fSIngo Weinhold#define B_BAD_INDEX					(B_GENERAL_ERROR_BASE + 3)
36965aa03fSIngo Weinhold#define B_BAD_TYPE					(B_GENERAL_ERROR_BASE + 4)
37965aa03fSIngo Weinhold#define B_BAD_VALUE					(B_GENERAL_ERROR_BASE + 5)
38965aa03fSIngo Weinhold#define B_MISMATCHED_VALUES			(B_GENERAL_ERROR_BASE + 6)
39965aa03fSIngo Weinhold#define B_NAME_NOT_FOUND			(B_GENERAL_ERROR_BASE + 7)
40965aa03fSIngo Weinhold#define B_NAME_IN_USE				(B_GENERAL_ERROR_BASE + 8)
41965aa03fSIngo Weinhold#define B_TIMED_OUT					(B_GENERAL_ERROR_BASE + 9)
42965aa03fSIngo Weinhold#define B_INTERRUPTED				(B_GENERAL_ERROR_BASE + 10)
43965aa03fSIngo Weinhold#define B_WOULD_BLOCK				(B_GENERAL_ERROR_BASE + 11)
44965aa03fSIngo Weinhold#define B_CANCELED					(B_GENERAL_ERROR_BASE + 12)
45965aa03fSIngo Weinhold#define B_NO_INIT					(B_GENERAL_ERROR_BASE + 13)
46d7571ebcSAxel Dörfler#define B_NOT_INITIALIZED			(B_GENERAL_ERROR_BASE + 13)
47965aa03fSIngo Weinhold#define B_BUSY						(B_GENERAL_ERROR_BASE + 14)
48965aa03fSIngo Weinhold#define B_NOT_ALLOWED				(B_GENERAL_ERROR_BASE + 15)
49965aa03fSIngo Weinhold#define B_BAD_DATA					(B_GENERAL_ERROR_BASE + 16)
50965aa03fSIngo Weinhold#define B_DONT_DO_THAT				(B_GENERAL_ERROR_BASE + 17)
51c3db7c3bSAxel Dörfler
52965aa03fSIngo Weinhold#define B_ERROR						(-1)
53965aa03fSIngo Weinhold#define B_OK						((int)0)
54965aa03fSIngo Weinhold#define B_NO_ERROR					((int)0)
5552a38012Sejakowatz
564a50aa51SAxel Dörfler/* Kernel Kit Errors */
57965aa03fSIngo Weinhold#define B_BAD_SEM_ID				(B_OS_ERROR_BASE + 0)
58965aa03fSIngo Weinhold#define B_NO_MORE_SEMS				(B_OS_ERROR_BASE + 1)
5952a38012Sejakowatz
60965aa03fSIngo Weinhold#define B_BAD_THREAD_ID				(B_OS_ERROR_BASE + 0x100)
61965aa03fSIngo Weinhold#define B_NO_MORE_THREADS			(B_OS_ERROR_BASE + 0x101)
62965aa03fSIngo Weinhold#define B_BAD_THREAD_STATE			(B_OS_ERROR_BASE + 0x102)
63965aa03fSIngo Weinhold#define B_BAD_TEAM_ID				(B_OS_ERROR_BASE + 0x103)
64965aa03fSIngo Weinhold#define B_NO_MORE_TEAMS				(B_OS_ERROR_BASE + 0x104)
6552a38012Sejakowatz
66965aa03fSIngo Weinhold#define B_BAD_PORT_ID				(B_OS_ERROR_BASE + 0x200)
67965aa03fSIngo Weinhold#define B_NO_MORE_PORTS				(B_OS_ERROR_BASE + 0x201)
6852a38012Sejakowatz
69965aa03fSIngo Weinhold#define B_BAD_IMAGE_ID				(B_OS_ERROR_BASE + 0x300)
70965aa03fSIngo Weinhold#define B_BAD_ADDRESS				(B_OS_ERROR_BASE + 0x301)
71965aa03fSIngo Weinhold#define B_NOT_AN_EXECUTABLE			(B_OS_ERROR_BASE + 0x302)
72965aa03fSIngo Weinhold#define B_MISSING_LIBRARY			(B_OS_ERROR_BASE + 0x303)
73965aa03fSIngo Weinhold#define B_MISSING_SYMBOL			(B_OS_ERROR_BASE + 0x304)
74aa4b5749SAlexander von Gluck IV#define B_UNKNOWN_EXECUTABLE		(B_OS_ERROR_BASE + 0x305)
75aa4b5749SAlexander von Gluck IV#define B_LEGACY_EXECUTABLE			(B_OS_ERROR_BASE + 0x306)
7652a38012Sejakowatz
77965aa03fSIngo Weinhold#define B_DEBUGGER_ALREADY_INSTALLED	(B_OS_ERROR_BASE + 0x400)
7852a38012Sejakowatz
794a50aa51SAxel Dörfler/* Application Kit Errors */
80965aa03fSIngo Weinhold#define B_BAD_REPLY							(B_APP_ERROR_BASE + 0)
81965aa03fSIngo Weinhold#define B_DUPLICATE_REPLY					(B_APP_ERROR_BASE + 1)
82965aa03fSIngo Weinhold#define B_MESSAGE_TO_SELF					(B_APP_ERROR_BASE + 2)
83965aa03fSIngo Weinhold#define B_BAD_HANDLER						(B_APP_ERROR_BASE + 3)
84965aa03fSIngo Weinhold#define B_ALREADY_RUNNING					(B_APP_ERROR_BASE + 4)
85965aa03fSIngo Weinhold#define B_LAUNCH_FAILED						(B_APP_ERROR_BASE + 5)
86965aa03fSIngo Weinhold#define B_AMBIGUOUS_APP_LAUNCH				(B_APP_ERROR_BASE + 6)
87965aa03fSIngo Weinhold#define B_UNKNOWN_MIME_TYPE					(B_APP_ERROR_BASE + 7)
88965aa03fSIngo Weinhold#define B_BAD_SCRIPT_SYNTAX					(B_APP_ERROR_BASE + 8)
89965aa03fSIngo Weinhold#define B_LAUNCH_FAILED_NO_RESOLVE_LINK		(B_APP_ERROR_BASE + 9)
90965aa03fSIngo Weinhold#define B_LAUNCH_FAILED_EXECUTABLE			(B_APP_ERROR_BASE + 10)
91965aa03fSIngo Weinhold#define B_LAUNCH_FAILED_APP_NOT_FOUND		(B_APP_ERROR_BASE + 11)
92965aa03fSIngo Weinhold#define B_LAUNCH_FAILED_APP_IN_TRASH		(B_APP_ERROR_BASE + 12)
93965aa03fSIngo Weinhold#define B_LAUNCH_FAILED_NO_PREFERRED_APP	(B_APP_ERROR_BASE + 13)
94965aa03fSIngo Weinhold#define B_LAUNCH_FAILED_FILES_APP_NOT_FOUND	(B_APP_ERROR_BASE + 14)
95965aa03fSIngo Weinhold#define B_BAD_MIME_SNIFFER_RULE				(B_APP_ERROR_BASE + 15)
96965aa03fSIngo Weinhold#define B_NOT_A_MESSAGE						(B_APP_ERROR_BASE + 16)
97965aa03fSIngo Weinhold#define B_SHUTDOWN_CANCELLED				(B_APP_ERROR_BASE + 17)
98965aa03fSIngo Weinhold#define B_SHUTTING_DOWN						(B_APP_ERROR_BASE + 18)
9952a38012Sejakowatz
1004a50aa51SAxel Dörfler/* Storage Kit/File System Errors */
101965aa03fSIngo Weinhold#define B_FILE_ERROR						(B_STORAGE_ERROR_BASE + 0)
102965aa03fSIngo Weinhold#define B_FILE_NOT_FOUND					(B_STORAGE_ERROR_BASE + 1)
103965aa03fSIngo Weinhold			/* deprecated: use B_ENTRY_NOT_FOUND instead */
104965aa03fSIngo Weinhold#define B_FILE_EXISTS						(B_STORAGE_ERROR_BASE + 2)
105965aa03fSIngo Weinhold#define B_ENTRY_NOT_FOUND					(B_STORAGE_ERROR_BASE + 3)
106965aa03fSIngo Weinhold#define B_NAME_TOO_LONG						(B_STORAGE_ERROR_BASE + 4)
107965aa03fSIngo Weinhold#define B_NOT_A_DIRECTORY					(B_STORAGE_ERROR_BASE + 5)
108965aa03fSIngo Weinhold#define B_DIRECTORY_NOT_EMPTY				(B_STORAGE_ERROR_BASE + 6)
109965aa03fSIngo Weinhold#define B_DEVICE_FULL						(B_STORAGE_ERROR_BASE + 7)
110965aa03fSIngo Weinhold#define B_READ_ONLY_DEVICE					(B_STORAGE_ERROR_BASE + 8)
111965aa03fSIngo Weinhold#define B_IS_A_DIRECTORY					(B_STORAGE_ERROR_BASE + 9)
112965aa03fSIngo Weinhold#define B_NO_MORE_FDS						(B_STORAGE_ERROR_BASE + 10)
113965aa03fSIngo Weinhold#define B_CROSS_DEVICE_LINK					(B_STORAGE_ERROR_BASE + 11)
114965aa03fSIngo Weinhold#define B_LINK_LIMIT						(B_STORAGE_ERROR_BASE + 12)
115965aa03fSIngo Weinhold#define B_BUSTED_PIPE						(B_STORAGE_ERROR_BASE + 13)
116965aa03fSIngo Weinhold#define B_UNSUPPORTED						(B_STORAGE_ERROR_BASE + 14)
117965aa03fSIngo Weinhold#define B_PARTITION_TOO_SMALL				(B_STORAGE_ERROR_BASE + 15)
118dec78bb2SIngo Weinhold#define B_PARTIAL_READ						(B_STORAGE_ERROR_BASE + 16)
119dec78bb2SIngo Weinhold#define B_PARTIAL_WRITE						(B_STORAGE_ERROR_BASE + 17)
12052a38012Sejakowatz
1214a50aa51SAxel Dörfler/* POSIX Errors */
12239d58e2fSIngo Weinhold#ifdef B_USE_POSITIVE_POSIX_ERRORS
12339d58e2fSIngo Weinhold#	define B_TO_POSIX_ERROR(error)		(-(error))
12439d58e2fSIngo Weinhold#	define B_FROM_POSIX_ERROR(error)	(-(error))
12539d58e2fSIngo Weinhold#else
12639d58e2fSIngo Weinhold#	define B_TO_POSIX_ERROR(error)		(error)
12739d58e2fSIngo Weinhold#	define B_FROM_POSIX_ERROR(error)	(error)
12839d58e2fSIngo Weinhold#endif
12939d58e2fSIngo Weinhold
13039d58e2fSIngo Weinhold#define B_POSIX_ENOMEM	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 0)
13139d58e2fSIngo Weinhold#define E2BIG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 1)
13239d58e2fSIngo Weinhold#define ECHILD			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 2)
13339d58e2fSIngo Weinhold#define EDEADLK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 3)
13439d58e2fSIngo Weinhold#define EFBIG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 4)
13539d58e2fSIngo Weinhold#define EMLINK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 5)
13639d58e2fSIngo Weinhold#define ENFILE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 6)
13739d58e2fSIngo Weinhold#define ENODEV			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 7)
13839d58e2fSIngo Weinhold#define ENOLCK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 8)
13939d58e2fSIngo Weinhold#define ENOSYS			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 9)
14039d58e2fSIngo Weinhold#define ENOTTY			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 10)
14139d58e2fSIngo Weinhold#define ENXIO			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 11)
14239d58e2fSIngo Weinhold#define ESPIPE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 12)
14339d58e2fSIngo Weinhold#define ESRCH			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 13)
14439d58e2fSIngo Weinhold#define EFPOS			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 14)
14539d58e2fSIngo Weinhold#define ESIGPARM		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 15)
14639d58e2fSIngo Weinhold#define EDOM			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 16)
14739d58e2fSIngo Weinhold#define ERANGE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 17)
14839d58e2fSIngo Weinhold#define EPROTOTYPE		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 18)
14939d58e2fSIngo Weinhold#define EPROTONOSUPPORT	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 19)
15039d58e2fSIngo Weinhold#define EPFNOSUPPORT	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 20)
15139d58e2fSIngo Weinhold#define EAFNOSUPPORT	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 21)
15239d58e2fSIngo Weinhold#define EADDRINUSE		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 22)
15339d58e2fSIngo Weinhold#define EADDRNOTAVAIL	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 23)
15439d58e2fSIngo Weinhold#define ENETDOWN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 24)
15539d58e2fSIngo Weinhold#define ENETUNREACH		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 25)
15639d58e2fSIngo Weinhold#define ENETRESET		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 26)
15739d58e2fSIngo Weinhold#define ECONNABORTED	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 27)
15839d58e2fSIngo Weinhold#define ECONNRESET		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 28)
15939d58e2fSIngo Weinhold#define EISCONN			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 29)
16039d58e2fSIngo Weinhold#define ENOTCONN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 30)
16139d58e2fSIngo Weinhold#define ESHUTDOWN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 31)
16239d58e2fSIngo Weinhold#define ECONNREFUSED	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 32)
16339d58e2fSIngo Weinhold#define EHOSTUNREACH	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 33)
16439d58e2fSIngo Weinhold#define ENOPROTOOPT		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 34)
16539d58e2fSIngo Weinhold#define ENOBUFS			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 35)
16639d58e2fSIngo Weinhold#define EINPROGRESS		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 36)
16739d58e2fSIngo Weinhold#define EALREADY		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 37)
168dd074cc7SKacper Kasper#define EILSEQ			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 38)
169dd074cc7SKacper Kasper#define ENOMSG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 39)
170dd074cc7SKacper Kasper#define ESTALE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 40)
171dd074cc7SKacper Kasper#define EOVERFLOW		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 41)
172dd074cc7SKacper Kasper#define EMSGSIZE		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 42)
173dd074cc7SKacper Kasper#define EOPNOTSUPP		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 43)
17439d58e2fSIngo Weinhold#define ENOTSOCK		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 44)
17539d58e2fSIngo Weinhold#define EHOSTDOWN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 45)
176dd074cc7SKacper Kasper#define EBADMSG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 46)
17739d58e2fSIngo Weinhold#define ECANCELED		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 47)
17839d58e2fSIngo Weinhold#define EDESTADDRREQ	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 48)
17939d58e2fSIngo Weinhold#define EDQUOT			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 49)
18039d58e2fSIngo Weinhold#define EIDRM			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 50)
18139d58e2fSIngo Weinhold#define EMULTIHOP		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 51)
18239d58e2fSIngo Weinhold#define ENODATA			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 52)
18339d58e2fSIngo Weinhold#define ENOLINK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 53)
18439d58e2fSIngo Weinhold#define ENOSR			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 54)
18539d58e2fSIngo Weinhold#define ENOSTR			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 55)
18639d58e2fSIngo Weinhold#define ENOTSUP			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 56)
18739d58e2fSIngo Weinhold#define EPROTO			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 57)
18839d58e2fSIngo Weinhold#define ETIME			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 58)
18939d58e2fSIngo Weinhold#define ETXTBSY			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 59)
1907c447600SIngo Weinhold#define ENOATTR			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 60)
19139d58e2fSIngo Weinhold
19239d58e2fSIngo Weinhold/* B_NO_MEMORY (0x80000000) can't be negated, so it needs special handling */
19339d58e2fSIngo Weinhold#ifdef B_USE_POSITIVE_POSIX_ERRORS
19439d58e2fSIngo Weinhold#	define ENOMEM		B_POSIX_ENOMEM
19539d58e2fSIngo Weinhold#else
19639d58e2fSIngo Weinhold#	define ENOMEM		B_NO_MEMORY
19739d58e2fSIngo Weinhold#endif
1989f20e178SJérôme Duval
1994a50aa51SAxel Dörfler/* POSIX errors that can be mapped to BeOS error codes */
20039d58e2fSIngo Weinhold#define EACCES			B_TO_POSIX_ERROR(B_PERMISSION_DENIED)
20139d58e2fSIngo Weinhold#define EINTR			B_TO_POSIX_ERROR(B_INTERRUPTED)
20239d58e2fSIngo Weinhold#define EIO				B_TO_POSIX_ERROR(B_IO_ERROR)
20339d58e2fSIngo Weinhold#define EBUSY			B_TO_POSIX_ERROR(B_BUSY)
20439d58e2fSIngo Weinhold#define EFAULT			B_TO_POSIX_ERROR(B_BAD_ADDRESS)
20539d58e2fSIngo Weinhold#define ETIMEDOUT		B_TO_POSIX_ERROR(B_TIMED_OUT)
20639d58e2fSIngo Weinhold#define EAGAIN 			B_TO_POSIX_ERROR(B_WOULD_BLOCK)	/* SysV compatibility */
20739d58e2fSIngo Weinhold#define EWOULDBLOCK 	B_TO_POSIX_ERROR(B_WOULD_BLOCK)	/* BSD compatibility */
20839d58e2fSIngo Weinhold#define EBADF			B_TO_POSIX_ERROR(B_FILE_ERROR)
20939d58e2fSIngo Weinhold#define EEXIST			B_TO_POSIX_ERROR(B_FILE_EXISTS)
21039d58e2fSIngo Weinhold#define EINVAL			B_TO_POSIX_ERROR(B_BAD_VALUE)
21139d58e2fSIngo Weinhold#define ENAMETOOLONG	B_TO_POSIX_ERROR(B_NAME_TOO_LONG)
21239d58e2fSIngo Weinhold#define ENOENT			B_TO_POSIX_ERROR(B_ENTRY_NOT_FOUND)
21339d58e2fSIngo Weinhold#define EPERM			B_TO_POSIX_ERROR(B_NOT_ALLOWED)
21439d58e2fSIngo Weinhold#define ENOTDIR			B_TO_POSIX_ERROR(B_NOT_A_DIRECTORY)
21539d58e2fSIngo Weinhold#define EISDIR			B_TO_POSIX_ERROR(B_IS_A_DIRECTORY)
21639d58e2fSIngo Weinhold#define ENOTEMPTY		B_TO_POSIX_ERROR(B_DIRECTORY_NOT_EMPTY)
21739d58e2fSIngo Weinhold#define ENOSPC			B_TO_POSIX_ERROR(B_DEVICE_FULL)
21839d58e2fSIngo Weinhold#define EROFS			B_TO_POSIX_ERROR(B_READ_ONLY_DEVICE)
21939d58e2fSIngo Weinhold#define EMFILE			B_TO_POSIX_ERROR(B_NO_MORE_FDS)
22039d58e2fSIngo Weinhold#define EXDEV			B_TO_POSIX_ERROR(B_CROSS_DEVICE_LINK)
22139d58e2fSIngo Weinhold#define ELOOP			B_TO_POSIX_ERROR(B_LINK_LIMIT)
22239d58e2fSIngo Weinhold#define ENOEXEC			B_TO_POSIX_ERROR(B_NOT_AN_EXECUTABLE)
22339d58e2fSIngo Weinhold#define EPIPE			B_TO_POSIX_ERROR(B_BUSTED_PIPE)
224afe886fcSDavid Reid
2254a50aa51SAxel Dörfler/* new error codes that can be mapped to POSIX errors */
226dd074cc7SKacper Kasper#define B_BUFFER_OVERFLOW			B_FROM_POSIX_ERROR(EOVERFLOW)
22739d58e2fSIngo Weinhold#define B_TOO_MANY_ARGS				B_FROM_POSIX_ERROR(E2BIG)
228dd074cc7SKacper Kasper#define B_FILE_TOO_LARGE			B_FROM_POSIX_ERROR(EFBIG)
22939d58e2fSIngo Weinhold#define B_RESULT_NOT_REPRESENTABLE	B_FROM_POSIX_ERROR(ERANGE)
230dd074cc7SKacper Kasper#define B_DEVICE_NOT_FOUND			B_FROM_POSIX_ERROR(ENODEV)
23139d58e2fSIngo Weinhold#define B_NOT_SUPPORTED				B_FROM_POSIX_ERROR(EOPNOTSUPP)
23268145d0dSAxel Dörfler
2334a50aa51SAxel Dörfler/* Media Kit Errors */
234965aa03fSIngo Weinhold#define B_STREAM_NOT_FOUND				(B_MEDIA_ERROR_BASE + 0)
235965aa03fSIngo Weinhold#define B_SERVER_NOT_FOUND				(B_MEDIA_ERROR_BASE + 1)
236965aa03fSIngo Weinhold#define B_RESOURCE_NOT_FOUND			(B_MEDIA_ERROR_BASE + 2)
237965aa03fSIngo Weinhold#define B_RESOURCE_UNAVAILABLE			(B_MEDIA_ERROR_BASE + 3)
238965aa03fSIngo Weinhold#define B_BAD_SUBSCRIBER				(B_MEDIA_ERROR_BASE + 4)
239965aa03fSIngo Weinhold#define B_SUBSCRIBER_NOT_ENTERED		(B_MEDIA_ERROR_BASE + 5)
240965aa03fSIngo Weinhold#define B_BUFFER_NOT_AVAILABLE			(B_MEDIA_ERROR_BASE + 6)
241965aa03fSIngo Weinhold#define B_LAST_BUFFER_ERROR				(B_MEDIA_ERROR_BASE + 7)
24252a38012Sejakowatz
243d4d27facSStephan Aßmus#define B_MEDIA_SYSTEM_FAILURE			(B_MEDIA_ERROR_BASE + 100)
244d4d27facSStephan Aßmus#define B_MEDIA_BAD_NODE				(B_MEDIA_ERROR_BASE + 101)
245d4d27facSStephan Aßmus#define B_MEDIA_NODE_BUSY				(B_MEDIA_ERROR_BASE + 102)
246d4d27facSStephan Aßmus#define B_MEDIA_BAD_FORMAT				(B_MEDIA_ERROR_BASE + 103)
247d4d27facSStephan Aßmus#define B_MEDIA_BAD_BUFFER				(B_MEDIA_ERROR_BASE + 104)
248d4d27facSStephan Aßmus#define B_MEDIA_TOO_MANY_NODES			(B_MEDIA_ERROR_BASE + 105)
249d4d27facSStephan Aßmus#define B_MEDIA_TOO_MANY_BUFFERS		(B_MEDIA_ERROR_BASE + 106)
250d4d27facSStephan Aßmus#define B_MEDIA_NODE_ALREADY_EXISTS		(B_MEDIA_ERROR_BASE + 107)
251d4d27facSStephan Aßmus#define B_MEDIA_BUFFER_ALREADY_EXISTS	(B_MEDIA_ERROR_BASE + 108)
252d4d27facSStephan Aßmus#define B_MEDIA_CANNOT_SEEK				(B_MEDIA_ERROR_BASE + 109)
253d4d27facSStephan Aßmus#define B_MEDIA_CANNOT_CHANGE_RUN_MODE	(B_MEDIA_ERROR_BASE + 110)
254d4d27facSStephan Aßmus#define B_MEDIA_APP_ALREADY_REGISTERED	(B_MEDIA_ERROR_BASE + 111)
255d4d27facSStephan Aßmus#define B_MEDIA_APP_NOT_REGISTERED		(B_MEDIA_ERROR_BASE + 112)
256d4d27facSStephan Aßmus#define B_MEDIA_CANNOT_RECLAIM_BUFFERS	(B_MEDIA_ERROR_BASE + 113)
257d4d27facSStephan Aßmus#define B_MEDIA_BUFFERS_NOT_RECLAIMED	(B_MEDIA_ERROR_BASE + 114)
258d4d27facSStephan Aßmus#define B_MEDIA_TIME_SOURCE_STOPPED		(B_MEDIA_ERROR_BASE + 115)
259d4d27facSStephan Aßmus#define B_MEDIA_TIME_SOURCE_BUSY		(B_MEDIA_ERROR_BASE + 116)
260d4d27facSStephan Aßmus#define B_MEDIA_BAD_SOURCE				(B_MEDIA_ERROR_BASE + 117)
261d4d27facSStephan Aßmus#define B_MEDIA_BAD_DESTINATION			(B_MEDIA_ERROR_BASE + 118)
262d4d27facSStephan Aßmus#define B_MEDIA_ALREADY_CONNECTED		(B_MEDIA_ERROR_BASE + 119)
263d4d27facSStephan Aßmus#define B_MEDIA_NOT_CONNECTED			(B_MEDIA_ERROR_BASE + 120)
264d4d27facSStephan Aßmus#define B_MEDIA_BAD_CLIP_FORMAT			(B_MEDIA_ERROR_BASE + 121)
265d4d27facSStephan Aßmus#define B_MEDIA_ADDON_FAILED			(B_MEDIA_ERROR_BASE + 122)
266d4d27facSStephan Aßmus#define B_MEDIA_ADDON_DISABLED			(B_MEDIA_ERROR_BASE + 123)
267d4d27facSStephan Aßmus#define B_MEDIA_CHANGE_IN_PROGRESS		(B_MEDIA_ERROR_BASE + 124)
268d4d27facSStephan Aßmus#define B_MEDIA_STALE_CHANGE_COUNT		(B_MEDIA_ERROR_BASE + 125)
269d4d27facSStephan Aßmus#define B_MEDIA_ADDON_RESTRICTED		(B_MEDIA_ERROR_BASE + 126)
270d4d27facSStephan Aßmus#define B_MEDIA_NO_HANDLER				(B_MEDIA_ERROR_BASE + 127)
271d4d27facSStephan Aßmus#define B_MEDIA_DUPLICATE_FORMAT		(B_MEDIA_ERROR_BASE + 128)
272d4d27facSStephan Aßmus#define B_MEDIA_REALTIME_DISABLED		(B_MEDIA_ERROR_BASE + 129)
273d4d27facSStephan Aßmus#define B_MEDIA_REALTIME_UNAVAILABLE	(B_MEDIA_ERROR_BASE + 130)
274d4d27facSStephan Aßmus
2754a50aa51SAxel Dörfler/* Mail Kit Errors */
276965aa03fSIngo Weinhold#define B_MAIL_NO_DAEMON				(B_MAIL_ERROR_BASE + 0)
277965aa03fSIngo Weinhold#define B_MAIL_UNKNOWN_USER				(B_MAIL_ERROR_BASE + 1)
278965aa03fSIngo Weinhold#define B_MAIL_WRONG_PASSWORD			(B_MAIL_ERROR_BASE + 2)
279965aa03fSIngo Weinhold#define B_MAIL_UNKNOWN_HOST				(B_MAIL_ERROR_BASE + 3)
280965aa03fSIngo Weinhold#define B_MAIL_ACCESS_ERROR				(B_MAIL_ERROR_BASE + 4)
281965aa03fSIngo Weinhold#define B_MAIL_UNKNOWN_FIELD			(B_MAIL_ERROR_BASE + 5)
282965aa03fSIngo Weinhold#define B_MAIL_NO_RECIPIENT				(B_MAIL_ERROR_BASE + 6)
283965aa03fSIngo Weinhold#define B_MAIL_INVALID_MAIL				(B_MAIL_ERROR_BASE + 7)
28452a38012Sejakowatz
2854a50aa51SAxel Dörfler/* Printing Errors */
286965aa03fSIngo Weinhold#define B_NO_PRINT_SERVER				(B_PRINT_ERROR_BASE + 0)
28752a38012Sejakowatz
2884a50aa51SAxel Dörfler/* Device Kit Errors */
289965aa03fSIngo Weinhold#define B_DEV_INVALID_IOCTL				(B_DEVICE_ERROR_BASE + 0)
290965aa03fSIngo Weinhold#define B_DEV_NO_MEMORY					(B_DEVICE_ERROR_BASE + 1)
291965aa03fSIngo Weinhold#define B_DEV_BAD_DRIVE_NUM				(B_DEVICE_ERROR_BASE + 2)
292965aa03fSIngo Weinhold#define B_DEV_NO_MEDIA					(B_DEVICE_ERROR_BASE + 3)
293965aa03fSIngo Weinhold#define B_DEV_UNREADABLE				(B_DEVICE_ERROR_BASE + 4)
294965aa03fSIngo Weinhold#define B_DEV_FORMAT_ERROR				(B_DEVICE_ERROR_BASE + 5)
295965aa03fSIngo Weinhold#define B_DEV_TIMEOUT					(B_DEVICE_ERROR_BASE + 6)
296965aa03fSIngo Weinhold#define B_DEV_RECALIBRATE_ERROR			(B_DEVICE_ERROR_BASE + 7)
297965aa03fSIngo Weinhold#define B_DEV_SEEK_ERROR				(B_DEVICE_ERROR_BASE + 8)
298965aa03fSIngo Weinhold#define B_DEV_ID_ERROR					(B_DEVICE_ERROR_BASE + 9)
299965aa03fSIngo Weinhold#define B_DEV_READ_ERROR				(B_DEVICE_ERROR_BASE + 10)
300965aa03fSIngo Weinhold#define B_DEV_WRITE_ERROR				(B_DEVICE_ERROR_BASE + 11)
301965aa03fSIngo Weinhold#define B_DEV_NOT_READY					(B_DEVICE_ERROR_BASE + 12)
302965aa03fSIngo Weinhold#define B_DEV_MEDIA_CHANGED				(B_DEVICE_ERROR_BASE + 13)
303965aa03fSIngo Weinhold#define B_DEV_MEDIA_CHANGE_REQUESTED	(B_DEVICE_ERROR_BASE + 14)
304965aa03fSIngo Weinhold#define B_DEV_RESOURCE_CONFLICT			(B_DEVICE_ERROR_BASE + 15)
305965aa03fSIngo Weinhold#define B_DEV_CONFIGURATION_ERROR		(B_DEVICE_ERROR_BASE + 16)
306965aa03fSIngo Weinhold#define B_DEV_DISABLED_BY_USER			(B_DEVICE_ERROR_BASE + 17)
307965aa03fSIngo Weinhold#define B_DEV_DOOR_OPEN					(B_DEVICE_ERROR_BASE + 18)
308a4733dd5SAxel Dörfler
309965aa03fSIngo Weinhold#define B_DEV_INVALID_PIPE				(B_DEVICE_ERROR_BASE + 19)
310965aa03fSIngo Weinhold#define B_DEV_CRC_ERROR					(B_DEVICE_ERROR_BASE + 20)
311965aa03fSIngo Weinhold#define B_DEV_STALLED					(B_DEVICE_ERROR_BASE + 21)
312965aa03fSIngo Weinhold#define B_DEV_BAD_PID					(B_DEVICE_ERROR_BASE + 22)
313965aa03fSIngo Weinhold#define B_DEV_UNEXPECTED_PID			(B_DEVICE_ERROR_BASE + 23)
314965aa03fSIngo Weinhold#define B_DEV_DATA_OVERRUN				(B_DEVICE_ERROR_BASE + 24)
315965aa03fSIngo Weinhold#define B_DEV_DATA_UNDERRUN				(B_DEVICE_ERROR_BASE + 25)
316965aa03fSIngo Weinhold#define B_DEV_FIFO_OVERRUN				(B_DEVICE_ERROR_BASE + 26)
317965aa03fSIngo Weinhold#define B_DEV_FIFO_UNDERRUN				(B_DEVICE_ERROR_BASE + 27)
318965aa03fSIngo Weinhold#define B_DEV_PENDING					(B_DEVICE_ERROR_BASE + 28)
319965aa03fSIngo Weinhold#define B_DEV_MULTIPLE_ERRORS			(B_DEVICE_ERROR_BASE + 29)
320965aa03fSIngo Weinhold#define B_DEV_TOO_LATE					(B_DEVICE_ERROR_BASE + 30)
32152a38012Sejakowatz
322d7571ebcSAxel Dörfler/* Translation Kit Errors */
323d7571ebcSAxel Dörfler#define B_TRANSLATION_BASE_ERROR		(B_TRANSLATION_ERROR_BASE + 0)
324d7571ebcSAxel Dörfler#define B_NO_TRANSLATOR					(B_TRANSLATION_ERROR_BASE + 1)
325d7571ebcSAxel Dörfler#define B_ILLEGAL_DATA					(B_TRANSLATION_ERROR_BASE + 2)
326d7571ebcSAxel Dörfler
32739d58e2fSIngo Weinhold
32839d58e2fSIngo Weinhold#define B_TO_POSITIVE_ERROR(error)	_to_positive_error(error)
32939d58e2fSIngo Weinhold#define B_TO_NEGATIVE_ERROR(error)	_to_negative_error(error)
33039d58e2fSIngo Weinhold
33139d58e2fSIngo Weinhold
33239d58e2fSIngo Weinhold#ifdef __cplusplus
33339d58e2fSIngo Weinholdextern "C" {
33439d58e2fSIngo Weinhold#endif
33539d58e2fSIngo Weinhold
33639d58e2fSIngo Weinholdint _to_positive_error(int error);
33739d58e2fSIngo Weinholdint _to_negative_error(int error);
33839d58e2fSIngo Weinhold
33939d58e2fSIngo Weinhold#ifdef __cplusplus
34039d58e2fSIngo Weinhold}
34139d58e2fSIngo Weinhold#endif
34239d58e2fSIngo Weinhold
3434a50aa51SAxel Dörfler#endif	/* _ERRORS_H */
344