* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
* $Author: ekohl $
- * $Date: 2001/07/03 22:15:02 $
+ * $Date: 2001/07/06 12:50:47 $
*
*/
int _wchdir(const wchar_t *szPath);
wchar_t* _wgetcwd(wchar_t *buffer, int maxlen);
int _wmkdir(const wchar_t *_path);
+wchar_t* _wmktemp (wchar_t *_template);
int _wrmdir(const wchar_t *_path);
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 12:55:00 $
+ * $Date: 2001/07/06 12:50:47 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
/*
* File Operations
*/
+FILE* _fdopen(int handle, char *mode);
+FILE* _wfdopen(int handle, wchar_t *mode);
FILE* fopen (const char* szFileName, const char* szMode);
-FILE* freopen (const char* szNewFileName, const char* szNewMode,
- FILE* fileChangeAssociation);
-int fflush (FILE* fileFlush);
-int fclose (FILE* fileClose);
+FILE* _wfopen(const wchar_t *file, const wchar_t *mode);
+
+FILE* freopen(const char* szNewFileName, const char* szNewMode,
+ FILE* fileChangeAssociation);
+FILE* _wfreopen(const wchar_t *file, const wchar_t *mode, FILE *f);
+
+FILE* _fsopen(const char *file, const char *mode, int shflag);
+FILE* _wfsopen(const wchar_t *file, const wchar_t *mode, int shflag);
+
+int fflush(FILE* fileFlush);
+int fclose(FILE* fileClose);
#define fcloseall _fcloseall
-int remove (const char* szFileName);
-int _wremove (const wchar_t* szFileName);
-int rename (const char* szOldFileName, const char* szNewFileName);
-FILE* tmpfile (void);
+int remove(const char* szFileName);
+int _wremove(const wchar_t* szFileName);
+int rename(const char* szOldFileName, const char* szNewFileName);
+int _wrename(const wchar_t *oldName, const wchar_t *newName);
+FILE* tmpfile(void);
int _filbuf(FILE *f);
-int _flsbuf(int c, FILE *f);
+int _flsbuf(int c, FILE *f);
void _fwalk(void (*func)(FILE *)); // not exported
-int _fcloseall( void );
+int _fcloseall(void);
/*
#define L_tmpnam (260)
char* tmpnam (char caName[]);
+wchar_t* _wtmpnam(wchar_t *s);
+
char* _tempnam (const char *szDir, const char *szPfx);
+wchar_t *_wtempnam(const wchar_t *dir,const wchar_t *prefix);
#ifndef _NO_OLDNAMES
#define tempnam _tempnam
int _pclose (FILE* pipeClose);
FILE* _popen (const char* szPipeName, const char* szMode);
+FILE* _wpopen (const wchar_t *cm, const wchar_t *md);
#define popen _popen
#define pclose _pclose
void perror (const char* szErrorMessage);
#endif
+void _wperror(const wchar_t *s);
+
#define clearerr(f) (((f)->_flag) &= ~(_IOERR|_IOEOF))
#define feof(f) (((f)->_flag&_IOEOF)!=0)
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 12:55:00 $
+ * $Date: 2001/07/06 12:50:47 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
struct tm* gmtime (const time_t* tm);
struct tm* localtime (const time_t* tm);
+char* _strdate(const char *datestr);
+wchar_t* _wstrdate(const wchar_t *datestr);
size_t strftime (char* caBuffer, size_t sizeMax, const char* szFormat,
const struct tm* tpPrint);
size_t wcsftime (wchar_t* wcaBuffer, size_t sizeMax,
const wchar_t* wsFormat, const struct tm* tpPrint);
+char* _strtime(char* buf);
+wchar_t* _wstrtime(wchar_t* buf);
+
#ifdef __cplusplus
}
#endif
-# $Id: Makefile,v 1.15 2001/07/06 00:58:15 ekohl Exp $
+# $Id: Makefile,v 1.16 2001/07/06 12:53:03 ekohl Exp $
#
# ReactOS Operating System
#
stdlib/atol.o \
stdlib/bsearch.o \
stdlib/div.o \
+ stdlib/ecvt.o \
+ stdlib/ecvtbuf.o \
stdlib/errno.o \
+ stdlib/fcvt.o \
+ stdlib/fcvtbuf.o \
stdlib/fullpath.o \
+ stdlib/gcvt.o \
stdlib/getenv.o \
stdlib/itoa.o \
stdlib/itow.o \
sys_stat/stat.o
OBJECTS_TIME = \
- time/time.o \
- time/ctime.o
+ time/clock.o \
+ time/ctime.o \
+ time/difftime.o \
+ time/strdate.o \
+ time/strftime.o \
+ time/strtime.o \
+ time/time.o
OBJECTS_WSTRING = \
wstring/wcscat.o \
-; $Id: msvcrt.def,v 1.10 2001/07/06 00:58:15 ekohl Exp $
+; $Id: msvcrt.def,v 1.11 2001/07/06 12:53:03 ekohl Exp $
;
; ReactOS MSVCRT Compatibility Library
;
; _dstbias
_dup
_dup2
-; _ecvt
+_ecvt
_endthread
_endthreadex
_environ_dll DATA
_exit
; _expand
_fcloseall
-; _fcvt
+_fcvt
_fdopen
_fgetchar
_fgetwchar
_ftol
_fullpath
_futime
-; _gcvt
+_gcvt
_get_osfhandle
; _get_sbh_threshold
_getch
_stati64
_statusfp
_strcmpi
-; _strdate
+_strdate
_strdup
_strerror
_stricmp
_winver DATA
_wmakepath
_wmkdir
-; _wmktemp
+_wmktemp
_wopen
_wperror
; _wpgmptr DATA
_wsplitpath
_wstat
_wstati64
-; _wstrdate
-; _wstrtime
+_wstrdate
+_wstrtime
; _wsystem
_wtempnam
_wtmpnam
calloc
ceil
clearerr
-; clock
+clock
cos
cosh
ctime
-; difftime
+difftime
div
exit
exp
strcpy
strcspn
strerror
-; strftime
+strftime
strlen
strncat
strncmp
wcscoll
wcscpy
wcscspn
-; wcsftime
+wcsftime
wcslen
wcsncat
wcsncmp
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/time/clock.c
+ * PURPOSE: Get elapsed time
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+
+#include <windows.h>
+#include <msvcrt/time.h>
+#include <msvcrt/internal/file.h>
+
+VOID STDCALL GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime );
+
+clock_t clock ( void )
+{
+ FILETIME CreationTime;
+ FILETIME ExitTime;
+ FILETIME KernelTime;
+ FILETIME UserTime;
+ DWORD Remainder;
+
+ if (!GetProcessTimes(GetCurrentProcess(),&CreationTime,&ExitTime,&KernelTime,&UserTime))
+ return -1;
+
+ return FileTimeToUnixTime(&KernelTime,&Remainder) + FileTimeToUnixTime(&UserTime,&Remainder);
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/time.h>
+
+double
+difftime(time_t time1, time_t time0)
+{
+ return time1-time0;
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/time/strtime.c
+ * PURPOSE: Fills a buffer with a formatted date representation
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <msvcrt/time.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+char *_strdate( const char *datestr )
+{
+ time_t t;
+ struct tm *d;
+ char *dt = (char *)datestr;
+
+ if ( datestr == NULL )
+ {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ t = time(NULL);
+ d = localtime(&t);
+ sprintf(dt,"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
+ return dt;
+}
+
+wchar_t *_wstrdate( const wchar_t *datestr )
+{
+ time_t t;
+ struct tm *d;
+ wchar_t *dt = (wchar_t *)datestr;
+
+ if ( datestr == NULL )
+ {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ t = time(NULL);
+ d = localtime(&t);
+ swprintf(dt,L"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
+ return dt;
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/string.h>
+#include <msvcrt/time.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/wchar.h>
+
+#define TM_YEAR_BASE 1900
+
+static const char *afmt[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
+};
+static const char *Afmt[] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
+ "Saturday",
+};
+static const char *bfmt[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
+ "Oct", "Nov", "Dec",
+};
+static const char *Bfmt[] = {
+ "January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December",
+};
+
+static size_t gsize;
+static char *pt;
+
+static int
+_add(const char *str)
+{
+ for (;; ++pt, --gsize)
+ {
+ if (!gsize)
+ return 0;
+ if (!(*pt = *str++))
+ return 1;
+ }
+}
+
+static int
+_conv(int n, int digits, char pad)
+{
+ static char buf[10];
+ char *p;
+
+ for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits)
+ *p-- = n % 10 + '0';
+ while (p > buf && digits-- > 0)
+ *p-- = pad;
+ return _add(++p);
+}
+
+static size_t
+_fmt(const char *format, const struct tm *t)
+{
+ for (; *format; ++format)
+ {
+ if (*format == '%') {
+ if (*(format+1) == '#' ) {format++;}
+
+ switch(*++format)
+ {
+ case '\0':
+ --format;
+ break;
+ case 'A':
+ if (t->tm_wday < 0 || t->tm_wday > 6)
+ return 0;
+ if (!_add(Afmt[t->tm_wday]))
+ return 0;
+ continue;
+ case 'a':
+ if (t->tm_wday < 0 || t->tm_wday > 6)
+ return 0;
+ if (!_add(afmt[t->tm_wday]))
+ return 0;
+ continue;
+ case 'B':
+ if (t->tm_mon < 0 || t->tm_mon > 11)
+ return 0;
+ if (!_add(Bfmt[t->tm_mon]))
+ return 0;
+ continue;
+ case 'b':
+ case 'h':
+ if (t->tm_mon < 0 || t->tm_mon > 11)
+ return 0;
+ if (!_add(bfmt[t->tm_mon]))
+ return 0;
+ continue;
+ case 'C':
+ if (!_fmt("%a %b %e %H:%M:%S %Y", t))
+ return 0;
+ continue;
+ case 'c':
+ if (!_fmt("%m/%d/%y %H:%M:%S", t))
+ return 0;
+ continue;
+ case 'e':
+ if (!_conv(t->tm_mday, 2, ' '))
+ return 0;
+ continue;
+ case 'D':
+ if (!_fmt("%m/%d/%y", t))
+ return 0;
+ continue;
+ case 'd':
+ if (!_conv(t->tm_mday, 2, '0'))
+ return 0;
+ continue;
+ case 'H':
+ if (!_conv(t->tm_hour, 2, '0'))
+ return 0;
+ continue;
+ case 'I':
+ if (!_conv(t->tm_hour % 12 ?
+ t->tm_hour % 12 : 12, 2, '0'))
+ return 0;
+ continue;
+ case 'j':
+ if (!_conv(t->tm_yday + 1, 3, '0'))
+ return 0;
+ continue;
+ case 'k':
+ if (!_conv(t->tm_hour, 2, ' '))
+ return 0;
+ continue;
+ case 'l':
+ if (!_conv(t->tm_hour % 12 ?
+ t->tm_hour % 12 : 12, 2, ' '))
+ return 0;
+ continue;
+ case 'M':
+ if (!_conv(t->tm_min, 2, '0'))
+ return 0;
+ continue;
+ case 'm':
+ if (!_conv(t->tm_mon + 1, 2, '0'))
+ return 0;
+ continue;
+ case 'n':
+ if (!_add("\n"))
+ return 0;
+ continue;
+ case 'p':
+ if (!_add(t->tm_hour >= 12 ? "PM" : "AM"))
+ return 0;
+ continue;
+ case 'R':
+ if (!_fmt("%H:%M", t))
+ return 0;
+ continue;
+ case 'r':
+ if (!_fmt("%I:%M:%S %p", t))
+ return 0;
+ continue;
+ case 'S':
+ if (!_conv(t->tm_sec, 2, '0'))
+ return 0;
+ continue;
+ case 'T':
+ case 'X':
+ if (!_fmt("%H:%M:%S", t))
+ return 0;
+ continue;
+ case 't':
+ if (!_add("\t"))
+ return 0;
+ continue;
+ case 'U':
+ if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7,
+ 2, '0'))
+ return 0;
+ continue;
+ case 'W':
+ if (!_conv((t->tm_yday + 7 -
+ (t->tm_wday ? (t->tm_wday - 1) : 6))
+ / 7, 2, '0'))
+ return 0;
+ continue;
+ case 'w':
+ if (!_conv(t->tm_wday, 1, '0'))
+ return 0;
+ continue;
+ case 'x':
+ if (!_fmt("%m/%d/%y", t))
+ return 0;
+ continue;
+ case 'y':
+ if (!_conv((t->tm_year + TM_YEAR_BASE)
+ % 100, 2, '0'))
+ return 0;
+ continue;
+ case 'Y':
+ if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0'))
+ return 0;
+ continue;
+ case 'Z':
+ if (!t->tm_zone || !_add(t->tm_zone))
+ return 0;
+ continue;
+ case '%':
+ /*
+ * X311J/88-090 (4.12.3.5): if conversion char is
+ * undefined, behavior is undefined. Print out the
+ * character itself as printf(3) does.
+ */
+ default:
+ break;
+ }
+ }
+ if (!gsize--)
+ return 0;
+ *pt++ = *format;
+ }
+ return gsize;
+}
+
+size_t
+strftime(char *s, size_t maxsize, const char *format, const struct tm *t)
+{
+ pt = s;
+ if ((gsize = maxsize) < 1)
+ return 0;
+ if (_fmt(format, t))
+ {
+ *pt = '\0';
+ return maxsize - gsize;
+ }
+ return 0;
+}
+
+size_t
+wcsftime(wchar_t *s, size_t maxsize, const wchar_t *format, const struct tm *t)
+{
+ char *x;
+ char *f;
+ int i,j;
+ x = malloc(maxsize);
+ j = wcslen(format);
+ f = malloc(j+1);
+ for(i=0;i<j;i++)
+ f[i] = (char)*format;
+ f[i] = 0;
+ pt = x;
+ if ((gsize = maxsize) < 1)
+ return 0;
+ if (_fmt(f, t))
+ {
+ *pt = '\0';
+ free(f);
+ for(i=0;i<maxsize;i++)
+ s[i] = (wchar_t)x[i];
+ s[i] = 0;
+ free(x);
+ return maxsize - gsize;
+ }
+ for(i=0;i<maxsize;i++)
+ s[i] = (wchar_t)x[i];
+ s[i] = 0;
+ free(f);
+ free(x);
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/msvcrt/time/strtime.c
+ * PURPOSE: Fills a buffer with a formatted time representation
+ * PROGRAMER: Boudewijn Dekker
+ * UPDATE HISTORY:
+ * 28/12/98: Created
+ */
+#include <msvcrt/time.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+char *_strtime(char* buf)
+{
+ time_t t;
+ struct tm *d;
+ char *dt = (char *)buf;
+
+ if ( buf == NULL )
+ {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ t = time(NULL);
+ d = localtime(&t);
+ sprintf(dt,"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec);
+ return dt;
+}
+
+wchar_t *_wstrtime(wchar_t* buf)
+{
+ time_t t;
+ struct tm *d;
+ wchar_t *dt = (wchar_t *)buf;
+
+ if ( buf == NULL )
+ {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ t = time(NULL);
+ d = localtime(&t);
+ swprintf(dt,L"%d:%d:%d",d->tm_hour,d->tm_min,d->tm_sec);
+ return dt;
+}