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

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

compilation fixes

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