From 0bbf23c333f88bf74d3cb4865bfd1dc4ec18f0a4 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 3 Jul 2001 12:56:48 +0000 Subject: [PATCH] Untangled crtdll/msvcrt header mess. svn path=/trunk/; revision=2028 --- reactos/include/crtdll/sys/fcntl.h | 2 +- reactos/include/crtdll/sys/file.h | 2 +- reactos/include/crtdll/sys/stat.h | 8 +- reactos/include/crtdll/sys/time.h | 2 +- reactos/include/crtdll/sys/unistd.h | 2 +- reactos/include/crtdll/sys/utime.h | 10 +- reactos/include/msvcrt/alloc.h | 77 +++++ reactos/include/msvcrt/assert.h | 69 +++++ reactos/include/msvcrt/ctype.h | 6 +- reactos/include/msvcrt/dir.h | 103 +++++++ reactos/include/msvcrt/errno.h | 19 +- reactos/include/msvcrt/fcntl.h | 125 ++++++++ reactos/include/msvcrt/internal/atexit.h | 33 +++ reactos/include/msvcrt/internal/file.h | 93 ++++++ reactos/include/msvcrt/io.h | 140 +++++++++ reactos/include/msvcrt/malloc.h | 53 ++++ reactos/include/msvcrt/process.h | 160 ++++++++++ reactos/include/msvcrt/share.h | 17 ++ reactos/include/msvcrt/signal.h | 111 +++++++ reactos/include/msvcrt/stdarg.h | 107 +++++++ reactos/include/msvcrt/stddef.h | 8 +- reactos/include/msvcrt/stdio.h | 359 +++++++++++++++++++++++ reactos/include/msvcrt/time.h | 119 ++++++++ reactos/include/msvcrt/wchar.h | 32 ++ 24 files changed, 1620 insertions(+), 37 deletions(-) create mode 100644 reactos/include/msvcrt/alloc.h create mode 100644 reactos/include/msvcrt/assert.h create mode 100644 reactos/include/msvcrt/dir.h create mode 100644 reactos/include/msvcrt/fcntl.h create mode 100644 reactos/include/msvcrt/internal/atexit.h create mode 100644 reactos/include/msvcrt/internal/file.h create mode 100644 reactos/include/msvcrt/io.h create mode 100644 reactos/include/msvcrt/malloc.h create mode 100644 reactos/include/msvcrt/process.h create mode 100644 reactos/include/msvcrt/share.h create mode 100644 reactos/include/msvcrt/signal.h create mode 100644 reactos/include/msvcrt/stdarg.h create mode 100644 reactos/include/msvcrt/stdio.h create mode 100644 reactos/include/msvcrt/time.h create mode 100644 reactos/include/msvcrt/wchar.h diff --git a/reactos/include/crtdll/sys/fcntl.h b/reactos/include/crtdll/sys/fcntl.h index b343f272f4a..19a67bc4b9e 100644 --- a/reactos/include/crtdll/sys/fcntl.h +++ b/reactos/include/crtdll/sys/fcntl.h @@ -4,5 +4,5 @@ * This fcntl.h maps to the root fcntl.h */ #ifndef __STRICT_ANSI__ -#include +#include #endif diff --git a/reactos/include/crtdll/sys/file.h b/reactos/include/crtdll/sys/file.h index 96c49e1174c..9b8cc980572 100644 --- a/reactos/include/crtdll/sys/file.h +++ b/reactos/include/crtdll/sys/file.h @@ -5,5 +5,5 @@ * TODO? */ #ifndef __STRICT_ANSI__ -#include +#include #endif diff --git a/reactos/include/crtdll/sys/stat.h b/reactos/include/crtdll/sys/stat.h index 4d2e883acd2..e38e9189da5 100644 --- a/reactos/include/crtdll/sys/stat.h +++ b/reactos/include/crtdll/sys/stat.h @@ -19,9 +19,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.4 $ - * $Author: ariadne $ - * $Date: 1999/04/03 10:41:29 $ + * $Revision: 1.5 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:56:12 $ * */ @@ -30,7 +30,7 @@ #ifndef _STAT_H_ #define _STAT_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/reactos/include/crtdll/sys/time.h b/reactos/include/crtdll/sys/time.h index 39d85f67b5f..27d64df0d18 100644 --- a/reactos/include/crtdll/sys/time.h +++ b/reactos/include/crtdll/sys/time.h @@ -1,3 +1,3 @@ -#include +#include diff --git a/reactos/include/crtdll/sys/unistd.h b/reactos/include/crtdll/sys/unistd.h index ed122d9dd65..21f6fd14151 100644 --- a/reactos/include/crtdll/sys/unistd.h +++ b/reactos/include/crtdll/sys/unistd.h @@ -4,6 +4,6 @@ * unistd.h maps (roughly) to io.h */ #ifndef __STRICT_ANSI__ -#include +#include #endif diff --git a/reactos/include/crtdll/sys/utime.h b/reactos/include/crtdll/sys/utime.h index 6d7f4e93dcc..cce2dafe389 100644 --- a/reactos/include/crtdll/sys/utime.h +++ b/reactos/include/crtdll/sys/utime.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ - * $Author: ariadne $ - * $Date: 1999/04/02 21:42:07 $ + * $Revision: 1.2 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:56:12 $ * */ @@ -31,8 +31,8 @@ #define __need_wchar_t #define __need_size_t -#include -#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/reactos/include/msvcrt/alloc.h b/reactos/include/msvcrt/alloc.h new file mode 100644 index 00000000000..355142d5ebe --- /dev/null +++ b/reactos/include/msvcrt/alloc.h @@ -0,0 +1,77 @@ +/* + * alloc.h + * + * Memory management functions. Because most of these functions are + * actually declared in stdlib.h I have decided to simply include that + * header file. This file is included by malloc.h. My head hurts... + * + * NOTE: In the version of the Standard C++ Library from Cygnus there + * is also an alloc.h which needs to be on your include path. Most of + * the time I think the most sensible option would be to get rid of + * this file. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _ALLOC_H_ +#define _ALLOC_H_ + +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The structure used to walk through the heap with _heapwalk. + * TODO: This is a guess at the internals of this structure. + */ +typedef struct _heapinfo +{ + void* ptr; + unsigned int size; + int in_use; +} _HEAPINFO; + +int _heapwalk (_HEAPINFO* pHeapinfo); +void * _alloca(size_t size); + + + +#ifndef _NO_OLDNAMES +#define heapwalk(x) _heapwalk(x) +#define alloca(s) _alloca(s) +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _ALLOC_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/reactos/include/msvcrt/assert.h b/reactos/include/msvcrt/assert.h new file mode 100644 index 00000000000..f3c456f8b7e --- /dev/null +++ b/reactos/include/msvcrt/assert.h @@ -0,0 +1,69 @@ +/* + * assert.h + * + * Define the assert macro for debug output. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ + +#ifndef _ASSERT_H_ +#define _ASSERT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NDEBUG + +/* + * If not debugging, assert does nothing. + */ +#define assert(x) ((void)0); + +#else /* debugging enabled */ + +/* + * CRTDLL nicely supplies a function which does the actual output and + * call to abort. + */ +#ifndef __ATTRIB_NORETURN +#ifdef __GNUC__ +#define _ATTRIB_NORETURN __attribute__ ((noreturn)) +#else /* Not __GNUC__ */ +#define _ATTRIB_NORETURN +#endif /* __GNUC__ */ +#endif + +void _assert (const char* szExpression, const char* szFileName, int nLine) +_ATTRIB_NORETURN +; + +/* + * Definition of the assert macro. + */ +#define assert(x) if(!(x)) _assert( #x , __FILE__, __LINE__); +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/reactos/include/msvcrt/ctype.h b/reactos/include/msvcrt/ctype.h index 0ea129b9b4d..4ea4d882772 100644 --- a/reactos/include/msvcrt/ctype.h +++ b/reactos/include/msvcrt/ctype.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: ekohl $ - * $Date: 2000/12/03 17:49:21 $ + * $Date: 2001/07/03 12:56:48 $ * */ @@ -74,7 +74,7 @@ int toupper(int c); /* * NOTE: The above are not old name type wrappers, but functions exported - * explicitly by CRTDLL. However, underscored versions are also exported. + * explicitly by MSVCRT. However, underscored versions are also exported. */ #ifndef __STRICT_ANSI__ int _tolower(int c); diff --git a/reactos/include/msvcrt/dir.h b/reactos/include/msvcrt/dir.h new file mode 100644 index 00000000000..9d0599671f4 --- /dev/null +++ b/reactos/include/msvcrt/dir.h @@ -0,0 +1,103 @@ +/* + * dir.h + * + * Functions for working with directories and path names. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DIR_H_ +#define _DIR_H_ + +#include /* To get FILENAME_MAX... ugly. */ +#include /* To get time_t. */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Attributes of files as returned by _findfirst et al. + */ +#define _A_NORMAL 0x00000000 +#define _A_RDONLY 0x00000001 +#define _A_HIDDEN 0x00000002 +#define _A_SYSTEM 0x00000004 +#define _A_VOLID 0x00000008 +#define _A_SUBDIR 0x00000010 +#define _A_ARCH 0x00000020 + +#ifndef _FSIZE_T_DEFINED +typedef unsigned long _fsize_t; +#define _FSIZE_T_DEFINED +#endif + +/* + * The following structure is filled in by _findfirst or _findnext when + * they succeed in finding a match. + */ +struct _finddata_t +{ + unsigned attrib; /* Attributes, see constants above. */ + time_t time_create; + time_t time_access; /* always midnight local time */ + time_t time_write; + _fsize_t size; + char name[FILENAME_MAX]; /* may include spaces. */ +}; + +/* + * Functions for searching for files. _findfirst returns -1 if no match + * is found. Otherwise it returns a handle to be used in _findnext and + * _findclose calls. _findnext also returns -1 if no match could be found, + * and 0 if a match was found. Call _findclose when you are finished. + */ +int _findfirst (const char* szFilespec, struct _finddata_t* find); +int _findnext (int nHandle, struct _finddata_t* find); +int _findclose (int nHandle); + +int _chdir (const char* szPath); +char* _getcwd (char* caBuffer, int nBufferSize); +int _mkdir (const char* szPath); +char* _mktemp (char* szTemplate); +int _rmdir (const char* szPath); + + +#ifndef _NO_OLDNAMES + +int chdir (const char* szPath); +char* getcwd (char* caBuffer, int nBufferSize); +int mkdir (const char* szPath); +char* mktemp (char* szTemplate); +int rmdir (const char* szPath); + +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not _DIR_H_ */ + +#endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/msvcrt/errno.h b/reactos/include/msvcrt/errno.h index 509bf60d7b0..2d460a202ef 100644 --- a/reactos/include/msvcrt/errno.h +++ b/reactos/include/msvcrt/errno.h @@ -18,9 +18,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: ekohl $ - * $Date: 2000/12/03 17:49:21 $ + * $Date: 2001/07/03 12:56:48 $ * */ @@ -101,7 +101,6 @@ int* _errno(void); int* __doserrno(void); #define _doserrno (*__doserrno()) -#if __MSVCRT__ /* One of the MSVCRTxx libraries */ extern int* __imp__sys_nerr; @@ -110,20 +109,6 @@ extern int* __imp__sys_nerr; extern char** __imp__sys_errlist; #define sys_errlist (__imp__sys_errlist) -#else -/* CRTDLL run time library */ - - -#define _sys_nerr (*_sys_nerr_dll) -extern int* _sys_nerr_dll; -#define sys_nerr (*_sys_nerr_dll) - -extern const char* __sys_errlist[]; -#define sys_errlist (__sys_errlist) - -#endif - - #ifdef __cplusplus } diff --git a/reactos/include/msvcrt/fcntl.h b/reactos/include/msvcrt/fcntl.h new file mode 100644 index 00000000000..dd6f63e3d10 --- /dev/null +++ b/reactos/include/msvcrt/fcntl.h @@ -0,0 +1,125 @@ +/* + * fcntl.h + * + * Access constants for _open. Note that the permissions constants are + * in sys/stat.h (ick). + * + * This code is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ +/* added _O_RANDOM_O_SEQUENTIAL _O_SHORT_LIVED*/ +/* changed fmode_dll */ + +#ifndef _FCNTL_H_ +#define _FCNTL_H_ + +/* + * It appears that fcntl.h should include io.h for compatibility... + */ +#include + +/* + * This variable determines the default file mode. + * TODO: Which flags work? + */ +#if 0 +#if __MSVCRT__ +extern unsigned int* __imp__fmode; +#define _fmode (*__imp__fmode) +#else +/* CRTDLL */ +extern unsigned int* _fmode_dll; +#define _fmode (*_fmode_dll) +#endif +#endif /* 0 */ + +/* + * NOTE: This is the correct definition to build crtdll. + * It is NOT valid outside of crtdll. + */ +extern unsigned int* _fmode_dll; +extern unsigned int _fmode; + + +/* Specifiy one of these flags to define the access mode. */ +#define _O_RDONLY 0 +#define _O_WRONLY 1 +#define _O_RDWR 2 + +/* Mask for access mode bits in the _open flags. */ +#define _O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) + +#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */ +#define _O_CREAT 0x0100 /* Create the file if it does not exist. */ +#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */ +#define _O_EXCL 0x0400 /* Open only if the file does not exist. */ + +/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */ +#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */ +#define _O_BINARY 0x8000 /* Input and output is not translated. */ +#define _O_RAW _O_BINARY + +#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing. + * WARNING: Even if not created by _open! */ + + +#define _O_RANDOM 0x0010 +#define _O_SEQUENTIAL _O_RANDOM +#define _O_SHORT_LIVED 0x1000 + +#ifndef __STRICT_ANSI__ +#ifndef _NO_OLDNAMES + +/* POSIX/Non-ANSI names for increased portability */ +#define O_RDONLY _O_RDONLY +#define O_WRONLY _O_WRONLY +#define O_RDWR _O_RDWR +#define O_ACCMODE _O_ACCMODE +#define O_APPEND _O_APPEND +#define O_CREAT _O_CREAT +#define O_TRUNC _O_TRUNC +#define O_EXCL _O_EXCL +#define O_TEXT _O_TEXT +#define O_BINARY _O_BINARY +#define O_TEMPORARY _O_TEMPORARY + +#define O_RANDOM _O_RANDOM +#define O_SEQUENTIAL _O_RANDOM +#define O_SHORT_LIVED _O_SHORT_LIVED + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +extern "C" { +#endif + +int _setmode (int nHandle, int nAccessMode); + +#ifndef _NO_OLDNAMES +int setmode (int nHandle, int nAccessMode); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not __STRICT_ANSI__ */ +#endif /* Not _FCNTL_H_ */ diff --git a/reactos/include/msvcrt/internal/atexit.h b/reactos/include/msvcrt/internal/atexit.h new file mode 100644 index 00000000000..b3a9f0103ad --- /dev/null +++ b/reactos/include/msvcrt/internal/atexit.h @@ -0,0 +1,33 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_atexit_h__ +#define __dj_include_libc_dosexec_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +struct __atexit { + struct __atexit *__next; + void (*__function)(void); +}; + +extern struct __atexit *__atexit_ptr; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_dosexec_h__ */ diff --git a/reactos/include/msvcrt/internal/file.h b/reactos/include/msvcrt/internal/file.h new file mode 100644 index 00000000000..b36a1264c87 --- /dev/null +++ b/reactos/include/msvcrt/internal/file.h @@ -0,0 +1,93 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#ifndef __dj_include_libc_file_h__ +#define __dj_include_libc_file_h__ + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#ifndef _IORMONCL +#define _IORMONCL 004000 /* remove on close, for temp files */ +#endif +/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ + +#ifndef _IOUNGETC +#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */ +#endif + + +// might need check for IO_APPEND aswell +#define OPEN4WRITING(f) ((((f)->_flag & _IOWRT) == _IOWRT ) ) + +#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD ) ) + +// might need check for IO_APPEND aswell +#define WRITE_STREAM(f) ((((f)->_flag & _IOWRT) == _IOWRT ) ) + +#define READ_STREAM(f) ((((f)->_flag & _IOREAD) == _IOREAD ) ) + + +char __validfp (FILE *f); + +int __set_errno(int err); +void *filehnd(int fn); + +char __is_text_file(FILE *p); + +int __fileno_alloc(void *hFile, int mode); + +int _doprnt(const char *fmt, va_list args, FILE *f); +int _doscan(FILE *iop, const char *fmt, va_list argp); + + +int __fileno_dup2( int handle1, int handle2 ); +int __fileno_setmode(int _fd, int _newmode); +int __fileno_close(int _fd); + +void sigabort_handler(int sig); + +#include + +void UnixTimeToFileTime( time_t unix_time, FILETIME *filetime, DWORD remainder ); +time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder ); + + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + + +#define __FILE_REC_MAX 20 +typedef struct __file_rec +{ + struct __file_rec *next; + int count; + FILE *files[__FILE_REC_MAX]; +} __file_rec; + +extern __file_rec *__file_rec_list; + + +#ifdef __cplusplus +} +#endif + + +#endif /* __dj_include_libc_file_h__ */ + + + diff --git a/reactos/include/msvcrt/io.h b/reactos/include/msvcrt/io.h new file mode 100644 index 00000000000..b080048f4b1 --- /dev/null +++ b/reactos/include/msvcrt/io.h @@ -0,0 +1,140 @@ +/* + * io.h + * + * System level I/O functions and types. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ +/* added D_OK */ +/* changed get_osfhandle and open_osfhandle */ +/* added fileno as macro */ +#ifndef _IO_H_ +#define _IO_H_ + +#ifndef __STRICT_ANSI__ + +#include + +#include + + +/* We need the definition of FILE anyway... */ +#include + +/* MSVC's io.h contains the stuff from dir.h, so I will too. + * NOTE: This also defines off_t, the file offset type, through + * and inclusion of sys/types.h */ +#include + +/* TODO: Maximum number of open handles has not been tested, I just set + * it the same as FOPEN_MAX. */ +#define HANDLE_MAX FOPEN_MAX + + +/* Some defines for _access nAccessMode (MS doesn't define them, but + * it doesn't seem to hurt to add them). */ +#define F_OK 0 /* Check for file existence */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ +/* TODO: Is this safe? X_OK not supported directly... */ +#define X_OK R_OK /* Check for execute permission */ +#define D_OK 0x10 + + + +#ifdef __cplusplus +extern "C" { +#endif + +int _access (const char* szFileName, int nAccessMode); +int _chsize (int nHandle, long lnNewSize); +int _close (int nHandle); +int _commit(int _fd); +int _creat (const char* szFileName, int nAccessMode); +int _dup (int nHandle); +int _dup2 (int nOldHandle, int nNewHandle); +long _filelength (int nHandle); +int _fileno (FILE* fileGetHandle); +void* _get_osfhandle (int nHandle); +int _isatty (int nHandle); + +/* In a very odd turn of events this function is excluded from those + * files which define _STREAM_COMPAT. This is required in order to + * build GNU libio because of a conflict with _eof in streambuf.h + * line 107. Actually I might just be able to change the name of + * the enum member in streambuf.h... we'll see. TODO */ +#ifndef _STREAM_COMPAT +int _eof (int nHandle); +#endif + +/* LK_... locking commands defined in sys/locking.h. */ +int _locking (int nHandle, int nCmd, long lnLockRegionLength); + +off_t _lseek(int _fd, off_t _offset, int _whence); +int _open (const char* szFileName, int nFlags, ...); +int _open_osfhandle (void *lnOSHandle, int nFlags); +int _pipe (int *naHandles, unsigned int unSize, int nMode); +size_t _read(int _fd, void *_buf, size_t _nbyte); + +/* SH_... flags for nFlag defined in share.h */ +int _sopen (char* szFileName, int nAccess, int nFlag, int nMode); + +long _tell (int nHandle); +unsigned _umask (unsigned unMode); +int _unlink (const char* szFileName); +size_t _write(int _fd, const void *_buf, size_t _nbyte); + +#ifndef _NO_OLDNAMES +/* + * Non-underscored versions of non-ANSI functions to improve portability. + * These functions live in libmoldname.a. + */ + +#define access _access +#define chsize _chsize +#define close _close +#define creat _creat +#define dup _dup +#define dup2 _dup2 +#define eof _eof +#define filelength _filelength +#define fileno(f) ((f)->_file) +#define isatty _isatty +#define lseek _lseek +#define open _open +#define read _read +#define sopen(path,access,shflag,mode) _open((path), (access)|(shflag), (mode)) +#define tell(file) _lseek(_file, 0, SEEK_CUR) +#define umask _umask +#define unlink _unlink +#define write _write + + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not strict ANSI */ + +#endif /* _IO_H_ not defined */ diff --git a/reactos/include/msvcrt/malloc.h b/reactos/include/msvcrt/malloc.h new file mode 100644 index 00000000000..646a74991e0 --- /dev/null +++ b/reactos/include/msvcrt/malloc.h @@ -0,0 +1,53 @@ +/* + * malloc.h + * + * Support for programs which want to use malloc.h to get memory management + * functions. Unless you absolutely need some of these functions and they are + * not in the ANSI headers you should use the ANSI standard header files + * instead. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _MALLOC_H_ +#define _MALLOC_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void * _expand( void *memblock, size_t size ); +int _heapchk (void); /* Verify heap integrety. */ +int _heapmin (void); /* Return unused heap to the OS. */ +int _heapset (unsigned int unFill); +size_t _msize (void* pBlock); + +#ifdef __cplusplus +} +#endif + +#endif /* Not _MALLOC_H_ */ + +#endif /* Not __STRICT_ANSI__ */ diff --git a/reactos/include/msvcrt/process.h b/reactos/include/msvcrt/process.h new file mode 100644 index 00000000000..99d4051d92d --- /dev/null +++ b/reactos/include/msvcrt/process.h @@ -0,0 +1,160 @@ +/* + * process.h + * + * Function calls for spawning child processes. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ +/* changed second argument of cwait from nPID to hProc */ + +#ifndef _PROCESS_H_ +#define _PROCESS_H_ + +#ifndef __STRICT_ANSI__ + +#ifdef __cplusplus +extern "C" { +#endif + +void _cexit(void); +void _c_exit(void); + +/* + * Constants for cwait actions. + * Obsolete for Win32. + */ +#define _WAIT_CHILD 0 +#define _WAIT_GRANDCHILD 1 + +#ifndef _NO_OLDNAMES +#define WAIT_CHILD _WAIT_CHILD +#define WAIT_GRANDCHILD _WAIT_GRANDCHILD +#endif /* Not _NO_OLDNAMES */ + +int _cwait (int* pnStatus, int hProc, int nAction); + +int _getpid(void); + +int _execl (const char* szPath, const char* szArgv0, ...); +int _execle (const char* szPath, const char* szArgv0, ...); +int _execlp (const char* szPath, const char* szArgv0, ...); +int _execlpe (const char* szPath, const char* szArgv0, ...); +int _execv (const char* szPath, char* const* szaArgv); +int _execve (const char* szPath, char* const* szaArgv, char* const* szaEnv); +int _execvp (const char* szPath, char* const* szaArgv); +int _execvpe (const char* szPath, char* const* szaArgv, char* const* szaEnv); + + +/* + * Mode constants for spawn functions. + */ +#define _P_WAIT 0 +#define _P_NOWAIT 1 +#define _P_OVERLAY 2 +#define _OLD_P_OVERLAY _P_OVERLAY +#define _P_NOWAITO 3 +#define _P_DETACH 4 + +#ifndef _NO_OLDNAMES +#define P_WAIT _P_WAIT +#define P_NOWAIT _P_NOWAIT +#define P_OVERLAY _P_OVERLAY +#define OLD_P_OVERLAY _OLD_P_OVERLAY +#define P_NOWAITO _P_NOWAITO +#define P_DETACH _P_DETACH +#endif /* Not _NO_OLDNAMES */ + +int _spawnl (int nMode, const char* szPath, const char* szArgv0, ...); +int _spawnle (int nMode, const char* szPath, const char* szArgv0,...); +int _spawnlp (int nMode, const char* szPath, const char* szArgv0,...); +int _spawnlpe (int nMode, const char* szPath, const char* szArgv0,...); +int _spawnv (int nMode, const char* szPath, char* const* szaArgv); +int _spawnve (int nMode, const char* szPath, char* const* szaArgv, char* const* szaEnv); +int _spawnvp (int nMode, const char* szPath, char* const* szaArgv); +int _spawnvpe (int nMode, const char* szPath, char* const* szaArgv, char* const* szaEnv); +/* + * The functions _beginthreadex and _endthreadex are not provided by CRTDLL. + * They are provided by MSVCRT. + * + * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread, + * making for race conditions if you are not careful. Basically you have to + * make sure that no-one is going to do *anything* with the thread handle + * after the thread calls _endthread or returns from the thread function. + * + * NOTE: No old names for these functions. Use the underscore. + */ +unsigned long + _beginthread (void (__cdecl *pfuncStart)(void *), + unsigned unStackSize, void* pArgList); +void _endthread (void); + +#if __MSVCRT__ +unsigned long + _beginthreadex (void *pSecurity, unsigned unStackSize, + unsigned (__stdcall *pfuncStart)(void*), void* pArgList, + unsigned unInitFlags, unsigned* pThreadAddr); +void _endthreadex (unsigned unExitCode); +#endif + + +void *_loaddll (char *name); +int _unloaddll(void *handle); + +unsigned long __threadid(void); +#define _threadid __threadid() +void * __threadhandle(void); + + +#ifndef _NO_OLDNAMES + +#define cwait _cwait +#define getpid _getpid +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execlpe _execlpe + +#define execv _execv +#define execve _execve +#define execvp _execvp +#define execvpe _execvpe + +#define spawnl _spawnl +#define spawnle _spawnle +#define spawnlp _spawnlp +#define spawnlpe _spawnlpe + +#define spawnv _spawnv +#define spawnve _spawnve +#define spawnvp _spawnvp +#define spawnvpe _spawnvpe + + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not __STRICT_ANSI__ */ + +#endif /* _PROCESS_H_ not defined */ diff --git a/reactos/include/msvcrt/share.h b/reactos/include/msvcrt/share.h new file mode 100644 index 00000000000..8e3af3f29ed --- /dev/null +++ b/reactos/include/msvcrt/share.h @@ -0,0 +1,17 @@ +#ifndef _include_share_h_ +#define _include_share_h_ + + +#define SH_COMPAT 0x0000 +#define SH_DENYRW 0x0010 +#define SH_DENYWR 0x0020 +#define SH_DENYRD 0x0030 +#define SH_DENYNO 0x0040 + +#define _SH_COMPAT SH_COMPAT +#define _SH_DENYRW SH_DENYRW +#define _SH_DENYWR SH_DENYWR +#define _SH_DENYRD SH_DENYRD +#define _SH_DENYNO SH_DENYNO + +#endif diff --git a/reactos/include/msvcrt/signal.h b/reactos/include/msvcrt/signal.h new file mode 100644 index 00000000000..216d9fffe65 --- /dev/null +++ b/reactos/include/msvcrt/signal.h @@ -0,0 +1,111 @@ +/* + * signal.h + * + * A way to set handlers for exceptional conditions (also known as signals). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* added some extra signal constants */ +#ifndef _SIGNAL_H_ +#define _SIGNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The prototypes (below) are the easy part. The hard part is figuring + * out what signals are available and what numbers they are assigned + * along with appropriate values of SIG_DFL and SIG_IGN. + */ + +/* + * A pointer to a signal handler function. A signal handler takes a + * single int, which is the signal it handles. + */ +typedef void (*_p_sig_fn_t)(int nSig); + +/* + * These are special values of signal handler pointers which are + * used to send a signal to the default handler (SIG_DFL), ignore + * the signal (SIG_IGN), or indicate an error return (SIG_ERR). + */ +#define SIG_DFL ((_p_sig_fn_t) 0) +#define SIG_IGN ((_p_sig_fn_t) 1) +#define SIG_ERR ((_p_sig_fn_t) -1) + +/* + * The actual signal values. Using other values with signal + * produces a SIG_ERR return value. + * + * NOTE: SIGINT is produced when the user presses Ctrl-C. + * SIGILL has not been tested. + * SIGFPE doesn't seem to work? + * SIGSEGV does not catch writing to a NULL pointer (that shuts down + * your app; can you say "segmentation violation core dump"?). + * SIGTERM comes from what kind of termination request exactly? + * SIGBREAK is indeed produced by pressing Ctrl-Break. + * SIGABRT is produced by calling abort. + * TODO: The above results may be related to not installing an appropriate + * structured exception handling frame. Results may be better if I ever + * manage to get the SEH stuff down. + */ +#define SIGINT 2 /* Interactive attention */ +#define SIGILL 4 /* Illegal instruction */ +#define SIGFPE 8 /* Floating point error */ +#define SIGSEGV 11 /* Segmentation violation */ +#define SIGTERM 15 /* Termination request */ +#define SIGBREAK 21 /* Control-break */ +#define SIGABRT 22 /* Abnormal termination (abort) */ + +#define SIGALRM 293 +#define SIGHUP 294 +/* SIGINT is ansi */ +#define SIGKILL 296 +#define SIGPIPE 297 +#define SIGQUIT 298 +#define SIGUSR1 299 +#define SIGUSR2 300 + +#define SIGNOFP 301 +#define SIGTRAP 302 +#define SIGTIMR 303 /* Internal for setitimer (SIGALRM, SIGPROF) */ +#define SIGPROF 304 +#define SIGMAX 320 + +/* + * Call signal to set the signal handler for signal sig to the + * function pointed to by handler. Returns a pointer to the + * previous handler, or SIG_ERR if an error occurs. Initially + * unhandled signals defined above will return SIG_DFL. + */ +_p_sig_fn_t signal(int sig, _p_sig_fn_t func); + +/* + * Raise the signal indicated by sig. Returns non-zero on success. + */ +int raise (int sig); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/reactos/include/msvcrt/stdarg.h b/reactos/include/msvcrt/stdarg.h new file mode 100644 index 00000000000..b02299807e2 --- /dev/null +++ b/reactos/include/msvcrt/stdarg.h @@ -0,0 +1,107 @@ +/* + * stdarg.h + * + * Provides facilities for stepping through a list of function arguments of + * an unknown number and type. + * + * NOTE: Gcc should provide stdarg.h, and I believe their version will work + * with crtdll. If necessary I think you can replace this with the GCC + * stdarg.h (or is it vararg.h). + * + * Note that the type used in va_arg is supposed to match the actual type + * *after default promotions*. Thus, va_arg (..., short) is not valid. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ + +#ifndef _STDARG_H_ +#define _STDARG_H_ + +/* + * Don't do any of this stuff for the resource compiler. + */ +#ifndef RC_INVOKED + +/* + * I was told that Win NT likes this. + */ +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif + +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + + +/* + * Amount of space required in an argument list (ie. the stack) for an + * argument of type t. + */ +#define __va_argsiz(t) \ + (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + + +/* + * Start variable argument list processing by setting AP to point to the + * argument after pN. + */ +#ifdef __GNUC__ +/* + * In GNU the stack is not necessarily arranged very neatly in order to + * pack shorts and such into a smaller argument list. Fortunately a + * neatly arranged version is available through the use of __builtin_next_arg. + */ +#define va_start(ap, pN) \ + ((ap) = ((va_list) __builtin_next_arg(pN))) +#else +/* + * For a simple minded compiler this should work (it works in GNU too for + * vararg lists that don't follow shorts and such). + */ +#define va_start(ap, pN) \ + ((ap) = ((va_list) (&pN) + __va_argsiz(pN))) +#endif + + +/* + * End processing of variable argument list. In this case we do nothing. + */ +#define va_end(ap) ((void)0) + + +/* + * Increment ap to the next argument in the list while returing a + * pointer to what ap pointed to first, which is of type t. + * + * We cast to void* and then to t* because this avoids a warning about + * increasing the alignment requirement. + */ + +#define va_arg(ap, t) \ + (((ap) = (ap) + __va_argsiz(t)), \ + *((t*) (void*) ((ap) - __va_argsiz(t)))) + +#endif /* Not RC_INVOKED */ + +#endif /* not _STDARG_H_ */ diff --git a/reactos/include/msvcrt/stddef.h b/reactos/include/msvcrt/stddef.h index b22918aedc7..23a8a2ac02f 100644 --- a/reactos/include/msvcrt/stddef.h +++ b/reactos/include/msvcrt/stddef.h @@ -28,9 +28,9 @@ * DISCLAMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.2 $ - * $Author: dwelch $ - * $Date: 2001/02/19 15:04:50 $ + * $Revision: 1.3 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:56:48 $ * */ @@ -55,7 +55,7 @@ * size_t is typedef'ed differently from what GCC expects it will give you * warnings when you prototype functions like memcmp and memcpy. The values * for __xxx_TYPE__ in this header file are the same as those given by GCC. - * Those values appear to work with the CRTDLL functions. + * Those values appear to work with the MSVCRT functions. */ /* diff --git a/reactos/include/msvcrt/stdio.h b/reactos/include/msvcrt/stdio.h new file mode 100644 index 00000000000..39afad52030 --- /dev/null +++ b/reactos/include/msvcrt/stdio.h @@ -0,0 +1,359 @@ +/* + * stdio.h + * + * Definitions of types and prototypes of functions for standard input and + * output. + * + * NOTE: The file manipulation functions provided by Microsoft seem to + * work with either slash (/) or backslash (\) as the path separator. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ +/* implemented clearerr feof ferror perror as macros */ +/* added _IOCOMMIT */ +/* added filbuf and flsbuf and fwalk */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define __need_size_t +#define __need_NULL +#define __need_wchar_t +#define __need_wint_t +#include + + +/* Some flags for the iobuf structure provided by djgpp stdio.h */ +#define _IOREAD 0x000010 +#define _IOWRT 0x000020 +#define _IOMYBUF 0x000040 +#define _IOEOF 0x000100 +#define _IOERR 0x000200 +#define _IOSTRG 0x000400 + +#define _IOAPPEND 0x002000 +#define _IORMONCL 0x004000 /* remove on close, for temp files */ +/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ +#define _IOUNGETC 0x010000 /* there is an ungetc'ed character in the buffer */ +#define _IOCOMMIT 0x008000 + +#define _IODIRTY 0x000080 +#define _IOAHEAD 0x000008 +#define _IORW (_IOREAD | _IOWRITE ) + + +/* + * I used to include stdarg.h at this point, in order to allow for the + * functions later on in the file which use va_list. That conflicts with + * using stdio.h and varargs.h in the same file, so I do the typedef myself. + */ +//#ifndef _VA_LIST +//#define _VA_LIST +//typedef char* va_list; +//#endif +#include + +/* + * FILE should be used as a pointer to an opaque data type. Do not rely on + * anything else, especially the size or contents of this structure! + */ +#ifndef _FILE_DEFINED +typedef struct { + char *_ptr; + int _cnt; + char *_base; + int _flag; + int _file; + int _ungotchar; + int _bufsiz; + char *_name_to_remove; +} FILE; +#define _FILE_DEFINED +#endif + +//#define _fillsize _bufsiz + +/* + * The three standard file pointers provided by the run time library. + * NOTE: These will go to the bit-bucket silently in GUI applications! + */ +extern FILE _iob[]; /* an array of FILE */ +#define stdin (&_iob[0]) +#define stdout (&_iob[1]) +#define stderr (&_iob[2]) +#define stdaux (&_iob[3]) +#define stdprn (&_iob[4]) + +/* Returned by various functions on end of file condition or error. */ +#define EOF (-1) + + +/* + * The maximum length of a file name. You should use GetVolumeInformation + * instead of this constant. But hey, this works. + * + * NOTE: This is used in the structure _finddata_t (see dir.h) so changing it + * is probably not a good idea. + */ +#define FILENAME_MAX (260) + +/* + * The maximum number of files that may be open at once. I have set this to + * a conservative number. The actual value may be higher. + */ +#define FOPEN_MAX (20) + + +/* + * File Operations + */ + +FILE* fopen (const char* szFileName, const char* szMode); +FILE* freopen (const char* szNewFileName, const char* szNewMode, + FILE* fileChangeAssociation); +int fflush (FILE* fileFlush); +int fclose (FILE* fileClose); +#define fcloseall _fcloseall +int remove (const char* szFileName); +int _wremove (const wchar_t* szFileName); +int rename (const char* szOldFileName, const char* szNewFileName); +FILE* tmpfile (void); + +int _filbuf(FILE *f); +int _flsbuf(int c, FILE *f); +void _fwalk(void (*func)(FILE *)); // not exported +int _fcloseall( void ); + + +/* + * The maximum size of name (including NUL) that will be put in the user + * supplied buffer caName. + * NOTE: This has not been determined by experiment, but based on the + * maximum file name length above it is probably reasonable. I could be + * wrong... + */ +#define L_tmpnam (260) + +char* tmpnam (char caName[]); +char* _tempnam (const char *szDir, const char *szPfx); + +#ifndef _NO_OLDNAMES +#define tempnam _tempnam +#endif /* Not _NO_OLDNAMES */ + +/* + * The three possible buffering mode (nMode) values for setvbuf. + * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered... + * maybe I'm testing it wrong? + */ +#define _IOFBF 0 /* fully buffered */ +#define _IOLBF 1 /* line buffered */ +#define _IONBF 2 /* unbuffered */ + +int setvbuf (FILE* fileSetBuffer, char* caBuffer, int nMode, + size_t sizeBuffer); + + +/* + * The buffer size as used by setbuf such that it is equivalent to + * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ). + */ +#define BUFSIZ 512 + +void setbuf (FILE* fileSetBuffer, char* caBuffer); + +/* + * Pipe Operations + */ + +int _pclose (FILE* pipeClose); +FILE* _popen (const char* szPipeName, const char* szMode); + +#define popen _popen +#define pclose _pclose + +/* Wide character version */ +FILE* _wpopen (const wchar_t* szPipeName, const wchar_t* szMode); + +/* + * Formatted Output + */ + +int fprintf (FILE* filePrintTo, const char* szFormat, ...); +int printf (const char* szFormat, ...); +int sprintf (char* caBuffer, const char* szFormat, ...); +int vfprintf (FILE* filePrintTo, const char* szFormat, va_list varg); +int vprintf (const char* szFormat, va_list varg); +int vsprintf (char* caBuffer, const char* szFormat, va_list varg); + +/* Wide character versions */ +int fwprintf (FILE* filePrintTo, const wchar_t* wsFormat, ...); +int wprintf (const wchar_t* wsFormat, ...); +int swprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, ...); +int vfwprintf (FILE* filePrintTo, const wchar_t* wsFormat, va_list varg); +int vwprintf (const wchar_t* wsFormat, va_list varg); +int vswprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, va_list varg); + +/* + * Formatted Input + */ + +int fscanf (FILE* fileReadFrom, const char* szFormat, ...); +int scanf (const char* szFormat, ...); +int sscanf (const char* szReadFrom, const char* szFormat, ...); + +/* Wide character versions */ +int fwscanf (FILE* fileReadFrom, const wchar_t* wsFormat, ...); +int wscanf (const wchar_t* wsFormat, ...); +int swscanf (const wchar_t* wsReadFrom, const wchar_t* wsFormat, ...); + +/* + * Character Input and Output Functions + */ + +int fgetc (FILE* fileRead); +char* fgets (char* caBuffer, int nBufferSize, FILE* fileRead); +int fputc (int c, FILE* fileWrite); +int fputs (const char* szOutput, FILE* fileWrite); +int getc (FILE* fileRead); +int getchar (void); +char* gets (char* caBuffer); /* Unsafe: how does gets know how long the + * buffer is? */ +int putc (int c, FILE* fileWrite); +int putchar (int c); +int puts (const char* szOutput); +int ungetc (int c, FILE* fileWasRead); + +/* Wide character versions */ +wint_t fgetwc (FILE* fileRead); +wint_t fputwc (wchar_t wc, FILE* fileWrite); +wint_t getwc (FILE *fileRead); +wint_t putwc (wint_t wc, FILE* fileWrite); +wint_t putwchar (wint_t c); +int _putws (const wchar_t* ws); +wint_t ungetwc (wchar_t wc, FILE* fileWasRead); + +wint_t _filwbuf(FILE *f); +wint_t _flswbuf(wchar_t c, FILE *f); + +/* + * Not exported by CRTDLL.DLL included for reference purposes. + */ +#if 0 +wchar_t* fgetws (wchar_t* wcaBuffer, int nBufferSize, FILE* fileRead); +int fputws (const wchar_t* wsOutput, FILE* fileWrite); +int getwc (FILE* fileRead); +int getwchar (); +wchar_t* getws (wchar_t* wcaBuffer); +#endif /* 0 */ + +/* NOTE: putchar has no wide char equivalent even in tchar.h */ + + +/* + * Direct Input and Output Functions + */ + +size_t fread (void* pBuffer, size_t sizeObject, size_t sizeObjCount, + FILE* fileRead); +size_t fwrite (const void* pObjArray, size_t sizeObject, size_t sizeObjCount, + FILE* fileWrite); + + +/* + * File Positioning Functions + */ + +/* Constants for nOrigin indicating the position relative to which fseek + * sets the file position. Enclosed in ifdefs because io.h could also + * define them. (Though not anymore since io.h includes this file now.) */ +#ifndef SEEK_SET +#define SEEK_SET (0) +#endif + +#ifndef SEEK_CUR +#define SEEK_CUR (1) +#endif + +#ifndef SEEK_END +#define SEEK_END (2) +#endif + +int fseek (FILE* fileSetPosition, long lnOffset, int nOrigin); +long ftell (FILE* fileGetPosition); +void rewind (FILE* fileRewind); + +/* + * An opaque data type used for storing file positions... The contents of + * this type are unknown, but we (the compiler) need to know the size + * because the programmer using fgetpos and fsetpos will be setting aside + * storage for fpos_t structres. Actually I tested using a byte array and + * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL). + * Perhaps an unsigned long? TODO? + */ +typedef long fpos_t; + +int fgetpos (FILE* fileGetPosition, fpos_t* pfpos); +int fsetpos (FILE* fileSetPosition, const fpos_t* pfpos); + + +/* + * Error Functions + */ +#if 0 +void clearerr (FILE* fileClearErrors); +int feof (FILE* fileIsAtEnd); +int ferror (FILE* fileIsError); +void perror (const char* szErrorMessage); + +#endif + +#define clearerr(f) (((f)->_flag) &= ~(_IOERR|_IOEOF)) +#define feof(f) (((f)->_flag&_IOEOF)!=0) +#define ferror(f) (((f)->_flag&_IOERR)!=0) +#define perror(s) (fprintf(stderr, "%s: %s\n", (s), _strerror(NULL))) +/* + * Non ANSI functions + */ + +#ifndef __STRICT_ANSI__ +int _fgetchar (void); +int _fputchar (int c); +FILE* _fdopen (int nHandle, char* szMode); + +#ifndef _NO_OLDNAMES +#define fgetchar _fgetchar +#define fputchar _fputchar +#define fdopen _fdopen +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _STDIO_H_ */ diff --git a/reactos/include/msvcrt/time.h b/reactos/include/msvcrt/time.h new file mode 100644 index 00000000000..5bdfd9be61c --- /dev/null +++ b/reactos/include/msvcrt/time.h @@ -0,0 +1,119 @@ +/* + * time.h + * + * Date and time functions and types. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ +#ifndef _TIME_H_ +#define _TIME_H_ + +#define __need_wchar_t +#define __need_size_t +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Number of clock ticks per second. A clock tick is the unit by which + * processor time is measured and is returned by 'clock'. + */ +#define CLOCKS_PER_SEC 1000.0 +#define CLK_TICK CLOCKS_PER_SEC + +/* + * A type for measuring processor time (in clock ticks). + */ +#ifndef _CLOCK_T_ +#define _CLOCK_T_ +typedef long clock_t; +#endif + +/* + * Need a definition of time_t. + */ +#include + +/* + * A type for storing the current time and date. This is the number of + * seconds since midnight Jan 1, 1970. + * NOTE: Normally this is defined by the above include of sys/types.h + */ +#ifndef _TIME_T_ +#define _TIME_T_ +typedef long time_t; +#endif + +/* + * A structure for storing all kinds of useful information about the + * current (or another) time. + */ +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + char *tm_zone; + int tm_gmtoff; +}; + + + +clock_t clock (void); +time_t time (time_t* tp); +double difftime (time_t t2, time_t t1); +time_t mktime (struct tm* tmsp); + +/* + * These functions write to and return pointers to static buffers that may + * be overwritten by other function calls. Yikes! + * + * NOTE: localtime, and perhaps the others of the four functions grouped + * below may return NULL if their argument is not 'acceptable'. Also note + * that calling asctime with a NULL pointer will produce an Invalid Page + * Fault and crap out your program. Guess how I know. Hint: stat called on + * a directory gives 'invalid' times in st_atime etc... + */ +char* asctime (const struct tm* tmsp); +char* ctime (const time_t* tp); +struct tm* gmtime (const time_t* tm); +struct tm* localtime (const time_t* tm); + + +size_t strftime (char* caBuffer, size_t sizeMax, const char* szFormat, + const struct tm* tpPrint); + +size_t wcsftime (wchar_t* wcaBuffer, size_t sizeMax, + const wchar_t* wsFormat, const struct tm* tpPrint); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/reactos/include/msvcrt/wchar.h b/reactos/include/msvcrt/wchar.h new file mode 100644 index 00000000000..ef1737f18d7 --- /dev/null +++ b/reactos/include/msvcrt/wchar.h @@ -0,0 +1,32 @@ +/* + * wchar.h + * + * Defines of all functions for supporting wide characters. Actually it + * just includes all those headers, which is not a good thing to do from a + * processing time point of view, but it does mean that everything will be + * in sync. + * + * This file is part of the Mingw32 package. + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision: 1.1 $ + * $Author: ekohl $ + * $Date: 2001/07/03 12:55:00 $ + * + */ + +#include +#include +#include +#include +#include +