mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
no message
svn path=/trunk/; revision=561
This commit is contained in:
parent
fdb2041671
commit
62cdaf7f99
25 changed files with 303 additions and 99 deletions
|
@ -55,6 +55,8 @@ int __fileno_dup2( int handle1, int handle2 );
|
|||
int __fileno_setmode(int _fd, int _newmode);
|
||||
int __fileno_close(int _fd);
|
||||
|
||||
void sigabort_handler(int sig);
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
void UnixTimeToFileTime( time_t unix_time, FILETIME *filetime, DWORD remainder );
|
||||
|
|
|
@ -7,6 +7,11 @@ extern "C" {
|
|||
|
||||
#include <crtdll/stddef.h>
|
||||
|
||||
size_t _mbstrlen(const char *str);
|
||||
|
||||
|
||||
|
||||
|
||||
int _mbbtype(unsigned char c, int type);
|
||||
int _mbsbtype( const unsigned char *str, size_t n );
|
||||
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
#include <crtdll/assert.h>
|
||||
#include <crtdll/stdio.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/signal.h>
|
||||
|
||||
void _assert(const char *msg, const char *file, int line)
|
||||
{
|
||||
/* Assertion failed at foo.c line 45: x<y */
|
||||
fprintf(stderr, "Assertion failed at %s line %d: %s\n", file, line, msg);
|
||||
// raise(SIGABRT);
|
||||
exit(1);
|
||||
for(;;);
|
||||
raise(SIGABRT);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ _cscanf(char *fmt, ...)
|
|||
|
||||
va_list ap;
|
||||
|
||||
// fixme cscanf
|
||||
printf("cscanf \n");
|
||||
//fixme cscanf should scan the console's keyboard
|
||||
|
||||
va_start(ap, fmt);
|
||||
cnt = __vscanf(fmt, ap);
|
||||
|
|
|
@ -24,7 +24,7 @@ _kbhit(void)
|
|||
if (char_avail)
|
||||
return(1);
|
||||
else {
|
||||
printf("fixeme PeekConsoleInput might do DeviceIo \n");
|
||||
//FIXME PeekConsoleInput might do DeviceIo
|
||||
//PeekConsoleInput((HANDLE)stdin->_file,&InputRecord,1,&NumberRead);
|
||||
return NumberRead;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ int _getdrive( void )
|
|||
|
||||
unsigned long _getdrives(void)
|
||||
{
|
||||
return printf("get logical drives\n");
|
||||
//fixme get logical drives
|
||||
//return GetLogicalDrives();
|
||||
return 5; // drive A and C
|
||||
}
|
|
@ -7,8 +7,13 @@
|
|||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
#include <crtdll/io.h>
|
||||
|
||||
// rember to interlock the allocation of fileno when making this thread safe
|
||||
|
||||
// possibly store extra information at the handle
|
||||
|
||||
#include <windows.h>
|
||||
#include <crtdll/io.h>
|
||||
#include <crtdll/fcntl.h>
|
||||
#include <crtdll/sys/stat.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
|
|
|
@ -17,7 +17,7 @@ char *setlocale(int category, const char *locale)
|
|||
char code_page[100];
|
||||
parse_locale((char *)locale,lang,country,code_page);
|
||||
|
||||
printf("%s %s %s %s\n",locale,lang,country,code_page);
|
||||
//printf("%s %s %s %s\n",locale,lang,country,code_page);
|
||||
|
||||
|
||||
switch ( category )
|
||||
|
@ -115,26 +115,26 @@ const struct map_cntr {
|
|||
};
|
||||
|
||||
|
||||
struct lconv _lconv = {
|
||||
'.', // decimal_point
|
||||
',', // thousands_sep
|
||||
"", // grouping;
|
||||
"DOL", // int_curr_symbol
|
||||
"$", // currency_symbol
|
||||
'.', // mon_decimal_point
|
||||
',', // mon_thousands_sep
|
||||
"", // mon_grouping;
|
||||
'+', // positive_sign
|
||||
'-', // negative_sign
|
||||
2, // int_frac_digits
|
||||
2, // frac_digits
|
||||
1, // p_cs_precedes
|
||||
1, // p_sep_by_space
|
||||
1, // n_cs_precedes
|
||||
1, // n_sep_by_space
|
||||
1, // p_sign_posn;
|
||||
1 // n_sign_posn;
|
||||
};
|
||||
struct lconv _lconv = {
|
||||
".", // decimal_point
|
||||
",", // thousands_sep
|
||||
"", // grouping;
|
||||
"DOL", // int_curr_symbol
|
||||
"$", // currency_symbol
|
||||
".", // mon_decimal_point
|
||||
",", // mon_thousands_sep
|
||||
"", // mon_grouping;
|
||||
"+", // positive_sign
|
||||
"-", // negative_sign
|
||||
127, // int_frac_digits
|
||||
127, // frac_digits
|
||||
127, // p_cs_precedes
|
||||
127, // p_sep_by_space
|
||||
127, // n_cs_precedes
|
||||
127, // n_sep_by_space
|
||||
127, // p_sign_posn;
|
||||
127 // n_sign_posn;
|
||||
};
|
||||
|
||||
struct lconv *localeconv(void)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
unsigned char * _mbsstr(const unsigned char *str1, const unsigned char *str2)
|
||||
#include <crtdll/mbstring.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
|
||||
unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2)
|
||||
{
|
||||
return strstr(str1,str2);
|
||||
int len;
|
||||
|
||||
if(src2 ==NULL || *src2 == 0)
|
||||
return src1;
|
||||
|
||||
len = _mbstrlen(src2);
|
||||
|
||||
while(*src1)
|
||||
{
|
||||
if((*src1 == *src2) && (_mbsncmp(src1,src2,len) == 0))
|
||||
return(src1);
|
||||
src1 = (unsigned char *)_mbsinc(src1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
int system(const char *command)
|
||||
{
|
||||
char szCmdLine[MAX_PATH];
|
||||
char *szComSpec;
|
||||
char *szComSpec=NULL;
|
||||
|
||||
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
int _getpid (void)
|
||||
{
|
||||
printf("get current processid\n");
|
||||
//fixme GetCurrentProcessId
|
||||
//return (int)GetCurrentProcessId();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,17 +83,17 @@ static int go32_exec(const char *program, char **argv, char **envp)
|
|||
args[0] = 0;
|
||||
|
||||
while(argv[i] != NULL ) {
|
||||
strcat(args,envp[i]);
|
||||
strcat(args," ");
|
||||
i++;
|
||||
strcat(args,envp[i]);
|
||||
strcat(args," ");
|
||||
i++;
|
||||
}
|
||||
printf("%s \n %s\n",args, GetEnvironmentStrings());
|
||||
|
||||
args[0] = 0;
|
||||
i = 0;
|
||||
i = 0;
|
||||
while(argv[i] != NULL ) {
|
||||
strcat(args,argv[i]);
|
||||
strcat(args," ");
|
||||
i++;
|
||||
strcat(args,argv[i]);
|
||||
strcat(args," ");
|
||||
i++;
|
||||
}
|
||||
|
||||
return direct_exec_tail(program,args,envp);
|
||||
|
|
|
@ -22,7 +22,7 @@ unsigned long
|
|||
}
|
||||
void _endthread(void)
|
||||
{
|
||||
printf("fixme ExitThread\n");
|
||||
//fixme ExitThread
|
||||
//ExitThread(0);
|
||||
for(;;);
|
||||
}
|
|
@ -1,59 +1,107 @@
|
|||
/* Copyright (C) 1994, 1995 Charles Sandmann (sandmann@clio.rice.edu)
|
||||
Exception handling and basis for signal support for DJGPP V2.0
|
||||
This software may be freely distributed, no warranty. */
|
||||
|
||||
#include <crtdll/signal.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/string.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
//extern unsigned end __asm__ ("end");
|
||||
void _default_handler(int signal);
|
||||
|
||||
void __djgpp_traceback_exit(int);
|
||||
typedef struct _sig_element
|
||||
{
|
||||
int signal;
|
||||
char *signame;
|
||||
_p_sig_fn_t handler;
|
||||
} sig_element;
|
||||
|
||||
static _p_sig_fn_t signal_list[SIGMAX]; /* SIG_DFL = 0 */
|
||||
static sig_element signal_list[SIGMAX] =
|
||||
{
|
||||
{ 0, "Signal 0", SIG_DFL },
|
||||
{ SIGABRT, "Aborted",SIG_DFL },
|
||||
{ SIGFPE, "Erroneous arithmetic operation",SIG_DFL },
|
||||
{ SIGILL, "Illegal instruction",SIG_DFL },
|
||||
{ SIGINT, "Interrupt",SIG_DFL },
|
||||
{ SIGSEGV, "Invalid access to storage",SIG_DFL },
|
||||
{ SIGTERM, "Terminated",SIG_DFL },
|
||||
{ SIGHUP, "Hangup",SIG_DFL },
|
||||
{ SIGQUIT, "Quit",SIG_DFL },
|
||||
{ SIGPIPE, "Broken pipe",SIG_DFL },
|
||||
{ SIGKILL, "Killed",SIG_DFL },
|
||||
{ SIGALRM, "Alarm clock",SIG_DFL },
|
||||
{ 0, "Stopped (signal)",SIG_DFL },
|
||||
{ 0, "Stopped",SIG_DFL },
|
||||
{ 0, "Continued",SIG_DFL },
|
||||
{ 0, "Child exited",SIG_DFL },
|
||||
{ 0, "Stopped (tty input)",SIG_DFL },
|
||||
{ 0, "Stopped (tty output)",SIG_DFL },
|
||||
{ 0, NULL, SIG_DFL }
|
||||
};
|
||||
|
||||
int nsignal = 21;
|
||||
|
||||
_p_sig_fn_t signal(int sig, _p_sig_fn_t func)
|
||||
{
|
||||
_p_sig_fn_t temp;
|
||||
int i;
|
||||
if(sig <= 0 || sig > SIGMAX || sig == SIGKILL)
|
||||
{
|
||||
//errno = EINVAL;
|
||||
__set_errno(EINVAL);
|
||||
return SIG_ERR;
|
||||
}
|
||||
temp = signal_list[sig - 1];
|
||||
signal_list[sig - 1] = func;
|
||||
// check with IsBadCodePtr
|
||||
|
||||
if ( func < (_p_sig_fn_t)4096 ) {
|
||||
__set_errno(EINVAL);
|
||||
return SIG_ERR;
|
||||
}
|
||||
|
||||
for(i=0;i<nsignal;i++) {
|
||||
if ( signal_list[i].signal == sig ) {
|
||||
temp = signal_list[i].handler;
|
||||
signal_list[i].handler = func;
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
temp = signal_list[i].handler;
|
||||
signal_list[i].handler = func;
|
||||
signal_list[i].signal = sig;
|
||||
signal_list[i].signame = "";
|
||||
nsignal++;
|
||||
return temp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
raise(int sig)
|
||||
{
|
||||
#if 0
|
||||
_p_sig_fn_t temp;
|
||||
|
||||
_p_sig_fn_t temp = SIG_DFL;
|
||||
int i;
|
||||
if(sig <= 0)
|
||||
return -1;
|
||||
if(sig > SIGMAX)
|
||||
return -1;
|
||||
temp = signal_list[sig - 1];
|
||||
for(i=0;i<nsignal;i++) {
|
||||
if ( signal_list[i].signal == sig ) {
|
||||
temp = signal_list[i].handler;
|
||||
}
|
||||
}
|
||||
if(temp == (_p_sig_fn_t)SIG_IGN
|
||||
|| (sig == SIGQUIT && temp == (_p_sig_fn_t)SIG_DFL))
|
||||
return 0; /* Ignore it */
|
||||
if(temp == (_p_sig_fn_t)SIG_DFL)
|
||||
__djgpp_traceback_exit(sig); /* this does not return */
|
||||
else if((unsigned)temp < 4096 || temp > (_p_sig_fn_t)&end)
|
||||
{
|
||||
// err("Bad signal handler, ");
|
||||
__djgpp_traceback_exit(sig); /* does not return */
|
||||
}
|
||||
_default_handler(sig); /* this does not return */
|
||||
else
|
||||
temp(sig);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __djgpp_traceback_exit(int sig)
|
||||
|
||||
|
||||
void _default_handler(int sig)
|
||||
{
|
||||
_exit(3);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@ int _XcptFilter (
|
|||
struct _EXCEPTION_POINTERS * ExceptionInfo
|
||||
)
|
||||
{
|
||||
return printf("Unhandled exception info\n");
|
||||
//fixme XcptFilter
|
||||
// return UnhandledExceptionFilter(ExceptionInfo);
|
||||
}
|
|
@ -22,14 +22,6 @@ Cambridge, MA 02139, USA. */
|
|||
#include <crtdll/wchar.h>
|
||||
#include <crtdll/alloc.h>
|
||||
|
||||
#if 0
|
||||
|
||||
int fscanf(FILE *stream,const char *format, ...)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
int __vfscanf (FILE *s, const char *format, va_list argptr);
|
||||
/* Read formatted input from STREAM according to the format string FORMAT. */
|
||||
|
@ -54,7 +46,7 @@ fwscanf(FILE *stream, const wchar_t *fmt, ...)
|
|||
char *cf;
|
||||
int i,len = wcslen(fmt);
|
||||
|
||||
cf = alloca(len+1);
|
||||
cf = malloc(len+1);
|
||||
for(i=0;i<len;i++)
|
||||
cf[i] = fmt[i];
|
||||
cf[i] = 0;
|
||||
|
@ -62,8 +54,7 @@ fwscanf(FILE *stream, const wchar_t *fmt, ...)
|
|||
va_start(arg, fmt);
|
||||
done = __vfscanf(stream, cf, arg);
|
||||
va_end(arg);
|
||||
|
||||
free(cf);
|
||||
return done;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@ _popen (const char *cm, const char *md) /* program name, pipe mode */
|
|||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
|
||||
printf("CreatePipe\n");
|
||||
// fixme CreatePipe
|
||||
|
||||
// if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024))
|
||||
// return NULL;
|
||||
|
|
|
@ -670,7 +670,7 @@ __vfprintf(FILE *f, const char *fmt, va_list args)
|
|||
while (--field_width > 0)
|
||||
putc( ' ',f);
|
||||
continue;
|
||||
|
||||
case 'S':
|
||||
case 'w':
|
||||
sw = va_arg(args,short int *);
|
||||
// DPRINT("L %x\n",sw);
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/stdio.h>
|
||||
#include <crtdll/io.h>
|
||||
#include <crtdll/signal.h>
|
||||
|
||||
static char msg[] = "Abort!\r\n";
|
||||
char *msg ="Abort\n\r";
|
||||
|
||||
void abort()
|
||||
{
|
||||
_write(stderr->_file, msg, sizeof(msg)-1);
|
||||
_exit(1);
|
||||
fflush(NULL);
|
||||
fcloseall();
|
||||
raise(SIGABRT);
|
||||
_write(stderr->_file, msg, sizeof(msg)-1);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
/*
|
||||
* 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 <windows.h>
|
||||
#include <crtdll/sys/types.h>
|
||||
#include <crtdll/sys/stat.h>
|
||||
#include <crtdll/fcntl.h>
|
||||
#include <crtdll/string.h>
|
||||
#include <windows.h>
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
|
||||
|
@ -14,15 +24,17 @@ _fstat(int fd, struct stat *statbuf)
|
|||
|
||||
if (!statbuf)
|
||||
{
|
||||
|
||||
__set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( !GetFileInformationByHandle(_get_osfhandle(fd),&FileInformation) )
|
||||
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);
|
||||
}
|
||||
statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
|
||||
statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
|
||||
statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL);
|
||||
|
||||
statbuf->st_dev = fd;
|
||||
statbuf->st_size = FileInformation.nFileSizeLow;
|
||||
|
|
|
@ -1,14 +1,67 @@
|
|||
#include <windows.h>
|
||||
#include <crtdll/sys/time.h>
|
||||
|
||||
|
||||
int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31};
|
||||
unsigned int _getsystime(struct tm *tp)
|
||||
{
|
||||
printf("getsystime\n");
|
||||
return 0;
|
||||
SYSTEMTIME Time;
|
||||
TIME_ZONE_INFORMATION TimeZoneInformation;
|
||||
DWORD TimeZoneId;
|
||||
int i;
|
||||
|
||||
GetLocalTime(&Time);
|
||||
|
||||
tp->tm_year = Time.wYear - 1900;
|
||||
tp->tm_mon = Time.wMonth - 1;
|
||||
tp->tm_wday = Time.wDayOfWeek;
|
||||
tp->tm_mday = Time.wDay;
|
||||
tp->tm_hour = Time.wHour;
|
||||
tp->tm_min = Time.wMinute;
|
||||
tp->tm_sec = Time.wSecond;
|
||||
|
||||
tp->tm_isdst = -1;
|
||||
|
||||
//FIXME GetTimeZoneInformation currently not in kernel32
|
||||
|
||||
//TimeZoneId = GetTimeZoneInformation(&TimeZoneInformation );
|
||||
//if ( TimeZoneId == TIME_ZONE_ID_DAYLIGHT ) {
|
||||
// tp->tm_isdst = 1;
|
||||
//}
|
||||
//else
|
||||
// tp->tm_isdst = 0;
|
||||
|
||||
|
||||
|
||||
if ( tp->tm_year%4 == 0 ) {
|
||||
if (tp->tm_year%100 != 0 )
|
||||
tp->tm_yday = 1;
|
||||
else if ( (tp->tm_year-100)%1000 == 0 )
|
||||
tp->tm_yday = 1;
|
||||
}
|
||||
|
||||
for(i=0;i<=tp->tm_mon;i++)
|
||||
tp->tm_yday += month[i];
|
||||
|
||||
return Time.wMilliseconds;
|
||||
}
|
||||
|
||||
|
||||
unsigned int _setsystime(struct tm *tp, unsigned int ms)
|
||||
{
|
||||
printf("setsystime\n");
|
||||
SYSTEMTIME Time;
|
||||
|
||||
Time.wYear = tp->tm_year + 1900;
|
||||
Time.wMonth = tp->tm_mon + 1;
|
||||
Time.wDayOfWeek = tp->tm_wday;
|
||||
Time.wDay = tp->tm_mday;
|
||||
Time.wHour = tp->tm_hour;
|
||||
Time.wMinute = tp->tm_min;
|
||||
Time.wSecond = tp->tm_sec;
|
||||
Time.wMilliseconds = ms;
|
||||
|
||||
if ( !SetLocalTime(&Time))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
|
||||
// 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,
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/time/strtime.c
|
||||
* PURPOSE: Fills a buffer with a formatted date representation
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
#include <crtdll/time.h>
|
||||
#include <crtdll/stdio.h>
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
// copy date according to mm/dd/yy format
|
||||
char *_strdate( const char *datestr )
|
||||
{
|
||||
|
||||
|
@ -9,10 +19,12 @@ char *_strdate( const char *datestr )
|
|||
struct tm *d;
|
||||
char *dt = (char *)datestr;
|
||||
|
||||
if ( datestr == NULL )
|
||||
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);
|
||||
sprintf(dt,"%d/%d/%d",d->tm_mday,d->tm_mon+1,d->tm_year);
|
||||
return dt;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/string.h>
|
||||
|
||||
|
||||
#include <crtdll/time.h>
|
||||
#include <crtdll/stdlib.h>
|
||||
#include <crtdll/wchar.h>
|
||||
|
||||
#define TM_YEAR_BASE 1900
|
||||
|
||||
|
@ -55,7 +55,9 @@ _fmt(const char *format, const struct tm *t)
|
|||
{
|
||||
for (; *format; ++format)
|
||||
{
|
||||
if (*format == '%')
|
||||
if (*format == '%') {
|
||||
if (*(format+1) == '#' ) {format++;}
|
||||
|
||||
switch(*++format)
|
||||
{
|
||||
case '\0':
|
||||
|
@ -206,6 +208,7 @@ _fmt(const char *format, const struct tm *t)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!gsize--)
|
||||
return 0;
|
||||
*pt++ = *format;
|
||||
|
@ -230,5 +233,32 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *t)
|
|||
size_t
|
||||
wcsftime(wchar_t *s, size_t maxsize, const wchar_t *format, const struct tm *t)
|
||||
{
|
||||
printf("wcsftime\n");
|
||||
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;
|
||||
}
|
|
@ -1,7 +1,29 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/time/strtime.c
|
||||
* PURPOSE: Fills a buffer with a formatted time representation
|
||||
* PROGRAMER: Boudewijn Dekker
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
#include <crtdll/time.h>
|
||||
#include <crtdll/stdio.h>
|
||||
#include <crtdll/errno.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
char *_strtime(char* buf)
|
||||
{
|
||||
printf("strtime\n");
|
||||
return "";
|
||||
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;
|
||||
}
|
Loading…
Reference in a new issue