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

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

Jens Weissner's changes

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