Ignore:
Timestamp:
Sep 5, 2001, 3:19:02 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/rtlstr.c

    r5574 r6648  
     1/* $Id: rtlstr.c,v 1.4 2001-09-05 13:14:08 bird Exp $ */
    12/*
    23 * Rtl string functions
     
    2324
    2425/**************************************************************************
    25  *      RtlInitAnsiString   (NTDLL.@)
     26 *  RtlInitAnsiString   (NTDLL.@)
    2627 */
    2728void WINAPI RtlInitAnsiString( PSTRING target, LPCSTR source)
     
    3738
    3839/**************************************************************************
    39  *      RtlInitString   (NTDLL.@)
     40 *  RtlInitString   (NTDLL.@)
    4041 */
    4142void WINAPI RtlInitString( PSTRING target, LPCSTR source )
     
    4647
    4748/**************************************************************************
    48  *      RtlFreeAnsiString   (NTDLL.@)
     49 *  RtlFreeAnsiString   (NTDLL.@)
    4950 */
    5051void WINAPI RtlFreeAnsiString( PSTRING str )
     
    5556
    5657/**************************************************************************
    57  *      RtlFreeOemString   (NTDLL.@)
     58 *  RtlFreeOemString   (NTDLL.@)
    5859 */
    5960void WINAPI RtlFreeOemString( PSTRING str )
     
    6465
    6566/**************************************************************************
    66  *      RtlCopyString   (NTDLL.@)
     67 *  RtlCopyString   (NTDLL.@)
    6768 */
    6869void WINAPI RtlCopyString( STRING *dst, const STRING *src )
     
    7980
    8081/**************************************************************************
    81  *      RtlInitUnicodeString   (NTDLL.@)
     82 *  RtlInitUnicodeString   (NTDLL.@)
    8283 */
    8384void WINAPI RtlInitUnicodeString( PUNICODE_STRING target, LPCWSTR source )
     
    9394
    9495/**************************************************************************
    95  *      RtlCreateUnicodeString   (NTDLL.@)
     96 *  RtlCreateUnicodeString   (NTDLL.@)
    9697 */
    9798BOOLEAN WINAPI RtlCreateUnicodeString( PUNICODE_STRING target, LPCWSTR src )
     
    107108
    108109/**************************************************************************
    109  *      RtlCreateUnicodeStringFromAsciiz   (NTDLL.@)
     110 *  RtlCreateUnicodeStringFromAsciiz   (NTDLL.@)
    110111 */
    111112BOOLEAN WINAPI RtlCreateUnicodeStringFromAsciiz( PUNICODE_STRING target, LPCSTR src )
     
    118119
    119120/**************************************************************************
    120  *      RtlFreeUnicodeString   (NTDLL.@)
     121 *  RtlFreeUnicodeString   (NTDLL.@)
    121122 */
    122123void WINAPI RtlFreeUnicodeString( PUNICODE_STRING str )
     
    127128
    128129/**************************************************************************
    129  *      RtlCopyUnicodeString   (NTDLL.@)
     130 *  RtlCopyUnicodeString   (NTDLL.@)
    130131 */
    131132void WINAPI RtlCopyUnicodeString( UNICODE_STRING *dst, const UNICODE_STRING *src )
     
    144145
    145146/**************************************************************************
    146  *      RtlEraseUnicodeString   (NTDLL.@)
     147 *  RtlEraseUnicodeString   (NTDLL.@)
    147148 */
    148149void WINAPI RtlEraseUnicodeString( UNICODE_STRING *str )
     
    160161
    161162/******************************************************************************
    162  *      RtlCompareString   (NTDLL.@)
     163 *  RtlCompareString   (NTDLL.@)
    163164 */
    164165LONG WINAPI RtlCompareString( const STRING *s1, const STRING *s2, BOOLEAN CaseInsensitive )
     
    186187
    187188/******************************************************************************
    188  *      RtlCompareUnicodeString   (NTDLL.@)
     189 *  RtlCompareUnicodeString   (NTDLL.@)
    189190 */
    190191LONG WINAPI RtlCompareUnicodeString( const UNICODE_STRING *s1, const UNICODE_STRING *s2,
     
    213214
    214215/**************************************************************************
    215  *      RtlEqualString   (NTDLL.@)
     216 *  RtlEqualString   (NTDLL.@)
    216217 */
    217218BOOLEAN WINAPI RtlEqualString( const STRING *s1, const STRING *s2, BOOLEAN CaseInsensitive )
     
    223224
    224225/**************************************************************************
    225  *      RtlEqualUnicodeString   (NTDLL.@)
     226 *  RtlEqualUnicodeString   (NTDLL.@)
    226227 */
    227228BOOLEAN WINAPI RtlEqualUnicodeString( const UNICODE_STRING *s1, const UNICODE_STRING *s2,
     
    234235
    235236/**************************************************************************
    236  *      RtlPrefixString   (NTDLL.@)
     237 *  RtlPrefixString   (NTDLL.@)
    237238 *
    238239 * Test if s1 is a prefix in s2
     
    258259
    259260/**************************************************************************
    260  *      RtlPrefixUnicodeString   (NTDLL.@)
     261 *  RtlPrefixUnicodeString   (NTDLL.@)
    261262 *
    262263 * Test if s1 is a prefix in s2
     
    284285
    285286/*
    286         COPY BETWEEN ANSI_STRING or UNICODE_STRING
    287         there is no parameter checking, it just crashes
     287    COPY BETWEEN ANSI_STRING or UNICODE_STRING
     288    there is no parameter checking, it just crashes
    288289*/
    289290
    290291
    291292/**************************************************************************
    292  *      RtlAnsiStringToUnicodeString   (NTDLL.@)
     293 *  RtlAnsiStringToUnicodeString   (NTDLL.@)
    293294 *
    294295 * NOTES:
     
    318319
    319320/**************************************************************************
    320  *      RtlOemStringToUnicodeString   (NTDLL.@)
     321 *  RtlOemStringToUnicodeString   (NTDLL.@)
    321322 *
    322323 * NOTES
     
    347348
    348349/**************************************************************************
    349  *      RtlUnicodeStringToAnsiString   (NTDLL.@)
     350 *  RtlUnicodeStringToAnsiString   (NTDLL.@)
    350351 *
    351352 * NOTES
     
    381382
    382383/**************************************************************************
    383  *      RtlUnicodeStringToOemString   (NTDLL.@)
     384 *  RtlUnicodeStringToOemString   (NTDLL.@)
    384385 *
    385386 * NOTES
     
    415416
    416417/**************************************************************************
    417  *      RtlMultiByteToUnicodeN   (NTDLL.@)
     418 *  RtlMultiByteToUnicodeN   (NTDLL.@)
    418419 *
    419420 * NOTES
     
    431432
    432433/**************************************************************************
    433  *      RtlOemToUnicodeN   (NTDLL.@)
     434 *  RtlOemToUnicodeN   (NTDLL.@)
    434435 */
    435436NTSTATUS WINAPI RtlOemToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
     
    444445
    445446/**************************************************************************
    446  *      RtlUnicodeToMultiByteN   (NTDLL.@)
     447 *  RtlUnicodeToMultiByteN   (NTDLL.@)
    447448 */
    448449NTSTATUS WINAPI RtlUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    458459
    459460/**************************************************************************
    460  *      RtlUnicodeToOemN   (NTDLL.@)
     461 *  RtlUnicodeToOemN   (NTDLL.@)
    461462 */
    462463NTSTATUS WINAPI RtlUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    476477
    477478/**************************************************************************
    478  *      RtlUpperString   (NTDLL.@)
     479 *  RtlUpperString   (NTDLL.@)
    479480 */
    480481void WINAPI RtlUpperString( STRING *dst, const STRING *src )
     
    488489
    489490/**************************************************************************
    490  *      RtlUpcaseUnicodeString   (NTDLL.@)
     491 *  RtlUpcaseUnicodeString   (NTDLL.@)
    491492 *
    492493 * NOTES:
     
    515516
    516517/**************************************************************************
    517  *      RtlUpcaseUnicodeStringToAnsiString   (NTDLL.@)
     518 *  RtlUpcaseUnicodeStringToAnsiString   (NTDLL.@)
    518519 *
    519520 * NOTES
     
    537538
    538539/**************************************************************************
    539  *      RtlUpcaseUnicodeStringToOemString   (NTDLL.@)
     540 *  RtlUpcaseUnicodeStringToOemString   (NTDLL.@)
    540541 *
    541542 * NOTES
     
    559560
    560561/**************************************************************************
    561  *      RtlUpcaseUnicodeToMultiByteN   (NTDLL.@)
     562 *  RtlUpcaseUnicodeToMultiByteN   (NTDLL.@)
    562563 */
    563564NTSTATUS WINAPI RtlUpcaseUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    577578
    578579/**************************************************************************
    579  *      RtlUpcaseUnicodeToOemN   (NTDLL.@)
     580 *  RtlUpcaseUnicodeToOemN   (NTDLL.@)
    580581 */
    581582NTSTATUS WINAPI RtlUpcaseUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    595596
    596597/*
    597         STRING SIZE
     598    STRING SIZE
    598599*/
    599600
     
    741742
    742743/*
    743         MISC
     744    MISC
    744745*/
    745746
    746747/**************************************************************************
    747  *      RtlIsTextUnicode
    748  *
    749  *      Apply various feeble heuristics to guess whether
    750  *      the text buffer contains Unicode.
    751  *      FIXME: should implement more tests.
     748 *  RtlIsTextUnicode
     749 *
     750 *  Apply various feeble heuristics to guess whether
     751 *  the text buffer contains Unicode.
     752 *  FIXME: should implement more tests.
    752753 */
    753754DWORD WINAPI RtlIsTextUnicode(
    754         LPVOID buf,
    755         DWORD len,
    756         DWORD *pf)
    757 {
    758         LPWSTR s = buf;
    759         DWORD flags = -1, out_flags = 0;
    760 
    761         if (!len)
    762                 goto out;
    763         if (pf)
    764                 flags = *pf;
    765         /*
    766         * Apply various tests to the text string. According to the
    767         * docs, each test "passed" sets the corresponding flag in
    768         * the output flags. But some of the tests are mutually
    769         * exclusive, so I don't see how you could pass all tests ...
    770         */
    771 
    772         /* Check for an odd length ... pass if even. */
    773         if (!(len & 1))
    774                 out_flags |= IS_TEXT_UNICODE_ODD_LENGTH;
    775 
    776         /* Check for the special unicode marker byte. */
    777         if (*s == 0xFEFF)
    778                 out_flags |= IS_TEXT_UNICODE_SIGNATURE;
    779 
    780         /*
    781         * Check whether the string passed all of the tests.
    782         */
    783         flags &= ITU_IMPLEMENTED_TESTS;
    784         if ((out_flags & flags) != flags)
    785                 len = 0;
     755    LPVOID buf,
     756    DWORD len,
     757    DWORD *pf)
     758{
     759    LPWSTR s = buf;
     760    DWORD flags = -1, out_flags = 0;
     761
     762    if (!len)
     763        goto out;
     764    if (pf)
     765        flags = *pf;
     766    /*
     767    * Apply various tests to the text string. According to the
     768    * docs, each test "passed" sets the corresponding flag in
     769    * the output flags. But some of the tests are mutually
     770    * exclusive, so I don't see how you could pass all tests ...
     771    */
     772
     773    /* Check for an odd length ... pass if even. */
     774    if (!(len & 1))
     775        out_flags |= IS_TEXT_UNICODE_ODD_LENGTH;
     776
     777    /* Check for the special unicode marker byte. */
     778    if (*s == 0xFEFF)
     779        out_flags |= IS_TEXT_UNICODE_SIGNATURE;
     780
     781    /*
     782    * Check whether the string passed all of the tests.
     783    */
     784    flags &= ITU_IMPLEMENTED_TESTS;
     785    if ((out_flags & flags) != flags)
     786        len = 0;
    786787out:
    787         if (pf)
    788                 *pf = out_flags;
    789         return len;
    790 }
     788    if (pf)
     789        *pf = out_flags;
     790    return len;
     791}
Note: See TracChangeset for help on using the changeset viewer.