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

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

JW: Removed the ERRNO Defs from CRTINC.H and included ERRNO.H

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