- Timestamp:
- Feb 3, 2000, 10:37:50 PM (26 years ago)
- Location:
- trunk/src/crtdll
- Files:
-
- 7 added
- 4 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/crtdll/crtdll.cpp
r2372 r2618 1 /* $Id: crtdll.cpp,v 1.2 1 2000-01-08 14:24:04sandervl Exp $ */1 /* $Id: crtdll.cpp,v 1.22 2000-02-03 21:37:48 sandervl Exp $ */ 2 2 3 3 /* … … 8 8 * TODO: Check setjmp(3) 9 9 * 10 * Partialy based on Wine and ReactOS10 * Partialy based on Wine 11 11 * 12 12 * Copyright 1996,1998 Marcus Meissner 13 13 * Copyright 1996 Jukka Iivonen 14 14 * Copyright 1997 Uwe Bonnes 15 * Copyright 1999 Jens Wiessner15 * Copyright 1999-2000 Jens Wiessner 16 16 */ 17 17 … … 29 29 #include <debugtools.h> 30 30 31 #include <wchar.h>32 #include <wctype.h>33 31 #include <math.h> 34 32 #include <libc\locale.h> … … 48 46 #include <sys\utime.h> 49 47 #include <sys\stat.h> 48 #include "signal.h" 50 49 51 50 #include <crtdll.h> 51 // #include <ieee.h> 52 #include <asmhlp.h> 52 53 #include "crtinc.h" 53 #include "ieee.h" 54 54 55 55 56 DEFAULT_DEBUG_CHANNEL(crtdll) 56 57 57 //SvL: per process heap for CRTDLL58 HANDLE CRTDLL_hHeap = 0;59 60 58 61 59 /********************************************************************* … … 65 63 { 66 64 if (fdwReason == DLL_PROCESS_ATTACH) { 67 CRTDLL__fdopen(0,"r");68 CRTDLL__fdopen(1,"w");69 CRTDLL__fdopen(2,"w");65 _fdopen(0,"r"); 66 _fdopen(1,"w"); 67 _fdopen(2,"w"); 70 68 CRTDLL_hHeap = HeapCreate(0, 0x10000, 0); 71 69 } … … 113 111 } 114 112 113 114 /********************************************************************* 115 * _CIacos (CRTDLL.004) 116 */ 117 double CDECL CRTDLL__CIacos() 118 { 119 double x; 120 dprintf2(("CRTDLL: _CIacos\n")); 121 POP_FPU(x); 122 return acos(x); 123 } 124 125 126 /********************************************************************* 127 * _CIasin (CRTDLL.005) 128 */ 129 double CDECL CRTDLL__CIasin() 130 { 131 double x; 132 dprintf2(("CRTDLL: _CIasin\n")); 133 POP_FPU(x); 134 return asin(x); 135 } 136 137 138 /********************************************************************* 139 * _CIatan (CRTDLL.006) 140 */ 141 double CDECL CRTDLL__CIatan() 142 { 143 double x; 144 dprintf2(("CRTDLL: _CIatan\n")); 145 POP_FPU(x); 146 return atan(x); 147 } 148 149 150 /********************************************************************* 151 * _CIatan2 (CRTDLL.007) 152 */ 153 double CDECL CRTDLL__CIatan2() 154 { 155 double x, y; 156 dprintf2(("CRTDLL: _CIatan2\n")); 157 POP_FPU(y); 158 POP_FPU(x); 159 return atan2(x,y); 160 } 161 162 163 /********************************************************************* 164 * _CIcos (CRTDLL.008) 165 */ 166 double CDECL CRTDLL__CIcos() 167 { 168 double x; 169 dprintf2(("CRTDLL: _CIcos\n")); 170 POP_FPU(x); 171 return cos(x); 172 } 173 174 175 /********************************************************************* 176 * _CIcosh (CRTDLL.009) 177 */ 178 double CDECL CRTDLL__CIcosh() 179 { 180 double x; 181 dprintf2(("CRTDLL: _CIcosh\n")); 182 POP_FPU(x); 183 return cosh(x); 184 } 185 186 187 /********************************************************************* 188 * _CIexp (CRTDLL.010) 189 */ 190 double CDECL CRTDLL__CIexp() 191 { 192 double x; 193 dprintf2(("CRTDLL: _CIexp\n")); 194 POP_FPU(x); 195 return exp(x); 196 } 197 198 199 /********************************************************************* 200 * _CIfmod (CRTDLL.011) 201 */ 202 double CDECL CRTDLL__CIfmod( ) 203 { 204 double x, y; 205 dprintf2(("CRTDLL: _CIfmod\n")); 206 POP_FPU(y); 207 POP_FPU(x); 208 return fmod(x,y); 209 } 210 211 212 /********************************************************************* 213 * _CIlog (CRTDLL.012) 214 */ 215 double CDECL CRTDLL__CIlog() 216 { 217 double x; 218 dprintf2(("CRTDLL: _CIlog\n")); 219 POP_FPU(x); 220 return log(x); 221 } 222 223 224 /********************************************************************* 225 * _CIlog10 (CRTDLL.013) 226 */ 227 double CDECL CRTDLL__CIlog10() 228 { 229 double x; 230 dprintf2(("CRTDLL: _CIlog10\n")); 231 POP_FPU(x); 232 return log10(x); 233 } 234 235 236 /********************************************************************* 237 * _CIpow (CRTDLL.014) 238 */ 239 LONG CDECL CRTDLL__CIpow() 240 { 241 double x,y; 242 dprintf2(("CRTDLL: _CIpow\n")); 243 POP_FPU(y); 244 POP_FPU(x); 245 return pow(x,y); 246 } 247 248 249 250 251 /********************************************************************* 252 * _CIsin (CRTDLL.015) 253 */ 254 double CDECL CRTDLL__CIsin() 255 { 256 double x; 257 dprintf2(("CRTDLL: _CIsin\n")); 258 POP_FPU(x); 259 return sin(x); 260 } 261 262 263 /********************************************************************* 264 * _CIsinh (CRTDLL.016) 265 */ 266 double CDECL CRTDLL__CIsinh() 267 { 268 double x; 269 dprintf2(("CRTDLL: _CIsinh\n")); 270 POP_FPU(x); 271 return sinh(x); 272 } 273 274 275 /********************************************************************* 276 * _CIsqrt (CRTDLL.017) 277 */ 278 double CDECL CRTDLL__CIsqrt() 279 { 280 double x; 281 dprintf2(("CRTDLL: _CIsqrt\n")); 282 POP_FPU(x); 283 return sqrt(x); 284 } 285 286 287 /********************************************************************* 288 * _CItan (CRTDLL.018) 289 */ 290 double CDECL CRTDLL__CItan() 291 { 292 double x; 293 dprintf2(("CRTDLL: _CItan\n")); 294 POP_FPU(x); 295 return tan(x); 296 } 297 298 299 /********************************************************************* 300 * _CItanh (CRTDLL.019) 301 */ 302 double CDECL CRTDLL__CItanh() 303 { 304 double x; 305 dprintf2(("CRTDLL: _CItanh\n")); 306 POP_FPU(x); 307 return tanh(x); 308 } 309 310 115 311 /********************************************************************* 116 312 * _XcptFilter (CRTDLL.21) … … 121 317 return UnhandledExceptionFilter(ExceptionInfo); 122 318 } 319 123 320 124 321 /********************************************************************* … … 189 386 190 387 /********************************************************************* 191 * __dllonexit (CRTDLL.25)192 */193 VOID CDECL CRTDLL___dllonexit ()194 {195 dprintf(("__dllonexit not implemented.\n"));196 }197 198 199 /*********************************************************************200 388 * __doserrno (CRTDLL.26) 201 389 */ 202 390 int * CDECL CRTDLL___doserrno() 203 391 { 204 dprintf2(("__doserrno\n")); 205 _doserrno = GetLastError(); 206 return &_doserrno; 207 } 208 209 210 /********************************************************************* 211 * __fpecode (CRTDLL.27) 212 */ 213 int fpecode = 0; 214 215 int * CDECL CRTDLL___fpecode ( void ) 216 { 217 dprintf2(("__fpecode\n")); 218 return &fpecode; 392 dprintf2(("CRTDLL: __doserrno\n")); 393 return (__doserrno()); 219 394 } 220 395 … … 225 400 int CDECL CRTDLL___isascii(int i) 226 401 { 227 dprintf2(("CRTDLL: __isascii\n")); 228 return (!((i)&(~0x7f))); 402 //TODO: Check if really ok. 403 dprintf(("CRTDLL: __isascii -> _isascii\n")); 404 return (_isascii(i)); 229 405 } 230 406 … … 235 411 int CDECL CRTDLL___iscsym(int c) 236 412 { 237 dprintf2(("CRTDLL: __iscsym\n")); 238 return (CRTDLL_isalnum(c) || ( c == '_' )) ; 413 //TODO: Check if really ok. 414 dprintf(("CRTDLL: __iscsym -> _iscsym\n")); 415 return (_iscsym(c)); 239 416 } 240 417 … … 245 422 int CDECL CRTDLL___iscsymf(int c) 246 423 { 247 dprintf2(("CRTDLL: __iscsymf\n")); 248 return (isalpha(c) || ( c == '_' )) ; 249 } 250 251 252 /********************************************************************* 253 * CRTDLL___pxcptinfoptrs (CRTDLL.32) 254 */ 255 void ** CDECL CRTDLL___pxcptinfoptrs (void) 256 { 257 dprintf(("CRTDLL: __pxcptinfoptrs not implemented.\n")); 258 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 259 return NULL; 424 //TODO: Check if really ok. 425 dprintf(("CRTDLL: __iscsymf -> _iscsymf\n")); 426 return (_iscsymf(c)); 260 427 } 261 428 … … 282 449 283 450 /********************************************************************* 284 * CRTDLL__abnormal_termination (CRTDLL.36)285 */286 int CDECL CRTDLL__abnormal_termination(void)287 {288 dprintf(("CRTDLL: _abnormal_termination not implemented.\n"));289 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);290 return FALSE;291 }292 293 294 /*********************************************************************295 451 * CRTDLL__access (CRTDLL.37) 296 452 */ … … 307 463 int CDECL CRTDLL___toascii(int c) 308 464 { 309 dprintf2(("CRTDLL: __toascii\n")); 310 return ((unsigned)(c) & 0x7F ); 465 //TODO: Check if really ok. 466 dprintf(("CRTDLL: __toascii -> _toascii\n")); 467 return (_toascii(c)); 311 468 } 312 469 … … 348 505 void CDECL CRTDLL__beep(unsigned nFreq, unsigned nDur) 349 506 { 350 dprintf2(("_beep\n")); 351 Beep(nFreq,nDur); 352 } 353 354 355 /********************************************************************* 356 * CRTDLL__beginthread (CRTDLL.46) 357 */ 358 unsigned long CDECL CRTDLL__beginthread(void (*pfuncStart)(void *), 359 unsigned unStackSize, void* pArgList) 360 { 361 DWORD ThreadId; 362 HANDLE hThread; 363 if ( pfuncStart == NULL ) 364 __set_errno(EINVAL); 365 366 hThread = CreateThread( NULL,unStackSize,(LPTHREAD_START_ROUTINE)pfuncStart,pArgList,0, &ThreadId); 367 if (hThread == NULL ) { 368 __set_errno(EAGAIN); 369 return -1; 370 } 371 return (unsigned long)hThread; 507 dprintf2(("_beep\n")); 508 Beep(nFreq,nDur); 509 } 510 511 512 /********************************************************************* 513 * _beginthread (CRTDLL.46) 514 */ 515 int CDECL CRTDLL__beginthread (void (*start)(void *arg), void *stack, unsigned stack_size, 516 void *arg_list) 517 { 518 dprintf(("CRTDLL: _beginthread\n")); 519 /* 520 ULONG rc; 521 TID tid; 522 struct _thread *tp; 523 tp = __alloc_thread (); 524 if (tp == NULL) 525 { 526 errno = ENOMEM; 527 return -1; 528 } 529 tp->_th_start = start; 530 tp->_th_arg = arg_list; 531 rc = DosCreateThread (&tid, (PFNTHREAD)start_thread, (ULONG)tp, 532 3, stack_size); 533 if (rc != 0) 534 { 535 if (rc == ERROR_NOT_ENOUGH_MEMORY) 536 errno = ENOMEM; 537 else if (rc == ERROR_MAX_THRDS_REACHED) 538 errno = EAGAIN; 539 else 540 errno = EINVAL; 541 DosFreeMem (tp); 542 return -1; 543 } 544 if (tid > MAX_THREADS) 545 { 546 DosKillThread (tid); 547 errno = EAGAIN; 548 DosFreeMem (tp); 549 return -1; 550 } 551 if (__newthread (tid) != 0) 552 { 553 DosKillThread (tid); 554 DosFreeMem (tp); 555 return -1; 556 } 557 _thread_tab[tid] = tp; 558 rc = DosResumeThread (tid); 559 if (rc != 0) 560 { 561 errno = ESRCH; 562 DosFreeMem (tp); 563 return -1; 564 } 565 return tid; 566 */ 567 return 0; 372 568 } 373 569 … … 385 581 386 582 /********************************************************************* 387 * CRTDLL__cabs (CRTDLL.48)388 */ 389 double CDECL CRTDLL__cabs(struct _complex z)583 * _cabs (CRTDLL.48) 584 */ 585 double CDECL CRTDLL__cabs(struct complex z) 390 586 { 391 587 dprintf2(("CRTDLL: _cabs\n")); 392 return sqrt( z.x*z.x + z.y*z.y);588 return (_cabs(z)); 393 589 } 394 590 … … 399 595 void CDECL CRTDLL__cexit(INT ret) 400 596 { 401 402 597 dprintf2(("_cexit(%d)\n",ret)); 598 ExitProcess(ret); 403 599 } 404 600 … … 419 615 INT CDECL CRTDLL__chdir(LPCSTR newdir) 420 616 { 421 dprintf2(("CRTDLL: chdir\n"));617 dprintf2(("CRTDLL: _chdir\n")); 422 618 if (!SetCurrentDirectoryA(newdir)) 423 619 return 1; … … 441 637 442 638 /********************************************************************* 443 * CRTDLL__chgsign (CRTDLL.53)444 */445 double CDECL CRTDLL__chgsign(double __x)446 {447 dprintf2(("CRTDLL: _chgsign\n"));448 double_t *x = (double_t *)&x;449 if ( x->sign == 1 )450 x->sign = 0;451 else452 x->sign = 1;453 454 return __x;455 }456 457 458 /*********************************************************************459 639 * CRTDLL__chmod (CRTDLL.54) 460 640 */ … … 497 677 498 678 /********************************************************************* 499 * CRTDLL__commit (CRTDLL.58)500 */501 int CDECL CRTDLL__commit( int _fd )502 {503 dprintf2(("CRTDLL: _commit\n"));504 if (! FlushFileBuffers((HFILE)CRTDLL__get_osfhandle(_fd)) ) {505 __set_errno(EBADF);506 return -1;507 }508 return 0;509 }510 511 512 /*********************************************************************513 679 * CRTDLL__control87 (CRTDLL.60) 514 680 */ … … 531 697 532 698 /********************************************************************* 533 * CRTDLL__copysign (CRTDLL.62)534 */535 double CDECL CRTDLL__copysign( double __d, double __s )536 {537 dprintf2(("CRTDLL: _copysign\n"));538 double_t *d = (double_t *)&__d;539 double_t *s = (double_t *)&__s;540 541 d->sign = s->sign;542 543 return __d;544 }545 546 547 /*********************************************************************548 699 * _cprintf (CRTDLL.63) 549 700 */ 550 INT CDECL CRTDLL__cprintf( char *fmt, ...)701 INT CDECL CRTDLL__cprintf( char *fmt, va_list arg ) 551 702 { 552 703 dprintf2(("CRTDLL: _cprintf.\n")); 553 554 int cnt; 555 char buf[ 2048 ]; /* this is buggy, because buffer might be too small. */ 556 va_list ap; 557 558 va_start(ap, fmt); 559 cnt = vsprintf(buf, fmt, ap); 560 va_end(ap); 561 562 _cputs(buf); 563 return cnt; 704 return (_cprintf(fmt, arg)); 564 705 } 565 706 … … 586 727 587 728 /********************************************************************* 588 * CRTDLL__cscanf (CRTDLL.67) 589 */ 590 INT CDECL CRTDLL__cscanf( char *s, ... ) 591 { 592 dprintf(("CRTDLL: _cscanf not implemented.\n")); 593 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 594 return FALSE; 729 * _cscanf (CRTDLL.67) 730 */ 731 INT CDECL CRTDLL__cscanf( char *s, va_list arg ) 732 { 733 dprintf(("CRTDLL: _cscanf\n")); 734 return (_cscanf(s, arg)); 595 735 } 596 736 … … 647 787 648 788 /********************************************************************* 649 * CRTDLL___eof (CRTDLL.76)789 * _eof (CRTDLL.76) 650 790 */ 651 791 int CDECL CRTDLL__eof( int _fd ) 652 792 { 653 793 dprintf2(("CRTDLL: _eof\n")); 654 int cur_pos = CRTDLL__lseek(_fd, 0, SEEK_CUR); 655 int end_pos = CRTDLL__filelength( _fd ); 656 if ( cur_pos == -1 || end_pos == -1) 657 return -1; 658 659 if ( cur_pos == end_pos ) 660 return 1; 661 662 return 0; 794 return (__eof(_fd)); 663 795 } 664 796 … … 681 813 PEXCEPTION_FRAME *dispatcher) 682 814 { 683 dprintf2(("CRTDLL: _except_handler2\n")); 684 return 1; 815 dprintf (("exception %lx flags=%lx at %p handler=%p %p %p stub\n", 816 rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress, 817 frame->Handler, context, dispatcher)); 818 return ExceptionContinueSearch; 685 819 } 686 820 … … 689 823 * _execl (CRTDLL.79) 690 824 */ 691 int CDECL CRTDLL__execl(c onst char* szPath, const char* szArgv0, ...)825 int CDECL CRTDLL__execl(char* szPath, char* szArgv0, va_list arg) 692 826 { 693 827 dprintf2(("CRTDLL: _execl\n")); 694 695 char *szArg[100]; 696 const char *a; 697 int i = 0; 698 va_list l = 0; 699 va_start(l,szArgv0); 700 do { 701 a = va_arg(l,const char *); 702 szArg[i++] = (char *)a; 703 } while ( a != NULL && i < 100 ); 704 705 return _spawnve(P_OVERLAY, (char*)szPath, szArg, _environ); 706 } 707 708 709 /********************************************************************* 710 * CRTDLL__execle (CRTDLL.80) 711 */ 712 int CDECL CRTDLL__execle(char *path, char *szArgv0, ...) 713 { 714 dprintf2(("CRTDLL: _execle not correct implemented.\n")); 715 char *szArg[100]; 716 const char *a; 717 char *ptr; 718 int i = 0; 719 va_list l = 0; 720 va_start(l,szArgv0); 721 do { 722 a = (const char *)va_arg(l,const char *); 723 szArg[i++] = (char *)a; 724 } while ( a != NULL && i < 100 ); 725 726 727 // szArg0 is passed and not environment if there is only one parameter; 728 729 if ( i >=2 ) { 730 ptr = szArg[i-2]; 731 szArg[i-2] = NULL; 732 } 733 else 734 ptr = NULL; 735 736 return _spawnve(P_OVERLAY, path, szArg, (char**)ptr); 828 return (_execl(szPath, szArgv0, arg)); 829 } 830 831 832 /********************************************************************* 833 * _execle (CRTDLL.80) 834 */ 835 int CDECL CRTDLL__execle(char *path, char *szArgv0, va_list arg) 836 { 837 dprintf2(("CRTDLL: _execle\n")); 838 return (_execle(path, szArgv0, arg)); 737 839 } 738 840 … … 741 843 * CRTDLL__execlp (CRTDLL.81) 742 844 */ 743 int CDECL CRTDLL__execlp( char *szPath, char *szArgv0, ...)845 int CDECL CRTDLL__execlp( char *szPath, char *szArgv0, va_list arg) 744 846 { 745 847 dprintf2(("CRTDLL: _execlp\n")); 746 char *szArg[100]; 747 const char *a; 748 int i = 0; 749 va_list l = 0; 750 va_start(l,szArgv0); 751 do { 752 a = (const char *)va_arg(l,const char *); 753 szArg[i++] = (char *)a; 754 } while ( a != NULL && i < 100 ); 755 return _spawnvpe(P_OVERLAY, szPath,szArg, _environ); 848 return (_execlp(szPath, szArgv0, arg)); 756 849 } 757 850 … … 760 853 * CRTDLL__execlpe (CRTDLL.82) 761 854 */ 762 int CDECL CRTDLL__execlpe( char *path, char *szArgv0, ...) 763 { 764 dprintf2(("CRTDLL: _execlpe not correct implemented.\n")); 765 char *szArg[100]; 766 const char *a; 767 char *ptr; 768 int i = 0; 769 va_list l = 0; 770 va_start(l,szArgv0); 771 do { 772 a = (const char *)va_arg(l,const char *); 773 szArg[i++] = (char *)a; 774 } while ( a != NULL && i < 100 ); 775 776 777 // szArg0 is passed and not environment if there is only one parameter; 778 779 if ( i >=2 ) { 780 ptr = szArg[i-2]; 781 szArg[i-2] = NULL; 782 } 783 else 784 ptr = NULL; 785 return spawnvpe(P_OVERLAY, path, szArg, (char**)ptr); 855 int CDECL CRTDLL__execlpe( char *path, char *szArgv0, va_list arg) 856 { 857 dprintf2(("CRTDLL: _execlpe\n")); 858 return (_execlpe(path, szArgv0, arg)); 786 859 } 787 860 … … 838 911 839 912 /********************************************************************* 840 * _expand (CRTDLL.88)841 */842 void * CDECL CRTDLL__expand( void *ptr, size_t size )843 {844 dprintf(("CRTDLL: _expand not implemented.\n"));845 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);846 return FALSE;847 }848 849 850 /*********************************************************************851 913 * _fcloseall (CRTDLL.89) 852 914 */ … … 871 933 * _fdopen (CRTDLL.91) 872 934 */ 873 CRTDLL_FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode) 874 { 875 dprintf2(("CRTDLL: fdopen\n")); 876 CRTDLL_FILE *file; 877 878 switch (handle) 879 { 880 case 0: 881 file = CRTDLL_stdin; 882 if (!file->handle) file->handle = GetStdHandle( STD_INPUT_HANDLE ); 883 break; 884 case 1: 885 file = CRTDLL_stdout; 886 if (!file->handle) file->handle = GetStdHandle( STD_OUTPUT_HANDLE ); 887 break; 888 case 2: 889 file=CRTDLL_stderr; 890 if (!file->handle) file->handle = GetStdHandle( STD_ERROR_HANDLE ); 891 break; 892 default: 893 file = (PCRTDLL_FILE)Heap_Alloc(sizeof(*file) ); 894 file->handle = handle; 895 break; 896 } 897 return file; 935 FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode) 936 { 937 dprintf2(("CRTDLL: _fdopen\n")); 938 return (_fdopen(handle, mode)); 898 939 } 899 940 … … 910 951 911 952 /********************************************************************* 912 * _fgetwchar (CRTDLL.93)913 */914 wint_t CDECL CRTDLL__fgetwchar( void *i )915 {916 dprintf2(("CRTDLL: _fgetwchar\n"));917 return CRTDLL__getch();918 }919 920 921 /*********************************************************************922 * _filbuf (CRTDLL.94)923 */924 int CDECL CRTDLL__filbuf(FILE * f)925 {926 dprintf(("CRTDLL: _filbuf not implemented.\n"));927 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);928 return FALSE;929 }930 931 932 /*********************************************************************933 953 * CRTDLL__filelength (CRTDLL.96) 934 954 */ … … 951 971 952 972 /********************************************************************* 953 * _findclose (CRTDLL.098)954 */955 int CDECL CRTDLL__findclose( long handle )956 {957 dprintf2(("CRTDLL: _findclose\n"));958 // check no wildcards or invalid handle959 if ( handle == 0 || handle == -1)960 return 0;961 return FindClose(handle);962 }963 964 965 /*********************************************************************966 * _findfirst (CRTDLL.099)967 */968 DWORD CDECL CRTDLL__findfirst(LPCSTR fname, struct find_t * x2)969 {970 dprintf(("CRTDLL: _findfirst not implemented.\n"));971 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);972 return FALSE;973 }974 975 976 /*********************************************************************977 * _findnext (CRTDLL.100)978 */979 INT CDECL CRTDLL__findnext(DWORD hand, struct find_t * x2)980 {981 dprintf(("CRTDLL: _findnext not implemented.\n"));982 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);983 return FALSE;984 }985 986 987 /*********************************************************************988 * _finite (CRTDLL.101)989 */990 INT CDECL CRTDLL__finite(double x)991 {992 dprintf2(("CRTDLL: _finite\n"));993 return !_isinf(x);994 }995 996 997 /*********************************************************************998 * _flsbuf (CRTDLL.102)999 */1000 INT CDECL CRTDLL__flsbuf(int i, FILE * f)1001 {1002 dprintf(("CRTDLL: _flsbuf not implemented.\n"));1003 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1004 return FALSE;1005 }1006 1007 1008 /*********************************************************************1009 973 * _flushall (CRTDLL.103) 1010 974 */ … … 1017 981 1018 982 /********************************************************************* 1019 * _fpclass (CRTDLL.105)1020 */1021 INT CDECL CRTDLL__fpclass( double __d )1022 {1023 dprintf2(("CRTDLL: _fpclass\n"));1024 double_t *d = (double_t *)&__d;1025 1026 if ( d->exponent == 0 ) {1027 if ( d->mantissah == 0 && d->mantissal == 0 ) {1028 if ( d->sign ==0 )1029 return FP_NZERO;1030 else1031 return FP_PZERO;1032 } else {1033 if ( d->sign ==0 )1034 return FP_NDENORM;1035 else1036 return FP_PDENORM;1037 }1038 }1039 if (d->exponent == 0x7ff ) {1040 if ( d->mantissah == 0 && d->mantissal == 0 ) {1041 if ( d->sign ==0 )1042 return FP_NINF;1043 else1044 return FP_PINF;1045 }1046 else if ( d->mantissah == 0 && d->mantissal != 0 ) {1047 return FP_QNAN;1048 }1049 else if ( d->mantissah == 0 && d->mantissal != 0 ) {1050 return FP_SNAN;1051 }1052 1053 }1054 1055 return 0;1056 }1057 1058 1059 /*********************************************************************1060 * _fpieee_flt (CRTDLL.106)1061 */1062 INT CDECL CRTDLL__fpieee_flt( unsigned long exc_code, struct _EXCEPTION_POINTERS *exc_info, int handler)1063 {1064 dprintf(("CRTDLL: _fpieee_flt not implemented.\n"));1065 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1066 return 0;1067 }1068 1069 1070 1071 /*********************************************************************1072 * _fpreset (CRTDLL.107)1073 */1074 void CDECL CRTDLL__fpreset(void)1075 {1076 dprintf(("CRTDLL: _fpreset not implemented.\n"));1077 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1078 }1079 1080 1081 /*********************************************************************1082 983 * _fputchar (CRTDLL.108) 1083 984 */ … … 1090 991 1091 992 /********************************************************************* 1092 * _fputwchar (CRTDLL.109) 1093 */ 1094 wint_t CDECL CRTDLL__fputwchar( wint_t ) 1095 { 1096 dprintf(("CRTDLL: _fputwchar not implemented.\n")); 1097 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1098 return FALSE; 1099 } 1100 1101 1102 /********************************************************************* 1103 * _fsopen (CRTDLL.110) 1104 */ 1105 FILE * CDECL CRTDLL__fsopen( const char *file, const char *mode, int shflag ) 1106 { 1107 dprintf(("CRTDLL: _fsopen not implemented.\n")); 1108 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1109 return FALSE; 1110 } 1111 1112 1113 /********************************************************************* 1114 * _fstat (CRTDLL.111) 1115 */ 1116 int CDECL CRTDLL__fstat(int file, struct stat* buf) 1117 { 1118 dprintf(("CRTDLL: _fstat not implemented.\n")); 1119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1120 return FALSE; 1121 } 1122 1123 1124 /********************************************************************* 1125 * _ftime (CRTDLL.112) 1126 */ 1127 int CDECL CRTDLL__ftime( struct timeb *timebuf ) 1128 { 1129 dprintf(("CRTDLL: _ftime not implemented.\n")); 1130 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1131 return FALSE; 993 * _ftol (CRTDLL.113) 994 */ 995 LONG CDECL CRTDLL__ftol(void) 996 { 997 /* don't just do DO_FPU("fistp",retval), because the rounding 998 * mode must also be set to "round towards zero"... */ 999 double fl; 1000 POP_FPU(fl); 1001 return (LONG)fl; 1132 1002 } 1133 1003 … … 1144 1014 1145 1015 /********************************************************************* 1146 * _futime (CRTDLL.115)1147 */1148 int CDECL CRTDLL__futime( int handle, struct _utimbuf *filetime )1149 {1150 dprintf(("CRTDLL: _futime not implemented.\n"));1151 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1152 return FALSE;1153 }1154 1155 1156 /*********************************************************************1157 1016 * _gcvt (CRTDLL.116) 1158 1017 */ … … 1165 1024 1166 1025 /********************************************************************* 1167 * _get_osfhandle (CRTDLL.117)1168 */1169 void* CDECL CRTDLL__get_osfhandle( int fileno )1170 {1171 dprintf2(("CRTDLL: _get_osfhandle\n"));1172 return filehnd(fileno);1173 }1174 1175 1176 /*********************************************************************1177 1026 * _getch (CRTDLL.118) 1178 1027 */ … … 1215 1064 1216 1065 /********************************************************************* 1217 * _getdiskfree (CRTDLL.122)1218 */1219 unsigned int CDECL CRTDLL__getdiskfree( unsigned int drive, struct _diskfree_t *diskspace)1220 {1221 dprintf2(("CRTDLL: _getdiskfree\n"));1222 char RootPathName[10];1223 RootPathName[0] = toupper(drive +'@');1224 RootPathName[1] = ':';1225 RootPathName[2] = '\\';1226 RootPathName[3] = 0;1227 if ( diskspace == NULL )1228 return 0;1229 1230 if ( !GetDiskFreeSpaceA(RootPathName,(LPDWORD)&diskspace->sectors_per_cluster,(LPDWORD)&diskspace->bytes_per_sector,1231 (LPDWORD )&diskspace->avail_clusters,(LPDWORD )&diskspace->total_clusters ) )1232 return 0;1233 return diskspace->avail_clusters;1234 }1235 1236 1237 /*********************************************************************1238 * _getdllprocaddr (CRTDLL.123)1239 */1240 FARPROC CDECL CRTDLL__getdllprocaddr(HMODULE hModule,char * lpProcName, int iOrdinal)1241 {1242 dprintf2(("CRTDLL: _getdllprocaddr\n"));1243 if ( lpProcName != NULL )1244 return GetProcAddress(hModule, lpProcName);1245 else1246 return GetProcAddress(hModule, (LPSTR)iOrdinal);1247 return (NULL);1248 }1249 1250 1251 /*********************************************************************1252 1066 * _getdrive (CRTDLL.124) 1253 1067 */ … … 1280 1094 1281 1095 /********************************************************************* 1282 * _getsystime (CRTDLL.127)1283 */1284 unsigned int CDECL CRTDLL__getsystime(struct tm *tp)1285 {1286 dprintf(("CRTDLL: _getsystime not implemented.\n"));1287 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1288 return FALSE;1289 }1290 1291 1292 /*********************************************************************1293 1096 * _getw (CRTDLL.128) 1294 1097 */ … … 1296 1099 { 1297 1100 dprintf2(("CRTDLL: _getw\n")); 1298 int w; 1299 1300 /* Is there a better way? */ 1301 if (CRTDLL_fread( &w, sizeof(w), 1, stream) != 1) 1302 return(EOF); 1303 return(w); 1101 int x; 1102 return (fread (&x, sizeof (x), 1, stream) == 1 ? x : EOF); 1304 1103 } 1305 1104 … … 1310 1109 void CDECL CRTDLL__global_unwind2( PEXCEPTION_FRAME frame ) 1311 1110 { 1312 dprintf2(("CRTDLL: global_undwind2\n"));1111 dprintf2(("CRTDLL: _global_unwind2\n")); 1313 1112 RtlUnwind( frame, 0, NULL, 0 ); 1314 1113 } … … 1342 1141 dprintf2(("CRTDLL: _heapset\n")); 1343 1142 return (_heapset(fill)); 1344 }1345 1346 1347 /*********************************************************************1348 * _heapwalk (CRTDLL.133)1349 */1350 int CDECL CRTDLL__heapwalk( struct _heapinfo *entry )1351 {1352 dprintf(("CRTDLL: _heapwalk not implemented.\n"));1353 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1354 return 0;1355 1143 } 1356 1144 … … 1380 1168 } 1381 1169 return 0; 1382 }1383 1384 1385 /*********************************************************************1386 * _isatty (CRTDLL.137)1387 */1388 BOOL CDECL CRTDLL__isatty(DWORD x)1389 {1390 dprintf2(("(%ld)\n",x));1391 return TRUE;1392 1170 } 1393 1171 … … 1419 1197 1420 1198 /********************************************************************* 1421 * _ismbbalnum (CRTDLL.139) 1422 */ 1423 int CDECL CRTDLL__ismbbalnum( unsigned int c ) 1424 { 1425 dprintf2(("CRTDLL: _ismbbalnum\n")); 1426 return (CRTDLL_isalnum(c) || CRTDLL__ismbbkalnum(c)); 1427 } 1428 1429 1430 /********************************************************************* 1431 * _ismbbalpha (CRTDLL.140) 1432 */ 1433 int CDECL CRTDLL__ismbbalpha( unsigned int c ) 1434 { 1435 dprintf2(("CRTDLL: _ismbbalpha\n")); 1436 return (isalpha(c) || CRTDLL__ismbbkalnum(c)); 1437 } 1438 1439 1440 /********************************************************************* 1441 * _ismbbgraph (CRTDLL.141) 1442 */ 1443 int CDECL CRTDLL__ismbbgraph( unsigned int c ) 1444 { 1445 dprintf2(("CRTDLL: _ismbbgraph\n")); 1446 return (CRTDLL_isgraph(c) || CRTDLL__ismbbkana(c)); 1447 } 1448 1449 1450 /********************************************************************* 1451 * _ismbbkalnum (CRTDLL.142) 1452 */ 1453 int CDECL CRTDLL__ismbbkalnum( unsigned int c ) 1454 { 1455 dprintf2(("CRTDLL: _ismbbkalnum\n")); 1456 return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P)); 1457 } 1458 1459 1460 /********************************************************************* 1461 * _ismbbkana (CRTDLL.143) 1462 */ 1463 int CDECL CRTDLL__ismbbkana( unsigned int c ) 1464 { 1465 dprintf2(("CRTDLL: _ismbbkana\n")); 1466 return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P)); 1467 } 1468 1469 1470 /********************************************************************* 1471 * _ismbbkpunct (CRTDLL.144) 1472 */ 1473 int CDECL CRTDLL__ismbbkpunct( unsigned int c ) 1474 { 1475 dprintf2(("CRTDLL: _ismbbkpunct\n")); 1476 return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P)); 1477 } 1478 1479 1480 /********************************************************************* 1481 * _ismbblead (CRTDLL.145) 1482 */ 1483 int CDECL CRTDLL__ismbblead( unsigned int c ) 1484 { 1485 dprintf2(("CRTDLL: _ismbblead\n")); 1486 return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1); 1487 } 1488 1489 1490 /********************************************************************* 1491 * _ismbbprint (CRTDLL.146) 1492 */ 1493 int CDECL CRTDLL__ismbbprint( unsigned int c ) 1494 { 1495 dprintf2(("CRTDLL: _ismbbprint\n")); 1496 return (isprint(c) || CRTDLL__ismbbkana(c)); 1497 } 1498 1499 1500 /********************************************************************* 1501 * _ismbbpunct (CRTDLL.147) 1502 */ 1503 int CDECL CRTDLL__ismbbpunct( unsigned int c ) 1504 { 1505 dprintf2(("CRTDLL: _ismbbpunct\n")); 1506 return (ispunct(c) || CRTDLL__ismbbkana(c)); 1507 } 1508 1509 1510 /********************************************************************* 1511 * _ismbbtrail (CRTDLL.148) 1512 */ 1513 int CDECL CRTDLL__ismbbtrail( unsigned int c ) 1514 { 1515 dprintf2(("CRTDLL: _ismbbtrail\n")); 1516 return ((_jctype+1)[(unsigned char)(c)] & _KNJ_2); 1517 } 1518 1519 1520 /********************************************************************* 1521 * _ismbcalpha (CRTDLL.149) 1522 */ 1523 int CDECL CRTDLL__ismbcalpha( unsigned int c ) 1524 { 1525 dprintf2(("CRTDLL: _ismbcalpha\n")); 1526 if ((c & 0xFF00) != 0) { 1527 // true multibyte character 1528 return 0; 1529 } 1530 else 1531 return CRTDLL__ismbbalpha(c); 1532 1533 return 0; 1534 } 1535 1536 1537 /********************************************************************* 1538 * _ismbcdigit (CRTDLL.150) 1539 */ 1540 int CDECL CRTDLL__ismbcdigit( unsigned int c ) 1541 { 1542 dprintf2(("CRTDLL: _ismbcdigit\n")); 1543 if ((c & 0xFF00) != 0) { 1544 // true multibyte character 1545 return 0; 1546 } 1547 else 1548 return 0; 1549 // return _ismbbdigit(c); 1550 1551 return 0; 1552 } 1553 1554 1555 /********************************************************************* 1556 * _ismbchira (CRTDLL.151) 1557 */ 1558 int CDECL CRTDLL__ismbchira( unsigned int c ) 1559 { 1560 dprintf2(("CRTDLL: _ismbchira\n")); 1561 return ((c>=0x829F) && (c<=0x82F1)); 1562 } 1563 1564 1565 /********************************************************************* 1566 * _ismbckata (CRTDLL.152) 1567 */ 1568 int CDECL CRTDLL__ismbckata( unsigned int c ) 1569 { 1570 dprintf2(("CRTDLL: _ismbckata\n")); 1571 return ((c>=0x8340) && (c<=0x8396)); 1572 } 1573 1574 /********************************************************************* 1575 * _ismbcl0 (CRTDLL.153) 1576 */ 1577 int CDECL CRTDLL__ismbcl0( unsigned int ch ) 1578 { 1579 dprintf(("CRTDLL: _ismbcl0 not implemented.\n")); 1580 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1581 return 0; 1582 } 1583 1584 1585 /********************************************************************* 1586 * _ismbcl1 (CRTDLL.154) 1587 */ 1588 int CDECL CRTDLL__ismbcl1( unsigned int ch ) 1589 { 1590 dprintf(("CRTDLL: _ismbcl1 not implemented.\n")); 1591 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1592 return 0; 1593 } 1594 1595 1596 /********************************************************************* 1597 * _ismbcl2 (CRTDLL.155) 1598 */ 1599 int CDECL CRTDLL__ismbcl2( unsigned int ch ) 1600 { 1601 dprintf(("CRTDLL: _ismbcl2 not implemented.\n")); 1602 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1603 return 0; 1604 } 1605 1606 1607 /********************************************************************* 1608 * _ismbclegal (CRTDLL.156) 1609 */ 1610 int CDECL CRTDLL__ismbclegal( unsigned int c ) 1611 { 1612 dprintf2(("CRTDLL: _ismbclegal\n")); 1613 if ((c & 0xFF00) != 0) { 1614 return CRTDLL__ismbblead(c>>8) && CRTDLL__ismbbtrail(c&0xFF); 1615 } 1616 else 1617 return CRTDLL__ismbbtrail(c&0xFF); 1618 1619 return 0; 1620 } 1621 1622 1623 /********************************************************************* 1624 * _ismbclower (CRTDLL.157) 1625 */ 1626 int CDECL CRTDLL__ismbclower( unsigned int c ) 1627 { 1628 dprintf2(("CRTDLL: _ismbclower\n")); 1629 if ((c & 0xFF00) != 0) { 1630 if ( c >= 0x829A && c<= 0x829A ) 1631 return 1; 1632 } 1633 else 1634 return isupper(c); 1635 } 1636 1637 1638 /********************************************************************* 1639 * _ismbcprint (CRTDLL.158) 1640 */ 1641 int CDECL CRTDLL__ismbcprint( unsigned int c ) 1642 { 1643 dprintf2(("CRTDLL: _ismbcprint\n")); 1644 if ((c & 0xFF00) != 0) { 1645 // true multibyte character 1646 return 0; 1647 } 1648 else 1649 return 0; 1650 // return _ismbbdigit(c); 1651 1652 return 0; 1653 } 1654 1655 1656 /********************************************************************* 1657 * _ismbcspace (CRTDLL.159) 1658 */ 1659 int CDECL CRTDLL__ismbcspace( unsigned int c ) 1660 { 1661 dprintf(("CRTDLL: _ismbcspace not implemented.\n")); 1662 if ((c & 0xFF00) != 0) { 1663 // true multibyte character 1664 return 0; 1665 } 1666 else 1667 return 0; 1668 // return _ismbbdigit(c); 1669 1670 return 0; 1671 } 1672 1673 1674 /********************************************************************* 1675 * _ismbcsymbol (CRTDLL.160) 1676 */ 1677 int CDECL CRTDLL__ismbcsymbol( unsigned int c ) 1678 { 1679 dprintf(("CRTDLL: _ismbcsymbol not implemented.\n")); 1680 if ((c & 0xFF00) != 0) { 1681 // true multibyte character 1682 return 0; 1683 } 1684 else 1685 return 0; 1686 // return _ismbbdigit(c); 1687 1688 return 0; 1689 } 1690 1691 1692 /********************************************************************* 1693 * _ismbcupper (CRTDLL.161) 1694 */ 1695 int CDECL CRTDLL__ismbcupper( unsigned int c ) 1696 { 1697 dprintf2(("CRTDLL: _ismbcupper\n")); 1698 if ((c & 0xFF00) != 0) { 1699 if ( c >= 0x8260 && c<= 0x8279 ) 1700 return 1; 1701 } 1702 else 1703 return isupper(c); 1704 } 1705 1706 1707 /********************************************************************* 1708 * _ismbslead (CRTDLL.162) 1709 */ 1710 int CDECL CRTDLL__ismbslead(const unsigned char *str, const unsigned char *t) 1711 { 1712 dprintf2(("CRTDLL: _ismbslead\n")); 1713 unsigned char *s = (unsigned char *)str; 1714 while(*s != 0 && s != t) 1715 { 1716 s+= _mbclen2(*s); 1717 } 1718 return CRTDLL__ismbblead( *s); 1719 } 1720 1721 1722 /********************************************************************* 1723 * _ismbstrail (CRTDLL.163) 1724 */ 1725 int CDECL CRTDLL__ismbstrail(const unsigned char *str, const unsigned char *t) 1726 { 1727 dprintf2(("CRTDLL: _ismbstrail\n")); 1728 unsigned char *s = (unsigned char *)str; 1729 while(*s != 0 && s != t) 1730 { 1731 1732 s+= _mbclen2(*s); 1733 } 1734 1735 return CRTDLL__ismbbtrail(*s); 1736 } 1737 1738 1739 /********************************************************************* 1740 * _isnan (CRTDLL.164) 1741 */ 1742 int CDECL CRTDLL__isnan( double __x ) 1743 { 1744 dprintf2(("CRTDLL: _isnan\n")); 1745 double_t * x = (double_t *)&__x; 1746 return ( x->exponent == 0x7ff && ( x->mantissah != 0 || x->mantissal != 0 )); 1747 } 1748 1199 * _itoa (CRTDLL.165) 1200 */ 1201 char * CDECL CRTDLL__itoa(int i, char *s, int r) 1202 { 1203 dprintf2(("CRTDLL: _itoa(%08xh, %08xh, %08xh)\n", 1204 i, 1205 s, 1206 r)); 1207 1208 return (itoa(i,s,r)); 1209 } 1749 1210 1750 1211 /********************************************************************* … … 1788 1249 1789 1250 /********************************************************************* 1790 * _lfind (CRTDLL.170)1791 */1792 void * CDECL CRTDLL__lfind(const void *key, const void *base, size_t *nelp,1793 size_t width, int (*compar)(const void *, const void *))1794 {1795 dprintf2(("CRTDLL: _lfind\n"));1796 char *char_base = (char *)base;1797 int i;1798 for(i=0;i<*nelp;i++) {1799 if ( compar(key,char_base) == 0)1800 return char_base;1801 char_base += width;1802 }1803 return NULL;1804 }1805 1806 1807 /*********************************************************************1808 1251 * _loaddll (CRTDLL.171) 1809 1252 */ … … 1820 1263 void CDECL CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr ) 1821 1264 { 1822 dprintf2(("CRTDLL: local_undwind2\n")); 1823 } 1824 1825 1826 /********************************************************************* 1827 * _locking (CRTDLL.173) 1828 */ 1829 int CDECL CRTDLL__locking(int handle,int mode,unsigned long nbyte) 1830 { 1831 dprintf(("CRTDLL: _locking not implemented.\n")); 1832 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1833 return FALSE; 1834 } 1835 1836 1837 /********************************************************************* 1838 * _logb (CRTDLL.174) 1839 */ 1840 double CDECL CRTDLL__logb( double x ) 1841 { 1842 dprintf(("CRTDLL: _logb not implemented.\n")); 1843 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 1844 return FALSE; 1265 dprintf2(("CRTDLL: _local_unwind2\n")); 1845 1266 } 1846 1267 … … 1867 1288 1868 1289 /********************************************************************* 1869 * _lsearch (CRTDLL.177)1870 */1871 void * CDECL CRTDLL__lsearch(const void *key, void *base, size_t *nelp, size_t width,1872 int (*compar)(const void *, const void *))1873 {1874 dprintf(("CRTDLL: _lsearch not implemented.\n"));1875 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1876 return FALSE;1877 }1878 1879 1880 /*********************************************************************1881 1290 * _lseek (CRTDLL.178) 1882 1291 */ … … 1889 1298 1890 1299 /********************************************************************* 1300 * _ltoa (CRTDLL.179) 1301 */ 1302 LPSTR CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix) 1303 { 1304 return ltoa(x,buf,radix); 1305 } 1306 1307 1308 /********************************************************************* 1891 1309 * _makepath (CRTDLL.180) 1892 1310 */ … … 1910 1328 1911 1329 /********************************************************************* 1912 * _mbbtombc (CRTDLL.182)1913 */1914 unsigned int CDECL CRTDLL__mbbtombc( unsigned int c )1915 {1916 dprintf2(("CRTDLL: _mbbtombc\n"));1917 if (c >= 0x20 && c <= 0x7e) {1918 return han_to_zen_ascii_table[c - 0x20];1919 } else if (ISKANA(c)) {1920 return han_to_zen_kana_table[c - 0xa0];1921 }1922 return c;1923 }1924 1925 1926 /*********************************************************************1927 * _mbbtype (CRTDLL.183)1928 */1929 int CDECL CRTDLL__mbbtype( unsigned char c, int type )1930 {1931 dprintf2(("CRTDLL: _mbbtype\n"));1932 if ( type == 1 ) {1933 if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )1934 {1935 return _MBC_TRAIL;1936 }1937 else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||1938 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )1939 return _MBC_ILLEGAL;1940 else1941 return 0;1942 1943 }1944 else {1945 if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {1946 return _MBC_SINGLE;1947 }1948 else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )1949 return _MBC_LEAD;1950 else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||1951 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )1952 return _MBC_ILLEGAL;1953 else1954 return 0;1955 1956 }1957 1958 1959 return 0;1960 }1961 1962 1963 /*********************************************************************1964 * _mbccpy (CRTDLL.184)1965 */1966 void CDECL CRTDLL__mbccpy( unsigned char *dst, const unsigned char *src )1967 {1968 dprintf2(("CRTDLL: _mbccpy\n"));1969 1970 if (!CRTDLL__ismbblead(*src) )1971 return;1972 1973 memcpy(dst,src,_mbclen2(*src));1974 }1975 1976 1977 /*********************************************************************1978 * _mbcjistojms (CRTDLL.185)1979 */1980 int CDECL CRTDLL__mbcjistojms( unsigned int c )1981 {1982 dprintf2(("CRTDLL: _mbcjistojms\n"));1983 int c1, c2;1984 1985 c2 = (unsigned char)c;1986 c1 = c >> 8;1987 if (c1 >= 0x21 && c1 <= 0x7e && c2 >= 0x21 && c2 <= 0x7e) {1988 if (c1 & 0x01) {1989 c2 += 0x1f;1990 if (c2 >= 0x7f)1991 c2 ++;1992 } else {1993 c2 += 0x7e;1994 }1995 c1 += 0xe1;1996 c1 >>= 1;1997 if (c1 >= 0xa0)1998 c1 += 0x40;1999 return ((c1 << 8) | c2);2000 }2001 return 0;2002 }2003 2004 2005 /*********************************************************************2006 * _mbcjmstojis (CRTDLL.186)2007 */2008 int CDECL CRTDLL__mbcjmstojis( unsigned int c )2009 {2010 dprintf2(("CRTDLL: _mbcjmstojis\n"));2011 int c1, c2;2012 2013 c2 = (unsigned char)c;2014 c1 = c >> 8;2015 if (c1 < 0xf0 && CRTDLL__ismbblead(c1) && CRTDLL__ismbbtrail(c2)) {2016 if (c1 >= 0xe0)2017 c1 -= 0x40;2018 c1 -= 0x70;2019 c1 <<= 1;2020 if (c2 < 0x9f) {2021 c1 --;2022 c2 -= 0x1f;2023 if (c2 >= (0x80-0x1f))2024 c2 --;2025 } else {2026 c2 -= 0x7e;2027 }2028 return ((c1 << 8) | c2);2029 }2030 return 0;2031 }2032 2033 2034 /*********************************************************************2035 * _mbclen (CRTDLL.187)2036 */2037 size_t CDECL CRTDLL__mbclen( const unsigned char *s )2038 {2039 dprintf2(("CRTDLL: _mbclen\n"));2040 return (CRTDLL__ismbblead(*s>>8) && CRTDLL__ismbbtrail(*s&0x00FF)) ? 2 : 1;2041 }2042 2043 2044 /*********************************************************************2045 * _mbctohira (CRTDLL.188)2046 */2047 int CDECL CRTDLL__mbctohira( unsigned int c )2048 {2049 dprintf2(("CRTDLL: _mbctohira\n"));2050 return c;2051 }2052 2053 2054 /*********************************************************************2055 * _mbctokata (CRTDLL.189)2056 */2057 int CDECL CRTDLL__mbctokata( unsigned int c )2058 {2059 dprintf2(("CRTDLL: _mbctokata\n"));2060 return c;2061 }2062 2063 2064 /*********************************************************************2065 * _mbctolower (CRTDLL.190)2066 */2067 unsigned int CDECL CRTDLL__mbctolower( unsigned int c )2068 {2069 dprintf2(("CRTDLL: _mbctolower\n"));2070 if ((c & 0xFF00) != 0) {2071 // true multibyte case conversion needed2072 if ( CRTDLL__ismbclower(c) )2073 return c + CASE_DIFF;2074 2075 } else2076 return _mbbtolower(c);2077 2078 return 0;2079 }2080 2081 2082 /*********************************************************************2083 * _mbctombb (CRTDLL.191)2084 */2085 unsigned int CDECL CRTDLL__mbctombb( unsigned int c )2086 {2087 dprintf2(("CRTDLL: _mbctombb\n"));2088 int i;2089 unsigned short *p;2090 2091 if (JISKANA(c)) {2092 return zen_to_han_kana_table[c - 0x8340];2093 } else if (JISHIRA(c)) {2094 c = JTOKANA(c);2095 return zen_to_han_kana_table[c - 0x8340];2096 } else if (c <= 0x8396) {2097 for (i = 0x20, p = han_to_zen_ascii_table; i <= 0x7e; i++, p++) {2098 if (*p == c) {2099 return i;2100 }2101 }2102 for (i = 0; i < ZTOH_SYMBOLS; i++) {2103 if (zen_to_han_symbol_table_1[i] == c) {2104 return zen_to_han_symbol_table_2[i];2105 }2106 }2107 }2108 return c;2109 }2110 2111 2112 /*********************************************************************2113 * _mbctoupper (CRTDLL.192)2114 */2115 unsigned int CDECL CRTDLL__mbctoupper( unsigned int c )2116 {2117 dprintf2(("CRTDLL: _mbctoupper\n"));2118 if ((c & 0xFF00) != 0) {2119 // true multibyte case conversion needed2120 if ( CRTDLL__ismbcupper(c) )2121 return c + CASE_DIFF;2122 2123 } else2124 return _mbbtoupper(c);2125 2126 return 0;2127 }2128 2129 2130 /*********************************************************************2131 * _mbsbtype (CRTDLL.194)2132 */2133 int CDECL CRTDLL__mbsbtype( const unsigned char *str, int n )2134 {2135 dprintf2(("CRTDLL: _mbsbtype\n"));2136 if ( str == NULL )2137 return -1;2138 return CRTDLL__mbbtype(*(str+n),1);2139 }2140 2141 2142 /*********************************************************************2143 * _mbscat (CRTDLL.195)2144 */2145 unsigned char * CDECL CRTDLL__mbscat( unsigned char *dst, const unsigned char *src )2146 {2147 dprintf2(("CRTDLL: _mbscat\n"));2148 return (unsigned char*)strcat((char*)dst,(char*)src);2149 }2150 2151 2152 /*********************************************************************2153 * _mbschr (CRTDLL.196)2154 */2155 unsigned char * CDECL CRTDLL__mbschr( const unsigned char *str, unsigned int c )2156 {2157 dprintf2(("CRTDLL: _mbschr\n"));2158 return (unsigned char*)strchr((char*)str,c);2159 }2160 2161 2162 /*********************************************************************2163 * _mbscmp (CRTDLL.197)2164 */2165 int CDECL CRTDLL__mbscmp( const unsigned char *s1, const unsigned char *s2 )2166 {2167 dprintf2(("CRTDLL: _mbscmp\n"));2168 return strcmp((char*)s1,(char*)s2);2169 }2170 2171 2172 /*********************************************************************2173 * _mbscpy (CRTDLL.198)2174 */2175 unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 )2176 {2177 dprintf2(("CRTDLL: _mbscpy\n"));2178 return (unsigned char*)strcpy((char*)s1,(char*)s2);2179 }2180 2181 2182 /*********************************************************************2183 * _mbscspn (CRTDLL.199)2184 */2185 size_t CDECL CRTDLL__mbscspn( const unsigned char *s1, const unsigned char *s2 )2186 {2187 dprintf2(("CRTDLL: _mbscspn\n"));2188 const char *p, *spanp;2189 char c, sc;2190 2191 for (p = (const char*)s1;;)2192 {2193 c = *p++;2194 spanp = (const char*)s2;2195 do {2196 if ((sc = *spanp++) == c)2197 return (size_t)(p - 1) - (size_t)s1;2198 } while (sc != 0);2199 }2200 /* NOTREACHED */2201 }2202 2203 2204 /*********************************************************************2205 * _mbsdec (CRTDLL.200)2206 */2207 unsigned char * CDECL CRTDLL__mbsdec( const unsigned char *str, const unsigned char *cur )2208 {2209 dprintf2(("CRTDLL: _mbsdec\n"));2210 unsigned char *s = (unsigned char *)cur;2211 if ( str >= cur )2212 return NULL;2213 s--;2214 if (CRTDLL__ismbblead(*(s-1)) )2215 s--;2216 2217 return s;2218 }2219 2220 2221 /*********************************************************************2222 * _mbsdup (CRTDLL.201)2223 */2224 unsigned char * CDECL CRTDLL__mbsdup( unsigned char *_s )2225 {2226 dprintf2(("CRTDLL: _mbsdup\n"));2227 char *rv;2228 if (_s == 0)2229 return 0;2230 rv = (char *)malloc(CRTDLL__mbslen((LPCSTR)_s) + 1);2231 if (rv == 0)2232 return 0;2233 CRTDLL__mbscpy((unsigned char*)rv, _s);2234 return (unsigned char*)rv;2235 }2236 2237 2238 /*********************************************************************2239 * CRTDLL__mbsicmp (CRTDLL.202)2240 */2241 int CDECL CRTDLL__mbsicmp( const unsigned char *x, const unsigned char *y )2242 {2243 dprintf2(("CRTDLL: _mbsicmp\n"));2244 do {2245 if (!*x)2246 return !!*y;2247 if (!*y)2248 return !!*x;2249 /* FIXME: MBCS handling... */2250 if (*x!=*y)2251 return 1;2252 x++;2253 y++;2254 } while (1);2255 }2256 2257 2258 /*********************************************************************2259 * CRTDLL__mbsinc (CRTDLL.203)2260 */2261 LPSTR CDECL CRTDLL__mbsinc( LPCSTR str )2262 {2263 dprintf2(("CRTDLL: _mbsinc\n"));2264 int len = mblen( str, MB_LEN_MAX );2265 if (len < 1) len = 1;2266 return (LPSTR)(str + len);2267 }2268 2269 2270 /*********************************************************************2271 * CRTDLL__mbslen (CRTDLL.204)2272 */2273 INT CDECL CRTDLL__mbslen( LPCSTR str )2274 {2275 dprintf2(("CRTDLL: _mbslen\n"));2276 INT len, total = 0;2277 while ((len = mblen( str, MB_LEN_MAX )) > 0)2278 {2279 str += len;2280 total++;2281 }2282 return total;2283 }2284 2285 2286 /*********************************************************************2287 * _mbslwr (CRTDLL.205)2288 */2289 unsigned char * CDECL CRTDLL__mbslwr( unsigned char *x )2290 {2291 dprintf2(("CRTDLL: _mbslwr\n"));2292 unsigned char *y=x;2293 2294 while (*y) {2295 if (!CRTDLL__ismbblead(*y) )2296 *y = tolower(*y);2297 else {2298 *y=CRTDLL__mbctolower(*(unsigned short *)y);2299 y++;2300 }2301 }2302 return x;2303 }2304 2305 2306 /*********************************************************************2307 * _mbsnbcat (CRTDLL.206)2308 */2309 unsigned char * CDECL CRTDLL__mbsnbcat( unsigned char *dst, const unsigned char *src, size_t n )2310 {2311 dprintf2(("CRTDLL: _mbsnbcat\n"));2312 char *d;2313 char *s = (char *)src;2314 if (n != 0) {2315 d = (char*)dst + strlen((char*)dst); // get the end of string2316 d += _mbclen2(*d); // move 1 or 2 up2317 2318 do {2319 if ((*d++ = *s++) == 0)2320 {2321 while (--n != 0)2322 *d++ = 0;2323 break;2324 }2325 if ( !(n==1 && CRTDLL__ismbblead(*s)) )2326 n--;2327 } while (n > 0);2328 }2329 return dst;2330 }2331 2332 2333 /*********************************************************************2334 * _mbsnbcmp (CRTDLL.207)2335 */2336 int CDECL CRTDLL__mbsnbcmp( const unsigned char *str1, const unsigned char *str2, size_t n )2337 {2338 dprintf2(("CRTDLL: _mbsnbcmp\n"));2339 unsigned char *s1 = (unsigned char *)str1;2340 unsigned char *s2 = (unsigned char *)str2;2341 2342 unsigned short *short_s1, *short_s2;2343 2344 int l1, l2;2345 2346 if (n == 0)2347 return 0;2348 do {2349 2350 if (*s1 == 0)2351 break;2352 2353 l1 = CRTDLL__ismbblead(*s1);2354 l2 = CRTDLL__ismbblead(*s2);2355 if ( !l1 && !l2 ) {2356 2357 if (*s1 != *s2)2358 return *s1 - *s2;2359 else {2360 s1 += 1;2361 s2 += 1;2362 n--;2363 }2364 }2365 else if ( l1 && l2 ){2366 short_s1 = (unsigned short *)s1;2367 short_s2 = (unsigned short *)s2;2368 if ( *short_s1 != *short_s2 )2369 return *short_s1 - *short_s2;2370 else {2371 s1 += 2;2372 s2 += 2;2373 n-=2;2374 2375 }2376 }2377 else2378 return *s1 - *s2;2379 } while (n > 0);2380 return 0;2381 }2382 2383 2384 /*********************************************************************2385 * _mbsnbcnt (CRTDLL.208)2386 */2387 size_t CDECL CRTDLL__mbsnbcnt( const unsigned char *str, size_t n )2388 {2389 dprintf2(("CRTDLL: _mbsnbcnt\n"));2390 unsigned char *s = (unsigned char *)str;2391 while(*s != 0 && n > 0) {2392 if (!CRTDLL__ismbblead(*s) )2393 n--;2394 s++;2395 }2396 2397 return (size_t)(s - str);2398 }2399 2400 2401 /*********************************************************************2402 * _mbsnbcpy (CRTDLL.209)2403 */2404 unsigned char * CDECL CRTDLL__mbsnbcpy( unsigned char *str1, const unsigned char *str2, size_t n )2405 {2406 dprintf2(("CRTDLL: _mbsnbcpy\n"));2407 unsigned char *s1 = (unsigned char *)str1;2408 unsigned char *s2 = (unsigned char *)str2;2409 2410 unsigned short *short_s1, *short_s2;2411 2412 if (n == 0)2413 return 0;2414 do {2415 2416 if (*s2 == 0)2417 break;2418 2419 if ( !CRTDLL__ismbblead(*s2) ) {2420 2421 *s1 = *s2;2422 s1 += 1;2423 s2 += 1;2424 n--;2425 }2426 else {2427 short_s1 = (unsigned short *)s1;2428 short_s2 = (unsigned short *)s2;2429 *short_s1 = *short_s2;2430 s1 += 2;2431 s2 += 2;2432 n-=2;2433 }2434 } while (n > 0);2435 return str1;2436 }2437 2438 2439 /*********************************************************************2440 * _mbsnbicmp (CRTDLL.210)2441 */2442 int CDECL CRTDLL__mbsnbicmp( const unsigned char *s1, const unsigned char *s2, size_t n )2443 {2444 dprintf2(("CRTDLL: _mbsnbicmp\n"));2445 if (n == 0)2446 return 0;2447 do {2448 if (_mbbtoupper(*s1) != _mbbtoupper(*s2))2449 return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);2450 s1 += _mbclen2(*s1);2451 s2 += _mbclen2(*s2);2452 2453 2454 if (*s1 == 0)2455 break;2456 n--;2457 } while (n > 0);2458 return 0;2459 }2460 2461 2462 /*********************************************************************2463 * _mbsnbset (CRTDLL.211)2464 */2465 unsigned char * CDECL CRTDLL__mbsnbset( unsigned char *src, unsigned int val, size_t count )2466 {2467 dprintf2(("CRTDLL: _mbsnbset\n"));2468 unsigned char *char_src = (unsigned char *)src;2469 unsigned short *short_src = (unsigned short *)src;2470 2471 if ( _mbclen2(val) == 1 ) {2472 2473 while(count > 0) {2474 *char_src = val;2475 char_src++;2476 count--;2477 }2478 *char_src = 0;2479 }2480 else {2481 while(count > 0) {2482 *short_src = val;2483 short_src++;2484 count-=2;2485 }2486 *short_src = 0;2487 }2488 2489 return src;2490 }2491 2492 2493 /*********************************************************************2494 * _mbsncat (CRTDLL.212)2495 */2496 unsigned char * CDECL CRTDLL__mbsncat( unsigned char *dst, const unsigned char *src, size_t n )2497 {2498 dprintf2(("CRTDLL: _mbsncat\n"));2499 char *d = (char *)dst;2500 char *s = (char *)src;2501 if (n != 0) {2502 d = (char*)dst + strlen((char*)dst); // get the end of string2503 d += _mbclen2(*d); // move 1 or 2 up2504 2505 do {2506 if ((*d++ = *s++) == 0)2507 {2508 while (--n != 0)2509 *d++ = 0;2510 break;2511 }2512 if (!CRTDLL__ismbblead(*s) )2513 n--;2514 } while (n > 0);2515 }2516 return dst;2517 }2518 2519 2520 /*********************************************************************2521 * _mbsnccnt (CRTDLL.213)2522 */2523 size_t CDECL CRTDLL__mbsnccnt( const unsigned char *str, size_t n )2524 {2525 dprintf2(("CRTDLL: _mbsnccnt\n"));2526 unsigned char *s = (unsigned char *)str;2527 size_t cnt = 0;2528 while(*s != 0 && n > 0) {2529 if (CRTDLL__ismbblead(*s) )2530 s++;2531 else2532 n--;2533 s++;2534 cnt++;2535 }2536 2537 return cnt;2538 }2539 2540 2541 /*********************************************************************2542 * _mbsncmp (CRTDLL.214)2543 */2544 int CDECL CRTDLL__mbsncmp( const unsigned char *str1, const unsigned char *str2, size_t n )2545 {2546 dprintf2(("CRTDLL: _mbsncmp\n"));2547 unsigned char *s1 = (unsigned char *)str1;2548 unsigned char *s2 = (unsigned char *)str2;2549 2550 unsigned short *short_s1, *short_s2;2551 2552 int l1, l2;2553 2554 if (n == 0)2555 return 0;2556 do {2557 2558 if (*s1 == 0)2559 break;2560 2561 l1 = CRTDLL__ismbblead(*s1);2562 l2 = CRTDLL__ismbblead(*s2);2563 if ( !l1 && !l2 ) {2564 2565 if (*s1 != *s2)2566 return *s1 - *s2;2567 else {2568 s1 += 1;2569 s2 += 1;2570 n--;2571 }2572 }2573 else if ( l1 && l2 ){2574 short_s1 = (unsigned short *)s1;2575 short_s2 = (unsigned short *)s2;2576 if ( *short_s1 != *short_s2 )2577 return *short_s1 - *short_s2;2578 else {2579 s1 += 2;2580 s2 += 2;2581 n--;2582 2583 }2584 }2585 else2586 return *s1 - *s2;2587 } while (n > 0);2588 return 0;2589 }2590 2591 2592 /*********************************************************************2593 * _mbsncpy (CRTDLL.215)2594 */2595 unsigned char * CDECL CRTDLL__mbsncpy( unsigned char *str1, const unsigned char *str2, size_t n )2596 {2597 dprintf2(("CRTDLL: _mbsncpy\n"));2598 unsigned char *s1 = (unsigned char *)str1;2599 unsigned char *s2 = (unsigned char *)str2;2600 2601 unsigned short *short_s1, *short_s2;2602 2603 if (n == 0)2604 return 0;2605 do {2606 2607 if (*s2 == 0)2608 break;2609 2610 if ( !CRTDLL__ismbblead(*s2) ) {2611 2612 *s1 = *s2;2613 s1 += 1;2614 s2 += 1;2615 n--;2616 }2617 else {2618 short_s1 = (unsigned short *)s1;2619 short_s2 = (unsigned short *)s2;2620 *short_s1 = *short_s2;2621 s1 += 2;2622 s2 += 2;2623 n--;2624 }2625 } while (n > 0);2626 return str1;2627 }2628 2629 2630 /*********************************************************************2631 * _mbsnextc (CRTDLL.216)2632 */2633 unsigned int CDECL CRTDLL__mbsnextc( const unsigned char *src )2634 {2635 dprintf2(("CRTDLL: _mbsnextc\n"));2636 unsigned char *char_src = (unsigned char *)src;2637 unsigned short *short_src = (unsigned short *)src;2638 2639 if ( src == NULL )2640 return 0;2641 2642 if ( !CRTDLL__ismbblead(*src) )2643 return *char_src;2644 else2645 return *short_src;2646 return 0;2647 2648 }2649 2650 2651 /*********************************************************************2652 * _mbsnicmp (CRTDLL.217)2653 */2654 int CDECL CRTDLL__mbsnicmp( const unsigned char *s1, const unsigned char *s2, size_t n )2655 {2656 dprintf2(("CRTDLL: _mbsnicmp\n"));2657 if (n == 0)2658 return 0;2659 do {2660 if (_mbbtoupper(*s1) != _mbbtoupper(*s2))2661 return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);2662 2663 // Next 2 lines won't compile2664 // *s1 += _mbclen2(*s1);2665 // *s2 += _mbclen2(*s2);2666 2667 2668 if (*s1 == 0)2669 break;2670 if (!CRTDLL__ismbblead(*s1) )2671 n--;2672 } while (n > 0);2673 return 0;2674 }2675 2676 2677 /*********************************************************************2678 * _mbsninc (CRTDLL.218)2679 */2680 unsigned char * CDECL CRTDLL__mbsninc( const unsigned char *str, size_t n )2681 {2682 dprintf2(("CRTDLL: _mbsninc\n"));2683 unsigned char *s = (unsigned char *)str;2684 while(*s != 0 && n > 0) {2685 if (!CRTDLL__ismbblead(*s) )2686 n--;2687 s++;2688 }2689 2690 return s;2691 }2692 2693 2694 /*********************************************************************2695 * _mbsnset (CRTDLL.219)2696 */2697 unsigned char * CDECL CRTDLL__mbsnset( unsigned char *src, unsigned int val, size_t count )2698 {2699 dprintf2(("CRTDLL: _mbsnset\n"));2700 unsigned char *char_src = (unsigned char *)src;2701 unsigned short *short_src = (unsigned short *)src;2702 2703 if ( _mbclen2(val) == 1 ) {2704 2705 while(count > 0) {2706 *char_src = val;2707 char_src++;2708 count--;2709 }2710 *char_src = 0;2711 }2712 else {2713 while(count > 0) {2714 *short_src = val;2715 short_src++;2716 count-=2;2717 }2718 *short_src = 0;2719 }2720 2721 return src;2722 2723 }2724 2725 2726 /*********************************************************************2727 * _mbspbrk (CRTDLL.220)2728 */2729 unsigned char * CDECL CRTDLL__mbspbrk( const unsigned char *s1, const unsigned char *s2 )2730 {2731 dprintf2(("CRTDLL: _mbspbrk\n"));2732 const char *scanp;2733 int c, sc;2734 2735 while ((c = *s1++) != 0)2736 {2737 for (scanp = (char*)s2; (sc = *scanp++) != 0;)2738 if (sc == c)2739 return (unsigned char *)((char *)s1 - (char *)1);2740 }2741 return 0;2742 }2743 2744 2745 /*********************************************************************2746 * CRTDLL__mbsrchr (CRTDLL.221)2747 */2748 LPSTR CDECL CRTDLL__mbsrchr(LPSTR s,CHAR x)2749 {2750 dprintf2(("CRTDLL: _mbsrchr\n"));2751 /* FIXME: handle multibyte strings */2752 return strrchr(s,x);2753 }2754 2755 2756 /*********************************************************************2757 * _mbsrev (CRTDLL.222)2758 */2759 unsigned char * CDECL CRTDLL__mbsrev( unsigned char *s )2760 {2761 dprintf2(("CRTDLL: _mbsrev\n"));2762 unsigned char *e;2763 unsigned char a;2764 e=s;2765 while (*e) {2766 if ( CRTDLL__ismbblead(*e) ) {2767 a = *e;2768 *e = *++e;2769 if ( *e == 0 )2770 break;2771 *e = a;2772 }2773 e++;2774 }2775 while (s<e) {2776 a=*s;2777 *s=*e;2778 *e=a;2779 s++;2780 e--;2781 }2782 2783 2784 return s;2785 }2786 2787 2788 /*********************************************************************2789 * _mbsset (CRTDLL.223)2790 */2791 unsigned char * CDECL CRTDLL__mbsset( unsigned char *src, unsigned int c )2792 {2793 dprintf2(("CRTDLL: _mbsset\n"));2794 unsigned char *char_src = src;2795 unsigned short *short_src = (unsigned short*)src;2796 2797 if ( _mbclen2(c) == 1 ) {2798 2799 while(*char_src != 0) {2800 *char_src = c;2801 char_src++;2802 }2803 *char_src = 0;2804 }2805 else {2806 while(*short_src != 0) {2807 *short_src = c;2808 short_src++;2809 }2810 *short_src = 0;2811 }2812 2813 return src;2814 }2815 2816 2817 /*********************************************************************2818 * _mbsspn (CRTDLL.224)2819 */2820 size_t CDECL CRTDLL__mbsspn( const unsigned char *s1, const unsigned char *s2 )2821 {2822 dprintf2(("CRTDLL: _mbsspn\n"));2823 const char *p = (char*)s1, *spanp;2824 char c, sc;2825 2826 cont:2827 c = *p++;2828 for (spanp = (char*)s2; (sc = *spanp++) != 0;)2829 if (sc == c)2830 goto cont;2831 return (size_t)(p - 1) - (size_t)s1;2832 }2833 2834 2835 /*********************************************************************2836 * _mbsspnp (CRTDLL.225)2837 */2838 unsigned char * CDECL CRTDLL__mbsspnp( const unsigned char *s1, const unsigned char *s2 )2839 {2840 dprintf2(("CRTDLL: _mbsspnp\n"));2841 const char *p = (char*)s1, *spanp;2842 char c, sc;2843 2844 cont:2845 c = *p++;2846 for (spanp = (char*)s2; (sc = *spanp++) != 0;)2847 if (sc == c)2848 goto cont;2849 return (unsigned char*)p;2850 }2851 2852 2853 /*********************************************************************2854 * _mbsstr (CRTDLL.226)2855 */2856 unsigned char * CDECL CRTDLL__mbsstr( const unsigned char *s1, const unsigned char *s2 )2857 {2858 dprintf2(("CRTDLL: _mbsstr\n"));2859 return (unsigned char*)strstr((const char*)s1,(const char*)s2);2860 }2861 2862 2863 /*********************************************************************2864 * _mbstok (CRTDLL.227)2865 */2866 unsigned char * CDECL CRTDLL__mbstok( unsigned char *s, const unsigned char *delim )2867 {2868 dprintf2(("CRTDLL: _mbstok\n"));2869 const char *spanp;2870 int c, sc;2871 char *tok;2872 static char *last;2873 2874 2875 if (s == NULL && (s = (unsigned char*)last) == NULL)2876 return (NULL);2877 2878 /*2879 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).2880 */2881 cont:2882 c = *s;2883 s = (unsigned char*)CRTDLL__mbsinc((LPCSTR)s);2884 2885 for (spanp = (const char*)delim; (sc = *spanp) != 0; spanp = CRTDLL__mbsinc(spanp)) {2886 if (c == sc)2887 goto cont;2888 }2889 2890 if (c == 0) { /* no non-delimiter characters */2891 last = NULL;2892 return (NULL);2893 }2894 tok = (char*)s - 1;2895 2896 /*2897 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).2898 * Note that delim must have one NUL; we stop if we see that, too.2899 */2900 for (;;) {2901 c = *s;2902 s = (unsigned char*)CRTDLL__mbsinc((LPCSTR)s);2903 spanp = (const char*)delim;2904 do {2905 if ((sc = *spanp) == c) {2906 if (c == 0)2907 s = NULL;2908 else2909 s[-1] = 0;2910 last = (char*)s;2911 return ((unsigned char*)tok);2912 }2913 spanp = CRTDLL__mbsinc(spanp);2914 } while (sc != 0);2915 }2916 /* NOTREACHED */2917 }2918 2919 2920 /*********************************************************************2921 * _mbstrlen (CRTDLL.228)2922 */2923 size_t CDECL CRTDLL__mbstrlen(const char *string)2924 {2925 dprintf2(("CRTDLL: _mbstrlen\n"));2926 char *s = (char *)string;2927 size_t i;2928 while ( *s != 0 ) {2929 if ( CRTDLL__ismbblead(*s) )2930 s++;2931 s++;2932 i++;2933 }2934 return i;2935 }2936 2937 2938 /*********************************************************************2939 * _mbsupr (CRTDLL.229)2940 */2941 unsigned char * CDECL CRTDLL__mbsupr( unsigned char *x )2942 {2943 dprintf2(("CRTDLL: _mbsupr\n"));2944 unsigned char *y=x;2945 while (*y) {2946 if (!CRTDLL__ismbblead(*y) )2947 *y = toupper(*y);2948 else {2949 *y=CRTDLL__mbctoupper(*(unsigned short *)y);2950 y++;2951 }2952 }2953 return x;2954 }2955 2956 2957 /*********************************************************************2958 * CRTDLL__memccpy (CRTDLL.230)2959 */2960 void * CDECL CRTDLL__memccpy(void *to, const void *from,int c,size_t count)2961 {2962 dprintf2(("CRTDLL: _memccpy\n"));2963 memcpy(to,from,count);2964 return memchr(to,c,count);2965 }2966 2967 2968 /*********************************************************************2969 1330 * _mkdir (CRTDLL.232) 2970 1331 */ 2971 1332 INT CDECL CRTDLL__mkdir(LPCSTR newdir) 2972 1333 { 2973 dprintf2(("CRTDLL: mkdir\n"));1334 dprintf2(("CRTDLL: _mkdir\n")); 2974 1335 if (!CreateDirectoryA(newdir,NULL)) 2975 1336 return -1; … … 2981 1342 * _mktemp (CRTDLL.233) 2982 1343 */ 2983 char * CDECL CRTDLL__mktemp( char * _template)1344 char * CDECL CRTDLL__mktemp( char *string ) 2984 1345 { 2985 1346 dprintf2(("CRTDLL: _mktemp\n")); 2986 static int count = 0; 2987 char *cp, *dp; 2988 int i, len, xcount, loopcnt; 2989 2990 2991 2992 len = strlen (_template); 2993 cp = _template + len; 2994 2995 xcount = 0; 2996 while (xcount < 6 && cp > _template && cp[-1] == 'X') 2997 xcount++, cp--; 2998 2999 if (xcount) { 3000 dp = cp; 3001 while (dp > _template && dp[-1] != '/' && dp[-1] != '\\' && dp[-1] != ':') 3002 dp--; 3003 3004 /* Keep the first characters of the template, but turn the rest into 3005 Xs. */ 3006 while (cp > dp + 8 - xcount) { 3007 *--cp = 'X'; 3008 xcount = (xcount >= 6) ? 6 : 1 + xcount; 1347 int pid, n, saved_errno; 1348 char *s; 1349 1350 pid = _getpid (); 1351 s = strchr (string, 0); 1352 n = 0; 1353 while (s != string && s[-1] == 'X') 1354 { 1355 --s; ++n; 1356 *s = (char)(pid % 10) + '0'; 1357 pid /= 10; 3009 1358 } 3010 3011 /* If dots occur too early -- squash them. */ 3012 while (dp < cp) { 3013 if (*dp == '.') *dp = 'a'; 3014 dp++; 1359 if (n < 2) 1360 return NULL; 1361 *s = 'a'; saved_errno = errno; 1362 for (;;) 1363 { 1364 errno = 0; 1365 if (_access (string, 0) != 0 && errno == ENOENT) 1366 { 1367 errno = saved_errno; 1368 return string; 1369 } 1370 if (*s == 'z') 1371 { 1372 errno = saved_errno; 1373 return NULL; 1374 } 1375 ++*s; 3015 1376 } 3016 3017 /* Try to add ".tmp" to the filename. Truncate unused Xs. */3018 if (cp + xcount + 3 < _template + len)3019 strcpy (cp + xcount, ".tmp");3020 else3021 cp[xcount] = 0;3022 3023 for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) {3024 int c = count++;3025 for (i = 0; i < xcount; i++, c >>= 5)3026 cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f];3027 if (CRTDLL__access(_template,0) == -1)3028 return _template;3029 }3030 }3031 /* Failure: truncate the template and return NULL. */3032 *_template = 0;3033 return 0;3034 1377 } 3035 1378 … … 3042 1385 dprintf2(("CRTDLL: _msize\n")); 3043 1386 return (_msize(ptr)); 3044 }3045 3046 3047 /*********************************************************************3048 * _nextafter (CRTDLL.235)3049 */3050 double CDECL CRTDLL__nextafter( double x, double y )3051 {3052 dprintf2(("CRTDLL: _nextafter\n"));3053 if ( x == y)3054 return x;3055 if ( CRTDLL__isnan(x) || CRTDLL__isnan(y) )3056 return x;3057 3058 return x;3059 1387 } 3060 1388 … … 3146 1474 3147 1475 /********************************************************************* 3148 * _pclose (CRTDLL.244)3149 */3150 INT CDECL CRTDLL__pclose( FILE *fp )3151 {3152 dprintf(("CRTDLL: _pclose not implemented.\n"));3153 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);3154 return FALSE;3155 }3156 3157 3158 /*********************************************************************3159 * _pipe (CRTDLL.247)3160 */3161 INT CDECL CRTDLL__pipe( int *phandles, unsigned psize, int textmode )3162 {3163 dprintf(("CRTDLL: _pipe not implemented.\n"));3164 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);3165 return FALSE;3166 }3167 3168 3169 /*********************************************************************3170 * _popen (CRTDLL.248)3171 */3172 FILE * CDECL CRTDLL__popen( const char *command, const char *mode )3173 {3174 dprintf(("CRTDLL: _popen not implemented.\n"));3175 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);3176 return FALSE;3177 }3178 3179 3180 /*********************************************************************3181 1476 * _purecall (CRTDLL.249) 3182 1477 */ … … 3210 1505 * _putw (CRTDLL.252) 3211 1506 */ 3212 INT CDECL CRTDLL__putw( int w, FILE *stream )1507 INT CDECL CRTDLL__putw( int x, FILE *stream ) 3213 1508 { 3214 1509 dprintf2(("CRTDLL: _putw\n")); 3215 if (fwrite( &w, sizeof(w), 1, stream) < 1) 3216 return(EOF); 3217 return(0); 1510 return (fwrite (&x, sizeof (x), 1, stream) == 1 ? x : EOF); 3218 1511 } 3219 1512 … … 3222 1515 * _read (CRTDLL.254) 3223 1516 */ 3224 INT CDECL CRTDLL__read(INT fd, LPVOID buf, UINT count) 3225 { 3226 dprintf(("CRTDLL: _read not implemented.\n")); 3227 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 3228 return FALSE; 1517 INT CDECL CRTDLL__read(int handle, void *buf, size_t nbyte) 1518 { 1519 dprintf(("CRTDLL: _read\n")); 1520 /* 1521 int n, *pflags, *pla; 1522 size_t j, k; 1523 char *dst, c; 1524 1525 if ((pflags = _fd_flags (handle)) == NULL 1526 || (pla = _fd_lookahead (handle)) == NULL) 1527 { 1528 errno = EBADF; 1529 return -1; 1530 } 1531 1532 *pflags &= ~F_CRLF; 1533 if (nbyte > 0 && (*pflags & F_EOF)) 1534 return 0; 1535 dst = buf; 1536 n = read_lookahead (handle, dst, nbyte, pla); 1537 if (n == -1) 1538 return -1; 1539 if ((*pflags & O_TEXT) && !(*pflags & F_TERMIO) && n > 0) 1540 { 1541 if (!(*pflags & (F_PIPE|F_SOCKET|F_DEV)) && dst[n-1] == 0x1a && 1542 _eof (handle)) 1543 { 1544 --n; 1545 *pflags |= F_EOF; 1546 if (n == 0) 1547 return 0; 1548 } 1549 if (n == 1 && dst[0] == '\r') 1550 { 1551 int saved_errno = errno; 1552 j = read_lookahead (handle, &c, 1, pla); 1553 if (j == -1 && errno == EAGAIN) 1554 { 1555 *pla = dst[0]; 1556 return -1; 1557 } 1558 errno = saved_errno; 1559 if (j == 1 && c == '\n') 1560 { 1561 dst[0] = '\n'; 1562 *pflags |= F_CRLF; 1563 } 1564 else 1565 *pla = c; 1566 } 1567 else 1568 { 1569 1570 if (_crlf (dst, n, &k)) 1571 { 1572 1573 *pla = '\r'; 1574 --n; 1575 } 1576 if (k != n) 1577 *pflags |= F_CRLF; 1578 n = k; 1579 } 1580 } 1581 return n; 1582 */ 1583 return 0; 3229 1584 } 3230 1585 … … 3273 1628 3274 1629 /********************************************************************* 3275 * _scalb (CRTDLL.259)3276 */3277 double CDECL CRTDLL__scalb( double __x, long e )3278 {3279 dprintf2(("CRTDLL: _scalb\n"));3280 double_t *x = (double_t *)&__x;3281 3282 x->exponent += e;3283 3284 return __x;3285 }3286 3287 3288 /*********************************************************************3289 1630 * CRTDLL__searchenv (CRTDLL.260) 3290 1631 */ 3291 void CDECL CRTDLL__searchenv(c onst char *file,constchar *var,char *path )1632 void CDECL CRTDLL__searchenv(char *file, char *var,char *path ) 3292 1633 { 3293 1634 dprintf2(("CRTDLL: _searchenv\n")); 3294 char *env = CRTDLL_getenv(var); 3295 3296 char *x; 3297 char *y; 3298 char *FilePart; 3299 x = strchr(env,'='); 3300 if ( x != NULL ) { 3301 *x = 0; 3302 x++; 3303 } 3304 y = strchr(env,';'); 3305 while ( y != NULL ) { 3306 *y = 0; 3307 if ( SearchPathA(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) { 3308 return; 3309 } 3310 x = y+1; 3311 y = strchr(env,';'); 3312 } 3313 return; 1635 _searchenv(file, var, path); 3314 1636 } 3315 1637 … … 3318 1640 * CRTDLL__seterrormode (CRTDLL.261) 3319 1641 */ 3320 void CDECL CRTDLL__seterrormode(int i)1642 void CDECL CRTDLL__seterrormode(int uMode) 3321 1643 { 3322 1644 dprintf2(("CRTDLL: _seterrormode\n")); 3323 SetErrorMode( i);1645 SetErrorMode(uMode); 3324 1646 return; 3325 1647 } … … 3336 1658 } 3337 1659 3338 /*********************************************************************3339 * CRTDLL__setjmp3 (CRTDLL.262)3340 */3341 int CDECL CRTDLL__setjmp3( jmp_buf env )3342 {3343 //TODO:3344 dprintf2(("CRTDLL: _setjmp3 -> setjmp (NOT IDENTICAL!!!)\n"));3345 return(setjmp( env));3346 }3347 3348 1660 3349 1661 /********************************************************************* … … 3358 1670 3359 1671 /********************************************************************* 3360 * _setsystime (CRTDLL.264)3361 */3362 unsigned int CDECL CRTDLL__setsystime(struct tm *tp, unsigned int ms)3363 {3364 dprintf(("CRTDLL: _setsystime not implemented.\n"));3365 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);3366 return FALSE;3367 }3368 3369 3370 /*********************************************************************3371 1672 * _sleep (CRTDLL.265) 3372 1673 */ 3373 1674 VOID CDECL CRTDLL__sleep(unsigned long timeout) 3374 1675 { 3375 dprintf2((" CRTDLL__sleep for %ld milliseconds\n",timeout));1676 dprintf2(("_sleep for %ld milliseconds\n",timeout)); 3376 1677 Sleep((timeout)?timeout:1); 3377 1678 } … … 3379 1680 3380 1681 /********************************************************************* 3381 * _sopen (CRTDLL.268)3382 */3383 int CDECL CRTDLL__sopen( const char *s, int i1, int i2, ... )3384 {3385 dprintf(("CRTDLL: _sopen not implemented.\n"));3386 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);3387 return FALSE;3388 }3389 3390 3391 /*********************************************************************3392 1682 * CRTDLL__spawnl (CRTDLL.269) 3393 1683 */ 3394 int CDECL CRTDLL__spawnl(int nMode, c onst char* szPath, const char* szArgv0,...)1684 int CDECL CRTDLL__spawnl(int nMode, char* szPath, char* szArgv0, va_list arg) 3395 1685 { 3396 1686 dprintf2(("CRTDLL: _spawnl\n")); 3397 char *szArg[100]; 3398 const char *a; 3399 int i = 0; 3400 va_list l = 0; 3401 va_start(l,szArgv0); 3402 do { 3403 a = va_arg(l,const char *); 3404 szArg[i++] = (char *)a; 3405 } while ( a != NULL && i < 100 ); 3406 3407 return _spawnve(nMode, (char*)szPath, szArg, _environ); 1687 return (_spawnl(nMode, szPath, szArgv0, arg)); 3408 1688 } 3409 1689 … … 3412 1692 * CRTDLL__spawnle (CRTDLL.270) 3413 1693 */ 3414 int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, ... ) 3415 { 3416 dprintf2(("CRTDLL: _spawnle not correct implemented.\n")); 3417 char *szArg[100]; 3418 char *a; 3419 char *ptr; 3420 int i = 0; 3421 va_list l = 0; 3422 va_start(l,szArgv0); 3423 do { 3424 a = (char*)va_arg(l,const char *); 3425 szArg[i++] = (char *)a; 3426 } while ( a != NULL && i < 100 ); 3427 3428 3429 // szArg0 is passed and not environment if there is only one parameter; 3430 3431 if ( i >=2 ) { 3432 ptr = szArg[i-2]; 3433 szArg[i-2] = NULL; 3434 } 3435 else 3436 ptr = NULL; 3437 3438 return _spawnve(mode, path, szArg, (char**)ptr); 1694 int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, va_list arg ) 1695 { 1696 dprintf2(("CRTDLL: _spawnle\n")); 1697 return (_spawnle(mode, path, (char*)szArgv0, arg)); 3439 1698 } 3440 1699 … … 3443 1702 * CRTDLL__spawnlp (CRTDLL.271) 3444 1703 */ 3445 int CDECL CRTDLL__spawnlp(int nMode, c onst char* szPath, const char* szArgv0, ...)1704 int CDECL CRTDLL__spawnlp(int nMode, char* szPath, char* szArgv0, va_list arg) 3446 1705 { 3447 1706 dprintf2(("CRTDLL: _spawnlp\n")); 3448 char *szArg[100]; 3449 const char *a; 3450 int i = 0; 3451 va_list l = 0; 3452 va_start(l,szArgv0); 3453 do { 3454 a = (const char *)va_arg(l,const char *); 3455 szArg[i++] = (char *)a; 3456 } while ( a != NULL && i < 100 ); 3457 return _spawnvpe(nMode, (char*)szPath,szArg, _environ); 1707 return (_spawnlp(nMode, szPath, szArgv0, arg)); 3458 1708 } 3459 1709 … … 3462 1712 * CRTDLL__spawnlpe (CRTDLL.272) 3463 1713 */ 3464 int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, ... ) 3465 { 3466 dprintf2(("CRTDLL: _spawnlpe not correct implemented.\n")); 3467 char *szArg[100]; 3468 const char *a; 3469 char *ptr; 3470 int i = 0; 3471 va_list l = 0; 3472 va_start(l,szArgv0); 3473 do { 3474 a = (char *)va_arg(l,const char *); 3475 szArg[i++] = (char *)a; 3476 } while ( a != NULL && i < 100 ); 3477 3478 3479 // szArg0 is passed and not environment if there is only one parameter; 3480 3481 if ( i >=2 ) { 3482 ptr = szArg[i-2]; 3483 szArg[i-2] = NULL; 3484 } 3485 else 3486 ptr = NULL; 3487 3488 return _spawnvpe(mode, path, szArg, (char**)ptr); 1714 int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, va_list arg ) 1715 { 1716 dprintf2(("CRTDLL: _spawnlpe\n")); 1717 return (_spawnlpe(mode, path, szArgv0, arg)); 3489 1718 } 3490 1719 … … 3530 1759 3531 1760 /********************************************************************* 1761 * _splitpath (CRTDLL.277) 1762 */ 1763 void CDECL CRTDLL__splitpath( char *path, char *drive, char *dir, char *fname, char *ext ) 1764 { 1765 dprintf2(("CRTDLL: _splitpath")); 1766 _splitpath( path, drive, dir, fname, ext); 1767 } 1768 1769 1770 /********************************************************************* 3532 1771 * CRTDLL__stat (CRTDLL.278) 3533 1772 */ … … 3550 1789 3551 1790 /********************************************************************* 3552 * CRTDLL__strdate (CRTDLL.281)3553 */3554 char * CDECL CRTDLL__strdate( char *buf )3555 {3556 dprintf2(("CRTDLL: _strdate\n"));3557 return(_strdate(buf));3558 }3559 3560 3561 /*********************************************************************3562 * CRTDLL__strdec (CRTDLL.282)3563 */3564 char * CDECL CRTDLL__strdec( const char *, const char *p )3565 {3566 dprintf2(("CRTDLL: _strdec\n"));3567 return( (char *)(p-1) );3568 }3569 3570 3571 /*********************************************************************3572 * CRTDLL__strdup (CRTDLL.283)3573 */3574 LPSTR CDECL CRTDLL__strdup(LPCSTR ptr)3575 {3576 dprintf2(("CRTDLL: _strdup\n"));3577 return HEAP_strdupA(GetProcessHeap(),0,ptr);3578 }3579 3580 3581 /*********************************************************************3582 * _strerror (CRTDLL.284)3583 */3584 char * CDECL CRTDLL__strerror(const char *s)3585 {3586 dprintf(("CRTDLL: _strerror not implemented\n"));3587 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);3588 return FALSE;3589 // return (_strerror(s));3590 }3591 3592 3593 /*********************************************************************3594 * CRTDLL__stricoll (CRTDLL.286)3595 */3596 int CDECL CRTDLL__stricoll( const char *s1, const char *s2 )3597 {3598 dprintf2(("CRTDLL: _stricoll\n"));3599 return stricmp(s1,s2);3600 }3601 3602 3603 /*********************************************************************3604 * CRTDLL__strinc (CRTDLL.287)3605 */3606 char * CDECL CRTDLL__strinc( const char *p )3607 {3608 dprintf2(("CRTDLL: _strinc\n"));3609 return( (char *)(p+1) );3610 }3611 3612 3613 /*********************************************************************3614 * CRTDLL__strncnt (CRTDLL.289)3615 */3616 size_t CDECL CRTDLL__strncnt( const char *p, size_t l )3617 {3618 dprintf2(("CRTDLL: _strncnt\n"));3619 size_t i;3620 i = strlen(p);3621 return( (i>l) ? l : i );3622 }3623 3624 /*********************************************************************3625 * CRTDLL__strnextc (CRTDLL.290)3626 */3627 unsigned int CDECL CRTDLL__strnextc( const char *p )3628 {3629 dprintf2(("CRTDLL: _strnextc\n"));3630 return( (unsigned int)*p );3631 }3632 3633 3634 /*********************************************************************3635 * CRTDLL__strninc (CRTDLL.292)3636 */3637 char * CDECL CRTDLL__strninc( const char *p, size_t l )3638 {3639 dprintf2(("CRTDLL: _strninc\n"));3640 return( (char *)(p+l) );3641 }3642 3643 3644 /*********************************************************************3645 * CRTDLL__strnset (CRTDLL.293)3646 */3647 char * CDECL CRTDLL__strnset(char* szToFill, int szFill, size_t sizeMaxFill)3648 {3649 dprintf2(("CRTDLL: _strnset\n"));3650 char *t = szToFill;3651 int i = 0;3652 while( *szToFill != 0 && i < sizeMaxFill)3653 {3654 *szToFill = szFill;3655 szToFill++;3656 i++;3657 }3658 return t;3659 }3660 3661 3662 /*********************************************************************3663 * CRTDLL__strrev (CRTDLL.294)3664 */3665 char * CDECL CRTDLL__strrev( char *s )3666 {3667 dprintf2(("CRTDLL: _strrev\n"));3668 char *e;3669 char a;3670 e=s;3671 while (*e)3672 e++;3673 while (s<e) {3674 a=*s;3675 *s=*e;3676 *e=a;3677 s++;3678 e--;3679 }3680 return s;3681 }3682 3683 3684 /*********************************************************************3685 * CRTDLL__strset (CRTDLL.295)3686 */3687 char * CDECL CRTDLL__strset(char* szToFill, int szFill)3688 {3689 dprintf2(("CRTDLL: _strset\n"));3690 char *t = szToFill;3691 while( *szToFill != 0 )3692 {3693 *szToFill = szFill;3694 szToFill++;3695 }3696 return t;3697 }3698 3699 3700 /*********************************************************************3701 * CRTDLL__strspnp (CRTDLL.296)3702 */3703 char * CDECL CRTDLL__strspnp( const char *p1, const char *p2 )3704 {3705 dprintf2(("CRTDLL: _strspnp\n"));3706 return( (*(p1 += strspn(p1,p2))!='\0') ? (char*)p1 : NULL );3707 }3708 3709 3710 /*********************************************************************3711 * CRTDLL__strtime (CRTDLL.297)3712 */3713 char * CDECL CRTDLL__strtime( char *buf )3714 {3715 dprintf2(("CRTDLL: _strtime\n"));3716 return (_strtime(buf));3717 }3718 3719 3720 /*********************************************************************3721 1791 * CRTDLL__swab (CRTDLL.299) 3722 1792 */ … … 3769 1839 3770 1840 /********************************************************************* 3771 * _ tzset (CRTDLL.308)3772 */ 3773 void CDECL CRTDLL__tzset( void)3774 { 3775 dprintf (("CRTDLL: _tzset not implemented.\n"));3776 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);1841 * _ultoa (CRTDLL.309) 1842 */ 1843 LPSTR CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix) 1844 { 1845 dprintf2(("CRTDLL: _ultoa\n")); 1846 return _ultoa(x,buf,radix); 3777 1847 } 3778 1848 … … 3823 1893 3824 1894 /********************************************************************* 3825 * CRTDLL__unloaddll (CRTDLL.313)1895 * _unloaddll (CRTDLL.313) 3826 1896 */ 3827 1897 int CDECL CRTDLL__unloaddll(void *handle) … … 3833 1903 3834 1904 /********************************************************************* 3835 * CRTDLL__utime(CRTDLL.314)1905 * _utime (CRTDLL.314) 3836 1906 */ 3837 1907 int CDECL CRTDLL__utime( char *path, struct utimbuf * times ) … … 3843 1913 3844 1914 /********************************************************************* 3845 * CRTDLL__vsnwprintf (CRTDLL.316) 3846 */ 3847 int CDECL CRTDLL__vsnwprintf( wchar_t *s1, size_t n, const wchar_t *s2, va_list arg ) 3848 { 3849 dprintf(("CRTDLL: _vsnwprintf not implemented.\n")); 3850 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 3851 return FALSE; 3852 } 3853 3854 3855 /********************************************************************* 3856 * CRTDLL__wcsdup (CRTDLL.317) 3857 */ 3858 LPWSTR CDECL CRTDLL__wcsdup( LPCWSTR str ) 3859 { 3860 dprintf2(("CRTDLL: _wcsdup\n")); 3861 LPWSTR ret = NULL; 3862 if (str) 3863 { 3864 int size = (wcslen((const wchar_t*)str) + 1) * sizeof(WCHAR); 3865 // FIXME ret = CRTDLL_malloc( size ); 3866 if (ret) memcpy( ret, str, size ); 3867 } 3868 return ret; 3869 } 3870 3871 3872 /********************************************************************* 3873 * CRTDLL__wcsicoll (CRTDLL.319) 3874 */ 3875 int CDECL CRTDLL__wcsicoll( LPCWSTR str1, LPCWSTR str2 ) 3876 { 3877 dprintf2(("CRTDLL: _wcsicoll\n")); 3878 return CRTDLL__wcsicmp( str1, str2 ); 3879 } 3880 3881 3882 /********************************************************************* 3883 * CRTDLL__wcsnset (CRTDLL.322) 3884 */ 3885 LPWSTR CDECL CRTDLL__wcsnset( LPWSTR str, WCHAR c, INT n ) 3886 { 3887 dprintf2(("CRTDLL: _wcsnset\n")); 3888 LPWSTR ret = str; 3889 while ((n-- > 0) && *str) *str++ = c; 3890 return ret; 3891 } 3892 3893 3894 /********************************************************************* 3895 * CRTDLL__wcsrev (CRTDLL.323) 3896 */ 3897 LPWSTR CDECL CRTDLL__wcsrev( LPWSTR str ) 3898 { 3899 dprintf2(("CRTDLL: _wcsrev\n")); 3900 LPWSTR ret = str; 3901 LPWSTR end = str + wcslen((const wchar_t*)str) - 1; 3902 while (end > str) 3903 { 3904 WCHAR t = *end; 3905 *end-- = *str; 3906 *str++ = t; 3907 } 3908 return ret; 3909 } 3910 3911 3912 /********************************************************************* 3913 * CRTDLL__wcsset (CRTDLL.324) 3914 */ 3915 LPWSTR CDECL CRTDLL__wcsset( LPWSTR str, WCHAR c ) 3916 { 3917 dprintf2(("CRTDLL: _wcsset\n")); 3918 LPWSTR ret = str; 3919 while (*str) *str++ = c; 3920 return ret; 1915 * _vsnprintf (CRTDLL.315) 1916 */ 1917 int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg ) 1918 { 1919 dprintf2(("CRTDLL: _vsnprintf(%08xh, %08xh, %08xh)\n", 1920 s, 1921 bufsize, 1922 format)); 1923 1924 return wvsnprintfA(s, bufsize, format, arg); 3921 1925 } 3922 1926 … … 3973 1977 3974 1978 /********************************************************************* 3975 * isleadbyte(CRTDLL.335)1979 * abort (CRTDLL.335) 3976 1980 */ 3977 1981 void CDECL CRTDLL_abort( void ) … … 3983 1987 3984 1988 /********************************************************************* 3985 * acos (CRTDLL.336) 1989 * abs (CRTDLL.336) 1990 */ 1991 double CDECL CRTDLL_abs(double d) 1992 { 1993 dprintf2(("CRTDLL: abs(%f)\n", 1994 d)); 1995 1996 return (abs(d)); 1997 } 1998 1999 2000 /********************************************************************* 2001 * acos (CRTDLL.337) 3986 2002 */ 3987 2003 double CDECL CRTDLL_acos( double x ) … … 4013 2029 4014 2030 /********************************************************************* 2031 * atan (CRTDLL.340) 2032 */ 2033 double CDECL CRTDLL_atan(double d) 2034 { 2035 dprintf2(("CRTDLL: atan(%f)\n", 2036 d)); 2037 2038 return (atan(d)); 2039 } 2040 2041 2042 /********************************************************************* 4015 2043 * atan2 (CRTDLL.341) 4016 2044 */ … … 4025 2053 * atexit (CRTDLL.342) 4026 2054 */ 4027 int CDECL CRTDLL_atexit( register void ( *func )( void ) ) 4028 { 4029 dprintf(("CRTDLL: atexit not implemented.\n")); 4030 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 4031 return FALSE; 2055 int CDECL CRTDLL_atexit(void (*func)(void)) 2056 { 2057 dprintf(("CRTDLL: atexit\n")); 2058 if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0])) 2059 return -1; 2060 _atexit_v[_atexit_n++] = func; 2061 return 0; 4032 2062 } 4033 2063 … … 4042 2072 } 4043 2073 2074 2075 /********************************************************************* 2076 * atoi (CRTDLL.344) 2077 */ 2078 int CDECL CRTDLL_atoi(LPSTR str) 2079 { 2080 dprintf2(("CRTDLL: atoi(%s)\n", 2081 str)); 2082 2083 return (atoi(str)); 2084 } 2085 2086 2087 /********************************************************************* 2088 * atol (CRTDLL.345) 2089 */ 2090 long CDECL CRTDLL_atol(LPSTR str) 2091 { 2092 dprintf2(("CRTDLL: atol(%s)\n", 2093 str)); 2094 2095 return (atol(str)); 2096 } 2097 2098 2099 /********************************************************************* 2100 * bsearch (CRTDLL.346) 2101 */ 2102 void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width, 2103 int (* CDECL compare)(const void *key, const void *element)) 2104 { 2105 int left, right, median, sign; 2106 const void *element; 2107 2108 if (width == 0) 2109 return 0; 2110 left = 1; right = num; 2111 while (left <= right) 2112 { 2113 median = (left + right) / 2; 2114 element = (void *)((char *)base + (median-1)*width); 2115 sign = compare (key, element); 2116 if (sign == 0) 2117 return (void *)element; 2118 if (sign > 0) 2119 left = median + 1; 2120 else 2121 right = median - 1; 2122 } 2123 return 0; 2124 } 2125 2126 4044 2127 /********************************************************************* 4045 2128 * calloc (CRTDLL.347) … … 4053 2136 4054 2137 /********************************************************************* 2138 * ceil (CRTDLL.348) 2139 */ 2140 double CDECL CRTDLL_ceil(double d) 2141 { 2142 dprintf2(("CRTDLL: ceil(%f)\n", 2143 d)); 2144 return (ceil(d)); 2145 } 2146 2147 2148 /********************************************************************* 4055 2149 * clearerr (CRTDLL.349) 4056 2150 */ … … 4073 2167 4074 2168 /********************************************************************* 2169 * cos (CRTDLL.351) 2170 */ 2171 double CDECL CRTDLL_cos(double d) 2172 { 2173 dprintf2(("CRTDLL: cos(%f)\n", 2174 d)); 2175 2176 return (cos(d)); 2177 } 2178 2179 2180 /********************************************************************* 4075 2181 * cosh (CRTDLL.352) 4076 2182 */ … … 4133 2239 4134 2240 /********************************************************************* 2241 * fabs (CRTDLL.358) 2242 */ 2243 double CDECL CRTDLL_fabs(double d) 2244 { 2245 dprintf2(("CRTDLL: fabs(%f)\n", 2246 d)); 2247 2248 return (fabs(d)); 2249 } 2250 2251 2252 /********************************************************************* 4135 2253 * fclose (CRTDLL.359) 4136 2254 */ … … 4203 2321 4204 2322 /********************************************************************* 4205 * fgetwc (CRTDLL.366) 4206 */ 4207 wint_t CDECL CRTDLL_fgetwc( FILE *f ) 4208 { 4209 dprintf2(("CRTDLL: fgetwc\n")); 4210 return (fgetwc(f)); 2323 * floor (CRTDLL.367) 2324 */ 2325 double CDECL CRTDLL_floor(double d) 2326 { 2327 dprintf2(("CRTDLL: floor(%f)\n", 2328 d)); 2329 2330 return (floor(d)); 4211 2331 } 4212 2332 … … 4235 2355 * fprintf (CRTDLL.370) 4236 2356 */ 4237 INT CDECL CRTDLL_fprintf( CRTDLL_FILE *file, LPSTR format, ...)2357 INT CDECL CRTDLL_fprintf( FILE *file, LPSTR format, va_list arg ) 4238 2358 { 4239 2359 dprintf2(("CRTDLL: fprintf\n")); 4240 va_list valist; 4241 INT res; 4242 4243 va_start( valist, format ); 4244 res = CRTDLL_vfprintf( file, format, valist ); 4245 va_end( valist ); 4246 return res; 2360 return (fprintf(file, format, arg)); 4247 2361 } 4248 2362 … … 4268 2382 4269 2383 4270 /*********************************************************************4271 * fputwc (CRTDLL.373)4272 */4273 wint_t CDECL CRTDLL_fputwc( wint_t wc, FILE *strm )4274 {4275 dprintf2(("CRTDLL: fputwc\n"));4276 return (fputwc(wc, strm));4277 }4278 4279 2384 4280 2385 /********************************************************************* … … 4321 2426 * fscanf (CRTDLL.378) 4322 2427 */ 4323 int CDECL CRTDLL_fscanf( FILE*fp, const char *format, ...)2428 int CDECL CRTDLL_fscanf( FILE*fp, const char *format, va_list arg ) 4324 2429 { 4325 2430 dprintf2(("CRTDLL: fscanf\n")); 4326 #if 0 4327 va_list valist; 4328 INT res; 4329 4330 va_start( valist, format ); 4331 #ifdef HAVE_VFSCANF 4332 res = vfscanf( xlat_file_ptr(stream), format, valist ); 4333 #endif 4334 va_end( valist ); 4335 return res; 4336 #endif 4337 dprintf2(("broken\n")); 4338 return 0; 2431 return (fscanf(fp, format, arg)); 4339 2432 } 4340 2433 … … 4346 2439 { 4347 2440 dprintf2(("CRTDLL: fseek\n")); 4348 dprintf2(("file %p to 0x%08lx pos %s\n", 4349 file,offset,(whence==SEEK_SET)?"SEEK_SET": 4350 (whence==SEEK_CUR)?"SEEK_CUR": 4351 (whence==SEEK_END)?"SEEK_END":"UNKNOWN")); 4352 // FIXME if (SetFilePointer( file->handle, offset, NULL, whence ) != 0xffffffff) 4353 // FIXME return 0; 4354 dprintf2((" failed!\n")); 4355 return -1; 2441 return (fseek(file, offset, whence)); 4356 2442 } 4357 2443 … … 4378 2464 4379 2465 /********************************************************************* 4380 * fwprintf (CRTDLL.382)4381 */4382 int CDECL CRTDLL_fwprintf( FILE *iop, const wchar_t *fmt, ... )4383 {4384 dprintf(("CRTDLL: fwprintf not implemented.\n"));4385 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);4386 return FALSE;4387 }4388 4389 4390 /*********************************************************************4391 2466 * fwrite (CRTDLL.383) 4392 2467 */ 4393 DWORD CDECL CRTDLL_fwrite( LPVOID ptr, INT size, INT nmemb, CRTDLL_FILE *file ) 4394 { 4395 DWORD ret; 4396 2468 DWORD CDECL CRTDLL_fwrite( LPVOID ptr, INT size, INT nmemb, FILE *file ) 2469 { 4397 2470 dprintf2(("CRTDLL: fwrite\n")); 4398 if (!WriteFile( file->handle, ptr, size * nmemb, &ret, NULL )) 4399 dprintf2((" failed!\n")); 4400 4401 return ret / size; 4402 } 4403 4404 4405 /********************************************************************* 4406 * fwscanf (CRTDLL.384) 4407 */ 4408 int CDECL CRTDLL_fwscanf( FILE *strm, const wchar_t *format, ... ) 4409 { 4410 dprintf(("CRTDLL: fwscanf not implemented.\n")); 4411 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 4412 return FALSE; 2471 return (fwrite( ptr, size, nmemb, file)); 4413 2472 } 4414 2473 … … 4465 2524 4466 2525 /********************************************************************* 4467 * is_wctype (CRTDLL.390)4468 */4469 INT CDECL CRTDLL_is_wctype(wint_t wc, wctype_t wctypeFlags)4470 {4471 dprintf2(("CRTDLL: is_wctype\n"));4472 return ((CRTDLL_pwctype_dll[(unsigned char)(wc & 0xFF)]&wctypeFlags) == wctypeFlags );4473 }4474 4475 4476 /*********************************************************************4477 2526 * isalnum (CRTDLL.391) 4478 2527 */ … … 4485 2534 4486 2535 /********************************************************************* 2536 * isalpha (CRTDLL.392) 2537 */ 2538 int CDECL CRTDLL_isalpha(int i) 2539 { 2540 dprintf2(("CRTDLL: isalpha(%08xh)\n", 2541 i)); 2542 2543 return (isalpha(i)); 2544 } 2545 2546 2547 /********************************************************************* 4487 2548 * iscntrl (CRTDLL.393) 4488 2549 */ … … 4495 2556 4496 2557 /********************************************************************* 2558 * isdigit (CRTDLL.394) 2559 */ 2560 int CDECL CRTDLL_isdigit(int i) 2561 { 2562 dprintf2(("CRTDLL: isdigit(%08xh)\n", 2563 i)); 2564 2565 return (isdigit(i)); 2566 } 2567 2568 2569 /********************************************************************* 4497 2570 * isgraph (CRTDLL.395) 4498 2571 */ … … 4505 2578 4506 2579 /********************************************************************* 4507 * isleadbyte (CRTDLL.396) 4508 */ 4509 int CDECL CRTDLL_isleadbyte(int i) 4510 { 4511 dprintf(("CRTDLL: isleadbyte(%08xh) not implemented.\n", i)); 4512 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 4513 return FALSE; 2580 * islower (CRTDLL.397) 2581 */ 2582 int CDECL CRTDLL_islower(int i) 2583 { 2584 dprintf2(("CRTDLL: islower(%08xh)\n", 2585 i)); 2586 2587 return (islower(i)); 2588 } 2589 2590 2591 /********************************************************************* 2592 * isprint (CRTDLL.398) 2593 */ 2594 int CDECL CRTDLL_isprint(int i) 2595 { 2596 dprintf2(("CRTDLL: isprint(%08xh)\n", 2597 i)); 2598 2599 return (isprint(i)); 4514 2600 } 4515 2601 … … 4526 2612 4527 2613 /********************************************************************* 4528 * iswalnum (CRTDLL.402) 4529 */ 4530 int CDECL CRTDLL_iswalnum(wint_t i) 4531 { 4532 dprintf2(("CRTDLL: iswalnum(%08xh)\n", i)); 4533 return (iswalnum(i)); 4534 } 4535 4536 4537 /********************************************************************* 4538 * iswascii (CRTDLL.404) 4539 */ 4540 int CDECL CRTDLL_iswascii(wint_t c) 4541 { 4542 dprintf2(("CRTDLL: iswascii\n", c)); 4543 return (!((c)&(~0x7f))); 4544 } 4545 4546 4547 /********************************************************************* 4548 * iswcntrl (CRTDLL.405) 4549 */ 4550 int CDECL CRTDLL_iswcntrl(wint_t i) 4551 { 4552 dprintf2(("CRTDLL: iswcntrl(%08xh)\n", i)); 4553 return (iswcntrl(i)); 4554 } 4555 4556 4557 /********************************************************************* 4558 * iswdigit (CRTDLL.407) 4559 */ 4560 int CDECL CRTDLL_iswdigit(wint_t i) 4561 { 4562 dprintf2(("CRTDLL: iswdigit(%08xh)\n", i)); 4563 return (iswdigit(i)); 4564 } 4565 4566 4567 /********************************************************************* 4568 * iswgraph (CRTDLL.408) 4569 */ 4570 int CDECL CRTDLL_iswgraph(wint_t i) 4571 { 4572 dprintf2(("CRTDLL: iswgraph(%08xh)\n", i)); 4573 return (iswgraph(i)); 4574 } 4575 4576 4577 /********************************************************************* 4578 * iswlower (CRTDLL.409) 4579 */ 4580 int CDECL CRTDLL_iswlower(wint_t i) 4581 { 4582 dprintf2(("CRTDLL: iswlower(%08xh)\n", i)); 4583 return (iswlower(i)); 4584 } 4585 4586 4587 /********************************************************************* 4588 * iswprint (CRTDLL.410) 4589 */ 4590 int CDECL CRTDLL_iswprint(wint_t i) 4591 { 4592 dprintf2(("CRTDLL: iswprint(%08xh)\n", i)); 4593 return (iswprint(i)); 4594 } 4595 4596 4597 /********************************************************************* 4598 * iswpunct (CRTDLL.411) 4599 */ 4600 int CDECL CRTDLL_iswpunct(wint_t i) 4601 { 4602 dprintf2(("CRTDLL: iswpunct(%08xh)\n", i)); 4603 return (iswpunct(i)); 4604 } 4605 4606 4607 /********************************************************************* 4608 * iswspace (CRTDLL.412) 4609 */ 4610 int CDECL CRTDLL_iswspace(wint_t i) 4611 { 4612 dprintf2(("CRTDLL: iswspace(%08xh)\n", i)); 4613 return (iswspace(i)); 4614 } 4615 4616 4617 /********************************************************************* 4618 * iswupper (CRTDLL.413) 4619 */ 4620 int CDECL CRTDLL_iswupper(wint_t i) 4621 { 4622 dprintf2(("CRTDLL: iswupper(%08xh)\n", i)); 4623 return (iswupper(i)); 4624 } 4625 4626 4627 /********************************************************************* 4628 * iswxdigit (CRTDLL.414) 4629 */ 4630 int CDECL CRTDLL_iswxdigit(wint_t i) 4631 { 4632 dprintf2(("CRTDLL: iswxdigit(%08xh)\n", i)); 4633 return (iswxdigit(i)); 2614 * isspace (CRTDLL.400) 2615 */ 2616 int CDECL CRTDLL_isspace(int i) 2617 { 2618 dprintf2(("CRTDLL: isspace(%08xh)\n", 2619 i)); 2620 2621 return (isspace(i)); 2622 } 2623 2624 2625 /********************************************************************* 2626 * isupper (CRTDLL.401) 2627 */ 2628 int CDECL CRTDLL_isupper(int i) 2629 { 2630 dprintf2(("CRTDLL: isupper(%08xh)\n", 2631 i)); 2632 2633 return (isupper(i)); 2634 } 2635 2636 2637 /********************************************************************* 2638 * isxdigit (CRTDLL.415) 2639 */ 2640 int CDECL CRTDLL_isxdigit(int i) 2641 { 2642 dprintf2(("CRTDLL: isxdigit(%08xh)\n", i)); 2643 return (isxdigit(i)); 2644 } 2645 2646 2647 /********************************************************************* 2648 * labs (CRTDLL.416) 2649 */ 2650 long int CDECL CRTDLL_labs( long int j ) 2651 { 2652 dprintf2(("CRTDLL: labs(%08xh)\n", j)); 2653 return (labs(j)); 4634 2654 } 4635 2655 … … 4676 2696 4677 2697 /********************************************************************* 2698 * log (CRTDLL.421) 2699 */ 2700 double CDECL CRTDLL_log( double x ) 2701 { 2702 dprintf2(("CRTDLL: log(%08xh)\n", x)); 2703 return (log(x)); 2704 } 2705 2706 2707 /********************************************************************* 4678 2708 * log10 (CRTDLL.422) 4679 2709 */ … … 4706 2736 4707 2737 /********************************************************************* 4708 * mblen (CRTDLL.425)4709 */4710 INT CDECL CRTDLL_mblen( const char *s, size_t n )4711 {4712 dprintf2(("CRTDLL: mblen\n"));4713 return (mblen(s, n));4714 }4715 4716 4717 /*********************************************************************4718 * CRTDLL_mbtowc (CRTDLL.427)4719 */4720 INT CDECL CRTDLL_mbtowc( WCHAR *dst, LPCSTR str, INT n )4721 {4722 dprintf2(("CRTDLL: _mbtowc\n"));4723 wchar_t res;4724 int ret = mbtowc( &res, str, n );4725 if (dst) *dst = (WCHAR)res;4726 return ret;4727 }4728 4729 4730 /*********************************************************************4731 2738 * mktime (CRTDLL.433) 4732 2739 */ … … 4759 2766 4760 2767 /********************************************************************* 2768 * pow (CRTDLL.436) 2769 */ 2770 double CDECL CRTDLL_pow( double x, double y ) 2771 { 2772 dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y)); 2773 return pow( x, y ); 2774 } 2775 2776 2777 /********************************************************************* 4761 2778 * printf (CRTDLL.437) 4762 2779 */ 4763 int CDECL CRTDLL_printf( const char *format, ...)2780 int CDECL CRTDLL_printf( const char *format, va_list arg ) 4764 2781 { 4765 2782 dprintf2(("CRTDLL: printf\n")); 4766 va_list arg; 4767 int done; 4768 4769 va_start (arg, format); 4770 done = vprintf (format, arg); 4771 va_end (arg); 4772 return done; 2783 return (printf(format, arg)); 4773 2784 } 4774 2785 … … 4805 2816 4806 2817 /********************************************************************* 2818 * qsort (CRTDLL.441) 2819 */ 2820 void CDECL CRTDLL_qsort (void *base, size_t num, size_t width, 2821 int (*CDECL compare)(const void *x1, const void *x2)) 2822 { 2823 dprintf2(("CRTDLL: qsort\n")); 2824 if (width > 0 && num > 1 && base != 0) 2825 qsort1 ((char *)base, (char *)base+(num-1)*width, width, compare); 2826 } 2827 2828 2829 /********************************************************************* 4807 2830 * raise (CRTDLL.442) 4808 2831 */ … … 4837 2860 * remove (CRTDLL.445) 4838 2861 */ 4839 INT CDECL CRTDLL_remove(LPCSTR file) 4840 { 4841 dprintf2(("CRTDLL: remove\n")); 4842 if (!DeleteFileA(file)) 4843 return -1; 4844 return 0; 2862 INT CDECL CRTDLL_remove(const char* file) 2863 { 2864 dprintf2(("CRTDLL: remove\n")); 2865 return (remove(file)); 4845 2866 } 4846 2867 … … 4867 2888 4868 2889 /********************************************************************* 4869 * scanf (CRTDLL.448) 4870 */ 4871 int CDECL CRTDLL_scanf( const char *format, ... ) 4872 { 4873 dprintf(("CRTDLL: scanf not implemented.\n")); 4874 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 4875 return FALSE; 4876 } 4877 4878 2890 * scanf (CRTDLL.448) 2891 */ 2892 int CDECL CRTDLL_scanf( const char *format, va_list arg ) 2893 { 2894 dprintf(("CRTDLL: scanf\n")); 2895 return (scanf(format, arg)); 2896 } 2897 2898 4879 2899 /********************************************************************* 4880 2900 * setbuf (CRTDLL.449) … … 4910 2930 * signal (CRTDLL.452) 4911 2931 */ 4912 void CDECL CRTDLL_signal( int sig, void (*func)(int)) 4913 { 4914 dprintf(("CRTDLL: signal not implemented.\n")); 4915 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 2932 _SigFunc CDECL CRTDLL_signal(int sig, _SigFunc func) 2933 { 2934 dprintf(("CRTDLL: signal\n")); 2935 return (signal(sig, func)); 2936 } 2937 2938 2939 /********************************************************************* 2940 * sin (CRTDLL.453) 2941 */ 2942 double CDECL CRTDLL_sin( double x ) 2943 { 2944 dprintf2(("CRTDLL: sin(%08xh)\n", x)); 2945 return (sin(x)); 4916 2946 } 4917 2947 … … 4928 2958 4929 2959 /********************************************************************* 2960 * sprintf (CRTDLL.455) 2961 */ 2962 LPSTR CDECL CRTDLL_sprintf(LPSTR lpstrBuffer, 2963 LPSTR lpstrFormat, 2964 ...) 2965 { 2966 va_list argptr; /* -> variable argument list */ 2967 2968 dprintf2(("CRTDLL: sprintf(%08xh,%s)\n", 2969 lpstrBuffer, 2970 lpstrFormat)); 2971 2972 va_start(argptr, 2973 lpstrFormat); /* get pointer to argument list */ 2974 vsprintf(lpstrBuffer, 2975 lpstrFormat, 2976 argptr); 2977 va_end(argptr); /* done with variable arguments */ 2978 2979 return (lpstrBuffer); 2980 } 2981 2982 2983 /********************************************************************* 2984 * sqrt (CRTDLL.456) 2985 */ 2986 double CDECL CRTDLL_sqrt( double x ) 2987 { 2988 dprintf2(("CRTDLL: sqrt(%08xh)\n", x)); 2989 return (sqrt(x)); 2990 } 2991 2992 2993 /********************************************************************* 4930 2994 * srand (CRTDLL.457) 4931 2995 */ … … 4938 3002 4939 3003 /********************************************************************* 4940 * strcoll (CRTDLL.462) 4941 */ 4942 int CDECL CRTDLL_strcoll( const char *s1, const char *s2 ) 4943 { 4944 dprintf2(("CRTDLL: strcoll\n")); 4945 return strcoll(s1, s2); 4946 } 4947 4948 4949 /********************************************************************* 4950 * strerror (CRTDLL.465) 4951 */ 4952 char * CDECL CRTDLL_strerror( int errnum ) 4953 { 4954 dprintf2(("CRTDLL: strerror\n")); 4955 return strerror(errnum); 4956 } 4957 4958 4959 /********************************************************************* 4960 * strftime (CRTDLL.466) 4961 */ 4962 size_t CDECL CRTDLL_strftime( char *s, size_t maxsiz, const char *fmt, const struct tm *tp ) 4963 { 4964 dprintf2(("CRTDLL: strftime\n")); 4965 return strftime(s, maxsiz, fmt, tp); 4966 } 4967 4968 4969 /********************************************************************* 4970 * strtod (CRTDLL.475) 4971 */ 4972 double CDECL CRTDLL_strtod( const char *nptr, char **endptr ) 4973 { 4974 dprintf2(("CRTDLL: strtod\n")); 4975 return strtod(nptr, endptr); 4976 } 4977 4978 4979 /********************************************************************* 4980 * strtok (CRTDLL.476) 4981 */ 4982 char * CDECL CRTDLL_strtok( char *s1, const char *s2 ) 4983 { 4984 dprintf2(("CRTDLL: strtok\n")); 4985 return strtok(s1, s2); 4986 } 4987 4988 4989 /********************************************************************* 4990 * strtol (CRTDLL.477) 4991 */ 4992 long int CDECL CRTDLL_strtol( const char *nptr, char **endptr, int base ) 4993 { 4994 dprintf2(("CRTDLL: strtol\n")); 4995 return strtol(nptr, endptr, base); 4996 } 4997 4998 4999 /********************************************************************* 5000 * strtoul (CRTDLL.478) 5001 */ 5002 unsigned long CDECL CRTDLL_strtoul( const char *nptr, char **endptr, int base ) 5003 { 5004 dprintf2(("CRTDLL: strtoul\n")); 5005 return strtoul(nptr, endptr, base); 5006 } 5007 5008 5009 /********************************************************************* 5010 * strxfrm (CRTDLL.479) 5011 */ 5012 size_t CDECL CRTDLL_strxfrm( char *s1, const char *s2, size_t n ) 5013 { 5014 dprintf2(("CRTDLL: strxfrm\n")); 5015 return strxfrm(s1, s2, n); 5016 } 5017 5018 5019 /********************************************************************* 5020 * swscanf (CRTDLL.481) 5021 */ 5022 int CDECL CRTDLL_swscanf( const wchar_t *s1, const wchar_t *s2, ... ) 5023 { 5024 dprintf(("CRTDLL: swscanf not implemented.\n")); 5025 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 5026 return FALSE; 3004 * sscanf (CRTDLL.458) 3005 */ 3006 int CDECL CRTDLL_sscanf( const char *s, const char *format, va_list arg ) 3007 { 3008 dprintf(("CRTDLL: sscanf\n")); 3009 return (sscanf(s, format, arg)); 5027 3010 } 5028 3011 … … 5039 3022 5040 3023 /********************************************************************* 5041 * tanh (CRTDLL.485) 3024 * tan (CRTDLL.483) 3025 */ 3026 double CDECL CRTDLL_tan(double d) 3027 { 3028 dprintf2(("CRTDLL: tan(%f)\n", 3029 d)); 3030 3031 return (tan(d)); 3032 } 3033 3034 3035 /********************************************************************* 3036 * tanh (CRTDLL.484) 5042 3037 */ 5043 3038 double CDECL CRTDLL_tanh( double x ) … … 5080 3075 5081 3076 /********************************************************************* 5082 * ungetc (CRTDLL.492) 5083 */ 5084 INT CDECL CRTDLL_ungetc(int c, FILE *f) 5085 { 5086 dprintf(("CRTDLL: ungetc not implemented.\n")); 5087 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 5088 return FALSE; 5089 } 5090 5091 5092 /********************************************************************* 5093 * ungetwc (CRTDLL.493) 5094 */ 5095 wint_t CDECL CRTDLL_ungetwc( wint_t wc, FILE *strm ) 5096 { 5097 dprintf2(("CRTDLL: ungetwc\n")); 5098 return (ungetwc(wc, strm)); 5099 } 3077 * tolower (CRTDLL.488) 3078 */ 3079 int CDECL CRTDLL_tolower(int c) 3080 { 3081 dprintf2(("CRTDLL: tolower(%c)\n", 3082 c)); 3083 3084 return (tolower(c)); 3085 } 3086 3087 3088 /********************************************************************* 3089 * toupper (CRTDLL.489) 3090 */ 3091 int CDECL CRTDLL_toupper(int c) 3092 { 3093 dprintf2(("CRTDLL: toupper(%c)\n", 3094 c)); 3095 3096 return (toupper(c)); 3097 } 3098 5100 3099 5101 3100 /********************************************************************* 5102 3101 * vfprintf (CRTDLL.494) 5103 3102 */ 5104 INT CDECL CRTDLL_vfprintf( CRTDLL_FILE *file, LPSTR format, va_list args ) 5105 { 5106 dprintf2(("CRTDLL: vprintf\n")); 5107 char buffer[2048]; /* FIXME... */ 5108 vsprintf( buffer, format, args ); 5109 return CRTDLL_fwrite( buffer, 1, strlen(buffer), file ); 5110 } 5111 5112 5113 /********************************************************************* 5114 * vfwprintf (CRTDLL.495) 5115 */ 5116 int CDECL CRTDLL_vfwprintf( FILE *F, const wchar_t *s, va_list arg ) 5117 { 5118 dprintf(("CRTDLL: vfwprintf not implemented.\n")); 5119 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 5120 return FALSE; 3103 INT CDECL CRTDLL_vfprintf( FILE *file, LPSTR format, va_list args ) 3104 { 3105 dprintf2(("CRTDLL: vfprintf\n")); 3106 return (vfprintf(file, format, args)); 5121 3107 } 5122 3108 … … 5133 3119 5134 3120 /********************************************************************* 5135 * vswprintf (CRTDLL.498) 5136 */ 5137 int CDECL CRTDLL_vswprintf( wchar_t *s , size_t t, const wchar_t *format, va_list arg ) 5138 { 5139 dprintf2(("CRTDLL: vswprintf\n")); 5140 return (vswprintf(s, t, format, arg)); 5141 } 5142 5143 5144 /********************************************************************* 5145 * vwprintf (CRTDLL.499) 5146 */ 5147 int CDECL CRTDLL_vwprintf( const wchar_t *s, va_list arg) 5148 { 5149 dprintf(("CRTDLL: vwprintf not implemented.\n")); 5150 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 5151 return FALSE; 5152 } 5153 5154 5155 /********************************************************************* 5156 * wcscoll (CRTDLL.503) 5157 */ 5158 DWORD CDECL CRTDLL_wcscoll(LPCWSTR str1, LPCWSTR str2) 5159 { 5160 dprintf2(("CRTDLL: wcscoll\n")); 5161 return (wcscoll((const wchar_t*)str1, (const wchar_t*)str2)); 5162 } 5163 5164 5165 /********************************************************************* 5166 * wcsftime (CRTDLL.506) 5167 */ 5168 size_t CDECL CRTDLL_wcsftime( wchar_t *s, size_t maxsize, 5169 const wchar_t *format, const struct tm *timeptr ) 5170 { 5171 dprintf2(("CRTDLL: wcsftime\n")); 5172 return (wcsftime(s, maxsize, format, timeptr)); 5173 } 5174 5175 5176 /********************************************************************* 5177 * wcstod (CRTDLL.515) 5178 */ 5179 double CDECL CRTDLL_wcstod( const wchar_t *nptr, wchar_t **endptr ) 5180 { 5181 dprintf2(("CRTDLL: wcstod\n")); 5182 return (wcstod(nptr, endptr)); 5183 } 5184 5185 5186 /********************************************************************* 5187 * wcsxfrm (CRTDLL.520) 5188 */ 5189 size_t CDECL CRTDLL_wcsxfrm( wchar_t *s1, const wchar_t *s2, size_t n ) 5190 { 5191 dprintf2(("CRTDLL: wcsxfrm\n")); 5192 return (wcsxfrm(s1, s2, n)); 5193 } 5194 5195 5196 /********************************************************************* 5197 * wctomb (CRTDLL.521) 5198 */ 5199 int CDECL CRTDLL_wctomb( LPSTR dst, WCHAR ch ) 5200 { 5201 dprintf2(("CRTDLL: wctomb\n")); 5202 return (wctomb((char*)dst,ch)); 5203 } 5204 5205 5206 /********************************************************************* 5207 * wprintf (CRTDLL.522) 5208 */ 5209 int CDECL CRTDLL_wprintf( const wchar_t *s, ... ) 5210 { 5211 dprintf(("CRTDLL: wprintf not implemented.\n")); 5212 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 5213 return FALSE; 5214 } 5215 5216 5217 /********************************************************************* 5218 * wscanf (CRTDLL.523) 5219 */ 5220 int CDECL CRTDLL_wscanf( const wchar_t *s, ... ) 5221 { 5222 dprintf(("CRTDLL: wscanf not implemented.\n")); 5223 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 5224 return FALSE; 5225 } 5226 5227 5228 5229 /********************************************************************* 5230 * __set_errno (INTERNAL-#1) 5231 */ 5232 int __set_errno (int error) 5233 { 5234 errno = error; 5235 return error; 5236 } 5237 5238 5239 /********************************************************************* 5240 * _mbbtoupper (INTERNAL-#2) 5241 */ 5242 unsigned int _mbbtoupper(unsigned int c) 5243 { 5244 if (!CRTDLL__ismbblead(c) ) 5245 return toupper(c); 5246 5247 return c; 5248 } 5249 5250 5251 /********************************************************************* 5252 * _mbbtolower (INTERNAL-#3) 5253 */ 5254 unsigned int _mbbtolower(unsigned int c) 5255 { 5256 if (!CRTDLL__ismbblead(c) ) 5257 return tolower(c); 5258 return c; 5259 } 5260 5261 5262 /********************************************************************* 5263 * _mbclen2 (INTERNAL-#4) 5264 */ 5265 size_t _mbclen2(const unsigned int s) 5266 { 5267 return (CRTDLL__ismbblead(s>>8) && CRTDLL__ismbbtrail(s&0x00FF)) ? 2 : 1; 5268 } 5269 5270 5271 /********************************************************************* 5272 * _isinf (INTERNAL-#5) 5273 */ 5274 int _isinf(double __x) 5275 { 5276 double_t * x = (double_t *)&__x; 5277 return ( x->exponent == 0x7ff && ( x->mantissah == 0 && x->mantissal == 0 )); 5278 } 5279 5280 5281 /********************************************************************* 5282 * _filehnd (INTERNAL-#6) 5283 */ 5284 void* filehnd(int fileno) 5285 { 5286 if ( fileno < 0 ) 5287 return (void *)-1; 5288 #define STD_AUX_HANDLE 3 5289 #define STD_PRINTER_HANDLE 4 5290 5291 switch(fileno) 5292 { 5293 case 0: 5294 return (void*)GetStdHandle(STD_INPUT_HANDLE); 5295 case 1: 5296 return (void*)GetStdHandle(STD_OUTPUT_HANDLE); 5297 case 2: 5298 return (void*)GetStdHandle(STD_ERROR_HANDLE); 5299 case 3: 5300 return (void*)GetStdHandle(STD_AUX_HANDLE); 5301 case 4: 5302 return (void*)GetStdHandle(STD_PRINTER_HANDLE); 5303 default: 5304 break; 5305 } 5306 5307 if ( fileno >= maxfno ) 5308 return (void *)-1; 5309 5310 if ( fileno_modes[fileno].fd == -1 ) 5311 return (void *)-1; 5312 return (void*)fileno_modes[fileno].hFile; 5313 } 3121 * vsprintf (CRTDLL.497) 3122 */ 3123 int CDECL CRTDLL_vsprintf( char *s, const char *format, va_list arg ) 3124 { 3125 dprintf2(("CRTDLL: vsprintf(%08xh, %08xh)\n", s, format)); 3126 return (vsprintf(s, format, arg)); 3127 } 3128 3129 3130 /********************************************************************* 3131 * CRTDLL__itow (CRTDLL.600) 3132 */ 3133 char * CDECL CRTDLL__itow(int i, char *s, int r) 3134 { 3135 dprintf(("CRTDLL: _itow(%08xh, %08xh, %08xh) no unicode support !\n", 3136 i, 3137 s, 3138 r)); 3139 3140 return (itoa(i,s,r)); 3141 } 3142 3143 3144 /********************************************************************* 3145 * CRTDLL__setjmp3 (CRTDLL.600) 3146 */ 3147 int CDECL CRTDLL__setjmp3( jmp_buf env ) 3148 { 3149 //TODO: 3150 dprintf2(("CRTDLL: _setjmp3 -> setjmp (NOT IDENTICAL!!!)\n")); 3151 return(setjmp( env)); 3152 } -
trunk/src/crtdll/crtinc.h
r2182 r2618 1 /* $Id: crtinc.h,v 1.1 3 1999-12-21 13:46:25sandervl Exp $ */1 /* $Id: crtinc.h,v 1.14 2000-02-03 21:37:49 sandervl Exp $ */ 2 2 3 3 /* Definitions for the CRTDLL library (CRTDLL.DLL) 4 4 * 5 * Copyright 1999 Jens Wiessner 5 * Copyright 1999-2000 Jens Wiessner 6 * 6 7 */ 7 8 8 #define MB_LEN_MAX 2 9 9 10 #ifndef MAX_PATHNAME_LEN 10 11 #define MAX_PATHNAME_LEN 260 … … 16 17 #define Heap_Free(a) HeapFree(CRTDLL_hHeap, 0, (PVOID)a) 17 18 18 // MBC Defs 19 #define _MBC_SINGLE 0 20 #define _MBC_LEAD 1 21 #define _MBC_TRAIL 2 22 #define _MBC_ILLEGAL -1 23 24 #define _MB_CP_SBCS 0 25 #define _MB_CP_OEM -2 26 #define _MB_CP_ANSI -3 27 #define _MB_CP_LOCALE -4 28 29 #define _KNJ_M ((char)0x01) /* Non-punctuation of Kana-set */ 30 #define _KNJ_P ((char)0x02) /* Punctuation of Kana-set */ 31 #define _KNJ_1 ((char)0x04) /* Legal 1st byte of double byte stream */ 32 #define _KNJ_2 ((char)0x08) /* Legal 2nd btye of double byte stream */ 33 34 #define ___ 0 35 #define _1_ _KNJ_1 /* Legal 1st byte of double byte code */ 36 #define __2 _KNJ_2 /* Legal 2nd byte of double byte code */ 37 #define _M_ _KNJ_M /* Non-puntuation in Kana-set */ 38 #define _P_ _KNJ_P /* Punctuation of Kana-set */ 39 #define _12 (_1_|__2) 40 #define _M2 (_M_|__2) 41 #define _P2 (_P_|__2) 42 43 #define CASE_DIFF (0x8281 - 0x8260) 44 45 46 // fpclass Defs 47 #define FP_SNAN 0x0001 // signaling NaN 48 #define FP_QNAN 0x0002 // quiet NaN 49 #define FP_NINF 0x0004 // negative infinity 50 #define FP_PINF 0x0200 // positive infinity 51 #define FP_NDENORM 0x0008 // negative denormalized non-zero 52 #define FP_PDENORM 0x0010 // positive denormalized non-zero 53 #define FP_NZERO 0x0020 // negative zero 54 #define FP_PZERO 0x0040 // positive zero 55 #define FP_NNORM 0x0080 // negative normalized non-zero 56 #define FP_PNORM 0x0100 // positive normalized non-zero 57 19 //SvL: per process heap for CRTDLL 20 HANDLE CRTDLL_hHeap = 0; 21 int __fileno_alloc(HANDLE hFile, int mode); 58 22 59 23 // Defs 60 24 #define DOSFS_GetFullName(a,b,c) strcpy(c,a) 61 25 62 #if defined(__GNUC__) && defined(__i386__)63 #define USING_REAL_FPU64 #define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )65 #define POP_FPU(x) DO_FPU("fstpl",x)66 #endif67 26 68 27 #if (__IBMCPP__ > 300) … … 86 45 87 46 /* Definition for _cabs */ 88 struct _complex47 struct complex 89 48 { 90 49 double x; /* Real part */ 91 50 double y; /* Imaginary part */ 92 51 }; 93 94 #ifndef _DISKFREE_T_DEFINED95 #define _DISKFREE_T_DEFINED96 #define _DISKFREE_T_DEFINED_97 struct _diskfree_t {98 unsigned total_clusters;99 unsigned avail_clusters;100 unsigned sectors_per_cluster;101 unsigned bytes_per_sector;102 };103 #define diskfree_t _diskfree_t104 #endif105 106 52 107 53 typedef VOID (*new_handler_type)(VOID); … … 115 61 static CRTDLL_FILE * const CRTDLL_stderr = &CRTDLL_iob[2]; 116 62 static new_handler_type new_handler; 63 117 64 118 65 // CRTDLL Exports … … 148 95 149 96 150 // CRTDLL Functions151 CRTDLL_FILE * CDECL CRTDLL__fdopen(INT handle, LPCSTR mode);152 INT CDECL CRTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 );153 INT CDECL CRTDLL_vfprintf( CRTDLL_FILE *file, LPSTR format, va_list args );154 VOID * CDECL CRTDLL_malloc(DWORD size);155 long CDECL CRTDLL__lseek(int handle,long offset,int origin);156 long CDECL CRTDLL__filelength( int i );157 VOID CDECL CRTDLL__exit(DWORD ret);158 INT CDECL CRTDLL_isalnum(int i);159 int CDECL CRTDLL_isgraph(int i);160 int CDECL CRTDLL__access(const char *path,int mode);161 int CDECL CRTDLL__getch(void);162 size_t CDECL CRTDLL_fread( void *ptr, size_t size, size_t n, FILE *fp );163 int CDECL CRTDLL__mbbtype( unsigned char c, int type );164 unsigned char * CDECL CRTDLL__mbscpy( unsigned char *s1, const unsigned char *s2 );165 LPSTR CDECL CRTDLL__mbsinc( LPCSTR str );166 INT CDECL CRTDLL__mbslen( LPCSTR str );167 int CDECL CRTDLL__ismbbkalnum( unsigned int c );168 int CDECL CRTDLL__ismbbkana( unsigned int c );169 int CDECL CRTDLL__ismbbalpha( unsigned int c );170 int CDECL CRTDLL__ismbbtrail( unsigned int c );171 int CDECL CRTDLL__ismbblead( unsigned int c );172 char * CDECL CRTDLL_getenv( const char *name );173 int CDECL CRTDLL__isnan( double __x );174 void * CDECL CRTDLL__get_osfhandle( int fileno );175 176 97 // 177 98 // Definitions for internal functions 178 99 // 179 int __set_errno (int error); 180 unsigned int _mbbtoupper(unsigned int c); 181 unsigned int _mbbtolower(unsigned int c); 182 size_t _mbclen2(const unsigned int s); 183 int _isinf(double __x); 184 void *filehnd(int fileno); 185 186 187 // 188 // Defs for filehnd 189 // 190 typedef struct _fileno_modes_type 191 { 192 HANDLE hFile; 193 int mode; 194 int fd; 195 } fileno_modes_type; 196 197 fileno_modes_type *fileno_modes = NULL; 198 199 int maxfno = 5; 200 int minfno = 5; 201 202 203 // 204 // MBC Includes 205 // 206 static unsigned short han_to_zen_ascii_table[0x5f] = { 207 0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166, 208 0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e, 209 0x824f, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256, 210 0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148, 211 0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266, 212 0x8267, 0x8268, 0x8269, 0x826a, 0x826b, 0x826c, 0x826d, 0x826e, 213 0x826f, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276, 214 0x8277, 0x8278, 0x8279, 0x816d, 0x818f, 0x816e, 0x814f, 0x8151, 215 0x8165, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287, 216 0x8288, 0x8289, 0x828a, 0x828b, 0x828c, 0x828d, 0x828e, 0x828f, 217 0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297, 218 0x8298, 0x8299, 0x829a, 0x816f, 0x8162, 0x8170, 0x8150 219 }; 220 static unsigned short han_to_zen_kana_table[0x40] = { 221 0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340, 222 0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362, 223 0x815b, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c, 224 0x834e, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c, 225 0x835e, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b, 226 0x836c, 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d, 227 0x837e, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389, 228 0x838a, 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, 0x814a, 0x814b 229 }; 230 static unsigned char zen_to_han_kana_table[0x8396-0x8340+1] = { 231 0xa7, 0xb1, 0xa8, 0xb2, 0xa9, 0xb3, 0xaa, 0xb4, 232 0xab, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb8, 0xb8, 233 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xbc, 0xbc, 234 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0xc0, 0xc0, 235 0xc1, 0xc1, 0xaf, 0xc2, 0xc2, 0xc3, 0xc3, 0xc4, 236 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xca, 237 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd, 238 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xd0, 0, 239 0xd1, 0xd2, 0xd3, 0xac, 0xd4, 0xad, 0xd5, 0xae, 240 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdc, 241 0xb2, 0xb4, 0xa6, 0xdd, 0xb3, 0xb6, 0xb9 242 }; 243 #define ZTOH_SYMBOLS 9 244 static unsigned short zen_to_han_symbol_table_1[ZTOH_SYMBOLS] = { 245 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x815b, 0x814a, 0x814b 246 }; 247 static unsigned char zen_to_han_symbol_table_2[ZTOH_SYMBOLS] = { 248 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xb0, 0xde, 0xdf 249 }; 250 #define ISKANA(c) ((c) >= 0xa1 && (c) <= 0xdf) 251 #define JISHIRA(c) ((c) >= 0x829f && (c) <= 0x82f1) 252 #define JISKANA(c) ((c) >= 0x8340 && (c) <= 0x8396 && (c) != 0x837f) 253 #define JTOKANA(c) ((c) <= 0x82dd ? (c) + 0xa1 : (c) + 0xa2) 254 255 char _jctype[257] = { 256 /*-1*/ ___, 257 /*0x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, 258 /*1x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, 259 /*2x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, 260 /*3x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___, 261 /*4x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2, 262 /*5x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2, 263 /*6x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2, 264 /*7x*/ __2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,__2,___, 265 /*8x*/ __2,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12, 266 /*9x*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12, 267 /*Ax*/ __2,_P2,_P2,_P2,_P2,_P2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, 268 /*Bx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, 269 /*Cx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, 270 /*Dx*/ _M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2,_M2, 271 /*Ex*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12, 272 /*Fx*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___ 273 }; 100 void qsort1 (char*, char*, size_t, 101 int (* CDECL)(const void*, const void*)); 274 102 275 103 276 104 // syserr / sysnerr Defs 277 105 const char *CRTDLL_sys_errlist[] = { 278 __syserr00, __syserr01, __syserr02, __syserr03, __syserr04, 279 __syserr05, __syserr06, __syserr07, __syserr08, __syserr09, 280 __syserr10, __syserr11, __syserr12, __syserr13, __syserr14, 281 __syserr15, __syserr16, __syserr17, __syserr18, __syserr19, 282 __syserr20, __syserr21, __syserr22, __syserr23, __syserr24, 283 __syserr25, __syserr26, __syserr27, __syserr28, __syserr29, 284 __syserr30, __syserr31, __syserr32, __syserr33, __syserr34, 285 __syserr35, __syserr36, __syserr37, __syserr38 106 /* 0 EZERO */ "Error 0", 107 /* 1 EPERM */ "Operation not permitted", 108 /* 2 ENOENT */ "No such file or directory", 109 /* 3 ESRCH */ "No such process", 110 /* 4 EINTR */ "Interrupted system call", 111 /* 5 EIO */ "I/O error", 112 /* 6 ENXIO */ "No such device or address", 113 /* 7 E2BIG */ "Arguments or environment too big", 114 /* 8 ENOEXEC */ "Invalid executable file format", 115 /* 9 EBADF */ "Bad file number", 116 /* 10 ECHILD */ "No children", 117 /* 11 EAGAIN */ "Resource temporarily unavailable", 118 /* 12 ENOMEM */ "Not enough memory", 119 /* 13 EACCES */ "Permission denied", 120 /* 14 EFAULT */ "Bad address", 121 /* 15 ENOLCK */ "No locks available", 122 /* 16 EBUSY */ "Resource busy", 123 /* 17 EEXIST */ "File exists", 124 /* 18 EXDEV */ "Cross-device link", 125 /* 19 ENODEV */ "No such device", 126 /* 20 ENOTDIR */ "Not a directory", 127 /* 21 EISDIR */ "Is a directory", 128 /* 22 EINVAL */ "Invalid argument", 129 /* 23 ENFILE */ "Too many open files in system", 130 /* 24 EMFILE */ "Too many open files", 131 /* 25 ENOTTY */ "Inappropriate ioctl", 132 /* 26 EDEADLK */ "Resource deadlock avoided", 133 /* 27 EFBIG */ "File too large", 134 /* 28 ENOSPC */ "Disk full", 135 /* 29 ESPIPE */ "Invalid seek", 136 /* 30 EROFS */ "Read-only file system", 137 /* 31 EMLINK */ "Too many links", 138 /* 32 EPIPE */ "Broken pipe", 139 /* 33 EDOM */ "Domain error", 140 /* 34 ERANGE */ "Result too large", 141 /* 35 ENOTEMPTY */ "Directory not empty", 142 /* 36 EINPROGRESS */ "Operation now in progress", 143 /* 37 ENOSYS */ "Function not implemented", 144 /* 38 ENAMETOOLONG */ "File name too long", 145 /* 39 EDESTADDRREQ */ "Destination address required", 146 /* 40 EMSGSIZE */ "Message too long", 147 /* 41 EPROTOTYPE */ "Protocol wrong type for socket", 148 /* 42 ENOPROTOOPT */ "Option not supported by protocol", 149 /* 43 EPROTONOSUPPORT */ "Protocol not supported", 150 /* 44 ESOCKTNOSUPPORT */ "Socket type not supported", 151 /* 45 EOPNOTSUPP */ "Operation not supported on socket", 152 /* 46 EPFNOSUPPORT */ "Protocol family not supported", 153 /* 47 EAFNOSUPPORT */ "Address family not supported by protocol family", 154 /* 48 EADDRINUSE */ "Address already in use", 155 /* 49 EADDRNOTAVAIL */ "Can't assign requested address", 156 /* 50 ENETDOWN */ "Network is down", 157 /* 51 ENETUNREACH */ "Network is unreachable", 158 /* 52 ENETRESET */ "Network dropped connection on reset", 159 /* 53 ECONNABORTED */ "Software caused connection abort", 160 /* 54 ECONNRESET */ "Connection reset by peer", 161 /* 55 ENOBUFS */ "No buffer space available", 162 /* 56 EISCONN */ "Socket is already connected", 163 /* 57 ENOTCONN */ "Socket is not connected", 164 /* 58 ESHUTDOWN */ "Can't send after socket shutdown", 165 /* 59 ETOOMANYREFS */ "Too many references: can't splice", 166 /* 60 ETIMEDOUT */ "Connection timed out", 167 /* 61 ECONNREFUSED */ "Connection refused", 168 /* 62 ELOOP */ "Too many levels of symbolic links", 169 /* 63 ENOTSOCK */ "Socket operation on non-socket", 170 /* 64 EHOSTDOWN */ "Host is down", 171 /* 65 EHOSTUNREACH */ "No route to host", 172 /* 66 EALREADY */ "Operation already in progress" 286 173 }; 287 174 288 175 int __sys_nerr = sizeof(CRTDLL_sys_errlist) / sizeof(CRTDLL_sys_errlist[0]); 176 int* CRTDLL_sys_nerr_dll = &__sys_nerr; 289 177 290 int* CRTDLL_sys_nerr_dll = &__sys_nerr; 178 179 // atexit 180 void (*_atexit_v[64])(void); 181 int _atexit_n = 0; -
trunk/src/crtdll/makefile
r2177 r2618 1 # $Id: makefile,v 1. 5 1999-12-21 12:27:12sandervl Exp $1 # $Id: makefile,v 1.6 2000-02-03 21:37:49 sandervl Exp $ 2 2 3 3 # … … 22 22 TARGET = crtdll 23 23 24 OBJS = crtdll.obj bsearch.obj initterm.obj qsort.obj crt.obj asmhlp.obj 24 OBJS = crtdll.obj asmhlp.obj stubs.obj internal.obj crt_string.obj \ 25 crt_memory.obj crt_mb.obj crt_wc.obj initterm.obj 25 26 26 27 all: $(TARGET).dll $(TARGET).lib … … 42 43 43 44 44 initterm.obj: initterm.cpp 45 crtdll.obj: crtdll.cpp 46 bsearch.obj: bsearch.c 47 qsort.obj: qsort.c 48 crt.obj: crt.cpp 49 asmhlp.obj: asmhlp.asm 45 initterm.obj: initterm.cpp 46 asmhlp.obj: asmhlp.asm 47 stubs.obj: stubs.cpp 48 internal.obj: internal.cpp 49 crt_string.obj: crt_string.cpp 50 crt_mb.obj: crt_mb.cpp 51 crt_memory.obj: crt_memory.cpp 52 crt_wc.obj: crt_wc.cpp 53 54 crtdll.obj: crtdll.cpp 50 55 51 56 clean:
Note:
See TracChangeset
for help on using the changeset viewer.