source: trunk/src/crtdll/crtdll.cpp@ 2372

Last change on this file since 2372 was 2372, checked in by sandervl, 26 years ago

Fixed many register based floating point exports

File size: 122.2 KB
Line 
1/* $Id: crtdll.cpp,v 1.21 2000-01-08 14:24:04 sandervl Exp $ */
2
3/*
4 * The C RunTime DLL
5 *
6 * Implements C run-time functionality as known from UNIX.
7 *
8 * TODO: Check setjmp(3)
9 *
10 * Partialy based on Wine and ReactOS
11 *
12 * Copyright 1996,1998 Marcus Meissner
13 * Copyright 1996 Jukka Iivonen
14 * Copyright 1997 Uwe Bonnes
15 * Copyright 1999 Jens Wiessner
16 */
17
18#include <os2win.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <odinwrap.h>
23#include <misc.h>
24#include <unicode.h>
25#include <heapstring.h>
26#include <ctype.h>
27#include <setjmp.h>
28#include <ntddk.h>
29#include <debugtools.h>
30
31#include <wchar.h>
32#include <wctype.h>
33#include <math.h>
34#include <libc\locale.h>
35#include <signal.h>
36#include <io.h>
37#include <assert.h>
38#include <process.h>
39#include <float.h>
40#include <conio.h>
41#include <direct.h>
42#include <malloc.h>
43#include <drive.h>
44#include <fcntl.h>
45#include <search.h>
46#include <heap.h>
47#include <errno.h>
48#include <sys\utime.h>
49#include <sys\stat.h>
50
51#include <crtdll.h>
52#include "crtinc.h"
53#include "ieee.h"
54
55DEFAULT_DEBUG_CHANNEL(crtdll)
56
57//SvL: per process heap for CRTDLL
58HANDLE CRTDLL_hHeap = 0;
59
60
61/*********************************************************************
62 * CRTDLL_MainInit (CRTDLL.init)
63 */
64BOOL WINAPI CRTDLL_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
65{
66 if (fdwReason == DLL_PROCESS_ATTACH) {
67 CRTDLL__fdopen(0,"r");
68 CRTDLL__fdopen(1,"w");
69 CRTDLL__fdopen(2,"w");
70 CRTDLL_hHeap = HeapCreate(0, 0x10000, 0);
71 }
72 else
73 if (fdwReason == DLL_PROCESS_DETACH) {
74 HeapDestroy(CRTDLL_hHeap);
75 CRTDLL_hHeap = 0;
76 }
77 return TRUE;
78}
79
80
81/*********************************************************************
82 * new (CRTDLL.001)
83 */
84VOID* CDECL CRTDLL_new(DWORD size)
85{
86 dprintf2(("CRTDLL: ??2@YAPAXI@Z\n"));
87 VOID* result;
88 if(!(result = Heap_Alloc(size)) && new_handler)
89 (*new_handler)();
90 return result;
91}
92
93
94/*********************************************************************
95 * delete (CRTDLL.002)
96 */
97VOID CDECL CRTDLL_delete(VOID* ptr)
98{
99 dprintf2(("CRTDLL: ??3@YAXPAX@Z\n"));
100 Heap_Free(ptr);
101}
102
103
104/*********************************************************************
105 * set_new_handler(CRTDLL.003)
106 */
107new_handler_type CDECL CRTDLL_set_new_handler(new_handler_type func)
108{
109 dprintf2(("CRTDLL: ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z\n"));
110 new_handler_type old_handler = new_handler;
111 new_handler = func;
112 return old_handler;
113}
114
115/*********************************************************************
116 * _XcptFilter (CRTDLL.21)
117 */
118INT CDECL CRTDLL__XcptFilter(DWORD ret, struct _EXCEPTION_POINTERS * ExceptionInfo )
119{
120 dprintf2(("CRTDLL: _XcptFilter\n"));
121 return UnhandledExceptionFilter(ExceptionInfo);
122}
123
124/*********************************************************************
125 * _GetMainArgs (CRTDLL.22)
126 */
127DWORD CDECL CRTDLL__GetMainArgs(LPDWORD argc,LPSTR **argv,
128 LPSTR *environ,DWORD flag)
129{
130 char *cmdline;
131 char **xargv;
132 int xargc,i,afterlastspace;
133 DWORD version;
134
135 dprintf2(("CRTDLL: GetMainArgs\n"));
136
137 CRTDLL_acmdln_dll = cmdline = HEAP_strdupA( GetProcessHeap(), 0,
138 GetCommandLineA() );
139
140 version = GetVersion();
141 CRTDLL_osver_dll = version >> 16;
142 CRTDLL_winminor_dll = version & 0xFF;
143 CRTDLL_winmajor_dll = (version>>8) & 0xFF;
144 CRTDLL_baseversion_dll = version >> 16;
145 CRTDLL_winver_dll = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
146 CRTDLL_baseminor_dll = (version >> 16) & 0xFF;
147 CRTDLL_basemajor_dll = (version >> 24) & 0xFF;
148 CRTDLL_osversion_dll = version & 0xFFFF;
149 CRTDLL_osminor_dll = version & 0xFF;
150 CRTDLL_osmajor_dll = (version>>8) & 0xFF;
151
152 /* missing threading init */
153
154 i=0;xargv=NULL;xargc=0;afterlastspace=0;
155/*
156 while (cmdline[i]) {
157 if (cmdline[i]==' ') {
158 xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
159 sizeof(char*)*(++xargc));
160 cmdline[i]='\0';
161 xargv[xargc-1] = HEAP_strdupA( GetProcessHeap(), 0,
162 cmdline+afterlastspace);
163 i++;
164 while (cmdline[i]==' ')
165 i++;
166 if (cmdline[i])
167 afterlastspace=i;
168
169 } else
170 i++;
171
172 }
173
174 xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
175 sizeof(char*)*(++xargc));
176 cmdline[i]='\0';
177 xargv[xargc-1] = HEAP_strdupA( GetProcessHeap(), 0,
178 cmdline+afterlastspace);
179*/
180 CRTDLL_argc_dll = xargc;
181 *argc = xargc;
182 CRTDLL_argv_dll = xargv;
183 *argv = xargv;
184 CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
185 dprintf2(("CRTDLL: GetMainArgs end\n"));
186 return 0;
187}
188
189
190/*********************************************************************
191 * __dllonexit (CRTDLL.25)
192 */
193VOID CDECL CRTDLL___dllonexit ()
194{
195 dprintf(("__dllonexit not implemented.\n"));
196}
197
198
199/*********************************************************************
200 * __doserrno (CRTDLL.26)
201 */
202int * CDECL CRTDLL___doserrno()
203{
204 dprintf2(("__doserrno\n"));
205 _doserrno = GetLastError();
206 return &_doserrno;
207}
208
209
210/*********************************************************************
211 * __fpecode (CRTDLL.27)
212 */
213int fpecode = 0;
214
215int * CDECL CRTDLL___fpecode ( void )
216{
217 dprintf2(("__fpecode\n"));
218 return &fpecode;
219}
220
221
222/*********************************************************************
223 * CRTDLL___isascii (CRTDLL.28)
224 */
225int CDECL CRTDLL___isascii(int i)
226{
227 dprintf2(("CRTDLL: __isascii\n"));
228 return (!((i)&(~0x7f)));
229}
230
231
232/*********************************************************************
233 * CRTDLL___iscsym (CRTDLL.29)
234 */
235int CDECL CRTDLL___iscsym(int c)
236{
237 dprintf2(("CRTDLL: __iscsym\n"));
238 return (CRTDLL_isalnum(c) || ( c == '_' )) ;
239}
240
241
242/*********************************************************************
243 * CRTDLL___iscsymf (CRTDLL.30)
244 */
245int CDECL CRTDLL___iscsymf(int c)
246{
247 dprintf2(("CRTDLL: __iscsymf\n"));
248 return (isalpha(c) || ( c == '_' )) ;
249}
250
251
252/*********************************************************************
253 * CRTDLL___pxcptinfoptrs (CRTDLL.32)
254 */
255void ** CDECL CRTDLL___pxcptinfoptrs (void)
256{
257 dprintf(("CRTDLL: __pxcptinfoptrs not implemented.\n"));
258 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
259 return NULL;
260}
261
262
263/*********************************************************************
264 * CRTDLL___threadhandle (CRTDLL.33)
265 */
266unsigned long CDECL CRTDLL___threadhandle( void )
267{
268 dprintf2(("CRTDLL: __threadhandle\n"));
269 return GetCurrentThread();
270}
271
272
273/*********************************************************************
274 * CRTDLL___threadid (CRTDLL.34)
275 */
276unsigned long CDECL CRTDLL___threadid(void)
277{
278 dprintf2(("CRTDLL: __threadid\n"));
279 return GetCurrentThreadId();
280}
281
282
283/*********************************************************************
284 * CRTDLL__abnormal_termination (CRTDLL.36)
285 */
286int CDECL CRTDLL__abnormal_termination(void)
287{
288 dprintf(("CRTDLL: _abnormal_termination not implemented.\n"));
289 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
290 return FALSE;
291}
292
293
294/*********************************************************************
295 * CRTDLL__access (CRTDLL.37)
296 */
297int CDECL CRTDLL__access(const char *path,int mode)
298{
299 dprintf2(("CRTDLL: _access\n"));
300 return (_access(path, mode));
301}
302
303
304/*********************************************************************
305 * CRTDLL___toascii (CRTDLL.38)
306 */
307int CDECL CRTDLL___toascii(int c)
308{
309 dprintf2(("CRTDLL: __toascii\n"));
310 return ((unsigned)(c) & 0x7F );
311}
312
313
314/*********************************************************************
315 * _aexit_rtn_dll (CRTDLL.39)
316 */
317VOID CDECL CRTDLL__aexit_rtn_dll(int exitcode)
318{
319 dprintf2(("CRTDLL: _aexit_rtn_dll\n"));
320 ExitProcess(exitcode);
321}
322
323
324/*********************************************************************
325 * _amsg_exit (CRTDLL.40)
326 */
327VOID CDECL CRTDLL__amsg_exit(int errnum)
328{
329 dprintf2(("CRTDLL: _amsg_exit\n"));
330 fprintf(stderr,strerror(errnum));
331 ExitProcess(-1);
332}
333
334
335/*********************************************************************
336 * CRTDLL__assert (CRTDLL.41)
337 */
338void CDECL CRTDLL__assert( char *s1, char *s2, int i)
339{
340 dprintf2(("CRTDLL: _assert\n"));
341 _assert(s1, s2, i);
342}
343
344
345/*********************************************************************
346 * CRTDLL__beep (CRTDLL.45)
347 */
348void CDECL CRTDLL__beep(unsigned nFreq, unsigned nDur)
349{
350 dprintf2(("_beep\n"));
351 Beep(nFreq,nDur);
352}
353
354
355/*********************************************************************
356 * CRTDLL__beginthread (CRTDLL.46)
357 */
358unsigned long CDECL CRTDLL__beginthread(void (*pfuncStart)(void *),
359 unsigned unStackSize, void* pArgList)
360{
361 DWORD ThreadId;
362 HANDLE hThread;
363 if ( pfuncStart == NULL )
364 __set_errno(EINVAL);
365
366 hThread = CreateThread( NULL,unStackSize,(LPTHREAD_START_ROUTINE)pfuncStart,pArgList,0, &ThreadId);
367 if (hThread == NULL ) {
368 __set_errno(EAGAIN);
369 return -1;
370 }
371 return (unsigned long)hThread;
372}
373
374
375/*********************************************************************
376 * _c_exit (CRTDLL.47)
377 *
378 */
379void CDECL CRTDLL__c_exit(INT ret)
380{
381 dprintf2(("_c_exit(%d)\n",ret));
382 ExitProcess(ret);
383}
384
385
386/*********************************************************************
387 * CRTDLL__cabs (CRTDLL.48)
388 */
389double CDECL CRTDLL__cabs(struct _complex z)
390{
391 dprintf2(("CRTDLL: _cabs\n"));
392 return sqrt( z.x*z.x + z.y*z.y );
393}
394
395
396/*********************************************************************
397 * _cexit (CRTDLL.49)
398 */
399void CDECL CRTDLL__cexit(INT ret)
400{
401 dprintf2(("_cexit(%d)\n",ret));
402 ExitProcess(ret);
403}
404
405
406/*********************************************************************
407 * CRTDLL__cgets (CRTDLL.50)
408 */
409char * CDECL CRTDLL__cgets( char *s )
410{
411 dprintf2(("CRTDLL: _cgets\n"));
412 return (_cgets(s));
413}
414
415
416/*********************************************************************
417 * _chdir (CRTDLL.51)
418 */
419INT CDECL CRTDLL__chdir(LPCSTR newdir)
420{
421 dprintf2(("CRTDLL: chdir\n"));
422 if (!SetCurrentDirectoryA(newdir))
423 return 1;
424 return 0;
425}
426
427
428/*********************************************************************
429 * _chdrive (CRTDLL.52)
430 *
431 * newdir [I] drive to change to, A=1
432 *
433 */
434BOOL CDECL CRTDLL__chdrive(INT newdrive)
435{
436 /* FIXME: generates errnos */
437 dprintf2(("CRTDLL: _chdrive\n"));
438 return DRIVE_SetCurrentDrive(newdrive-1);
439}
440
441
442/*********************************************************************
443 * CRTDLL__chgsign (CRTDLL.53)
444 */
445double CDECL CRTDLL__chgsign(double __x)
446{
447 dprintf2(("CRTDLL: _chgsign\n"));
448 double_t *x = (double_t *)&x;
449 if ( x->sign == 1 )
450 x->sign = 0;
451 else
452 x->sign = 1;
453
454 return __x;
455}
456
457
458/*********************************************************************
459 * CRTDLL__chmod (CRTDLL.54)
460 */
461int CDECL CRTDLL__chmod( const char *s, int i)
462{
463 dprintf2(("CRTDLL: _chmod\n"));
464 return (_chmod(s, i));
465}
466
467
468/*********************************************************************
469 * CRTDLL__chsize (CRTDLL.55)
470 */
471int CDECL CRTDLL__chsize( int i, long l )
472{
473 dprintf2(("CRTDLL: _chsize\n"));
474 return (_chsize(i, l));
475}
476
477
478/*********************************************************************
479 * CRTDLL__clearfp (CRTDLL.56)
480 */
481unsigned int CDECL CRTDLL__clearfp( void )
482{
483 dprintf2(("CRTDLL: _clearfp\n"));
484 return (_clear87());
485}
486
487
488/*********************************************************************
489 * CRTDLL__close (CRTDLL.57)
490 */
491int CDECL CRTDLL__close(int handle)
492{
493 dprintf2(("CRTDLL: _close\n"));
494 return (_close(handle));
495}
496
497
498/*********************************************************************
499 * CRTDLL__commit (CRTDLL.58)
500 */
501int CDECL CRTDLL__commit( int _fd )
502{
503 dprintf2(("CRTDLL: _commit\n"));
504 if (! FlushFileBuffers((HFILE)CRTDLL__get_osfhandle(_fd)) ) {
505 __set_errno(EBADF);
506 return -1;
507 }
508 return 0;
509}
510
511
512/*********************************************************************
513 * CRTDLL__control87 (CRTDLL.60)
514 */
515unsigned CDECL CRTDLL__control87(unsigned i1,unsigned i2)
516{
517 dprintf2(("CRTDLL: _control87\n"));
518 return (_control87(i1, i2));
519}
520
521
522/*********************************************************************
523 * CRTDLL__controlfp (CRTDLL.61)
524 */
525unsigned CDECL CRTDLL__controlfp(unsigned i1,unsigned i2)
526{
527 dprintf2(("CRTDLL: _controlfp\n"));
528 return (_control87(i1, i2));
529}
530
531
532/*********************************************************************
533 * CRTDLL__copysign (CRTDLL.62)
534 */
535double CDECL CRTDLL__copysign( double __d, double __s )
536{
537 dprintf2(("CRTDLL: _copysign\n"));
538 double_t *d = (double_t *)&__d;
539 double_t *s = (double_t *)&__s;
540
541 d->sign = s->sign;
542
543 return __d;
544}
545
546
547/*********************************************************************
548 * _cprintf (CRTDLL.63)
549 */
550INT CDECL CRTDLL__cprintf( char *fmt, ... )
551{
552 dprintf2(("CRTDLL: _cprintf.\n"));
553
554 int cnt;
555 char buf[ 2048 ]; /* this is buggy, because buffer might be too small. */
556 va_list ap;
557
558 va_start(ap, fmt);
559 cnt = vsprintf(buf, fmt, ap);
560 va_end(ap);
561
562 _cputs(buf);
563 return cnt;
564}
565
566
567/*********************************************************************
568 * CRTDLL__cputs (CRTDLL.65)
569 */
570INT CDECL CRTDLL__cputs( char * s )
571{
572 dprintf2(("CRTDLL: _cputs\n"));
573 return (_cputs(s));
574}
575
576
577/*********************************************************************
578 * CRTDLL__creat (CRTDLL.66)
579 */
580INT CDECL CRTDLL__creat( const char *s, int i )
581{
582 dprintf2(("CRTDLL: _creat\n"));
583 return (_creat(s, i));
584}
585
586
587/*********************************************************************
588 * CRTDLL__cscanf (CRTDLL.67)
589 */
590INT CDECL CRTDLL__cscanf( char *s, ... )
591{
592 dprintf(("CRTDLL: _cscanf not implemented.\n"));
593 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
594 return FALSE;
595}
596
597
598/*********************************************************************
599 * CRTDLL__cwait (CRTDLL.69)
600 */
601int CDECL CRTDLL__cwait( int *status, int process_id, int action_code )
602{
603 dprintf2(("CRTDLL: _cwait\n"));
604 return (_cwait(status, process_id, action_code));
605}
606
607
608/*********************************************************************
609 * CRTDLL__dup (CRTDLL.71)
610 */
611int CDECL CRTDLL__dup(int handle)
612{
613 dprintf2(("CRTDLL: _dup\n"));
614 return (_dup(handle));
615}
616
617
618/*********************************************************************
619 * CRTDLL__dup2 (CRTDLL.72)
620 */
621int CDECL CRTDLL__dup2(int handle1,int handle2)
622{
623 dprintf2(("CRTDLL: _dup2\n"));
624 return (_dup2(handle1, handle2));
625}
626
627
628/*********************************************************************
629 * CRTDLL__ecvt (CRTDLL.73)
630 */
631char * CDECL CRTDLL__ecvt( double val, int ndig, int *dec, int *sign )
632{
633 dprintf2(("CRTDLL: _ecvt\n"));
634 return (_ecvt(val, ndig, dec, sign));
635}
636
637
638/*********************************************************************
639 * CRTDLL__endthread (CRTDLL.74)
640 */
641void CDECL CRTDLL__endthread(void)
642{
643 dprintf2(("CRTDLL: _endthread\n"));
644 _endthread ();
645}
646
647
648/*********************************************************************
649 * CRTDLL___eof (CRTDLL.76)
650 */
651int CDECL CRTDLL__eof( int _fd )
652{
653 dprintf2(("CRTDLL: _eof\n"));
654 int cur_pos = CRTDLL__lseek(_fd, 0, SEEK_CUR);
655 int end_pos = CRTDLL__filelength( _fd );
656 if ( cur_pos == -1 || end_pos == -1)
657 return -1;
658
659 if ( cur_pos == end_pos )
660 return 1;
661
662 return 0;
663}
664
665
666/*********************************************************************
667 * CRTDLL__errno (CRTDLL.77)
668 */
669int * CDECL CRTDLL__errno(void)
670{
671 dprintf2(("CRTDLL: _errno\n"));
672 return (_errno());
673}
674
675
676/*********************************************************************
677 * _except_handler2 (CRTDLL.78)
678 */
679INT CDECL CRTDLL__except_handler2 ( PEXCEPTION_RECORD rec,
680 PEXCEPTION_FRAME frame, PCONTEXT context,
681 PEXCEPTION_FRAME *dispatcher)
682{
683 dprintf2(("CRTDLL: _except_handler2\n"));
684 return 1;
685}
686
687
688/*********************************************************************
689 * _execl (CRTDLL.79)
690 */
691int CDECL CRTDLL__execl(const char* szPath, const char* szArgv0, ...)
692{
693 dprintf2(("CRTDLL: _execl\n"));
694
695 char *szArg[100];
696 const char *a;
697 int i = 0;
698 va_list l = 0;
699 va_start(l,szArgv0);
700 do {
701 a = va_arg(l,const char *);
702 szArg[i++] = (char *)a;
703 } while ( a != NULL && i < 100 );
704
705 return _spawnve(P_OVERLAY, (char*)szPath, szArg, _environ);
706}
707
708
709/*********************************************************************
710 * CRTDLL__execle (CRTDLL.80)
711 */
712int CDECL CRTDLL__execle(char *path, char *szArgv0, ...)
713{
714 dprintf2(("CRTDLL: _execle not correct implemented.\n"));
715 char *szArg[100];
716 const char *a;
717 char *ptr;
718 int i = 0;
719 va_list l = 0;
720 va_start(l,szArgv0);
721 do {
722 a = (const char *)va_arg(l,const char *);
723 szArg[i++] = (char *)a;
724 } while ( a != NULL && i < 100 );
725
726
727// szArg0 is passed and not environment if there is only one parameter;
728
729 if ( i >=2 ) {
730 ptr = szArg[i-2];
731 szArg[i-2] = NULL;
732 }
733 else
734 ptr = NULL;
735
736 return _spawnve(P_OVERLAY, path, szArg, (char**)ptr);
737}
738
739
740/*********************************************************************
741 * CRTDLL__execlp (CRTDLL.81)
742 */
743int CDECL CRTDLL__execlp( char *szPath, char *szArgv0, ...)
744{
745 dprintf2(("CRTDLL: _execlp\n"));
746 char *szArg[100];
747 const char *a;
748 int i = 0;
749 va_list l = 0;
750 va_start(l,szArgv0);
751 do {
752 a = (const char *)va_arg(l,const char *);
753 szArg[i++] = (char *)a;
754 } while ( a != NULL && i < 100 );
755 return _spawnvpe(P_OVERLAY, szPath,szArg, _environ);
756}
757
758
759/*********************************************************************
760 * CRTDLL__execlpe (CRTDLL.82)
761 */
762int CDECL CRTDLL__execlpe( char *path, char *szArgv0, ...)
763{
764 dprintf2(("CRTDLL: _execlpe not correct implemented.\n"));
765 char *szArg[100];
766 const char *a;
767 char *ptr;
768 int i = 0;
769 va_list l = 0;
770 va_start(l,szArgv0);
771 do {
772 a = (const char *)va_arg(l,const char *);
773 szArg[i++] = (char *)a;
774 } while ( a != NULL && i < 100 );
775
776
777// szArg0 is passed and not environment if there is only one parameter;
778
779 if ( i >=2 ) {
780 ptr = szArg[i-2];
781 szArg[i-2] = NULL;
782 }
783 else
784 ptr = NULL;
785 return spawnvpe(P_OVERLAY, path, szArg, (char**)ptr);
786}
787
788
789/*********************************************************************
790 * CRTDLL__execv (CRTDLL.83)
791 */
792int CDECL CRTDLL__execv( char *s1, char **s2)
793{
794 dprintf2(("CRTDLL: _execv\n"));
795 return (_execv(s1, s2));
796}
797
798
799/*********************************************************************
800 * CRTDLL__execve (CRTDLL.84)
801 */
802int CDECL CRTDLL__execve( char *s1, char **s2, char **s3)
803{
804 dprintf2(("CRTDLL: _execve\n"));
805 return (_execve(s1, s2, s3));
806}
807
808
809/*********************************************************************
810 * CRTDLL__execvp (CRTDLL.85)
811 */
812int CDECL CRTDLL__execvp( char *s1, char **s2)
813{
814 dprintf2(("CRTDLL: _execvp\n"));
815 return (_execvp(s1, s2));
816}
817
818
819/*********************************************************************
820 * CRTDLL__execvpe (CRTDLL.86)
821 */
822int CDECL CRTDLL__execvpe( char *s1, char **s2, char **s3)
823{
824 dprintf2(("CRTDLL: _execvpe\n"));
825 return (_execvpe(s1, s2, s3));
826}
827
828
829/*********************************************************************
830 * _exit (CRTDLL.87)
831 */
832VOID CDECL CRTDLL__exit(DWORD ret)
833{
834 dprintf2(("CRTDLL: _exit\n"));
835 ExitProcess(ret);
836}
837
838
839/*********************************************************************
840 * _expand (CRTDLL.88)
841 */
842void * CDECL CRTDLL__expand( void *ptr, size_t size )
843{
844 dprintf(("CRTDLL: _expand not implemented.\n"));
845 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
846 return FALSE;
847}
848
849
850/*********************************************************************
851 * _fcloseall (CRTDLL.89)
852 */
853int CDECL CRTDLL__fcloseall( void )
854{
855 dprintf2(("CRTDLL: _fcloseall\n"));
856 return (_fcloseall());
857}
858
859
860/*********************************************************************
861 * _fcvt (CRTDLL.90)
862 */
863char * CDECL CRTDLL__fcvt( double val, int ndig, int *dec, int *sign )
864{
865 dprintf2(("CRTDLL: _fcvt\n"));
866 return (_fcvt(val, ndig, dec, sign));
867}
868
869
870/*********************************************************************
871 * _fdopen (CRTDLL.91)
872 */
873CRTDLL_FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode)
874{
875 dprintf2(("CRTDLL: fdopen\n"));
876 CRTDLL_FILE *file;
877
878 switch (handle)
879 {
880 case 0:
881 file = CRTDLL_stdin;
882 if (!file->handle) file->handle = GetStdHandle( STD_INPUT_HANDLE );
883 break;
884 case 1:
885 file = CRTDLL_stdout;
886 if (!file->handle) file->handle = GetStdHandle( STD_OUTPUT_HANDLE );
887 break;
888 case 2:
889 file=CRTDLL_stderr;
890 if (!file->handle) file->handle = GetStdHandle( STD_ERROR_HANDLE );
891 break;
892 default:
893 file = (PCRTDLL_FILE)Heap_Alloc(sizeof(*file) );
894 file->handle = handle;
895 break;
896 }
897 return file;
898}
899
900
901/*********************************************************************
902 * _fgetchar (CRTDLL.92)
903 */
904int CDECL CRTDLL__fgetchar( void )
905{
906 dprintf2(("CRTDLL: _fgetchar\n"));
907 return (_fgetchar());
908}
909
910
911/*********************************************************************
912 * _fgetwchar (CRTDLL.93)
913 */
914wint_t CDECL CRTDLL__fgetwchar( void *i )
915{
916 dprintf2(("CRTDLL: _fgetwchar\n"));
917 return CRTDLL__getch();
918}
919
920
921/*********************************************************************
922 * _filbuf (CRTDLL.94)
923 */
924int CDECL CRTDLL__filbuf(FILE * f)
925{
926 dprintf(("CRTDLL: _filbuf not implemented.\n"));
927 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
928 return FALSE;
929}
930
931
932/*********************************************************************
933 * CRTDLL__filelength (CRTDLL.96)
934 */
935long CDECL CRTDLL__filelength( int i )
936{
937 dprintf2(("CRTDLL: _filelength\n"));
938 return (_filelength(i));
939}
940
941
942/*********************************************************************
943 * _fileno (CRTDLL.97)
944 */
945int CDECL CRTDLL__fileno(FILE * f)
946{
947 dprintf2(("CRTDLL: _fileno\n"));
948 return (_fileno(f));
949}
950
951
952/*********************************************************************
953* _findclose (CRTDLL.098)
954*/
955int CDECL CRTDLL__findclose( long handle )
956{
957 dprintf2(("CRTDLL: _findclose\n"));
958 // check no wildcards or invalid handle
959 if ( handle == 0 || handle == -1)
960 return 0;
961 return FindClose(handle);
962}
963
964
965 /*********************************************************************
966 * _findfirst (CRTDLL.099)
967 */
968DWORD CDECL CRTDLL__findfirst(LPCSTR fname, struct find_t * x2)
969{
970 dprintf(("CRTDLL: _findfirst not implemented.\n"));
971 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
972 return FALSE;
973}
974
975
976/*********************************************************************
977 * _findnext (CRTDLL.100)
978 */
979INT CDECL CRTDLL__findnext(DWORD hand, struct find_t * x2)
980{
981 dprintf(("CRTDLL: _findnext not implemented.\n"));
982 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
983 return FALSE;
984}
985
986
987/*********************************************************************
988 * _finite (CRTDLL.101)
989 */
990INT CDECL CRTDLL__finite(double x)
991{
992 dprintf2(("CRTDLL: _finite\n"));
993 return !_isinf(x);
994}
995
996
997/*********************************************************************
998 * _flsbuf (CRTDLL.102)
999 */
1000INT CDECL CRTDLL__flsbuf(int i, FILE * f)
1001{
1002 dprintf(("CRTDLL: _flsbuf not implemented.\n"));
1003 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1004 return FALSE;
1005}
1006
1007
1008/*********************************************************************
1009 * _flushall (CRTDLL.103)
1010 */
1011INT CDECL CRTDLL__flushall(void)
1012{
1013 dprintf2(("CRTDLL: _flushall\n"));
1014 return (_flushall());
1015}
1016
1017
1018/*********************************************************************
1019 * _fpclass (CRTDLL.105)
1020 */
1021INT CDECL CRTDLL__fpclass( double __d )
1022{
1023 dprintf2(("CRTDLL: _fpclass\n"));
1024 double_t *d = (double_t *)&__d;
1025
1026 if ( d->exponent == 0 ) {
1027 if ( d->mantissah == 0 && d->mantissal == 0 ) {
1028 if ( d->sign ==0 )
1029 return FP_NZERO;
1030 else
1031 return FP_PZERO;
1032 } else {
1033 if ( d->sign ==0 )
1034 return FP_NDENORM;
1035 else
1036 return FP_PDENORM;
1037 }
1038 }
1039 if (d->exponent == 0x7ff ) {
1040 if ( d->mantissah == 0 && d->mantissal == 0 ) {
1041 if ( d->sign ==0 )
1042 return FP_NINF;
1043 else
1044 return FP_PINF;
1045 }
1046 else if ( d->mantissah == 0 && d->mantissal != 0 ) {
1047 return FP_QNAN;
1048 }
1049 else if ( d->mantissah == 0 && d->mantissal != 0 ) {
1050 return FP_SNAN;
1051 }
1052
1053 }
1054
1055 return 0;
1056}
1057
1058
1059/*********************************************************************
1060 * _fpieee_flt (CRTDLL.106)
1061 */
1062INT CDECL CRTDLL__fpieee_flt( unsigned long exc_code, struct _EXCEPTION_POINTERS *exc_info, int handler)
1063{
1064 dprintf(("CRTDLL: _fpieee_flt not implemented.\n"));
1065 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1066 return 0;
1067}
1068
1069
1070
1071/*********************************************************************
1072 * _fpreset (CRTDLL.107)
1073 */
1074void CDECL CRTDLL__fpreset(void)
1075{
1076 dprintf(("CRTDLL: _fpreset not implemented.\n"));
1077 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1078}
1079
1080
1081/*********************************************************************
1082 * _fputchar (CRTDLL.108)
1083 */
1084INT CDECL CRTDLL__fputchar( int c )
1085{
1086 dprintf2(("CRTDLL: _fputchar\n"));
1087 return(_fputchar(c));
1088}
1089
1090
1091/*********************************************************************
1092 * _fputwchar (CRTDLL.109)
1093 */
1094wint_t CDECL CRTDLL__fputwchar( wint_t )
1095{
1096 dprintf(("CRTDLL: _fputwchar not implemented.\n"));
1097 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1098 return FALSE;
1099}
1100
1101
1102/*********************************************************************
1103 * _fsopen (CRTDLL.110)
1104 */
1105FILE * CDECL CRTDLL__fsopen( const char *file, const char *mode, int shflag )
1106{
1107 dprintf(("CRTDLL: _fsopen not implemented.\n"));
1108 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1109 return FALSE;
1110}
1111
1112
1113/*********************************************************************
1114 * _fstat (CRTDLL.111)
1115 */
1116int CDECL CRTDLL__fstat(int file, struct stat* buf)
1117{
1118 dprintf(("CRTDLL: _fstat not implemented.\n"));
1119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1120 return FALSE;
1121}
1122
1123
1124/*********************************************************************
1125 * _ftime (CRTDLL.112)
1126 */
1127int CDECL CRTDLL__ftime( struct timeb *timebuf )
1128{
1129 dprintf(("CRTDLL: _ftime not implemented.\n"));
1130 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1131 return FALSE;
1132}
1133
1134
1135/*********************************************************************
1136 * _fullpath (CRTDLL.114)
1137 */
1138char * CDECL CRTDLL__fullpath( char *buf, char *path, size_t size )
1139{
1140 dprintf2(("CRTDLL: _fullpath\n"));
1141 return (_fullpath(buf, path, size));
1142}
1143
1144
1145/*********************************************************************
1146 * _futime (CRTDLL.115)
1147 */
1148int CDECL CRTDLL__futime( int handle, struct _utimbuf *filetime )
1149{
1150 dprintf(("CRTDLL: _futime not implemented.\n"));
1151 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1152 return FALSE;
1153}
1154
1155
1156/*********************************************************************
1157 * _gcvt (CRTDLL.116)
1158 */
1159char * CDECL CRTDLL__gcvt( double val, int ndig, char *buf )
1160{
1161 dprintf2(("CRTDLL: _gcvt\n"));
1162 return (_gcvt(val, ndig, buf));
1163}
1164
1165
1166/*********************************************************************
1167 * _get_osfhandle (CRTDLL.117)
1168 */
1169void* CDECL CRTDLL__get_osfhandle( int fileno )
1170{
1171 dprintf2(("CRTDLL: _get_osfhandle\n"));
1172 return filehnd(fileno);
1173}
1174
1175
1176/*********************************************************************
1177 * _getch (CRTDLL.118)
1178 */
1179int CDECL CRTDLL__getch(void)
1180{
1181 dprintf2(("CRTDLL: _getch\n"));
1182 return (_getch());
1183}
1184
1185
1186/*********************************************************************
1187 * _getche (CRTDLL.119)
1188 */
1189int CDECL CRTDLL__getche(void)
1190{
1191 dprintf2(("CRTDLL: _getche\n"));
1192 return (_getche());
1193}
1194
1195
1196/*********************************************************************
1197 * _getcwd (CRTDLL.120)
1198 */
1199char * CDECL CRTDLL__getcwd( char *buf, size_t size )
1200{
1201 dprintf2(("CRTDLL: _getcwd\n"));
1202 return (_getcwd(buf, size));
1203}
1204
1205
1206/*********************************************************************
1207 * _getdcwd (CRTDLL.121)
1208 */
1209char * CDECL CRTDLL__getdcwd( int drive, char *buffer, size_t maxlen )
1210{
1211 dprintf2(("CRTDLL: _getdcwd\n"));
1212 return (_getdcwd(drive, buffer, maxlen));
1213}
1214
1215
1216/*********************************************************************
1217 * _getdiskfree (CRTDLL.122)
1218 */
1219unsigned int CDECL CRTDLL__getdiskfree( unsigned int drive, struct _diskfree_t *diskspace)
1220{
1221 dprintf2(("CRTDLL: _getdiskfree\n"));
1222 char RootPathName[10];
1223 RootPathName[0] = toupper(drive +'@');
1224 RootPathName[1] = ':';
1225 RootPathName[2] = '\\';
1226 RootPathName[3] = 0;
1227 if ( diskspace == NULL )
1228 return 0;
1229
1230 if ( !GetDiskFreeSpaceA(RootPathName,(LPDWORD)&diskspace->sectors_per_cluster,(LPDWORD)&diskspace->bytes_per_sector,
1231 (LPDWORD )&diskspace->avail_clusters,(LPDWORD )&diskspace->total_clusters ) )
1232 return 0;
1233 return diskspace->avail_clusters;
1234}
1235
1236
1237/*********************************************************************
1238 * _getdllprocaddr (CRTDLL.123)
1239 */
1240FARPROC CDECL CRTDLL__getdllprocaddr(HMODULE hModule,char * lpProcName, int iOrdinal)
1241{
1242 dprintf2(("CRTDLL: _getdllprocaddr\n"));
1243 if ( lpProcName != NULL )
1244 return GetProcAddress(hModule, lpProcName);
1245 else
1246 return GetProcAddress(hModule, (LPSTR)iOrdinal);
1247 return (NULL);
1248}
1249
1250
1251/*********************************************************************
1252 * _getdrive (CRTDLL.124)
1253 */
1254unsigned CDECL CRTDLL__getdrive( void )
1255{
1256 dprintf2(("CRTDLL: _getdrive\n"));
1257 return DRIVE_GetCurrentDrive() + 1;
1258}
1259
1260
1261/*********************************************************************
1262 * _getdrives (CRTDLL.125)
1263 */
1264unsigned long CDECL CRTDLL__getdrives(void)
1265{
1266 dprintf2(("CRTDLL: _getdrives\n"));
1267 return GetLogicalDrives();
1268}
1269
1270
1271/*********************************************************************
1272 * _getpid (CRTDLL.126)
1273 */
1274int CDECL CRTDLL__getpid( void )
1275{
1276 dprintf2(("CRTDLL: _getpid\n"));
1277 return (_getpid());
1278}
1279
1280
1281/*********************************************************************
1282 * _getsystime (CRTDLL.127)
1283 */
1284unsigned int CDECL CRTDLL__getsystime(struct tm *tp)
1285{
1286 dprintf(("CRTDLL: _getsystime not implemented.\n"));
1287 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1288 return FALSE;
1289}
1290
1291
1292/*********************************************************************
1293 * _getw (CRTDLL.128)
1294 */
1295int CDECL CRTDLL__getw( FILE *stream )
1296{
1297 dprintf2(("CRTDLL: _getw\n"));
1298 int w;
1299
1300 /* Is there a better way? */
1301 if (CRTDLL_fread( &w, sizeof(w), 1, stream) != 1)
1302 return(EOF);
1303 return(w);
1304}
1305
1306
1307/*******************************************************************
1308 * _global_unwind2 (CRTDLL.129)
1309 */
1310void CDECL CRTDLL__global_unwind2( PEXCEPTION_FRAME frame )
1311{
1312 dprintf2(("CRTDLL: global_undwind2\n"));
1313 RtlUnwind( frame, 0, NULL, 0 );
1314}
1315
1316
1317/*********************************************************************
1318 * _heapchk (CRTDLL.130)
1319 */
1320int CDECL CRTDLL__heapchk( void )
1321{
1322 dprintf2(("CRTDLL: _heapchk\n"));
1323 return (_heapchk());
1324}
1325
1326
1327/*********************************************************************
1328 * _heapmin (CRTDLL.131)
1329 */
1330int CDECL CRTDLL__heapmin( void )
1331{
1332 dprintf2(("CRTDLL: _heapmin\n"));
1333 return (_heapmin());
1334}
1335
1336
1337/*********************************************************************
1338 * _heapset (CRTDLL.132)
1339 */
1340int CDECL CRTDLL__heapset( unsigned int fill )
1341{
1342 dprintf2(("CRTDLL: _heapset\n"));
1343 return (_heapset(fill));
1344}
1345
1346
1347/*********************************************************************
1348 * _heapwalk (CRTDLL.133)
1349 */
1350int CDECL CRTDLL__heapwalk( struct _heapinfo *entry )
1351{
1352 dprintf(("CRTDLL: _heapwalk not implemented.\n"));
1353 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1354 return 0;
1355}
1356
1357
1358/*********************************************************************
1359 * _hypot (CRTDLL.134)
1360 */
1361double CDECL CRTDLL__hypot(double x1, double x2)
1362{
1363 dprintf2(("CRTDLL: _hypot\n"));
1364 return (_hypot(x1, x2));
1365}
1366
1367
1368/*********************************************************************
1369 * _initterm (CRTDLL.135)
1370 */
1371DWORD CDECL CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end)
1372{
1373 dprintf2(("CRTDLL: initterm\n"));
1374 _INITTERMFUN *current;
1375
1376 current=start;
1377 while (current<end) {
1378 if (*current) (*current)();
1379 current++;
1380 }
1381 return 0;
1382}
1383
1384
1385/*********************************************************************
1386 * _isatty (CRTDLL.137)
1387 */
1388BOOL CDECL CRTDLL__isatty(DWORD x)
1389{
1390 dprintf2(("(%ld)\n",x));
1391 return TRUE;
1392}
1393
1394
1395/*********************************************************************
1396 * _isctype (CRTDLL.138)
1397 */
1398BOOL CDECL CRTDLL__isctype(CHAR x,CHAR type)
1399{
1400 dprintf2(("CRTDLL: isctype\n"));
1401 if ((type & CRTDLL_SPACE) && isspace(x))
1402 return TRUE;
1403 if ((type & CRTDLL_PUNCT) && ispunct(x))
1404 return TRUE;
1405 if ((type & CRTDLL_LOWER) && islower(x))
1406 return TRUE;
1407 if ((type & CRTDLL_UPPER) && isupper(x))
1408 return TRUE;
1409 if ((type & CRTDLL_ALPHA) && isalpha(x))
1410 return TRUE;
1411 if ((type & CRTDLL_DIGIT) && isdigit(x))
1412 return TRUE;
1413 if ((type & CRTDLL_CONTROL) && iscntrl(x))
1414 return TRUE;
1415 /* check CRTDLL_LEADBYTE */
1416 return FALSE;
1417}
1418
1419
1420/*********************************************************************
1421 * _ismbbalnum (CRTDLL.139)
1422 */
1423int CDECL CRTDLL__ismbbalnum( unsigned int c )
1424{
1425 dprintf2(("CRTDLL: _ismbbalnum\n"));
1426 return (CRTDLL_isalnum(c) || CRTDLL__ismbbkalnum(c));
1427}
1428
1429
1430/*********************************************************************
1431 * _ismbbalpha (CRTDLL.140)
1432 */
1433int CDECL CRTDLL__ismbbalpha( unsigned int c )
1434{
1435 dprintf2(("CRTDLL: _ismbbalpha\n"));
1436 return (isalpha(c) || CRTDLL__ismbbkalnum(c));
1437}
1438
1439
1440/*********************************************************************
1441 * _ismbbgraph (CRTDLL.141)
1442 */
1443int CDECL CRTDLL__ismbbgraph( unsigned int c )
1444{
1445 dprintf2(("CRTDLL: _ismbbgraph\n"));
1446 return (CRTDLL_isgraph(c) || CRTDLL__ismbbkana(c));
1447}
1448
1449
1450/*********************************************************************
1451 * _ismbbkalnum (CRTDLL.142)
1452 */
1453int CDECL CRTDLL__ismbbkalnum( unsigned int c )
1454{
1455 dprintf2(("CRTDLL: _ismbbkalnum\n"));
1456 return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
1457}
1458
1459
1460/*********************************************************************
1461 * _ismbbkana (CRTDLL.143)
1462 */
1463int CDECL CRTDLL__ismbbkana( unsigned int c )
1464{
1465 dprintf2(("CRTDLL: _ismbbkana\n"));
1466 return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P));
1467}
1468
1469
1470/*********************************************************************
1471 * _ismbbkpunct (CRTDLL.144)
1472 */
1473int CDECL CRTDLL__ismbbkpunct( unsigned int c )
1474{
1475 dprintf2(("CRTDLL: _ismbbkpunct\n"));
1476 return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
1477}
1478
1479
1480/*********************************************************************
1481 * _ismbblead (CRTDLL.145)
1482 */
1483int CDECL CRTDLL__ismbblead( unsigned int c )
1484{
1485 dprintf2(("CRTDLL: _ismbblead\n"));
1486 return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1);
1487}
1488
1489
1490/*********************************************************************
1491 * _ismbbprint (CRTDLL.146)
1492 */
1493int CDECL CRTDLL__ismbbprint( unsigned int c )
1494{
1495 dprintf2(("CRTDLL: _ismbbprint\n"));
1496 return (isprint(c) || CRTDLL__ismbbkana(c));
1497}
1498
1499
1500/*********************************************************************
1501 * _ismbbpunct (CRTDLL.147)
1502 */
1503int CDECL CRTDLL__ismbbpunct( unsigned int c )
1504{
1505 dprintf2(("CRTDLL: _ismbbpunct\n"));
1506 return (ispunct(c) || CRTDLL__ismbbkana(c));
1507}
1508
1509
1510/*********************************************************************
1511 * _ismbbtrail (CRTDLL.148)
1512 */
1513int CDECL CRTDLL__ismbbtrail( unsigned int c )
1514{
1515 dprintf2(("CRTDLL: _ismbbtrail\n"));
1516 return ((_jctype+1)[(unsigned char)(c)] & _KNJ_2);
1517}
1518
1519
1520/*********************************************************************
1521 * _ismbcalpha (CRTDLL.149)
1522 */
1523int CDECL CRTDLL__ismbcalpha( unsigned int c )
1524{
1525 dprintf2(("CRTDLL: _ismbcalpha\n"));
1526 if ((c & 0xFF00) != 0) {
1527 // true multibyte character
1528 return 0;
1529 }
1530 else
1531 return CRTDLL__ismbbalpha(c);
1532
1533 return 0;
1534}
1535
1536
1537/*********************************************************************
1538 * _ismbcdigit (CRTDLL.150)
1539 */
1540int CDECL CRTDLL__ismbcdigit( unsigned int c )
1541{
1542 dprintf2(("CRTDLL: _ismbcdigit\n"));
1543 if ((c & 0xFF00) != 0) {
1544 // true multibyte character
1545 return 0;
1546 }
1547 else
1548 return 0;
1549// return _ismbbdigit(c);
1550
1551 return 0;
1552}
1553
1554
1555/*********************************************************************
1556 * _ismbchira (CRTDLL.151)
1557 */
1558int CDECL CRTDLL__ismbchira( unsigned int c )
1559{
1560 dprintf2(("CRTDLL: _ismbchira\n"));
1561 return ((c>=0x829F) && (c<=0x82F1));
1562}
1563
1564
1565/*********************************************************************
1566 * _ismbckata (CRTDLL.152)
1567 */
1568int CDECL CRTDLL__ismbckata( unsigned int c )
1569{
1570 dprintf2(("CRTDLL: _ismbckata\n"));
1571 return ((c>=0x8340) && (c<=0x8396));
1572}
1573
1574/*********************************************************************
1575 * _ismbcl0 (CRTDLL.153)
1576 */
1577int CDECL CRTDLL__ismbcl0( unsigned int ch )
1578{
1579 dprintf(("CRTDLL: _ismbcl0 not implemented.\n"));
1580 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1581 return 0;
1582}
1583
1584
1585/*********************************************************************
1586 * _ismbcl1 (CRTDLL.154)
1587 */
1588int CDECL CRTDLL__ismbcl1( unsigned int ch )
1589{
1590 dprintf(("CRTDLL: _ismbcl1 not implemented.\n"));
1591 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1592 return 0;
1593}
1594
1595
1596/*********************************************************************
1597 * _ismbcl2 (CRTDLL.155)
1598 */
1599int CDECL CRTDLL__ismbcl2( unsigned int ch )
1600{
1601 dprintf(("CRTDLL: _ismbcl2 not implemented.\n"));
1602 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1603 return 0;
1604}
1605
1606
1607/*********************************************************************
1608 * _ismbclegal (CRTDLL.156)
1609 */
1610int CDECL CRTDLL__ismbclegal( unsigned int c )
1611{
1612 dprintf2(("CRTDLL: _ismbclegal\n"));
1613 if ((c & 0xFF00) != 0) {
1614 return CRTDLL__ismbblead(c>>8) && CRTDLL__ismbbtrail(c&0xFF);
1615 }
1616 else
1617 return CRTDLL__ismbbtrail(c&0xFF);
1618
1619 return 0;
1620}
1621
1622
1623/*********************************************************************
1624 * _ismbclower (CRTDLL.157)
1625 */
1626int CDECL CRTDLL__ismbclower( unsigned int c )
1627{
1628 dprintf2(("CRTDLL: _ismbclower\n"));
1629 if ((c & 0xFF00) != 0) {
1630 if ( c >= 0x829A && c<= 0x829A )
1631 return 1;
1632 }
1633 else
1634 return isupper(c);
1635}
1636
1637
1638/*********************************************************************
1639 * _ismbcprint (CRTDLL.158)
1640 */
1641int CDECL CRTDLL__ismbcprint( unsigned int c )
1642{
1643 dprintf2(("CRTDLL: _ismbcprint\n"));
1644 if ((c & 0xFF00) != 0) {
1645 // true multibyte character
1646 return 0;
1647 }
1648 else
1649 return 0;
1650// return _ismbbdigit(c);
1651
1652 return 0;
1653}
1654
1655
1656/*********************************************************************
1657 * _ismbcspace (CRTDLL.159)
1658 */
1659int CDECL CRTDLL__ismbcspace( unsigned int c )
1660{
1661 dprintf(("CRTDLL: _ismbcspace not implemented.\n"));
1662 if ((c & 0xFF00) != 0) {
1663 // true multibyte character
1664 return 0;
1665 }
1666 else
1667 return 0;
1668// return _ismbbdigit(c);
1669
1670 return 0;
1671}
1672
1673
1674/*********************************************************************
1675 * _ismbcsymbol (CRTDLL.160)
1676 */
1677int CDECL CRTDLL__ismbcsymbol( unsigned int c )
1678{
1679 dprintf(("CRTDLL: _ismbcsymbol not implemented.\n"));
1680 if ((c & 0xFF00) != 0) {
1681 // true multibyte character
1682 return 0;
1683 }
1684 else
1685 return 0;
1686// return _ismbbdigit(c);
1687
1688 return 0;
1689}
1690
1691
1692/*********************************************************************
1693 * _ismbcupper (CRTDLL.161)
1694 */
1695int CDECL CRTDLL__ismbcupper( unsigned int c )
1696{
1697 dprintf2(("CRTDLL: _ismbcupper\n"));
1698 if ((c & 0xFF00) != 0) {
1699 if ( c >= 0x8260 && c<= 0x8279 )
1700 return 1;
1701 }
1702 else
1703 return isupper(c);
1704}
1705
1706
1707/*********************************************************************
1708 * _ismbslead (CRTDLL.162)
1709 */
1710int CDECL CRTDLL__ismbslead(const unsigned char *str, const unsigned char *t)
1711{
1712 dprintf2(("CRTDLL: _ismbslead\n"));
1713 unsigned char *s = (unsigned char *)str;
1714 while(*s != 0 && s != t)
1715 {
1716 s+= _mbclen2(*s);
1717 }
1718 return CRTDLL__ismbblead( *s);
1719}
1720
1721
1722/*********************************************************************
1723 * _ismbstrail (CRTDLL.163)
1724 */
1725int CDECL CRTDLL__ismbstrail(const unsigned char *str, const unsigned char *t)
1726{
1727 dprintf2(("CRTDLL: _ismbstrail\n"));
1728 unsigned char *s = (unsigned char *)str;
1729 while(*s != 0 && s != t)
1730 {
1731
1732 s+= _mbclen2(*s);
1733 }
1734
1735 return CRTDLL__ismbbtrail(*s);
1736}
1737
1738
1739/*********************************************************************
1740 * _isnan (CRTDLL.164)
1741 */
1742int CDECL CRTDLL__isnan( double __x )
1743{
1744 dprintf2(("CRTDLL: _isnan\n"));
1745 double_t * x = (double_t *)&__x;
1746 return ( x->exponent == 0x7ff && ( x->mantissah != 0 || x->mantissal != 0 ));
1747}
1748
1749
1750/*********************************************************************
1751 * _j0 (CRTDLL.166)
1752 */
1753double CDECL CRTDLL__j0(double x)
1754{
1755 dprintf2(("CRTDLL: _j0\n"));
1756 return (_j0(x));
1757}
1758
1759
1760/*********************************************************************
1761 * _j1 (CRTDLL.167)
1762 */
1763double CDECL CRTDLL__j1(double x)
1764{
1765 dprintf2(("CRTDLL: _j1\n"));
1766 return (_j1(x));}
1767
1768
1769/*********************************************************************
1770 * _jn (CRTDLL.168)
1771 */
1772double CDECL CRTDLL__jn(int i, double x)
1773{
1774 dprintf2(("CRTDLL: _jn\n"));
1775 return (_jn(i, x));
1776}
1777
1778
1779/*********************************************************************
1780 * _kbhit (CRTDLL.169)
1781 */
1782int CDECL CRTDLL__kbhit( void )
1783{
1784 dprintf2(("CRTDLL: _kbhit\n"));
1785 return (_kbhit());
1786}
1787
1788
1789/*********************************************************************
1790 * _lfind (CRTDLL.170)
1791 */
1792void * CDECL CRTDLL__lfind(const void *key, const void *base, size_t *nelp,
1793 size_t width, int (*compar)(const void *, const void *))
1794{
1795 dprintf2(("CRTDLL: _lfind\n"));
1796 char *char_base = (char *)base;
1797 int i;
1798 for(i=0;i<*nelp;i++) {
1799 if ( compar(key,char_base) == 0)
1800 return char_base;
1801 char_base += width;
1802 }
1803 return NULL;
1804}
1805
1806
1807/*********************************************************************
1808 * _loaddll (CRTDLL.171)
1809 */
1810void * CDECL CRTDLL__loaddll (char *name)
1811{
1812 dprintf2(("CRTDLL: _loaddll\n"));
1813 return (void*)LoadLibraryA(name);
1814}
1815
1816
1817/*******************************************************************
1818 * _local_unwind2 (CRTDLL.172)
1819 */
1820void CDECL CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr )
1821{
1822 dprintf2(("CRTDLL: local_undwind2\n"));
1823}
1824
1825
1826/*********************************************************************
1827 * _locking (CRTDLL.173)
1828 */
1829int CDECL CRTDLL__locking(int handle,int mode,unsigned long nbyte)
1830{
1831 dprintf(("CRTDLL: _locking not implemented.\n"));
1832 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1833 return FALSE;
1834}
1835
1836
1837/*********************************************************************
1838 * _logb (CRTDLL.174)
1839 */
1840double CDECL CRTDLL__logb( double x )
1841{
1842 dprintf(("CRTDLL: _logb not implemented.\n"));
1843 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1844 return FALSE;
1845}
1846
1847
1848/*********************************************************************
1849 * _lrotl (CRTDLL.175)
1850 */
1851unsigned long CDECL CRTDLL__lrotl( unsigned long value, unsigned int shift )
1852{
1853 dprintf2(("CRTDLL: _lrotl\n"));
1854 return (_lrotl(value, shift));
1855}
1856
1857
1858/*********************************************************************
1859 * _lrotr (CRTDLL.176)
1860 */
1861unsigned long CDECL CRTDLL__lrotr( unsigned long value, unsigned int shift )
1862{
1863 dprintf2(("CRTDLL: _lrotr\n"));
1864 return (_lrotr(value, shift));
1865}
1866
1867
1868/*********************************************************************
1869 * _lsearch (CRTDLL.177)
1870 */
1871void * CDECL CRTDLL__lsearch(const void *key, void *base, size_t *nelp, size_t width,
1872 int (*compar)(const void *, const void *))
1873{
1874 dprintf(("CRTDLL: _lsearch not implemented.\n"));
1875 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1876 return FALSE;
1877}
1878
1879
1880/*********************************************************************
1881 * _lseek (CRTDLL.178)
1882 */
1883long CDECL CRTDLL__lseek(int handle,long offset,int origin)
1884{
1885 dprintf2(("CRTDLL: _lssek\n"));
1886 return (_lseek(handle, offset, origin));
1887}
1888
1889
1890/*********************************************************************
1891 * _makepath (CRTDLL.180)
1892 */
1893void CDECL CRTDLL__makepath( char *path, char *drive,
1894 char *dir, char *fname, char *ext )
1895{
1896 dprintf2(("CRTDLL: _makepath\n"));
1897 _makepath(path, drive, dir, fname, ext);
1898}
1899
1900
1901/*********************************************************************
1902 * _matherr (CRTDLL.181)
1903 */
1904double CDECL CRTDLL__matherr( struct exception * excep )
1905{
1906 dprintf2(("CRTDLL: _matherr\n"));
1907 return (_matherr(excep));
1908}
1909
1910
1911/*********************************************************************
1912 * _mbbtombc (CRTDLL.182)
1913 */
1914unsigned int CDECL CRTDLL__mbbtombc( unsigned int c )
1915{
1916 dprintf2(("CRTDLL: _mbbtombc\n"));
1917 if (c >= 0x20 && c <= 0x7e) {
1918 return han_to_zen_ascii_table[c - 0x20];
1919 } else if (ISKANA(c)) {
1920 return han_to_zen_kana_table[c - 0xa0];
1921 }
1922 return c;
1923}
1924
1925
1926/*********************************************************************
1927 * _mbbtype (CRTDLL.183)
1928 */
1929int CDECL CRTDLL__mbbtype( unsigned char c, int type )
1930{
1931 dprintf2(("CRTDLL: _mbbtype\n"));
1932 if ( type == 1 ) {
1933 if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )
1934 {
1935 return _MBC_TRAIL;
1936 }
1937 else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
1938 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
1939 return _MBC_ILLEGAL;
1940 else
1941 return 0;
1942
1943 }
1944 else {
1945 if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
1946 return _MBC_SINGLE;
1947 }
1948 else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )
1949 return _MBC_LEAD;
1950 else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
1951 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
1952 return _MBC_ILLEGAL;
1953 else
1954 return 0;
1955
1956 }
1957
1958
1959 return 0;
1960}
1961
1962
1963/*********************************************************************
1964 * _mbccpy (CRTDLL.184)
1965 */
1966void CDECL CRTDLL__mbccpy( unsigned char *dst, const unsigned char *src )
1967{
1968 dprintf2(("CRTDLL: _mbccpy\n"));
1969
1970 if (!CRTDLL__ismbblead(*src) )
1971 return;
1972
1973 memcpy(dst,src,_mbclen2(*src));
1974}
1975
1976
1977/*********************************************************************
1978 * _mbcjistojms (CRTDLL.185)
1979 */
1980int CDECL CRTDLL__mbcjistojms( unsigned int c )
1981{
1982 dprintf2(("CRTDLL: _mbcjistojms\n"));
1983 int c1, c2;
1984
1985 c2 = (unsigned char)c;
1986 c1 = c >> 8;
1987 if (c1 >= 0x21 && c1 <= 0x7e && c2 >= 0x21 && c2 <= 0x7e) {
1988 if (c1 & 0x01) {
1989 c2 += 0x1f;
1990 if (c2 >= 0x7f)
1991 c2 ++;
1992 } else {
1993 c2 += 0x7e;
1994 }
1995 c1 += 0xe1;
1996 c1 >>= 1;
1997 if (c1 >= 0xa0)
1998 c1 += 0x40;
1999 return ((c1 << 8) | c2);
2000 }
2001 return 0;
2002}
2003
2004
2005/*********************************************************************
2006 * _mbcjmstojis (CRTDLL.186)
2007 */
2008int CDECL CRTDLL__mbcjmstojis( unsigned int c )
2009{
2010 dprintf2(("CRTDLL: _mbcjmstojis\n"));
2011 int c1, c2;
2012
2013 c2 = (unsigned char)c;
2014 c1 = c >> 8;
2015 if (c1 < 0xf0 && CRTDLL__ismbblead(c1) && CRTDLL__ismbbtrail(c2)) {
2016 if (c1 >= 0xe0)
2017 c1 -= 0x40;
2018 c1 -= 0x70;
2019 c1 <<= 1;
2020 if (c2 < 0x9f) {
2021 c1 --;
2022 c2 -= 0x1f;
2023 if (c2 >= (0x80-0x1f))
2024 c2 --;
2025 } else {
2026 c2 -= 0x7e;
2027 }
2028 return ((c1 << 8) | c2);
2029 }
2030 return 0;
2031}
2032
2033
2034/*********************************************************************
2035 * _mbclen (CRTDLL.187)
2036 */
2037size_t CDECL CRTDLL__mbclen( const unsigned char *s )
2038{
2039 dprintf2(("CRTDLL: _mbclen\n"));
2040 return (CRTDLL__ismbblead(*s>>8) && CRTDLL__ismbbtrail(*s&0x00FF)) ? 2 : 1;
2041}
2042
2043
2044/*********************************************************************
2045 * _mbctohira (CRTDLL.188)
2046 */
2047int CDECL CRTDLL__mbctohira( unsigned int c )
2048{
2049 dprintf2(("CRTDLL: _mbctohira\n"));
2050 return c;
2051}
2052
2053
2054/*********************************************************************
2055 * _mbctokata (CRTDLL.189)
2056 */
2057int CDECL CRTDLL__mbctokata( unsigned int c )
2058{
2059 dprintf2(("CRTDLL: _mbctokata\n"));
2060 return c;
2061}
2062
2063
2064/*********************************************************************
2065 * _mbctolower (CRTDLL.190)
2066 */
2067unsigned int CDECL CRTDLL__mbctolower( unsigned int c )
2068{
2069 dprintf2(("CRTDLL: _mbctolower\n"));
2070 if ((c & 0xFF00) != 0) {
2071// true multibyte case conversion needed
2072 if ( CRTDLL__ismbclower(c) )
2073 return c + CASE_DIFF;
2074
2075 } else
2076 return _mbbtolower(c);
2077
2078 return 0;
2079}
2080
2081
2082/*********************************************************************
2083 * _mbctombb (CRTDLL.191)
2084 */
2085unsigned int CDECL CRTDLL__mbctombb( unsigned int c )
2086{
2087 dprintf2(("CRTDLL: _mbctombb\n"));
2088 int i;
2089 unsigned short *p;
2090
2091 if (JISKANA(c)) {
2092 return zen_to_han_kana_table[c - 0x8340];
2093 } else if (JISHIRA(c)) {
2094 c = JTOKANA(c);
2095 return zen_to_han_kana_table[c - 0x8340];
2096 } else if (c <= 0x8396) {
2097 for (i = 0x20, p = han_to_zen_ascii_table; i <= 0x7e; i++, p++) {
2098 if (*p == c) {
2099 return i;
2100 }
2101 }
2102 for (i = 0; i < ZTOH_SYMBOLS; i++) {
2103 if (zen_to_han_symbol_table_1[i] == c) {
2104 return zen_to_han_symbol_table_2[i];
2105 }
2106 }
2107 }
2108 return c;
2109}
2110
2111
2112/*********************************************************************
2113 * _mbctoupper (CRTDLL.192)
2114 */
2115unsigned int CDECL CRTDLL__mbctoupper( unsigned int c )
2116{
2117 dprintf2(("CRTDLL: _mbctoupper\n"));
2118 if ((c & 0xFF00) != 0) {
2119// true multibyte case conversion needed
2120 if ( CRTDLL__ismbcupper(c) )
2121 return c + CASE_DIFF;
2122
2123 } else
2124 return _mbbtoupper(c);
2125
2126 return 0;
2127}
2128
2129
2130/*********************************************************************
2131 * _mbsbtype (CRTDLL.194)
2132 */
2133int CDECL CRTDLL__mbsbtype( const unsigned char *str, int n )
2134{
2135 dprintf2(("CRTDLL: _mbsbtype\n"));
2136 if ( str == NULL )
2137 return -1;
2138 return CRTDLL__mbbtype(*(str+n),1);
2139}
2140
2141
2142/*********************************************************************
2143 * _mbscat (CRTDLL.195)
2144 */
2145unsigned char * CDECL CRTDLL__mbscat( unsigned char *dst, const unsigned char *src )
2146{
2147 dprintf2(("CRTDLL: _mbscat\n"));
2148 return (unsigned char*)strcat((char*)dst,(char*)src);
2149}
2150
2151
2152/*********************************************************************
2153 * _mbschr (CRTDLL.196)
2154 */
2155unsigned char * CDECL CRTDLL__mbschr( const unsigned char *str, unsigned int c )
2156{
2157 dprintf2(("CRTDLL: _mbschr\n"));
2158 return (unsigned char*)strchr((char*)str,c);
2159}
2160
2161
2162/*********************************************************************
2163 * _mbscmp (CRTDLL.197)
2164 */
2165int CDECL CRTDLL__mbscmp( const unsigned char *s1, const unsigned char *s2 )
2166{
2167 dprintf2(("CRTDLL: _mbscmp\n"));
2168 return strcmp((char*)s1,(char*)s2);
2169}
2170
2171
2172/*********************************************************************
2173 * _mbscpy (CRTDLL.198)
2174 */
2175unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 )
2176{
2177 dprintf2(("CRTDLL: _mbscpy\n"));
2178 return (unsigned char*)strcpy((char*)s1,(char*)s2);
2179}
2180
2181
2182/*********************************************************************
2183 * _mbscspn (CRTDLL.199)
2184 */
2185size_t CDECL CRTDLL__mbscspn( const unsigned char *s1, const unsigned char *s2 )
2186{
2187 dprintf2(("CRTDLL: _mbscspn\n"));
2188 const char *p, *spanp;
2189 char c, sc;
2190
2191 for (p = (const char*)s1;;)
2192 {
2193 c = *p++;
2194 spanp = (const char*)s2;
2195 do {
2196 if ((sc = *spanp++) == c)
2197 return (size_t)(p - 1) - (size_t)s1;
2198 } while (sc != 0);
2199 }
2200 /* NOTREACHED */
2201}
2202
2203
2204/*********************************************************************
2205 * _mbsdec (CRTDLL.200)
2206 */
2207unsigned char * CDECL CRTDLL__mbsdec( const unsigned char *str, const unsigned char *cur )
2208{
2209 dprintf2(("CRTDLL: _mbsdec\n"));
2210 unsigned char *s = (unsigned char *)cur;
2211 if ( str >= cur )
2212 return NULL;
2213 s--;
2214 if (CRTDLL__ismbblead(*(s-1)) )
2215 s--;
2216
2217 return s;
2218}
2219
2220
2221/*********************************************************************
2222 * _mbsdup (CRTDLL.201)
2223 */
2224unsigned char * CDECL CRTDLL__mbsdup( unsigned char *_s )
2225{
2226 dprintf2(("CRTDLL: _mbsdup\n"));
2227 char *rv;
2228 if (_s == 0)
2229 return 0;
2230 rv = (char *)malloc(CRTDLL__mbslen((LPCSTR)_s) + 1);
2231 if (rv == 0)
2232 return 0;
2233 CRTDLL__mbscpy((unsigned char*)rv, _s);
2234 return (unsigned char*)rv;
2235}
2236
2237
2238/*********************************************************************
2239 * CRTDLL__mbsicmp (CRTDLL.202)
2240 */
2241int CDECL CRTDLL__mbsicmp( const unsigned char *x, const unsigned char *y )
2242{
2243 dprintf2(("CRTDLL: _mbsicmp\n"));
2244 do {
2245 if (!*x)
2246 return !!*y;
2247 if (!*y)
2248 return !!*x;
2249 /* FIXME: MBCS handling... */
2250 if (*x!=*y)
2251 return 1;
2252 x++;
2253 y++;
2254 } while (1);
2255}
2256
2257
2258/*********************************************************************
2259 * CRTDLL__mbsinc (CRTDLL.203)
2260 */
2261LPSTR CDECL CRTDLL__mbsinc( LPCSTR str )
2262{
2263 dprintf2(("CRTDLL: _mbsinc\n"));
2264 int len = mblen( str, MB_LEN_MAX );
2265 if (len < 1) len = 1;
2266 return (LPSTR)(str + len);
2267}
2268
2269
2270/*********************************************************************
2271 * CRTDLL__mbslen (CRTDLL.204)
2272 */
2273INT CDECL CRTDLL__mbslen( LPCSTR str )
2274{
2275 dprintf2(("CRTDLL: _mbslen\n"));
2276 INT len, total = 0;
2277 while ((len = mblen( str, MB_LEN_MAX )) > 0)
2278 {
2279 str += len;
2280 total++;
2281 }
2282 return total;
2283}
2284
2285
2286/*********************************************************************
2287 * _mbslwr (CRTDLL.205)
2288 */
2289unsigned char * CDECL CRTDLL__mbslwr( unsigned char *x )
2290{
2291 dprintf2(("CRTDLL: _mbslwr\n"));
2292 unsigned char *y=x;
2293
2294 while (*y) {
2295 if (!CRTDLL__ismbblead(*y) )
2296 *y = tolower(*y);
2297 else {
2298 *y=CRTDLL__mbctolower(*(unsigned short *)y);
2299 y++;
2300 }
2301 }
2302 return x;
2303}
2304
2305
2306/*********************************************************************
2307 * _mbsnbcat (CRTDLL.206)
2308 */
2309unsigned char * CDECL CRTDLL__mbsnbcat( unsigned char *dst, const unsigned char *src, size_t n )
2310{
2311 dprintf2(("CRTDLL: _mbsnbcat\n"));
2312 char *d;
2313 char *s = (char *)src;
2314 if (n != 0) {
2315 d = (char*)dst + strlen((char*)dst); // get the end of string
2316 d += _mbclen2(*d); // move 1 or 2 up
2317
2318 do {
2319 if ((*d++ = *s++) == 0)
2320 {
2321 while (--n != 0)
2322 *d++ = 0;
2323 break;
2324 }
2325 if ( !(n==1 && CRTDLL__ismbblead(*s)) )
2326 n--;
2327 } while (n > 0);
2328 }
2329 return dst;
2330}
2331
2332
2333/*********************************************************************
2334 * _mbsnbcmp (CRTDLL.207)
2335 */
2336int CDECL CRTDLL__mbsnbcmp( const unsigned char *str1, const unsigned char *str2, size_t n )
2337{
2338 dprintf2(("CRTDLL: _mbsnbcmp\n"));
2339 unsigned char *s1 = (unsigned char *)str1;
2340 unsigned char *s2 = (unsigned char *)str2;
2341
2342 unsigned short *short_s1, *short_s2;
2343
2344 int l1, l2;
2345
2346 if (n == 0)
2347 return 0;
2348 do {
2349
2350 if (*s1 == 0)
2351 break;
2352
2353 l1 = CRTDLL__ismbblead(*s1);
2354 l2 = CRTDLL__ismbblead(*s2);
2355 if ( !l1 && !l2 ) {
2356
2357 if (*s1 != *s2)
2358 return *s1 - *s2;
2359 else {
2360 s1 += 1;
2361 s2 += 1;
2362 n--;
2363 }
2364 }
2365 else if ( l1 && l2 ){
2366 short_s1 = (unsigned short *)s1;
2367 short_s2 = (unsigned short *)s2;
2368 if ( *short_s1 != *short_s2 )
2369 return *short_s1 - *short_s2;
2370 else {
2371 s1 += 2;
2372 s2 += 2;
2373 n-=2;
2374
2375 }
2376 }
2377 else
2378 return *s1 - *s2;
2379 } while (n > 0);
2380 return 0;
2381}
2382
2383
2384/*********************************************************************
2385 * _mbsnbcnt (CRTDLL.208)
2386 */
2387size_t CDECL CRTDLL__mbsnbcnt( const unsigned char *str, size_t n )
2388{
2389 dprintf2(("CRTDLL: _mbsnbcnt\n"));
2390 unsigned char *s = (unsigned char *)str;
2391 while(*s != 0 && n > 0) {
2392 if (!CRTDLL__ismbblead(*s) )
2393 n--;
2394 s++;
2395 }
2396
2397 return (size_t)(s - str);
2398}
2399
2400
2401/*********************************************************************
2402 * _mbsnbcpy (CRTDLL.209)
2403 */
2404unsigned char * CDECL CRTDLL__mbsnbcpy( unsigned char *str1, const unsigned char *str2, size_t n )
2405{
2406 dprintf2(("CRTDLL: _mbsnbcpy\n"));
2407 unsigned char *s1 = (unsigned char *)str1;
2408 unsigned char *s2 = (unsigned char *)str2;
2409
2410 unsigned short *short_s1, *short_s2;
2411
2412 if (n == 0)
2413 return 0;
2414 do {
2415
2416 if (*s2 == 0)
2417 break;
2418
2419 if ( !CRTDLL__ismbblead(*s2) ) {
2420
2421 *s1 = *s2;
2422 s1 += 1;
2423 s2 += 1;
2424 n--;
2425 }
2426 else {
2427 short_s1 = (unsigned short *)s1;
2428 short_s2 = (unsigned short *)s2;
2429 *short_s1 = *short_s2;
2430 s1 += 2;
2431 s2 += 2;
2432 n-=2;
2433 }
2434 } while (n > 0);
2435 return str1;
2436}
2437
2438
2439/*********************************************************************
2440 * _mbsnbicmp (CRTDLL.210)
2441 */
2442int CDECL CRTDLL__mbsnbicmp( const unsigned char *s1, const unsigned char *s2, size_t n )
2443{
2444 dprintf2(("CRTDLL: _mbsnbicmp\n"));
2445 if (n == 0)
2446 return 0;
2447 do {
2448 if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
2449 return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
2450 s1 += _mbclen2(*s1);
2451 s2 += _mbclen2(*s2);
2452
2453
2454 if (*s1 == 0)
2455 break;
2456 n--;
2457 } while (n > 0);
2458 return 0;
2459}
2460
2461
2462/*********************************************************************
2463 * _mbsnbset (CRTDLL.211)
2464 */
2465unsigned char * CDECL CRTDLL__mbsnbset( unsigned char *src, unsigned int val, size_t count )
2466{
2467 dprintf2(("CRTDLL: _mbsnbset\n"));
2468 unsigned char *char_src = (unsigned char *)src;
2469 unsigned short *short_src = (unsigned short *)src;
2470
2471 if ( _mbclen2(val) == 1 ) {
2472
2473 while(count > 0) {
2474 *char_src = val;
2475 char_src++;
2476 count--;
2477 }
2478 *char_src = 0;
2479 }
2480 else {
2481 while(count > 0) {
2482 *short_src = val;
2483 short_src++;
2484 count-=2;
2485 }
2486 *short_src = 0;
2487 }
2488
2489 return src;
2490}
2491
2492
2493/*********************************************************************
2494 * _mbsncat (CRTDLL.212)
2495 */
2496unsigned char * CDECL CRTDLL__mbsncat( unsigned char *dst, const unsigned char *src, size_t n )
2497{
2498 dprintf2(("CRTDLL: _mbsncat\n"));
2499 char *d = (char *)dst;
2500 char *s = (char *)src;
2501 if (n != 0) {
2502 d = (char*)dst + strlen((char*)dst); // get the end of string
2503 d += _mbclen2(*d); // move 1 or 2 up
2504
2505 do {
2506 if ((*d++ = *s++) == 0)
2507 {
2508 while (--n != 0)
2509 *d++ = 0;
2510 break;
2511 }
2512 if (!CRTDLL__ismbblead(*s) )
2513 n--;
2514 } while (n > 0);
2515 }
2516 return dst;
2517}
2518
2519
2520/*********************************************************************
2521 * _mbsnccnt (CRTDLL.213)
2522 */
2523size_t CDECL CRTDLL__mbsnccnt( const unsigned char *str, size_t n )
2524{
2525 dprintf2(("CRTDLL: _mbsnccnt\n"));
2526 unsigned char *s = (unsigned char *)str;
2527 size_t cnt = 0;
2528 while(*s != 0 && n > 0) {
2529 if (CRTDLL__ismbblead(*s) )
2530 s++;
2531 else
2532 n--;
2533 s++;
2534 cnt++;
2535 }
2536
2537 return cnt;
2538}
2539
2540
2541/*********************************************************************
2542 * _mbsncmp (CRTDLL.214)
2543 */
2544int CDECL CRTDLL__mbsncmp( const unsigned char *str1, const unsigned char *str2, size_t n )
2545{
2546 dprintf2(("CRTDLL: _mbsncmp\n"));
2547 unsigned char *s1 = (unsigned char *)str1;
2548 unsigned char *s2 = (unsigned char *)str2;
2549
2550 unsigned short *short_s1, *short_s2;
2551
2552 int l1, l2;
2553
2554 if (n == 0)
2555 return 0;
2556 do {
2557
2558 if (*s1 == 0)
2559 break;
2560
2561 l1 = CRTDLL__ismbblead(*s1);
2562 l2 = CRTDLL__ismbblead(*s2);
2563 if ( !l1 && !l2 ) {
2564
2565 if (*s1 != *s2)
2566 return *s1 - *s2;
2567 else {
2568 s1 += 1;
2569 s2 += 1;
2570 n--;
2571 }
2572 }
2573 else if ( l1 && l2 ){
2574 short_s1 = (unsigned short *)s1;
2575 short_s2 = (unsigned short *)s2;
2576 if ( *short_s1 != *short_s2 )
2577 return *short_s1 - *short_s2;
2578 else {
2579 s1 += 2;
2580 s2 += 2;
2581 n--;
2582
2583 }
2584 }
2585 else
2586 return *s1 - *s2;
2587 } while (n > 0);
2588 return 0;
2589}
2590
2591
2592/*********************************************************************
2593 * _mbsncpy (CRTDLL.215)
2594 */
2595unsigned char * CDECL CRTDLL__mbsncpy( unsigned char *str1, const unsigned char *str2, size_t n )
2596{
2597 dprintf2(("CRTDLL: _mbsncpy\n"));
2598 unsigned char *s1 = (unsigned char *)str1;
2599 unsigned char *s2 = (unsigned char *)str2;
2600
2601 unsigned short *short_s1, *short_s2;
2602
2603 if (n == 0)
2604 return 0;
2605 do {
2606
2607 if (*s2 == 0)
2608 break;
2609
2610 if ( !CRTDLL__ismbblead(*s2) ) {
2611
2612 *s1 = *s2;
2613 s1 += 1;
2614 s2 += 1;
2615 n--;
2616 }
2617 else {
2618 short_s1 = (unsigned short *)s1;
2619 short_s2 = (unsigned short *)s2;
2620 *short_s1 = *short_s2;
2621 s1 += 2;
2622 s2 += 2;
2623 n--;
2624 }
2625 } while (n > 0);
2626 return str1;
2627}
2628
2629
2630/*********************************************************************
2631 * _mbsnextc (CRTDLL.216)
2632 */
2633unsigned int CDECL CRTDLL__mbsnextc( const unsigned char *src )
2634{
2635 dprintf2(("CRTDLL: _mbsnextc\n"));
2636 unsigned char *char_src = (unsigned char *)src;
2637 unsigned short *short_src = (unsigned short *)src;
2638
2639 if ( src == NULL )
2640 return 0;
2641
2642 if ( !CRTDLL__ismbblead(*src) )
2643 return *char_src;
2644 else
2645 return *short_src;
2646 return 0;
2647
2648}
2649
2650
2651/*********************************************************************
2652 * _mbsnicmp (CRTDLL.217)
2653 */
2654int CDECL CRTDLL__mbsnicmp( const unsigned char *s1, const unsigned char *s2, size_t n )
2655{
2656 dprintf2(("CRTDLL: _mbsnicmp\n"));
2657 if (n == 0)
2658 return 0;
2659 do {
2660 if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
2661 return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
2662
2663// Next 2 lines won't compile
2664// *s1 += _mbclen2(*s1);
2665// *s2 += _mbclen2(*s2);
2666
2667
2668 if (*s1 == 0)
2669 break;
2670 if (!CRTDLL__ismbblead(*s1) )
2671 n--;
2672 } while (n > 0);
2673 return 0;
2674}
2675
2676
2677/*********************************************************************
2678 * _mbsninc (CRTDLL.218)
2679 */
2680unsigned char * CDECL CRTDLL__mbsninc( const unsigned char *str, size_t n )
2681{
2682 dprintf2(("CRTDLL: _mbsninc\n"));
2683 unsigned char *s = (unsigned char *)str;
2684 while(*s != 0 && n > 0) {
2685 if (!CRTDLL__ismbblead(*s) )
2686 n--;
2687 s++;
2688 }
2689
2690 return s;
2691}
2692
2693
2694/*********************************************************************
2695 * _mbsnset (CRTDLL.219)
2696 */
2697unsigned char * CDECL CRTDLL__mbsnset( unsigned char *src, unsigned int val, size_t count )
2698{
2699 dprintf2(("CRTDLL: _mbsnset\n"));
2700 unsigned char *char_src = (unsigned char *)src;
2701 unsigned short *short_src = (unsigned short *)src;
2702
2703 if ( _mbclen2(val) == 1 ) {
2704
2705 while(count > 0) {
2706 *char_src = val;
2707 char_src++;
2708 count--;
2709 }
2710 *char_src = 0;
2711 }
2712 else {
2713 while(count > 0) {
2714 *short_src = val;
2715 short_src++;
2716 count-=2;
2717 }
2718 *short_src = 0;
2719 }
2720
2721 return src;
2722
2723}
2724
2725
2726/*********************************************************************
2727 * _mbspbrk (CRTDLL.220)
2728 */
2729unsigned char * CDECL CRTDLL__mbspbrk( const unsigned char *s1, const unsigned char *s2 )
2730{
2731 dprintf2(("CRTDLL: _mbspbrk\n"));
2732 const char *scanp;
2733 int c, sc;
2734
2735 while ((c = *s1++) != 0)
2736 {
2737 for (scanp = (char*)s2; (sc = *scanp++) != 0;)
2738 if (sc == c)
2739 return (unsigned char *)((char *)s1 - (char *)1);
2740 }
2741 return 0;
2742}
2743
2744
2745/*********************************************************************
2746 * CRTDLL__mbsrchr (CRTDLL.221)
2747 */
2748LPSTR CDECL CRTDLL__mbsrchr(LPSTR s,CHAR x)
2749{
2750 dprintf2(("CRTDLL: _mbsrchr\n"));
2751 /* FIXME: handle multibyte strings */
2752 return strrchr(s,x);
2753}
2754
2755
2756/*********************************************************************
2757 * _mbsrev (CRTDLL.222)
2758 */
2759unsigned char * CDECL CRTDLL__mbsrev( unsigned char *s )
2760{
2761 dprintf2(("CRTDLL: _mbsrev\n"));
2762 unsigned char *e;
2763 unsigned char a;
2764 e=s;
2765 while (*e) {
2766 if ( CRTDLL__ismbblead(*e) ) {
2767 a = *e;
2768 *e = *++e;
2769 if ( *e == 0 )
2770 break;
2771 *e = a;
2772 }
2773 e++;
2774 }
2775 while (s<e) {
2776 a=*s;
2777 *s=*e;
2778 *e=a;
2779 s++;
2780 e--;
2781 }
2782
2783
2784 return s;
2785}
2786
2787
2788/*********************************************************************
2789 * _mbsset (CRTDLL.223)
2790 */
2791unsigned char * CDECL CRTDLL__mbsset( unsigned char *src, unsigned int c )
2792{
2793 dprintf2(("CRTDLL: _mbsset\n"));
2794 unsigned char *char_src = src;
2795 unsigned short *short_src = (unsigned short*)src;
2796
2797 if ( _mbclen2(c) == 1 ) {
2798
2799 while(*char_src != 0) {
2800 *char_src = c;
2801 char_src++;
2802 }
2803 *char_src = 0;
2804 }
2805 else {
2806 while(*short_src != 0) {
2807 *short_src = c;
2808 short_src++;
2809 }
2810 *short_src = 0;
2811 }
2812
2813 return src;
2814}
2815
2816
2817/*********************************************************************
2818 * _mbsspn (CRTDLL.224)
2819 */
2820size_t CDECL CRTDLL__mbsspn( const unsigned char *s1, const unsigned char *s2 )
2821{
2822 dprintf2(("CRTDLL: _mbsspn\n"));
2823 const char *p = (char*)s1, *spanp;
2824 char c, sc;
2825
2826 cont:
2827 c = *p++;
2828 for (spanp = (char*)s2; (sc = *spanp++) != 0;)
2829 if (sc == c)
2830 goto cont;
2831 return (size_t)(p - 1) - (size_t)s1;
2832}
2833
2834
2835/*********************************************************************
2836 * _mbsspnp (CRTDLL.225)
2837 */
2838unsigned char * CDECL CRTDLL__mbsspnp( const unsigned char *s1, const unsigned char *s2 )
2839{
2840 dprintf2(("CRTDLL: _mbsspnp\n"));
2841 const char *p = (char*)s1, *spanp;
2842 char c, sc;
2843
2844 cont:
2845 c = *p++;
2846 for (spanp = (char*)s2; (sc = *spanp++) != 0;)
2847 if (sc == c)
2848 goto cont;
2849 return (unsigned char*)p;
2850}
2851
2852
2853/*********************************************************************
2854 * _mbsstr (CRTDLL.226)
2855 */
2856unsigned char * CDECL CRTDLL__mbsstr( const unsigned char *s1, const unsigned char *s2 )
2857{
2858 dprintf2(("CRTDLL: _mbsstr\n"));
2859 return (unsigned char*)strstr((const char*)s1,(const char*)s2);
2860}
2861
2862
2863/*********************************************************************
2864 * _mbstok (CRTDLL.227)
2865 */
2866unsigned char * CDECL CRTDLL__mbstok( unsigned char *s, const unsigned char *delim )
2867{
2868 dprintf2(("CRTDLL: _mbstok\n"));
2869 const char *spanp;
2870 int c, sc;
2871 char *tok;
2872 static char *last;
2873
2874
2875 if (s == NULL && (s = (unsigned char*)last) == NULL)
2876 return (NULL);
2877
2878 /*
2879 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
2880 */
2881 cont:
2882 c = *s;
2883 s = (unsigned char*)CRTDLL__mbsinc((LPCSTR)s);
2884
2885 for (spanp = (const char*)delim; (sc = *spanp) != 0; spanp = CRTDLL__mbsinc(spanp)) {
2886 if (c == sc)
2887 goto cont;
2888 }
2889
2890 if (c == 0) { /* no non-delimiter characters */
2891 last = NULL;
2892 return (NULL);
2893 }
2894 tok = (char*)s - 1;
2895
2896 /*
2897 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
2898 * Note that delim must have one NUL; we stop if we see that, too.
2899 */
2900 for (;;) {
2901 c = *s;
2902 s = (unsigned char*)CRTDLL__mbsinc((LPCSTR)s);
2903 spanp = (const char*)delim;
2904 do {
2905 if ((sc = *spanp) == c) {
2906 if (c == 0)
2907 s = NULL;
2908 else
2909 s[-1] = 0;
2910 last = (char*)s;
2911 return ((unsigned char*)tok);
2912 }
2913 spanp = CRTDLL__mbsinc(spanp);
2914 } while (sc != 0);
2915 }
2916 /* NOTREACHED */
2917}
2918
2919
2920/*********************************************************************
2921 * _mbstrlen (CRTDLL.228)
2922 */
2923size_t CDECL CRTDLL__mbstrlen(const char *string)
2924{
2925 dprintf2(("CRTDLL: _mbstrlen\n"));
2926 char *s = (char *)string;
2927 size_t i;
2928 while ( *s != 0 ) {
2929 if ( CRTDLL__ismbblead(*s) )
2930 s++;
2931 s++;
2932 i++;
2933 }
2934 return i;
2935}
2936
2937
2938/*********************************************************************
2939 * _mbsupr (CRTDLL.229)
2940 */
2941unsigned char * CDECL CRTDLL__mbsupr( unsigned char *x )
2942{
2943 dprintf2(("CRTDLL: _mbsupr\n"));
2944 unsigned char *y=x;
2945 while (*y) {
2946 if (!CRTDLL__ismbblead(*y) )
2947 *y = toupper(*y);
2948 else {
2949 *y=CRTDLL__mbctoupper(*(unsigned short *)y);
2950 y++;
2951 }
2952 }
2953 return x;
2954}
2955
2956
2957/*********************************************************************
2958 * CRTDLL__memccpy (CRTDLL.230)
2959 */
2960void * CDECL CRTDLL__memccpy(void *to, const void *from,int c,size_t count)
2961{
2962 dprintf2(("CRTDLL: _memccpy\n"));
2963 memcpy(to,from,count);
2964 return memchr(to,c,count);
2965}
2966
2967
2968/*********************************************************************
2969 * _mkdir (CRTDLL.232)
2970 */
2971INT CDECL CRTDLL__mkdir(LPCSTR newdir)
2972{
2973 dprintf2(("CRTDLL: mkdir\n"));
2974 if (!CreateDirectoryA(newdir,NULL))
2975 return -1;
2976 return 0;
2977}
2978
2979
2980/*********************************************************************
2981 * _mktemp (CRTDLL.233)
2982 */
2983char * CDECL CRTDLL__mktemp( char * _template )
2984{
2985 dprintf2(("CRTDLL: _mktemp\n"));
2986 static int count = 0;
2987 char *cp, *dp;
2988 int i, len, xcount, loopcnt;
2989
2990
2991
2992 len = strlen (_template);
2993 cp = _template + len;
2994
2995 xcount = 0;
2996 while (xcount < 6 && cp > _template && cp[-1] == 'X')
2997 xcount++, cp--;
2998
2999 if (xcount) {
3000 dp = cp;
3001 while (dp > _template && dp[-1] != '/' && dp[-1] != '\\' && dp[-1] != ':')
3002 dp--;
3003
3004 /* Keep the first characters of the template, but turn the rest into
3005 Xs. */
3006 while (cp > dp + 8 - xcount) {
3007 *--cp = 'X';
3008 xcount = (xcount >= 6) ? 6 : 1 + xcount;
3009 }
3010
3011 /* If dots occur too early -- squash them. */
3012 while (dp < cp) {
3013 if (*dp == '.') *dp = 'a';
3014 dp++;
3015 }
3016
3017 /* Try to add ".tmp" to the filename. Truncate unused Xs. */
3018 if (cp + xcount + 3 < _template + len)
3019 strcpy (cp + xcount, ".tmp");
3020 else
3021 cp[xcount] = 0;
3022
3023 for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {
3024 int c = count++;
3025 for (i = 0; i < xcount; i++, c >>= 5)
3026 cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];
3027 if (CRTDLL__access(_template,0) == -1)
3028 return _template;
3029 }
3030 }
3031 /* Failure: truncate the template and return NULL. */
3032 *_template = 0;
3033 return 0;
3034}
3035
3036
3037/*********************************************************************
3038 * _msize (CRTDLL.234)
3039 */
3040size_t CDECL CRTDLL__msize( void *ptr )
3041{
3042 dprintf2(("CRTDLL: _msize\n"));
3043 return (_msize(ptr));
3044}
3045
3046
3047/*********************************************************************
3048 * _nextafter (CRTDLL.235)
3049 */
3050double CDECL CRTDLL__nextafter( double x, double y )
3051{
3052 dprintf2(("CRTDLL: _nextafter\n"));
3053 if ( x == y)
3054 return x;
3055 if ( CRTDLL__isnan(x) || CRTDLL__isnan(y) )
3056 return x;
3057
3058 return x;
3059}
3060
3061
3062/*********************************************************************
3063 * _onexit (CRTDLL.236)
3064 */
3065onexit_t CDECL CRTDLL__onexit(onexit_t t)
3066{
3067 dprintf2(("CRTDLL: _onexit\n"));
3068 return (_onexit(t));
3069}
3070
3071
3072/*********************************************************************
3073 * _open (CRTDLL.237)
3074 */
3075HFILE CDECL CRTDLL__open(LPCSTR path,INT flags)
3076{
3077 dprintf2(("CRTDLL: _open\n"));
3078 DWORD access = 0, creation = 0;
3079 HFILE ret;
3080
3081 switch(flags & 3)
3082 {
3083 case O_RDONLY: access |= GENERIC_READ; break;
3084 case O_WRONLY: access |= GENERIC_WRITE; break;
3085 case O_RDWR: access |= GENERIC_WRITE | GENERIC_READ; break;
3086 }
3087
3088 if (flags & 0x0100) /* O_CREAT */
3089 {
3090 if (flags & 0x0400) /* O_EXCL */
3091 creation = CREATE_NEW;
3092 else if (flags & 0x0200) /* O_TRUNC */
3093 creation = CREATE_ALWAYS;
3094 else
3095 creation = OPEN_ALWAYS;
3096 }
3097 else /* no O_CREAT */
3098 {
3099 if (flags & 0x0200) /* O_TRUNC */
3100 creation = TRUNCATE_EXISTING;
3101 else
3102 creation = OPEN_EXISTING;
3103 }
3104 if (flags & 0x0008) /* O_APPEND */
3105 dprintf2(("O_APPEND not supported\n" ));
3106 if (flags & 0xf0f4)
3107 dprintf2(("CRTDLL_open file unsupported flags 0x%04x\n",flags));
3108 /* End Fixme */
3109
3110 ret = CreateFileA( path, access, FILE_SHARE_READ | FILE_SHARE_WRITE,
3111 NULL, creation, FILE_ATTRIBUTE_NORMAL, -1 );
3112 dprintf2(("CRTDLL_open file %s mode 0x%04x got handle %d\n", path,flags,ret));
3113 return ret;
3114}
3115
3116
3117/*********************************************************************
3118 * _open_osfhandle (CRTDLL.238)
3119 */
3120INT CDECL CRTDLL__open_osfhandle( long osfhandle, int flags )
3121{
3122 dprintf2(("CRTDLL: _open_osfhandle\n"));
3123HFILE handle;
3124
3125 switch (osfhandle) {
3126 case STD_INPUT_HANDLE :
3127 case 0 :
3128 handle=0;
3129 break;
3130 case STD_OUTPUT_HANDLE:
3131 case 1:
3132 handle=1;
3133 break;
3134 case STD_ERROR_HANDLE:
3135 case 2:
3136 handle=2;
3137 break;
3138 default:
3139 return (-1);
3140 }
3141 dprintf2(("(handle %08lx,flags %d) return %d\n",
3142 osfhandle,flags,handle));
3143 return handle;
3144}
3145
3146
3147/*********************************************************************
3148 * _pclose (CRTDLL.244)
3149 */
3150INT CDECL CRTDLL__pclose( FILE *fp )
3151{
3152 dprintf(("CRTDLL: _pclose not implemented.\n"));
3153 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3154 return FALSE;
3155}
3156
3157
3158/*********************************************************************
3159 * _pipe (CRTDLL.247)
3160 */
3161INT CDECL CRTDLL__pipe( int *phandles, unsigned psize, int textmode )
3162{
3163 dprintf(("CRTDLL: _pipe not implemented.\n"));
3164 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3165 return FALSE;
3166}
3167
3168
3169/*********************************************************************
3170 * _popen (CRTDLL.248)
3171 */
3172FILE * CDECL CRTDLL__popen( const char *command, const char *mode )
3173{
3174 dprintf(("CRTDLL: _popen not implemented.\n"));
3175 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3176 return FALSE;
3177}
3178
3179
3180/*********************************************************************
3181 * _purecall (CRTDLL.249)
3182 */
3183void CDECL CRTDLL__purecall(void)
3184{
3185 dprintf2(("CRTDLL: _purecall\n"));
3186}
3187
3188
3189/*********************************************************************
3190 * _putch (CRTDLL.250)
3191 */
3192INT CDECL CRTDLL__putch( int i )
3193{
3194 dprintf2(("CRTDLL: _putch\n"));
3195 return (_putch(i));
3196}
3197
3198
3199/*********************************************************************
3200 * _putenv (CRTDLL.251)
3201 */
3202INT CDECL CRTDLL__putenv(const char *s)
3203{
3204 dprintf2(("CRTDLL: _putenv\n"));
3205 return (_putenv(s));
3206}
3207
3208
3209/*********************************************************************
3210 * _putw (CRTDLL.252)
3211 */
3212INT CDECL CRTDLL__putw( int w, FILE *stream )
3213{
3214 dprintf2(("CRTDLL: _putw\n"));
3215 if (fwrite( &w, sizeof(w), 1, stream) < 1)
3216 return(EOF);
3217 return(0);
3218}
3219
3220
3221/*********************************************************************
3222 * _read (CRTDLL.254)
3223 */
3224INT CDECL CRTDLL__read(INT fd, LPVOID buf, UINT count)
3225{
3226 dprintf(("CRTDLL: _read not implemented.\n"));
3227 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3228 return FALSE;
3229}
3230
3231
3232/*********************************************************************
3233 * _rmdir (CRTDLL.255)
3234 */
3235INT CDECL CRTDLL__rmdir(const char *path)
3236{
3237 dprintf2(("CRTDLL: _rmdir\n"));
3238 if (!RemoveDirectoryA(path))
3239 return -1;
3240 return 0;
3241}
3242
3243
3244/*********************************************************************
3245 * _rmtmp (CRTDLL.256)
3246 */
3247INT CDECL CRTDLL__rmtmp(void)
3248{
3249 dprintf2(("CRTDLL: _rmtmp\n"));
3250 return(_rmtmp());
3251}
3252
3253
3254/*********************************************************************
3255 * CRTDLL__rotl (CRTDLL.257)
3256 */
3257unsigned int CDECL CRTDLL__rotl( unsigned int value, unsigned int shift )
3258{
3259 dprintf2(("CRTDLL: _rotl\n"));
3260 return (_rotl(value, shift));
3261}
3262
3263
3264/*********************************************************************
3265 * CRTDLL__rotr (CRTDLL.258)
3266 */
3267unsigned int CDECL CRTDLL__rotr( unsigned int value, unsigned int shift )
3268{
3269 dprintf2(("CRTDLL: _rotr\n"));
3270 return (_rotr(value, shift));
3271}
3272
3273
3274/*********************************************************************
3275 * _scalb (CRTDLL.259)
3276 */
3277double CDECL CRTDLL__scalb( double __x, long e )
3278{
3279 dprintf2(("CRTDLL: _scalb\n"));
3280 double_t *x = (double_t *)&__x;
3281
3282 x->exponent += e;
3283
3284 return __x;
3285}
3286
3287
3288/*********************************************************************
3289 * CRTDLL__searchenv (CRTDLL.260)
3290 */
3291void CDECL CRTDLL__searchenv(const char *file,const char *var,char *path )
3292{
3293 dprintf2(("CRTDLL: _searchenv\n"));
3294 char *env = CRTDLL_getenv(var);
3295
3296 char *x;
3297 char *y;
3298 char *FilePart;
3299 x = strchr(env,'=');
3300 if ( x != NULL ) {
3301 *x = 0;
3302 x++;
3303 }
3304 y = strchr(env,';');
3305 while ( y != NULL ) {
3306 *y = 0;
3307 if ( SearchPathA(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
3308 return;
3309 }
3310 x = y+1;
3311 y = strchr(env,';');
3312 }
3313 return;
3314}
3315
3316
3317/*********************************************************************
3318 * CRTDLL__seterrormode (CRTDLL.261)
3319 */
3320void CDECL CRTDLL__seterrormode(int i)
3321{
3322 dprintf2(("CRTDLL: _seterrormode\n"));
3323 SetErrorMode(i);
3324 return;
3325}
3326
3327
3328/*********************************************************************
3329 * CRTDLL__setjmp (CRTDLL.262)
3330 */
3331int CDECL CRTDLL__setjmp( jmp_buf env )
3332{
3333 //TODO:
3334 dprintf2(("CRTDLL: _setjmp -> setjmp (NOT IDENTICAL!!!)\n"));
3335 return(setjmp( env));
3336}
3337
3338/*********************************************************************
3339 * CRTDLL__setjmp3 (CRTDLL.262)
3340 */
3341int CDECL CRTDLL__setjmp3( jmp_buf env )
3342{
3343 //TODO:
3344 dprintf2(("CRTDLL: _setjmp3 -> setjmp (NOT IDENTICAL!!!)\n"));
3345 return(setjmp( env));
3346}
3347
3348
3349/*********************************************************************
3350 * _setmode (CRTDLL.263)
3351 */
3352INT CDECL CRTDLL__setmode( INT fh,INT mode)
3353{
3354 dprintf2(("CRTDLL: _setmode\n"));
3355 return (_setmode(fh, mode));
3356}
3357
3358
3359/*********************************************************************
3360 * _setsystime (CRTDLL.264)
3361 */
3362unsigned int CDECL CRTDLL__setsystime(struct tm *tp, unsigned int ms)
3363{
3364 dprintf(("CRTDLL: _setsystime not implemented.\n"));
3365 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3366 return FALSE;
3367}
3368
3369
3370/*********************************************************************
3371 * _sleep (CRTDLL.265)
3372 */
3373VOID CDECL CRTDLL__sleep(unsigned long timeout)
3374{
3375 dprintf2(("CRTDLL__sleep for %ld milliseconds\n",timeout));
3376 Sleep((timeout)?timeout:1);
3377}
3378
3379
3380/*********************************************************************
3381 * _sopen (CRTDLL.268)
3382 */
3383int CDECL CRTDLL__sopen( const char *s, int i1, int i2, ... )
3384{
3385 dprintf(("CRTDLL: _sopen not implemented.\n"));
3386 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3387 return FALSE;
3388}
3389
3390
3391/*********************************************************************
3392 * CRTDLL__spawnl (CRTDLL.269)
3393 */
3394int CDECL CRTDLL__spawnl(int nMode, const char* szPath, const char* szArgv0,...)
3395{
3396 dprintf2(("CRTDLL: _spawnl\n"));
3397 char *szArg[100];
3398 const char *a;
3399 int i = 0;
3400 va_list l = 0;
3401 va_start(l,szArgv0);
3402 do {
3403 a = va_arg(l,const char *);
3404 szArg[i++] = (char *)a;
3405 } while ( a != NULL && i < 100 );
3406
3407 return _spawnve(nMode, (char*)szPath, szArg, _environ);
3408}
3409
3410
3411/*********************************************************************
3412 * CRTDLL__spawnle (CRTDLL.270)
3413 */
3414int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, ... )
3415{
3416 dprintf2(("CRTDLL: _spawnle not correct implemented.\n"));
3417 char *szArg[100];
3418 char *a;
3419 char *ptr;
3420 int i = 0;
3421 va_list l = 0;
3422 va_start(l,szArgv0);
3423 do {
3424 a = (char*)va_arg(l,const char *);
3425 szArg[i++] = (char *)a;
3426 } while ( a != NULL && i < 100 );
3427
3428
3429// szArg0 is passed and not environment if there is only one parameter;
3430
3431 if ( i >=2 ) {
3432 ptr = szArg[i-2];
3433 szArg[i-2] = NULL;
3434 }
3435 else
3436 ptr = NULL;
3437
3438 return _spawnve(mode, path, szArg, (char**)ptr);
3439}
3440
3441
3442/*********************************************************************
3443 * CRTDLL__spawnlp (CRTDLL.271)
3444 */
3445int CDECL CRTDLL__spawnlp(int nMode, const char* szPath, const char* szArgv0, ...)
3446{
3447 dprintf2(("CRTDLL: _spawnlp\n"));
3448 char *szArg[100];
3449 const char *a;
3450 int i = 0;
3451 va_list l = 0;
3452 va_start(l,szArgv0);
3453 do {
3454 a = (const char *)va_arg(l,const char *);
3455 szArg[i++] = (char *)a;
3456 } while ( a != NULL && i < 100 );
3457 return _spawnvpe(nMode, (char*)szPath,szArg, _environ);
3458}
3459
3460
3461/*********************************************************************
3462 * CRTDLL__spawnlpe (CRTDLL.272)
3463 */
3464int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, ... )
3465{
3466 dprintf2(("CRTDLL: _spawnlpe not correct implemented.\n"));
3467 char *szArg[100];
3468 const char *a;
3469 char *ptr;
3470 int i = 0;
3471 va_list l = 0;
3472 va_start(l,szArgv0);
3473 do {
3474 a = (char *)va_arg(l,const char *);
3475 szArg[i++] = (char *)a;
3476 } while ( a != NULL && i < 100 );
3477
3478
3479// szArg0 is passed and not environment if there is only one parameter;
3480
3481 if ( i >=2 ) {
3482 ptr = szArg[i-2];
3483 szArg[i-2] = NULL;
3484 }
3485 else
3486 ptr = NULL;
3487
3488 return _spawnvpe(mode, path, szArg, (char**)ptr);
3489}
3490
3491
3492/*********************************************************************
3493 * CRTDLL__spawnv (CRTDLL.273)
3494 */
3495int CDECL CRTDLL__spawnv( int i, char *s1, char ** s2 )
3496{
3497 dprintf2(("CRTDLL: _spawnv\n"));
3498 return (_spawnv(i, s1, s2));
3499}
3500
3501
3502/*********************************************************************
3503 * CRTDLL__spawnve (CRTDLL.274)
3504 */
3505int CDECL CRTDLL__spawnve( int i, char *s1, char ** s2, char ** s3 )
3506{
3507 dprintf2(("CRTDLL: _spawnve\n"));
3508 return (_spawnve(i, s1, s2, s3));
3509}
3510
3511
3512/*********************************************************************
3513 * CRTDLL__spawnvp (CRTDLL.275)
3514 */
3515int CDECL CRTDLL__spawnvp( int i, char *s1, char ** s2 )
3516{
3517 dprintf2(("CRTDLL: _spawnvp\n"));
3518 return (_spawnvp(i, s1, s2));
3519}
3520
3521/*********************************************************************
3522 * CRTDLL__spawnv (CRTDLL.276)
3523 */
3524int CDECL CRTDLL__spawnvpe( int i, char *s1, char ** s2, char ** s3 )
3525{
3526 dprintf2(("CRTDLL: _spawnvpe\n"));
3527 return (_spawnvpe(i, s1, s2, s3));
3528}
3529
3530
3531/*********************************************************************
3532 * CRTDLL__stat (CRTDLL.278)
3533 */
3534int CDECL CRTDLL__stat( const char *s1, struct stat * n )
3535{
3536 dprintf2(("CRTDLL: _stat\n"));
3537 return(_stat(s1, n));
3538}
3539
3540
3541/*********************************************************************
3542 * CRTDLL__statusfp (CRTDLL.279)
3543 */
3544unsigned int CDECL CRTDLL__statusfp( void )
3545{
3546 dprintf2(("CRTDLL: _statusfp\n"));
3547 return (_status87());
3548}
3549
3550
3551/*********************************************************************
3552 * CRTDLL__strdate (CRTDLL.281)
3553 */
3554char * CDECL CRTDLL__strdate( char *buf )
3555{
3556 dprintf2(("CRTDLL: _strdate\n"));
3557 return(_strdate(buf));
3558}
3559
3560
3561/*********************************************************************
3562 * CRTDLL__strdec (CRTDLL.282)
3563 */
3564char * CDECL CRTDLL__strdec( const char *, const char *p )
3565{
3566 dprintf2(("CRTDLL: _strdec\n"));
3567 return( (char *)(p-1) );
3568}
3569
3570
3571/*********************************************************************
3572 * CRTDLL__strdup (CRTDLL.283)
3573 */
3574LPSTR CDECL CRTDLL__strdup(LPCSTR ptr)
3575{
3576 dprintf2(("CRTDLL: _strdup\n"));
3577 return HEAP_strdupA(GetProcessHeap(),0,ptr);
3578}
3579
3580
3581/*********************************************************************
3582 * _strerror (CRTDLL.284)
3583 */
3584char * CDECL CRTDLL__strerror(const char *s)
3585{
3586 dprintf(("CRTDLL: _strerror not implemented\n"));
3587 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3588 return FALSE;
3589// return (_strerror(s));
3590}
3591
3592
3593/*********************************************************************
3594 * CRTDLL__stricoll (CRTDLL.286)
3595 */
3596int CDECL CRTDLL__stricoll( const char *s1, const char *s2 )
3597{
3598 dprintf2(("CRTDLL: _stricoll\n"));
3599 return stricmp(s1,s2);
3600}
3601
3602
3603/*********************************************************************
3604 * CRTDLL__strinc (CRTDLL.287)
3605 */
3606char * CDECL CRTDLL__strinc( const char *p )
3607{
3608 dprintf2(("CRTDLL: _strinc\n"));
3609 return( (char *)(p+1) );
3610}
3611
3612
3613/*********************************************************************
3614 * CRTDLL__strncnt (CRTDLL.289)
3615 */
3616size_t CDECL CRTDLL__strncnt( const char *p, size_t l )
3617{
3618 dprintf2(("CRTDLL: _strncnt\n"));
3619 size_t i;
3620 i = strlen(p);
3621 return( (i>l) ? l : i );
3622}
3623
3624/*********************************************************************
3625 * CRTDLL__strnextc (CRTDLL.290)
3626 */
3627unsigned int CDECL CRTDLL__strnextc( const char *p )
3628{
3629 dprintf2(("CRTDLL: _strnextc\n"));
3630 return( (unsigned int)*p );
3631}
3632
3633
3634/*********************************************************************
3635 * CRTDLL__strninc (CRTDLL.292)
3636 */
3637char * CDECL CRTDLL__strninc( const char *p, size_t l )
3638{
3639 dprintf2(("CRTDLL: _strninc\n"));
3640 return( (char *)(p+l) );
3641}
3642
3643
3644/*********************************************************************
3645 * CRTDLL__strnset (CRTDLL.293)
3646 */
3647char * CDECL CRTDLL__strnset(char* szToFill, int szFill, size_t sizeMaxFill)
3648{
3649 dprintf2(("CRTDLL: _strnset\n"));
3650 char *t = szToFill;
3651 int i = 0;
3652 while( *szToFill != 0 && i < sizeMaxFill)
3653 {
3654 *szToFill = szFill;
3655 szToFill++;
3656 i++;
3657 }
3658 return t;
3659}
3660
3661
3662/*********************************************************************
3663 * CRTDLL__strrev (CRTDLL.294)
3664 */
3665char * CDECL CRTDLL__strrev( char *s )
3666{
3667 dprintf2(("CRTDLL: _strrev\n"));
3668 char *e;
3669 char a;
3670 e=s;
3671 while (*e)
3672 e++;
3673 while (s<e) {
3674 a=*s;
3675 *s=*e;
3676 *e=a;
3677 s++;
3678 e--;
3679 }
3680 return s;
3681}
3682
3683
3684/*********************************************************************
3685 * CRTDLL__strset (CRTDLL.295)
3686 */
3687char * CDECL CRTDLL__strset(char* szToFill, int szFill)
3688{
3689 dprintf2(("CRTDLL: _strset\n"));
3690 char *t = szToFill;
3691 while( *szToFill != 0 )
3692 {
3693 *szToFill = szFill;
3694 szToFill++;
3695 }
3696 return t;
3697}
3698
3699
3700/*********************************************************************
3701 * CRTDLL__strspnp (CRTDLL.296)
3702 */
3703char * CDECL CRTDLL__strspnp( const char *p1, const char *p2 )
3704{
3705 dprintf2(("CRTDLL: _strspnp\n"));
3706 return( (*(p1 += strspn(p1,p2))!='\0') ? (char*)p1 : NULL );
3707}
3708
3709
3710/*********************************************************************
3711 * CRTDLL__strtime (CRTDLL.297)
3712 */
3713char * CDECL CRTDLL__strtime( char *buf )
3714{
3715 dprintf2(("CRTDLL: _strtime\n"));
3716 return (_strtime(buf));
3717}
3718
3719
3720/*********************************************************************
3721 * CRTDLL__swab (CRTDLL.299)
3722 */
3723void CDECL CRTDLL__swab(char *s1, char *s2, int i)
3724{
3725 dprintf2(("CRTDLL: _swab\n"));
3726 _swab(s1, s2, i);
3727}
3728
3729
3730/*********************************************************************
3731 * CRTDLL__tell (CRTDLL.302)
3732 */
3733long CDECL CRTDLL__tell( int i )
3734{
3735 dprintf2(("CRTDLL: _tell\n"));
3736 return (_tell(i));
3737}
3738
3739
3740/*********************************************************************
3741 * CRTDLL__tempnam (CRTDLL.303)
3742 */
3743char * CDECL CRTDLL__tempnam( char *dir, char *prefix )
3744{
3745 dprintf2(("CRTDLL: _tempnam\n"));
3746 return (_tempnam(dir, prefix));
3747}
3748
3749
3750/*********************************************************************
3751 * CRTDLL__tolower (CRTDLL.305)
3752 */
3753int CDECL CRTDLL__tolower(int n)
3754{
3755 dprintf2(("CRTDLL: _tolower\n"));
3756 return (_tolower(n));
3757}
3758
3759
3760/*********************************************************************
3761 * CRTDLL__toupper (CRTDLL.306)
3762 */
3763int CDECL CRTDLL__toupper(int n)
3764{
3765 dprintf2(("CRTDLL: _toupper\n"));
3766 return (_toupper(n));
3767}
3768
3769
3770/*********************************************************************
3771 * _tzset (CRTDLL.308)
3772 */
3773void CDECL CRTDLL__tzset( void )
3774{
3775 dprintf(("CRTDLL: _tzset not implemented.\n"));
3776 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3777}
3778
3779
3780/*********************************************************************
3781 * CRTDLL__umask (CRTDLL.310)
3782 */
3783int CDECL CRTDLL__umask( int i )
3784{
3785 dprintf2(("CRTDLL: _umask\n"));
3786 return (_umask(i));
3787}
3788
3789
3790/*********************************************************************
3791 * CRTDLL__ungetch (CRTDLL.311)
3792 */
3793int CDECL CRTDLL__ungetch( int i )
3794{
3795 dprintf2(("CRTDLL: _ungetch\n"));
3796 return (_ungetch(i));
3797}
3798
3799
3800/*********************************************************************
3801 * _unlink (CRTDLL.312)
3802 */
3803INT CDECL CRTDLL__unlink(LPCSTR pathname)
3804{
3805 dprintf2(("CRTDLL: _unlink\n"));
3806 int ret=0;
3807 DOS_FULL_NAME full_name;
3808
3809 if (!DOSFS_GetFullName( pathname, FALSE, (CHAR*)&full_name )) {
3810 dprintf2(("CRTDLL_unlink file %s bad name\n",pathname));
3811 return EOF;
3812 }
3813
3814 ret=unlink(full_name.long_name);
3815 dprintf2(("(%s unix %s)\n",
3816 pathname,full_name.long_name));
3817 if(ret)
3818 dprintf2((" Failed!\n"));
3819
3820 return ret;
3821}
3822
3823
3824/*********************************************************************
3825 * CRTDLL__unloaddll (CRTDLL.313)
3826 */
3827int CDECL CRTDLL__unloaddll(void *handle)
3828{
3829 dprintf2(("CRTDLL: _unloaddll\n"));
3830 return FreeLibrary((HMODULE)handle);
3831}
3832
3833
3834/*********************************************************************
3835 * CRTDLL__utime (CRTDLL.314)
3836 */
3837int CDECL CRTDLL__utime( char *path, struct utimbuf * times )
3838{
3839 dprintf2(("CRTDLL: _utime\n"));
3840 return (_utime(path, times));
3841}
3842
3843
3844/*********************************************************************
3845 * CRTDLL__vsnwprintf (CRTDLL.316)
3846 */
3847int CDECL CRTDLL__vsnwprintf( wchar_t *s1, size_t n, const wchar_t *s2, va_list arg )
3848{
3849 dprintf(("CRTDLL: _vsnwprintf not implemented.\n"));
3850 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3851 return FALSE;
3852}
3853
3854
3855/*********************************************************************
3856 * CRTDLL__wcsdup (CRTDLL.317)
3857 */
3858LPWSTR CDECL CRTDLL__wcsdup( LPCWSTR str )
3859{
3860 dprintf2(("CRTDLL: _wcsdup\n"));
3861 LPWSTR ret = NULL;
3862 if (str)
3863 {
3864 int size = (wcslen((const wchar_t*)str) + 1) * sizeof(WCHAR);
3865// FIXME ret = CRTDLL_malloc( size );
3866 if (ret) memcpy( ret, str, size );
3867 }
3868 return ret;
3869}
3870
3871
3872/*********************************************************************
3873 * CRTDLL__wcsicoll (CRTDLL.319)
3874 */
3875int CDECL CRTDLL__wcsicoll( LPCWSTR str1, LPCWSTR str2 )
3876{
3877 dprintf2(("CRTDLL: _wcsicoll\n"));
3878 return CRTDLL__wcsicmp( str1, str2 );
3879}
3880
3881
3882/*********************************************************************
3883 * CRTDLL__wcsnset (CRTDLL.322)
3884 */
3885LPWSTR CDECL CRTDLL__wcsnset( LPWSTR str, WCHAR c, INT n )
3886{
3887 dprintf2(("CRTDLL: _wcsnset\n"));
3888 LPWSTR ret = str;
3889 while ((n-- > 0) && *str) *str++ = c;
3890 return ret;
3891}
3892
3893
3894/*********************************************************************
3895 * CRTDLL__wcsrev (CRTDLL.323)
3896 */
3897LPWSTR CDECL CRTDLL__wcsrev( LPWSTR str )
3898{
3899 dprintf2(("CRTDLL: _wcsrev\n"));
3900 LPWSTR ret = str;
3901 LPWSTR end = str + wcslen((const wchar_t*)str) - 1;
3902 while (end > str)
3903 {
3904 WCHAR t = *end;
3905 *end-- = *str;
3906 *str++ = t;
3907 }
3908 return ret;
3909}
3910
3911
3912/*********************************************************************
3913 * CRTDLL__wcsset (CRTDLL.324)
3914 */
3915LPWSTR CDECL CRTDLL__wcsset( LPWSTR str, WCHAR c )
3916{
3917 dprintf2(("CRTDLL: _wcsset\n"));
3918 LPWSTR ret = str;
3919 while (*str) *str++ = c;
3920 return ret;
3921}
3922
3923
3924/*********************************************************************
3925 * _write (CRTDLL.329)
3926 */
3927INT CDECL CRTDLL__write(INT fd,LPCVOID buf,UINT count)
3928{
3929 dprintf2(("CRTDLL: _write\n"));
3930 INT len=0;
3931
3932 if (fd == -1)
3933 len = -1;
3934 else if (fd<=2)
3935 len = (UINT)write(fd,buf,(LONG)count);
3936 else
3937 len = _lwrite(fd,(LPCSTR)buf,count);
3938 dprintf2(("%d/%d byte to dfh %d from %p,\n",
3939 len,count,fd,buf));
3940 return len;
3941}
3942
3943
3944/*********************************************************************
3945 * _y0 (CRTDLL.332)
3946 */
3947double CDECL CRTDLL__y0(double x)
3948{
3949 dprintf2(("CRTDLL: _y0\n"));
3950 return (_y0(x));
3951}
3952
3953
3954/*********************************************************************
3955 * _y1 (CRTDLL.333)
3956 */
3957double CDECL CRTDLL__y1(double x)
3958{
3959 dprintf2(("CRTDLL: _y1\n"));
3960 return (_y1(x));
3961}
3962
3963
3964/*********************************************************************
3965 * _yn (CRTDLL.334)
3966 */
3967double CDECL CRTDLL__yn(int i, double x)
3968{
3969 dprintf2(("CRTDLL: _yn\n"));
3970 return (_yn(i, x));
3971}
3972
3973
3974/*********************************************************************
3975 * isleadbyte (CRTDLL.335)
3976 */
3977void CDECL CRTDLL_abort( void )
3978{
3979 dprintf2(("CRTDLL: abort\n"));
3980 abort();
3981}
3982
3983
3984/*********************************************************************
3985 * acos (CRTDLL.336)
3986 */
3987double CDECL CRTDLL_acos( double x )
3988{
3989 dprintf2(("CRTDLL: acos\n"));
3990 return (acos(x));
3991}
3992
3993
3994/*********************************************************************
3995 * asctime (CRTDLL.338)
3996 */
3997char * CDECL CRTDLL_asctime( const struct tm *timeptr )
3998{
3999 dprintf2(("CRTDLL: asctime\n"));
4000 return (asctime(timeptr));
4001}
4002
4003
4004/*********************************************************************
4005 * asin (CRTDLL.339)
4006 */
4007double CDECL CRTDLL_asin( double x )
4008{
4009 dprintf2(("CRTDLL: asin\n"));
4010 return (asin(x));
4011}
4012
4013
4014/*********************************************************************
4015 * atan2 (CRTDLL.341)
4016 */
4017double CDECL CRTDLL_atan2( double y, double x )
4018{
4019 dprintf2(("CRTDLL: atan2\n"));
4020 return (atan2(y, x));
4021}
4022
4023
4024/*********************************************************************
4025 * atexit (CRTDLL.342)
4026 */
4027int CDECL CRTDLL_atexit( register void ( *func )( void ) )
4028{
4029 dprintf(("CRTDLL: atexit not implemented.\n"));
4030 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
4031 return FALSE;
4032}
4033
4034
4035/*********************************************************************
4036 * atof (CRTDLL.343)
4037 */
4038double CDECL CRTDLL_atof( const char *nptr )
4039{
4040 dprintf2(("CRTDLL: atof\n"));
4041 return (atof(nptr));
4042}
4043
4044/*********************************************************************
4045 * calloc (CRTDLL.347)
4046 */
4047void * CDECL CRTDLL_calloc( size_t n, size_t size )
4048{
4049// dprintf2(("CRTDLL: calloc\n"));
4050 return Heap_Alloc(size*n);
4051}
4052
4053
4054/*********************************************************************
4055 * clearerr (CRTDLL.349)
4056 */
4057void CDECL CRTDLL_clearerr( FILE *fp )
4058{
4059 dprintf2(("CRTDLL: clearerr\n"));
4060 clearerr(fp);
4061}
4062
4063
4064/*********************************************************************
4065 * clock (CRTDLL.350)
4066 */
4067clock_t CDECL CRTDLL_clock( void )
4068{
4069 dprintf2(("CRTDLL: clock\n"));
4070 return (clock());
4071}
4072
4073
4074/*********************************************************************
4075 * cosh (CRTDLL.352)
4076 */
4077double CDECL CRTDLL_cosh( double x )
4078{
4079 dprintf2(("CRTDLL: cosh\n"));
4080 return (cosh(x));
4081}
4082
4083
4084/*********************************************************************
4085 * ctime (CRTDLL.353)
4086 */
4087char * CDECL CRTDLL_ctime( const time_t *timer )
4088{
4089 dprintf2(("CRTDLL: ctime\n"));
4090 return (ctime(timer));
4091}
4092
4093
4094/*********************************************************************
4095 * difftime (CRTDLL.354)
4096 */
4097double CDECL CRTDLL_difftime( time_t t1, time_t t0 )
4098{
4099 dprintf2(("CRTDLL: difftime\n"));
4100 return (difftime(t1, t0));
4101}
4102
4103
4104/*********************************************************************
4105 * div (CRTDLL.355)
4106 */
4107div_t CDECL CRTDLL_div( int numer, int denom )
4108{
4109 dprintf2(("CRTDLL: div\n"));
4110 return (div(numer, denom));
4111}
4112
4113
4114/*********************************************************************
4115 * exit (CRTDLL.356)
4116 */
4117void CDECL CRTDLL_exit(DWORD ret)
4118{
4119 dprintf2(("CRTDLL: exit\n"));
4120 ExitProcess(ret);
4121}
4122
4123
4124/*********************************************************************
4125 * exp (CRTDLL.357)
4126 */
4127double CDECL CRTDLL_exp( double x )
4128{
4129 dprintf2(("CRTDLL: exp\n"));
4130 return (exp(x));
4131}
4132
4133
4134/*********************************************************************
4135 * fclose (CRTDLL.359)
4136 */
4137int CDECL CRTDLL_fclose( FILE *fp )
4138{
4139 dprintf2(("CRTDLL: fclose\n"));
4140 return (fclose(fp));
4141}
4142
4143
4144/*********************************************************************
4145 * feof (CRTDLL.360)
4146 */
4147int CDECL CRTDLL_feof( FILE *fp )
4148{
4149 dprintf2(("CRTDLL: feof\n"));
4150 return (feof(fp));
4151}
4152
4153
4154/*********************************************************************
4155 * ferror (CRTDLL.361)
4156 */
4157int CDECL CRTDLL_ferror( FILE *fp )
4158{
4159 dprintf2(("CRTDLL: ferror\n"));
4160 return (ferror(fp));
4161}
4162
4163
4164/*********************************************************************
4165 * fflush (CRTDLL.362)
4166 */
4167int CDECL CRTDLL_fflush( FILE *fp )
4168{
4169 dprintf2(("CRTDLL: fflush\n"));
4170 return (fflush(fp));
4171}
4172
4173
4174/*********************************************************************
4175 * fgetc (CRTDLL.363)
4176 */
4177int CDECL CRTDLL_fgetc( FILE *fp )
4178{
4179 dprintf2(("CRTDLL: fgetc\n"));
4180 return (fgetc(fp));
4181}
4182
4183
4184/*********************************************************************
4185 * fgetpos (CRTDLL.364)
4186 */
4187int CDECL CRTDLL_fgetpos( FILE *fp, fpos_t *pos )
4188{
4189 dprintf2(("CRTDLL: fgetpos\n"));
4190 return (fgetpos(fp, pos));
4191}
4192
4193
4194/*********************************************************************
4195 * fgets (CRTDLL.365)
4196 */
4197char * CDECL CRTDLL_fgets( char *s, int n, FILE *fp )
4198{
4199 dprintf2(("CRTDLL: fgets\n"));
4200 return (fgets(s, n, fp));
4201}
4202
4203
4204/*********************************************************************
4205 * fgetwc (CRTDLL.366)
4206 */
4207wint_t CDECL CRTDLL_fgetwc( FILE *f )
4208{
4209 dprintf2(("CRTDLL: fgetwc\n"));
4210 return (fgetwc(f));
4211}
4212
4213
4214/*********************************************************************
4215 * fmod (CRTDLL.368)
4216 */
4217double CDECL CRTDLL_fmod(double x, double y )
4218{
4219 dprintf2(("CRTDLL: fmod\n"));
4220 return (fmod(x,y));
4221}
4222
4223
4224/*********************************************************************
4225 * fopen (CRTDLL.369)
4226 */
4227FILE * CDECL CRTDLL_fopen( const char *filename, const char *mode )
4228{
4229 dprintf2(("CRTDLL: fopen\n"));
4230 return (fopen( filename, mode));
4231}
4232
4233
4234/*********************************************************************
4235 * fprintf (CRTDLL.370)
4236 */
4237INT CDECL CRTDLL_fprintf( CRTDLL_FILE *file, LPSTR format, ... )
4238{
4239 dprintf2(("CRTDLL: fprintf\n"));
4240 va_list valist;
4241 INT res;
4242
4243 va_start( valist, format );
4244 res = CRTDLL_vfprintf( file, format, valist );
4245 va_end( valist );
4246 return res;
4247}
4248
4249
4250/*********************************************************************
4251 * fputc (CRTDLL.371)
4252 */
4253int CDECL CRTDLL_fputc( int c, FILE *fp )
4254{
4255 dprintf2(("CRTDLL: fputc\n"));
4256 return (fputc(c, fp));
4257}
4258
4259
4260/*********************************************************************
4261 * fputs (CRTDLL.372)
4262 */
4263int CDECL CRTDLL_fputs( const char *s, FILE *fp )
4264{
4265 dprintf2(("CRTDLL: fputs\n"));
4266 return (fputs(s, fp));
4267}
4268
4269
4270/*********************************************************************
4271 * fputwc (CRTDLL.373)
4272 */
4273wint_t CDECL CRTDLL_fputwc( wint_t wc, FILE *strm )
4274{
4275 dprintf2(("CRTDLL: fputwc\n"));
4276 return (fputwc(wc, strm));
4277}
4278
4279
4280/*********************************************************************
4281 * fread (CRTDLL.374)
4282 */
4283size_t CDECL CRTDLL_fread( void *ptr, size_t size, size_t n, FILE *fp )
4284{
4285// dprintf2(("CRTDLL: fread\n"));
4286 return (fread(ptr, size, n, fp));
4287}
4288
4289
4290/*********************************************************************
4291 * free (CRTDLL.375)
4292 */
4293VOID CDECL CRTDLL_free(LPVOID ptr)
4294{
4295// dprintf2(("CRTDLL: free\n"));
4296 Heap_Free(ptr);
4297}
4298
4299
4300/*********************************************************************
4301 * freopen (CRTDLL.376)
4302 */
4303FILE * CDECL CRTDLL_freopen( const char *filename, const char *mode, FILE *fp )
4304{
4305 dprintf2(("CRTDLL: freopen\n"));
4306 return (freopen(filename, mode, fp));
4307}
4308
4309
4310/*********************************************************************
4311 * frexp (CRTDLL.377)
4312 */
4313double CDECL CRTDLL_frexp( double value, int *exp )
4314{
4315 dprintf2(("CRTDLL: frexp\n"));
4316 return (frexp(value, exp));
4317}
4318
4319
4320/*********************************************************************
4321 * fscanf (CRTDLL.378)
4322 */
4323int CDECL CRTDLL_fscanf( FILE*fp, const char *format, ... )
4324{
4325 dprintf2(("CRTDLL: fscanf\n"));
4326#if 0
4327 va_list valist;
4328 INT res;
4329
4330 va_start( valist, format );
4331#ifdef HAVE_VFSCANF
4332 res = vfscanf( xlat_file_ptr(stream), format, valist );
4333#endif
4334 va_end( valist );
4335 return res;
4336#endif
4337 dprintf2(("broken\n"));
4338 return 0;
4339}
4340
4341
4342/*********************************************************************
4343 * fseek (CRTDLL.379)
4344 */
4345int CDECL CRTDLL_fseek( FILE *file, long int offset, int whence )
4346{
4347 dprintf2(("CRTDLL: fseek\n"));
4348 dprintf2(("file %p to 0x%08lx pos %s\n",
4349 file,offset,(whence==SEEK_SET)?"SEEK_SET":
4350 (whence==SEEK_CUR)?"SEEK_CUR":
4351 (whence==SEEK_END)?"SEEK_END":"UNKNOWN"));
4352// FIXME if (SetFilePointer( file->handle, offset, NULL, whence ) != 0xffffffff)
4353// FIXME return 0;
4354 dprintf2((" failed!\n"));
4355 return -1;
4356}
4357
4358
4359/*********************************************************************
4360 * fsetpos (CRTDLL.380)
4361 */
4362int CDECL CRTDLL_fsetpos( FILE *fp, const fpos_t *pos )
4363{
4364 dprintf2(("CRTDLL: fsetpos\n"));
4365 return (fsetpos(fp, pos));
4366}
4367
4368
4369/*********************************************************************
4370 * ftell (CRTDLL.381)
4371 */
4372long int CDECL CRTDLL_ftell( FILE *fp )
4373{
4374 dprintf2(("CRTDLL: ftell\n"));
4375 return (ftell(fp));
4376}
4377
4378
4379/*********************************************************************
4380 * fwprintf (CRTDLL.382)
4381 */
4382int CDECL CRTDLL_fwprintf( FILE *iop, const wchar_t *fmt, ... )
4383{
4384 dprintf(("CRTDLL: fwprintf not implemented.\n"));
4385 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
4386 return FALSE;
4387}
4388
4389
4390/*********************************************************************
4391 * fwrite (CRTDLL.383)
4392 */
4393DWORD CDECL CRTDLL_fwrite( LPVOID ptr, INT size, INT nmemb, CRTDLL_FILE *file )
4394{
4395 DWORD ret;
4396
4397 dprintf2(("CRTDLL: fwrite\n"));
4398 if (!WriteFile( file->handle, ptr, size * nmemb, &ret, NULL ))
4399 dprintf2((" failed!\n"));
4400
4401 return ret / size;
4402}
4403
4404
4405/*********************************************************************
4406 * fwscanf (CRTDLL.384)
4407 */
4408int CDECL CRTDLL_fwscanf( FILE *strm, const wchar_t *format, ... )
4409{
4410 dprintf(("CRTDLL: fwscanf not implemented.\n"));
4411 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
4412 return FALSE;
4413}
4414
4415
4416/*********************************************************************
4417 * getc (CRTDLL.385)
4418 */
4419int CDECL CRTDLL_getc( FILE *fp )
4420{
4421 dprintf2(("CRTDLL: getc\n"));
4422 return (getc(fp));
4423}
4424
4425
4426/*********************************************************************
4427 * getchar (CRTDLL.386)
4428 */
4429int CDECL CRTDLL_getchar( void )
4430{
4431 dprintf2(("CRTDLL: getchar\n"));
4432 return (getchar());
4433}
4434
4435
4436/*********************************************************************
4437 * getenv (CRTDLL.387)
4438 */
4439char * CDECL CRTDLL_getenv( const char *name )
4440{
4441 dprintf2(("CRTDLL: getenv\n"));
4442 return (getenv(name));
4443}
4444
4445
4446/*********************************************************************
4447 * gets (CRTDLL.388)
4448 */
4449char * CDECL CRTDLL_gets( char *s )
4450{
4451 dprintf2(("CRTDLL: gets\n"));
4452 return (gets(s));
4453}
4454
4455
4456/*********************************************************************
4457 * gmtime (CRTDLL.389)
4458 */
4459struct tm * CDECL CRTDLL_gmtime( const time_t *timer )
4460{
4461 dprintf2(("CRTDLL: gmtime\n"));
4462 return (gmtime(timer));
4463}
4464
4465
4466/*********************************************************************
4467 * is_wctype (CRTDLL.390)
4468 */
4469INT CDECL CRTDLL_is_wctype(wint_t wc, wctype_t wctypeFlags)
4470{
4471 dprintf2(("CRTDLL: is_wctype\n"));
4472 return ((CRTDLL_pwctype_dll[(unsigned char)(wc & 0xFF)]&wctypeFlags) == wctypeFlags );
4473}
4474
4475
4476/*********************************************************************
4477 * isalnum (CRTDLL.391)
4478 */
4479int CDECL CRTDLL_isalnum(int i)
4480{
4481 dprintf2(("CRTDLL: isalnum(%08xh)\n", i));
4482 return (isalnum(i));
4483}
4484
4485
4486/*********************************************************************
4487 * iscntrl (CRTDLL.393)
4488 */
4489int CDECL CRTDLL_iscntrl(int i)
4490{
4491 dprintf2(("CRTDLL: iscntrl(%08xh)\n", i));
4492 return (iscntrl(i));
4493}
4494
4495
4496/*********************************************************************
4497 * isgraph (CRTDLL.395)
4498 */
4499int CDECL CRTDLL_isgraph(int i)
4500{
4501 dprintf2(("CRTDLL: isgraph(%08xh)\n", i));
4502 return (isgraph(i));
4503}
4504
4505
4506/*********************************************************************
4507 * isleadbyte (CRTDLL.396)
4508 */
4509int CDECL CRTDLL_isleadbyte(int i)
4510{
4511 dprintf(("CRTDLL: isleadbyte(%08xh) not implemented.\n", i));
4512 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
4513 return FALSE;
4514}
4515
4516
4517/*********************************************************************
4518 * ispunct (CRTDLL.399)
4519 */
4520int CDECL CRTDLL_ispunct(int i)
4521{
4522 dprintf2(("CRTDLL: ispunct(%08xh)\n", i));
4523 return (ispunct(i));
4524}
4525
4526
4527/*********************************************************************
4528 * iswalnum (CRTDLL.402)
4529 */
4530int CDECL CRTDLL_iswalnum(wint_t i)
4531{
4532 dprintf2(("CRTDLL: iswalnum(%08xh)\n", i));
4533 return (iswalnum(i));
4534}
4535
4536
4537/*********************************************************************
4538 * iswascii (CRTDLL.404)
4539 */
4540int CDECL CRTDLL_iswascii(wint_t c)
4541{
4542 dprintf2(("CRTDLL: iswascii\n", c));
4543 return (!((c)&(~0x7f)));
4544}
4545
4546
4547/*********************************************************************
4548 * iswcntrl (CRTDLL.405)
4549 */
4550int CDECL CRTDLL_iswcntrl(wint_t i)
4551{
4552 dprintf2(("CRTDLL: iswcntrl(%08xh)\n", i));
4553 return (iswcntrl(i));
4554}
4555
4556
4557/*********************************************************************
4558 * iswdigit (CRTDLL.407)
4559 */
4560int CDECL CRTDLL_iswdigit(wint_t i)
4561{
4562 dprintf2(("CRTDLL: iswdigit(%08xh)\n", i));
4563 return (iswdigit(i));
4564}
4565
4566
4567/*********************************************************************
4568 * iswgraph (CRTDLL.408)
4569 */
4570int CDECL CRTDLL_iswgraph(wint_t i)
4571{
4572 dprintf2(("CRTDLL: iswgraph(%08xh)\n", i));
4573 return (iswgraph(i));
4574}
4575
4576
4577/*********************************************************************
4578 * iswlower (CRTDLL.409)
4579 */
4580int CDECL CRTDLL_iswlower(wint_t i)
4581{
4582 dprintf2(("CRTDLL: iswlower(%08xh)\n", i));
4583 return (iswlower(i));
4584}
4585
4586
4587/*********************************************************************
4588 * iswprint (CRTDLL.410)
4589 */
4590int CDECL CRTDLL_iswprint(wint_t i)
4591{
4592 dprintf2(("CRTDLL: iswprint(%08xh)\n", i));
4593 return (iswprint(i));
4594}
4595
4596
4597/*********************************************************************
4598 * iswpunct (CRTDLL.411)
4599 */
4600int CDECL CRTDLL_iswpunct(wint_t i)
4601{
4602 dprintf2(("CRTDLL: iswpunct(%08xh)\n", i));
4603 return (iswpunct(i));
4604}
4605
4606
4607/*********************************************************************
4608 * iswspace (CRTDLL.412)
4609 */
4610int CDECL CRTDLL_iswspace(wint_t i)
4611{
4612 dprintf2(("CRTDLL: iswspace(%08xh)\n", i));
4613 return (iswspace(i));
4614}
4615
4616
4617/*********************************************************************
4618 * iswupper (CRTDLL.413)
4619 */
4620int CDECL CRTDLL_iswupper(wint_t i)
4621{
4622 dprintf2(("CRTDLL: iswupper(%08xh)\n", i));
4623 return (iswupper(i));
4624}
4625
4626
4627/*********************************************************************
4628 * iswxdigit (CRTDLL.414)
4629 */
4630int CDECL CRTDLL_iswxdigit(wint_t i)
4631{
4632 dprintf2(("CRTDLL: iswxdigit(%08xh)\n", i));
4633 return (iswxdigit(i));
4634}
4635
4636
4637/*********************************************************************
4638 * ldexp (CRTDLL.417)
4639 */
4640double CDECL CRTDLL_ldexp( double x, int exp )
4641{
4642 dprintf2(("CRTDLL: ldexp\n"));
4643 return (ldexp(x, exp));
4644}
4645
4646
4647/*********************************************************************
4648 * ldiv (CRTDLL.418)
4649 */
4650ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom )
4651{
4652 dprintf2(("CRTDLL: ldiv\n"));
4653 return (ldiv(numer, denom));
4654}
4655
4656
4657/*********************************************************************
4658 * localeconv (CRTDLL.419)
4659 */
4660struct lconv * CDECL CRTDLL_localeconv(void)
4661{
4662 dprintf2(("CRTDLL: localeconv\n"));
4663 return (localeconv());
4664}
4665
4666
4667/*********************************************************************
4668 * localtime (CRTDLL.420)
4669 */
4670struct tm * CDECL CRTDLL_localtime( const time_t *timer )
4671{
4672 dprintf2(("CRTDLL: localtime\n"));
4673 return (localtime(timer));
4674}
4675
4676
4677/*********************************************************************
4678 * log10 (CRTDLL.422)
4679 */
4680double CDECL CRTDLL_log10( double x )
4681{
4682 dprintf2(("CRTDLL: log10\n"));
4683 return (log10(x));
4684}
4685
4686
4687/*********************************************************************
4688 * longjmp (CRTDLL.423)
4689 */
4690VOID CDECL CRTDLL_longjmp(jmp_buf env, int val)
4691{
4692 dprintf2(("CRTDLL: longjmp\n"));
4693 longjmp(env, val);
4694}
4695
4696
4697/*********************************************************************
4698 * malloc (CRTDLL.424)
4699 */
4700VOID* CDECL CRTDLL_malloc(DWORD size)
4701{
4702// dprintf2(("CRTDLL: malloc\n"));
4703 return Heap_Alloc(size);
4704}
4705
4706
4707/*********************************************************************
4708 * mblen (CRTDLL.425)
4709 */
4710INT CDECL CRTDLL_mblen( const char *s, size_t n )
4711{
4712 dprintf2(("CRTDLL: mblen\n"));
4713 return (mblen(s, n));
4714}
4715
4716
4717/*********************************************************************
4718 * CRTDLL_mbtowc (CRTDLL.427)
4719 */
4720INT CDECL CRTDLL_mbtowc( WCHAR *dst, LPCSTR str, INT n )
4721{
4722 dprintf2(("CRTDLL: _mbtowc\n"));
4723 wchar_t res;
4724 int ret = mbtowc( &res, str, n );
4725 if (dst) *dst = (WCHAR)res;
4726 return ret;
4727}
4728
4729
4730/*********************************************************************
4731 * mktime (CRTDLL.433)
4732 */
4733time_t CDECL CRTDLL_mktime( struct tm *timeptr )
4734{
4735 dprintf2(("CRTDLL: mktime\n"));
4736 return mktime( timeptr );
4737}
4738
4739
4740/*********************************************************************
4741 * modf (CRTDLL.434)
4742 */
4743double CDECL CRTDLL_modf( double value, double *iptr )
4744{
4745 dprintf2(("CRTDLL: modf\n"));
4746 return modf( value, iptr );
4747}
4748
4749
4750/*********************************************************************
4751 * perror (CRTDLL.435)
4752 */
4753void CDECL CRTDLL_perror( const char *s )
4754{
4755 dprintf2(("CRTDLL: perror\n"));
4756 perror( s );
4757}
4758
4759
4760/*********************************************************************
4761 * printf (CRTDLL.437)
4762 */
4763int CDECL CRTDLL_printf( const char *format, ... )
4764{
4765 dprintf2(("CRTDLL: printf\n"));
4766 va_list arg;
4767 int done;
4768
4769 va_start (arg, format);
4770 done = vprintf (format, arg);
4771 va_end (arg);
4772 return done;
4773}
4774
4775
4776/*********************************************************************
4777 * putc (CRTDLL.438)
4778 */
4779int CDECL CRTDLL_putc( int c, FILE *fp )
4780{
4781 dprintf2(("CRTDLL: putc\n"));
4782 return putc( c, fp );
4783}
4784
4785
4786/*********************************************************************
4787 * putchar (CRTDLL.439)
4788 */
4789int CDECL CRTDLL_putchar( int c )
4790{
4791 dprintf2(("CRTDLL: putchar\n"));
4792 return putchar( c );
4793}
4794
4795
4796/*********************************************************************
4797 * puts (CRTDLL.440)
4798 */
4799int CDECL CRTDLL_puts( const char *s )
4800{
4801 dprintf2(("CRTDLL: puts\n"));
4802 return puts( s );
4803}
4804
4805
4806/*********************************************************************
4807 * raise (CRTDLL.442)
4808 */
4809int CDECL CRTDLL_raise( int sig )
4810{
4811 dprintf2(("CRTDLL: raise\n"));
4812 return raise( sig );
4813}
4814
4815
4816/*********************************************************************
4817 * rand (CRTDLL.443)
4818 */
4819int CDECL CRTDLL_rand( void )
4820{
4821// dprintf2(("CRTDLL: rand\n"));
4822 return (rand());
4823}
4824
4825
4826/*********************************************************************
4827 * realloc (CRTDLL.444)
4828 */
4829void * CDECL CRTDLL_realloc( void *ptr, size_t size )
4830{
4831 dprintf2(("CRTDLL: realloc\n"));
4832 return HeapReAlloc( GetProcessHeap(), 0, ptr, size );
4833}
4834
4835
4836/*********************************************************************
4837 * remove (CRTDLL.445)
4838 */
4839INT CDECL CRTDLL_remove(LPCSTR file)
4840{
4841 dprintf2(("CRTDLL: remove\n"));
4842 if (!DeleteFileA(file))
4843 return -1;
4844 return 0;
4845}
4846
4847
4848/*********************************************************************
4849 * rename (CRTDLL.446)
4850 */
4851int CDECL CRTDLL_rename (const char *old, const char *new2)
4852{
4853 dprintf2(("CRTDLL: rename\n"));
4854 return (rename(old, new2));
4855}
4856
4857
4858/*********************************************************************
4859 * rewind (CRTDLL.447)
4860 */
4861void CDECL CRTDLL_rewind( FILE *fp )
4862{
4863 dprintf2(("CRTDLL: rewind\n"));
4864 rewind(fp);
4865}
4866
4867
4868/*********************************************************************
4869 * scanf (CRTDLL.448)
4870 */
4871int CDECL CRTDLL_scanf( const char *format, ... )
4872{
4873 dprintf(("CRTDLL: scanf not implemented.\n"));
4874 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
4875 return FALSE;
4876}
4877
4878
4879/*********************************************************************
4880 * setbuf (CRTDLL.449)
4881 */
4882void CDECL CRTDLL_setbuf( FILE *fp, char *buf )
4883{
4884 dprintf2(("CRTDLL: setbuf\n"));
4885 setbuf(fp, buf);
4886}
4887
4888
4889/*********************************************************************
4890 * setlocale (CRTDLL.450)
4891 */
4892char * CDECL CRTDLL_setlocale(int category,const char *locale)
4893{
4894 dprintf2(("CRTDLL: setlocale\n"));
4895 return (setlocale(category, locale));
4896}
4897
4898
4899/*********************************************************************
4900 * setvbuf (CRTDLL.451)
4901 */
4902int CDECL CRTDLL_setvbuf( FILE *fp, char *buf, int mode, size_t size )
4903{
4904 dprintf2(("CRTDLL: setvbuf\n"));
4905 return (setvbuf(fp, buf, mode, size));
4906}
4907
4908
4909/*********************************************************************
4910 * signal (CRTDLL.452)
4911 */
4912void CDECL CRTDLL_signal( int sig, void (*func)(int))
4913{
4914 dprintf(("CRTDLL: signal not implemented.\n"));
4915 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
4916}
4917
4918
4919/*********************************************************************
4920 * sinh (CRTDLL.454)
4921 */
4922double CDECL CRTDLL_sinh( double x )
4923{
4924 dprintf2(("CRTDLL: sinh\n"));
4925 return (sinh(x));
4926}
4927
4928
4929/*********************************************************************
4930 * srand (CRTDLL.457)
4931 */
4932void CDECL CRTDLL_srand( unsigned int seed )
4933{
4934 dprintf2(("CRTDLL: srand\n"));
4935 srand(seed);
4936}
4937
4938
4939/*********************************************************************
4940 * strcoll (CRTDLL.462)
4941 */
4942int CDECL CRTDLL_strcoll( const char *s1, const char *s2 )
4943{
4944 dprintf2(("CRTDLL: strcoll\n"));
4945 return strcoll(s1, s2);
4946}
4947
4948
4949/*********************************************************************
4950 * strerror (CRTDLL.465)
4951 */
4952char * CDECL CRTDLL_strerror( int errnum )
4953{
4954 dprintf2(("CRTDLL: strerror\n"));
4955 return strerror(errnum);
4956}
4957
4958
4959/*********************************************************************
4960 * strftime (CRTDLL.466)
4961 */
4962size_t CDECL CRTDLL_strftime( char *s, size_t maxsiz, const char *fmt, const struct tm *tp )
4963{
4964 dprintf2(("CRTDLL: strftime\n"));
4965 return strftime(s, maxsiz, fmt, tp);
4966}
4967
4968
4969/*********************************************************************
4970 * strtod (CRTDLL.475)
4971 */
4972double CDECL CRTDLL_strtod( const char *nptr, char **endptr )
4973{
4974 dprintf2(("CRTDLL: strtod\n"));
4975 return strtod(nptr, endptr);
4976}
4977
4978
4979/*********************************************************************
4980 * strtok (CRTDLL.476)
4981 */
4982char * CDECL CRTDLL_strtok( char *s1, const char *s2 )
4983{
4984 dprintf2(("CRTDLL: strtok\n"));
4985 return strtok(s1, s2);
4986}
4987
4988
4989/*********************************************************************
4990 * strtol (CRTDLL.477)
4991 */
4992long int CDECL CRTDLL_strtol( const char *nptr, char **endptr, int base )
4993{
4994 dprintf2(("CRTDLL: strtol\n"));
4995 return strtol(nptr, endptr, base);
4996}
4997
4998
4999/*********************************************************************
5000 * strtoul (CRTDLL.478)
5001 */
5002unsigned long CDECL CRTDLL_strtoul( const char *nptr, char **endptr, int base )
5003{
5004 dprintf2(("CRTDLL: strtoul\n"));
5005 return strtoul(nptr, endptr, base);
5006}
5007
5008
5009/*********************************************************************
5010 * strxfrm (CRTDLL.479)
5011 */
5012size_t CDECL CRTDLL_strxfrm( char *s1, const char *s2, size_t n )
5013{
5014 dprintf2(("CRTDLL: strxfrm\n"));
5015 return strxfrm(s1, s2, n);
5016}
5017
5018
5019/*********************************************************************
5020 * swscanf (CRTDLL.481)
5021 */
5022int CDECL CRTDLL_swscanf( const wchar_t *s1, const wchar_t *s2, ... )
5023{
5024 dprintf(("CRTDLL: swscanf not implemented.\n"));
5025 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
5026 return FALSE;
5027}
5028
5029
5030/*********************************************************************
5031 * system (CRTDLL.482)
5032 */
5033int CDECL CRTDLL_system( const char *string )
5034{
5035 dprintf2(("CRTDLL: system\n"));
5036 return system(string);
5037}
5038
5039
5040/*********************************************************************
5041 * tanh (CRTDLL.485)
5042 */
5043double CDECL CRTDLL_tanh( double x )
5044{
5045 dprintf2(("CRTDLL: tanh\n"));
5046 return tanh(x);
5047}
5048
5049
5050/*********************************************************************
5051 * time (CRTDLL.485)
5052 */
5053time_t CDECL CRTDLL_time( time_t *timer )
5054{
5055 dprintf2(("CRTDLL: time\n"));
5056
5057 return time(timer);
5058}
5059
5060
5061/*********************************************************************
5062 * tmpfile (CRTDLL.486)
5063 */
5064FILE * CDECL CRTDLL_tmpfile( void )
5065{
5066 dprintf2(("CRTDLL: tmpfile\n"));
5067 return (tmpfile());
5068}
5069
5070
5071/*********************************************************************
5072 * tmpnam (CRTDLL.487)
5073 */
5074char * CDECL CRTDLL_tmpnam( char *s )
5075{
5076 dprintf2(("CRTDLL: tmpnam\n"));
5077 return (tmpnam(s));
5078}
5079
5080
5081/*********************************************************************
5082 * ungetc (CRTDLL.492)
5083 */
5084INT CDECL CRTDLL_ungetc(int c, FILE *f)
5085{
5086 dprintf(("CRTDLL: ungetc not implemented.\n"));
5087 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
5088 return FALSE;
5089}
5090
5091
5092/*********************************************************************
5093 * ungetwc (CRTDLL.493)
5094 */
5095wint_t CDECL CRTDLL_ungetwc( wint_t wc, FILE *strm )
5096{
5097 dprintf2(("CRTDLL: ungetwc\n"));
5098 return (ungetwc(wc, strm));
5099}
5100
5101/*********************************************************************
5102 * vfprintf (CRTDLL.494)
5103 */
5104INT CDECL CRTDLL_vfprintf( CRTDLL_FILE *file, LPSTR format, va_list args )
5105{
5106 dprintf2(("CRTDLL: vprintf\n"));
5107 char buffer[2048]; /* FIXME... */
5108 vsprintf( buffer, format, args );
5109 return CRTDLL_fwrite( buffer, 1, strlen(buffer), file );
5110}
5111
5112
5113/*********************************************************************
5114 * vfwprintf (CRTDLL.495)
5115 */
5116int CDECL CRTDLL_vfwprintf( FILE *F, const wchar_t *s, va_list arg )
5117{
5118 dprintf(("CRTDLL: vfwprintf not implemented.\n"));
5119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
5120 return FALSE;
5121}
5122
5123
5124/*********************************************************************
5125 * vprintf (CRTDLL.496)
5126 */
5127int CDECL CRTDLL_vprintf( const char *format, __va_list arg )
5128{
5129 dprintf2(("CRTDLL: vprintf\n"));
5130 return (vprintf(format, arg));
5131}
5132
5133
5134/*********************************************************************
5135 * vswprintf (CRTDLL.498)
5136 */
5137int CDECL CRTDLL_vswprintf( wchar_t *s , size_t t, const wchar_t *format, va_list arg )
5138{
5139 dprintf2(("CRTDLL: vswprintf\n"));
5140 return (vswprintf(s, t, format, arg));
5141}
5142
5143
5144/*********************************************************************
5145 * vwprintf (CRTDLL.499)
5146 */
5147int CDECL CRTDLL_vwprintf( const wchar_t *s, va_list arg)
5148{
5149 dprintf(("CRTDLL: vwprintf not implemented.\n"));
5150 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
5151 return FALSE;
5152}
5153
5154
5155/*********************************************************************
5156 * wcscoll (CRTDLL.503)
5157 */
5158DWORD CDECL CRTDLL_wcscoll(LPCWSTR str1, LPCWSTR str2)
5159{
5160 dprintf2(("CRTDLL: wcscoll\n"));
5161 return (wcscoll((const wchar_t*)str1, (const wchar_t*)str2));
5162}
5163
5164
5165/*********************************************************************
5166 * wcsftime (CRTDLL.506)
5167 */
5168size_t CDECL CRTDLL_wcsftime( wchar_t *s, size_t maxsize,
5169 const wchar_t *format, const struct tm *timeptr )
5170{
5171 dprintf2(("CRTDLL: wcsftime\n"));
5172 return (wcsftime(s, maxsize, format, timeptr));
5173}
5174
5175
5176/*********************************************************************
5177 * wcstod (CRTDLL.515)
5178 */
5179double CDECL CRTDLL_wcstod( const wchar_t *nptr, wchar_t **endptr )
5180{
5181 dprintf2(("CRTDLL: wcstod\n"));
5182 return (wcstod(nptr, endptr));
5183}
5184
5185
5186/*********************************************************************
5187 * wcsxfrm (CRTDLL.520)
5188 */
5189size_t CDECL CRTDLL_wcsxfrm( wchar_t *s1, const wchar_t *s2, size_t n )
5190{
5191 dprintf2(("CRTDLL: wcsxfrm\n"));
5192 return (wcsxfrm(s1, s2, n));
5193}
5194
5195
5196/*********************************************************************
5197 * wctomb (CRTDLL.521)
5198 */
5199int CDECL CRTDLL_wctomb( LPSTR dst, WCHAR ch )
5200{
5201 dprintf2(("CRTDLL: wctomb\n"));
5202 return (wctomb((char*)dst,ch));
5203}
5204
5205
5206/*********************************************************************
5207 * wprintf (CRTDLL.522)
5208 */
5209int CDECL CRTDLL_wprintf( const wchar_t *s, ... )
5210{
5211 dprintf(("CRTDLL: wprintf not implemented.\n"));
5212 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
5213 return FALSE;
5214}
5215
5216
5217/*********************************************************************
5218 * wscanf (CRTDLL.523)
5219 */
5220int CDECL CRTDLL_wscanf( const wchar_t *s, ... )
5221{
5222 dprintf(("CRTDLL: wscanf not implemented.\n"));
5223 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
5224 return FALSE;
5225}
5226
5227
5228
5229/*********************************************************************
5230 * __set_errno (INTERNAL-#1)
5231 */
5232int __set_errno (int error)
5233{
5234 errno = error;
5235 return error;
5236}
5237
5238
5239/*********************************************************************
5240 * _mbbtoupper (INTERNAL-#2)
5241 */
5242unsigned int _mbbtoupper(unsigned int c)
5243{
5244 if (!CRTDLL__ismbblead(c) )
5245 return toupper(c);
5246
5247 return c;
5248}
5249
5250
5251/*********************************************************************
5252 * _mbbtolower (INTERNAL-#3)
5253 */
5254unsigned int _mbbtolower(unsigned int c)
5255{
5256 if (!CRTDLL__ismbblead(c) )
5257 return tolower(c);
5258 return c;
5259}
5260
5261
5262/*********************************************************************
5263 * _mbclen2 (INTERNAL-#4)
5264 */
5265size_t _mbclen2(const unsigned int s)
5266{
5267 return (CRTDLL__ismbblead(s>>8) && CRTDLL__ismbbtrail(s&0x00FF)) ? 2 : 1;
5268}
5269
5270
5271/*********************************************************************
5272 * _isinf (INTERNAL-#5)
5273 */
5274int _isinf(double __x)
5275{
5276 double_t * x = (double_t *)&__x;
5277 return ( x->exponent == 0x7ff && ( x->mantissah == 0 && x->mantissal == 0 ));
5278}
5279
5280
5281/*********************************************************************
5282 * _filehnd (INTERNAL-#6)
5283 */
5284void* filehnd(int fileno)
5285{
5286 if ( fileno < 0 )
5287 return (void *)-1;
5288#define STD_AUX_HANDLE 3
5289#define STD_PRINTER_HANDLE 4
5290
5291 switch(fileno)
5292 {
5293 case 0:
5294 return (void*)GetStdHandle(STD_INPUT_HANDLE);
5295 case 1:
5296 return (void*)GetStdHandle(STD_OUTPUT_HANDLE);
5297 case 2:
5298 return (void*)GetStdHandle(STD_ERROR_HANDLE);
5299 case 3:
5300 return (void*)GetStdHandle(STD_AUX_HANDLE);
5301 case 4:
5302 return (void*)GetStdHandle(STD_PRINTER_HANDLE);
5303 default:
5304 break;
5305 }
5306
5307 if ( fileno >= maxfno )
5308 return (void *)-1;
5309
5310 if ( fileno_modes[fileno].fd == -1 )
5311 return (void *)-1;
5312 return (void*)fileno_modes[fileno].hFile;
5313}
Note: See TracBrowser for help on using the repository browser.