Changeset 3209 for trunk/src/user32/wsprintf.cpp
- Timestamp:
- Mar 24, 2000, 12:06:54 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/wsprintf.cpp
r2804 r3209 1 /* $Id: wsprintf.cpp,v 1. 6 2000-02-16 14:34:41sandervl Exp $ */1 /* $Id: wsprintf.cpp,v 1.7 2000-03-23 23:06:54 sandervl Exp $ */ 2 2 3 3 /* … … 549 549 550 550 551 #if 0 552 //@@@PH old ODIN implementation 1999/11/04 553 /* String Manipulation Functions */ 554 555 int __cdecl wsprintfA(char *lpOut, LPCSTR lpFmt, ...) 556 { 557 int rc; 558 va_list argptr; 559 560 #ifdef DEBUG 561 WriteLog("USER32: wsprintfA\n"); 562 WriteLog("USER32: %s\n", lpFmt); 563 #endif 564 va_start(argptr, lpFmt); 565 rc = O32_wvsprintf(lpOut, (char *)lpFmt, argptr); 566 va_end(argptr); 567 #ifdef DEBUG 568 WriteLog("USER32: %s\n", lpOut); 569 #endif 570 return(rc); 571 } 572 //****************************************************************************** 573 //****************************************************************************** 574 int __cdecl wsprintfW(LPWSTR lpOut, LPCWSTR lpFmt, ...) 575 { 576 int rc; 577 char *lpFmtA; 578 char szOut[512]; 579 va_list argptr; 580 581 dprintf(("USER32: wsprintfW(%08xh,%08xh).\n", 582 lpOut, 583 lpFmt)); 584 585 lpFmtA = UnicodeToAsciiString((LPWSTR)lpFmt); 586 587 /* @@@PH 98/07/13 transform "%s" to "%ls" does the unicode magic */ 588 { 589 PCHAR pszTemp; 590 PCHAR pszTemp1; 591 ULONG ulStrings; 592 ULONG ulIndex; /* temporary string counter */ 593 594 for (ulStrings = 0, /* determine number of placeholders */ 595 pszTemp = lpFmtA; 596 597 (pszTemp != NULL) && 598 (*pszTemp != 0); 599 600 ulStrings++) 601 { 602 pszTemp = strstr(pszTemp, 603 "%s"); 604 if (pszTemp != NULL) /* skip 2 characters */ 605 { 606 pszTemp++; 607 pszTemp++; 608 } 609 else 610 break; /* leave loop immediately */ 611 } 612 613 if (ulStrings != 0) /* transformation required ? */ 614 { 615 /* now reallocate lpFmt */ 616 ulStrings += strlen(lpFmtA); /* calculate total string length */ 617 pszTemp = lpFmtA; /* save string pointer */ 618 pszTemp1 = lpFmtA; /* save string pointer */ 619 620 /* @@@PH allocation has to be compatible to FreeAsciiString !!! */ 621 lpFmtA = (char *)malloc(ulStrings + 1); 622 if (lpFmtA == NULL) /* check proper allocation */ 623 return (0); /* raise error condition */ 624 625 for (ulIndex = 0; 626 ulIndex <= ulStrings; 627 ulIndex++, 628 pszTemp++) 629 { 630 if ((pszTemp[0] == '%') && 631 (pszTemp[1] == 's') ) 632 { 633 /* replace %s by %ls */ 634 lpFmtA[ulIndex++] = '%'; 635 lpFmtA[ulIndex ] = 'l'; 636 lpFmtA[ulIndex+1] = 's'; 637 } 638 else 639 lpFmtA[ulIndex] = *pszTemp; /* just copy over the character */ 640 } 641 642 lpFmtA[ulStrings] = 0; /* string termination */ 643 644 FreeAsciiString(pszTemp1); /* the original string is obsolete */ 645 } 646 } 647 648 dprintf(("USER32: wsprintfW (%s).\n", 649 lpFmt)); 650 651 va_start(argptr, 652 lpFmt); 653 654 rc = O32_wvsprintf(szOut, 655 lpFmtA, 656 argptr); 657 658 AsciiToUnicode(szOut, 659 lpOut); 660 661 FreeAsciiString(lpFmtA); 662 return(rc); 663 } 664 //****************************************************************************** 665 //****************************************************************************** 666 int WIN32API wvsprintfA( LPSTR lpOutput, LPCSTR lpFormat, va_list arglist) 667 { 668 #ifdef DEBUG 669 WriteLog("USER32: wvsprintfA\n"); 670 #endif 671 return O32_wvsprintf(lpOutput,lpFormat,(LPCVOID*)arglist); 672 } 673 //****************************************************************************** 674 //****************************************************************************** 675 int WIN32API wvsprintfW(LPWSTR lpOutput, LPCWSTR lpFormat, va_list arglist) 676 { 677 int rc; 678 char szOut[256]; 679 char *lpFmtA; 680 681 lpFmtA = UnicodeToAsciiString((LPWSTR)lpFormat); 682 #ifdef DEBUG 683 WriteLog("USER32: wvsprintfW, DOES NOT HANDLE UNICODE STRINGS!\n"); 684 WriteLog("USER32: %s\n", lpFormat); 685 #endif 686 rc = O32_wvsprintf(szOut, lpFmtA, (LPCVOID)arglist); 687 688 AsciiToUnicode(szOut, lpOutput); 689 #ifdef DEBUG 690 WriteLog("USER32: %s\n", lpOutput); 691 #endif 692 FreeAsciiString(lpFmtA); 693 return(rc); 694 } 695 #endif 696 551
Note:
See TracChangeset
for help on using the changeset viewer.