Commit 1317b935 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Use errno values from public header.

parent fbc9110d
......@@ -451,7 +451,7 @@ int CDECL MSVCRT__toupper_l(int c, _locale_t locale)
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
*p++ = (c>>8) & 255;
else {
*MSVCRT__errno() = MSVCRT_EILSEQ;
*MSVCRT__errno() = EILSEQ;
str[1] = 0;
}
*p++ = c & 255;
......@@ -505,7 +505,7 @@ int CDECL MSVCRT__tolower_l(int c, _locale_t locale)
if(locinfo->pctype[(c>>8)&255] & MSVCRT__LEADBYTE)
*p++ = (c>>8) & 255;
else {
*MSVCRT__errno() = MSVCRT_EILSEQ;
*MSVCRT__errno() = EILSEQ;
str[1] = 0;
}
*p++ = c & 255;
......
......@@ -249,7 +249,7 @@ WCHAR** CDECL MSVCRT___p__wpgmptr(void) { return &MSVCRT__wpgmptr; }
*/
int CDECL _get_pgmptr(char** p)
{
if (!MSVCRT_CHECK_PMT(p)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(p)) return EINVAL;
*p = MSVCRT__pgmptr;
return 0;
......@@ -260,7 +260,7 @@ int CDECL _get_pgmptr(char** p)
*/
int CDECL _get_wpgmptr(WCHAR** p)
{
if (!MSVCRT_CHECK_PMT(p)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(p)) return EINVAL;
*p = MSVCRT__wpgmptr;
return 0;
}
......@@ -277,7 +277,7 @@ int CDECL MSVCRT__set_fmode(int mode)
{
/* TODO: support _O_WTEXT */
if(!MSVCRT_CHECK_PMT(mode==MSVCRT__O_TEXT || mode==MSVCRT__O_BINARY))
return MSVCRT_EINVAL;
return EINVAL;
MSVCRT__fmode = mode;
return 0;
......@@ -289,7 +289,7 @@ int CDECL MSVCRT__set_fmode(int mode)
int CDECL MSVCRT__get_fmode(int *mode)
{
if(!MSVCRT_CHECK_PMT(mode))
return MSVCRT_EINVAL;
return EINVAL;
*mode = MSVCRT__fmode;
return 0;
......@@ -366,7 +366,7 @@ wchar_t*** CDECL __p___winitenv(void) { return &MSVCRT___winitenv; }
*/
int CDECL MSVCRT__get_osplatform(int *pValue)
{
if (!MSVCRT_CHECK_PMT(pValue != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(pValue != NULL)) return EINVAL;
*pValue = MSVCRT__osplatform;
return 0;
}
......@@ -787,7 +787,7 @@ wchar_t* CDECL _get_wide_winmain_command_line(void)
*/
int CDECL MSVCRT__get_winmajor(int* value)
{
if (!MSVCRT_CHECK_PMT(value != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(value != NULL)) return EINVAL;
*value = MSVCRT__winmajor;
return 0;
}
......@@ -797,7 +797,7 @@ int CDECL MSVCRT__get_winmajor(int* value)
*/
int CDECL MSVCRT__get_winminor(int* value)
{
if (!MSVCRT_CHECK_PMT(value != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(value != NULL)) return EINVAL;
*value = MSVCRT__winminor;
return 0;
}
......@@ -807,7 +807,7 @@ int CDECL MSVCRT__get_winminor(int* value)
*/
int CDECL MSVCRT__get_osver(int* value)
{
if (!MSVCRT_CHECK_PMT(value != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(value != NULL)) return EINVAL;
*value = MSVCRT__osver;
return 0;
}
......@@ -216,16 +216,16 @@ int CDECL _dupenv_s(char **buffer, size_t *numberOfElements, const char *varname
char *e;
size_t sz;
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return EINVAL;
if (!(e = MSVCRT_getenv(varname))) return *MSVCRT__errno() = MSVCRT_EINVAL;
if (!(e = MSVCRT_getenv(varname))) return *MSVCRT__errno() = EINVAL;
sz = strlen(e) + 1;
if (!(*buffer = MSVCRT_malloc(sz)))
{
if (numberOfElements) *numberOfElements = 0;
return *MSVCRT__errno() = MSVCRT_ENOMEM;
return *MSVCRT__errno() = ENOMEM;
}
strcpy(*buffer, e);
if (numberOfElements) *numberOfElements = sz;
......@@ -241,16 +241,16 @@ int CDECL _wdupenv_s(wchar_t **buffer, size_t *numberOfElements,
wchar_t *e;
size_t sz;
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return EINVAL;
if (!(e = MSVCRT__wgetenv(varname))) return *MSVCRT__errno() = MSVCRT_EINVAL;
if (!(e = MSVCRT__wgetenv(varname))) return *MSVCRT__errno() = EINVAL;
sz = MSVCRT_wcslen(e) + 1;
if (!(*buffer = MSVCRT_malloc(sz * sizeof(wchar_t))))
{
if (numberOfElements) *numberOfElements = 0;
return *MSVCRT__errno() = MSVCRT_ENOMEM;
return *MSVCRT__errno() = ENOMEM;
}
MSVCRT_wcscpy(*buffer, e);
if (numberOfElements) *numberOfElements = sz;
......@@ -266,19 +266,19 @@ int CDECL getenv_s(size_t *pReturnValue, char* buffer, size_t numberOfElements,
{
char *e;
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0))) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0))) return EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return EINVAL;
if (!(e = MSVCRT_getenv(varname)))
{
*pReturnValue = 0;
return *MSVCRT__errno() = MSVCRT_EINVAL;
return *MSVCRT__errno() = EINVAL;
}
*pReturnValue = strlen(e) + 1;
if (numberOfElements < *pReturnValue)
{
return *MSVCRT__errno() = MSVCRT_ERANGE;
return *MSVCRT__errno() = ERANGE;
}
strcpy(buffer, e);
return 0;
......@@ -292,19 +292,19 @@ int CDECL _wgetenv_s(size_t *pReturnValue, wchar_t *buffer, size_t numberOfEleme
{
wchar_t *e;
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0))) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0))) return EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return EINVAL;
if (!(e = MSVCRT__wgetenv(varname)))
{
*pReturnValue = 0;
return *MSVCRT__errno() = MSVCRT_EINVAL;
return *MSVCRT__errno() = EINVAL;
}
*pReturnValue = MSVCRT_wcslen(e) + 1;
if (numberOfElements < *pReturnValue)
{
return *MSVCRT__errno() = MSVCRT_ERANGE;
return *MSVCRT__errno() = ERANGE;
}
MSVCRT_wcscpy(buffer, e);
return 0;
......
......@@ -150,7 +150,7 @@ void msvcrt_set_errno(int err)
ERR_CASE(ERROR_NOT_LOCKED)
ERR_CASE(ERROR_INVALID_ACCESS)
ERR_CASE(ERROR_SHARING_VIOLATION)
ERR_MAPS(ERROR_LOCK_VIOLATION, MSVCRT_EACCES);
ERR_MAPS(ERROR_LOCK_VIOLATION, EACCES);
ERR_CASE(ERROR_FILE_NOT_FOUND)
ERR_CASE(ERROR_NO_MORE_FILES)
ERR_CASE(ERROR_BAD_PATHNAME)
......@@ -158,33 +158,33 @@ void msvcrt_set_errno(int err)
ERR_CASE(ERROR_INVALID_DRIVE)
ERR_CASE(ERROR_BAD_NET_NAME)
ERR_CASE(ERROR_FILENAME_EXCED_RANGE)
ERR_MAPS(ERROR_PATH_NOT_FOUND, MSVCRT_ENOENT);
ERR_MAPS(ERROR_IO_DEVICE, MSVCRT_EIO);
ERR_MAPS(ERROR_BAD_FORMAT, MSVCRT_ENOEXEC);
ERR_MAPS(ERROR_INVALID_HANDLE, MSVCRT_EBADF);
ERR_MAPS(ERROR_PATH_NOT_FOUND, ENOENT);
ERR_MAPS(ERROR_IO_DEVICE, EIO);
ERR_MAPS(ERROR_BAD_FORMAT, ENOEXEC);
ERR_MAPS(ERROR_INVALID_HANDLE, EBADF);
ERR_CASE(ERROR_OUTOFMEMORY)
ERR_CASE(ERROR_INVALID_BLOCK)
ERR_CASE(ERROR_NOT_ENOUGH_QUOTA)
ERR_MAPS(ERROR_ARENA_TRASHED, MSVCRT_ENOMEM);
ERR_MAPS(ERROR_BUSY, MSVCRT_EBUSY);
ERR_MAPS(ERROR_ARENA_TRASHED, ENOMEM);
ERR_MAPS(ERROR_BUSY, EBUSY);
ERR_CASE(ERROR_ALREADY_EXISTS)
ERR_MAPS(ERROR_FILE_EXISTS, MSVCRT_EEXIST);
ERR_MAPS(ERROR_BAD_DEVICE, MSVCRT_ENODEV);
ERR_MAPS(ERROR_TOO_MANY_OPEN_FILES, MSVCRT_EMFILE);
ERR_MAPS(ERROR_DISK_FULL, MSVCRT_ENOSPC);
ERR_MAPS(ERROR_BROKEN_PIPE, MSVCRT_EPIPE);
ERR_MAPS(ERROR_POSSIBLE_DEADLOCK, MSVCRT_EDEADLK);
ERR_MAPS(ERROR_DIR_NOT_EMPTY, MSVCRT_ENOTEMPTY);
ERR_MAPS(ERROR_BAD_ENVIRONMENT, MSVCRT_E2BIG);
ERR_MAPS(ERROR_FILE_EXISTS, EEXIST);
ERR_MAPS(ERROR_BAD_DEVICE, ENODEV);
ERR_MAPS(ERROR_TOO_MANY_OPEN_FILES, EMFILE);
ERR_MAPS(ERROR_DISK_FULL, ENOSPC);
ERR_MAPS(ERROR_BROKEN_PIPE, EPIPE);
ERR_MAPS(ERROR_POSSIBLE_DEADLOCK, EDEADLK);
ERR_MAPS(ERROR_DIR_NOT_EMPTY, ENOTEMPTY);
ERR_MAPS(ERROR_BAD_ENVIRONMENT, E2BIG);
ERR_CASE(ERROR_WAIT_NO_CHILDREN)
ERR_MAPS(ERROR_CHILD_NOT_COMPLETE, MSVCRT_ECHILD);
ERR_MAPS(ERROR_CHILD_NOT_COMPLETE, ECHILD);
ERR_CASE(ERROR_NO_PROC_SLOTS)
ERR_CASE(ERROR_MAX_THRDS_REACHED)
ERR_MAPS(ERROR_NESTING_NOT_ALLOWED, MSVCRT_EAGAIN);
ERR_MAPS(ERROR_NESTING_NOT_ALLOWED, EAGAIN);
default:
/* Remaining cases map to EINVAL */
/* FIXME: may be missing some errors above */
*errno_ptr = MSVCRT_EINVAL;
*errno_ptr = EINVAL;
}
}
......@@ -230,7 +230,7 @@ __msvcrt_ulong* CDECL MSVCRT___doserrno(void)
int CDECL _get_errno(int *pValue)
{
if (!pValue)
return MSVCRT_EINVAL;
return EINVAL;
*pValue = *MSVCRT__errno();
return 0;
......@@ -242,7 +242,7 @@ int CDECL _get_errno(int *pValue)
int CDECL _get_doserrno(int *pValue)
{
if (!pValue)
return MSVCRT_EINVAL;
return EINVAL;
*pValue = *MSVCRT___doserrno();
return 0;
......@@ -290,8 +290,8 @@ int CDECL MSVCRT_strerror_s(char *buffer, size_t numberOfElements, int errnum)
if (!buffer || !numberOfElements)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
if (errnum < 0 || errnum > MSVCRT__sys_nerr)
......@@ -377,8 +377,8 @@ void CDECL MSVCRT__wperror(const wchar_t* str)
*/
int CDECL MSVCRT__wcserror_s(wchar_t* buffer, size_t nc, int err)
{
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(nc > 0)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(nc > 0)) return EINVAL;
if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;
MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer, nc);
......@@ -413,8 +413,8 @@ int CDECL MSVCRT___wcserror_s(wchar_t* buffer, size_t nc, const wchar_t* str)
if (str && *str) len += MSVCRT_wcslen(str) + 2 /* ': ' */;
if (len > nc)
{
MSVCRT_INVALID_PMT("buffer[nc] is too small", MSVCRT_ERANGE);
return MSVCRT_ERANGE;
MSVCRT_INVALID_PMT("buffer[nc] is too small", ERANGE);
return ERANGE;
}
if (str && *str)
{
......
......@@ -118,7 +118,7 @@ typedef struct _SCOPETABLE
void * (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
typedef struct MSVCRT_EXCEPTION_FRAME
{
EXCEPTION_REGISTRATION_RECORD *prev;
void (*handler)(PEXCEPTION_RECORD, EXCEPTION_REGISTRATION_RECORD*,
......
......@@ -335,7 +335,7 @@ int CDECL _heapset(unsigned int value)
int CDECL _heapadd(void* mem, size_t size)
{
TRACE("(%p,%Iu) unsupported in Win32\n", mem,size);
*MSVCRT__errno() = MSVCRT_ENOSYS;
*MSVCRT__errno() = ENOSYS;
return -1;
}
......@@ -388,7 +388,7 @@ void* CDECL DECLSPEC_HOTPATCH MSVCRT_calloc(size_t count, size_t size)
if (size && bytes / size != count)
{
*MSVCRT__errno() = MSVCRT_ENOMEM;
*MSVCRT__errno() = ENOMEM;
return NULL;
}
......@@ -438,7 +438,7 @@ void* CDECL MSVCRT_malloc(size_t size)
} while(_callnewh(size));
if (!ret)
*MSVCRT__errno() = MSVCRT_ENOMEM;
*MSVCRT__errno() = ENOMEM;
return ret;
}
......@@ -490,7 +490,7 @@ void* CDECL _recalloc(void *mem, size_t num, size_t size)
ret = MSVCRT_realloc(mem, size);
if(!ret) {
*MSVCRT__errno() = MSVCRT_ENOMEM;
*MSVCRT__errno() = ENOMEM;
return NULL;
}
......@@ -564,14 +564,14 @@ void * CDECL _aligned_offset_malloc(size_t size, size_t alignment, size_t offset
/* alignment must be a power of 2 */
if ((alignment & (alignment - 1)) != 0)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return NULL;
}
/* offset must be less than size */
if (offset && offset >= size)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return NULL;
}
......@@ -621,14 +621,14 @@ void * CDECL _aligned_offset_realloc(void *memblock, size_t size,
/* alignment must be a power of 2 */
if ((alignment & (alignment - 1)) != 0)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return NULL;
}
/* offset must be less than size */
if (offset >= size)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return NULL;
}
......@@ -646,7 +646,7 @@ void * CDECL _aligned_offset_realloc(void *memblock, size_t size,
saved = SAVED_PTR(memblock);
if (memblock != ALIGN_PTR(*saved, alignment, offset))
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return NULL;
}
......@@ -739,9 +739,9 @@ int CDECL MSVCRT_memmove_s(void *dest, size_t numberOfElements, const void *src,
if(!count)
return 0;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT_ERR( count <= numberOfElements, MSVCRT_ERANGE )) return MSVCRT_ERANGE;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT_ERR( count <= numberOfElements, ERANGE )) return ERANGE;
memmove(dest, src, count);
return 0;
......@@ -763,9 +763,9 @@ int CDECL wmemmove_s(wchar_t *dest, size_t numberOfElements,
* http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1225.pdf
* in that it does not zero the output buffer on constraint violation.
*/
if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT_ERR(count <= numberOfElements, MSVCRT_ERANGE)) return MSVCRT_ERANGE;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT_ERR(count <= numberOfElements, ERANGE)) return ERANGE;
memmove(dest, src, sizeof(wchar_t)*count);
return 0;
......@@ -782,16 +782,16 @@ int CDECL MSVCRT_memcpy_s(void *dest, size_t numberOfElements, const void *src,
if(!count)
return 0;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL))
{
memset(dest, 0, numberOfElements);
return MSVCRT_EINVAL;
return EINVAL;
}
if (!MSVCRT_CHECK_PMT_ERR( count <= numberOfElements, MSVCRT_ERANGE ))
if (!MSVCRT_CHECK_PMT_ERR( count <= numberOfElements, ERANGE ))
{
memset(dest, 0, numberOfElements);
return MSVCRT_ERANGE;
return ERANGE;
}
memmove(dest, src, count);
......@@ -810,15 +810,15 @@ int CDECL wmemcpy_s(wchar_t *dest, size_t numberOfElements,
if (!count)
return 0;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) {
memset(dest, 0, numberOfElements*sizeof(wchar_t));
return MSVCRT_EINVAL;
return EINVAL;
}
if (!MSVCRT_CHECK_PMT_ERR(count <= numberOfElements, MSVCRT_ERANGE)) {
if (!MSVCRT_CHECK_PMT_ERR(count <= numberOfElements, ERANGE)) {
memset(dest, 0, numberOfElements*sizeof(wchar_t));
return MSVCRT_ERANGE;
return ERANGE;
}
memmove(dest, src, sizeof(wchar_t)*count);
......@@ -842,9 +842,9 @@ int CDECL MSVCRT_strncpy_s(char *dest, size_t numberOfElements,
return 0;
}
if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return EINVAL;
if(count!=MSVCRT__TRUNCATE && count<numberOfElements)
end = count;
......@@ -859,9 +859,9 @@ int CDECL MSVCRT_strncpy_s(char *dest, size_t numberOfElements,
return 0;
}
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", MSVCRT_EINVAL);
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", EINVAL);
dest[0] = '\0';
return MSVCRT_EINVAL;
return EINVAL;
}
BOOL msvcrt_init_heap(void)
......
......@@ -390,7 +390,7 @@ int CDECL _setmbcp(int cp)
mbcinfo = create_mbcinfo(cp, -1, get_mbcinfo());
if(!mbcinfo)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return -1;
}
......@@ -675,20 +675,20 @@ int CDECL _mbccpy_s_l(unsigned char* dest, size_t maxsize,
int *copied, const unsigned char* src, _locale_t locale)
{
if(copied) *copied = 0;
if(!MSVCRT_CHECK_PMT(dest != NULL && maxsize >= 1)) return MSVCRT_EINVAL;
if(!MSVCRT_CHECK_PMT(dest != NULL && maxsize >= 1)) return EINVAL;
dest[0] = 0;
if(!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
if(!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
if(_ismbblead_l(*src, locale)) {
if(!src[1]) {
if(copied) *copied = 1;
*MSVCRT__errno() = MSVCRT_EILSEQ;
return MSVCRT_EILSEQ;
*MSVCRT__errno() = EILSEQ;
return EILSEQ;
}
if(maxsize < 2) {
MSVCRT_INVALID_PMT("dst buffer is too small", MSVCRT_ERANGE);
return MSVCRT_ERANGE;
MSVCRT_INVALID_PMT("dst buffer is too small", ERANGE);
return ERANGE;
}
*dest++ = *src++;
......@@ -783,11 +783,11 @@ int CDECL _mbsnbcpy_s_l(unsigned char* dst, size_t size,
size_t pos = 0;
if(!dst || size == 0)
return MSVCRT_EINVAL;
return EINVAL;
if(!src)
{
dst[0] = '\0';
return MSVCRT_EINVAL;
return EINVAL;
}
if(!n)
return 0;
......@@ -800,7 +800,7 @@ int CDECL _mbsnbcpy_s_l(unsigned char* dst, size_t size,
if(pos == size)
{
dst[0] = '\0';
return MSVCRT_ERANGE;
return ERANGE;
}
is_lead = (!is_lead && _ismbblead(*src));
n--;
......@@ -818,7 +818,7 @@ int CDECL _mbsnbcpy_s_l(unsigned char* dst, size_t size,
if(pos == size)
{
dst[0] = '\0';
return MSVCRT_ERANGE;
return ERANGE;
}
if(!(*src)) break;
......@@ -831,7 +831,7 @@ int CDECL _mbsnbcpy_s_l(unsigned char* dst, size_t size,
else
{
dst[0] = '\0';
return MSVCRT_ERANGE;
return ERANGE;
}
return 0;
......@@ -1216,32 +1216,32 @@ int CDECL _mbscat_s_l( unsigned char *dst, size_t size,
size_t i, j;
int ret = 0;
if(!MSVCRT_CHECK_PMT(dst != NULL)) return MSVCRT_EINVAL;
if(!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
if(!MSVCRT_CHECK_PMT(dst != NULL)) return EINVAL;
if(!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
for(i=0; i<size; i++)
if(!dst[i]) break;
if(i == size) {
MSVCRT_INVALID_PMT("dst is not NULL-terminated", MSVCRT_EINVAL);
MSVCRT_INVALID_PMT("dst is not NULL-terminated", EINVAL);
if(size) dst[0] = 0;
return MSVCRT_EINVAL;
return EINVAL;
}
if(i && _ismbblead_l(dst[i-1], locale)) {
ret = MSVCRT_EILSEQ;
ret = EILSEQ;
i--;
}
for(j=0; src[j] && i+j<size; j++)
dst[i+j] = src[j];
if(i+j == size) {
MSVCRT_INVALID_PMT("dst buffer is too small", MSVCRT_ERANGE);
MSVCRT_INVALID_PMT("dst buffer is too small", ERANGE);
dst[0] = 0;
return MSVCRT_ERANGE;
return ERANGE;
}
if(j && _ismbblead_l(src[j-1], locale)) {
ret = MSVCRT_EILSEQ;
ret = EILSEQ;
j--;
}
......@@ -1950,8 +1950,8 @@ int CDECL _mbsnbcat_s(unsigned char *dst, size_t size, const unsigned char *src,
if (dst && size)
*dst = '\0';
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
/* Find the null terminator of the destination buffer. */
......@@ -1961,8 +1961,8 @@ int CDECL _mbsnbcat_s(unsigned char *dst, size_t size, const unsigned char *src,
if (!size)
{
*dst = '\0';
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
/* If necessary, check that the character preceding the null terminator is
......@@ -1978,8 +1978,8 @@ int CDECL _mbsnbcat_s(unsigned char *dst, size_t size, const unsigned char *src,
if (!size)
{
*dst = '\0';
*MSVCRT__errno() = MSVCRT_ERANGE;
return MSVCRT_ERANGE;
*MSVCRT__errno() = ERANGE;
return ERANGE;
}
}
......@@ -2052,8 +2052,8 @@ int CDECL _mbslwr_s(unsigned char* s, size_t len)
}
else if (!s || !len)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
if (get_mbcinfo()->ismbcodepage)
{
......@@ -2074,8 +2074,8 @@ int CDECL _mbslwr_s(unsigned char* s, size_t len)
if (*s)
{
*s = '\0';
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
return 0;
}
......@@ -2120,8 +2120,8 @@ int CDECL _mbsupr_s(unsigned char* s, size_t len)
}
else if (!s || !len)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
if (get_mbcinfo()->ismbcodepage)
{
......@@ -2142,8 +2142,8 @@ int CDECL _mbsupr_s(unsigned char* s, size_t len)
if (*s)
{
*s = '\0';
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
return 0;
}
......@@ -2374,7 +2374,7 @@ size_t CDECL _mbstrlen_l(const char* str, _locale_t locale)
len = MultiByteToWideChar(locinfo->lc_codepage, MB_ERR_INVALID_CHARS,
str, -1, NULL, 0);
if (!len) {
*MSVCRT__errno() = MSVCRT_EILSEQ;
*MSVCRT__errno() = EILSEQ;
return -1;
}
return len - 1;
......@@ -2512,7 +2512,7 @@ size_t CDECL MSVCRT__mbstowcs_l(wchar_t *wcstr, const char *mbstr,
size_t i, size;
if(!mbstr) {
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return -1;
}
......@@ -2537,7 +2537,7 @@ size_t CDECL MSVCRT__mbstowcs_l(wchar_t *wcstr, const char *mbstr,
size = MultiByteToWideChar(locinfo->lc_codepage,
MB_ERR_INVALID_CHARS, mbstr, -1, NULL, 0);
if(!size) {
*MSVCRT__errno() = MSVCRT_EILSEQ;
*MSVCRT__errno() = EILSEQ;
return -1;
}
return size - 1;
......@@ -2555,7 +2555,7 @@ size_t CDECL MSVCRT__mbstowcs_l(wchar_t *wcstr, const char *mbstr,
MB_ERR_INVALID_CHARS, mbstr, size, wcstr, count);
if(!size) {
if(count) wcstr[0] = '\0';
*MSVCRT__errno() = MSVCRT_EILSEQ;
*MSVCRT__errno() = EILSEQ;
return -1;
}
}
......@@ -2591,10 +2591,10 @@ int CDECL MSVCRT__mbstowcs_s_l(size_t *ret, wchar_t *wcstr,
return 0;
}
if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return MSVCRT_EINVAL;
if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(mbstr != NULL)) {
if(size) wcstr[0] = '\0';
return MSVCRT_EINVAL;
return EINVAL;
}
if(count==MSVCRT__TRUNCATE || size<count)
......@@ -2607,12 +2607,12 @@ int CDECL MSVCRT__mbstowcs_s_l(size_t *ret, wchar_t *wcstr,
wcstr[conv++] = '\0';
else if(conv==size && count==MSVCRT__TRUNCATE && wcstr[conv-1]!='\0') {
wcstr[conv-1] = '\0';
err = MSVCRT_STRUNCATE;
err = STRUNCATE;
}else if(conv==size && wcstr[conv-1]!='\0') {
MSVCRT_INVALID_PMT("wcstr[size] is too small", MSVCRT_ERANGE);
MSVCRT_INVALID_PMT("wcstr[size] is too small", ERANGE);
if(size)
wcstr[0] = '\0';
return MSVCRT_ERANGE;
return ERANGE;
}
if(ret)
......@@ -2675,7 +2675,7 @@ int CDECL MSVCRT_mbsrtowcs_s(size_t *ret, wchar_t *wcstr, size_t len,
if(!ret) ret = &tmp;
if(!MSVCRT_CHECK_PMT(!!wcstr == !!len)) {
*ret = -1;
return MSVCRT_EINVAL;
return EINVAL;
}
*ret = MSVCRT_mbsrtowcs(wcstr, mbstr, count>len ? len : count, state);
......
......@@ -69,8 +69,8 @@ int CDECL MSVCRT_rand_s(unsigned int *pval)
{
if (!pval || !RtlGenRandom(pval, sizeof(*pval)))
{
*MSVCRT__errno() = MSVCRT_EINVAL;
return MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return EINVAL;
}
return 0;
}
......
......@@ -20,6 +20,7 @@
#ifndef __WINE_MSVCRT_H
#define __WINE_MSVCRT_H
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <wchar.h>
......@@ -588,47 +589,6 @@ struct MSVCRT__stat64 {
#define MSVCRT__P_NOWAITO 3
#define MSVCRT__P_DETACH 4
#define MSVCRT_EPERM 1
#define MSVCRT_ENOENT 2
#define MSVCRT_ESRCH 3
#define MSVCRT_EINTR 4
#define MSVCRT_EIO 5
#define MSVCRT_ENXIO 6
#define MSVCRT_E2BIG 7
#define MSVCRT_ENOEXEC 8
#define MSVCRT_EBADF 9
#define MSVCRT_ECHILD 10
#define MSVCRT_EAGAIN 11
#define MSVCRT_ENOMEM 12
#define MSVCRT_EACCES 13
#define MSVCRT_EFAULT 14
#define MSVCRT_EBUSY 16
#define MSVCRT_EEXIST 17
#define MSVCRT_EXDEV 18
#define MSVCRT_ENODEV 19
#define MSVCRT_ENOTDIR 20
#define MSVCRT_EISDIR 21
#define MSVCRT_EINVAL 22
#define MSVCRT_ENFILE 23
#define MSVCRT_EMFILE 24
#define MSVCRT_ENOTTY 25
#define MSVCRT_EFBIG 27
#define MSVCRT_ENOSPC 28
#define MSVCRT_ESPIPE 29
#define MSVCRT_EROFS 30
#define MSVCRT_EMLINK 31
#define MSVCRT_EPIPE 32
#define MSVCRT_EDOM 33
#define MSVCRT_ERANGE 34
#define MSVCRT_EDEADLK 36
#define MSVCRT_EDEADLOCK MSVCRT_EDEADLK
#define MSVCRT_ENAMETOOLONG 38
#define MSVCRT_ENOLCK 39
#define MSVCRT_ENOSYS 40
#define MSVCRT_ENOTEMPTY 41
#define MSVCRT_EILSEQ 42
#define MSVCRT_STRUNCATE 80
#define MSVCRT_LC_ALL 0
#define MSVCRT_LC_COLLATE 1
#define MSVCRT_LC_CTYPE 2
......@@ -1009,7 +969,7 @@ int fpnum_double(struct fpnum*, double*) DECLSPEC_HIDDEN;
*/
#define MSVCRT_INVALID_PMT(x,err) (*MSVCRT__errno() = (err), MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0))
#define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), FALSE))
#define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), MSVCRT_EINVAL)
#define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), EINVAL)
#define MSVCRT__ARGMAX 100
typedef int (*puts_clbk_a)(void*, int, const char*);
......
......@@ -1126,7 +1126,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
int *used;
if(!n_format_enabled) {
MSVCRT_INVALID_PMT("\'n\' format specifier disabled", MSVCRT_EINVAL);
MSVCRT_INVALID_PMT("\'n\' format specifier disabled", EINVAL);
return -1;
}
......@@ -1189,7 +1189,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
} else {
if(invoke_invalid_param_handler) {
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return -1;
}
......
......@@ -139,7 +139,7 @@ static intptr_t msvcrt_spawn(int flags, const wchar_t* exe, wchar_t* cmdline,
if ((unsigned)flags > MSVCRT__P_DETACH)
{
*MSVCRT__errno() = MSVCRT_EINVAL;
*MSVCRT__errno() = EINVAL;
return -1;
}
......@@ -372,7 +372,7 @@ intptr_t CDECL _cwait(int *status, intptr_t pid, int action)
if (doserrno == ERROR_INVALID_HANDLE)
{
*MSVCRT__errno() = MSVCRT_ECHILD;
*MSVCRT__errno() = ECHILD;
*MSVCRT___doserrno() = doserrno;
}
else
......@@ -1191,7 +1191,7 @@ int CDECL MSVCRT__pclose(MSVCRT_FILE* file)
if(i == popen_handles_size)
{
_unlock(_POPEN_LOCK);
*MSVCRT__errno() = MSVCRT_EBADF;
*MSVCRT__errno() = EBADF;
return -1;
}
......@@ -1228,7 +1228,7 @@ int CDECL _wsystem(const wchar_t* cmd)
{
if (comspec == NULL)
{
*MSVCRT__errno() = MSVCRT_ENOENT;
*MSVCRT__errno() = ENOENT;
return 0;
}
HeapFree(GetProcessHeap(), 0, comspec);
......
......@@ -121,7 +121,7 @@ uintptr_t CDECL _beginthread(
trampoline = MSVCRT_malloc(sizeof(*trampoline));
if(!trampoline) {
*MSVCRT__errno() = MSVCRT_EAGAIN;
*MSVCRT__errno() = EAGAIN;
return -1;
}
......@@ -129,7 +129,7 @@ uintptr_t CDECL _beginthread(
trampoline, CREATE_SUSPENDED, NULL);
if(!thread) {
MSVCRT_free(trampoline);
*MSVCRT__errno() = MSVCRT_EAGAIN;
*MSVCRT__errno() = EAGAIN;
return -1;
}
......@@ -139,7 +139,7 @@ uintptr_t CDECL _beginthread(
if(ResumeThread(thread) == -1) {
MSVCRT_free(trampoline);
*MSVCRT__errno() = MSVCRT_EAGAIN;
*MSVCRT__errno() = EAGAIN;
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment