From: Steven Edwards Date: Fri, 13 Jan 2006 06:35:52 +0000 (+0000) Subject: This screws up my grep and is not used anymore X-Git-Tag: backups/expat-rbuild@40467~338 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5bf3b55eb0059426b2153230abad7360a0b58dbc This screws up my grep and is not used anymore svn path=/trunk/; revision=20830 --- diff --git a/reactos/lib/crtdll/old cruft/direct/chdir.c b/reactos/lib/crtdll/old cruft/direct/chdir.c deleted file mode 100644 index 7ad9e12f016..00000000000 --- a/reactos/lib/crtdll/old cruft/direct/chdir.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - */ -int _chdir(const char* _path) -{ - if (_path[1] == ':') - _chdrive(tolower(_path[0] - 'a')+1); - if (!SetCurrentDirectoryA((char*)_path)) - return -1; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/direct/chdrive.c b/reactos/lib/crtdll/old cruft/direct/chdrive.c deleted file mode 100644 index 85e578955cd..00000000000 --- a/reactos/lib/crtdll/old cruft/direct/chdrive.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - - -int cur_drive = 0; - - -/* - * @implemented - */ -int _chdrive(int drive) -{ - char d[3]; - - if (!( drive >= 1 && drive <= 26)) - return -1; - if (cur_drive != drive) { - cur_drive = drive; - d[0] = toupper(cur_drive + '@'); - d[1] = ':'; - d[2] = 0; - SetCurrentDirectoryA(d); - } - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/direct/getcwd.c b/reactos/lib/crtdll/old cruft/direct/getcwd.c deleted file mode 100644 index fe0a30a4de8..00000000000 --- a/reactos/lib/crtdll/old cruft/direct/getcwd.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - */ -char *_getcwd(char* buffer, int maxlen) -{ - char *cwd; - int len; - - if (buffer == NULL) { - cwd = malloc(MAX_PATH); - len = MAX_PATH; - } else { - cwd = buffer; - len = maxlen; - } - if (GetCurrentDirectoryA(len, cwd) == 0) { - return NULL; - } - return cwd; -} diff --git a/reactos/lib/crtdll/old cruft/direct/getdcwd.c b/reactos/lib/crtdll/old cruft/direct/getdcwd.c deleted file mode 100644 index 600fc5d534d..00000000000 --- a/reactos/lib/crtdll/old cruft/direct/getdcwd.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -/* - * @implemented - */ -char* _getdcwd(int nDrive, char* caBuffer, int nBufLen) -{ - int i =0; - int dr = _getdrive(); - - if (nDrive < 1 || nDrive > 26) - return NULL; - if (dr != nDrive) - _chdrive(nDrive); - i = GetCurrentDirectoryA(nBufLen, caBuffer); - if (i == nBufLen) - return NULL; - if (dr != nDrive) - _chdrive(dr); - return caBuffer; -} diff --git a/reactos/lib/crtdll/old cruft/direct/rmdir.c b/reactos/lib/crtdll/old cruft/direct/rmdir.c deleted file mode 100644 index c45ebc07cc1..00000000000 --- a/reactos/lib/crtdll/old cruft/direct/rmdir.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -int _rmdir(const char* _path) -{ - if (!RemoveDirectoryA(_path)) - return -1; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/dirent/dirent.c b/reactos/lib/crtdll/old cruft/dirent/dirent.c deleted file mode 100644 index 2832b923b82..00000000000 --- a/reactos/lib/crtdll/old cruft/dirent/dirent.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * dirent.c - * - * Derived from DIRLIB.C by Matt J. Weinstein - * This note appears in the DIRLIB.H - * DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89 - * - * Updated by Jeremy Bettis - * Significantly revised and rewinddir, seekdir and telldir added by Colin - * Peters - * - * $Revision: 1.3 $ - * $Author$ - * $Date$ - * - */ - -#include -/* #include */ -#include -#include -#include -#include -#include - -#include - -#define SUFFIX "*" -#define SLASH "\\" -#define streq(a,b) (strcmp(a,b)==0) - -/* - * opendir - * - * Returns a pointer to a DIR structure appropriately filled in to begin - * searching a directory. - */ -DIR* -opendir(const char* szPath) -{ - DIR* nd; - struct stat statDir; - - errno = 0; - - if (!szPath) - { - errno = EFAULT; - return (DIR*) 0; - } - - if (szPath[0] == '\0') - { - errno = ENOTDIR; - return (DIR*) 0; - } - - /* Attempt to determine if the given path really is a directory. */ - if (_stat (szPath, &statDir)) - { - /* Error, stat should have set an error value. */ - return (DIR*) 0; - } - - if (!S_ISDIR(statDir.st_mode)) - { - /* Error, stat reports not a directory. */ - errno = ENOTDIR; - return (DIR*) 0; - } - - /* Allocate enough space to store DIR structure and the complete - * directory path given. */ - nd = (DIR*) malloc (sizeof(DIR) + strlen(szPath) + strlen(SLASH) + - strlen(SUFFIX)); - - if (!nd) - { - /* Error, out of memory. */ - errno = ENOMEM; - return (DIR*) 0; - } - - /* Create the search expression. */ - strcpy(nd->dd_name, szPath); - - /* Add on a slash if the path does not end with one. */ - if (nd->dd_name[0] != '\0' && - nd->dd_name[strlen(nd->dd_name)-1] != '/' && - nd->dd_name[strlen(nd->dd_name)-1] != '\\') - { - strcat(nd->dd_name, SLASH); - } - - /* Add on the search pattern */ - strcat(nd->dd_name, SUFFIX); - - /* Initialize handle to -1 so that a premature closedir doesn't try - * to call _findclose on it. */ - nd->dd_handle = -1; - - /* Initialize the status. */ - nd->dd_stat = 0; - - /* Initialize the dirent structure. ino and reclen are invalid under - * Win32, and name simply points at the appropriate part of the - * findfirst_t structure. */ - nd->dd_dir.d_ino = 0; - nd->dd_dir.d_reclen = 0; - nd->dd_dir.d_namlen = 0; - nd->dd_dir.d_name = nd->dd_dta.name; - - return nd; -} - - -/* - * readdir - * - * Return a pointer to a dirent structure filled with the information on the - * next entry in the directory. - */ -struct dirent * -readdir( DIR *dirp ) -{ - errno = 0; - - /* Check for valid DIR struct. */ - if (!dirp) - { - errno = EFAULT; - return (struct dirent*) 0; - } - - if (dirp->dd_dir.d_name != dirp->dd_dta.name) - { - /* The structure does not seem to be set up correctly. */ - errno = EINVAL; - return (struct dirent*) 0; - } - - if (dirp->dd_stat < 0) - { - /* We have already returned all files in the directory - * (or the structure has an invalid dd_stat). */ - return (struct dirent *) 0; - } - else if (dirp->dd_stat == 0) - { - /* We haven't started the search yet. */ - /* Start the search */ - dirp->dd_handle = _findfirst(dirp->dd_name, &(dirp->dd_dta)); - - if (dirp->dd_handle == -1) - { - /* Whoops! Seems there are no files in that - * directory. */ - dirp->dd_stat = -1; - } - else - { - dirp->dd_stat = 1; - } - } - else - { - /* Get the next search entry. */ - if (_findnext(dirp->dd_handle, &(dirp->dd_dta))) - { - /* We are off the end or otherwise error. */ - _findclose (dirp->dd_handle); - dirp->dd_handle = -1; - dirp->dd_stat = -1; - } - else - { - /* Update the status to indicate the correct - * number. */ - dirp->dd_stat++; - } - } - - if (dirp->dd_stat > 0) - { - /* Successfully got an entry. Everything about the file is - * already appropriately filled in except the length of the - * file name. */ - dirp->dd_dir.d_namlen = strlen(dirp->dd_dir.d_name); - return &dirp->dd_dir; - } - - return (struct dirent*) 0; -} - - -/* - * closedir - * - * Frees up resources allocated by opendir. - */ -int -closedir (DIR* dirp) -{ - int rc; - - errno = 0; - rc = 0; - - if (!dirp) - { - errno = EFAULT; - return -1; - } - - if (dirp->dd_handle != -1) - { - rc = _findclose(dirp->dd_handle); - } - - /* Delete the dir structure. */ - free (dirp); - - return rc; -} - -/* - * rewinddir - * - * Return to the beginning of the directory "stream". We simply call findclose - * and then reset things like an opendir. - */ -void -rewinddir (DIR* dirp) -{ - errno = 0; - - if (!dirp) - { - errno = EFAULT; - return; - } - - if (dirp->dd_handle != -1) - { - _findclose(dirp->dd_handle); - } - - dirp->dd_handle = -1; - dirp->dd_stat = 0; -} - -/* - * telldir - * - * Returns the "position" in the "directory stream" which can be used with - * seekdir to go back to an old entry. We simply return the value in stat. - */ -long -telldir (DIR* dirp) -{ - errno = 0; - - if (!dirp) - { - errno = EFAULT; - return -1; - } - return dirp->dd_stat; -} - -/* - * seekdir - * - * Seek to an entry previously returned by telldir. We rewind the directory - * and call readdir repeatedly until either dd_stat is the position number - * or -1 (off the end). This is not perfect, in that the directory may - * have changed while we weren't looking. But that is probably the case with - * any such system. - */ -void -seekdir (DIR* dirp, long lPos) -{ - errno = 0; - - if (!dirp) - { - errno = EFAULT; - return; - } - - if (lPos < -1) - { - /* Seeking to an invalid position. */ - errno = EINVAL; - return; - } - else if (lPos == -1) - { - /* Seek past end. */ - if (dirp->dd_handle != -1) - { - _findclose (dirp->dd_handle); - } - dirp->dd_handle = -1; - dirp->dd_stat = -1; - } - else - { - /* Rewind and read forward to the appropriate index. */ - rewinddir (dirp); - - while ((dirp->dd_stat < lPos) && readdir(dirp)) - ; - } -} - diff --git a/reactos/lib/crtdll/old cruft/float/chgsign.c b/reactos/lib/crtdll/old cruft/float/chgsign.c deleted file mode 100644 index cd81af13c22..00000000000 --- a/reactos/lib/crtdll/old cruft/float/chgsign.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -double _chgsign(double __x) -{ - double_t* x = (double_t*)&x; - - if (x->sign == 1) - x->sign = 0; - else - x->sign = 1; - - return __x; -} diff --git a/reactos/lib/crtdll/old cruft/float/copysign.c b/reactos/lib/crtdll/old cruft/float/copysign.c deleted file mode 100644 index d31d19b0fbd..00000000000 --- a/reactos/lib/crtdll/old cruft/float/copysign.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -/* - * @implemented - */ -double _copysign (double __d, double __s) -{ - double_t *d = (double_t *)&__d; - double_t *s = (double_t *)&__s; - - d->sign = s->sign; - - return __d; -} - diff --git a/reactos/lib/crtdll/old cruft/float/fpclass.c b/reactos/lib/crtdll/old cruft/float/fpclass.c deleted file mode 100644 index 31d7aebfefa..00000000000 --- a/reactos/lib/crtdll/old cruft/float/fpclass.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include - - -#define _FPCLASS_SNAN 0x0001 /* signaling NaN */ -#define _FPCLASS_QNAN 0x0002 /* quiet NaN */ -#define _FPCLASS_NINF 0x0004 /* negative infinity */ -#define _FPCLASS_NN 0x0008 /* negative normal */ -#define _FPCLASS_ND 0x0010 /* negative denormal */ -#define _FPCLASS_NZ 0x0020 /* -0 */ -#define _FPCLASS_PZ 0x0040 /* +0 */ -#define _FPCLASS_PD 0x0080 /* positive denormal */ -#define _FPCLASS_PN 0x0100 /* positive normal */ -#define _FPCLASS_PINF 0x0200 /* positive infinity */ - -#define FP_SNAN 0x0001 // signaling NaN -#define FP_QNAN 0x0002 // quiet NaN -#define FP_NINF 0x0004 // negative infinity -#define FP_PINF 0x0200 // positive infinity -#define FP_NDENORM 0x0008 // negative denormalized non-zero -#define FP_PDENORM 0x0010 // positive denormalized non-zero -#define FP_NZERO 0x0020 // negative zero -#define FP_PZERO 0x0040 // positive zero -#define FP_NNORM 0x0080 // negative normalized non-zero -#define FP_PNORM 0x0100 // positive normalized non-zero - -typedef int fpclass_t; - -/* - * @implemented - */ -fpclass_t _fpclass(double __d) -{ - double_t* d = (double_t*)&__d; - - if (d->exponent == 0) { - if (d->mantissah == 0 && d->mantissal == 0) { - if (d->sign ==0) - return FP_NZERO; - else - return FP_PZERO; - } else { - if (d->sign ==0) - return FP_NDENORM; - else - return FP_PDENORM; - } - } - if (d->exponent == 0x7ff) { - if (d->mantissah == 0 && d->mantissal == 0) { - if (d->sign ==0) - return FP_NINF; - else - return FP_PINF; - } - else if (d->mantissah == 0 && d->mantissal != 0) { - return FP_QNAN; - } - else if (d->mantissah == 0 && d->mantissal != 0) { - return FP_SNAN; - } - - } - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/float/isnan.c b/reactos/lib/crtdll/old cruft/float/isnan.c deleted file mode 100644 index 814d573c1c6..00000000000 --- a/reactos/lib/crtdll/old cruft/float/isnan.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include - - -/* - * @implemented - */ -int _isnan(double __x) -{ - double_t* x = (double_t*)&__x; - return (x->exponent == 0x7ff && (x->mantissah != 0 || x->mantissal != 0)); -} - -int _isnanl(long double __x) -{ - /* Intel's extended format has the normally implicit 1 explicit - present. Sigh! */ - - long_double_t* x = (long_double_t*)&__x; - - - /* IEEE 854 NaN's have the maximum possible - exponent and a nonzero mantissa. */ - - return (( x->exponent == 0x7fff) - && ((x->mantissah & 0x80000000) != 0) - && ((x->mantissah & (unsigned int)0x7fffffff) != 0 || x->mantissal != 0)); -} - -int _isinf(double __x) -{ - double_t* x = (double_t*)&__x; - return (x->exponent == 0x7ff && (x->mantissah == 0 && x->mantissal == 0)); -} - -/* - * @implemented - */ -int _finite(double x) -{ - return !_isinf(x); -} - -int _isinfl(long double __x) -{ - /* Intel's extended format has the normally implicit 1 explicit - present. Sigh! */ - - long_double_t* x = (long_double_t*)&__x; - - - /* An IEEE 854 infinity has an exponent with the - maximum possible value and a zero mantissa. */ - - - if (x->exponent == 0x7fff && ((x->mantissah == 0x80000000) && x->mantissal == 0)) - return x->sign ? -1 : 1; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/float/nextaf.c b/reactos/lib/crtdll/old cruft/float/nextaf.c deleted file mode 100644 index d97d2dd2a71..00000000000 --- a/reactos/lib/crtdll/old cruft/float/nextaf.c +++ /dev/null @@ -1,48 +0,0 @@ -#define MAX_DOUBLE 1.7976931348623158e+308 -#define MIN_DOUBLE 2.2250738585072014e-308 - -double _xnextafter( double __x, double __y ) -{ - double_t *x = ( double_t *)&__x; - - double __e; - double_t *e = (double_t *)&__e; - - - if ( _isnan(__x) || _isinf(__x) ) - return __x; - - if ( _isnan(__y) ) - return __y; - - - // don't go to infinity just by adding - - if ( _isinf(__y) && fabs(__x) >= MAX_DOUBLE ) - return __x; - - if ( !_isinf(__y) && fabs(__x - __y) <= MIN_DOUBLE ) - return __y; - - - - - e->mantissal = 1; - e->mantissah = 0; - if ( x->exponent >= 53 ) - e->exponent = x->exponent - 52; - else - e->exponent = 1; - - if ( fabs(__x) < fabs(__y) ) - e->sign = 0; - else - e->sign = 1; - - - - return __x+__e; - - - -} diff --git a/reactos/lib/crtdll/old cruft/float/scalb.c b/reactos/lib/crtdll/old cruft/float/scalb.c deleted file mode 100644 index 3b460ff6483..00000000000 --- a/reactos/lib/crtdll/old cruft/float/scalb.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -/* - * @implemented - */ -double _scalb( double __x, long e ) -{ - double_t *x = (double_t *)&__x; - - x->exponent += e; - - return __x; -} diff --git a/reactos/lib/crtdll/old cruft/io/access.c b/reactos/lib/crtdll/old cruft/io/access.c deleted file mode 100644 index 074753d7621..00000000000 --- a/reactos/lib/crtdll/old cruft/io/access.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#define NDEBUG -#include - - -/* - * @implemented - */ -int _access( const char *_path, int _amode ) -{ - DWORD Attributes = GetFileAttributesA(_path); - DPRINT("_access('%s', %x)\n", _path, _amode); - - if (Attributes == -1) { - __set_errno(ENOENT); - return -1; - } - if ((_amode & W_OK) == W_OK) { - if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) { - __set_errno(EACCES); - return -1; - } - } - if ((_amode & D_OK) == D_OK) { - if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { - __set_errno(EACCES); - return -1; - } - } - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/io/chmod.c b/reactos/lib/crtdll/old cruft/io/chmod.c deleted file mode 100644 index 544a51c531a..00000000000 --- a/reactos/lib/crtdll/old cruft/io/chmod.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#define NDEBUG -#include - -#define mode_t int - - -/* - * @implemented - */ -int _chmod(const char* filename, mode_t mode) -{ - DWORD FileAttributes = 0; - DPRINT("_chmod('%s', %x)\n", filename, mode); - - FileAttributes = GetFileAttributesA(filename); - if ( FileAttributes == -1 ) - return -1; - - if ( mode == 0 ) - return -1; - - if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE) - FileAttributes &= FILE_ATTRIBUTE_READONLY; - else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE)) - FileAttributes &= FILE_ATTRIBUTE_NORMAL; - else - FileAttributes &= FILE_ATTRIBUTE_NORMAL; - - if (SetFileAttributesA(filename, FileAttributes) == FALSE) - return -1; - - return 1; -} diff --git a/reactos/lib/crtdll/old cruft/io/create.c b/reactos/lib/crtdll/old cruft/io/create.c deleted file mode 100644 index 45019052308..00000000000 --- a/reactos/lib/crtdll/old cruft/io/create.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -/* - * @implemented - */ -int _creat(const char *filename, int mode) -{ - return open(filename,_O_CREAT|_O_TRUNC,mode); -} diff --git a/reactos/lib/crtdll/old cruft/io/dup.c b/reactos/lib/crtdll/old cruft/io/dup.c deleted file mode 100644 index e16064df7aa..00000000000 --- a/reactos/lib/crtdll/old cruft/io/dup.c +++ /dev/null @@ -1,21 +0,0 @@ -/* $Id$ */ -#include -#include -#include - -// fixme change type of mode argument to mode_t - -int __fileno_alloc(HANDLE hFile, int mode); -int __fileno_getmode(int _fd); - -/* - * @implemented - */ -int _dup(int handle) -{ - HANDLE hFile; - int fd; - hFile = _get_osfhandle(handle); - fd = __fileno_alloc(hFile, __fileno_getmode(handle)); - return fd; -} diff --git a/reactos/lib/crtdll/old cruft/io/eof.c b/reactos/lib/crtdll/old cruft/io/eof.c deleted file mode 100644 index cdbdbf5ebeb..00000000000 --- a/reactos/lib/crtdll/old cruft/io/eof.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -/* - * @implemented - */ -int _eof( int _fd ) -{ - int cur_pos = _lseek(_fd, 0, SEEK_CUR); - int end_pos = _filelength( _fd ); - if ( cur_pos == -1 || end_pos == -1) - return -1; - - if ( cur_pos == end_pos ) - return 1; - - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/io/filelen.c b/reactos/lib/crtdll/old cruft/io/filelen.c deleted file mode 100644 index ba37d1e1adb..00000000000 --- a/reactos/lib/crtdll/old cruft/io/filelen.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -long _filelength(int _fd) -{ - return GetFileSize(_get_osfhandle(_fd),NULL); -} diff --git a/reactos/lib/crtdll/old cruft/io/find.c b/reactos/lib/crtdll/old cruft/io/find.c deleted file mode 100644 index 6a3e1b0ba98..00000000000 --- a/reactos/lib/crtdll/old cruft/io/find.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include - - -/* - * @implemented - */ -int _findclose(int handle) -{ - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - return FindClose((void*)handle); -} - -/* - * @implemented - */ -int _findfirst(const char* _name, struct _finddata_t* result) -{ - WIN32_FIND_DATAA FindFileData; - char dir[MAX_PATH]; - long hFindFile; - int len = 0; - - if (_name == NULL || _name[0] == 0) { - len = GetCurrentDirectoryA(MAX_PATH-4,dir); - if (dir[len-1] != '\\') { - dir[len] = '\\'; - dir[len+1] = 0; - } - strcat(dir,"*.*"); - } else { - strcpy(dir,_name); - } - - hFindFile = (long)FindFirstFileA(dir, &FindFileData); - if (hFindFile == -1) { - memset(result,0,sizeof(struct _finddata_t)); - return -1; - } - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = FindFileData.nFileSizeLow; - strncpy(result->name,FindFileData.cFileName,MAX_PATH); - - // if no wildcard the find file handle can be closed right away - // a return value of 0 can flag this. - - if (!strchr(dir,'*') && !strchr(dir,'?')) { - _findclose(hFindFile); - return 0; - } - - return hFindFile; -} - -/* - * @implemented - */ -int _findnext(int handle, struct _finddata_t* result) -{ - WIN32_FIND_DATAA FindFileData; - - // check no wildcards or invalid handle - if (handle == 0 || handle == -1) - return 0; - - if (!FindNextFileA((void*)handle, &FindFileData)) - return -1; - - result->attrib = FindFileData.dwFileAttributes; - result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); - result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); - result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); - result->size = FindFileData.nFileSizeLow; - strncpy(result->name,FindFileData.cFileName, MAX_PATH); - - return 0; -} - diff --git a/reactos/lib/crtdll/old cruft/io/fmode.c b/reactos/lib/crtdll/old cruft/io/fmode.c deleted file mode 100644 index 870ac3a2f1f..00000000000 --- a/reactos/lib/crtdll/old cruft/io/fmode.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -#undef _fmode -unsigned int _fmode = O_TEXT; - -unsigned int *_fmode_dll = &_fmode; - diff --git a/reactos/lib/crtdll/old cruft/io/locking.c b/reactos/lib/crtdll/old cruft/io/locking.c deleted file mode 100644 index 733fe8411fc..00000000000 --- a/reactos/lib/crtdll/old cruft/io/locking.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -int _locking(int _fd, int mode, long nbytes) -{ - long offset = _lseek(_fd, 0L, 1); - if (!LockFile(_get_osfhandle(_fd),offset,0,nbytes,0)) - return -1; - - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/io/lseek.c b/reactos/lib/crtdll/old cruft/io/lseek.c deleted file mode 100644 index 0764147d62d..00000000000 --- a/reactos/lib/crtdll/old cruft/io/lseek.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - */ -long _lseek(int _fildes, long _offset, int _whence) -{ - return _llseek((HFILE)filehnd(_fildes),_offset,_whence); -} diff --git a/reactos/lib/crtdll/old cruft/io/open.c b/reactos/lib/crtdll/old cruft/io/open.c deleted file mode 100644 index 4f30882eafd..00000000000 --- a/reactos/lib/crtdll/old cruft/io/open.c +++ /dev/null @@ -1,254 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/io/open.c - * PURPOSE: Opens a file and translates handles to fileno - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ - -// rember to interlock the allocation of fileno when making this thread safe - -// possibly store extra information at the handle - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define STD_AUX_HANDLE 3 -#define STD_PRINTER_HANDLE 4 - -typedef struct _fileno_modes_type -{ - HANDLE hFile; - int mode; - int fd; -} fileno_modes_type; - -int __fileno_alloc(HANDLE hFile, int mode); - -fileno_modes_type *fileno_modes = NULL; - -int maxfno = 5; -int minfno = 5; - -char __is_text_file(FILE* p) -{ - if (p == NULL || fileno_modes == NULL) - return FALSE; - return (!((p)->_flag&_IOSTRG) && (fileno_modes[(p)->_file].mode&O_TEXT)); -} - -/* - * @implemented - */ -int _open(const char* _path, int _oflag,...) -{ - HANDLE hFile; - DWORD dwDesiredAccess = 0; - DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - DWORD dwCreationDistribution = 0; - DWORD dwFlagsAndAttributes = 0; - int mode; - va_list arg; - - va_start(arg, _oflag); - mode = va_arg(arg,int); - va_end (arg); - if ((mode == S_IWRITE) || (mode == 0)) - dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY; - /* - * - * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.) - * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.) - * - */ - if (( _oflag & _O_RDWR ) == _O_RDWR ) - dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ ; - else if (( _oflag & _O_WRONLY ) == _O_WRONLY ) - dwDesiredAccess |= GENERIC_WRITE ; - else - dwDesiredAccess |= GENERIC_READ ; - - if ((_oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL)) - dwCreationDistribution |= CREATE_NEW; - - else if ((_oflag & O_TRUNC) == O_TRUNC) { - if ((_oflag & O_CREAT) == O_CREAT) - dwCreationDistribution |= CREATE_ALWAYS; - else if ((_oflag & O_RDONLY ) != O_RDONLY) - dwCreationDistribution |= TRUNCATE_EXISTING; - } - else if ((_oflag & _O_APPEND) == _O_APPEND) - dwCreationDistribution |= OPEN_EXISTING; - else if ((_oflag & _O_CREAT) == _O_CREAT) - dwCreationDistribution |= OPEN_ALWAYS; - else - dwCreationDistribution |= OPEN_EXISTING; - - if ((_oflag & _O_RANDOM) == _O_RANDOM) - dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS; - if ((_oflag & _O_SEQUENTIAL) == _O_SEQUENTIAL) - dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN; - - if ((_oflag & _O_TEMPORARY) == _O_TEMPORARY) - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - - if ((_oflag & _O_SHORT_LIVED) == _O_SHORT_LIVED) - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - - hFile = CreateFileA(_path, - dwDesiredAccess, - dwShareMode, - NULL, - dwCreationDistribution, - dwFlagsAndAttributes, - NULL); - if (hFile == (HANDLE)-1) - return -1; - return __fileno_alloc(hFile,_oflag); - -// _O_APPEND Moves file pointer to end of file before every write operation. - -} - - -int -__fileno_alloc(HANDLE hFile, int mode) -{ - int i; - /* Check for bogus values */ - if (hFile < 0) - return -1; - - for(i=minfno;i= maxfno) - return (void*)-1; - if (fileno_modes[fileno].fd == -1) - return (void*)-1; - return fileno_modes[fileno].hFile; -} - -int __fileno_setmode(int _fd, int _newmode) -{ - int m; - - if (_fd < minfno) { - return -1; - } - if (_fd >= maxfno) - return -1; - m = fileno_modes[_fd].mode; - fileno_modes[_fd].mode = _newmode; - return m; -} - -int __fileno_getmode(int _fd) -{ - if (_fd < minfno) { - return -1; - } - if (_fd >= maxfno) - return -1; - return fileno_modes[_fd].mode; -} - -int __fileno_close(int _fd) -{ - if (_fd < 0) { - return -1; - } - if (_fd >= maxfno) - return -1; - fileno_modes[_fd].fd = -1; - fileno_modes[_fd].hFile = (HANDLE)-1; - return 0; -} - -/* - * @implemented - */ -int _open_osfhandle(void *osfhandle, int flags) -{ - return __fileno_alloc((HANDLE)osfhandle, flags); -} - -/* - * @implemented - */ -void *_get_osfhandle(int fileno) -{ - return filehnd(fileno); -} - -int __fileno_dup2(int handle1, int handle2) -{ - if (handle1 >= maxfno) { - return -1; - } - if (handle1 < 0) - return -1; - if (handle2 >= maxfno) - return -1; - if (handle2 < 0) - return -1; - memcpy(&fileno_modes[handle1],&fileno_modes[handle2],sizeof(fileno_modes)); - return handle1; -} diff --git a/reactos/lib/crtdll/old cruft/io/pipe.c b/reactos/lib/crtdll/old cruft/io/pipe.c deleted file mode 100644 index 48a7cd58436..00000000000 --- a/reactos/lib/crtdll/old cruft/io/pipe.c +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/io/pipe.c - * PURPOSE: Creates a pipe - * PROGRAMER: DJ Delorie - * UPDATE HISTORY: - * 28/12/98: Appropriated for Reactos - */ - -#include -#include -#include - - -/* - * @implemented - */ -int _pipe(int _fildes[2], unsigned int size, int mode ) -{ - HANDLE hReadPipe, hWritePipe; - - if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,size)) - return -1; - - _fildes[0] = __fileno_alloc(hReadPipe, mode); - _fildes[1] = __fileno_alloc(hWritePipe, mode); - - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/io/read.c b/reactos/lib/crtdll/old cruft/io/read.c deleted file mode 100644 index 10010ab12fd..00000000000 --- a/reactos/lib/crtdll/old cruft/io/read.c +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/io/read.c - * PURPOSE: Reads a file - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/1998: Created - */ - -#include -#include -#include - -#define NDEBUG -#include - -/* - * @implemented - */ -size_t _read(int _fd, void *_buf, size_t _nbyte) -{ - DWORD _rbyte; - - if (!ReadFile(_get_osfhandle(_fd),_buf,_nbyte,&_rbyte,NULL)) - { - return -1; - } - return (size_t)_rbyte; -} diff --git a/reactos/lib/crtdll/old cruft/io/unlink.c b/reactos/lib/crtdll/old cruft/io/unlink.c deleted file mode 100644 index ccdef39399e..00000000000 --- a/reactos/lib/crtdll/old cruft/io/unlink.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/io/unlink.c - * PURPOSE: Deletes a file - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include - - -/* - * @implemented - */ -int _unlink( const char *filename ) -{ - if ( !DeleteFileA(filename) ) - return -1; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/io/write.c b/reactos/lib/crtdll/old cruft/io/write.c deleted file mode 100644 index 313bbe32f22..00000000000 --- a/reactos/lib/crtdll/old cruft/io/write.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/io/write.c - * PURPOSE: Writes to a file - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include - - -/* - * @implemented - */ -size_t _write(int _fd, const void *_buf, size_t _nbyte) -{ - DWORD _wbyte; - - if ( !WriteFile(_get_osfhandle(_fd),_buf,_nbyte,&_wbyte,NULL) ) - { - return -1; - } - return (size_t)_wbyte; -} diff --git a/reactos/lib/crtdll/old cruft/math/acosh.c b/reactos/lib/crtdll/old cruft/math/acosh.c deleted file mode 100644 index cb1dbed706b..00000000000 --- a/reactos/lib/crtdll/old cruft/math/acosh.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -double acosh(double x) -{ - return log(x + sqrt(x*x - 1)); -} diff --git a/reactos/lib/crtdll/old cruft/math/asinh.c b/reactos/lib/crtdll/old cruft/math/asinh.c deleted file mode 100644 index 402c46e9b92..00000000000 --- a/reactos/lib/crtdll/old cruft/math/asinh.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -double asinh(double x) -{ - return x>0 ? log(x + sqrt(x*x + 1)) : -log(sqrt(x*x+1)-x); -} diff --git a/reactos/lib/crtdll/old cruft/math/atanh.c b/reactos/lib/crtdll/old cruft/math/atanh.c deleted file mode 100644 index ee1228826ad..00000000000 --- a/reactos/lib/crtdll/old cruft/math/atanh.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -double atanh(double x) -{ - return log((1+x)/(1-x)) / 2.0; -} diff --git a/reactos/lib/crtdll/old cruft/math/ceil.c b/reactos/lib/crtdll/old cruft/math/ceil.c deleted file mode 100644 index 66a1359bf6e..00000000000 --- a/reactos/lib/crtdll/old cruft/math/ceil.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -/* - * @implemented - */ -double ceil (double __x) -{ - register double __value; -#ifdef __GNUC__ - __volatile unsigned short int __cw, __cwtmp; - - __asm __volatile ("fnstcw %0" : "=m" (__cw)); - __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */ - __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); - __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); - __asm __volatile ("fldcw %0" : : "m" (__cw)); -#else - __value = linkme_ceil(__x); -#endif /*__GNUC__*/ - return __value; -} - - -long double ceill (long double __x) -{ - return floor(__x)+1; -} diff --git a/reactos/lib/crtdll/old cruft/math/floor.c b/reactos/lib/crtdll/old cruft/math/floor.c deleted file mode 100644 index b799387ebe4..00000000000 --- a/reactos/lib/crtdll/old cruft/math/floor.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Math functions for i387. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by John C. Bowman , 1995. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include - -double floor (double __x); - -double floor (double __x) -{ - register double __value; -#ifdef __GNUC__ - __volatile unsigned short int __cw, __cwtmp; - - __asm __volatile ("fnstcw %0" : "=m" (__cw)); - __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */ - __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); - __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); - __asm __volatile ("fldcw %0" : : "m" (__cw)); -#else - __value = linkme_floor(__x); -#endif /*__GNUC__*/ - return __value; -} - -typedef struct IEEExp { - unsigned manl:32; - unsigned manh:32; - unsigned exp:15; - unsigned sign:1; - } long_double_t; - -long double floorl(long double x ) -{ - - return (long double)(long long int)x; -} - diff --git a/reactos/lib/crtdll/old cruft/math/frexp.c b/reactos/lib/crtdll/old cruft/math/frexp.c deleted file mode 100644 index 911c00dd43a..00000000000 --- a/reactos/lib/crtdll/old cruft/math/frexp.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -double -frexp(double __x, int *exptr) -{ - double_t *x = (double_t *)&__x; - - if ( exptr != NULL ) - *exptr = x->exponent - 0x3FE; - - - x->exponent = 0x3FE; - - return __x; -} - - - diff --git a/reactos/lib/crtdll/old cruft/math/huge_val.c b/reactos/lib/crtdll/old cruft/math/huge_val.c deleted file mode 100644 index 6b92fcb5959..00000000000 --- a/reactos/lib/crtdll/old cruft/math/huge_val.c +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include - -#undef _HUGE -double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 }; -double *_HUGE_dll = (double *)&_HUGE; diff --git a/reactos/lib/crtdll/old cruft/math/modf.c b/reactos/lib/crtdll/old cruft/math/modf.c deleted file mode 100644 index 336a7d712bf..00000000000 --- a/reactos/lib/crtdll/old cruft/math/modf.c +++ /dev/null @@ -1,132 +0,0 @@ -/* @(#)s_modf.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include -#include -#include - - - -//static const double one = 1.0; - -double modf(double __x, double *__i) -{ - double_t * x = (double_t *)&__x; - double_t * iptr = ( double_t *)__i; - - int j0; - unsigned int i; - j0 = x->exponent - 0x3ff; /* exponent of x */ - if(j0<20) { /* integer part in high x */ - if(j0<0) { /* |x|<1 */ - *__i = 0.0; - iptr->sign = x->sign; - return __x; - } else { - - if ( x->mantissah == 0 && x->mantissal == 0 ) { - *__i = __x; - return 0.0; - } - - i = (0x000fffff)>>j0; - iptr->sign = x->sign; - iptr->exponent = x->exponent; - iptr->mantissah = x->mantissah&(~i); - iptr->mantissal = 0; - if ( __x == *__i ) { - __x = 0.0; - x->sign = iptr->sign; - return __x; - } - return __x - *__i; - } - } else if (j0>51) { /* no fraction part */ - *__i = __x; - if ( _isnan(__x) || _isinf(__x) ) - return __x; - - __x = 0.0; - x->sign = iptr->sign; - return __x; - } else { /* fraction part in low x */ - - i = ((unsigned)(0xffffffff))>>(j0-20); - iptr->sign = x->sign; - iptr->exponent = x->exponent; - iptr->mantissah = x->mantissah; - iptr->mantissal = x->mantissal&(~i); - if ( __x == *__i ) { - __x = 0.0; - x->sign = iptr->sign; - return __x; - } - return __x - *__i; - } -} - - -long double modfl(long double __x, long double *__i) -{ - long_double_t * x = (long_double_t *)&__x; - long_double_t * iptr = (long_double_t *)__i; - - int j0; - unsigned int i; - j0 = x->exponent - 0x3fff; /* exponent of x */ - - if(j0<32) { /* integer part in high x */ - if(j0<0) { /* |x|<1 */ - *__i = 0.0L; - iptr->sign = x->sign; - return __x; - } else { - - i = ((unsigned int)(0xffffffff))>>(j0+1); - if ( x->mantissal == 0 && (x->mantissal & i) == 0 ) { - *__i = __x; - __x = 0.0L; - x->sign = iptr->sign; - return __x; - } - iptr->sign = x->sign; - iptr->exponent = x->exponent; - iptr->mantissah = x->mantissah&((~i)); - iptr->mantissal = 0; - - return __x - *__i; - } - } else if (j0>63) { /* no fraction part */ - *__i = __x; - if ( _isnanl(__x) || _isinfl(__x) ) - return __x; - - __x = 0.0L; - x->sign = iptr->sign; - return __x; - } else { /* fraction part in low x */ - - i = ((unsigned int)(0xffffffff))>>(j0-32); - if ( x->mantissal == 0 ) { - *__i = __x; - __x = 0.0L; - x->sign = iptr->sign; - return __x; - } - iptr->sign = x->sign; - iptr->exponent = x->exponent; - iptr->mantissah = x->mantissah; - iptr->mantissal = x->mantissal&(~i); - - return __x - *__i; - } -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/islead.c b/reactos/lib/crtdll/old cruft/mbstring/islead.c deleted file mode 100644 index 5e560678352..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/islead.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -/* - * @unimplemented - */ -int isleadbyte(char *mbstr) -{ - return 0; - //return IsDBCSLeadByteEx(0,*c); -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbclen.c b/reactos/lib/crtdll/old cruft/mbstring/mbclen.c deleted file mode 100644 index a79be0b75f8..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbclen.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -size_t _mbclen(const unsigned char *s) -{ - return (_ismbblead(*s>>8) && _ismbbtrail(*s&0x00FF)) ? 2 : 1; -} - -size_t _mbclen2(const unsigned int s) -{ - return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1; -} - -/* - * assume MB_CUR_MAX == 2 - * - * @implemented - */ -int mblen( const char *s, size_t count ) -{ - size_t l; - if ( s == NULL ) - return 0; - - l = _mbclen(s); - if ( l < count ) - return -1; - return l; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbscat.c b/reactos/lib/crtdll/old cruft/mbstring/mbscat.c deleted file mode 100644 index de3f87bb688..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbscat.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbscat(unsigned char *dst, const unsigned char *src) -{ - return strcat(dst,src); -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbschr.c b/reactos/lib/crtdll/old cruft/mbstring/mbschr.c deleted file mode 100644 index 51769833bb0..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbschr.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbschr(const unsigned char *str, unsigned int c) -{ - return strchr(str,c); -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbscmp.c b/reactos/lib/crtdll/old cruft/mbstring/mbscmp.c deleted file mode 100644 index cea23b4d7c8..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbscmp.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -/* - * @implemented - */ -int _mbscmp(const unsigned char *str1, const unsigned char *str2) -{ - return strcmp(str1,str2); -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbscpy.c b/reactos/lib/crtdll/old cruft/mbstring/mbscpy.c deleted file mode 100644 index 0f9884be7ad..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbscpy.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned char * _mbscpy(unsigned char *dst, const unsigned char *str) -{ - return strcpy(dst,str); -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbscspn.c b/reactos/lib/crtdll/old cruft/mbstring/mbscspn.c deleted file mode 100644 index c5653ddfac6..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbscspn.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -/* - * FIXME not correct - * - * @unimplemented - */ -size_t _mbscspn(const unsigned char *s1, const unsigned char *s2) -{ - const char *p, *spanp; - char c, sc; - - for (p = s1;;) - { - c = *p++; - spanp = s2; - do { - if ((sc = *spanp++) == c) - return (size_t)(p - 1) - (size_t)s1; - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbsdup.c b/reactos/lib/crtdll/old cruft/mbstring/mbsdup.c deleted file mode 100644 index 216c6400f70..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbsdup.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/mbstring/hanzen.c - * PURPOSE: Duplicates a multi byte string - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - Modified from DJGPP strdup - * 12/04/99: Created - */ - -#include -#include - -/* - * @implemented - */ -unsigned char * _mbsdup(const unsigned char *_s) -{ - char *rv; - if (_s == 0) - return 0; - rv = (char *)malloc(_mbslen(_s) + 1); - if (rv == 0) - return 0; - _mbscpy(rv, _s); - return rv; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbsncat.c b/reactos/lib/crtdll/old cruft/mbstring/mbsncat.c deleted file mode 100644 index 38b05d8d62d..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbsncat.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/mbstring/mbsset.c - * PURPOSE: Concatenate two multi byte string to maximum of n characters or bytes - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include -#include - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n) -{ - char *d = (char *)dst; - char *s = (char *)src; - if (n != 0) { - d = dst + strlen(dst); // get the end of string - d += _mbclen2(*d); // move 1 or 2 up - - do { - if ((*d++ = *s++) == 0) - { - while (--n != 0) - *d++ = 0; - break; - } - if (!_ismbblead(*s) ) - n--; - } while (n > 0); - } - return dst; -} - -/* - * @implemented - */ -unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n) -{ - char *d; - char *s = (char *)src; - if (n != 0) { - d = dst + strlen(dst); // get the end of string - d += _mbclen2(*d); // move 1 or 2 up - - do { - if ((*d++ = *s++) == 0) - { - while (--n != 0) - *d++ = 0; - break; - } - if ( !(n==1 && _ismbblead(*s)) ) - n--; - } while (n > 0); - } - return dst; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbspbrk.c b/reactos/lib/crtdll/old cruft/mbstring/mbspbrk.c deleted file mode 100644 index 05ec0f97153..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbspbrk.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -/* - * FIXME not correct - * - * @implemented - */ -unsigned char * _mbspbrk(const unsigned char *s1, const unsigned char *s2) -{ - const char *scanp; - int c, sc; - - while ((c = *s1++) != 0) - { - for (scanp = s2; (sc = *scanp++) != 0;) - if (sc == c) - return (unsigned char *)((char *)s1 - (char *)1); - } - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbsrchr.c b/reactos/lib/crtdll/old cruft/mbstring/mbsrchr.c deleted file mode 100644 index 7c720587ace..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbsrchr.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/mbstring/mbsrchr.c - * PURPOSE: Searches for a character in reverse - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 12/04/99: Created - */ - -#include - -size_t _mbclen2(const unsigned int s); - -/* - * @implemented - */ -unsigned char * _mbsrchr(const unsigned char *src, unsigned int val) -{ - char *s = (char *)src; - short cc = val; - const char *sp=(char *)0; - - while (*s) - { - if (*(short *)s == cc) - sp = s; - s+= _mbclen2(*s); - } - if (cc == 0) - sp = s; - return (char *)sp; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbsrev.c b/reactos/lib/crtdll/old cruft/mbstring/mbsrev.c deleted file mode 100644 index 6179c2d936f..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbsrev.c +++ /dev/null @@ -1,31 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbsrev(unsigned char *s) -{ - unsigned char *e; - unsigned char a; - e=s; - while (*e) { - if ( _ismbblead(*e) ) { - a = *e; - *e = *++e; - if ( *e == 0 ) - break; - *e = a; - } - e++; - } - while (s - -/* - * FIXME not correct - * - * @implemented - */ -size_t _mbsspn(const unsigned char *s1, const unsigned char *s2) -{ - const char *p = s1, *spanp; - char c, sc; - - cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (size_t)(p - 1) - (size_t)s1; -// - (char *)s1); -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbsspnp.c b/reactos/lib/crtdll/old cruft/mbstring/mbsspnp.c deleted file mode 100644 index e2824da6892..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbsspnp.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -/* - * FIXME not correct - * - * @implemented - */ -unsigned char * _mbsspnp(const unsigned char *s1, const unsigned char *s2) -{ - const char *p = s1, *spanp; - char c, sc; - - cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (unsigned char *)p; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbsstr.c b/reactos/lib/crtdll/old cruft/mbstring/mbsstr.c deleted file mode 100644 index 68a5a36bfde..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbsstr.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -/* - * @implemented - */ -unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2) -{ - int len; - - if(src2 ==NULL || *src2 == 0) - return (unsigned char *)src1; - - len = _mbstrlen(src2); - - while(*src1) - { - if((*src1 == *src2) && (_mbsncmp(src1,src2,len) == 0)) - return (unsigned char *)src1; - src1 = (unsigned char *)_mbsinc(src1); - } - return NULL; -} diff --git a/reactos/lib/crtdll/old cruft/mbstring/mbstok.c b/reactos/lib/crtdll/old cruft/mbstring/mbstok.c deleted file mode 100644 index d8c184bd09c..00000000000 --- a/reactos/lib/crtdll/old cruft/mbstring/mbstok.c +++ /dev/null @@ -1,56 +0,0 @@ -#include - -/* - * @implemented - */ -unsigned char * _mbstok(unsigned char *s, unsigned char *delim) -{ - const char *spanp; - int c, sc; - char *tok; - static char *last; - - - if (s == NULL && (s = last) == NULL) - return (NULL); - - /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). - */ - cont: - c = *s; - s = _mbsinc(s); - - for (spanp = delim; (sc = *spanp) != 0; spanp = _mbsinc(spanp)) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-delimiter characters */ - last = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s; - s = _mbsinc(s); - spanp = delim; - do { - if ((sc = *spanp) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - last = s; - return (tok); - } - spanp = _mbsinc(spanp); - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/reactos/lib/crtdll/old cruft/misc/CRT_noglob.c b/reactos/lib/crtdll/old cruft/misc/CRT_noglob.c deleted file mode 100644 index b66cf57f740..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/CRT_noglob.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * noglob.c - * - * This file defines _CRT_glob to have a value of 0, which will - * turn off command line globbing. It is compiled into a separate object - * file which you can add to your link line to turn off globbing like - * this: - * - * gcc -o foo.exe foo.o noglob.o - * - * $Revision: 1.1 $ - * $Author$ - * $Date$ - * - */ - -int _CRT_glob = 0; - diff --git a/reactos/lib/crtdll/old cruft/misc/CRTfmode.c b/reactos/lib/crtdll/old cruft/misc/CRTfmode.c deleted file mode 100644 index dd8ef946a91..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/CRTfmode.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * CRTfmode.c - * - * Sets _CRT_fmode to be zero, which will cause _mingw32_init_fmode to leave - * all file modes in their default state (basically text mode). - * - * This file is part of the Mingw32 package. - * - * THIS FILE IS IN THE PUBLIC DOMAIN. - * - * Contributers: - * Created by Colin Peters - * - * $Revision: 1.1 $ - * $Author$ - * $Date$ - * - */ - -unsigned int _CRT_fmode = 0; - diff --git a/reactos/lib/crtdll/old cruft/misc/CRTglob.c b/reactos/lib/crtdll/old cruft/misc/CRTglob.c deleted file mode 100644 index 0d545c088e4..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/CRTglob.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * CRTglob.c - * - * This object file defines _CRT_glob to have a value of -1, which will - * turn on command line globbing by default. If you want to turn off - * command line globbing include a line - * - * int _CRT_glob = 0; - * - * in one of your source modules. - * - * $Revision: 1.1 $ - * $Author$ - * $Date$ - * - */ - -int _CRT_glob = -1; - diff --git a/reactos/lib/crtdll/old cruft/misc/CRTinit.c b/reactos/lib/crtdll/old cruft/misc/CRTinit.c deleted file mode 100644 index 20a8e5394b7..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/CRTinit.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * CRTinit.c - * - * A dummy version of _CRT_INIT for MS compatibility. Programs, or more often - * dlls, which use the static version of the MSVC run time are supposed to - * call _CRT_INIT to initialize the run time library in DllMain. This does - * not appear to be necessary when using crtdll or the dll versions of the - * MSVC runtime, so the dummy call simply does nothing. - * - * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.1 $ - * $Author$ - * $Date$ - * - */ - -void -_CRT_INIT () -{ -} - diff --git a/reactos/lib/crtdll/old cruft/misc/GetArgs.c b/reactos/lib/crtdll/old cruft/misc/GetArgs.c deleted file mode 100644 index 6209363780a..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/GetArgs.c +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include -#include - - -char *_pgmptr_dll; -char *_acmdln_dll; -unsigned int _commode_dll; -unsigned int _winmajor_dll; -unsigned int _winminor_dll; -unsigned int _winver_dll; - - -unsigned int _osmajor_dll; -unsigned int _osminor_dll; -unsigned int _osmode_dll; -unsigned int _osver_dll; -unsigned int _osversion_dll; - -unsigned int _basemajor_dll; -unsigned int _baseminor_dll; -unsigned int _baseversion_dll; - -#undef __argv -#undef __argc - -char *xargv[1024]; - -char **__argv = xargv; -int __argc = 0; -int *__argc_dll = &__argc; -char ***__argv_dll = &__argv; - - -#undef _environ -char **_environ; -#undef _environ_dll -char *** _environ_dll = &_environ; -static int envAlloced = 0; - - -int BlockEnvToEnviron(void) -{ - char * ptr; - int i; - - if (!envAlloced) - { - envAlloced = 50; - _environ = malloc (envAlloced * sizeof (char **)); - if (!_environ) return -1; - _environ[0] =NULL; - } - ptr = (char *)GetEnvironmentStringsA(); - if (!ptr) return -1; - for (i = 0 ; *ptr ; i++) - { - if(i>envAlloced-2) - { - envAlloced = i+3; - _environ = realloc (_environ,envAlloced * sizeof (char **)); - } - _environ[i] = ptr; - while(*ptr) ptr++; - ptr++; - } - _environ[i] =0; - return 0; -} - -/* - * @implemented - */ -int __GetMainArgs(int *argc,char ***argv,char ***env,int flag) -{ - int i,afterlastspace; - DWORD version; - - _acmdln_dll = GetCommandLineA(); - - version = GetVersion(); - _osver_dll = version >> 16; - _winminor_dll = version & 0xFF; - _winmajor_dll = (version>>8) & 0xFF; - _winver_dll = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8); - - - /* missing threading init */ - - i=0; - afterlastspace=0; - __argc=0; - - while (_acmdln_dll[i]) - { - if (_acmdln_dll[i]==' ') - { - __argc++; - _acmdln_dll[i]='\0'; - __argv[__argc-1] = _strdup(_acmdln_dll + afterlastspace); - _acmdln_dll[i]=' '; - i++; - while (_acmdln_dll[i]==' ') - i++; - afterlastspace=i; - } - else - { - i++; - } - } - - if (_acmdln_dll[afterlastspace] != 0) - { - __argc++; - _acmdln_dll[i]='\0'; - __argv[__argc-1] = _strdup(_acmdln_dll+afterlastspace); - } - HeapValidate(GetProcessHeap(),0,NULL); - - if( BlockEnvToEnviron() ) - return FALSE; - _environ_dll = &_environ; - - *argc = __argc; - *argv = __argv; - *env = _environ; - - _pgmptr_dll = _strdup((char *)argv[0]); - - return 0; -} - -int _chkstk(void) -{ - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/misc/amsg.c b/reactos/lib/crtdll/old cruft/misc/amsg.c deleted file mode 100644 index 1b4a7b7588d..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/amsg.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/misc/amsg.c - * PURPOSE: Print runtime error messages - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include -#include -#include - -/* - * @implemented - */ -int _aexit_rtn_dll(int exitcode) -{ - _exit(exitcode); -} - -/* - * @implemented - */ -void _amsg_exit(int errnum) -{ - fprintf(stderr,strerror(errnum)); - _aexit_rtn_dll(-1); -} - diff --git a/reactos/lib/crtdll/old cruft/misc/assert.c b/reactos/lib/crtdll/old cruft/misc/assert.c deleted file mode 100644 index f7c9d37e59a..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/assert.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include - - -/* - * @implemented - */ -void _assert(const char* msg, const char* file, int line) -{ - /* Assertion failed at foo.c line 45: x - * - * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.5 $ - * $Author$ - * $Date$ - * - */ - -#include -#include -#include -#include -#include -#include -#include - - -/* NOTE: The code for initializing the _argv, _argc, and environ variables - * has been moved to a separate .c file which is included in both - * crt1.c and dllcrt1.c. This means changes in the code don't have to - * be manually synchronized, but it does lead to this not-generally- - * a-good-idea use of include. */ -#include "init.c" - -extern int main(int, char**, char**); - -/* - * Setup the default file handles to have the _CRT_fmode mode, as well as - * any new files created by the user. - */ -extern unsigned int _CRT_fmode; - -void -_mingw32_init_fmode (void) -{ - /* Don't set the file mode if the user hasn't set any value for it. */ - if (_CRT_fmode) - { - _fmode = _CRT_fmode; - - /* - * This overrides the default file mode settings for stdin, - * stdout and stderr. At first I thought you would have to - * test with isatty, but it seems that the DOS console at - * least is smart enough to handle _O_BINARY stdout and - * still display correctly. - */ - if (stdin) - { - _setmode (_fileno(stdin), _CRT_fmode); - } - if (stdout) - { - _setmode (_fileno(stdout), _CRT_fmode); - } - if (stderr) - { - _setmode (_fileno(stderr), _CRT_fmode); - } - } -} - - -/* - * The function mainCRTStartup is the entry point for all console programs. - */ -int -mainCRTStartup (void) -{ - int nRet; - - /* - * I have been told that this is the correct thing to do. You - * have to uncomment the prototype of SetUnhandledExceptionFilter - * in the GNU Win32 API headers for this to work. The type it - * expects is a pointer to a function of the same type as - * UnhandledExceptionFilter, which is prototyped just above - * (see Functions.h). - */ - //SetUnhandledExceptionFilter (NULL); - - /* - * Initialize floating point unit. - */ - _fpreset (); /* Supplied by the runtime library. */ - - /* - * Set up __argc, __argv and _environ. - */ - _mingw32_init_mainargs(); - - /* - * Sets the default file mode for stdin, stdout and stderr, as well - * as files later opened by the user, to _CRT_fmode. - * NOTE: DLLs don't do this because that would be rude! - */ - _mingw32_init_fmode(); - - /* - * Call the main function. If the user does not supply one - * the one in the 'libmingw32.a' library will be linked in, and - * that one calls WinMain. See main.c in the 'lib' dir - * for more details. - */ - nRet = main(_argc, _argv, _environ); - - /* - * Perform exit processing for the C library. This means - * flushing output and calling 'atexit' registered functions. - */ - _cexit(); - - ExitProcess (nRet); - - return 0; -} - -/* - * For now the GUI startup function is the same as the console one. - * This simply gets rid of the annoying warning about not being able - * to find WinMainCRTStartup when linking GUI applications. - */ -int -WinMainCRTStartup (void) -{ - return mainCRTStartup(); -} - -/* With the EGCS build from Mumit Khan (or apparently b19 from Cygnus) this - * is no longer necessary. */ -#ifdef __GNUC__ -/* - * This section terminates the list of imports under GCC. If you do not - * include this then you will have problems when linking with DLLs. - * - */ -asm (".section .idata$3\n" ".long 0,0,0,0,0,0,0,0"); -#endif - diff --git a/reactos/lib/crtdll/old cruft/misc/debug.c b/reactos/lib/crtdll/old cruft/misc/debug.c deleted file mode 100644 index 36787852d6f..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/debug.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include -#include - - -void debug_printf(char* fmt, ...) -{ - va_list args; - char buffer[255]; - HANDLE OutputHandle; - - AllocConsole(); - OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE); - va_start(args,fmt); - vsprintf(buffer,fmt,args); - WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL); - va_end(args); -} diff --git a/reactos/lib/crtdll/old cruft/misc/dllcrt1.c b/reactos/lib/crtdll/old cruft/misc/dllcrt1.c deleted file mode 100644 index ffd72876a28..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/dllcrt1.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * dllcrt1.c - * - * Initialization code for DLLs. - * - * This file is part of the Mingw32 package. - * - * Contributors: - * Created by Colin Peters - * DLL support adapted from Gunther Ebert - * - * - * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.5 $ - * $Author$ - * $Date$ - * - */ - -#include -#include -#include -#include - - -/* See note in crt0.c */ -#include "init.c" - -/* Unlike normal crt0, I don't initialize the FPU, because the process - * should have done that already. I also don't set the file handle modes, - * because that would be rude. */ - -#ifdef __GNUC__ -extern void __main(); -extern void __do_global_dtors(); -#endif - -extern BOOL WINAPI DllMain(HANDLE, DWORD, LPVOID); - -BOOL WINAPI -DllMainCRTStartup(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) -{ - BOOL bRet; - - if (dwReason == DLL_PROCESS_ATTACH) { - _mingw32_init_mainargs(); - -#ifdef __GNUC__ - /* From libgcc.a, calls global class constructors. */ - __main(); -#endif - } - - /* - * Call the user-supplied DllMain subroutine - * NOTE: DllMain is optional, so libmingw32.a includes a stub - * which will be used if the user does not supply one. - */ - bRet = DllMain(hDll, dwReason, lpReserved); - -#ifdef __GNUC__ - if (dwReason == DLL_PROCESS_DETACH) { - /* From libgcc.a, calls global class destructors. */ - __do_global_dtors(); - } -#endif - - return bRet; -} - -/* - * For the moment a dummy atexit. Atexit causes problems in DLLs, especially - * if they are dynamically loaded. For now atexit inside a DLL does nothing. - * NOTE: We need this even if the DLL author never calls atexit because - * the global constructor function __do_global_ctors called from __main - * will attempt to register __do_global_dtors using atexit. - * Thanks to Andrey A. Smirnov for pointing this one out. - * - * @unimplemented - */ -int -atexit(void (*pfn)()) -{ - return 0; -} - -/* With the EGCS snapshot from Mumit Khan (or b19 from Cygnus I hear) this - * is no longer necessary. */ -#if 0 -#ifdef __GNUC__ -/* - * This section terminates the list of imports under GCC. If you do not - * include this then you will have problems when linking with DLLs. - */ -asm (".section .idata$3\n" ".long 0,0,0,0,0,0,0,0"); -#endif -#endif diff --git a/reactos/lib/crtdll/old cruft/misc/dllmain.c b/reactos/lib/crtdll/old cruft/misc/dllmain.c deleted file mode 100644 index 2435b6bb6d2..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/dllmain.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $Id$ - * - * dllmain.c - * - * A stub DllMain function which will be called by DLLs which do not - * have a user supplied DllMain. - * - * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.6 $ - * $Author$ - * $Date$ - * - */ - -#include -#include -#include -#include - - -/* EXTERNAL PROTOTYPES ********************************************************/ - -void debug_printf(char* fmt, ...); - - -/* LIBRARY GLOBAL VARIABLES ***************************************************/ - -int __mb_cur_max_dll = 1; -int _commode_dll = _IOCOMMIT; - - -/* LIBRARY ENTRY POINT ********************************************************/ - -BOOL -WINAPI -DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) -{ - return TRUE; -} - -/* EOF */ diff --git a/reactos/lib/crtdll/old cruft/misc/gccmain.c b/reactos/lib/crtdll/old cruft/misc/gccmain.c deleted file mode 100644 index e34ad17c4cd..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/gccmain.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * gccmain.c - * - * A separate version of __main, __do_global_ctors and __do_global_dtors for - * Mingw32 for use with Cygwin32 b19. Hopefully this object file will only - * be linked if the libgcc.a doesn't include __main, __do_global_dtors and - * __do_global_ctors. - * - * This file is part of the Mingw32 package. - * - * Contributors: - * Code supplied by Stan Cox - * - * $Revision: 1.3 $ - * $Author$ - * $Date$ - * - */ - -/* Needed for the atexit prototype. */ -#include - - -typedef void (*func_ptr) (void); -extern func_ptr __CTOR_LIST__[]; -extern func_ptr __DTOR_LIST__[]; - -void __do_global_dtors(void) -{ - static func_ptr* p = __DTOR_LIST__ + 1; - - /* - * Call each destructor in the destructor list until a null pointer - * is encountered. - */ - while (*p) - { - (*(p)) (); - p++; - } -} - -void __do_global_ctors(void) -{ - unsigned long nptrs = (unsigned long)__CTOR_LIST__[0]; - unsigned i; - - /* - * If the first entry in the constructor list is -1 then the list - * is terminated with a null entry. Otherwise the first entry was - * the number of pointers in the list. - */ - if (nptrs == -1) { - for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++) - ; - } - - /* - * Go through the list backwards calling constructors. - */ - for (i = nptrs; i >= 1; i--) { - __CTOR_LIST__[i] (); - } - - /* - * Register the destructors for processing on exit. - */ - atexit(__do_global_dtors); -} - -static int initialized = 0; - -void __main(void) -{ - if (!initialized) { - initialized = 1; - __do_global_ctors (); - } -} - diff --git a/reactos/lib/crtdll/old cruft/misc/init.c b/reactos/lib/crtdll/old cruft/misc/init.c deleted file mode 100644 index 21aa5f9a4ff..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/init.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * init.c - * - * Code to initialize standard file handles and command line arguments. - * This file is #included in both crt1.c and dllcrt1.c. - * - * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.4 $ - * $Author$ - * $Date$ - * - */ - -/* - * Access to a standard 'main'-like argument count and list. Also included - * is a table of environment variables. - */ -int _argc = 0; -char** _argv = 0; - -/* NOTE: Thanks to Pedro A. Aranda Gutiirrez for pointing - * this out to me. GetMainArgs (used below) takes a fourth argument - * which is an int that controls the globbing of the command line. If - * _CRT_glob is non-zero the command line will be globbed (e.g. *.* - * expanded to be all files in the startup directory). In the mingw32 - * library a _CRT_glob variable is defined as being -1, enabling - * this command line globbing by default. To turn it off and do all - * command line processing yourself (and possibly escape bogons in - * MS's globbing code) include a line in one of your source modules - * defining _CRT_glob and setting it to zero, like this: - * int _CRT_glob = 0; - */ -extern int _CRT_glob; - -extern void __GetMainArgs(int *, char***, char***, int); - -/* - * Initialize the _argc, _argv and environ variables. - */ -static void -_mingw32_init_mainargs (void) -{ - /* The environ variable is provided directly in stdlib.h through - * a dll function call. */ - char** dummy_environ; - - /* - * Microsoft's runtime provides a function for doing just that. - */ -#ifdef _MSVCRT_LIB_ - (void) __getmainargs(&_argc, &_argv, &dummy_environ, _CRT_glob); -#else - /* CRTDLL version */ - (void) __GetMainArgs(&_argc, &_argv, &dummy_environ, _CRT_glob); -#endif -} - diff --git a/reactos/lib/crtdll/old cruft/misc/initter.c b/reactos/lib/crtdll/old cruft/misc/initter.c deleted file mode 100644 index 0f511c855c3..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/initter.c +++ /dev/null @@ -1,10 +0,0 @@ - -typedef void(*atexit_t)(void); - -/* - * @unimplemented - */ -void _initterm(atexit_t *, atexit_t *) -{ - return; -} diff --git a/reactos/lib/crtdll/old cruft/misc/initterm.c b/reactos/lib/crtdll/old cruft/misc/initterm.c deleted file mode 100644 index 13b9026afa2..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/initterm.c +++ /dev/null @@ -1,38 +0,0 @@ -#include - - -/* - * @implemented - */ -void _initterm(void (*fStart[])(void), void (*fEnd[])(void)) -{ - int i = 0; - - if ( fStart == NULL || fEnd == NULL ) - return; - - while ( &fStart[i] < fEnd ) - { - if ( fStart[i] != NULL ) - (*fStart[i])(); - i++; - } -} - - -typedef int (* _onexit_t)(void); - -/* - * @unimplemented - */ -_onexit_t __dllonexit(_onexit_t func, void (** fStart[])(void), void (** fEnd[])(void)) -{ -} - -/* - * @unimplemented - */ -_onexit_t _onexit(_onexit_t x) -{ - return x; -} diff --git a/reactos/lib/crtdll/old cruft/misc/main.c b/reactos/lib/crtdll/old cruft/misc/main.c deleted file mode 100644 index 53d1b918f9a..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/main.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * main.c - * - * Extra startup code for applications which do not have a main function - * of their own (but do have a WinMain). Generally these are GUI - * applications, but they don't *have* to be. - * - * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAMED. This includes but is not limited to warrenties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision: 1.4 $ - * $Author$ - * $Date$ - * - */ - -#include -#include -#include - - -#define ISSPACE(a) (a == ' ' || a == '\t') - -extern int PASCAL WinMain (HANDLE hInst, HANDLE hPrevInst, LPSTR szCmdLine, int nShow); - -int main(int argc, char* argv[], char* environ[]) -{ - char* szCmd; - STARTUPINFO startinfo; - int nRet; - - /* Get the command line passed to the process. */ - szCmd = GetCommandLineA(); - GetStartupInfoA(&startinfo); - - /* Strip off the name of the application and any leading - * whitespace. */ - if (szCmd) - { - while(ISSPACE(*szCmd)) - { - szCmd++; - } - - /* On my system I always get the app name enclosed - * in quotes... */ - if (*szCmd == '\"') - { - do - { - szCmd++; - } - while (*szCmd != '\"' && *szCmd != '\0'); - - if (*szCmd == '\"') - { - szCmd++; - } - } - else - { - /* If no quotes then assume first token is program - * name. */ - while (!ISSPACE(*szCmd) && *szCmd != '\0') - { - szCmd++; - } - } - - while (ISSPACE(*szCmd)) - { - szCmd++; - } - } - - nRet = WinMain (GetModuleHandle(NULL), NULL, szCmd, - (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? - startinfo.wShowWindow : SW_SHOWDEFAULT); - - return nRet; -} diff --git a/reactos/lib/crtdll/old cruft/misc/purecall.c b/reactos/lib/crtdll/old cruft/misc/purecall.c deleted file mode 100644 index 0887461bfaf..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/purecall.c +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * @unimplemented - */ -int _purecall(void) -{ - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/misc/setnew.c b/reactos/lib/crtdll/old cruft/misc/setnew.c deleted file mode 100644 index 9f0ad6f54ba..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/setnew.c +++ /dev/null @@ -1,28 +0,0 @@ -#include - - -typedef int (*new_handler_t)(size_t); - -new_handler_t new_handler; - -#undef _set_new_handler -new_handler_t _set_new_handler__FPFUi_i(new_handler_t hnd) -{ - new_handler_t old = new_handler; - - new_handler = hnd; - return old; -} - -#undef delete -void __builtin_delete(void* m) -{ - if (m != NULL) - free(m); -} - -#undef new -void* __builtin_new(unsigned int s) -{ - return malloc( s ); -} diff --git a/reactos/lib/crtdll/old cruft/misc/sleep.c b/reactos/lib/crtdll/old cruft/misc/sleep.c deleted file mode 100644 index 6225b424388..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/sleep.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - - -void sleep(unsigned long timeout) -{ - Sleep((timeout)?timeout:1); -} diff --git a/reactos/lib/crtdll/old cruft/misc/unwind.c b/reactos/lib/crtdll/old cruft/misc/unwind.c deleted file mode 100644 index 9d5fc17fc71..00000000000 --- a/reactos/lib/crtdll/old cruft/misc/unwind.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * @implemented - */ -void _global_unwind2( PEXCEPTION_FRAME frame ) -{ - RtlUnwind( frame, 0, NULL, 0 ); -} - - -/* - * @implemented - */ -void _local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr ) -{ - TRACE(crtdll,"(%p,%ld)\n",endframe,nr); -} diff --git a/reactos/lib/crtdll/old cruft/process/_cwait.c b/reactos/lib/crtdll/old cruft/process/_cwait.c deleted file mode 100644 index a1e0ea89e10..00000000000 --- a/reactos/lib/crtdll/old cruft/process/_cwait.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/process/cwait.c - * PURPOSE: Waits for a process to exit - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 04/03/99: Created - */ - -#include -#include -#include -#include - - -/* - * @implemented - */ -int _cwait(int* pnStatus, int hProc, int nAction) -{ - DWORD ExitCode; - - nAction = 0; - if (WaitForSingleObject((void*)hProc, INFINITE) != WAIT_OBJECT_0) { - __set_errno(ECHILD); - return -1; - } - - if (!GetExitCodeProcess((void*)hProc, &ExitCode)) - return -1; - if (pnStatus != NULL) - *pnStatus = (int)ExitCode; - return hProc; -} diff --git a/reactos/lib/crtdll/old cruft/process/_system.c b/reactos/lib/crtdll/old cruft/process/_system.c deleted file mode 100644 index 18bea6a77fb..00000000000 --- a/reactos/lib/crtdll/old cruft/process/_system.c +++ /dev/null @@ -1,88 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/process/system.c - * PURPOSE: Excutes a shell command - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 04/03/99: Created - */ - -#include -#include -#include -#include - -/* - * @implemented - */ -int system(const char *command) -{ - char szCmdLine[MAX_PATH]; - char *szComSpec=NULL; - - - PROCESS_INFORMATION ProcessInformation; - STARTUPINFOA StartupInfo; - - int nStatus; - - szComSpec = getenv("COMSPEC"); - -// system should return 0 if command is null and the shell is found - - if ( command == NULL ) { - if ( szComSpec == NULL ) - return 0; - else - return -1; - } - - - -// should return 127 or 0 ( MS ) if the shell is not found -// __set_errno(ENOENT); - - if ( szComSpec == NULL ) - szComSpec = "cmd.exe"; - - - - strcpy(szCmdLine," /C "); - - strncat(szCmdLine,command,MAX_PATH-5); - -//check for a too long argument E2BIG - -//command file has invalid format ENOEXEC - - - StartupInfo.cb = sizeof(StartupInfo); - StartupInfo.lpReserved= NULL; - StartupInfo.dwFlags = 0; - StartupInfo.wShowWindow = SW_SHOWDEFAULT; - StartupInfo.lpReserved2 = NULL; - StartupInfo.cbReserved2 = 0; - -// According to ansi standards the new process should ignore SIGINT and SIGQUIT -// In order to disable ctr-c the process is created with CREATE_NEW_PROCESS_GROUP, -// thus SetConsoleCtrlHandler(NULL,TRUE) is made on behalf of the new process. - - -//SIGCHILD should be blocked aswell - - if ( CreateProcessA(szComSpec,szCmdLine,NULL,NULL,TRUE,CREATE_NEW_PROCESS_GROUP,NULL,NULL,&StartupInfo,&ProcessInformation) == FALSE) { - return -1; - } - - -// system should wait untill the calling process is finished - - _cwait(&nStatus,(int)ProcessInformation.hProcess,0); - -// free the comspec [ if the COMSPEC == NULL provision is removed - // free(szComSpec); - - return nStatus; -} diff --git a/reactos/lib/crtdll/old cruft/process/execl.c b/reactos/lib/crtdll/old cruft/process/execl.c deleted file mode 100644 index 08cc27b5196..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execl.c +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include - -/* - * @implemented - */ -int _execl(const char* szPath, const char* szArgv0, ...) -{ - char *szArg[100]; - const char *a; - int i = 0; - va_list l = 0; - va_start(l,szArgv0); - do { - a = va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - - return _spawnve(P_OVERLAY, szPath, szArg, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/execle.c b/reactos/lib/crtdll/old cruft/process/execle.c deleted file mode 100644 index 47fb121a796..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execle.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include - - -/* - * FIXME rewrite to pass the array variants to va_list variant - * - * @unimplemented - */ -int _execle(const char *path, const char *szArgv0, ... /*, const char **envp */) -{ - char *szArg[100]; - const char *a; - char *ptr; - int i = 0; - va_list l = 0; - va_start(l,szArgv0); - do { - a = (const char *)va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - - -// szArg0 is passed and not environment if there is only one parameter; - - if ( i >=2 ) { - ptr = szArg[i-2]; - szArg[i-2] = NULL; - } - else - ptr = NULL; - - - return _spawnve(P_OVERLAY, path, (char * const *)szArg, (char * const *)ptr); -} diff --git a/reactos/lib/crtdll/old cruft/process/execlp.c b/reactos/lib/crtdll/old cruft/process/execlp.c deleted file mode 100644 index d15461f3b2c..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execlp.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -int _execlp(const char *szPath, const char *szArgv0, ...) -{ - char *szArg[100]; - const char *a; - int i = 0; - va_list l = 0; - va_start(l,szArgv0); - do { - a = (const char *)va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - return _spawnvpe(P_OVERLAY, szPath,szArg, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/execlpe.c b/reactos/lib/crtdll/old cruft/process/execlpe.c deleted file mode 100644 index e6e6f2179ea..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execlpe.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - - -int execlpe(const char *path, const char *szArgv0, ... /*, const char **envp */) -{ - char *szArg[100]; - const char *a; - char *ptr; - int i = 0; - va_list l = 0; - va_start(l,szArgv0); - do { - a = (const char *)va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - - -// szArg0 is passed and not environment if there is only one parameter; - - if ( i >=2 ) { - ptr = szArg[i-2]; - szArg[i-2] = NULL; - } - else - ptr = NULL; - return spawnvpe(P_OVERLAY, path, (char * const *)szArg, (char * const *)ptr); -} diff --git a/reactos/lib/crtdll/old cruft/process/execv.c b/reactos/lib/crtdll/old cruft/process/execv.c deleted file mode 100644 index e1b6f7ee41c..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execv.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include - -/* - * @implemented - */ -int _execv(const char* szPath, char* const* szaArgv) -{ - return _spawnve(P_OVERLAY, szPath, szaArgv, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/execve.c b/reactos/lib/crtdll/old cruft/process/execve.c deleted file mode 100644 index a4303bd0799..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execve.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - - -/* - * @implemented - */ -int _execve(const char* szPath, char* const* szaArgv, char* const* szaEnv) -{ - return spawnve(P_OVERLAY, szPath, szaArgv, szaEnv); -} diff --git a/reactos/lib/crtdll/old cruft/process/execvp.c b/reactos/lib/crtdll/old cruft/process/execvp.c deleted file mode 100644 index 0f2ed57c611..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execvp.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details *///#include -//#include -#include -#include - -/* - * @implemented - */ -int _execvp(const char* szPath, char* const* szaArgv) -{ - return _spawnvpe(P_OVERLAY, szPath, szaArgv, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/execvpe.c b/reactos/lib/crtdll/old cruft/process/execvpe.c deleted file mode 100644 index f02f35a686d..00000000000 --- a/reactos/lib/crtdll/old cruft/process/execvpe.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - - -#include - -/* - * @implemented - */ -int _execvpe(const char* szPath, char* const* szaArgv, char* const* szaEnv) -{ - return _spawnvpe(P_OVERLAY, szPath, szaArgv, szaEnv); -} - - diff --git a/reactos/lib/crtdll/old cruft/process/spawnl.c b/reactos/lib/crtdll/old cruft/process/spawnl.c deleted file mode 100644 index d37eec4ccc9..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnl.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include - - -/* - * @implemented - */ -int _spawnl(int nMode, const char* szPath, const char* szArgv0,...) -{ - char* szArg[100]; - const char* a; - int i = 1; - va_list l = 0; - szArg[0]=(char*)szArgv0; - va_start(l,szArgv0); - do { - a = va_arg(l, const char*); - szArg[i++] = (char*)a; - } while (a != NULL && i < 100); - - return _spawnve(nMode, szPath, szArg, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnle.c b/reactos/lib/crtdll/old cruft/process/spawnle.c deleted file mode 100644 index 74ac71f18e8..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnle.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - */ -int _spawnle(int mode, const char *path, const char *szArgv0, ... /*, const char **envp */) -{ - char *szArg[100]; - char *a; - char *ptr; - int i = 1; - va_list l = 0; - szArg[0]=(char*)szArgv0; - va_start(l,szArgv0); - do { - a = (char *)va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - - if(a != NULL) - { -// __set_errno(E2BIG); - return -1; - } - - ptr = (char *)va_arg(l,const char *); - - return _spawnve(mode, path, (char * const *)szArg, (char * const *)ptr); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnlp.c b/reactos/lib/crtdll/old cruft/process/spawnlp.c deleted file mode 100644 index e7beb0043e7..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnlp.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include - -/* - * @implemented - */ -int _spawnlp(int nMode, const char* szPath, const char* szArgv0, ...) -{ - char *szArg[100]; - const char *a; - int i = 0; - va_list l = 0; - va_start(l,szArgv0); - do { - a = (const char *)va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - return _spawnvpe(nMode, szPath,szArg, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnlpe.c b/reactos/lib/crtdll/old cruft/process/spawnlpe.c deleted file mode 100644 index 7c07cff7c8a..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnlpe.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - - -/* - * @implemented - */ -int _spawnlpe(int mode, const char *path, const char *szArgv0, ... /*, const char **envp */) -{ - char *szArg[100]; - const char *a; - char *ptr; - int i = 0; - va_list l = 0; - va_start(l,szArgv0); - do { - a = (const char *)va_arg(l,const char *); - szArg[i++] = (char *)a; - } while ( a != NULL && i < 100 ); - - -// szArg0 is passed and not environment if there is only one parameter; - - if ( i >=2 ) { - ptr = szArg[i-2]; - szArg[i-2] = NULL; - } - else - ptr = NULL; - - return _spawnvpe(mode, path, (char * const *)szArg, (char * const *)ptr); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnv.c b/reactos/lib/crtdll/old cruft/process/spawnv.c deleted file mode 100644 index c9186316f2b..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnv.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include - -/* - * @implemented - */ -int _spawnv(int nMode, const char* szPath, char* const* szaArgv) -{ - return _spawnve(nMode, szPath, (char * const *)szaArgv, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnve.c b/reactos/lib/crtdll/old cruft/process/spawnve.c deleted file mode 100644 index 78a4adb9098..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnve.c +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifndef F_OK - #define F_OK 0x01 -#endif -#ifndef R_OK - #define R_OK 0x02 -#endif -#ifndef W_OK - #define W_OK 0x04 -#endif -#ifndef X_OK - #define X_OK 0x08 -#endif -#ifndef D_OK - #define D_OK 0x10 -#endif - -// information about crtdll file handles is not passed to child -int _fileinfo_dll = 0; - -static int -direct_exec_tail(const char* program, const char* args, - char* const envp[], - PROCESS_INFORMATION* ProcessInformation) -{ - static STARTUPINFOA StartupInfo; - - StartupInfo.cb = sizeof(StartupInfo); - StartupInfo.lpReserved= NULL; - StartupInfo.dwFlags = 0; - StartupInfo.wShowWindow = SW_SHOWDEFAULT; - StartupInfo.lpReserved2 = NULL; - StartupInfo.cbReserved2 = 0; - if (!CreateProcessA((char*)program,(char*)args,NULL,NULL,FALSE,0,(char**)envp,NULL,&StartupInfo,ProcessInformation)) { - __set_errno( GetLastError() ); - return -1; - } - return (int)ProcessInformation->hProcess; -} - -static int vdm_exec(const char* program, char** argv, char** envp, - PROCESS_INFORMATION* ProcessInformation) -{ - static char args[1024]; - int i = 0; - args[0] = 0; - - strcpy(args, "vdm.exe "); - while (argv[i] != NULL) { - strcat(args, argv[i]); - strcat(args, " "); - i++; - } - return direct_exec_tail(program,args,envp,ProcessInformation); -} - -static int go32_exec(const char* program, char** argv, char** envp, - PROCESS_INFORMATION* ProcessInformation) -{ - static char args[1024]; - static char envblock[2048]; - char* penvblock; - int i = 0; - - envblock[0] = 0; - penvblock=envblock; - while(envp[i] != NULL ) { - strcat(penvblock,envp[i]); - penvblock+=strlen(envp[i])+1; - i++; - } - penvblock[0]=0; - args[0] = 0; - i = 0; - while(argv[i] != NULL ) { - strcat(args,argv[i]); - strcat(args," "); - i++; - } - return direct_exec_tail(program,args,envp,ProcessInformation); -} - -int command_exec(const char* program, char** argv, char** envp, - PROCESS_INFORMATION* ProcessInformation) -{ - static char args[1024]; - int i = 0; - - args[0] = 0; - strcpy(args,"cmd.exe /c "); - while(argv[i] != NULL ) { - strcat(args,argv[i]); - strcat(args," "); - i++; - } - return direct_exec_tail(program,args,envp,ProcessInformation); -} - -static int script_exec(const char* program, char** argv, char** envp, - PROCESS_INFORMATION* ProcessInformation) -{ - return 0; -} - - -/* Note: the following list is not supposed to mention *every* - possible extension of an executable file. It only mentions - those extensions that can be *omitted* when you invoke the - executable from one of the shells used on MSDOS. */ -static struct { - const char* extension; - int (*interp)(const char*, char**, char**, PROCESS_INFORMATION*); -} interpreters[] = { - { ".com", vdm_exec }, - { ".exe", go32_exec }, - { ".dll", go32_exec }, - { ".cmd", command_exec }, - { ".bat", command_exec }, - { ".btm", command_exec }, - { ".sh", script_exec }, /* for compatibility with ms_sh */ - { ".ksh", script_exec }, - { ".pl", script_exec }, /* Perl */ - { ".sed", script_exec }, - { "", go32_exec }, - { 0, script_exec }, /* every extension not mentioned above calls it */ - { 0, 0 }, -}; - -/* This is the index into the above array of the interpreter - which is called when the program filename has no extension. */ -#define INTERP_NO_EXT (sizeof(interpreters)/sizeof(interpreters[0]) - 3) - -/*-------------------------------------------------*/ - -/* - * @implemented - */ -int _spawnve(int mode, const char* path, char* const argv[], char* const envp[]) -{ - /* This is the one that does the work! */ - PROCESS_INFORMATION ProcessInformation; - union { char* const* x; char** p; } u; - int i = -1; - char** argvp; - char** envpp; - char rpath[FILENAME_MAX], *rp, *rd = 0; - int e = errno; - int is_dir = 0; - int found = 0; - DWORD ExitCode; - - if (path == 0 || argv[0] == 0) { - errno = EINVAL; - return -1; - } - if (strlen(path) > FILENAME_MAX - 1) { - errno = ENAMETOOLONG; - return -1; - } - u.x = argv; argvp = u.p; - u.x = envp; envpp = u.p; - fflush(stdout); /* just in case */ - for (rp=rpath; *path; *rp++ = *path++) { - if (*path == '.') - rd = rp; - if (*path == '\\' || *path == '/') - rd = 0; - } - *rp = 0; - - /* If LFN is supported on the volume where rpath resides, we - might have something like foo.bar.exe or even foo.exe.com. - If so, look for RPATH.ext before even trying RPATH itself. */ - if (!rd) { - for (i=0; interpreters[i].extension; i++) { - strcpy(rp, interpreters[i].extension); - if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0))) { - found = 1; - break; - } - } - } - - if (!found) { - const char *rpath_ext; - - if (rd) { - i = 0; - rpath_ext = rd; - } else { - i = INTERP_NO_EXT; - rpath_ext = ""; - } - for ( ; interpreters[i].extension; i++) - if (_stricmp(rpath_ext, interpreters[i].extension) == 0 - && _access(rpath, F_OK) == 0 - && !(is_dir = (_access(rpath, D_OK) == 0))) - { - found = 1; - break; - } - } - if (!found) { - errno = is_dir ? EISDIR : ENOENT; - return -1; - } - errno = e; - i = interpreters[i].interp(rpath, argvp, envpp, &ProcessInformation); - if (mode == P_OVERLAY) - exit(i); - if (mode == P_WAIT) { - WaitForSingleObject(ProcessInformation.hProcess,INFINITE); - GetExitCodeProcess(ProcessInformation.hProcess,&ExitCode); - i = (int)ExitCode; - } - return i; -} - -const char* find_exec(char* path, char* rpath) -{ - char *rp, *rd=0; - int i; - int is_dir = 0; - int found = 0; - - if (path == 0 ) - return 0; - if (strlen(path) > FILENAME_MAX - 1) - return path; - - /* copy path in rpath */ - for (rd=path,rp=rpath; *rd; *rp++ = *rd++) - ; - *rp = 0; - /* try first with the name as is */ - for (i=0; interpreters[i].extension; i++) { - strcpy(rp, interpreters[i].extension); - if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0))) { - found = 1; - break; - } - } - if (!found) { - /* search in the PATH */ - char winpath[MAX_PATH]; - if (GetEnvironmentVariableA("PATH", winpath, MAX_PATH)) { - char* ep = winpath; - while (*ep) { - if (*ep == ';') ep++; - rp = rpath; - for ( ; *ep && (*ep != ';') ; *rp++ = *ep++) - ; - *rp++ = '/'; - for (rd = path ; *rd ; *rp++ = *rd++) - ; - for (i = 0; interpreters[i].extension; i++) { - strcpy(rp, interpreters[i].extension); - if (_access(rpath, F_OK) == 0 && !(is_dir = (_access(rpath, D_OK) == 0))) { - found = 1; - break; - } - } - if (found) break; - } - } - } - if (!found) - return path; - return rpath; -} - -/* - * @implemented - */ -int _spawnvpe(int nMode, const char* szPath, char* const* szaArgv, char* const* szaEnv) -{ - char rpath[FILENAME_MAX]; - - return _spawnve(nMode, find_exec((char*)szPath,rpath), szaArgv, szaEnv); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnvp.c b/reactos/lib/crtdll/old cruft/process/spawnvp.c deleted file mode 100644 index 0a6bacc7426..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnvp.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include - -/* - * @implemented - */ -int _spawnvp(int nMode, const char* szPath, char* const* szaArgv) -{ - return spawnvpe(nMode, szPath, (char * const *)szaArgv, _environ); -} diff --git a/reactos/lib/crtdll/old cruft/process/spawnvpe.c b/reactos/lib/crtdll/old cruft/process/spawnvpe.c deleted file mode 100644 index 042be0ad7cf..00000000000 --- a/reactos/lib/crtdll/old cruft/process/spawnvpe.c +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include - - -/* - * @implemented - */ -int _spawnvpe(int nMode, const char* szPath, char* const* szaArgv, char* const* szaEnv) -{ - - return spawnve(nMode, szPath, szaArgv, szaEnv); - -} diff --git a/reactos/lib/crtdll/old cruft/process/thread.c b/reactos/lib/crtdll/old cruft/process/thread.c deleted file mode 100644 index 3a8d3b32ad4..00000000000 --- a/reactos/lib/crtdll/old cruft/process/thread.c +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id$ - * - */ - -#include -#include -#include -#include - - -/* - * @implemented - */ -unsigned long _beginthread( - void (*pfuncStart)(void*), - unsigned unStackSize, - void* pArgList) -{ - DWORD ThreadId; - HANDLE hThread; - if ( pfuncStart == NULL ) - __set_errno(EINVAL); - - hThread = CreateThread( NULL,unStackSize,(LPTHREAD_START_ROUTINE)pfuncStart,pArgList,0, &ThreadId); - if (hThread == NULL ) { - __set_errno(EAGAIN); - return -1; - } - return (unsigned long)hThread; -} - -/* - * @unimplemented - */ -void _endthread(void) -{ - //fixme ExitThread - //ExitThread(0); - for(;;); -} diff --git a/reactos/lib/crtdll/old cruft/readme.txt b/reactos/lib/crtdll/old cruft/readme.txt deleted file mode 100644 index fd3673fffd4..00000000000 --- a/reactos/lib/crtdll/old cruft/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -When merging msvcrt and crtdll into crt, mostly msvcrt stuff were used. All files in crtdll that was equal to files in msvcrt were deleted but those who were not are still here, possibly containing changes that we might want to merge into crt, thou its very likely that the changes are worthless. Someone should go thru it and either delete or merge sometime... --Gunnar diff --git a/reactos/lib/crtdll/old cruft/setjmp/setjmp.c b/reactos/lib/crtdll/old cruft/setjmp/setjmp.c deleted file mode 100644 index 6234c33a450..00000000000 --- a/reactos/lib/crtdll/old cruft/setjmp/setjmp.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* modified by Boudewijn Dekker */ -/* ms uses a smaller jmp_buf structure */ -/* might do a realloc in setjmp */ - -typedef struct { - unsigned int __eax, __ebx, __ecx, __edx, __esi; - unsigned int __edi, __ebp, __esp, __eip, __eflags; - unsigned short __cs, __ds, __es, __fs, __gs, __ss; - unsigned long __sigmask; /* for POSIX signals only */ - unsigned long __signum; /* for expansion */ - unsigned long __exception_ptr; /* pointer to previous exception */ - unsigned char __fpu_state[108]; /* for future use */ -} jmp_buf[1]; - - -/* jumps back to position specified in jmp_buf */ - -/* - * @implemented - */ -int longjmp( jmp_buf env, int value ) -{ - //push ebp generated by the compiler - //mov ebp, esp - -#ifdef __GNUC__ - __asm__ __volatile__ ( - "movl 8(%ebp),%edi\n\t" /* get jmp_buf */ - "movl 12(%ebp),%eax\n\t" /* store retval in j->eax */ - "movl %eax,0(%edi)\n\t" - - "movw 46(%edi),%fs\n\t" - "movw 48(%edi),%gs\n\t" - "movl 4(%edi),%ebx\n\t" - "movl 8(%edi),%ecx\n\t" - "movl 12(%edi),%edx\n\t" - "movl 24(%edi),%ebp\n\t" - - /* Now for some uglyness. The jmp_buf structure may be ABOVE the - point on the new SS:ESP we are moving to. We don't allow overlap, - but do force that it always be valid. We will use ES:ESI for - our new stack before swapping to it. */ - - "movw 50(%edi),%es\n\t" - "movl 28(%edi),%esi\n\t" - "subl $28,%esi\n\t" /* We need 7 working longwords on stack */ - - "movl 60(%edi),%eax\n\t" - "es\n\t" - "movl %eax,(%esi)\n\t" /* Exception pointer */ - - "movzwl 42(%edi),%eax\n\t" - "es\n\t" - "movl %eax,4(%esi)\n\t" /* DS */ - - "movl 20(%edi),%eax\n\t" - "es\n\t" - "movl %eax,8(%esi)\n\t" /* EDI */ - - "movl 16(%edi),%eax\n\t" - "es\n\t" - "movl %eax,12(%esi)\n\t" /* ESI */ - - "movl 32(%edi),%eax\n\t" - "es\n\t" - "movl %eax,16(%esi)\n\t" /* EIP - start of IRET frame */ - - "movl 40(%edi),%eax\n\t" - "es\n\t" - "movl %eax,20(%esi)\n\t" /* CS */ - - "movl 36(%edi),%eax\n\t" - "es\n\t" - "movl %eax,24(%esi)\n\t" /* EFLAGS */ - - "movl 0(%edi),%eax\n\t" - "movw 44(%edi),%es\n\t" - - "movw 50(%edi),%ss\n\t" - "movl %esi,%esp\n\t" - - //"popl ___djgpp_exception_state_ptr\n\t" - "popl %edi\n\t" // dummy popl instead of djgpp_exception_state_ptr - "popl %ds\n\t" - "popl %edi\n\t" - "popl %esi\n\t" - - "iret\n\t" /* actually jump to new cs:eip loading flags */ - ); - -#else -#endif /*__GNUC__*/ - return value; // dummy return never reached -} - -#ifdef __GNUC__ - -/* - * @implemented - */ -int _setjmp( jmp_buf env ) -{ - //push ebp generated by the compiler - //mov ebp, esp - __asm__ __volatile__ ( - "pushl %edi\n\t" - "movl 8(%ebp),%edi\n\t" - - "movl %eax, (%edi)\n\t" - "movl %ebx,4(%edi)\n\t" - "movl %ecx,8(%edi)\n\t" - "movl %edx,12(%edi)\n\t" - "movl %esi,16(%edi)\n\t" - - "movl -4(%ebp),%eax\n\t" - "movl %eax,20(%edi)\n\t" - - "movl (%ebp),%eax\n\t" - "movl %eax,24(%edi)\n\t" - - "movl %esp,%eax\n\t" - "addl $12,%eax\n\t" - "movl %eax,28(%edi)\n\t" - - "movl 4(%ebp),%eax\n\t" - "movl %eax,32(%edi)\n\t" - - "pushfl\n\t" - "popl 36(%edi)\n\t" - - "movw %cs, 40(%edi)\n\t" - "movw %ds, 42(%edi)\n\t" - "movw %es, 44(%edi)\n\t" - "movw %fs, 46(%edi)\n\t" - "movw %gs, 48(%edi)\n\t" - "movw %ss, 50(%edi)\n\t" - - //movl ___djgpp_exception_state_ptr, %eax - //movl %eax, 60(%edi) - - "popl %edi\n\t" - ); - return 0; -} - -#else -#endif /*__GNUC__*/ diff --git a/reactos/lib/crtdll/old cruft/stdio/FILE.DOC b/reactos/lib/crtdll/old cruft/stdio/FILE.DOC deleted file mode 100644 index a4367326563..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/FILE.DOC +++ /dev/null @@ -1,43 +0,0 @@ -meaning of struct FILE* members - -int _cnt; - -W: number of empty slots left in the buffer. -R: number of characters left in the buffer. - -char *_ptr; - -pointer inside the buffer we're using. -R: points to next character to read out. -W: points to next cell to put character in. - -char *_base; - -pointer to the start of the buffer we're using. - -int _bufsiz; - -size of the buffer - -int _flag; - -_IORW file is used for both read and write -_IOWRT file is opened for write -_IOREAD file is opened for read -_IOMYBUF buffer needs to be freed -_IOEOF file is at EOF -_IOERR error occurred -_IOSTRG sprintf -_IOAPPEND append mode -_IORMONCL remove file on close -_IOUNGETC buffer contents does not correspond to file - -int _file; - -dos file descriptor - -char *_name_to_remove; - -If nonzero, the named file is removed when the file is fclosed. - - diff --git a/reactos/lib/crtdll/old cruft/stdio/doscan.c b/reactos/lib/crtdll/old cruft/stdio/doscan.c deleted file mode 100644 index 09868e22217..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/doscan.c +++ /dev/null @@ -1,409 +0,0 @@ -/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include - - -#define atold atof - -// dubious variable -//static int _fltused = 0; - -int -_doscan_low(FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), - const char *fmt, va_list argp); - -//#include - -#define SPC 01 -#define STP 02 - -#define SHORT 0 -#define REGULAR 1 -#define LONG 2 -#define LONGDOUBLE 4 -#define INT 0 -#define FLOAT 1 - - - -static int _innum(int **ptr, int type, int len, int size, FILE *iop, - int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), - int *eofptr); -static int _instr(char *ptr, int type, int len, FILE *iop, - int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), - int *eofptr); -static const char *_getccl(const unsigned char *s); - -static char _sctab[256] = { - 0,0,0,0,0,0,0,0, - 0,SPC,SPC,SPC,SPC,SPC,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - SPC,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, -}; - -static int nchars = 0; - -int -_doscan(FILE *iop, const char *fmt, va_list argp) -{ - return(_doscan_low(iop, fgetc, ungetc, fmt, argp)); -} - -int -_dowscan(FILE *iop, const wchar_t *fmt, va_list argp) -{ - return(_doscan_low(iop, fgetwc, ((void *)ungetwc), ((void *)fmt), argp)); -} - -int -_doscan_low(FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), - const char *fmt, va_list argp) -{ - register int ch; - int nmatch, len, ch1; - int **ptr, fileended, size; - - nchars = 0; - nmatch = 0; - fileended = 0; - for (;;) switch (ch = *fmt++) { - case '\0': - return (nmatch); - case '%': - if ((ch = *fmt++) == '%') - goto def; - ptr = 0; - if (ch != '*') - ptr = va_arg(argp, int **); - else - ch = *fmt++; - len = 0; - size = REGULAR; - while (isdigit(ch)) { - len = len*10 + ch - '0'; - ch = *fmt++; - } - if (len == 0) - len = 30000; - - if (ch=='l') - { - size = LONG; - ch = *fmt++; - if (ch=='l') - { - size = LONGDOUBLE; /* for long long 'll' format */ - ch = *fmt++; - } - } - else if (ch=='h') { - size = SHORT; - ch = *fmt++; - } else if (ch=='L') { - size = LONGDOUBLE; - ch = *fmt++; - } else if (ch=='[') - fmt = _getccl((const unsigned char *)fmt); - if (isupper(ch)) { - /* ch = tolower(ch); - gcc gives warning: ANSI C forbids braced - groups within expressions */ - ch += 'a' - 'A'; - if (size==LONG) - size = LONGDOUBLE; - else if (size != LONGDOUBLE) - size = LONG; - } - if (ch == '\0') - return(-1); - - if (ch == 'n') - { - if (!ptr) - break; - if (size==LONG) - **(long**)ptr = nchars; - else if (size==SHORT) - **(short**)ptr = nchars; - else if (size==LONGDOUBLE) - **(long**)ptr = nchars; - else - **(int**)ptr = nchars; - break; - } - - if (_innum(ptr, ch, len, size, iop, scan_getc, scan_ungetc, - &fileended)) - { - if (ptr) - nmatch++; - } - else - { - if (fileended && nmatch==0) - return(-1); - return(nmatch); - } - break; - case ' ': - case '\n': - case '\t': - case '\r': - case '\f': - case '\v': - while (((nchars++, ch1 = scan_getc(iop))!=EOF) && (_sctab[ch1] & SPC)) - ; - if (ch1 != EOF) - { - scan_ungetc(ch1, iop); - } - nchars--; - break; - - default: - def: - ch1 = scan_getc(iop); - if (ch1 != EOF) nchars++; - if (ch1 != ch) { - if (ch1==EOF) - return(nmatch? nmatch: -1); - scan_ungetc(ch1, iop); - nchars--; - return(nmatch); - } - } -} - -static int -_innum(int **ptr, int type, int len, int size, FILE *iop, - int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr) -{ - register char *np; - char numbuf[64]; - register int c, base; - int expseen, scale, negflg, c1, ndigit; - long lcval; - int cpos; - - if (type=='c' || type=='s' || type=='[') - return(_instr(ptr? *(char **)ptr: (char *)NULL, type, len, - iop, scan_getc, scan_ungetc, eofptr)); - lcval = 0; - ndigit = 0; - scale = INT; - if (type=='e'||type=='f'||type=='g') - scale = FLOAT; - base = 10; - if (type=='o') - base = 8; - else if (type=='x') - base = 16; - np = numbuf; - expseen = 0; - negflg = 0; - while (((nchars++, c = scan_getc(iop)) != EOF) && (_sctab[c] & SPC) ) - ; - if (c == EOF) nchars--; - if (c=='-') { - negflg++; - *np++ = c; - c = scan_getc(iop); - nchars++; - len--; - } else if (c=='+') { - len--; - c = scan_getc(iop); - nchars++; - } - cpos = 0; - for ( ; --len>=0; *np++ = c, c = scan_getc(iop), nchars++) { - cpos++; - if (c == '0' && cpos == 1 && type == 'i') - base = 8; - if ((c == 'x' || c == 'X') && (type == 'i' || type == 'x') - && cpos == 2 && lcval == 0) - { - base = 16; - continue; - } - if (isdigit(c) - || (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) { - ndigit++; - if (base==8) - lcval <<=3; - else if (base==10) - lcval = ((lcval<<2) + lcval)<<1; - else - lcval <<= 4; - c1 = c; - if (isdigit(c)) - c -= '0'; - else if ('a'<=c && c<='f') - c -= 'a'-10; - else - c -= 'A'-10; - lcval += c; - c = c1; - continue; - } else if (c=='.') { - if (base!=10 || scale==INT) - break; - ndigit++; - continue; - } else if ((c=='e'||c=='E') && expseen==0) { - if (base!=10 || scale==INT || ndigit==0) - break; - expseen++; - *np++ = c; - c = scan_getc(iop); - nchars++; - if (c!='+'&&c!='-'&&('0'>c||c>'9')) - break; - } else - break; - } - if (negflg) - lcval = -lcval; - if (c != EOF) { - scan_ungetc(c, iop); - *eofptr = 0; - } else - *eofptr = 1; - nchars--; - if (np==numbuf || (negflg && np==numbuf+1) ) /* gene dykes*/ - return(0); - if (ptr==NULL) - return(1); - *np++ = 0; - switch((scale<<4) | size) { - - case (FLOAT<<4) | SHORT: - case (FLOAT<<4) | REGULAR: - **(float **)ptr = (float)atof(numbuf); - break; - - case (FLOAT<<4) | LONG: - **(double **)ptr = atof(numbuf); - break; - - case (FLOAT<<4) | LONGDOUBLE: - **(long double **)ptr = atold(numbuf); - break; - - case (INT<<4) | SHORT: - **(short **)ptr = (short)lcval; - break; - - case (INT<<4) | REGULAR: - **(int **)ptr = (int)lcval; - break; - - case (INT<<4) | LONG: - **(long **)ptr = lcval; - break; - - case (INT<<4) | LONGDOUBLE: - **(long **)ptr = lcval; - break; - } - return(1); -} - -static int -_instr(char *ptr, int type, int len, FILE *iop, - int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr) -{ - register int ch; - register char *optr; - int ignstp; - - *eofptr = 0; - optr = ptr; - if (type=='c' && len==30000) - len = 1; - ignstp = 0; - if (type=='s') - ignstp = SPC; - while ((nchars++, ch = scan_getc(iop)) != EOF && _sctab[ch] & ignstp) - ; - ignstp = SPC; - if (type=='c') - ignstp = 0; - else if (type=='[') - ignstp = STP; - while (ch!=EOF && (_sctab[ch]&ignstp)==0) { - if (ptr) - *ptr++ = ch; - if (--len <= 0) - break; - ch = scan_getc(iop); - nchars++; - } - if (ch != EOF) { - if (len > 0) - { - scan_ungetc(ch, iop); - nchars--; - } - *eofptr = 0; - } else - { - nchars--; - *eofptr = 1; - } - if (!ptr) - return(1); - if (ptr!=optr) { - if (type!='c') - *ptr++ = '\0'; - return(1); - } - return(0); -} - -static const char * -_getccl(const unsigned char *s) -{ - register int c, t; - - t = 0; - if (*s == '^') { - t++; - s++; - } - for (c = 0; c < (sizeof _sctab / sizeof _sctab[0]); c++) - if (t) - _sctab[c] &= ~STP; - else - _sctab[c] |= STP; - if ((c = *s) == ']' || c == '-') { /* first char is special */ - if (t) - _sctab[c] |= STP; - else - _sctab[c] &= ~STP; - s++; - } - while ((c = *s++) != ']') { - if (c==0) - return((const char *)--s); - else if (c == '-' && *s != ']' && s[-2] < *s) { - for (c = s[-2] + 1; c < *s; c++) - if (t) - _sctab[c] |= STP; - else - _sctab[c] &= ~STP; - } else if (t) - _sctab[c] |= STP; - else - _sctab[c] &= ~STP; - } - return((const char *)s); -} diff --git a/reactos/lib/crtdll/old cruft/stdio/fgetws.c b/reactos/lib/crtdll/old cruft/stdio/fgetws.c deleted file mode 100644 index 282b8fc8a8c..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/fgetws.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -//wchar_t* fgetws(wchar_t* wcaBuffer, int nBufferSize, FILE* fileRead); -//char* fgets(char *s, int n, FILE *f); -//int _getw(FILE *stream); -/* -// Read a word (int) from STREAM. -int _getw(FILE *stream) -{ - int w; - - // Is there a better way? - if (fread( &w, sizeof(w), 1, stream) != 1) - return(EOF); - return(w); -} - -//getc can be a macro -#undef getc - -int getc(FILE *fp) -{ - int c = -1; -// check for invalid stream - if ( !__validfp (fp) ) { - __set_errno(EINVAL); - return EOF; - } -// check for read access on stream - if ( !OPEN4READING(fp) ) { - __set_errno(EINVAL); - return -1; - } - if(fp->_cnt > 0) { - fp->_cnt--; - c = (int)*fp->_ptr++; - } - else { - c = _filbuf(fp); - } - return c; -} - */ - -wchar_t* fgetws(wchar_t* s, int n, FILE* f) -{ - int c = 0; - wchar_t* cs; - - cs = s; - while (--n > 0 && (c = _getw(f)) != EOF) { - *cs++ = c; - if (c == L'\n') - break; - } - if (c == EOF && cs == s) { - return NULL; - } - *cs++ = L'\0'; - return s; -} diff --git a/reactos/lib/crtdll/old cruft/stdio/filbuf.c b/reactos/lib/crtdll/old cruft/stdio/filbuf.c deleted file mode 100644 index b059f60142e..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/filbuf.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include -#include -#include -#include -#include -#include - -int _readcnv(int fn, void *buf, size_t siz ); - -/* - * @implemented - */ -int -_filbuf(FILE *f) -{ - int size; - char c; - - - if ( !OPEN4READING(f)) { - __set_errno (EINVAL); - return EOF; - } - - - if (f->_flag&(_IOSTRG|_IOEOF)) - return EOF; - f->_flag &= ~_IOUNGETC; - - if (f->_base==NULL && (f->_flag&_IONBF)==0) { - size = 4096; - if ((f->_base = malloc(size+1)) == NULL) - { - // error ENOMEM - f->_flag |= _IONBF; - f->_flag &= ~(_IOFBF|_IOLBF); - } - else - { - f->_flag |= _IOMYBUF; - f->_bufsiz = size; - } - } - - - if (f->_flag&_IONBF) - f->_base = &c; - - -// fush stdout before reading from stdin - if (f == stdin) { - if (stdout->_flag&_IOLBF) - fflush(stdout); - if (stderr->_flag&_IOLBF) - fflush(stderr); - } - -// if we have a dirty stream we flush it - if ( (f->_flag &_IODIRTY) == _IODIRTY ) - fflush(f); - - - - f->_cnt = _read(fileno(f), f->_base, f->_flag & _IONBF ? 1 : f->_bufsiz ); - f->_flag |= _IOAHEAD; - - if(__is_text_file(f) && f->_cnt>0) - { - /* truncate text file at Ctrl-Z */ - char *cz=memchr(f->_base, 0x1A, f->_cnt); - if(cz) - { - int newcnt = cz - f->_base; - lseek(fileno(f), -(f->_cnt - newcnt), SEEK_CUR); - f->_cnt = newcnt; - } - } - - f->_ptr = f->_base; - - if (f->_flag & _IONBF) - f->_base = NULL; // statically allocated buffer for sprintf - - -//check for error - if (--f->_cnt < 0) { - if (f->_cnt == -1) { - f->_flag |= _IOEOF; - } else - f->_flag |= _IOERR; - f->_cnt = 0; - -// should set errno - - return EOF; - } - - f->_cnt--; - return *f->_ptr++ & 0377; -} - -wint_t _filwbuf(FILE *fp) -{ - return (wint_t )_filbuf(fp); -} - -// convert the carriage return line feed pairs - -int _readcnv(int fn, void *buf, size_t siz ) -{ - char *bufp = (char *)buf; - int _bufsiz = siz; - int cr = 0; - int n; - - n = _read(fn, buf, siz ); - - while (_bufsiz > 0) { - if (*bufp == '\r') - cr++; - else if ( cr != 0 ) - *bufp = *(bufp + cr); - bufp++; - _bufsiz--; - } - return n + cr; -} - diff --git a/reactos/lib/crtdll/old cruft/stdio/flsbuf.c b/reactos/lib/crtdll/old cruft/stdio/flsbuf.c deleted file mode 100644 index 8585237bd26..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/flsbuf.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include -#include -#include -#include -#include - - -int cntcr(char *bufp, int bufsiz); -int convert(char *endp, int bufsiz,int n); -int _writecnv(int fn, void *buf, size_t bufsiz); - - -/* - * @implemented - */ -int _flsbuf(int c, FILE *f) -{ - char *base; - int n, rn; - char c1; - int size; - - if (!OPEN4WRITING(f)) { - __set_errno (EINVAL); - return EOF; - } - - // no file associated with buffer, this is a memory stream - if (fileno(f) == -1) { - return c; - } - - /* if the buffer is not yet allocated, allocate it */ - if ((base = f->_base) == NULL && (f->_flag & _IONBF) == 0) { - size = 4096; - if ((f->_base = base = malloc (size)) == NULL) { - f->_flag |= _IONBF; - f->_flag &= ~(_IOFBF|_IOLBF); - } else { - f->_flag |= _IOMYBUF; - f->_cnt = f->_bufsiz = size; - f->_ptr = base; - rn = 0; - if (f == stdout && isatty (fileno (stdout))) { - f->_flag |= _IOLBF; - } - } - } - - if (f->_flag & _IOLBF) { - /* in line-buffering mode we get here on each character */ - *f->_ptr++ = c; - rn = f->_ptr - base; - if (c == '\n' || rn >= f->_bufsiz) { - /* time for real flush */ - f->_ptr = base; - f->_cnt = 0; - } else { - /* we got here because _cnt is wrong, so fix it */ - /* Negative _cnt causes all output functions to call */ - /* _flsbuf for each character, thus realizing line-buffering */ - f->_cnt = -rn; - return c; - } - } else if (f->_flag & _IONBF) { - c1 = c; - rn = 1; - base = &c1; - f->_cnt = 0; - } else { /* _IOFBF */ - rn = f->_ptr - base; - f->_ptr = base; - if ( (f->_flag & _IOAHEAD) == _IOAHEAD ) - _lseek(fileno(f),-(rn+f->_cnt), SEEK_CUR); - f->_cnt = f->_bufsiz; - f->_flag &= ~_IOAHEAD; - } - f->_flag &= ~_IODIRTY; - while (rn > 0) { - n = _write(fileno(f), base, rn); - if (n <= 0) { - f->_flag |= _IOERR; - return EOF; - } - rn -= n; - base += n; - } - if ((f->_flag&(_IOLBF|_IONBF)) == 0) { - f->_cnt--; - *f->_ptr++ = c; - } - return c; -} - -wint_t _flswbuf(wchar_t c,FILE *fp) -{ - int result; - - result = _flsbuf((int)c, fp); - if (result == EOF) - return WEOF; - return (wint_t)result; -} - -int _writecnv(int fn, void *buf, size_t siz) -{ - char *bufp = (char *)buf; - int bufsiz = siz; - char *tmp; - int cr1 = 0; - int cr2 = 0; - int n; - - cr1 = cntcr(bufp,bufsiz); - tmp = malloc(cr1); - memcpy(tmp,bufp+bufsiz-cr1,cr1); - cr2 = cntcr(tmp,cr1); - convert(bufp,bufsiz-cr2,cr1-cr2); - n = _write(fn, bufp, bufsiz + cr1); - convert(tmp,cr1,cr2); - n += _write(fn, tmp, cr1 + cr2); - free(tmp); - return n; -} - -int convert(char *endp, int bufsiz,int n) -{ - endp = endp + bufsiz + n; - while (bufsiz > 0) { - *endp = *(endp - n); - if (*endp == '\n') { - *endp--; - n--; - *endp = '\r'; - } - endp--; - bufsiz--; - } - return n; -} - -int cntcr(char *bufp, int bufsiz) -{ - int cr = 0; - - while (bufsiz > 0) { - if (*bufp == '\n') { - cr++; - } - bufp++; - bufsiz--; - } - return cr; -} diff --git a/reactos/lib/crtdll/old cruft/stdio/fputchar.c b/reactos/lib/crtdll/old cruft/stdio/fputchar.c deleted file mode 100644 index abe1f92ca5a..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/fputchar.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -/* - * @implemented - */ -int _fputchar (int c) -{ - return _putch(c); -} - -/* - * @unimplemented - */ -int _fputwchar (wchar_t c) -{ - //return _putch(c); - return 0; -} - diff --git a/reactos/lib/crtdll/old cruft/stdio/fputws.c b/reactos/lib/crtdll/old cruft/stdio/fputws.c deleted file mode 100644 index 79fb80c9eb9..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/fputws.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include -#include - -//int fputws(const wchar_t* wsOutput, FILE* fileWrite) -//int fputs(const char *s, FILE *f) - -int -fputws(const wchar_t* s, FILE* f) -{ - int r = 0; - int c; - int unbuffered; - wchar_t localbuf[BUFSIZ]; - - unbuffered = f->_flag & _IONBF; - if (unbuffered) - { - f->_flag &= ~_IONBF; - f->_ptr = f->_base = localbuf; - f->_bufsiz = BUFSIZ; - } - - while ((c = *s++)) - r = putwc(c, f); - - if (unbuffered) - { - fflush(f); - f->_flag |= _IONBF; - f->_base = NULL; - f->_bufsiz = 0; - f->_cnt = 0; - } - return(r); -} diff --git a/reactos/lib/crtdll/old cruft/stdio/fread.c b/reactos/lib/crtdll/old cruft/stdio/fread.c deleted file mode 100644 index 4db96a352f1..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/fread.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include -#include - - -// carriage return line feed conversion is done in filbuf and flsbuf -#if 0 -/* - * @unimplemented - */ -size_t -fread(void *p, size_t size, size_t count, FILE *iop) -{ - char *ptr = (char *)p; - int to_read; - - to_read = size * count; - - - - while ( to_read > 0 ) { - *ptr = getc(iop) ; - if ( *ptr == EOF ) - break; - to_read--; - ptr++; - } - - - - return count- (to_read/size); -} - - -#else -size_t fread(void *vptr, size_t size, size_t count, FILE *iop) -{ - char *ptr = (char *)vptr; - size_t to_read ,n_read; - - to_read = size * count; - - if (!OPEN4READING(iop)) - { - __set_errno (EINVAL); - return 0; - } - - if (!__validfp (iop) ) - { - __set_errno (EINVAL); - return 0; - } - if (feof (iop) || ferror (iop)) - return 0; - - if (vptr == NULL || to_read == 0) - return 0; - - - while(iop->_cnt > 0 && to_read > 0 ) { - to_read--; - *ptr++ = getc(iop); - } - - // if the buffer is dirty it will have to be written now - // otherwise the file pointer won't match anymore. - - fflush(iop); - - // check to see if this will work with in combination with ungetc - - n_read = _read(fileno(iop), ptr, to_read); - if ( n_read != -1 ) - to_read -= n_read; - - // the file buffer is empty and there is no read ahead information anymore. - - iop->_flag &= ~_IOAHEAD; - - return count- (to_read/size); -} -#endif - diff --git a/reactos/lib/crtdll/old cruft/stdio/frlist.c b/reactos/lib/crtdll/old cruft/stdio/frlist.c deleted file mode 100644 index 33969982c83..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/frlist.c +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -//#include -#include - - -static __file_rec __initial_file_rec = { - 0, - 5, - { &_iob[0], &_iob[1], &_iob[2], &_iob[3], &_iob[4] } -}; - -__file_rec *__file_rec_list = &__initial_file_rec; diff --git a/reactos/lib/crtdll/old cruft/stdio/fwrite.c b/reactos/lib/crtdll/old cruft/stdio/fwrite.c deleted file mode 100644 index 4d3c0697bce..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/fwrite.c +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include -#include -#include -#include - -/* - * @implemented - */ -#if 0 -size_t -fwrite(const void *p, size_t size, size_t count, FILE *iop) -{ - char *ptr = (char *)p; - size_t to_write; - - - to_write = size * count; - - - - while ( to_write > 0 ) { - if ( putc(*ptr,iop) == EOF ) - break; - to_write--; - ptr++; - } - - - - return count -to_write/size; - -} - - -#else -size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop) - { - size_t to_write, n_written; - char *ptr = (char *)vptr; - - to_write = size*count; - if (!OPEN4WRITING(iop) ) - { - __set_errno (EINVAL); - return 0; - } - - - if (iop == NULL ) - { - __set_errno (EINVAL); - return 0; - } - - if (ferror (iop)) - return 0; - if (vptr == NULL || to_write == 0) - return 0; - - - while(iop->_cnt > 0 && to_write > 0 ) { - to_write--; - putc(*ptr++,iop); - } - - // if the buffer is dirty it will have to be written now - // otherwise the file pointer won't match anymore. - - fflush(iop); - - n_written = _write(fileno(iop), ptr,to_write); - if ( n_written != -1 ) - to_write -= n_written; - - // check to see if this will work with in combination with ungetc - - - // the file buffer is empty and there is no read ahead information anymore. - - iop->_flag &= ~_IOAHEAD; - - return count - (to_write/size); - -} - -#endif diff --git a/reactos/lib/crtdll/old cruft/stdio/getchar.c b/reactos/lib/crtdll/old cruft/stdio/getchar.c deleted file mode 100644 index ed1fef6be28..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/getchar.c +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -#undef getchar -/* - * @implemented - */ -int -getchar(void) -{ - return getc(stdin); -} diff --git a/reactos/lib/crtdll/old cruft/stdio/getenv.c b/reactos/lib/crtdll/old cruft/stdio/getenv.c deleted file mode 100644 index 5a8ca82617b..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/getenv.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -void *malloc(size_t size); - - - -/* - * @implemented - */ -char *getenv(const char *name) -{ - char *buffer; - buffer = (char *)malloc(MAX_PATH); - buffer[0] = 0; - if ( GetEnvironmentVariableA(name,buffer,MAX_PATH) == 0 ) - return NULL; - return buffer; -} diff --git a/reactos/lib/crtdll/old cruft/stdio/popen.c b/reactos/lib/crtdll/old cruft/stdio/popen.c deleted file mode 100644 index 05dca81b6f3..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/popen.c +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - - -/* - * @unimplemented - */ -FILE *_popen (const char *cm, const char *md) /* program name, pipe mode */ -{ - FILE *pf; - HANDLE hReadPipe, hWritePipe; - STARTUPINFOA StartupInfo; - PROCESS_INFORMATION ProcessInformation; - - // fixme CreatePipe - - if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024)) - return NULL; - - StartupInfo.cb = sizeof(StartupInfo); - if ( md == "r" ) { - StartupInfo.hStdOutput = hWritePipe; - } - else if ( md == "w" ) { - StartupInfo.hStdInput = hReadPipe; - } - - if (CreateProcessA("cmd.exe",(char *)cm,NULL,NULL,TRUE, - CREATE_NEW_CONSOLE,NULL,NULL, - &StartupInfo, - &ProcessInformation) == FALSE) - return NULL; - - - if ( *md == 'r' ) { - pf = _fdopen( __fileno_alloc(hReadPipe, _fmode) , "r" ); - } - else { - pf = _fdopen( __fileno_alloc(hWritePipe, _fmode) , "w" ); - } - - pf->_name_to_remove = ProcessInformation.hProcess; - - return pf; - - -} - - -/* - * @unimplemented - */ -int -_pclose (FILE *pp) -{ - - fclose(pp); - printf("Terminate Process\n"); -// if (!TerminateProcess(pp->_name_to_remove,0)) -// return -1; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/stdio/putc.c b/reactos/lib/crtdll/old cruft/stdio/putc.c deleted file mode 100644 index 832368cfba1..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/putc.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include - -// putc can be a macro -#undef putc -#undef putwc - -/* - * @implemented - */ -int putc(int c, FILE* fp) -{ -// valid stream macro should check that fp is dword aligned - if (!__validfp (fp)) { - __set_errno(EINVAL); - return -1; - } -// check for write access on fp - - if ( !OPEN4WRITING(fp) ) { - __set_errno(EINVAL); - return -1; - } - - fp->_flag |= _IODIRTY; - if (fp->_cnt > 0 ) { - fp->_cnt--; - *(fp)->_ptr++ = (unsigned char)c; - return (int)(unsigned char)c; - } - else { - return _flsbuf((unsigned char)c,fp); - } - return EOF; -} - -//wint_t putwc(wint_t c, FILE* fp) -//int putwc(wchar_t c, FILE* fp) -int putwc(wint_t c, FILE* fp) -{ - // might check on multi bytes if text mode - - if (fp->_cnt > 0 ) { - fp->_cnt-= sizeof(wchar_t); - *((wchar_t *)(fp->_ptr)) = c; - fp->_ptr += sizeof(wchar_t); - return (wint_t)c; - } - else - return _flswbuf(c,fp); - - return -1; - - -} diff --git a/reactos/lib/crtdll/old cruft/stdio/putchar.c b/reactos/lib/crtdll/old cruft/stdio/putchar.c deleted file mode 100644 index c6c84134f00..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/putchar.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/conio/getch.c - * PURPOSE: Writes a character to stdout - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ -#include - -#undef putc -#undef putchar - -/* - * @implemented - */ -int putchar(int c) -{ - int r = putc(c, stdout); - if (stdout->_flag & _IOLBF) - fflush(stdout); - return r; -} diff --git a/reactos/lib/crtdll/old cruft/stdio/setbuffe.c b/reactos/lib/crtdll/old cruft/stdio/setbuffe.c deleted file mode 100644 index d694b4da183..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/setbuffe.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -//#include -#include -#include - -void setbuffer(FILE *f, void *buf, int size) -{ - if (buf) - setvbuf(f, buf, _IOFBF, size); - else - setvbuf(f, 0, _IONBF, 0); -} diff --git a/reactos/lib/crtdll/old cruft/stdio/setlineb.c b/reactos/lib/crtdll/old cruft/stdio/setlineb.c deleted file mode 100644 index a46de6645d7..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/setlineb.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -// not exported - -void setlinebuf(FILE *f) -{ - setvbuf(f, 0, _IOLBF, BUFSIZ); -} diff --git a/reactos/lib/crtdll/old cruft/stdio/setvbuf.c b/reactos/lib/crtdll/old cruft/stdio/setvbuf.c deleted file mode 100644 index 8447b35602d..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/setvbuf.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -#include - - -/* - * @implemented - */ -int setvbuf(FILE *f, char *buf, int type, size_t len) -{ - int mine=0; - if (!__validfp (f) ) { - __set_errno (EINVAL); - return 0; - } - if ( f->_base != NULL ) - fflush(f); - switch (type) - { - case _IOFBF: - case _IOLBF: - if (len <= 0) { - __set_errno (EINVAL); - return EOF; - } - if (buf == 0) - { - buf = (char *)malloc(len+1); - if (buf == NULL) { - __set_errno (ENOMEM); - return -1; - } - mine = 1; - } - /* FALLTHROUGH */ - case _IONBF: - if (f->_base != NULL && f->_flag & _IOMYBUF) - free(f->_base); - f->_cnt = 0; - - f->_flag &= ~(_IONBF|_IOFBF|_IOLBF|_IOUNGETC); - f->_flag |= type; - if (type != _IONBF) - { - if (mine) - f->_flag |= _IOMYBUF; - f->_ptr = f->_base = buf; - f->_bufsiz = len; - } - else - { - f->_base = 0; - f->_bufsiz = 0; - } - return 0; - default: - __set_errno (EINVAL); - return EOF; - } -} diff --git a/reactos/lib/crtdll/old cruft/stdio/stdhnd.c b/reactos/lib/crtdll/old cruft/stdio/stdhnd.c deleted file mode 100644 index c4fc04df908..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/stdhnd.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -FILE _iob[5] = -{ - // stdin -{ - NULL, 0, NULL, - _IOREAD | _IOLBF , - 0, 0,0, NULL -}, - // stdout -{ - NULL, 0, NULL, - _IOWRT | _IOLBF |_IOSTRG, - 1,0,0, NULL -}, - // stderr -{ - NULL, 0, NULL, - _IOWRT | _IONBF, - 2,0,0, NULL -}, - // stdaux -{ - NULL, 0, NULL, - _IOREAD | _IOWRT | _IONBF, - 3,0,0, NULL -}, - // stdprn -{ - NULL, 0, NULL, - _IOWRT | _IONBF, - 4, 0,0,NULL -} -}; - - - diff --git a/reactos/lib/crtdll/old cruft/stdio/stdiohk.c b/reactos/lib/crtdll/old cruft/stdio/stdiohk.c deleted file mode 100644 index a808c37541a..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/stdiohk.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include - - -static void fcloseall_helper(FILE *f) -{ - fflush(f); - if (fileno(f) > 2) - fclose(f); -} - -void __stdio_cleanup_proc(void); -void __stdio_cleanup_proc(void) -{ - _fwalk(fcloseall_helper); -} - -void (*__stdio_cleanup_hook)(void) = __stdio_cleanup_proc; diff --git a/reactos/lib/crtdll/old cruft/stdio/vprintf.c b/reactos/lib/crtdll/old cruft/stdio/vprintf.c deleted file mode 100644 index f7247499e96..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/vprintf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#undef __OPTIMIZE__ /* Avoid inline `vprintf' function. */ -#include -#include - -#undef vprintf -#undef vwprintf - -/* Write formatted output to stdout according to the - format string FORMAT, using the argument list in ARG. */ -int -vprintf (format, arg) - const char *format; - va_list arg; -{ - int ret = vfprintf (stdout, format, arg); - fflush(stdout); - return ret; -} - -int -vwprintf (format, arg) - const wchar_t *format; - va_list arg; -{ - int ret = vfwprintf (stdout, format, arg); - fflush(stdout); - return ret; -} diff --git a/reactos/lib/crtdll/old cruft/stdio/vsprintf.c b/reactos/lib/crtdll/old cruft/stdio/vsprintf.c deleted file mode 100644 index cb6210aae4a..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/vsprintf.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include - -/* - * @implemented - */ -int -crt_vsprintf(char *str, const char *fmt, va_list ap) -{ - FILE f; - int len; - - f._flag = _IOWRT|_IOSTRG; - f._ptr = str; - f._cnt = INT_MAX; - f._file = -1; - len = vfprintf(&f,fmt, ap); - *f._ptr = 0; - return len; -} - -/* - * @implemented - */ -int -vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap) -{ - FILE f; - int len; - - f._flag = _IOWRT|_IOSTRG; - f._ptr = (char*)str; - f._cnt = INT_MAX; - f._file = -1; - len = vfwprintf(&f,fmt, ap); - *f._ptr = 0; - return len; -} - - -/* - * @implemented - */ -int -_vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap) -{ - FILE f; - int len; - f._flag = _IOWRT|_IOSTRG; - f._ptr = str; - f._cnt = maxlen; - f._file = -1; - len = vfprintf(&f,fmt, ap); - // what if the buffer is full ?? - *f._ptr = 0; - return len; -} - -/* - * @implemented - */ -int -crt__vsnwprintf(wchar_t *str, size_t maxlen, const wchar_t *fmt, va_list ap) -{ - FILE f; - int len; - f._flag = _IOWRT|_IOSTRG; - f._ptr = (char*)str; - f._cnt = maxlen; - f._file = -1; - len = vfwprintf(&f,fmt, ap); - // what if the buffer is full ?? - *f._ptr = 0; - return len; -} - - diff --git a/reactos/lib/crtdll/old cruft/stdio/vsscanf.c b/reactos/lib/crtdll/old cruft/stdio/vsscanf.c deleted file mode 100644 index 920ff13d1f8..00000000000 --- a/reactos/lib/crtdll/old cruft/stdio/vsscanf.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include -#include - -#undef vsscanf - -/* Read formatted input from S according to the format - string FORMAT, using the argument list in ARG. */ -int __vsscanf(const char *s,const char *format,va_list arg) -{ - FILE f; - - if (s == NULL) - { - __set_errno (EINVAL); - return -1; - } - - memset ((void *) &f, 0, sizeof (f)); - - f._flag = _IOREAD; - f._ptr = (char *)s; - f._base = (char *)s; - f._bufsiz = strlen(s); - f._cnt = f._bufsiz; - - return __vfscanf (&f, format, arg); -} - diff --git a/reactos/lib/crtdll/old cruft/stdlib/alloca.c b/reactos/lib/crtdll/old cruft/stdlib/alloca.c deleted file mode 100644 index 2efea72764c..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/alloca.c +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include - - -#undef alloca -void *alloca(size_t s) -{ - register unsigned int as = s; - -// alloca(0) should not return the stack pointer - if ( s == 0 ) - return NULL; - - as = (as + 3) & (~3); - - __asm__ __volatile__( - "mov %0, %%edx \n" -// "popl %%ebp \n" - "leave \n" - "popl %%ecx \n" - "subl %%edx, %%esp \n" - "movl %%esp, %%eax \n" - "addl $20, %%eax \n"//4 bytes + 16 bytes = arguments - "push %%ecx \n" - "ret \n" - : - :"g" ( as) - ); - - - return NULL; -} - -void *_alloca(size_t s) -{ - register unsigned int as = s; - -// alloca(0) should not return the stack pointer - if ( s == 0 ) - return NULL; - - - if ( (s & 0xfffffffc) != 0 ) - as += 4; - - as &= 0xfffffffc; - - __asm__ __volatile__( - "mov %0, %%edx \n" -// "popl %%ebp \n" - "leave \n" - "popl %%ecx \n" - "subl %%edx, %%esp \n" - "movl %%esp, %%eax \n" - "addl $20, %%eax \n"//4 bytes + 16 bytes = arguments - "push %%ecx \n" - "ret \n" - : - :"g" ( as) - ); - - - return NULL; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/atexit.c b/reactos/lib/crtdll/old cruft/stdlib/atexit.c deleted file mode 100644 index 66a084d8870..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/atexit.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -/* - * @implemented - */ -int -atexit(void (*a)(void)) -{ - struct __atexit *ap; - if (a == 0) - return -1; - ap = (struct __atexit *)malloc(sizeof(struct __atexit)); - if (!ap) - return -1; - ap->__next = __atexit_ptr; - ap->__function = a; - __atexit_ptr = ap; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/calloc.c b/reactos/lib/crtdll/old cruft/stdlib/calloc.c deleted file mode 100644 index 27e2b20d493..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/calloc.c +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include - -/* - * @implemented - */ -void * -calloc(size_t size, size_t nelem) -{ - void *rv = malloc(size*nelem); - if (rv) - memset(rv, 0, size*nelem); - return rv; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/errno.c b/reactos/lib/crtdll/old cruft/stdlib/errno.c deleted file mode 100644 index 3630b18d1c2..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/errno.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include "../../msvcrt/stdlib/doserrmap.h" - -#undef errno -int errno; - -#undef _doserrno -int _doserrno; - -#undef _fpecode -int fpecode; - -/* - * @implemented - */ -int *_errno(void) -{ - return &errno; -} - -int __set_errno (int error) -{ - errno = error; - return error; -} - -/* - * @implemented - */ -int * __fpecode ( void ) -{ - return &fpecode; -} - -/* - * @implemented - */ -int* __doserrno(void) -{ - _doserrno = GetLastError(); - return &_doserrno; -} - -/* - * This function sets both doserrno to the passed in OS error code - * and also maps this to an appropriate errno code. The mapping - * has been deduced automagically by running this functions, which - * exists in MSVCRT but is undocumented, on all the error codes in - * winerror.h. - */ -void _dosmaperr(unsigned long oserror) -{ - int pos, base, lim; - - SetLastError(oserror); - - /* Use binary chop to find the corresponding errno code */ - for (base=0, lim=sizeof(doserrmap)/sizeof(doserrmap[0]); lim; lim >>= 1) { - pos = base+(lim >> 1); - if (doserrmap[pos].winerr == oserror) { - __set_errno(doserrmap[pos].en); - return; - } else if (doserrmap[pos].winerr > oserror) { - base = pos + 1; - --lim; - } - } - /* EINVAL appears to be the default */ - __set_errno(EINVAL); -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/fullpath.c b/reactos/lib/crtdll/old cruft/stdlib/fullpath.c deleted file mode 100644 index 54da89c53e8..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/fullpath.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/stdlib/fullpath.c - * PURPOSE: Gets the fullpathname - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include - -#undef fullpath -char *fullpath(char *absPath, const char *relPath, size_t maxLength) -{ - return _fullpath(absPath,relPath,maxLength ); -} - -/* - * @implemented - */ -char* _fullpath(char* absPath, const char* relPath, size_t maxLength) -{ - char* lpFilePart; - - if (GetFullPathNameA(relPath,maxLength,absPath,&lpFilePart) == 0) - return NULL; - - return absPath; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/itoa.c b/reactos/lib/crtdll/old cruft/stdlib/itoa.c deleted file mode 100644 index 245cbbeaa83..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/itoa.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/stdlib/itoa.c - * PURPOSE: converts a integer to ascii - * PROGRAMER: - * UPDATE HISTORY: - * 1995: Created - * 1998: Added ltoa Boudewijn Dekker - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include - - -/* - * @implemented - * - * this function is now forwarded to NTDLL._itoa to reduce code duplication - */ -#if 0 -char* _itoa(int value, char* string, int radix) -{ - char tmp[33]; - char *tp = tmp; - int i; - unsigned v; - int sign; - char *sp; - - if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } - - sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - if (string == 0) - string = (char *)malloc((tp-tmp)+sign+1); - sp = string; - - if (sign) - *sp++ = '-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} -#endif - -/* - * @implemented - * - * this function is now forwarded to NTDLL._ltoa to reduce code duplication - */ -#if 0 -char* _ltoa(long value, char* string, int radix) -{ - char tmp[33]; - char *tp = tmp; - long i; - unsigned long v; - int sign; - char *sp; - - if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } - - sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned long)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - if (string == 0) - string = (char *)malloc((tp-tmp)+sign+1); - sp = string; - - if (sign) - *sp++ = '-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} -#endif - -/* - * @implemented - * - * this function is now forwarded to NTDLL._ultoa to reduce code duplication - */ -#if 0 -char* _ultoa(unsigned long value, char* string, int radix) -{ - char tmp[33]; - char *tp = tmp; - long i; - unsigned long v = value; - char *sp; - - if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } - - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - if (string == 0) - string = (char *)malloc((tp-tmp)+1); - sp = string; - - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; -} -#endif diff --git a/reactos/lib/crtdll/old cruft/stdlib/itow.c b/reactos/lib/crtdll/old cruft/stdlib/itow.c deleted file mode 100644 index 36f97087eed..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/itow.c +++ /dev/null @@ -1,168 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/stdlib/itow.c - * PURPOSE: converts a integer to wchar_t - * PROGRAMER: - * UPDATE HISTORY: - * 1995: Created - * 1998: Added ltoa Boudewijn Dekker - * 2000: derived from ./itoa.c by ea - */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - -#include -#include -#include - - -/* - * @implemented - * - * this function is now forwarded to NTDLL._itow to reduce code duplication - */ -#if 0 -wchar_t* _itow(int value, wchar_t* string, int radix) -{ - wchar_t tmp [33]; - wchar_t * tp = tmp; - int i; - unsigned int v; - int sign; - wchar_t * sp; - - if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } - - sign = ((radix == 10) && (value < 0)); - if (sign) { - v = -value; - } else { - v = (unsigned) value; - } - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) { - *tp++ = i+ (wchar_t) '0'; - } else { - *tp++ = i + (wchar_t) 'a' - 10; - } - } - - if (string == 0) { - string = (wchar_t *) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t)); - } - sp = string; - - if (sign) { - *sp++ = (wchar_t) '-'; - } - while (tp > tmp) { - *sp++ = *--tp; - } - *sp = (wchar_t) 0; - return string; -} -#endif - -/* - * @implemented - * - * this function is now forwarded to NTDLL._ltow to reduce code duplication - */ -#if 0 -wchar_t* _ltow(long value, wchar_t* string, int radix) -{ - wchar_t tmp [33]; - wchar_t * tp = tmp; - long int i; - unsigned long int v; - int sign; - wchar_t * sp; - - if (radix > 36 || radix <= 1) { - __set_errno(EDOM); - return 0; - } - - sign = ((radix == 10) && (value < 0)); - if (sign) { - v = -value; - } else { - v = (unsigned long) value; - } - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) { - *tp++ = i + (wchar_t) '0'; - } else { - *tp++ = i + (wchar_t) 'a' - 10; - } - } - - if (string == 0) { - string = (wchar_t *) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t)); - } - sp = string; - - if (sign) { - *sp++ = (wchar_t) '-'; - } - while (tp > tmp) { - *sp++ = *--tp; - } - *sp = (wchar_t) 0; - return string; -} -#endif - -/* - * @implemented - * - * this function is now forwarded to NTDLL._ultow to reduce code duplication - */ -#if 0 -wchar_t* _ultow(unsigned long value, wchar_t* string, int radix) -{ - wchar_t tmp [33]; - wchar_t * tp = tmp; - long int i; - unsigned long int v = value; - wchar_t * sp; - - if (radix > 36 || radix <= 1) { - __set_errno(EDOM); - return 0; - } - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) { - *tp++ = i + (wchar_t) '0'; - } else { - *tp++ = i + (wchar_t) 'a' - 10; - } - } - - if (string == 0) { -#ifdef _MSVCRT_LIB_ // TODO: check on difference? - string = (wchar_t *)malloc(((tp-tmp)+1)*sizeof(wchar_t)); -#else // TODO: FIXME: review which is correct - string = (wchar_t *) malloc((tp - tmp) + sizeof(wchar_t)); -#endif /*_MSVCRT_LIB_*/ - } - sp = string; - - while (tp > tmp) { - *sp++ = *--tp; - } - *sp = (wchar_t) 0; - return string; -} -#endif diff --git a/reactos/lib/crtdll/old cruft/stdlib/llabs.c b/reactos/lib/crtdll/old cruft/stdlib/llabs.c deleted file mode 100644 index 83ba4ef72c8..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/llabs.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -long long -llabs(long long j) -{ - return j<0 ? -j : j; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/lldiv.c b/reactos/lib/crtdll/old cruft/stdlib/lldiv.c deleted file mode 100644 index 75f065bb8f4..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/lldiv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -lldiv_t -lldiv(long long num, long long denom) -{ - lldiv_t r; - - if (num > 0 && denom < 0) - { - num = -num; - denom = -denom; - } - r.quot = num / denom; - r.rem = num % denom; - if (num < 0 && denom > 0) - { - if (r.rem > 0) - { - r.quot++; - r.rem -= denom; - } - } - return r; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/makepath.c b/reactos/lib/crtdll/old cruft/stdlib/makepath.c deleted file mode 100644 index 7e34891c3b6..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/makepath.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id$ - */ -#include -#include - -/* - * @implemented - */ -void _makepath(char *path, const char *drive, const char *dir, const char *fname, const char *ext) -{ - int dir_len; - - if ((drive != NULL) && (*drive)) { - strcpy(path, drive); - strcat(path, ":"); - } else { - (*path)=0; - } - - if (dir != NULL) { - strcat(path, dir); - dir_len = strlen(dir); - if (dir_len && *(dir + dir_len - 1) != '\\') - strcat(path, "\\"); - } - - if (fname != NULL) { - strcat(path, fname); - if (ext != NULL && *ext != 0) { - if (*ext != '.') - strcat(path, "."); - strcat(path, ext); - } - } -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/malloc.c b/reactos/lib/crtdll/old cruft/stdlib/malloc.c deleted file mode 100644 index ed21b46bb8e..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/malloc.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -void* malloc(size_t _size) -{ - return(HeapAlloc(GetProcessHeap(),0,_size)); -} - -/* - * @implemented - */ -void free(void* _ptr) -{ - HeapFree(GetProcessHeap(),0,_ptr); -} - -/* - * @implemented - */ -void* calloc(size_t _nmemb, size_t _size) -{ - return(HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, _nmemb*_size)); -} - -/* - * @implemented - */ -void* realloc(void* _ptr, size_t _size) -{ - if (!_ptr) - return(HeapAlloc(GetProcessHeap(),0,_size)); - return(HeapReAlloc(GetProcessHeap(),0,_ptr,_size)); -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/mbstowcs.c b/reactos/lib/crtdll/old cruft/stdlib/mbstowcs.c deleted file mode 100644 index 63b45b20250..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/mbstowcs.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -/* - * @unimplemented - */ -size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count ) -{ - return 0; -} - -/* - * @unimplemented - */ -int mbtowc( wchar_t *wchar, const char *mbchar, size_t count ) -{ - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/putenv.c b/reactos/lib/crtdll/old cruft/stdlib/putenv.c deleted file mode 100644 index 188873ae305..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/putenv.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include - - - -int putenv(const char *val) -{ - - char buffer[1024]; - char *epos; - - strcpy(buffer,val); - - - epos = strchr(buffer, '='); - if ( epos == NULL ) - return -1; - - *epos = 0; - - return SetEnvironmentVariableA(buffer,epos+1); -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/qsort.c b/reactos/lib/crtdll/old cruft/stdlib/qsort.c deleted file mode 100644 index b526c76dad7..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/qsort.c +++ /dev/null @@ -1,239 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -/*- - * Copyright (c) 1980, 1983 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* - * qsort.c: - * Our own version of the system qsort routine which is faster by an average - * of 25%, with lows and highs of 10% and 50%. - * The THRESHold below is the insertion sort threshold, and has been adjusted - * for records of size 48 bytes. - * The MTHREShold is where we stop finding a better median. - */ - -#define THRESH 4 /* threshold for insertion */ -#define MTHRESH 6 /* threshold for median */ - -static int (*qcmp)(const void *, const void *); /* the comparison routine */ -static int qsz; /* size of each record */ -static int thresh; /* THRESHold in chars */ -static int mthresh; /* MTHRESHold in chars */ - -/* - * qst: - * Do a quicksort - * First, find the median element, and put that one in the first place as the - * discriminator. (This "median" is just the median of the first, last and - * middle elements). (Using this median instead of the first element is a big - * win). Then, the usual partitioning/swapping, followed by moving the - * discriminator into the right place. Then, figure out the sizes of the two - * partions, do the smaller one recursively and the larger one via a repeat of - * this code. Stopping when there are less than THRESH elements in a partition - * and cleaning up with an insertion sort (in our caller) is a huge win. - * All data swaps are done in-line, which is space-losing but time-saving. - * (And there are only three places where this is done). - */ - -static void -qst(char *base, char *max) -{ - char c, *i, *j, *jj; - int ii; - char *mid, *tmp; - int lo, hi; - - /* - * At the top here, lo is the number of characters of elements in the - * current partition. (Which should be max - base). - * Find the median of the first, last, and middle element and make - * that the middle element. Set j to largest of first and middle. - * If max is larger than that guy, then it's that guy, else compare - * max with loser of first and take larger. Things are set up to - * prefer the middle, then the first in case of ties. - */ - lo = max - base; /* number of elements as chars */ - do { - mid = i = base + qsz * ((lo / qsz) >> 1); - if (lo >= mthresh) - { - j = (qcmp((jj = base), i) > 0 ? jj : i); - if (qcmp(j, (tmp = max - qsz)) > 0) - { - /* switch to first loser */ - j = (j == jj ? i : jj); - if (qcmp(j, tmp) < 0) - j = tmp; - } - if (j != i) - { - ii = qsz; - do { - c = *i; - *i++ = *j; - *j++ = c; - } while (--ii); - } - } - /* - * Semi-standard quicksort partitioning/swapping - */ - for (i = base, j = max - qsz; ; ) - { - while (i < mid && qcmp(i, mid) <= 0) - i += qsz; - while (j > mid) - { - if (qcmp(mid, j) <= 0) - { - j -= qsz; - continue; - } - tmp = i + qsz; /* value of i after swap */ - if (i == mid) - { - /* j <-> mid, new mid is j */ - mid = jj = j; - } - else - { - /* i <-> j */ - jj = j; - j -= qsz; - } - goto swap; - } - if (i == mid) - { - break; - } - else - { - /* i <-> mid, new mid is i */ - jj = mid; - tmp = mid = i; /* value of i after swap */ - j -= qsz; - } - swap: - ii = qsz; - do { - c = *i; - *i++ = *jj; - *jj++ = c; - } while (--ii); - i = tmp; - } - /* - * Look at sizes of the two partitions, do the smaller - * one first by recursion, then do the larger one by - * making sure lo is its size, base and max are update - * correctly, and branching back. But only repeat - * (recursively or by branching) if the partition is - * of at least size THRESH. - */ - i = (j = mid) + qsz; - if ((lo = j - base) <= (hi = max - i)) - { - if (lo >= thresh) - qst(base, j); - base = i; - lo = hi; - } - else - { - if (hi >= thresh) - qst(i, max); - max = j; - } - } while (lo >= thresh); -} - -/* - * qsort: - * First, set up some global parameters for qst to share. Then, quicksort - * with qst(), and then a cleanup insertion sort ourselves. Sound simple? - * It's not... - * - * @implemented - */ -void -qsort(const void *base0, size_t n, size_t size, _pfunccmp_t compar) -{ - char *base = (char *)base0; - char c, *i, *j, *lo, *hi; - char *min, *max; - - if (n <= 1) - return; - qsz = size; - qcmp = compar; - thresh = qsz * THRESH; - mthresh = qsz * MTHRESH; - max = base + n * qsz; - if (n >= THRESH) - { - qst(base, max); - hi = base + thresh; - } - else - { - hi = max; - } - /* - * First put smallest element, which must be in the first THRESH, in - * the first position as a sentinel. This is done just by searching - * the first THRESH elements (or the first n if n < THRESH), finding - * the min, and swapping it into the first position. - */ - for (j = lo = base; (lo += qsz) < hi; ) - if (qcmp(j, lo) > 0) - j = lo; - if (j != base) - { - /* swap j into place */ - for (i = base, hi = base + qsz; i < hi; ) - { - c = *j; - *j++ = *i; - *i++ = c; - } - } - /* - * With our sentinel in place, we now run the following hyper-fast - * insertion sort. For each remaining element, min, from [1] to [n-1], - * set hi to the index of the element AFTER which this one goes. - * Then, do the standard insertion sort shift on a character at a time - * basis for each element in the frob. - */ - for (min = base; (hi = min += qsz) < max; ) - { - while (qcmp(hi -= qsz, min) > 0) - /* void */; - if ((hi += qsz) != min) { - for (lo = min + qsz; --lo >= min; ) - { - c = *lo; - for (i = j = lo; (j -= qsz) >= hi; i = j) - *i = *j; - *i = c; - } - } - } -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/rand.c b/reactos/lib/crtdll/old cruft/stdlib/rand.c deleted file mode 100644 index 536cf84a265..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/rand.c +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -static unsigned long long next = 0; - -/* - * @implemented - */ -int -rand(void) -{ - next = next * 0x5deece66dLL + 11; - return (int)((next >> 16) & RAND_MAX); -} - -/* - * @implemented - */ -void -srand(unsigned seed) -{ - next = seed; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/splitp.c b/reactos/lib/crtdll/old cruft/stdlib/splitp.c deleted file mode 100644 index 61f0479430b..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/splitp.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include - - -/* - * @implemented - */ -void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext ) -{ - char *tmp_drive; - char *tmp_dir; - char *tmp_ext; - - tmp_drive = (char *)strchr(path,':'); - if ( tmp_drive != (char *)NULL ) { - strncpy(drive,tmp_drive-1,1); - *(drive+1) = 0; - } - else { - *drive = 0; - tmp_drive = (char *)path; - } - - tmp_dir = (char *)strrchr(path,'\\'); - if( tmp_dir != NULL && tmp_dir != tmp_drive + 1 ) { - strncpy(dir,tmp_drive+1,tmp_dir - tmp_drive); - *(dir + (tmp_dir - tmp_drive)) = 0; - } - else - *dir =0; - - tmp_ext = ( char *)strrchr(path,'.'); - if ( tmp_ext != NULL ) { - strcpy(ext,tmp_ext); - } - else - { - *ext = 0; - tmp_ext = (char*)path+strlen(path); - } - if ( tmp_dir != NULL ) { - strncpy(fname,tmp_dir+1,tmp_ext - tmp_dir - 1); - *(fname + (tmp_ext - tmp_dir -1)) = 0; - } - else - { - strncpy(fname,path,tmp_ext - path); - *(fname+(tmp_ext-path))=0; - } -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/stdlib/.gitignore b/reactos/lib/crtdll/old cruft/stdlib/stdlib/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/reactos/lib/crtdll/old cruft/stdlib/strtoull.c b/reactos/lib/crtdll/old cruft/stdlib/strtoull.c deleted file mode 100644 index ec9f852525f..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/strtoull.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include -//#include - -/* - * Convert a string to an unsigned long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -unsigned long -strtoull(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - cutoff = (unsigned long)ULONG_MAX / base; - cutlim = (unsigned long)ULONG_MAX % base; - for (acc = 0, any = 0;; c = *s++) - { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = ULONG_MAX; - errno = ERANGE; - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *)s - 1 : (char *)nptr; - return acc; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/swab.c b/reactos/lib/crtdll/old cruft/stdlib/swab.c deleted file mode 100644 index c948f45bfaf..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/swab.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include - -/* - * @implemented - */ -void _swab (const char* caFrom, char* caTo, size_t sizeToCopy) -{ - unsigned long temp; - - sizeToCopy >>= 1; sizeToCopy++; -#define STEP temp = *((const char *)caFrom)++,*((char *)caTo)++ = *((const char *)caFrom)++,*((char *)caTo)++ = temp - /* round to multiple of 8 */ - while ((--sizeToCopy) & 07) - STEP; - sizeToCopy >>= 3; - while (--sizeToCopy >= 0) { - STEP; STEP; STEP; STEP; - STEP; STEP; STEP; STEP; - } -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/wcstom.c b/reactos/lib/crtdll/old cruft/stdlib/wcstom.c deleted file mode 100644 index 11bc59f323d..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/wcstom.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -/* - * @unimplemented - */ -size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size) -{ - return 0; -} - -/* - * @unimplemented - */ -int wctomb (char* mbDest, wchar_t wc) -{ - return 0; -} - - - diff --git a/reactos/lib/crtdll/old cruft/stdlib/wcstomb.c b/reactos/lib/crtdll/old cruft/stdlib/wcstomb.c deleted file mode 100644 index f0020082ea2..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/wcstomb.c +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#ifndef EILSEQ -#define EILSEQ EINVAL -#endif - -static const wchar_t encoding_mask[] = -{ - (wchar_t)~0x7ff, (wchar_t)~0xffff, (wchar_t)~0x1fffff, (wchar_t)~0x3ffffff -}; - -static const unsigned char encoding_byte[] = -{ - 0xc0, 0xe0, 0xf0, 0xf8, 0xfc -}; - -/* The state is for this UTF8 encoding not used. */ -//static mbstate_t internal; - - -//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ - -size_t -__wcrtomb (char *s, wchar_t wc); - -/* - * Convert WCHAR into its multibyte character representation, - * putting this in S and returning its length. - * - * Attention: this function should NEVER be intentionally used. - * The interface is completely stupid. The state is shared between - * all conversion functions. You should use instead the restartable - * version `wcrtomb'. - * - * @implemented - */ -int -wctomb (char *s, wchar_t wchar) -{ - /* If S is NULL the function has to return null or not null - depending on the encoding having a state depending encoding or - not. This is nonsense because any multibyte encoding has a - state. The ISO C amendment 1 corrects this while introducing the - restartable functions. We simply say here all encodings have a - state. */ - if (s == NULL) - return 1; - - return __wcrtomb (s, wchar); -} - - -size_t -__wcrtomb (char *s, wchar_t wc) -{ - char fake[1]; - size_t written = 0; - - if (s == NULL) - { - s = fake; - wc = L'\0'; - } - - if (wc < 0x80) - { - /* It's a one byte sequence. */ - if (s != NULL) - *s = (char) wc; - return 1; - } - - for (written = 2; written < 6; ++written) - if ((wc & encoding_mask[written - 2]) == 0) - break; - - if (s != NULL) - { - size_t cnt = written; - s[0] = encoding_byte[cnt - 2]; - - --cnt; - do - { - s[cnt] = 0x80 | (wc & 0x3f); - wc >>= 6; - } - while (--cnt > 0); - s[0] |= wc; - } - - return written; -} diff --git a/reactos/lib/crtdll/old cruft/stdlib/wcstombs.c b/reactos/lib/crtdll/old cruft/stdlib/wcstombs.c deleted file mode 100644 index d28336ec71b..00000000000 --- a/reactos/lib/crtdll/old cruft/stdlib/wcstombs.c +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#ifndef EILSEQ -#define EILSEQ EINVAL -#endif - - -static const wchar_t encoding_mask[] = -{ - ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff -}; - -static const unsigned char encoding_byte[] = -{ - 0xc0, 0xe0, 0xf0, 0xf8, 0xfc -}; - -/* We don't need the state really because we don't have shift states - to maintain between calls to this function. */ -typedef int mbstate_t; -static mbstate_t mbstate_internal; - - -mbstate_t __no_r_state; /* Now defined in wcstombs.c. */ -//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ - -size_t -__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps); - -/* Convert the `wchar_t' string in PWCS to a multibyte character string - * in S, writing no more than N characters. Return the number of bytes - * written, or (size_t) -1 if an invalid `wchar_t' was found. - * - * Attention: this function should NEVER be intentionally used. - * The interface is completely stupid. The state is shared between - * all conversion functions. You should use instead the restartable - * version `wcsrtombs'. - * - * @implemented - */ -size_t -wcstombs (char *s, const wchar_t *pwcs, size_t n) -{ - mbstate_t save_shift = __no_r_state; - size_t written; - - written = __wcsrtombs (s, &pwcs, n, &__no_r_state); - - /* Restore the old shift state. */ - __no_r_state = save_shift; - - /* Return how many we wrote (or maybe an error). */ - return written; -} - -size_t -__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps) -{ - size_t written = 0; - const wchar_t *run = *src; - - if (ps == NULL) - ps = &mbstate_internal; - - if (dst == NULL) - /* The LEN parameter has to be ignored if we don't actually write - anything. */ - len = ~0; - - while (written < len) - { - wchar_t wc = *run++; - - if (wc < 0 || wc > 0x7fffffff) - { - /* This is no correct ISO 10646 character. */ - __set_errno (EILSEQ); - return (size_t) -1; - } - - if (wc == L'\0') - { - /* Found the end. */ - if (dst != NULL) - *dst = '\0'; - *src = NULL; - return written; - } - else if (wc < 0x80) - { - /* It's an one byte sequence. */ - if (dst != NULL) - *dst++ = (char) wc; - ++written; - } - else - { - size_t step; - - for (step = 2; step < 6; ++step) - if ((wc & encoding_mask[step - 2]) == 0) - break; - - if (written + step >= len) - /* Too long. */ - break; - - if (dst != NULL) - { - size_t cnt = step; - - dst[0] = encoding_byte[cnt - 2]; - - --cnt; - do - { - dst[cnt] = 0x80 | (wc & 0x3f); - wc >>= 6; - } - while (--cnt > 0); - dst[0] |= wc; - - dst += step; - } - - written += step; - } - } - - /* Store position of first unprocessed word. */ - *src = run; - - return written; -} -//weak_alias (__wcsrtombs, wcsrtombs) diff --git a/reactos/lib/crtdll/old cruft/sys_stat/fstat.c b/reactos/lib/crtdll/old cruft/sys_stat/fstat.c deleted file mode 100644 index c9d721443ac..00000000000 --- a/reactos/lib/crtdll/old cruft/sys_stat/fstat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/crtdll/sys/fstat.c - * PURPOSE: Gather file information - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/12/98: Created - */ - -#include -#include -#include -#include -#include -#include -#include - - -/* - * @implemented - */ -int _fstat(int fd, struct stat* statbuf) -{ - BY_HANDLE_FILE_INFORMATION FileInformation; - - if (!statbuf) { - __set_errno(EINVAL); - return -1; - } - - if (!GetFileInformationByHandle(_get_osfhandle(fd),&FileInformation)) { - __set_errno (EBADF); - return -1; - } - statbuf->st_ctime = FileTimeToUnixTime(&FileInformation.ftCreationTime,NULL); - statbuf->st_atime = FileTimeToUnixTime(&FileInformation.ftLastAccessTime,NULL); - statbuf->st_mtime = FileTimeToUnixTime(&FileInformation.ftLastWriteTime,NULL); - if (statbuf->st_atime ==0) - statbuf->st_atime = statbuf->st_mtime; - if (statbuf->st_ctime ==0) - statbuf->st_ctime = statbuf->st_mtime; - - statbuf->st_dev = FileInformation.dwVolumeSerialNumber; - statbuf->st_size = FileInformation.nFileSizeLow; - statbuf->st_nlink = FileInformation.nNumberOfLinks; - statbuf->st_mode = S_IREAD; - if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - statbuf->st_mode |= S_IFDIR | S_IEXEC; - else - statbuf->st_mode |= S_IFREG; - if (!(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - statbuf->st_mode |= S_IWRITE; - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/sys_stat/ftime.c b/reactos/lib/crtdll/old cruft/sys_stat/ftime.c deleted file mode 100644 index 1d3234b137d..00000000000 --- a/reactos/lib/crtdll/old cruft/sys_stat/ftime.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1994, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include - - -/* - * crtdll has void return type instead of int - * - * @implemented - */ -void _ftime(struct timeb* timebuf) -{ - int save = errno; - struct tm* tp; - - __set_errno (0); - if (time (&timebuf->time) == (time_t) -1 && errno != 0) - return; - timebuf->millitm = 0; - tp = localtime(&timebuf->time); - if (tp == NULL) - return; - - timebuf->_timezone = tp->tm_gmtoff / 60; - timebuf->dstflag = tp->tm_isdst; - - free(tp); - __set_errno(save); - return; -} diff --git a/reactos/lib/crtdll/old cruft/sys_stat/stat.c b/reactos/lib/crtdll/old cruft/sys_stat/stat.c deleted file mode 100644 index cdcc42e2d8a..00000000000 --- a/reactos/lib/crtdll/old cruft/sys_stat/stat.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -/* - * @implemented - */ -int _stat(const char* path, struct stat* buffer) -{ - HANDLE fh; - WIN32_FIND_DATAA wfd; - - fh = FindFirstFileA(path, &wfd); - if (fh == INVALID_HANDLE_VALUE) { - __set_errno(ENOFILE); - return -1; - } - if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - int fd = _open(path, _O_RDONLY); - int ret; - ret = fstat(fd, buffer); - _close(fd); - return ret; - } - buffer->st_ctime = FileTimeToUnixTime(&wfd.ftCreationTime,NULL); - buffer->st_atime = FileTimeToUnixTime(&wfd.ftLastAccessTime,NULL); - buffer->st_mtime = FileTimeToUnixTime(&wfd.ftLastWriteTime,NULL); - - if (buffer->st_atime ==0) - buffer->st_atime = buffer->st_mtime; - if (buffer->st_ctime ==0) - buffer->st_ctime = buffer->st_mtime; - - buffer->st_mode = S_IREAD; - if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - buffer->st_mode |= S_IFDIR; - else - buffer->st_mode |= S_IFREG; - if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) - buffer->st_mode |= S_IWRITE | S_IEXEC; - - buffer->st_size = wfd.nFileSizeLow; - buffer->st_nlink = 1; - if (FindNextFileA(fh, &wfd)) { - __set_errno(ENOFILE); - FindClose(fh); - return -1; - } - return 0; -} diff --git a/reactos/lib/crtdll/old cruft/time/ctime.c b/reactos/lib/crtdll/old cruft/time/ctime.c deleted file mode 100644 index 8de81bf6207..00000000000 --- a/reactos/lib/crtdll/old cruft/time/ctime.c +++ /dev/null @@ -1,1439 +0,0 @@ - -// fix djdir - -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* This file has been modified by DJ Delorie. These modifications are -** Copyright (C) 1995 DJ Delorie, 24 Kirsten Ave, Rochester NH, -** 03867-2954, USA. -*/ - -/* - * Copyright (c) 1987, 1989 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Arthur David Olson of the National Cancer Institute. - * - * Redistribution and use in source and binary forms are permitted provided - * that: (1) source distributions retain this entire copyright notice and - * comment, and (2) distributions including binaries display the following - * acknowledgement: ``This product includes software developed by the - * University of California, Berkeley and its contributors'' in the - * documentation or other materials provided with the distribution and in - * all advertising materials mentioning features or use of this software. - * Neither the name of the University nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* -** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). -** POSIX-style TZ environment variable handling from Guy Harris -** (guy@auspex.com). -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "tzfile.h" - -#include - -#include "posixrul.h" - - -#ifdef __cplusplus -#define CPP_CONST const -#else -#define CPP_CONST -#endif - -#define P(s) s -#define alloc_size_t size_t -#define qsort_size_t size_t -#define fread_size_t size_t -#define fwrite_size_t size_t - -#define ACCESS_MODE O_RDONLY|O_BINARY -#define OPEN_MODE O_RDONLY|O_BINARY - -/* -** Someone might make incorrect use of a time zone abbreviation: -** 1. They might reference tzname[0] before calling tzset (explicitly -** or implicitly). -** 2. They might reference tzname[1] before calling tzset (explicitly -** or implicitly). -** 3. They might reference tzname[1] after setting to a time zone -** in which Daylight Saving Time is never observed. -** 4. They might reference tzname[0] after setting to a time zone -** in which Standard Time is never observed. -** 5. They might reference tm.TM_ZONE after calling offtime. -** What's best to do in the above cases is open to debate; -** for now, we just set things up so that in any of the five cases -** 4ABBR is used. Another possibility: initialize tzname[0] to the -** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the -** manual page of what this "time zone abbreviation" means (doing this so -** that tzname[0] has the "normal" length of three characters). -*/ - -void _set_daylight_export(int); -void _set_timezone_export(int); - -static char TZ_NAME[16] = "JST"; -static char TZ_DST_NAME[12] = ""; - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif /* !defined TRUE */ - -static const char GMT[] = "GMT"; - -struct ttinfo { /* time type information */ - long tt_gmtoff; /* GMT offset in seconds */ - int tt_isdst; /* used to set tm_isdst */ - int tt_abbrind; /* abbreviation list index */ - int tt_ttisstd; /* TRUE if transition is std time */ -}; - -struct lsinfo { /* leap second information */ - time_t ls_trans; /* transition time */ - long ls_corr; /* correction to apply */ -}; - -struct state { - int leapcnt; - int timecnt; - int typecnt; - int charcnt; - time_t ats[TZ_MAX_TIMES]; - unsigned char types[TZ_MAX_TIMES]; - struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ? TZ_MAX_CHARS + 1 : sizeof GMT]; - struct lsinfo lsis[TZ_MAX_LEAPS]; -}; - -struct rule { - int r_type; /* type of rule--see below */ - int r_day; /* day number of rule */ - int r_week; /* week number of rule */ - int r_mon; /* month number of rule */ - long r_time; /* transition time of rule */ -}; - -#define JULIAN_DAY 0 /* Jn - Julian day */ -#define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ - -/* -** Prototypes for static functions. -*/ -#if 0 -static long detzcode P((const char * codep)); -static const char * getzname P((const char * strp)); -static const char * getnum P((const char * strp, int * nump, int min, int max)); -static const char * getsecs P((const char * strp, long * secsp)); -static const char * getoffset P((const char * strp, long * offsetp)); -static const char * getrule P((const char * strp, struct rule * rulep)); -static void gmtload P((struct state * sp)); -static void gmtsub P((const time_t * timep, long offset, struct tm * tmp)); -static void localsub P((const time_t * timep, long offset, struct tm * tmp)); -static void normalize P((int * tensptr, int * unitsptr, int base)); -static void settzname P((void)); -static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset)); -static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * CPP_CONST, const long, struct tm * CPP_CONST), long offset, int * okayp)); -static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp)); -static int tmcomp P((const struct tm * atmp, const struct tm * btmp)); -static time_t transtime P((time_t janfirst, int year, const struct rule * rulep, long offset)); -static int tzload P((const char * name, struct state * sp)); -static int tzparse P((const char * name, struct state * sp, int lastditch)); -static void tzsetwall(void); - -#else - -static const char * getnum(const char * strp, int * CPP_CONST nump, const int min, const int max); -static void timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp); -static time_t transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset); -static void tzsetwall(void); - -#endif - -#ifdef ALL_STATE -static struct state *lclptr; -static struct state *gmtptr; -#endif /* defined ALL_STATE */ - -#ifndef ALL_STATE -static struct state lclmem; -static struct state gmtmem; -#define lclptr (&lclmem) -#define gmtptr (&gmtmem) -#endif /* State Farm */ - -static int lcl_is_set; -static int gmt_is_set; - -char * _tzname[2] = { - TZ_NAME, - TZ_DST_NAME -}; - -static long -detzcode(const char * CPP_CONST codep) -{ - long result; - int i; - - result = 0; - for (i = 0; i < 4; ++i) - result = (result << 8) | (codep[i] & 0xff); - return result; -} - -static void -settzname(void) -{ - const struct state * CPP_CONST sp = lclptr; - int i; - - _tzname[0] = TZ_NAME; - _tzname[1] = TZ_DST_NAME; -#ifdef ALL_STATE - if (sp == NULL) - { - _tzname[0] = _tzname[1] = GMT; - return; - } -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) - { - register const struct ttinfo * CPP_CONST ttisp = &sp->ttis[i]; - - _tzname[ttisp->tt_isdst] = - (char *)&sp->chars[ttisp->tt_abbrind]; -#if 0 - if (ttisp->tt_isdst) { - //_daylight = 1; - _set_daylight_export(1); - } - if (i == 0 || !ttisp->tt_isdst) { - //_timezone_dll = -(ttisp->tt_gmtoff); - _set_timezone_export(-(ttisp->tt_gmtoff)); - } - if (i == 0 || ttisp->tt_isdst) { - _altzone = -(ttisp->tt_gmtoff); - } -#endif - } - /* - ** And to get the latest zone names into tzname. . . - */ - for (i = 0; i < sp->timecnt; ++i) - { - const struct ttinfo * CPP_CONST ttisp = &sp->ttis[sp->types[i]]; - - _tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; - } -} - -static char * -tzdir(void) -{ - static char dir[80]={0}, *cp; - if (dir[0] == 0) - { - if ((cp = getenv("TZDIR"))) - { - strcpy(dir, cp); - } - else if ((cp = getenv("DJDIR"))) - { - strcpy(dir, cp); - strcat(dir, "/zoneinfo"); - } - else - strcpy(dir, "./"); - } - return dir; -} - -static int -tzload(const char *name, struct state * CPP_CONST sp) -{ - const char * p; - int i; - int fid; - char fullname[FILENAME_MAX + 1]; - const struct tzhead * tzhp; - char buf[sizeof *sp + sizeof *tzhp]; - int ttisstdcnt; - - if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; - - if (name[0] == ':') - ++name; - if (name[0] != '/') - { - if ((p = tzdir()) == NULL) - return -1; - if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) - return -1; - strcpy(fullname, p); - strcat(fullname, "/"); - strcat(fullname, name); - name = fullname; - } - - if ((fid = open(name, OPEN_MODE)) == -1) - { - const char *base = strrchr(name, '/'); - if (base) - base++; - else - base = name; - if (strcmp(base, "posixrules")) - return -1; - - /* We've got a built-in copy of posixrules just in case */ - memcpy(buf, _posixrules_data, sizeof(_posixrules_data)); - i = sizeof(_posixrules_data); - } - else - { - i = read(fid, buf, sizeof buf); - if (close(fid) != 0 || i < sizeof *tzhp) - return -1; - } - - tzhp = (struct tzhead *) buf; - ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt); - sp->leapcnt = (int) detzcode(tzhp->tzh_leapcnt); - sp->timecnt = (int) detzcode(tzhp->tzh_timecnt); - sp->typecnt = (int) detzcode(tzhp->tzh_typecnt); - sp->charcnt = (int) detzcode(tzhp->tzh_charcnt); - if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || - sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || - sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || - sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || - (ttisstdcnt != sp->typecnt && ttisstdcnt != 0)) - return -1; - if (i < sizeof *tzhp + - sp->timecnt * (4 + sizeof (char)) + - sp->typecnt * (4 + 2 * sizeof (char)) + - sp->charcnt * sizeof (char) + - sp->leapcnt * 2 * 4 + - ttisstdcnt * sizeof (char)) - return -1; - p = buf + sizeof *tzhp; - for (i = 0; i < sp->timecnt; ++i) - { - sp->ats[i] = detzcode(p); - p += 4; - } - for (i = 0; i < sp->timecnt; ++i) - { - sp->types[i] = (unsigned char) *p++; - if (sp->types[i] >= sp->typecnt) - return -1; - } - for (i = 0; i < sp->typecnt; ++i) - { - struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - ttisp->tt_gmtoff = detzcode(p); - p += 4; - ttisp->tt_isdst = (unsigned char) *p++; - if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; - ttisp->tt_abbrind = (unsigned char) *p++; - if (ttisp->tt_abbrind < 0 || - ttisp->tt_abbrind > sp->charcnt) - return -1; - } - for (i = 0; i < sp->charcnt; ++i) - sp->chars[i] = *p++; - sp->chars[i] = '\0'; /* ensure '\0' at end */ - for (i = 0; i < sp->leapcnt; ++i) - { - struct lsinfo * lsisp; - - lsisp = &sp->lsis[i]; - lsisp->ls_trans = detzcode(p); - p += 4; - lsisp->ls_corr = detzcode(p); - p += 4; - } - for (i = 0; i < sp->typecnt; ++i) - { - struct ttinfo * ttisp; - - ttisp = &sp->ttis[i]; - if (ttisstdcnt == 0) - ttisp->tt_ttisstd = FALSE; - else - { - ttisp->tt_ttisstd = *p++; - if (ttisp->tt_ttisstd != TRUE && - ttisp->tt_ttisstd != FALSE) - return -1; - } - } - return 0; -} - -static const int mon_lengths[2][MONSPERYEAR] = { -{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, -{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -static const int year_lengths[2] = { -DAYSPERNYEAR, DAYSPERLYEAR -}; - -/* -** Given a pointer into a time zone string, scan until a character that is not -** a valid character in a zone name is found. Return a pointer to that -** character. -*/ - -static const char * -getzname(const char *strp) -{ - char c; - - while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && - c != '+') - ++strp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number from that string. -** Check that the number is within a specified range; if it is not, return -** NULL. -** Otherwise, return a pointer to the first character not part of the number. -*/ - -static const char * -getnum(const char *strp, int * CPP_CONST nump, const int min, const int max) -{ - char c; - int num; - - if (strp == NULL || !isdigit(*strp)) - return NULL; - num = 0; - while ((c = *strp) != '\0' && isdigit(c)) - { - num = num * 10 + (c - '0'); - if (num > max) - return NULL; - ++strp; - } - if (num < min) - return NULL; - *nump = num; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a number of seconds, -** in hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the number -** of seconds. -*/ - -static const char * -getsecs(const char *strp, long * CPP_CONST secsp) -{ - int num; - - strp = getnum(strp, &num, 0, HOURSPERDAY); - if (strp == NULL) - return NULL; - *secsp = num * SECSPERHOUR; - if (*strp == ':') - { - ++strp; - strp = getnum(strp, &num, 0, MINSPERHOUR - 1); - if (strp == NULL) - return NULL; - *secsp += num * SECSPERMIN; - if (*strp == ':') - { - ++strp; - strp = getnum(strp, &num, 0, SECSPERMIN - 1); - if (strp == NULL) - return NULL; - *secsp += num; - } - } - return strp; -} - -/* -** Given a pointer into a time zone string, extract an offset, in -** [+-]hh[:mm[:ss]] form, from the string. -** If any error occurs, return NULL. -** Otherwise, return a pointer to the first character not part of the time. -*/ - -static const char * -getoffset(const char *strp, long * CPP_CONST offsetp) -{ - int neg; - - if (*strp == '-') - { - neg = 1; - ++strp; - } - else if (isdigit(*strp) || *strp++ == '+') - neg = 0; - else - return NULL; /* illegal offset */ - strp = getsecs(strp, offsetp); - if (strp == NULL) - return NULL; /* illegal time */ - if (neg) - *offsetp = -*offsetp; - return strp; -} - -/* -** Given a pointer into a time zone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". -** If a valid rule is not found, return NULL. -** Otherwise, return a pointer to the first character not part of the rule. -*/ - -static const char * -getrule(const char *strp, struct rule * CPP_CONST rulep) -{ - if (*strp == 'J') - { - /* - ** Julian day. - */ - rulep->r_type = JULIAN_DAY; - ++strp; - strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); - } - else if (*strp == 'M') - { - /* - ** Month, week, day. - */ - rulep->r_type = MONTH_NTH_DAY_OF_WEEK; - ++strp; - strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_week, 1, 5); - if (strp == NULL) - return NULL; - if (*strp++ != '.') - return NULL; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); - } - else if (isdigit(*strp)) - { - /* - ** Day of year. - */ - rulep->r_type = DAY_OF_YEAR; - strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); - } - else - return NULL; /* invalid format */ - if (strp == NULL) - return NULL; - if (*strp == '/') - { - /* - ** Time specified. - */ - ++strp; - strp = getsecs(strp, &rulep->r_time); - } - else - rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ - return strp; -} - -/* -** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the -** year, a rule, and the offset from GMT at the time that rule takes effect, -** calculate the Epoch-relative time that rule takes effect. -*/ - -static time_t -transtime(const time_t janfirst, const int year, const struct rule * CPP_CONST rulep, const long offset) -{ - int leapyear; - time_t value=0; - int i; - int d, m1, yy0, yy1, yy2, dow; - - leapyear = isleap(year); - switch (rulep->r_type) - { - - case JULIAN_DAY: - /* - ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap - ** years. - ** In non-leap years, or if the day number is 59 or less, just - ** add SECSPERDAY times the day number-1 to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + (rulep->r_day - 1) * SECSPERDAY; - if (leapyear && rulep->r_day >= 60) - value += SECSPERDAY; - break; - - case DAY_OF_YEAR: - /* - ** n - day of year. - ** Just add SECSPERDAY times the day number to the time of - ** January 1, midnight, to get the day. - */ - value = janfirst + rulep->r_day * SECSPERDAY; - break; - - case MONTH_NTH_DAY_OF_WEEK: - /* - ** Mm.n.d - nth "dth day" of month m. - */ - value = janfirst; - for (i = 0; i < rulep->r_mon - 1; ++i) - value += mon_lengths[leapyear][i] * SECSPERDAY; - - /* - ** Use Zeller's Congruence to get day-of-week of first day of - ** month. - */ - m1 = (rulep->r_mon + 9) % 12 + 1; - yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; - yy1 = yy0 / 100; - yy2 = yy0 % 100; - dow = ((26 * m1 - 2) / 10 + - 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; - if (dow < 0) - dow += DAYSPERWEEK; - - /* - ** "dow" is the day-of-week of the first day of the month. Get - ** the day-of-month (zero-origin) of the first "dow" day of the - ** month. - */ - d = rulep->r_day - dow; - if (d < 0) - d += DAYSPERWEEK; - for (i = 1; i < rulep->r_week; ++i) - { - if (d + DAYSPERWEEK >= - mon_lengths[leapyear][rulep->r_mon - 1]) - break; - d += DAYSPERWEEK; - } - - /* - ** "d" is the day-of-month (zero-origin) of the day we want. - */ - value += d * SECSPERDAY; - break; - } - - /* - ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in - ** question. To get the Epoch-relative time of the specified local - ** time on that day, add the transition time and the current offset - ** from GMT. - */ - return value + rulep->r_time + offset; -} - -/* -** Given a POSIX section 8-style TZ string, fill in the rule tables as -** appropriate. -*/ - -static int -tzparse(const char *name, struct state * CPP_CONST sp, const int lastditch) -{ - const char * stdname; - const char * dstname=0; - int stdlen; - int dstlen; - long stdoffset; - long dstoffset; - time_t * atp; - unsigned char * typep; - char * cp; - int load_result; - - stdname = name; - if (lastditch) - { - stdlen = strlen(name); /* length of standard zone name */ - name += stdlen; - if (stdlen >= sizeof sp->chars) - stdlen = (sizeof sp->chars) - 1; - } - else - { - name = getzname(name); - stdlen = name - stdname; - if (stdlen < 3) - return -1; - } - if (*name == '\0') - return -1; - else - { - name = getoffset(name, &stdoffset); - if (name == NULL) - return -1; - } - load_result = tzload(TZDEFRULES, sp); - if (load_result != 0) - sp->leapcnt = 0; /* so, we're off a little */ - if (*name != '\0') - { - dstname = name; - name = getzname(name); - dstlen = name - dstname; /* length of DST zone name */ - if (dstlen < 3) - return -1; - if (*name != '\0' && *name != ',' && *name != ';') - { - name = getoffset(name, &dstoffset); - if (name == NULL) - return -1; - } - else - dstoffset = stdoffset - SECSPERHOUR; - if (*name == ',' || *name == ';') - { - struct rule start; - struct rule end; - int year; - time_t janfirst; - time_t starttime; - time_t endtime; - - ++name; - if ((name = getrule(name, &start)) == NULL) - return -1; - if (*name++ != ',') - return -1; - if ((name = getrule(name, &end)) == NULL) - return -1; - if (*name != '\0') - return -1; - sp->typecnt = 2; /* standard time and DST */ - /* - ** Two transitions per year, from EPOCH_YEAR to 2037. - */ - sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); - if (sp->timecnt > TZ_MAX_TIMES) - return -1; - sp->ttis[0].tt_gmtoff = -dstoffset; - sp->ttis[0].tt_isdst = 1; - sp->ttis[0].tt_abbrind = stdlen + 1; - sp->ttis[1].tt_gmtoff = -stdoffset; - sp->ttis[1].tt_isdst = 0; - sp->ttis[1].tt_abbrind = 0; - atp = sp->ats; - typep = sp->types; - janfirst = 0; - for (year = EPOCH_YEAR; year <= 2037; ++year) - { - starttime = transtime(janfirst, year, &start, - stdoffset); - endtime = transtime(janfirst, year, &end, - dstoffset); - if (starttime > endtime) - { - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - } - else - { - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - } - janfirst += - year_lengths[isleap(year)] * SECSPERDAY; - } - } - else - { - int sawstd; - int sawdst; - long stdfix; - long dstfix; - long oldfix; - int isdst; - int i; - - if (*name != '\0') - return -1; - if (load_result != 0) - return -1; - /* - ** Compute the difference between the real and - ** prototype standard and summer time offsets - ** from GMT, and put the real standard and summer - ** time offsets into the rules in place of the - ** prototype offsets. - */ - sawstd = FALSE; - sawdst = FALSE; - stdfix = 0; - dstfix = 0; - for (i = 0; i < sp->typecnt; ++i) - { - if (sp->ttis[i].tt_isdst) - { - oldfix = dstfix; - dstfix = - sp->ttis[i].tt_gmtoff + dstoffset; - if (sawdst && (oldfix != dstfix)) - return -1; - sp->ttis[i].tt_gmtoff = -dstoffset; - sp->ttis[i].tt_abbrind = stdlen + 1; - sawdst = TRUE; - } - else - { - oldfix = stdfix; - stdfix = - sp->ttis[i].tt_gmtoff + stdoffset; - if (sawstd && (oldfix != stdfix)) - return -1; - sp->ttis[i].tt_gmtoff = -stdoffset; - sp->ttis[i].tt_abbrind = 0; - sawstd = TRUE; - } - } - /* - ** Make sure we have both standard and summer time. - */ - if (!sawdst || !sawstd) - return -1; - /* - ** Now correct the transition times by shifting - ** them by the difference between the real and - ** prototype offsets. Note that this difference - ** can be different in standard and summer time; - ** the prototype probably has a 1-hour difference - ** between standard and summer time, but a different - ** difference can be specified in TZ. - */ - isdst = FALSE; /* we start in standard time */ - for (i = 0; i < sp->timecnt; ++i) - { - const struct ttinfo * ttisp; - - /* - ** If summer time is in effect, and the - ** transition time was not specified as - ** standard time, add the summer time - ** offset to the transition time; - ** otherwise, add the standard time offset - ** to the transition time. - */ - ttisp = &sp->ttis[sp->types[i]]; - sp->ats[i] += - (isdst && !ttisp->tt_ttisstd) ? - dstfix : stdfix; - isdst = ttisp->tt_isdst; - } - } - } - else - { - dstlen = 0; - sp->typecnt = 1; /* only standard time */ - sp->timecnt = 0; - sp->ttis[0].tt_gmtoff = -stdoffset; - sp->ttis[0].tt_isdst = 0; - sp->ttis[0].tt_abbrind = 0; - } - sp->charcnt = stdlen + 1; - if (dstlen != 0) - sp->charcnt += dstlen + 1; - if (sp->charcnt > sizeof sp->chars) - return -1; - cp = sp->chars; - (void) strncpy(cp, stdname, stdlen); - cp += stdlen; - *cp++ = '\0'; - if (dstlen != 0) - { - (void) strncpy(cp, dstname, dstlen); - *(cp + dstlen) = '\0'; - } - return 0; -} - -static void -gmtload(struct state * CPP_CONST sp) -{ - if (tzload(GMT, sp) != 0) - (void) tzparse(GMT, sp, TRUE); -} - -/* - * @implemented - */ -void -_tzset(void) -{ - const char * name; - - name = getenv("TZ"); - if (name == NULL) - { - tzsetwall(); - return; - } - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) - { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) - { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (*name == '\0') - { - /* - ** User wants it fast rather than right. - */ - lclptr->leapcnt = 0; /* so, we're off a little */ - lclptr->timecnt = 0; - lclptr->ttis[0].tt_gmtoff = 0; - lclptr->ttis[0].tt_abbrind = 0; - (void) strcpy(lclptr->chars, GMT); - } - else if (tzload(name, lclptr) != 0) - if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) - gmtload(lclptr); - settzname(); -} - -void -tzsetwall(void) -{ - lcl_is_set = TRUE; -#ifdef ALL_STATE - if (lclptr == NULL) - { - lclptr = (struct state *) malloc(sizeof *lclptr); - if (lclptr == NULL) - { - settzname(); /* all we can do */ - return; - } - } -#endif /* defined ALL_STATE */ - if (tzload((char *) NULL, lclptr) != 0) - gmtload(lclptr); - settzname(); -} - -/* -** The easy way to behave "as if no library function calls" localtime -** is to not call it--so we drop its guts into "localsub", which can be -** freely called. (And no, the PANS doesn't require the above behavior-- -** but it *is* desirable.) -** -** The unused offset argument is for the benefit of mktime variants. -*/ - -/*ARGSUSED*/ -static void -localsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp) -{ - const struct state * sp; - const struct ttinfo * ttisp; - int i; - const time_t t = *timep; - - if (!lcl_is_set) - _tzset(); - sp = lclptr; -#ifdef ALL_STATE - if (sp == NULL) - { - gmtsub(timep, offset, tmp); - return; - } -#endif /* defined ALL_STATE */ - if (sp->timecnt == 0 || t < sp->ats[0]) - { - i = 0; - while (sp->ttis[i].tt_isdst) - if (++i >= sp->typecnt) - { - i = 0; - break; - } - } - else - { - for (i = 1; i < sp->timecnt; ++i) - if (t < sp->ats[i]) - break; - i = sp->types[i - 1]; - } - ttisp = &sp->ttis[i]; - /* - ** To get (wrong) behavior that's compatible with System V Release 2.0 - ** you'd replace the statement below with - ** t += ttisp->tt_gmtoff; - ** timesub(&t, 0L, sp, tmp); - */ - timesub(&t, ttisp->tt_gmtoff, sp, tmp); - tmp->tm_isdst = ttisp->tt_isdst; - _tzname[tmp->tm_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; - tmp->tm_zone = (char *)&sp->chars[ttisp->tt_abbrind]; -} - -/* - * @implemented - */ -struct tm * -localtime(const time_t * CPP_CONST timep) -{ - static struct tm tm; - - localsub(timep, 0L, &tm); - return &tm; -} - -/* -** gmtsub is to gmtime as localsub is to localtime. -*/ - -static void -gmtsub(const time_t * CPP_CONST timep, const long offset, struct tm * CPP_CONST tmp) -{ - if (!gmt_is_set) - { - gmt_is_set = TRUE; -#ifdef ALL_STATE - gmtptr = (struct state *) malloc(sizeof *gmtptr); - if (gmtptr != NULL) -#endif /* defined ALL_STATE */ - gmtload(gmtptr); - } - timesub(timep, offset, gmtptr, tmp); - /* - ** Could get fancy here and deliver something such as - ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, - ** but this is no time for a treasure hunt. - */ - if (offset != 0) - tmp->tm_zone = TZ_NAME; - else - { -#ifdef ALL_STATE - if (gmtptr == NULL) - tmp->TM_ZONE = GMT; - else - tmp->TM_ZONE = gmtptr->chars; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - tmp->tm_zone = gmtptr->chars; -#endif /* State Farm */ - } -} - -/* - * @implemented - */ -struct tm * -gmtime(const time_t * CPP_CONST timep) -{ - static struct tm tm; - - gmtsub(timep, 0L, &tm); - return &tm; -} - -static void -timesub(const time_t * CPP_CONST timep, const long offset, const struct state * CPP_CONST sp, struct tm * CPP_CONST tmp) -{ - const struct lsinfo * lp; - long days; - long rem; - int y; - int yleap; - const int * ip; - long corr; - int hit; - int i; - - corr = 0; - hit = FALSE; -#ifdef ALL_STATE - i = (sp == NULL) ? 0 : sp->leapcnt; -#endif /* defined ALL_STATE */ -#ifndef ALL_STATE - i = sp->leapcnt; -#endif /* State Farm */ - while (--i >= 0) - { - lp = &sp->lsis[i]; - if (*timep >= lp->ls_trans) - { - if (*timep == lp->ls_trans) - hit = ((i == 0 && lp->ls_corr > 0) || - lp->ls_corr > sp->lsis[i - 1].ls_corr); - corr = lp->ls_corr; - break; - } - } - days = *timep / SECSPERDAY; - rem = *timep % SECSPERDAY; -#ifdef mc68k - if (*timep == 0x80000000) - { - /* - ** A 3B1 muffs the division on the most negative number. - */ - days = -24855; - rem = -11648; - } -#endif /* mc68k */ - rem += (offset - corr); - while (rem < 0) - { - rem += SECSPERDAY; - --days; - } - while (rem >= SECSPERDAY) - { - rem -= SECSPERDAY; - ++days; - } - tmp->tm_hour = (int) (rem / SECSPERHOUR); - rem = rem % SECSPERHOUR; - tmp->tm_min = (int) (rem / SECSPERMIN); - tmp->tm_sec = (int) (rem % SECSPERMIN); - if (hit) - /* - ** A positive leap second requires a special - ** representation. This uses "... ??:59:60". - */ - ++(tmp->tm_sec); - tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); - if (tmp->tm_wday < 0) - tmp->tm_wday += DAYSPERWEEK; - y = EPOCH_YEAR; - if (days >= 0) - for ( ; ; ) - { - yleap = isleap(y); - if (days < (long) year_lengths[yleap]) - break; - ++y; - days = days - (long) year_lengths[yleap]; - } - else - do { - --y; - yleap = isleap(y); - days = days + (long) year_lengths[yleap]; - } while (days < 0); - tmp->tm_year = y - TM_YEAR_BASE; - tmp->tm_yday = (int) days; - ip = mon_lengths[yleap]; - for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) - days = days - (long) ip[tmp->tm_mon]; - tmp->tm_mday = (int) (days + 1); - tmp->tm_isdst = 0; - tmp->tm_gmtoff = offset; -} - -/* -** A la X3J11 -*/ - -/* - * @implemented - */ -char * -asctime(const struct tm *timeptr) -{ - static const char wday_name[DAYSPERWEEK][3] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - static const char mon_name[MONSPERYEAR][3] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - static char result[26]; - - (void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n", - wday_name[timeptr->tm_wday], - mon_name[timeptr->tm_mon], - timeptr->tm_mday, timeptr->tm_hour, - timeptr->tm_min, timeptr->tm_sec, - TM_YEAR_BASE + timeptr->tm_year); - return result; -} - -/* - * @implemented - */ -char * -ctime(const time_t * CPP_CONST timep) -{ - return asctime(localtime(timep)); -} - -/* -** Adapted from code provided by Robert Elz, who writes: -** The "best" way to do mktime I think is based on an idea of Bob -** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). -** It does a binary search of the time_t space. Since time_t's are -** just 32 bits, its a max of 32 iterations (even at 64 bits it -** would still be very reasonable). -*/ - -#ifndef WRONG -#define WRONG (-1) -#endif /* !defined WRONG */ - -static void -normalize(int * CPP_CONST tensptr, int * CPP_CONST unitsptr, const int base) -{ - if (*unitsptr >= base) - { - *tensptr += *unitsptr / base; - *unitsptr %= base; - } - else if (*unitsptr < 0) - { - --*tensptr; - *unitsptr += base; - if (*unitsptr < 0) - { - *tensptr -= 1 + (-*unitsptr) / base; - *unitsptr = base - (-*unitsptr) % base; - } - } -} - -static int -tmcomp(const struct tm * CPP_CONST atmp, const struct tm * CPP_CONST btmp) -{ - int result; - - if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && - (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && - (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && - (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && - (result = (atmp->tm_min - btmp->tm_min)) == 0) - result = atmp->tm_sec - btmp->tm_sec; - return result; -} - -static time_t -time2(struct tm *tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset, int * CPP_CONST okayp) -{ - const struct state * sp; - int dir; - int bits; - int i, j ; - int saved_seconds; - time_t newt; - time_t t; - struct tm yourtm, mytm; - - *okayp = FALSE; - yourtm = *tmp; - if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) - normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); - normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); - normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); - normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); - while (yourtm.tm_mday <= 0) - { - --yourtm.tm_year; - yourtm.tm_mday += - year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; - } - for ( ; ; ) - { - i = mon_lengths[isleap(yourtm.tm_year + - TM_YEAR_BASE)][yourtm.tm_mon]; - if (yourtm.tm_mday <= i) - break; - yourtm.tm_mday -= i; - if (++yourtm.tm_mon >= MONSPERYEAR) - { - yourtm.tm_mon = 0; - ++yourtm.tm_year; - } - } - saved_seconds = yourtm.tm_sec; - yourtm.tm_sec = 0; - /* - ** Calculate the number of magnitude bits in a time_t - ** (this works regardless of whether time_t is - ** signed or unsigned, though lint complains if unsigned). - */ - for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) - ; - /* - ** If time_t is signed, then 0 is the median value, - ** if time_t is unsigned, then 1 << bits is median. - */ -#ifdef _MSVCRT_LIB_ - t = (time_t) ((1 << bits) - 1); -#else // TODO: FIXME: review which is correct - t = (time_t) 1 << bits; -#endif /*_MSVCRT_LIB_*/ - - for ( ; ; ) - { - (*funcp)(&t, offset, &mytm); - dir = tmcomp(&mytm, &yourtm); - if (dir != 0) - { - if (bits-- < 0) - return WRONG; - if (bits < 0) - --t; - else if (dir > 0) - t -= (time_t) 1 << bits; - else t += (time_t) 1 << bits; - continue; - } - if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) - break; - /* - ** Right time, wrong type. - ** Hunt for right time, right type. - ** It's okay to guess wrong since the guess - ** gets checked. - */ - sp = (const struct state *) - ((funcp == localsub) ? lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (i = 0; i < sp->typecnt; ++i) - { - if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) - continue; - for (j = 0; j < sp->typecnt; ++j) - { - if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) - continue; - newt = t + sp->ttis[j].tt_gmtoff - - sp->ttis[i].tt_gmtoff; - (*funcp)(&newt, offset, &mytm); - if (tmcomp(&mytm, &yourtm) != 0) - continue; - if (mytm.tm_isdst != yourtm.tm_isdst) - continue; - /* - ** We have a match. - */ - t = newt; - goto label; - } - } - return WRONG; - } - label: - t += saved_seconds; - (*funcp)(&t, offset, tmp); - *okayp = TRUE; - return t; -} - -static time_t -time1(struct tm * CPP_CONST tmp, void (*const funcp)(const time_t * CPP_CONST, const long, struct tm *), const long offset) -{ - time_t t; - const struct state * sp; - int samei, otheri; - int okay; - - if (tmp->tm_isdst > 1) - tmp->tm_isdst = 1; - t = time2(tmp, funcp, offset, &okay); - if (okay || tmp->tm_isdst < 0) - return t; - /* - ** We're supposed to assume that somebody took a time of one type - ** and did some math on it that yielded a "struct tm" that's bad. - ** We try to divine the type they started from and adjust to the - ** type they need. - */ - sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); -#ifdef ALL_STATE - if (sp == NULL) - return WRONG; -#endif /* defined ALL_STATE */ - for (samei = 0; samei < sp->typecnt; ++samei) - { - if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) - continue; - for (otheri = 0; otheri < sp->typecnt; ++otheri) - { - if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) - continue; - tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - t = time2(tmp, funcp, offset, &okay); - if (okay) - return t; - tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - - sp->ttis[samei].tt_gmtoff; - tmp->tm_isdst = !tmp->tm_isdst; - } - } - return WRONG; -} - -/* - * @implemented - */ -time_t -mktime(struct tm * tmp) -{ - return time1(tmp, localsub, 0L); -}