Added debug messages.

svn path=/trunk/; revision=2795
This commit is contained in:
Hartmut Birr 2002-04-01 21:38:50 +00:00
parent a45170ea27
commit 50c7ca2780
11 changed files with 114 additions and 12 deletions

View file

@ -0,0 +1,43 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/msvcrt/msvcrtdbg.h
* PURPOSE: Useful debugging macros
* PROGRAMMER:
* UPDATE HISTORY:
*
*/
/*
* NOTE: Define NDEBUG before including this header to disable debugging
* macros
*/
#ifndef __MSVCRT_DEBUG
#define __MSVCRT_DEBUG
#include <roscfg.h>
#if 0
#ifdef NDEBUG
#undef NDEBUG
#endif
#endif
#ifdef DBG
#define DPRINT1(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#define CHECKPOINT1 do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
#else
#define DPRINT1(args...)
#define CHECKPOINT1
#endif
#if !defined(NDEBUG) && defined(DBG)
#define DPRINT(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#define CHECKPOINT do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
#else
#define DPRINT(args...)
#define CHECKPOINT
#endif /* NDEBUG */
#endif /* __MSVCRT_DEBUG */

View file

@ -1,5 +1,8 @@
#include <windows.h> #include <windows.h>
#include <msvcrt/io.h> #include <msvcrt/io.h>
#include <msvcrt/errno.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#ifndef F_OK #ifndef F_OK
#define F_OK 0x01 #define F_OK 0x01
@ -20,17 +23,24 @@
int _access( const char *_path, int _amode ) int _access( const char *_path, int _amode )
{ {
DWORD Attributes = GetFileAttributesA(_path); DWORD Attributes = GetFileAttributesA(_path);
DPRINT("_access('%s', %x)\n", _path, _amode);
if ( Attributes == -1 ) if ( Attributes == -1 ) {
__set_errno(ENOENT);
return -1; return -1;
}
if ( (_amode & W_OK) == W_OK ) { if ( (_amode & W_OK) == W_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) {
__set_errno(EACCES);
return -1; return -1;
}
} }
if ( (_amode & D_OK) == D_OK ) { if ( (_amode & D_OK) == D_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) {
__set_errno(EACCES);
return -1; return -1;
}
} }
return 0; return 0;
@ -40,16 +50,22 @@ int _waccess( const wchar_t *_path, int _amode )
{ {
DWORD Attributes = GetFileAttributesW(_path); DWORD Attributes = GetFileAttributesW(_path);
if ( Attributes == -1 ) if ( Attributes == -1 ) {
__set_errno(ENOENT);
return -1; return -1;
}
if ( (_amode & W_OK) == W_OK ) { if ( (_amode & W_OK) == W_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) {
__set_errno(EACCES);
return -1; return -1;
}
} }
if ( (_amode & D_OK) == D_OK ) { if ( (_amode & D_OK) == D_OK ) {
if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) {
__set_errno(EACCES);
return -1; return -1;
}
} }
return 0; return 0;

View file

