Added some functions to msvcrt
authorEric Kohl <eric.kohl@reactos.org>
Sun, 3 Dec 2000 17:49:41 +0000 (17:49 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 3 Dec 2000 17:49:41 +0000 (17:49 +0000)
svn path=/trunk/; revision=1444

reactos/include/msvcrt/ctype.h [new file with mode: 0644]
reactos/include/msvcrt/direct.h [new file with mode: 0644]
reactos/include/msvcrt/errno.h [new file with mode: 0644]
reactos/include/msvcrt/internal/tls.h [new file with mode: 0644]
reactos/include/msvcrt/mbstring.h [new file with mode: 0644]
reactos/include/msvcrt/stddef.h [new file with mode: 0644]
reactos/include/msvcrt/stdlib.h [new file with mode: 0644]
reactos/include/msvcrt/string.h [new file with mode: 0644]

diff --git a/reactos/include/msvcrt/ctype.h b/reactos/include/msvcrt/ctype.h
new file mode 100644 (file)
index 0000000..0ea129b
--- /dev/null
@@ -0,0 +1,139 @@
+/* 
+ * ctype.h
+ *
+ * Functions for testing character types and converting characters.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  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: 2000/12/03 17:49:21 $
+ *
+ */
+
+#ifndef _CTYPE_H_
+#define _CTYPE_H_
+
+#define        __need_wchar_t
+#define        __need_wint_t
+#include <msvcrt/stddef.h>
+
+
+/*
+ * The following flags are used to tell iswctype and _isctype what character
+ * types you are looking for.
+ */
+#define        _UPPER          0x0001
+#define        _LOWER          0x0002
+#define        _DIGIT          0x0004
+#define        _SPACE          0x0008
+#define        _PUNCT          0x0010
+#define        _CONTROL        0x0020
+#define        _BLANK          0x0040
+#define        _HEX            0x0080
+
+#define        _ALPHA          0x0103
+#define        _LEADBYTE       0x8000
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int    isalnum(int c);
+int    isalpha(int c);
+int    iscntrl(int c);
+int    isdigit(int c);
+int    isgraph(int c);
+int    islower(int c);
+int    isprint(int c);
+int    ispunct(int c);
+int    isspace(int c);
+int    isupper(int c);
+int    isxdigit(int c);
+
+#ifndef        __STRICT_ANSI__
+int    _isctype (unsigned int c, int ctypeFlags);
+#endif
+
+int    tolower(int c);
+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.
+ */
+#ifndef        __STRICT_ANSI__
+int    _tolower(int c);
+int    _toupper(int c);
+#endif
+
+#ifndef WEOF
+#define        WEOF    (wchar_t)(0xFFFF)
+#endif
+
+/*
+ * TODO: MB_CUR_MAX should be defined here (if not already defined, since
+ *       it should also be defined in stdlib.h). It is supposed to be the
+ *       maximum number of bytes in a multi-byte character in the current
+ *       locale. Perhaps accessible through the __mb_curr_max_dll entry point,
+ *       but I think (again) that that is a variable pointer, which leads to
+ *       problems under the current Cygwin compiler distribution.
+ */
+
+typedef int    wctype_t;
+
+/* Wide character equivalents */
+int    iswalnum(wint_t wc);
+int    iswalpha(wint_t wc);
+int    iswascii(wint_t wc);
+int    iswcntrl(wint_t wc);
+int    iswctype(wint_t wc, wctype_t wctypeFlags);
+int    is_wctype(wint_t wc, wctype_t wctypeFlags);     /* Obsolete! */
+int    iswdigit(wint_t wc);
+int    iswgraph(wint_t wc);
+int    iswlower(wint_t wc);
+int    iswprint(wint_t wc);
+int    iswpunct(wint_t wc);
+int    iswspace(wint_t wc);
+int    iswupper(wint_t wc);
+int    iswxdigit(wint_t wc);
+
+wchar_t        towlower(wchar_t c);
+wchar_t        towupper(wchar_t c);
+
+int    isleadbyte (int c);
+
+#ifndef        __STRICT_ANSI__
+int    __isascii (int c);
+int    __toascii (int c);
+int    __iscsymf (int c);      /* Valid first character in C symbol */
+int    __iscsym (int c);       /* Valid character in C symbol (after first) */
+
+#ifndef        _NO_OLDNAMES
+#define        isascii(c)      __isascii(c)
+#define        toascii(c)      _toascii(c)
+#define        iscsymf(c)      __iscsymf(c)
+#define        iscsym(c)       __iscsym(c)
+#endif /* Not _NO_OLDNAMES */
+
+#endif /* Not __STRICT_ANSI__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* Not _CTYPE_H_ */
diff --git a/reactos/include/msvcrt/direct.h b/reactos/include/msvcrt/direct.h
new file mode 100644 (file)
index 0000000..e1849ec
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef _DIRECT_H_
+#define _DIRECT_H_
+
+#ifndef _WCHAR_T_
+typedef unsigned short wchar_t;
+#define _WCHAR_T_
+#endif
+
+#ifndef _SIZE_T_
+typedef unsigned int size_t;
+#define _SIZE_T_
+#endif
+
+struct _diskfree_t {
+  unsigned short total_clusters;
+  unsigned short avail_clusters;
+  unsigned short sectors_per_cluster;
+  unsigned short bytes_per_sector;
+};
+
+unsigned int _getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace);
+
+int _chdrive( int drive );
+int _getdrive( void );
+
+char *_getcwd( char *buffer, int maxlen );
+char *_getdcwd (int nDrive, char* caBuffer, int nBufLen);
+
+int _chdir(const char *_path);
+int  _mkdir(const char *_path);
+int  _rmdir(const char *_path);
+
+#define chdir _chdir
+#define getcwd _getcwd
+#define mkdir _mkdir
+#define rmdir _rmdir
+
+
+wchar_t *_wgetcwd( wchar_t *buffer, int maxlen );
+wchar_t *_wgetdcwd (int nDrive, wchar_t* caBuffer, int nBufLen);
+
+int _wchdir(const wchar_t *_path);
+int  _wmkdir(const wchar_t *_path);
+int  _wrmdir(const wchar_t *_path);
+
+#endif
diff --git a/reactos/include/msvcrt/errno.h b/reactos/include/msvcrt/errno.h
new file mode 100644 (file)
index 0000000..509bf60
--- /dev/null
@@ -0,0 +1,132 @@
+/* 
+ * errno.h
+ *
+ * Error numbers and access to error reporting.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  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: 2000/12/03 17:49:21 $
+ *
+ */
+
+#ifndef _ERRNO_H_
+#define        _ERRNO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Error numbers.
+ * TODO: Can't be sure of some of these assignments, I guessed from the
+ * names given by strerror and the defines in the Cygnus errno.h. A lot
+ * of the names from the Cygnus errno.h are not represented, and a few
+ * of the descriptions returned by strerror do not obviously match
+ * their error naming.
+ */
+#define EPERM          1       /* Operation not permitted */
+#define        ENOFILE         2       /* No such file or directory */
+#define        ENOENT          2
+#define        ESRCH           3       /* No such process */
+#define        EINTR           4       /* Interrupted function call */
+#define        EIO             5       /* Input/output error */
+#define        ENXIO           6       /* No such device or address */
+#define        E2BIG           7       /* Arg list too long */
+#define        ENOEXEC         8       /* Exec format error */
+#define        EBADF           9       /* Bad file descriptor */
+#define        ECHILD          10      /* No child processes */
+#define        EAGAIN          11      /* Resource temporarily unavailable */
+#define        ENOMEM          12      /* Not enough space */
+#define        EACCES          13      /* Permission denied */
+#define        EFAULT          14      /* Bad address */
+/* 15 - Unknown Error */
+#define        EBUSY           16      /* strerror reports "Resource device" */
+#define        EEXIST          17      /* File exists */
+#define        EXDEV           18      /* Improper link (cross-device link?) */
+#define        ENODEV          19      /* No such device */
+#define        ENOTDIR         20      /* Not a directory */
+#define        EISDIR          21      /* Is a directory */
+#define        EINVAL          22      /* Invalid argument */
+#define        ENFILE          23      /* Too many open files in system */
+#define        EMFILE          24      /* Too many open files */
+#define        ENOTTY          25      /* Inappropriate I/O control operation */
+/* 26 - Unknown Error */
+#define        EFBIG           27      /* File too large */
+#define        ENOSPC          28      /* No space left on device */
+#define        ESPIPE          29      /* Invalid seek (seek on a pipe?) */
+#define        EROFS           30      /* Read-only file system */
+#define        EMLINK          31      /* Too many links */
+#define        EPIPE           32      /* Broken pipe */
+#define        EDOM            33      /* Domain error (math functions) */
+#define        ERANGE          34      /* Result too large (possibly too small) */
+/* 35 - Unknown Error */
+#define        EDEADLOCK       36      /* Resource deadlock avoided (non-Cyg) */
+#define        EDEADLK         36
+/* 37 - Unknown Error */
+#define        ENAMETOOLONG    38      /* Filename too long (91 in Cyg?) */
+#define        ENOLCK          39      /* No locks available (46 in Cyg?) */
+#define        ENOSYS          40      /* Function not implemented (88 in Cyg?) */
+#define        ENOTEMPTY       41      /* Directory not empty (90 in Cyg?) */
+#define        EILSEQ          42      /* Illegal byte sequence */
+
+/*
+ * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
+ *       sockets.h header provided with windows32api-0.1.2.
+ *       You should go and put an #if 0 ... #endif around the whole block
+ *       of errors (look at the comment above them).
+ */
+
+/*
+ * Definitions of macros for the 'variables' errno, _doserrno, sys_nerr and
+ * sys_errlist.
+ */
+int*   _errno(void);
+#define        errno           (*_errno())
+
+int*   __doserrno(void);
+#define        _doserrno       (*__doserrno())
+
+#if    __MSVCRT__
+/* One of the MSVCRTxx libraries */
+
+extern int*    __imp__sys_nerr;
+#define        sys_nerr        (*__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
+}
+#endif
+
+#endif
diff --git a/reactos/include/msvcrt/internal/tls.h b/reactos/include/msvcrt/internal/tls.h
new file mode 100644 (file)
index 0000000..483a20d
--- /dev/null
@@ -0,0 +1,28 @@
+/* tls.h */
+
+#ifndef __MSVCRT_INTERNAL_TLS_H
+#define __MSVCRT_INTERNAL_TLS_H
+
+#include <msvcrt/stddef.h>
+
+typedef struct _ThreadData
+{
+       int terrno;
+       unsigned long tdoserrno;
+       unsigned long long tnext;       /* used by rand/srand */
+
+       char *lasttoken;                /* used by strtok */
+       wchar_t *wlasttoken;            /* used by wcstok */
+
+} THREADDATA, *PTHREADDATA;
+
+
+int CreateThreadData(void);
+void DestroyThreadData(void);
+
+void FreeThreadData(PTHREADDATA ptd);
+PTHREADDATA GetThreadData(void);
+
+#endif /* __MSVCRT_INTERNAL_TLS_H */
+
+/* EOF */
\ No newline at end of file
diff --git a/reactos/include/msvcrt/mbstring.h b/reactos/include/msvcrt/mbstring.h
new file mode 100644 (file)
index 0000000..7a145eb
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef _MBSTRING_H_
+#define _MBSTRING_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <msvcrt/stddef.h>
+
+size_t _mbstrlen(const char *str);
+
+
+
+
+int _mbbtype(unsigned char c, int type);
+int _mbsbtype( const unsigned char *str, size_t n );
+
+unsigned int _mbbtombc(unsigned int c);
+unsigned int _mbctombb(unsigned int c);
+
+unsigned char * _mbscat(unsigned char *dst, const unsigned char *src);
+unsigned char * _mbschr(const unsigned char *str, unsigned int c);
+int _mbscmp(const unsigned char *, const unsigned char *);
+int _mbscoll(const unsigned char *, const unsigned char *);
+unsigned char * _mbscpy(unsigned char *, const unsigned char *);
+size_t _mbscspn(const unsigned char *, const unsigned char *);
+unsigned char * _mbsdup(const unsigned char *str);
+int _mbsicmp(const unsigned char *, const unsigned char *);
+int _mbsicoll(const unsigned char *, const unsigned char *);
+size_t _mbslen(const unsigned char *str);
+
+unsigned char * _mbsncat(unsigned char *, const unsigned char *, size_t);
+unsigned char * _mbsnbcat(unsigned char *, const unsigned char *, size_t);
+
+
+int _mbsncmp(const unsigned char *, const unsigned char *, size_t);
+int _mbsnbcmp(const unsigned char *, const unsigned char *, size_t);
+
+int _mbsncoll(const unsigned char *, const unsigned char *, size_t);
+int _mbsnbcoll(const unsigned char *, const unsigned char *, size_t);
+
+
+unsigned char * _mbsncpy(unsigned char *, const unsigned char *, size_t);
+unsigned char * _mbsnbcpy(unsigned char *, const unsigned char *, size_t);
+
+int _mbsnicmp(const unsigned char *, const unsigned char *, size_t);
+int _mbsnbicmp(const unsigned char *, const unsigned char *, size_t);
+
+int _mbsnicoll(const unsigned char *, const unsigned char *, size_t);
+int _mbsnbicoll(const unsigned char *, const unsigned char *, size_t);
+
+unsigned char * _mbsnset(unsigned char *, unsigned int, size_t);
+unsigned char * _mbsnbset(unsigned char *, unsigned int, size_t);
+
+size_t _mbsnccnt(const unsigned char *, size_t);
+
+
+unsigned char * _mbspbrk(const unsigned char *, const unsigned char *);
+unsigned char * _mbsrchr(const unsigned char *, unsigned int);
+unsigned char * _mbsrev(unsigned char *);
+unsigned char * _mbsset(unsigned char *, unsigned int);
+size_t _mbsspn(const unsigned char *, const unsigned char *);
+
+unsigned char * _mbsstr(const unsigned char *, const unsigned char *);
+unsigned char * _mbstok(unsigned char *, const unsigned char *);
+
+unsigned char * _mbslwr(unsigned char *str);
+unsigned char * _mbsupr(unsigned char *str);
+
+size_t _mbclen(const unsigned char *);
+void _mbccpy(unsigned char *, const unsigned char *);
+
+/* tchar routines */
+
+unsigned char * _mbsdec(const unsigned char *, const unsigned char *);
+unsigned char * _mbsinc(const unsigned char *);
+size_t _mbsnbcnt(const unsigned char *, size_t);
+unsigned int _mbsnextc (const unsigned char *);
+unsigned char * _mbsninc(const unsigned char *, size_t);
+unsigned char * _mbsspnp(const unsigned char *, const unsigned char *);
+
+/* character routines */
+
+int _ismbcalnum(unsigned int c);
+int _ismbcalpha(unsigned int c);
+int _ismbcdigit(unsigned int c);
+int _ismbcgraph(unsigned int c);
+int _ismbclegal(unsigned int c);
+int _ismbclower(unsigned int c);
+int _ismbcprint(unsigned int c);
+int _ismbcpunct(unsigned int c);
+int _ismbcspace(unsigned int c);
+int _ismbcupper(unsigned int c);
+
+unsigned int _mbctolower(unsigned int);
+unsigned int _mbctoupper(unsigned int);
+
+
+int _ismbblead( unsigned int c);
+int _ismbbtrail( unsigned int c);
+int _ismbslead( const unsigned char *s, const unsigned char *c);
+int _ismbstrail( const unsigned char *s, const unsigned char *c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/reactos/include/msvcrt/stddef.h b/reactos/include/msvcrt/stddef.h
new file mode 100644 (file)
index 0000000..9ee7734
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * stddef.h
+ *
+ * Standard type definitions provided by the C library.
+ *
+ * NOTE: Actually supplied by the compiler (correct?). As such, GCC
+ *       supplies a version of this header file. Unfortunately, GCC's
+ *       version is all tied up with the way other headers for the
+ *       GNU C library are implemented (or vice-versa), in a similar
+ *       way to how the other Mingw32 headers are dependent on
+ *       certain internals of this file. It is not clear to me whether
+ *       you can safely use the GCC version in place of this version.
+ *       TODO: Line up usage in other header files to work with GCC
+ *       stddef.h.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  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: 2000/12/03 17:49:21 $
+ *
+ */
+
+
+#ifndef _STDDEF_H_
+
+/*
+ * Any one of these symbols __need_* means that a standard header file
+ * wants us just to define one data type.  So don't define
+ * the symbols that indicate this file's entire job has been done.
+ */
+#if (!defined(__need_wchar_t) && !defined(__need_wint_t)       \
+     && !defined(__need_size_t) && !defined(__need_ptrdiff_t)  \
+     && !defined(__need_NULL))
+#define _STDDEF_H_
+#endif
+
+/*
+ * NOTE: The following typedefs are done using __xxx_TYPE__ defines followed
+ * by typedefs using those defines. I have chosen to do it this way because
+ * GCC supplies definitions for __xxx_TYPE__ macros and if, for example, your
+ * 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.
+ */
+
+/*
+ * Signed type of difference of two pointers. 
+ */
+
+/* Define this type if we are doing the whole job, or if we want this type
+ * in particular.  */
+#if defined (_STDDEF_H_) || defined (__need_ptrdiff_t)
+
+#ifndef _PTRDIFF_T_
+#define _PTRDIFF_T_
+#ifndef __PTRDIFF_TYPE__
+#define        __PTRDIFF_TYPE__        int
+#endif
+typedef __PTRDIFF_TYPE__       ptrdiff_t;
+#endif
+
+/* If this symbol has done its job, get rid of it.  */
+#undef __need_ptrdiff_t
+
+#endif /* _STDDEF_H_ or __need_ptrdiff_t.  */
+
+/*
+ * Unsigned type of `sizeof' something.
+ */
+
+
+/* Define this type if we are doing the whole job,
+ * or if we want this type in particular.  */
+#if defined (_STDDEF_H_) || defined (__need_size_t)
+
+#ifndef _SIZE_T_
+#define _SIZE_T_
+#define SIZE_T_DEFINED
+#define _SIZE_T
+#ifndef __SIZE_TYPE__
+#define        __SIZE_TYPE__           unsigned int
+#endif
+typedef __SIZE_TYPE__          size_t;
+#endif
+
+#undef __need_size_t
+
+#endif /* _STDDEF_H_ or __need_size_t.  */
+
+/* Wide character type.
+   Locale-writers should change this as necessary to
+   be big enough to hold unique values not between 0 and 127,
+   and not (wchar_t) -1, for each defined multibyte character.  */
+
+/* Define this type if we are doing the whole job,
+   or if we want this type in particular.  */
+#if defined (_STDDEF_H_) || defined (__need_wchar_t)
+
+#ifndef _WCHAR_T_
+#define _WCHAR_T_
+#define _WCHAR_T
+#define _WCHAR_T_DEFINED
+#ifndef __WCHAR_TYPE__
+#define        __WCHAR_TYPE__          short unsigned int
+#endif
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__         wchar_t;
+#endif /* C++ */
+#endif /* wchar_t not already defined */
+
+#undef __need_wchar_t
+
+#endif /* _STDDEF_H_ or __need_wchar_t. */
+
+/*
+ * wint_t, the equivalent of int in wchar ctype functions.
+ */
+#if defined (_STDDEF_H_) || defined (__need_wint_t)
+
+#ifndef _WINT_T_
+#define _WINT_T_
+#define _WINT_T                /* To satisfy libstdc++ */
+#ifndef __WINT_TYPE__
+#define        __WINT_TYPE__           short int
+#endif /* Not defined __WINT_TYPE__ */
+
+typedef        __WINT_TYPE__           wint_t;
+#endif /* Not defined _WINT_T_ */
+
+#undef __need_wint_t
+
+#endif /* _STDDEF_H_ or __need_wint_t. */
+
+
+/*
+ * A null pointer constant.
+ */
+
+#if defined (_STDDEF_H_) || defined (__need_NULL)
+
+#undef NULL
+#define NULL (0)
+#endif /* _STDDEF_H_ or __need_NULL */
+
+#undef __need_NULL
+
+
+/*
+ * Offsetof, a macro for finding the offset of a member in a structure.
+ * Works by returning the 'address' of the MEMBER of a TYPE struct at address
+ * zero.
+ */
+
+#if defined (_STDDEF_H_)
+#define        offsetof(TYPE, MEMBER)  ((size_t) &( ((TYPE *) 0)->MEMBER ))
+#endif /* _STDDEF_H_ */
+
+
+#endif /* not _STDDEF_H_ */
diff --git a/reactos/include/msvcrt/stdlib.h b/reactos/include/msvcrt/stdlib.h
new file mode 100644 (file)
index 0000000..1c6b868
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * stdlib.h
+ *
+ * Definitions for common types, variables, and functions.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  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: 2000/12/03 17:49:21 $
+ *
+ */
+/* Appropriated for Reactos Crtdll by Ariadne */
+/* added splitpath */
+/* changed definition of environ and argc */
+/* moved prototype for swab from string.h to stdlib.h */
+#ifndef _STDLIB_H_
+#define _STDLIB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This seems like a convenient place to declare these variables, which
+ * give programs using WinMain (or main for that matter) access to main-ish
+ * argc and argv. environ is a pointer to a table of environment variables.
+ * NOTE: Strings in _argv and environ are ANSI strings.
+ */
+extern int*    __argc_dll;
+extern char*** __argv_dll;
+extern char*** _environ_dll;
+#define __argc      (*__argc_dll)
+#define __argv      (*__argv_dll)
+#define _environ    (*_environ_dll)
+
+
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <msvcrt/stddef.h>
+
+#include <msvcrt/mbstring.h>
+
+#ifndef  __ATTRIB_NORETURN
+#ifdef __GNUC__
+#define        _ATTRIB_NORETURN        __attribute__ ((noreturn))
+#else  /* Not __GNUC__ */
+#define        _ATTRIB_NORETURN
+#endif /* __GNUC__ */
+#endif
+
+double atof    (const char* szNumber);
+int    atoi    (const char* szNumber);
+long   atol    (const char* szNumber);
+
+
+double strtod  (const char* szNumber, char** pszAfterNumber);
+double wcstod  (const wchar_t* wsNumber, wchar_t** pwsAfterNumber);
+long   strtol  (const char* szNumber, char** pszAfterNumber, int nBase);
+long   wcstol  (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, int nBase);
+
+unsigned long  strtoul (const char* szNumber, char** pszAfterNumber,
+                       int nBase);
+unsigned long  wcstoul (const wchar_t* wsNumber, wchar_t** pwsAfterNumber,
+                       int nBase);
+
+size_t wcstombs        (char* mbsDest, const wchar_t* wsConvert, size_t size);
+int    wctomb          (char* mbDest, wchar_t wc);
+
+int    mblen           (const char* mbs, size_t sizeString);
+size_t mbstowcs        (wchar_t* wcaDest, const char* mbsConvert,
+                        size_t size);
+int    mbtowc          (wchar_t* wcDest, const char* mbConvert, size_t size);
+
+
+/*
+ * RAND_MAX is the maximum value that may be returned by rand.
+ * The minimum is zero.
+ */
+#define        RAND_MAX        0x7FFF
+
+int    rand    (void);
+void   srand   (unsigned int nSeed);
+
+
+void*  calloc  (size_t sizeObjCnt, size_t sizeObject);
+void*  malloc  (size_t sizeObject);
+void*  realloc (void* pObject, size_t sizeNew);
+void   free    (void* pObject);
+
+/* These values may be used as exit status codes. */
+#define        EXIT_SUCCESS    0
+#define        EXIT_FAILURE    -1
+
+void   abort   (void)  _ATTRIB_NORETURN;
+void   exit    (int nStatus) _ATTRIB_NORETURN;
+int    atexit  (void (*pfuncExitProcessing)(void));
+
+int    system  (const char* szCommand); // impl in process
+char*  getenv  (const char* szVarName);
+wchar_t* _wgetenv (const wchar_t* szVarName);
+
+typedef        int (*_pfunccmp_t)(const void*, const void*);
+
+void*  bsearch (const void* pKey, const void* pBase, size_t cntObjects,
+               size_t sizeObject, _pfunccmp_t pfuncCmp);
+void   qsort   (const void* pBase, size_t cntObjects, size_t sizeObject,
+               _pfunccmp_t pfuncCmp);
+
+int    abs     (int n);
+long   labs    (long n);
+
+/*
+ * div_t and ldiv_t are structures used to return the results of div and
+ * ldiv.
+ *
+ * NOTE: div and ldiv appear not to work correctly unless
+ *       -fno-pcc-struct-return is specified. This is included in the
+ *       mingw32 specs file.
+ */
+typedef struct { int quot, rem; } div_t;
+typedef struct { long quot, rem; } ldiv_t;
+typedef struct { long long quot, rem; } lldiv_t;
+
+div_t  div     (int nNumerator, int nDenominator);
+ldiv_t ldiv    (long lNumerator, long lDenominator);
+lldiv_t        lldiv   (long long lNumerator, long long lDenominator);
+
+
+#ifndef        __STRICT_ANSI__
+
+/*
+ * NOTE: Officially the three following functions are obsolete. The Win32 API
+ *       functions SetErrorMode, Beep and Sleep are their replacements.
+ */
+void   _beep (unsigned int, unsigned int);
+void   _seterrormode (int nMode);
+void   _sleep (unsigned long ulTime);
+
+void   _exit   (int nStatus) _ATTRIB_NORETURN;
+
+int    _putenv (const char *val);
+int    _wputenv(const wchar_t *val);
+void   _searchenv (const char *file, const char *var, char *path);
+void   _wsearchenv (const wchar_t *file, const wchar_t *var, wchar_t *path);
+
+void   _makepath( char *path, const char *drive, const char *dir,
+                const char *fname, const char *ext );
+void   _wmakepath( wchar_t *path, const wchar_t *drive, const wchar_t *dir,
+                const wchar_t *fname, const wchar_t *ext );
+void   _splitpath( const char *path, char *drive, char *dir,
+                char *fname, char *ext );
+char*  _fullpath( char* caBuf, const char* szPath, size_t sizeMax );
+wchar_t *_wfullpath( wchar_t *absPath, const wchar_t *relPath, size_t maxLength );
+
+char*  _itoa (int nValue, char* sz, int nRadix);
+char*  _ltoa (long lnValue, char* sz, int nRadix);
+char*  _ultoa(unsigned long value, char *string, int radix);
+
+wchar_t* _itow (int nValue, wchar_t* sz, int nRadix);
+wchar_t* _ltow (long lnValue, wchar_t* sz, int nRadix);
+wchar_t* _ultow(unsigned long value, wchar_t *string, int radix);
+
+char*  _ecvt (double dValue, int nDig, int* pnDec, int* pnSign);
+char*  _fcvt (double dValue, int nDig, int* pnDec, int* pnSign);
+char*  _gcvt (double dValue, int nDec, char* caBuf);
+
+void   _swab (const char* caFrom, char* caTo, size_t sizeToCopy);
+
+unsigned int _rotl( unsigned int value, int shift );
+unsigned int _rotr( unsigned int value, int shift );
+unsigned long _lrotl( unsigned long value, int shift );
+unsigned long _lrotr( unsigned long value, int shift );
+
+int    _wtoi( const wchar_t *str );
+long   _wtol( const wchar_t *str );
+
+
+#ifndef        _NO_OLDNAMES
+#define  beep          _beep
+#define  seterrormode  _seterrormode
+#define  sleep         _sleep
+#define  putenv                _putenv
+#define  searchenv     _searchenv
+#define  splitpath     _splitpath
+
+#define  itoa          _itoa
+#define  ltoa          _ltoa
+
+#define  ecvt          _ecvt
+#define  fcvt          _fcvt
+#define  gcvt          _gcvt
+
+#define  swab          _swab
+#endif /* Not _NO_OLDNAMES */
+
+#endif /* Not __STRICT_ANSI__ */
+
+/*
+ * Undefine the no return attribute used in some function definitions
+ */
+#undef _ATTRIB_NORETURN
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _STDLIB_H_ */
diff --git a/reactos/include/msvcrt/string.h b/reactos/include/msvcrt/string.h
new file mode 100644 (file)
index 0000000..d0a0071
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * string.h
+ *
+ * Definitions for memory and string functions.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  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: 2000/12/03 17:49:21 $
+ *
+ */
+/* Appropriated for Reactos Crtdll by Ariadne */
+/* changed prototype for _strerror */
+/* moved prototype for swab from string.h to stdlib.h */
+
+
+#ifndef _STRING_H_
+#define        _STRING_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Define size_t, wchar_t and NULL
+ */
+#define __need_size_t
+#define __need_wchar_t
+#define        __need_NULL
+#include <msvcrt/stddef.h>
+
+char * ___strtok; // removed extern specifier 02-06-98, BD
+
+/*
+ * Prototypes of the ANSI Standard C library string functions.
+ */
+void*  memchr (const void* p, int cSearchFor, size_t sizeSearch);
+int    memcmp (const void* p1, const void* p2, size_t sizeSearch);
+void*  memcpy (void* pCopyTo, const void* pSource, size_t sizeSource);
+void*  memmove (void* pMoveTo, const void* pSource, size_t sizeSource);
+void*  memset (void* p, int cFill, size_t sizeRepeatCount);
+char*  strcat (char* szAddTo, const char* szAdd);
+char*  strchr (const char* szSearch, int cFor);
+int    strcmp (const char* sz1, const char* sz2);
+int    strcoll (const char* sz1, const char* sz2); /* Compare using locale */
+char*  strcpy (char* szCopyTo, const char* szSource);
+size_t strcspn (const char* szGetPrefix, const char* szNotIncluding);
+char*  strerror (int nError); /* NOTE: NOT an old name wrapper. */
+char *  _strerror(const char *s);
+size_t strlen (const char* sz);
+size_t strnlen (const char* sz, size_t count); // not exported
+char*  strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd);
+int    strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
+char*  strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy);
+char*  strpbrk (const char* szSearch, const char* szAnyOf);
+char*  strrchr (const char* szSearch, int cFor);
+size_t strspn (const char* szGetPrefix, const char *szIncluding);
+char*  strstr (const char* szSearch, const char *szFor);
+char*  strtok (char* szTokenize, const char* szDelimiters);
+size_t strxfrm (char* szTransformed, const char *szSource,
+                size_t sizeTransform);
+
+#ifndef __STRICT_ANSI__
+/*
+ * Extra non-ANSI functions provided by the CRTDLL library
+ */
+void*  _memccpy (void* pCopyTo, const void* pSource, int cTerminator,
+                 size_t sizeMaxCopy);
+int    _memicmp (const void* p1, const void* p2, size_t sizeSearch);
+char*  _strdup (const char *szDuplicate);
+int    _strcmpi (const char* sz1, const char* sz2);
+int    _stricmp (const char* sz1, const char* sz2);
+int    _stricoll (const char* sz1, const char* sz2);
+char*  _strlwr (char* szToConvert);
+int    _strnicmp (const char* sz1, const char* sz2,
+                  size_t sizeMaxCompare);
+char*  _strnset (char* szToFill, int cFill, size_t sizeMaxFill);
+char*  _strrev (char* szToReverse);
+char*  _strset (char* szToFill, int cFill);
+char*  _strupr (char* szToConvert);
+
+
+#endif /* Not __STRICT_ANSI__ */
+
+
+/*
+ * Unicode versions of the standard calls.
+ */
+wchar_t* wcscat (wchar_t* wsAddTo, const wchar_t* wsAdd);
+wchar_t* wcschr (const wchar_t* wsSearch, wchar_t wcFor);
+int    wcscmp (const wchar_t* ws1, const wchar_t* ws2);
+int    wcscoll (const wchar_t* ws1, const wchar_t* ws2);
+wchar_t* wcscpy (wchar_t* wsCopyTo, const wchar_t* wsSource);
+size_t wcscspn (const wchar_t* wsGetPrefix, const wchar_t* wsNotIncluding);
+/* Note: No wcserror in CRTDLL. */
+size_t wcslen (const wchar_t* ws);
+wchar_t* wcsncat (wchar_t* wsAddTo, const wchar_t* wsAdd, size_t sizeMaxAdd);
+int    wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare);
+wchar_t* wcsncpy(wchar_t* wsCopyTo, const wchar_t* wsSource,
+                 size_t sizeMaxCopy);
+wchar_t* wcspbrk(const wchar_t* wsSearch, const wchar_t* wsAnyOf);
+wchar_t* wcsrchr(const wchar_t* wsSearch, wchar_t wcFor);
+size_t wcsspn(const wchar_t* wsGetPrefix, const wchar_t* wsIncluding);
+wchar_t* wcsstr(const wchar_t* wsSearch, const wchar_t* wsFor);
+wchar_t* wcstok(wchar_t* wsTokenize, const wchar_t* wsDelimiters);
+size_t wcsxfrm(wchar_t* wsTransformed, const wchar_t *wsSource,
+               size_t sizeTransform);
+
+
+#ifndef        __STRICT_ANSI__
+/*
+ * Unicode versions of non-ANSI functions provided by CRTDLL.
+ */
+
+/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
+#define                _wcscmpi        _wcsicmp
+
+wchar_t* _wcsdup (const wchar_t* wsToDuplicate);
+int    _wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
+int    _wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
+int    _wcsncoll (const wchar_t *s1, const wchar_t *s2, size_t c);
+int    _wcsnicoll (const wchar_t *s1, const wchar_t *s2, size_t c);
+wchar_t* _wcslwr (wchar_t* wsToConvert);
+int    _wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
+                  size_t sizeMaxCompare);
+wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
+wchar_t* _wcsrev (wchar_t* wsToReverse);
+wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill);
+wchar_t* _wcsupr (wchar_t* wsToConvert);
+
+#endif /* Not __STRICT_ANSI__ */
+
+
+#ifndef        __STRICT_ANSI__
+#ifndef        _NO_OLDNAMES
+
+/*
+ * Non-underscored versions of non-ANSI functions. They live in liboldnames.a
+ * and provide a little extra portability. Also a few extra UNIX-isms like
+ * strcasecmp.
+ */
+
+void*  memccpy (void* pCopyTo, const void* pSource, int cTerminator,
+                size_t sizeMaxCopy);
+int    memicmp (const void* p1, const void* p2, size_t sizeSearch);
+#define        strdup(szDuplicate)     _strdup(szDuplicate)
+int    strcmpi (const char* sz1, const char* sz2);
+int    stricmp (const char* sz1, const char* sz2);
+int    strcasecmp (const char* sz1, const char* sz2);
+int    stricoll (const char* sz1, const char* sz2);
+char*  strlwr (char* szToConvert);
+int    strnicmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
+int    strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
+char*  strnset (char* szToFill, int cFill, size_t sizeMaxFill);
+char*  strrev (char* szToReverse);
+char*  strset (char* szToFill, int cFill);
+char*  strupr (char* szToConvert);
+
+
+/* NOTE: There is no _wcscmpi, but this is for compatibility. */
+int    wcscmpi (const wchar_t* ws1, const wchar_t* ws2);
+wchar_t* wcsdup (const wchar_t* wsToDuplicate);
+int    wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
+int    wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
+wchar_t* wcslwr (wchar_t* wsToConvert);
+int    wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
+                 size_t sizeMaxCompare);
+wchar_t* wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
+wchar_t* wcsrev (wchar_t* wsToReverse);
+wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill);
+wchar_t* wcsupr (wchar_t* wsToConvert);
+
+#endif /* Not _NO_OLDNAMES */
+#endif /* Not strict ANSI */
+
+#endif
+
+#ifdef __cplusplus
+extern "C" }
+#endif
\ No newline at end of file