HaikuDepot: notify work status from main window
[haiku.git] / src / libs / posix_error_mapper / misc.cpp
blob317b61eb62c8273caa19fa054b7d644a9e6f838e
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include <stdio.h>
7 #include <string.h>
9 #include "posix_error_mapper.h"
12 static int*
13 real_errnop()
15 GET_REAL_FUNCTION(int*, _errnop, (void));
16 return sReal__errnop();
20 int*
21 _errnop(void)
23 HIDDEN_FUNCTION(_errnop);
25 // convert errno to positive error code
26 int* error = real_errnop();
27 if (*error < 0)
28 *error = B_TO_POSITIVE_ERROR(*error);
29 return error;
34 WRAPPER_FUNCTION(char*, strerror, (int errorCode),
35 return sReal_strerror(B_TO_NEGATIVE_ERROR(errorCode));
39 WRAPPER_FUNCTION(int, strerror_r,
40 (int errorCode, char* buffer, size_t bufferSize),
41 return sReal_strerror_r(B_TO_NEGATIVE_ERROR(errorCode), buffer, bufferSize);
45 WRAPPER_FUNCTION(void, perror, (const char* errorPrefix),
46 // convert errno to negative error code
47 int* error = real_errnop();
48 int oldError = *error;
49 if (*error > 0)
50 *error = B_TO_NEGATIVE_ERROR(*error);
52 // call the real perror()
53 sReal_perror(errorPrefix);
55 // reset errno
56 *error = oldError;