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

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

JW's update

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