ntdll: -critical.c: catch (more) invalid use -impl. sscanf (stolen from wine) crt: -use native mingw headers and not private copies of them -converted some routines to using tchar == impl. many missing unicode routines -impl. sscanf and friends correctly (stolen from wine) tchar.h: -added lotsa missin stuff Added: trunk/reactos/lib/crt/include/ Added: trunk/reactos/lib/crt/include/internal/ Added: trunk/reactos/lib/crt/include/internal/atexit.h Added: trunk/reactos/lib/crt/include/internal/console.h Added: trunk/reactos/lib/crt/include/internal/file.h Added: trunk/reactos/lib/crt/include/internal/ieee.h Added: trunk/reactos/lib/crt/include/internal/math.h Added: trunk/reactos/lib/crt/include/internal/mbstring.h Added: trunk/reactos/lib/crt/include/internal/msvcrtdbg.h Added: trunk/reactos/lib/crt/include/internal/mtdll.h Added: trunk/reactos/lib/crt/include/internal/rterror.h Added: trunk/reactos/lib/crt/include/internal/tls.h Added: trunk/reactos/lib/crt/include/internal/wine/ Modified: trunk/reactos/lib/crt/include/internal/wine/msvcrt.h _____
Copied: trunk/reactos/lib/crt/include/internal/atexit.h (from rev 13517, trunk/reactos/include/msvcrt/internal/atexit.h) --- trunk/reactos/include/msvcrt/internal/atexit.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/atexit.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,14 @@
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __CRT_INTERNAL_ATEXIT_H +#define __CRT_INTERNAL_ATEXIT_H + + +struct __atexit { + struct __atexit* __next; + void (*__function)(void); +}; + +extern struct __atexit* __atexit_ptr; + + +#endif _____
Copied: trunk/reactos/lib/crt/include/internal/console.h (from rev 13517, trunk/reactos/include/msvcrt/internal/console.h) --- trunk/reactos/include/msvcrt/internal/console.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/console.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,12 @@
+/* console.h */ + +#ifndef __CRT_INTERNAL_CONSOLE_H +#define __CRT_INTERNAL_CONSOLE_H + +extern int char_avail; +extern int ungot_char; + +#endif + +/* EOF */ + _____
Copied: trunk/reactos/lib/crt/include/internal/file.h (from rev 13517, trunk/reactos/include/msvcrt/internal/file.h) --- trunk/reactos/include/msvcrt/internal/file.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/file.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,190 @@
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * Some stuff taken from active perl: perl\win32.c (ioinfo stuff) + * + * (c) 1995 Microsoft Corporation. All rights reserved. + * Developed by hip communications inc., http://info.hip.com/info/ + * Portions (c) 1993 Intergraph Corporation. All rights reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + */ + +#ifndef __CRT_INTERNAL_FILE_H +#define __CRT_INTERNAL_FILE_H + +#include <stdio.h> +#include <fcntl.h> +#include <stdarg.h> + + +#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*); +int __set_errno(int err); +int __set_doserrno(int error); +void* filehnd(int fn); +char __is_text_file(FILE*); +int alloc_fd(void* hFile, char mode); +int _doprnt(const char* fmt, va_list args, FILE *); +int _doscan(FILE* iop, const char* fmt, va_list argp); +int __fileno_dup2(int handle1, int handle2); +char __fileno_getmode(int _fd); +int __fileno_setmode(int _fd, int _newmode); +void free_fd(int _fd); +void sigabort_handler(int sig); +char split_oflags(int oflags); + + +#include <windows.h> + +unsigned create_io_inherit_block(STARTUPINFOA* si); +void UnixTimeToFileTime(time_t unix_time, FILETIME* filetime, DWORD remainder); +time_t FileTimeToUnixTime(const FILETIME* filetime, DWORD *remainder); + + +#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; + + +typedef struct _FDINFO +{ + HANDLE hFile; + char fdflags; + char pipechar; /* one char buffer for handles opened on pipes */ + int lockinitflag; + CRITICAL_SECTION lock; +} FDINFO; + +#define FDINFO_ENTRIES_PER_BUCKET_SHIFT 5 /* log2(32) = 5 */ +#define FDINFO_BUCKETS 64 +#define FDINFO_ENTRIES_PER_BUCKET 32 +#define FDINFO_ENTRIES (FDINFO_BUCKETS * FDINFO_ENTRIES_PER_BUCKET) + +/* pipech */ +#define LF 10 /* line feed */ +#define CR 13 /* carriage return */ +#define CTRLZ 26 /* ctrl-z means eof for text */ + +/* mode */ +#define FOPEN 0x01 /* file handle open */ +#define FEOFLAG 0x02 /* end of file has been encountered */ +#define FCRLF 0x04 /* CR-LF across read buffer (in text mode) */ +#define FPIPE 0x08 /* file refers to a pipe */ +#define FNOINHERIT 0x10 /* file handle opened _O_NOINHERIT */ +#define FAPPEND 0x20 /* file opened O_APPEND */ +#define FDEV 0x40 /* file refers to device */ +#define FTEXT 0x80 /* file is in text mode (absence = binary) */ + +/* get bucket index (0-63) from an fd */ +#define fdinfo_bucket_idx(i) ((i) >> FDINFO_ENTRIES_PER_BUCKET_SHIFT) +/* get position inside a bucket (0-31) from an fd */ +#define fdinfo_bucket_entry_idx(i) ((i) & (FDINFO_ENTRIES_PER_BUCKET - 1)) +/* get bucket ptr. (ptr. to fist fdinfo inside a bucket) from an fd */ +#define fdinfo_bucket(i) ( __pioinfo[fdinfo_bucket_idx(i)]) +/* get fdinfo ptr. from an fd */ +#define fdinfo(i) (fdinfo_bucket(i) + fdinfo_bucket_entry_idx(i)) + +extern FDINFO* __pioinfo[]; + + +void _dosmaperr(unsigned long oserrcode); + + + +FILE* __alloc_file(void); + + + +int access_dirA(const char *_path); +int access_dirW(const wchar_t *_path); + +#ifdef _UNICODE + #define access_dirT access_dirW +#else + #define access_dirT access_dirA +#endif + + + +void _fwalk(void (*func)(FILE*)); // not exported + + + +#undef MB_CUR_MAX +#define MB_CUR_MAX __mb_cur_max + + +int _isnanl(double x); +int _isinfl(double x); +int _isnan(double x); +int _isinf(double x); + + + +/* Flags for the iobuf structure (for reference) */ +#if 0 +#define _IOREAD 1 /* currently reading */ +#define _IOWRT 2 /* currently writing */ +#define _IORW 0x0080 /* opened as "r+w" */ +#endif + +/* internal FILE->_flag flags */ + +#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */ +#define _IOEOF 0x0010 /* EOF reached on read */ +#define _IOERR 0x0020 /* I/O error from system */ +#define _IOSTRG 0x0040 /* Strange or no file descriptor */ + +#define _IOBINARY 0x040000 +#define _IOTEXT 0x000000 + +#define _IOCOMMIT 0x100000 + +#define _IODIRTY 0x010000 +#define _IOAHEAD 0x020000 + + + + +/* + * 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 0x0000 /* full buffered */ +#define _IOLBF 0x0040 /* line buffered */ +#define _IONBF 0x0004 /* not buffered */ + +#define _IO_LBF 0x80000 /* this value is used insteat of _IOLBF within the + structure FILE as value for _flags, + because _IOLBF has the same value as _IOSTRG */ + + +wint_t _filwbuf(FILE *f); + + + +#endif /* __dj_include_libc_file_h__ */ _____
Copied: trunk/reactos/lib/crt/include/internal/ieee.h (from rev 13517, trunk/reactos/include/msvcrt/internal/ieee.h) --- trunk/reactos/include/msvcrt/internal/ieee.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/ieee.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,25 @@
+#ifndef __CRT_INTERNAL_IEEE_H +#define __CRT_INTERNAL_IEEE_H + +typedef struct { + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int sign:1; +} float_t; + +typedef struct { + unsigned int mantissal:32; + unsigned int mantissah:20; + unsigned int exponent:11; + unsigned int sign:1; +} double_t; + +typedef struct { + unsigned int mantissal:32; + unsigned int mantissah:32; + unsigned int exponent:15; + unsigned int sign:1; + unsigned int empty:16; +} long_double_t; + +#endif _____
Added: trunk/reactos/lib/crt/include/internal/math.h --- trunk/reactos/lib/crt/include/internal/math.h 2005-02-16 22:22:42 UTC (rev 13606) +++ trunk/reactos/lib/crt/include/internal/math.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,10 @@
+ +#ifndef __CRT_INTERNAL_MATH_H +#define __CRT_INTERNAL_MATH_H + + +int _isinf (double); /* not exported */ +int _isnanl (long double); /* not exported */ +int _isinfl (long double); /* not exported */ + +#endif _____
Added: trunk/reactos/lib/crt/include/internal/mbstring.h --- trunk/reactos/lib/crt/include/internal/mbstring.h 2005-02-16 22:22:42 UTC (rev 13606) +++ trunk/reactos/lib/crt/include/internal/mbstring.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,20 @@
+#ifndef __CRT_INTERNAL_MBSTRING_H +#define __CRT_INTERNAL_MBSTRING_H + +#define _KNJ_M ((char)0x01) /* Non-punctuation of Kana-set */ +#define _KNJ_P ((char)0x02) /* Punctuation of Kana-set */ +#define _KNJ_1 ((char)0x04) /* Legal 1st byte of double byte stream */ +#define _KNJ_2 ((char)0x08) /* Legal 2nd btye of double byte stream */ + + +#define ___ 0 +#define _1_ _KNJ_1 /* Legal 1st byte of double byte code */ +#define __2 _KNJ_2 /* Legal 2nd byte of double byte code */ +#define _M_ _KNJ_M /* Non-puntuation in Kana-set */ +#define _P_ _KNJ_P /* Punctuation of Kana-set */ +#define _12 (_1_|__2) +#define _M2 (_M_|__2) +#define _P2 (_P_|__2) + + +#endif _____
Copied: trunk/reactos/lib/crt/include/internal/msvcrtdbg.h (from rev 13517, trunk/reactos/include/msvcrt/msvcrtdbg.h) --- trunk/reactos/include/msvcrt/msvcrtdbg.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/msvcrtdbg.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,90 @@
+/* + * 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> +#include <windows.h> + + +#define MK_STR(s) #s + +#ifdef _UNICODE + #define sT "S" +#else + #define sT "s" +#endif + + + +#define TRACE(...) + + +#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 + #ifdef __GNUC__ + #define DPRINT1(args...) + #else + #define DPRINT DbgPrint + #endif + #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 + #ifdef __GNUC__ + #define DPRINT(args...) + #else + #define DPRINT DbgPrint + #endif + #define CHECKPOINT +#endif /* NDEBUG */ + + +#if 0 + + #define TRACE_RETURN(format_str, ret_type) \ + ret_type __return_value__; \ + static char* __return_format_str__ = "%s ret: "format_str"\n" + + #define FUNCTION(func) \ + static char* __func_name__ = #func + + #define TRACE(a,b...) DPRINT1(a"\n", b) + + #define RETURN(a) \ + do{ __return_value__ = (a); DPRINT1(__return_format_str__ ,__func_name__,__return_value__); return __return_value__ ; }while(0) + +#endif + + +/* ULONG CDECL DbgPrint(PCH Format, ...); */ +ULONG DbgPrint(PCH Format,...); +/* unsigned long DbgPrint(const char* Format, ...); */ + + + +/* #define TRACE 0 ? (void)0 : Trace */ + +/* void Trace(TCHAR* lpszFormat, ...); */ + + + +#endif /* __MSVCRT_DEBUG */ _____
Copied: trunk/reactos/lib/crt/include/internal/mtdll.h (from rev 13517, trunk/reactos/include/msvcrt/internal/mtdll.h) --- trunk/reactos/include/msvcrt/internal/mtdll.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/mtdll.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,72 @@
+/* + * Copyright (c) 2002, TransGaming Technologies Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __CRT_INTERNAL_WINE_MTDLL_H +#define __CRT_INTERNAL_WINE_MTDLL_H + +#if defined(_MT) + +#define _mlock(locknum) _lock(locknum) +#define _munlock(locknum) _unlock(locknum) + +void _unlock( int locknum ); +void _lock( int locknum ); + +#else + +#define _mlock(locknum) do {} while(0) +#define _munlock(locknum) do {} while(0) + +#endif + + +#define _SIGNAL_LOCK 1 +#define _IOB_SCAN_LOCK 2 +#define _TMPNAM_LOCK 3 +#define _INPUT_LOCK 4 +#define _OUTPUT_LOCK 5 +#define _CSCANF_LOCK 6 +#define _CPRINTF_LOCK 7 +#define _CONIO_LOCK 8 +#define _HEAP_LOCK 9 +#define _BHEAP_LOCK 10 /* No longer used? */ +#define _TIME_LOCK 11 +#define _ENV_LOCK 12 +#define _EXIT_LOCK1 13 +#define _EXIT_LOCK2 14 +#define _THREADDATA_LOCK 15 /* No longer used? */ +#define _POPEN_LOCK 16 +#define _LOCKTAB_LOCK 17 +#define _OSFHND_LOCK 18 +#define _SETLOCALE_LOCK 19 +#define _LC_COLLATE_LOCK 20 /* No longer used? */ +#define _LC_CTYPE_LOCK 21 /* No longer used? */ +#define _LC_MONETARY_LOCK 22 /* No longer used? */ +#define _LC_NUMERIC_LOCK 23 /* No longer used? */ +#define _LC_TIME_LOCK 24 /* No longer used? */ +#define _MB_CP_LOCK 25 +#define _NLG_LOCK 26 +#define _TYPEINFO_LOCK 27 +#define _STREAM_LOCKS 28 + +/* Must match definition in msvcrt/stdio.h */ +#define _IOB_ENTRIES 20 +#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_IOB_ENTRIES-1) +#define _TOTAL_LOCKS (_LAST_STREAM_LOCK+1) + +#endif /* WINE_MTDLL_H */ _____
Copied: trunk/reactos/lib/crt/include/internal/rterror.h (from rev 13517, trunk/reactos/include/msvcrt/internal/rterror.h) --- trunk/reactos/include/msvcrt/internal/rterror.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/rterror.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,31 @@
+/* rterror.h */ + +#ifndef __CRT_INTERNAL_RTERROR_H +#define __CRT_INTERNAL_RTERROR_H + + +#define _RT_STACK 0 /* stack overflow */ +#define _RT_NULLPTR 1 /* null pointer assignment */ +#define _RT_FLOAT 2 /* floating point not loaded */ +#define _RT_INTDIV 3 /* integer divide by 0 */ +#define _RT_SPACEARG 4 /* not enough space for arguments */ +#define _RT_SPACEENV 5 /* not enough space for environment */ +#define _RT_ABORT 6 /* abnormal program termination */ +#define _RT_THREAD 7 /* not enough space for thread data */ +#define _RT_LOCK 8 /* unexpected multi-thread lock error */ +#define _RT_HEAP 9 /* unexpected heap error */ +#define _RT_OPENCON 10 /* unable to open console device */ +#define _RT_NONCONT 11 /* non-continuable exception */ +#define _RT_INVALDISP 12 /* invalid disposition of exception */ +#define _RT_ONEXIT 13 /* insufficient heap to allocate + * initial table of function pointers + * used by _onexit()/atexit(). */ +#define _RT_PUREVIRT 14 /* pure virtual function call attempted + * (C++ error) */ +#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */ +#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */ + +void _amsg_exit (int errnum); + + +#endif /* __MSVCRT_INTERNAL_RTERROR_H */ _____
Copied: trunk/reactos/lib/crt/include/internal/tls.h (from rev 13517, trunk/reactos/include/msvcrt/internal/tls.h) --- trunk/reactos/include/msvcrt/internal/tls.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/tls.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -0,0 +1,42 @@
+/* tls.h */ + +#ifndef __CRT_INTERNAL_TLS_H +#define __CRT_INTERNAL_TLS_H + +#include <windows.h> +#include <msvcrt/crttypes.h> +#include <stddef.h> + +typedef struct _ThreadData +{ + int terrno; /* *nix error code */ + unsigned long tdoserrno; /* Win32 error code (for I/O only) */ + unsigned LONGLONG tnext; /* used by rand/srand */ + + char *lasttoken; /* used by strtok */ + wchar_t *wlasttoken; /* used by wcstok */ + + + int fpecode; /* fp exception code */ + + /* qsort variables */ + int (*qcmp)(const void *, const void *); /* the comparison routine */ + int qsz; /* size of each record */ + int thresh; /* THRESHold in chars */ + int mthresh; /* MTHRESHold in chars */ + + EXCEPTION_RECORD *exc_record; /* Head of exception record list */ + +} THREADDATA, *PTHREADDATA; + + +int CreateThreadData(void); +void DestroyThreadData(void); + +void FreeThreadData(PTHREADDATA ptd); +PTHREADDATA GetThreadData(void); + +#endif /* __MSVCRT_INTERNAL_TLS_H */ + +/* EOF */ + _____
Copied: trunk/reactos/lib/crt/include/internal/wine (from rev 13517, trunk/reactos/include/msvcrt/wine) _____
Modified: trunk/reactos/lib/crt/include/internal/wine/msvcrt.h --- trunk/reactos/include/msvcrt/wine/msvcrt.h 2005-02-12 21:46:45 UTC (rev 13517) +++ trunk/reactos/lib/crt/include/internal/wine/msvcrt.h 2005-02-16 22:29:16 UTC (rev 13607) @@ -28,7 +28,7 @@
#include "winerror.h" #include "winnls.h"
-#include "msvcrt/string.h" +//#include "msvcrt/string.h" #include "eh.h"
/* TLS data */