4 * Implements C run-time functionality as known from UNIX.
6 * Copyright 1996,1998 Marcus Meissner
7 * Copyright 1996 Jukka Iivonen
8 * Copyright 1997 Uwe Bonnes
12 Unresolved issues Uwe Bonnes 970904:
13 - Handling of Binary/Text Files is crude. If in doubt, use fromdos or recode
14 - Arguments in crtdll.spec for functions with double argument
15 - system-call calls another wine process, but without debugging arguments
16 and uses the first wine executable in the path
17 - tested with ftp://ftp.remcomp.com/pub/remcomp/lcc-win32.zip, a C-Compiler
18 for Win32, based on lcc, from Jacob Navia
21 /* NOTE: This file also implements the wcs* functions. They _ARE_ in
22 * the newer Linux libcs, but use 4 byte wide characters, so are unusable,
23 * since we need 2 byte wide characters. - Marcus Meissner, 981031
26 /* FIXME: all the file handling is hopelessly broken -- AJ */
33 #include <sys/times.h>
53 static DOS_FULL_NAME CRTDLL_tmpname
;
55 UINT32 CRTDLL_argc_dll
; /* CRTDLL.23 */
56 LPSTR
*CRTDLL_argv_dll
; /* CRTDLL.24 */
57 LPSTR CRTDLL_acmdln_dll
; /* CRTDLL.38 */
58 UINT32 CRTDLL_basemajor_dll
; /* CRTDLL.42 */
59 UINT32 CRTDLL_baseminor_dll
; /* CRTDLL.43 */
60 UINT32 CRTDLL_baseversion_dll
; /* CRTDLL.44 */
61 UINT32 CRTDLL_commode_dll
; /* CRTDLL.59 */
62 LPSTR CRTDLL_environ_dll
; /* CRTDLL.75 */
63 UINT32 CRTDLL_fmode_dll
; /* CRTDLL.104 */
64 UINT32 CRTDLL_osmajor_dll
; /* CRTDLL.241 */
65 UINT32 CRTDLL_osminor_dll
; /* CRTDLL.242 */
66 UINT32 CRTDLL_osmode_dll
; /* CRTDLL.243 */
67 UINT32 CRTDLL_osver_dll
; /* CRTDLL.244 */
68 UINT32 CRTDLL_osversion_dll
; /* CRTDLL.245 */
69 UINT32 CRTDLL_winmajor_dll
; /* CRTDLL.329 */
70 UINT32 CRTDLL_winminor_dll
; /* CRTDLL.330 */
71 UINT32 CRTDLL_winver_dll
; /* CRTDLL.331 */
73 BYTE CRTDLL_iob
[32*3]; /* FIXME */
75 typedef VOID (*new_handler_type
)(VOID
);
77 static new_handler_type new_handler
;
79 /*********************************************************************
80 * _GetMainArgs (CRTDLL.022)
82 DWORD __cdecl
CRTDLL__GetMainArgs(LPDWORD argc
,LPSTR
**argv
,
83 LPSTR
*environ
,DWORD flag
)
87 int xargc
,i
,afterlastspace
;
90 TRACE(crtdll
,"(%p,%p,%p,%ld).\n",
91 argc
,argv
,environ
,flag
93 CRTDLL_acmdln_dll
= cmdline
= HEAP_strdupA( GetProcessHeap(), 0,
94 GetCommandLine32A() );
95 TRACE(crtdll
,"got '%s'\n", cmdline
);
97 version
= GetVersion32();
98 CRTDLL_osver_dll
= version
>> 16;
99 CRTDLL_winminor_dll
= version
& 0xFF;
100 CRTDLL_winmajor_dll
= (version
>>8) & 0xFF;
101 CRTDLL_baseversion_dll
= version
>> 16;
102 CRTDLL_winver_dll
= ((version
>> 8) & 0xFF) + ((version
& 0xFF) << 8);
103 CRTDLL_baseminor_dll
= (version
>> 16) & 0xFF;
104 CRTDLL_basemajor_dll
= (version
>> 24) & 0xFF;
105 CRTDLL_osversion_dll
= version
& 0xFFFF;
106 CRTDLL_osminor_dll
= version
& 0xFF;
107 CRTDLL_osmajor_dll
= (version
>>8) & 0xFF;
109 /* missing threading init */
111 i
=0;xargv
=NULL
;xargc
=0;afterlastspace
=0;
113 if (cmdline
[i
]==' ') {
114 xargv
=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv
,
115 sizeof(char*)*(++xargc
));
117 xargv
[xargc
-1] = HEAP_strdupA( GetProcessHeap(), 0,
118 cmdline
+afterlastspace
);
120 while (cmdline
[i
]==' ')
127 xargv
=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv
,
128 sizeof(char*)*(++xargc
));
130 xargv
[xargc
-1] = HEAP_strdupA( GetProcessHeap(), 0,
131 cmdline
+afterlastspace
);
132 CRTDLL_argc_dll
= xargc
;
134 CRTDLL_argv_dll
= xargv
;
137 TRACE(crtdll
,"found %d arguments\n",
139 CRTDLL_environ_dll
= *environ
= GetEnvironmentStrings32A();
144 typedef void (*_INITTERMFUN
)();
146 /* fixme: move to header */
149 time_t time_create
; /* -1 when not avaiable */
150 time_t time_access
; /* -1 when not avaiable */
152 unsigned long size
; /* fixme: 64 bit ??*/
155 /*********************************************************************
156 * _findfirst (CRTDLL.099)
161 DWORD __cdecl
CRTDLL__findfirst(LPCSTR fname
, struct find_t
* x2
)
163 FIXME(crtdll
, ":(%s,%p): stub\n",fname
,x2
);
164 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
168 /*********************************************************************
169 * _findnext (CRTDLL.100)
174 INT32 __cdecl
CRTDLL__findnext(DWORD hand
, struct find_t
* x2
)
176 FIXME(crtdll
, ":(%ld,%p): stub\n",hand
,x2
);
177 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
181 /*********************************************************************
182 * _fstat (CRTDLL.111)
187 int __cdecl
CRTDLL__fstat(int file
, struct stat
* buf
)
189 FIXME(crtdll
, ":(%d,%p): stub\n",file
,buf
);
190 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
194 /*********************************************************************
195 * _initterm (CRTDLL.135)
197 DWORD __cdecl
CRTDLL__initterm(_INITTERMFUN
*start
,_INITTERMFUN
*end
)
199 _INITTERMFUN
*current
;
201 TRACE(crtdll
,"(%p,%p)\n",start
,end
);
203 while (current
<end
) {
204 if (*current
) (*current
)();
210 /*********************************************************************
211 * _fdopen (CRTDLL.91)
213 DWORD __cdecl
CRTDLL__fdopen(INT32 handle
, LPCSTR mode
)
221 case 1 : file
=stdout
;
223 case 2 : file
=stderr
;
226 file
=fdopen(handle
,mode
);
228 TRACE(crtdll
, "open handle %d mode %s got file %p\n",
233 static FILE *xlat_file_ptr(void *ptr
)
237 /* CRT sizeof(FILE) == 32 */
238 dif
= ((char *)ptr
- (char *)CRTDLL_iob
) / 32;
241 case 0: return stdin
;
242 case 1: return stdout
;
243 case 2: return stderr
;
248 /*******************************************************************
249 * _global_unwind2 (CRTDLL.129)
251 void __cdecl
CRTDLL__global_unwind2( PEXCEPTION_FRAME frame
)
253 RtlUnwind( frame
, 0, NULL
, 0 );
256 /*******************************************************************
257 * _local_unwind2 (CRTDLL.173)
259 void __cdecl
CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe
, DWORD nr
)
261 TRACE(crtdll
,"(%p,%ld)\n",endframe
,nr
);
263 /*********************************************************************
269 INT32 __cdecl
CRTDLL__read(INT32 fd
, LPVOID buf
, UINT32 count
)
271 FIXME(crtdll
,":(%d,%p,%d): stub\n",fd
,buf
,count
);
272 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
276 /*********************************************************************
279 DWORD __cdecl
CRTDLL_fopen(LPCSTR path
, LPCSTR mode
)
284 DOS_FULL_NAME full_name
;
286 if (!DOSFS_GetFullName( path
, FALSE
, &full_name
)) {
287 WARN(crtdll
, "file %s bad name\n",path
);
291 file
=fopen(full_name
.long_name
,mode
);
296 if ((strchr(mode
,'r')&&strchr(mode
,'a'))||
297 (strchr(mode
,'r')&&strchr(mode
,'w'))||
298 (strchr(mode
,'w')&&strchr(mode
,'a')))
301 if (strstr(mode
,"r+")) flagmode
=O_RDWR
;
302 else if (strchr(mode
,'r')) flagmode
= O_RDONLY
;
303 else if (strstr(mode
,"w+")) flagmode
= O_RDWR
| O_TRUNC
| O_CREAT
;
304 else if (strchr(mode
,'w')) flagmode
= O_WRONLY
| O_TRUNC
| O_CREAT
;
305 else if (strstr(mode
,"a+")) flagmode
= O_RDWR
| O_CREAT
| O_APPEND
;
306 else if (strchr(mode
,'w')) flagmode
= O_RDWR
| O_CREAT
| O_APPEND
;
307 else if (strchr(mode
,'b'))
308 TRACE(crtdll
, "%s in BINARY mode\n",path
);
310 dos_fildes
=FILE_Open(path
, flagmode
,0);
311 unix_fildes
=FILE_GetUnixHandle(dos_fildes
,0);
312 file
= fdopen(unix_fildes
,mode
);
314 TRACE(crtdll
, "file %s mode %s got ufh %d dfh %d file %p\n",
315 path
,mode
,unix_fildes
,dos_fildes
,file
);
319 /*********************************************************************
322 DWORD __cdecl
CRTDLL_fread(LPVOID ptr
, INT32 size
, INT32 nmemb
, LPVOID vfile
)
325 FILE *file
=xlat_file_ptr(vfile
);
330 /* If we would honour CR/LF <-> LF translation, we could do it like this.
331 We should keep track of all files opened, and probably files with \
332 known binary extensions must be unchanged */
333 while ( (i
< (nmemb
*size
)) && (ret
==1)) {
334 ret
=fread(temp
,1,1,file
);
335 TRACE(crtdll
, "got %c 0x%02x ret %d\n",
336 (isalpha(*(unsigned char*)temp
))? *(unsigned char*)temp
:
337 ' ',*(unsigned char*)temp
, ret
);
338 if (*(unsigned char*)temp
!= 0xd) { /* skip CR */
343 TRACE(crtdll
, "skipping ^M\n");
345 TRACE(crtdll
, "0x%08x items of size %d from file %p to %p\n",
346 nmemb
,size
,file
,ptr
,);
348 WARN(crtdll
, " failed!\n");
353 ret
=fread(ptr
,size
,nmemb
,file
);
354 TRACE(crtdll
, "0x%08x items of size %d from file %p to %p\n",
355 nmemb
,size
,file
,ptr
);
357 WARN(crtdll
, " failed!\n");
362 /*********************************************************************
363 * freopen (CRTDLL.379)
368 DWORD __cdecl
CRTDLL_freopen(LPCSTR path
, LPCSTR mode
, LPVOID stream
)
370 FIXME(crtdll
, ":(%s,%s,%p): stub\n", path
, mode
, stream
);
371 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
375 /*********************************************************************
376 * fscanf (CRTDLL.381)
378 INT32 __cdecl
CRTDLL_fscanf( LPVOID stream
, LPSTR format
, ... )
383 va_start( valist
, format
);
385 res
= vfscanf( xlat_file_ptr(stream
), format
, valist
);
391 /*********************************************************************
394 LONG __cdecl
CRTDLL_fseek(LPVOID stream
, LONG offset
, INT32 whence
)
398 ret
=fseek(xlat_file_ptr(stream
),offset
,whence
);
399 TRACE(crtdll
, "file %p to 0x%08lx pos %s\n",
400 stream
,offset
,(whence
==SEEK_SET
)?"SEEK_SET":
401 (whence
==SEEK_CUR
)?"SEEK_CUR":
402 (whence
==SEEK_END
)?"SEEK_END":"UNKNOWN");
404 WARN(crtdll
, " failed!\n");
409 /*********************************************************************
410 * fsetpos (CRTDLL.383)
412 INT32 __cdecl
CRTDLL_fsetpos(LPVOID stream
, fpos_t *pos
)
414 TRACE(crtdll
, "file %p\n", stream
);
415 return fseek(xlat_file_ptr(stream
), *pos
, SEEK_SET
);
418 /*********************************************************************
421 LONG __cdecl
CRTDLL_ftell(LPVOID stream
)
425 ret
=ftell(xlat_file_ptr(stream
));
426 TRACE(crtdll
, "file %p at 0x%08lx\n",
431 /*********************************************************************
432 * fwrite (CRTDLL.386)
434 DWORD __cdecl
CRTDLL_fwrite(LPVOID ptr
, INT32 size
, INT32 nmemb
, LPVOID vfile
)
437 FILE *file
=xlat_file_ptr(vfile
);
439 ret
=fwrite(ptr
,size
,nmemb
,file
);
440 TRACE(crtdll
, "0x%08x items of size %d from %p to file %p\n",
441 nmemb
,size
,ptr
,file
);
443 WARN(crtdll
, " Failed!\n");
448 /*********************************************************************
449 * setbuf (CRTDLL.452)
451 INT32 __cdecl
CRTDLL_setbuf(LPVOID file
, LPSTR buf
)
453 TRACE(crtdll
, "(file %p buf %p)\n", file
, buf
);
454 /* this doesn't work:"void value not ignored as it ought to be"
455 return setbuf(file,buf);
457 setbuf(xlat_file_ptr(file
),buf
);
461 /*********************************************************************
462 * _open_osfhandle (CRTDLL.240)
464 HFILE32 __cdecl
CRTDLL__open_osfhandle(LONG osfhandle
, INT32 flags
)
469 case STD_INPUT_HANDLE
:
473 case STD_OUTPUT_HANDLE
:
477 case STD_ERROR_HANDLE
:
484 TRACE(crtdll
, "(handle %08lx,flags %d) return %d\n",
485 osfhandle
,flags
,handle
);
490 /*********************************************************************
493 void __cdecl
CRTDLL_srand(DWORD seed
)
495 /* FIXME: should of course be thread? process? local */
499 /*********************************************************************
500 * fprintf (CRTDLL.373)
502 INT32 __cdecl
CRTDLL_fprintf( FILE *file
, LPSTR format
, ... )
507 va_start( valist
, format
);
508 res
= vfprintf( xlat_file_ptr(file
), format
, valist
);
513 /*********************************************************************
514 * vfprintf (CRTDLL.373)
516 INT32 __cdecl
CRTDLL_vfprintf( FILE *file
, LPSTR format
, va_list args
)
518 return vfprintf( xlat_file_ptr(file
), format
, args
);
521 /*********************************************************************
524 time_t __cdecl
CRTDLL_time(time_t *timeptr
)
526 time_t curtime
= time(NULL
);
533 /*********************************************************************
536 clock_t __cdecl
CRTDLL_clock(void)
542 res
= alltimes
.tms_utime
+ alltimes
.tms_stime
+
543 alltimes
.tms_cutime
+ alltimes
.tms_cstime
;
544 /* Fixme: We need some symbolic representation
545 for (Hostsystem_)CLOCKS_PER_SEC
546 and (Emulated_system_)CLOCKS_PER_SEC
547 10 holds only for Windows/Linux_i86)
552 /*********************************************************************
553 * _isatty (CRTDLL.137)
555 BOOL32 __cdecl
CRTDLL__isatty(DWORD x
)
557 TRACE(crtdll
,"(%ld)\n",x
);
561 /*********************************************************************
562 * _write (CRTDLL.332)
564 INT32 __cdecl
CRTDLL__write(INT32 fd
,LPCVOID buf
,UINT32 count
)
571 len
= (UINT32
)write(fd
,buf
,(LONG
)count
);
573 len
= _lwrite32(fd
,buf
,count
);
574 TRACE(crtdll
,"%d/%d byte to dfh %d from %p,\n",
580 /*********************************************************************
583 * FIXME: What the heck is the difference between
584 * FIXME _c_exit (CRTDLL.47)
585 * FIXME _cexit (CRTDLL.49)
586 * FIXME _exit (CRTDLL.87)
587 * FIXME exit (CRTDLL.359)
589 * atexit-processing comes to mind -- MW.
592 void __cdecl
CRTDLL__cexit(INT32 ret
)
594 TRACE(crtdll
,"(%d)\n",ret
);
599 /*********************************************************************
602 void __cdecl
CRTDLL_exit(DWORD ret
)
604 TRACE(crtdll
,"(%ld)\n",ret
);
609 /*********************************************************************
610 * _abnormal_termination (CRTDLL.36)
612 INT32 __cdecl
CRTDLL__abnormal_termination(void)
614 TRACE(crtdll
,"(void)\n");
619 /*********************************************************************
620 * _access (CRTDLL.37)
622 INT32 __cdecl
CRTDLL__access(LPCSTR filename
, INT32 mode
)
624 DWORD attr
= GetFileAttributes32A(filename
);
628 if (GetLastError() == ERROR_INVALID_ACCESS
)
635 if ((attr
& FILE_ATTRIBUTE_READONLY
) && (mode
& W_OK
))
645 /*********************************************************************
646 * fflush (CRTDLL.365)
648 INT32 __cdecl
CRTDLL_fflush(LPVOID stream
)
652 ret
= fflush(xlat_file_ptr(stream
));
653 TRACE(crtdll
,"%p returnd %d\n",stream
,ret
);
655 WARN(crtdll
, " Failed!\n");
661 /*********************************************************************
664 LPSTR __cdecl
CRTDLL_gets(LPSTR buf
)
667 LPSTR buf_start
= buf
;
669 /* BAD, for the whole WINE process blocks... just done this way to test
670 * windows95's ftp.exe.
673 for(cc
= fgetc(stdin
); cc
!= EOF
&& cc
!= '\n'; cc
= fgetc(stdin
))
674 if(cc
!= '\r') *buf
++ = (char)cc
;
678 TRACE(crtdll
,"got '%s'\n", buf_start
);
683 /*********************************************************************
686 INT32 __cdecl
CRTDLL_rand()
692 /*********************************************************************
693 * putchar (CRTDLL.442)
695 void __cdecl
CRTDLL_putchar( INT32 x
)
701 /*********************************************************************
704 INT32 __cdecl
CRTDLL_fputc( INT32 c
, FILE *stream
)
706 TRACE(crtdll
, "%c to file %p\n",c
,stream
);
707 return fputc(c
,xlat_file_ptr(stream
));
711 /*********************************************************************
714 INT32 __cdecl
CRTDLL_fputs( LPCSTR s
, FILE *stream
)
716 TRACE(crtdll
, "%s to file %p\n",s
,stream
);
717 return fputs(s
,xlat_file_ptr(stream
));
721 /*********************************************************************
724 INT32 __cdecl
CRTDLL_puts(LPCSTR s
)
726 TRACE(crtdll
, "%s \n",s
);
731 /*********************************************************************
734 INT32 __cdecl
CRTDLL_putc(INT32 c
, FILE *stream
)
736 TRACE(crtdll
, " %c to file %p\n",c
,stream
);
737 return fputc(c
,xlat_file_ptr(stream
));
739 /*********************************************************************
742 INT32 __cdecl
CRTDLL_fgetc( FILE *stream
)
744 int ret
= fgetc(xlat_file_ptr(stream
));
745 TRACE(crtdll
, "got %d\n",ret
);
750 /*********************************************************************
753 INT32 __cdecl
CRTDLL_getc( FILE *stream
)
755 int ret
= fgetc(xlat_file_ptr(stream
));
756 TRACE(crtdll
, "got %d\n",ret
);
760 /*********************************************************************
763 UINT32 __cdecl
CRTDLL__rotl(UINT32 x
,INT32 shift
)
765 unsigned int ret
= (x
>> shift
)|( x
>>((sizeof(x
))-shift
));
767 TRACE(crtdll
, "got 0x%08x rot %d ret 0x%08x\n",
772 /*********************************************************************
773 * _lrotl (CRTDLL.176)
775 DWORD __cdecl
CRTDLL__lrotl(DWORD x
,INT32 shift
)
777 unsigned long ret
= (x
>> shift
)|( x
>>((sizeof(x
))-shift
));
779 TRACE(crtdll
, "got 0x%08lx rot %d ret 0x%08lx\n",
786 /*********************************************************************
789 CHAR
* __cdecl
CRTDLL_fgets(LPSTR s
,INT32 size
, LPVOID stream
)
794 ret
=fgets(s
, size
,xlat_file_ptr(stream
));
795 /*FIXME: Control with CRTDLL_setmode */
796 control_M
= strrchr(s
,'\r');
797 /*delete CR if we read a DOS File */
803 TRACE(crtdll
, "got %s for %d chars from file %p\n",
806 WARN(crtdll
, " Failed!\n");
812 /*********************************************************************
813 * _mbsicmp (CRTDLL.204)
815 int __cdecl
CRTDLL__mbsicmp(unsigned char *x
,unsigned char *y
)
822 /* FIXME: MBCS handling... */
831 /*********************************************************************
832 * _mbsinc (CRTDLL.205)
834 unsigned char * __cdecl
CRTDLL__mbsinc(unsigned char *x
)
841 /*********************************************************************
842 * vsprintf (CRTDLL.500)
844 INT32 __cdecl
CRTDLL_vsprintf( LPSTR buffer
, LPCSTR spec
, va_list args
)
846 return wvsprintf32A( buffer
, spec
, args
);
849 /*********************************************************************
850 * vswprintf (CRTDLL.501)
852 INT32 __cdecl
CRTDLL_vswprintf( LPWSTR buffer
, LPCWSTR spec
, va_list args
)
854 return wvsprintf32W( buffer
, spec
, args
);
857 /*********************************************************************
858 * _mbscpy (CRTDLL.200)
860 unsigned char* __cdecl
CRTDLL__mbscpy(unsigned char *x
,unsigned char *y
)
862 TRACE(crtdll
,"CRTDLL_mbscpy %s and %s\n",x
,y
);
867 /*********************************************************************
868 * _mbscat (CRTDLL.197)
870 unsigned char* __cdecl
CRTDLL__mbscat(unsigned char *x
,unsigned char *y
)
876 /*********************************************************************
877 * _strcmpi (CRTDLL.282) (CRTDLL.287)
879 INT32 __cdecl
CRTDLL__strcmpi( LPCSTR s1
, LPCSTR s2
)
881 return lstrcmpi32A( s1
, s2
);
885 /*********************************************************************
886 * _strnicmp (CRTDLL.293)
888 INT32 __cdecl
CRTDLL__strnicmp( LPCSTR s1
, LPCSTR s2
, INT32 n
)
890 return lstrncmpi32A( s1
, s2
, n
);
894 /*********************************************************************
895 * _strlwr (CRTDLL.293)
897 * convert a string in place to lowercase
899 LPSTR __cdecl
CRTDLL__strlwr(LPSTR x
)
903 TRACE(crtdll
, "CRTDLL_strlwr got %s\n", x
);
905 if ((*y
> 0x40) && (*y
< 0x5b))
909 TRACE(crtdll
, " returned %s\n", x
);
914 /*********************************************************************
915 * system (CRTDLL.485)
917 INT32 __cdecl
CRTDLL_system(LPSTR x
)
919 #define SYSBUF_LENGTH 1500
920 char buffer
[SYSBUF_LENGTH
];
921 unsigned char *y
= x
;
925 sprintf( buffer
, "%s \"", Options
.argv0
);
926 bp
= buffer
+ strlen(buffer
);
927 i
= strlen(buffer
) + strlen(x
) +2;
929 /* Calculate needed buffer size to prevent overflow. */
934 /* If buffer too short, exit. */
935 if (i
> SYSBUF_LENGTH
) {
936 TRACE(crtdll
,"_system buffer to small\n");
945 if (*(y
-1) =='\\') *bp
++ = '\\';
947 /* Remove spaces from end of string. */
948 while (*(y
-1) == ' ') {
953 TRACE(crtdll
, "_system got '%s', executing '%s'\n",x
,buffer
);
955 return system(buffer
);
958 /*********************************************************************
959 * _strupr (CRTDLL.300)
961 LPSTR __cdecl
CRTDLL__strupr(LPSTR x
)
972 /*********************************************************************
973 * _wcsupr (CRTDLL.328)
975 LPWSTR __cdecl
CRTDLL__wcsupr(LPWSTR x
)
986 /*********************************************************************
987 * _wcslwr (CRTDLL.323)
989 LPWSTR __cdecl
CRTDLL__wcslwr(LPWSTR x
)
1001 /*********************************************************************
1002 * longjmp (CRTDLL.426)
1004 VOID __cdecl
CRTDLL_longjmp(jmp_buf env
, int val
)
1006 FIXME(crtdll
,"CRTDLL_longjmp semistup, expect crash\n");
1007 return longjmp(env
, val
);
1010 /*********************************************************************
1011 * malloc (CRTDLL.427)
1013 VOID
* __cdecl
CRTDLL_malloc(DWORD size
)
1015 return HeapAlloc(GetProcessHeap(),0,size
);
1018 /*********************************************************************
1021 VOID
* __cdecl
CRTDLL_new(DWORD size
)
1024 if(!(result
= HeapAlloc(GetProcessHeap(),0,size
)) && new_handler
)
1029 /*********************************************************************
1030 * set_new_handler(CRTDLL.003)
1032 new_handler_type __cdecl
CRTDLL_set_new_handler(new_handler_type func
)
1034 new_handler_type old_handler
= new_handler
;
1039 /*********************************************************************
1040 * calloc (CRTDLL.350)
1042 VOID
* __cdecl
CRTDLL_calloc(DWORD size
, DWORD count
)
1044 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, size
* count
);
1047 /*********************************************************************
1048 * realloc (CRTDLL.447)
1050 VOID
* __cdecl
CRTDLL_realloc( VOID
*ptr
, DWORD size
)
1052 return HeapReAlloc( GetProcessHeap(), 0, ptr
, size
);
1055 /*********************************************************************
1058 VOID __cdecl
CRTDLL_free(LPVOID ptr
)
1060 HeapFree(GetProcessHeap(),0,ptr
);
1063 /*********************************************************************
1064 * delete (CRTDLL.002)
1066 VOID __cdecl
CRTDLL_delete(VOID
* ptr
)
1068 HeapFree(GetProcessHeap(),0,ptr
);
1071 /*********************************************************************
1072 * _strdup (CRTDLL.285)
1074 LPSTR __cdecl
CRTDLL__strdup(LPCSTR ptr
)
1076 return HEAP_strdupA(GetProcessHeap(),0,ptr
);
1079 /*********************************************************************
1080 * _wcsdup (CRTDLL.320)
1082 LPWSTR __cdecl
CRTDLL__wcsdup(LPCWSTR ptr
)
1084 return HEAP_strdupW(GetProcessHeap(),0,ptr
);
1087 /*********************************************************************
1088 * fclose (CRTDLL.362)
1090 INT32 __cdecl
CRTDLL_fclose( FILE *stream
)
1093 HFILE32 dos_handle
=1;
1096 stream
=xlat_file_ptr(stream
);
1097 unix_handle
=fileno(stream
);
1099 if (unix_handle
<4) ret
= fclose(stream
);
1102 while((h
= FILE_GetUnixHandle(dos_handle
,0)) != unix_handle
)
1108 ret
= _lclose32( dos_handle
);
1110 TRACE(crtdll
,"(%p) ufh %d dfh %d\n",
1111 stream
,unix_handle
,dos_handle
);
1114 WARN(crtdll
, " Failed!\n");
1119 /*********************************************************************
1120 * _unlink (CRTDLL.315)
1122 INT32 __cdecl
CRTDLL__unlink(LPCSTR pathname
)
1125 DOS_FULL_NAME full_name
;
1127 if (!DOSFS_GetFullName( pathname
, FALSE
, &full_name
)) {
1128 WARN(crtdll
, "CRTDLL_unlink file %s bad name\n",pathname
);
1132 ret
=unlink(full_name
.long_name
);
1133 TRACE(crtdll
,"(%s unix %s)\n",
1134 pathname
,full_name
.long_name
);
1136 WARN(crtdll
, " Failed!\n");
1141 /*********************************************************************
1142 * rename (CRTDLL.449)
1144 INT32 __cdecl
CRTDLL_rename(LPCSTR oldpath
,LPCSTR newpath
)
1146 BOOL32 ok
= MoveFileEx32A( oldpath
, newpath
, MOVEFILE_REPLACE_EXISTING
);
1151 /*********************************************************************
1152 * _stat (CRTDLL.280)
1170 int __cdecl
CRTDLL__stat(const char * filename
, struct win_stat
* buf
)
1173 DOS_FULL_NAME full_name
;
1176 if (!DOSFS_GetFullName( filename
, TRUE
, &full_name
))
1178 WARN(crtdll
, "CRTDLL__stat filename %s bad name\n",filename
);
1181 ret
=stat(full_name
.long_name
,&mystat
);
1182 TRACE(crtdll
,"CRTDLL__stat %s\n", filename
);
1184 WARN(crtdll
, " Failed!\n");
1186 /* FIXME: should check what Windows returns */
1188 buf
->win_st_dev
= mystat
.st_dev
;
1189 buf
->win_st_ino
= mystat
.st_ino
;
1190 buf
->win_st_mode
= mystat
.st_mode
;
1191 buf
->win_st_nlink
= mystat
.st_nlink
;
1192 buf
->win_st_uid
= mystat
.st_uid
;
1193 buf
->win_st_gid
= mystat
.st_gid
;
1194 buf
->win_st_rdev
= mystat
.st_rdev
;
1195 buf
->win_st_size
= mystat
.st_size
;
1196 buf
->win_st_atime
= mystat
.st_atime
;
1197 buf
->win_st_mtime
= mystat
.st_mtime
;
1198 buf
->win_st_ctime
= mystat
.st_ctime
;
1202 /*********************************************************************
1203 * _open (CRTDLL.239)
1205 HFILE32 __cdecl
CRTDLL__open(LPCSTR path
,INT32 flags
)
1211 the flags in lcc's header differ from the ones in Linux, e.g.
1212 Linux: define O_APPEND 02000 (= 0x400)
1213 lcc: define _O_APPEND 0x0008
1214 so here a scheme to translate them
1215 Probably lcc is wrong here, but at least a hack to get is going
1217 wineflags
= (flags
& 3);
1218 if (flags
& 0x0008 ) wineflags
|= O_APPEND
;
1219 if (flags
& 0x0100 ) wineflags
|= O_CREAT
;
1220 if (flags
& 0x0200 ) wineflags
|= O_TRUNC
;
1221 if (flags
& 0x0400 ) wineflags
|= O_EXCL
;
1222 if (flags
& 0xf0f4 )
1223 TRACE(crtdll
,"CRTDLL_open file unsupported flags 0x%04x\n",flags
);
1226 ret
= FILE_Open(path
,wineflags
,0);
1227 TRACE(crtdll
,"CRTDLL_open file %s mode 0x%04x (lccmode 0x%04x) got dfh %d\n",
1228 path
,wineflags
,flags
,ret
);
1232 /*********************************************************************
1233 * _close (CRTDLL.57)
1235 INT32 __cdecl
CRTDLL__close(HFILE32 fd
)
1237 int ret
=_lclose32(fd
);
1239 TRACE(crtdll
,"(%d)\n",fd
);
1241 WARN(crtdll
, " Failed!\n");
1246 /*********************************************************************
1249 INT32 __cdecl
CRTDLL_feof( FILE *stream
)
1253 ret
=feof(xlat_file_ptr(stream
));
1254 TRACE(crtdll
,"(%p) %s\n",stream
,(ret
)?"true":"false");
1258 /*********************************************************************
1259 * setlocale (CRTDLL.453)
1261 LPSTR __cdecl
CRTDLL_setlocale(INT32 category
,LPCSTR locale
)
1266 case CRTDLL_LC_ALL
: categorystr
="LC_ALL";break;
1267 case CRTDLL_LC_COLLATE
: categorystr
="LC_COLLATE";break;
1268 case CRTDLL_LC_CTYPE
: categorystr
="LC_CTYPE";break;
1269 case CRTDLL_LC_MONETARY
: categorystr
="LC_MONETARY";break;
1270 case CRTDLL_LC_NUMERIC
: categorystr
="LC_NUMERIC";break;
1271 case CRTDLL_LC_TIME
: categorystr
="LC_TIME";break;
1272 default: categorystr
= "UNKNOWN?";break;
1274 FIXME(crtdll
,"(%s,%s),stub!\n",categorystr
,locale
);
1278 /*********************************************************************
1279 * wcscat (CRTDLL.503)
1281 LPWSTR __cdecl
CRTDLL_wcscat( LPWSTR s1
, LPCWSTR s2
)
1283 return lstrcat32W( s1
, s2
);
1286 /*********************************************************************
1287 * wcschr (CRTDLL.504)
1289 LPWSTR __cdecl
CRTDLL_wcschr(LPCWSTR str
,WCHAR xchar
)
1301 /*********************************************************************
1302 * wcscmp (CRTDLL.505)
1304 INT32 __cdecl
CRTDLL_wcscmp( LPCWSTR s1
, LPCWSTR s2
)
1306 return lstrcmp32W( s1
, s2
);
1309 /*********************************************************************
1310 * wcscpy (CRTDLL.507)
1312 LPWSTR __cdecl
CRTDLL_wcscpy( LPWSTR s1
, LPCWSTR s2
)
1314 return lstrcpy32W( s1
, s2
);
1317 /*********************************************************************
1318 * wcscspn (CRTDLL.508)
1320 INT32 __cdecl
CRTDLL_wcscspn(LPWSTR str
,LPWSTR reject
)
1327 while (*t
) { if (*t
==*s
) break;t
++;}
1331 return s
-str
; /* nr of wchars */
1334 /*********************************************************************
1335 * wcslen (CRTDLL.510)
1337 INT32 __cdecl
CRTDLL_wcslen( LPCWSTR s
)
1339 return lstrlen32W( s
);
1342 /*********************************************************************
1343 * wcsncat (CRTDLL.511)
1345 LPWSTR __cdecl
CRTDLL_wcsncat( LPWSTR s1
, LPCWSTR s2
, INT32 n
)
1347 return lstrcatn32W( s1
, s2
, n
);
1350 /*********************************************************************
1351 * wcsncmp (CRTDLL.512)
1353 INT32 __cdecl
CRTDLL_wcsncmp( LPCWSTR s1
, LPCWSTR s2
, INT32 n
)
1355 return lstrncmp32W( s1
, s2
, n
);
1358 /*********************************************************************
1359 * wcsncpy (CRTDLL.513)
1361 LPWSTR __cdecl
CRTDLL_wcsncpy( LPWSTR s1
, LPCWSTR s2
, INT32 n
)
1363 return lstrcpyn32W( s1
, s2
, n
);
1366 /*********************************************************************
1367 * wcsspn (CRTDLL.516)
1369 INT32 __cdecl
CRTDLL_wcsspn(LPWSTR str
,LPWSTR accept
)
1376 while (*t
) { if (*t
==*s
) break;t
++;}
1380 return s
-str
; /* nr of wchars */
1383 /*********************************************************************
1384 * _wcsicmp (CRTDLL.321)
1386 DWORD __cdecl
CRTDLL__wcsicmp( LPCWSTR s1
, LPCWSTR s2
)
1388 return lstrcmpi32W( s1
, s2
);
1391 /*********************************************************************
1392 * _wcsicoll (CRTDLL.322)
1394 DWORD __cdecl
CRTDLL__wcsicoll(LPCWSTR a1
,LPCWSTR a2
)
1396 /* FIXME: handle collates */
1397 return lstrcmpi32W(a1
,a2
);
1400 /*********************************************************************
1401 * _wcsnicmp (CRTDLL.324)
1403 DWORD __cdecl
CRTDLL__wcsnicmp( LPCWSTR s1
, LPCWSTR s2
, INT32 len
)
1405 return lstrncmpi32W( s1
, s2
, len
);
1408 /*********************************************************************
1409 * wcscoll (CRTDLL.506)
1411 DWORD __cdecl
CRTDLL_wcscoll(LPWSTR a1
,LPWSTR a2
)
1413 /* FIXME: handle collates */
1414 return lstrcmp32W(a1
,a2
);
1417 /*********************************************************************
1418 * _wcsrev (CRTDLL.326)
1420 VOID __cdecl
CRTDLL__wcsrev(LPWSTR s
) {
1434 /*********************************************************************
1435 * wcsstr (CRTDLL.517)
1437 LPWSTR __cdecl
CRTDLL_wcsstr(LPWSTR s
,LPWSTR b
)
1445 while (*y
&& *c
&& *y
==*c
) { c
++;y
++; }
1454 /*********************************************************************
1455 * wcstombs (CRTDLL.521)
1457 INT32 __cdecl
CRTDLL_wcstombs( LPSTR dst
, LPCWSTR src
, INT32 len
)
1459 lstrcpynWtoA( dst
, src
, len
);
1460 return strlen(dst
); /* FIXME: is this right? */
1463 /*********************************************************************
1464 * wcsrchr (CRTDLL.515)
1466 LPWSTR __cdecl
CRTDLL_wcsrchr(LPWSTR str
,WCHAR xchar
)
1470 s
=str
+lstrlen32W(str
);
1479 /*********************************************************************
1480 * _setmode (CRTDLL.265)
1481 * FIXME: At present we ignore the request to translate CR/LF to LF.
1483 * We allways translate when we read with fgets, we never do with fread
1486 INT32 __cdecl
CRTDLL__setmode( INT32 fh
,INT32 mode
)
1489 #define O_TEXT 0x4000
1490 #define O_BINARY 0x8000
1492 FIXME(crtdll
, "on fhandle %d mode %s, STUB.\n",
1493 fh
,(mode
=O_TEXT
)?"O_TEXT":
1494 (mode
=O_BINARY
)?"O_BINARY":"UNKNOWN");
1498 /*********************************************************************
1499 * _fpreset (CRTDLL.107)
1501 VOID __cdecl
CRTDLL__fpreset(void)
1503 FIXME(crtdll
," STUB.\n");
1506 /*********************************************************************
1507 * atexit (CRTDLL.345)
1509 INT32 __cdecl
CRTDLL_atexit(LPVOID x
)
1511 FIXME(crtdll
,"(%p), STUB.\n",x
);
1512 return 0; /* successful */
1515 /*********************************************************************
1516 * mblen (CRTDLL.428)
1517 * FIXME: check multibyte support
1519 WCHAR __cdecl
CRTDLL_mblen(CHAR
*mb
,INT32 size
)
1526 else if ((size
<1)||(!*(mb
+1)))
1531 TRACE(crtdll
,"CRTDLL_mlen %s for max %d bytes ret %d\n",mb
,size
,ret
);
1536 /*********************************************************************
1537 * mbstowcs (CRTDLL.429)
1538 * FIXME: check multibyte support
1540 INT32 __cdecl
CRTDLL_mbstowcs(LPWSTR wcs
, LPCSTR mbs
, INT32 size
)
1543 /* Slightly modified lstrcpynAtoW functions from memory/strings.c
1544 * We need the number of characters transfered
1545 * FIXME: No multibyte support yet
1552 while ((n
-- > 0) && *src
) {
1553 *p
++ = (WCHAR
)(unsigned char)*src
++;
1558 TRACE(crtdll
,"CRTDLL_mbstowcs %s for %d chars put %d wchars\n",
1563 /*********************************************************************
1564 * mbtowc (CRTDLL.430)
1565 * FIXME: check multibyte support
1567 WCHAR __cdecl
CRTDLL_mbtowc(WCHAR
* wc
,CHAR
* mb
,INT32 size
)
1576 if ( (ret
= mblen(mb
,size
)) != -1 )
1578 if (ret
<= sizeof(char))
1579 *wc
= (WCHAR
) ((unsigned char)*mb
);
1586 TRACE(crtdll
,"CRTDLL_mbtowc %s for %d chars\n",mb
,size
);
1591 /*********************************************************************
1592 * _isctype (CRTDLL.138)
1594 BOOL32 __cdecl
CRTDLL__isctype(CHAR x
,CHAR type
)
1596 if ((type
& CRTDLL_SPACE
) && isspace(x
))
1598 if ((type
& CRTDLL_PUNCT
) && ispunct(x
))
1600 if ((type
& CRTDLL_LOWER
) && islower(x
))
1602 if ((type
& CRTDLL_UPPER
) && isupper(x
))
1604 if ((type
& CRTDLL_ALPHA
) && isalpha(x
))
1606 if ((type
& CRTDLL_DIGIT
) && isdigit(x
))
1608 if ((type
& CRTDLL_CONTROL
) && iscntrl(x
))
1610 /* check CRTDLL_LEADBYTE */
1614 /*********************************************************************
1615 * _chdrive (CRTDLL.52)
1617 * newdir [I] drive to change to, A=1
1620 BOOL32 __cdecl
CRTDLL__chdrive(INT32 newdrive
)
1622 /* FIXME: generates errnos */
1623 return DRIVE_SetCurrentDrive(newdrive
-1);
1626 /*********************************************************************
1627 * _chdir (CRTDLL.51)
1629 INT32 __cdecl
CRTDLL__chdir(LPCSTR newdir
)
1631 if (!SetCurrentDirectory32A(newdir
))
1636 /*********************************************************************
1637 * _fullpath (CRTDLL.114)
1639 LPSTR __cdecl
CRTDLL__fullpath(LPSTR buf
, LPCSTR name
, INT32 size
)
1641 DOS_FULL_NAME full_name
;
1646 if(!(buf
= CRTDLL_malloc(size
))) return NULL
;
1648 if (!DOSFS_GetFullName( name
, FALSE
, &full_name
)) return NULL
;
1649 lstrcpyn32A(buf
,full_name
.short_name
,size
);
1650 TRACE(crtdll
,"CRTDLL_fullpath got %s\n",buf
);
1654 /*********************************************************************
1655 * _splitpath (CRTDLL.279)
1657 VOID __cdecl
CRTDLL__splitpath(LPCSTR path
, LPSTR drive
, LPSTR directory
, LPSTR filename
, LPSTR extension
)
1660 directory includes leading and trailing (forward and backward slashes)
1661 filename without dot and slashes
1662 extension with leading dot
1664 char * drivechar
,*dirchar
,*namechar
;
1666 TRACE(crtdll
,"CRTDLL__splitpath got %s\n",path
);
1668 drivechar
= strchr(path
,':');
1669 dirchar
= strrchr(path
,'/');
1670 namechar
= strrchr(path
,'\\');
1671 dirchar
= MAX(dirchar
,namechar
);
1673 namechar
= strrchr(dirchar
,'.');
1675 namechar
= strrchr(path
,'.');
1683 strncat(drive
,path
,drivechar
-path
+1);
1692 strncat(directory
,path
,dirchar
-path
+1);
1701 strncat(filename
,path
,namechar
-path
);
1705 strcat(extension
,namechar
);
1710 TRACE(crtdll
,"CRTDLL__splitpath found %s %s %s %s\n",drive
,directory
,filename
,extension
);
1714 /*********************************************************************
1715 * _getcwd (CRTDLL.120)
1717 CHAR
* __cdecl
CRTDLL__getcwd(LPSTR buf
, INT32 size
)
1724 if (size
< 0) /* allocate as big as nescessary */
1725 len
=GetCurrentDirectory32A(1,test
) + 1;
1726 if(!(buf
= CRTDLL_malloc(len
)))
1728 /* set error to OutOfRange */
1733 if(!(len
=GetCurrentDirectory32A(len
,buf
)))
1739 /* set error to ERANGE */
1740 TRACE(crtdll
,"CRTDLL_getcwd buffer to small\n");
1747 /*********************************************************************
1748 * _getdcwd (CRTDLL.121)
1750 CHAR
* __cdecl
CRTDLL__getdcwd(INT32 drive
,LPSTR buf
, INT32 size
)
1755 FIXME(crtdll
,"(\"%c:\",%s,%d)\n",drive
+'A',buf
,size
);
1758 if (size
< 0) /* allocate as big as nescessary */
1759 len
=GetCurrentDirectory32A(1,test
) + 1;
1760 if(!(buf
= CRTDLL_malloc(len
)))
1762 /* set error to OutOfRange */
1767 if(!(len
=GetCurrentDirectory32A(len
,buf
)))
1773 /* set error to ERANGE */
1774 TRACE(crtdll
,"buffer to small\n");
1781 /*********************************************************************
1782 * _getdrive (CRTDLL.124)
1784 * Return current drive, 1 for A, 2 for B
1786 INT32 __cdecl
CRTDLL__getdrive(VOID
)
1788 return DRIVE_GetCurrentDrive() + 1;
1791 /*********************************************************************
1792 * _mkdir (CRTDLL.234)
1794 INT32 __cdecl
CRTDLL__mkdir(LPCSTR newdir
)
1796 if (!CreateDirectory32A(newdir
,NULL
))
1801 /*********************************************************************
1802 * remove (CRTDLL.448)
1804 INT32 __cdecl
CRTDLL_remove(LPCSTR file
)
1806 if (!DeleteFile32A(file
))
1811 /*********************************************************************
1812 * _errno (CRTDLL.52)
1813 * Yes, this is a function.
1815 LPINT32 __cdecl
CRTDLL__errno()
1817 static int crtdllerrno
;
1819 /* FIXME: we should set the error at the failing function call time */
1820 crtdllerrno
= LastErrorToErrno(GetLastError());
1821 return &crtdllerrno
;
1824 /*********************************************************************
1825 * _tempnam (CRTDLL.305)
1828 LPSTR __cdecl
CRTDLL__tempnam(LPCSTR dir
, LPCSTR prefix
)
1832 DOS_FULL_NAME tempname
;
1834 if ((ret
= tempnam(dir
,prefix
))==NULL
) {
1835 WARN(crtdll
, "Unable to get unique filename\n");
1838 if (!DOSFS_GetFullName(ret
,FALSE
,&tempname
))
1840 TRACE(crtdll
, "Wrong path?\n");
1844 if ((ret
= CRTDLL_malloc(strlen(tempname
.short_name
)+1)) == NULL
) {
1845 WARN(crtdll
, "CRTDL_malloc for shortname failed\n");
1848 if ((ret
= strcpy(ret
,tempname
.short_name
)) == NULL
) {
1849 WARN(crtdll
, "Malloc for shortname failed\n");
1853 TRACE(crtdll
,"dir %s prefix %s got %s\n",
1858 /*********************************************************************
1859 * tmpnam (CRTDLL.490)
1861 * lcclnk from lcc-win32 relies on a terminating dot in the name returned
1864 LPSTR __cdecl
CRTDLL_tmpnam(LPSTR s
)
1868 if ((ret
=tmpnam(s
))== NULL
) {
1869 WARN(crtdll
, "Unable to get unique filename\n");
1872 if (!DOSFS_GetFullName(ret
,FALSE
,&CRTDLL_tmpname
))
1874 TRACE(crtdll
, "Wrong path?\n");
1877 strcat(CRTDLL_tmpname
.short_name
,".");
1878 TRACE(crtdll
,"for buf %p got %s\n",
1879 s
,CRTDLL_tmpname
.short_name
);
1880 TRACE(crtdll
,"long got %s\n",
1881 CRTDLL_tmpname
.long_name
);
1883 return strcpy(s
,CRTDLL_tmpname
.short_name
);
1885 return CRTDLL_tmpname
.short_name
;
1889 /*********************************************************************
1890 * _itoa (CRTDLL.165)
1892 LPSTR __cdecl
CRTDLL__itoa(INT32 x
,LPSTR buf
,INT32 buflen
)
1894 wsnprintf32A(buf
,buflen
,"%d",x
);
1898 /*********************************************************************
1899 * _ltoa (CRTDLL.180)
1901 LPSTR __cdecl
CRTDLL__ltoa(long x
,LPSTR buf
,INT32 radix
)
1904 case 2: FIXME(crtdll
, "binary format not implemented !\n");
1906 case 8: wsnprintf32A(buf
,0x80,"%o",x
);
1908 case 10: wsnprintf32A(buf
,0x80,"%d",x
);
1910 case 16: wsnprintf32A(buf
,0x80,"%x",x
);
1912 default: FIXME(crtdll
, "radix %d not implemented !\n", radix
);
1917 /*********************************************************************
1918 * _ultoa (CRTDLL.311)
1920 LPSTR __cdecl
CRTDLL__ultoa(long x
,LPSTR buf
,INT32 radix
)
1923 case 2: FIXME(crtdll
, "binary format not implemented !\n");
1925 case 8: wsnprintf32A(buf
,0x80,"%lo",x
);
1927 case 10: wsnprintf32A(buf
,0x80,"%ld",x
);
1929 case 16: wsnprintf32A(buf
,0x80,"%lx",x
);
1931 default: FIXME(crtdll
, "radix %d not implemented !\n", radix
);
1936 typedef VOID (*sig_handler_type
)(VOID
);
1938 /*********************************************************************
1939 * signal (CRTDLL.455)
1941 VOID __cdecl
CRTDLL_signal(int sig
, sig_handler_type ptr
)
1943 FIXME(crtdll
, "(%d %p):stub.\n", sig
, ptr
);
1946 /*********************************************************************
1947 * _ftol (CRTDLL.113)
1949 LONG __cdecl
CRTDLL__ftol(double fl
) {
1952 /*********************************************************************
1953 * _sleep (CRTDLL.267)
1955 VOID __cdecl
CRTDLL__sleep(unsigned long timeout
)
1957 TRACE(crtdll
,"CRTDLL__sleep for %ld milliseconds\n",timeout
);
1958 Sleep((timeout
)?timeout
:1);
1961 /*********************************************************************
1962 * getenv (CRTDLL.437)
1964 LPSTR __cdecl
CRTDLL_getenv(const char *name
)
1966 LPSTR environ
= GetEnvironmentStrings32A();
1967 LPSTR pp
,pos
= NULL
;
1968 unsigned int length
;
1970 for (pp
= environ
; (*pp
); pp
= pp
+ strlen(pp
) +1)
1972 pos
=strchr(pp
,'=');
1976 length
= strlen(pp
);
1977 if (!strncmp(pp
,name
,length
)) break;
1982 TRACE(crtdll
,"got %s\n",pp
);
1984 FreeEnvironmentStrings32A( environ
);
1988 /*********************************************************************
1989 * _mbsrchr (CRTDLL.223)
1991 LPSTR __cdecl
CRTDLL__mbsrchr(LPSTR s
,CHAR x
) {
1992 /* FIXME: handle multibyte strings */
1993 return strrchr(s
,x
);
1996 /*********************************************************************
1997 * _memicmp (CRTDLL.233)(NTDLL.868)
1998 * A stringcompare, without \0 check
2000 * -1:if first string is alphabetically before second string
2001 * 1:if second '' '' '' '' first ''
2002 * 0:if both are equal.
2004 INT32 __cdecl
CRTDLL__memicmp(
2005 LPCSTR s1
, /* [in] first string */
2006 LPCSTR s2
, /* [in] second string */
2007 DWORD len
/* [in] length to compare */
2011 for (i
=0;i
<len
;i
++) {
2012 if (tolower(s1
[i
])<tolower(s2
[i
]))
2014 if (tolower(s1
[i
])>tolower(s2
[i
]))
2019 /*********************************************************************
2020 * __dllonexit (CRTDLL.25)
2022 VOID __cdecl
CRTDLL__dllonexit ()
2024 FIXME(crtdll
,"stub\n");
2027 /*********************************************************************
2028 * wcstok (CRTDLL.519)
2029 * Like strtok, but for wide character strings. s is modified, yes.
2031 LPWSTR
CRTDLL_wcstok(LPWSTR s
,LPCWSTR delim
) {
2032 static LPWSTR nexttok
= NULL
;
2040 while (*x
&& !CRTDLL_wcschr(delim
,*x
))
2051 /*********************************************************************
2052 * wcstol (CRTDLL.520)
2053 * Like strtol, but for wide character strings.
2055 INT32
CRTDLL_wcstol(LPWSTR s
,LPWSTR
*end
,INT32 base
) {
2056 LPSTR sA
= HEAP_strdupWtoA(GetProcessHeap(),0,s
),endA
;
2057 INT32 ret
= strtol(sA
,&endA
,base
);
2059 HeapFree(GetProcessHeap(),0,sA
);
2060 if (end
) *end
= s
+(endA
-sA
); /* pointer magic checked. */
2063 /*********************************************************************
2064 * strdate (CRTDLL.283)
2066 LPSTR __cdecl
CRTDLL__strdate (LPSTR date
)
2067 { FIXME (crtdll
,"%p stub\n", date
);
2071 /*********************************************************************
2072 * strtime (CRTDLL.299)
2074 LPSTR __cdecl
CRTDLL__strtime (LPSTR date
)
2075 { FIXME (crtdll
,"%p stub\n", date
);