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

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

all crt functions moved to crtdll

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