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

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

JW's GetMainArgs fix

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