@ -1,12 +1,15 @@
#include <windows.h> #include <windows.h>
#include <msvcrt/io.h> #include <msvcrt/io.h>
#define mode_t int #define NDEBUG
#include <msvcrt/msvcrtdbg.h>
#define mode_t int
int _chmod(const char *filename, mode_t mode) int _chmod(const char *filename, mode_t mode)
{ {
DWORD FileAttributes = 0; DWORD FileAttributes = 0;
DPRINT("_chmod('%s', %x)\n", filename, mode);
FileAttributes = GetFileAttributesA(filename); FileAttributes = GetFileAttributesA(filename);
if ( FileAttributes == -1 ) if ( FileAttributes == -1 )
@ -31,6 +34,7 @@ int _chmod(const char *filename, mode_t mode)
int _wchmod(const wchar_t *filename, mode_t mode) int _wchmod(const wchar_t *filename, mode_t mode)
{ {
DWORD FileAttributes = 0; DWORD FileAttributes = 0;
DPRINT("_wchmod('%S', %x)\n", filename, mode);
FileAttributes = GetFileAttributesW(filename); FileAttributes = GetFileAttributesW(filename);
if ( FileAttributes == -1 ) if ( FileAttributes == -1 )

View file

@ -1,8 +1,12 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
#include <msvcrt/io.h> #include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _chsize(int _fd, long size) int _chsize(int _fd, long size)
{ {
DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
if (lseek(_fd, size, 0) == -1) if (lseek(_fd, size, 0) == -1)
return -1; return -1;
if (_write(_fd, 0, 0) < 0) if (_write(_fd, 0, 0) < 0)

View file

@ -2,8 +2,12 @@
#include <msvcrt/io.h> #include <msvcrt/io.h>
#include <msvcrt/internal/file.h> #include <msvcrt/internal/file.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _close(int _fd) int _close(int _fd)
{ {
DPRINT("_close(fd %d)\n", _fd);
if (_fd == -1) if (_fd == -1)
return -1; return -1;
if (CloseHandle(_get_osfhandle(_fd)) == FALSE) if (CloseHandle(_get_osfhandle(_fd)) == FALSE)

View file

@ -1,12 +1,17 @@
#include <msvcrt/io.h> #include <msvcrt/io.h>
#include <msvcrt/fcntl.h> #include <msvcrt/fcntl.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _creat(const char *filename, int mode) int _creat(const char *filename, int mode)
{ {
DPRINT("_creat('%s', mode %x)\n", filename, mode);
return _open(filename,_O_CREAT|_O_TRUNC,mode); return _open(filename,_O_CREAT|_O_TRUNC,mode);
} }
int _wcreat(const wchar_t *filename, int mode) int _wcreat(const wchar_t *filename, int mode)
{ {
DPRINT("_wcreat('%S', mode %x)\n", filename, mode);
return _wopen(filename,_O_CREAT|_O_TRUNC,mode); return _wopen(filename,_O_CREAT|_O_TRUNC,mode);
} }

View file

@ -1,11 +1,13 @@
#include <msvcrt/io.h> #include <msvcrt/io.h>
#include <msvcrt/sys/stat.h> #include <msvcrt/sys/stat.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _isatty( int fd ) int _isatty( int fd )
{ {
struct stat buf; struct stat buf;
DPRINT("_isatty(fd %d)\n", fd);
if (_fstat (fd, &buf) < 0) if (_fstat (fd, &buf) < 0)
return 0; return 0;
if (S_ISCHR (buf.st_mode)) if (S_ISCHR (buf.st_mode))

View file

@ -17,6 +17,9 @@
#include <msvcrt/string.h> #include <msvcrt/string.h>
#include <msvcrt/io.h> #include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
char* _mktemp (char *_template) char* _mktemp (char *_template)
{ {
@ -24,6 +27,7 @@ char* _mktemp (char *_template)
char *cp, *dp; char *cp, *dp;
int i, len, xcount, loopcnt; int i, len, xcount, loopcnt;
DPRINT("_mktemp('%s')\n", _template);
len = strlen (_template); len = strlen (_template);
cp = _template + len; cp = _template + len;
@ -76,6 +80,7 @@ wchar_t* _wmktemp (wchar_t *_template)
wchar_t *cp, *dp; wchar_t *cp, *dp;
int i, len, xcount, loopcnt; int i, len, xcount, loopcnt;
DPRINT("_wmktemp('%S')\n", _template);
len = wcslen (_template); len = wcslen (_template);
cp = _template + len; cp = _template + len;

View file

@ -10,16 +10,23 @@
#include <windows.h> #include <windows.h>
#include <msvcrt/io.h> #include <msvcrt/io.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int _unlink(const char *filename) int _unlink(const char *filename)
{ {
int result = 0;
DPRINT("_unlink('%s')\n", filename);
if (!DeleteFileA(filename)) if (!DeleteFileA(filename))
return -1; result = -1;
return 0; DPRINT("%d\n", result);
return result;
} }
int _wunlink(const wchar_t *filename) int _wunlink(const wchar_t *filename)
{ {
DPRINT("_wunlink('%S')\n", filename);
if (!DeleteFileW(filename)) if (!DeleteFileW(filename))
return -1; return -1;
return 0; return 0;

View file

@ -2,15 +2,22 @@
#include <msvcrt/stddef.h> #include <msvcrt/stddef.h>
#include <msvcrt/stdio.h> #include <msvcrt/stdio.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
int remove(const char *fn) int remove(const char *fn)
{ {
int result = 0;
DPRINT("remove('%s')\n", fn);
if (!DeleteFileA(fn)) if (!DeleteFileA(fn))
return -1; result = -1;
return 0; DPRINT("%d\n", result);
return result;
} }
int _wremove(const wchar_t *fn) int _wremove(const wchar_t *fn)
{ {
DPRINT("_wremove('%S')\n", fn);
if (!DeleteFileW(fn)) if (!DeleteFileW(fn))
return -1; return -1;
return 0; return 0;

View file

@ -2,6 +2,9 @@
#include <msvcrt/stdlib.h> #include <msvcrt/stdlib.h>
#include <msvcrt/string.h> #include <msvcrt/string.h>
#define NDEBUG
#include <msvcrt/msvcrtdbg.h>
void _searchenv(const char *file,const char *var,char *path ) void _searchenv(const char *file,const char *var,char *path )
{ {
char *env = getenv(var); char *env = getenv(var);
@ -9,6 +12,7 @@ void _searchenv(const char *file,const char *var,char *path )
char *y; char *y;
char *FilePart; char *FilePart;
DPRINT("_searchenv()\n");
x = strchr(env,'='); x = strchr(env,'=');
if ( x != NULL ) { if ( x != NULL ) {
*x = 0; *x = 0;
@ -33,6 +37,7 @@ void _wsearchenv(const wchar_t *file,const wchar_t *var,wchar_t *path)
wchar_t *y; wchar_t *y;
wchar_t *FilePart; wchar_t *FilePart;
DPRINT("_searchenw()\n");
x = wcschr(env,L'='); x = wcschr(env,L'=');
if ( x != NULL ) { if ( x != NULL ) {
*x = 0; *x = 0;