Changeset 6712 for trunk/src


Ignore:
Timestamp:
Sep 15, 2001, 11:47:44 AM (24 years ago)
Author:
sandervl
Message:

restored old version

Location:
trunk/src
Files:
53 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/initterm.cpp

    r6648 r6712  
    1 /* $Id: initterm.cpp,v 1.13 2001-09-05 13:14:08 bird Exp $
    2  *
     1/*
    32 * DLL entry point
    43 *
     
    5453   case DLL_THREAD_ATTACH:
    5554   case DLL_THREAD_DETACH:
    56     return NTDLL_LibMain(hinstDLL, fdwReason, fImpLoad);
     55        return NTDLL_LibMain(hinstDLL, fdwReason, fImpLoad);
    5756
    5857   case DLL_PROCESS_DETACH:
    59     NTDLL_LibMain(hinstDLL, fdwReason, fImpLoad);
    60     ctordtorTerm();
    61     return TRUE;
     58        NTDLL_LibMain(hinstDLL, fdwReason, fImpLoad);
     59        ctordtorTerm();
     60        return TRUE;
    6261   }
    6362   return FALSE;
     
    8988         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9089
    91     dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
    92          if(dllHandle == 0)
    93         return 0UL;
     90        dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     91         if(dllHandle == 0) 
     92                return 0UL;
    9493
    9594         break;
    9695      case 1 :
    9796         if(dllHandle) {
    98         UnregisterLxDll(dllHandle);
     97                UnregisterLxDll(dllHandle);
    9998         }
    10099         break;
  • trunk/src/NTDLL/rtlstr.c

    r6648 r6712  
    1 /* $Id: rtlstr.c,v 1.4 2001-09-05 13:14:08 bird Exp $ */
    21/*
    32 * Rtl string functions
     
    2423
    2524/**************************************************************************
    26  *  RtlInitAnsiString   (NTDLL.@)
     25 *      RtlInitAnsiString   (NTDLL.@)
    2726 */
    2827void WINAPI RtlInitAnsiString( PSTRING target, LPCSTR source)
     
    3837
    3938/**************************************************************************
    40  *  RtlInitString   (NTDLL.@)
     39 *      RtlInitString   (NTDLL.@)
    4140 */
    4241void WINAPI RtlInitString( PSTRING target, LPCSTR source )
     
    4746
    4847/**************************************************************************
    49  *  RtlFreeAnsiString   (NTDLL.@)
     48 *      RtlFreeAnsiString   (NTDLL.@)
    5049 */
    5150void WINAPI RtlFreeAnsiString( PSTRING str )
     
    5655
    5756/**************************************************************************
    58  *  RtlFreeOemString   (NTDLL.@)
     57 *      RtlFreeOemString   (NTDLL.@)
    5958 */
    6059void WINAPI RtlFreeOemString( PSTRING str )
     
    6564
    6665/**************************************************************************
    67  *  RtlCopyString   (NTDLL.@)
     66 *      RtlCopyString   (NTDLL.@)
    6867 */
    6968void WINAPI RtlCopyString( STRING *dst, const STRING *src )
     
    8079
    8180/**************************************************************************
    82  *  RtlInitUnicodeString   (NTDLL.@)
     81 *      RtlInitUnicodeString   (NTDLL.@)
    8382 */
    8483void WINAPI RtlInitUnicodeString( PUNICODE_STRING target, LPCWSTR source )
     
    9493
    9594/**************************************************************************
    96  *  RtlCreateUnicodeString   (NTDLL.@)
     95 *      RtlCreateUnicodeString   (NTDLL.@)
    9796 */
    9897BOOLEAN WINAPI RtlCreateUnicodeString( PUNICODE_STRING target, LPCWSTR src )
     
    108107
    109108/**************************************************************************
    110  *  RtlCreateUnicodeStringFromAsciiz   (NTDLL.@)
     109 *      RtlCreateUnicodeStringFromAsciiz   (NTDLL.@)
    111110 */
    112111BOOLEAN WINAPI RtlCreateUnicodeStringFromAsciiz( PUNICODE_STRING target, LPCSTR src )
     
    119118
    120119/**************************************************************************
    121  *  RtlFreeUnicodeString   (NTDLL.@)
     120 *      RtlFreeUnicodeString   (NTDLL.@)
    122121 */
    123122void WINAPI RtlFreeUnicodeString( PUNICODE_STRING str )
     
    128127
    129128/**************************************************************************
    130  *  RtlCopyUnicodeString   (NTDLL.@)
     129 *      RtlCopyUnicodeString   (NTDLL.@)
    131130 */
    132131void WINAPI RtlCopyUnicodeString( UNICODE_STRING *dst, const UNICODE_STRING *src )
     
    145144
    146145/**************************************************************************
    147  *  RtlEraseUnicodeString   (NTDLL.@)
     146 *      RtlEraseUnicodeString   (NTDLL.@)
    148147 */
    149148void WINAPI RtlEraseUnicodeString( UNICODE_STRING *str )
     
    161160
    162161/******************************************************************************
    163  *  RtlCompareString   (NTDLL.@)
     162 *      RtlCompareString   (NTDLL.@)
    164163 */
    165164LONG WINAPI RtlCompareString( const STRING *s1, const STRING *s2, BOOLEAN CaseInsensitive )
     
    187186
    188187/******************************************************************************
    189  *  RtlCompareUnicodeString   (NTDLL.@)
     188 *      RtlCompareUnicodeString   (NTDLL.@)
    190189 */
    191190LONG WINAPI RtlCompareUnicodeString( const UNICODE_STRING *s1, const UNICODE_STRING *s2,
     
    214213
    215214/**************************************************************************
    216  *  RtlEqualString   (NTDLL.@)
     215 *      RtlEqualString   (NTDLL.@)
    217216 */
    218217BOOLEAN WINAPI RtlEqualString( const STRING *s1, const STRING *s2, BOOLEAN CaseInsensitive )
     
    224223
    225224/**************************************************************************
    226  *  RtlEqualUnicodeString   (NTDLL.@)
     225 *      RtlEqualUnicodeString   (NTDLL.@)
    227226 */
    228227BOOLEAN WINAPI RtlEqualUnicodeString( const UNICODE_STRING *s1, const UNICODE_STRING *s2,
     
    235234
    236235/**************************************************************************
    237  *  RtlPrefixString   (NTDLL.@)
     236 *      RtlPrefixString   (NTDLL.@)
    238237 *
    239238 * Test if s1 is a prefix in s2
     
    259258
    260259/**************************************************************************
    261  *  RtlPrefixUnicodeString   (NTDLL.@)
     260 *      RtlPrefixUnicodeString   (NTDLL.@)
    262261 *
    263262 * Test if s1 is a prefix in s2
     
    285284
    286285/*
    287     COPY BETWEEN ANSI_STRING or UNICODE_STRING
    288     there is no parameter checking, it just crashes
     286        COPY BETWEEN ANSI_STRING or UNICODE_STRING
     287        there is no parameter checking, it just crashes
    289288*/
    290289
    291290
    292291/**************************************************************************
    293  *  RtlAnsiStringToUnicodeString   (NTDLL.@)
     292 *      RtlAnsiStringToUnicodeString   (NTDLL.@)
    294293 *
    295294 * NOTES:
     
    319318
    320319/**************************************************************************
    321  *  RtlOemStringToUnicodeString   (NTDLL.@)
     320 *      RtlOemStringToUnicodeString   (NTDLL.@)
    322321 *
    323322 * NOTES
     
    348347
    349348/**************************************************************************
    350  *  RtlUnicodeStringToAnsiString   (NTDLL.@)
     349 *      RtlUnicodeStringToAnsiString   (NTDLL.@)
    351350 *
    352351 * NOTES
     
    382381
    383382/**************************************************************************
    384  *  RtlUnicodeStringToOemString   (NTDLL.@)
     383 *      RtlUnicodeStringToOemString   (NTDLL.@)
    385384 *
    386385 * NOTES
     
    416415
    417416/**************************************************************************
    418  *  RtlMultiByteToUnicodeN   (NTDLL.@)
     417 *      RtlMultiByteToUnicodeN   (NTDLL.@)
    419418 *
    420419 * NOTES
     
    432431
    433432/**************************************************************************
    434  *  RtlOemToUnicodeN   (NTDLL.@)
     433 *      RtlOemToUnicodeN   (NTDLL.@)
    435434 */
    436435NTSTATUS WINAPI RtlOemToUnicodeN( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
     
    445444
    446445/**************************************************************************
    447  *  RtlUnicodeToMultiByteN   (NTDLL.@)
     446 *      RtlUnicodeToMultiByteN   (NTDLL.@)
    448447 */
    449448NTSTATUS WINAPI RtlUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    459458
    460459/**************************************************************************
    461  *  RtlUnicodeToOemN   (NTDLL.@)
     460 *      RtlUnicodeToOemN   (NTDLL.@)
    462461 */
    463462NTSTATUS WINAPI RtlUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    477476
    478477/**************************************************************************
    479  *  RtlUpperString   (NTDLL.@)
     478 *      RtlUpperString   (NTDLL.@)
    480479 */
    481480void WINAPI RtlUpperString( STRING *dst, const STRING *src )
     
    489488
    490489/**************************************************************************
    491  *  RtlUpcaseUnicodeString   (NTDLL.@)
     490 *      RtlUpcaseUnicodeString   (NTDLL.@)
    492491 *
    493492 * NOTES:
     
    516515
    517516/**************************************************************************
    518  *  RtlUpcaseUnicodeStringToAnsiString   (NTDLL.@)
     517 *      RtlUpcaseUnicodeStringToAnsiString   (NTDLL.@)
    519518 *
    520519 * NOTES
     
    538537
    539538/**************************************************************************
    540  *  RtlUpcaseUnicodeStringToOemString   (NTDLL.@)
     539 *      RtlUpcaseUnicodeStringToOemString   (NTDLL.@)
    541540 *
    542541 * NOTES
     
    560559
    561560/**************************************************************************
    562  *  RtlUpcaseUnicodeToMultiByteN   (NTDLL.@)
     561 *      RtlUpcaseUnicodeToMultiByteN   (NTDLL.@)
    563562 */
    564563NTSTATUS WINAPI RtlUpcaseUnicodeToMultiByteN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    578577
    579578/**************************************************************************
    580  *  RtlUpcaseUnicodeToOemN   (NTDLL.@)
     579 *      RtlUpcaseUnicodeToOemN   (NTDLL.@)
    581580 */
    582581NTSTATUS WINAPI RtlUpcaseUnicodeToOemN( LPSTR dst, DWORD dstlen, LPDWORD reslen,
     
    596595
    597596/*
    598     STRING SIZE
     597        STRING SIZE
    599598*/
    600599
     
    742741
    743742/*
    744     MISC
     743        MISC
    745744*/
    746745
    747746/**************************************************************************
    748  *  RtlIsTextUnicode
    749  *
    750  *  Apply various feeble heuristics to guess whether
    751  *  the text buffer contains Unicode.
    752  *  FIXME: should implement more tests.
     747 *      RtlIsTextUnicode
     748 *
     749 *      Apply various feeble heuristics to guess whether
     750 *      the text buffer contains Unicode.
     751 *      FIXME: should implement more tests.
    753752 */
    754753DWORD WINAPI RtlIsTextUnicode(
    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;
     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;
    787786out:
    788     if (pf)
    789         *pf = out_flags;
    790     return len;
    791 }
     787        if (pf)
     788                *pf = out_flags;
     789        return len;
     790}
  • trunk/src/NTDLL/unknown.cpp

    r6647 r6712  
    1 /* $Id: unknown.cpp,v 1.9 2001-09-05 13:14:30 bird Exp $ */
     1/* $Id: unknown.cpp,v 1.10 2001-09-15 09:36:50 sandervl Exp $ */
    22
    33/*
     
    425425 * Opens a thread...
    426426 * @returns Error code?
    427  * @param   phThreadHandle
     427 * @param   pThreadHandle
    428428 * @param   dwFlags
    429  * @param   pAttribs            Pointer to some attribute structure.
     429 * @param   pvAttribs           Pointer to some attribute structure.
    430430 * @param   padwOpenThreadParam Pointer to array of dword it seems. 2 entries?
    431431 * @status  stub
  • trunk/src/NTDLL/wcstring.c

    r6648 r6712  
    1 /* $Id: wcstring.c,v 1.2 2001-09-05 13:14:08 bird Exp $ */
    21/*
    32 * NTDLL wide-char functions
     
    287286{
    288287    LPSTR sA = HEAP_strdupWtoA(GetProcessHeap(),0,s),endA;
    289     INT ret = strtol(sA,&endA,base);
     288    INT ret = strtol(sA,&endA,base);
    290289
    291290    HeapFree(GetProcessHeap(),0,sA);
     
    326325
    327326    if (radix > 36 || radix <= 1)
    328     return 0;
     327        return 0;
    329328
    330329    while (v || tp == tmp)
    331330    {
    332     i = v % radix;
    333     v = v / radix;
    334     if (i < 10)
    335         *tp++ = i + '0';
    336     else
    337         *tp++ = i + 'a' - 10;
     331        i = v % radix;
     332        v = v / radix;
     333        if (i < 10)
     334            *tp++ = i + '0';
     335        else
     336            *tp++ = i + 'a' - 10;
    338337    }
    339338
    340339    sp = string;
    341340    while (tp > tmp)
    342     *sp++ = *--tp;
     341        *sp++ = *--tp;
    343342    *sp = 0;
    344343    return string;
  • trunk/src/avifil32/api.c

    r6644 r6712  
    1 /* $Id: api.c,v 1.2 2001-09-05 12:00:53 bird Exp $
    2  *
     1/*
    32 * Copyright 1999 Marcus Meissner
    43 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
     
    2322
    2423/***********************************************************************
    25  *      AVIFileInit (AVIFILE.100)
    26  *      AVIFileInit (AVIFIL32.@)
     24 *              AVIFileInit (AVIFILE.100)
     25 *              AVIFileInit (AVIFIL32.@)
    2726 */
    2827void WINAPI AVIFileInit(void)
    2928{
    30     TRACE("()\n");
    31     if ( AVIFILE_data.dwAVIFileRef == 0 )
    32     {
    33         if ( FAILED(CoInitialize(NULL)) )
    34             AVIFILE_data.fInitCOM = FALSE;
    35         else
    36             AVIFILE_data.fInitCOM = TRUE;
    37     }
    38     AVIFILE_data.dwAVIFileRef ++;
    39 }
    40 
    41 /***********************************************************************
    42  *      AVIFileExit (AVIFILE.101)
    43  *      AVIFileExit (AVIFIL32.@)
     29        TRACE("()\n");
     30        if ( AVIFILE_data.dwAVIFileRef == 0 )
     31        {
     32                if ( FAILED(CoInitialize(NULL)) )
     33                        AVIFILE_data.fInitCOM = FALSE;
     34                else
     35                        AVIFILE_data.fInitCOM = TRUE;
     36        }
     37        AVIFILE_data.dwAVIFileRef ++;
     38}
     39
     40/***********************************************************************
     41 *              AVIFileExit (AVIFILE.101)
     42 *              AVIFileExit (AVIFIL32.@)
    4443 */
    4544void WINAPI AVIFileExit(void)
    4645{
    47     TRACE("()\n");
    48     if ( AVIFILE_data.dwAVIFileRef == 0 )
    49     {
    50         ERR( "unexpected AVIFileExit()\n" );
    51         return;
    52     }
    53 
    54     AVIFILE_data.dwAVIFileRef --;
    55     if ( AVIFILE_data.dwAVIFileRef == 0 )
    56     {
    57         if ( AVIFILE_data.fInitCOM )
    58         {
    59             CoUninitialize();
    60             AVIFILE_data.fInitCOM = FALSE;
    61         }
    62     }
    63 }
    64 
    65 /***********************************************************************
    66  *      AVIFileAddRef (AVIFIL32.@)
     46        TRACE("()\n");
     47        if ( AVIFILE_data.dwAVIFileRef == 0 )
     48        {
     49                ERR( "unexpected AVIFileExit()\n" );
     50                return;
     51        }
     52
     53        AVIFILE_data.dwAVIFileRef --;
     54        if ( AVIFILE_data.dwAVIFileRef == 0 )
     55        {
     56                if ( AVIFILE_data.fInitCOM )
     57                {
     58                        CoUninitialize();
     59                        AVIFILE_data.fInitCOM = FALSE;
     60                }
     61        }
     62}
     63
     64/***********************************************************************
     65 *              AVIFileAddRef (AVIFIL32.@)
    6766 */
    6867ULONG WINAPI AVIFileAddRef(PAVIFILE pfile)
    6968{
    70     return IAVIFile_AddRef( pfile );
    71 }
    72 
    73 /***********************************************************************
    74  *      AVIFileRelease (AVIFILE.141)
    75  *      AVIFileRelease (AVIFIL32.@)
     69        return IAVIFile_AddRef( pfile );
     70}
     71
     72/***********************************************************************
     73 *              AVIFileRelease (AVIFILE.141)
     74 *              AVIFileRelease (AVIFIL32.@)
    7675 */
    7776ULONG WINAPI AVIFileRelease(PAVIFILE pfile)
    7877{
    79     return IAVIFile_Release( pfile );
    80 }
    81 
    82 /***********************************************************************
    83  *      AVIFileOpen  (AVIFILE.102)
    84  *      AVIFileOpenA (AVIFIL32.@)
     78        return IAVIFile_Release( pfile );
     79}
     80
     81/***********************************************************************
     82 *              AVIFileOpen  (AVIFILE.102)
     83 *              AVIFileOpenA (AVIFIL32.@)
    8584 */
    8685HRESULT WINAPI AVIFileOpenA(
    87     PAVIFILE* ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler )
    88 {
    89     WCHAR*  pwsz;
    90     HRESULT hr;
    91 
    92     TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
    93     pwsz = AVIFILE_strdupAtoW( szFile );
    94     if ( pwsz == NULL )
    95         return AVIERR_MEMORY;
    96     hr = AVIFileOpenW(ppfile,pwsz,uMode,lpHandler);
    97     HeapFree( AVIFILE_data.hHeap, 0, pwsz );
    98     return hr;
    99 }
    100 
    101 /***********************************************************************
    102  *      AVIFileOpenW (AVIFIL32.@)
     86        PAVIFILE* ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler )
     87{
     88        WCHAR*  pwsz;
     89        HRESULT hr;
     90
     91        TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
     92        pwsz = AVIFILE_strdupAtoW( szFile );
     93        if ( pwsz == NULL )
     94                return AVIERR_MEMORY;
     95        hr = AVIFileOpenW(ppfile,pwsz,uMode,lpHandler);
     96        HeapFree( AVIFILE_data.hHeap, 0, pwsz );
     97        return hr;
     98}
     99
     100/***********************************************************************
     101 *              AVIFileOpenW (AVIFIL32.@)
    103102 */
    104103HRESULT WINAPI AVIFileOpenW(
    105     PAVIFILE* ppfile,LPCWSTR szFile,UINT uMode,LPCLSID lpHandler )
    106 {
    107     HRESULT hr;
    108     IClassFactory*  pcf;
    109     CLSID   clsRIFF;
    110 
    111     TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
    112     *ppfile = (PAVIFILE)NULL;
    113 
    114     if ( lpHandler == NULL )
    115     {
    116         /* FIXME - check RIFF type and get a handler from registry
    117         *         if IAVIFile::Open is worked...
    118         */
    119         memcpy( &clsRIFF, &CLSID_AVIFile, sizeof(CLSID) );
    120         lpHandler = &clsRIFF;
    121     }
    122 
    123     /*
    124     * FIXME - MS says IAVIFile::Open will be called,
    125     *         but no such method in vfw.h... why????
    126     */
    127     if ( !IsEqualGUID( lpHandler, &CLSID_AVIFile ) )
    128         return REGDB_E_CLASSNOTREG;
    129 
    130     hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
    131                        &IID_IClassFactory,(void**)&pcf);
    132     if ( hr != S_OK )
    133         return hr;
    134 
    135     hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIFile,
    136                        (void**)ppfile );
    137     IClassFactory_Release( pcf );
    138 
    139     if ( hr == S_OK )
    140     {
    141         /* FIXME??? */
    142         hr = AVIFILE_IAVIFile_Open( *ppfile, szFile, uMode );
    143         if ( hr != S_OK )
    144         {
    145             IAVIFile_Release( (*ppfile) );
    146             *ppfile = NULL;
    147         }
    148     }
    149 
    150     return hr;
    151 }
    152 
    153 /***********************************************************************
    154  *      AVIFileInfoW (AVIFIL32.@)
     104        PAVIFILE* ppfile,LPCWSTR szFile,UINT uMode,LPCLSID lpHandler )
     105{
     106        HRESULT hr;
     107        IClassFactory*  pcf;
     108        CLSID   clsRIFF;
     109
     110        TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
     111        *ppfile = (PAVIFILE)NULL;
     112
     113        if ( lpHandler == NULL )
     114        {
     115                /* FIXME - check RIFF type and get a handler from registry
     116                *         if IAVIFile::Open is worked...
     117                */
     118                memcpy( &clsRIFF, &CLSID_AVIFile, sizeof(CLSID) );
     119                lpHandler = &clsRIFF;
     120        }
     121
     122        /*
     123        * FIXME - MS says IAVIFile::Open will be called,
     124        *         but no such method in vfw.h... why????
     125        */
     126        if ( !IsEqualGUID( lpHandler, &CLSID_AVIFile ) )
     127                return REGDB_E_CLASSNOTREG;
     128
     129        hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
     130                                       &IID_IClassFactory,(void**)&pcf);
     131        if ( hr != S_OK )
     132                return hr;
     133
     134        hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIFile,
     135                                           (void**)ppfile );
     136        IClassFactory_Release( pcf );
     137
     138        if ( hr == S_OK )
     139        {
     140                /* FIXME??? */
     141                hr = AVIFILE_IAVIFile_Open( *ppfile, szFile, uMode );
     142                if ( hr != S_OK )
     143                {
     144                        IAVIFile_Release( (*ppfile) );
     145                        *ppfile = NULL;
     146                }
     147        }
     148
     149        return hr;
     150}
     151
     152/***********************************************************************
     153 *              AVIFileInfoW (AVIFIL32.@)
    155154 */
    156155HRESULT WINAPI AVIFileInfoW(PAVIFILE pfile,AVIFILEINFOW* pfi,LONG lSize)
    157156{
    158     return IAVIFile_Info( pfile, pfi, lSize );
    159 }
    160 
    161 /***********************************************************************
    162  *      AVIFileInfo  (AVIFIL32.@)
    163  *      AVIFileInfoA (AVIFIL32.@)
     157        return IAVIFile_Info( pfile, pfi, lSize );
     158}
     159
     160/***********************************************************************
     161 *              AVIFileInfo  (AVIFIL32.@)
     162 *              AVIFileInfoA (AVIFIL32.@)
    164163 */
    165164HRESULT WINAPI AVIFileInfoA(PAVIFILE pfile,AVIFILEINFOA* pfi,LONG lSize)
    166165{
    167     AVIFILEINFOW    fiw;
    168     HRESULT     hr;
    169 
    170     if ( lSize < sizeof(AVIFILEINFOA) )
    171         return AVIERR_BADSIZE;
    172     hr = AVIFileInfoW( pfile, &fiw, sizeof(AVIFILEINFOW) );
    173     if ( hr != S_OK )
    174         return hr;
    175     memcpy( pfi,&fiw,sizeof(AVIFILEINFOA) );
    176     AVIFILE_strncpyWtoA( pfi->szFileType, fiw.szFileType,
    177                  sizeof(pfi->szFileType) );
    178     pfi->szFileType[sizeof(pfi->szFileType)-1] = 0;
    179 
    180     return S_OK;
    181 }
    182 
    183 /***********************************************************************
    184  *      AVIFileGetStream (AVIFILE.143)
    185  *      AVIFileGetStream (AVIFIL32.@)
     166        AVIFILEINFOW    fiw;
     167        HRESULT         hr;
     168
     169        if ( lSize < sizeof(AVIFILEINFOA) )
     170                return AVIERR_BADSIZE;
     171        hr = AVIFileInfoW( pfile, &fiw, sizeof(AVIFILEINFOW) );
     172        if ( hr != S_OK )
     173                return hr;
     174        memcpy( pfi,&fiw,sizeof(AVIFILEINFOA) );
     175        AVIFILE_strncpyWtoA( pfi->szFileType, fiw.szFileType,
     176                             sizeof(pfi->szFileType) );
     177        pfi->szFileType[sizeof(pfi->szFileType)-1] = 0;
     178
     179        return S_OK;
     180}
     181
     182/***********************************************************************
     183 *              AVIFileGetStream (AVIFILE.143)
     184 *              AVIFileGetStream (AVIFIL32.@)
    186185 */
    187186HRESULT WINAPI AVIFileGetStream(PAVIFILE pfile,PAVISTREAM* pas,DWORD fccType,LONG lParam)
    188187{
    189     return IAVIFile_GetStream(pfile,pas,fccType,lParam);
    190 }
    191 
    192 /***********************************************************************
    193  *      AVIFileCreateStreamW (AVIFIL32.@)
     188        return IAVIFile_GetStream(pfile,pas,fccType,lParam);
     189}
     190
     191/***********************************************************************
     192 *              AVIFileCreateStreamW (AVIFIL32.@)
    194193 */
    195194HRESULT WINAPI AVIFileCreateStreamW(PAVIFILE pfile,PAVISTREAM* ppas,AVISTREAMINFOW* pasi)
    196195{
    197     return IAVIFile_CreateStream(pfile,ppas,pasi);
    198 }
    199 
    200 /***********************************************************************
    201  *      AVIFileCreateStreamA (AVIFIL32.@)
     196        return IAVIFile_CreateStream(pfile,ppas,pasi);
     197}
     198
     199/***********************************************************************
     200 *              AVIFileCreateStreamA (AVIFIL32.@)
    202201 */
    203202HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE pfile,PAVISTREAM* ppas,AVISTREAMINFOA* pasi)
    204203{
    205     AVISTREAMINFOW  siw;
    206     HRESULT     hr;
    207 
    208     memcpy( &siw,pasi,sizeof(AVISTREAMINFOA) );
    209     AVIFILE_strncpyAtoW( siw.szName, pasi->szName,
    210         sizeof(siw.szName)/sizeof(siw.szName[0]) );
    211     siw.szName[sizeof(siw.szName)/sizeof(siw.szName[0])-1] = 0;
    212 
    213     hr = AVIFileCreateStreamW(pfile,ppas,&siw);
    214 
    215     return hr;
    216 }
    217 
    218 /***********************************************************************
    219  *      AVIFileWriteData (AVIFIL32.@)
     204        AVISTREAMINFOW  siw;
     205        HRESULT         hr;
     206
     207        memcpy( &siw,pasi,sizeof(AVISTREAMINFOA) );
     208        AVIFILE_strncpyAtoW( siw.szName, pasi->szName,
     209                sizeof(siw.szName)/sizeof(siw.szName[0]) );
     210        siw.szName[sizeof(siw.szName)/sizeof(siw.szName[0])-1] = 0;
     211
     212        hr = AVIFileCreateStreamW(pfile,ppas,&siw);
     213
     214        return hr;
     215}
     216
     217/***********************************************************************
     218 *              AVIFileWriteData (AVIFIL32.@)
    220219 */
    221220HRESULT WINAPI AVIFileWriteData(
    222     PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LONG cbData )
    223 {
    224     return IAVIFile_WriteData( pfile,dwChunkId,lpvData,cbData );
    225 }
    226 
    227 /***********************************************************************
    228  *      AVIFileReadData (AVIFIL32.@)
     221        PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LONG cbData )
     222{
     223        return IAVIFile_WriteData( pfile,dwChunkId,lpvData,cbData );
     224}
     225
     226/***********************************************************************
     227 *              AVIFileReadData (AVIFIL32.@)
    229228 */
    230229HRESULT WINAPI AVIFileReadData(
    231     PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LPLONG pcbData )
    232 {
    233     return IAVIFile_ReadData( pfile,dwChunkId,lpvData,pcbData );
    234 }
    235 
    236 /***********************************************************************
    237  *      AVIFileEndRecord (AVIFIL32.@)
     230        PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LPLONG pcbData )
     231{
     232        return IAVIFile_ReadData( pfile,dwChunkId,lpvData,pcbData );
     233}
     234
     235/***********************************************************************
     236 *              AVIFileEndRecord (AVIFIL32.@)
    238237 */
    239238HRESULT WINAPI AVIFileEndRecord( PAVIFILE pfile )
    240239{
    241     return IAVIFile_EndRecord( pfile );
    242 }
    243 
    244 /***********************************************************************
    245  *      AVIStreamAddRef (AVIFIL32.@)
     240        return IAVIFile_EndRecord( pfile );
     241}
     242
     243/***********************************************************************
     244 *              AVIStreamAddRef (AVIFIL32.@)
    246245 */
    247246ULONG WINAPI AVIStreamAddRef(PAVISTREAM pas)
    248247{
    249     return IAVIStream_Release(pas);
    250 }
    251 
    252 /***********************************************************************
    253  *      AVIStreamRelease (AVIFIL32.@)
     248        return IAVIStream_Release(pas);
     249}
     250
     251/***********************************************************************
     252 *              AVIStreamRelease (AVIFIL32.@)
    254253 */
    255254ULONG WINAPI AVIStreamRelease(PAVISTREAM pas)
    256255{
    257     return IAVIStream_Release(pas);
    258 }
    259 
    260 /***********************************************************************
    261  *      AVIStreamInfoW (AVIFIL32.@)
     256        return IAVIStream_Release(pas);
     257}
     258
     259/***********************************************************************
     260 *              AVIStreamInfoW (AVIFIL32.@)
    262261 */
    263262HRESULT WINAPI AVIStreamInfoW(PAVISTREAM pas,AVISTREAMINFOW* psi,LONG lSize)
    264263{
    265     return IAVIStream_Info(pas,psi,lSize);
    266 }
    267 
    268 /***********************************************************************
    269  *      AVIStreamInfo  (AVIFIL32.@)
    270  *      AVIStreamInfoA (AVIFIL32.@)
     264        return IAVIStream_Info(pas,psi,lSize);
     265}
     266
     267/***********************************************************************
     268 *              AVIStreamInfo  (AVIFIL32.@)
     269 *              AVIStreamInfoA (AVIFIL32.@)
    271270 */
    272271HRESULT WINAPI AVIStreamInfoA(PAVISTREAM pas,AVISTREAMINFOA* psi,LONG lSize)
    273272{
    274     AVISTREAMINFOW  siw;
    275     HRESULT     hr;
    276 
    277     if (lSize < sizeof(AVISTREAMINFOA))
    278         return AVIERR_BADSIZE;
    279     hr = AVIStreamInfoW(pas,&siw,sizeof(AVISTREAMINFOW));
    280     if ( hr != S_OK )
    281         return hr;
    282     memcpy( psi,&siw,sizeof(AVIFILEINFOA) );
    283     AVIFILE_strncpyWtoA( psi->szName, siw.szName, sizeof(psi->szName) );
    284     psi->szName[sizeof(psi->szName)-1] = 0;
    285 
    286     return hr;
    287 }
    288 
    289 /***********************************************************************
    290  *      AVIStreamFindSample (AVIFIL32.@)
     273        AVISTREAMINFOW  siw;
     274        HRESULT         hr;
     275
     276        if (lSize < sizeof(AVISTREAMINFOA))
     277                return AVIERR_BADSIZE;
     278        hr = AVIStreamInfoW(pas,&siw,sizeof(AVISTREAMINFOW));
     279        if ( hr != S_OK )
     280                return hr;
     281        memcpy( psi,&siw,sizeof(AVIFILEINFOA) );
     282        AVIFILE_strncpyWtoA( psi->szName, siw.szName, sizeof(psi->szName) );
     283        psi->szName[sizeof(psi->szName)-1] = 0;
     284
     285        return hr;
     286}
     287
     288/***********************************************************************
     289 *              AVIStreamFindSample (AVIFIL32.@)
    291290 */
    292291LONG WINAPI AVIStreamFindSample(PAVISTREAM pas,LONG lPos,LONG lFlags)
    293292{
    294     return IAVIStream_FindSample(pas,lPos,lFlags);
    295 }
    296 
    297 /***********************************************************************
    298  *      AVIStreamReadFormat (AVIFIL32.@)
     293        return IAVIStream_FindSample(pas,lPos,lFlags);
     294}
     295
     296/***********************************************************************
     297 *              AVIStreamReadFormat (AVIFIL32.@)
    299298 */
    300299HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM pas,LONG pos,LPVOID format,LONG *formatsize) {
    301     return IAVIStream_ReadFormat(pas,pos,format,formatsize);
    302 }
    303 
    304 /***********************************************************************
    305  *      AVIStreamSetFormat (AVIFIL32.@)
     300        return IAVIStream_ReadFormat(pas,pos,format,formatsize);
     301}
     302
     303/***********************************************************************
     304 *              AVIStreamSetFormat (AVIFIL32.@)
    306305 */
    307306HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM pas,LONG pos,LPVOID format,LONG formatsize) {
    308     return IAVIStream_SetFormat(pas,pos,format,formatsize);
    309 }
    310 
    311 /***********************************************************************
    312  *      AVIStreamReadData (AVIFIL32.@)
     307        return IAVIStream_SetFormat(pas,pos,format,formatsize);
     308}
     309
     310/***********************************************************************
     311 *              AVIStreamReadData (AVIFIL32.@)
    313312 */
    314313HRESULT WINAPI AVIStreamReadData(PAVISTREAM pas,DWORD fcc,LPVOID lp,LONG *lpread) {
    315     return IAVIStream_ReadData(pas,fcc,lp,lpread);
    316 }
    317 
    318 /***********************************************************************
    319  *      AVIStreamWriteData (AVIFIL32.@)
     314        return IAVIStream_ReadData(pas,fcc,lp,lpread);
     315}
     316
     317/***********************************************************************
     318 *              AVIStreamWriteData (AVIFIL32.@)
    320319 */
    321320HRESULT WINAPI AVIStreamWriteData(PAVISTREAM pas,DWORD fcc,LPVOID lp,LONG size) {
    322     return IAVIStream_WriteData(pas,fcc,lp,size);
    323 }
    324 
    325 /***********************************************************************
    326  *      AVIStreamRead (AVIFIL32.@)
     321        return IAVIStream_WriteData(pas,fcc,lp,size);
     322}
     323
     324/***********************************************************************
     325 *              AVIStreamRead (AVIFIL32.@)
    327326 */
    328327HRESULT WINAPI AVIStreamRead(PAVISTREAM pas,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread)
    329328{
    330     return IAVIStream_Read(pas,start,samples,buffer,buffersize,bytesread,samplesread);
    331 }
    332 
    333 /***********************************************************************
    334  *      AVIStreamWrite (AVIFIL32.@)
     329        return IAVIStream_Read(pas,start,samples,buffer,buffersize,bytesread,samplesread);
     330}
     331
     332/***********************************************************************
     333 *              AVIStreamWrite (AVIFIL32.@)
    335334 */
    336335HRESULT WINAPI AVIStreamWrite(PAVISTREAM pas,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
    337     return IAVIStream_Write(pas,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
    338 }
    339 
    340 
    341 /***********************************************************************
    342  *      AVIStreamStart (AVIFIL32.@)
     336        return IAVIStream_Write(pas,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
     337}
     338
     339
     340/***********************************************************************
     341 *              AVIStreamStart (AVIFIL32.@)
    343342 */
    344343LONG WINAPI AVIStreamStart(PAVISTREAM pas)
    345344{
    346     AVISTREAMINFOW  si;
    347     HRESULT         hr;
    348 
    349     hr = IAVIStream_Info(pas,&si,sizeof(si));
    350     if (hr != S_OK)
    351         return -1;
    352     return (LONG)si.dwStart;
    353 }
    354 
    355 /***********************************************************************
    356  *      AVIStreamLength (AVIFIL32.@)
     345        AVISTREAMINFOW  si;
     346        HRESULT                 hr;
     347
     348        hr = IAVIStream_Info(pas,&si,sizeof(si));
     349        if (hr != S_OK)
     350                return -1;
     351        return (LONG)si.dwStart;
     352}
     353
     354/***********************************************************************
     355 *              AVIStreamLength (AVIFIL32.@)
    357356 */
    358357LONG WINAPI AVIStreamLength(PAVISTREAM pas)
    359358{
    360     AVISTREAMINFOW  si;
    361     HRESULT         hr;
    362 
    363     hr = IAVIStream_Info(pas,&si,sizeof(si));
    364     if (hr != S_OK)
    365         return -1;
    366     return (LONG)si.dwLength;
    367 }
    368 
    369 /***********************************************************************
    370  *      AVIStreamTimeToSample (AVIFIL32.@)
     359        AVISTREAMINFOW  si;
     360        HRESULT                 hr;
     361
     362        hr = IAVIStream_Info(pas,&si,sizeof(si));
     363        if (hr != S_OK)
     364                return -1;
     365        return (LONG)si.dwLength;
     366}
     367
     368/***********************************************************************
     369 *              AVIStreamTimeToSample (AVIFIL32.@)
    371370 */
    372371LONG WINAPI AVIStreamTimeToSample(PAVISTREAM pas,LONG lTime)
    373372{
    374     AVISTREAMINFOW  si;
    375     HRESULT         hr;
    376 
    377     hr = IAVIStream_Info(pas,&si,sizeof(si));
    378     if (hr != S_OK)
    379         return -1;
    380 
    381     /* I am too lazy... */
    382     FIXME("(%p,%ld)",pas,lTime);
    383     return (LONG)-1L;
    384 }
    385 
    386 /***********************************************************************
    387  *      AVIStreamSampleToTime (AVIFIL32.@)
     373        AVISTREAMINFOW  si;
     374        HRESULT                 hr;
     375
     376        hr = IAVIStream_Info(pas,&si,sizeof(si));
     377        if (hr != S_OK)
     378                return -1;
     379
     380        /* I am too lazy... */
     381        FIXME("(%p,%ld)",pas,lTime);
     382        return (LONG)-1L;
     383}
     384
     385/***********************************************************************
     386 *              AVIStreamSampleToTime (AVIFIL32.@)
    388387 */
    389388LONG WINAPI AVIStreamSampleToTime(PAVISTREAM pas,LONG lSample)
    390389{
    391     AVISTREAMINFOW  si;
    392     HRESULT         hr;
    393 
    394     hr = IAVIStream_Info(pas,&si,sizeof(si));
    395     if (hr != S_OK)
    396         return -1;
    397 
    398     /* I am too lazy... */
    399     FIXME("(%p,%ld)",pas,lSample);
    400     return (LONG)-1L;
    401 }
    402 
    403 /***********************************************************************
    404  *      AVIStreamBeginStreaming (AVIFIL32.@)
     390        AVISTREAMINFOW  si;
     391        HRESULT                 hr;
     392
     393        hr = IAVIStream_Info(pas,&si,sizeof(si));
     394        if (hr != S_OK)
     395                return -1;
     396
     397        /* I am too lazy... */
     398        FIXME("(%p,%ld)",pas,lSample);
     399        return (LONG)-1L;
     400}
     401
     402/***********************************************************************
     403 *              AVIStreamBeginStreaming (AVIFIL32.@)
    405404 */
    406405HRESULT WINAPI AVIStreamBeginStreaming(PAVISTREAM pas,LONG lStart,LONG lEnd,LONG lRate)
    407406{
    408     FIXME("(%p)->(%ld,%ld,%ld),stub!\n",pas,lStart,lEnd,lRate);
    409     return E_FAIL;
    410 }
    411 
    412 /***********************************************************************
    413  *      AVIStreamEndStreaming (AVIFIL32.@)
     407        FIXME("(%p)->(%ld,%ld,%ld),stub!\n",pas,lStart,lEnd,lRate);
     408        return E_FAIL;
     409}
     410
     411/***********************************************************************
     412 *              AVIStreamEndStreaming (AVIFIL32.@)
    414413 */
    415414HRESULT WINAPI AVIStreamEndStreaming(PAVISTREAM pas)
    416415{
    417     FIXME("(%p)->(),stub!\n",pas);
    418     return E_FAIL;
    419 }
    420 
    421 /***********************************************************************
    422  *      AVIStreamGetFrameOpen (AVIFIL32.@)
     416        FIXME("(%p)->(),stub!\n",pas);
     417        return E_FAIL;
     418}
     419
     420/***********************************************************************
     421 *              AVIStreamGetFrameOpen (AVIFIL32.@)
    423422 */
    424423PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM pas,LPBITMAPINFOHEADER pbi)
    425424{
    426     IGetFrame*  pgf;
    427     HRESULT     hr;
    428     AVISTREAMINFOW  si;
    429 
    430     FIXME("(%p,%p)\n",pas,pbi);
    431 
    432     hr = IAVIStream_Info(pas,&si,sizeof(si));
    433     if (hr != S_OK)
    434         return NULL;
    435 
    436     hr = AVIFILE_CreateIGetFrame((void**)&pgf,pas,pbi);
    437     if ( hr != S_OK )
    438         return NULL;
    439     hr = IGetFrame_Begin( pgf, si.dwStart, si.dwLength, 1000 );
    440     if ( hr != S_OK )
    441     {
    442         IGetFrame_Release( pgf );
    443         return NULL;
    444     }
    445 
    446     return pgf;
    447 }
    448 
    449 /***********************************************************************
    450  *      AVIStreamGetFrame (AVIFIL32.@)
     425        IGetFrame*      pgf;
     426        HRESULT         hr;
     427        AVISTREAMINFOW  si;
     428
     429        FIXME("(%p,%p)\n",pas,pbi);
     430
     431        hr = IAVIStream_Info(pas,&si,sizeof(si));
     432        if (hr != S_OK)
     433                return NULL;
     434
     435        hr = AVIFILE_CreateIGetFrame((void**)&pgf,pas,pbi);
     436        if ( hr != S_OK )
     437                return NULL;
     438        hr = IGetFrame_Begin( pgf, si.dwStart, si.dwLength, 1000 );
     439        if ( hr != S_OK )
     440        {
     441                IGetFrame_Release( pgf );
     442                return NULL;
     443        }
     444
     445        return pgf;
     446}
     447
     448/***********************************************************************
     449 *              AVIStreamGetFrame (AVIFIL32.@)
    451450 */
    452451LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pgf, LONG lPos)
    453452{
    454     return IGetFrame_GetFrame(pgf,lPos);
    455 }
    456 
    457 /***********************************************************************
    458  *      AVIStreamGetFrameClose (AVIFIL32.@)
     453        return IGetFrame_GetFrame(pgf,lPos);
     454}
     455
     456/***********************************************************************
     457 *              AVIStreamGetFrameClose (AVIFIL32.@)
    459458 */
    460459HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pgf)
    461460{
    462     return IGetFrame_End(pgf);
    463 }
    464 
    465 /***********************************************************************
    466  *      AVIStreamOpenFromFileA (AVIFIL32.@)
     461        return IGetFrame_End(pgf);
     462}
     463
     464/***********************************************************************
     465 *              AVIStreamOpenFromFileA (AVIFIL32.@)
    467466 */
    468467HRESULT WINAPI AVIStreamOpenFromFileA(PAVISTREAM* ppas, LPCSTR szFile, DWORD fccType, LONG lParam, UINT uMode, CLSID* lpHandler)
    469468{
    470     WCHAR*  pwsz;
    471     HRESULT hr;
    472 
    473     pwsz = AVIFILE_strdupAtoW( szFile );
    474     if ( pwsz == NULL )
    475         return AVIERR_MEMORY;
    476     hr = AVIStreamOpenFromFileW(ppas,pwsz,fccType,lParam,uMode,lpHandler);
    477     HeapFree( AVIFILE_data.hHeap, 0, pwsz );
    478     return hr;
    479 }
    480 
    481 /***********************************************************************
    482  *      AVIStreamOpenFromFileW (AVIFIL32.@)
     469        WCHAR*  pwsz;
     470        HRESULT hr;
     471
     472        pwsz = AVIFILE_strdupAtoW( szFile );
     473        if ( pwsz == NULL )
     474                return AVIERR_MEMORY;
     475        hr = AVIStreamOpenFromFileW(ppas,pwsz,fccType,lParam,uMode,lpHandler);
     476        HeapFree( AVIFILE_data.hHeap, 0, pwsz );
     477        return hr;
     478}
     479
     480/***********************************************************************
     481 *              AVIStreamOpenFromFileW (AVIFIL32.@)
    483482 */
    484483HRESULT WINAPI AVIStreamOpenFromFileW(PAVISTREAM* ppas, LPCWSTR szFile, DWORD fccType, LONG lParam, UINT uMode, CLSID* lpHandler)
    485484{
    486     HRESULT hr;
    487     PAVIFILE    paf;
    488     AVIFILEINFOW    fi;
    489 
    490     *ppas = NULL;
    491     hr = AVIFileOpenW(&paf,szFile,uMode,lpHandler);
    492     if ( hr != S_OK )
    493         return hr;
    494     hr = AVIFileInfoW(paf,&fi,sizeof(AVIFILEINFOW));
    495     if ( hr == S_OK )
    496         hr = AVIFileGetStream(paf,ppas,fccType,lParam);
    497 
    498     IAVIFile_Release(paf);
    499 
    500     return hr;
    501 }
    502 
    503 /***********************************************************************
    504  *      AVIStreamCreate (AVIFIL32.@)
     485        HRESULT hr;
     486        PAVIFILE        paf;
     487        AVIFILEINFOW    fi;
     488
     489        *ppas = NULL;
     490        hr = AVIFileOpenW(&paf,szFile,uMode,lpHandler);
     491        if ( hr != S_OK )
     492                return hr;
     493        hr = AVIFileInfoW(paf,&fi,sizeof(AVIFILEINFOW));
     494        if ( hr == S_OK )
     495                hr = AVIFileGetStream(paf,ppas,fccType,lParam);
     496
     497        IAVIFile_Release(paf);
     498
     499        return hr;
     500}
     501
     502/***********************************************************************
     503 *              AVIStreamCreate (AVIFIL32.@)
    505504 */
    506505HRESULT WINAPI AVIStreamCreate(PAVISTREAM* ppas, LONG lParam1, LONG lParam2, CLSID* lpHandler)
    507506{
    508     HRESULT hr;
    509     IClassFactory*  pcf;
    510 
    511     *ppas = NULL;
    512 
    513     if ( lpHandler == NULL )
    514     {
    515         hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
    516                            &IID_IClassFactory,(void**)&pcf);
    517     }
    518     else
    519     {
    520         if ( !AVIFILE_data.fInitCOM )
    521             return E_UNEXPECTED;
    522         hr = CoGetClassObject(lpHandler,CLSCTX_INPROC_SERVER,
    523                       NULL,&IID_IClassFactory,(void**)&pcf);
    524     }
    525     if ( hr != S_OK )
    526         return hr;
    527 
    528     hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIStream,
    529                        (void**)ppas );
    530     IClassFactory_Release( pcf );
    531 
    532     if ( hr == S_OK )
    533     {
    534         hr = IAVIStream_Create((*ppas),lParam1,lParam2);
    535         if ( hr != S_OK )
    536         {
    537             IAVIStream_Release((*ppas));
    538             *ppas = NULL;
    539         }
    540     }
    541 
    542     return hr;
    543 }
    544 
    545 /***********************************************************************
    546  *      AVIMakeCompressedStream (AVIFIL32.@)
     507        HRESULT hr;
     508        IClassFactory*  pcf;
     509
     510        *ppas = NULL;
     511
     512        if ( lpHandler == NULL )
     513        {
     514                hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
     515                                               &IID_IClassFactory,(void**)&pcf);
     516        }
     517        else
     518        {
     519                if ( !AVIFILE_data.fInitCOM )
     520                        return E_UNEXPECTED;
     521                hr = CoGetClassObject(lpHandler,CLSCTX_INPROC_SERVER,
     522                                      NULL,&IID_IClassFactory,(void**)&pcf);
     523        }
     524        if ( hr != S_OK )
     525                return hr;
     526
     527        hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIStream,
     528                                           (void**)ppas );
     529        IClassFactory_Release( pcf );
     530
     531        if ( hr == S_OK )
     532        {
     533                hr = IAVIStream_Create((*ppas),lParam1,lParam2);
     534                if ( hr != S_OK )
     535                {
     536                        IAVIStream_Release((*ppas));
     537                        *ppas = NULL;
     538                }
     539        }
     540
     541        return hr;
     542}
     543
     544/***********************************************************************
     545 *              AVIMakeCompressedStream (AVIFIL32.@)
    547546 */
    548547HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler)
    549548{
    550     FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
    551     return E_FAIL;
    552 }
    553 
     549        FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
     550        return E_FAIL;
     551}
     552
  • trunk/src/avifil32/comentry.c

    r6644 r6712  
    1 /* $Id: comentry.c,v 1.2 2001-09-05 12:00:53 bird Exp $
    2  *
     1/*
    32 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
    43 */
     
    2827static ICOM_VTABLE(IClassFactory) iclassfact =
    2928{
    30     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    31     IClassFactory_fnQueryInterface,
    32     IClassFactory_fnAddRef,
    33     IClassFactory_fnRelease,
    34     IClassFactory_fnCreateInstance,
    35     IClassFactory_fnLockServer
     29        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     30        IClassFactory_fnQueryInterface,
     31        IClassFactory_fnAddRef,
     32        IClassFactory_fnRelease,
     33        IClassFactory_fnCreateInstance,
     34        IClassFactory_fnLockServer
    3635};
    3736
    3837typedef struct
    3938{
    40     /* IUnknown fields */
    41     ICOM_VFIELD(IClassFactory);
    42     DWORD   ref;
     39        /* IUnknown fields */
     40        ICOM_VFIELD(IClassFactory);
     41        DWORD   ref;
    4342} IClassFactoryImpl;
    4443
     
    5049IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
    5150{
    52     ICOM_THIS(IClassFactoryImpl,iface);
     51        ICOM_THIS(IClassFactoryImpl,iface);
    5352
    54     TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
    55     if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
    56          ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
    57     {
    58         *ppobj = iface;
    59         IClassFactory_AddRef(iface);
    60         return S_OK;
    61     }
     53        TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
     54        if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
     55             ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
     56        {
     57                *ppobj = iface;
     58                IClassFactory_AddRef(iface);
     59                return S_OK;
     60        }
    6261
    63     return E_NOINTERFACE;
     62        return E_NOINTERFACE;
    6463}
    6564
    6665static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
    6766{
    68     ICOM_THIS(IClassFactoryImpl,iface);
     67        ICOM_THIS(IClassFactoryImpl,iface);
    6968
    70     TRACE("(%p)->()\n",This);
    71     if ( (This->ref) == 0 )
    72         AVIFILE_data.dwClassObjRef ++;
     69        TRACE("(%p)->()\n",This);
     70        if ( (This->ref) == 0 )
     71                AVIFILE_data.dwClassObjRef ++;
    7372
    74     return ++(This->ref);
     73        return ++(This->ref);
    7574}
    7675
    7776static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
    7877{
    79     ICOM_THIS(IClassFactoryImpl,iface);
     78        ICOM_THIS(IClassFactoryImpl,iface);
    8079
    81     TRACE("(%p)->()\n",This);
    82     if ( (--(This->ref)) > 0 )
    83         return This->ref;
     80        TRACE("(%p)->()\n",This);
     81        if ( (--(This->ref)) > 0 )
     82                return This->ref;
    8483
    85     AVIFILE_data.dwClassObjRef --;
    86     return 0;
     84        AVIFILE_data.dwClassObjRef --;
     85        return 0;
    8786}
    8887
     
    9190    /*ICOM_THIS(IClassFactoryImpl,iface);*/
    9291
    93     *ppobj = NULL;
    94     if ( pOuter != NULL )
    95         return E_FAIL;
     92        *ppobj = NULL;
     93        if ( pOuter != NULL )
     94                return E_FAIL;
    9695
    97     if ( IsEqualGUID( &IID_IAVIFile, riid ) )
    98         return AVIFILE_CreateIAVIFile(ppobj);
    99     if ( IsEqualGUID( &IID_IAVIStream, riid ) )
    100         return AVIFILE_CreateIAVIStream(ppobj);
     96        if ( IsEqualGUID( &IID_IAVIFile, riid ) )
     97                return AVIFILE_CreateIAVIFile(ppobj);
     98        if ( IsEqualGUID( &IID_IAVIStream, riid ) )
     99                return AVIFILE_CreateIAVIStream(ppobj);
    101100
    102     return E_NOINTERFACE;
     101        return E_NOINTERFACE;
    103102}
    104103
    105104static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock)
    106105{
    107     ICOM_THIS(IClassFactoryImpl,iface);
    108     HRESULT hr;
     106        ICOM_THIS(IClassFactoryImpl,iface);
     107        HRESULT hr;
    109108
    110     FIXME("(%p)->(%d),stub!\n",This,dolock);
    111     if (dolock)
    112         hr = IClassFactory_AddRef(iface);
    113     else
    114         hr = IClassFactory_Release(iface);
     109        FIXME("(%p)->(%d),stub!\n",This,dolock);
     110        if (dolock)
     111                hr = IClassFactory_AddRef(iface);
     112        else
     113                hr = IClassFactory_Release(iface);
    115114
    116     return hr;
     115        return hr;
    117116}
    118117
    119118
    120119/***********************************************************************
    121  *      DllGetClassObject (AVIFIL32.@)
     120 *              DllGetClassObject (AVIFIL32.@)
    122121 */
    123122HRESULT WINAPI AVIFILE_DllGetClassObject(const CLSID* pclsid,const IID* piid,void** ppv)
    124123{
    125     *ppv = NULL;
    126     if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
    127     {
    128         *ppv = (LPVOID)&AVIFILE_GlobalCF;
    129         IClassFactory_AddRef((IClassFactory*)*ppv);
    130         return S_OK;
    131     }
     124        *ppv = NULL;
     125        if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
     126        {
     127                *ppv = (LPVOID)&AVIFILE_GlobalCF;
     128                IClassFactory_AddRef((IClassFactory*)*ppv);
     129                return S_OK;
     130        }
    132131
    133     return CLASS_E_CLASSNOTAVAILABLE;
     132        return CLASS_E_CLASSNOTAVAILABLE;
    134133}
    135134
    136135/*****************************************************************************
    137  *      DllCanUnloadNow (AVIFIL32.@)
     136 *              DllCanUnloadNow (AVIFIL32.@)
    138137 */
    139138DWORD WINAPI AVIFILE_DllCanUnloadNow(void)
    140139{
    141     return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;
     140        return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;
    142141}
    143142
  • trunk/src/avifil32/guid.c

    r6652 r6712  
    1 /* $Id: guid.c,v 1.2 2001-09-05 14:16:44 bird Exp $ */
    21#define INITGUID
    32
  • trunk/src/avifil32/iafile.c

    r6652 r6712  
    1 /* $Id: iafile.c,v 1.2 2001-09-05 14:16:44 bird Exp $ */
    21/*
    32 * Copyright 1999 Marcus Meissner
     
    2120DEFAULT_DEBUG_CHANNEL(avifile);
    2221
    23 #define AVIFILE_STREAMS_MAX 4
     22#define AVIFILE_STREAMS_MAX     4
    2423
    2524
     
    5352typedef struct IAVIFileImpl
    5453{
    55     ICOM_VFIELD(IAVIFile);
    56     /* IUnknown stuff */
    57     DWORD           ref;
    58     /* IAVIFile stuff */
    59     HANDLE          hf;
    60     DWORD           dwAVIFileCaps;
    61     DWORD           dwAVIFileScale;
    62     DWORD           dwAVIFileRate;
    63     DWORD           dwAVIFileLength;
    64     DWORD           dwAVIFileEditCount;
    65     MainAVIHeader       hdr;
    66     IAVIStream*     pStreams[AVIFILE_STREAMS_MAX];
    67     AVIStreamHeader     strhdrs[AVIFILE_STREAMS_MAX];
    68     DWORD           dwMoviTop;
    69     DWORD           dwCountOfIndexEntry;
    70     AVIINDEXENTRY*      pIndexEntry;
    71     AVIINDEXENTRY*      pStreamIndexEntry[AVIFILE_STREAMS_MAX+1];
     54        ICOM_VFIELD(IAVIFile);
     55        /* IUnknown stuff */
     56        DWORD                   ref;
     57        /* IAVIFile stuff */
     58        HANDLE                  hf;
     59        DWORD                   dwAVIFileCaps;
     60        DWORD                   dwAVIFileScale;
     61        DWORD                   dwAVIFileRate;
     62        DWORD                   dwAVIFileLength;
     63        DWORD                   dwAVIFileEditCount;
     64        MainAVIHeader           hdr;
     65        IAVIStream*             pStreams[AVIFILE_STREAMS_MAX];
     66        AVIStreamHeader         strhdrs[AVIFILE_STREAMS_MAX];
     67        DWORD                   dwMoviTop;
     68        DWORD                   dwCountOfIndexEntry;
     69        AVIINDEXENTRY*          pIndexEntry;
     70        AVIINDEXENTRY*          pStreamIndexEntry[AVIFILE_STREAMS_MAX+1];
    7271} IAVIFileImpl;
    7372
     
    7877
    7978static HRESULT AVIFILE_IAVIFile_ReadNextChunkHeader(
    80         IAVIFileImpl* This, FOURCC* pfcc, DWORD* pdwSize )
    81 {
    82     BYTE    buf[8];
    83     DWORD   dwRead;
    84 
    85     if ( ( !ReadFile( This->hf, buf, 8, &dwRead, NULL ) ) ||
    86          ( 8 != dwRead ) )
    87         return AVIERR_FILEREAD;
    88     *pfcc = mmioFOURCC(buf[0],buf[1],buf[2],buf[3]);
    89     *pdwSize = ( ((DWORD)buf[4])       ) |
    90            ( ((DWORD)buf[5]) <<  8 ) |
    91            ( ((DWORD)buf[6]) << 16 ) |
    92            ( ((DWORD)buf[7]) << 24 );
    93 
    94     return S_OK;
     79                IAVIFileImpl* This, FOURCC* pfcc, DWORD* pdwSize )
     80{
     81        BYTE    buf[8];
     82        DWORD   dwRead;
     83
     84        if ( ( !ReadFile( This->hf, buf, 8, &dwRead, NULL ) ) ||
     85             ( 8 != dwRead ) )
     86                return AVIERR_FILEREAD;
     87        *pfcc = mmioFOURCC(buf[0],buf[1],buf[2],buf[3]);
     88        *pdwSize = ( ((DWORD)buf[4])       ) |
     89                   ( ((DWORD)buf[5]) <<  8 ) |
     90                   ( ((DWORD)buf[6]) << 16 ) |
     91                   ( ((DWORD)buf[7]) << 24 );
     92
     93        return S_OK;
    9594}
    9695
    9796static HRESULT AVIFILE_IAVIFile_SkipChunkData(
    98         IAVIFileImpl* This, DWORD dwChunkSize )
    99 {
    100     LONG    lHigh = 0;
    101     DWORD   dwRes;
    102 
    103     if ( dwChunkSize == 0 )
    104         return S_OK;
    105 
    106     SetLastError(NO_ERROR);
    107     dwRes = SetFilePointer( This->hf, (LONG)dwChunkSize,
    108                 &lHigh, FILE_CURRENT );
    109     if ( dwRes == (DWORD)0xffffffff && GetLastError() != NO_ERROR )
    110         return AVIERR_FILEREAD;
    111 
    112     return S_OK;
     97                IAVIFileImpl* This, DWORD dwChunkSize )
     98{
     99        LONG    lHigh = 0;
     100        DWORD   dwRes;
     101
     102        if ( dwChunkSize == 0 )
     103                return S_OK;
     104
     105        SetLastError(NO_ERROR);
     106        dwRes = SetFilePointer( This->hf, (LONG)dwChunkSize,
     107                                &lHigh, FILE_CURRENT );
     108        if ( dwRes == (DWORD)0xffffffff && GetLastError() != NO_ERROR )
     109                return AVIERR_FILEREAD;
     110
     111        return S_OK;
    113112}
    114113
    115114static HRESULT AVIFILE_IAVIFile_ReadChunkData(
    116         IAVIFileImpl* This, DWORD dwChunkSize,
    117         LPVOID lpvBuf, DWORD dwBufSize, LPDWORD lpdwRead )
    118 {
    119     if ( dwBufSize > dwChunkSize )
    120         dwBufSize = dwChunkSize;
    121     if ( ( !ReadFile( This->hf, lpvBuf, dwBufSize, lpdwRead, NULL ) ) ||
    122          ( dwBufSize != *lpdwRead ) )
    123         return AVIERR_FILEREAD;
    124 
    125     return AVIFILE_IAVIFile_SkipChunkData( This, dwChunkSize - dwBufSize );
     115                IAVIFileImpl* This, DWORD dwChunkSize,
     116                LPVOID lpvBuf, DWORD dwBufSize, LPDWORD lpdwRead )
     117{
     118        if ( dwBufSize > dwChunkSize )
     119                dwBufSize = dwChunkSize;
     120        if ( ( !ReadFile( This->hf, lpvBuf, dwBufSize, lpdwRead, NULL ) ) ||
     121             ( dwBufSize != *lpdwRead ) )
     122                return AVIERR_FILEREAD;
     123
     124        return AVIFILE_IAVIFile_SkipChunkData( This, dwChunkSize - dwBufSize );
    126125}
    127126
    128127static HRESULT AVIFILE_IAVIFile_SeekToSpecifiedChunk(
    129         IAVIFileImpl* This, FOURCC fccType, DWORD* pdwLen )
    130 {
    131     HRESULT hr;
    132     FOURCC  fcc;
    133     BYTE    buf[4];
    134     DWORD   dwRead;
    135 
    136     while ( 1 )
    137     {
    138         hr = AVIFILE_IAVIFile_ReadNextChunkHeader(
    139                 This, &fcc, pdwLen );
    140         if ( hr != S_OK )
    141             return hr;
    142         if ( fcc == fccType )
    143             return S_OK;
    144 
    145         if ( fcc == FOURCC_LIST )
    146         {
    147             if ( ( !ReadFile( This->hf, buf, 4, &dwRead, NULL ) ) ||
    148             ( 4 != dwRead ) )
    149             return AVIERR_FILEREAD;
    150         }
    151         else
    152         {
    153             hr = AVIFILE_IAVIFile_SkipChunkData(
    154                     This, *pdwLen );
    155             if ( hr != S_OK )
    156             return hr;
    157         }
    158     }
     128                IAVIFileImpl* This, FOURCC fccType, DWORD* pdwLen )
     129{
     130        HRESULT hr;
     131        FOURCC  fcc;
     132        BYTE    buf[4];
     133        DWORD   dwRead;
     134
     135        while ( 1 )
     136        {
     137                hr = AVIFILE_IAVIFile_ReadNextChunkHeader(
     138                                This, &fcc, pdwLen );
     139                if ( hr != S_OK )
     140                        return hr;
     141                if ( fcc == fccType )
     142                        return S_OK;
     143
     144                if ( fcc == FOURCC_LIST )
     145                {
     146                    if ( ( !ReadFile( This->hf, buf, 4, &dwRead, NULL ) ) ||
     147                        ( 4 != dwRead ) )
     148                        return AVIERR_FILEREAD;
     149                }
     150                else
     151                {
     152                    hr = AVIFILE_IAVIFile_SkipChunkData(
     153                                        This, *pdwLen );
     154                    if ( hr != S_OK )
     155                        return hr;
     156                }
     157        }
    159158}
    160159
     
    162161WINE_AVISTREAM_DATA* AVIFILE_Alloc_IAVIStreamData( DWORD dwFmtLen )
    163162{
    164     WINE_AVISTREAM_DATA*    pData;
    165 
    166     pData = (WINE_AVISTREAM_DATA*)
    167         HeapAlloc( AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    168                sizeof(WINE_AVISTREAM_DATA) );
    169     if ( pData == NULL )
    170         return NULL;
    171     if ( dwFmtLen > 0 )
    172     {
    173         pData->pbFmt = (BYTE*)
    174             HeapAlloc( AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    175                    sizeof(BYTE)*dwFmtLen );
    176         if ( pData->pbFmt == NULL )
    177         {
    178             AVIFILE_Free_IAVIStreamData( pData );
    179             return NULL;
    180         }
    181     }
    182     pData->dwFmtLen = dwFmtLen;
    183 
    184     return pData;
     163        WINE_AVISTREAM_DATA*    pData;
     164
     165        pData = (WINE_AVISTREAM_DATA*)
     166                HeapAlloc( AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     167                           sizeof(WINE_AVISTREAM_DATA) );
     168        if ( pData == NULL )
     169                return NULL;
     170        if ( dwFmtLen > 0 )
     171        {
     172                pData->pbFmt = (BYTE*)
     173                        HeapAlloc( AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     174                                   sizeof(BYTE)*dwFmtLen );
     175                if ( pData->pbFmt == NULL )
     176                {
     177                        AVIFILE_Free_IAVIStreamData( pData );
     178                        return NULL;
     179                }
     180        }
     181        pData->dwFmtLen = dwFmtLen;
     182
     183        return pData;
    185184}
    186185
    187186void AVIFILE_Free_IAVIStreamData( WINE_AVISTREAM_DATA* pData )
    188187{
    189     if ( pData != NULL )
    190     {
    191         if ( pData->pbFmt != NULL )
    192             HeapFree( AVIFILE_data.hHeap,0,pData->pbFmt );
    193         HeapFree( AVIFILE_data.hHeap,0,pData );
    194     }
     188        if ( pData != NULL )
     189        {
     190                if ( pData->pbFmt != NULL )
     191                        HeapFree( AVIFILE_data.hHeap,0,pData->pbFmt );
     192                HeapFree( AVIFILE_data.hHeap,0,pData );
     193        }
    195194}
    196195
    197196static void AVIFILE_IAVIFile_InitIndexTable(
    198         IAVIFileImpl* This,
    199         AVIINDEXENTRY* pIndexBuf,
    200         AVIINDEXENTRY* pIndexData,
    201         DWORD dwCountOfIndexEntry )
    202 {
    203     DWORD   dwStreamIndex;
    204     DWORD   dwIndex;
    205     FOURCC  ckid;
    206 
    207     dwStreamIndex = 0;
    208     for ( ; dwStreamIndex < (AVIFILE_STREAMS_MAX+1); dwStreamIndex ++ )
    209         This->pStreamIndexEntry[dwStreamIndex] = NULL;
    210 
    211     dwStreamIndex = 0;
    212     for ( ; dwStreamIndex < This->hdr.dwStreams; dwStreamIndex ++ )
    213     {
    214         ckid = mmioFOURCC('0','0'+dwStreamIndex,0,0);
    215         TRACE( "testing ckid %c%c%c%c\n",
    216             (int)(ckid>> 0)&0xff,
    217             (int)(ckid>> 8)&0xff,
    218             (int)(ckid>>16)&0xff,
    219             (int)(ckid>>24)&0xff );
    220         This->pStreamIndexEntry[dwStreamIndex] = pIndexBuf;
    221         FIXME( "pIndexBuf = %p\n", pIndexBuf );
    222         for ( dwIndex = 0; dwIndex < dwCountOfIndexEntry; dwIndex++ )
    223         {
    224             TRACE( "ckid %c%c%c%c\n",
    225                 (int)(pIndexData[dwIndex].ckid>> 0)&0xff,
     197                IAVIFileImpl* This,
     198                AVIINDEXENTRY* pIndexBuf,
     199                AVIINDEXENTRY* pIndexData,
     200                DWORD dwCountOfIndexEntry )
     201{
     202        DWORD   dwStreamIndex;
     203        DWORD   dwIndex;
     204        FOURCC  ckid;
     205
     206        dwStreamIndex = 0;
     207        for ( ; dwStreamIndex < (AVIFILE_STREAMS_MAX+1); dwStreamIndex ++ )
     208                This->pStreamIndexEntry[dwStreamIndex] = NULL;
     209
     210        dwStreamIndex = 0;
     211        for ( ; dwStreamIndex < This->hdr.dwStreams; dwStreamIndex ++ )
     212        {
     213                ckid = mmioFOURCC('0','0'+dwStreamIndex,0,0);
     214                TRACE( "testing ckid %c%c%c%c\n",
     215                        (int)(ckid>> 0)&0xff,
     216                        (int)(ckid>> 8)&0xff,
     217                        (int)(ckid>>16)&0xff,
     218                        (int)(ckid>>24)&0xff );
     219                This->pStreamIndexEntry[dwStreamIndex] = pIndexBuf;
     220                FIXME( "pIndexBuf = %p\n", pIndexBuf );
     221                for ( dwIndex = 0; dwIndex < dwCountOfIndexEntry; dwIndex++ )
     222                {
     223                    TRACE( "ckid %c%c%c%c\n",
     224                            (int)(pIndexData[dwIndex].ckid>> 0)&0xff,
    226225                            (int)(pIndexData[dwIndex].ckid>> 8)&0xff,
    227226                            (int)(pIndexData[dwIndex].ckid>>16)&0xff,
    228227                            (int)(pIndexData[dwIndex].ckid>>24)&0xff );
    229 
    230             if ( (pIndexData[dwIndex].ckid & mmioFOURCC(0xff,0xff,0,0))
    231                                 == ckid )
    232             {
    233             memcpy( pIndexBuf, &pIndexData[dwIndex],
    234                 sizeof(AVIINDEXENTRY) );
    235             pIndexBuf ++;
    236             }
    237         }
     228                           
     229                    if ( (pIndexData[dwIndex].ckid & mmioFOURCC(0xff,0xff,0,0))
     230                                                                == ckid )
     231                    {
     232                        memcpy( pIndexBuf, &pIndexData[dwIndex],
     233                                sizeof(AVIINDEXENTRY) );
     234                        pIndexBuf ++;
     235                    }
     236                }
    238237                FIXME( "pIndexBuf = %p\n", pIndexBuf );
    239     }
    240     This->pStreamIndexEntry[This->hdr.dwStreams] = pIndexBuf;
     238        }
     239        This->pStreamIndexEntry[This->hdr.dwStreams] = pIndexBuf;
    241240}
    242241
     
    251250HRESULT AVIFILE_CreateIAVIFile(void** ppobj)
    252251{
    253     IAVIFileImpl    *This;
    254     HRESULT     hr;
    255 
    256     TRACE("(%p)\n",ppobj);
    257     *ppobj = NULL;
    258     This = (IAVIFileImpl*)HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    259                     sizeof(IAVIFileImpl));
    260     if ( This == NULL )
    261         return AVIERR_MEMORY;
    262     This->ref = 1;
    263     ICOM_VTBL(This) = &iavift;
    264     hr = AVIFILE_IAVIFile_Construct( This );
    265     if ( hr != S_OK )
    266     {
    267         AVIFILE_IAVIFile_Destruct( This );
    268         return hr;
    269     }
    270 
    271     TRACE("new -> %p\n",This);
    272     *ppobj = (LPVOID)This;
    273 
    274     return S_OK;
     252        IAVIFileImpl    *This;
     253        HRESULT         hr;
     254
     255        TRACE("(%p)\n",ppobj);
     256        *ppobj = NULL;
     257        This = (IAVIFileImpl*)HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     258                                        sizeof(IAVIFileImpl));
     259        if ( This == NULL )
     260                return AVIERR_MEMORY;
     261        This->ref = 1;
     262        ICOM_VTBL(This) = &iavift;
     263        hr = AVIFILE_IAVIFile_Construct( This );
     264        if ( hr != S_OK )
     265        {
     266                AVIFILE_IAVIFile_Destruct( This );
     267                return hr;
     268        }
     269
     270        TRACE("new -> %p\n",This);
     271        *ppobj = (LPVOID)This;
     272
     273        return S_OK;
    275274}
    276275
     
    280279
    281280static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj) {
    282     ICOM_THIS(IAVIFileImpl,iface);
    283 
    284     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    285     if ( IsEqualGUID(&IID_IUnknown,refiid) ||
    286          IsEqualGUID(&IID_IAVIFile,refiid) )
    287     {
    288         *obj = iface;
    289         IAVIFile_AddRef(iface);
    290         return S_OK;
    291     }
    292     return OLE_E_ENUM_NOMORE;
     281        ICOM_THIS(IAVIFileImpl,iface);
     282
     283        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     284        if ( IsEqualGUID(&IID_IUnknown,refiid) ||
     285             IsEqualGUID(&IID_IAVIFile,refiid) )
     286        {
     287                *obj = iface;
     288                IAVIFile_AddRef(iface);
     289                return S_OK;
     290        }
     291        return OLE_E_ENUM_NOMORE;
    293292}
    294293
    295294static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface) {
    296     ICOM_THIS(IAVIFileImpl,iface);
    297 
    298     TRACE("(%p)->AddRef()\n",iface);
    299     return ++(This->ref);
     295        ICOM_THIS(IAVIFileImpl,iface);
     296
     297        TRACE("(%p)->AddRef()\n",iface);
     298        return ++(This->ref);
    300299}
    301300
    302301static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface) {
    303     ICOM_THIS(IAVIFileImpl,iface);
    304 
    305     TRACE("(%p)->Release()\n",iface);
    306     if ( (--(This->ref)) > 0 )
    307         return This->ref;
    308 
    309     AVIFILE_IAVIFile_Destruct(This);
    310     HeapFree(AVIFILE_data.hHeap,0,iface);
    311     return 0;
     302        ICOM_THIS(IAVIFileImpl,iface);
     303
     304        TRACE("(%p)->Release()\n",iface);
     305        if ( (--(This->ref)) > 0 )
     306                return This->ref;
     307
     308        AVIFILE_IAVIFile_Destruct(This);
     309        HeapFree(AVIFILE_data.hHeap,0,iface);
     310        return 0;
    312311}
    313312
     
    318317static HRESULT AVIFILE_IAVIFile_Construct( IAVIFileImpl* This )
    319318{
    320     DWORD   dwIndex;
    321 
    322     This->hf = INVALID_HANDLE_VALUE;
    323     This->dwAVIFileCaps = 0;
    324     This->dwAVIFileScale = 0;
    325     This->dwAVIFileRate = 0;
    326     This->dwAVIFileLength = 0;
    327     This->dwAVIFileEditCount = 0;
    328     for ( dwIndex = 0; dwIndex < AVIFILE_STREAMS_MAX; dwIndex++ )
    329         This->pStreams[dwIndex] = NULL;
    330     This->dwCountOfIndexEntry = 0;
    331     This->pIndexEntry = NULL;
    332 
    333     AVIFILE_data.dwClassObjRef ++;
    334 
    335     return S_OK;
     319        DWORD   dwIndex;
     320
     321        This->hf = INVALID_HANDLE_VALUE;
     322        This->dwAVIFileCaps = 0;
     323        This->dwAVIFileScale = 0;
     324        This->dwAVIFileRate = 0;
     325        This->dwAVIFileLength = 0;
     326        This->dwAVIFileEditCount = 0;
     327        for ( dwIndex = 0; dwIndex < AVIFILE_STREAMS_MAX; dwIndex++ )
     328                This->pStreams[dwIndex] = NULL;
     329        This->dwCountOfIndexEntry = 0;
     330        This->pIndexEntry = NULL;
     331
     332        AVIFILE_data.dwClassObjRef ++;
     333
     334        return S_OK;
    336335}
    337336
    338337static void AVIFILE_IAVIFile_Destruct( IAVIFileImpl* This )
    339338{
    340     DWORD   dwIndex;
    341 
    342     if ( This->pIndexEntry != NULL )
    343     {
    344         HeapFree(AVIFILE_data.hHeap,0,This->pIndexEntry);
    345         This->pIndexEntry = NULL;
    346     }
    347 
    348     for ( dwIndex = 0; dwIndex < AVIFILE_STREAMS_MAX; dwIndex++ )
    349     {
    350         if ( This->pStreams[dwIndex] != NULL )
    351         {
    352             IAVIStream_Release( This->pStreams[dwIndex] );
    353             This->pStreams[dwIndex] = NULL;
    354         }
    355     }
    356 
    357     if ( This->hf != INVALID_HANDLE_VALUE )
    358         CloseHandle( This->hf );
    359 
    360     AVIFILE_data.dwClassObjRef --;
     339        DWORD   dwIndex;
     340
     341        if ( This->pIndexEntry != NULL )
     342        {
     343                HeapFree(AVIFILE_data.hHeap,0,This->pIndexEntry);
     344                This->pIndexEntry = NULL;
     345        }
     346
     347        for ( dwIndex = 0; dwIndex < AVIFILE_STREAMS_MAX; dwIndex++ )
     348        {
     349                if ( This->pStreams[dwIndex] != NULL )
     350                {
     351                        IAVIStream_Release( This->pStreams[dwIndex] );
     352                        This->pStreams[dwIndex] = NULL;
     353                }
     354        }
     355
     356        if ( This->hf != INVALID_HANDLE_VALUE )
     357                CloseHandle( This->hf );
     358
     359        AVIFILE_data.dwClassObjRef --;
    361360}
    362361
    363362static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size)
    364363{
    365     ICOM_THIS(IAVIFileImpl,iface);
    366     AVIFILEINFOW    fiw;
    367 
    368     FIXME("(%p)->Info(%p,%ld)\n",iface,afi,size);
    369 
    370     memset( &fiw, 0, sizeof(fiw) );
    371     fiw.dwMaxBytesPerSec = This->hdr.dwMaxBytesPerSec;
    372     fiw.dwFlags = This->hdr.dwFlags;
    373     fiw.dwCaps = This->dwAVIFileCaps;
    374     fiw.dwStreams = This->hdr.dwStreams;
    375     fiw.dwSuggestedBufferSize = This->hdr.dwSuggestedBufferSize;
    376     fiw.dwWidth = This->hdr.dwWidth;
    377     fiw.dwHeight = This->hdr.dwHeight;
    378     fiw.dwScale = This->dwAVIFileScale; /* FIXME */
    379     fiw.dwRate = This->dwAVIFileRate; /* FIXME */
    380     fiw.dwLength = This->dwAVIFileLength; /* FIXME */
    381     fiw.dwEditCount = This->dwAVIFileEditCount; /* FIXME */
    382     /* fiw.szFileType[64]; */
    383 
    384     if ( size > sizeof(AVIFILEINFOW) )
    385         size = sizeof(AVIFILEINFOW);
    386     memcpy( afi, &fiw, size );
    387 
    388     return S_OK;
     364        ICOM_THIS(IAVIFileImpl,iface);
     365        AVIFILEINFOW    fiw;
     366
     367        FIXME("(%p)->Info(%p,%ld)\n",iface,afi,size);
     368
     369        memset( &fiw, 0, sizeof(fiw) );
     370        fiw.dwMaxBytesPerSec = This->hdr.dwMaxBytesPerSec;
     371        fiw.dwFlags = This->hdr.dwFlags;
     372        fiw.dwCaps = This->dwAVIFileCaps;
     373        fiw.dwStreams = This->hdr.dwStreams;
     374        fiw.dwSuggestedBufferSize = This->hdr.dwSuggestedBufferSize;
     375        fiw.dwWidth = This->hdr.dwWidth;
     376        fiw.dwHeight = This->hdr.dwHeight;
     377        fiw.dwScale = This->dwAVIFileScale; /* FIXME */
     378        fiw.dwRate = This->dwAVIFileRate; /* FIXME */
     379        fiw.dwLength = This->dwAVIFileLength; /* FIXME */
     380        fiw.dwEditCount = This->dwAVIFileEditCount; /* FIXME */
     381        /* fiw.szFileType[64]; */
     382
     383        if ( size > sizeof(AVIFILEINFOW) )
     384                size = sizeof(AVIFILEINFOW);
     385        memcpy( afi, &fiw, size );
     386
     387        return S_OK;
    389388}
    390389
    391390static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam)
    392391{
    393     ICOM_THIS(IAVIFileImpl,iface);
    394 
    395     FIXME("(%p)->GetStream(%p,0x%08lx,%ld)\n",iface,avis,fccType,lParam);
    396     if ( fccType != 0 )
    397         return E_FAIL;
    398     if ( lParam < 0 || lParam >= This->hdr.dwStreams )
    399         return E_FAIL;
    400     *avis = This->pStreams[lParam];
    401     IAVIStream_AddRef( *avis );
    402 
    403     return S_OK;
     392        ICOM_THIS(IAVIFileImpl,iface);
     393
     394        FIXME("(%p)->GetStream(%p,0x%08lx,%ld)\n",iface,avis,fccType,lParam);
     395        if ( fccType != 0 )
     396                return E_FAIL;
     397        if ( lParam < 0 || lParam >= This->hdr.dwStreams )
     398                return E_FAIL;
     399        *avis = This->pStreams[lParam];
     400        IAVIStream_AddRef( *avis );
     401
     402        return S_OK;
    404403}
    405404
    406405static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi)
    407406{
    408     ICOM_THIS(IAVIFileImpl,iface);
    409 
    410     FIXME("(%p,%p,%p)\n",This,avis,asi);
    411     return E_FAIL;
     407        ICOM_THIS(IAVIFileImpl,iface);
     408
     409        FIXME("(%p,%p,%p)\n",This,avis,asi);
     410        return E_FAIL;
    412411}
    413412
    414413static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size)
    415414{
    416     ICOM_THIS(IAVIFileImpl,iface);
    417 
    418     FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",This,ckid,lpData,size);
    419     /* FIXME: write data to file */
    420     return E_FAIL;
     415        ICOM_THIS(IAVIFileImpl,iface);
     416
     417        FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",This,ckid,lpData,size);
     418        /* FIXME: write data to file */
     419        return E_FAIL;
    421420}
    422421
    423422static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size)
    424423{
    425     ICOM_THIS(IAVIFileImpl,iface);
    426 
    427     FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",This,ckid,lpData,size);
    428     /* FIXME: read at most size bytes from file */
    429 
    430     return E_FAIL;
     424        ICOM_THIS(IAVIFileImpl,iface);
     425
     426        FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",This,ckid,lpData,size);
     427        /* FIXME: read at most size bytes from file */
     428
     429        return E_FAIL;
    431430}
    432431
    433432static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface)
    434433{
    435     ICOM_THIS(IAVIFileImpl,iface);
    436 
    437     FIXME("(%p)->EndRecord()\n",This);
    438     /* FIXME: end record? */
    439     return E_FAIL;
     434        ICOM_THIS(IAVIFileImpl,iface);
     435
     436        FIXME("(%p)->EndRecord()\n",This);
     437        /* FIXME: end record? */
     438        return E_FAIL;
    440439}
    441440
    442441static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam)
    443442{
    444     ICOM_THIS(IAVIFileImpl,iface);
    445 
    446     FIXME("(%p)->DeleteStream(0x%08lx,%ld)\n",This,fccType,lParam);
    447     /* FIXME: delete stream? */
    448     return E_FAIL;
     443        ICOM_THIS(IAVIFileImpl,iface);
     444
     445        FIXME("(%p)->DeleteStream(0x%08lx,%ld)\n",This,fccType,lParam);
     446        /* FIXME: delete stream? */
     447        return E_FAIL;
    449448}
    450449
    451450/*****************************************************************************
    452  *  AVIFILE_IAVIFile_Open (internal)
     451 *      AVIFILE_IAVIFile_Open (internal)
    453452 */
    454453HRESULT AVIFILE_IAVIFile_Open( PAVIFILE paf, LPCWSTR szFile, UINT uMode )
    455454{
    456     ICOM_THIS(IAVIFileImpl,paf);
    457     HRESULT     hr;
    458     DWORD       dwAcc;
    459     DWORD       dwShared;
    460     DWORD       dwCreate;
    461     BYTE        buf[12];
    462     DWORD       dwRead;
    463     FOURCC      fccFileType;
    464     DWORD       dwLen;
    465     DWORD       dwIndex;
    466 
    467     FIXME("(%p)->Open(%p,%u)\n",This,szFile,uMode);
    468 
    469     if ( This->hf != INVALID_HANDLE_VALUE )
    470     {
    471         CloseHandle( This->hf );
    472         This->hf = INVALID_HANDLE_VALUE;
    473     }
    474 
    475     switch ( uMode & 0x3 )
    476     {
    477     case OF_READ: /* 0x0 */
    478         dwAcc = GENERIC_READ;
    479         dwCreate = OPEN_EXISTING;
    480         This->dwAVIFileCaps = AVIFILECAPS_CANREAD;
    481         break;
    482     case OF_WRITE: /* 0x1 */
    483         dwAcc = GENERIC_WRITE;
    484         dwCreate = OPEN_ALWAYS;
    485         This->dwAVIFileCaps = AVIFILECAPS_CANWRITE;
    486         break;
    487     case OF_READWRITE: /* 0x2 */
    488         dwAcc = GENERIC_READ|GENERIC_WRITE;
    489         dwCreate = OPEN_ALWAYS;
    490         This->dwAVIFileCaps = AVIFILECAPS_CANREAD|AVIFILECAPS_CANWRITE;
    491         break;
    492     default:
    493         return E_FAIL;
    494     }
    495 
    496     if ( This->dwAVIFileCaps & AVIFILECAPS_CANWRITE )
    497     {
    498         FIXME( "editing AVI is currently not supported!\n" );
    499         return E_FAIL;
    500     }
    501 
    502     switch ( uMode & 0x70 )
    503     {
    504     case OF_SHARE_COMPAT: /* 0x00 */
    505         dwShared = FILE_SHARE_READ|FILE_SHARE_WRITE;
    506         break;
    507     case OF_SHARE_EXCLUSIVE: /* 0x10 */
    508         dwShared = 0;
    509         break;
    510     case OF_SHARE_DENY_WRITE: /* 0x20 */
    511         dwShared = FILE_SHARE_READ;
    512         break;
    513     case OF_SHARE_DENY_READ: /* 0x30 */
    514         dwShared = FILE_SHARE_WRITE;
    515         break;
    516     case OF_SHARE_DENY_NONE: /* 0x40 */
    517         dwShared = FILE_SHARE_READ|FILE_SHARE_WRITE;
    518         break;
    519     default:
    520         return E_FAIL;
    521     }
    522     if ( uMode & OF_CREATE )
    523         dwCreate = CREATE_ALWAYS;
    524 
    525     This->hf = CreateFileW( szFile, dwAcc, dwShared, NULL,
    526                 dwCreate, FILE_ATTRIBUTE_NORMAL,
    527                 (HANDLE)NULL );
    528     if ( This->hf == INVALID_HANDLE_VALUE )
    529         return AVIERR_FILEOPEN;
    530 
    531     if ( dwAcc & GENERIC_READ )
    532     {
    533         if ( !ReadFile( This->hf, buf, 12, &dwRead, NULL ) )
    534         return AVIERR_FILEREAD;
    535         if ( dwRead == 12 )
    536         {
    537         if ( mmioFOURCC(buf[0],buf[1],buf[2],buf[3]) != FOURCC_RIFF )
    538             return AVIERR_BADFORMAT;
    539 
    540         fccFileType = mmioFOURCC(buf[8],buf[9],buf[10],buf[11]);
    541         if ( fccFileType != formtypeAVI )
    542             return AVIERR_BADFORMAT;
    543 
    544         /* get AVI main header. */
    545         hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
    546                 This, ckidAVIMAINHDR, &dwLen );
    547         if ( hr != S_OK )
    548             return hr;
    549         if ( dwLen < (sizeof(DWORD)*10) )
    550             return AVIERR_BADFORMAT;
    551         hr = AVIFILE_IAVIFile_ReadChunkData(
    552                 This, dwLen,
    553                 &(This->hdr), sizeof(MainAVIHeader), &dwLen );
    554         if ( This->hdr.dwStreams == 0 ||
    555              This->hdr.dwStreams > AVIFILE_STREAMS_MAX )
    556             return AVIERR_BADFORMAT;
    557 
    558         /* get stream headers. */
    559         dwIndex = 0;
    560         while ( dwIndex < This->hdr.dwStreams )
    561         {
    562             WINE_AVISTREAM_DATA*    pData;
    563 
    564             hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
    565                     This, ckidSTREAMHEADER, &dwLen );
    566             if ( hr != S_OK )
    567                 return hr;
    568             if ( dwLen < (sizeof(DWORD)*12) )
    569                 return AVIERR_BADFORMAT;
    570             hr = AVIFILE_IAVIFile_ReadChunkData(
    571                 This, dwLen,
    572                 &This->strhdrs[dwIndex],
    573                 sizeof(AVIStreamHeader), &dwLen );
    574 
    575             hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
    576                     This, ckidSTREAMFORMAT, &dwLen );
    577             if ( hr != S_OK )
    578                 return hr;
    579             pData = AVIFILE_Alloc_IAVIStreamData( dwLen );
    580             if ( pData == NULL )
    581                 return AVIERR_MEMORY;
    582             hr = AVIFILE_IAVIFile_ReadChunkData(
    583                 This, dwLen,
    584                 pData->pbFmt, dwLen, &dwLen );
    585             if ( hr != S_OK )
    586             {
    587                 AVIFILE_Free_IAVIStreamData( pData );
    588                 return hr;
    589             }
    590             pData->dwStreamIndex = dwIndex;
    591             pData->pstrhdr = &This->strhdrs[dwIndex];
    592 
    593             hr = AVIStreamCreate(&This->pStreams[dwIndex],
    594                          (LONG)paf, (LONG)(pData), NULL );
    595             if ( hr != S_OK )
    596             {
    597                 AVIFILE_Free_IAVIStreamData( pData );
    598                 return hr;
    599             }
    600 
    601             if ( (This->strhdrs[dwIndex].fccType
    602                     == mmioFOURCC('v','i','d','s')) ||
    603                  (This->strhdrs[dwIndex].fccType
    604                     == mmioFOURCC('V','I','D','S')) )
    605             {
    606                 This->dwAVIFileScale =
    607                     This->strhdrs[dwIndex].dwScale;
    608                 This->dwAVIFileRate =
    609                     This->strhdrs[dwIndex].dwRate;
    610                 This->dwAVIFileLength =
    611                     This->strhdrs[dwIndex].dwLength;
    612             }
    613             else
    614             if ( This->dwAVIFileScale == 0 )
    615             {
    616                 This->dwAVIFileScale =
    617                     This->strhdrs[dwIndex].dwScale;
    618                 This->dwAVIFileRate =
    619                     This->strhdrs[dwIndex].dwRate;
    620                 This->dwAVIFileLength =
    621                     This->strhdrs[dwIndex].dwLength;
    622             }
    623 
    624             dwIndex ++;
    625         }
    626 
    627         /* skip movi. */
    628         while ( 1 )
    629         {
    630             hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
    631                     This, FOURCC_LIST, &dwLen );
    632             if ( hr != S_OK )
    633                 return hr;
    634             if ( dwLen < 4 )
    635                 return AVIERR_BADFORMAT;
    636 
    637             This->dwMoviTop = SetFilePointer( This->hf,0,NULL,FILE_CURRENT );
    638             if ( This->dwMoviTop == 0xffffffff )
    639                 return AVIERR_BADFORMAT;
    640 
    641             if ( ( !ReadFile(This->hf, buf, 4, &dwRead, NULL) ) ||
    642                  ( dwRead != 4 ) )
    643                 return AVIERR_FILEREAD;
    644 
    645             hr = AVIFILE_IAVIFile_SkipChunkData(
    646                     This, dwLen - 4 );
    647             if ( hr != S_OK )
    648                 return hr;
    649             if ( mmioFOURCC(buf[0],buf[1],buf[2],buf[3])
    650                 == mmioFOURCC('m', 'o', 'v', 'i') )
    651                 break;
    652         }
    653 
    654         /* get idx1. */
    655         hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
    656                 This, ckidAVINEWINDEX, &dwLen );
    657         if ( hr != S_OK )
    658             return hr;
    659 
    660         This->dwCountOfIndexEntry = dwLen / sizeof(AVIINDEXENTRY);
    661         This->pIndexEntry = (AVIINDEXENTRY*)
    662             HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    663                   sizeof(AVIINDEXENTRY) *
    664                   This->dwCountOfIndexEntry * 2 );
    665         if ( This->pIndexEntry == NULL )
    666             return AVIERR_MEMORY;
    667         hr = AVIFILE_IAVIFile_ReadChunkData(
    668                 This, dwLen,
    669                 This->pIndexEntry + This->dwCountOfIndexEntry,
    670                 sizeof(AVIINDEXENTRY) *
    671                 This->dwCountOfIndexEntry, &dwLen );
    672         if ( hr != S_OK )
    673             return hr;
    674         AVIFILE_IAVIFile_InitIndexTable(
    675                 This, This->pIndexEntry,
    676                 This->pIndexEntry + This->dwCountOfIndexEntry,
    677                 This->dwCountOfIndexEntry );
    678         }
    679         else
    680         {
    681         /* FIXME - create the handle has GENERIC_WRITE access. */
    682         return AVIERR_FILEREAD;
    683         }
    684     }
    685     else
    686     {
    687         return AVIERR_FILEOPEN; /* FIXME */
    688     }
    689 
    690     return S_OK;
     455        ICOM_THIS(IAVIFileImpl,paf);
     456        HRESULT         hr;
     457        DWORD           dwAcc;
     458        DWORD           dwShared;
     459        DWORD           dwCreate;
     460        BYTE            buf[12];
     461        DWORD           dwRead;
     462        FOURCC          fccFileType;
     463        DWORD           dwLen;
     464        DWORD           dwIndex;
     465
     466        FIXME("(%p)->Open(%p,%u)\n",This,szFile,uMode);
     467
     468        if ( This->hf != INVALID_HANDLE_VALUE )
     469        {
     470                CloseHandle( This->hf );
     471                This->hf = INVALID_HANDLE_VALUE;
     472        }
     473
     474        switch ( uMode & 0x3 )
     475        {
     476        case OF_READ: /* 0x0 */
     477                dwAcc = GENERIC_READ;
     478                dwCreate = OPEN_EXISTING;
     479                This->dwAVIFileCaps = AVIFILECAPS_CANREAD;
     480                break;
     481        case OF_WRITE: /* 0x1 */
     482                dwAcc = GENERIC_WRITE;
     483                dwCreate = OPEN_ALWAYS;
     484                This->dwAVIFileCaps = AVIFILECAPS_CANWRITE;
     485                break;
     486        case OF_READWRITE: /* 0x2 */
     487                dwAcc = GENERIC_READ|GENERIC_WRITE;
     488                dwCreate = OPEN_ALWAYS;
     489                This->dwAVIFileCaps = AVIFILECAPS_CANREAD|AVIFILECAPS_CANWRITE;
     490                break;
     491        default:
     492                return E_FAIL;
     493        }
     494
     495        if ( This->dwAVIFileCaps & AVIFILECAPS_CANWRITE )
     496        {
     497                FIXME( "editing AVI is currently not supported!\n" );
     498                return E_FAIL;
     499        }
     500
     501        switch ( uMode & 0x70 )
     502        {
     503        case OF_SHARE_COMPAT: /* 0x00 */
     504                dwShared = FILE_SHARE_READ|FILE_SHARE_WRITE;
     505                break;
     506        case OF_SHARE_EXCLUSIVE: /* 0x10 */
     507                dwShared = 0;
     508                break;
     509        case OF_SHARE_DENY_WRITE: /* 0x20 */
     510                dwShared = FILE_SHARE_READ;
     511                break;
     512        case OF_SHARE_DENY_READ: /* 0x30 */
     513                dwShared = FILE_SHARE_WRITE;
     514                break;
     515        case OF_SHARE_DENY_NONE: /* 0x40 */
     516                dwShared = FILE_SHARE_READ|FILE_SHARE_WRITE;
     517                break;
     518        default:
     519                return E_FAIL;
     520        }
     521        if ( uMode & OF_CREATE )
     522                dwCreate = CREATE_ALWAYS;
     523
     524        This->hf = CreateFileW( szFile, dwAcc, dwShared, NULL,
     525                                dwCreate, FILE_ATTRIBUTE_NORMAL,
     526                                (HANDLE)NULL );
     527        if ( This->hf == INVALID_HANDLE_VALUE )
     528                return AVIERR_FILEOPEN;
     529
     530        if ( dwAcc & GENERIC_READ )
     531        {
     532            if ( !ReadFile( This->hf, buf, 12, &dwRead, NULL ) )
     533                return AVIERR_FILEREAD;
     534            if ( dwRead == 12 )
     535            {
     536                if ( mmioFOURCC(buf[0],buf[1],buf[2],buf[3]) != FOURCC_RIFF )
     537                        return AVIERR_BADFORMAT;
     538
     539                fccFileType = mmioFOURCC(buf[8],buf[9],buf[10],buf[11]);
     540                if ( fccFileType != formtypeAVI )
     541                        return AVIERR_BADFORMAT;
     542
     543                /* get AVI main header. */
     544                hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
     545                                This, ckidAVIMAINHDR, &dwLen );
     546                if ( hr != S_OK )
     547                        return hr;
     548                if ( dwLen < (sizeof(DWORD)*10) )
     549                        return AVIERR_BADFORMAT;
     550                hr = AVIFILE_IAVIFile_ReadChunkData(
     551                                This, dwLen,
     552                                &(This->hdr), sizeof(MainAVIHeader), &dwLen );
     553                if ( This->hdr.dwStreams == 0 ||
     554                     This->hdr.dwStreams > AVIFILE_STREAMS_MAX )
     555                        return AVIERR_BADFORMAT;
     556
     557                /* get stream headers. */
     558                dwIndex = 0;
     559                while ( dwIndex < This->hdr.dwStreams )
     560                {
     561                        WINE_AVISTREAM_DATA*    pData;
     562
     563                        hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
     564                                        This, ckidSTREAMHEADER, &dwLen );
     565                        if ( hr != S_OK )
     566                                return hr;
     567                        if ( dwLen < (sizeof(DWORD)*12) )
     568                                return AVIERR_BADFORMAT;
     569                        hr = AVIFILE_IAVIFile_ReadChunkData(
     570                                This, dwLen,
     571                                &This->strhdrs[dwIndex],
     572                                sizeof(AVIStreamHeader), &dwLen );
     573
     574                        hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
     575                                        This, ckidSTREAMFORMAT, &dwLen );
     576                        if ( hr != S_OK )
     577                                return hr;
     578                        pData = AVIFILE_Alloc_IAVIStreamData( dwLen );
     579                        if ( pData == NULL )
     580                                return AVIERR_MEMORY;
     581                        hr = AVIFILE_IAVIFile_ReadChunkData(
     582                                This, dwLen,
     583                                pData->pbFmt, dwLen, &dwLen );
     584                        if ( hr != S_OK )
     585                        {
     586                                AVIFILE_Free_IAVIStreamData( pData );
     587                                return hr;
     588                        }
     589                        pData->dwStreamIndex = dwIndex;
     590                        pData->pstrhdr = &This->strhdrs[dwIndex];
     591
     592                        hr = AVIStreamCreate(&This->pStreams[dwIndex],
     593                                             (LONG)paf, (LONG)(pData), NULL );
     594                        if ( hr != S_OK )
     595                        {
     596                                AVIFILE_Free_IAVIStreamData( pData );
     597                                return hr;
     598                        }
     599
     600                        if ( (This->strhdrs[dwIndex].fccType
     601                                        == mmioFOURCC('v','i','d','s')) ||
     602                             (This->strhdrs[dwIndex].fccType
     603                                        == mmioFOURCC('V','I','D','S')) )
     604                        {
     605                                This->dwAVIFileScale =
     606                                        This->strhdrs[dwIndex].dwScale;
     607                                This->dwAVIFileRate =
     608                                        This->strhdrs[dwIndex].dwRate;
     609                                This->dwAVIFileLength =
     610                                        This->strhdrs[dwIndex].dwLength;
     611                        }
     612                        else
     613                        if ( This->dwAVIFileScale == 0 )
     614                        {
     615                                This->dwAVIFileScale =
     616                                        This->strhdrs[dwIndex].dwScale;
     617                                This->dwAVIFileRate =
     618                                        This->strhdrs[dwIndex].dwRate;
     619                                This->dwAVIFileLength =
     620                                        This->strhdrs[dwIndex].dwLength;
     621                        }
     622
     623                        dwIndex ++;
     624                }
     625
     626                /* skip movi. */
     627                while ( 1 )
     628                {
     629                        hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
     630                                        This, FOURCC_LIST, &dwLen );
     631                        if ( hr != S_OK )
     632                                return hr;
     633                        if ( dwLen < 4 )
     634                                return AVIERR_BADFORMAT;
     635
     636                        This->dwMoviTop = SetFilePointer( This->hf,0,NULL,FILE_CURRENT );
     637                        if ( This->dwMoviTop == 0xffffffff )
     638                                return AVIERR_BADFORMAT;
     639
     640                        if ( ( !ReadFile(This->hf, buf, 4, &dwRead, NULL) ) ||
     641                             ( dwRead != 4 ) )
     642                                return AVIERR_FILEREAD;
     643
     644                        hr = AVIFILE_IAVIFile_SkipChunkData(
     645                                        This, dwLen - 4 );
     646                        if ( hr != S_OK )
     647                                return hr;
     648                        if ( mmioFOURCC(buf[0],buf[1],buf[2],buf[3])
     649                                == mmioFOURCC('m', 'o', 'v', 'i') )
     650                                break;
     651                }
     652
     653                /* get idx1. */
     654                hr = AVIFILE_IAVIFile_SeekToSpecifiedChunk(
     655                                This, ckidAVINEWINDEX, &dwLen );
     656                if ( hr != S_OK )
     657                        return hr;
     658
     659                This->dwCountOfIndexEntry = dwLen / sizeof(AVIINDEXENTRY);
     660                This->pIndexEntry = (AVIINDEXENTRY*)
     661                        HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     662                                  sizeof(AVIINDEXENTRY) *
     663                                  This->dwCountOfIndexEntry * 2 );
     664                if ( This->pIndexEntry == NULL )
     665                        return AVIERR_MEMORY;
     666                hr = AVIFILE_IAVIFile_ReadChunkData(
     667                                This, dwLen,
     668                                This->pIndexEntry + This->dwCountOfIndexEntry,
     669                                sizeof(AVIINDEXENTRY) *
     670                                This->dwCountOfIndexEntry, &dwLen );
     671                if ( hr != S_OK )
     672                        return hr;
     673                AVIFILE_IAVIFile_InitIndexTable(
     674                                This, This->pIndexEntry,
     675                                This->pIndexEntry + This->dwCountOfIndexEntry,
     676                                This->dwCountOfIndexEntry );
     677            }
     678            else
     679            {
     680                /* FIXME - create the handle has GENERIC_WRITE access. */
     681                return AVIERR_FILEREAD;
     682            }
     683        }
     684        else
     685        {
     686            return AVIERR_FILEOPEN; /* FIXME */
     687        }
     688
     689        return S_OK;
    691690}
    692691
    693692/*****************************************************************************
    694  *  AVIFILE_IAVIFile_GetIndexTable (internal)
     693 *      AVIFILE_IAVIFile_GetIndexTable (internal)
    695694 */
    696695HRESULT AVIFILE_IAVIFile_GetIndexTable( PAVIFILE paf, DWORD dwStreamIndex,
    697                     AVIINDEXENTRY** ppIndexEntry,
    698                     DWORD* pdwCountOfIndexEntry )
    699 {
    700     ICOM_THIS(IAVIFileImpl,paf);
    701 
    702     if ( dwStreamIndex < 0 || dwStreamIndex >= This->hdr.dwStreams )
    703     {
    704         FIXME( "invalid stream index %lu\n", dwStreamIndex );
    705         return E_FAIL;
    706     }
    707     FIXME( "cur %p, next %p\n",
    708         This->pStreamIndexEntry[dwStreamIndex],
    709         This->pStreamIndexEntry[dwStreamIndex+1] );
    710     *ppIndexEntry = This->pStreamIndexEntry[dwStreamIndex];
    711     *pdwCountOfIndexEntry =
    712         This->pStreamIndexEntry[dwStreamIndex+1] -
    713             This->pStreamIndexEntry[dwStreamIndex];
    714 
    715     return S_OK;
     696                                        AVIINDEXENTRY** ppIndexEntry,
     697                                        DWORD* pdwCountOfIndexEntry )
     698{
     699        ICOM_THIS(IAVIFileImpl,paf);
     700
     701        if ( dwStreamIndex < 0 || dwStreamIndex >= This->hdr.dwStreams )
     702        {
     703                FIXME( "invalid stream index %lu\n", dwStreamIndex );
     704                return E_FAIL;
     705        }
     706        FIXME( "cur %p, next %p\n",
     707                This->pStreamIndexEntry[dwStreamIndex],
     708                This->pStreamIndexEntry[dwStreamIndex+1] );
     709        *ppIndexEntry = This->pStreamIndexEntry[dwStreamIndex];
     710        *pdwCountOfIndexEntry =
     711                This->pStreamIndexEntry[dwStreamIndex+1] -
     712                        This->pStreamIndexEntry[dwStreamIndex];
     713
     714        return S_OK;
    716715}
    717716
    718717/*****************************************************************************
    719  *  AVIFILE_IAVIFile_ReadMovieData (internal)
     718 *      AVIFILE_IAVIFile_ReadMovieData (internal)
    720719 */
    721720HRESULT AVIFILE_IAVIFile_ReadMovieData( PAVIFILE paf, DWORD dwOffset,
    722                     DWORD dwLength, LPVOID lpvBuf )
    723 {
    724     ICOM_THIS(IAVIFileImpl,paf);
    725     LONG    lHigh = 0;
    726     DWORD   dwRes;
    727 
    728     if ( dwLength == 0 )
    729         return S_OK;
    730     SetLastError(NO_ERROR);
    731     dwRes = SetFilePointer( This->hf, (LONG)(dwOffset+This->dwMoviTop),
    732                 &lHigh, FILE_BEGIN );
    733     if ( dwRes == (DWORD)0xffffffff && GetLastError() != NO_ERROR )
    734         return AVIERR_FILEREAD;
    735 
    736     if ( ( !ReadFile(This->hf, lpvBuf, dwLength, &dwRes, NULL) ) ||
    737          ( dwLength != dwRes ) )
    738     {
    739         FIXME( "error in ReadFile()\n" );
    740         return AVIERR_FILEREAD;
    741     }
    742 
    743     return S_OK;
    744 }
    745 
     721                                        DWORD dwLength, LPVOID lpvBuf )
     722{
     723        ICOM_THIS(IAVIFileImpl,paf);
     724        LONG    lHigh = 0;
     725        DWORD   dwRes;
     726
     727        if ( dwLength == 0 )
     728                return S_OK;
     729        SetLastError(NO_ERROR);
     730        dwRes = SetFilePointer( This->hf, (LONG)(dwOffset+This->dwMoviTop),
     731                                &lHigh, FILE_BEGIN );
     732        if ( dwRes == (DWORD)0xffffffff && GetLastError() != NO_ERROR )
     733                return AVIERR_FILEREAD;
     734
     735        if ( ( !ReadFile(This->hf, lpvBuf, dwLength, &dwRes, NULL) ) ||
     736             ( dwLength != dwRes ) )
     737        {
     738                FIXME( "error in ReadFile()\n" );
     739                return AVIERR_FILEREAD;
     740        }
     741
     742        return S_OK;
     743}
     744
  • trunk/src/avifil32/iastream.c

    r6652 r6712  
    1 /* $Id: iastream.c,v 1.2 2001-09-05 14:16:45 bird Exp $ */
    21/*
    32 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
     
    5655typedef struct IAVIStreamImpl
    5756{
    58     ICOM_VFIELD(IAVIStream);
    59     /* IUnknown stuff */
    60     DWORD       ref;
    61     /* IAVIStream stuff */
    62     IAVIFile*       paf;
    63     WINE_AVISTREAM_DATA*    pData;
     57        ICOM_VFIELD(IAVIStream);
     58        /* IUnknown stuff */
     59        DWORD           ref;
     60        /* IAVIStream stuff */
     61        IAVIFile*               paf;
     62        WINE_AVISTREAM_DATA*    pData;
    6463} IAVIStreamImpl;
    6564
     
    6968HRESULT AVIFILE_CreateIAVIStream(void** ppobj)
    7069{
    71     IAVIStreamImpl  *This;
    72     HRESULT     hr;
    73 
    74     *ppobj = NULL;
    75     This = (IAVIStreamImpl*)HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    76                       sizeof(IAVIStreamImpl));
    77     This->ref = 1;
    78     ICOM_VTBL(This) = &iavist;
    79     hr = IAVIStream_Construct( This );
    80     if ( hr != S_OK )
    81     {
    82         IAVIStream_Destruct( This );
    83         return hr;
    84     }
    85 
    86     *ppobj = (LPVOID)This;
    87 
    88     return S_OK;
     70        IAVIStreamImpl  *This;
     71        HRESULT         hr;
     72
     73        *ppobj = NULL;
     74        This = (IAVIStreamImpl*)HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     75                                          sizeof(IAVIStreamImpl));
     76        This->ref = 1;
     77        ICOM_VTBL(This) = &iavist;
     78        hr = IAVIStream_Construct( This );
     79        if ( hr != S_OK )
     80        {
     81                IAVIStream_Destruct( This );
     82                return hr;
     83        }
     84
     85        *ppobj = (LPVOID)This;
     86
     87        return S_OK;
    8988}
    9089
     
    9594
    9695static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj) {
    97     ICOM_THIS(IAVIStreamImpl,iface);
    98 
    99     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    100     if ( IsEqualGUID(&IID_IUnknown,refiid) ||
    101          IsEqualGUID(&IID_IAVIStream,refiid) )
    102     {
    103         IAVIStream_AddRef(iface);
    104         *obj = iface;
    105         return S_OK;
    106     }
    107     /* can return IGetFrame interface too */
    108 
    109     return OLE_E_ENUM_NOMORE;
     96        ICOM_THIS(IAVIStreamImpl,iface);
     97
     98        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     99        if ( IsEqualGUID(&IID_IUnknown,refiid) ||
     100             IsEqualGUID(&IID_IAVIStream,refiid) )
     101        {
     102                IAVIStream_AddRef(iface);
     103                *obj = iface;
     104                return S_OK;
     105        }
     106        /* can return IGetFrame interface too */
     107
     108        return OLE_E_ENUM_NOMORE;
    110109}
    111110
    112111static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface) {
    113     ICOM_THIS(IAVIStreamImpl,iface);
    114 
    115     TRACE("(%p)->AddRef()\n",iface);
    116     return ++(This->ref);
     112        ICOM_THIS(IAVIStreamImpl,iface);
     113
     114        TRACE("(%p)->AddRef()\n",iface);
     115        return ++(This->ref);
    117116}
    118117
    119118static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) {
    120     ICOM_THIS(IAVIStreamImpl,iface);
    121 
    122     TRACE("(%p)->Release()\n",iface);
    123     if ((--(This->ref)) > 0 )
    124         return This->ref;
    125     IAVIStream_Destruct(This);
    126 
    127     HeapFree(AVIFILE_data.hHeap,0,iface);
    128     return 0;
     119        ICOM_THIS(IAVIStreamImpl,iface);
     120
     121        TRACE("(%p)->Release()\n",iface);
     122        if ((--(This->ref)) > 0 )
     123                return This->ref;
     124        IAVIStream_Destruct(This);
     125
     126        HeapFree(AVIFILE_data.hHeap,0,iface);
     127        return 0;
    129128}
    130129
     
    135134static HRESULT IAVIStream_Construct( IAVIStreamImpl* This )
    136135{
    137     This->paf = NULL;
    138     This->pData = NULL;
    139 
    140     AVIFILE_data.dwClassObjRef ++;
    141 
    142     return S_OK;
     136        This->paf = NULL;
     137        This->pData = NULL;
     138
     139        AVIFILE_data.dwClassObjRef ++;
     140
     141        return S_OK;
    143142}
    144143
    145144static void IAVIStream_Destruct( IAVIStreamImpl* This )
    146145{
    147     AVIFILE_data.dwClassObjRef --;
     146        AVIFILE_data.dwClassObjRef --;
    148147}
    149148
    150149static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2)
    151150{
    152     ICOM_THIS(IAVIStreamImpl,iface);
    153 
    154     FIXME("(%p)->Create(%ld,%ld)\n",iface,lParam1,lParam2);
    155 
    156     This->paf = (IAVIFile*)lParam1;
    157     This->pData = (WINE_AVISTREAM_DATA*)lParam2;
    158 
    159     return S_OK;
     151        ICOM_THIS(IAVIStreamImpl,iface);
     152
     153        FIXME("(%p)->Create(%ld,%ld)\n",iface,lParam1,lParam2);
     154
     155        This->paf = (IAVIFile*)lParam1;
     156        This->pData = (WINE_AVISTREAM_DATA*)lParam2;
     157
     158        return S_OK;
    160159}
    161160
    162161static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size)
    163162{
    164     ICOM_THIS(IAVIStreamImpl,iface);
    165     AVISTREAMINFOW  siw;
    166 
    167     FIXME("(%p)->Info(%p,%ld)\n",iface,psi,size);
    168     if ( This->pData == NULL )
    169         return E_UNEXPECTED;
    170 
    171     memset( &siw, 0, sizeof(AVISTREAMINFOW) );
    172     siw.fccType = This->pData->pstrhdr->fccType;
    173     siw.fccHandler = This->pData->pstrhdr->fccHandler;
    174     siw.dwFlags = This->pData->pstrhdr->dwFlags;
    175     siw.dwCaps = 0; /* FIXME */
    176     siw.wPriority = This->pData->pstrhdr->wPriority;
    177     siw.wLanguage = This->pData->pstrhdr->wLanguage;
    178     siw.dwScale = This->pData->pstrhdr->dwScale;
    179     siw.dwRate = This->pData->pstrhdr->dwRate;
    180     siw.dwStart = This->pData->pstrhdr->dwStart;
    181     siw.dwLength = This->pData->pstrhdr->dwLength;
    182     siw.dwInitialFrames = This->pData->pstrhdr->dwInitialFrames;
    183     siw.dwSuggestedBufferSize = This->pData->pstrhdr->dwSuggestedBufferSize;
    184     siw.dwQuality = This->pData->pstrhdr->dwQuality;
    185     siw.dwSampleSize = This->pData->pstrhdr->dwSampleSize;
    186     siw.rcFrame.left = This->pData->pstrhdr->rcFrame.left;
    187     siw.rcFrame.top = This->pData->pstrhdr->rcFrame.top;
    188     siw.rcFrame.right = This->pData->pstrhdr->rcFrame.right;
    189     siw.rcFrame.bottom = This->pData->pstrhdr->rcFrame.bottom;
    190     siw.dwEditCount = 0; /* FIXME */
    191     siw.dwFormatChangeCount = 0; /* FIXME */
    192     /* siw.szName[64] */
    193 
    194     if ( size > sizeof(AVISTREAMINFOW) )
    195         size = sizeof(AVISTREAMINFOW);
    196     memcpy( psi, &siw, size );
    197 
    198     return S_OK;
     163        ICOM_THIS(IAVIStreamImpl,iface);
     164        AVISTREAMINFOW  siw;
     165
     166        FIXME("(%p)->Info(%p,%ld)\n",iface,psi,size);
     167        if ( This->pData == NULL )
     168                return E_UNEXPECTED;
     169
     170        memset( &siw, 0, sizeof(AVISTREAMINFOW) );
     171        siw.fccType = This->pData->pstrhdr->fccType;
     172        siw.fccHandler = This->pData->pstrhdr->fccHandler;
     173        siw.dwFlags = This->pData->pstrhdr->dwFlags;
     174        siw.dwCaps = 0; /* FIXME */
     175        siw.wPriority = This->pData->pstrhdr->wPriority;
     176        siw.wLanguage = This->pData->pstrhdr->wLanguage;
     177        siw.dwScale = This->pData->pstrhdr->dwScale;
     178        siw.dwRate = This->pData->pstrhdr->dwRate;
     179        siw.dwStart = This->pData->pstrhdr->dwStart;
     180        siw.dwLength = This->pData->pstrhdr->dwLength;
     181        siw.dwInitialFrames = This->pData->pstrhdr->dwInitialFrames;
     182        siw.dwSuggestedBufferSize = This->pData->pstrhdr->dwSuggestedBufferSize;
     183        siw.dwQuality = This->pData->pstrhdr->dwQuality;
     184        siw.dwSampleSize = This->pData->pstrhdr->dwSampleSize;
     185        siw.rcFrame.left = This->pData->pstrhdr->rcFrame.left;
     186        siw.rcFrame.top = This->pData->pstrhdr->rcFrame.top;
     187        siw.rcFrame.right = This->pData->pstrhdr->rcFrame.right;
     188        siw.rcFrame.bottom = This->pData->pstrhdr->rcFrame.bottom;
     189        siw.dwEditCount = 0; /* FIXME */
     190        siw.dwFormatChangeCount = 0; /* FIXME */
     191        /* siw.szName[64] */
     192
     193        if ( size > sizeof(AVISTREAMINFOW) )
     194                size = sizeof(AVISTREAMINFOW);
     195        memcpy( psi, &siw, size );
     196
     197        return S_OK;
    199198}
    200199
    201200static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags)
    202201{
    203     ICOM_THIS(IAVIStreamImpl,iface);
    204     HRESULT hr;
    205     AVIINDEXENTRY*  pIndexEntry;
    206     DWORD       dwCountOfIndexEntry;
    207     LONG        lCur, lAdd, lEnd;
    208 
    209     FIXME("(%p)->FindSample(%ld,0x%08lx)\n",This,pos,flags);
    210 
    211     hr = AVIFILE_IAVIFile_GetIndexTable(
    212         This->paf, This->pData->dwStreamIndex,
    213         &pIndexEntry, &dwCountOfIndexEntry );
    214     if ( hr != S_OK )
    215         return -1L;
    216 
    217     if ( flags & (~(FIND_DIR|FIND_TYPE|FIND_RET)) )
    218     {
    219         FIXME( "unknown flag %08lx\n", flags );
    220         return -1L;
    221     }
    222 
    223     switch ( flags & FIND_DIR )
    224     {
    225     case FIND_NEXT:
    226         lCur = pos;
    227         lAdd = 1;
    228         lEnd = dwCountOfIndexEntry;
    229         if ( lCur > dwCountOfIndexEntry )
    230             return -1L;
    231         break;
    232     case FIND_PREV:
    233         lCur = pos;
    234         if ( lCur > dwCountOfIndexEntry )
    235             lCur = dwCountOfIndexEntry;
    236         lAdd = -1;
    237         lEnd = 0;
    238         break;
    239     case FIND_FROM_START:
    240         lCur = 0;
    241         lAdd = 1;
    242         lEnd = dwCountOfIndexEntry;
    243         break;
    244     default:
    245         FIXME( "unknown direction flag %08lx\n", (flags & FIND_DIR) );
    246         return -1L;
    247     }
    248 
    249     switch ( flags & FIND_TYPE )
    250     {
    251     case FIND_KEY:
    252         while ( 1 )
    253         {
    254             if ( pIndexEntry[lCur].dwFlags & AVIIF_KEYFRAME )
    255                 break;
    256             if ( lCur == lEnd )
    257                 return -1L;
    258             lCur += lAdd;
    259         }
    260         break;
    261     case FIND_ANY:
    262         while ( 1 )
    263         {
    264             if ( !(pIndexEntry[lCur].dwFlags & AVIIF_NOTIME) )
    265                 break;
    266             if ( lCur == lEnd )
    267                 return -1L;
    268             lCur += lAdd;
    269         }
    270         break;
    271     case FIND_FORMAT:
    272         FIXME( "FIND_FORMAT is not implemented.\n" );
    273         return -1L;
    274     default:
    275         FIXME( "unknown type flag %08lx\n", (flags & FIND_TYPE) );
    276         return -1L;
    277     }
    278 
    279     switch ( flags & FIND_RET )
    280     {
    281     case FIND_POS:
    282         return lCur;
    283     case FIND_LENGTH:
    284         FIXME( "FIND_LENGTH is not implemented.\n" );
    285         return -1L;
    286     case FIND_OFFSET:
    287         return pIndexEntry[lCur].dwChunkOffset;
    288     case FIND_SIZE:
    289         return pIndexEntry[lCur].dwChunkLength;
    290     case FIND_INDEX:
    291         FIXME( "FIND_INDEX is not implemented.\n" );
    292         return -1L;
    293     default:
    294         FIXME( "unknown return type flag %08lx\n", (flags & FIND_RET) );
    295         break;
    296     }
    297 
    298     return -1L;
     202        ICOM_THIS(IAVIStreamImpl,iface);
     203        HRESULT hr;
     204        AVIINDEXENTRY*  pIndexEntry;
     205        DWORD           dwCountOfIndexEntry;
     206        LONG            lCur, lAdd, lEnd;
     207
     208        FIXME("(%p)->FindSample(%ld,0x%08lx)\n",This,pos,flags);
     209
     210        hr = AVIFILE_IAVIFile_GetIndexTable(
     211                This->paf, This->pData->dwStreamIndex,
     212                &pIndexEntry, &dwCountOfIndexEntry );
     213        if ( hr != S_OK )
     214                return -1L;
     215
     216        if ( flags & (~(FIND_DIR|FIND_TYPE|FIND_RET)) )
     217        {
     218                FIXME( "unknown flag %08lx\n", flags );
     219                return -1L;
     220        }
     221
     222        switch ( flags & FIND_DIR )
     223        {
     224        case FIND_NEXT:
     225                lCur = pos;
     226                lAdd = 1;
     227                lEnd = dwCountOfIndexEntry;
     228                if ( lCur > dwCountOfIndexEntry )
     229                        return -1L;
     230                break;
     231        case FIND_PREV:
     232                lCur = pos;
     233                if ( lCur > dwCountOfIndexEntry )
     234                        lCur = dwCountOfIndexEntry;
     235                lAdd = -1;
     236                lEnd = 0;
     237                break;
     238        case FIND_FROM_START:
     239                lCur = 0;
     240                lAdd = 1;
     241                lEnd = dwCountOfIndexEntry;
     242                break;
     243        default:
     244                FIXME( "unknown direction flag %08lx\n", (flags & FIND_DIR) );
     245                return -1L;
     246        }
     247
     248        switch ( flags & FIND_TYPE )
     249        {
     250        case FIND_KEY:
     251                while ( 1 )
     252                {
     253                        if ( pIndexEntry[lCur].dwFlags & AVIIF_KEYFRAME )
     254                                break;
     255                        if ( lCur == lEnd )
     256                                return -1L;
     257                        lCur += lAdd;
     258                }
     259                break;
     260        case FIND_ANY:
     261                while ( 1 )
     262                {
     263                        if ( !(pIndexEntry[lCur].dwFlags & AVIIF_NOTIME) )
     264                                break;
     265                        if ( lCur == lEnd )
     266                                return -1L;
     267                        lCur += lAdd;
     268                }
     269                break;
     270        case FIND_FORMAT:
     271                FIXME( "FIND_FORMAT is not implemented.\n" );
     272                return -1L;
     273        default:
     274                FIXME( "unknown type flag %08lx\n", (flags & FIND_TYPE) );
     275                return -1L;
     276        }
     277
     278        switch ( flags & FIND_RET )
     279        {
     280        case FIND_POS:
     281                return lCur;
     282        case FIND_LENGTH:
     283                FIXME( "FIND_LENGTH is not implemented.\n" );
     284                return -1L;
     285        case FIND_OFFSET:
     286                return pIndexEntry[lCur].dwChunkOffset;
     287        case FIND_SIZE:
     288                return pIndexEntry[lCur].dwChunkLength;
     289        case FIND_INDEX:
     290                FIXME( "FIND_INDEX is not implemented.\n" );
     291                return -1L;
     292        default:
     293                FIXME( "unknown return type flag %08lx\n", (flags & FIND_RET) );
     294                break;
     295        }
     296
     297        return -1L;
    299298}
    300299
    301300static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize) {
    302     ICOM_THIS(IAVIStreamImpl,iface);
    303 
    304     TRACE("(%p)->ReadFormat(%ld,%p,%p)\n",This,pos,format,formatsize);
    305     if ( This->pData == NULL )
    306         return E_UNEXPECTED;
    307 
    308     /* FIXME - check pos. */
    309     if ( format == NULL )
    310     {
    311         *formatsize = This->pData->dwFmtLen;
    312         return S_OK;
    313     }
    314     if ( (*formatsize) < This->pData->dwFmtLen )
    315         return AVIERR_BUFFERTOOSMALL;
    316 
    317     memcpy( format, This->pData->pbFmt, This->pData->dwFmtLen );
    318     *formatsize = This->pData->dwFmtLen;
    319 
    320     return S_OK;
     301        ICOM_THIS(IAVIStreamImpl,iface);
     302
     303        TRACE("(%p)->ReadFormat(%ld,%p,%p)\n",This,pos,format,formatsize);
     304        if ( This->pData == NULL )
     305                return E_UNEXPECTED;
     306
     307        /* FIXME - check pos. */
     308        if ( format == NULL )
     309        {
     310                *formatsize = This->pData->dwFmtLen;
     311                return S_OK;
     312        }
     313        if ( (*formatsize) < This->pData->dwFmtLen )
     314                return AVIERR_BUFFERTOOSMALL;
     315
     316        memcpy( format, This->pData->pbFmt, This->pData->dwFmtLen );
     317        *formatsize = This->pData->dwFmtLen;
     318
     319        return S_OK;
    321320}
    322321
    323322static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize) {
    324     ICOM_THIS(IAVIStreamImpl,iface);
    325 
    326     FIXME("(%p)->SetFormat(%ld,%p,%ld)\n",This,pos,format,formatsize);
    327     return E_FAIL;
     323        ICOM_THIS(IAVIStreamImpl,iface);
     324
     325        FIXME("(%p)->SetFormat(%ld,%p,%ld)\n",This,pos,format,formatsize);
     326        return E_FAIL;
    328327}
    329328
    330329static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
    331     ICOM_THIS(IAVIStreamImpl,iface);
    332     HRESULT hr;
    333     AVIINDEXENTRY*  pIndexEntry;
    334     DWORD       dwCountOfIndexEntry;
    335     DWORD       dwFrameLength;
    336 
    337     FIXME("(%p)->Read(%ld,%ld,%p,%ld,%p,%p)\n",This,start,samples,buffer,buffersize,bytesread,samplesread);
    338 
    339     *bytesread = 0;
    340     *samplesread = 0;
    341 
    342     hr = AVIFILE_IAVIFile_GetIndexTable(
    343         This->paf, This->pData->dwStreamIndex,
    344         &pIndexEntry, &dwCountOfIndexEntry );
    345     if ( hr != S_OK )
    346         return hr;
    347     if ( start < 0 )
    348         return E_FAIL;
    349     if ( start >= dwCountOfIndexEntry || samples <= 0 )
    350     {
    351         FIXME("start %ld,samples %ld,total %ld\n",start,samples,dwCountOfIndexEntry);
    352         return S_OK;
    353     }
    354 
    355     /* FIXME - is this data valid??? */
    356     dwFrameLength = pIndexEntry[start].dwChunkLength + sizeof(DWORD)*2;
    357 
    358     if ( buffer == NULL )
    359     {
    360         *bytesread = dwFrameLength;
    361         *samplesread = 1;
    362         return S_OK;
    363     }
    364     if ( buffersize < dwFrameLength )
    365     {
    366         FIXME( "buffer is too small!\n" );
    367         return AVIERR_BUFFERTOOSMALL;
    368     }
    369 
    370     hr = AVIFILE_IAVIFile_ReadMovieData(
    371             This->paf,
    372             pIndexEntry[start].dwChunkOffset,
    373             dwFrameLength, buffer );
    374     if ( hr != S_OK )
    375     {
    376         FIXME( "ReadMovieData failed!\n");
    377         return hr;
    378     }
    379     *bytesread = dwFrameLength;
    380     *samplesread = 1;
    381 
    382     return S_OK;
     330        ICOM_THIS(IAVIStreamImpl,iface);
     331        HRESULT hr;
     332        AVIINDEXENTRY*  pIndexEntry;
     333        DWORD           dwCountOfIndexEntry;
     334        DWORD           dwFrameLength;
     335
     336        FIXME("(%p)->Read(%ld,%ld,%p,%ld,%p,%p)\n",This,start,samples,buffer,buffersize,bytesread,samplesread);
     337
     338        *bytesread = 0;
     339        *samplesread = 0;
     340
     341        hr = AVIFILE_IAVIFile_GetIndexTable(
     342                This->paf, This->pData->dwStreamIndex,
     343                &pIndexEntry, &dwCountOfIndexEntry );
     344        if ( hr != S_OK )
     345                return hr;
     346        if ( start < 0 )
     347                return E_FAIL;
     348        if ( start >= dwCountOfIndexEntry || samples <= 0 )
     349        {
     350                FIXME("start %ld,samples %ld,total %ld\n",start,samples,dwCountOfIndexEntry);
     351                return S_OK;
     352        }
     353
     354        /* FIXME - is this data valid??? */
     355        dwFrameLength = pIndexEntry[start].dwChunkLength + sizeof(DWORD)*2;
     356
     357        if ( buffer == NULL )
     358        {
     359                *bytesread = dwFrameLength;
     360                *samplesread = 1;
     361                return S_OK;
     362        }
     363        if ( buffersize < dwFrameLength )
     364        {
     365                FIXME( "buffer is too small!\n" );
     366                return AVIERR_BUFFERTOOSMALL;
     367        }
     368
     369        hr = AVIFILE_IAVIFile_ReadMovieData(
     370                        This->paf,
     371                        pIndexEntry[start].dwChunkOffset,
     372                        dwFrameLength, buffer );
     373        if ( hr != S_OK )
     374        {
     375                FIXME( "ReadMovieData failed!\n");
     376                return hr;
     377        }
     378        *bytesread = dwFrameLength;
     379        *samplesread = 1;
     380
     381        return S_OK;
    383382}
    384383
    385384static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
    386     ICOM_THIS(IAVIStreamImpl,iface);
    387 
    388 
    389     FIXME("(%p)->Write(%ld,%ld,%p,%ld,0x%08lx,%p,%p)\n",This,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
    390     return E_FAIL;
     385        ICOM_THIS(IAVIStreamImpl,iface);
     386
     387
     388        FIXME("(%p)->Write(%ld,%ld,%p,%ld,0x%08lx,%p,%p)\n",This,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
     389        return E_FAIL;
    391390}
    392391
    393392static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples) {
    394     ICOM_THIS(IAVIStreamImpl,iface);
    395 
    396     FIXME("(%p)->Delete(%ld,%ld)\n",This,start,samples);
    397     return E_FAIL;
     393        ICOM_THIS(IAVIStreamImpl,iface);
     394
     395        FIXME("(%p)->Delete(%ld,%ld)\n",This,start,samples);
     396        return E_FAIL;
    398397}
    399398static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread) {
    400     ICOM_THIS(IAVIStreamImpl,iface);
    401 
    402     FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",This,fcc,lp,lpread);
    403     return E_FAIL;
     399        ICOM_THIS(IAVIStreamImpl,iface);
     400
     401        FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",This,fcc,lp,lpread);
     402        return E_FAIL;
    404403}
    405404
    406405static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size) {
    407     ICOM_THIS(IAVIStreamImpl,iface);
    408 
    409     FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",This,fcc,lp,size);
    410     return E_FAIL;
     406        ICOM_THIS(IAVIStreamImpl,iface);
     407
     408        FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",This,fcc,lp,size);
     409        return E_FAIL;
    411410}
    412411
    413412static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen) {
    414     ICOM_THIS(IAVIStreamImpl,iface);
    415 
    416     FIXME("(%p)->SetInfo(%p,%ld)\n",This,info,infolen);
    417 
    418     return E_FAIL;
    419 }
    420 
     413        ICOM_THIS(IAVIStreamImpl,iface);
     414
     415        FIXME("(%p)->SetInfo(%p,%ld)\n",This,info,infolen);
     416
     417        return E_FAIL;
     418}
     419
  • trunk/src/avifil32/igframe.c

    r6652 r6712  
    1 /* $Id: igframe.c,v 1.2 2001-09-05 14:16:45 bird Exp $ */
    21/*
    32 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
     
    3029struct ICOM_VTABLE(IGetFrame) igetfrm = {
    3130    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    32     IGetFrame_fnQueryInterface,
    33     IGetFrame_fnAddRef,
    34     IGetFrame_fnRelease,
    35     IGetFrame_fnGetFrame,
    36     IGetFrame_fnBegin,
    37     IGetFrame_fnEnd,
    38     IGetFrame_fnSetFormat,
     31        IGetFrame_fnQueryInterface,
     32        IGetFrame_fnAddRef,
     33        IGetFrame_fnRelease,
     34        IGetFrame_fnGetFrame,
     35        IGetFrame_fnBegin,
     36        IGetFrame_fnEnd,
     37        IGetFrame_fnSetFormat,
    3938};
    4039
    4140typedef struct IGetFrameImpl
    4241{
    43     ICOM_VFIELD(IGetFrame);
    44     /* IUnknown stuff */
    45     DWORD           ref;
    46     /* IGetFrame stuff */
    47     IAVIStream*     pas;
    48     HIC         hIC;
    49     LONG            lCachedFrame;
    50     BITMAPINFO*     pbiICIn;
    51     BITMAPINFO*     pbiICOut;
    52     LPVOID          pvICOutBits;
    53     LPVOID          pvICInFmtBuf;
    54     DWORD           dwICInDataBufSize;
    55     LPVOID          pvICInDataBuf;
    56     LPVOID          pvICOutBuf;
     42        ICOM_VFIELD(IGetFrame);
     43        /* IUnknown stuff */
     44        DWORD                   ref;
     45        /* IGetFrame stuff */
     46        IAVIStream*             pas;
     47        HIC                     hIC;
     48        LONG                    lCachedFrame;
     49        BITMAPINFO*             pbiICIn;
     50        BITMAPINFO*             pbiICOut;
     51        LPVOID                  pvICOutBits;
     52        LPVOID                  pvICInFmtBuf;
     53        DWORD                   dwICInDataBufSize;
     54        LPVOID                  pvICInDataBuf;
     55        LPVOID                  pvICOutBuf;
    5756} IGetFrameImpl;
    5857
    5958static HRESULT IGetFrame_Construct( IGetFrameImpl* This,
    60                     IAVIStream* pstr,
    61                     LPBITMAPINFOHEADER lpbi );
     59                                    IAVIStream* pstr,
     60                                    LPBITMAPINFOHEADER lpbi );
    6261static void IGetFrame_Destruct( IGetFrameImpl* This );
    6362
     
    6766static LPVOID AVIFILE_IGetFrame_DecodeFrame(IGetFrameImpl* This,LONG lPos)
    6867{
    69     HRESULT hr;
    70     DWORD   dwRes;
    71     LONG    lFrameLength;
    72     LONG    lSampleCount;
    73     ICDECOMPRESS    icd;
    74 
    75     if ( This->hIC == (HIC)NULL )
    76         return NULL;
    77 
    78     hr = IAVIStream_Read(This->pas,lPos,1,NULL,0,
    79                  &lFrameLength,&lSampleCount);
    80     if ( hr != S_OK || lSampleCount <= 0 )
    81     {
    82         FIXME( "IAVIStream_Read failed! res = %08lx\n", hr );
    83         return NULL;
    84     }
    85     TRACE( "frame length = %ld\n", lFrameLength );
    86 
    87     if ( This->dwICInDataBufSize < lFrameLength )
    88     {
    89         LPVOID  lpv;
    90 
    91         if ( This->pvICInDataBuf == NULL )
    92         {
    93             lpv = HeapAlloc(
    94                 AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    95                 lFrameLength );
    96         }
    97         else
    98         {
    99             lpv = HeapReAlloc(
    100                 AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    101                 This->pvICInDataBuf,lFrameLength );
    102         }
    103         if ( lpv == NULL )
    104         {
    105             ERR( "out of memory!\n" );
    106             return NULL;
    107         }
    108         This->pvICInDataBuf = lpv;
    109         This->dwICInDataBufSize = lFrameLength;
    110     }
    111 
    112     hr = IAVIStream_Read(This->pas,lPos,1,
    113                  This->pvICInDataBuf,This->dwICInDataBufSize,
    114                  &lFrameLength,&lSampleCount);
    115     if ( hr != S_OK || lSampleCount <= 0 )
    116     {
    117         FIXME( "IAVIStream_Read to buffer failed! res = %08lx\n", hr );
    118         return NULL;
    119     }
    120 
    121     This->pbiICIn->bmiHeader.biSizeImage = lFrameLength;
    122 
    123     TRACE( "call ICM_DECOMPRESS\n" );
    124     icd.dwFlags = (*(BYTE*)This->pvICInDataBuf) == 'c' ?
    125                       ICDECOMPRESS_NOTKEYFRAME : 0;
    126     icd.lpbiInput = &This->pbiICIn->bmiHeader;
    127     icd.lpInput = (BYTE*)This->pvICInDataBuf + 8;
    128     icd.lpbiOutput = &This->pbiICOut->bmiHeader;
    129     icd.lpOutput = This->pvICOutBits;
    130     icd.ckid = *((DWORD*)This->pvICInDataBuf);
    131     dwRes = ICSendMessage(This->hIC,ICM_DECOMPRESS,
    132                   (DWORD)(&icd),sizeof(ICDECOMPRESS) );
    133     TRACE( "returned from ICM_DECOMPRESS\n" );
    134     if ( dwRes != ICERR_OK )
    135     {
    136         ERR( "ICDecompress failed!\n" );
    137         return NULL;
    138     }
    139 
    140     This->lCachedFrame = lPos;
    141 
    142     return This->pvICOutBits;
     68        HRESULT hr;
     69        DWORD   dwRes;
     70        LONG    lFrameLength;
     71        LONG    lSampleCount;
     72        ICDECOMPRESS    icd;
     73
     74        if ( This->hIC == (HIC)NULL )
     75                return NULL;
     76
     77        hr = IAVIStream_Read(This->pas,lPos,1,NULL,0,
     78                             &lFrameLength,&lSampleCount);
     79        if ( hr != S_OK || lSampleCount <= 0 )
     80        {
     81                FIXME( "IAVIStream_Read failed! res = %08lx\n", hr );
     82                return NULL;
     83        }
     84        TRACE( "frame length = %ld\n", lFrameLength );
     85
     86        if ( This->dwICInDataBufSize < lFrameLength )
     87        {
     88                LPVOID  lpv;
     89
     90                if ( This->pvICInDataBuf == NULL )
     91                {
     92                        lpv = HeapAlloc(
     93                                AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     94                                lFrameLength );
     95                }
     96                else
     97                {
     98                        lpv = HeapReAlloc(
     99                                AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     100                                This->pvICInDataBuf,lFrameLength );
     101                }
     102                if ( lpv == NULL )
     103                {
     104                        ERR( "out of memory!\n" );
     105                        return NULL;
     106                }
     107                This->pvICInDataBuf = lpv;
     108                This->dwICInDataBufSize = lFrameLength;
     109        }
     110
     111        hr = IAVIStream_Read(This->pas,lPos,1,
     112                             This->pvICInDataBuf,This->dwICInDataBufSize,
     113                             &lFrameLength,&lSampleCount);
     114        if ( hr != S_OK || lSampleCount <= 0 )
     115        {
     116                FIXME( "IAVIStream_Read to buffer failed! res = %08lx\n", hr );
     117                return NULL;
     118        }
     119
     120        This->pbiICIn->bmiHeader.biSizeImage = lFrameLength;
     121
     122        TRACE( "call ICM_DECOMPRESS\n" );
     123        icd.dwFlags = (*(BYTE*)This->pvICInDataBuf) == 'c' ?
     124                                      ICDECOMPRESS_NOTKEYFRAME : 0;
     125        icd.lpbiInput = &This->pbiICIn->bmiHeader;
     126        icd.lpInput = (BYTE*)This->pvICInDataBuf + 8;
     127        icd.lpbiOutput = &This->pbiICOut->bmiHeader;
     128        icd.lpOutput = This->pvICOutBits;
     129        icd.ckid = *((DWORD*)This->pvICInDataBuf);
     130        dwRes = ICSendMessage(This->hIC,ICM_DECOMPRESS,
     131                              (DWORD)(&icd),sizeof(ICDECOMPRESS) );
     132        TRACE( "returned from ICM_DECOMPRESS\n" );
     133        if ( dwRes != ICERR_OK )
     134        {
     135                ERR( "ICDecompress failed!\n" );
     136                return NULL;
     137        }
     138
     139        This->lCachedFrame = lPos;
     140
     141        return This->pvICOutBits;
    143142}
    144143
     
    146145
    147146HRESULT AVIFILE_CreateIGetFrame(void** ppobj,
    148                 IAVIStream* pstr,LPBITMAPINFOHEADER lpbi)
    149 {
    150     IGetFrameImpl   *This;
    151     HRESULT     hr;
    152 
    153     *ppobj = NULL;
    154     This = (IGetFrameImpl*)HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    155                       sizeof(IGetFrameImpl));
    156     This->ref = 1;
    157     ICOM_VTBL(This) = &igetfrm;
    158     hr = IGetFrame_Construct( This, pstr, lpbi );
    159     if ( hr != S_OK )
    160     {
    161         IGetFrame_Destruct( This );
    162         return hr;
    163     }
    164 
    165     *ppobj = (LPVOID)This;
    166 
    167     return S_OK;
     147                                IAVIStream* pstr,LPBITMAPINFOHEADER lpbi)
     148{
     149        IGetFrameImpl   *This;
     150        HRESULT         hr;
     151
     152        *ppobj = NULL;
     153        This = (IGetFrameImpl*)HeapAlloc(AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     154                                          sizeof(IGetFrameImpl));
     155        This->ref = 1;
     156        ICOM_VTBL(This) = &igetfrm;
     157        hr = IGetFrame_Construct( This, pstr, lpbi );
     158        if ( hr != S_OK )
     159        {
     160                IGetFrame_Destruct( This );
     161                return hr;
     162        }
     163
     164        *ppobj = (LPVOID)This;
     165
     166        return S_OK;
    168167}
    169168
     
    174173static HRESULT WINAPI IGetFrame_fnQueryInterface(IGetFrame* iface,REFIID refiid,LPVOID *obj)
    175174{
    176     ICOM_THIS(IGetFrameImpl,iface);
    177 
    178     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    179     if ( IsEqualGUID(&IID_IUnknown,refiid) ||
    180          IsEqualGUID(&IID_IGetFrame,refiid) )
    181     {
    182         IGetFrame_AddRef(iface);
    183         *obj = iface;
    184         return S_OK;
    185     }
    186 
    187     return OLE_E_ENUM_NOMORE;
     175        ICOM_THIS(IGetFrameImpl,iface);
     176
     177        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     178        if ( IsEqualGUID(&IID_IUnknown,refiid) ||
     179             IsEqualGUID(&IID_IGetFrame,refiid) )
     180        {
     181                IGetFrame_AddRef(iface);
     182                *obj = iface;
     183                return S_OK;
     184        }
     185
     186        return OLE_E_ENUM_NOMORE;
    188187}
    189188
    190189static ULONG WINAPI IGetFrame_fnAddRef(IGetFrame* iface)
    191190{
    192     ICOM_THIS(IGetFrameImpl,iface);
    193 
    194     TRACE("(%p)->AddRef()\n",iface);
    195     return ++(This->ref);
     191        ICOM_THIS(IGetFrameImpl,iface);
     192
     193        TRACE("(%p)->AddRef()\n",iface);
     194        return ++(This->ref);
    196195}
    197196
    198197static ULONG WINAPI IGetFrame_fnRelease(IGetFrame* iface)
    199198{
    200     ICOM_THIS(IGetFrameImpl,iface);
    201 
    202     TRACE("(%p)->Release()\n",iface);
    203     if ((--(This->ref)) > 0 )
    204         return This->ref;
    205     IGetFrame_Destruct(This);
    206     if ( This->pas != NULL )
    207         IAVIStream_Release( This->pas );
    208 
    209     HeapFree(AVIFILE_data.hHeap,0,iface);
    210     return 0;
     199        ICOM_THIS(IGetFrameImpl,iface);
     200
     201        TRACE("(%p)->Release()\n",iface);
     202        if ((--(This->ref)) > 0 )
     203                return This->ref;
     204        IGetFrame_Destruct(This);
     205        if ( This->pas != NULL )
     206                IAVIStream_Release( This->pas );
     207
     208        HeapFree(AVIFILE_data.hHeap,0,iface);
     209        return 0;
    211210}
    212211
     
    217216static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame* iface,LONG lPos)
    218217{
    219     ICOM_THIS(IGetFrameImpl,iface);
    220     LPVOID  lpv;
    221     LONG    lKeyFrame;
    222 
    223     TRACE( "(%p)->(%ld)\n", This, lPos );
    224 
    225     if ( lPos < 0 )
    226         return NULL;
    227 
    228     if ( This->lCachedFrame == lPos )
    229         return This->pvICOutBits;
    230     if ( (This->lCachedFrame+1) != lPos )
    231     {
    232         lKeyFrame = IAVIStream_FindSample( This->pas, lPos,
    233                            FIND_KEY | FIND_PREV );
    234         if ( lKeyFrame < 0 || lKeyFrame > lPos )
    235             return NULL;
    236         while ( ++lKeyFrame < lPos )
    237         {
    238             lpv = AVIFILE_IGetFrame_DecodeFrame(This, lKeyFrame);
    239             if ( lpv == NULL )
    240                 return NULL;
    241         }
    242     }
    243 
    244     lpv = AVIFILE_IGetFrame_DecodeFrame(This, lPos);
    245     TRACE( "lpv = %p\n",lpv );
    246     if ( lpv == NULL )
    247         return NULL;
    248 
    249     return lpv;
     218        ICOM_THIS(IGetFrameImpl,iface);
     219        LPVOID  lpv;
     220        LONG    lKeyFrame;
     221
     222        TRACE( "(%p)->(%ld)\n", This, lPos );
     223
     224        if ( lPos < 0 )
     225                return NULL;
     226
     227        if ( This->lCachedFrame == lPos )
     228                return This->pvICOutBits;
     229        if ( (This->lCachedFrame+1) != lPos )
     230        {
     231                lKeyFrame = IAVIStream_FindSample( This->pas, lPos,
     232                                                   FIND_KEY | FIND_PREV );
     233                if ( lKeyFrame < 0 || lKeyFrame > lPos )
     234                        return NULL;
     235                while ( ++lKeyFrame < lPos )
     236                {
     237                        lpv = AVIFILE_IGetFrame_DecodeFrame(This, lKeyFrame);
     238                        if ( lpv == NULL )
     239                                return NULL;
     240                }
     241        }
     242
     243        lpv = AVIFILE_IGetFrame_DecodeFrame(This, lPos);
     244        TRACE( "lpv = %p\n",lpv );
     245        if ( lpv == NULL )
     246                return NULL;
     247
     248        return lpv;
    250249}
    251250
    252251static HRESULT WINAPI IGetFrame_fnBegin(IGetFrame* iface,LONG lStart,LONG lEnd,LONG lRate)
    253252{
    254     ICOM_THIS(IGetFrameImpl,iface);
    255 
    256     TRACE( "(%p)->(%ld,%ld,%ld)\n", This, lStart, lEnd, lRate );
    257 
    258     if ( This->hIC == (HIC)NULL )
    259         return E_UNEXPECTED;
    260 
    261     if ( ICDecompressBegin( This->hIC,
    262                 This->pbiICIn,
    263                 This->pbiICOut ) != ICERR_OK )
    264         return E_FAIL;
    265 
    266     return S_OK;
     253        ICOM_THIS(IGetFrameImpl,iface);
     254
     255        TRACE( "(%p)->(%ld,%ld,%ld)\n", This, lStart, lEnd, lRate );
     256
     257        if ( This->hIC == (HIC)NULL )
     258                return E_UNEXPECTED;
     259
     260        if ( ICDecompressBegin( This->hIC,
     261                                This->pbiICIn,
     262                                This->pbiICOut ) != ICERR_OK )
     263                return E_FAIL;
     264
     265        return S_OK;
    267266}
    268267
    269268static HRESULT WINAPI IGetFrame_fnEnd(IGetFrame* iface)
    270269{
    271     ICOM_THIS(IGetFrameImpl,iface);
    272 
    273     TRACE( "(%p)->()\n", This );
    274 
    275     if ( This->hIC == (HIC)NULL )
    276         return E_UNEXPECTED;
    277 
    278     if ( ICDecompressEnd( This->hIC ) != ICERR_OK )
    279         return E_FAIL;
    280 
    281     return S_OK;
     270        ICOM_THIS(IGetFrameImpl,iface);
     271
     272        TRACE( "(%p)->()\n", This );
     273
     274        if ( This->hIC == (HIC)NULL )
     275                return E_UNEXPECTED;
     276
     277        if ( ICDecompressEnd( This->hIC ) != ICERR_OK )
     278                return E_FAIL;
     279
     280        return S_OK;
    282281}
    283282
    284283static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame* iface,LPBITMAPINFOHEADER lpbi,LPVOID lpBits,INT x,INT y,INT dx,INT dy)
    285284{
    286     ICOM_THIS(IGetFrameImpl,iface);
    287     HRESULT hr;
    288     LONG    fmtlen;
    289     BITMAPINFOHEADER    biTemp;
    290     DWORD   dwSizeImage;
    291 
    292     FIXME( "(%p)->(%p,%p,%d,%d,%d,%d)\n",This,lpbi,lpBits,x,y,dx,dy );
    293 
    294     IGetFrame_Destruct(This);
    295 
    296     hr = IAVIStream_ReadFormat(This->pas,0,NULL,&fmtlen);
    297     if ( hr != S_OK )
    298         return hr;
    299     This->pvICInFmtBuf = HeapAlloc(
    300         AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,fmtlen);
    301     if ( This->pvICInFmtBuf == NULL )
    302         return AVIERR_MEMORY;
    303     hr = IAVIStream_ReadFormat(This->pas,0,This->pvICInFmtBuf,&fmtlen);
    304     if ( hr != S_OK )
    305         return hr;
    306     This->pbiICIn = (LPBITMAPINFO)This->pvICInFmtBuf;
    307 
    308     This->hIC = (HIC)ICOpen( ICTYPE_VIDEO,
    309                 This->pbiICIn->bmiHeader.biCompression,
    310                 ICMODE_DECOMPRESS );
    311     if ( This->hIC == (HIC)NULL )
    312     {
    313         ERR( "no AVI decompressor for %c%c%c%c.\n",
    314              (int)(This->pbiICIn->bmiHeader.biCompression>> 0)&0xff,
    315              (int)(This->pbiICIn->bmiHeader.biCompression>> 8)&0xff,
    316              (int)(This->pbiICIn->bmiHeader.biCompression>>16)&0xff,
    317              (int)(This->pbiICIn->bmiHeader.biCompression>>24)&0xff );
    318         return E_FAIL;
    319     }
    320 
    321     if ( lpbi == NULL || lpbi == ((LPBITMAPINFOHEADER)1) )
    322     {
    323         memset( &biTemp, 0, sizeof(biTemp) );
    324         biTemp.biSize = sizeof(BITMAPINFOHEADER);
    325         biTemp.biWidth = This->pbiICIn->bmiHeader.biWidth;
    326         biTemp.biHeight = This->pbiICIn->bmiHeader.biHeight;
    327         biTemp.biPlanes = 1;
    328         biTemp.biBitCount = 24;
    329         biTemp.biCompression = 0;
    330         lpbi = &biTemp;
    331     }
    332 
    333     if ( lpbi->biPlanes != 1 || lpbi->biCompression != 0 )
    334         return E_FAIL;
    335 
    336     dwSizeImage =
    337         ((This->pbiICIn->bmiHeader.biWidth*lpbi->biBitCount+7)/8)*
    338                     This->pbiICIn->bmiHeader.biHeight;
    339     This->pvICOutBuf = HeapAlloc(
    340         AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
    341         (sizeof(BITMAPINFO)+sizeof(RGBQUAD)*256)*2+
    342         dwSizeImage );
    343     if ( This->pvICOutBuf == NULL )
    344         return AVIERR_MEMORY;
    345 
    346     This->pbiICOut = (BITMAPINFO*)This->pvICOutBuf;
    347     This->pvICOutBits = (LPVOID)( (BYTE*)This->pvICOutBuf +
    348                 sizeof(BITMAPINFO) + sizeof(RGBQUAD)*256 );
    349 
    350     This->pbiICOut->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    351     This->pbiICOut->bmiHeader.biWidth = This->pbiICIn->bmiHeader.biWidth;
    352     This->pbiICOut->bmiHeader.biHeight = This->pbiICIn->bmiHeader.biHeight;
    353     This->pbiICOut->bmiHeader.biPlanes = 1;
    354     This->pbiICOut->bmiHeader.biBitCount = lpbi->biBitCount;
    355     This->pbiICOut->bmiHeader.biSizeImage = dwSizeImage;
    356     memcpy( This->pvICOutBits, This->pbiICOut, sizeof(BITMAPINFOHEADER) );
    357 
    358     return S_OK;
     285        ICOM_THIS(IGetFrameImpl,iface);
     286        HRESULT hr;
     287        LONG    fmtlen;
     288        BITMAPINFOHEADER        biTemp;
     289        DWORD   dwSizeImage;
     290
     291        FIXME( "(%p)->(%p,%p,%d,%d,%d,%d)\n",This,lpbi,lpBits,x,y,dx,dy );
     292
     293        IGetFrame_Destruct(This);
     294
     295        hr = IAVIStream_ReadFormat(This->pas,0,NULL,&fmtlen);
     296        if ( hr != S_OK )
     297                return hr;
     298        This->pvICInFmtBuf = HeapAlloc(
     299                AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,fmtlen);
     300        if ( This->pvICInFmtBuf == NULL )
     301                return AVIERR_MEMORY;
     302        hr = IAVIStream_ReadFormat(This->pas,0,This->pvICInFmtBuf,&fmtlen);
     303        if ( hr != S_OK )
     304                return hr;
     305        This->pbiICIn = (LPBITMAPINFO)This->pvICInFmtBuf;
     306
     307        This->hIC = (HIC)ICOpen( ICTYPE_VIDEO,
     308                                This->pbiICIn->bmiHeader.biCompression,
     309                                ICMODE_DECOMPRESS );
     310        if ( This->hIC == (HIC)NULL )
     311        {
     312                ERR( "no AVI decompressor for %c%c%c%c.\n",
     313                     (int)(This->pbiICIn->bmiHeader.biCompression>> 0)&0xff,
     314                     (int)(This->pbiICIn->bmiHeader.biCompression>> 8)&0xff,
     315                     (int)(This->pbiICIn->bmiHeader.biCompression>>16)&0xff,
     316                     (int)(This->pbiICIn->bmiHeader.biCompression>>24)&0xff );
     317                return E_FAIL;
     318        }
     319
     320        if ( lpbi == NULL || lpbi == ((LPBITMAPINFOHEADER)1) )
     321        {
     322                memset( &biTemp, 0, sizeof(biTemp) );
     323                biTemp.biSize = sizeof(BITMAPINFOHEADER);
     324                biTemp.biWidth = This->pbiICIn->bmiHeader.biWidth;
     325                biTemp.biHeight = This->pbiICIn->bmiHeader.biHeight;
     326                biTemp.biPlanes = 1;
     327                biTemp.biBitCount = 24;
     328                biTemp.biCompression = 0;
     329                lpbi = &biTemp;
     330        }
     331
     332        if ( lpbi->biPlanes != 1 || lpbi->biCompression != 0 )
     333                return E_FAIL;
     334
     335        dwSizeImage =
     336                ((This->pbiICIn->bmiHeader.biWidth*lpbi->biBitCount+7)/8)*
     337                                        This->pbiICIn->bmiHeader.biHeight;
     338        This->pvICOutBuf = HeapAlloc(
     339                AVIFILE_data.hHeap,HEAP_ZERO_MEMORY,
     340                (sizeof(BITMAPINFO)+sizeof(RGBQUAD)*256)*2+
     341                dwSizeImage );
     342        if ( This->pvICOutBuf == NULL )
     343                return AVIERR_MEMORY;
     344
     345        This->pbiICOut = (BITMAPINFO*)This->pvICOutBuf;
     346        This->pvICOutBits = (LPVOID)( (BYTE*)This->pvICOutBuf +
     347                                sizeof(BITMAPINFO) + sizeof(RGBQUAD)*256 );
     348
     349        This->pbiICOut->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
     350        This->pbiICOut->bmiHeader.biWidth = This->pbiICIn->bmiHeader.biWidth;
     351        This->pbiICOut->bmiHeader.biHeight = This->pbiICIn->bmiHeader.biHeight;
     352        This->pbiICOut->bmiHeader.biPlanes = 1;
     353        This->pbiICOut->bmiHeader.biBitCount = lpbi->biBitCount;
     354        This->pbiICOut->bmiHeader.biSizeImage = dwSizeImage;
     355        memcpy( This->pvICOutBits, This->pbiICOut, sizeof(BITMAPINFOHEADER) );
     356
     357        return S_OK;
    359358}
    360359
    361360static HRESULT IGetFrame_Construct( IGetFrameImpl* This,
    362                     IAVIStream* pstr,
    363                     LPBITMAPINFOHEADER lpbi )
    364 {
    365     HRESULT hr;
    366 
    367     TRACE( "(%p)->(%p,%p)\n",This,pstr,lpbi );
    368 
    369     IAVIStream_AddRef( pstr );
    370     This->pas = pstr;
    371     This->hIC = (HIC)NULL;
    372     This->lCachedFrame = -1L;
    373     This->pbiICIn = NULL;
    374     This->pbiICOut = NULL;
    375     This->pvICInFmtBuf = NULL;
    376     This->pvICInDataBuf = NULL;
    377     This->dwICInDataBufSize = 0;
    378     This->pvICOutBuf = NULL;
    379 
    380     hr = IGetFrame_SetFormat((IGetFrame*)This,lpbi,NULL,0,0,0,0);
    381     if ( hr != S_OK )
    382         return hr;
    383 
    384     return S_OK;
     361                                    IAVIStream* pstr,
     362                                    LPBITMAPINFOHEADER lpbi )
     363{
     364        HRESULT hr;
     365
     366        TRACE( "(%p)->(%p,%p)\n",This,pstr,lpbi );
     367
     368        IAVIStream_AddRef( pstr );
     369        This->pas = pstr;
     370        This->hIC = (HIC)NULL;
     371        This->lCachedFrame = -1L;
     372        This->pbiICIn = NULL;
     373        This->pbiICOut = NULL;
     374        This->pvICInFmtBuf = NULL;
     375        This->pvICInDataBuf = NULL;
     376        This->dwICInDataBufSize = 0;
     377        This->pvICOutBuf = NULL;
     378
     379        hr = IGetFrame_SetFormat((IGetFrame*)This,lpbi,NULL,0,0,0,0);
     380        if ( hr != S_OK )
     381                return hr;
     382
     383        return S_OK;
    385384}
    386385
    387386static void IGetFrame_Destruct( IGetFrameImpl* This )
    388387{
    389     if ( This->hIC != (HIC)NULL )
    390     {
    391         ICClose( This->hIC );
    392         This->hIC = (HIC)NULL;
    393     }
    394     if ( This->pvICInFmtBuf != NULL )
    395     {
    396         HeapFree( AVIFILE_data.hHeap, 0, This->pvICInFmtBuf );
    397         This->pvICInFmtBuf = NULL;
    398     }
    399     if ( This->pvICInDataBuf != NULL )
    400     {
    401         HeapFree( AVIFILE_data.hHeap, 0, This->pvICInDataBuf );
    402         This->pvICInDataBuf = NULL;
    403     }
    404     if ( This->pvICOutBuf != NULL )
    405     {
    406         HeapFree( AVIFILE_data.hHeap, 0, This->pvICOutBuf );
    407         This->pvICOutBuf = NULL;
    408     }
    409 
    410     This->lCachedFrame = -1L;
    411     This->pbiICIn = NULL;
    412     This->pbiICOut = NULL;
    413     This->dwICInDataBufSize = 0;
    414 }
     388        if ( This->hIC != (HIC)NULL )
     389        {
     390                ICClose( This->hIC );
     391                This->hIC = (HIC)NULL;
     392        }
     393        if ( This->pvICInFmtBuf != NULL )
     394        {
     395                HeapFree( AVIFILE_data.hHeap, 0, This->pvICInFmtBuf );
     396                This->pvICInFmtBuf = NULL;
     397        }
     398        if ( This->pvICInDataBuf != NULL )
     399        {
     400                HeapFree( AVIFILE_data.hHeap, 0, This->pvICInDataBuf );
     401                This->pvICInDataBuf = NULL;
     402        }
     403        if ( This->pvICOutBuf != NULL )
     404        {
     405                HeapFree( AVIFILE_data.hHeap, 0, This->pvICOutBuf );
     406                This->pvICOutBuf = NULL;
     407        }
     408
     409        This->lCachedFrame = -1L;
     410        This->pbiICIn = NULL;
     411        This->pbiICOut = NULL;
     412        This->dwICInDataBufSize = 0;
     413}
  • trunk/src/avifil32/main.c

    r6652 r6712  
    1 /* $Id: main.c,v 1.2 2001-09-05 14:16:45 bird Exp $ */
    21/*
    32 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
     
    2221
    2322/***********************************************************************
    24  *      AVIFILE_InitProcess (internal)
     23 *              AVIFILE_InitProcess (internal)
    2524 */
    2625static BOOL AVIFILE_InitProcess( void )
    2726{
    28     TRACE("()\n");
     27        TRACE("()\n");
    2928
    30     AVIFILE_data.dwAVIFileRef = 0;
    31     AVIFILE_data.dwClassObjRef = 0;
    32     AVIFILE_data.hHeap = (HANDLE)NULL;
     29        AVIFILE_data.dwAVIFileRef = 0;
     30        AVIFILE_data.dwClassObjRef = 0;
     31        AVIFILE_data.hHeap = (HANDLE)NULL;
    3332
    34     AVIFILE_data.hHeap = HeapCreate( 0, 0x10000, 0 );
    35     if ( AVIFILE_data.hHeap  == (HANDLE)NULL )
    36     {
    37         ERR( "cannot allocate heap for AVIFILE.\n" );
    38         return FALSE;
    39     }
     33        AVIFILE_data.hHeap = HeapCreate( 0, 0x10000, 0 );
     34        if ( AVIFILE_data.hHeap  == (HANDLE)NULL )
     35        {
     36                ERR( "cannot allocate heap for AVIFILE.\n" );
     37                return FALSE;
     38        }
    4039
    41     return TRUE;
     40        return TRUE;
    4241}
    4342
    4443/***********************************************************************
    45  *      AVIFILE_UninitProcess (internal)
     44 *              AVIFILE_UninitProcess (internal)
    4645 */
    4746static void AVIFILE_UninitProcess( void )
    4847{
    49     TRACE("()\n");
     48        TRACE("()\n");
    5049
    51     if ( AVIFILE_data.dwAVIFileRef != 0 )
    52         ERR( "you must call AVIFileExit()\n" );
     50        if ( AVIFILE_data.dwAVIFileRef != 0 )
     51                ERR( "you must call AVIFileExit()\n" );
    5352
    54     if ( AVIFILE_data.dwClassObjRef != 0 )
    55         ERR( "you must release some objects allocated from AVIFile.\n" );
     53        if ( AVIFILE_data.dwClassObjRef != 0 )
     54                ERR( "you must release some objects allocated from AVIFile.\n" );
    5655
    57     if ( AVIFILE_data.hHeap != (HANDLE)NULL )
    58     {
    59         HeapDestroy( AVIFILE_data.hHeap );
    60         AVIFILE_data.hHeap = (HANDLE)NULL;
    61     }
     56        if ( AVIFILE_data.hHeap != (HANDLE)NULL )
     57        {
     58                HeapDestroy( AVIFILE_data.hHeap );
     59                AVIFILE_data.hHeap = (HANDLE)NULL;
     60        }
    6261}
    6362
    6463/***********************************************************************
    65  *      AVIFILE_DllMain
     64 *              AVIFILE_DllMain
    6665 */
    6766BOOL WINAPI AVIFILE_DllMain(
    68     HINSTANCE hInstDLL,
    69     DWORD fdwReason,
    70     LPVOID lpvReserved )
     67        HINSTANCE hInstDLL,
     68        DWORD fdwReason,
     69        LPVOID lpvReserved )
    7170{
    72     switch ( fdwReason )
    73     {
    74     case DLL_PROCESS_ATTACH:
    75         if ( !AVIFILE_InitProcess() )
    76             return FALSE;
    77         break;
    78     case DLL_PROCESS_DETACH:
    79         AVIFILE_UninitProcess();
    80         break;
    81     case DLL_THREAD_ATTACH:
    82         break;
    83     case DLL_THREAD_DETACH:
    84         break;
    85     }
     71        switch ( fdwReason )
     72        {
     73        case DLL_PROCESS_ATTACH:
     74                if ( !AVIFILE_InitProcess() )
     75                        return FALSE;
     76                break;
     77        case DLL_PROCESS_DETACH:
     78                AVIFILE_UninitProcess();
     79                break;
     80        case DLL_THREAD_ATTACH:
     81                break;
     82        case DLL_THREAD_DETACH:
     83                break;
     84        }
    8685
    87     return TRUE;
     86        return TRUE;
    8887}
    8988
  • trunk/src/avifil32/string.c

    r6652 r6712  
    1 /* $Id: string.c,v 1.2 2001-09-05 14:16:46 bird Exp $ */
    21/*
    32 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
     
    2524INT AVIFILE_strlenAtoW( LPCSTR lpstr )
    2625{
    27     INT len;
     26        INT     len;
    2827
    29     len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
    30     return ( len > 0 ) ? (len-1) : 0;
     28        len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
     29        return ( len > 0 ) ? (len-1) : 0;
    3130}
    3231
    3332INT AVIFILE_strlenWtoA( LPCWSTR lpwstr )
    3433{
    35     INT len;
     34        INT     len;
    3635
    37     len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
    38                    NULL, 0, NULL, NULL );
    39     return ( len > 0 ) ? (len-1) : 0;
     36        len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
     37                                   NULL, 0, NULL, NULL );
     38        return ( len > 0 ) ? (len-1) : 0;
    4039}
    4140
    4241LPWSTR AVIFILE_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
    4342{
    44     INT len;
     43        INT     len;
    4544
    46     len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
    47     if ( len == 0 )
    48         *lpwstr = 0;
    49     return lpwstr;
     45        len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
     46        if ( len == 0 )
     47                *lpwstr = 0;
     48        return lpwstr;
    5049}
    5150
    5251LPSTR AVIFILE_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen )
    5352{
    54     INT len;
     53        INT     len;
    5554
    56     len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
    57                    lpstr, abuflen, NULL, NULL );
    58     if ( len == 0 )
    59         *lpstr = 0;
    60     return lpstr;
     55        len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
     56                                   lpstr, abuflen, NULL, NULL );
     57        if ( len == 0 )
     58                *lpstr = 0;
     59        return lpstr;
    6160}
    6261
    6362LPWSTR AVIFILE_strdupAtoW( LPCSTR lpstr )
    6463{
    65     INT len;
    66     LPWSTR lpwstr = NULL;
     64        INT len;
     65        LPWSTR lpwstr = NULL;
    6766
    68     len = AVIFILE_strlenAtoW( lpstr );
    69     if ( len > 0 )
    70     {
    71         lpwstr = (LPWSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(WCHAR)*(len+1) );
    72         if ( lpwstr != NULL )
    73             (void)AVIFILE_strncpyAtoW( lpwstr, lpstr, len+1 );
    74     }
     67        len = AVIFILE_strlenAtoW( lpstr );
     68        if ( len > 0 )
     69        {
     70                lpwstr = (LPWSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(WCHAR)*(len+1) );
     71                if ( lpwstr != NULL )
     72                        (void)AVIFILE_strncpyAtoW( lpwstr, lpstr, len+1 );
     73        }
    7574
    76     return lpwstr;
     75        return lpwstr;
    7776}
    7877
    7978LPSTR AVIFILE_strdupWtoA( LPCWSTR lpwstr )
    8079{
    81     INT len;
    82     LPSTR lpstr = NULL;
     80        INT len;
     81        LPSTR lpstr = NULL;
    8382
    84     len = AVIFILE_strlenWtoA( lpwstr );
    85     if ( len > 0 )
    86     {
    87         lpstr = (LPSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(CHAR)*(len+1) );
    88         if ( lpstr != NULL )
    89             (void)AVIFILE_strncpyWtoA( lpstr, lpwstr, len+1 );
    90     }
     83        len = AVIFILE_strlenWtoA( lpwstr );
     84        if ( len > 0 )
     85        {
     86                lpstr = (LPSTR)HeapAlloc( AVIFILE_data.hHeap, 0, sizeof(CHAR)*(len+1) );
     87                if ( lpstr != NULL )
     88                        (void)AVIFILE_strncpyWtoA( lpstr, lpwstr, len+1 );
     89        }
    9190
    92     return lpstr;
     91        return lpstr;
    9392}
    9493
  • trunk/src/crtdll/crtdll.cpp

    r6645 r6712  
    1 /* $Id: crtdll.cpp,v 1.30 2001-09-05 12:14:23 bird Exp $ */
    21/*
    32 * The C RunTime DLL
    4  *
     3 * 
    54 * Implements C run-time functionality as known from UNIX.
    65 *
    7  * TODO:
     6 * TODO: 
    87 *   - Check setjmp(3)
    98 *   - fix *ALL* functions for the FS: wrapper problem
     
    7372// Definitions for internal functions
    7473//
    75 void        qsort1 (char*, char*, size_t,
     74void            qsort1 (char*, char*, size_t,
    7675                    int (* CDECL)(const void*, const void*));
    7776
     
    445444
    446445/*********************************************************************
    447  *  _cscanf                     (CRTDLL.67)
     446 *      _cscanf                                 (CRTDLL.67)
    448447 */
    449448INT CDECL CRTDLL__cscanf( char *s, va_list arg )
     
    605604
    606605/*********************************************************************
    607  *  _ftime                  (CRTDLL.112)
     606 *      _ftime                                  (CRTDLL.112)
    608607 */
    609608void CDECL CRTDLL__ftime( struct timeb *timebuf )
     
    619618LONG CDECL CRTDLL__ftol(void)
    620619{
    621     /* don't just do DO_FPU("fistp",retval), because the rounding
    622     * mode must also be set to "round towards zero"... */
    623     double fl;
    624     POP_FPU(fl);
    625     return (LONG)fl;
     620        /* don't just do DO_FPU("fistp",retval), because the rounding
     621        * mode must also be set to "round towards zero"... */
     622        double fl;
     623        POP_FPU(fl);
     624        return (LONG)fl;
    626625}
    627626
     
    776775
    777776/*********************************************************************
    778  *                  _ltoa   (CRTDLL.179)
     777 *                  _ltoa       (CRTDLL.179)
    779778 */
    780779LPSTR  CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix)
     
    785784
    786785/*********************************************************************
    787  *                  _matherr    (CRTDLL.181)
     786 *                  _matherr    (CRTDLL.181)
    788787 */
    789788double CDECL CRTDLL__matherr( struct exception * excep )
     
    882881
    883882/*********************************************************************
    884  *           CRTDLL__searchenv   (CRTDLL.260)
     883 *           CRTDLL__searchenv   (CRTDLL.260)
    885884 */
    886885void CDECL CRTDLL__searchenv(char *file, char *var,char *path )
     
    892891
    893892/*********************************************************************
    894  *           CRTDLL__seterrormode   (CRTDLL.261)
     893 *           CRTDLL__seterrormode       (CRTDLL.261)
    895894 */
    896895void CDECL CRTDLL__seterrormode(int uMode)
     
    903902
    904903/*********************************************************************
    905  *           CRTDLL__setjmp     (CRTDLL.262)
     904 *           CRTDLL__setjmp     (CRTDLL.262)
    906905 */
    907906int CDECL CRTDLL__setjmp( jmp_buf env )
     
    938937
    939938/*********************************************************************
    940  *  _sopen                  (CRTDLL.268)
     939 *      _sopen                                  (CRTDLL.268)
    941940 */
    942941int CDECL CRTDLL__sopen( const char *s, int i1, int i2, va_list arg )
     
    948947
    949948/*********************************************************************
    950  *           CRTDLL__spawnl     (CRTDLL.269)
     949 *           CRTDLL__spawnl     (CRTDLL.269)
    951950 */
    952951int CDECL CRTDLL__spawnl(int nMode, char* szPath, char* szArgv0, va_list arg)
     
    958957
    959958/*********************************************************************
    960  *           CRTDLL__spawnle     (CRTDLL.270)
     959 *           CRTDLL__spawnle     (CRTDLL.270)
    961960 */
    962961int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, va_list arg )
     
    968967
    969968/*********************************************************************
    970  *           CRTDLL__spawnlp     (CRTDLL.271)
     969 *           CRTDLL__spawnlp     (CRTDLL.271)
    971970 */
    972971int CDECL CRTDLL__spawnlp(int nMode, char* szPath, char* szArgv0, va_list arg)
     
    978977
    979978/*********************************************************************
    980  *           CRTDLL__spawnlpe   (CRTDLL.272)
     979 *           CRTDLL__spawnlpe   (CRTDLL.272)
    981980 */
    982981int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, va_list arg )
     
    988987
    989988/*********************************************************************
    990  *           CRTDLL__spawnv     (CRTDLL.273)
     989 *           CRTDLL__spawnv     (CRTDLL.273)
    991990 */
    992991int CDECL CRTDLL__spawnv( int i, char *s1, char ** s2 )
     
    998997
    999998/*********************************************************************
    1000  *           CRTDLL__spawnvp     (CRTDLL.275)
     999 *           CRTDLL__spawnvp     (CRTDLL.275)
    10011000 */
    10021001int CDECL CRTDLL__spawnvp( int i, char *s1, char ** s2 )
     
    10071006
    10081007/*********************************************************************
    1009  *           CRTDLL__spawnv     (CRTDLL.276)
     1008 *           CRTDLL__spawnv     (CRTDLL.276)
    10101009 */
    10111010int CDECL CRTDLL__spawnvpe( int i, char *s1, char ** s2, char ** s3 )
     
    10171016
    10181017/*********************************************************************
    1019  *           CRTDLL__statusfp    (CRTDLL.279)
     1018 *           CRTDLL__statusfp    (CRTDLL.279)
    10201019 */
    10211020unsigned int CDECL CRTDLL__statusfp( void )
     
    10241023  return (_status87());
    10251024}
    1026 
    1027 
    1028 /*********************************************************************
    1029  *           _ultoa      (CRTDLL.309)
     1025       
     1026
     1027/*********************************************************************
     1028 *           _ultoa              (CRTDLL.309)
    10301029 */
    10311030LPSTR  CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix)
     
    10371036
    10381037/*********************************************************************
    1039  *           CRTDLL__ungetch    (CRTDLL.311)
     1038 *           CRTDLL__ungetch    (CRTDLL.311)
    10401039 */
    10411040int CDECL CRTDLL__ungetch( int i )
     
    10471046
    10481047/*********************************************************************
    1049  *           _utime      (CRTDLL.314)
     1048 *           _utime              (CRTDLL.314)
    10501049 */
    10511050int CDECL CRTDLL__utime( char *path, struct utimbuf * times )
     
    10571056
    10581057/*********************************************************************
    1059  *  _vsnprintf              (CRTDLL.315)
     1058 *      _vsnprintf                              (CRTDLL.315)
    10601059 */
    10611060int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg )
     
    11011100
    11021101/*********************************************************************
    1103  *                  abs     (CRTDLL.336)
     1102 *                  abs         (CRTDLL.336)
    11041103 */
    11051104double CDECL CRTDLL_abs(double d)
     
    11131112
    11141113/*********************************************************************
    1115  *                  acos    (CRTDLL.337)
     1114 *                  acos        (CRTDLL.337)
    11161115 */
    11171116double CDECL CRTDLL_acos( double x )
     
    11231122
    11241123/*********************************************************************
    1125  *                  asctime (CRTDLL.338)
     1124 *                  asctime     (CRTDLL.338)
    11261125 */
    11271126char * CDECL CRTDLL_asctime( const struct tm *timeptr )
     
    11331132
    11341133/*********************************************************************
    1135  *                  asin    (CRTDLL.339)
     1134 *                  asin        (CRTDLL.339)
    11361135 */
    11371136double CDECL CRTDLL_asin( double x )
     
    11431142
    11441143/*********************************************************************
    1145  *                  atan    (CRTDLL.340)
     1144 *                  atan        (CRTDLL.340)
    11461145 */
    11471146double CDECL CRTDLL_atan(double d)
     
    11551154
    11561155/*********************************************************************
    1157  *                  atan2   (CRTDLL.341)
     1156 *                  atan2       (CRTDLL.341)
    11581157 */
    11591158double CDECL CRTDLL_atan2( double y, double x )
     
    11651164
    11661165/*********************************************************************
    1167  *                  atof    (CRTDLL.343)
     1166 *                  atof        (CRTDLL.343)
    11681167 */
    11691168double CDECL CRTDLL_atof( const char *nptr )
     
    11751174
    11761175/*********************************************************************
    1177  *                  atoi    (CRTDLL.344)
     1176 *                  atoi        (CRTDLL.344)
    11781177 */
    11791178int CDECL CRTDLL_atoi(LPSTR str)
     
    11871186
    11881187/*********************************************************************
    1189  *                  atol    (CRTDLL.345)
     1188 *                  atol        (CRTDLL.345)
    11901189 */
    11911190long CDECL CRTDLL_atol(LPSTR str)
     
    11991198
    12001199/*********************************************************************
    1201  *                  bsearch (CRTDLL.346)
     1200 *                  bsearch     (CRTDLL.346)
    12021201 */
    12031202void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width,
     
    12061205  int left, right, median, sign;
    12071206  const void *element;
    1208 
     1207 
    12091208  if (width == 0)
    12101209    return 0;
     
    12271226
    12281227/*********************************************************************
    1229  *                  ceil    (CRTDLL.348)
     1228 *                  ceil        (CRTDLL.348)
    12301229 */
    12311230double CDECL CRTDLL_ceil(double d)
     
    12381237
    12391238/*********************************************************************
    1240  *                  clock   (CRTDLL.350)
     1239 *                  clock       (CRTDLL.350)
    12411240 */
    12421241clock_t CDECL CRTDLL_clock( void )
     
    12481247
    12491248/*********************************************************************
    1250  *                  cos     (CRTDLL.351)
     1249 *                  cos         (CRTDLL.351)
    12511250 */
    12521251double CDECL CRTDLL_cos(double d)
     
    12601259
    12611260/*********************************************************************
    1262  *                  cosh    (CRTDLL.352)
     1261 *                  cosh        (CRTDLL.352)
    12631262 */
    12641263double CDECL CRTDLL_cosh( double x )
     
    12701269
    12711270/*********************************************************************
    1272  *                  ctime   (CRTDLL.353)
     1271 *                  ctime       (CRTDLL.353)
    12731272 */
    12741273char * CDECL CRTDLL_ctime( const time_t *timer )
     
    12801279
    12811280/*********************************************************************
    1282  *                  difftime    (CRTDLL.354)
     1281 *                  difftime    (CRTDLL.354)
    12831282 */
    12841283double CDECL CRTDLL_difftime( time_t t1, time_t t0 )
     
    12901289
    12911290/*********************************************************************
    1292  *                  div     (CRTDLL.355)
     1291 *                  div         (CRTDLL.355)
    12931292 */
    12941293ULONG CDECL CRTDLL_div( int number, int denom )
     
    13041303
    13051304/*********************************************************************
    1306  *                  exp     (CRTDLL.357)
     1305 *                  exp         (CRTDLL.357)
    13071306 */
    13081307double CDECL CRTDLL_exp( double x )
     
    13141313
    13151314/*********************************************************************
    1316  *                  fabs    (CRTDLL.358)
     1315 *                  fabs        (CRTDLL.358)
    13171316 */
    13181317double CDECL CRTDLL_fabs(double d)
     
    13261325
    13271326/*********************************************************************
    1328  *                  floor       (CRTDLL.367)
     1327 *                  floor               (CRTDLL.367)
    13291328 */
    13301329double CDECL CRTDLL_floor(double d)
     
    13381337
    13391338/*********************************************************************
    1340  *                  fmod    (CRTDLL.368)
     1339 *                  fmod        (CRTDLL.368)
    13411340 */
    13421341double CDECL CRTDLL_fmod(double x, double y )
     
    13481347
    13491348/*********************************************************************
    1350  *                  frexp     (CRTDLL.377)
     1349 *                  frexp         (CRTDLL.377)
    13511350 */
    13521351double CDECL CRTDLL_frexp( double value, int *exp )
     
    14901489
    14911490/*********************************************************************
    1492  *                  labs    (CRTDLL.416)
     1491 *                  labs        (CRTDLL.416)
    14931492 */
    14941493long int CDECL CRTDLL_labs( long int j )
     
    15001499
    15011500/*********************************************************************
    1502  *                  ldexp   (CRTDLL.417)
    1503  */
    1504 double CDECL CRTDLL_ldexp( double x, int exp )
     1501 *                  ldexp       (CRTDLL.417)
     1502 */
     1503double CDECL CRTDLL_ldexp( double x, int exp ) 
    15051504{
    15061505  dprintf2(("CRTDLL: ldexp\n"));
     
    15101509
    15111510/*********************************************************************
    1512  *                  ldiv    (CRTDLL.418)
    1513  */
    1514 ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom )
     1511 *                  ldiv        (CRTDLL.418)
     1512 */
     1513ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom ) 
    15151514{
    15161515  dprintf2(("CRTDLL: ldiv\n"));
     
    15201519
    15211520/*********************************************************************
    1522  *                  localeconv  (CRTDLL.419)
     1521 *                  localeconv  (CRTDLL.419)
    15231522 */
    15241523struct lconv * CDECL CRTDLL_localeconv(void)
     
    15301529
    15311530/*********************************************************************
    1532  *                  localtime   (CRTDLL.420)
     1531 *                  localtime   (CRTDLL.420)
    15331532 */
    15341533struct tm * CDECL CRTDLL_localtime( const time_t *timer )
     
    15401539
    15411540/*********************************************************************
    1542  *                  log     (CRTDLL.421)
     1541 *                  log         (CRTDLL.421)
    15431542 */
    15441543double CDECL CRTDLL_log( double x )
     
    15501549
    15511550/*********************************************************************
    1552  *                  log10   (CRTDLL.422)
     1551 *                  log10       (CRTDLL.422)
    15531552 */
    15541553double CDECL CRTDLL_log10( double x )
     
    15821581 *                  pow      (CRTDLL.436)
    15831582 */
    1584 double CDECL CRTDLL_pow( double x, double y )
     1583double CDECL CRTDLL_pow( double x, double y )   
    15851584{
    15861585    dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y));
     
    16221621
    16231622/*********************************************************************
    1624  *  scanf                   (CRTDLL.448)
     1623 *      scanf                                   (CRTDLL.448)
    16251624 */
    16261625int CDECL CRTDLL_scanf( const char *format, va_list arg )
     
    17061705
    17071706/*********************************************************************
    1708  *  sscanf                  (CRTDLL.458)
     1707 *      sscanf                                  (CRTDLL.458)
    17091708 */
    17101709int CDECL CRTDLL_sscanf( const char *s, const char *format, va_list arg )
     
    17831782
    17841783/*********************************************************************
    1785  *  ungetc                  (CRTDLL.492)
     1784 *      ungetc                                  (CRTDLL.492)
    17861785 */
    17871786INT CDECL CRTDLL_ungetc(int c, FILE *f)
     
    18131812
    18141813/*********************************************************************
    1815  *           CRTDLL__setjmp3     (CRTDLL.600)
     1814 *           CRTDLL__setjmp3     (CRTDLL.600)
    18161815 */
    18171816int CDECL CRTDLL__setjmp3( jmp_buf env )
  • trunk/src/crtdll/crtdll_main.c

    r6645 r6712  
    1 /* $Id: crtdll_main.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */
    21/*
    32 * The C RunTime DLL
    4  *
     3 * 
    54 * Implements C run-time functionality as known from UNIX.
    65 *
     
    1413Unresolved issues Uwe Bonnes 970904:
    1514- tested with ftp://ftp.remcomp.com/pub/remcomp/lcc-win32.zip, a C-Compiler
    16         for Win32, based on lcc, from Jacob Navia
     15                for Win32, based on lcc, from Jacob Navia
    1716UB 000416:
    1817- probably not thread safe
    1918*/
    2019
    21 /* NOTE: This file also implements the wcs* functions. They _ARE_ in
     20/* NOTE: This file also implements the wcs* functions. They _ARE_ in 
    2221 * the newer Linux libcs, but use 4 byte wide characters, so are unusable,
    2322 * since we need 2 byte wide characters. - Marcus Meissner, 981031
     
    6463UINT CRTDLL_winminor_dll;     /* CRTDLL.330 */
    6564UINT CRTDLL_winver_dll;       /* CRTDLL.331 */
    66 INT  CRTDLL_doserrno = 0;
     65INT  CRTDLL_doserrno = 0; 
    6766INT  CRTDLL_errno = 0;
    6867const INT  CRTDLL__sys_nerr = 43;
     
    7877 *                  CRTDLL_MainInit  (CRTDLL.init)
    7978 */
    80 
     79 
    8180BOOL WINAPI CRTDLL_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    8281{
    8382  FS_OS2
    84 
     83   
    8584    // call i/o initializer in file.c
    86     if (fdwReason == DLL_PROCESS_ATTACH)
     85    if (fdwReason == DLL_PROCESS_ATTACH) 
    8786    {
    8887      __CRTDLL__init_io();
    8988    }
    90 
     89   
    9190  /*
    9291    PH 2000/11/21 this code doesn't look very useful
    93 
     92   
    9493    if (fdwReason == DLL_PROCESS_ATTACH) {
    9594      _fdopen(0,"r");
     
    104103      }
    105104  */
    106 
     105 
    107106  FS_WIN32
    108107  return TRUE;
     
    177176        char *cmdline;
    178177        char  **xargv;
    179     int xargc,end,last_arg,afterlastspace;
    180     DWORD   version;
    181 
    182     TRACE("(%p,%p,%p,%ld).\n",
    183         argc,argv,environ,flag
    184     );
    185 
    186     if (CRTDLL_acmdln_dll != NULL)
    187         HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);
    188 
    189     CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );
    190     TRACE("got '%s'\n", cmdline);
    191 
    192     version = GetVersion();
    193     CRTDLL_osver_dll       = version >> 16;
    194     CRTDLL_winminor_dll    = version & 0xFF;
    195     CRTDLL_winmajor_dll    = (version>>8) & 0xFF;
    196     CRTDLL_baseversion_dll = version >> 16;
    197     CRTDLL_winver_dll      = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
    198     CRTDLL_baseminor_dll   = (version >> 16) & 0xFF;
    199     CRTDLL_basemajor_dll   = (version >> 24) & 0xFF;
    200     CRTDLL_osversion_dll   = version & 0xFFFF;
    201     CRTDLL_osminor_dll     = version & 0xFF;
    202     CRTDLL_osmajor_dll     = (version>>8) & 0xFF;
    203 
    204     /* missing threading init */
    205 
    206     end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;
    207     while (1)
    208     {
    209         if ((cmdline[end]==' ') || (cmdline[end]=='\0'))
    210         {
    211         if (cmdline[end]=='\0')
    212             last_arg=1;
    213         else
    214             cmdline[end]='\0';
    215         /* alloc xargc + NULL entry */
    216             xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
    217                                      sizeof(char*)*(xargc+1));
    218         if (strlen(cmdline+afterlastspace))
    219         {
    220             xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);
    221             xargc++;
     178        int     xargc,end,last_arg,afterlastspace;
     179        DWORD   version;
     180
     181        TRACE("(%p,%p,%p,%ld).\n",
     182                argc,argv,environ,flag
     183        );
     184
     185        if (CRTDLL_acmdln_dll != NULL)
     186                HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);
     187
     188        CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );
     189        TRACE("got '%s'\n", cmdline);
     190
     191        version = GetVersion();
     192        CRTDLL_osver_dll       = version >> 16;
     193        CRTDLL_winminor_dll    = version & 0xFF;
     194        CRTDLL_winmajor_dll    = (version>>8) & 0xFF;
     195        CRTDLL_baseversion_dll = version >> 16;
     196        CRTDLL_winver_dll      = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
     197        CRTDLL_baseminor_dll   = (version >> 16) & 0xFF;
     198        CRTDLL_basemajor_dll   = (version >> 24) & 0xFF;
     199        CRTDLL_osversion_dll   = version & 0xFFFF;
     200        CRTDLL_osminor_dll     = version & 0xFF;
     201        CRTDLL_osmajor_dll     = (version>>8) & 0xFF;
     202
     203        /* missing threading init */
     204
     205        end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;
     206        while (1)
     207        {
     208            if ((cmdline[end]==' ') || (cmdline[end]=='\0'))
     209            {
     210                if (cmdline[end]=='\0')
     211                    last_arg=1;
     212                else
     213                    cmdline[end]='\0';
     214                /* alloc xargc + NULL entry */
     215                        xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
     216                                             sizeof(char*)*(xargc+1));
     217                if (strlen(cmdline+afterlastspace))
     218                {
     219                    xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);
     220                    xargc++;
    222221                    if (!last_arg) /* need to seek to the next arg ? */
    223             {
    224             end++;
    225             while (cmdline[end]==' ')
    226                 end++;
    227     }
    228             afterlastspace=end;
    229         }
    230         else
    231         {
    232             xargv[xargc] = NULL; /* the last entry is NULL */
    233             break;
    234         }
    235         }
    236         else
    237         end++;
    238     }
    239     CRTDLL_argc_dll = xargc;
    240     *argc       = xargc;
    241     CRTDLL_argv_dll = xargv;
    242     *argv       = xargv;
    243 
    244     TRACE("found %d arguments\n",
    245         CRTDLL_argc_dll);
    246     CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
    247     return environ;
     222                    {
     223                        end++;
     224                        while (cmdline[end]==' ')
     225                            end++;
     226        }
     227                    afterlastspace=end;
     228                }
     229                else
     230                {
     231                    xargv[xargc] = NULL; /* the last entry is NULL */
     232                    break;
     233                }
     234            }
     235            else
     236                end++;
     237        }
     238        CRTDLL_argc_dll = xargc;
     239        *argc           = xargc;
     240        CRTDLL_argv_dll = xargv;
     241        *argv           = xargv;
     242
     243        TRACE("found %d arguments\n",
     244                CRTDLL_argc_dll);
     245        CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
     246        return environ;
    248247}
    249248
     
    254253DWORD CDECL CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end)
    255254{
    256     _INITTERMFUN    *current;
    257 
    258     TRACE("(%p,%p)\n",start,end);
    259     current=start;
    260     while (current<end) {
    261         if (*current) (*current)();
    262         current++;
    263     }
    264     return 0;
     255        _INITTERMFUN    *current;
     256
     257        TRACE("(%p,%p)\n",start,end);
     258        current=start;
     259        while (current<end) {
     260                if (*current) (*current)();
     261                current++;
     262        }
     263        return 0;
    265264}
    266265
     
    310309INT CDECL CRTDLL_rand()
    311310{
    312     return (rand() & CRTDLL_RAND_MAX);
     311    return (rand() & CRTDLL_RAND_MAX); 
    313312}
    314313
     
    320319{
    321320  // return (_rotl(value, shift));
    322 
     321 
    323322    shift &= 31;
    324323    return (x << shift) | (x >> (32-shift));
     
    332331{
    333332  // return (_lrotl(value, shift));
    334 
     333 
    335334    shift &= 31;
    336335    return (x << shift) | (x >> (32-shift));
     
    344343{
    345344  // return (_lrotr(value, shift));
    346 
     345 
    347346    shift &= 0x1f;
    348347    return (x >> shift) | (x << (32-shift));
     
    356355{
    357356  // return (_rotr(value, shift));
    358 
     357 
    359358    shift &= 0x1f;
    360359    return (x >> shift) | (x << (32-shift));
     
    368367{
    369368  // return (vswprintf(s, t, format, arg));
    370 
     369 
    371370    return wvsprintfW( buffer, spec, args );
    372371}
     
    389388{
    390389  return (setlocale(category, locale));
    391 
     390 
    392391  /*
    393392    LPSTR categorystr;
     
    438437{
    439438  // return (_fullpath(buf, path, size));
    440 
     439 
    441440  if (!buf)
    442441  {
     
    456455{
    457456  // _splitpath( path, drive, dir, fname, ext);
    458 
     457 
    459458  /* drive includes :
    460459     directory includes leading and trailing (forward and backward slashes)
     
    520519{
    521520  // _makepath(path, drive, dir, fname, ext);
    522 
     521 
    523522    char ch;
    524523    TRACE("CRTDLL__makepath got %s %s %s %s\n", drive, directory,
     
    568567{
    569568  // return (_errno());
    570 
     569 
    571570  return &CRTDLL_errno;
    572571}
     
    575574/*********************************************************************
    576575 *                  __doserrno       (CRTDLL.26)
    577  *
     576 * 
    578577 * Return the address of the DOS errno (holding the last OS error).
    579578 * @@@PH Note: veeeery strange ...
     
    584583{
    585584  // return (__doserrno());
    586 
     585 
    587586  return &CRTDLL_doserrno;
    588587}
     
    602601{
    603602  // return (_strerror((char*)s));
    604 
     603 
    605604  static char strerrbuff[256];
    606605  sprintf(strerrbuff,"%s: %s\n",err,CRTDLL_strerror(CRTDLL_errno));
     
    617616{
    618617  // perror( s );
    619 
     618 
    620619  char *err_str = CRTDLL_strerror(CRTDLL_errno);
    621620  CRTDLL_fprintf(CRTDLL_stderr,"%s: %s\n",err,err_str);
    622621  CRTDLL_free(err_str);
    623622}
    624 
     623 
    625624
    626625/*********************************************************************
     
    632631 * The caller does not own the string returned.
    633632 */
    634 extern char *strerror(int errnum);
     633extern char *strerror(int errnum); 
    635634
    636635LPSTR CDECL CRTDLL_strerror (INT err)
     
    646645{
    647646  //return (signal(sig, ptr));
    648 
     647 
    649648  FIXME("(%d %p):stub.\n", sig, ptr);
    650649  return (void*)-1;
     
    668667{
    669668  // return (getenv(name));
    670 
     669 
    671670     LPSTR environ = GetEnvironmentStringsA();
    672671     LPSTR pp,pos = NULL;
     
    675674     for (pp = environ; (*pp); pp = pp + strlen(pp) +1)
    676675       {
    677     pos =strchr(pp,'=');
    678     if (pos)
    679        length = pos -pp;
    680     else
    681        length = strlen(pp);
    682     if (!strncmp(pp,name,length)) break;
     676        pos =strchr(pp,'=');
     677        if (pos)
     678           length = pos -pp;
     679        else
     680           length = strlen(pp);
     681        if (!strncmp(pp,name,length)) break;
    683682       }
    684      if ((pp)&& (pos))
     683     if ((pp)&& (pos)) 
    685684       {
    686     pp = pos+1;
    687     TRACE("got %s\n",pp);
     685        pp = pos+1;
     686        TRACE("got %s\n",pp);
    688687       }
    689688     FreeEnvironmentStringsA( environ );
     
    696695 */
    697696INT CDECL CRTDLL__except_handler2 (
    698     PEXCEPTION_RECORD rec,
    699     PEXCEPTION_FRAME frame,
    700     PCONTEXT context,
    701     PEXCEPTION_FRAME  *dispatcher)
    702 {
    703     FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
    704     rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
    705     frame->Handler, context, dispatcher);
    706     return ExceptionContinueSearch;
     697        PEXCEPTION_RECORD rec,
     698        PEXCEPTION_FRAME frame,
     699        PCONTEXT context,
     700        PEXCEPTION_FRAME  *dispatcher)
     701{
     702        FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
     703        rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
     704        frame->Handler, context, dispatcher);
     705        return ExceptionContinueSearch;
    707706}
    708707
     
    725724{
    726725  // return (_toascii(c));
    727 
     726 
    728727  return c & 0x7f;
    729728}
     
    755754{
    756755  // return (_iscsym(c));
    757 
     756 
    758757  return (isalnum(c) || c == '_');
    759758}
     
    774773{
    775774  // return (_iscsymf(c));
    776 
     775 
    777776  return (isalpha(c) || c == '_');
    778777}
     
    847846    {
    848847      if (cf((LPVOID*)match, (LPVOID*)pStart) == 0)
    849     return pStart; /* found */
     848        return pStart; /* found */
    850849      pStart += elem_size;
    851850    } while (--size);
     
    915914{
    916915  // return (_toupper(n));
    917 
     916 
    918917  return toupper(c);
    919918}
     
    926925{
    927926  // return (_tolower(n));
    928 
     927 
    929928  return tolower(c);
    930929}
     
    947946{
    948947  // return (_cabs(c));
    949 
     948 
    950949  return sqrt(c.real * c.real + c.imaginary * c.imaginary);
    951950}
     
    10071006 *
    10081007 * Reset the state of the floating point processor.
    1009  *
     1008 * 
    10101009 * PARAMS
    10111010 *   None.
  • trunk/src/crtdll/dir.c

    r6645 r6712  
    1 /* $Id: dir.c,v 1.5 2001-09-05 12:14:24 bird Exp $ */
    21/*
    32 * CRTDLL drive/directory functions
    4  *
     3 * 
    54 * Copyright 1996,1998 Marcus Meissner
    65 * Copyright 1996 Jukka Iivonen
     
    5857 * RETURNS
    5958 * Sucess:  0
    60  *
     59 * 
    6160 * Failure: -1
    6261 */
     
    6564  dprintf(("CRTDLL: _chdir(%s)\n",
    6665          newdir));
    67 
     66 
    6867  if (!SetCurrentDirectoryA(newdir))
    6968  {
     
    8584 * RETURNS
    8685 * Sucess:  0
    87  *
    88  * Failure: 1
     86 * 
     87 * Failure: 1 
    8988 */
    9089BOOL CDECL CRTDLL__chdrive(INT newdrive)
     
    9291  char buffer[3] = "A:";
    9392  buffer[0] += newdrive - 1;
    94 
     93 
    9594  dprintf(("CRTDLL: _chdrive(%s)\n",
    9695          buffer));
    97 
     96 
    9897  if (!SetCurrentDirectoryA( buffer ))
    9998  {
     
    109108/*********************************************************************
    110109 *                  _findclose     (CRTDLL.098)
    111  *
     110 * 
    112111 * Free the resources from a search handle created from _findfirst.
    113112 *
     
    124123  dprintf(("CRTDLL: _findclose(%08xh)\n",
    125124          hand));
    126 
     125 
    127126  if (!FindClose((HANDLE)hand))
    128127  {
     
    142141 * PARAMS
    143142 *   fspec [in]  File specification string for search, e.g "C:\*.BAT"
    144  *
     143 * 
    145144 *   ft [out]    A pointer to a find_t structure to populate.
    146145 *
     
    156155  WIN32_FIND_DATAA find_data;
    157156  HANDLE hfind;
    158 
     157 
    159158  dprintf(("CRTDLL: _findfirst(%s)\n",
    160159          fspec));
     
    174173/*********************************************************************
    175174 *                  _findnext     (CRTDLL.100)
    176  *
     175 * 
    177176 * Return the next matching file/directory from a search hadle.
    178177 *
    179178 * PARAMS
    180179 *   hand [in] Search handle from a pervious call to _findfirst
    181  *
     180 * 
    182181 *   ft [out]  A pointer to a find_t structure to populate.
    183182 *
     
    191190{
    192191  WIN32_FIND_DATAA find_data;
    193 
     192 
    194193  dprintf(("CRTDLL: _findnext(%08xh)\n",
    195194          hand));
    196 
     195 
    197196  if (!FindNextFileA(hand, &find_data))
    198197  {
     
    225224{
    226225  // return (_getcwd(buf, size));
    227 
     226 
    228227  char dir[_MAX_PATH];
    229228  int dir_len = GetCurrentDirectoryA(_MAX_PATH,dir);
    230 
     229 
    231230  dprintf(("CRTDLL: _getcwd()\n"));
    232 
     231 
    233232  if (dir_len < 1)
    234233    return NULL; /* FIXME: Real return value untested */
     
    259258{
    260259  // return (_getdcwd(drive, buffer, maxlen));
    261 
     260 
    262261  static CHAR* dummy;
    263 
     262 
    264263  dprintf(("CRTDLL: _getdcwd()\n"));
    265 
     264 
    266265  if (!drive || drive == CRTDLL__getdrive())
    267266    return CRTDLL__getcwd(buf,size); /* current */
     
    306305  DWORD ret[4];
    307306  UINT err;
    308 
     307 
    309308  dprintf(("CRTDLL: _getdiskfree(%08xh)\n", disk));
    310 
     309 
    311310  if (disk > 26)
    312311    return ERROR_INVALID_PARAMETER; /* CRTDLL doesn't set errno here */
     
    336335{
    337336  // return DRIVE_GetCurrentDrive() + 1;
    338 
     337 
    339338  char buffer[MAX_PATH];
    340 
     339 
    341340  dprintf(("CRTDLL: _getdrive()\n"));
    342341
    343   if (!GetCurrentDirectoryA( sizeof(buffer), buffer ))
    344     return 0;
    345   if (buffer[1] != ':')
     342  if (!GetCurrentDirectoryA( sizeof(buffer), buffer )) 
     343    return 0;
     344  if (buffer[1] != ':') 
    346345    return 0;
    347346  return toupper(buffer[0]) - 'A' + 1;
     
    358357  dprintf(("CRTDLL: _mkdir(%s)\n",
    359358          newdir));
    360 
     359 
    361360  if (CreateDirectoryA(newdir,NULL))
    362361    return 0;
     
    369368 *                  _rmdir           (CRTDLL.255)
    370369 *
    371  * Delete a directory
     370 * Delete a directory 
    372371 *
    373372 */
     
    376375  dprintf(("CRTDLL: _rmdir(%s)\n",
    377376          dir));
    378 
     377 
    379378  if (RemoveDirectoryA(dir))
    380379    return 0;
  • trunk/src/crtdll/exit.c

    r6645 r6712  
    1 /* $Id: exit.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */
    21/*
    32 * CRTDLL exit/abort/atexit functions
    4  *
     3 * 
    54 * Copyright 1996,1998 Marcus Meissner
    65 * Copyright 1996 Jukka Iivonen
     
    1110 * and whether they return to the caller (really!).
    1211 *            return      do
    13  *  Name      to caller?  cleanup?
     12 *  Name      to caller?  cleanup? 
    1413 *  _c_exit     Y           N
    1514 *  _cexit      Y           Y
     
    5554
    5655/*********************************************************************
    57  *  __dllonexit                     (CRTDLL.25)
     56 *      __dllonexit                             (CRTDLL.25)
    5857 */
    5958VOID CDECL CRTDLL___dllonexit ()
    60 {
     59{       
    6160  dprintf(("__dllonexit not implemented.\n"));
    6261  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     
    6564
    6665/*********************************************************************
    67  *  _abnormal_termination           (CRTDLL.36)
     66 *      _abnormal_termination                   (CRTDLL.36)
    6867 */
    6968int CDECL CRTDLL__abnormal_termination(void)
     
    8483{
    8584  dprintf2(("CRTDLL: _amsg_exit\n"));
    86 
     85 
    8786  // fprintf(stderr,strerror(errnum));
    8887  // ExitProcess(-1);
    89 
     88 
    9089  CRTDLL_fprintf(CRTDLL_stderr,"\nrun-time error:\nError Code %d\n",errnum);
    9190  CRTDLL__exit(255);
     
    9695 *                  _assert     (CRTDLL.041)
    9796 *
    98  * Print an assertion message and call abort(). Really only present
     97 * Print an assertion message and call abort(). Really only present 
    9998 * for win binaries. Winelib programs would typically use libc's
    10099 * version.
     
    103102{
    104103  dprintf2(("CRTDLL: _assert\n"));
    105 
     104 
    106105  CRTDLL_fprintf(CRTDLL_stderr,"Assertion failed: %s, file %s, line %d\n\n",
    107106                 (char*)str,(char*)file, line);
    108107  CRTDLL_abort();
    109 
     108 
    110109  // _assert(str, file, line);
    111110}
     
    120119  dprintf2(("_c_exit(%d)\n",ret));
    121120  FIXME("not calling CRTDLL cleanup\n");
    122 
     121 
    123122  /* dont exit, return to caller */
    124 
     123 
    125124  ExitProcess(ret);
    126125}
     
    136135  FIXME("not calling CRTDLL cleanup\n");
    137136  /* dont exit, return to caller */
    138 
     137 
    139138  ExitProcess(ret);
    140139}
     
    146145VOID CDECL CRTDLL__exit(LONG ret)
    147146{
    148   dprintf2(("CRTDLL: _exit (%08xh)\n",
     147  dprintf2(("CRTDLL: _exit (%08xh)\n", 
    149148            ret));
    150149  TRACE(":exit code %ld\n",ret);
     
    200199{
    201200  dprintf2(("CRTDLL: abort\n"));
    202 
     201 
    203202  CRTDLL_fprintf(CRTDLL_stderr,"\nabnormal program termination\n");
    204203  CRTDLL__exit(3);
     
    208207
    209208/*********************************************************************
    210  *                  atexit  (CRTDLL.342)
     209 *                  atexit      (CRTDLL.342)
    211210 *
    212211 * Register a function to be called when the process terminates.
     
    215214{
    216215  dprintf(("CRTDLL: atexit\n"));
    217 
     216 
    218217  return CRTDLL__onexit(func) == func ? 0 : -1;
    219 
     218 
    220219  // if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0]))
    221220  //   return -1;
  • trunk/src/crtdll/file.c

    r6645 r6712  
    1 /* $Id: file.c,v 1.3 2001-09-05 12:14:24 bird Exp $ */
    21/*
    32 * CRTDLL file functions
    4  *
     3 * 
    54 * Copyright 1996,1998 Marcus Meissner
    65 * Copyright 1996 Jukka Iivonen
     
    98 *
    109 * Implementation Notes:
    11  * Mapping is performed between FILE*, fd and HANDLE's. This allows us to
    12  * implement all calls using the Win32 API, support remapping fd's to
     10 * Mapping is performed between FILE*, fd and HANDLE's. This allows us to 
     11 * implement all calls using the Win32 API, support remapping fd's to 
    1312 * FILES and do some other tricks as well (like closeall, _get_osfhandle).
    1413 * For mix and matching with the host libc, processes can use the Win32 HANDLE
     
    129128  else
    130129    while(__CRTDLL_fdstart < __CRTDLL_fdend &&
    131       __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)
     130          __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)
    132131      __CRTDLL_fdstart++;
    133132
     
    144143{
    145144  TRACE(":fd (%d) allocating FILE*\n",fd);
    146   if (fd < 0 || fd >= __CRTDLL_fdend ||
     145  if (fd < 0 || fd >= __CRTDLL_fdend || 
    147146      __CRTDLL_handles[fd] == INVALID_HANDLE_VALUE)
    148147  {
     
    179178
    180179  TRACE(":handles (%d)(%d)(%d)\n",__CRTDLL_handles[0],
    181     __CRTDLL_handles[1],__CRTDLL_handles[2]);
     180        __CRTDLL_handles[1],__CRTDLL_handles[2]);
    182181
    183182  for (i = 0; i < 3; i++)
     
    196195{
    197196  // return (_access(path, mode));
    198 
     197 
    199198  DWORD attr = GetFileAttributesA(filename);
    200199
     
    203202    if (!filename)
    204203    {
    205     /* FIXME: Should GetFileAttributesA() return this? */
     204        /* FIXME: Should GetFileAttributesA() return this? */
    206205      __CRTDLL__set_errno(ERROR_INVALID_DATA);
    207206      return -1;
     
    304303{
    305304  // return (__eof(_fd));
    306 
     305 
    307306  DWORD curpos,endpos;
    308307  HANDLE hand = __CRTDLL__fdtoh(fd);
     
    339338{
    340339  // return (_fcloseall());
    341 
     340 
    342341  int num_closed = 0, i = 3;
    343342
     
    362361{
    363362  // return (_fdopen(handle, mode));
    364 
     363 
    365364  CRTDLL_FILE* file = __CRTDLL__alloc_fp(fd);
    366365
     
    379378{
    380379  // return (_fgetchar());
    381 
     380 
    382381  return CRTDLL_fgetc(CRTDLL_stdin);
    383382}
     
    391390 * becomes negative. We ensure that _cnt is always 0 after any read
    392391 * so this function is always called. Our implementation simply calls
    393  * fgetc as all the underlying buffering is handled by Wines
     392 * fgetc as all the underlying buffering is handled by Wines 
    394393 * implementation of the Win32 file I/O calls.
    395394 */
     
    411410{
    412411  // return (_fileno(f));
    413 
     412 
    414413  TRACE(":FILE* (%p) fd (%d)\n",file,file->_file);
    415414  return file->_file;
     
    441440{
    442441  // return (_flushall());
    443 
     442 
    444443  int num_flushed = 0, i = 3;
    445444
     
    448447    {
    449448      if (CRTDLL__commit(i) == -1)
    450     if (__CRTDLL_files[i])
    451       __CRTDLL_files[i]->_flag |= _IOERR;
     449        if (__CRTDLL_files[i])
     450          __CRTDLL_files[i]->_flag |= _IOERR;
    452451      num_flushed++;
    453452    }
     
    466465{
    467466  // return(_fputchar(c));
    468 
     467 
    469468  return CRTDLL_fputc(c, CRTDLL_stdout);
    470469}
     
    485484/*********************************************************************
    486485 *                  _fstat        (CRTDLL.111)
    487  *
     486 * 
    488487 * Get information about an open file.
    489488 */
     
    491490{
    492491  // return (_fstat(file, buf));
    493 
     492 
    494493  DWORD dw;
    495494  BY_HANDLE_FILE_INFORMATION hfi;
     
    549548  {
    550549    /* FIXME: I'm not convinced that I should be copying the
    551      * handle here - it may be leaked if the app doesn't
     550     * handle here - it may be leaked if the app doesn't 
    552551     * close it (and the API docs dont say that it should)
    553552     * Not duplicating it means that it can't be inherited
     
    558557     */
    559558    DuplicateHandle(GetCurrentProcess(),hand,GetCurrentProcess(),
    560             &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );
     559                    &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );
    561560  }
    562561  return newhand;
     
    589588{
    590589  // return (_lseek(handle, offset, origin));
    591 
     590 
    592591  LONG ret;
    593592  HANDLE hand = __CRTDLL__fdtoh(fd);
     
    778777{
    779778  // return (_setmode(fh, mode));
    780 
     779 
    781780  if (mode & _O_TEXT)
    782781    FIXME("fd (%d) mode (%d) TEXT not implemented\n",fd,mode);
     
    791790{
    792791  // return(_stat(s1, n));
    793 
     792 
    794793  DWORD dw;
    795794  WIN32_FILE_ATTRIBUTE_DATA hfi;
     
    827826    {
    828827      unsigned int ext = tolower(path[plen-1]) | (tolower(path[plen-2]) << 8)
    829     | (tolower(path[plen-3]) << 16);
     828        | (tolower(path[plen-3]) << 16);
    830829      if (ext == EXE || ext == BAT || ext == CMD || ext == COM)
    831     mode |= CRTDLL_S_IEXEC;
     830        mode |= CRTDLL_S_IEXEC;
    832831    }
    833832  }
     
    844843  buf->st_mtime = buf->st_ctime = dw;
    845844  TRACE("\n%d %d %d %d %d %d\n", buf->st_mode,buf->st_nlink,buf->st_size,
    846     buf->st_atime,buf->st_mtime, buf->st_ctime);
     845        buf->st_atime,buf->st_mtime, buf->st_ctime);
    847846  return 0;
    848847}
     
    857856{
    858857  // return (_tell(i));
    859 
     858 
    860859  return CRTDLL__lseek(fd, 0, SEEK_CUR);
    861860}
     
    864863/*********************************************************************
    865864 *                  _tempnam           (CRTDLL.305)
    866  *
     865 * 
    867866 */
    868867LPSTR CDECL CRTDLL__tempnam(LPCSTR dir, LPCSTR prefix)
    869868{
    870869  // return (_tempnam(dir, prefix));
    871 
     870 
    872871  char tmpbuf[MAX_PATH];
    873872
     
    891890{
    892891  // return (_umask(i));
    893 
     892 
    894893  INT old_umask = __CRTDLL_umask;
    895894  TRACE("umask (%d)\n",umask);
     
    977976{
    978977  // return (fclose(fp));
    979 
     978 
    980979  return CRTDLL__close(file->_file);
    981980}
     
    990989{
    991990  // return (feof(fp));
    992 
     991 
    993992  return file->_flag & _IOEOF;
    994993}
     
    10031002{
    10041003  // return (ferror(fp));
    1005 
     1004 
    10061005  return file->_flag & _IOERR;
    10071006}
     
    10251024{
    10261025  // return (fgetc(fp));
    1027 
     1026 
    10281027  char c;
    10291028  if (CRTDLL__read(file->_file,&c,1) != 1)
     
    10511050{
    10521051  // return (fgets(s, n, fp));
    1053 
     1052 
    10541053  int    cc;
    10551054  LPSTR  buf_start = s;
    10561055
    10571056  TRACE(":file(%p) fd (%d) str (%p) len (%d)\n",
    1058     file,file->_file,s,size);
     1057        file,file->_file,s,size);
    10591058
    10601059  /* BAD, for the whole WINE process blocks... just done this way to test
     
    10891088{
    10901089  // return (fputs(s, fp));
    1091 
     1090 
    10921091  return CRTDLL_fwrite(s,strlen(s),1,file);
    10931092}
     
    11001099{
    11011100    // return (fprintf(file, format, arg));
    1102 
     1101 
    11031102    va_list valist;
    11041103    INT res;
     
    11191118{
    11201119  // return (fopen( filename, mode));
    1121 
     1120 
    11221121  CRTDLL_FILE* file;
    11231122  INT flags = 0, plus = 0, fd;
     
    11831182{
    11841183  // return (fputc(c, fp));
    1185 
     1184 
    11861185  return CRTDLL__write(file->_file, &c, 1) == 1? c : EOF;
    11871186}
     
    11941193{
    11951194  // return (fread(ptr, size, n, fp));
    1196 
     1195 
    11971196  DWORD read = CRTDLL__read(file->_file,ptr, size * nmemb);
    11981197  if (read <= 0)
     
    12041203/*********************************************************************
    12051204 *                  freopen    (CRTDLL.379)
    1206  *
     1205 * 
    12071206 */
    12081207CRTDLL_FILE* CDECL CRTDLL_freopen(LPCSTR path, LPCSTR mode,CRTDLL_FILE* file)
    12091208{
    12101209  // return (freopen(filename, mode, fp));
    1211 
     1210 
    12121211  CRTDLL_FILE* newfile;
    12131212  INT fd;
     
    12571256{
    12581257  // return (fsetpos(fp, pos));
    1259 
     1258 
    12601259  return CRTDLL__lseek(file->_file,*pos,SEEK_SET);
    12611260}
     
    13931392{
    13941393  // return (fseek(file, offset, whence));
    1395 
     1394 
    13961395  return CRTDLL__lseek(file->_file,offset,whence);
    13971396}
     
    14041403{
    14051404  // return (ftell(fp));
    1406 
     1405 
    14071406  return CRTDLL__tell(file->_file);
    14081407}
     
    14291428{
    14301429  // return (getchar());
    1431 
     1430 
    14321431  return CRTDLL_fgetc(CRTDLL_stdin);
    14331432}
     
    14601459     */
    14611460    for(cc = CRTDLL_fgetc(CRTDLL_stdin); cc != EOF && cc != '\n';
    1462     cc = CRTDLL_fgetc(CRTDLL_stdin))
    1463     if(cc != '\r') *buf++ = (char)cc;
     1461        cc = CRTDLL_fgetc(CRTDLL_stdin))
     1462        if(cc != '\r') *buf++ = (char)cc;
    14641463
    14651464    *buf = '\0';
     
    14981497{
    14991498  // return puts( s );
    1500 
     1499 
    15011500  return CRTDLL_fputs(s, CRTDLL_stdout);
    15021501}
     
    15121511{
    15131512  // rewind(fp);
    1514 
     1513 
    15151514  TRACE(":file (%p) fd (%d)\n",file,file->_file);
    15161515  CRTDLL__lseek(file->_file,0,SEEK_SET);
     
    15251524{
    15261525  // return (remove(file));
    1527 
     1526 
    15281527  TRACE(":path (%s)\n",path);
    15291528  if (DeleteFileA(path))
     
    15411540{
    15421541  // return (rename(old, new2));
    1543 
     1542 
    15441543  TRACE(":from %s to %s\n",oldpath,newpath);
    15451544  if (MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
     
    15571556{
    15581557  // setbuf(fp, buf);
    1559 
     1558 
    15601559  TRACE(":file (%p) fd (%d) buf (%p)\n", file, file->_file,buf);
    15611560  if (buf)
     
    15701569 *
    15711570 * lcclnk from lcc-win32 relies on a terminating dot in the name returned
    1572  *
     1571 * 
    15731572 */
    15741573LPSTR CDECL CRTDLL_tmpnam(LPSTR s)
    15751574{
    15761575  // return (tmpnam(s));
    1577 
     1576 
    15781577  char tmpbuf[MAX_PATH];
    15791578  char* prefix = "TMP";
     
    16001599{
    16011600  // return (vfprintf(file, format, args));
    1602 
     1601 
    16031602  /* FIXME: We should parse the format string, calculate the maximum,
    16041603   * length of each arg, malloc a buffer, print to it, and fwrite that.
  • trunk/src/crtdll/initterm.cpp

    r6645 r6712  
    1 /* $Id: initterm.cpp,v 1.7 2001-09-05 12:14:25 bird Exp $ */
    21/*
    32 * DLL entry point
     
    5655   case DLL_THREAD_ATTACH:
    5756   case DLL_THREAD_DETACH:
    58     return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
     57        return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
    5958
    6059   case DLL_PROCESS_DETACH:
    61     CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
    62     ctordtorTerm();
    63     return TRUE;
     60        CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
     61        ctordtorTerm();
     62        return TRUE;
    6463   }
    6564   return FALSE;
     
    9190         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9291
    93     dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
    94          if(dllHandle == 0)
    95         return 0UL;
     92//      dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     93//         if(dllHandle == 0)
     94//              return 0UL;
    9695
    9796         break;
    9897      case 1 :
    99          if(dllHandle) {
    100         UnregisterLxDll(dllHandle);
    101          }
     98//         if(dllHandle) {
     99//              UnregisterLxDll(dllHandle);
     100//         }
    102101         break;
    103102
  • trunk/src/crtdll/memory.c

    r6645 r6712  
    1 /* $Id: memory.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */
    21/*
    32 * CRTDLL memory functions
    4  *
     3 * 
    54 * Copyright 1996,1998 Marcus Meissner
    65 * Copyright 1996 Jukka Iivonen
     
    3332    VOID* result;
    3433    if(!(result = HeapAlloc(GetProcessHeap(),0,size)) && new_handler)
    35     (*new_handler)();
     34        (*new_handler)();
    3635    return result;
    3736}
     
    8079{
    8180  // return (_heapchk());
    82 
     81 
    8382  if (!HeapValidate( GetProcessHeap(), 0, NULL))
    8483  {
     
    9897{
    9998  // return (_heapmin());
    100 
     99 
    101100  if (!HeapCompact( GetProcessHeap(), 0 ))
    102101  {
     
    117116{
    118117  // return (_heapset(fill));
    119 
     118 
    120119  INT retVal;
    121120  struct _heapinfo heap;
     
    145144  phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
    146145
    147   if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
     146  if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && 
    148147      !HeapValidate( GetProcessHeap(), 0, phe.lpData ))
    149148  {
     
    181180{
    182181  // return (_msize(ptr));
    183 
     182 
    184183  LONG size = HeapSize(GetProcessHeap(),0,mem);
    185184  if (size == -1)
     
    216215/*********************************************************************
    217216 *                  malloc        (CRTDLL.424)
    218  *
     217 * 
    219218 * Alocate memory from the heap.
    220219 */
  • trunk/src/crtdll/spawn.c

    r6645 r6712  
    1 /* $Id: spawn.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */
    21/*
    32 * CRTDLL spawn functions
    4  *
     3 * 
    54 * Copyright 1996,1998 Marcus Meissner
    65 * Copyright 1996 Jukka Iivonen
     
    2524 * Implementation Notes:
    2625 * MT Safe - But only because of missing functionality.
    27  *
     26 * 
    2827 * After translating input arguments into the required format for
    2928 * CreateProcess(), the internal function __CRTDLL__spawn() is
     
    8382
    8483  if (!CreateProcessA(exe, args, NULL, NULL, TRUE,
    85               flags == _P_DETACH ? DETACHED_PROCESS : 0,
    86               env, NULL, &si, &pi))
     84                      flags == _P_DETACH ? DETACHED_PROCESS : 0,
     85                      env, NULL, &si, &pi))
    8786  {
    8887    __CRTDLL__set_errno(GetLastError());
     
    158157{
    159158  // return (_spawnve(i, s1, s2, s3));
    160 
     159 
    161160  LPSTR args = __CRTDLL__argvtos(argv,' ');
    162161  LPSTR envs = __CRTDLL__argvtos(envv,0);
     
    187186{
    188187  // return system(string);
    189 
     188 
    190189    /* FIXME: should probably launch cmd interpreter in COMSPEC */
    191190    return __CRTDLL__spawn(_P_WAIT, NULL, x, NULL);
  • trunk/src/msacm32/driver.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: driver.c,v 1.2 2001-09-05 13:11:25 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
    55 *
    66 *      Copyright 1998  Patrik Stridvall
    7  *        1999  Eric Pouech
     7 *                1999  Eric Pouech
    88 */
    99
     
    2929
    3030DEFAULT_DEBUG_CHANNEL(msacm);
    31 
     31       
    3232/***********************************************************************
    3333 *           acmDriverAddA (MSACM32.2)
    3434 */
    3535MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
    36                   LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
     36                              LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
    3737{
    3838    if (!phadid)
    39     return MMSYSERR_INVALPARAM;
    40 
     39        return MMSYSERR_INVALPARAM;
     40   
    4141    /* Check if any unknown flags */
    42     if (fdwAdd &
    43     ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
    44       ACM_DRIVERADDF_GLOBAL))
    45     return MMSYSERR_INVALFLAG;
    46 
     42    if (fdwAdd & 
     43        ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
     44          ACM_DRIVERADDF_GLOBAL))
     45        return MMSYSERR_INVALFLAG;
     46   
    4747    /* Check if any incompatible flags */
    48     if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
    49     (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
    50     return MMSYSERR_INVALFLAG;
    51 
    52     /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
     48    if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) && 
     49        (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
     50        return MMSYSERR_INVALFLAG;
     51   
     52    /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a 
    5353     * LoadDriver on it, to be sure we can call SendDriverMessage on the
    5454     * hDrvr handle.
    5555     */
    5656    *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule);
    57 
     57   
    5858    /* FIXME: lParam, dwPriority and fdwAdd ignored */
    59 
     59   
    6060    return MMSYSERR_NOERROR;
    6161}
     
    6767 */
    6868MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule,
    69                   LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
     69                              LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
    7070{
    7171    FIXME("(%p, 0x%08x, %ld, %ld, %ld): stub\n",
    72       phadid, hinstModule, lParam, dwPriority, fdwAdd);
    73 
     72          phadid, hinstModule, lParam, dwPriority, fdwAdd);
     73   
    7474    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    7575    return MMSYSERR_ERROR;
     
    8181MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
    8282{
    83     PWINE_ACMDRIVER pad;
    84     PWINE_ACMDRIVERID   padid;
    85     PWINE_ACMDRIVER*    tpad;
     83    PWINE_ACMDRIVER     pad;
     84    PWINE_ACMDRIVERID   padid;
     85    PWINE_ACMDRIVER*    tpad;
    8686
    8787    if (fdwClose)
    88     return MMSYSERR_INVALFLAG;
    89 
     88        return MMSYSERR_INVALFLAG;
     89   
    9090    pad = MSACM_GetDriver(had);
    9191    if (!pad)
    92     return MMSYSERR_INVALHANDLE;
     92        return MMSYSERR_INVALHANDLE;
    9393
    9494    padid = pad->obj.pACMDriverID;
     
    9696    /* remove driver from list */
    9797    for (tpad = &(padid->pACMDriverList); *tpad; *tpad = (*tpad)->pNextACMDriver) {
    98     if (*tpad == pad) {
    99         *tpad = (*tpad)->pNextACMDriver;
    100         break;
    101     }
    102     }
    103 
     98        if (*tpad == pad) {
     99            *tpad = (*tpad)->pNextACMDriver;
     100            break;
     101        }
     102    }
     103   
    104104    /* close driver if it has been opened */
    105105    if (pad->hDrvr && !padid->hInstModule)
    106     CloseDriver(pad->hDrvr, 0, 0);
    107 
     106        CloseDriver(pad->hDrvr, 0, 0);
     107   
    108108    HeapFree(MSACM_hHeap, 0, pad);
    109 
     109   
    110110    return MMSYSERR_NOERROR;
    111111}
     
    117117{
    118118    MMRESULT mmr;
    119     ACMDRIVERDETAILSW   addw;
    120 
     119    ACMDRIVERDETAILSW   addw;
     120   
    121121    addw.cbStruct = sizeof(addw);
    122122    mmr = acmDriverDetailsW(hadid, &addw, fdwDetails);
    123123    if (mmr == 0) {
    124     padd->fccType = addw.fccType;
    125     padd->fccComp = addw.fccComp;
    126     padd->wMid = addw.wMid;
    127     padd->wPid = addw.wPid;
    128     padd->vdwACM = addw.vdwACM;
    129     padd->vdwDriver = addw.vdwDriver;
    130     padd->fdwSupport = addw.fdwSupport;
    131     padd->cFormatTags = addw.cFormatTags;
    132     padd->cFilterTags = addw.cFilterTags;
    133     padd->hicon = addw.hicon;
     124        padd->fccType = addw.fccType;
     125        padd->fccComp = addw.fccComp;
     126        padd->wMid = addw.wMid;
     127        padd->wPid = addw.wPid;
     128        padd->vdwACM = addw.vdwACM;
     129        padd->vdwDriver = addw.vdwDriver;
     130        padd->fdwSupport = addw.fdwSupport;
     131        padd->cFormatTags = addw.cFormatTags;
     132        padd->cFilterTags = addw.cFilterTags;
     133        padd->hicon = addw.hicon;
    134134        WideCharToMultiByte( CP_ACP, 0, addw.szShortName, -1, padd->szShortName,
    135135                             sizeof(padd->szShortName), NULL, NULL );
     
    153153    HACMDRIVER acmDrvr;
    154154    MMRESULT mmr;
    155 
     155   
    156156    if (fdwDetails)
    157     return MMSYSERR_INVALFLAG;
    158 
     157        return MMSYSERR_INVALFLAG;
     158   
    159159    mmr = acmDriverOpen(&acmDrvr, hadid, 0);
    160160    if (mmr == MMSYSERR_NOERROR) {
    161     mmr = (MMRESULT)MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)padd,  0);
    162 
    163     acmDriverClose(acmDrvr, 0);
    164     }
    165 
     161        mmr = (MMRESULT)MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)padd,  0);
     162   
     163        acmDriverClose(acmDrvr, 0);
     164    }
     165   
    166166    return mmr;
    167167}
     
    172172MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
    173173{
    174     PWINE_ACMDRIVERID   p;
    175     ACMDRIVERDETAILSW   add;
     174    PWINE_ACMDRIVERID   p;
     175    ACMDRIVERDETAILSW   add;
    176176
    177177    if (!fnCallback) return MMSYSERR_INVALPARAM;
    178 
     178   
    179179    if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED))
    180     return MMSYSERR_INVALFLAG;
    181 
     180        return MMSYSERR_INVALFLAG;
     181   
    182182    add.cbStruct = sizeof(add);
    183183    for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
    184     if (acmDriverDetailsW((HACMDRIVERID)p, &add, 0) != MMSYSERR_NOERROR)
    185         continue;
    186     if (!p->bEnabled) {
    187         if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
    188         add.fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
    189         else
    190         continue;
    191     }
    192     if (!(*fnCallback)((HACMDRIVERID)p, dwInstance, add.fdwSupport))
    193         break;
    194     }
    195 
     184        if (acmDriverDetailsW((HACMDRIVERID)p, &add, 0) != MMSYSERR_NOERROR)
     185            continue;
     186        if (!p->bEnabled) {
     187            if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
     188                add.fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
     189            else
     190                continue;
     191        }
     192        if (!(*fnCallback)((HACMDRIVERID)p, dwInstance, add.fdwSupport))
     193            break;
     194    }
     195   
    196196    return MMSYSERR_NOERROR;
    197197}
     
    203203{
    204204    PWINE_ACMOBJ pao;
    205 
     205   
    206206    if (!phadid)
    207     return MMSYSERR_INVALPARAM;
    208 
     207        return MMSYSERR_INVALPARAM;
     208   
    209209    if (fdwDriverID)
    210     return MMSYSERR_INVALFLAG;
    211 
     210        return MMSYSERR_INVALFLAG;
     211   
    212212    pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
    213213    if (!pao)
    214     return MMSYSERR_INVALHANDLE;
    215 
     214        return MMSYSERR_INVALHANDLE;
     215   
    216216    *phadid = (HACMDRIVERID) pao->pACMDriverID;
    217 
     217   
    218218    return MMSYSERR_NOERROR;
    219219}
     
    226226{
    227227    if ((uMsg >= ACMDM_USER && uMsg < ACMDM_RESERVED_LOW) ||
    228     uMsg == ACMDM_DRIVER_ABOUT ||
    229     uMsg == DRV_QUERYCONFIGURE ||
    230     uMsg == DRV_CONFIGURE)
    231     return MSACM_Message(had, uMsg, lParam1, lParam2);
     228        uMsg == ACMDM_DRIVER_ABOUT ||
     229        uMsg == DRV_QUERYCONFIGURE ||
     230        uMsg == DRV_CONFIGURE)
     231        return MSACM_Message(had, uMsg, lParam1, lParam2);
    232232    return MMSYSERR_INVALPARAM;
    233233}
     
    239239MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
    240240{
    241     PWINE_ACMDRIVERID   padid;
    242     PWINE_ACMDRIVER pad;
     241    PWINE_ACMDRIVERID   padid;
     242    PWINE_ACMDRIVER     pad;
    243243
    244244    TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
    245245
    246246    if (!phad)
    247     return MMSYSERR_INVALPARAM;
    248 
     247        return MMSYSERR_INVALPARAM;
     248   
    249249    if (fdwOpen)
    250     return MMSYSERR_INVALFLAG;
    251 
    252     padid = MSACM_GetDriverID(hadid);
     250        return MMSYSERR_INVALFLAG;
     251   
     252    padid = MSACM_GetDriverID(hadid); 
    253253    if (!padid)
    254     return MMSYSERR_INVALHANDLE;
    255 
     254        return MMSYSERR_INVALHANDLE;
     255   
    256256    pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
    257257    if (!pad) return MMSYSERR_NOMEM;
     
    259259    pad->obj.dwType = WINE_ACMOBJ_DRIVER;
    260260    pad->obj.pACMDriverID = padid;
    261 
     261   
    262262    if (!(pad->hDrvr = padid->hInstModule) && padid->pszDriverAlias)
    263     pad->hDrvr = OpenDriverA(padid->pszDriverAlias, NULL, 0);
     263        pad->hDrvr = OpenDriverA(padid->pszDriverAlias, NULL, 0);
    264264    if (!pad->hDrvr) {
    265     HeapFree(MSACM_hHeap, 0, pad);
    266     return MMSYSERR_ERROR;
     265        HeapFree(MSACM_hHeap, 0, pad);
     266        return MMSYSERR_ERROR;
    267267    }
    268268
     
    289289    HKEY hPriorityKey;
    290290    DWORD dwPriorityCounter;
    291 
     291   
    292292    padid = MSACM_GetDriverID(hadid);
    293293    if (!padid)
    294     return MMSYSERR_INVALHANDLE;
    295 
     294        return MMSYSERR_INVALHANDLE;
     295   
    296296    /* Check for unknown flags */
    297     if (fdwPriority &
    298     ~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE|
    299       ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END))
    300     return MMSYSERR_INVALFLAG;
    301 
     297    if (fdwPriority & 
     298        ~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE|
     299          ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END))
     300        return MMSYSERR_INVALFLAG;
     301   
    302302    /* Check for incompatible flags */
    303303    if ((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) &&
    304     (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE))
    305     return MMSYSERR_INVALFLAG;
    306 
     304        (fdwPriority & ACM_DRIVERPRIORITYF_DISABLE))
     305        return MMSYSERR_INVALFLAG;
     306   
    307307    /* Check for incompatible flags */
    308308    if ((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) &&
    309     (fdwPriority & ACM_DRIVERPRIORITYF_END))
    310     return MMSYSERR_INVALFLAG;
    311 
    312     lError = RegOpenKeyA(HKEY_CURRENT_USER,
    313             "Software\\Microsoft\\Multimedia\\"
    314             "Audio Compression Manager\\Priority v4.00",
    315             &hPriorityKey
    316             );
     309        (fdwPriority & ACM_DRIVERPRIORITYF_END))
     310        return MMSYSERR_INVALFLAG;
     311   
     312    lError = RegOpenKeyA(HKEY_CURRENT_USER, 
     313                        "Software\\Microsoft\\Multimedia\\"
     314                        "Audio Compression Manager\\Priority v4.00",
     315                        &hPriorityKey
     316                        );
    317317    /* FIXME: Create key */
    318318    if (lError != ERROR_SUCCESS)
     319        return MMSYSERR_ERROR;
     320   
     321    for (dwPriorityCounter = 1; ; dwPriorityCounter++)  {
     322        snprintf(szSubKey, 17, "Priorty%ld", dwPriorityCounter);
     323        lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);
     324        if (lError != ERROR_SUCCESS)
     325            break;
     326       
     327        FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
     328              hadid, dwPriority, fdwPriority);
     329        break;
     330    }
     331   
     332    RegCloseKey(hPriorityKey);
     333   
    319334    return MMSYSERR_ERROR;
    320 
    321     for (dwPriorityCounter = 1; ; dwPriorityCounter++)  {
    322     snprintf(szSubKey, 17, "Priorty%ld", dwPriorityCounter);
    323     lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);
    324     if (lError != ERROR_SUCCESS)
    325         break;
    326 
    327     FIXME("(0x%08x, %ld, %ld): stub (partial)\n",
    328           hadid, dwPriority, fdwPriority);
    329     break;
    330     }
    331 
    332     RegCloseKey(hPriorityKey);
    333 
    334     return MMSYSERR_ERROR;
    335335}
    336336
     
    341341{
    342342    PWINE_ACMDRIVERID padid;
    343 
     343   
    344344    padid = MSACM_GetDriverID(hadid);
    345345    if (!padid)
    346     return MMSYSERR_INVALHANDLE;
    347 
     346        return MMSYSERR_INVALHANDLE;
     347   
    348348    if (fdwRemove)
    349     return MMSYSERR_INVALFLAG;
    350 
     349        return MMSYSERR_INVALFLAG;
     350   
    351351    MSACM_UnregisterDriver(padid);
    352 
    353     return MMSYSERR_NOERROR;
    354 }
    355 
     352   
     353    return MMSYSERR_NOERROR;
     354}
     355
  • trunk/src/msacm32/filter.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: filter.c,v 1.2 2001-09-05 13:11:25 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
     
    4242 *           acmFilterDetailsA (MSACM32.15)
    4343 */
    44 MMRESULT WINAPI acmFilterDetailsA(HACMDRIVER had, PACMFILTERDETAILSA pafd,
    45                   DWORD fdwDetails)
    46 {
    47     ACMFILTERDETAILSW   afdw;
    48     MMRESULT        mmr;
     44MMRESULT WINAPI acmFilterDetailsA(HACMDRIVER had, PACMFILTERDETAILSA pafd, 
     45                                  DWORD fdwDetails)
     46{
     47    ACMFILTERDETAILSW   afdw;
     48    MMRESULT            mmr;
    4949
    5050    memset(&afdw, 0, sizeof(afdw));
    5151    afdw.cbStruct = sizeof(afdw);
    5252    afdw.dwFilterIndex = pafd->dwFilterIndex;
    53     afdw.dwFilterTag = pafd->dwFilterTag;
     53    afdw.dwFilterTag = pafd->dwFilterTag; 
    5454    afdw.pwfltr = pafd->pwfltr;
    5555    afdw.cbwfltr = pafd->cbwfltr;
     
    5757    mmr = acmFilterDetailsW(had, &afdw, fdwDetails);
    5858    if (mmr == MMSYSERR_NOERROR) {
    59     pafd->dwFilterTag = afdw.dwFilterTag;
    60     pafd->fdwSupport = afdw.fdwSupport;
     59        pafd->dwFilterTag = afdw.dwFilterTag;
     60        pafd->fdwSupport = afdw.fdwSupport;
    6161        WideCharToMultiByte( CP_ACP, 0, afdw.szFilter, -1, pafd->szFilter,
    6262                             sizeof(pafd->szFilter), NULL, NULL );
     
    6868 *           acmFilterDetailsW (MSACM32.16)
    6969 */
    70 MMRESULT WINAPI acmFilterDetailsW(HACMDRIVER had, PACMFILTERDETAILSW pafd,
    71                   DWORD fdwDetails)
    72 {
    73     MMRESULT            mmr;
    74     ACMFILTERTAGDETAILSA    aftd;
     70MMRESULT WINAPI acmFilterDetailsW(HACMDRIVER had, PACMFILTERDETAILSW pafd, 
     71                                  DWORD fdwDetails)
     72{
     73    MMRESULT                    mmr;
     74    ACMFILTERTAGDETAILSA        aftd;
    7575
    7676    TRACE("(0x%08x, %p, %ld)\n", had, pafd, fdwDetails);
     
    8080
    8181    if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
    82 
     82       
    8383    switch (fdwDetails) {
    8484    case ACM_FILTERDETAILSF_FILTER:
    85     if (pafd->dwFilterTag != pafd->pwfltr->dwFilterTag) {
    86         mmr = MMSYSERR_INVALPARAM;
    87         break;
    88     }
    89     if (had == (HACMDRIVER)NULL) {
    90         PWINE_ACMDRIVERID       padid;
    91 
    92         mmr = ACMERR_NOTPOSSIBLE;
    93         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    94         /* should check for codec only */
    95         if (padid->bEnabled &&
    96             acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
    97             mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
    98                     (LPARAM)pafd, (LPARAM)fdwDetails);
    99             acmDriverClose(had, 0);
    100             if (mmr == MMSYSERR_NOERROR) break;
    101         }
    102         }
    103     } else {
    104         mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
    105                 (LPARAM)pafd, (LPARAM)fdwDetails);
    106     }
    107     break;
     85        if (pafd->dwFilterTag != pafd->pwfltr->dwFilterTag) {
     86            mmr = MMSYSERR_INVALPARAM;
     87            break;
     88        }
     89        if (had == (HACMDRIVER)NULL) {
     90            PWINE_ACMDRIVERID           padid;
     91
     92            mmr = ACMERR_NOTPOSSIBLE;
     93            for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     94                /* should check for codec only */
     95                if (padid->bEnabled &&
     96                    acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
     97                    mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
     98                                        (LPARAM)pafd, (LPARAM)fdwDetails);
     99                    acmDriverClose(had, 0);
     100                    if (mmr == MMSYSERR_NOERROR) break;
     101                }
     102            }               
     103        } else {
     104            mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
     105                                (LPARAM)pafd, (LPARAM)fdwDetails);
     106        }
     107        break;
    108108    case ACM_FILTERDETAILSF_INDEX:
    109     /* should check pafd->dwFilterIndex < aftd->cStandardFilters */
    110     mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
    111                 (LPARAM)pafd, (LPARAM)fdwDetails);
    112     break;
     109        /* should check pafd->dwFilterIndex < aftd->cStandardFilters */
     110        mmr = MSACM_Message(had, ACMDM_FILTER_DETAILS,
     111                            (LPARAM)pafd, (LPARAM)fdwDetails);
     112        break;
    113113    default:
    114     WARN("Unknown fdwDetails %08lx\n", fdwDetails);
    115     mmr = MMSYSERR_INVALFLAG;
    116     break;
     114        WARN("Unknown fdwDetails %08lx\n", fdwDetails);
     115        mmr = MMSYSERR_INVALFLAG;
     116        break;
    117117    }
    118118
     
    122122
    123123struct MSACM_FilterEnumWtoA_Instance {
    124     PACMFILTERDETAILSA  pafda;
    125     DWORD       dwInstance;
    126     ACMFILTERENUMCBA    fnCallback;
     124    PACMFILTERDETAILSA  pafda;
     125    DWORD               dwInstance;
     126    ACMFILTERENUMCBA    fnCallback;
    127127};
    128128
    129129static BOOL CALLBACK MSACM_FilterEnumCallbackWtoA(HACMDRIVERID hadid,
    130                           PACMFILTERDETAILSW pafdw,
    131                           DWORD dwInstance,
    132                           DWORD fdwSupport)
     130                                                  PACMFILTERDETAILSW pafdw, 
     131                                                  DWORD dwInstance,             
     132                                                  DWORD fdwSupport)
    133133{
    134134    struct MSACM_FilterEnumWtoA_Instance* pafei;
     
    136136    pafei = (struct MSACM_FilterEnumWtoA_Instance*)dwInstance;
    137137
    138     pafei->pafda->dwFilterIndex = pafdw->dwFilterIndex;
    139     pafei->pafda->dwFilterTag = pafdw->dwFilterTag;
    140     pafei->pafda->fdwSupport = pafdw->fdwSupport;
     138    pafei->pafda->dwFilterIndex = pafdw->dwFilterIndex; 
     139    pafei->pafda->dwFilterTag = pafdw->dwFilterTag; 
     140    pafei->pafda->fdwSupport = pafdw->fdwSupport; 
    141141    WideCharToMultiByte( CP_ACP, 0, pafdw->szFilter, -1, pafei->pafda->szFilter,
    142142                         sizeof(pafei->pafda->szFilter), NULL, NULL );
    143143
    144     return (pafei->fnCallback)(hadid, pafei->pafda,
    145                    pafei->dwInstance, fdwSupport);
     144    return (pafei->fnCallback)(hadid, pafei->pafda, 
     145                               pafei->dwInstance, fdwSupport);
    146146}
    147147
     
    149149 *           acmFilterEnumA (MSACM32.17)
    150150 */
    151 MMRESULT WINAPI acmFilterEnumA(HACMDRIVER had, PACMFILTERDETAILSA pafda,
    152                    ACMFILTERENUMCBA fnCallback, DWORD dwInstance,
    153                    DWORD fdwEnum)
    154 {
    155     ACMFILTERDETAILSW       afdw;
     151MMRESULT WINAPI acmFilterEnumA(HACMDRIVER had, PACMFILTERDETAILSA pafda, 
     152                               ACMFILTERENUMCBA fnCallback, DWORD dwInstance,
     153                               DWORD fdwEnum)
     154{
     155    ACMFILTERDETAILSW           afdw;
    156156    struct MSACM_FilterEnumWtoA_Instance afei;
    157157
     
    167167    afei.fnCallback = fnCallback;
    168168
    169     return acmFilterEnumW(had, &afdw, MSACM_FilterEnumCallbackWtoA,
    170               (DWORD)&afei, fdwEnum);
    171 }
    172 
    173 static BOOL MSACM_FilterEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had,
    174                    PACMFILTERDETAILSW pafd,
    175                    ACMFILTERENUMCBW fnCallback, DWORD dwInstance,
    176                    DWORD fdwEnum)
    177 {
    178     ACMDRIVERDETAILSW       add;
    179     ACMFILTERTAGDETAILSW    aftd;
    180     int             i, j;
     169    return acmFilterEnumW(had, &afdw, MSACM_FilterEnumCallbackWtoA, 
     170                          (DWORD)&afei, fdwEnum);
     171}
     172
     173static BOOL MSACM_FilterEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, 
     174                                   PACMFILTERDETAILSW pafd,
     175                                   ACMFILTERENUMCBW fnCallback, DWORD dwInstance, 
     176                                   DWORD fdwEnum)
     177{
     178    ACMDRIVERDETAILSW           add;
     179    ACMFILTERTAGDETAILSW        aftd;
     180    int                         i, j;
    181181
    182182    add.cbStruct = sizeof(add);
    183 
     183   
    184184    if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) != MMSYSERR_NOERROR) return FALSE;
    185185
    186186    for (i = 0; i < add.cFilterTags; i++) {
    187     memset(&aftd, 0, sizeof(aftd));
    188     aftd.cbStruct = sizeof(aftd);
    189     aftd.dwFilterTagIndex = i;
    190     if (acmFilterTagDetailsW(had, &aftd, ACM_FILTERTAGDETAILSF_INDEX) != MMSYSERR_NOERROR)
    191         continue;
    192 
    193     if ((fdwEnum & ACM_FILTERENUMF_DWFILTERTAG) &&
    194         aftd.dwFilterTag != pafd->pwfltr->dwFilterTag)
    195         continue;
    196 
    197     for (j = 0; j < aftd.cStandardFilters; j++) {
    198         pafd->dwFilterIndex = j;
    199         pafd->dwFilterTag = aftd.dwFilterTag;
    200         if (acmFilterDetailsW(had, pafd, ACM_FILTERDETAILSF_INDEX) != MMSYSERR_NOERROR)
    201         continue;
    202 
    203         if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, add.fdwSupport))
    204         return FALSE;
    205     }
     187        memset(&aftd, 0, sizeof(aftd));
     188        aftd.cbStruct = sizeof(aftd);
     189        aftd.dwFilterTagIndex = i;
     190        if (acmFilterTagDetailsW(had, &aftd, ACM_FILTERTAGDETAILSF_INDEX) != MMSYSERR_NOERROR)
     191            continue;
     192       
     193        if ((fdwEnum & ACM_FILTERENUMF_DWFILTERTAG) &&
     194            aftd.dwFilterTag != pafd->pwfltr->dwFilterTag)
     195            continue;
     196       
     197        for (j = 0; j < aftd.cStandardFilters; j++) {
     198            pafd->dwFilterIndex = j;
     199            pafd->dwFilterTag = aftd.dwFilterTag;
     200            if (acmFilterDetailsW(had, pafd, ACM_FILTERDETAILSF_INDEX) != MMSYSERR_NOERROR)
     201                continue;
     202           
     203            if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, add.fdwSupport))
     204                return FALSE;
     205        }
    206206    }
    207207    return TRUE;
     
    211211 *           acmFilterEnumW (MSACM32.18)
    212212 */
    213 MMRESULT WINAPI acmFilterEnumW(HACMDRIVER had, PACMFILTERDETAILSW pafd,
    214                    ACMFILTERENUMCBW fnCallback, DWORD dwInstance,
    215                    DWORD fdwEnum)
    216 {
    217     PWINE_ACMDRIVERID       padid;
    218     BOOL            ret;
     213MMRESULT WINAPI acmFilterEnumW(HACMDRIVER had, PACMFILTERDETAILSW pafd, 
     214                               ACMFILTERENUMCBW fnCallback, DWORD dwInstance,
     215                               DWORD fdwEnum)
     216{
     217    PWINE_ACMDRIVERID           padid;
     218    BOOL                        ret;
    219219
    220220    TRACE("(0x%08x, %p, %p, %ld, %ld)\n",
    221       had, pafd, fnCallback, dwInstance, fdwEnum);
     221          had, pafd, fnCallback, dwInstance, fdwEnum);
    222222
    223223    if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
    224224
    225225    if (fdwEnum & ~(ACM_FILTERENUMF_DWFILTERTAG))
    226     FIXME("Unsupported fdwEnum values\n");
     226        FIXME("Unsupported fdwEnum values\n");
    227227
    228228    if (had) {
    229     HACMDRIVERID    hadid;
    230 
    231     if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR)
    232         return MMSYSERR_INVALHANDLE;
    233     MSACM_FilterEnumHelper(MSACM_GetDriverID(hadid), had, pafd,
    234                    fnCallback, dwInstance, fdwEnum);
     229        HACMDRIVERID    hadid;
     230
     231        if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR)
     232            return MMSYSERR_INVALHANDLE;
     233        MSACM_FilterEnumHelper(MSACM_GetDriverID(hadid), had, pafd,
     234                               fnCallback, dwInstance, fdwEnum);
     235        return MMSYSERR_NOERROR;
     236    }
     237    for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     238            /* should check for codec only */
     239            if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
     240                continue;
     241            ret = MSACM_FilterEnumHelper(padid, had, pafd,
     242                                         fnCallback, dwInstance, fdwEnum);
     243            acmDriverClose(had, 0);
     244            if (!ret) break;
     245    }
    235246    return MMSYSERR_NOERROR;
    236     }
    237     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    238         /* should check for codec only */
    239         if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
    240         continue;
    241         ret = MSACM_FilterEnumHelper(padid, had, pafd,
    242                      fnCallback, dwInstance, fdwEnum);
    243         acmDriverClose(had, 0);
    244         if (!ret) break;
    245     }
    246     return MMSYSERR_NOERROR;
    247247}
    248248
     
    250250 *           acmFilterTagDetailsA (MSACM32.19)
    251251 */
    252 MMRESULT WINAPI acmFilterTagDetailsA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda,
    253                      DWORD fdwDetails)
    254 {
    255     ACMFILTERTAGDETAILSW    aftdw;
    256     MMRESULT            mmr;
     252MMRESULT WINAPI acmFilterTagDetailsA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda, 
     253                                     DWORD fdwDetails)
     254{
     255    ACMFILTERTAGDETAILSW        aftdw;
     256    MMRESULT                    mmr;
    257257
    258258    memset(&aftdw, 0, sizeof(aftdw));
     
    263263    mmr = acmFilterTagDetailsW(had, &aftdw, fdwDetails);
    264264    if (mmr == MMSYSERR_NOERROR) {
    265     paftda->dwFilterTag = aftdw.dwFilterTag;
    266     paftda->dwFilterTagIndex = aftdw.dwFilterTagIndex;
    267     paftda->cbFilterSize = aftdw.cbFilterSize;
    268     paftda->fdwSupport = aftdw.fdwSupport;
    269     paftda->cStandardFilters = aftdw.cStandardFilters;
     265        paftda->dwFilterTag = aftdw.dwFilterTag;
     266        paftda->dwFilterTagIndex = aftdw.dwFilterTagIndex;
     267        paftda->cbFilterSize = aftdw.cbFilterSize;
     268        paftda->fdwSupport = aftdw.fdwSupport;
     269        paftda->cStandardFilters = aftdw.cStandardFilters;
    270270        WideCharToMultiByte( CP_ACP, 0, aftdw.szFilterTag, -1, paftda->szFilterTag,
    271271                             sizeof(paftda->szFilterTag), NULL, NULL );
     
    277277 *           acmFilterTagDetailsW (MSACM32.20)
    278278 */
    279 MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd,
    280                      DWORD fdwDetails)
    281 {
    282     PWINE_ACMDRIVERID   padid;
    283     MMRESULT        mmr;
     279MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd, 
     280                                     DWORD fdwDetails)
     281{
     282    PWINE_ACMDRIVERID   padid;
     283    MMRESULT            mmr;
    284284
    285285    TRACE("(0x%08x, %p, %ld)\n", had, paftd, fdwDetails);
    286286
    287287    if (fdwDetails & ~(ACM_FILTERTAGDETAILSF_FILTERTAG|ACM_FILTERTAGDETAILSF_INDEX|
    288                ACM_FILTERTAGDETAILSF_LARGESTSIZE))
    289     return MMSYSERR_INVALFLAG;
     288                       ACM_FILTERTAGDETAILSF_LARGESTSIZE))
     289        return MMSYSERR_INVALFLAG;
    290290
    291291    switch (fdwDetails) {
    292292    case ACM_FILTERTAGDETAILSF_FILTERTAG:
    293     if (had == (HACMDRIVER)NULL) {
    294         mmr = ACMERR_NOTPOSSIBLE;
    295         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    296         /* should check for codec only */
    297         if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
    298             mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
    299                     (LPARAM)paftd, (LPARAM)fdwDetails);
    300             acmDriverClose(had, 0);
    301             if (mmr == MMSYSERR_NOERROR) break;
    302         }
    303         }
    304     } else {
    305         mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
    306                 (LPARAM)paftd, (LPARAM)fdwDetails);
    307     }
    308     break;
     293        if (had == (HACMDRIVER)NULL) {
     294            mmr = ACMERR_NOTPOSSIBLE;
     295            for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     296                /* should check for codec only */
     297                if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
     298                    mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
     299                                        (LPARAM)paftd, (LPARAM)fdwDetails);
     300                    acmDriverClose(had, 0);
     301                    if (mmr == MMSYSERR_NOERROR) break;
     302                }
     303            }
     304        } else {
     305            mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
     306                                (LPARAM)paftd, (LPARAM)fdwDetails);
     307        }
     308        break;
    309309
    310310    case ACM_FILTERTAGDETAILSF_INDEX:
    311     /* FIXME should check paftd->dwFilterTagIndex < add.cFilterTags */
    312     mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
    313                 (LPARAM)paftd, (LPARAM)fdwDetails);
    314     break;
     311        /* FIXME should check paftd->dwFilterTagIndex < add.cFilterTags */
     312        mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
     313                            (LPARAM)paftd, (LPARAM)fdwDetails);
     314        break;
    315315
    316316    case ACM_FILTERTAGDETAILSF_LARGESTSIZE:
    317     if (had == (HACMDRIVER)NULL) {
    318         ACMFILTERTAGDETAILSW    tmp;
    319         DWORD           ft = paftd->dwFilterTag;
    320 
    321         mmr = ACMERR_NOTPOSSIBLE;
    322         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    323         /* should check for codec only */
    324         if (padid->bEnabled &&
    325             acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
    326 
    327             memset(&tmp, 0, sizeof(tmp));
    328             tmp.cbStruct = sizeof(tmp);
    329             tmp.dwFilterTag = ft;
    330 
    331             if (MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
    332                       (LPARAM)&tmp,
    333                       (LPARAM)fdwDetails) == MMSYSERR_NOERROR) {
    334             if (mmr == ACMERR_NOTPOSSIBLE ||
    335                 paftd->cbFilterSize < tmp.cbFilterSize) {
    336                 *paftd = tmp;
    337                 mmr = MMSYSERR_NOERROR;
    338             }
    339             }
    340             acmDriverClose(had, 0);
    341         }
    342         }
    343     } else {
    344         mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
    345                 (LPARAM)paftd, (LPARAM)fdwDetails);
    346     }
    347     break;
     317        if (had == (HACMDRIVER)NULL) {
     318            ACMFILTERTAGDETAILSW        tmp;
     319            DWORD                       ft = paftd->dwFilterTag;
     320
     321            mmr = ACMERR_NOTPOSSIBLE;
     322            for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     323                /* should check for codec only */
     324                if (padid->bEnabled &&
     325                    acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
     326
     327                    memset(&tmp, 0, sizeof(tmp));
     328                    tmp.cbStruct = sizeof(tmp);
     329                    tmp.dwFilterTag = ft;
     330
     331                    if (MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
     332                                      (LPARAM)&tmp,
     333                                      (LPARAM)fdwDetails) == MMSYSERR_NOERROR) {
     334                        if (mmr == ACMERR_NOTPOSSIBLE ||
     335                            paftd->cbFilterSize < tmp.cbFilterSize) {
     336                            *paftd = tmp;
     337                            mmr = MMSYSERR_NOERROR;
     338                        }
     339                    }
     340                    acmDriverClose(had, 0);
     341                }
     342            }
     343        } else {
     344            mmr = MSACM_Message(had, ACMDM_FILTERTAG_DETAILS,
     345                                (LPARAM)paftd, (LPARAM)fdwDetails);
     346        }
     347        break;
    348348
    349349    default:
    350     WARN("Unsupported fdwDetails=%08lx\n", fdwDetails);
    351     mmr = MMSYSERR_ERROR;
    352     }
    353 
    354     if (mmr == MMSYSERR_NOERROR &&
    355     paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0)
     350        WARN("Unsupported fdwDetails=%08lx\n", fdwDetails);
     351        mmr = MMSYSERR_ERROR;
     352    }
     353
     354    if (mmr == MMSYSERR_NOERROR && 
     355        paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0)
    356356        MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFilterTag,
    357357                             sizeof(paftd->szFilterTag)/sizeof(WCHAR) );
     
    361361
    362362struct MSACM_FilterTagEnumWtoA_Instance {
    363     PACMFILTERTAGDETAILSA   paftda;
    364     DWORD           dwInstance;
    365     ACMFILTERTAGENUMCBA     fnCallback;
     363    PACMFILTERTAGDETAILSA       paftda;
     364    DWORD                       dwInstance;
     365    ACMFILTERTAGENUMCBA         fnCallback;
    366366};
    367367
    368368static BOOL CALLBACK MSACM_FilterTagEnumCallbackWtoA(HACMDRIVERID hadid,
    369                              PACMFILTERTAGDETAILSW paftdw,
    370                              DWORD dwInstance,
    371                              DWORD fdwSupport)
     369                                                     PACMFILTERTAGDETAILSW paftdw, 
     370                                                     DWORD dwInstance,             
     371                                                     DWORD fdwSupport)
    372372{
    373373    struct MSACM_FilterTagEnumWtoA_Instance* paftei;
     
    375375    paftei = (struct MSACM_FilterTagEnumWtoA_Instance*)dwInstance;
    376376
    377     paftei->paftda->dwFilterTagIndex = paftdw->dwFilterTagIndex;
    378     paftei->paftda->dwFilterTag = paftdw->dwFilterTag;
    379     paftei->paftda->cbFilterSize = paftdw->cbFilterSize;
    380     paftei->paftda->fdwSupport = paftdw->fdwSupport;
    381     paftei->paftda->cStandardFilters = paftdw->cStandardFilters;
     377    paftei->paftda->dwFilterTagIndex = paftdw->dwFilterTagIndex; 
     378    paftei->paftda->dwFilterTag = paftdw->dwFilterTag; 
     379    paftei->paftda->cbFilterSize = paftdw->cbFilterSize; 
     380    paftei->paftda->fdwSupport = paftdw->fdwSupport; 
     381    paftei->paftda->cStandardFilters = paftdw->cStandardFilters; 
    382382    WideCharToMultiByte( CP_ACP, 0, paftdw->szFilterTag, -1, paftei->paftda->szFilterTag,
    383383                         sizeof(paftei->paftda->szFilterTag), NULL, NULL );
    384384
    385     return (paftei->fnCallback)(hadid, paftei->paftda,
    386                 paftei->dwInstance, fdwSupport);
     385    return (paftei->fnCallback)(hadid, paftei->paftda, 
     386                                paftei->dwInstance, fdwSupport);
    387387}
    388388
     
    391391 */
    392392MMRESULT WINAPI acmFilterTagEnumA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftda,
    393                   ACMFILTERTAGENUMCBA fnCallback, DWORD dwInstance,
    394                   DWORD fdwEnum)
    395 {
    396     ACMFILTERTAGDETAILSW    aftdw;
     393                                  ACMFILTERTAGENUMCBA fnCallback, DWORD dwInstance,
     394                                  DWORD fdwEnum)
     395{
     396    ACMFILTERTAGDETAILSW        aftdw;
    397397    struct MSACM_FilterTagEnumWtoA_Instance aftei;
    398398
     
    406406    aftei.fnCallback = fnCallback;
    407407
    408     return acmFilterTagEnumW(had, &aftdw, MSACM_FilterTagEnumCallbackWtoA,
    409                  (DWORD)&aftei, fdwEnum);
     408    return acmFilterTagEnumW(had, &aftdw, MSACM_FilterTagEnumCallbackWtoA, 
     409                             (DWORD)&aftei, fdwEnum);
    410410}
    411411
     
    414414 */
    415415MMRESULT WINAPI acmFilterTagEnumW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd,
    416                   ACMFILTERTAGENUMCBW fnCallback, DWORD dwInstance,
    417                   DWORD fdwEnum)
    418 {
    419     PWINE_ACMDRIVERID       padid;
    420     ACMDRIVERDETAILSW       add;
    421     int             i;
     416                                  ACMFILTERTAGENUMCBW fnCallback, DWORD dwInstance,
     417                                  DWORD fdwEnum)
     418{
     419    PWINE_ACMDRIVERID           padid;
     420    ACMDRIVERDETAILSW           add;
     421    int                         i;
    422422
    423423    TRACE("(0x%08x, %p, %p, %ld, %ld)\n",
    424       had, paftd, fnCallback, dwInstance, fdwEnum);
     424          had, paftd, fnCallback, dwInstance, fdwEnum);
    425425
    426426    if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM;
    427427
    428428    if (had) FIXME("had != NULL, not supported\n");
    429 
     429   
    430430    for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    431     /* should check for codec only */
    432     if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) {
    433         add.cbStruct = sizeof(add);
    434 
    435         if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) == MMSYSERR_NOERROR) {
    436         for (i = 0; i < add.cFilterTags; i++) {
    437             paftd->dwFilterTagIndex = i;
    438             if (acmFilterTagDetailsW(had, paftd, ACM_FILTERTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
    439             if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance,
    440                       add.fdwSupport)) {
    441                 padid = NULL;
    442                 break;
    443             }
    444             }
    445         }
    446         }
    447     }
    448     acmDriverClose(had, 0);
     431        /* should check for codec only */
     432        if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) {
     433            add.cbStruct = sizeof(add);
     434
     435            if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) == MMSYSERR_NOERROR) {
     436                for (i = 0; i < add.cFilterTags; i++) {
     437                    paftd->dwFilterTagIndex = i;
     438                    if (acmFilterTagDetailsW(had, paftd, ACM_FILTERTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
     439                        if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance,
     440                                          add.fdwSupport)) {
     441                            padid = NULL;
     442                            break;
     443                        }
     444                    }
     445                }
     446            }
     447        }
     448        acmDriverClose(had, 0);
    449449    }
    450450    return MMSYSERR_NOERROR;
  • trunk/src/msacm32/format.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: format.c,v 1.2 2001-09-05 13:11:25 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
    55 *
    66 *      Copyright 1998  Patrik Stridvall
    7  *        2000  Eric Pouech
     7 *                2000  Eric Pouech
    88 */
    99
     
    2424DEFAULT_DEBUG_CHANNEL(msacm);
    2525
    26 static  PACMFORMATCHOOSEA   afc;
     26static  PACMFORMATCHOOSEA       afc;
    2727
    2828struct MSACM_FillFormatData {
    29     HWND        hWnd;
    30 #define WINE_ACMFF_TAG      0
    31 #define WINE_ACMFF_FORMAT   1
    32 #define WINE_ACMFF_WFX      2
    33     int         mode;
    34     char        szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
    35     PACMFORMATCHOOSEA   afc;
    36     DWORD       ret;
     29    HWND                hWnd;
     30#define WINE_ACMFF_TAG          0
     31#define WINE_ACMFF_FORMAT       1
     32#define WINE_ACMFF_WFX          2
     33    int                 mode;
     34    char                szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
     35    PACMFORMATCHOOSEA   afc;
     36    DWORD               ret;
    3737};
    3838
    39 static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
    40                         PACMFORMATTAGDETAILSA paftd,
    41                         DWORD dwInstance, DWORD fdwSupport)
    42 {
    43     struct MSACM_FillFormatData*    affd = (struct MSACM_FillFormatData*)dwInstance;
     39static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, 
     40                                            PACMFORMATTAGDETAILSA paftd,
     41                                            DWORD dwInstance, DWORD fdwSupport)
     42{
     43    struct MSACM_FillFormatData*        affd = (struct MSACM_FillFormatData*)dwInstance;
    4444
    4545    switch (affd->mode) {
    4646    case WINE_ACMFF_TAG:
    47     if (SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
    48                 CB_FINDSTRINGEXACT,
    49                 (WPARAM)-1, (LPARAM)paftd->szFormatTag) == CB_ERR)
    50         SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
    51                 CB_ADDSTRING, 0, (DWORD)paftd->szFormatTag);
    52     break;
     47        if (SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
     48                                CB_FINDSTRINGEXACT,
     49                                (WPARAM)-1, (LPARAM)paftd->szFormatTag) == CB_ERR)
     50            SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
     51                                CB_ADDSTRING, 0, (DWORD)paftd->szFormatTag);
     52        break;
    5353    case WINE_ACMFF_FORMAT:
    54     if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) {
    55         HACMDRIVER      had;
    56 
    57         if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
    58         ACMFORMATDETAILSA   afd;
    59         int         i, idx;
    60         MMRESULT        mmr;
    61         char            buffer[64];
    62 
    63         afd.cbStruct = sizeof(afd);
    64         afd.dwFormatTag = paftd->dwFormatTag;
    65         afd.pwfx = HeapAlloc(GetProcessHeap(), 0, paftd->cbFormatSize);
    66         afd.pwfx->wFormatTag = paftd->dwFormatTag;
    67         afd.pwfx->cbSize = paftd->cbFormatSize;
    68         afd.cbwfx = paftd->cbFormatSize;
    69 
    70         for (i = 0; i < paftd->cStandardFormats; i++) {
    71             afd.dwFormatIndex = i;
    72             mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
    73             if (mmr == MMSYSERR_NOERROR) {
    74             strcpy(buffer, afd.szFormat);
    75             for (idx = strlen(buffer);
    76                  idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++)
    77                 buffer[idx] = ' ';
    78             wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
    79                   "%d Ko/s",
    80                   (afd.pwfx->nAvgBytesPerSec + 512) / 1024);
    81             SendDlgItemMessageA(affd->hWnd,
    82                         IDD_ACMFORMATCHOOSE_CMB_FORMAT,
    83                         CB_ADDSTRING, 0, (DWORD)buffer);
    84             }
    85         }
    86         acmDriverClose(had, 0);
    87         SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
    88                     CB_SETCURSEL, 0, 0);
    89         }
    90     }
    91     break;
     54        if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) {
     55            HACMDRIVER          had;
     56
     57            if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
     58                ACMFORMATDETAILSA       afd;
     59                int                     i, idx;
     60                MMRESULT                mmr;
     61                char                    buffer[64];
     62
     63                afd.cbStruct = sizeof(afd);
     64                afd.dwFormatTag = paftd->dwFormatTag;
     65                afd.pwfx = HeapAlloc(GetProcessHeap(), 0, paftd->cbFormatSize);
     66                afd.pwfx->wFormatTag = paftd->dwFormatTag;
     67                afd.pwfx->cbSize = paftd->cbFormatSize;
     68                afd.cbwfx = paftd->cbFormatSize;
     69
     70                for (i = 0; i < paftd->cStandardFormats; i++) {
     71                    afd.dwFormatIndex = i;
     72                    mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
     73                    if (mmr == MMSYSERR_NOERROR) {
     74                        strcpy(buffer, afd.szFormat);
     75                        for (idx = strlen(buffer);
     76                             idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++)
     77                            buffer[idx] = ' ';
     78                        wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
     79                                  "%d Ko/s",
     80                                  (afd.pwfx->nAvgBytesPerSec + 512) / 1024);
     81                        SendDlgItemMessageA(affd->hWnd,
     82                                            IDD_ACMFORMATCHOOSE_CMB_FORMAT,
     83                                            CB_ADDSTRING, 0, (DWORD)buffer);
     84                    }
     85                }
     86                acmDriverClose(had, 0);
     87                SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
     88                                    CB_SETCURSEL, 0, 0);
     89            }
     90        }
     91        break;
    9292    case WINE_ACMFF_WFX:
    93     if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) {
    94         HACMDRIVER      had;
    95 
    96         if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
    97         ACMFORMATDETAILSA   afd;
    98 
    99         afd.cbStruct = sizeof(afd);
    100         afd.dwFormatTag = paftd->dwFormatTag;
    101         afd.pwfx = affd->afc->pwfx;
    102         afd.cbwfx = affd->afc->cbwfx;
    103 
    104         afd.dwFormatIndex = SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_GETCURSEL, 0, 0);;
    105         affd->ret = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
    106         acmDriverClose(had, 0);
    107         return TRUE;
    108         }
    109     }
    110     break;
     93        if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) {
     94            HACMDRIVER          had;
     95
     96            if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
     97                ACMFORMATDETAILSA       afd;
     98
     99                afd.cbStruct = sizeof(afd);
     100                afd.dwFormatTag = paftd->dwFormatTag;
     101                afd.pwfx = affd->afc->pwfx;
     102                afd.cbwfx = affd->afc->cbwfx;
     103
     104                afd.dwFormatIndex = SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_GETCURSEL, 0, 0);;
     105                affd->ret = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
     106                acmDriverClose(had, 0);
     107                return TRUE;
     108            }
     109        }
     110        break;
    111111    default:
    112     FIXME("Unknown mode (%d)\n", affd->mode);
    113     break;
     112        FIXME("Unknown mode (%d)\n", affd->mode);
     113        break;
    114114    }
    115115    return TRUE;
     
    118118static BOOL MSACM_FillFormatTags(HWND hWnd)
    119119{
    120     ACMFORMATTAGDETAILSA    aftd;
    121     struct MSACM_FillFormatData affd;
     120    ACMFORMATTAGDETAILSA        aftd;
     121    struct MSACM_FillFormatData affd;
    122122
    123123    memset(&aftd, 0, sizeof(aftd));
     
    134134static BOOL MSACM_FillFormat(HWND hWnd)
    135135{
    136     ACMFORMATTAGDETAILSA    aftd;
    137     struct MSACM_FillFormatData affd;
     136    ACMFORMATTAGDETAILSA        aftd;
     137    struct MSACM_FillFormatData affd;
    138138
    139139    SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_RESETCONTENT, 0, 0);
     
    144144    affd.hWnd = hWnd;
    145145    affd.mode = WINE_ACMFF_FORMAT;
    146     SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
    147             CB_GETLBTEXT,
    148             SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
    149                         CB_GETCURSEL, 0, 0),
    150             (DWORD)affd.szFormatTag);
    151 
     146    SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, 
     147                        CB_GETLBTEXT,
     148                        SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
     149                                            CB_GETCURSEL, 0, 0),
     150                        (DWORD)affd.szFormatTag);
     151   
    152152    acmFormatTagEnumA((HACMDRIVER)0, &aftd, MSACM_FillFormatTagsCB, (DWORD)&affd, 0);
    153153    SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_SETCURSEL, 0, 0);
     
    157157static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEA afc)
    158158{
    159     ACMFORMATTAGDETAILSA    aftd;
    160     struct MSACM_FillFormatData affd;
     159    ACMFORMATTAGDETAILSA        aftd;
     160    struct MSACM_FillFormatData affd;
    161161
    162162    memset(&aftd, 0, sizeof(aftd));
     
    172172}
    173173
    174 static BOOL WINAPI FormatChooseDlgProc(HWND hWnd, UINT msg,
    175                        WPARAM wParam, LPARAM lParam)
    176 {
    177 
     174static BOOL WINAPI FormatChooseDlgProc(HWND hWnd, UINT msg, 
     175                                       WPARAM wParam, LPARAM lParam)
     176{
     177   
    178178    TRACE("hwnd=%i msg=%i 0x%08x 0x%08lx\n", hWnd,  msg, wParam, lParam );
    179 
     179   
    180180    switch (msg) {
    181181    case WM_INITDIALOG:
    182     afc = (PACMFORMATCHOOSEA)lParam;
    183     MSACM_FillFormatTags(hWnd);
    184     MSACM_FillFormat(hWnd);
    185     if ((afc->fdwStyle & ~(ACMFORMATCHOOSE_STYLEF_CONTEXTHELP|
    186                    ACMFORMATCHOOSE_STYLEF_SHOWHELP)) != 0)
    187         FIXME("Unsupported style %08lx\n", ((PACMFORMATCHOOSEA)lParam)->fdwStyle);
    188     if (!(afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP))
    189         ShowWindow(GetDlgItem(hWnd, IDD_ACMFORMATCHOOSE_BTN_HELP), SW_HIDE);
    190     return TRUE;
    191 
     182        afc = (PACMFORMATCHOOSEA)lParam;
     183        MSACM_FillFormatTags(hWnd);
     184        MSACM_FillFormat(hWnd);
     185        if ((afc->fdwStyle & ~(ACMFORMATCHOOSE_STYLEF_CONTEXTHELP|
     186                               ACMFORMATCHOOSE_STYLEF_SHOWHELP)) != 0)
     187            FIXME("Unsupported style %08lx\n", ((PACMFORMATCHOOSEA)lParam)->fdwStyle);
     188        if (!(afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP))
     189            ShowWindow(GetDlgItem(hWnd, IDD_ACMFORMATCHOOSE_BTN_HELP), SW_HIDE);
     190        return TRUE;
     191       
    192192    case WM_COMMAND:
    193     switch (LOWORD(wParam)) {
    194     case IDOK:
    195         EndDialog(hWnd, MSACM_GetWFX(hWnd, afc));
    196         return TRUE;
    197     case IDCANCEL:
    198         EndDialog(hWnd, ACMERR_CANCELED);
    199         return TRUE;
    200     case IDD_ACMFORMATCHOOSE_CMB_FORMATTAG:
    201         switch (HIWORD(wParam)) {
    202         case CBN_SELCHANGE:
    203         MSACM_FillFormat(hWnd);
    204         break;
    205         default:
    206         TRACE("Dropped dlgNotif (fmtTag): 0x%08x 0x%08lx\n",
    207               HIWORD(wParam), lParam);
    208         break;
    209         }
    210         break;
    211     case IDD_ACMFORMATCHOOSE_BTN_HELP:
    212         if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP)
    213         SendMessageA(afc->hwndOwner,
    214                  RegisterWindowMessageA(ACMHELPMSGSTRINGA), 0L, 0L);
    215         break;
    216 
    217     default:
    218         TRACE("Dropped dlgCmd: ctl=%d ntf=0x%04x 0x%08lx\n",
    219           LOWORD(wParam), HIWORD(wParam), lParam);
    220         break;
    221     }
    222     break;
     193        switch (LOWORD(wParam)) {
     194        case IDOK:
     195            EndDialog(hWnd, MSACM_GetWFX(hWnd, afc));
     196            return TRUE;
     197        case IDCANCEL:
     198            EndDialog(hWnd, ACMERR_CANCELED);
     199            return TRUE;
     200        case IDD_ACMFORMATCHOOSE_CMB_FORMATTAG:
     201            switch (HIWORD(wParam)) {
     202            case CBN_SELCHANGE:
     203                MSACM_FillFormat(hWnd);
     204                break;
     205            default:
     206                TRACE("Dropped dlgNotif (fmtTag): 0x%08x 0x%08lx\n",
     207                      HIWORD(wParam), lParam);
     208                break;
     209            }
     210            break;
     211        case IDD_ACMFORMATCHOOSE_BTN_HELP:
     212            if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP)
     213                SendMessageA(afc->hwndOwner,
     214                             RegisterWindowMessageA(ACMHELPMSGSTRINGA), 0L, 0L);
     215            break;
     216           
     217        default:
     218            TRACE("Dropped dlgCmd: ctl=%d ntf=0x%04x 0x%08lx\n",
     219                  LOWORD(wParam), HIWORD(wParam), lParam);
     220            break;
     221        }
     222        break;
    223223    case WM_CONTEXTMENU:
    224     if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
    225         SendMessageA(afc->hwndOwner,
    226              RegisterWindowMessageA(ACMHELPMSGCONTEXTMENUA),
    227             wParam, lParam);
    228     break;
     224        if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
     225            SendMessageA(afc->hwndOwner,
     226                         RegisterWindowMessageA(ACMHELPMSGCONTEXTMENUA),
     227                        wParam, lParam);
     228        break;
    229229#if defined(WM_CONTEXTHELP)
    230230    case WM_CONTEXTHELP:
    231     if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
    232         SendMessageA(afc->hwndOwner,
    233              RegisterWindowMessageA(ACMHELPMSGCONTEXTHELPA),
    234             wParam, lParam);
    235     break;
    236 #endif
     231        if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
     232            SendMessageA(afc->hwndOwner,
     233                         RegisterWindowMessageA(ACMHELPMSGCONTEXTHELPA),
     234                        wParam, lParam);
     235        break;
     236#endif       
    237237    default:
    238     TRACE("Dropped dlgMsg: hwnd=%i msg=%i 0x%08x 0x%08lx\n",
    239           hWnd,  msg, wParam, lParam );
    240     break;
     238        TRACE("Dropped dlgMsg: hwnd=%i msg=%i 0x%08x 0x%08lx\n",
     239              hWnd,  msg, wParam, lParam );
     240        break;
    241241    }
    242242    return FALSE;
     
    249249{
    250250    return DialogBoxParamA(MSACM_hInstance32, MAKEINTRESOURCEA(DLG_ACMFORMATCHOOSE_ID),
    251                pafmtc->hwndOwner, FormatChooseDlgProc, (INT)pafmtc);
     251                           pafmtc->hwndOwner, FormatChooseDlgProc, (INT)pafmtc);
    252252}
    253253
     
    265265 *           acmFormatDetailsA (MSACM32.25)
    266266 */
    267 MMRESULT WINAPI acmFormatDetailsA(HACMDRIVER had, PACMFORMATDETAILSA pafd,
    268                   DWORD fdwDetails)
    269 {
    270     ACMFORMATDETAILSW   afdw;
    271     MMRESULT        mmr;
     267MMRESULT WINAPI acmFormatDetailsA(HACMDRIVER had, PACMFORMATDETAILSA pafd, 
     268                                  DWORD fdwDetails)
     269{
     270    ACMFORMATDETAILSW   afdw;
     271    MMRESULT            mmr;
    272272
    273273    memset(&afdw, 0, sizeof(afdw));
    274274    afdw.cbStruct = sizeof(afdw);
    275275    afdw.dwFormatIndex = pafd->dwFormatIndex;
    276     afdw.dwFormatTag = pafd->dwFormatTag;
    277     afdw.pwfx = pafd->pwfx;
    278     afdw.cbwfx = pafd->cbwfx;
     276    afdw.dwFormatTag = pafd->dwFormatTag; 
     277    afdw.pwfx = pafd->pwfx; 
     278    afdw.cbwfx = pafd->cbwfx; 
    279279
    280280    mmr = acmFormatDetailsW(had, &afdw, fdwDetails);
    281281    if (mmr == MMSYSERR_NOERROR) {
    282     pafd->dwFormatTag = afdw.dwFormatTag;
    283     pafd->fdwSupport = afdw.fdwSupport;
     282        pafd->dwFormatTag = afdw.dwFormatTag;
     283        pafd->fdwSupport = afdw.fdwSupport;
    284284        WideCharToMultiByte( CP_ACP, 0, afdw.szFormat, -1,
    285285                             pafd->szFormat, sizeof(pafd->szFormat), NULL, NULL );
     
    291291 *           acmFormatDetailsW (MSACM32.26)
    292292 */
    293 MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd,
    294                   DWORD fdwDetails)
    295 {
    296     MMRESULT            mmr;
    297     static WCHAR        fmt1[] = {'%','d',' ','H','z',0};
    298     static WCHAR        fmt2[] = {';',' ','%','d',' ','b','i','t','s',0};
    299     ACMFORMATTAGDETAILSA    aftd;
     293MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, 
     294                                  DWORD fdwDetails)
     295{
     296    MMRESULT                    mmr;
     297    static WCHAR                fmt1[] = {'%','d',' ','H','z',0};
     298    static WCHAR                fmt2[] = {';',' ','%','d',' ','b','i','t','s',0};
     299    ACMFORMATTAGDETAILSA        aftd;
    300300
    301301    TRACE("(0x%08x, %p, %ld)\n", had, pafd, fdwDetails);
     
    305305
    306306    if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
    307 
     307       
    308308    switch (fdwDetails) {
    309309    case ACM_FORMATDETAILSF_FORMAT:
    310     if (pafd->dwFormatTag != pafd->pwfx->wFormatTag) {
    311         mmr = MMSYSERR_INVALPARAM;
    312         break;
    313     }
    314     if (had == (HACMDRIVER)NULL) {
    315         PWINE_ACMDRIVERID       padid;
    316 
    317         mmr = ACMERR_NOTPOSSIBLE;
    318         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    319         /* should check for codec only */
    320         if (padid->bEnabled &&
    321             acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
    322             mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS,
    323                     (LPARAM)pafd, (LPARAM)fdwDetails);
    324             acmDriverClose(had, 0);
    325             if (mmr == MMSYSERR_NOERROR) break;
    326         }
    327         }
    328     } else {
    329         mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS,
    330                 (LPARAM)pafd, (LPARAM)fdwDetails);
    331     }
    332     break;
     310        if (pafd->dwFormatTag != pafd->pwfx->wFormatTag) {
     311            mmr = MMSYSERR_INVALPARAM;
     312            break;
     313        }
     314        if (had == (HACMDRIVER)NULL) {
     315            PWINE_ACMDRIVERID           padid;
     316
     317            mmr = ACMERR_NOTPOSSIBLE;
     318            for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     319                /* should check for codec only */
     320                if (padid->bEnabled &&
     321                    acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
     322                    mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS,
     323                                        (LPARAM)pafd, (LPARAM)fdwDetails);
     324                    acmDriverClose(had, 0);
     325                    if (mmr == MMSYSERR_NOERROR) break;
     326                }
     327            }               
     328        } else {
     329            mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS,
     330                                (LPARAM)pafd, (LPARAM)fdwDetails);
     331        }
     332        break;
    333333    case ACM_FORMATDETAILSF_INDEX:
    334     /* should check pafd->dwFormatIndex < aftd->cStandardFormats */
    335     mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS,
    336                 (LPARAM)pafd, (LPARAM)fdwDetails);
    337     break;
     334        /* should check pafd->dwFormatIndex < aftd->cStandardFormats */
     335        mmr = MSACM_Message(had, ACMDM_FORMAT_DETAILS,
     336                            (LPARAM)pafd, (LPARAM)fdwDetails);
     337        break;
    338338    default:
    339     WARN("Unknown fdwDetails %08lx\n", fdwDetails);
    340     mmr = MMSYSERR_INVALFLAG;
    341     break;
     339        WARN("Unknown fdwDetails %08lx\n", fdwDetails);
     340        mmr = MMSYSERR_INVALFLAG;
     341        break;
    342342    }
    343343
    344344    if (mmr == MMSYSERR_NOERROR && pafd->szFormat[0] == (WCHAR)0) {
    345     wsprintfW(pafd->szFormat, fmt1, pafd->pwfx->nSamplesPerSec);
    346     if (pafd->pwfx->wBitsPerSample) {
    347         wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2,
    348               pafd->pwfx->wBitsPerSample);
    349     }
     345        wsprintfW(pafd->szFormat, fmt1, pafd->pwfx->nSamplesPerSec);
     346        if (pafd->pwfx->wBitsPerSample) {
     347            wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2,
     348                      pafd->pwfx->wBitsPerSample);
     349        }
    350350        MultiByteToWideChar( CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1,
    351351                             pafd->szFormat + strlenW(pafd->szFormat),
     
    358358
    359359struct MSACM_FormatEnumWtoA_Instance {
    360     PACMFORMATDETAILSA  pafda;
    361     DWORD       dwInstance;
    362     ACMFORMATENUMCBA    fnCallback;
     360    PACMFORMATDETAILSA  pafda;
     361    DWORD               dwInstance;
     362    ACMFORMATENUMCBA    fnCallback;
    363363};
    364364
    365365static BOOL CALLBACK MSACM_FormatEnumCallbackWtoA(HACMDRIVERID hadid,
    366                           PACMFORMATDETAILSW pafdw,
    367                           DWORD dwInstance,
    368                           DWORD fdwSupport)
     366                                                  PACMFORMATDETAILSW pafdw, 
     367                                                  DWORD dwInstance,             
     368                                                  DWORD fdwSupport)
    369369{
    370370    struct MSACM_FormatEnumWtoA_Instance* pafei;
     
    372372    pafei = (struct MSACM_FormatEnumWtoA_Instance*)dwInstance;
    373373
    374     pafei->pafda->dwFormatIndex = pafdw->dwFormatIndex;
    375     pafei->pafda->dwFormatTag = pafdw->dwFormatTag;
    376     pafei->pafda->fdwSupport = pafdw->fdwSupport;
     374    pafei->pafda->dwFormatIndex = pafdw->dwFormatIndex; 
     375    pafei->pafda->dwFormatTag = pafdw->dwFormatTag; 
     376    pafei->pafda->fdwSupport = pafdw->fdwSupport; 
    377377    WideCharToMultiByte( CP_ACP, 0, pafdw->szFormat, -1,
    378378                         pafei->pafda->szFormat, sizeof(pafei->pafda->szFormat), NULL, NULL );
    379379
    380     return (pafei->fnCallback)(hadid, pafei->pafda,
    381                    pafei->dwInstance, fdwSupport);
     380    return (pafei->fnCallback)(hadid, pafei->pafda, 
     381                               pafei->dwInstance, fdwSupport);
    382382}
    383383
     
    386386 */
    387387MMRESULT WINAPI acmFormatEnumA(HACMDRIVER had, PACMFORMATDETAILSA pafda,
    388                    ACMFORMATENUMCBA fnCallback, DWORD dwInstance,
    389                    DWORD fdwEnum)
    390 {
    391     ACMFORMATDETAILSW       afdw;
     388                               ACMFORMATENUMCBA fnCallback, DWORD dwInstance,
     389                               DWORD fdwEnum)
     390{
     391    ACMFORMATDETAILSW           afdw;
    392392    struct MSACM_FormatEnumWtoA_Instance afei;
    393393
     
    403403    afei.fnCallback = fnCallback;
    404404
    405     return acmFormatEnumW(had, &afdw, MSACM_FormatEnumCallbackWtoA,
    406               (DWORD)&afei, fdwEnum);
     405    return acmFormatEnumW(had, &afdw, MSACM_FormatEnumCallbackWtoA, 
     406                          (DWORD)&afei, fdwEnum);
    407407}
    408408
     
    410410 *           acmFormatEnumW (MSACM32.28)
    411411 */
    412 static BOOL MSACM_FormatEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had,
    413                    PACMFORMATDETAILSW pafd, PWAVEFORMATEX pwfxRef,
    414                    ACMFORMATENUMCBW fnCallback, DWORD dwInstance,
    415                    DWORD fdwEnum)
    416 {
    417     ACMDRIVERDETAILSW       add;
    418     ACMFORMATTAGDETAILSW    aftd;
    419     int             i, j;
     412static BOOL MSACM_FormatEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, 
     413                                   PACMFORMATDETAILSW pafd, PWAVEFORMATEX pwfxRef,
     414                                   ACMFORMATENUMCBW fnCallback, DWORD dwInstance, 
     415                                   DWORD fdwEnum)
     416{
     417    ACMDRIVERDETAILSW           add;
     418    ACMFORMATTAGDETAILSW        aftd;
     419    int                         i, j;
    420420
    421421    add.cbStruct = sizeof(add);
    422 
     422   
    423423    if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) != MMSYSERR_NOERROR) return FALSE;
    424424
    425425    for (i = 0; i < add.cFormatTags; i++) {
    426     memset(&aftd, 0, sizeof(aftd));
    427     aftd.cbStruct = sizeof(aftd);
    428     aftd.dwFormatTagIndex = i;
    429     if (acmFormatTagDetailsW(had, &aftd, ACM_FORMATTAGDETAILSF_INDEX) != MMSYSERR_NOERROR)
    430         continue;
    431 
    432     if ((fdwEnum & ACM_FORMATENUMF_WFORMATTAG) && aftd.dwFormatTag != pwfxRef->wFormatTag)
    433         continue;
    434 
    435     for (j = 0; j < aftd.cStandardFormats; j++) {
    436         pafd->dwFormatIndex = j;
    437         pafd->dwFormatTag = aftd.dwFormatTag;
    438         if (acmFormatDetailsW(had, pafd, ACM_FORMATDETAILSF_INDEX) != MMSYSERR_NOERROR)
    439         continue;
    440 
    441         if ((fdwEnum & ACM_FORMATENUMF_NCHANNELS) &&
    442         pafd->pwfx->nChannels != pwfxRef->nChannels)
    443         continue;
    444         if ((fdwEnum & ACM_FORMATENUMF_NSAMPLESPERSEC) &&
    445         pafd->pwfx->nSamplesPerSec != pwfxRef->nSamplesPerSec)
    446         continue;
    447         if ((fdwEnum & ACM_FORMATENUMF_WBITSPERSAMPLE) &&
    448         pafd->pwfx->wBitsPerSample != pwfxRef->wBitsPerSample)
    449         continue;
    450         if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) &&
    451         !(pafd->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_HARDWARE))
    452         continue;
    453 
    454         /* more checks to be done on fdwEnum */
    455 
    456         if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, add.fdwSupport))
    457         return FALSE;
    458     }
    459     /* the "formats" used by the filters are also reported */
     426        memset(&aftd, 0, sizeof(aftd));
     427        aftd.cbStruct = sizeof(aftd);
     428        aftd.dwFormatTagIndex = i;
     429        if (acmFormatTagDetailsW(had, &aftd, ACM_FORMATTAGDETAILSF_INDEX) != MMSYSERR_NOERROR)
     430            continue;
     431       
     432        if ((fdwEnum & ACM_FORMATENUMF_WFORMATTAG) && aftd.dwFormatTag != pwfxRef->wFormatTag)
     433            continue;
     434       
     435        for (j = 0; j < aftd.cStandardFormats; j++) {
     436            pafd->dwFormatIndex = j;
     437            pafd->dwFormatTag = aftd.dwFormatTag;
     438            if (acmFormatDetailsW(had, pafd, ACM_FORMATDETAILSF_INDEX) != MMSYSERR_NOERROR)
     439                continue;
     440           
     441            if ((fdwEnum & ACM_FORMATENUMF_NCHANNELS) &&
     442                pafd->pwfx->nChannels != pwfxRef->nChannels)
     443                continue;
     444            if ((fdwEnum & ACM_FORMATENUMF_NSAMPLESPERSEC) &&
     445                pafd->pwfx->nSamplesPerSec != pwfxRef->nSamplesPerSec)
     446                continue;
     447            if ((fdwEnum & ACM_FORMATENUMF_WBITSPERSAMPLE) &&
     448                pafd->pwfx->wBitsPerSample != pwfxRef->wBitsPerSample)
     449                continue;
     450            if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) &&
     451                !(pafd->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_HARDWARE))
     452                continue;
     453           
     454            /* more checks to be done on fdwEnum */
     455
     456            if (!(fnCallback)((HACMDRIVERID)padid, pafd, dwInstance, add.fdwSupport))
     457                return FALSE;
     458        }
     459        /* the "formats" used by the filters are also reported */
    460460    }
    461461    return TRUE;
     
    465465
    466466MMRESULT WINAPI acmFormatEnumW(HACMDRIVER had, PACMFORMATDETAILSW pafd,
    467                    ACMFORMATENUMCBW fnCallback, DWORD dwInstance,
    468                    DWORD fdwEnum)
    469 {
    470     PWINE_ACMDRIVERID       padid;
    471     WAVEFORMATEX        wfxRef;
    472     BOOL            ret;
     467                               ACMFORMATENUMCBW fnCallback, DWORD dwInstance, 
     468                               DWORD fdwEnum)
     469{
     470    PWINE_ACMDRIVERID           padid;
     471    WAVEFORMATEX                wfxRef;
     472    BOOL                        ret;
    473473
    474474    TRACE("(0x%08x, %p, %p, %ld, %ld)\n",
    475       had, pafd, fnCallback, dwInstance, fdwEnum);
     475          had, pafd, fnCallback, dwInstance, fdwEnum);
    476476
    477477    if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
    478478
    479479    if (fdwEnum & (ACM_FORMATENUMF_WFORMATTAG|ACM_FORMATENUMF_NCHANNELS|
    480            ACM_FORMATENUMF_NSAMPLESPERSEC|ACM_FORMATENUMF_WBITSPERSAMPLE|
    481            ACM_FORMATENUMF_CONVERT|ACM_FORMATENUMF_SUGGEST))
     480                   ACM_FORMATENUMF_NSAMPLESPERSEC|ACM_FORMATENUMF_WBITSPERSAMPLE|
     481                   ACM_FORMATENUMF_CONVERT|ACM_FORMATENUMF_SUGGEST))
    482482        wfxRef = *pafd->pwfx;
    483483
    484     if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) &&
    485     !(fdwEnum & (ACM_FORMATENUMF_INPUT|ACM_FORMATENUMF_OUTPUT)))
    486     return MMSYSERR_INVALPARAM;
     484    if ((fdwEnum & ACM_FORMATENUMF_HARDWARE) && 
     485        !(fdwEnum & (ACM_FORMATENUMF_INPUT|ACM_FORMATENUMF_OUTPUT)))
     486        return MMSYSERR_INVALPARAM;
    487487
    488488    if ((fdwEnum & ACM_FORMATENUMF_WFORMATTAG) &&
    489     (pafd->dwFormatTag != pafd->pwfx->wFormatTag))
    490     return MMSYSERR_INVALPARAM;
     489        (pafd->dwFormatTag != pafd->pwfx->wFormatTag))
     490        return MMSYSERR_INVALPARAM;
    491491
    492492    if (fdwEnum & (ACM_FORMATENUMF_CONVERT|ACM_FORMATENUMF_SUGGEST|
    493            ACM_FORMATENUMF_INPUT|ACM_FORMATENUMF_OUTPUT))
    494     FIXME("Unsupported fdwEnum values %08lx\n", fdwEnum);
     493                   ACM_FORMATENUMF_INPUT|ACM_FORMATENUMF_OUTPUT))
     494        FIXME("Unsupported fdwEnum values %08lx\n", fdwEnum);
    495495
    496496    if (had) {
    497     HACMDRIVERID    hadid;
    498 
    499     if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR)
    500         return MMSYSERR_INVALHANDLE;
    501     MSACM_FormatEnumHelper(MSACM_GetDriverID(hadid), had, pafd, &wfxRef,
    502                    fnCallback, dwInstance, fdwEnum);
     497        HACMDRIVERID    hadid;
     498
     499        if (acmDriverID(had, &hadid, 0) != MMSYSERR_NOERROR)
     500            return MMSYSERR_INVALHANDLE;
     501        MSACM_FormatEnumHelper(MSACM_GetDriverID(hadid), had, pafd, &wfxRef,
     502                               fnCallback, dwInstance, fdwEnum);
     503        return MMSYSERR_NOERROR;
     504    }
     505    for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     506            /* should check for codec only */
     507            if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
     508                continue;
     509            ret = MSACM_FormatEnumHelper(padid, had, pafd, &wfxRef,
     510                                         fnCallback, dwInstance, fdwEnum);
     511            acmDriverClose(had, 0);
     512            if (!ret) break;
     513    }
    503514    return MMSYSERR_NOERROR;
    504     }
    505     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    506         /* should check for codec only */
    507         if (!padid->bEnabled || acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
    508         continue;
    509         ret = MSACM_FormatEnumHelper(padid, had, pafd, &wfxRef,
    510                      fnCallback, dwInstance, fdwEnum);
    511         acmDriverClose(had, 0);
    512         if (!ret) break;
    513     }
    514     return MMSYSERR_NOERROR;
    515515}
    516516
     
    518518 *           acmFormatSuggest (MSACM32.29)
    519519 */
    520 MMRESULT WINAPI acmFormatSuggest(HACMDRIVER had, PWAVEFORMATEX pwfxSrc,
    521                 PWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest)
    522 {
    523     ACMDRVFORMATSUGGEST adfg;
    524     MMRESULT        mmr;
    525 
    526     TRACE("(0x%08x, %p, %p, %ld, %ld)\n",
    527       had, pwfxSrc, pwfxDst, cbwfxDst, fdwSuggest);
     520MMRESULT WINAPI acmFormatSuggest(HACMDRIVER had, PWAVEFORMATEX pwfxSrc, 
     521                                PWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest)
     522{
     523    ACMDRVFORMATSUGGEST adfg;
     524    MMRESULT            mmr;
     525
     526    TRACE("(0x%08x, %p, %p, %ld, %ld)\n", 
     527          had, pwfxSrc, pwfxDst, cbwfxDst, fdwSuggest);
    528528
    529529    if (fdwSuggest & ~(ACM_FORMATSUGGESTF_NCHANNELS|ACM_FORMATSUGGESTF_NSAMPLESPERSEC|
    530                ACM_FORMATSUGGESTF_WBITSPERSAMPLE|ACM_FORMATSUGGESTF_WFORMATTAG))
    531     return MMSYSERR_INVALFLAG;
     530                       ACM_FORMATSUGGESTF_WBITSPERSAMPLE|ACM_FORMATSUGGESTF_WFORMATTAG))
     531        return MMSYSERR_INVALFLAG;
    532532
    533533    adfg.cbStruct = sizeof(adfg);
     
    535535    adfg.pwfxSrc = pwfxSrc;
    536536    adfg.cbwfxSrc = (pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) ?
    537     sizeof(WAVEFORMATEX) : pwfxSrc->cbSize;
     537        sizeof(WAVEFORMATEX) : pwfxSrc->cbSize;
    538538    adfg.pwfxDst = pwfxDst;
    539539    adfg.cbwfxDst = cbwfxDst;
    540540
    541541    if (had == (HACMDRIVER)NULL) {
    542     PWINE_ACMDRIVERID   padid;
    543 
    544     /* MS doc says: ACM finds the best suggestion.
    545     * Well, first found will be the "best"
    546     */
    547     mmr = ACMERR_NOTPOSSIBLE;
    548     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    549         /* should check for codec only */
    550         if (!padid->bEnabled ||
    551         acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
    552         continue;
    553 
    554         if (MSACM_Message(had, ACMDM_FORMAT_SUGGEST,
    555                   (LPARAM)&adfg, 0L) == MMSYSERR_NOERROR) {
    556         mmr = MMSYSERR_NOERROR;
    557         break;
    558         }
    559         acmDriverClose(had, 0);
    560     }
     542        PWINE_ACMDRIVERID       padid;
     543       
     544        /* MS doc says: ACM finds the best suggestion.
     545        * Well, first found will be the "best"
     546        */
     547        mmr = ACMERR_NOTPOSSIBLE;
     548        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     549            /* should check for codec only */
     550            if (!padid->bEnabled ||
     551                acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != MMSYSERR_NOERROR)
     552                continue;
     553           
     554            if (MSACM_Message(had, ACMDM_FORMAT_SUGGEST,
     555                              (LPARAM)&adfg, 0L) == MMSYSERR_NOERROR) {
     556                mmr = MMSYSERR_NOERROR;
     557                break;
     558            }
     559            acmDriverClose(had, 0);
     560        }
    561561    } else {
    562     mmr = MSACM_Message(had, ACMDM_FORMAT_SUGGEST, (LPARAM)&adfg, 0L);
     562        mmr = MSACM_Message(had, ACMDM_FORMAT_SUGGEST, (LPARAM)&adfg, 0L);
    563563    }
    564564    return mmr;
     
    568568 *           acmFormatTagDetailsA (MSACM32.30)
    569569 */
    570 MMRESULT WINAPI acmFormatTagDetailsA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda,
    571                      DWORD fdwDetails)
    572 {
    573     ACMFORMATTAGDETAILSW    aftdw;
    574     MMRESULT            mmr;
     570MMRESULT WINAPI acmFormatTagDetailsA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda, 
     571                                     DWORD fdwDetails)
     572{
     573    ACMFORMATTAGDETAILSW        aftdw;
     574    MMRESULT                    mmr;
    575575
    576576    memset(&aftdw, 0, sizeof(aftdw));
     
    581581    mmr = acmFormatTagDetailsW(had, &aftdw, fdwDetails);
    582582    if (mmr == MMSYSERR_NOERROR) {
    583     paftda->dwFormatTag = aftdw.dwFormatTag;
    584     paftda->dwFormatTagIndex = aftdw.dwFormatTagIndex;
    585     paftda->cbFormatSize = aftdw.cbFormatSize;
    586     paftda->fdwSupport = aftdw.fdwSupport;
    587     paftda->cStandardFormats = aftdw.cStandardFormats;
     583        paftda->dwFormatTag = aftdw.dwFormatTag;
     584        paftda->dwFormatTagIndex = aftdw.dwFormatTagIndex;
     585        paftda->cbFormatSize = aftdw.cbFormatSize;
     586        paftda->fdwSupport = aftdw.fdwSupport;
     587        paftda->cStandardFormats = aftdw.cStandardFormats;
    588588        WideCharToMultiByte( CP_ACP, 0, aftdw.szFormatTag, -1, paftda->szFormatTag,
    589589                             sizeof(paftda->szFormatTag), NULL, NULL );
     
    595595 *           acmFormatTagDetailsW (MSACM32.31)
    596596 */
    597 MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
    598                      DWORD fdwDetails)
    599 {
    600     PWINE_ACMDRIVERID   padid;
    601     MMRESULT        mmr;
     597MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd, 
     598                                     DWORD fdwDetails)
     599{
     600    PWINE_ACMDRIVERID   padid;
     601    MMRESULT            mmr;
    602602
    603603    TRACE("(0x%08x, %p, %ld)\n", had, paftd, fdwDetails);
    604604
    605605    if (fdwDetails & ~(ACM_FORMATTAGDETAILSF_FORMATTAG|ACM_FORMATTAGDETAILSF_INDEX|
    606                ACM_FORMATTAGDETAILSF_LARGESTSIZE))
    607     return MMSYSERR_INVALFLAG;
     606                       ACM_FORMATTAGDETAILSF_LARGESTSIZE))
     607        return MMSYSERR_INVALFLAG;
    608608
    609609    switch (fdwDetails) {
    610610    case ACM_FORMATTAGDETAILSF_FORMATTAG:
    611     if (had == (HACMDRIVER)NULL) {
    612         mmr = ACMERR_NOTPOSSIBLE;
    613         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    614         /* should check for codec only */
    615         if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
    616             mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
    617                     (LPARAM)paftd, (LPARAM)fdwDetails);
    618             acmDriverClose(had, 0);
    619             if (mmr == MMSYSERR_NOERROR) break;
    620         }
    621         }
    622     } else {
    623         mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
    624                 (LPARAM)paftd, (LPARAM)fdwDetails);
    625     }
    626     break;
     611        if (had == (HACMDRIVER)NULL) {
     612            mmr = ACMERR_NOTPOSSIBLE;
     613            for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     614                /* should check for codec only */
     615                if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
     616                    mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
     617                                        (LPARAM)paftd, (LPARAM)fdwDetails);
     618                    acmDriverClose(had, 0);
     619                    if (mmr == MMSYSERR_NOERROR) break;
     620                }
     621            }
     622        } else {
     623            mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
     624                                (LPARAM)paftd, (LPARAM)fdwDetails);
     625        }
     626        break;
    627627
    628628    case ACM_FORMATTAGDETAILSF_INDEX:
    629     /* FIXME should check paftd->dwFormatTagIndex < add.cFormatTags */
    630     mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
    631                 (LPARAM)paftd, (LPARAM)fdwDetails);
    632     break;
     629        /* FIXME should check paftd->dwFormatTagIndex < add.cFormatTags */
     630        mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
     631                            (LPARAM)paftd, (LPARAM)fdwDetails);
     632        break;
    633633
    634634    case ACM_FORMATTAGDETAILSF_LARGESTSIZE:
    635     if (had == (HACMDRIVER)NULL) {
    636         ACMFORMATTAGDETAILSW    tmp;
    637         DWORD           ft = paftd->dwFormatTag;
    638 
    639         mmr = ACMERR_NOTPOSSIBLE;
    640         for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    641         /* should check for codec only */
    642         if (padid->bEnabled &&
    643             acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
    644 
    645             memset(&tmp, 0, sizeof(tmp));
    646             tmp.cbStruct = sizeof(tmp);
    647             tmp.dwFormatTag = ft;
    648 
    649             if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
    650                       (LPARAM)&tmp,
    651                       (LPARAM)fdwDetails) == MMSYSERR_NOERROR) {
    652             if (mmr == ACMERR_NOTPOSSIBLE ||
    653                 paftd->cbFormatSize < tmp.cbFormatSize) {
    654                 *paftd = tmp;
    655                 mmr = MMSYSERR_NOERROR;
    656             }
    657             }
    658             acmDriverClose(had, 0);
    659         }
    660         }
    661     } else {
    662         mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
    663                 (LPARAM)paftd, (LPARAM)fdwDetails);
    664     }
    665     break;
     635        if (had == (HACMDRIVER)NULL) {
     636            ACMFORMATTAGDETAILSW        tmp;
     637            DWORD                       ft = paftd->dwFormatTag;
     638
     639            mmr = ACMERR_NOTPOSSIBLE;
     640            for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
     641                /* should check for codec only */
     642                if (padid->bEnabled &&
     643                    acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == 0) {
     644
     645                    memset(&tmp, 0, sizeof(tmp));
     646                    tmp.cbStruct = sizeof(tmp);
     647                    tmp.dwFormatTag = ft;
     648
     649                    if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
     650                                      (LPARAM)&tmp,
     651                                      (LPARAM)fdwDetails) == MMSYSERR_NOERROR) {
     652                        if (mmr == ACMERR_NOTPOSSIBLE ||
     653                            paftd->cbFormatSize < tmp.cbFormatSize) {
     654                            *paftd = tmp;
     655                            mmr = MMSYSERR_NOERROR;
     656                        }
     657                    }
     658                    acmDriverClose(had, 0);
     659                }
     660            }
     661        } else {
     662            mmr = MSACM_Message(had, ACMDM_FORMATTAG_DETAILS,
     663                                (LPARAM)paftd, (LPARAM)fdwDetails);
     664        }
     665        break;
    666666
    667667    default:
    668     WARN("Unsupported fdwDetails=%08lx\n", fdwDetails);
    669     mmr = MMSYSERR_ERROR;
    670     }
    671 
    672     if (mmr == MMSYSERR_NOERROR &&
    673     paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0)
     668        WARN("Unsupported fdwDetails=%08lx\n", fdwDetails);
     669        mmr = MMSYSERR_ERROR;
     670    }
     671
     672    if (mmr == MMSYSERR_NOERROR && 
     673        paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0)
    674674        MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
    675675                             sizeof(paftd->szFormatTag)/sizeof(WCHAR) );
     
    679679
    680680struct MSACM_FormatTagEnumWtoA_Instance {
    681     PACMFORMATTAGDETAILSA   paftda;
    682     DWORD           dwInstance;
    683     ACMFORMATTAGENUMCBA     fnCallback;
     681    PACMFORMATTAGDETAILSA       paftda;
     682    DWORD                       dwInstance;
     683    ACMFORMATTAGENUMCBA         fnCallback;
    684684};
    685685
    686686static BOOL CALLBACK MSACM_FormatTagEnumCallbackWtoA(HACMDRIVERID hadid,
    687                              PACMFORMATTAGDETAILSW paftdw,
    688                              DWORD dwInstance,
    689                              DWORD fdwSupport)
     687                                                     PACMFORMATTAGDETAILSW paftdw, 
     688                                                     DWORD dwInstance,             
     689                                                     DWORD fdwSupport)
    690690{
    691691    struct MSACM_FormatTagEnumWtoA_Instance* paftei;
     
    693693    paftei = (struct MSACM_FormatTagEnumWtoA_Instance*)dwInstance;
    694694
    695     paftei->paftda->dwFormatTagIndex = paftdw->dwFormatTagIndex;
    696     paftei->paftda->dwFormatTag = paftdw->dwFormatTag;
    697     paftei->paftda->cbFormatSize = paftdw->cbFormatSize;
    698     paftei->paftda->fdwSupport = paftdw->fdwSupport;
    699     paftei->paftda->cStandardFormats = paftdw->cStandardFormats;
     695    paftei->paftda->dwFormatTagIndex = paftdw->dwFormatTagIndex; 
     696    paftei->paftda->dwFormatTag = paftdw->dwFormatTag; 
     697    paftei->paftda->cbFormatSize = paftdw->cbFormatSize; 
     698    paftei->paftda->fdwSupport = paftdw->fdwSupport; 
     699    paftei->paftda->cStandardFormats = paftdw->cStandardFormats; 
    700700    WideCharToMultiByte( CP_ACP, 0, paftdw->szFormatTag, -1, paftei->paftda->szFormatTag,
    701701                         sizeof(paftei->paftda->szFormatTag), NULL, NULL );
    702702
    703     return (paftei->fnCallback)(hadid, paftei->paftda,
    704                 paftei->dwInstance, fdwSupport);
     703    return (paftei->fnCallback)(hadid, paftei->paftda, 
     704                                paftei->dwInstance, fdwSupport);
    705705}
    706706
     
    709709 */
    710710MMRESULT WINAPI acmFormatTagEnumA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftda,
    711                   ACMFORMATTAGENUMCBA fnCallback, DWORD dwInstance,
    712                   DWORD fdwEnum)
    713 {
    714     ACMFORMATTAGDETAILSW    aftdw;
     711                                  ACMFORMATTAGENUMCBA fnCallback, DWORD dwInstance,
     712                                  DWORD fdwEnum)
     713{
     714    ACMFORMATTAGDETAILSW        aftdw;
    715715    struct MSACM_FormatTagEnumWtoA_Instance aftei;
    716716
     
    724724    aftei.fnCallback = fnCallback;
    725725
    726     return acmFormatTagEnumW(had, &aftdw, MSACM_FormatTagEnumCallbackWtoA,
    727                  (DWORD)&aftei, fdwEnum);
     726    return acmFormatTagEnumW(had, &aftdw, MSACM_FormatTagEnumCallbackWtoA, 
     727                             (DWORD)&aftei, fdwEnum);
    728728}
    729729
     
    732732 */
    733733MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
    734                   ACMFORMATTAGENUMCBW fnCallback, DWORD dwInstance,
    735                   DWORD fdwEnum)
    736 {
    737     PWINE_ACMDRIVERID       padid;
    738     ACMDRIVERDETAILSW       add;
    739     int             i;
    740     BOOL            bPcmDone = FALSE;
     734                                  ACMFORMATTAGENUMCBW fnCallback, DWORD dwInstance,
     735                                  DWORD fdwEnum)
     736{
     737    PWINE_ACMDRIVERID           padid;
     738    ACMDRIVERDETAILSW           add;
     739    int                         i;
     740    BOOL                        bPcmDone = FALSE;
    741741
    742742    TRACE("(0x%08x, %p, %p, %ld, %ld)\n",
    743       had, paftd, fnCallback, dwInstance, fdwEnum);
     743          had, paftd, fnCallback, dwInstance, fdwEnum);
    744744
    745745    if (paftd->cbStruct < sizeof(*paftd)) return MMSYSERR_INVALPARAM;
    746746
    747747    if (had) FIXME("had != NULL, not supported\n");
    748 
     748   
    749749    for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
    750     /* should check for codec only */
    751     if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) {
    752         add.cbStruct = sizeof(add);
    753 
    754         if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) == MMSYSERR_NOERROR) {
    755         for (i = 0; i < add.cFormatTags; i++) {
    756             paftd->dwFormatTagIndex = i;
    757             if (acmFormatTagDetailsW(had, paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
    758             if (paftd->dwFormatTag == WAVE_FORMAT_PCM) {
    759                 /* FIXME (EPP): I'm not sure this is the correct
    760                  * algorithm (should make more sense to apply the same
    761                  * for all already loaded formats, but this will do
    762                  * for now
    763                  */
    764                 if (bPcmDone) continue;
    765                 bPcmDone = TRUE;
    766             }
    767             if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance,
    768                       add.fdwSupport)) {
    769                 padid = NULL;
    770                 break;
    771             }
    772             }
    773         }
    774         }
    775     }
    776     acmDriverClose(had, 0);
     750        /* should check for codec only */
     751        if (padid->bEnabled && acmDriverOpen(&had, (HACMDRIVERID)padid, 0) == MMSYSERR_NOERROR) {
     752            add.cbStruct = sizeof(add);
     753
     754            if (acmDriverDetailsW((HACMDRIVERID)padid, &add, 0) == MMSYSERR_NOERROR) {
     755                for (i = 0; i < add.cFormatTags; i++) {
     756                    paftd->dwFormatTagIndex = i;
     757                    if (acmFormatTagDetailsW(had, paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
     758                        if (paftd->dwFormatTag == WAVE_FORMAT_PCM) {
     759                            /* FIXME (EPP): I'm not sure this is the correct
     760                             * algorithm (should make more sense to apply the same
     761                             * for all already loaded formats, but this will do
     762                             * for now
     763                             */
     764                            if (bPcmDone) continue;
     765                            bPcmDone = TRUE;
     766                        }
     767                        if (!(fnCallback)((HACMDRIVERID)padid, paftd, dwInstance,
     768                                          add.fdwSupport)) {
     769                            padid = NULL;
     770                            break;
     771                        }
     772                    }
     773                }
     774            }
     775        }
     776        acmDriverClose(had, 0);
    777777    }
    778778    return MMSYSERR_NOERROR;
  • trunk/src/msacm32/initterm.cpp

    r6648 r6712  
    1 /* $Id: initterm.cpp,v 1.7 2001-09-05 13:11:25 bird Exp $
    2  *
     1/*
    32 * DLL entry point
    43 *
     
    5453   case DLL_THREAD_ATTACH:
    5554   case DLL_THREAD_DETACH:
    56     return MSACM32_LibMain(hinstDLL, fdwReason, fImpLoad);
     55        return MSACM32_LibMain(hinstDLL, fdwReason, fImpLoad);
    5756
    5857   case DLL_PROCESS_DETACH:
    59     MSACM32_LibMain(hinstDLL, fdwReason, fImpLoad);
    60     ctordtorTerm();
    61     return TRUE;
     58        MSACM32_LibMain(hinstDLL, fdwReason, fImpLoad);
     59        ctordtorTerm();
     60        return TRUE;
    6261   }
    6362   return FALSE;
     
    8988         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9089
    91     dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
    92          if(dllHandle == 0)
    93         return 0UL;
     90        dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     91         if(dllHandle == 0) 
     92                return 0UL;
    9493
    9594         break;
    9695      case 1 :
    9796         if(dllHandle) {
    98         UnregisterLxDll(dllHandle);
     97                UnregisterLxDll(dllHandle);
    9998         }
    10099         break;
  • trunk/src/msacm32/internal.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: internal.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
    55 *
    66 *      Copyright 1998  Patrik Stridvall
    7  *        1999  Eric Pouech
     7 *                1999  Eric Pouech
    88 */
    99
     
    3434
    3535/***********************************************************************
    36  *           MSACM_RegisterDriver()
     36 *           MSACM_RegisterDriver() 
    3737 */
    3838PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
    39                        HINSTANCE hinstModule)
    40 {
     39                                       HINSTANCE hinstModule)
     40{ 
    4141    PWINE_ACMDRIVERID padid;
    4242
     
    6464    padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
    6565    if (MSACM_pLastACMDriverID)
    66     MSACM_pLastACMDriverID->pNextACMDriverID = padid;
     66        MSACM_pLastACMDriverID->pNextACMDriverID = padid;
    6767    MSACM_pLastACMDriverID = padid;
    6868    if (!MSACM_pFirstACMDriverID)
    69     MSACM_pFirstACMDriverID = padid;
    70 
     69        MSACM_pFirstACMDriverID = padid;
     70   
    7171    return padid;
    7272}
    7373
    7474/***********************************************************************
    75  *           MSACM_RegisterAllDrivers()
     75 *           MSACM_RegisterAllDrivers() 
    7676 */
    7777void MSACM_RegisterAllDrivers(void)
     
    8080    DWORD dwBufferLength;
    8181
    82     /* FIXME
     82    /* FIXME 
    8383     *  What if the user edits system.ini while the program is running?
    8484     *  Does Windows handle that?
    8585     */
    8686    if (MSACM_pFirstACMDriverID)
    87     return;
    88 
     87        return;
     88   
    8989    /* FIXME: Do not work! How do I determine the section length? */
    9090    dwBufferLength = 1024;
    91 /* EPP  GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
    92 
     91/* EPP  GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
     92   
    9393    pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength);
    9494    if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) {
    95     char* s = pszBuffer;
    96     while (*s) {
    97         if (!strncasecmp("MSACM.", s, 6)) {
    98         char *s2 = s;
    99         while (*s2 != '\0' && *s2 != '=') s2++;
    100         if (*s2) {
    101             *s2 = '\0';
    102             MSACM_RegisterDriver(s, s2 + 1, 0);
    103             *s2 = '=';
    104         }
    105         }
    106         s += strlen(s) + 1; /* Either next char or \0 */
     95        char* s = pszBuffer;
     96        while (*s) {
     97            if (!strncasecmp("MSACM.", s, 6)) {
     98                char *s2 = s;
     99                while (*s2 != '\0' && *s2 != '=') s2++;
     100                if (*s2) {
     101                    *s2 = '\0';
     102                    MSACM_RegisterDriver(s, s2 + 1, 0);
     103                    *s2 = '=';
     104                }
     105            } 
     106            s += strlen(s) + 1; /* Either next char or \0 */
     107        }
    107108    }
    108     }
    109 
     109   
    110110    HeapFree(MSACM_hHeap, 0, pszBuffer);
    111111
     
    119119{
    120120    PWINE_ACMDRIVERID pNextACMDriverID;
    121 
     121   
    122122    while (p->pACMDriverList)
    123     acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
    124 
     123        acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
     124   
    125125    if (p->pszDriverAlias)
    126     HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
     126        HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
    127127    if (p->pszFileName)
    128     HeapFree(MSACM_hHeap, 0, p->pszFileName);
    129 
     128        HeapFree(MSACM_hHeap, 0, p->pszFileName);
     129   
    130130    if (p == MSACM_pFirstACMDriverID)
    131     MSACM_pFirstACMDriverID = p->pNextACMDriverID;
     131        MSACM_pFirstACMDriverID = p->pNextACMDriverID;
    132132    if (p == MSACM_pLastACMDriverID)
    133     MSACM_pLastACMDriverID = p->pPrevACMDriverID;
     133        MSACM_pLastACMDriverID = p->pPrevACMDriverID;
    134134
    135135    if (p->pPrevACMDriverID)
    136     p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
     136        p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
    137137    if (p->pNextACMDriverID)
    138     p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
    139 
     138        p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
     139   
    140140    pNextACMDriverID = p->pNextACMDriverID;
    141 
     141   
    142142    HeapFree(MSACM_hHeap, 0, p);
    143 
     143   
    144144    return pNextACMDriverID;
    145145}
     
    162162PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj, DWORD type)
    163163{
    164     PWINE_ACMOBJ    pao = (PWINE_ACMOBJ)hObj;
     164    PWINE_ACMOBJ        pao = (PWINE_ACMOBJ)hObj;
    165165
    166166    if (pao == NULL || IsBadReadPtr(pao, sizeof(WINE_ACMOBJ)) ||
    167     ((type != WINE_ACMOBJ_DONTCARE) && (type != pao->dwType)))
    168     return NULL;
     167        ((type != WINE_ACMOBJ_DONTCARE) && (type != pao->dwType)))
     168        return NULL;
    169169    return pao;
    170170}
    171171
    172172/***********************************************************************
    173  *           MSACM_GetDriverID()
     173 *           MSACM_GetDriverID() 
    174174 */
    175175PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
     
    191191MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
    192192{
    193     PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
     193    PWINE_ACMDRIVER     pad = MSACM_GetDriver(had);
    194194
    195195    return pad ? SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2) : MMSYSERR_INVALHANDLE;
  • trunk/src/msacm32/msacm32_main.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: msacm32_main.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
    55 *
    66 *      Copyright 1998  Patrik Stridvall
    7  *        1999  Eric Pouech
     7 *                1999  Eric Pouech
    88 */
    99
     
    1717
    1818DEFAULT_DEBUG_CHANNEL(msacm);
    19 
     19       
    2020/**********************************************************************/
    21 
    22 HINSTANCE   MSACM_hInstance32 = 0;
     21       
     22HINSTANCE       MSACM_hInstance32 = 0;
    2323
    2424/***********************************************************************
    25  *           MSACM_LibMain (MSACM32.init)
     25 *           MSACM_LibMain (MSACM32.init) 
    2626 */
    2727BOOL WINAPI MSACM32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
     
    3434        MSACM_hInstance32 = hInstDLL;
    3535        MSACM_RegisterAllDrivers();
    36     break;
     36        break;
    3737    case DLL_PROCESS_DETACH:
    3838        MSACM_UnregisterAllDrivers();
     
    4040        MSACM_hHeap = (HANDLE) NULL;
    4141        MSACM_hInstance32 = (HINSTANCE)NULL;
    42     break;
     42        break;
    4343    case DLL_THREAD_ATTACH:
    44     break;
     44        break;
    4545    case DLL_THREAD_DETACH:
    46     break;
     46        break;
    4747    default:
    48     break;
     48        break;
    4949    }
    5050    return TRUE;
     
    6767    {
    6868    case VER_PLATFORM_WIN32_NT:
    69     return 0x04000565; /* 4.0.1381 */
     69        return 0x04000565; /* 4.0.1381 */
    7070    default:
    7171        FIXME("%ld not supported",version.dwPlatformId);
    7272    case VER_PLATFORM_WIN32_WINDOWS:
    73     return 0x04000000; /* 4.0.0 */
     73        return 0x04000000; /* 4.0.0 */
    7474  }
    7575}
     
    8686MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
    8787{
    88     PWINE_ACMOBJ    pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
    89     BOOL        bLocal = TRUE;
    90     PWINE_ACMDRIVERID   padid;
    91     DWORD       val = 0;
    92     MMRESULT        mmr = MMSYSERR_NOERROR;
     88    PWINE_ACMOBJ        pao = MSACM_GetObj(hao, WINE_ACMOBJ_DONTCARE);
     89    BOOL                bLocal = TRUE;
     90    PWINE_ACMDRIVERID   padid;
     91    DWORD               val = 0;
     92    MMRESULT            mmr = MMSYSERR_NOERROR;
    9393
    9494    TRACE("(0x%08x, %d, %p);\n", hao, uMetric, pMetric);
    95 
     95   
    9696    switch (uMetric) {
    9797    case ACM_METRIC_COUNT_DRIVERS:
    98     bLocal = FALSE;
    99     /* fall thru */
     98        bLocal = FALSE;
     99        /* fall thru */
    100100    case ACM_METRIC_COUNT_LOCAL_DRIVERS:
    101     if (!pao)
    102         return MMSYSERR_INVALHANDLE;
    103     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
    104         if (padid->bEnabled /* && (local(padid) || !bLocal) */)
    105         val++;
    106     *(LPDWORD)pMetric = val;
    107     break;
     101        if (!pao)
     102            return MMSYSERR_INVALHANDLE;
     103        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
     104            if (padid->bEnabled /* && (local(padid) || !bLocal) */)
     105                val++;
     106        *(LPDWORD)pMetric = val;
     107        break;
    108108
    109109    case ACM_METRIC_COUNT_CODECS:
    110     if (!pao)
    111         return MMSYSERR_INVALHANDLE;
    112     bLocal = FALSE;
    113     /* fall thru */
     110        if (!pao)
     111            return MMSYSERR_INVALHANDLE;
     112        bLocal = FALSE;
     113        /* fall thru */
    114114    case ACM_METRIC_COUNT_LOCAL_CODECS:
    115     /* FIXME: don't know how to differentiate codec, converters & filters yet */
    116     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
    117         if (padid->bEnabled /* && (local(padid) || !bLocal) */)
    118         val++;
    119     *(LPDWORD)pMetric = val;
    120     break;
     115        /* FIXME: don't know how to differentiate codec, converters & filters yet */
     116        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
     117            if (padid->bEnabled /* && (local(padid) || !bLocal) */)
     118                val++;
     119        *(LPDWORD)pMetric = val;
     120        break;
    121121
    122122    case ACM_METRIC_COUNT_CONVERTERS:
    123     bLocal = FALSE;
    124     /* fall thru */
     123        bLocal = FALSE;
     124        /* fall thru */
    125125    case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
    126     /* FIXME: don't know how to differentiate codec, converters & filters yet */
    127     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
    128         if (padid->bEnabled /* && (local(padid) || !bLocal) */)
    129         val++;
    130     *(LPDWORD)pMetric = val;
    131     break;
     126        /* FIXME: don't know how to differentiate codec, converters & filters yet */
     127        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
     128            if (padid->bEnabled /* && (local(padid) || !bLocal) */)
     129                val++;
     130        *(LPDWORD)pMetric = val;
     131        break;
    132132
    133133    case ACM_METRIC_COUNT_FILTERS:
    134     bLocal = FALSE;
    135     /* fall thru */
     134        bLocal = FALSE;
     135        /* fall thru */
    136136    case ACM_METRIC_COUNT_LOCAL_FILTERS:
    137     /* FIXME: don't know how to differentiate codec, converters & filters yet */
    138     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
    139         if (padid->bEnabled /* && (local(padid) || !bLocal) */)
    140         val++;
    141     *(LPDWORD)pMetric = val;
    142     break;
     137        /* FIXME: don't know how to differentiate codec, converters & filters yet */
     138        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
     139            if (padid->bEnabled /* && (local(padid) || !bLocal) */)
     140                val++;
     141        *(LPDWORD)pMetric = val;
     142        break;
    143143
    144144    case ACM_METRIC_COUNT_DISABLED:
    145     bLocal = FALSE;
    146     /* fall thru */
     145        bLocal = FALSE;
     146        /* fall thru */
    147147    case ACM_METRIC_COUNT_LOCAL_DISABLED:
    148     if (!pao)
    149         return MMSYSERR_INVALHANDLE;
    150     for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
    151         if (!padid->bEnabled /* && (local(padid) || !bLocal) */)
    152         val++;
    153     *(LPDWORD)pMetric = val;
    154     break;
     148        if (!pao)
     149            return MMSYSERR_INVALHANDLE; 
     150        for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
     151            if (!padid->bEnabled /* && (local(padid) || !bLocal) */)
     152                val++;
     153        *(LPDWORD)pMetric = val;
     154        break;
     155   
     156    case ACM_METRIC_MAX_SIZE_FORMAT:
     157        {
     158            ACMFORMATTAGDETAILSW        aftd;
    155159
    156     case ACM_METRIC_MAX_SIZE_FORMAT:
    157     {
    158         ACMFORMATTAGDETAILSW    aftd;
     160            aftd.cbStruct = sizeof(aftd);
     161            aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
    159162
    160         aftd.cbStruct = sizeof(aftd);
    161         aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
    162 
    163         if (hao == (HACMOBJ)NULL) {
    164         mmr = acmFormatTagDetailsW((HACMDRIVER)NULL, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
    165         } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVER)) {
    166         mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
    167         } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVERID)) {
    168         HACMDRIVER  had;
    169 
    170         if (acmDriverOpen(&had, (HACMDRIVERID)hao, 0) == 0) {
    171             mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
    172             acmDriverClose(had, 0);
    173         }
    174         } else {
    175         mmr = MMSYSERR_INVALHANDLE;
    176         }
    177         if (mmr == MMSYSERR_NOERROR) *(LPDWORD)pMetric = aftd.cbFormatSize;
    178     }
     163            if (hao == (HACMOBJ)NULL) {
     164                mmr = acmFormatTagDetailsW((HACMDRIVER)NULL, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
     165            } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVER)) {
     166                mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
     167            } else if (MSACM_GetObj(hao, WINE_ACMOBJ_DRIVERID)) {
     168                HACMDRIVER      had;
     169               
     170                if (acmDriverOpen(&had, (HACMDRIVERID)hao, 0) == 0) {
     171                    mmr = acmFormatTagDetailsW((HACMDRIVER)hao, &aftd, ACM_FORMATTAGDETAILSF_LARGESTSIZE);
     172                    acmDriverClose(had, 0);
     173                }
     174            } else {
     175                mmr = MMSYSERR_INVALHANDLE;
     176            }
     177            if (mmr == MMSYSERR_NOERROR) *(LPDWORD)pMetric = aftd.cbFormatSize;
     178        }
    179179        break;
    180180
     
    186186    case ACM_METRIC_DRIVER_PRIORITY:
    187187    default:
    188     FIXME("(0x%08x, %d, %p): stub\n", hao, uMetric, pMetric);
    189     mmr = MMSYSERR_NOTSUPPORTED;
     188        FIXME("(0x%08x, %d, %p): stub\n", hao, uMetric, pMetric);
     189        mmr = MMSYSERR_NOTSUPPORTED;
    190190    }
    191191    return mmr;
  • trunk/src/msacm32/pcmconverter.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: pcmconverter.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
    55 *
    6  *      Copyright 2000      Eric Pouech
    7  *
    8  *  FIXME / TODO list
    9  *  + most of the computation should be done in fixed point arithmetic
    10  *    instead of floating point (16 bits for integral part, and 16 bits
    11  *    for fractional part for example)
    12  *  + implement PCM_FormatSuggest function
    13  *  + get rid of hack for PCM_DriverProc (msacm32.dll shouldn't export
    14  *    a DriverProc, but this would require implementing a generic
    15  *    embedded driver handling scheme in msacm32.dll which isn't done yet
     6 *      Copyright 2000          Eric Pouech
     7 *
     8 *      FIXME / TODO list
     9 *      + most of the computation should be done in fixed point arithmetic
     10 *        instead of floating point (16 bits for integral part, and 16 bits
     11 *        for fractional part for example)
     12 *      + implement PCM_FormatSuggest function
     13 *      + get rid of hack for PCM_DriverProc (msacm32.dll shouldn't export
     14 *        a DriverProc, but this would require implementing a generic
     15 *        embedded driver handling scheme in msacm32.dll which isn't done yet
    1616 */
    1717
     
    3535 *           PCM_drvOpen
    3636 */
    37 static  DWORD   PCM_drvOpen(LPCSTR str)
     37static  DWORD   PCM_drvOpen(LPCSTR str)
    3838{
    3939    return 1;
     
    4343 *           PCM_drvClose
    4444 */
    45 static  DWORD   PCM_drvClose(DWORD dwDevID)
     45static  DWORD   PCM_drvClose(DWORD dwDevID)
    4646{
    4747    return 1;
    4848}
    4949
    50 #define NUM_PCM_FORMATS (sizeof(PCM_Formats) / sizeof(PCM_Formats[0]))
    51 #define NUM_OF(a,b) (((a)+(b)-1)/(b))
     50#define NUM_PCM_FORMATS (sizeof(PCM_Formats) / sizeof(PCM_Formats[0]))
     51#define NUM_OF(a,b)     (((a)+(b)-1)/(b))
    5252
    5353/* flags for fdwDriver */
    54 #define PCM_RESAMPLE    1
     54#define PCM_RESAMPLE    1
    5555
    5656/* data used while converting */
     
    5858    /* conversion routine, depending if rate conversion is required */
    5959    union {
    60     void (*cvtKeepRate)(const unsigned char*, int, unsigned char*);
    61     void (*cvtChangeRate)(struct tagAcmPcmData*, const unsigned char*,
    62                   LPDWORD, unsigned char*, LPDWORD);
     60        void (*cvtKeepRate)(const unsigned char*, int, unsigned char*);
     61        void (*cvtChangeRate)(struct tagAcmPcmData*, const unsigned char*,
     62                              LPDWORD, unsigned char*, LPDWORD);
    6363    } cvt;
    6464    /* the following fields are used only with rate conversion) */
    65     DWORD   srcPos;     /* position in source stream */
    66     double  dstPos;     /* position in destination stream */
    67     double  dstIncr;    /* value to increment dst stream when src stream
    68                    is incremented by 1 */
     65    DWORD       srcPos;         /* position in source stream */
     66    double      dstPos;         /* position in destination stream */
     67    double      dstIncr;        /* value to increment dst stream when src stream
     68                                   is incremented by 1 */
    6969    /* last source stream value read */
    7070    union {
    71     unsigned char   b;  /*  8 bit value */
    72     short       s;  /* 16 bit value */
     71        unsigned char   b;      /*  8 bit value */
     72        short           s;      /* 16 bit value */
    7373    } last[2]; /* two channels max (stereo) */
    7474} AcmPcmData;
     
    7777 * also helps given a unique index to each of the supported formats
    7878 */
    79 static  struct {
    80     int     nChannels;
    81     int     nBits;
    82     int     rate;
     79static  struct {
     80    int         nChannels;
     81    int         nBits;
     82    int         rate;
    8383} PCM_Formats[] = {
    8484    {1,  8,  8000}, {2,  8,  8000}, {1, 16,  8000}, {2, 16,  8000},
     
    9191 *           PCM_GetFormatIndex
    9292 */
    93 static  DWORD   PCM_GetFormatIndex(LPWAVEFORMATEX wfx)
     93static  DWORD   PCM_GetFormatIndex(LPWAVEFORMATEX wfx)
    9494{
    9595    int i;
    96 
     96   
    9797    for (i = 0; i < NUM_PCM_FORMATS; i++) {
    98     if (wfx->nChannels == PCM_Formats[i].nChannels &&
    99         wfx->nSamplesPerSec == PCM_Formats[i].rate &&
    100         wfx->wBitsPerSample == PCM_Formats[i].nBits)
    101         return i;
     98        if (wfx->nChannels == PCM_Formats[i].nChannels &&
     99            wfx->nSamplesPerSec == PCM_Formats[i].rate &&
     100            wfx->wBitsPerSample == PCM_Formats[i].nBits)
     101            return i;
    102102    }
    103103    return 0xFFFFFFFF;
     
    107107 *
    108108 * parameters:
    109  *  + 8 bit unsigned vs 16 bit signed
    110  *  + mono vs stereo (1 or 2 channels)
    111  *  + sampling rate (8.0, 11.025, 22.05, 44.1 kHz are defined, but algo shall work
    112  *    in all cases)
     109 *      + 8 bit unsigned vs 16 bit signed
     110 *      + mono vs stereo (1 or 2 channels)
     111 *      + sampling rate (8.0, 11.025, 22.05, 44.1 kHz are defined, but algo shall work
     112 *        in all cases)
    113113 *
    114114 * mono => stereo: copy the same sample on Left & Right channels
    115115 * stereo =) mono: use the average value of samples from Left & Right channels
    116116 * resampling; we lookup for each destination sample the two source adjacent samples
    117  *  were src <= dst < src+1 (dst is increased by a fractional value which is
    118  *  equivalent to the increment by one on src); then we use a linear
    119  *  interpolation between src and src+1
     117 *      were src <= dst < src+1 (dst is increased by a fractional value which is
     118 *      equivalent to the increment by one on src); then we use a linear
     119 *      interpolation between src and src+1
    120120 */
    121121
     
    125125 * Converts a 8 bit sample to a 16 bit one
    126126 */
    127 static inline short C816(unsigned char b)
     127static inline short C816(unsigned char b) 
    128128{
    129129    return (short)(b ^ 0x80) * 256;
     
    135135 * Converts a 16 bit sample to a 8 bit one (data loss !!)
    136136 */
    137 static inline unsigned char C168(short s)
     137static inline unsigned char C168(short s) 
    138138{
    139139    return HIBYTE(s) ^ (unsigned char)0x80;
     
    164164 *           M16
    165165 *
    166  * Convert the (l,r) 16 bit stereo sample into a 16 bit mono
     166 * Convert the (l,r) 16 bit stereo sample into a 16 bit mono 
    167167 * (takes the mid-point of the two values)
    168168 */
     
    175175 *           M8
    176176 *
    177  * Convert the (l,r) 8 bit stereo sample into a 8 bit mono
     177 * Convert the (l,r) 8 bit stereo sample into a 8 bit mono 
    178178 * (takes the mid-point of the two values)
    179179 */
     
    194194 */
    195195
    196 static  void cvtMM88K(const unsigned char* src, int ns, unsigned char* dst)
     196static  void cvtMM88K(const unsigned char* src, int ns, unsigned char* dst)
    197197{
    198198    memcpy(dst, src, ns);
    199199}
    200200
    201 static  void cvtSS88K(const unsigned char* src, int ns, unsigned char* dst)
     201static  void cvtSS88K(const unsigned char* src, int ns, unsigned char* dst)
    202202{
    203203    memcpy(dst, src, ns * 2);
    204204}
    205205
    206 static  void cvtMM1616K(const unsigned char* src, int ns, unsigned char* dst)
     206static  void cvtMM1616K(const unsigned char* src, int ns, unsigned char* dst)
    207207{
    208208    memcpy(dst, src, ns * 2);
    209209}
    210210
    211 static  void cvtSS1616K(const unsigned char* src, int ns, unsigned char* dst)
     211static  void cvtSS1616K(const unsigned char* src, int ns, unsigned char* dst)
    212212{
    213213    memcpy(dst, src, ns * 4);
    214214}
    215215
    216 static  void cvtMS88K(const unsigned char* src, int ns, unsigned char* dst)
    217 {
    218     while (ns--) {
    219     *dst++ = *src;
    220     *dst++ = *src++;
    221     }
    222 }
    223 
    224 static  void cvtMS816K(const unsigned char* src, int ns, unsigned char* dst)
    225 {
    226     short   v;
    227 
    228     while (ns--) {
    229     v = C816(*src++);
    230     W16(dst, v);        dst += 2;
    231     W16(dst, v);        dst += 2;
    232     }
    233 }
    234 
    235 static  void cvtMS168K(const unsigned char* src, int ns, unsigned char* dst)
     216static  void cvtMS88K(const unsigned char* src, int ns, unsigned char* dst)
     217{
     218    while (ns--) {
     219        *dst++ = *src;
     220        *dst++ = *src++;
     221    }
     222}
     223
     224static  void cvtMS816K(const unsigned char* src, int ns, unsigned char* dst)
     225{
     226    short       v;
     227   
     228    while (ns--) {
     229        v = C816(*src++);
     230        W16(dst, v);            dst += 2;
     231        W16(dst, v);            dst += 2;
     232    }
     233}
     234
     235static  void cvtMS168K(const unsigned char* src, int ns, unsigned char* dst)
    236236{
    237237    unsigned char v;
    238 
    239     while (ns--) {
    240     v = C168(R16(src));     src += 2;
    241     *dst++ = v;
    242     *dst++ = v;
    243     }
    244 }
    245 
    246 static  void cvtMS1616K(const unsigned char* src, int ns, unsigned char* dst)
    247 {
    248     short   v;
    249 
    250     while (ns--) {
    251     v = R16(src);       src += 2;
    252     W16(dst, v);        dst += 2;
    253     W16(dst, v);        dst += 2;
    254     }
    255 }
    256 
    257 static  void cvtSM88K(const unsigned char* src, int ns, unsigned char* dst)
    258 {
    259     while (ns--) {
    260     *dst++ = M8(src[0], src[1]);
    261     src += 2;
    262     }
    263 }
    264 
    265 static  void cvtSM816K(const unsigned char* src, int ns, unsigned char* dst)
    266 {
    267     short   v;
    268 
    269     while (ns--) {
    270     v = M16(C816(src[0]), C816(src[1]));
    271     src += 2;
    272     W16(dst, v);        dst += 2;
    273     }
    274 }
    275 
    276 static  void cvtSM168K(const unsigned char* src, int ns, unsigned char* dst)
    277 {
    278     while (ns--) {
    279     *dst++ = C168(M16(R16(src), R16(src + 2)));
    280     src += 4;
    281     }
    282 }
    283 
    284 static  void cvtSM1616K(const unsigned char* src, int ns, unsigned char* dst)
    285 {
    286     while (ns--) {
    287     W16(dst, M16(R16(src),R16(src+2))); dst += 2;
    288     src += 4;
    289     }
    290 }
    291 
    292 static  void cvtMM816K(const unsigned char* src, int ns, unsigned char* dst)
    293 {
    294     while (ns--) {
    295     W16(dst, C816(*src++));     dst += 2;
    296     }
    297 }
    298 
    299 static  void cvtSS816K(const unsigned char* src, int ns, unsigned char* dst)
    300 {
    301     while (ns--) {
    302     W16(dst, C816(*src++)); dst += 2;
    303     W16(dst, C816(*src++)); dst += 2;
    304     }
    305 }
    306 
    307 static  void cvtMM168K(const unsigned char* src, int ns, unsigned char* dst)
    308 {
    309     while (ns--) {
    310     *dst++ = C168(R16(src));    src += 2;
    311     }
    312 }
    313 
    314 static  void cvtSS168K(const unsigned char* src, int ns, unsigned char* dst)
    315 {
    316     while (ns--) {
    317     *dst++ = C168(R16(src));    src += 2;
    318     *dst++ = C168(R16(src));    src += 2;
    319     }
    320 }
    321 
    322 static  void (*PCM_ConvertKeepRate[16])(const unsigned char*, int, unsigned char*) = {
    323     cvtSS88K,   cvtSM88K,   cvtMS88K,   cvtMM88K,
    324     cvtSS816K,  cvtSM816K,  cvtMS816K,  cvtMM816K,
    325     cvtSS168K,  cvtSM168K,  cvtMS168K,  cvtMM168K,
     238   
     239    while (ns--) {
     240        v = C168(R16(src));             src += 2;
     241        *dst++ = v;
     242        *dst++ = v;
     243    }
     244}
     245
     246static  void cvtMS1616K(const unsigned char* src, int ns, unsigned char* dst)
     247{
     248    short       v;
     249
     250    while (ns--) {
     251        v = R16(src);           src += 2;
     252        W16(dst, v);            dst += 2;
     253        W16(dst, v);            dst += 2;
     254    }
     255}
     256
     257static  void cvtSM88K(const unsigned char* src, int ns, unsigned char* dst)
     258{
     259    while (ns--) {
     260        *dst++ = M8(src[0], src[1]);
     261        src += 2;
     262    }
     263}
     264
     265static  void cvtSM816K(const unsigned char* src, int ns, unsigned char* dst)
     266{
     267    short       v;
     268   
     269    while (ns--) {
     270        v = M16(C816(src[0]), C816(src[1]));
     271        src += 2;
     272        W16(dst, v);            dst += 2;
     273    }
     274}
     275
     276static  void cvtSM168K(const unsigned char* src, int ns, unsigned char* dst)
     277{
     278    while (ns--) {
     279        *dst++ = C168(M16(R16(src), R16(src + 2)));
     280        src += 4;
     281    }
     282}
     283
     284static  void cvtSM1616K(const unsigned char* src, int ns, unsigned char* dst)
     285{
     286    while (ns--) {
     287        W16(dst, M16(R16(src),R16(src+2)));     dst += 2;
     288        src += 4;
     289    }
     290}
     291
     292static  void cvtMM816K(const unsigned char* src, int ns, unsigned char* dst)
     293{
     294    while (ns--) {
     295        W16(dst, C816(*src++));         dst += 2;
     296    }
     297}
     298
     299static  void cvtSS816K(const unsigned char* src, int ns, unsigned char* dst)
     300{
     301    while (ns--) {
     302        W16(dst, C816(*src++)); dst += 2;
     303        W16(dst, C816(*src++)); dst += 2;
     304    }
     305}
     306
     307static  void cvtMM168K(const unsigned char* src, int ns, unsigned char* dst)
     308{
     309    while (ns--) {
     310        *dst++ = C168(R16(src));        src += 2;
     311    }
     312}
     313
     314static  void cvtSS168K(const unsigned char* src, int ns, unsigned char* dst)
     315{
     316    while (ns--) {
     317        *dst++ = C168(R16(src));        src += 2;
     318        *dst++ = C168(R16(src));        src += 2;
     319    }
     320}
     321
     322static  void (*PCM_ConvertKeepRate[16])(const unsigned char*, int, unsigned char*) = {
     323    cvtSS88K,   cvtSM88K,   cvtMS88K,   cvtMM88K,
     324    cvtSS816K,  cvtSM816K,  cvtMS816K,  cvtMM816K,
     325    cvtSS168K,  cvtSM168K,  cvtMS168K,  cvtMM168K,
    326326    cvtSS1616K, cvtSM1616K, cvtMS1616K, cvtMM1616K,
    327327};
     
    333333 * Linear interpolation is used
    334334 */
    335 static  inline double   I(double v1, double v2, double r)
     335static  inline double   I(double v1, double v2, double r)
    336336{
    337337    if (0.0 >= r || r > 1.0) FIXME("r!! %f\n", r);
     
    339339}
    340340
    341 static  void cvtSS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    342               unsigned char* dst, LPDWORD ndst)
    343 {
    344     double          r;
    345 
    346     while (*nsrc != 0 && *ndst != 0) {
    347     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    348         if (*nsrc == 0) return;
    349         apd->last[0].b = *src++;
    350         apd->last[1].b = *src++;
    351         apd->srcPos++;
    352         (*nsrc)--;
    353     }
    354     /* now do the interpolation */
    355     *dst++ = I(apd->last[0].b, src[0], r);
    356     *dst++ = I(apd->last[1].b, src[1], r);
    357     apd->dstPos += apd->dstIncr;
    358     (*ndst)--;
     341static  void cvtSS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     342                      unsigned char* dst, LPDWORD ndst)
     343{
     344    double              r;
     345
     346    while (*nsrc != 0 && *ndst != 0) {
     347        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     348            if (*nsrc == 0) return;
     349            apd->last[0].b = *src++;
     350            apd->last[1].b = *src++;
     351            apd->srcPos++;
     352            (*nsrc)--;
     353        }
     354        /* now do the interpolation */
     355        *dst++ = I(apd->last[0].b, src[0], r);
     356        *dst++ = I(apd->last[1].b, src[1], r);
     357        apd->dstPos += apd->dstIncr;
     358        (*ndst)--;
    359359    }
    360360}
     
    368368 *
    369369 */
    370 static  void cvtSM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    371               unsigned char* dst, LPDWORD ndst)
    372 {
    373     double      r;
    374 
    375     while (*nsrc != 0 && *ndst != 0) {
    376     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    377         if (*nsrc == 0) return;
    378         apd->last[0].b = *src++;
    379         apd->last[1].b = *src++;
    380         apd->srcPos++;
    381         (*nsrc)--;
    382     }
    383     /* now do the interpolation */
    384     *dst++ = I(M8(apd->last[0].b, apd->last[1].b), M8(src[0], src[1]), r);
    385     apd->dstPos += apd->dstIncr;
    386     (*ndst)--;
    387     }
    388 }
    389 
    390 static  void cvtMS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    391               unsigned char* dst, LPDWORD ndst)
    392 {
    393     double  r;
    394 
    395     while (*nsrc != 0 && *ndst != 0) {
    396     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    397         if (*nsrc == 0) return;
    398         apd->last[0].b = *src++;
    399         apd->srcPos++;
    400         (*nsrc)--;
    401     }
    402     /* now do the interpolation */
    403     dst[0] = dst[1] = I(apd->last[0].b, src[0], r);
    404     dst += 2;
    405     apd->dstPos += apd->dstIncr;
    406     (*ndst)--;
    407     }
    408 }
    409 
    410 static  void cvtMM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    411               unsigned char* dst, LPDWORD ndst)
    412 {
    413     double      r;
    414 
    415     while (*nsrc != 0 && *ndst != 0) {
    416     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    417         if (*nsrc == 0) return;
    418         apd->last[0].b = *src++;
    419         apd->srcPos++;
    420         (*nsrc)--;
    421     }
    422     /* now do the interpolation */
    423     *dst++ = I(apd->last[0].b, src[0], r);
    424     apd->dstPos += apd->dstIncr;
    425     (*ndst)--;
    426     }
    427 }
    428 
    429 static  void cvtSS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    430                unsigned char* dst, LPDWORD ndst)
    431 {
    432     double  r;
    433 
    434     while (*nsrc != 0 && *ndst != 0) {
    435     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    436         if (*nsrc == 0) return;
    437         apd->last[0].b = *src++;
    438         apd->last[1].b = *src++;
    439         apd->srcPos++;
    440         (*nsrc)--;
    441     }
    442     /* now do the interpolation */
    443     W16(dst, I(C816(apd->last[0].b), C816(src[0]), r)); dst += 2;
    444     W16(dst, I(C816(apd->last[1].b), C816(src[1]), r)); dst += 2;
    445     apd->dstPos += apd->dstIncr;
    446     (*ndst)--;
    447     }
    448 }
    449 
    450 static  void cvtSM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    451             unsigned char* dst, LPDWORD ndst)
    452 {
    453     double      r;
    454 
    455     while (*nsrc != 0 && *ndst != 0) {
    456     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    457         if (*nsrc == 0) return;
    458         apd->last[0].b = *src++;
    459         apd->last[1].b = *src++;
    460         apd->srcPos++;
    461         (*nsrc)--;
    462     }
    463     /* now do the interpolation */
    464     W16(dst, I(M16(C816(apd->last[0].b), C816(apd->last[1].b)),
    465             M16(C816(src[0]), C816(src[1])), r));
    466     dst += 2;
    467     apd->dstPos += apd->dstIncr;
    468     (*ndst)--;
    469     }
    470 }
    471 
    472 static  void cvtMS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    473             unsigned char* dst, LPDWORD ndst)
    474 {
    475     double      r;
    476     short   v;
    477 
    478     while (*nsrc != 0 && *ndst != 0) {
    479     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    480         if (*nsrc == 0) return;
    481         apd->last[0].b = *src++;
    482         apd->srcPos++;
    483         (*nsrc)--;
    484     }
    485     /* now do the interpolation */
    486     v = I(C816(apd->last[0].b), C816(src[0]), r);
    487     W16(dst, v);        dst += 2;
    488     W16(dst, v);        dst += 2;
    489     apd->dstPos += apd->dstIncr;
    490     (*ndst)--;
    491     }
    492 }
    493 
    494 static  void cvtMM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    495             unsigned char* dst, LPDWORD ndst)
    496 {
    497     double      r;
    498 
    499     while (*nsrc != 0 && *ndst != 0) {
    500     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    501         if (*nsrc == 0) return;
    502         apd->last[0].b = *src++;
    503         apd->srcPos++;
    504         (*nsrc)--;
    505     }
    506     /* now do the interpolation */
    507     W16(dst, I(C816(apd->last[0].b), C816(src[0]), r));
    508     dst += 2;
    509     apd->dstPos += apd->dstIncr;
    510     (*ndst)--;
    511     }
    512 }
    513 
    514 static  void cvtSS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    515             unsigned char* dst, LPDWORD ndst)
    516 {
    517     double      r;
    518 
    519     while (*nsrc != 0 && *ndst != 0) {
    520     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    521         if (*nsrc == 0) return;
    522         apd->last[0].s = R16(src);  src += 2;
    523         apd->last[1].s = R16(src);  src += 2;
    524         apd->srcPos++;
    525         (*nsrc)--;
    526     }
    527     /* now do the interpolation */
    528     *dst++ = C168(I(apd->last[0].s, R16(src)  , r));
    529     *dst++ = C168(I(apd->last[1].s, R16(src+2), r));
    530     apd->dstPos += apd->dstIncr;
    531     (*ndst)--;
    532     }
    533 }
    534 
    535 static  void cvtSM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    536             unsigned char* dst, LPDWORD ndst)
    537 {
    538     double      r;
    539 
    540     while (*nsrc != 0 && *ndst != 0) {
    541     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    542         if (*nsrc == 0) return;
    543         apd->last[0].s = R16(src);  src += 2;
    544         apd->last[1].s = R16(src);  src += 2;
    545         apd->srcPos++;
    546         (*nsrc)--;
    547     }
    548     /* now do the interpolation */
    549     *dst++ = C168(I(M16(apd->last[0].s, apd->last[1].s),
    550             M16(R16(src), R16(src + 2)), r));
    551     apd->dstPos += apd->dstIncr;
    552     (*ndst)--;
    553     }
    554 }
    555 
    556 
    557 static  void cvtMS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    558             unsigned char* dst, LPDWORD ndst)
    559 {
    560     double      r;
    561 
    562     while (*nsrc != 0 && *ndst != 0) {
    563     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    564         if (*nsrc == 0) return;
    565         apd->last[0].s = R16(src);  src += 2;
    566         apd->srcPos++;
    567         (*nsrc)--;
    568     }
    569     /* now do the interpolation */
    570     dst[0] = dst[1] = C168(I(apd->last[0].s, R16(src), r)); dst += 2;
    571     apd->dstPos += apd->dstIncr;
    572     (*ndst)--;
    573     }
    574 }
    575 
    576 
    577 static  void cvtMM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    578             unsigned char* dst, LPDWORD ndst)
    579 {
    580     double      r;
    581 
    582     while (*nsrc != 0 && *ndst != 0) {
    583     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    584         if (*nsrc == 0) return;
    585         apd->last[0].s = R16(src);  src += 2;
    586         apd->srcPos++;
    587         (*nsrc)--;
    588     }
    589     /* now do the interpolation */
    590     *dst++ = C168(I(apd->last[0].s, R16(src), r));
    591     apd->dstPos += apd->dstIncr;
    592     (*ndst)--;
    593     }
    594 }
    595 
    596 static  void cvtSS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    597             unsigned char* dst, LPDWORD ndst)
    598 {
    599     double      r;
    600 
    601     while (*nsrc != 0 && *ndst != 0) {
    602     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    603         if (*nsrc == 0) return;
    604         apd->last[0].s = R16(src);  src += 2;
    605         apd->last[1].s = R16(src);  src += 2;
    606         apd->srcPos++;
    607         (*nsrc)--;
    608     }
    609     /* now do the interpolation */
    610     W16(dst, I(apd->last[0].s, R16(src)  , r)); dst += 2;
    611     W16(dst, I(apd->last[1].s, R16(src+2), r)); dst += 2;
    612     apd->dstPos += apd->dstIncr;
    613     (*ndst)--;
    614     }
    615 }
    616 
    617 static  void cvtSM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    618             unsigned char* dst, LPDWORD ndst)
    619 {
    620     double      r;
    621 
    622     while (*nsrc != 0 && *ndst != 0) {
    623     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    624         if (*nsrc == 0) return;
    625         apd->last[0].s = R16(src);  src += 2;
    626         apd->last[1].s = R16(src);  src += 2;
    627         apd->srcPos++;
    628         (*nsrc)--;
    629     }
    630     /* now do the interpolation */
    631     W16(dst, I(M16(apd->last[0].s, apd->last[1].s),
    632            M16(R16(src), R16(src+2)), r));
    633     dst += 2;
    634     apd->dstPos += apd->dstIncr;
    635     (*ndst)--;
    636     }
    637 }
    638 
    639 static  void cvtMS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    640             unsigned char* dst, LPDWORD ndst)
    641 {
    642     double      r;
    643     short   v;
    644 
    645     while (*nsrc != 0 && *ndst != 0) {
    646     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    647         if (*nsrc == 0) return;
    648         apd->last[0].s = R16(src);  src += 2;
    649         apd->srcPos++;
    650         (*nsrc)--;
    651     }
    652     /* now do the interpolation */
    653     v = I(apd->last[0].s, R16(src), r);
    654     W16(dst, v);        dst += 2;
    655     W16(dst, v);        dst += 2;
    656     apd->dstPos += apd->dstIncr;
    657     (*ndst)--;
    658     }
    659 }
    660 
    661 static  void cvtMM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
    662             unsigned char* dst, LPDWORD ndst)
    663 {
    664     double      r;
    665 
    666     while (*nsrc != 0 && *ndst != 0) {
    667     while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
    668         if (*nsrc == 0) return;
    669         apd->last[0].s = R16(src);  src += 2;
    670         apd->srcPos++;
    671         (*nsrc)--;
    672     }
    673     /* now do the interpolation */
    674     W16(dst, I(apd->last[0].s, R16(src), r));   dst += 2;
    675     apd->dstPos += apd->dstIncr;
    676     (*ndst)--;
    677     }
    678 }
    679 
    680 static  void (*PCM_ConvertChangeRate[16])(AcmPcmData* apd,
    681                       const unsigned char* src, LPDWORD nsrc,
    682                       unsigned char* dst, LPDWORD ndst) = {
     370static  void cvtSM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     371                      unsigned char* dst, LPDWORD ndst)
     372{
     373    double      r;
     374
     375    while (*nsrc != 0 && *ndst != 0) {
     376        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     377            if (*nsrc == 0) return;
     378            apd->last[0].b = *src++;
     379            apd->last[1].b = *src++;
     380            apd->srcPos++;
     381            (*nsrc)--;
     382        }
     383        /* now do the interpolation */
     384        *dst++ = I(M8(apd->last[0].b, apd->last[1].b), M8(src[0], src[1]), r);
     385        apd->dstPos += apd->dstIncr;
     386        (*ndst)--;
     387    }
     388}
     389
     390static  void cvtMS88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     391                      unsigned char* dst, LPDWORD ndst)
     392{
     393    double      r;
     394
     395    while (*nsrc != 0 && *ndst != 0) {
     396        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     397            if (*nsrc == 0) return;
     398            apd->last[0].b = *src++;
     399            apd->srcPos++;
     400            (*nsrc)--;
     401        }
     402        /* now do the interpolation */
     403        dst[0] = dst[1] = I(apd->last[0].b, src[0], r);
     404        dst += 2;
     405        apd->dstPos += apd->dstIncr;
     406        (*ndst)--;
     407    }
     408}
     409
     410static  void cvtMM88C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     411                      unsigned char* dst, LPDWORD ndst)
     412{
     413    double      r;
     414
     415    while (*nsrc != 0 && *ndst != 0) {
     416        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     417            if (*nsrc == 0) return;
     418            apd->last[0].b = *src++;
     419            apd->srcPos++;
     420            (*nsrc)--;
     421        }
     422        /* now do the interpolation */
     423        *dst++ = I(apd->last[0].b, src[0], r);
     424        apd->dstPos += apd->dstIncr;
     425        (*ndst)--;
     426    }
     427}
     428
     429static  void cvtSS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     430                       unsigned char* dst, LPDWORD ndst)
     431{
     432    double      r;
     433       
     434    while (*nsrc != 0 && *ndst != 0) {
     435        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     436            if (*nsrc == 0) return;
     437            apd->last[0].b = *src++;
     438            apd->last[1].b = *src++;
     439            apd->srcPos++;
     440            (*nsrc)--;
     441        }
     442        /* now do the interpolation */
     443        W16(dst, I(C816(apd->last[0].b), C816(src[0]), r));     dst += 2;
     444        W16(dst, I(C816(apd->last[1].b), C816(src[1]), r));     dst += 2;
     445        apd->dstPos += apd->dstIncr;
     446        (*ndst)--;
     447    }
     448}
     449
     450static  void cvtSM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     451                        unsigned char* dst, LPDWORD ndst)
     452{
     453    double      r;
     454
     455    while (*nsrc != 0 && *ndst != 0) {
     456        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     457            if (*nsrc == 0) return;
     458            apd->last[0].b = *src++;
     459            apd->last[1].b = *src++;
     460            apd->srcPos++;
     461            (*nsrc)--;
     462        }
     463        /* now do the interpolation */
     464        W16(dst, I(M16(C816(apd->last[0].b), C816(apd->last[1].b)),
     465                    M16(C816(src[0]), C816(src[1])), r));
     466        dst += 2;
     467        apd->dstPos += apd->dstIncr;
     468        (*ndst)--;
     469    }
     470}
     471
     472static  void cvtMS816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     473                        unsigned char* dst, LPDWORD ndst)
     474{
     475    double      r;
     476    short       v;
     477
     478    while (*nsrc != 0 && *ndst != 0) {
     479        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     480            if (*nsrc == 0) return;
     481            apd->last[0].b = *src++;
     482            apd->srcPos++;
     483            (*nsrc)--;
     484        }
     485        /* now do the interpolation */
     486        v = I(C816(apd->last[0].b), C816(src[0]), r);
     487        W16(dst, v);            dst += 2;
     488        W16(dst, v);            dst += 2;
     489        apd->dstPos += apd->dstIncr;
     490        (*ndst)--;
     491    }
     492}
     493
     494static  void cvtMM816C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     495                        unsigned char* dst, LPDWORD ndst)
     496{
     497    double      r;
     498
     499    while (*nsrc != 0 && *ndst != 0) {
     500        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     501            if (*nsrc == 0) return;
     502            apd->last[0].b = *src++;
     503            apd->srcPos++;
     504            (*nsrc)--;
     505        }
     506        /* now do the interpolation */
     507        W16(dst, I(C816(apd->last[0].b), C816(src[0]), r));
     508        dst += 2;
     509        apd->dstPos += apd->dstIncr;
     510        (*ndst)--;
     511    }
     512}
     513
     514static  void cvtSS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     515                        unsigned char* dst, LPDWORD ndst)
     516{
     517    double      r;
     518
     519    while (*nsrc != 0 && *ndst != 0) {
     520        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     521            if (*nsrc == 0) return;
     522            apd->last[0].s = R16(src);  src += 2;
     523            apd->last[1].s = R16(src);  src += 2;
     524            apd->srcPos++;
     525            (*nsrc)--;
     526        }
     527        /* now do the interpolation */
     528        *dst++ = C168(I(apd->last[0].s, R16(src)  , r));
     529        *dst++ = C168(I(apd->last[1].s, R16(src+2), r));
     530        apd->dstPos += apd->dstIncr;
     531        (*ndst)--;
     532    }
     533}
     534
     535static  void cvtSM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     536                        unsigned char* dst, LPDWORD ndst)
     537{
     538    double      r;
     539
     540    while (*nsrc != 0 && *ndst != 0) {
     541        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     542            if (*nsrc == 0) return;
     543            apd->last[0].s = R16(src);  src += 2;
     544            apd->last[1].s = R16(src);  src += 2;
     545            apd->srcPos++;
     546            (*nsrc)--;
     547        }
     548        /* now do the interpolation */
     549        *dst++ = C168(I(M16(apd->last[0].s, apd->last[1].s),
     550                        M16(R16(src), R16(src + 2)), r));
     551        apd->dstPos += apd->dstIncr;
     552        (*ndst)--;
     553    }
     554}
     555
     556
     557static  void cvtMS168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     558                        unsigned char* dst, LPDWORD ndst)
     559{
     560    double      r;
     561
     562    while (*nsrc != 0 && *ndst != 0) {
     563        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     564            if (*nsrc == 0) return;
     565            apd->last[0].s = R16(src);  src += 2;
     566            apd->srcPos++;
     567            (*nsrc)--;
     568        }
     569        /* now do the interpolation */
     570        dst[0] = dst[1] = C168(I(apd->last[0].s, R16(src), r)); dst += 2;
     571        apd->dstPos += apd->dstIncr;
     572        (*ndst)--;
     573    }
     574}
     575
     576
     577static  void cvtMM168C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     578                        unsigned char* dst, LPDWORD ndst)
     579{
     580    double      r;
     581
     582    while (*nsrc != 0 && *ndst != 0) {
     583        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     584            if (*nsrc == 0) return;
     585            apd->last[0].s = R16(src);  src += 2;
     586            apd->srcPos++;
     587            (*nsrc)--;
     588        }
     589        /* now do the interpolation */
     590        *dst++ = C168(I(apd->last[0].s, R16(src), r));
     591        apd->dstPos += apd->dstIncr;
     592        (*ndst)--;
     593    }
     594}
     595
     596static  void cvtSS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     597                        unsigned char* dst, LPDWORD ndst)
     598{
     599    double      r;
     600
     601    while (*nsrc != 0 && *ndst != 0) {
     602        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     603            if (*nsrc == 0) return;
     604            apd->last[0].s = R16(src);  src += 2;
     605            apd->last[1].s = R16(src);  src += 2;
     606            apd->srcPos++;
     607            (*nsrc)--;
     608        }
     609        /* now do the interpolation */
     610        W16(dst, I(apd->last[0].s, R16(src)  , r));     dst += 2;
     611        W16(dst, I(apd->last[1].s, R16(src+2), r));     dst += 2;
     612        apd->dstPos += apd->dstIncr;
     613        (*ndst)--;
     614    }
     615}
     616
     617static  void cvtSM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     618                        unsigned char* dst, LPDWORD ndst)
     619{
     620    double      r;
     621
     622    while (*nsrc != 0 && *ndst != 0) {
     623        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     624            if (*nsrc == 0) return;
     625            apd->last[0].s = R16(src);  src += 2;
     626            apd->last[1].s = R16(src);  src += 2;
     627            apd->srcPos++;
     628            (*nsrc)--;
     629        }
     630        /* now do the interpolation */
     631        W16(dst, I(M16(apd->last[0].s, apd->last[1].s),
     632                   M16(R16(src), R16(src+2)), r));
     633        dst += 2;
     634        apd->dstPos += apd->dstIncr;
     635        (*ndst)--;
     636    }
     637}
     638
     639static  void cvtMS1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     640                        unsigned char* dst, LPDWORD ndst)
     641{
     642    double      r;
     643    short       v;
     644
     645    while (*nsrc != 0 && *ndst != 0) {
     646        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     647            if (*nsrc == 0) return;
     648            apd->last[0].s = R16(src);  src += 2;
     649            apd->srcPos++;
     650            (*nsrc)--;
     651        }
     652        /* now do the interpolation */
     653        v = I(apd->last[0].s, R16(src), r);
     654        W16(dst, v);            dst += 2;
     655        W16(dst, v);            dst += 2;
     656        apd->dstPos += apd->dstIncr;
     657        (*ndst)--;
     658    }
     659}
     660
     661static  void cvtMM1616C(AcmPcmData* apd, const unsigned char* src, LPDWORD nsrc,
     662                        unsigned char* dst, LPDWORD ndst)
     663{
     664    double      r;
     665
     666    while (*nsrc != 0 && *ndst != 0) {
     667        while ((r = (double)apd->srcPos - apd->dstPos) <= 0) {
     668            if (*nsrc == 0) return;
     669            apd->last[0].s = R16(src);  src += 2;
     670            apd->srcPos++;
     671            (*nsrc)--;
     672        }
     673        /* now do the interpolation */
     674        W16(dst, I(apd->last[0].s, R16(src), r));       dst += 2;
     675        apd->dstPos += apd->dstIncr;
     676        (*ndst)--;
     677    }
     678}
     679
     680static  void (*PCM_ConvertChangeRate[16])(AcmPcmData* apd,
     681                                          const unsigned char* src, LPDWORD nsrc,
     682                                          unsigned char* dst, LPDWORD ndst) = {
    683683    cvtSS88C,   cvtSM88C,   cvtMS88C,   cvtMM88C,
    684     cvtSS816C,  cvtSM816C,  cvtMS816C,  cvtMM816C,
    685     cvtSS168C,  cvtSM168C,  cvtMS168C,  cvtMM168C,
     684    cvtSS816C,  cvtSM816C,  cvtMS816C,  cvtMM816C,
     685    cvtSS168C,  cvtSM168C,  cvtMS168C,  cvtMM168C,
    686686    cvtSS1616C, cvtSM1616C, cvtMS1616C, cvtMM1616C,
    687687};
     
    691691 *
    692692 */
    693 static  LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add)
     693static  LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add)
    694694{
    695695    add->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
     
    712712                         add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) );
    713713    add->szFeatures[0] = 0;
    714 
     714   
    715715    return MMSYSERR_NOERROR;
    716716}
     
    720720 *
    721721 */
    722 static  LRESULT PCM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
     722static  LRESULT PCM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
    723723{
    724724    switch (dwQuery) {
    725725    case ACM_FORMATTAGDETAILSF_INDEX:
    726     if (aftd->dwFormatTagIndex != 0) return ACMERR_NOTPOSSIBLE;
    727     break;
    728     case ACM_FORMATTAGDETAILSF_FORMATTAG:
    729     if (aftd->dwFormatTag != WAVE_FORMAT_PCM) return ACMERR_NOTPOSSIBLE;
    730     break;
     726        if (aftd->dwFormatTagIndex != 0) return ACMERR_NOTPOSSIBLE;
     727        break;
     728    case ACM_FORMATTAGDETAILSF_FORMATTAG: 
     729        if (aftd->dwFormatTag != WAVE_FORMAT_PCM) return ACMERR_NOTPOSSIBLE;
     730        break;
    731731    case ACM_FORMATTAGDETAILSF_LARGESTSIZE:
    732     if (aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN &&
    733         aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN)
    734         return ACMERR_NOTPOSSIBLE;
    735     break;
     732        if (aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN &&
     733            aftd->dwFormatTag != WAVE_FORMAT_UNKNOWN)
     734            return ACMERR_NOTPOSSIBLE;
     735        break;
    736736    default:
    737     WARN("Unsupported query %08lx\n", dwQuery);
    738     return MMSYSERR_NOTSUPPORTED;
    739     }
    740 
     737        WARN("Unsupported query %08lx\n", dwQuery);
     738        return MMSYSERR_NOTSUPPORTED;
     739    }
     740   
    741741    aftd->dwFormatTagIndex = 0;
    742742    aftd->dwFormatTag = WAVE_FORMAT_PCM;
     
    745745    aftd->cStandardFormats = NUM_PCM_FORMATS;
    746746    aftd->szFormatTag[0] = 0;
    747 
     747   
    748748    return MMSYSERR_NOERROR;
    749749}
     
    753753 *
    754754 */
    755 static  LRESULT PCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
     755static  LRESULT PCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
    756756{
    757757    switch (dwQuery) {
    758758    case ACM_FORMATDETAILSF_FORMAT:
    759     afd->dwFormatIndex = PCM_GetFormatIndex(afd->pwfx);
    760     if (afd->dwFormatIndex == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
    761     break;
     759        afd->dwFormatIndex = PCM_GetFormatIndex(afd->pwfx);
     760        if (afd->dwFormatIndex == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
     761        break;
    762762    case ACM_FORMATDETAILSF_INDEX:
    763     assert(afd->dwFormatIndex < NUM_PCM_FORMATS);
    764     afd->pwfx->wFormatTag = WAVE_FORMAT_PCM;
    765     afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels;
    766     afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate;
    767     afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits;
    768     /* native MSACM uses a PCMWAVEFORMAT structure, so cbSize is not accessible
    769      * afd->pwfx->cbSize = 0;
    770     */
    771     afd->pwfx->nBlockAlign =
    772         (afd->pwfx->nChannels * afd->pwfx->wBitsPerSample) / 8;
    773     afd->pwfx->nAvgBytesPerSec =
    774         afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign;
    775     break;
     763        assert(afd->dwFormatIndex < NUM_PCM_FORMATS);
     764        afd->pwfx->wFormatTag = WAVE_FORMAT_PCM;
     765        afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels;
     766        afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate;
     767        afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits;
     768        /* native MSACM uses a PCMWAVEFORMAT structure, so cbSize is not accessible
     769         * afd->pwfx->cbSize = 0;
     770        */
     771        afd->pwfx->nBlockAlign =
     772            (afd->pwfx->nChannels * afd->pwfx->wBitsPerSample) / 8;
     773        afd->pwfx->nAvgBytesPerSec =
     774            afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign;
     775        break;
    776776    default:
    777     WARN("Unsupported query %08lx\n", dwQuery);
    778     return MMSYSERR_NOTSUPPORTED;
    779     }
    780 
     777        WARN("Unsupported query %08lx\n", dwQuery);
     778        return MMSYSERR_NOTSUPPORTED;   
     779    }
     780   
    781781    afd->dwFormatTag = WAVE_FORMAT_PCM;
    782782    afd->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CONVERTER;
    783783    afd->szFormat[0] = 0; /* let MSACM format this for us... */
    784 
     784   
    785785    return MMSYSERR_NOERROR;
    786786}
     
    790790 *
    791791 */
    792 static  LRESULT PCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
     792static  LRESULT PCM_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
    793793{
    794794    FIXME("(%p);\n", adfs);
     
    800800 *
    801801 */
    802 static  void    PCM_Reset(AcmPcmData* apd, int srcNumBits)
     802static  void    PCM_Reset(AcmPcmData* apd, int srcNumBits)
    803803{
    804804    apd->srcPos = 0;
     
    806806    /* initialize with neutral value */
    807807    if (srcNumBits == 16) {
    808     apd->last[0].s = 0;
    809     apd->last[1].s = 0;
     808        apd->last[0].s = 0;
     809        apd->last[1].s = 0;
    810810    } else {
    811     apd->last[0].b = (BYTE)0x80;
    812     apd->last[1].b = (BYTE)0x80;
     811        apd->last[0].b = (BYTE)0x80;
     812        apd->last[1].b = (BYTE)0x80;
    813813    }
    814814}
     
    818818 *
    819819 */
    820 static  LRESULT PCM_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
    821 {
    822     AcmPcmData* apd;
    823     int     idx = 0;
     820static  LRESULT PCM_StreamOpen(PACMDRVSTREAMINSTANCE adsi)
     821{
     822    AcmPcmData* apd;
     823    int         idx = 0;
    824824
    825825    assert(!(adsi->fdwOpen & ACM_STREAMOPENF_ASYNC));
    826 
     826   
    827827    if (PCM_GetFormatIndex(adsi->pwfxSrc) == 0xFFFFFFFF ||
    828     PCM_GetFormatIndex(adsi->pwfxDst) == 0xFFFFFFFF)
    829     return ACMERR_NOTPOSSIBLE;
     828        PCM_GetFormatIndex(adsi->pwfxDst) == 0xFFFFFFFF)
     829        return ACMERR_NOTPOSSIBLE;
    830830
    831831    apd = HeapAlloc(GetProcessHeap(), 0, sizeof(AcmPcmData));
     
    834834    adsi->dwDriver = (DWORD)apd;
    835835    adsi->fdwDriver = 0;
    836 
     836   
    837837    if (adsi->pwfxSrc->wBitsPerSample == 16) idx += 8;
    838838    if (adsi->pwfxDst->wBitsPerSample == 16) idx += 4;
     
    841841
    842842    if (adsi->pwfxSrc->nSamplesPerSec == adsi->pwfxDst->nSamplesPerSec) {
    843     apd->cvt.cvtKeepRate = PCM_ConvertKeepRate[idx];
     843        apd->cvt.cvtKeepRate = PCM_ConvertKeepRate[idx];
    844844    } else {
    845     adsi->fdwDriver |= PCM_RESAMPLE;
    846     apd->dstIncr = (double)(adsi->pwfxSrc->nSamplesPerSec) /
    847         (double)(adsi->pwfxDst->nSamplesPerSec);
    848     PCM_Reset(apd, adsi->pwfxSrc->wBitsPerSample);
    849     apd->cvt.cvtChangeRate = PCM_ConvertChangeRate[idx];
     845        adsi->fdwDriver |= PCM_RESAMPLE;
     846        apd->dstIncr = (double)(adsi->pwfxSrc->nSamplesPerSec) /
     847            (double)(adsi->pwfxDst->nSamplesPerSec);
     848        PCM_Reset(apd, adsi->pwfxSrc->wBitsPerSample);
     849        apd->cvt.cvtChangeRate = PCM_ConvertChangeRate[idx];
    850850    }
    851851
     
    857857 *
    858858 */
    859 static  LRESULT PCM_StreamClose(PACMDRVSTREAMINSTANCE adsi)
     859static  LRESULT PCM_StreamClose(PACMDRVSTREAMINSTANCE adsi)
    860860{
    861861    HeapFree(GetProcessHeap(), 0, (void*)adsi->dwDriver);
     
    867867 *
    868868 */
    869 static  inline DWORD    PCM_round(DWORD a, DWORD b, DWORD c)
     869static  inline DWORD    PCM_round(DWORD a, DWORD b, DWORD c)
    870870{
    871871    assert(a && b && c);
     
    878878 *
    879879 */
    880 static  LRESULT PCM_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss)
     880static  LRESULT PCM_StreamSize(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMSIZE adss)
    881881{
    882882    switch (adss->fdwSize) {
    883883    case ACM_STREAMSIZEF_DESTINATION:
    884     /* cbDstLength => cbSrcLength */
    885     adss->cbSrcLength = PCM_round(adss->cbDstLength,
    886                       adsi->pwfxSrc->nAvgBytesPerSec,
    887                       adsi->pwfxDst->nAvgBytesPerSec);
    888     break;
     884        /* cbDstLength => cbSrcLength */
     885        adss->cbSrcLength = PCM_round(adss->cbDstLength,
     886                                      adsi->pwfxSrc->nAvgBytesPerSec,
     887                                      adsi->pwfxDst->nAvgBytesPerSec);
     888        break;
    889889    case ACM_STREAMSIZEF_SOURCE:
    890     /* cbSrcLength => cbDstLength */
    891     adss->cbDstLength =  PCM_round(adss->cbSrcLength,
    892                        adsi->pwfxDst->nAvgBytesPerSec,
    893                        adsi->pwfxSrc->nAvgBytesPerSec);
    894     break;
     890        /* cbSrcLength => cbDstLength */
     891        adss->cbDstLength =  PCM_round(adss->cbSrcLength,
     892                                       adsi->pwfxDst->nAvgBytesPerSec,
     893                                       adsi->pwfxSrc->nAvgBytesPerSec);
     894        break;
    895895    default:
    896     WARN("Unsupported query %08lx\n", adss->fdwSize);
    897     return MMSYSERR_NOTSUPPORTED;
     896        WARN("Unsupported query %08lx\n", adss->fdwSize);
     897        return MMSYSERR_NOTSUPPORTED;   
    898898    }
    899899    return MMSYSERR_NOERROR;
     
    906906static LRESULT PCM_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEADER adsh)
    907907{
    908     AcmPcmData* apd = (AcmPcmData*)adsi->dwDriver;
    909     DWORD   nsrc = NUM_OF(adsh->cbSrcLength, adsi->pwfxSrc->nBlockAlign);
    910     DWORD   ndst = NUM_OF(adsh->cbDstLength, adsi->pwfxDst->nBlockAlign);
    911 
    912     if (adsh->fdwConvert &
    913     ~(ACM_STREAMCONVERTF_BLOCKALIGN|
    914       ACM_STREAMCONVERTF_END|
    915       ACM_STREAMCONVERTF_START)) {
    916     FIXME("Unsupported fdwConvert (%08lx), ignoring it\n", adsh->fdwConvert);
     908    AcmPcmData* apd = (AcmPcmData*)adsi->dwDriver;
     909    DWORD       nsrc = NUM_OF(adsh->cbSrcLength, adsi->pwfxSrc->nBlockAlign);
     910    DWORD       ndst = NUM_OF(adsh->cbDstLength, adsi->pwfxDst->nBlockAlign);
     911
     912    if (adsh->fdwConvert & 
     913        ~(ACM_STREAMCONVERTF_BLOCKALIGN|
     914          ACM_STREAMCONVERTF_END|
     915          ACM_STREAMCONVERTF_START)) {
     916        FIXME("Unsupported fdwConvert (%08lx), ignoring it\n", adsh->fdwConvert);
    917917    }
    918918    /* ACM_STREAMCONVERTF_BLOCKALIGN
    919      *  currently all conversions are block aligned, so do nothing for this flag
     919     *  currently all conversions are block aligned, so do nothing for this flag
    920920     * ACM_STREAMCONVERTF_END
    921      *  no pending data, so do nothing for this flag
     921     *  no pending data, so do nothing for this flag
    922922     */
    923     if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START) &&
    924     (adsi->fdwDriver & PCM_RESAMPLE)) {
    925     PCM_Reset(apd, adsi->pwfxSrc->wBitsPerSample);
     923    if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START) && 
     924        (adsi->fdwDriver & PCM_RESAMPLE)) {
     925        PCM_Reset(apd, adsi->pwfxSrc->wBitsPerSample);
    926926    }
    927927
    928928    /* do the job */
    929929    if (adsi->fdwDriver & PCM_RESAMPLE) {
    930     DWORD   nsrc2 = nsrc;
    931     DWORD   ndst2 = ndst;
    932 
    933     apd->cvt.cvtChangeRate(apd, adsh->pbSrc, &nsrc2, adsh->pbDst, &ndst2);
    934     nsrc -= nsrc2;
    935     ndst -= ndst2;
     930        DWORD   nsrc2 = nsrc;
     931        DWORD   ndst2 = ndst;
     932
     933        apd->cvt.cvtChangeRate(apd, adsh->pbSrc, &nsrc2, adsh->pbDst, &ndst2);
     934        nsrc -= nsrc2;
     935        ndst -= ndst2;
    936936    } else {
    937     if (nsrc < ndst) ndst = nsrc; else nsrc = ndst;
    938 
    939     /* nsrc is now equal to ndst */
    940     apd->cvt.cvtKeepRate(adsh->pbSrc, nsrc, adsh->pbDst);
     937        if (nsrc < ndst) ndst = nsrc; else nsrc = ndst;
     938
     939        /* nsrc is now equal to ndst */
     940        apd->cvt.cvtKeepRate(adsh->pbSrc, nsrc, adsh->pbDst);
    941941    }
    942942
     
    948948
    949949/**************************************************************************
    950  *          PCM_DriverProc          [exported]
    951  */
    952 LRESULT CALLBACK    PCM_DriverProc(DWORD dwDevID, HDRVR hDriv, UINT wMsg,
    953                        LPARAM dwParam1, LPARAM dwParam2)
    954 {
    955     TRACE("(%08lx %08lx %u %08lx %08lx);\n",
    956       dwDevID, (DWORD)hDriv, wMsg, dwParam1, dwParam2);
    957 
     950 *                      PCM_DriverProc                  [exported]
     951 */
     952LRESULT CALLBACK        PCM_DriverProc(DWORD dwDevID, HDRVR hDriv, UINT wMsg,
     953                                       LPARAM dwParam1, LPARAM dwParam2)
     954{
     955    TRACE("(%08lx %08lx %u %08lx %08lx);\n", 
     956          dwDevID, (DWORD)hDriv, wMsg, dwParam1, dwParam2);
     957   
    958958    switch (wMsg) {
    959     case DRV_LOAD:      return 1;
    960     case DRV_FREE:      return 1;
    961     case DRV_OPEN:      return PCM_drvOpen((LPSTR)dwParam1);
    962     case DRV_CLOSE:     return PCM_drvClose(dwDevID);
    963     case DRV_ENABLE:        return 1;
    964     case DRV_DISABLE:       return 1;
    965     case DRV_QUERYCONFIGURE:    return 1;
    966     case DRV_CONFIGURE:     MessageBoxA(0, "MSACM PCM filter !", "Wine Driver", MB_OK); return 1;
    967     case DRV_INSTALL:       return DRVCNF_RESTART;
    968     case DRV_REMOVE:        return DRVCNF_RESTART;
    969 
     959    case DRV_LOAD:              return 1;
     960    case DRV_FREE:              return 1;
     961    case DRV_OPEN:              return PCM_drvOpen((LPSTR)dwParam1);
     962    case DRV_CLOSE:             return PCM_drvClose(dwDevID);
     963    case DRV_ENABLE:            return 1;       
     964    case DRV_DISABLE:           return 1;
     965    case DRV_QUERYCONFIGURE:    return 1;
     966    case DRV_CONFIGURE:         MessageBoxA(0, "MSACM PCM filter !", "Wine Driver", MB_OK); return 1;
     967    case DRV_INSTALL:           return DRVCNF_RESTART;
     968    case DRV_REMOVE:            return DRVCNF_RESTART;
     969       
    970970    case ACMDM_DRIVER_NOTIFY:
    971     /* no caching from other ACM drivers is done so far */
    972     return MMSYSERR_NOERROR;
    973 
     971        /* no caching from other ACM drivers is done so far */
     972        return MMSYSERR_NOERROR;
     973       
    974974    case ACMDM_DRIVER_DETAILS:
    975     return PCM_DriverDetails((PACMDRIVERDETAILSW)dwParam1);
    976 
     975        return PCM_DriverDetails((PACMDRIVERDETAILSW)dwParam1);
     976       
    977977    case ACMDM_FORMATTAG_DETAILS:
    978     return PCM_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);
    979 
     978        return PCM_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);
     979       
    980980    case ACMDM_FORMAT_DETAILS:
    981     return PCM_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);
    982 
     981        return PCM_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);
     982       
    983983    case ACMDM_FORMAT_SUGGEST:
    984     return PCM_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);
    985 
     984        return PCM_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);
     985       
    986986    case ACMDM_STREAM_OPEN:
    987     return PCM_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);
    988 
     987        return PCM_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);
     988       
    989989    case ACMDM_STREAM_CLOSE:
    990     return PCM_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);
    991 
     990        return PCM_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);
     991       
    992992    case ACMDM_STREAM_SIZE:
    993     return PCM_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);
    994 
     993        return PCM_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);
     994       
    995995    case ACMDM_STREAM_CONVERT:
    996     return PCM_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);
    997 
     996        return PCM_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);
     997       
    998998    case ACMDM_HARDWARE_WAVE_CAPS_INPUT:
    999999    case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT:
    1000     /* this converter is not a hardware driver */
     1000        /* this converter is not a hardware driver */
    10011001    case ACMDM_FILTERTAG_DETAILS:
    10021002    case ACMDM_FILTER_DETAILS:
    1003     /* this converter is not a filter */
     1003        /* this converter is not a filter */
    10041004    case ACMDM_STREAM_RESET:
    1005     /* only needed for asynchronous driver... we aren't, so just say it */
     1005        /* only needed for asynchronous driver... we aren't, so just say it */
    10061006    case ACMDM_STREAM_PREPARE:
    10071007    case ACMDM_STREAM_UNPREPARE:
    1008     /* nothing special to do here... so don't do anything */
    1009     return MMSYSERR_NOTSUPPORTED;
    1010 
     1008        /* nothing special to do here... so don't do anything */
     1009        return MMSYSERR_NOTSUPPORTED;
     1010       
    10111011    default:
    1012     return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
     1012        return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
    10131013    }
    10141014    return 0;
  • trunk/src/msacm32/stream.c

    r6648 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    2 /* $Id: stream.c,v 1.2 2001-09-05 13:11:26 bird Exp $ */
     2
    33/*
    44 *      MSACM32 library
    55 *
    66 *      Copyright 1998  Patrik Stridvall
    7  *        1999  Eric Pouech
     7 *                1999  Eric Pouech
    88 */
    99
    1010/* TODO
    11  *  + asynchronous conversion is not implemented
    12  *  + callback/notification
    13  *  * acmStreamMessage
    14  *  + properly close ACM streams
     11 *      + asynchronous conversion is not implemented
     12 *      + callback/notification
     13 *      * acmStreamMessage
     14 *      + properly close ACM streams
    1515 */
    1616
     
    2626
    2727DEFAULT_DEBUG_CHANNEL(msacm);
    28 
    29 static PWINE_ACMSTREAM  ACM_GetStream(HACMSTREAM has)
     28   
     29static PWINE_ACMSTREAM  ACM_GetStream(HACMSTREAM has)
    3030{
    3131    return (PWINE_ACMSTREAM)has;
     
    3737MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
    3838{
    39     PWINE_ACMSTREAM was;
    40     MMRESULT        ret;
    41 
     39    PWINE_ACMSTREAM     was;
     40    MMRESULT            ret;
     41               
    4242    TRACE("(0x%08x, %ld)\n", has, fdwClose);
    43 
     43   
    4444    if ((was = ACM_GetStream(has)) == NULL) {
    45     return MMSYSERR_INVALHANDLE;
     45        return MMSYSERR_INVALHANDLE;
    4646    }
    4747    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0);
    4848    if (ret == MMSYSERR_NOERROR) {
    49     if (was->hAcmDriver)
    50         acmDriverClose(was->hAcmDriver, 0L);
    51     HeapFree(MSACM_hHeap, 0, was);
     49        if (was->hAcmDriver)
     50            acmDriverClose(was->hAcmDriver, 0L);       
     51        HeapFree(MSACM_hHeap, 0, was);
    5252    }
    5353    TRACE("=> (%d)\n", ret);
     
    5858 *           acmStreamConvert (MSACM32.38)
    5959 */
    60 MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
    61                 DWORD fdwConvert)
    62 {
    63     PWINE_ACMSTREAM was;
    64     MMRESULT        ret = MMSYSERR_NOERROR;
    65     PACMDRVSTREAMHEADER padsh;
     60MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, 
     61                                DWORD fdwConvert)
     62{
     63    PWINE_ACMSTREAM     was;
     64    MMRESULT            ret = MMSYSERR_NOERROR;
     65    PACMDRVSTREAMHEADER padsh;
    6666
    6767    TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert);
    68 
     68   
    6969    if ((was = ACM_GetStream(has)) == NULL)
    70     return MMSYSERR_INVALHANDLE;
     70        return MMSYSERR_INVALHANDLE;
    7171    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
    72     return MMSYSERR_INVALPARAM;
     72        return MMSYSERR_INVALPARAM;
    7373
    7474    if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
    75     return ACMERR_UNPREPARED;
     75        return ACMERR_UNPREPARED;
    7676
    7777    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
     
    8383    /* check that pointers have not been modified */
    8484    if (padsh->pbPreparedSrc != padsh->pbSrc ||
    85     padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
    86     padsh->pbPreparedDst != padsh->pbDst ||
    87     padsh->cbPreparedDstLength < padsh->cbDstLength) {
    88     return MMSYSERR_INVALPARAM;
    89     }
     85        padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
     86        padsh->pbPreparedDst != padsh->pbDst ||
     87        padsh->cbPreparedDstLength < padsh->cbDstLength) {
     88        return MMSYSERR_INVALPARAM;
     89    }   
    9090
    9191    padsh->fdwConvert = fdwConvert;
     
    9393    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CONVERT, (DWORD)&was->drvInst, (DWORD)padsh);
    9494    if (ret == MMSYSERR_NOERROR) {
    95     padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
     95        padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
    9696    }
    9797    TRACE("=> (%d)\n", ret);
     
    102102 *           acmStreamMessage (MSACM32.39)
    103103 */
    104 MMRESULT WINAPI acmStreamMessage(HACMSTREAM has, UINT uMsg, LPARAM lParam1,
    105                 LPARAM lParam2)
     104MMRESULT WINAPI acmStreamMessage(HACMSTREAM has, UINT uMsg, LPARAM lParam1, 
     105                                LPARAM lParam2)
    106106{
    107107    FIXME("(0x%08x, %u, %ld, %ld): stub\n", has, uMsg, lParam1, lParam2);
     
    114114 */
    115115MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc,
    116                   PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
    117                   DWORD dwInstance, DWORD fdwOpen)
    118 {
    119     PWINE_ACMSTREAM was;
    120     PWINE_ACMDRIVER wad;
    121     MMRESULT        ret;
    122     int         wfxSrcSize;
    123     int         wfxDstSize;
    124 
     116                              PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
     117                              DWORD dwInstance, DWORD fdwOpen)
     118{
     119    PWINE_ACMSTREAM     was;
     120    PWINE_ACMDRIVER     wad;
     121    MMRESULT            ret;
     122    int                 wfxSrcSize;
     123    int                 wfxDstSize;
     124   
    125125    TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
    126       phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
    127 
    128     TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
    129       pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
    130       pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
    131 
    132     TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
    133       pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
    134       pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
     126          phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
     127
     128    TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 
     129          pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
     130          pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
     131
     132    TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 
     133          pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
     134          pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
    135135
    136136    if ((fdwOpen & ACM_STREAMOPENF_QUERY) && phas) return MMSYSERR_INVALPARAM;
     
    143143    was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
    144144    if (was == NULL)
    145     return MMSYSERR_NOMEM;
    146 
     145        return MMSYSERR_NOMEM;
     146   
    147147    was->drvInst.cbStruct = sizeof(was->drvInst);
    148148    was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
     
    151151    memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
    152152    if (pwfltr) {
    153     was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
    154     memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
     153        was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
     154        memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
    155155    } else {
    156     was->drvInst.pwfltr = NULL;
    157     }
    158     was->drvInst.dwCallback = dwCallback;
     156        was->drvInst.pwfltr = NULL;
     157    }
     158    was->drvInst.dwCallback = dwCallback;   
    159159    was->drvInst.dwInstance = dwInstance;
    160160    was->drvInst.fdwOpen = fdwOpen;
    161     was->drvInst.fdwDriver = 0L;
    162     was->drvInst.dwDriver = 0L;
     161    was->drvInst.fdwDriver = 0L; 
     162    was->drvInst.dwDriver = 0L;     
    163163    was->drvInst.has = (HACMSTREAM)was;
    164 
     164   
    165165    if (had) {
    166     if (!(wad = MSACM_GetDriver(had))) {
    167         ret = MMSYSERR_INVALPARAM;
    168         goto errCleanUp;
    169     }
    170 
    171     was->obj.dwType = WINE_ACMOBJ_STREAM;
    172     was->obj.pACMDriverID = wad->obj.pACMDriverID;
    173     was->pDrv = wad;
    174     was->hAcmDriver = 0; /* not to close it in acmStreamClose */
    175 
    176     ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
    177     if (ret != MMSYSERR_NOERROR)
    178         goto errCleanUp;
     166        if (!(wad = MSACM_GetDriver(had))) {
     167            ret = MMSYSERR_INVALPARAM;
     168            goto errCleanUp;
     169        }
     170       
     171        was->obj.dwType = WINE_ACMOBJ_STREAM;
     172        was->obj.pACMDriverID = wad->obj.pACMDriverID;
     173        was->pDrv = wad;
     174        was->hAcmDriver = 0; /* not to close it in acmStreamClose */
     175
     176        ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
     177        if (ret != MMSYSERR_NOERROR)
     178            goto errCleanUp;
    179179    } else {
    180     PWINE_ACMDRIVERID wadi;
    181 
    182     ret = ACMERR_NOTPOSSIBLE;
    183     for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
    184         ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
    185         if (ret == MMSYSERR_NOERROR) {
    186         if ((wad = MSACM_GetDriver(had)) != 0) {
    187             was->obj.dwType = WINE_ACMOBJ_STREAM;
    188             was->obj.pACMDriverID = wad->obj.pACMDriverID;
    189             was->pDrv = wad;
    190             was->hAcmDriver = had;
    191 
    192             ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
    193             if (ret == MMSYSERR_NOERROR) {
    194             if (fdwOpen & ACM_STREAMOPENF_QUERY) {
    195                 acmDriverClose(had, 0L);
    196             }
    197             break;
    198             }
    199         }
    200         /* no match, close this acm driver and try next one */
    201         acmDriverClose(had, 0L);
    202         }
    203     }
    204     if (ret != MMSYSERR_NOERROR) {
    205         ret = ACMERR_NOTPOSSIBLE;
    206         goto errCleanUp;
    207     }
     180        PWINE_ACMDRIVERID wadi;
     181       
     182        ret = ACMERR_NOTPOSSIBLE;
     183        for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
     184            ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
     185            if (ret == MMSYSERR_NOERROR) {
     186                if ((wad = MSACM_GetDriver(had)) != 0) {
     187                    was->obj.dwType = WINE_ACMOBJ_STREAM;
     188                    was->obj.pACMDriverID = wad->obj.pACMDriverID;
     189                    was->pDrv = wad;
     190                    was->hAcmDriver = had;
     191                   
     192                    ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
     193                    if (ret == MMSYSERR_NOERROR) {
     194                        if (fdwOpen & ACM_STREAMOPENF_QUERY) {
     195                            acmDriverClose(had, 0L);
     196                        }
     197                        break;
     198                    }
     199                }
     200                /* no match, close this acm driver and try next one */
     201                acmDriverClose(had, 0L);
     202            }
     203        }
     204        if (ret != MMSYSERR_NOERROR) {
     205            ret = ACMERR_NOTPOSSIBLE;
     206            goto errCleanUp;
     207        }
    208208    }
    209209    ret = MMSYSERR_NOERROR;
    210210    if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) {
     211        if (phas)
     212            *phas = (HACMSTREAM)was;
     213        TRACE("=> (%d)\n", ret);
     214        return ret;
     215    }
     216errCleanUp:             
    211217    if (phas)
    212         *phas = (HACMSTREAM)was;
    213     TRACE("=> (%d)\n", ret);
    214     return ret;
    215     }
    216 errCleanUp:
    217     if (phas)
    218     *phas = (HACMSTREAM)0;
     218        *phas = (HACMSTREAM)0;
    219219    HeapFree(MSACM_hHeap, 0, was);
    220220    TRACE("=> (%d)\n", ret);
     
    226226 *           acmStreamPrepareHeader (MSACM32.41)
    227227 */
    228 MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
    229                        DWORD fdwPrepare)
    230 {
    231     PWINE_ACMSTREAM was;
    232     MMRESULT        ret = MMSYSERR_NOERROR;
    233     PACMDRVSTREAMHEADER padsh;
     228MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 
     229                                       DWORD fdwPrepare)
     230{
     231    PWINE_ACMSTREAM     was;
     232    MMRESULT            ret = MMSYSERR_NOERROR;
     233    PACMDRVSTREAMHEADER padsh;
    234234
    235235    TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwPrepare);
    236 
     236   
    237237    if ((was = ACM_GetStream(has)) == NULL)
    238     return MMSYSERR_INVALHANDLE;
     238        return MMSYSERR_INVALHANDLE;
    239239    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
    240     return MMSYSERR_INVALPARAM;
     240        return MMSYSERR_INVALPARAM;
    241241    if (fdwPrepare)
    242     ret = MMSYSERR_INVALFLAG;
     242        ret = MMSYSERR_INVALFLAG;
    243243
    244244    if (pash->fdwStatus & ACMSTREAMHEADER_STATUSF_DONE)
    245     return MMSYSERR_NOERROR;
     245        return MMSYSERR_NOERROR;
    246246
    247247    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
     
    264264    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_PREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
    265265    if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
    266     ret = MMSYSERR_NOERROR;
    267     padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE);
    268     padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
    269     padsh->fdwPrepared = padsh->fdwStatus;
    270     padsh->dwPrepared = 0;
    271     padsh->pbPreparedSrc = padsh->pbSrc;
    272     padsh->cbPreparedSrcLength = padsh->cbSrcLength;
    273     padsh->pbPreparedDst = padsh->pbDst;
    274     padsh->cbPreparedDstLength = padsh->cbDstLength;
     266        ret = MMSYSERR_NOERROR;
     267        padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE);
     268        padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
     269        padsh->fdwPrepared = padsh->fdwStatus;
     270        padsh->dwPrepared = 0;
     271        padsh->pbPreparedSrc = padsh->pbSrc;
     272        padsh->cbPreparedSrcLength = padsh->cbSrcLength;
     273        padsh->pbPreparedDst = padsh->pbDst;
     274        padsh->cbPreparedDstLength = padsh->cbDstLength;
    275275    } else {
    276     padsh->fdwPrepared = 0;
    277     padsh->dwPrepared = 0;
    278     padsh->pbPreparedSrc = 0;
    279     padsh->cbPreparedSrcLength = 0;
    280     padsh->pbPreparedDst = 0;
    281     padsh->cbPreparedDstLength = 0;
     276        padsh->fdwPrepared = 0;
     277        padsh->dwPrepared = 0;
     278        padsh->pbPreparedSrc = 0;
     279        padsh->cbPreparedSrcLength = 0;
     280        padsh->pbPreparedDst = 0;
     281        padsh->cbPreparedDstLength = 0;
    282282    }
    283283    TRACE("=> (%d)\n", ret);
     
    290290MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset)
    291291{
    292     PWINE_ACMSTREAM was;
    293     MMRESULT        ret = MMSYSERR_NOERROR;
     292    PWINE_ACMSTREAM     was;
     293    MMRESULT            ret = MMSYSERR_NOERROR;
    294294
    295295    TRACE("(0x%08x, %ld)\n", has, fdwReset);
    296296
    297297    if (fdwReset) {
    298     ret = MMSYSERR_INVALFLAG;
     298        ret = MMSYSERR_INVALFLAG;
    299299    } else if ((was = ACM_GetStream(has)) == NULL) {
    300     return MMSYSERR_INVALHANDLE;
     300        return MMSYSERR_INVALHANDLE;
    301301    } else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) {
    302     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0);
     302        ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0);
    303303    }
    304304    TRACE("=> (%d)\n", ret);
     
    309309 *           acmStreamSize (MSACM32.43)
    310310 */
    311 MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput,
    312                   LPDWORD pdwOutputBytes, DWORD fdwSize)
    313 {
    314     PWINE_ACMSTREAM was;
    315     ACMDRVSTREAMSIZE    adss;
    316     MMRESULT        ret;
    317 
     311MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, 
     312                              LPDWORD pdwOutputBytes, DWORD fdwSize)
     313{
     314    PWINE_ACMSTREAM     was;
     315    ACMDRVSTREAMSIZE    adss;
     316    MMRESULT            ret;
     317   
    318318    TRACE("(0x%08x, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize);
    319 
     319   
    320320    if ((was = ACM_GetStream(has)) == NULL) {
    321     return MMSYSERR_INVALHANDLE;
     321        return MMSYSERR_INVALHANDLE;
    322322    }
    323323    if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) {
    324     return MMSYSERR_INVALFLAG;
     324        return MMSYSERR_INVALFLAG;
    325325    }
    326326
    327327    *pdwOutputBytes = 0L;
    328 
     328   
    329329    switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
    330330    case ACM_STREAMSIZEF_DESTINATION:
    331     adss.cbDstLength = cbInput;
    332     adss.cbSrcLength = 0;
    333     break;
     331        adss.cbDstLength = cbInput;
     332        adss.cbSrcLength = 0;
     333        break;
    334334    case ACM_STREAMSIZEF_SOURCE:
    335     adss.cbSrcLength = cbInput;
    336     adss.cbDstLength = 0;
    337     break;
    338     default:
    339     return MMSYSERR_INVALFLAG;
    340     }
    341 
     335        adss.cbSrcLength = cbInput;
     336        adss.cbDstLength = 0;
     337        break;
     338    default:   
     339        return MMSYSERR_INVALFLAG;
     340    }
     341   
    342342    adss.cbStruct = sizeof(adss);
    343343    adss.fdwSize = fdwSize;
    344     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE,
    345                 (DWORD)&was->drvInst, (DWORD)&adss);
     344    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE, 
     345                            (DWORD)&was->drvInst, (DWORD)&adss);
    346346    if (ret == MMSYSERR_NOERROR) {
    347     switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
    348     case ACM_STREAMSIZEF_DESTINATION:
    349         *pdwOutputBytes = adss.cbSrcLength;
    350         break;
    351     case ACM_STREAMSIZEF_SOURCE:
    352         *pdwOutputBytes = adss.cbDstLength;
    353         break;
    354     }
     347        switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
     348        case ACM_STREAMSIZEF_DESTINATION:
     349            *pdwOutputBytes = adss.cbSrcLength;
     350            break;
     351        case ACM_STREAMSIZEF_SOURCE:
     352            *pdwOutputBytes = adss.cbDstLength;
     353            break;
     354        }
    355355    }
    356356    TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes);
     
    361361 *           acmStreamUnprepareHeader (MSACM32.44)
    362362 */
    363 MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
    364                     DWORD fdwUnprepare)
    365 {
    366     PWINE_ACMSTREAM was;
    367     MMRESULT        ret = MMSYSERR_NOERROR;
    368     PACMDRVSTREAMHEADER padsh;
     363MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 
     364                                        DWORD fdwUnprepare)
     365{
     366    PWINE_ACMSTREAM     was;
     367    MMRESULT            ret = MMSYSERR_NOERROR;
     368    PACMDRVSTREAMHEADER padsh;
    369369
    370370    TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwUnprepare);
    371 
     371   
    372372    if ((was = ACM_GetStream(has)) == NULL)
    373     return MMSYSERR_INVALHANDLE;
     373        return MMSYSERR_INVALHANDLE;
    374374    if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
    375     return MMSYSERR_INVALPARAM;
     375        return MMSYSERR_INVALPARAM;
    376376
    377377    if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
    378     return ACMERR_UNPREPARED;
     378        return ACMERR_UNPREPARED;
    379379
    380380    /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
     
    386386    /* check that pointers have not been modified */
    387387    if (padsh->pbPreparedSrc != padsh->pbSrc ||
    388     padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
    389     padsh->pbPreparedDst != padsh->pbDst ||
    390     padsh->cbPreparedDstLength < padsh->cbDstLength) {
    391     return MMSYSERR_INVALPARAM;
    392     }
     388        padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
     389        padsh->pbPreparedDst != padsh->pbDst ||
     390        padsh->cbPreparedDstLength < padsh->cbDstLength) {
     391        return MMSYSERR_INVALPARAM;
     392    }   
    393393
    394394    padsh->fdwConvert = fdwUnprepare;
     
    396396    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_UNPREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
    397397    if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
    398     ret = MMSYSERR_NOERROR;
    399     padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
    400     }
    401     TRACE("=> (%d)\n", ret);
    402     return ret;
    403 }
     398        ret = MMSYSERR_NOERROR;
     399        padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
     400    }
     401    TRACE("=> (%d)\n", ret);
     402    return ret;
     403}
  • trunk/src/msacm32/wineacm.h

    r5434 r6712  
    33#define __WINE_WINEACM_H
    44
    5 #ifndef __WIN32OS2__
     5#ifdef __WIN32OS2__
     6#include "windef.h"
     7#else
    68#include "wine/windef16.h"
    79#include "wine/mmsystem16.h"
  • trunk/src/msvfw32/drawdib.c

    r6648 r6712  
    1 /* $Id: drawdib.c,v 1.2 2001-09-05 13:12:34 bird Exp $ */
    2 /*
     1/*
    32 * Copyright 2000 Bradley Baetz
    43 *
     
    2221
    2322typedef struct {
    24     HDC hdc;
    25     INT dxDst;
    26     INT dyDst;
    27     LPBITMAPINFOHEADER lpbi;
    28     INT dxSrc;
    29     INT dySrc;
    30     HPALETTE hpal;              /* Palette to use for the DIB */
    31     BOOL begun;                 /* DrawDibBegin has been called */
    32     LPBITMAPINFOHEADER lpbiOut; /* Output format */
    33     HIC hic;                    /* HIC for decompression */
    34     HDC hMemDC;                 /* DC for buffering */
    35     HBITMAP hOldDib;            /* Original Dib */
    36     HBITMAP hDib;               /* DibSection */
    37     LPVOID lpvbits;             /* Buffer for holding decompressed dib */
     23        HDC hdc;
     24        INT dxDst;
     25        INT dyDst;
     26        LPBITMAPINFOHEADER lpbi;
     27        INT dxSrc;
     28        INT dySrc;
     29        HPALETTE hpal;                          /* Palette to use for the DIB */
     30        BOOL begun;                                     /* DrawDibBegin has been called */
     31        LPBITMAPINFOHEADER lpbiOut;     /* Output format */
     32        HIC hic;                                        /* HIC for decompression */
     33        HDC hMemDC;                                     /* DC for buffering */
     34        HBITMAP hOldDib;                        /* Original Dib */
     35        HBITMAP hDib;                           /* DibSection */
     36        LPVOID lpvbits;                         /* Buffer for holding decompressed dib */
    3837} WINE_HDD;
    3938
     
    5958
    6059/***********************************************************************
    61  *      DrawDibOpen     [MSVFW32.@]
     60 *              DrawDibOpen             [MSVFW32.@]
    6261 */
    6362HDRAWDIB VFWAPI DrawDibOpen(void) {
    64     HDRAWDIB hdd;
    65 
    66     TRACE("(void)\n");
    67     hdd = GlobalAlloc16(GHND,sizeof(WINE_HDD));
    68     TRACE("=> %d\n",hdd);
    69     return hdd;
    70 }
    71 
    72 /***********************************************************************
    73  *      DrawDibOpen     [MSVIDEO.102]
     63        HDRAWDIB hdd;
     64
     65        TRACE("(void)\n");
     66        hdd = GlobalAlloc16(GHND,sizeof(WINE_HDD));
     67        TRACE("=> %d\n",hdd);
     68        return hdd;
     69}
     70
     71/***********************************************************************
     72 *              DrawDibOpen             [MSVIDEO.102]
    7473 */
    7574HDRAWDIB16 VFWAPI DrawDibOpen16(void) {
    76     return (HDRAWDIB16)DrawDibOpen();
    77 }
    78 
    79 /***********************************************************************
    80  *      DrawDibClose        [MSVFW32.@]
     75        return (HDRAWDIB16)DrawDibOpen();
     76}
     77
     78/***********************************************************************
     79 *              DrawDibClose            [MSVFW32.@]
    8180 */
    8281BOOL VFWAPI DrawDibClose(HDRAWDIB hdd) {
    83     WINE_HDD *whdd = GlobalLock16(hdd);
    84 
    85     TRACE("(0x%08lx)\n",(DWORD)hdd);
    86 
    87     if (!whdd)
    88         return FALSE;
    89 
    90     if (whdd->begun)
    91         DrawDibEnd(hdd);
    92 
    93     GlobalUnlock16(hdd);
    94     GlobalFree16(hdd);
    95     return TRUE;
    96 }
    97 
    98 /***********************************************************************
    99  *      DrawDibClose        [MSVIDEO.103]
     82        WINE_HDD *whdd = GlobalLock16(hdd);
     83
     84        TRACE("(0x%08lx)\n",(DWORD)hdd);
     85
     86        if (!whdd)
     87                return FALSE;
     88
     89        if (whdd->begun)
     90                DrawDibEnd(hdd);
     91
     92        GlobalUnlock16(hdd);
     93        GlobalFree16(hdd);
     94        return TRUE;
     95}
     96
     97/***********************************************************************
     98 *              DrawDibClose            [MSVIDEO.103]
    10099 */
    101100BOOL16 VFWAPI DrawDibClose16(HDRAWDIB16 hdd) {
    102     return DrawDibClose(hdd);
    103 }
    104 
    105 /***********************************************************************
    106  *      DrawDibEnd      [MSVFW32.@]
     101        return DrawDibClose(hdd);
     102}
     103
     104/***********************************************************************
     105 *              DrawDibEnd              [MSVFW32.@]
    107106 */
    108107BOOL VFWAPI DrawDibEnd(HDRAWDIB hdd) {
    109     BOOL ret = TRUE;
    110     WINE_HDD *whdd = GlobalLock16(hdd);
    111 
    112     TRACE("(0x%08lx)\n",(DWORD)hdd);
    113 
    114     whdd->hpal = 0; /* Do not free this */
    115     whdd->hdc = 0;
    116     if (whdd->lpbi) {
    117         HeapFree(GetProcessHeap(),0,whdd->lpbi);
    118         whdd->lpbi = NULL;
    119     }
    120     if (whdd->lpbiOut) {
    121         HeapFree(GetProcessHeap(),0,whdd->lpbiOut);
    122         whdd->lpbiOut = NULL;
    123     }
    124 
    125     whdd->begun = FALSE;
    126 
    127     /*if (whdd->lpvbits)
    128       HeapFree(GetProcessHeap(),0,whdd->lpvbuf);*/
    129 
    130     if (whdd->hMemDC) {
    131         SelectObject(whdd->hMemDC,whdd->hOldDib);
    132         DeleteDC(whdd->hMemDC);
    133     }
    134 
    135     if (whdd->hDib)
    136         DeleteObject(whdd->hDib);
    137 
    138     if (whdd->hic) {
    139         ICDecompressEnd(whdd->hic);
    140         ICClose(whdd->hic);
    141     }
    142 
    143     whdd->lpvbits = NULL;
    144 
    145     GlobalUnlock16(hdd);
    146     return ret;
    147 }
    148 
    149 /***********************************************************************
    150  *      DrawDibEnd      [MSVIDEO.105]
     108        BOOL ret = TRUE;
     109        WINE_HDD *whdd = GlobalLock16(hdd);
     110       
     111        TRACE("(0x%08lx)\n",(DWORD)hdd);
     112
     113        whdd->hpal = 0; /* Do not free this */
     114        whdd->hdc = 0;
     115        if (whdd->lpbi) {
     116                HeapFree(GetProcessHeap(),0,whdd->lpbi);
     117                whdd->lpbi = NULL;
     118        }
     119        if (whdd->lpbiOut) {
     120                HeapFree(GetProcessHeap(),0,whdd->lpbiOut);
     121                whdd->lpbiOut = NULL;
     122        }
     123
     124        whdd->begun = FALSE;
     125
     126        /*if (whdd->lpvbits)
     127          HeapFree(GetProcessHeap(),0,whdd->lpvbuf);*/
     128
     129        if (whdd->hMemDC) {
     130                SelectObject(whdd->hMemDC,whdd->hOldDib);
     131                DeleteDC(whdd->hMemDC);
     132        }
     133
     134        if (whdd->hDib)
     135                DeleteObject(whdd->hDib);
     136       
     137        if (whdd->hic) {
     138                ICDecompressEnd(whdd->hic);
     139                ICClose(whdd->hic);
     140        }
     141
     142        whdd->lpvbits = NULL;
     143
     144        GlobalUnlock16(hdd);
     145        return ret;
     146}
     147
     148/***********************************************************************
     149 *              DrawDibEnd              [MSVIDEO.105]
    151150 */
    152151BOOL16 VFWAPI DrawDibEnd16(HDRAWDIB16 hdd) {
    153     return DrawDibEnd(hdd);
     152        return DrawDibEnd(hdd);
    154153}
    155154
     
    158157 */
    159158BOOL VFWAPI DrawDibBegin(HDRAWDIB hdd,
    160                         HDC      hdc,
    161                         INT      dxDst,
    162                         INT      dyDst,
    163                         LPBITMAPINFOHEADER lpbi,
    164                         INT      dxSrc,
    165                         INT      dySrc,
    166                         UINT     wFlags) {
    167     BOOL ret = TRUE;
    168     WINE_HDD *whdd;
    169 
    170     TRACE("(%d,0x%lx,%d,%d,%p,%d,%d,0x%08lx)\n",
    171         hdd,(DWORD)hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,(DWORD)wFlags
    172     );
    173     TRACE("lpbi: %ld,%ld/%ld,%d,%d,%ld,%ld,%ld,%ld,%ld,%ld\n",
    174           lpbi->biSize, lpbi->biWidth, lpbi->biHeight, lpbi->biPlanes,
    175           lpbi->biBitCount, lpbi->biCompression, lpbi->biSizeImage,
    176           lpbi->biXPelsPerMeter, lpbi->biYPelsPerMeter, lpbi->biClrUsed,
    177           lpbi->biClrImportant);
    178 
    179     if (wFlags & ~(DDF_BUFFER))
    180         FIXME("wFlags == 0x%08x not handled\n", wFlags & ~(DDF_BUFFER));
    181 
    182     whdd = (WINE_HDD*)GlobalLock16(hdd);
    183     if (!whdd) return FALSE;
    184 
    185     if (whdd->begun)
    186         DrawDibEnd(hdd);
    187 
    188     if (lpbi->biCompression) {
    189         DWORD size = 0;
    190 
    191         whdd->hic = ICOpen(ICTYPE_VIDEO,lpbi->biCompression,ICMODE_DECOMPRESS);
    192         if (!whdd->hic) {
    193             WARN("Could not open IC. biCompression == 0x%08lx\n",lpbi->biCompression);
    194             ret = FALSE;
    195         }
    196 
    197         if (ret) {
    198             size = ICDecompressGetFormat(whdd->hic,lpbi,NULL);
    199             if (size == ICERR_UNSUPPORTED) {
    200                 WARN("Codec doesn't support GetFormat, giving up.\n");
    201                 ret = FALSE;
    202             }
    203         }
    204 
    205         if (ret) {
    206             whdd->lpbiOut = HeapAlloc(GetProcessHeap(),0,size);
    207 
    208             if (ICDecompressGetFormat(whdd->hic,lpbi,whdd->lpbiOut) != ICERR_OK)
    209                 ret = FALSE;
    210         }
    211 
    212         if (ret) {
    213             /* FIXME: Use Ex functions if available? */
    214             if (ICDecompressBegin(whdd->hic,lpbi,whdd->lpbiOut) != ICERR_OK)
    215                 ret = FALSE;
    216 
    217             TRACE("biSizeImage == %ld\n",whdd->lpbiOut->biSizeImage);
    218             TRACE("biCompression == %ld\n",whdd->lpbiOut->biCompression);
    219             TRACE("biBitCount == %d\n",whdd->lpbiOut->biBitCount);
    220         }
    221     } else {
    222         DWORD dwSize;
    223         /* No compression */
    224         TRACE("Not compressed!\n");
    225         dwSize = lpbi->biSize + lpbi->biClrUsed*sizeof(RGBQUAD);
    226         whdd->lpbiOut = HeapAlloc(GetProcessHeap(),0,dwSize);
    227         memcpy(whdd->lpbiOut,lpbi,dwSize);
    228     }
    229 
    230     if (ret) {
    231         /*whdd->lpvbuf = HeapAlloc(GetProcessHeap(),0,whdd->lpbiOut->biSizeImage);*/
    232 
    233         whdd->hMemDC = CreateCompatibleDC(hdc);
    234         TRACE("Creating: %ld,%p\n",whdd->lpbiOut->biSize,whdd->lpvbits);
    235         whdd->hDib = CreateDIBSection(whdd->hMemDC,(BITMAPINFO *)whdd->lpbiOut,DIB_RGB_COLORS,&(whdd->lpvbits),0,0);
    236         if (!whdd->hDib) {
    237             TRACE("Error: %ld\n",GetLastError());
    238         }
    239         TRACE("Created: %d,%p\n",whdd->hDib,whdd->lpvbits);
    240         whdd->hOldDib = SelectObject(whdd->hMemDC,whdd->hDib);
    241     }
    242 
    243     if (ret) {
    244         whdd->hdc = hdc;
    245         whdd->dxDst = dxDst;
    246         whdd->dyDst = dyDst;
    247         whdd->lpbi = HeapAlloc(GetProcessHeap(),0,lpbi->biSize);
    248         memcpy(whdd->lpbi,lpbi,lpbi->biSize);
    249         whdd->dxSrc = dxSrc;
    250         whdd->dySrc = dySrc;
    251         whdd->begun = TRUE;
    252         whdd->hpal = 0;
    253     } else {
    254         if (whdd->hic)
    255             ICClose(whdd->hic);
    256         if (whdd->lpbiOut) {
    257             HeapFree(GetProcessHeap(),0,whdd->lpbiOut);
    258             whdd->lpbiOut = NULL;
    259         }
    260     }
    261 
    262     GlobalUnlock16(hdd);
    263 
    264     return ret;
     159                                                HDC      hdc,
     160                                                INT      dxDst,
     161                                                INT      dyDst,
     162                                                LPBITMAPINFOHEADER lpbi,
     163                                                INT      dxSrc,
     164                                                INT      dySrc,
     165                                                UINT     wFlags) {
     166        BOOL ret = TRUE;
     167        WINE_HDD *whdd;
     168
     169        TRACE("(%d,0x%lx,%d,%d,%p,%d,%d,0x%08lx)\n",
     170                hdd,(DWORD)hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,(DWORD)wFlags
     171        );
     172        TRACE("lpbi: %ld,%ld/%ld,%d,%d,%ld,%ld,%ld,%ld,%ld,%ld\n",
     173                  lpbi->biSize, lpbi->biWidth, lpbi->biHeight, lpbi->biPlanes,
     174                  lpbi->biBitCount, lpbi->biCompression, lpbi->biSizeImage,
     175                  lpbi->biXPelsPerMeter, lpbi->biYPelsPerMeter, lpbi->biClrUsed,
     176                  lpbi->biClrImportant);
     177
     178        if (wFlags & ~(DDF_BUFFER))
     179                FIXME("wFlags == 0x%08x not handled\n", wFlags & ~(DDF_BUFFER));
     180
     181        whdd = (WINE_HDD*)GlobalLock16(hdd);
     182        if (!whdd) return FALSE;
     183
     184        if (whdd->begun)
     185                DrawDibEnd(hdd);
     186
     187        if (lpbi->biCompression) {
     188                DWORD size = 0;
     189
     190                whdd->hic = ICOpen(ICTYPE_VIDEO,lpbi->biCompression,ICMODE_DECOMPRESS);
     191                if (!whdd->hic) {
     192                        WARN("Could not open IC. biCompression == 0x%08lx\n",lpbi->biCompression);
     193                        ret = FALSE;
     194                }
     195
     196                if (ret) {
     197                        size = ICDecompressGetFormat(whdd->hic,lpbi,NULL);
     198                        if (size == ICERR_UNSUPPORTED) {
     199                                WARN("Codec doesn't support GetFormat, giving up.\n");
     200                                ret = FALSE;
     201                        }
     202                }
     203
     204                if (ret) {
     205                        whdd->lpbiOut = HeapAlloc(GetProcessHeap(),0,size);
     206
     207                        if (ICDecompressGetFormat(whdd->hic,lpbi,whdd->lpbiOut) != ICERR_OK)
     208                                ret = FALSE;
     209                }
     210
     211                if (ret) {
     212                        /* FIXME: Use Ex functions if available? */
     213                        if (ICDecompressBegin(whdd->hic,lpbi,whdd->lpbiOut) != ICERR_OK)
     214                                ret = FALSE;
     215
     216                        TRACE("biSizeImage == %ld\n",whdd->lpbiOut->biSizeImage);
     217                        TRACE("biCompression == %ld\n",whdd->lpbiOut->biCompression);
     218                        TRACE("biBitCount == %d\n",whdd->lpbiOut->biBitCount);
     219                }
     220        } else {
     221                DWORD dwSize;
     222                /* No compression */
     223                TRACE("Not compressed!\n");
     224                dwSize = lpbi->biSize + lpbi->biClrUsed*sizeof(RGBQUAD);
     225                whdd->lpbiOut = HeapAlloc(GetProcessHeap(),0,dwSize);
     226                memcpy(whdd->lpbiOut,lpbi,dwSize);
     227        }
     228
     229        if (ret) {
     230                /*whdd->lpvbuf = HeapAlloc(GetProcessHeap(),0,whdd->lpbiOut->biSizeImage);*/
     231               
     232                whdd->hMemDC = CreateCompatibleDC(hdc);
     233                TRACE("Creating: %ld,%p\n",whdd->lpbiOut->biSize,whdd->lpvbits);
     234                whdd->hDib = CreateDIBSection(whdd->hMemDC,(BITMAPINFO *)whdd->lpbiOut,DIB_RGB_COLORS,&(whdd->lpvbits),0,0);
     235                if (!whdd->hDib) {
     236                        TRACE("Error: %ld\n",GetLastError());
     237                }
     238                TRACE("Created: %d,%p\n",whdd->hDib,whdd->lpvbits);
     239                whdd->hOldDib = SelectObject(whdd->hMemDC,whdd->hDib);
     240        }
     241
     242        if (ret) {
     243                whdd->hdc = hdc;
     244                whdd->dxDst = dxDst;
     245                whdd->dyDst = dyDst;
     246                whdd->lpbi = HeapAlloc(GetProcessHeap(),0,lpbi->biSize);
     247                memcpy(whdd->lpbi,lpbi,lpbi->biSize);
     248                whdd->dxSrc = dxSrc;
     249                whdd->dySrc = dySrc;
     250                whdd->begun = TRUE;
     251                whdd->hpal = 0;
     252        } else {
     253                if (whdd->hic)
     254                        ICClose(whdd->hic);
     255                if (whdd->lpbiOut) {
     256                        HeapFree(GetProcessHeap(),0,whdd->lpbiOut);
     257                        whdd->lpbiOut = NULL;
     258                }
     259        }
     260
     261        GlobalUnlock16(hdd);
     262
     263        return ret;
    265264}
    266265
    267266/************************************************************************
    268  *      DrawDibBegin        [MSVIDEO.104]
     267 *              DrawDibBegin            [MSVIDEO.104]
    269268 */
    270269BOOL16 VFWAPI DrawDibBegin16(HDRAWDIB16 hdd,
    271                            HDC16      hdc,
    272                            INT16      dxDst,
    273                            INT16      dyDst,
    274                            LPBITMAPINFOHEADER lpbi,
    275                            INT16      dxSrc,
    276                            INT16      dySrc,
    277                            UINT16     wFlags) {
    278     return DrawDibBegin(hdd,hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,wFlags);
     270                                                   HDC16      hdc,
     271                                                   INT16      dxDst,
     272                                                   INT16      dyDst,
     273                                                   LPBITMAPINFOHEADER lpbi,
     274                                                   INT16      dxSrc,
     275                                                   INT16      dySrc,
     276                                                   UINT16     wFlags) {
     277        return DrawDibBegin(hdd,hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,wFlags);
    279278}
    280279
    281280/**********************************************************************
    282  *      DrawDibDraw     [MSVFW32.@]
     281 *              DrawDibDraw             [MSVFW32.@]
    283282 */
    284283BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc,
    285     INT xDst, INT yDst, INT dxDst, INT dyDst,
    286     LPBITMAPINFOHEADER lpbi,
    287     LPVOID lpBits,
    288     INT xSrc, INT ySrc, INT dxSrc, INT dySrc,
    289     UINT wFlags
     284        INT xDst, INT yDst, INT dxDst, INT dyDst,
     285        LPBITMAPINFOHEADER lpbi,
     286        LPVOID lpBits,
     287        INT xSrc, INT ySrc, INT dxSrc, INT dySrc,
     288        UINT wFlags
    290289) {
    291     WINE_HDD *whdd;
    292     BOOL ret = TRUE;
    293 
    294     TRACE("(%d,0x%lx,%d,%d,%d,%d,%p,%p,%d,%d,%d,%d,0x%08lx)\n",
    295           hdd,(DWORD)hdc,xDst,yDst,dxDst,dyDst,lpbi,lpBits,xSrc,ySrc,dxSrc,dySrc,(DWORD)wFlags
    296     );
    297 
    298     if (wFlags & ~(DDF_SAME_HDC | DDF_SAME_DRAW | DDF_NOTKEYFRAME |
    299                    DDF_UPDATE | DDF_DONTDRAW))
    300         FIXME("wFlags == 0x%08lx not handled\n",(DWORD)wFlags);
    301 
    302     if (!lpBits) {
    303         /* Undocumented? */
    304         lpBits = (LPSTR)lpbi + (WORD)(lpbi->biSize) + (WORD)(lpbi->biClrUsed*sizeof(RGBQUAD));
    305     }
    306 
    307     whdd = GlobalLock16(hdd);
     290        WINE_HDD *whdd;
     291        BOOL ret = TRUE;
     292
     293        TRACE("(%d,0x%lx,%d,%d,%d,%d,%p,%p,%d,%d,%d,%d,0x%08lx)\n",
     294                  hdd,(DWORD)hdc,xDst,yDst,dxDst,dyDst,lpbi,lpBits,xSrc,ySrc,dxSrc,dySrc,(DWORD)wFlags
     295        );
     296
     297        if (wFlags & ~(DDF_SAME_HDC | DDF_SAME_DRAW | DDF_NOTKEYFRAME |
     298                                   DDF_UPDATE | DDF_DONTDRAW))
     299                FIXME("wFlags == 0x%08lx not handled\n",(DWORD)wFlags);
     300
     301        if (!lpBits) {
     302                /* Undocumented? */
     303                lpBits = (LPSTR)lpbi + (WORD)(lpbi->biSize) + (WORD)(lpbi->biClrUsed*sizeof(RGBQUAD));
     304        }
     305
     306        whdd = GlobalLock16(hdd);
    308307
    309308#define CHANGED(x) (whdd->x != x)
    310309
    311     if ((!whdd->begun) || (!(wFlags & DDF_SAME_HDC) && CHANGED(hdc)) || (!(wFlags & DDF_SAME_DRAW) &&
    312         (CHANGED(lpbi) || CHANGED(dxSrc) || CHANGED(dySrc) || CHANGED(dxDst) || CHANGED(dyDst)))) {
    313         TRACE("Something changed!\n");
    314         ret = DrawDibBegin(hdd,hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,0);
    315     }
     310        if ((!whdd->begun) || (!(wFlags & DDF_SAME_HDC) && CHANGED(hdc)) || (!(wFlags & DDF_SAME_DRAW) &&
     311                (CHANGED(lpbi) || CHANGED(dxSrc) || CHANGED(dySrc) || CHANGED(dxDst) || CHANGED(dyDst)))) {
     312                TRACE("Something changed!\n");
     313                ret = DrawDibBegin(hdd,hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,0);
     314        }
    316315
    317316#undef CHANGED
    318317
    319318        if ((dxDst == -1) && (dyDst == -1)) {
    320         dxDst = dxSrc;
    321         dyDst = dySrc;
    322     }
    323 
    324     if (!(wFlags & DDF_UPDATE)) {
    325         /* biSizeImage may be set to 0 for BI_RGB (uncompressed) bitmaps */
    326         if ((lpbi->biCompression == BI_RGB) && (lpbi->biSizeImage == 0))
    327             lpbi->biSizeImage = ((lpbi->biWidth * lpbi->biBitCount + 31) / 32) * 4 * lpbi->biHeight;
    328 
    329         if (lpbi->biCompression) {
    330             DWORD flags = 0;
    331 
    332             TRACE("Compression == 0x%08lx\n",lpbi->biCompression);
    333 
    334             if (wFlags & DDF_NOTKEYFRAME)
    335                 flags |= ICDECOMPRESS_NOTKEYFRAME;
    336 
    337             ICDecompress(whdd->hic,flags,lpbi,lpBits,whdd->lpbiOut,whdd->lpvbits);
    338         } else {
    339             memcpy(whdd->lpvbits,lpBits,lpbi->biSizeImage);
    340         }
    341     }
    342     if (!(wFlags & DDF_DONTDRAW) && whdd->hpal)
    343         SelectPalette(hdc,whdd->hpal,FALSE);
    344 
    345     if (!(StretchBlt(whdd->hdc,xDst,yDst,dxDst,dyDst,whdd->hMemDC,xSrc,ySrc,dxSrc,dySrc,SRCCOPY)))
    346         ret = FALSE;
    347 
    348     GlobalUnlock16(hdd);
    349     return ret;
     319                dxDst = dxSrc;
     320                dyDst = dySrc;
     321        }
     322
     323        if (!(wFlags & DDF_UPDATE)) {
     324            /* biSizeImage may be set to 0 for BI_RGB (uncompressed) bitmaps */
     325            if ((lpbi->biCompression == BI_RGB) && (lpbi->biSizeImage == 0))
     326                    lpbi->biSizeImage = ((lpbi->biWidth * lpbi->biBitCount + 31) / 32) * 4 * lpbi->biHeight;
     327
     328                if (lpbi->biCompression) {
     329                    DWORD flags = 0;
     330               
     331                        TRACE("Compression == 0x%08lx\n",lpbi->biCompression);
     332               
     333                        if (wFlags & DDF_NOTKEYFRAME)
     334                            flags |= ICDECOMPRESS_NOTKEYFRAME;
     335               
     336                        ICDecompress(whdd->hic,flags,lpbi,lpBits,whdd->lpbiOut,whdd->lpvbits);
     337                } else {
     338                    memcpy(whdd->lpvbits,lpBits,lpbi->biSizeImage);
     339                }       
     340        }
     341        if (!(wFlags & DDF_DONTDRAW) && whdd->hpal)
     342            SelectPalette(hdc,whdd->hpal,FALSE);
     343
     344        if (!(StretchBlt(whdd->hdc,xDst,yDst,dxDst,dyDst,whdd->hMemDC,xSrc,ySrc,dxSrc,dySrc,SRCCOPY)))
     345            ret = FALSE;
     346
     347        GlobalUnlock16(hdd);
     348        return ret;
    350349}
    351350
    352351/**********************************************************************
    353  *      DrawDibDraw     [MSVIDEO.106]
    354  */
    355 BOOL16 VFWAPI DrawDibDraw16(HDRAWDIB16 hdd,
    356                           HDC16 hdc,
    357                           INT16 xDst,
    358                           INT16 yDst,
    359                           INT16 dxDst,
    360                           INT16 dyDst,
    361                           LPBITMAPINFOHEADER lpbi,
    362                           LPVOID lpBits,
    363                           INT16 xSrc,
    364                           INT16 ySrc,
    365                           INT16 dxSrc,
    366                           INT16 dySrc,
    367                           UINT16 wFlags) {
    368     return DrawDibDraw(hdd,hdc,xDst,yDst,dxDst,dyDst,lpbi,lpBits,xSrc,ySrc,dxSrc,dySrc,wFlags);
     352 *              DrawDibDraw             [MSVIDEO.106]
     353 */
     354BOOL16 VFWAPI DrawDibDraw16(HDRAWDIB16 hdd,             
     355                                                  HDC16 hdc,
     356                                                  INT16 xDst,
     357                                                  INT16 yDst,
     358                                                  INT16 dxDst,
     359                                                  INT16 dyDst,
     360                                                  LPBITMAPINFOHEADER lpbi,
     361                                                  LPVOID lpBits,
     362                                                  INT16 xSrc,
     363                                                  INT16 ySrc,
     364                                                  INT16 dxSrc,
     365                                                  INT16 dySrc,
     366                                                  UINT16 wFlags) {
     367        return DrawDibDraw(hdd,hdc,xDst,yDst,dxDst,dyDst,lpbi,lpBits,xSrc,ySrc,dxSrc,dySrc,wFlags);
    369368}
    370369
    371370/*************************************************************************
    372  *      DrawDibStart        [MSVFW32.@]
     371 *              DrawDibStart            [MSVFW32.@]
    373372 */
    374373BOOL VFWAPI DrawDibStart(HDRAWDIB hdd, DWORD rate) {
    375     FIXME("(0x%08lx,%ld), stub\n",(DWORD)hdd,rate);
    376     return TRUE;
     374        FIXME("(0x%08lx,%ld), stub\n",(DWORD)hdd,rate);
     375        return TRUE;
    377376}
    378377
    379378/*************************************************************************
    380  *      DrawDibStart        [MSVIDEO.118]
     379 *              DrawDibStart            [MSVIDEO.118]
    381380 */
    382381BOOL16 VFWAPI DrawDibStart16(HDRAWDIB16 hdd, DWORD rate) {
    383     return DrawDibStart(hdd,rate);
     382        return DrawDibStart(hdd,rate);
    384383}
    385384
    386385/*************************************************************************
    387  *      DrawDibStop     [MSVFW32.@]
     386 *              DrawDibStop             [MSVFW32.@]
    388387 */
    389388BOOL VFWAPI DrawDibStop(HDRAWDIB hdd) {
    390     FIXME("(0x%08lx), stub\n",(DWORD)hdd);
    391     return TRUE;
     389        FIXME("(0x%08lx), stub\n",(DWORD)hdd);
     390        return TRUE;
    392391}
    393392
    394393/*************************************************************************
    395  *      DrawDibStop     [MSVIDEO.119]
     394 *              DrawDibStop             [MSVIDEO.119]
    396395 */
    397396BOOL16 DrawDibStop16(HDRAWDIB16 hdd) {
    398     return DrawDibStop(hdd);
     397        return DrawDibStop(hdd);
    399398}
    400399
     
    403402 */
    404403BOOL VFWAPI DrawDibSetPalette(HDRAWDIB hdd, HPALETTE hpal) {
    405     WINE_HDD *whdd;
    406 
    407     TRACE("(0x%08lx,0x%08lx)\n",(DWORD)hdd,(DWORD)hpal);
    408 
    409     whdd = GlobalLock16(hdd);
    410     whdd->hpal = hpal;
    411 
    412     if (whdd->begun) {
    413         SelectPalette(whdd->hdc,hpal,0);
    414         RealizePalette(whdd->hdc);
    415     }
    416     GlobalUnlock16(hdd);
    417     return TRUE;
     404        WINE_HDD *whdd;
     405
     406        TRACE("(0x%08lx,0x%08lx)\n",(DWORD)hdd,(DWORD)hpal);
     407
     408        whdd = GlobalLock16(hdd);
     409        whdd->hpal = hpal;
     410       
     411        if (whdd->begun) {
     412                SelectPalette(whdd->hdc,hpal,0);
     413                RealizePalette(whdd->hdc);
     414        }
     415        GlobalUnlock16(hdd);
     416        return TRUE;
    418417}
    419418
     
    422421 */
    423422BOOL16 VFWAPI DrawDibSetPalette16(HDRAWDIB16 hdd, HPALETTE16 hpal) {
    424     return DrawDibSetPalette(hdd,hpal);
     423        return DrawDibSetPalette(hdd,hpal);
    425424}
    426425
     
    429428 */
    430429HPALETTE VFWAPI DrawDibGetPalette(HDRAWDIB hdd) {
    431     WINE_HDD *whdd;
    432     HPALETTE ret;
    433 
    434     TRACE("(0x%08lx)\n",(DWORD)hdd);
    435 
    436     whdd = GlobalLock16(hdd);
    437     ret = whdd->hpal;
    438     GlobalUnlock16(hdd);
    439     return ret;
     430        WINE_HDD *whdd;
     431        HPALETTE ret;
     432
     433        TRACE("(0x%08lx)\n",(DWORD)hdd);
     434
     435        whdd = GlobalLock16(hdd);
     436        ret = whdd->hpal;
     437        GlobalUnlock16(hdd);
     438        return ret;
    440439}
    441440
     
    444443 */
    445444HPALETTE16 VFWAPI DrawDibGetPalette16(HDRAWDIB16 hdd) {
    446     return (HPALETTE16)DrawDibGetPalette(hdd);
     445        return (HPALETTE16)DrawDibGetPalette(hdd);
    447446}
    448447
     
    451450 */
    452451UINT VFWAPI DrawDibRealize(HDRAWDIB hdd, HDC hdc, BOOL fBackground) {
    453     WINE_HDD *whdd;
    454     HPALETTE oldPal;
    455     UINT ret = 0;
    456 
    457     FIXME("(%d,0x%08lx,%d), stub\n",hdd,(DWORD)hdc,fBackground);
    458 
    459     whdd = GlobalLock16(hdd);
    460 
    461     if (!whdd || !(whdd->begun)) {
    462         ret = 0;
    463         goto out;
    464     }
    465 
    466     if (!whdd->hpal)
    467         whdd->hpal = CreateHalftonePalette(hdc);
    468 
    469     oldPal = SelectPalette(hdc,whdd->hpal,fBackground);
    470     ret = RealizePalette(hdc);
    471 
     452        WINE_HDD *whdd;
     453        HPALETTE oldPal;
     454        UINT ret = 0;
     455
     456        FIXME("(%d,0x%08lx,%d), stub\n",hdd,(DWORD)hdc,fBackground);
     457       
     458        whdd = GlobalLock16(hdd);
     459
     460        if (!whdd || !(whdd->begun)) {
     461                ret = 0;
     462                goto out;
     463        }
     464       
     465        if (!whdd->hpal)
     466                whdd->hpal = CreateHalftonePalette(hdc);
     467
     468        oldPal = SelectPalette(hdc,whdd->hpal,fBackground);
     469        ret = RealizePalette(hdc);
     470       
    472471 out:
    473     GlobalUnlock16(hdd);
    474 
    475     TRACE("=> %u\n",ret);
    476     return ret;
     472        GlobalUnlock16(hdd);
     473
     474        TRACE("=> %u\n",ret);
     475        return ret;
    477476}
    478477
     
    481480 */
    482481UINT16 VFWAPI DrawDibRealize16(HDRAWDIB16 hdd, HDC16 hdc, BOOL16 fBackground) {
    483     return (UINT16)DrawDibRealize(hdd,hdc,fBackground);
    484 }
     482        return (UINT16)DrawDibRealize(hdd,hdc,fBackground);
     483}
  • trunk/src/msvfw32/msvideo_main.c

    r6648 r6712  
    1 /* $Id: msvideo_main.c,v 1.2 2001-09-05 13:12:35 bird Exp $ */
    21/*
    32 * Copyright 1998 Marcus Meissner
    4  * Copyright 2000 Bradley Baetz
     3 * Copyright 2000 Bradley Baetz 
    54 *
    65 * FIXME: This all assumes 32 bit codecs
    7  *      Win95 appears to prefer 32 bit codecs, even from 16 bit code.
    8  *      There is the ICOpenFunction16 to worry about still, though.
     6 *              Win95 appears to prefer 32 bit codecs, even from 16 bit code.
     7 *              There is the ICOpenFunction16 to worry about still, though.
    98 */
    109
     
    3534#define GlobalFree16 GlobalFree
    3635#undef SEGPTR_NEW
    37 #define SEGPTR_NEW(a)   malloc(sizeof(a))
     36#define SEGPTR_NEW(a)   malloc(sizeof(a))
    3837#define SEGPTR_FREE(a)  free(a)
    3938#define SEGPTR_GET(a)   a
     
    6059
    6160/***********************************************************************
    62  *      VideoForWindowsVersion      [MSVFW32.2]
    63  *      VideoForWindowsVersion      [MSVIDEO.2]
     61 *              VideoForWindowsVersion          [MSVFW32.2]
     62 *              VideoForWindowsVersion          [MSVIDEO.2]
    6463 * Returns the version in major.minor form.
    6564 * In Windows95 this returns 0x040003b6 (4.950)
    6665 */
    6766DWORD WINAPI VideoForWindowsVersion(void) {
    68     return 0x040003B6; /* 4.950 */
    69 }
    70 
    71 /***********************************************************************
    72  *      VideoCapDriverDescAndVer    [MSVIDEO.22]
     67        return 0x040003B6; /* 4.950 */
     68}
     69
     70/***********************************************************************
     71 *              VideoCapDriverDescAndVer        [MSVIDEO.22]
    7372 */
    7473DWORD WINAPI VideoCapDriverDescAndVer(
    75     WORD nr,LPSTR buf1,WORD buf1len,LPSTR buf2,WORD buf2len
     74        WORD nr,LPSTR buf1,WORD buf1len,LPSTR buf2,WORD buf2len
    7675) {
    77     DWORD   verhandle;
    78     WORD    xnr = nr;
    79     DWORD   infosize;
    80     UINT    subblocklen;
    81     char    *s,buf[2000],fn[260];
    82     LPBYTE  infobuf;
    83     LPVOID  subblock;
    84 
    85     TRACE("(%d,%p,%d,%p,%d)\n",nr,buf1,buf1len,buf2,buf2len);
    86     if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,sizeof(buf),"system.ini")) {
    87         s = buf;
    88         while (*s) {
    89                 if (!strncasecmp(s,"vid",3)) {
    90                 if (!xnr)
    91                 break;
    92                 xnr--;
    93             }
    94             s=s+strlen(s)+1; /* either next char or \0 */
    95         }
    96     } else
    97         return 20; /* hmm, out of entries even if we don't have any */
    98     if (xnr) {
    99         FIXME("No more VID* entries found\n");
    100         return 20;
    101     }
    102     GetPrivateProfileStringA("drivers32",s,NULL,fn,sizeof(fn),"system.ini");
    103     infosize = GetFileVersionInfoSizeA(fn,&verhandle);
    104     if (!infosize) {
    105         TRACE("%s has no fileversioninfo.\n",fn);
    106         return 18;
    107     }
    108     infobuf = HeapAlloc(GetProcessHeap(),0,infosize);
    109     if (GetFileVersionInfoA(fn,verhandle,infosize,infobuf)) {
    110         char    vbuf[200];
    111         /* Yes, two space behind : */
    112         /* FIXME: test for buflen */
    113         sprintf(vbuf,"Version:  %d.%d.%d.%d\n",
    114             ((WORD*)infobuf)[0x0f],
    115             ((WORD*)infobuf)[0x0e],
    116             ((WORD*)infobuf)[0x11],
    117             ((WORD*)infobuf)[0x10]
    118         );
    119         TRACE("version of %s is %s\n",fn,vbuf);
    120         strncpy(buf2,vbuf,buf2len);
    121     } else {
    122         TRACE("GetFileVersionInfoA failed for %s.\n",fn);
    123         strncpy(buf2,fn,buf2len); /* msvideo.dll appears to copy fn*/
    124     }
    125     /* FIXME: language problem? */
    126     if (VerQueryValueA( infobuf,
    127                 "\\StringFileInfo\\040904E4\\FileDescription",
    128                 &subblock,
    129                 &subblocklen
    130     )) {
    131         TRACE("VQA returned %s\n",(LPCSTR)subblock);
    132         strncpy(buf1,subblock,buf1len);
    133     } else {
    134         TRACE("VQA did not return on query \\StringFileInfo\\040904E4\\FileDescription?\n");
    135         strncpy(buf1,fn,buf1len); /* msvideo.dll appears to copy fn*/
    136     }
    137     HeapFree(GetProcessHeap(),0,infobuf);
    138     return 0;
     76        DWORD   verhandle;
     77        WORD    xnr = nr;
     78        DWORD   infosize;
     79        UINT    subblocklen;
     80        char    *s,buf[2000],fn[260];
     81        LPBYTE  infobuf;
     82        LPVOID  subblock;
     83
     84        TRACE("(%d,%p,%d,%p,%d)\n",nr,buf1,buf1len,buf2,buf2len);
     85        if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,sizeof(buf),"system.ini")) {
     86                s = buf;
     87                while (*s) {
     88                        if (!strncasecmp(s,"vid",3)) {
     89                            if (!xnr)
     90                                break;
     91                            xnr--;
     92                        }
     93                        s=s+strlen(s)+1; /* either next char or \0 */
     94                }
     95        } else
     96            return 20; /* hmm, out of entries even if we don't have any */
     97        if (xnr) {
     98                FIXME("No more VID* entries found\n");
     99                return 20;
     100        }
     101        GetPrivateProfileStringA("drivers32",s,NULL,fn,sizeof(fn),"system.ini");
     102        infosize = GetFileVersionInfoSizeA(fn,&verhandle);
     103        if (!infosize) {
     104            TRACE("%s has no fileversioninfo.\n",fn);
     105            return 18;
     106        }
     107        infobuf = HeapAlloc(GetProcessHeap(),0,infosize);
     108        if (GetFileVersionInfoA(fn,verhandle,infosize,infobuf)) {
     109            char        vbuf[200];
     110            /* Yes, two space behind : */
     111            /* FIXME: test for buflen */
     112            sprintf(vbuf,"Version:  %d.%d.%d.%d\n",
     113                    ((WORD*)infobuf)[0x0f],
     114                    ((WORD*)infobuf)[0x0e],
     115                    ((WORD*)infobuf)[0x11],
     116                    ((WORD*)infobuf)[0x10]
     117            );
     118            TRACE("version of %s is %s\n",fn,vbuf);
     119            strncpy(buf2,vbuf,buf2len);
     120        } else {
     121            TRACE("GetFileVersionInfoA failed for %s.\n",fn);
     122            strncpy(buf2,fn,buf2len); /* msvideo.dll appears to copy fn*/
     123        }
     124        /* FIXME: language problem? */
     125        if (VerQueryValueA(     infobuf,
     126                                "\\StringFileInfo\\040904E4\\FileDescription",
     127                                &subblock,
     128                                &subblocklen
     129        )) {
     130            TRACE("VQA returned %s\n",(LPCSTR)subblock);
     131            strncpy(buf1,subblock,buf1len);
     132        } else {
     133            TRACE("VQA did not return on query \\StringFileInfo\\040904E4\\FileDescription?\n");
     134            strncpy(buf1,fn,buf1len); /* msvideo.dll appears to copy fn*/
     135        }
     136        HeapFree(GetProcessHeap(),0,infobuf);
     137        return 0;
    139138}
    140139
     
    142141
    143142/***********************************************************************
    144  *      ICInfo              [MSVFW32.@]
     143 *              ICInfo                          [MSVFW32.@]
    145144 * Get information about an installable compressor. Return TRUE if there
    146145 * is one.
    147146 */
    148147BOOL VFWAPI ICInfo(
    149     DWORD fccType,      /* [in] type of compressor ('vidc') */
    150     DWORD fccHandler,   /* [in] <n>th compressor */
    151     ICINFO *lpicinfo)   /* [out] information about compressor */
     148        DWORD fccType,          /* [in] type of compressor ('vidc') */
     149        DWORD fccHandler,       /* [in] <n>th compressor */
     150        ICINFO *lpicinfo)       /* [out] information about compressor */
    152151{
    153     char    type[5],buf[2000];
    154 
    155     memcpy(type,&fccType,4);type[4]=0;
    156     TRACE("(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
    157     /* does OpenDriver/CloseDriver */
    158     lpicinfo->dwSize = sizeof(ICINFO);
    159     lpicinfo->fccType = fccType;
    160     lpicinfo->dwFlags = 0;
    161     if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
    162         char *s = buf;
    163         while (*s) {
    164             if (!strncasecmp(type,s,4)) {
    165                 if(!fccHandler--) {
    166                     lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
    167                     return TRUE;
    168                 }
    169             }
    170             s=s+strlen(s)+1; /* either next char or \0 */
    171         }
    172     }
    173     return FALSE;
     152        char    type[5],buf[2000];
     153
     154        memcpy(type,&fccType,4);type[4]=0;
     155        TRACE("(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
     156        /* does OpenDriver/CloseDriver */
     157        lpicinfo->dwSize = sizeof(ICINFO);
     158        lpicinfo->fccType = fccType;
     159        lpicinfo->dwFlags = 0;
     160        if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
     161                char *s = buf;
     162                while (*s) {
     163                        if (!strncasecmp(type,s,4)) {
     164                                if(!fccHandler--) {
     165                                        lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
     166                                        return TRUE;
     167                                }
     168                        }
     169                        s=s+strlen(s)+1; /* either next char or \0 */
     170                }
     171        }
     172        return FALSE;
    174173}
    175174#ifndef __WIN32OS2__
    176175/***********************************************************************
    177  *      ICInfo              [MSVIDEO.200]
     176 *              ICInfo                          [MSVIDEO.200]
    178177 */
    179178BOOL16 VFWAPI ICInfo16(
    180     DWORD     fccType,    /* [in] */
    181     DWORD     fccHandler, /* [in] */
    182     ICINFO16 *lpicinfo)   /* [in/out] NOTE: SEGPTR */
     179        DWORD     fccType,    /* [in] */
     180        DWORD     fccHandler, /* [in] */
     181        ICINFO16 *lpicinfo)   /* [in/out] NOTE: SEGPTR */
    183182{
    184     BOOL16 ret;
    185     LPVOID lpv;
    186     DWORD lParam = (DWORD)lpicinfo;
    187     DWORD size = ((ICINFO*)(MapSL((SEGPTR)lpicinfo)))->dwSize;
    188 
    189     /* Use the mapping functions to map the ICINFO structure */
    190     lpv = MSVIDEO_MapMsg16To32(ICM_GETINFO,&lParam,&size);
    191 
    192     ret = ICInfo(fccType,fccHandler,(ICINFO*)lParam);
    193 
    194     MSVIDEO_UnmapMsg16To32(ICM_GETINFO,lpv,&lParam,&size);
    195 
    196     return ret;
    197 }
    198 #endif
    199 /***********************************************************************
    200  *      ICOpen              [MSVFW32.@]
     183        BOOL16 ret;
     184        LPVOID lpv;
     185        DWORD lParam = (DWORD)lpicinfo;
     186        DWORD size = ((ICINFO*)(MapSL((SEGPTR)lpicinfo)))->dwSize;
     187
     188        /* Use the mapping functions to map the ICINFO structure */
     189        lpv = MSVIDEO_MapMsg16To32(ICM_GETINFO,&lParam,&size);
     190
     191        ret = ICInfo(fccType,fccHandler,(ICINFO*)lParam);
     192
     193        MSVIDEO_UnmapMsg16To32(ICM_GETINFO,lpv,&lParam,&size);
     194       
     195        return ret;
     196}
     197#endif
     198/***********************************************************************
     199 *              ICOpen                          [MSVFW32.@]
    201200 * Opens an installable compressor. Return special handle.
    202201 */
    203202HIC VFWAPI ICOpen(DWORD fccType,DWORD fccHandler,UINT wMode) {
    204     char        type[5],handler[5],codecname[20];
    205     ICOPEN      icopen;
    206     HDRVR       hdrv;
    207     HIC16       hic;
    208     WINE_HIC    *whic;
    209 
    210     memcpy(type,&fccType,4);type[4]=0;
    211     memcpy(handler,&fccHandler,4);handler[4]=0;
    212     TRACE("(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
    213 
    214     sprintf(codecname,"%s.%s",type,handler);
    215 
    216     /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
    217     * same layout as ICOPEN
    218     */
    219     icopen.fccType      = fccType;
    220     icopen.fccHandler   = fccHandler;
    221     icopen.dwSize       = sizeof(ICOPEN);
    222     icopen.dwFlags      = wMode;
    223     /* FIXME: do we need to fill out the rest too? */
    224     hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
    225     if (!hdrv) {
    226         if (!strcasecmp(type,"vids")) {
    227         sprintf(codecname,"vidc.%s",handler);
    228         fccType = mmioFOURCC('v','i','d','c');
    229         }
    230         hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
    231         if (!hdrv)
    232             return 0;
    233     }
    234     /* The handle should be a valid 16-bit handle as well */
    235     hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
    236     whic = (WINE_HIC*)GlobalLock16(hic);
    237     whic->hdrv  = hdrv;
    238     whic->driverproc= NULL;
     203        char            type[5],handler[5],codecname[20];
     204        ICOPEN          icopen;
     205        HDRVR           hdrv;
     206        HIC16           hic;
     207        WINE_HIC        *whic;
     208
     209        memcpy(type,&fccType,4);type[4]=0;
     210        memcpy(handler,&fccHandler,4);handler[4]=0;
     211        TRACE("(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
     212
     213        sprintf(codecname,"%s.%s",type,handler);
     214
     215        /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
     216        * same layout as ICOPEN
     217        */
     218        icopen.fccType          = fccType;
     219        icopen.fccHandler       = fccHandler;
     220        icopen.dwSize           = sizeof(ICOPEN);
     221        icopen.dwFlags          = wMode;
     222        /* FIXME: do we need to fill out the rest too? */
     223        hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
     224        if (!hdrv) {
     225            if (!strcasecmp(type,"vids")) {
     226                sprintf(codecname,"vidc.%s",handler);
     227                fccType = mmioFOURCC('v','i','d','c');
     228            }
     229            hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
     230            if (!hdrv)
     231                    return 0;
     232        }
     233        /* The handle should be a valid 16-bit handle as well */
     234        hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
     235        whic = (WINE_HIC*)GlobalLock16(hic);
     236        whic->hdrv      = hdrv;
     237        whic->driverproc= NULL;
    239238#ifdef __WIN32OS2__
    240     whic->privatevfw    = 0;
     239        whic->privatevfw        = 0;
    241240#else
    242     whic->private   = 0;
    243 #endif
    244     GlobalUnlock16(hic);
    245     TRACE("=> 0x%08lx\n",(DWORD)hic);
    246     return hic;
     241        whic->private   = 0;
     242#endif
     243        GlobalUnlock16(hic);
     244        TRACE("=> 0x%08lx\n",(DWORD)hic);
     245        return hic;
    247246}
    248247
    249248HIC MSVIDEO_OpenFunc(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler, BOOL bFrom32) {
    250     char    type[5],handler[5],codecname[20];
    251     HIC16   hic;
    252     ICOPEN*  icopen = SEGPTR_NEW(ICOPEN);
    253     WINE_HIC    *whic;
    254 
    255     memcpy(type,&fccType,4);type[4]=0;
    256     memcpy(handler,&fccHandler,4);handler[4]=0;
    257     TRACE("(%s,%s,%d,%p,%d)\n",type,handler,wMode,lpfnHandler,bFrom32?32:16);
    258 
    259     icopen->fccType     = fccType;
    260     icopen->fccHandler  = fccHandler;
    261     icopen->dwSize      = sizeof(ICOPEN);
    262     icopen->dwFlags     = wMode;
    263 
    264     sprintf(codecname,"%s.%s",type,handler);
    265 
    266     hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
    267     if (!hic)
    268         return 0;
    269     whic = GlobalLock16(hic);
    270     whic->driverproc = lpfnHandler;
    271 
     249        char    type[5],handler[5],codecname[20];
     250        HIC16   hic;
     251        ICOPEN*  icopen = SEGPTR_NEW(ICOPEN);
     252        WINE_HIC        *whic;
     253
     254        memcpy(type,&fccType,4);type[4]=0;
     255        memcpy(handler,&fccHandler,4);handler[4]=0;
     256        TRACE("(%s,%s,%d,%p,%d)\n",type,handler,wMode,lpfnHandler,bFrom32?32:16);
     257       
     258        icopen->fccType         = fccType;
     259        icopen->fccHandler      = fccHandler;
     260        icopen->dwSize          = sizeof(ICOPEN);
     261        icopen->dwFlags         = wMode;
     262       
     263        sprintf(codecname,"%s.%s",type,handler);
     264
     265        hic = GlobalAlloc16(GHND,sizeof(WINE_HIC));
     266        if (!hic)
     267                return 0;
     268        whic = GlobalLock16(hic);
     269        whic->driverproc = lpfnHandler;
     270       
    272271#ifdef __WIN32OS2__
    273     whic->privatevfw    = bFrom32;
     272        whic->privatevfw        = bFrom32;
    274273#else
    275     whic->private = bFrom32;
    276 #endif
    277 
    278     /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
    279     /* What if the function is used more than once? */
    280 
    281     if (MSVIDEO_SendMessage(hic,DRV_LOAD,0L,0L,bFrom32) != DRV_SUCCESS) {
    282         WARN("DRV_LOAD failed for hic 0x%08lx\n",(DWORD)hic);
    283         GlobalFree16(hic);
    284         return 0;
    285     }
    286     /* return value is not checked */
    287     MSVIDEO_SendMessage(hic,DRV_ENABLE,0L,0L,bFrom32);
    288 
    289     whic->hdrv = MSVIDEO_SendMessage(hic,DRV_OPEN,0,(LPARAM)(SEGPTR_GET(icopen)),FALSE);
    290     if (whic->hdrv == 0) {
    291         WARN("DRV_OPEN failed for hic 0x%08lx\n",(DWORD)hic);
    292         GlobalFree16(hic);
    293         return 0;
    294     }
    295 
    296     GlobalUnlock16(hic);
    297     TRACE("=> 0x%08lx\n",(DWORD)hic);
    298     return hic;
    299 }
    300 
    301 /***********************************************************************
    302  *      ICOpenFunction          [MSVFW32.@]
     274        whic->private = bFrom32;
     275#endif
     276       
     277        /* Now try opening/loading the driver. Taken from DRIVER_AddToList */
     278        /* What if the function is used more than once? */
     279       
     280        if (MSVIDEO_SendMessage(hic,DRV_LOAD,0L,0L,bFrom32) != DRV_SUCCESS) {
     281                WARN("DRV_LOAD failed for hic 0x%08lx\n",(DWORD)hic);
     282                GlobalFree16(hic);
     283                return 0;
     284        }
     285        /* return value is not checked */
     286        MSVIDEO_SendMessage(hic,DRV_ENABLE,0L,0L,bFrom32);
     287
     288        whic->hdrv = MSVIDEO_SendMessage(hic,DRV_OPEN,0,(LPARAM)(SEGPTR_GET(icopen)),FALSE);
     289        if (whic->hdrv == 0) {
     290                WARN("DRV_OPEN failed for hic 0x%08lx\n",(DWORD)hic);
     291                GlobalFree16(hic);
     292                return 0;
     293        }
     294
     295        GlobalUnlock16(hic);
     296        TRACE("=> 0x%08lx\n",(DWORD)hic);
     297        return hic;
     298}
     299
     300/***********************************************************************
     301 *              ICOpenFunction                  [MSVFW32.@]
    303302 */
    304303HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler) {
    305     return MSVIDEO_OpenFunc(fccType,fccHandler,wMode,lpfnHandler,TRUE);
     304        return MSVIDEO_OpenFunc(fccType,fccHandler,wMode,lpfnHandler,TRUE);
    306305}
    307306
    308307#ifndef __WIN32OS2__
    309308/***********************************************************************
    310  *      ICOpen              [MSVIDEO.203]
     309 *              ICOpen                          [MSVIDEO.203]
    311310 */
    312311HIC16 VFWAPI ICOpen16(DWORD fccType, DWORD fccHandler, UINT16 wMode) {
    313     return (HIC16)ICOpen(fccType, fccHandler, wMode);
    314 }
    315 
    316 /***********************************************************************
    317  *      ICOpenFunction          [MSVIDEO.206]
     312        return (HIC16)ICOpen(fccType, fccHandler, wMode);
     313}
     314
     315/***********************************************************************
     316 *              ICOpenFunction                  [MSVIDEO.206]
    318317 */
    319318HIC16 VFWAPI ICOpenFunction16(DWORD fccType, DWORD fccHandler, UINT16 wMode, FARPROC16 lpfnHandler)
    320319{
    321     return MSVIDEO_OpenFunc(fccType, fccHandler, wMode, (FARPROC)lpfnHandler,FALSE);
    322 }
    323 #endif
    324 
    325 /***********************************************************************
    326  *      ICGetInfo           [MSVFW32.@]
     320        return MSVIDEO_OpenFunc(fccType, fccHandler, wMode, (FARPROC)lpfnHandler,FALSE);
     321}
     322#endif
     323
     324/***********************************************************************
     325 *              ICGetInfo                       [MSVFW32.@]
    327326 */
    328327LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) {
    329     LRESULT     ret;
    330 
    331     TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
    332     ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
    333     TRACE(" -> 0x%08lx\n",ret);
    334     return ret;
     328        LRESULT         ret;
     329
     330        TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
     331        ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
     332        TRACE(" -> 0x%08lx\n",ret);
     333        return ret;
    335334}
    336335
    337336#ifndef __WIN32OS2__
    338337/***********************************************************************
    339  *      ICGetInfo           [MSVIDEO.212]
     338 *              ICGetInfo                       [MSVIDEO.212]
    340339 */
    341340LRESULT VFWAPI ICGetInfo16(HIC16 hic, ICINFO16 *picinfo,DWORD cb) {
    342     LRESULT     ret;
    343 
    344     TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
    345     ret = ICSendMessage16(hic,ICM_GETINFO,(DWORD)picinfo,cb);
    346     TRACE(" -> 0x%08lx\n",ret);
    347     return ret;
    348 }
    349 #endif
    350 
    351 /***********************************************************************
    352  *      ICLocate            [MSVFW32.@]
     341        LRESULT         ret;
     342
     343        TRACE("(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
     344        ret = ICSendMessage16(hic,ICM_GETINFO,(DWORD)picinfo,cb);
     345        TRACE(" -> 0x%08lx\n",ret);
     346        return ret;
     347}
     348#endif
     349
     350/***********************************************************************
     351 *              ICLocate                        [MSVFW32.@]
    353352 */
    354353HIC VFWAPI ICLocate(
    355     DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
    356     LPBITMAPINFOHEADER lpbiOut, WORD wMode)
     354        DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
     355        LPBITMAPINFOHEADER lpbiOut, WORD wMode)
    357356{
    358     char    type[5],handler[5];
    359     HIC hic;
    360     DWORD   querymsg;
    361     LPSTR pszBuffer;
    362 
    363     type[4]=0;memcpy(type,&fccType,4);
    364     handler[4]=0;memcpy(handler,&fccHandler,4);
    365 
    366     TRACE("(%s,%s,%p,%p,0x%04x)\n", type, handler, lpbiIn, lpbiOut, wMode);
    367 
    368     switch (wMode) {
    369     case ICMODE_FASTCOMPRESS:
    370     case ICMODE_COMPRESS:
    371         querymsg = ICM_COMPRESS_QUERY;
    372         break;
    373     case ICMODE_FASTDECOMPRESS:
    374     case ICMODE_DECOMPRESS:
    375         querymsg = ICM_DECOMPRESS_QUERY;
    376         break;
    377     case ICMODE_DRAW:
    378         querymsg = ICM_DRAW_QUERY;
    379         break;
    380     default:
    381         WARN("Unknown mode (%d)\n",wMode);
    382         return 0;
    383     }
    384 
    385     /* Easy case: handler/type match, we just fire a query and return */
    386     hic = ICOpen(fccType,fccHandler,wMode);
    387     if (hic) {
    388         if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
    389             return hic;
    390         ICClose(hic);
    391     }
    392 
    393     type[4]='.';memcpy(type,&fccType,4);
    394     handler[4]='.';memcpy(handler,&fccHandler,4);
    395 
    396     /* Now try each driver in turn. 32 bit codecs only. */
    397     /* FIXME: Move this to an init routine? */
    398 
    399     pszBuffer = (LPSTR)HeapAlloc(GetProcessHeap(),0,1024);
    400     if (GetPrivateProfileSectionA("drivers32",pszBuffer,1024,"system.ini")) {
    401         char* s = pszBuffer;
    402         while (*s) {
    403             if (!strncasecmp(type,s,5)) {
    404                 char *s2 = s;
    405                 while (*s2 != '\0' && *s2 != '.') s2++;
    406                 if (*s2++) {
    407                     HIC h;
    408 
    409                     h = ICOpen(fccType,*(DWORD*)s2,wMode);
    410                     if (h) {
    411                         if (!ICSendMessage(h,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
    412                             return h;
    413                         ICClose(h);
    414                     }
    415                 }
    416             }
    417             s += strlen(s) + 1;
    418         }
    419     }
    420     HeapFree(GetProcessHeap(),0,pszBuffer);
    421 
    422     if (fccType==streamtypeVIDEO) {
    423         hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
    424         if (hic)
    425             return hic;
    426     }
    427 
    428     type[4] = handler[4] = '\0';
    429     WARN("(%.4s,%.4s,%p,%p,0x%04x) not found!\n",type,handler,lpbiIn,lpbiOut,wMode);
    430     return 0;
     357        char    type[5],handler[5];
     358        HIC     hic;
     359        DWORD   querymsg;
     360        LPSTR pszBuffer;
     361
     362        type[4]=0;memcpy(type,&fccType,4);
     363        handler[4]=0;memcpy(handler,&fccHandler,4);
     364
     365        TRACE("(%s,%s,%p,%p,0x%04x)\n", type, handler, lpbiIn, lpbiOut, wMode);
     366
     367        switch (wMode) {
     368        case ICMODE_FASTCOMPRESS:
     369        case ICMODE_COMPRESS:
     370                querymsg = ICM_COMPRESS_QUERY;
     371                break;
     372        case ICMODE_FASTDECOMPRESS:
     373        case ICMODE_DECOMPRESS:
     374                querymsg = ICM_DECOMPRESS_QUERY;
     375                break;
     376        case ICMODE_DRAW:
     377                querymsg = ICM_DRAW_QUERY;
     378                break;
     379        default:
     380                WARN("Unknown mode (%d)\n",wMode);
     381                return 0;
     382        }
     383
     384        /* Easy case: handler/type match, we just fire a query and return */
     385        hic = ICOpen(fccType,fccHandler,wMode);
     386        if (hic) {
     387                if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
     388                        return hic;
     389                ICClose(hic);
     390        }
     391
     392        type[4]='.';memcpy(type,&fccType,4);
     393        handler[4]='.';memcpy(handler,&fccHandler,4);
     394
     395        /* Now try each driver in turn. 32 bit codecs only. */
     396        /* FIXME: Move this to an init routine? */
     397       
     398        pszBuffer = (LPSTR)HeapAlloc(GetProcessHeap(),0,1024);
     399        if (GetPrivateProfileSectionA("drivers32",pszBuffer,1024,"system.ini")) {
     400                char* s = pszBuffer;
     401                while (*s) {
     402                        if (!strncasecmp(type,s,5)) {
     403                                char *s2 = s;
     404                                while (*s2 != '\0' && *s2 != '.') s2++;
     405                                if (*s2++) {
     406                                        HIC h;
     407
     408                                        h = ICOpen(fccType,*(DWORD*)s2,wMode);
     409                                        if (h) {
     410                                                if (!ICSendMessage(h,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
     411                                                        return h;
     412                                                ICClose(h);
     413                                        }
     414                                }
     415                        }
     416                        s += strlen(s) + 1;
     417                }
     418        }
     419        HeapFree(GetProcessHeap(),0,pszBuffer);
     420       
     421        if (fccType==streamtypeVIDEO) {
     422                hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
     423                if (hic)
     424                        return hic;
     425        }
     426
     427        type[4] = handler[4] = '\0';
     428        WARN("(%.4s,%.4s,%p,%p,0x%04x) not found!\n",type,handler,lpbiIn,lpbiOut,wMode);
     429        return 0;
    431430}
    432431
    433432#ifndef __WIN32OS2__
    434433/***********************************************************************
    435  *      ICLocate            [MSVIDEO.213]
     434 *              ICLocate                        [MSVIDEO.213]
    436435 */
    437436HIC16 VFWAPI ICLocate16(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
    438                         LPBITMAPINFOHEADER lpbiOut, WORD wFlags) {
    439     return (HIC16)ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, wFlags);
    440 }
    441 #endif
    442 
    443 /***********************************************************************
    444  *      ICGetDisplayFormat          [MSVFW32.@]
     437                                                LPBITMAPINFOHEADER lpbiOut, WORD wFlags) {
     438        return (HIC16)ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, wFlags);
     439}
     440#endif
     441
     442/***********************************************************************
     443 *              ICGetDisplayFormat                      [MSVFW32.@]
    445444 */
    446445HIC VFWAPI ICGetDisplayFormat(
    447     HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
    448     INT depth,INT dx,INT dy)
     446        HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
     447        INT depth,INT dx,INT dy)
    449448{
    450     HIC tmphic = hic;
    451 
    452     FIXME("(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD)hic,lpbiIn,lpbiOut,depth,dx,dy);
    453     if (!tmphic) {
    454         tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
    455         if (!tmphic)
    456             return tmphic;
    457     }
    458     if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
    459         dy = dx = 0; /* no resize needed */
    460 
    461     /* Can we decompress it ? */
    462     if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
    463         goto errout; /* no, sorry */
    464 
    465     ICDecompressGetFormat(tmphic,lpbiIn,lpbiOut);
    466 
    467     if (lpbiOut->biCompression != 0) {
    468        FIXME("Ooch, how come decompressor outputs compressed data (%ld)??\n",
    469             lpbiOut->biCompression);
    470     }
    471     if (lpbiOut->biSize < sizeof(*lpbiOut)) {
    472        FIXME("Ooch, size of output BIH is too small (%ld)\n",
    473             lpbiOut->biSize);
    474        lpbiOut->biSize = sizeof(*lpbiOut);
    475     }
    476     if (!depth) {
    477         HDC hdc;
    478 
    479         hdc = GetDC(0);
    480         depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
    481         ReleaseDC(0,hdc);
    482         if (depth==15)  depth = 16;
    483         if (depth<8)    depth =  8;
    484     }
    485     if (lpbiIn->biBitCount == 8)
    486         depth = 8;
    487 
    488     TRACE("=> 0x%08lx\n",(DWORD)tmphic);
    489     return tmphic;
     449        HIC     tmphic = hic;
     450
     451        FIXME("(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD)hic,lpbiIn,lpbiOut,depth,dx,dy);
     452        if (!tmphic) {
     453                tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
     454                if (!tmphic)
     455                        return tmphic;
     456        }
     457        if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
     458                dy = dx = 0; /* no resize needed */
     459
     460        /* Can we decompress it ? */
     461        if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
     462                goto errout; /* no, sorry */
     463
     464        ICDecompressGetFormat(tmphic,lpbiIn,lpbiOut);
     465
     466        if (lpbiOut->biCompression != 0) {
     467           FIXME("Ooch, how come decompressor outputs compressed data (%ld)??\n",
     468                        lpbiOut->biCompression);
     469        }
     470        if (lpbiOut->biSize < sizeof(*lpbiOut)) {
     471           FIXME("Ooch, size of output BIH is too small (%ld)\n",
     472                        lpbiOut->biSize);
     473           lpbiOut->biSize = sizeof(*lpbiOut);
     474        }
     475        if (!depth) {
     476                HDC     hdc;
     477
     478                hdc = GetDC(0);
     479                depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
     480                ReleaseDC(0,hdc);
     481                if (depth==15)  depth = 16;
     482                if (depth<8)    depth =  8;
     483        }
     484        if (lpbiIn->biBitCount == 8)
     485                depth = 8;
     486       
     487        TRACE("=> 0x%08lx\n",(DWORD)tmphic);
     488        return tmphic;
    490489errout:
    491     if (hic!=tmphic)
    492         ICClose(tmphic);
    493 
    494     TRACE("=> 0\n");
    495     return 0;
     490        if (hic!=tmphic)
     491                ICClose(tmphic);
     492
     493        TRACE("=> 0\n");
     494        return 0;
    496495}
    497496
    498497#ifndef __WIN32OS2__
    499498/***********************************************************************
    500  *      ICGetDisplayFormat          [MSVIDEO.239]
     499 *              ICGetDisplayFormat                      [MSVIDEO.239]
    501500 */
    502501HIC16 VFWAPI ICGetDisplayFormat16(HIC16 hic, LPBITMAPINFOHEADER lpbiIn,
    503                                   LPBITMAPINFOHEADER lpbiOut, INT16 depth, INT16 dx, INT16 dy) {
    504     return (HIC16)ICGetDisplayFormat(hic,lpbiIn,lpbiOut,depth,dx,dy);
    505 }
    506 #endif
    507 
    508 /***********************************************************************
    509  *      ICCompress          [MSVFW32.@]
     502                                                                  LPBITMAPINFOHEADER lpbiOut, INT16 depth, INT16 dx, INT16 dy) {
     503        return (HIC16)ICGetDisplayFormat(hic,lpbiIn,lpbiOut,depth,dx,dy);
     504}
     505#endif
     506
     507/***********************************************************************
     508 *              ICCompress                      [MSVFW32.@]
    510509 */
    511510DWORD VFWAPIV
    512511ICCompress(
    513     HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
    514     LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
    515     LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
    516     LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
     512        HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
     513        LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
     514        LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
     515        LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev)
    517516{
    518     ICCOMPRESS  iccmp;
    519 
    520     TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
    521 
    522     iccmp.dwFlags       = dwFlags;
    523 
    524     iccmp.lpbiOutput    = lpbiOutput;
    525     iccmp.lpOutput      = lpData;
    526     iccmp.lpbiInput     = lpbiInput;
    527     iccmp.lpInput       = lpBits;
    528 
    529     iccmp.lpckid        = lpckid;
    530     iccmp.lpdwFlags     = lpdwFlags;
    531     iccmp.lFrameNum     = lFrameNum;
    532     iccmp.dwFrameSize   = dwFrameSize;
    533     iccmp.dwQuality     = dwQuality;
    534     iccmp.lpbiPrev      = lpbiPrev;
    535     iccmp.lpPrev        = lpPrev;
    536     return ICSendMessage(hic,ICM_COMPRESS,(DWORD)&iccmp,sizeof(iccmp));
     517        ICCOMPRESS      iccmp;
     518
     519        TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
     520
     521        iccmp.dwFlags           = dwFlags;
     522
     523        iccmp.lpbiOutput        = lpbiOutput;
     524        iccmp.lpOutput          = lpData;
     525        iccmp.lpbiInput         = lpbiInput;
     526        iccmp.lpInput           = lpBits;
     527
     528        iccmp.lpckid            = lpckid;
     529        iccmp.lpdwFlags         = lpdwFlags;
     530        iccmp.lFrameNum         = lFrameNum;
     531        iccmp.dwFrameSize       = dwFrameSize;
     532        iccmp.dwQuality         = dwQuality;
     533        iccmp.lpbiPrev          = lpbiPrev;
     534        iccmp.lpPrev            = lpPrev;
     535        return ICSendMessage(hic,ICM_COMPRESS,(DWORD)&iccmp,sizeof(iccmp));
    537536}
    538537
    539538#ifndef __WIN32OS2__
    540539/***********************************************************************
    541  *      _ICCompress         [MSVIDEO.224]
     540 *              _ICCompress                     [MSVIDEO.224]
    542541 */
    543542DWORD VFWAPIV ICCompress16(HIC16 hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData,
    544                            LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid,
    545                            LPDWORD lpdwFlags, LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality,
    546                            LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev) {
    547 
    548     DWORD ret;
    549     ICCOMPRESS *iccmp = SEGPTR_NEW(ICCOMPRESS);
    550 
    551     TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
    552 
    553     iccmp->dwFlags      = dwFlags;
    554 
    555     iccmp->lpbiOutput   = lpbiOutput;
    556     iccmp->lpOutput     = lpData;
    557     iccmp->lpbiInput        = lpbiInput;
    558     iccmp->lpInput      = lpBits;
    559 
    560     iccmp->lpckid       = lpckid;
    561     iccmp->lpdwFlags        = lpdwFlags;
    562     iccmp->lFrameNum        = lFrameNum;
    563     iccmp->dwFrameSize  = dwFrameSize;
    564     iccmp->dwQuality        = dwQuality;
    565     iccmp->lpbiPrev     = lpbiPrev;
    566     iccmp->lpPrev       = lpPrev;
    567     ret = ICSendMessage16(hic,ICM_COMPRESS,(DWORD)SEGPTR_GET(iccmp),sizeof(ICCOMPRESS));
    568     SEGPTR_FREE(iccmp);
    569     return ret;
    570 }
    571 #endif
    572 
    573 /***********************************************************************
    574  *      ICDecompress            [MSVFW32.@]
     543                                                   LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid,
     544                                                   LPDWORD lpdwFlags, LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality,
     545                                                   LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev) {
     546
     547        DWORD ret;
     548        ICCOMPRESS *iccmp = SEGPTR_NEW(ICCOMPRESS);
     549
     550        TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n",(DWORD)hic,dwFlags,lpbiOutput,lpData,lpbiInput,lpBits);
     551
     552        iccmp->dwFlags          = dwFlags;
     553
     554        iccmp->lpbiOutput       = lpbiOutput;
     555        iccmp->lpOutput         = lpData;
     556        iccmp->lpbiInput                = lpbiInput;
     557        iccmp->lpInput          = lpBits;
     558
     559        iccmp->lpckid           = lpckid;
     560        iccmp->lpdwFlags                = lpdwFlags;
     561        iccmp->lFrameNum                = lFrameNum;
     562        iccmp->dwFrameSize      = dwFrameSize;
     563        iccmp->dwQuality                = dwQuality;
     564        iccmp->lpbiPrev         = lpbiPrev;
     565        iccmp->lpPrev           = lpPrev;
     566        ret = ICSendMessage16(hic,ICM_COMPRESS,(DWORD)SEGPTR_GET(iccmp),sizeof(ICCOMPRESS));
     567        SEGPTR_FREE(iccmp);
     568        return ret;
     569}
     570#endif
     571
     572/***********************************************************************
     573 *              ICDecompress                    [MSVFW32.@]
    575574 */
    576575DWORD VFWAPIV  ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,
    577                 LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
     576                                LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits)
    578577{
    579     ICDECOMPRESS    icd;
    580     DWORD ret;
    581 
    582     TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
    583 
    584     TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
    585 
    586     icd.dwFlags = dwFlags;
    587     icd.lpbiInput   = lpbiFormat;
    588     icd.lpInput = lpData;
    589 
    590     icd.lpbiOutput  = lpbi;
    591     icd.lpOutput    = lpBits;
    592     icd.ckid    = 0;
    593     ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS));
    594 
    595     TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
    596 
    597     TRACE("-> %ld\n",ret);
    598 
    599     return ret;
     578        ICDECOMPRESS    icd;
     579        DWORD ret;
     580
     581        TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
     582
     583        TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
     584
     585        icd.dwFlags     = dwFlags;
     586        icd.lpbiInput   = lpbiFormat;
     587        icd.lpInput     = lpData;
     588
     589        icd.lpbiOutput  = lpbi;
     590        icd.lpOutput    = lpBits;
     591        icd.ckid        = 0;
     592        ret = ICSendMessage(hic,ICM_DECOMPRESS,(DWORD)&icd,sizeof(ICDECOMPRESS));
     593
     594        TRACE("lpBits[0] == %ld\n",((LPDWORD)lpBits)[0]);
     595
     596        TRACE("-> %ld\n",ret);
     597
     598        return ret;
    600599}
    601600
    602601#ifndef __WIN32OS2__
    603602/***********************************************************************
    604  *      _ICDecompress           [MSVIDEO.230]
     603 *              _ICDecompress                   [MSVIDEO.230]
    605604 */
    606605DWORD VFWAPIV ICDecompress16(HIC16 hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat,
    607                             LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits) {
    608 
    609     ICDECOMPRESS *icd = SEGPTR_NEW(ICDECOMPRESS);
    610     DWORD ret;
    611 
    612     TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
    613 
    614     icd->dwFlags = dwFlags;
    615     icd->lpbiInput = lpbiFormat;
    616     icd->lpInput = lpData;
    617     icd->lpbiOutput = lpbi;
    618     icd->lpOutput = lpBits;
    619     icd->ckid = 0;
    620 
    621     ret = ICSendMessage16(hic,ICM_DECOMPRESS,(DWORD)SEGPTR_GET(icd),sizeof(ICDECOMPRESS));
    622 
    623     SEGPTR_FREE(icd);
    624     return ret;
     606                                                        LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits) {
     607
     608        ICDECOMPRESS *icd = SEGPTR_NEW(ICDECOMPRESS);
     609        DWORD ret;
     610       
     611        TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n",(DWORD)hic,dwFlags,lpbiFormat,lpData,lpbi,lpBits);
     612
     613        icd->dwFlags = dwFlags;
     614        icd->lpbiInput = lpbiFormat;
     615        icd->lpInput = lpData;
     616        icd->lpbiOutput = lpbi;
     617        icd->lpOutput = lpBits;
     618        icd->ckid = 0;
     619
     620        ret = ICSendMessage16(hic,ICM_DECOMPRESS,(DWORD)SEGPTR_GET(icd),sizeof(ICDECOMPRESS));
     621
     622        SEGPTR_FREE(icd);
     623        return ret;
    625624}
    626625
     
    629628
    630629LPVOID MSVIDEO_MapICDEX16To32(LPDWORD lParam) {
    631     LPVOID ret;
    632 
    633     ICDECOMPRESSEX *icdx = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESSEX));
    634     ICDECOMPRESSEX16 *icdx16 = MapSL(*lParam);
    635     ret = icdx16;
    636 
    637     COPY(icdx,dwFlags);
    638     COPYPTR(icdx,lpbiSrc);
    639     COPYPTR(icdx,lpSrc);
    640     COPYPTR(icdx,lpbiDst);
    641     COPYPTR(icdx,lpDst);
    642     COPY(icdx,xDst);
    643     COPY(icdx,yDst);
    644     COPY(icdx,dxDst);
    645     COPY(icdx,dyDst);
    646     COPY(icdx,xSrc);
    647     COPY(icdx,ySrc);
    648     COPY(icdx,dxSrc);
    649     COPY(icdx,dySrc);
    650 
    651     *lParam = (DWORD)(icdx);
    652     return ret;
     630        LPVOID ret;
     631
     632        ICDECOMPRESSEX *icdx = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESSEX));
     633        ICDECOMPRESSEX16 *icdx16 = MapSL(*lParam);
     634        ret = icdx16;
     635       
     636        COPY(icdx,dwFlags);
     637        COPYPTR(icdx,lpbiSrc);
     638        COPYPTR(icdx,lpSrc);
     639        COPYPTR(icdx,lpbiDst);
     640        COPYPTR(icdx,lpDst);
     641        COPY(icdx,xDst);
     642        COPY(icdx,yDst);
     643        COPY(icdx,dxDst);
     644        COPY(icdx,dyDst);
     645        COPY(icdx,xSrc);
     646        COPY(icdx,ySrc);
     647        COPY(icdx,dxSrc);
     648        COPY(icdx,dySrc);
     649       
     650        *lParam = (DWORD)(icdx);
     651        return ret;
    653652}
    654653
    655654LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2) {
    656     LPVOID ret = 0;
    657 
    658     TRACE("Mapping %d\n",msg);
    659 
    660     switch (msg) {
    661     case DRV_LOAD:
    662     case DRV_ENABLE:
    663     case DRV_CLOSE:
    664     case DRV_DISABLE:
    665     case DRV_FREE:
    666     case ICM_ABOUT:
    667     case ICM_CONFIGURE:
    668     case ICM_COMPRESS_END:
    669     case ICM_DECOMPRESS_END:
    670     case ICM_DECOMPRESSEX_END:
    671     case ICM_SETQUALITY:
    672     case ICM_DRAW_START_PLAY:
    673     case ICM_DRAW_STOP_PLAY:
    674     case ICM_DRAW_REALIZE:
    675     case ICM_DRAW_RENDERBUFFER:
    676     case ICM_DRAW_END:
    677         break;
    678     case DRV_OPEN:
    679     case ICM_GETDEFAULTQUALITY:
    680     case ICM_GETQUALITY:
    681     case ICM_SETSTATE:
    682     case ICM_DRAW_WINDOW:
    683     case ICM_GETBUFFERSWANTED:
    684         *lParam1 = (DWORD)MapSL(*lParam1);
    685         break;
    686     case ICM_GETINFO:
    687         {
    688             ICINFO *ici = HeapAlloc(GetProcessHeap(),0,sizeof(ICINFO));
    689             ICINFO16 *ici16;
    690 
    691             ici16 = MapSL(*lParam1);
    692             ret = ici16;
    693 
    694             ici->dwSize = sizeof(ICINFO);
    695             COPY(ici,fccType);
    696             COPY(ici,fccHandler);
    697             COPY(ici,dwFlags);
    698             COPY(ici,dwVersion);
    699             COPY(ici,dwVersionICM);
     655        LPVOID ret = 0;
     656       
     657        TRACE("Mapping %d\n",msg);
     658
     659        switch (msg) {
     660        case DRV_LOAD:
     661        case DRV_ENABLE:
     662        case DRV_CLOSE:
     663        case DRV_DISABLE:
     664        case DRV_FREE:
     665        case ICM_ABOUT:
     666        case ICM_CONFIGURE:
     667        case ICM_COMPRESS_END:
     668        case ICM_DECOMPRESS_END:
     669        case ICM_DECOMPRESSEX_END:
     670        case ICM_SETQUALITY:
     671        case ICM_DRAW_START_PLAY:
     672        case ICM_DRAW_STOP_PLAY:
     673        case ICM_DRAW_REALIZE:
     674        case ICM_DRAW_RENDERBUFFER:
     675        case ICM_DRAW_END:
     676                break;
     677        case DRV_OPEN:
     678        case ICM_GETDEFAULTQUALITY:
     679        case ICM_GETQUALITY:
     680        case ICM_SETSTATE:
     681        case ICM_DRAW_WINDOW:
     682        case ICM_GETBUFFERSWANTED:
     683                *lParam1 = (DWORD)MapSL(*lParam1);
     684                break;
     685        case ICM_GETINFO:
     686                {
     687                        ICINFO *ici = HeapAlloc(GetProcessHeap(),0,sizeof(ICINFO));
     688                        ICINFO16 *ici16;
     689
     690                        ici16 = MapSL(*lParam1);
     691                        ret = ici16;
     692
     693                        ici->dwSize = sizeof(ICINFO);
     694                        COPY(ici,fccType);
     695                        COPY(ici,fccHandler);
     696                        COPY(ici,dwFlags);
     697                        COPY(ici,dwVersion);
     698                        COPY(ici,dwVersionICM);
    700699                        MultiByteToWideChar( CP_ACP, 0, ici16->szName, -1, ici->szName, 16 );
    701700                        MultiByteToWideChar( CP_ACP, 0, ici16->szDescription, -1, ici->szDescription, 128 );
    702701                        MultiByteToWideChar( CP_ACP, 0, ici16->szDriver, -1, ici->szDriver, 128 );
    703             *lParam1 = (DWORD)(ici);
    704             *lParam2 = sizeof(ICINFO);
    705         }
    706         break;
    707     case ICM_COMPRESS:
    708         {
    709             ICCOMPRESS *icc = HeapAlloc(GetProcessHeap(),0,sizeof(ICCOMPRESS));
    710             ICCOMPRESS *icc16;
    711 
    712             icc16 = MapSL(*lParam1);
    713             ret = icc16;
    714 
    715             COPY(icc,dwFlags);
    716             COPYPTR(icc,lpbiOutput);
    717             COPYPTR(icc,lpOutput);
    718             COPYPTR(icc,lpbiInput);
    719             COPYPTR(icc,lpInput);
    720             COPYPTR(icc,lpckid);
    721             COPYPTR(icc,lpdwFlags);
    722             COPY(icc,lFrameNum);
    723             COPY(icc,dwFrameSize);
    724             COPY(icc,dwQuality);
    725             COPYPTR(icc,lpbiPrev);
    726             COPYPTR(icc,lpPrev);
    727 
    728             *lParam1 = (DWORD)(icc);
    729             *lParam2 = sizeof(ICCOMPRESS);
    730         }
    731         break;
    732     case ICM_DECOMPRESS:
    733         {
    734             ICDECOMPRESS *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESS));
    735             ICDECOMPRESS *icd16; /* Same structure except for the pointers */
    736 
    737             icd16 = MapSL(*lParam1);
    738             ret = icd16;
    739 
    740             COPY(icd,dwFlags);
    741             COPYPTR(icd,lpbiInput);
    742             COPYPTR(icd,lpInput);
    743             COPYPTR(icd,lpbiOutput);
    744             COPYPTR(icd,lpOutput);
    745             COPY(icd,ckid);
    746 
    747             *lParam1 = (DWORD)(icd);
    748             *lParam2 = sizeof(ICDECOMPRESS);
    749         }
    750         break;
    751     case ICM_COMPRESS_BEGIN:
    752     case ICM_COMPRESS_GET_FORMAT:
    753     case ICM_COMPRESS_GET_SIZE:
    754     case ICM_COMPRESS_QUERY:
    755     case ICM_DECOMPRESS_GET_FORMAT:
    756     case ICM_DECOMPRESS_QUERY:
    757     case ICM_DECOMPRESS_BEGIN:
    758     case ICM_DECOMPRESS_SET_PALETTE:
    759     case ICM_DECOMPRESS_GET_PALETTE:
    760         *lParam1 = (DWORD)MapSL(*lParam1);
    761         *lParam2 = (DWORD)MapSL(*lParam2);
    762         break;
    763     case ICM_DECOMPRESSEX_QUERY:
    764         if ((*lParam2 != sizeof(ICDECOMPRESSEX16)) && (*lParam2 != 0))
    765             WARN("*lParam2 has unknown value %p\n",(ICDECOMPRESSEX16*)*lParam2);
    766         /* FIXME: *lParm2 is meant to be 0 or an ICDECOMPRESSEX16*, but is sizeof(ICDECOMRPESSEX16)
    767         * This is because of ICMessage(). Special case it?
    768         {
    769         LPVOID* addr = HeapAlloc(GetProcessHeap(),0,2*sizeof(LPVOID));
    770         addr[0] = MSVIDEO_MapICDEX16To32(lParam1);
    771         if (*lParam2)
    772         addr[1] = MSVIDEO_MapICDEX16To32(lParam2);
    773         else
    774         addr[1] = 0;
    775 
    776         ret = addr;
    777         }
    778         break;*/
    779     case ICM_DECOMPRESSEX_BEGIN:
    780     case ICM_DECOMPRESSEX:
    781         ret = MSVIDEO_MapICDEX16To32(lParam1);
    782         *lParam2 = sizeof(ICDECOMPRESSEX);
    783         break;
    784     case ICM_DRAW_BEGIN:
    785         {
    786             ICDRAWBEGIN *icdb = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWBEGIN));
    787             ICDRAWBEGIN16 *icdb16 = MapSL(*lParam1);
    788             ret = icdb16;
    789 
    790             COPY(icdb,dwFlags);
    791             COPY(icdb,hpal);
    792             COPY(icdb,hwnd);
    793             COPY(icdb,hdc);
    794             COPY(icdb,xDst);
    795             COPY(icdb,yDst);
    796             COPY(icdb,dxDst);
    797             COPY(icdb,dyDst);
    798             COPYPTR(icdb,lpbi);
    799             COPY(icdb,xSrc);
    800             COPY(icdb,ySrc);
    801             COPY(icdb,dxSrc);
    802             COPY(icdb,dySrc);
    803             COPY(icdb,dwRate);
    804             COPY(icdb,dwScale);
    805 
    806             *lParam1 = (DWORD)(icdb);
    807             *lParam2 = sizeof(ICDRAWBEGIN);
    808         }
    809         break;
    810     case ICM_DRAW_SUGGESTFORMAT:
    811         {
    812             ICDRAWSUGGEST *icds = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWSUGGEST));
    813             ICDRAWSUGGEST16 *icds16 = MapSL(*lParam1);
    814 
    815             ret = icds16;
    816 
    817             COPY(icds,dwFlags);
    818             COPYPTR(icds,lpbiIn);
    819             COPYPTR(icds,lpbiSuggest);
    820             COPY(icds,dxSrc);
    821             COPY(icds,dySrc);
    822             COPY(icds,dxDst);
    823             COPY(icds,dyDst);
    824             COPY(icds,hicDecompressor);
    825 
    826             *lParam1 = (DWORD)(icds);
    827             *lParam2 = sizeof(ICDRAWSUGGEST);
    828         }
    829         break;
    830     case ICM_DRAW:
    831         {
    832             ICDRAW *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAW));
    833             ICDRAW *icd16 = MapSL(*lParam1);
    834             ret = icd16;
    835 
    836             COPY(icd,dwFlags);
    837             COPYPTR(icd,lpFormat);
    838             COPYPTR(icd,lpData);
    839             COPY(icd,cbData);
    840             COPY(icd,lTime);
    841 
    842             *lParam1 = (DWORD)(icd);
    843             *lParam2 = sizeof(ICDRAW);
    844         }
    845         break;
    846     case ICM_DRAW_START:
    847     case ICM_DRAW_STOP:
    848         break;
    849     default:
    850         FIXME("%d is not yet handled. Expect a crash.\n",msg);
    851     }
    852     return ret;
     702                        *lParam1 = (DWORD)(ici);
     703                        *lParam2 = sizeof(ICINFO);
     704                }
     705                break;
     706        case ICM_COMPRESS:
     707                {
     708                        ICCOMPRESS *icc = HeapAlloc(GetProcessHeap(),0,sizeof(ICCOMPRESS));
     709                        ICCOMPRESS *icc16;
     710
     711                        icc16 = MapSL(*lParam1);
     712                        ret = icc16;
     713
     714                        COPY(icc,dwFlags);
     715                        COPYPTR(icc,lpbiOutput);
     716                        COPYPTR(icc,lpOutput);
     717                        COPYPTR(icc,lpbiInput);
     718                        COPYPTR(icc,lpInput);
     719                        COPYPTR(icc,lpckid);
     720                        COPYPTR(icc,lpdwFlags);
     721                        COPY(icc,lFrameNum);
     722                        COPY(icc,dwFrameSize);
     723                        COPY(icc,dwQuality);
     724                        COPYPTR(icc,lpbiPrev);
     725                        COPYPTR(icc,lpPrev);
     726                       
     727                        *lParam1 = (DWORD)(icc);
     728                        *lParam2 = sizeof(ICCOMPRESS);
     729                }
     730                break;
     731        case ICM_DECOMPRESS:
     732                {
     733                        ICDECOMPRESS *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDECOMPRESS));
     734                        ICDECOMPRESS *icd16; /* Same structure except for the pointers */
     735                       
     736                        icd16 = MapSL(*lParam1);
     737                        ret = icd16;
     738                       
     739                        COPY(icd,dwFlags);
     740                        COPYPTR(icd,lpbiInput);
     741                        COPYPTR(icd,lpInput);
     742                        COPYPTR(icd,lpbiOutput);
     743                        COPYPTR(icd,lpOutput);
     744                        COPY(icd,ckid);
     745                       
     746                        *lParam1 = (DWORD)(icd);
     747                        *lParam2 = sizeof(ICDECOMPRESS);
     748                }
     749                break;
     750        case ICM_COMPRESS_BEGIN:
     751        case ICM_COMPRESS_GET_FORMAT:
     752        case ICM_COMPRESS_GET_SIZE:
     753        case ICM_COMPRESS_QUERY:
     754        case ICM_DECOMPRESS_GET_FORMAT:
     755        case ICM_DECOMPRESS_QUERY:
     756        case ICM_DECOMPRESS_BEGIN:
     757        case ICM_DECOMPRESS_SET_PALETTE:
     758        case ICM_DECOMPRESS_GET_PALETTE:
     759                *lParam1 = (DWORD)MapSL(*lParam1);
     760                *lParam2 = (DWORD)MapSL(*lParam2);
     761                break;
     762        case ICM_DECOMPRESSEX_QUERY:
     763                if ((*lParam2 != sizeof(ICDECOMPRESSEX16)) && (*lParam2 != 0))
     764                        WARN("*lParam2 has unknown value %p\n",(ICDECOMPRESSEX16*)*lParam2);
     765                /* FIXME: *lParm2 is meant to be 0 or an ICDECOMPRESSEX16*, but is sizeof(ICDECOMRPESSEX16)
     766                * This is because of ICMessage(). Special case it?
     767                {
     768                LPVOID* addr = HeapAlloc(GetProcessHeap(),0,2*sizeof(LPVOID));
     769                addr[0] = MSVIDEO_MapICDEX16To32(lParam1);
     770                if (*lParam2)
     771                addr[1] = MSVIDEO_MapICDEX16To32(lParam2);
     772                else
     773                addr[1] = 0;
     774                 
     775                ret = addr;
     776                }
     777                break;*/
     778        case ICM_DECOMPRESSEX_BEGIN:
     779        case ICM_DECOMPRESSEX:
     780                ret = MSVIDEO_MapICDEX16To32(lParam1);
     781                *lParam2 = sizeof(ICDECOMPRESSEX);
     782                break;
     783        case ICM_DRAW_BEGIN:
     784                {
     785                        ICDRAWBEGIN *icdb = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWBEGIN));
     786                        ICDRAWBEGIN16 *icdb16 = MapSL(*lParam1);
     787                        ret = icdb16;
     788
     789                        COPY(icdb,dwFlags);
     790                        COPY(icdb,hpal);
     791                        COPY(icdb,hwnd);
     792                        COPY(icdb,hdc);
     793                        COPY(icdb,xDst);
     794                        COPY(icdb,yDst);
     795                        COPY(icdb,dxDst);
     796                        COPY(icdb,dyDst);
     797                        COPYPTR(icdb,lpbi);
     798                        COPY(icdb,xSrc);
     799                        COPY(icdb,ySrc);
     800                        COPY(icdb,dxSrc);
     801                        COPY(icdb,dySrc);
     802                        COPY(icdb,dwRate);
     803                        COPY(icdb,dwScale);
     804
     805                        *lParam1 = (DWORD)(icdb);
     806                        *lParam2 = sizeof(ICDRAWBEGIN);
     807                }
     808                break;
     809        case ICM_DRAW_SUGGESTFORMAT:
     810                {
     811                        ICDRAWSUGGEST *icds = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAWSUGGEST));
     812                        ICDRAWSUGGEST16 *icds16 = MapSL(*lParam1);
     813                       
     814                        ret = icds16;
     815
     816                        COPY(icds,dwFlags);
     817                        COPYPTR(icds,lpbiIn);
     818                        COPYPTR(icds,lpbiSuggest);
     819                        COPY(icds,dxSrc);
     820                        COPY(icds,dySrc);
     821                        COPY(icds,dxDst);
     822                        COPY(icds,dyDst);
     823                        COPY(icds,hicDecompressor);
     824
     825                        *lParam1 = (DWORD)(icds);
     826                        *lParam2 = sizeof(ICDRAWSUGGEST);
     827                }
     828                break;
     829        case ICM_DRAW:
     830                {
     831                        ICDRAW *icd = HeapAlloc(GetProcessHeap(),0,sizeof(ICDRAW));
     832                        ICDRAW *icd16 = MapSL(*lParam1);
     833                        ret = icd16;
     834
     835                        COPY(icd,dwFlags);
     836                        COPYPTR(icd,lpFormat);
     837                        COPYPTR(icd,lpData);
     838                        COPY(icd,cbData);
     839                        COPY(icd,lTime);
     840
     841                        *lParam1 = (DWORD)(icd);
     842                        *lParam2 = sizeof(ICDRAW);
     843                }
     844                break;
     845        case ICM_DRAW_START:
     846        case ICM_DRAW_STOP:
     847                break;
     848        default:
     849                FIXME("%d is not yet handled. Expect a crash.\n",msg);
     850        }
     851        return ret;
    853852}
    854853
     
    857856
    858857void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID data16, LPDWORD lParam1, LPDWORD lParam2) {
    859     TRACE("Unmapping %d\n",msg);
     858        TRACE("Unmapping %d\n",msg);
    860859
    861860#define UNCOPY(x,y) (x##16->y = x->y);
    862861
    863     switch (msg) {
    864     case ICM_GETINFO:
    865         {
    866             ICINFO *ici = (ICINFO*)(*lParam1);
    867             ICINFO16 *ici16 = (ICINFO16*)data16;
    868 
    869             UNCOPY(ici,fccType);
    870             UNCOPY(ici,fccHandler);
    871             UNCOPY(ici,dwFlags);
    872             UNCOPY(ici,dwVersion);
    873             UNCOPY(ici,dwVersionICM);
     862        switch (msg) {
     863        case ICM_GETINFO:
     864                {
     865                        ICINFO *ici = (ICINFO*)(*lParam1);
     866                        ICINFO16 *ici16 = (ICINFO16*)data16;
     867
     868                        UNCOPY(ici,fccType);
     869                        UNCOPY(ici,fccHandler);
     870                        UNCOPY(ici,dwFlags);
     871                        UNCOPY(ici,dwVersion);
     872                        UNCOPY(ici,dwVersionICM);
    874873                        WideCharToMultiByte( CP_ACP, 0, ici->szName, -1, ici16->szName,
    875874                                             sizeof(ici16->szName), NULL, NULL );
     
    878877                                             sizeof(ici16->szDescription), NULL, NULL );
    879878                        ici16->szDescription[sizeof(ici16->szDescription)-1] = 0;
    880             /* This just gives garbage for some reason - BB
    881                lstrcpynWtoA(ici16->szDriver,ici->szDriver,128);*/
    882 
    883             HeapFree(GetProcessHeap(),0,ici);
    884         }
    885         break;
    886     case ICM_DECOMPRESS_QUERY:
    887         /*{
    888           LPVOID* x = data16;
    889           HeapFree(GetProcessHeap(),0,x[0]);
    890           if (x[1])
    891           HeapFree(GetProcessHeap(),0,x[1]);
    892           }
    893           break;*/
    894     case ICM_COMPRESS:
    895     case ICM_DECOMPRESS:
    896     case ICM_DECOMPRESSEX_QUERY:
    897     case ICM_DECOMPRESSEX_BEGIN:
    898     case ICM_DECOMPRESSEX:
    899     case ICM_DRAW_BEGIN:
    900     case ICM_DRAW_SUGGESTFORMAT:
    901     case ICM_DRAW:
    902         HeapFree(GetProcessHeap(),0,data16);
    903         break;
    904     default:
    905         ERR("Unmapping unmapped msg %d\n",msg);
    906     }
    907 #undef UNCOPY
     879                        /* This just gives garbage for some reason - BB
     880                           lstrcpynWtoA(ici16->szDriver,ici->szDriver,128);*/
     881
     882                        HeapFree(GetProcessHeap(),0,ici);
     883                }
     884                break;
     885        case ICM_DECOMPRESS_QUERY:
     886                /*{
     887                  LPVOID* x = data16;
     888                  HeapFree(GetProcessHeap(),0,x[0]);
     889                  if (x[1])
     890                  HeapFree(GetProcessHeap(),0,x[1]);
     891                  }
     892                  break;*/
     893        case ICM_COMPRESS:
     894        case ICM_DECOMPRESS:
     895        case ICM_DECOMPRESSEX_QUERY:
     896        case ICM_DECOMPRESSEX_BEGIN:
     897        case ICM_DECOMPRESSEX:
     898        case ICM_DRAW_BEGIN:
     899        case ICM_DRAW_SUGGESTFORMAT:
     900        case ICM_DRAW:
     901                HeapFree(GetProcessHeap(),0,data16);
     902                break;
     903        default:
     904                ERR("Unmapping unmapped msg %d\n",msg);
     905        }
     906#undef UNCOPY           
    908907}
    909908#endif
    910909
    911910LRESULT MSVIDEO_SendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2, BOOL bFrom32) {
    912     LRESULT     ret;
    913     WINE_HIC    *whic = GlobalLock16(hic);
    914     LPVOID data16 = 0;
    915     BOOL bDrv32;
     911        LRESULT         ret;
     912        WINE_HIC        *whic = GlobalLock16(hic);
     913        LPVOID data16 = 0;
     914        BOOL bDrv32;
    916915
    917916#define XX(x) case x: TRACE("(0x%08lx,"#x",0x%08lx,0x%08lx,%d)\n",(DWORD)hic,lParam1,lParam2,bFrom32?32:16);break;
    918917
    919     switch (msg) {
    920         /* DRV_* */
    921         XX(DRV_LOAD);
    922         XX(DRV_ENABLE);
    923         XX(DRV_OPEN);
    924         XX(DRV_CLOSE);
    925         XX(DRV_DISABLE);
    926         XX(DRV_FREE);
    927         /* ICM_RESERVED+X */
    928         XX(ICM_ABOUT);
    929         XX(ICM_CONFIGURE);
    930         XX(ICM_GET);
    931         XX(ICM_GETINFO);
    932         XX(ICM_GETDEFAULTQUALITY);
    933         XX(ICM_GETQUALITY);
    934         XX(ICM_GETSTATE);
    935         XX(ICM_SETQUALITY);
    936         XX(ICM_SET);
    937         XX(ICM_SETSTATE);
    938         /* ICM_USER+X */
    939         XX(ICM_COMPRESS_FRAMES_INFO);
    940         XX(ICM_COMPRESS_GET_FORMAT);
    941         XX(ICM_COMPRESS_GET_SIZE);
    942         XX(ICM_COMPRESS_QUERY);
    943         XX(ICM_COMPRESS_BEGIN);
    944         XX(ICM_COMPRESS);
    945         XX(ICM_COMPRESS_END);
    946         XX(ICM_DECOMPRESS_GET_FORMAT);
    947         XX(ICM_DECOMPRESS_QUERY);
    948         XX(ICM_DECOMPRESS_BEGIN);
    949         XX(ICM_DECOMPRESS);
    950         XX(ICM_DECOMPRESS_END);
    951         XX(ICM_DECOMPRESS_SET_PALETTE);
    952         XX(ICM_DECOMPRESS_GET_PALETTE);
    953         XX(ICM_DRAW_QUERY);
    954         XX(ICM_DRAW_BEGIN);
    955         XX(ICM_DRAW_GET_PALETTE);
    956         XX(ICM_DRAW_START);
    957         XX(ICM_DRAW_STOP);
    958         XX(ICM_DRAW_END);
    959         XX(ICM_DRAW_GETTIME);
    960         XX(ICM_DRAW);
    961         XX(ICM_DRAW_WINDOW);
    962         XX(ICM_DRAW_SETTIME);
    963         XX(ICM_DRAW_REALIZE);
    964         XX(ICM_DRAW_FLUSH);
    965         XX(ICM_DRAW_RENDERBUFFER);
    966         XX(ICM_DRAW_START_PLAY);
    967         XX(ICM_DRAW_STOP_PLAY);
    968         XX(ICM_DRAW_SUGGESTFORMAT);
    969         XX(ICM_DRAW_CHANGEPALETTE);
    970         XX(ICM_GETBUFFERSWANTED);
    971         XX(ICM_GETDEFAULTKEYFRAMERATE);
    972         XX(ICM_DECOMPRESSEX_BEGIN);
    973         XX(ICM_DECOMPRESSEX_QUERY);
    974         XX(ICM_DECOMPRESSEX);
    975         XX(ICM_DECOMPRESSEX_END);
    976         XX(ICM_SET_STATUS_PROC);
    977     default:
    978         FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,%i) unknown message\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2,bFrom32?32:16);
    979     }
     918        switch (msg) {
     919                /* DRV_* */
     920                XX(DRV_LOAD);
     921                XX(DRV_ENABLE);
     922                XX(DRV_OPEN);
     923                XX(DRV_CLOSE);
     924                XX(DRV_DISABLE);
     925                XX(DRV_FREE);
     926                /* ICM_RESERVED+X */
     927                XX(ICM_ABOUT);
     928                XX(ICM_CONFIGURE);
     929                XX(ICM_GET);
     930                XX(ICM_GETINFO);
     931                XX(ICM_GETDEFAULTQUALITY);
     932                XX(ICM_GETQUALITY);
     933                XX(ICM_GETSTATE);
     934                XX(ICM_SETQUALITY);
     935                XX(ICM_SET);
     936                XX(ICM_SETSTATE);
     937                /* ICM_USER+X */
     938                XX(ICM_COMPRESS_FRAMES_INFO);
     939                XX(ICM_COMPRESS_GET_FORMAT);
     940                XX(ICM_COMPRESS_GET_SIZE);
     941                XX(ICM_COMPRESS_QUERY);
     942                XX(ICM_COMPRESS_BEGIN);
     943                XX(ICM_COMPRESS);
     944                XX(ICM_COMPRESS_END);
     945                XX(ICM_DECOMPRESS_GET_FORMAT);
     946                XX(ICM_DECOMPRESS_QUERY);
     947                XX(ICM_DECOMPRESS_BEGIN);
     948                XX(ICM_DECOMPRESS);
     949                XX(ICM_DECOMPRESS_END);
     950                XX(ICM_DECOMPRESS_SET_PALETTE);
     951                XX(ICM_DECOMPRESS_GET_PALETTE);
     952                XX(ICM_DRAW_QUERY);
     953                XX(ICM_DRAW_BEGIN);
     954                XX(ICM_DRAW_GET_PALETTE);
     955                XX(ICM_DRAW_START);
     956                XX(ICM_DRAW_STOP);
     957                XX(ICM_DRAW_END);
     958                XX(ICM_DRAW_GETTIME);
     959                XX(ICM_DRAW);
     960                XX(ICM_DRAW_WINDOW);
     961                XX(ICM_DRAW_SETTIME);
     962                XX(ICM_DRAW_REALIZE);
     963                XX(ICM_DRAW_FLUSH);
     964                XX(ICM_DRAW_RENDERBUFFER);
     965                XX(ICM_DRAW_START_PLAY);
     966                XX(ICM_DRAW_STOP_PLAY);
     967                XX(ICM_DRAW_SUGGESTFORMAT);
     968                XX(ICM_DRAW_CHANGEPALETTE);
     969                XX(ICM_GETBUFFERSWANTED);
     970                XX(ICM_GETDEFAULTKEYFRAMERATE);
     971                XX(ICM_DECOMPRESSEX_BEGIN);
     972                XX(ICM_DECOMPRESSEX_QUERY);
     973                XX(ICM_DECOMPRESSEX);
     974                XX(ICM_DECOMPRESSEX_END);
     975                XX(ICM_SET_STATUS_PROC);
     976        default:
     977                FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,%i) unknown message\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2,bFrom32?32:16);
     978        }
    980979
    981980#undef XX
    982981
    983     if (!whic) return ICERR_BADHANDLE;
    984 
    985     if (whic->driverproc) { /* IC is a function */
     982        if (!whic) return ICERR_BADHANDLE;
     983
     984        if (whic->driverproc) { /* IC is a function */
    986985#ifdef __WIN32OS2__
    987             bDrv32 = whic->privatevfw;
     986                bDrv32 = whic->privatevfw;
    988987#else
    989         bDrv32 = whic->private;
    990 #endif
    991     } else {
    992         bDrv32 = ((GetDriverFlags(whic->hdrv) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) == WINE_GDF_EXIST);
    993     }
     988                bDrv32 = whic->private;
     989#endif
     990        } else {
     991                bDrv32 = ((GetDriverFlags(whic->hdrv) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) == WINE_GDF_EXIST);
     992        }
    994993
    995994#ifndef __WIN32OS2__
    996     if (!bFrom32) {
    997         if (bDrv32)
    998             data16 = MSVIDEO_MapMsg16To32(msg,&lParam1,&lParam2);
    999     } else {
    1000         if (!bDrv32) {
    1001             ERR("Can't do 32->16 mappings\n");
    1002             ret = -1;
    1003             goto out;
    1004         }
    1005     }
    1006 #endif
    1007 
    1008     if (whic->driverproc) {
     995        if (!bFrom32) {
     996                if (bDrv32)
     997                        data16 = MSVIDEO_MapMsg16To32(msg,&lParam1,&lParam2);
     998        } else {
     999                if (!bDrv32) {
     1000                        ERR("Can't do 32->16 mappings\n");
     1001                        ret = -1;
     1002                        goto out;
     1003                }
     1004        }
     1005#endif
     1006       
     1007        if (whic->driverproc) {
    10091008#ifdef __WIN32OS2__
    1010             ret = whic->driverproc(whic->hdrv,hic,msg,lParam1,lParam2);
     1009                ret = whic->driverproc(whic->hdrv,hic,msg,lParam1,lParam2);
    10111010#else
    1012         if (bDrv32) {
    1013             ret = whic->driverproc(whic->hdrv,hic,msg,lParam1,lParam2);
    1014         } else {
    1015             ret = MSVIDEO_CallTo16_long_lwwll((FARPROC16)whic->driverproc,whic->hdrv,hic,msg,lParam1,lParam2);
    1016         }
    1017 #endif
    1018     } else {
    1019         ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
    1020     }
     1011                if (bDrv32) {
     1012                        ret = whic->driverproc(whic->hdrv,hic,msg,lParam1,lParam2);
     1013                } else {
     1014                        ret = MSVIDEO_CallTo16_long_lwwll((FARPROC16)whic->driverproc,whic->hdrv,hic,msg,lParam1,lParam2);
     1015                }
     1016#endif
     1017        } else {
     1018                ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
     1019        }
    10211020
    10221021#ifndef __WIN32OS2__
    1023     if (data16)
    1024         MSVIDEO_UnmapMsg16To32(msg,data16,&lParam1,&lParam2);
    1025 #endif
    1026 
     1022        if (data16)
     1023                MSVIDEO_UnmapMsg16To32(msg,data16,&lParam1,&lParam2);
     1024#endif
     1025 
    10271026 out:
    1028     GlobalUnlock16(hic);
    1029 
    1030     TRACE(" -> 0x%08lx\n",ret);
    1031     return ret;
    1032 }
    1033 
    1034 /***********************************************************************
    1035  *      ICSendMessage           [MSVFW32.@]
     1027        GlobalUnlock16(hic);
     1028       
     1029        TRACE(" -> 0x%08lx\n",ret);
     1030        return ret;
     1031}
     1032
     1033/***********************************************************************
     1034 *              ICSendMessage                   [MSVFW32.@]
    10361035 */
    10371036LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD lParam1, DWORD lParam2) {
    1038     return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,TRUE);
     1037        return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,TRUE);
    10391038}
    10401039#ifndef __WIN32OS2__
    10411040/***********************************************************************
    1042  *      ICSendMessage           [MSVIDEO.205]
     1041 *              ICSendMessage                   [MSVIDEO.205]
    10431042 */
    10441043LRESULT VFWAPI ICSendMessage16(HIC16 hic, UINT16 msg, DWORD lParam1, DWORD lParam2) {
    1045     return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,FALSE);
    1046 }
    1047 
    1048 /***********************************************************************
    1049  *      _ICMessage          [MSVIDEO.207]
     1044        return MSVIDEO_SendMessage(hic,msg,lParam1,lParam2,FALSE);
     1045}
     1046
     1047/***********************************************************************
     1048 *              _ICMessage                      [MSVIDEO.207]
    10501049 */
    10511050LRESULT VFWAPIV ICMessage16(void) {
    1052     HIC16 hic;
    1053     UINT16 msg;
    1054     UINT16 cb;
    1055     LPWORD lpData;
    1056     LRESULT ret;
    1057     UINT16 i;
    1058 
    1059     VA_LIST16 valist;
    1060 
    1061     VA_START16(valist);
    1062     hic = VA_ARG16(valist, HIC16);
    1063     msg = VA_ARG16(valist, UINT16);
    1064     cb  = VA_ARG16(valist, UINT16);
    1065 
    1066     lpData = SEGPTR_ALLOC(cb);
    1067 
    1068     TRACE("0x%08lx, %u, %u, ...)\n",(DWORD)hic,msg,cb);
    1069 
    1070     for(i=0;i<cb/sizeof(WORD);i++) {
    1071         lpData[i] = VA_ARG16(valist, WORD);
    1072     }
    1073 
    1074     VA_END16(valist);
    1075     ret = ICSendMessage16(hic, msg, (DWORD)(SEGPTR_GET(lpData)), (DWORD)cb);
    1076 
    1077     SEGPTR_FREE(lpData);
    1078     return ret;
    1079 }
    1080 #endif
    1081 /***********************************************************************
    1082  *      ICDrawBegin     [MSVFW32.@]
     1051        HIC16 hic;
     1052        UINT16 msg;
     1053        UINT16 cb;
     1054        LPWORD lpData;
     1055        LRESULT ret;
     1056        UINT16 i;
     1057
     1058        VA_LIST16 valist;
     1059       
     1060        VA_START16(valist);
     1061        hic = VA_ARG16(valist, HIC16);
     1062        msg = VA_ARG16(valist, UINT16);
     1063        cb  = VA_ARG16(valist, UINT16);
     1064
     1065        lpData = SEGPTR_ALLOC(cb);
     1066
     1067        TRACE("0x%08lx, %u, %u, ...)\n",(DWORD)hic,msg,cb);
     1068
     1069        for(i=0;i<cb/sizeof(WORD);i++) {
     1070                lpData[i] = VA_ARG16(valist, WORD);
     1071        }
     1072               
     1073        VA_END16(valist);
     1074        ret = ICSendMessage16(hic, msg, (DWORD)(SEGPTR_GET(lpData)), (DWORD)cb);
     1075
     1076        SEGPTR_FREE(lpData);
     1077        return ret;
     1078}
     1079#endif
     1080/***********************************************************************
     1081 *              ICDrawBegin             [MSVFW32.@]
    10831082 */
    10841083DWORD VFWAPIV ICDrawBegin(
    1085     HIC                hic,     /* [in] */
    1086     DWORD              dwFlags, /* [in] flags */
    1087     HPALETTE           hpal,    /* [in] palette to draw with */
    1088     HWND               hwnd,    /* [in] window to draw to */
    1089     HDC                hdc,     /* [in] HDC to draw to */
    1090     INT                xDst,    /* [in] destination rectangle */
    1091     INT                yDst,    /* [in] */
    1092     INT                dxDst,   /* [in] */
    1093     INT                dyDst,   /* [in] */
    1094     LPBITMAPINFOHEADER lpbi,    /* [in] format of frame to draw */
    1095     INT                xSrc,    /* [in] source rectangle */
    1096     INT                ySrc,    /* [in] */
    1097     INT                dxSrc,   /* [in] */
    1098     INT                dySrc,   /* [in] */
    1099     DWORD              dwRate,  /* [in] frames/second = (dwRate/dwScale) */
    1100     DWORD              dwScale) /* [in] */
     1084        HIC                hic,     /* [in] */
     1085        DWORD              dwFlags, /* [in] flags */
     1086        HPALETTE           hpal,    /* [in] palette to draw with */
     1087        HWND               hwnd,    /* [in] window to draw to */
     1088        HDC                hdc,     /* [in] HDC to draw to */
     1089        INT                xDst,    /* [in] destination rectangle */
     1090        INT                yDst,    /* [in] */
     1091        INT                dxDst,   /* [in] */
     1092        INT                dyDst,   /* [in] */
     1093        LPBITMAPINFOHEADER lpbi,    /* [in] format of frame to draw */
     1094        INT                xSrc,    /* [in] source rectangle */
     1095        INT                ySrc,    /* [in] */
     1096        INT                dxSrc,   /* [in] */
     1097        INT                dySrc,   /* [in] */
     1098        DWORD              dwRate,  /* [in] frames/second = (dwRate/dwScale) */
     1099        DWORD              dwScale) /* [in] */
    11011100{
    1102 
    1103     ICDRAWBEGIN icdb;
    1104 
    1105     TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
    1106           (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
    1107           lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
    1108 
    1109     icdb.dwFlags = dwFlags;
    1110     icdb.hpal = hpal;
    1111     icdb.hwnd = hwnd;
    1112     icdb.hdc = hdc;
    1113     icdb.xDst = xDst;
    1114     icdb.yDst = yDst;
    1115     icdb.dxDst = dxDst;
    1116     icdb.dyDst = dyDst;
    1117     icdb.lpbi = lpbi;
    1118     icdb.xSrc = xSrc;
    1119     icdb.ySrc = ySrc;
    1120     icdb.dxSrc = dxSrc;
    1121     icdb.dySrc = dySrc;
    1122     icdb.dwRate = dwRate;
    1123     icdb.dwScale = dwScale;
    1124     return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD)&icdb,sizeof(icdb));
     1101       
     1102        ICDRAWBEGIN     icdb;
     1103
     1104        TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
     1105                  (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
     1106                  lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
     1107
     1108        icdb.dwFlags = dwFlags;
     1109        icdb.hpal = hpal;
     1110        icdb.hwnd = hwnd;
     1111        icdb.hdc = hdc;
     1112        icdb.xDst = xDst;
     1113        icdb.yDst = yDst;
     1114        icdb.dxDst = dxDst;
     1115        icdb.dyDst = dyDst;
     1116        icdb.lpbi = lpbi;
     1117        icdb.xSrc = xSrc;
     1118        icdb.ySrc = ySrc;
     1119        icdb.dxSrc = dxSrc;
     1120        icdb.dySrc = dySrc;
     1121        icdb.dwRate = dwRate;
     1122        icdb.dwScale = dwScale;
     1123        return ICSendMessage(hic,ICM_DRAW_BEGIN,(DWORD)&icdb,sizeof(icdb));
    11251124}
    11261125
    11271126#ifndef __WIN32OS2__
    11281127/***********************************************************************
    1129  *      _ICDrawBegin        [MSVIDEO.232]
     1128 *              _ICDrawBegin            [MSVIDEO.232]
    11301129 */
    11311130DWORD VFWAPIV ICDrawBegin16(
    1132     HIC16               hic,     /* [in] */
    1133     DWORD               dwFlags, /* [in] flags */
    1134     HPALETTE16          hpal,    /* [in] palette to draw with */
    1135     HWND16              hwnd,    /* [in] window to draw to */
    1136     HDC16               hdc,     /* [in] HDC to draw to */
    1137     INT16               xDst,    /* [in] destination rectangle */
    1138     INT16               yDst,    /* [in] */
    1139     INT16               dxDst,   /* [in] */
    1140     INT16               dyDst,   /* [in] */
    1141     LPBITMAPINFOHEADER  lpbi,    /* [in] format of frame to draw NOTE: SEGPTR */
    1142     INT16           xSrc,    /* [in] source rectangle */
    1143     INT16           ySrc,    /* [in] */
    1144     INT16           dxSrc,   /* [in] */
    1145     INT16           dySrc,   /* [in] */
    1146     DWORD           dwRate,  /* [in] frames/second = (dwRate/dwScale) */
    1147     DWORD           dwScale) /* [in] */
     1131        HIC16               hic,     /* [in] */
     1132        DWORD               dwFlags, /* [in] flags */
     1133        HPALETTE16          hpal,    /* [in] palette to draw with */
     1134        HWND16              hwnd,    /* [in] window to draw to */
     1135        HDC16               hdc,     /* [in] HDC to draw to */
     1136        INT16               xDst,    /* [in] destination rectangle */
     1137        INT16               yDst,    /* [in] */
     1138        INT16               dxDst,   /* [in] */
     1139        INT16               dyDst,   /* [in] */
     1140        LPBITMAPINFOHEADER  lpbi,    /* [in] format of frame to draw NOTE: SEGPTR */
     1141        INT16               xSrc,    /* [in] source rectangle */
     1142        INT16               ySrc,    /* [in] */
     1143        INT16               dxSrc,   /* [in] */
     1144        INT16               dySrc,   /* [in] */
     1145        DWORD               dwRate,  /* [in] frames/second = (dwRate/dwScale) */
     1146        DWORD               dwScale) /* [in] */
    11481147{
    1149     DWORD ret;
    1150     ICDRAWBEGIN16* icdb = SEGPTR_NEW(ICDRAWBEGIN16); /* SEGPTR for mapper to deal with */
    1151 
    1152     TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
    1153           (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
    1154           lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
    1155 
    1156     icdb->dwFlags = dwFlags;
    1157     icdb->hpal = hpal;
    1158     icdb->hwnd = hwnd;
    1159     icdb->hdc = hdc;
    1160     icdb->xDst = xDst;
    1161     icdb->yDst = yDst;
    1162     icdb->dxDst = dxDst;
    1163     icdb->dyDst = dyDst;
    1164     icdb->lpbi = lpbi; /* Keep this as SEGPTR for the mapping code to deal with */
    1165     icdb->xSrc = xSrc;
    1166     icdb->ySrc = ySrc;
    1167     icdb->dxSrc = dxSrc;
    1168     icdb->dySrc = dySrc;
    1169     icdb->dwRate = dwRate;
    1170     icdb->dwScale = dwScale;
    1171 
    1172     ret = (DWORD)ICSendMessage16(hic,ICM_DRAW_BEGIN,(DWORD)SEGPTR_GET(icdb),sizeof(ICDRAWBEGIN16));
    1173     SEGPTR_FREE(icdb);
    1174     return ret;
    1175 }
    1176 #endif
    1177 
    1178 /***********************************************************************
    1179  *      ICDraw          [MSVFW32.@]
     1148        DWORD ret;
     1149        ICDRAWBEGIN16* icdb = SEGPTR_NEW(ICDRAWBEGIN16); /* SEGPTR for mapper to deal with */
     1150
     1151        TRACE("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
     1152                  (DWORD)hic, dwFlags, (DWORD)hpal, (DWORD)hwnd, (DWORD)hdc, xDst, yDst, dxDst, dyDst,
     1153                  lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate, dwScale);
     1154
     1155        icdb->dwFlags = dwFlags;
     1156        icdb->hpal = hpal;
     1157        icdb->hwnd = hwnd;
     1158        icdb->hdc = hdc;
     1159        icdb->xDst = xDst;
     1160        icdb->yDst = yDst;
     1161        icdb->dxDst = dxDst;
     1162        icdb->dyDst = dyDst;
     1163        icdb->lpbi = lpbi; /* Keep this as SEGPTR for the mapping code to deal with */
     1164        icdb->xSrc = xSrc;
     1165        icdb->ySrc = ySrc;
     1166        icdb->dxSrc = dxSrc;
     1167        icdb->dySrc = dySrc;
     1168        icdb->dwRate = dwRate;
     1169        icdb->dwScale = dwScale;
     1170       
     1171        ret = (DWORD)ICSendMessage16(hic,ICM_DRAW_BEGIN,(DWORD)SEGPTR_GET(icdb),sizeof(ICDRAWBEGIN16));
     1172        SEGPTR_FREE(icdb);
     1173        return ret;
     1174}
     1175#endif
     1176
     1177/***********************************************************************
     1178 *              ICDraw                  [MSVFW32.@]
    11801179 */
    11811180DWORD VFWAPIV ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime) {
    1182     ICDRAW  icd;
    1183 
    1184     TRACE("(0x%09lx,%ld,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
    1185 
    1186     icd.dwFlags = dwFlags;
    1187     icd.lpFormat = lpFormat;
    1188     icd.lpData = lpData;
    1189     icd.cbData = cbData;
    1190     icd.lTime = lTime;
    1191 
    1192     return ICSendMessage(hic,ICM_DRAW,(DWORD)&icd,sizeof(icd));
     1181        ICDRAW  icd;
     1182
     1183        TRACE("(0x%09lx,%ld,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
     1184
     1185        icd.dwFlags = dwFlags;
     1186        icd.lpFormat = lpFormat;
     1187        icd.lpData = lpData;
     1188        icd.cbData = cbData;
     1189        icd.lTime = lTime;
     1190
     1191        return ICSendMessage(hic,ICM_DRAW,(DWORD)&icd,sizeof(icd));
    11931192}
    11941193
    11951194#ifndef __WIN32OS2__
    11961195/***********************************************************************
    1197  *      _ICDraw         [MSVIDEO.234]
     1196 *              _ICDraw                 [MSVIDEO.234]
    11981197 */
    11991198DWORD VFWAPIV ICDraw16(
    1200     HIC16 hic,
    1201     DWORD dwFlags,
    1202     LPVOID lpFormat, /* [???] NOTE: SEGPTR */
    1203     LPVOID lpData,   /* [???] NOTE: SEGPTR */
    1204     DWORD cbData,
    1205     LONG lTime)
     1199        HIC16 hic,
     1200        DWORD dwFlags,
     1201        LPVOID lpFormat, /* [???] NOTE: SEGPTR */
     1202        LPVOID lpData,   /* [???] NOTE: SEGPTR */
     1203        DWORD cbData,
     1204        LONG lTime)
    12061205{
    1207     ICDRAW* icd = SEGPTR_NEW(ICDRAW); /* SEGPTR for mapper to deal with */
    1208 
    1209     TRACE("(0x%08lx,0x%08lx,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
    1210     icd->dwFlags = dwFlags;
    1211     icd->lpFormat = lpFormat;
    1212     icd->lpData = lpData;
    1213     icd->cbData = cbData;
    1214     icd->lTime = lTime;
    1215 
    1216     return ICSendMessage16(hic,ICM_DRAW,(DWORD)SEGPTR_GET(icd),sizeof(ICDRAW));
    1217 }
    1218 #endif
    1219 
    1220 /***********************************************************************
    1221  *      ICClose         [MSVFW32.@]
     1206        ICDRAW* icd = SEGPTR_NEW(ICDRAW); /* SEGPTR for mapper to deal with */
     1207
     1208        TRACE("(0x%08lx,0x%08lx,%p,%p,%ld,%ld)\n",(DWORD)hic,dwFlags,lpFormat,lpData,cbData,lTime);
     1209        icd->dwFlags = dwFlags;
     1210        icd->lpFormat = lpFormat;
     1211        icd->lpData = lpData;
     1212        icd->cbData = cbData;
     1213        icd->lTime = lTime;
     1214
     1215        return ICSendMessage16(hic,ICM_DRAW,(DWORD)SEGPTR_GET(icd),sizeof(ICDRAW));
     1216}
     1217#endif
     1218
     1219/***********************************************************************
     1220 *              ICClose                 [MSVFW32.@]
    12221221 */
    12231222LRESULT WINAPI ICClose(HIC hic) {
    1224     WINE_HIC *whic = GlobalLock16(hic);
    1225     TRACE("(0x%08lx)\n",(DWORD)hic);
    1226     if (whic->driverproc) {
    1227         ICSendMessage(hic,DRV_CLOSE,0,0);
    1228         ICSendMessage(hic,DRV_DISABLE,0,0);
    1229         ICSendMessage(hic,DRV_FREE,0,0);
    1230     } else {
    1231         CloseDriver(whic->hdrv,0,0);
    1232     }
    1233 
    1234     GlobalUnlock16(hic);
    1235     GlobalFree16(hic);
    1236     return 0;
     1223        WINE_HIC *whic = GlobalLock16(hic);
     1224        TRACE("(0x%08lx)\n",(DWORD)hic);
     1225        if (whic->driverproc) {
     1226                ICSendMessage(hic,DRV_CLOSE,0,0);
     1227                ICSendMessage(hic,DRV_DISABLE,0,0);
     1228                ICSendMessage(hic,DRV_FREE,0,0);
     1229        } else {
     1230                CloseDriver(whic->hdrv,0,0);
     1231        }
     1232
     1233        GlobalUnlock16(hic);
     1234        GlobalFree16(hic);
     1235        return 0;
    12371236}
    12381237
    12391238#ifndef __WIN32OS2__
    12401239/***********************************************************************
    1241  *      ICClose         [MSVIDEO.204]
     1240 *              ICClose                 [MSVIDEO.204]
    12421241 */
    12431242LRESULT WINAPI ICClose16(HIC16 hic) {
    1244     return ICClose(hic);
    1245 }
    1246 #endif
    1247 
    1248 /***********************************************************************
    1249  *      MCIWndCreate        [MSVFW32.@]
    1250  *      MCIWndCreateA       [MSVFW32.@]
     1243        return ICClose(hic);
     1244}
     1245#endif
     1246
     1247/***********************************************************************
     1248 *              MCIWndCreate            [MSVFW32.@]
     1249 *              MCIWndCreateA           [MSVFW32.@]
    12511250 */
    12521251HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance,
    12531252                      DWORD dwStyle,LPCSTR szFile)
    12541253{
    1255     FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, szFile);
    1256     return 0;
    1257 }
    1258 
    1259 /***********************************************************************
    1260  *      MCIWndCreateW       [MSVFW32.@]
     1254        FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, szFile);
     1255        return 0;
     1256}
     1257
     1258/***********************************************************************
     1259 *              MCIWndCreateW           [MSVFW32.@]
    12611260 */
    12621261HWND VFWAPIV MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance,
    12631262                      DWORD dwStyle,LPCWSTR szFile)
    12641263{
    1265     FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, debugstr_w(szFile));
    1266     return 0;
    1267 }
     1264        FIXME("%x %x %lx %s\n",hwndParent, hInstance, dwStyle, debugstr_w(szFile));
     1265        return 0;
     1266}
  • trunk/src/setupapi/devinst.c

    r6649 r6712  
    1 /* $Id: devinst.c,v 1.2 2001-09-05 13:38:23 bird Exp $ */
    21/*
    32 * SetupAPI device installer
     
    1312
    1413/***********************************************************************
    15  *      DiGetClassDevs (SETUPX.304)
     14 *              DiGetClassDevs (SETUPX.304)
    1615 * Return a list of installed system devices.
    1716 * Uses HKLM\\ENUM to list devices.
  • trunk/src/setupapi/infparse.c

    r6649 r6712  
    1 /* $Id: infparse.c,v 1.2 2001-09-05 13:38:23 bird Exp $ */
    21/*
    32 * SetupX .inf file parsing functions
     
    3029
    3130    if (!lphInf)
    32     return IP_ERROR;
     31        return IP_ERROR;
    3332
    3433    /* this could be improved by checking for already freed handles */
    35     if (IP_curr_handle == 0xffff)
    36     return ERR_IP_OUT_OF_HANDLES;
     34    if (IP_curr_handle == 0xffff) 
     35        return ERR_IP_OUT_OF_HANDLES;
    3736
    3837    if (hFile != HFILE_ERROR)
    3938    {
    40     InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
    41     InfList[InfNumEntries].hInf = IP_curr_handle++;
    42     InfList[InfNumEntries].hInfFile = hFile;
    43     InfList[InfNumEntries].lpInfFileName = HeapAlloc( GetProcessHeap(), 0,
     39        InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
     40        InfList[InfNumEntries].hInf = IP_curr_handle++;
     41        InfList[InfNumEntries].hInfFile = hFile;
     42        InfList[InfNumEntries].lpInfFileName = HeapAlloc( GetProcessHeap(), 0,
    4443                                                          strlen(lpInfFileName)+1);
    4544        strcpy( InfList[InfNumEntries].lpInfFileName, lpInfFileName );
    4645        *lphInf = InfList[InfNumEntries].hInf;
    47     InfNumEntries++;
    48     TRACE("ret handle %d.\n", *lphInf);
    49     return OK;
     46        InfNumEntries++;
     47        TRACE("ret handle %d.\n", *lphInf);
     48        return OK;
    5049    }
    5150    *lphInf = 0xffff;
     
    5857
    5958    for (n=0; n < InfNumEntries; n++)
    60     if (InfList[n].hInf == hInf)
    61     {
    62         *ret = n;
    63         return TRUE;
    64     }
     59        if (InfList[n].hInf == hInf)
     60        {
     61            *ret = n;
     62            return TRUE;
     63        }
    6564    return FALSE;
    6665}
    67 
     66       
    6867
    6968LPCSTR IP_GetFileName(HINF16 hInf)
     
    7271    if (IP_FindInf(hInf, &n))
    7372    {
    74     return InfList[n].lpInfFileName;
     73        return InfList[n].lpInfFileName;
    7574    }
    7675    return NULL;
     
    8584    if (IP_FindInf(hInf, &n))
    8685    {
    87     _lclose(InfList[n].hInfFile);
    88     HeapFree(GetProcessHeap(), 0, InfList[n].lpInfFileName);
    89     for (i=n; i < InfNumEntries-1; i++)
    90         InfList[i] = InfList[i+1];
    91     InfNumEntries--;
    92     InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries);
    93     res = OK;
     86        _lclose(InfList[n].hInfFile);
     87        HeapFree(GetProcessHeap(), 0, InfList[n].lpInfFileName);
     88        for (i=n; i < InfNumEntries-1; i++)
     89            InfList[i] = InfList[i+1];
     90        InfNumEntries--;
     91        InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries);
     92        res = OK;
    9493    }
    9594    return res;
     
    9796
    9897/***********************************************************************
    99  *      IpOpen16
     98 *              IpOpen16
    10099 *
    101100 */
     
    107106
    108107/***********************************************************************
    109  *      IpClose16
     108 *              IpClose16
    110109 */
    111110RETERR16 WINAPI IpClose16(HINF16 hInf)
     
    115114
    116115/***********************************************************************
    117  *      IpGetProfileString16
     116 *              IpGetProfileString16
    118117 */
    119 RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen)
     118RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen) 
    120119{
    121120    TRACE("'%s': section '%s' entry '%s'\n", IP_GetFileName(hInf), section, entry);
  • trunk/src/setupapi/setupx_main.c

    r6649 r6712  
    1 /* $Id: setupx_main.c,v 1.2 2001-09-05 13:38:23 bird Exp $ */
    21/*
    32 *      SETUPX library
     
    2726 *
    2827 * SETUPX consists of several parts with the following acronyms/prefixes:
    29  * Di   device installer (devinst.c ?)
    30  * Gen  generic installer (geninst.c ?)
    31  * Ip   .INF parsing (infparse.c)
    32  * LDD  logical device descriptor (ldd.c ?)
    33  * LDID logical device ID
     28 * Di   device installer (devinst.c ?)
     29 * Gen  generic installer (geninst.c ?)
     30 * Ip   .INF parsing (infparse.c)
     31 * LDD  logical device descriptor (ldd.c ?)
     32 * LDID logical device ID
    3433 * SU   setup (setup.c ?)
    35  * Tp   text processing (textproc.c ?)
    36  * Vcp  virtual copy module (vcp.c ?)
     34 * Tp   text processing (textproc.c ?)
     35 * Vcp  virtual copy module (vcp.c ?)
    3736 * ...
    3837 *
     
    5655
    5756/***********************************************************************
    58  *      SURegOpenKey
     57 *              SURegOpenKey
    5958 */
    6059DWORD WINAPI SURegOpenKey( HKEY hkey, LPCSTR lpszSubKey, LPHKEY retkey )
     
    6564
    6665/***********************************************************************
    67  *      SURegQueryValueEx
     66 *              SURegQueryValueEx
    6867 */
    6968DWORD WINAPI SURegQueryValueEx( HKEY hkey, LPSTR lpszValueName,
     
    9594    while (1)
    9695    {
    97     /* find beginning of real substring */
    98     while ( (*p == ' ') || (*p == '\t') || (*p == '"') ) p++;
    99 
    100     /* find end of real substring */
    101     q = p;
    102     while ( (*q)
    103          && (*q != ' ') && (*q != '\t') && (*q != '"')
    104          && (*q != ';') && (*q != delimiter) ) q++;
    105     if (q == p)
    106         break;
    107     len = (int)q - (int)p;
    108 
    109     /* alloc entry for new substring in steps of 32 units and copy over */
    110     if (count % 32 == 0)
    111     { /* 1 for count field + current count + 32 */
    112         res = HeapReAlloc(GetProcessHeap(), 0, res, (1+count+32)*sizeof(LPSTR));
    113     }
    114     *(res+1+count) = HeapAlloc(GetProcessHeap(), 0, len+1);
    115     strncpy(*(res+1+count), p, len);
    116     (*(res+1+count))[len] = '\0';
    117     count++;
    118 
    119     /* we are still within last substring (before delimiter),
    120     * so get out of it */
    121     while ((*q) && (*q != ';') && (*q != delimiter)) q++;
    122     if ((!*q) || (*q == ';'))
    123         break;
    124     p = q+1;
    125     }
    126 
     96        /* find beginning of real substring */
     97        while ( (*p == ' ') || (*p == '\t') || (*p == '"') ) p++;
     98
     99        /* find end of real substring */
     100        q = p;
     101        while ( (*q)
     102             && (*q != ' ') && (*q != '\t') && (*q != '"')
     103             && (*q != ';') && (*q != delimiter) ) q++;
     104        if (q == p)
     105            break;
     106        len = (int)q - (int)p;
     107
     108        /* alloc entry for new substring in steps of 32 units and copy over */
     109        if (count % 32 == 0)
     110        { /* 1 for count field + current count + 32 */
     111            res = HeapReAlloc(GetProcessHeap(), 0, res, (1+count+32)*sizeof(LPSTR));
     112        }
     113        *(res+1+count) = HeapAlloc(GetProcessHeap(), 0, len+1);
     114        strncpy(*(res+1+count), p, len);
     115        (*(res+1+count))[len] = '\0';
     116        count++;
     117
     118        /* we are still within last substring (before delimiter),
     119        * so get out of it */
     120        while ((*q) && (*q != ';') && (*q != delimiter)) q++;
     121        if ((!*q) || (*q == ';'))
     122            break;
     123        p = q+1;
     124    }
     125   
    127126    /* put number of entries at beginning of list */
    128127    *(DWORD *)res = count;
     
    137136
    138137    for (n=0; n < count; n++)
    139     HeapFree(GetProcessHeap(), 0, *pStrings++);
     138        HeapFree(GetProcessHeap(), 0, *pStrings++);
    140139
    141140    HeapFree(GetProcessHeap(), 0, substr);
     
    164163 *        Hmm, but on the other hand SETUPX_GetSubStrings() will probably
    165164 *        soon be replaced by InitSubstrData() etc. anyway.
    166  *
     165 * 
    167166 */
    168167static BOOL SETUPX_LookupRegistryString(LPSTR regstr, LPSTR buffer, DWORD buflen)
     
    182181    for (n=0; n < 5; n++)
    183182    {
    184     q = strchr(p, ',');
    185     if (!q)
    186     {
    187         if (n == 4)
    188         q = p+strlen(p);
    189         else
    190         return FALSE;
    191     }
    192     next = q+1;
    193     if (q < regstr)
     183        q = strchr(p, ',');
     184        if (!q)
     185        {
     186            if (n == 4)
     187                q = p+strlen(p);
     188            else
     189                return FALSE;
     190        }
     191        next = q+1;
     192        if (q < regstr)
    194193            return FALSE;
    195194        SETUPX_IsolateSubString(&p, &q);
     
    198197        strncpy(items[n], p, len);
    199198        items[n][len] = '\0';
    200     p = next;
     199        p = next;
    201200    }
    202201    TRACE("got '%s','%s','%s','%s','%s'\n",
    203             items[0], items[1], items[2], items[3], items[4]);
    204 
     202                        items[0], items[1], items[2], items[3], items[4]);
     203   
    205204    /* check root key */
    206205    if (!strcasecmp(items[0], "HKCR"))
    207     hkey = HKEY_CLASSES_ROOT;
     206        hkey = HKEY_CLASSES_ROOT;
    208207    else
    209208    if (!strcasecmp(items[0], "HKCU"))
    210     hkey = HKEY_CURRENT_USER;
     209        hkey = HKEY_CURRENT_USER;
    211210    else
    212211    if (!strcasecmp(items[0], "HKLM"))
    213     hkey = HKEY_LOCAL_MACHINE;
     212        hkey = HKEY_LOCAL_MACHINE;
    214213    else
    215214    if (!strcasecmp(items[0], "HKU"))
    216     hkey = HKEY_USERS;
     215        hkey = HKEY_USERS;
    217216    else
    218217    { /* HKR ? -> relative to key passed to GenInstallEx */
    219     FIXME("unsupported regkey '%s'\n", items[0]);
     218        FIXME("unsupported regkey '%s'\n", items[0]);
    220219        goto regfailed;
    221220    }
     
    225224
    226225    if (RegQueryValueExA(hsubkey, items[2], NULL, &dwType, buffer, &buflen)
    227         != ERROR_SUCCESS)
     226                != ERROR_SUCCESS)
    228227        goto regfailed;
    229228    goto done;
     
    235234        HeapFree(heap, 0, items[n]);
    236235    if (buffer)
    237     TRACE("return '%s'\n", buffer);
     236        TRACE("return '%s'\n", buffer);
    238237    return TRUE;
    239238}
     
    245244
    246245    do {
    247     buf = HeapReAlloc(GetProcessHeap(), 0, buf, len);
    248     res = GetPrivateProfileStringA(NULL, NULL, NULL, buf, len, filename);
    249     len *= 2;
     246        buf = HeapReAlloc(GetProcessHeap(), 0, buf, len);
     247        res = GetPrivateProfileStringA(NULL, NULL, NULL, buf, len, filename);
     248        len *= 2;
    250249    } while ((!res) && (len < 1048576));
    251250    if (!res)
    252251    {
    253     HeapFree(GetProcessHeap(), 0, buf);
    254     return NULL;
     252        HeapFree(GetProcessHeap(), 0, buf);
     253        return NULL;
    255254    }
    256255    return buf;
     
    263262
    264263    do {
    265     buf = HeapReAlloc(GetProcessHeap(), 0, buf, len);
    266     res = GetPrivateProfileSectionA(section, buf, len, filename);
    267     len *= 2;
     264        buf = HeapReAlloc(GetProcessHeap(), 0, buf, len);
     265        res = GetPrivateProfileSectionA(section, buf, len, filename);
     266        len *= 2;
    268267    } while ((!res) && (len < 1048576));
    269268    if (!res)
    270269    {
    271     HeapFree(GetProcessHeap(), 0, buf);
    272     return NULL;
     270        HeapFree(GetProcessHeap(), 0, buf);
     271        return NULL;
    273272    }
    274273    return buf;
     
    277276
    278277/***********************************************************************
    279  *      InstallHinfSection
     278 *              InstallHinfSection
    280279 *
    281280 * hwnd = parent window
     
    284283 * Here "DefaultInstall" is the .inf file section to be installed (optional).
    285284 * The 132 value is made of the HOW_xxx flags and sometimes 128 (-> setupx16.h).
    286  *
     285 * 
    287286 * nCmdShow = nCmdShow of CreateProcess
    288287 */
     
    298297    HMODULE hMod;
    299298    MSGBOX_PROC pMessageBoxA;
    300 
     299   
    301300    TRACE("(%04x, %04x, %s, %d);\n", hwnd, hinst, lpszCmdLine, nCmdShow);
    302 
     301   
    303302    pSub = SETUPX_GetSubStrings((LPSTR)lpszCmdLine, ' ');
    304303
    305304    count = *(DWORD *)pSub;
    306305    if (count < 2) /* invalid number of arguments ? */
    307     goto end;
     306        goto end;
    308307    if (IpOpen16(*(pSub+count), &hInf) != OK)
    309308    {
    310     res = ERROR_FILE_NOT_FOUND; /* yes, correct */
    311     goto end;
     309        res = ERROR_FILE_NOT_FOUND; /* yes, correct */
     310        goto end;
    312311    }
    313312    if (GenInstall16(hInf, *(pSub+count-2), GENINSTALL_DO_ALL) != OK)
    314     goto end;
     313        goto end;
    315314    wFlags = atoi(*(pSub+count-1)) & ~128;
    316315    switch (wFlags)
    317316    {
    318     case HOW_ALWAYS_SILENT_REBOOT:
    319     case HOW_SILENT_REBOOT:
    320         reboot = TRUE;
    321         break;
    322     case HOW_ALWAYS_PROMPT_REBOOT:
    323     case HOW_PROMPT_REBOOT:
    324         if ((hMod = GetModuleHandleA("user32.dll")))
    325         {
    326           if ((pMessageBoxA = (MSGBOX_PROC)GetProcAddress( hMod, "MessageBoxA" )))
    327           {
    328 
    329             if (pMessageBoxA(hwnd, "You must restart Wine before the new settings will take effect.\n\nDo you want to exit Wine now ?", "Systems Settings Change", MB_YESNO|MB_ICONQUESTION) == IDYES)
    330           reboot = TRUE;
    331           }
    332         }
    333         break;
    334     default:
    335         ERR("invalid flags %d !\n", wFlags);
    336         goto end;
    337     }
    338 
     317        case HOW_ALWAYS_SILENT_REBOOT:
     318        case HOW_SILENT_REBOOT:
     319            reboot = TRUE;
     320            break;
     321        case HOW_ALWAYS_PROMPT_REBOOT:
     322        case HOW_PROMPT_REBOOT:
     323            if ((hMod = GetModuleHandleA("user32.dll")))
     324            {
     325              if ((pMessageBoxA = (MSGBOX_PROC)GetProcAddress( hMod, "MessageBoxA" )))
     326              {
     327                 
     328                if (pMessageBoxA(hwnd, "You must restart Wine before the new settings will take effect.\n\nDo you want to exit Wine now ?", "Systems Settings Change", MB_YESNO|MB_ICONQUESTION) == IDYES)
     329                  reboot = TRUE;
     330              }
     331            }
     332            break;
     333        default:
     334            ERR("invalid flags %d !\n", wFlags);
     335            goto end;
     336    }
     337   
    339338    res = OK;
    340339end:
     
    343342    if (reboot)
    344343    {
    345     /* FIXME: we should have a means of terminating all wine + wineserver */
    346     MESSAGE("Program or user told me to restart. Exiting Wine...\n");
    347     ExitProcess(1);
     344        /* FIXME: we should have a means of terminating all wine + wineserver */
     345        MESSAGE("Program or user told me to restart. Exiting Wine...\n");
     346        ExitProcess(1);
    348347    }
    349348
     
    360359{
    361360    { /* 0 (LDID_NULL) -- not defined */
    362     NULL,
    363     NULL
     361        NULL,
     362        NULL
    364363    },
    365364    { /* 1 (LDID_SRCPATH) = source of installation. hmm, what to do here ? */
    366     "SourcePath", /* hmm, does SETUPX have to care about updating it ?? */
    367     NULL
     365        "SourcePath", /* hmm, does SETUPX have to care about updating it ?? */
     366        NULL
    368367    },
    369368    { /* 2 (LDID_SETUPTEMP) = setup temp dir */
    370     "SetupTempDir",
    371     NULL
     369        "SetupTempDir",
     370        NULL
    372371    },
    373372    { /* 3 (LDID_UNINSTALL) = uninstall backup dir */
    374     "UninstallDir",
    375     NULL
     373        "UninstallDir",
     374        NULL
    376375    },
    377376    { /* 4 (LDID_BACKUP) = backup dir */
    378     "BackupDir",
    379     NULL
     377        "BackupDir",
     378        NULL
    380379    },
    381380    { /* 5 (LDID_SETUPSCRATCH) = setup scratch dir */
    382     "SetupScratchDir",
    383     NULL
     381        "SetupScratchDir",
     382        NULL
    384383    },
    385384    { /* 6 -- not defined */
    386     NULL,
    387     NULL
     385        NULL,
     386        NULL
    388387    },
    389388    { /* 7 -- not defined */
    390     NULL,
    391     NULL
     389        NULL,
     390        NULL
    392391    },
    393392    { /* 8 -- not defined */
    394     NULL,
    395     NULL
     393        NULL,
     394        NULL
    396395    },
    397396    { /* 9 -- not defined */
    398     NULL,
    399     NULL
     397        NULL,
     398        NULL
    400399    },
    401400    { /* 10 (LDID_WIN) = windows dir */
    402     "WinDir",
     401        "WinDir",
    403402        ""
    404403    },
    405404    { /* 11 (LDID_SYS) = system dir */
    406     "SysDir",
    407     NULL /* call GetSystemDirectory() instead */
     405        "SysDir",
     406        NULL /* call GetSystemDirectory() instead */
    408407    },
    409408    { /* 12 (LDID_IOS) = IOSubSys dir */
    410409        NULL, /* FIXME: registry string ? */
    411     "SYSTEM\\IOSUBSYS"
     410        "SYSTEM\\IOSUBSYS"
    412411    },
    413412    { /* 13 (LDID_CMD) = COMMAND dir */
    414     NULL, /* FIXME: registry string ? */
    415     "COMMAND"
     413        NULL, /* FIXME: registry string ? */
     414        "COMMAND"
    416415    },
    417416    { /* 14 (LDID_CPL) = control panel dir */
    418     NULL,
    419     ""
     417        NULL,
     418        ""
    420419    },
    421420    { /* 15 (LDID_PRINT) = windows printer dir */
    422     NULL,
    423     "SYSTEM" /* correct ?? */
     421        NULL,
     422        "SYSTEM" /* correct ?? */
    424423    },
    425424    { /* 16 (LDID_MAIL) = destination mail dir */
    426     NULL,
    427     ""
     425        NULL,
     426        ""
    428427    },
    429428    { /* 17 (LDID_INF) = INF dir */
    430     "SetupScratchDir", /* correct ? */
    431     "INF"
     429        "SetupScratchDir", /* correct ? */
     430        "INF"
    432431    },
    433432    { /* 18 (LDID_HELP) = HELP dir */
    434     NULL, /* ??? */
    435     "HELP"
     433        NULL, /* ??? */
     434        "HELP"
    436435    },
    437436    { /* 19 (LDID_WINADMIN) = Admin dir */
    438     "WinAdminDir",
    439     ""
     437        "WinAdminDir",
     438        ""
    440439    },
    441440    { /* 20 (LDID_FONTS) = Fonts dir */
    442     NULL, /* ??? */
    443     "FONTS"
     441        NULL, /* ??? */
     442        "FONTS"
    444443    },
    445444    { /* 21 (LDID_VIEWERS) = Viewers */
    446     NULL, /* ??? */
    447     "SYSTEM\\VIEWERS"
     445        NULL, /* ??? */
     446        "SYSTEM\\VIEWERS"
    448447    },
    449448    { /* 22 (LDID_VMM32) = VMM32 dir */
    450     NULL, /* ??? */
    451     "SYSTEM\\VMM32"
     449        NULL, /* ??? */
     450        "SYSTEM\\VMM32"
    452451    },
    453452    { /* 23 (LDID_COLOR) = ICM dir */
    454     "ICMPath",
    455     "SYSTEM\\COLOR"
     453        "ICMPath",
     454        "SYSTEM\\COLOR"
    456455    },
    457456    { /* 24 (LDID_APPS) = root of boot drive ? */
    458     "AppsDir",
    459     "C:\\"
     457        "AppsDir",
     458        "C:\\"
    460459    },
    461460    { /* 25 (LDID_SHARED) = shared dir */
    462     "SharedDir",
    463     ""
     461        "SharedDir",
     462        ""
    464463    },
    465464    { /* 26 (LDID_WINBOOT) = Windows boot dir */
    466     "WinBootDir",
    467     ""
     465        "WinBootDir",
     466        ""
    468467    },
    469468    { /* 27 (LDID_MACHINE) = machine specific files */
    470     "MachineDir",
    471     NULL
     469        "MachineDir",
     470        NULL
    472471    },
    473472    { /* 28 (LDID_HOST_WINBOOT) = Host Windows boot dir */
    474     "HostWinBootDir",
    475     NULL
     473        "HostWinBootDir",
     474        NULL
    476475    },
    477476    { /* 29 -- not defined */
    478     NULL,
    479     NULL
     477        NULL,
     478        NULL
    480479    },
    481480    { /* 30 (LDID_BOOT) = Root of boot drive */
    482     "BootDir",
    483     NULL
     481        "BootDir",
     482        NULL
    484483    },
    485484    { /* 31 (LDID_BOOT_HOST) = Root of boot drive host */
    486     "BootHost",
    487     NULL
     485        "BootHost",
     486        NULL
    488487    },
    489488    { /* 32 (LDID_OLD_WINBOOT) = subdir of root */
    490     "OldWinBootDir",
    491     NULL
     489        "OldWinBootDir",
     490        NULL
    492491    },
    493492    { /* 33 (LDID_OLD_WIN) = old win dir */
    494     "OldWinDir",
    495     NULL
     493        "OldWinDir",
     494        NULL
    496495    }
    497496    /* the rest (34-38) isn't too interesting, so I'll forget about it */
    498497};
    499498
    500 /*
     499/* 
    501500 * LDD  == Logical Device Descriptor
    502501 * LDID == Logical Device ID
     
    528527    for (n=0; n < sizeof(LDID_Data)/sizeof(LDID_DATA); n++)
    529528    {
    530     buffer[0] = '\0';
    531 
    532     len = MAX_PATH;
    533     if ( (hKey) && (LDID_Data[n].RegValName)
    534     &&   (RegQueryValueExA(hKey, LDID_Data[n].RegValName,
    535         NULL, &type, buffer, &len) == ERROR_SUCCESS)
    536     &&   (type == REG_SZ) )
    537     {
    538         TRACE("found value '%s' for LDID %d\n", buffer, n);
    539     }
    540     else
     529        buffer[0] = '\0';
     530
     531        len = MAX_PATH;
     532        if ( (hKey) && (LDID_Data[n].RegValName)
     533        &&   (RegQueryValueExA(hKey, LDID_Data[n].RegValName,
     534                NULL, &type, buffer, &len) == ERROR_SUCCESS)
     535        &&   (type == REG_SZ) )
     536        {
     537            TRACE("found value '%s' for LDID %d\n", buffer, n);
     538        }
     539        else
    541540        switch(n)
    542     {
    543         case LDID_SRCPATH:
    544         FIXME("LDID_SRCPATH: what exactly do we have to do here ?\n");
    545         strcpy(buffer, "X:\\FIXME");
    546         break;
    547         case LDID_SYS:
    548             GetSystemDirectoryA(buffer, MAX_PATH);
    549         break;
    550         case LDID_APPS:
    551         case LDID_MACHINE:
    552         case LDID_HOST_WINBOOT:
    553         case LDID_BOOT:
    554         case LDID_BOOT_HOST:
    555         strcpy(buffer, "C:\\");
    556         break;
    557         default:
    558         if (LDID_Data[n].StdString)
    559         {
    560             DWORD len = GetWindowsDirectoryA(buffer, MAX_PATH);
    561             LPSTR p;
    562             p = buffer + len;
    563             *p++ = '\\';
    564             strcpy(p, LDID_Data[n].StdString);
     541        {
     542            case LDID_SRCPATH:
     543                FIXME("LDID_SRCPATH: what exactly do we have to do here ?\n");
     544                strcpy(buffer, "X:\\FIXME");
     545                break;
     546            case LDID_SYS:
     547                GetSystemDirectoryA(buffer, MAX_PATH);
     548                break;
     549            case LDID_APPS:
     550            case LDID_MACHINE:
     551            case LDID_HOST_WINBOOT:
     552            case LDID_BOOT:
     553            case LDID_BOOT_HOST:
     554                strcpy(buffer, "C:\\");
     555                break;
     556            default:
     557                if (LDID_Data[n].StdString)
     558                {
     559                    DWORD len = GetWindowsDirectoryA(buffer, MAX_PATH);
     560                    LPSTR p;
     561                    p = buffer + len;
     562                    *p++ = '\\';
     563                    strcpy(p, LDID_Data[n].StdString);
     564                }
     565                break;
    565566        }
    566         break;
    567         }
    568     if (buffer[0])
    569     {
    570         INIT_LDD(ldd, n);
    571         ldd.pszPath = buffer;
    572         TRACE("LDID %d -> '%s'\n", ldd.ldid, ldd.pszPath);
    573         CtlSetLdd16(&ldd);
    574     }
     567        if (buffer[0])
     568        {
     569            INIT_LDD(ldd, n);
     570            ldd.pszPath = buffer;
     571            TRACE("LDID %d -> '%s'\n", ldd.ldid, ldd.pszPath);
     572            CtlSetLdd16(&ldd);
     573        }
    575574    }
    576575    if (hKey) RegCloseKey(hKey);
    577576}
    578 
    579 /***********************************************************************
    580  * CtlDelLdd        (SETUPX.37)
     577       
     578/***********************************************************************
     579 * CtlDelLdd            (SETUPX.37)
    581580 *
    582581 * RETURN
     
    590589
    591590    if (!std_LDDs_done)
    592     SETUPX_CreateStandardLDDs();
     591        SETUPX_CreateStandardLDDs();
    593592
    594593    if (ldid < LDID_ASSIGN_START)
    595     return ERR_VCP_LDDINVALID;
     594        return ERR_VCP_LDDINVALID;
    596595
    597596    pCurr = pFirstLDD;
     
    599598    while ((pCurr != NULL) && (ldid > pCurr->pldd->ldid))
    600599    {
    601     pPrev = pCurr;
    602     pCurr = pCurr->next;
     600        pPrev = pCurr;
     601        pCurr = pCurr->next;
    603602    }
    604603    if ( (pCurr == NULL) /* hit end of list */
    605604      || (ldid != pCurr->pldd->ldid) )
    606     return ERR_VCP_LDDFIND; /* correct ? */
     605        return ERR_VCP_LDDFIND; /* correct ? */
    607606
    608607    /* ok, found our victim: eliminate it */
    609608
    610609    if (pPrev)
    611     pPrev->next = pCurr->next;
     610        pPrev->next = pCurr->next;
    612611
    613612    if (pCurr == pFirstLDD)
    614     pFirstLDD = NULL;
     613        pFirstLDD = NULL;
    615614    HeapFree(GetProcessHeap(), 0, pCurr);
    616 
     615   
    617616    return OK;
    618617}
    619618
    620619/***********************************************************************
    621  *      CtlDelLdd (SETUPX.37)
     620 *              CtlDelLdd (SETUPX.37)
    622621 */
    623622RETERR16 WINAPI CtlDelLdd16(LOGDISKID16 ldid)
     
    628627
    629628/***********************************************************************
    630  * CtlFindLdd       (SETUPX.35)
     629 * CtlFindLdd           (SETUPX.35)
    631630 *
    632631 * doesn't check pldd ptr validity: crash (W98SE)
     
    635634 *   ERR_VCP_LDDINVALID if pldd->cbSize != structsize
    636635 *   1 in all other cases ??
    637  *
     636 * 
    638637 */
    639638RETERR16 WINAPI CtlFindLdd16(LPLOGDISKDESC pldd)
     
    642641
    643642    TRACE("(%p)\n", pldd);
    644 
     643   
    645644    if (!std_LDDs_done)
    646     SETUPX_CreateStandardLDDs();
     645        SETUPX_CreateStandardLDDs();
    647646
    648647    if (pldd->cbSize != sizeof(LOGDISKDESC_S))
     
    653652    while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
    654653    {
    655     pPrev = pCurr;
    656     pCurr = pCurr->next;
     654        pPrev = pCurr;
     655        pCurr = pCurr->next;
    657656    }
    658657    if ( (pCurr == NULL) /* hit end of list */
    659658      || (pldd->ldid != pCurr->pldd->ldid) )
    660     return ERR_VCP_LDDFIND; /* correct ? */
     659        return ERR_VCP_LDDFIND; /* correct ? */
    661660
    662661    memcpy(pldd, pCurr->pldd, pldd->cbSize);
    663662    /* hmm, we probably ought to strcpy() the string ptrs here */
    664 
     663   
    665664    return 1; /* what is this ?? */
    666665}
    667666
    668667/***********************************************************************
    669  * CtlSetLdd            (SETUPX.33)
     668 * CtlSetLdd                    (SETUPX.33)
    670669 *
    671670 * Set an LDD entry.
     
    685684
    686685    if (!std_LDDs_done)
    687     SETUPX_CreateStandardLDDs();
     686        SETUPX_CreateStandardLDDs();
    688687
    689688    if (pldd->cbSize != sizeof(LOGDISKDESC_S))
    690     return ERR_VCP_LDDINVALID;
     689        return ERR_VCP_LDDINVALID;
    691690
    692691    heap = GetProcessHeap();
     
    695694    while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
    696695    {
    697     pPrev = pCurr;
    698     pCurr = pCurr->next;
     696        pPrev = pCurr;
     697        pCurr = pCurr->next;
    699698    }
    700699    if (pCurr == NULL) /* hit end of list */
    701700    {
    702     is_new = TRUE;
     701        is_new = TRUE;
    703702        pCurr = HeapAlloc(heap, 0, sizeof(LDD_LIST));
    704703        pCurr->pldd = HeapAlloc(heap, 0, sizeof(LOGDISKDESC_S));
     
    709708    {
    710709        pCurrLDD = pCurr->pldd;
    711     if (pCurrLDD->pszPath)      HeapFree(heap, 0, pCurrLDD->pszPath);
    712     if (pCurrLDD->pszVolLabel)  HeapFree(heap, 0, pCurrLDD->pszVolLabel);
    713     if (pCurrLDD->pszDiskName)  HeapFree(heap, 0, pCurrLDD->pszDiskName);
     710        if (pCurrLDD->pszPath)          HeapFree(heap, 0, pCurrLDD->pszPath);
     711        if (pCurrLDD->pszVolLabel)      HeapFree(heap, 0, pCurrLDD->pszVolLabel);
     712        if (pCurrLDD->pszDiskName)      HeapFree(heap, 0, pCurrLDD->pszDiskName);
    714713    }
    715714
     
    717716
    718717    if (pldd->pszPath)
    719         pCurrLDD->pszPath   = HEAP_strdupA(heap, 0, pldd->pszPath);
     718        pCurrLDD->pszPath       = HEAP_strdupA(heap, 0, pldd->pszPath);
    720719    if (pldd->pszVolLabel)
    721     pCurrLDD->pszVolLabel   = HEAP_strdupA(heap, 0, pldd->pszVolLabel);
     720        pCurrLDD->pszVolLabel   = HEAP_strdupA(heap, 0, pldd->pszVolLabel);
    722721    if (pldd->pszDiskName)
    723     pCurrLDD->pszDiskName   = HEAP_strdupA(heap, 0, pldd->pszDiskName);
     722        pCurrLDD->pszDiskName   = HEAP_strdupA(heap, 0, pldd->pszDiskName);
    724723
    725724    if (is_new) /* link into list */
    726725    {
    727726        if (pPrev)
    728     {
    729         pCurr->next = pPrev->next;
     727        {
     728            pCurr->next = pPrev->next;
    730729            pPrev->next = pCurr;
    731     }
    732     if (!pFirstLDD)
    733         pFirstLDD = pCurr;
    734     }
    735 
     730        }
     731        if (!pFirstLDD)
     732            pFirstLDD = pCurr;
     733    }
     734   
    736735    return OK;
    737736}
     
    739738
    740739/***********************************************************************
    741  * CtlAddLdd        (SETUPX.36)
     740 * CtlAddLdd            (SETUPX.36)
    742741 *
    743742 * doesn't check pldd ptr validity: crash (W98SE)
     
    752751
    753752/***********************************************************************
    754  * CtlGetLdd        (SETUPX.34)
     753 * CtlGetLdd            (SETUPX.34)
    755754 *
    756755 * doesn't check pldd ptr validity: crash (W98SE)
     
    759758 * RETURN
    760759 *   ERR_VCP_LDDINVALID if pldd->cbSize != structsize
    761  *
     760 * 
    762761 */
    763762static RETERR16 SETUPX_GetLdd(LPLOGDISKDESC pldd)
     
    766765
    767766    if (!std_LDDs_done)
    768     SETUPX_CreateStandardLDDs();
     767        SETUPX_CreateStandardLDDs();
    769768
    770769    if (pldd->cbSize != sizeof(LOGDISKDESC_S))
     
    775774    while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
    776775    {
    777     pPrev = pCurr;
    778     pCurr = pCurr->next;
     776        pPrev = pCurr;
     777        pCurr = pCurr->next;
    779778    }
    780779    if (pCurr == NULL) /* hit end of list */
    781     return ERR_VCP_LDDFIND; /* correct ? */
     780        return ERR_VCP_LDDFIND; /* correct ? */
    782781
    783782    memcpy(pldd, pCurr->pldd, pldd->cbSize);
     
    796795
    797796/***********************************************************************
    798  *      CtlGetLddPath       (SETUPX.38)
     797 *              CtlGetLddPath           (SETUPX.38)
    799798 *
    800799 * Gets the path of an LDD.
     
    810809    if (szPath)
    811810    {
    812     LOGDISKDESC_S ldd;
    813     INIT_LDD(ldd, ldid);
    814     if (CtlFindLdd16(&ldd) == ERR_VCP_LDDFIND)
    815         return ERR_VCP_LDDUNINIT;
    816     SETUPX_GetLdd(&ldd);
     811        LOGDISKDESC_S ldd;
     812        INIT_LDD(ldd, ldid);
     813        if (CtlFindLdd16(&ldd) == ERR_VCP_LDDFIND)
     814            return ERR_VCP_LDDUNINIT;
     815        SETUPX_GetLdd(&ldd);
    817816        strcpy(szPath, ldd.pszPath);
    818     TRACE("ret '%s' for LDID %d\n", szPath, ldid);
     817        TRACE("ret '%s' for LDID %d\n", szPath, ldid);
    819818    }
    820819    return OK;
     
    822821
    823822/***********************************************************************
    824  *      CtlSetLddPath       (SETUPX.508)
     823 *              CtlSetLddPath           (SETUPX.508)
    825824 *
    826825 * Sets the path of an LDD.
     
    831830    LOGDISKDESC_S ldd;
    832831    TRACE("(%d, '%s');\n", ldid, szPath);
    833 
     832   
    834833    INIT_LDD(ldd, ldid);
    835834    ldd.pszPath = szPath;
     
    848847 * -- registry lookup -->
    849848 * C:\Program Files (or C:\ if not found in registry)
    850  *
     849 * 
    851850 * FIXME:
    852851 * - maybe we ought to add a caching array for speed ? - I don't care :)
     
    854853 *   LDIDs for both install and removal sections.
    855854 * - probably the whole function can be removed as installers add that on their
    856  *   own
     855 *   own 
    857856 */
    858857static BOOL SETUPX_AddCustomLDID(int ldid, INT16 hInf)
     
    870869    if (!(sectionbuf = SETUPX_GetSections(filename)))
    871870    {
    872     ERR("couldn't get sections !\n");
    873     return FALSE;
     871        ERR("couldn't get sections !\n");
     872        return FALSE;
    874873    }
    875874    for (pSec=sectionbuf; *pSec; pSec += strlen(pSec)+1)
    876875    {
    877     if (!(entrybuf = SETUPX_GetSectionEntries(filename, pSec)))
    878     {
    879         ERR("couldn't get section entries !\n");
    880         goto end;
    881     }
    882     for (pEnt=entrybuf; *pEnt; pEnt += strlen(pEnt)+1)
    883     {
    884         if (strstr(pEnt, ldidstr))
    885         {
    886         pEqual = strchr(pEnt, '=');
    887         if (!pEqual) /* crippled entry ?? */
    888             continue;
    889 
    890         /* make sure we found the LDID on left side of the equation */
    891         if (pEnt+strlen(ldidstr) <= pEqual)
    892         { /* found */
    893 
    894             /* but we don't want entries in the strings section */
    895             if (!strcasecmp(pSec, "Strings"))
    896             goto next_section;
    897             p = pEqual+1;
    898             goto found;
    899         }
    900         }
    901     }
     876        if (!(entrybuf = SETUPX_GetSectionEntries(filename, pSec)))
     877        {
     878            ERR("couldn't get section entries !\n");
     879            goto end;
     880        }
     881        for (pEnt=entrybuf; *pEnt; pEnt += strlen(pEnt)+1)
     882        {
     883            if (strstr(pEnt, ldidstr))
     884            {
     885                pEqual = strchr(pEnt, '=');
     886                if (!pEqual) /* crippled entry ?? */
     887                    continue;
     888
     889                /* make sure we found the LDID on left side of the equation */
     890                if (pEnt+strlen(ldidstr) <= pEqual)
     891                { /* found */
     892
     893                    /* but we don't want entries in the strings section */
     894                    if (!strcasecmp(pSec, "Strings"))
     895                        goto next_section;
     896                    p = pEqual+1;
     897                    goto found;
     898                }
     899            }
     900        }
    902901next_section:
    903902    }
     
    908907    if (*(DWORD *)pSub > 2)
    909908    {
    910     ERR("malformed entry '%s' ?\n", p);
    911     goto end;
     909        ERR("malformed entry '%s' ?\n", p);
     910        goto end;
    912911    }
    913912    TRACE("found section '%s'\n", *(pSub+1));
     
    917916    if (!(regsectionbuf = SETUPX_GetSectionEntries(filename, *(pSub+1))))
    918917    {
    919     ERR("couldn't get registry section entries !\n");
    920     goto end;
     918        ERR("couldn't get registry section entries !\n");
     919        goto end;
    921920    }
    922921    /* sectionbuf is > 1024 bytes anyway, so use it */
     
    929928end:
    930929    SETUPX_FreeSubStrings(pSub);
    931     if (sectionbuf) HeapFree(GetProcessHeap(), 0, sectionbuf);
    932     if (entrybuf)   HeapFree(GetProcessHeap(), 0, entrybuf);
    933     if (regsectionbuf)  HeapFree(GetProcessHeap(), 0, regsectionbuf);
     930    if (sectionbuf)     HeapFree(GetProcessHeap(), 0, sectionbuf);
     931    if (entrybuf)       HeapFree(GetProcessHeap(), 0, entrybuf);
     932    if (regsectionbuf)  HeapFree(GetProcessHeap(), 0, regsectionbuf);
    934933    return ret;
    935934}
     
    948947    if (CtlFindLdd16(&ldd) == ERR_VCP_LDDFIND)
    949948    {
    950     /* hmm, it seems the installers already do the work for us
    951     * (by calling CtlSetLddPath) that SETUPX_AddCustomLDID
    952     * is supposed to do. Grmbl ;-)
    953     * Well, I'll leave it here anyway, but print error... */
    954     ERR("hmm, LDID %d not registered yet !?\n", ldid);
    955     handled = SETUPX_AddCustomLDID(ldid, hInf);
     949        /* hmm, it seems the installers already do the work for us
     950        * (by calling CtlSetLddPath) that SETUPX_AddCustomLDID
     951        * is supposed to do. Grmbl ;-)
     952        * Well, I'll leave it here anyway, but print error... */
     953        ERR("hmm, LDID %d not registered yet !?\n", ldid);
     954        handled = SETUPX_AddCustomLDID(ldid, hInf);
    956955    }
    957956    else
    958     handled = TRUE;
    959 
     957        handled = TRUE;
     958   
    960959    SETUPX_GetLdd(&ldd);
    961 
     960   
    962961    if (!handled)
    963962    {
    964963        FIXME("What is LDID %d ??\n", ldid);
    965     *p = "LDID_FIXME";
     964        *p = "LDID_FIXME";
    966965    }
    967966    else
    968     *p = ldd.pszPath;
     967        *p = ldd.pszPath;
    969968
    970969    return handled;
     
    972971
    973972/***********************************************************************
    974  *      GenFormStrWithoutPlaceHolders
     973 *              GenFormStrWithoutPlaceHolders
    975974 *
    976975 * ought to be pretty much implemented, I guess...
     
    981980    LPSTR pDst = szDst, p, pPHBegin;
    982981    int count;
    983 
     982   
    984983    TRACE("(%p, '%s', %04x);\n", szDst, szSrc, hInf);
    985984    while (pSrc < pSrcEnd)
    986985    {
    987     p = strchr(pSrc, '%');
    988     if (p)
    989     {
    990         count = (int)p - (int)pSrc;
    991         strncpy(pDst, pSrc, count);
    992         pSrc += count;
    993         pDst += count;
    994         pPHBegin = p+1;
    995         p = strchr(pPHBegin, '%');
    996         if (p)
    997         {
    998         char placeholder[80]; /* that really ought to be enough ;) */
    999         int ldid;
    1000         BOOL done = TRUE;
    1001         count = (int)p - (int)pPHBegin;
    1002         strncpy(placeholder, pPHBegin, count);
    1003         placeholder[count] = '\0';
    1004         ldid = atoi(placeholder);
    1005         if (ldid)
    1006         {
    1007             LPSTR p;
    1008             done = SETUPX_IP_TranslateLDID(ldid, &p, hInf);
    1009             strcpy(pDst, p);
    1010             if (done)
    1011             pDst += strlen(pDst);
    1012         }
    1013         else
    1014         { /* hmm, string placeholder. Need to look up
    1015              in the [strings] section of the hInf */
    1016             DWORD ret;
    1017             char buf[256]; /* long enough ? */
    1018 
    1019             ret = GetPrivateProfileStringA("strings", placeholder, "",
    1020                         buf, 256, IP_GetFileName(hInf));
    1021             if (ret)
    1022             {
    1023             strcpy(pDst, buf);
    1024             pDst += strlen(buf);
    1025             }
    1026             else
    1027             {
    1028                 ERR("placeholder string '%s' not found !\n", placeholder);
    1029             done = FALSE;
    1030             }
    1031         }
    1032         if (!done)
    1033         { /* copy raw placeholder string over */
    1034             count = (int)p - (int)pPHBegin + 2;
    1035             strncpy(pDst, pPHBegin-1, count);
    1036             pDst += count;
    1037 
    1038         }
    1039         pSrc = p+1;
    1040         continue;
    1041         }
    1042     }
    1043 
    1044     /* copy the remaining source string over */
    1045     strncpy(pDst, pSrc, (int)pSrcEnd - (int)pSrc + 1);
    1046     break;
     986        p = strchr(pSrc, '%');
     987        if (p)
     988        {
     989            count = (int)p - (int)pSrc;
     990            strncpy(pDst, pSrc, count);
     991            pSrc += count;
     992            pDst += count;
     993            pPHBegin = p+1;
     994            p = strchr(pPHBegin, '%');
     995            if (p)
     996            {
     997                char placeholder[80]; /* that really ought to be enough ;) */
     998                int ldid;
     999                BOOL done = TRUE;
     1000                count = (int)p - (int)pPHBegin;
     1001                strncpy(placeholder, pPHBegin, count);
     1002                placeholder[count] = '\0';
     1003                ldid = atoi(placeholder);
     1004                if (ldid)
     1005                {
     1006                    LPSTR p;
     1007                    done = SETUPX_IP_TranslateLDID(ldid, &p, hInf);
     1008                    strcpy(pDst, p);
     1009                    if (done)
     1010                        pDst += strlen(pDst);
     1011                }
     1012                else
     1013                { /* hmm, string placeholder. Need to look up
     1014                     in the [strings] section of the hInf */
     1015                    DWORD ret;
     1016                    char buf[256]; /* long enough ? */
     1017                   
     1018                    ret = GetPrivateProfileStringA("strings", placeholder, "",
     1019                                        buf, 256, IP_GetFileName(hInf));
     1020                    if (ret)
     1021                    {
     1022                        strcpy(pDst, buf);
     1023                        pDst += strlen(buf);
     1024                    }
     1025                    else
     1026                    {
     1027                        ERR("placeholder string '%s' not found !\n", placeholder);
     1028                        done = FALSE;
     1029                    }
     1030                }
     1031                if (!done)
     1032                { /* copy raw placeholder string over */
     1033                    count = (int)p - (int)pPHBegin + 2;
     1034                    strncpy(pDst, pPHBegin-1, count);
     1035                    pDst += count;
     1036                   
     1037                }
     1038                pSrc = p+1;
     1039                continue;
     1040            }
     1041        }
     1042
     1043        /* copy the remaining source string over */
     1044        strncpy(pDst, pSrc, (int)pSrcEnd - (int)pSrc + 1);
     1045        break;
    10471046    }
    10481047    TRACE("ret '%s'\n", szDst);
     
    10501049
    10511050/***********************************************************************
    1052  *      VcpOpen
     1051 *              VcpOpen
    10531052 *
    10541053 * No idea what to do here.
     
    10611060
    10621061/***********************************************************************
    1063  *      VcpClose
     1062 *              VcpClose
    10641063 *
    10651064 * Is fl related to VCPDISKINFO.fl ?
     
    10921091    for (n=0; n < *(DWORD *)pSub; n++)
    10931092    {
    1094     pCopyEntry = *(pSub+1+n);
    1095     if (*pCopyEntry == '@')
    1096     {
    1097         ERR("single file not handled yet !\n");
    1098         continue;
    1099     }
    1100 
    1101     /* get source directory for that entry */
    1102     INIT_LDD(ldd, LDID_SRCPATH);
    1103     SETUPX_GetLdd(&ldd);
    1104     pSrcDir = ldd.pszPath;
    1105 
     1093        pCopyEntry = *(pSub+1+n);
     1094        if (*pCopyEntry == '@')
     1095        {
     1096            ERR("single file not handled yet !\n");
     1097            continue;
     1098        }
     1099
     1100        /* get source directory for that entry */
     1101        INIT_LDD(ldd, LDID_SRCPATH);
     1102        SETUPX_GetLdd(&ldd);
     1103        pSrcDir = ldd.pszPath;
     1104       
    11061105        /* get destination directory for that entry */
    1107     if (!(GetPrivateProfileStringA("DestinationDirs", pCopyEntry, "",
    1108                     pDestStr, sizeof(pDestStr), filename)))
    1109         continue;
    1110 
    1111     /* translate destination dir if given as LDID */
    1112     ldid = atoi(pDestStr);
    1113     if (ldid)
    1114     {
    1115         if (!(SETUPX_IP_TranslateLDID(ldid, &pDstDir, hInf)))
    1116         continue;
    1117     }
    1118     else
    1119         pDstDir = pDestStr;
    1120 
    1121     /* now that we have the destination dir, iterate over files to copy */
    1122     pFileEntries = SETUPX_GetSectionEntries(filename, pCopyEntry);
     1106        if (!(GetPrivateProfileStringA("DestinationDirs", pCopyEntry, "",
     1107                                        pDestStr, sizeof(pDestStr), filename)))
     1108            continue;
     1109
     1110        /* translate destination dir if given as LDID */
     1111        ldid = atoi(pDestStr);
     1112        if (ldid)
     1113        {
     1114            if (!(SETUPX_IP_TranslateLDID(ldid, &pDstDir, hInf)))
     1115                continue;
     1116        }
     1117        else
     1118            pDstDir = pDestStr;
     1119       
     1120        /* now that we have the destination dir, iterate over files to copy */
     1121        pFileEntries = SETUPX_GetSectionEntries(filename, pCopyEntry);
    11231122        for (p=pFileEntries; *p; p +=strlen(p)+1)
    1124     {
    1125         pSubFile = SETUPX_GetSubStrings(p, ',');
    1126         pSrcFile = *(pSubFile+1);
    1127         pDstFile = (*(DWORD *)pSubFile > 1) ? *(pSubFile+2) : pSrcFile;
    1128         TRACE("copying file '%s\\%s' to '%s\\%s'\n", pSrcDir, pSrcFile, pDstDir, pDstFile);
    1129         if (*(DWORD *)pSubFile > 2)
    1130         {
    1131         WORD flag;
    1132         if ((flag = atoi(*(pSubFile+3)))) /* ah, flag */
    1133         {
    1134             if (flag & 0x2c)
    1135             FIXME("VNLP_xxx flag %d not handled yet.\n", flag);
    1136         }
    1137         else
    1138             FIXME("temp file name '%s' given. Need to register in wininit.ini !\n", *(pSubFile+3)); /* strong guess that this is VcpQueueCopy() */
    1139         }
    1140         SETUPX_FreeSubStrings(pSubFile);
    1141         /* we don't copy ANYTHING yet ! (I'm too lazy and want to verify
    1142          * this first before destroying whole partitions ;-) */
    1143     }
    1144     }
    1145 
     1123        {
     1124            pSubFile = SETUPX_GetSubStrings(p, ',');
     1125            pSrcFile = *(pSubFile+1);
     1126            pDstFile = (*(DWORD *)pSubFile > 1) ? *(pSubFile+2) : pSrcFile;
     1127            TRACE("copying file '%s\\%s' to '%s\\%s'\n", pSrcDir, pSrcFile, pDstDir, pDstFile);
     1128            if (*(DWORD *)pSubFile > 2)
     1129            {
     1130                WORD flag;
     1131                if ((flag = atoi(*(pSubFile+3)))) /* ah, flag */
     1132                {
     1133                    if (flag & 0x2c)
     1134                    FIXME("VNLP_xxx flag %d not handled yet.\n", flag);
     1135                }
     1136                else
     1137                    FIXME("temp file name '%s' given. Need to register in wininit.ini !\n", *(pSubFile+3)); /* strong guess that this is VcpQueueCopy() */
     1138            }
     1139            SETUPX_FreeSubStrings(pSubFile);
     1140            /* we don't copy ANYTHING yet ! (I'm too lazy and want to verify
     1141             * this first before destroying whole partitions ;-) */
     1142        }
     1143    }
     1144           
    11461145    return res;
    11471146}
    11481147
    11491148/***********************************************************************
    1150  *      GenInstall
     1149 *              GenInstall
    11511150 *
    11521151 * general install function for .INF file sections
    11531152 *
    11541153 * This is not perfect - patch whenever you can !
    1155  *
     1154 * 
    11561155 * wFlags == GENINSTALL_DO_xxx
    11571156 * e.g. NetMeeting:
     
    11701169    if (!pEntries)
    11711170    {
    1172     ERR("couldn't find entries for section '%s' !\n", szInstallSection);
    1173     return ERR_IP_SECT_NOT_FOUND;
     1171        ERR("couldn't find entries for section '%s' !\n", szInstallSection);
     1172        return ERR_IP_SECT_NOT_FOUND;
    11741173    }
    11751174    for (p=pEntries; *p; p +=strlen(p)+1)
    11761175    {
    1177     pEnd = strchr(p, '=');
    1178     if (!pEnd) continue;
    1179     pSub = SETUPX_GetSubStrings(pEnd+1, ','); /* split entries after the '=' */
    1180     SETUPX_IsolateSubString(&p, &pEnd);
    1181     len = (int)pEnd - (int)p;
    1182 
    1183     if (wFlags & GENINSTALL_DO_FILES)
    1184     {
    1185         if (!strncasecmp(p, "CopyFiles", len))
    1186         {
    1187             SETUPX_CopyFiles(pSub, hInfFile);
    1188         continue;
    1189         }
     1176        pEnd = strchr(p, '=');
     1177        if (!pEnd) continue;
     1178        pSub = SETUPX_GetSubStrings(pEnd+1, ','); /* split entries after the '=' */
     1179        SETUPX_IsolateSubString(&p, &pEnd);
     1180        len = (int)pEnd - (int)p;
     1181
     1182        if (wFlags & GENINSTALL_DO_FILES)
     1183        {
     1184            if (!strncasecmp(p, "CopyFiles", len))
     1185            {
     1186                SETUPX_CopyFiles(pSub, hInfFile);
     1187                continue;
     1188            }
    11901189#if IMPLEMENT_THAT
    1191         else
    1192         if (!strncasecmp(p, "DelFiles", len))
    1193         {
    1194             SETUPX_DelFiles(filename, szInstallSection, pSub);
    1195         continue;
    1196         }
     1190            else
     1191            if (!strncasecmp(p, "DelFiles", len))
     1192            {
     1193                SETUPX_DelFiles(filename, szInstallSection, pSub);
     1194                continue;
     1195            }
    11971196#endif
    1198     }
    1199     if (wFlags & GENINSTALL_DO_INI)
    1200     {
     1197        }
     1198        if (wFlags & GENINSTALL_DO_INI)
     1199        {
    12011200#if IMPLEMENT_THAT
    1202         if (!strncasecmp(p, "UpdateInis", len))
    1203         {
    1204             SETUPX_UpdateInis(filename, szInstallSection, pSub);
    1205         continue;
    1206         }
     1201            if (!strncasecmp(p, "UpdateInis", len))
     1202            {
     1203                SETUPX_UpdateInis(filename, szInstallSection, pSub);
     1204                continue;
     1205            }
    12071206#endif
    1208     }
    1209     if (wFlags & GENINSTALL_DO_REG)
    1210     {
     1207        }
     1208        if (wFlags & GENINSTALL_DO_REG)
     1209        {
    12111210#if IMPLEMENT_THAT
    1212         /* probably use SUReg*() functions here */
    1213         if (!strncasecmp(p, "AddReg", len))
    1214         {
    1215             SETUPX_AddReg(filename, szInstallSection, pSub);
    1216         continue;
    1217         }
    1218         else
    1219         if (!strncasecmp(p, "DelReg", len))
    1220         {
    1221             SETUPX_DelReg(filename, szInstallSection, pSub);
    1222         continue;
    1223         }
     1211            /* probably use SUReg*() functions here */
     1212            if (!strncasecmp(p, "AddReg", len))
     1213            {
     1214                SETUPX_AddReg(filename, szInstallSection, pSub);
     1215                continue;
     1216            }
     1217            else
     1218            if (!strncasecmp(p, "DelReg", len))
     1219            {
     1220                SETUPX_DelReg(filename, szInstallSection, pSub);
     1221                continue;
     1222            }
    12241223#endif
    1225     }
    1226 
    1227     SETUPX_FreeSubStrings(pSub);
     1224        }
     1225       
     1226        SETUPX_FreeSubStrings(pSub);
    12281227    }
    12291228    HeapFree(GetProcessHeap(), 0, pEntries);
  • trunk/src/setupapi/stubs.c

    r6649 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 8 -*- */
    2 /* $Id: stubs.c,v 1.2 2001-09-05 13:38:24 bird Exp $ */
    32/*
    43 * SetupAPI stubs
     
    1716
    1817/***********************************************************************
    19  *      SetupCloseFileQueue
     18 *              SetupCloseFileQueue
    2019 */
    2120VOID WINAPI SetupCloseFileQueue(HSPFILEQ QueueHandle)
    2221{
    23     FIXME("not implemented (setupapi.dll) \n");
    24 }
    25 
    26 /***********************************************************************
    27  *      SetupCommitFileQueueA
     22        FIXME("not implemented (setupapi.dll) \n");
     23}
     24
     25/***********************************************************************
     26 *              SetupCommitFileQueueA
    2827 */
    2928BOOL WINAPI SetupCommitFileQueueA(HWND Owner, HSPFILEQ QueueHandle,
    30                   PSP_FILE_CALLBACK_A MsgHandler,
    31                   PVOID Context)
    32 {
    33     FIXME("not implemented (setupapi.dll) \n");
    34     return FALSE;
    35 }
    36 
    37 /***********************************************************************
    38  *      SetupIterateCabinetA
     29                                  PSP_FILE_CALLBACK_A MsgHandler,
     30                                  PVOID Context)
     31{
     32        FIXME("not implemented (setupapi.dll) \n");
     33        return FALSE;
     34}
     35
     36/***********************************************************************
     37 *              SetupIterateCabinetA
    3938 */
    4039BOOL WINAPI SetupIterateCabinetA(PCSTR CabinetFile, DWORD Reserved,
    4140                                 PSP_FILE_CALLBACK_A MsgHandler, PVOID Context)
    4241{
    43     FIXME("not implemented (setupapi.dll) \n");
    44     return 0;
    45 }
    46 
    47 /***********************************************************************
    48  *      SetupIterateCabinetW
     42        FIXME("not implemented (setupapi.dll) \n");
     43        return 0;
     44}
     45
     46/***********************************************************************
     47 *              SetupIterateCabinetW
    4948 */
    5049BOOL WINAPI SetupIterateCabinetW(PWSTR CabinetFile, DWORD Reserved,
    51                                  PSP_FILE_CALLBACK_W MsgHandler, PVOID Context)
    52 {
    53     FIXME("not implemented (setupapi.dll) \n");
    54     return 0;
    55 }
    56 
    57 
    58 /***********************************************************************
    59  *      SetupGetLineTextA
     50                                 PSP_FILE_CALLBACK_W MsgHandler, PVOID Context) 
     51{
     52        FIXME("not implemented (setupapi.dll) \n");
     53        return 0;
     54}
     55
     56
     57/***********************************************************************
     58 *              SetupGetLineTextA
    6059 */
    6160BOOL WINAPI SetupGetLineTextA (PINFCONTEXT Context, HINF InfHandle,
     
    6362                        DWORD ReturnBufferSize, PDWORD RequiredSize)
    6463{
    65     FIXME("not implemented (setupapi.dll) \n");
    66     return 0;
    67 }
    68 
    69 /***********************************************************************
    70  *      SetupGetStringFieldA
    71  */
    72 BOOL WINAPI SetupGetStringFieldA(PINFCONTEXT Context, DWORD FieldIndex,
     64        FIXME("not implemented (setupapi.dll) \n");
     65        return 0;
     66}
     67
     68/***********************************************************************
     69 *              SetupGetStringFieldA
     70 */
     71BOOL WINAPI SetupGetStringFieldA(PINFCONTEXT Context, DWORD FieldIndex, 
    7372                                 LPSTR ReturnBuffer, DWORD ReturnBufferSize,
    7473                                 PDWORD RequiredSize)
    7574{
    76     FIXME("not implemented (setupapi.dll) \n");
    77     return 0;
    78 }
    79 
    80 
    81 /***********************************************************************
    82  *      SetupFindNextLine
     75        FIXME("not implemented (setupapi.dll) \n");
     76        return 0;
     77}
     78
     79
     80/***********************************************************************
     81 *              SetupFindNextLine
    8382 */
    8483BOOL WINAPI SetupFindNextLine (PINFCONTEXT ContextIn, PINFCONTEXT ContextOut)
    8584{
    86     FIXME("not implemented (setupapi.dll) \n");
    87     return 0;
    88 }
    89 
    90 
    91 /***********************************************************************
    92  *      SetupInitDefaultQueueCallback
     85        FIXME("not implemented (setupapi.dll) \n");
     86        return 0;
     87}
     88
     89
     90/***********************************************************************
     91 *              SetupInitDefaultQueueCallback
    9392 */
    9493PVOID WINAPI SetupInitDefaultQueueCallback(HWND OwnerWindow)
    9594{
    96     FIXME("not implemented (setupapi.dll) \n");
    97     return 0;
    98 }
    99 
    100 /***********************************************************************
    101  *      SetupInitDefaultQueueCallbackEx
     95        FIXME("not implemented (setupapi.dll) \n");
     96        return 0;
     97}
     98
     99/***********************************************************************
     100 *              SetupInitDefaultQueueCallbackEx
    102101 */
    103102PVOID WINAPI SetupInitDefaultQueueCallbackEx(HWND OwnerWindow,
    104                          HWND AlternativeProgressWindow,
    105                          UINT ProgressMessage,
    106                          DWORD res1,
    107                          PVOID res2)
    108 {
    109     FIXME("not implemented (setupapi.dll) \n");
    110     return 0;
    111 }
    112 
    113 /***********************************************************************
    114  *      SetupCloseInfFile
     103                                             HWND AlternativeProgressWindow,
     104                                             UINT ProgressMessage,
     105                                             DWORD res1,
     106                                             PVOID res2)
     107{
     108        FIXME("not implemented (setupapi.dll) \n");
     109        return 0;
     110}
     111
     112/***********************************************************************
     113 *              SetupCloseInfFile
    115114 */
    116115VOID WINAPI SetupCloseInfFile (HINF InfHandle)
    117116{
    118     FIXME("not implemented (setupapi.dll) \n");
    119 }
    120 
    121 
    122 /***********************************************************************
    123  *      SetupDefaultQueueCallbackA
     117        FIXME("not implemented (setupapi.dll) \n");
     118}
     119
     120
     121/***********************************************************************
     122 *              SetupDefaultQueueCallbackA
    124123 */
    125124UINT WINAPI SetupDefaultQueueCallbackA (PVOID Context, UINT Notification,
    126125                                        UINT Param1, UINT Param2)
    127126{
    128     FIXME("not implemented (setupapi.dll) \n");
    129     return 0;
    130 }
    131 
    132 
    133 /***********************************************************************
    134  *      SetupFindFirstLineA
     127        FIXME("not implemented (setupapi.dll) \n");
     128        return 0;
     129}
     130
     131
     132/***********************************************************************
     133 *              SetupFindFirstLineA
    135134 */
    136135BOOL WINAPI SetupFindFirstLineA (HINF InfHandle, PCSTR Section, PCSTR Key,
    137136                                 PINFCONTEXT Context)
    138137{
    139     FIXME("not implemented (setupapi.dll) \n");
    140     return 0;
    141 }
    142 
    143 /***********************************************************************
    144  *      SetupGetLineByIndexA
     138        FIXME("not implemented (setupapi.dll) \n");
     139        return 0;
     140}
     141
     142/***********************************************************************
     143 *              SetupGetLineByIndexA
    145144 */
    146145BOOL WINAPI SetupGetLineByIndexA (HINF InfHandle, PCSTR Section, DWORD Index,
    147146                                 PINFCONTEXT Context)
    148147{
    149     FIXME("not implemented (setupapi.dll) \n");
    150     return FALSE;
    151 }
    152 
    153 
    154 /***********************************************************************
    155  *      SetupInstallFromInfSectionA
     148        FIXME("not implemented (setupapi.dll) \n");
     149        return FALSE;
     150}
     151
     152
     153/***********************************************************************
     154 *              SetupInstallFromInfSectionA
    156155 */
    157156BOOL WINAPI SetupInstallFromInfSectionA (HWND Owner, HINF InfHandle, PCSTR SectionName,
     
    161160                                         PSP_DEVINFO_DATA DeviceInfoData)
    162161{
    163     FIXME("not implemented (setupapi.dll) \n");
    164     return 0;
    165 }
    166 
    167 /***********************************************************************
    168  *      SetupOpenAppendInfFileA
     162        FIXME("not implemented (setupapi.dll) \n");
     163        return 0;
     164}
     165
     166/***********************************************************************
     167 *              SetupOpenAppendInfFileA
    169168 */
    170169BOOL WINAPI SetupOpenAppendInfFileA (PCSTR FileName, HINF InfHandle,
    171                     PUINT ErrorLine)
    172 {
    173     FIXME("not implemented (setupapi.dll) \n");
    174     return FALSE;
    175 }
    176 
    177 /***********************************************************************
    178  *      SetupOpenFileQueue
     170                                    PUINT ErrorLine)
     171{
     172        FIXME("not implemented (setupapi.dll) \n");
     173        return FALSE;
     174}
     175
     176/***********************************************************************
     177 *              SetupOpenFileQueue
    179178 */
    180179HSPFILEQ WINAPI SetupOpenFileQueue (VOID)
    181180{
    182     FIXME("not implemented (setupapi.dll) \n");
    183     return (HSPFILEQ) INVALID_HANDLE_VALUE;
    184 }
    185 
    186 /***********************************************************************
    187  *      SetupOpenInfFileA
     181        FIXME("not implemented (setupapi.dll) \n");
     182        return (HSPFILEQ) INVALID_HANDLE_VALUE;
     183}
     184
     185/***********************************************************************
     186 *              SetupOpenInfFileA
    188187 */
    189188HINF WINAPI SetupOpenInfFileA (PCSTR FileName, PCSTR InfClass, DWORD InfStyle,
    190189                               PUINT ErrorLine)
    191190{
    192     FIXME("not implemented (setupapi.dll) \n");
    193     return 0;
    194 }
    195 
    196 /***********************************************************************
    197  *      SetupQueueCopyA
     191        FIXME("not implemented (setupapi.dll) \n");
     192        return 0;
     193}
     194
     195/***********************************************************************
     196 *              SetupQueueCopyA
    198197 */
    199198BOOL WINAPI SetupQueueCopyA (HSPFILEQ QueueHandle, PCSTR SourceRootPath, PCSTR SourcePath,
    200                  PCSTR SourceFileName, PCSTR SourceDescription, PCSTR SourceTagFile,
    201                  PCSTR TargetDirectory, PCSTR TargetFileName, DWORD CopyStyle)
    202 {
    203     FIXME("not implemented (setupapi.dll) \n");
    204     return FALSE;
    205 }
    206 
    207 /***********************************************************************
    208  *      SetupSetDirectoryIdA
     199                             PCSTR SourceFileName, PCSTR SourceDescription, PCSTR SourceTagFile,
     200                             PCSTR TargetDirectory, PCSTR TargetFileName, DWORD CopyStyle)
     201{
     202        FIXME("not implemented (setupapi.dll) \n");
     203        return FALSE;
     204}
     205
     206/***********************************************************************
     207 *              SetupSetDirectoryIdA
    209208 */
    210209BOOL WINAPI SetupSetDirectoryIdA (HINF InfHandle,
    211                   DWORD Id,
    212                   PCSTR Directory)
    213 {
    214     FIXME("not implemented (setupapi.dll) \n");
    215     return FALSE;
    216 }
    217 
    218 
    219 /***********************************************************************
    220  *      SetupTermDefaultQueueCallback
     210                                  DWORD Id,
     211                                  PCSTR Directory)
     212{
     213        FIXME("not implemented (setupapi.dll) \n");
     214        return FALSE;
     215}
     216
     217
     218/***********************************************************************
     219 *              SetupTermDefaultQueueCallback
    221220 */
    222221VOID WINAPI SetupTermDefaultQueueCallback (PVOID Callback)
    223222{
    224     FIXME("not implemented (setupapi.dll) \n");
    225 }
    226 
     223        FIXME("not implemented (setupapi.dll) \n");
     224}
     225
  • trunk/src/shdocvw/classinfo.c

    r6649 r6712  
    1 /* $Id: classinfo.c,v 1.2 2001-09-05 13:39:11 bird Exp $ */
    21/*
    32 * Implementation of IProvideClassInfo interfaces for IE Web Browser control
     
    5756 */
    5857
    59 static ICOM_VTABLE(IProvideClassInfo) WBPCI_Vtbl =
     58static ICOM_VTABLE(IProvideClassInfo) WBPCI_Vtbl = 
    6059{
    6160    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    142141 */
    143142
    144 static ICOM_VTABLE(IProvideClassInfo2) WBPCI2_Vtbl =
     143static ICOM_VTABLE(IProvideClassInfo2) WBPCI2_Vtbl = 
    145144{
    146145    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shdocvw/events.c

    r6649 r6712  
    1 /* $Id: events.c,v 1.2 2001-09-05 13:39:11 bird Exp $ */
    21/*
    32 * Implementation of event-related interfaces for IE Web Browser control:
     
    8786 */
    8887
    89 static ICOM_VTABLE(IConnectionPointContainer) WBCPC_Vtbl =
     88static ICOM_VTABLE(IConnectionPointContainer) WBCPC_Vtbl = 
    9089{
    9190    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    182181 */
    183182
    184 static ICOM_VTABLE(IConnectionPoint) WBCP_Vtbl =
     183static ICOM_VTABLE(IConnectionPoint) WBCP_Vtbl = 
    185184{
    186185    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shdocvw/factory.c

    r6649 r6712  
    1 /* $Id: factory.c,v 1.2 2001-09-05 13:39:11 bird Exp $ */
    21/*
    32 * Implementation of class factory for IE Web Browser
     
    9695}
    9796
    98 static ICOM_VTABLE(IClassFactory) WBCF_Vtbl =
     97static ICOM_VTABLE(IClassFactory) WBCF_Vtbl = 
    9998{
    10099    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shdocvw/misc.c

    r6649 r6712  
    1 /* $Id: misc.c,v 1.2 2001-09-05 13:39:12 bird Exp $ */
    21/*
    32 * Implementation of miscellaneous interfaces for IE Web Browser control:
     
    6867 */
    6968
    70 static ICOM_VTABLE(IQuickActivate) WBQA_Vtbl =
     69static ICOM_VTABLE(IQuickActivate) WBQA_Vtbl = 
    7170{
    7271    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shdocvw/oleobject.c

    r6649 r6712  
    1 /* $Id: oleobject.c,v 1.2 2001-09-05 13:39:12 bird Exp $ */
    21/*
    32 * Implementation of IOleObject interfaces for IE Web Browser
     
    397396 */
    398397
    399 static ICOM_VTABLE(IOleObject) WBOOBJ_Vtbl =
     398static ICOM_VTABLE(IOleObject) WBOOBJ_Vtbl = 
    400399{
    401400    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    515514 */
    516515
    517 static ICOM_VTABLE(IOleInPlaceObject) WBOIPO_Vtbl =
     516static ICOM_VTABLE(IOleInPlaceObject) WBOIPO_Vtbl = 
    518517{
    519518    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    590589 */
    591590
    592 static ICOM_VTABLE(IOleControl) WBOC_Vtbl =
     591static ICOM_VTABLE(IOleControl) WBOC_Vtbl = 
    593592{
    594593    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shdocvw/persist.c

    r6649 r6712  
    1 /* $Id: persist.c,v 1.2 2001-09-05 13:39:12 bird Exp $ */
    21/*
    32 * Implementation of IPersist interfaces for IE Web Browser control
     
    8281 */
    8382
    84 static ICOM_VTABLE(IPersistStorage) WBPS_Vtbl =
     83static ICOM_VTABLE(IPersistStorage) WBPS_Vtbl = 
    8584{
    8685    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    171170 */
    172171
    173 static ICOM_VTABLE(IPersistStreamInit) WBPSI_Vtbl =
     172static ICOM_VTABLE(IPersistStreamInit) WBPSI_Vtbl = 
    174173{
    175174    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shdocvw/shdocvw_main.c

    r6649 r6712  
    1 /* $Id: shdocvw_main.c,v 1.2 2001-09-05 13:39:12 bird Exp $ */
    21/*
    32 * SHDOCVW - Internet Explorer Web Control
     
    6766
    6867/***********************************************************************
    69  *      DllRegisterServer (SHDOCVW.124)
     68 *              DllRegisterServer (SHDOCVW.124)
    7069 */
    7170HRESULT WINAPI SHDOCVW_DllRegisterServer()
     
    7675
    7776/***********************************************************************
    78  *      DllUnregisterServer (SHDOCVW.127)
     77 *              DllUnregisterServer (SHDOCVW.127)
    7978 */
    8079HRESULT WINAPI SHDOCVW_DllUnregisterServer()
  • trunk/src/shdocvw/webbrowser.c

    r6649 r6712  
    1 /* $Id: webbrowser.c,v 1.2 2001-09-05 13:39:12 bird Exp $ */
    21/*
    32 * Implementation of IWebBrowser interface for IE Web Browser control
     
    229228 */
    230229
    231 static ICOM_VTABLE(IWebBrowser) WB_Vtbl =
     230static ICOM_VTABLE(IWebBrowser) WB_Vtbl = 
    232231{
    233232    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/shlwapi/ordinal.c

    r6650 r6712  
    1 /* $Id: ordinal.c,v 1.6 2001-09-05 13:48:37 bird Exp $ */
    21/*
    32 * SHLWAPI ordinal functions
     
    6665#ifndef __WIN32OS2__
    6766/*************************************************************************
    68  *      SHLWAPI_1   [SHLWAPI.1]
     67 *      SHLWAPI_1       [SHLWAPI.1]
    6968 */
    7069DWORD WINAPI SHLWAPI_1 (
    71     LPSTR   lpURL,
    72     LPDWORD lpdwFlags)
     70        LPSTR   lpURL,
     71        LPDWORD lpdwFlags)
    7372{
    7473  if (lpURL == NULL)
    7574    return E_INVALIDARG;
    76 
     75 
    7776  if (lpdwFlags == NULL)
    7877    return E_INVALIDARG;
    79 
     78 
    8079  // verify flags
    8180  if (*lpdwFlags != 0x18)   // some unknown flag
    8281    return E_INVALIDARG;      // some unknown error condition
    83 
     82 
    8483  FIXME("(%p %s %p %s)\n",lpStr, debugstr_a(lpStr),x, debugstr_a(x));
    8584  return 0;
     
    8786
    8887/*************************************************************************
    89  *      SHLWAPI_2   [SHLWAPI.2]
     88 *      SHLWAPI_2       [SHLWAPI.2]
    9089 */
    9190DWORD WINAPI SHLWAPI_2 (LPCWSTR x,LPVOID y)
    9291{
    93     FIXME("(%s,%p)\n",debugstr_w(x),y);
    94     return 0;
    95 }
    96 
    97 /*************************************************************************
    98  *      SHLWAPI_16  [SHLWAPI.16]
     92        FIXME("(%s,%p)\n",debugstr_w(x),y);
     93        return 0;
     94}
     95
     96/*************************************************************************
     97 *      SHLWAPI_16      [SHLWAPI.16]
    9998 */
    10099HRESULT WINAPI SHLWAPI_16 (
    101     LPVOID w,
    102     LPVOID x,
    103     LPVOID y,
    104     LPWSTR z)
    105 {
    106     FIXME("(%p %p %p %p)stub\n",w,x,y,z);
    107     return 0xabba1252;
    108 }
    109 #endif
    110 
    111 /*************************************************************************
    112  *      SHLWAPI_23  [SHLWAPI.23]
     100        LPVOID w,
     101        LPVOID x,
     102        LPVOID y,
     103        LPWSTR z)
     104{
     105        FIXME("(%p %p %p %p)stub\n",w,x,y,z);
     106        return 0xabba1252;
     107}
     108#endif
     109
     110/*************************************************************************
     111 *      SHLWAPI_23      [SHLWAPI.23]
    113112 *
    114113 * NOTES
    115  *  converts a guid to a string
    116  *  returns strlen(str)
     114 *      converts a guid to a string
     115 *      returns strlen(str)
    117116 */
    118117DWORD WINAPI SHLWAPI_23 (
    119     REFGUID guid,   /* [in]  clsid */
    120     LPSTR str,  /* [out] buffer */
    121     INT cmax)   /* [in]  size of buffer */
    122 {
    123     char xguid[40];
     118        REFGUID guid,   /* [in]  clsid */
     119        LPSTR str,      /* [out] buffer */
     120        INT cmax)       /* [in]  size of buffer */
     121{
     122        char xguid[40];
    124123
    125124        sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
     
    127126                 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
    128127                 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
    129     TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
    130     if (strlen(xguid)>=cmax) return 0;
    131     strcpy(str,xguid);
    132     return strlen(xguid) + 1;
    133 }
    134 
    135 /*************************************************************************
    136  *      SHLWAPI_24  [SHLWAPI.24]
     128        TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
     129        if (strlen(xguid)>=cmax) return 0;
     130        strcpy(str,xguid);
     131        return strlen(xguid) + 1;
     132}
     133
     134/*************************************************************************
     135 *      SHLWAPI_24      [SHLWAPI.24]
    137136 *
    138137 * NOTES
    139  *  converts a guid to a string
    140  *  returns strlen(str)
     138 *      converts a guid to a string
     139 *      returns strlen(str)
    141140 */
    142141DWORD WINAPI SHLWAPI_24 (
    143     REFGUID guid,   /* [in]  clsid */
    144     LPWSTR str, /* [out] buffer */
    145     INT cmax)   /* [in]  size of buffer */
     142        REFGUID guid,   /* [in]  clsid */
     143        LPWSTR str,     /* [out] buffer */
     144        INT cmax)       /* [in]  size of buffer */
    146145{
    147146    char xguid[40];
     
    155154
    156155/*************************************************************************
    157  *      SHLWAPI_30  [SHLWAPI.30]
     156 *      SHLWAPI_30      [SHLWAPI.30]
    158157 *
    159158 * Seems to be an isspaceW.
     
    174173
    175174/*************************************************************************
    176  *      SHLWAPI_32  [SHLWAPI.32]
     175 *      SHLWAPI_32      [SHLWAPI.32]
    177176 */
    178177BOOL WINAPI SHLWAPI_32(LPCWSTR lpcChar)
     
    188187
    189188/*************************************************************************
    190  *      SHLWAPI_40  [SHLWAPI.40]
     189 *      SHLWAPI_40      [SHLWAPI.40]
    191190 *
    192191 * Get pointer to next Unicode character.
     
    198197
    199198/*************************************************************************
    200  *      SHLWAPI_74  [SHLWAPI.74]
     199 *      SHLWAPI_74      [SHLWAPI.74]
    201200 *
    202201 * Get the text from a given dialog item.
     
    213212}
    214213/*************************************************************************
    215  *      SHLWAPI_151 [SHLWAPI.151]
     214 *      SHLWAPI_151     [SHLWAPI.151]
    216215 */
    217216#ifdef __WIN32OS2__
     
    239238
    240239/*************************************************************************
    241  *      SHLWAPI_152 [SHLWAPI.152]
     240 *      SHLWAPI_152     [SHLWAPI.152]
    242241 */
    243242DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
     
    255254
    256255/*************************************************************************
    257  *      SHLWAPI_153 [SHLWAPI.153]
     256 *      SHLWAPI_153     [SHLWAPI.153]
    258257 */
    259258#ifdef __WIN32OS2__
     
    285284
    286285/*************************************************************************
    287  *      SHLWAPI_156 [SHLWAPI.156]
    288  *
    289  *  Case sensitive string compare. Does not SetLastError().
     286 *      SHLWAPI_156     [SHLWAPI.156]
     287 *
     288 *      Case sensitive string compare. Does not SetLastError().
    290289 */
    291290DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
     
    296295
    297296/*************************************************************************
    298  *      SHLWAPI_162 [SHLWAPI.162]
     297 *      SHLWAPI_162     [SHLWAPI.162]
    299298 *
    300299 * Ensure a multibyte character string doesn't end in a hanging lead byte.
     
    320319
    321320/*************************************************************************
    322  *      SHLWAPI_165 [SHLWAPI.165]
     321 *      SHLWAPI_165     [SHLWAPI.165]
    323322 *
    324323 * SetWindowLongA with mask.
     
    335334
    336335/*************************************************************************
    337  *      SHLWAPI_169 [SHLWAPI.169]
     336 *      SHLWAPI_169     [SHLWAPI.169]
    338337 */
    339338DWORD WINAPI SHLWAPI_169 (IUnknown * lpUnknown)
    340339{
    341     TRACE("(%p)\n",lpUnknown);
     340        TRACE("(%p)\n",lpUnknown);
    342341#if 0
    343     if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
    344     return IUnknown_Release(lpUnknown);
    345 #endif
    346     return 0;
    347 }
    348 
    349 /*************************************************************************
    350  *      SHLWAPI_170 [SHLWAPI.170]
     342        if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
     343        return IUnknown_Release(lpUnknown);
     344#endif
     345        return 0;
     346}
     347
     348/*************************************************************************
     349 *      SHLWAPI_170     [SHLWAPI.170]
    351350 *
    352351 * Skip URL '//' sequence.
     
    360359
    361360/*************************************************************************
    362  *      SHLWAPI_181 [SHLWAPI.181]
    363  *
    364  *  Enable or disable a menu item.
     361 *      SHLWAPI_181     [SHLWAPI.181]
     362 *
     363 *      Enable or disable a menu item.
    365364 */
    366365UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
     
    370369
    371370/*************************************************************************
    372  *      SHLWAPI_183 [SHLWAPI.183]
     371 *      SHLWAPI_183     [SHLWAPI.183]
    373372 *
    374373 * Register a window class if it isn't already.
     
    383382
    384383/*************************************************************************
    385  *      SHLWAPI_193 [SHLWAPI.193]
     384 *      SHLWAPI_193     [SHLWAPI.193]
    386385 */
    387386DWORD WINAPI SHLWAPI_193 ()
    388387{
    389     HDC hdc;
    390     DWORD ret;
    391 
    392     TRACE("()\n");
    393 
    394     hdc = GetDC(0);
    395     ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
    396     ReleaseDC(0, hdc);
    397     return ret;
    398 }
    399 
    400 /*************************************************************************
    401  *      SHLWAPI_215 [SHLWAPI.215]
     388        HDC hdc;
     389        DWORD ret;
     390
     391        TRACE("()\n");
     392
     393        hdc = GetDC(0);
     394        ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
     395        ReleaseDC(0, hdc);
     396        return ret;
     397}
     398
     399/*************************************************************************
     400 *      SHLWAPI_215     [SHLWAPI.215]
    402401 *
    403402 * NOTES
     
    405404 */
    406405LPWSTR WINAPI SHLWAPI_215 (
    407     LPWSTR lpStrSrc,
    408     LPVOID lpwStrDest,
    409     int len)
    410 {
    411     WARN("(%p %p %u)\n",lpStrSrc,lpwStrDest,len);
    412     return strncpyW(lpwStrDest, lpStrSrc, len);
    413 }
    414 
    415 /*************************************************************************
    416  *      SHLWAPI_218 [SHLWAPI.218]
     406        LPWSTR lpStrSrc,
     407        LPVOID lpwStrDest,
     408        int len)
     409{
     410        WARN("(%p %p %u)\n",lpStrSrc,lpwStrDest,len);
     411        return strncpyW(lpwStrDest, lpStrSrc, len);
     412}
     413
     414/*************************************************************************
     415 *      SHLWAPI_218     [SHLWAPI.218]
    417416 *
    418417 * WideCharToMultiByte with multi language support.
     
    508507
    509508/*************************************************************************
    510  *      SHLWAPI_217 [SHLWAPI.217]
     509 *      SHLWAPI_217     [SHLWAPI.217]
    511510 *
    512511 */
     
    518517#ifndef __WIN32OS2__
    519518/*************************************************************************
    520  *      SHLWAPI_219 [SHLWAPI.219]
     519 *      SHLWAPI_219     [SHLWAPI.219]
    521520 *
    522521 * NOTES
     
    524523 */
    525524HRESULT WINAPI SHLWAPI_219 (
    526     LPVOID w, /* [???] NOTE: returned by LocalAlloc, 0x450 bytes, iface */
    527     LPVOID x,
    528     REFIID riid,
    529     LPWSTR z) /* [???] NOTE: OUT: path */
    530 {
    531     FIXME("(%p %p %s %p)stub\n",w,x,debugstr_guid(riid),z);
    532     return 0xabba1252;
    533 }
    534 #endif
    535 
    536 /*************************************************************************
    537  *      SHLWAPI_222 [SHLWAPI.222]
     525        LPVOID w, /* [???] NOTE: returned by LocalAlloc, 0x450 bytes, iface */
     526        LPVOID x,
     527        REFIID riid,
     528        LPWSTR z) /* [???] NOTE: OUT: path */
     529{
     530        FIXME("(%p %p %s %p)stub\n",w,x,debugstr_guid(riid),z);
     531        return 0xabba1252;
     532}
     533#endif
     534
     535/*************************************************************************
     536 *      SHLWAPI_222     [SHLWAPI.222]
    538537 *
    539538 * NOTES
     
    542541HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
    543542{
    544     char lpstrName[80];
     543        char lpstrName[80];
    545544
    546545        sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
     
    548547                 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
    549548                 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
    550     FIXME("(%s) stub\n", lpstrName);
    551     return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
    552 }
    553 
    554 /*************************************************************************
    555  *      SHLWAPI_223 [SHLWAPI.223]
     549        FIXME("(%s) stub\n", lpstrName);
     550        return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
     551}
     552
     553/*************************************************************************
     554 *      SHLWAPI_223     [SHLWAPI.223]
    556555 *
    557556 * NOTES
     
    560559DWORD WINAPI SHLWAPI_223 (HANDLE handle)
    561560{
    562     DWORD oldCount;
    563 
    564     FIXME("(0x%08x) stub\n",handle);
    565 
    566     ReleaseSemaphore( handle, 1, &oldCount);    /* +1 */
    567     WaitForSingleObject( handle, 0 );       /* -1 */
    568     return oldCount;
    569 }
    570 
    571 /*************************************************************************
    572  *      SHLWAPI_237 [SHLWAPI.237]
     561        DWORD oldCount;
     562
     563        FIXME("(0x%08x) stub\n",handle);
     564
     565        ReleaseSemaphore( handle, 1, &oldCount);        /* +1 */
     566        WaitForSingleObject( handle, 0 );               /* -1 */
     567        return oldCount;
     568}
     569
     570/*************************************************************************
     571 *      SHLWAPI_237     [SHLWAPI.237]
    573572 *
    574573 * Unicode version of SHLWAPI_183.
     
    576575DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
    577576{
    578     WNDCLASSW WndClass;
    579 
    580     TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
    581 
    582     if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
    583         return TRUE;
    584     return RegisterClassW(lpWndClass);
    585 }
    586 
    587 /*************************************************************************
    588  *      SHLWAPI_240 [SHLWAPI.240]
    589  *
    590  *  Calls ASCII or Unicode WindowProc for the given window.
     577        WNDCLASSW WndClass;
     578
     579        TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
     580
     581        if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
     582                return TRUE;
     583        return RegisterClassW(lpWndClass);
     584}
     585
     586/*************************************************************************
     587 *      SHLWAPI_240     [SHLWAPI.240]
     588 *
     589 *      Calls ASCII or Unicode WindowProc for the given window.
    591590 */
    592591LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
    593592{
    594     if (IsWindowUnicode(hWnd))
    595         return DefWindowProcW(hWnd, uMessage, wParam, lParam);
    596     return DefWindowProcA(hWnd, uMessage, wParam, lParam);
     593        if (IsWindowUnicode(hWnd))
     594                return DefWindowProcW(hWnd, uMessage, wParam, lParam);
     595        return DefWindowProcA(hWnd, uMessage, wParam, lParam);
    597596}
    598597#ifndef __WIN32OS2__
    599598/*************************************************************************
    600  *      SHLWAPI_241 [SHLWAPI.241]
     599 *      SHLWAPI_241     [SHLWAPI.241]
    601600 *
    602601 */
    603602DWORD WINAPI SHLWAPI_241 ()
    604603{
    605     FIXME("()stub\n");
    606     return 0xabba1243;
    607 }
    608 
    609 /*************************************************************************
    610  *      SHLWAPI_266 [SHLWAPI.266]
     604        FIXME("()stub\n");
     605        return 0xabba1243;
     606}
     607
     608/*************************************************************************
     609 *      SHLWAPI_266     [SHLWAPI.266]
    611610 */
    612611DWORD WINAPI SHLWAPI_266 (
    613     LPVOID w,
    614     LPVOID x,
    615     LPVOID y,
    616     LPVOID z)
    617 {
    618     FIXME("(%p %p %p %p)stub\n",w,x,y,z);
    619     return 0xabba1248;
    620 }
    621 
    622 /*************************************************************************
    623  *      SHLWAPI_267 [SHLWAPI.267]
     612        LPVOID w,
     613        LPVOID x,
     614        LPVOID y,
     615        LPVOID z)
     616{
     617        FIXME("(%p %p %p %p)stub\n",w,x,y,z);
     618        return 0xabba1248;
     619}
     620
     621/*************************************************************************
     622 *      SHLWAPI_267     [SHLWAPI.267]
    624623 */
    625624HRESULT WINAPI SHLWAPI_267 (
    626     LPVOID w, /* [???] NOTE: same as 1th parameter of SHLWAPI_219 */
    627     LPVOID x, /* [???] NOTE: same as 2nd parameter of SHLWAPI_219 */
    628     LPVOID y,
    629     LPVOID z)
    630 {
    631     FIXME("(%p %p %p %p)stub\n",w,x,y,z);
    632     *((LPDWORD)z) = 0xabba1200;
    633     return 0xabba1254;
    634 }
    635 
    636 /*************************************************************************
    637  *      SHLWAPI_268 [SHLWAPI.268]
     625        LPVOID w, /* [???] NOTE: same as 1th parameter of SHLWAPI_219 */
     626        LPVOID x, /* [???] NOTE: same as 2nd parameter of SHLWAPI_219 */
     627        LPVOID y,
     628        LPVOID z)
     629{
     630        FIXME("(%p %p %p %p)stub\n",w,x,y,z);
     631        *((LPDWORD)z) = 0xabba1200;
     632        return 0xabba1254;
     633}
     634
     635/*************************************************************************
     636 *      SHLWAPI_268     [SHLWAPI.268]
    638637 */
    639638DWORD WINAPI SHLWAPI_268 (
    640     LPVOID w,
    641     LPVOID x)
    642 {
    643     FIXME("(%p %p)\n",w,x);
    644     return 0xabba1251; /* 0 = failure */
    645 }
    646 
    647 /*************************************************************************
    648  *      SHLWAPI_276 [SHLWAPI.276]
     639        LPVOID w,
     640        LPVOID x)
     641{
     642        FIXME("(%p %p)\n",w,x);
     643        return 0xabba1251; /* 0 = failure */
     644}
     645
     646/*************************************************************************
     647 *      SHLWAPI_276     [SHLWAPI.276]
    649648 *
    650649 */
    651650DWORD WINAPI SHLWAPI_276 ()
    652651{
    653     FIXME("()stub\n");
    654     return 0xabba1244;
    655 }
    656 #endif
    657 /*************************************************************************
    658  *      SHLWAPI_278 [SHLWAPI.278]
     652        FIXME("()stub\n");
     653        return 0xabba1244;
     654}
     655#endif
     656/*************************************************************************
     657 *      SHLWAPI_278     [SHLWAPI.278]
    659658 *
    660659 */
    661660DWORD WINAPI SHLWAPI_278 (
    662     LONG wndProc,
    663     HWND hWndParent,
    664     DWORD dwExStyle,
    665     DWORD dwStyle,
    666     HMENU hMenu,
    667     LONG z)
    668 {
    669     WNDCLASSA wndclass;
    670     HWND hwnd;
    671     HCURSOR hCursor;
    672     char * clsname = "WorkerA";
    673 
    674     FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx)stub\n",
    675       wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
    676 
    677     hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
    678 
    679     if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
    680     {
    681       RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
    682       wndclass.lpfnWndProc = DefWindowProcW;
    683       wndclass.cbWndExtra = 4;
    684       wndclass.hInstance = shlwapi_hInstance;
    685       wndclass.hCursor = hCursor;
    686       wndclass.hbrBackground = COLOR_BTNSHADOW;
    687       wndclass.lpszMenuName = NULL;
    688       wndclass.lpszClassName = clsname;
    689       RegisterClassA (&wndclass);
    690     }
    691     hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
    692         hMenu,shlwapi_hInstance,0);
    693     SetWindowLongA(hwnd, 0, z);
    694     SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
    695     return hwnd;
    696 }
    697 
    698 /*************************************************************************
    699  *      SHLWAPI_289 [SHLWAPI.289]
     661        LONG wndProc,
     662        HWND hWndParent,
     663        DWORD dwExStyle,
     664        DWORD dwStyle,
     665        HMENU hMenu,
     666        LONG z)
     667{
     668        WNDCLASSA wndclass;
     669        HWND hwnd;
     670        HCURSOR hCursor;
     671        char * clsname = "WorkerA";
     672
     673        FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx)stub\n",
     674          wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
     675
     676        hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
     677
     678        if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
     679        {
     680          RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
     681          wndclass.lpfnWndProc = DefWindowProcW;
     682          wndclass.cbWndExtra = 4;
     683          wndclass.hInstance = shlwapi_hInstance;
     684          wndclass.hCursor = hCursor;
     685          wndclass.hbrBackground = COLOR_BTNSHADOW;
     686          wndclass.lpszMenuName = NULL;
     687          wndclass.lpszClassName = clsname;
     688          RegisterClassA (&wndclass);
     689        }
     690        hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
     691                hMenu,shlwapi_hInstance,0);
     692        SetWindowLongA(hwnd, 0, z);
     693        SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
     694        return hwnd;
     695}
     696
     697/*************************************************************************
     698 *      SHLWAPI_289     [SHLWAPI.289]
    700699 *
    701700 * Late bound call to winmm.PlaySoundW
     
    710709
    711710/*************************************************************************
    712  *      SHLWAPI_313 [SHLWAPI.313]
     711 *      SHLWAPI_313     [SHLWAPI.313]
    713712 *
    714713 * Late bound call to shell32.SHGetFileInfoW
     
    724723
    725724/*************************************************************************
    726  *      SHLWAPI_318 [SHLWAPI.318]
     725 *      SHLWAPI_318     [SHLWAPI.318]
    727726 *
    728727 * Late bound call to shell32.DragQueryFileW
     
    737736
    738737/*************************************************************************
    739  *      SHLWAPI_333 [SHLWAPI.333]
     738 *      SHLWAPI_333     [SHLWAPI.333]
    740739 *
    741740 * Late bound call to shell32.SHBrowseForFolderW
     
    750749
    751750/*************************************************************************
    752  *      SHLWAPI_334 [SHLWAPI.334]
     751 *      SHLWAPI_334     [SHLWAPI.334]
    753752 *
    754753 * Late bound call to shell32.SHGetPathFromIDListW
     
    763762
    764763/*************************************************************************
    765  *      SHLWAPI_335 [SHLWAPI.335]
     764 *      SHLWAPI_335     [SHLWAPI.335]
    766765 *
    767766 * Late bound call to shell32.ShellExecuteExW
     
    776775
    777776/*************************************************************************
    778  *      SHLWAPI_336 [SHLWAPI.336]
     777 *      SHLWAPI_336     [SHLWAPI.336]
    779778 *
    780779 * Late bound call to shell32.SHFileOperationW.
     
    789788
    790789/*************************************************************************
    791  *      SHLWAPI_337 [SHLWAPI.337]
     790 *      SHLWAPI_337     [SHLWAPI.337]
    792791 *
    793792 * Late bound call to shell32.ExtractIconExW.
     
    804803//Bugbug: is forwarder for InterlockedCompareExchange
    805804/*************************************************************************
    806  *      SHLWAPI_342 [SHLWAPI.342]
     805 *      SHLWAPI_342     [SHLWAPI.342]
    807806 *
    808807 */
    809808DWORD WINAPI SHLWAPI_342 (
    810     LPVOID w,
    811     LPVOID x,
    812     LPVOID y,
    813     LPVOID z)
    814 {
    815     FIXME("(%p %p %p %p)stub\n",w,x,y,z);
    816     return 0xabba1249;
    817 }
    818 #endif
    819 /*************************************************************************
    820  *      SHLWAPI_346 [SHLWAPI.346]
     809        LPVOID w,
     810        LPVOID x,
     811        LPVOID y,
     812        LPVOID z)
     813{
     814        FIXME("(%p %p %p %p)stub\n",w,x,y,z);
     815        return 0xabba1249;
     816}
     817#endif
     818/*************************************************************************
     819 *      SHLWAPI_346     [SHLWAPI.346]
    821820 */
    822821DWORD WINAPI SHLWAPI_346 (
    823     LPCWSTR src,
    824     LPWSTR dest,
    825     int len)
    826 {
    827     FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
    828     lstrcpynW(dest, src, len);
    829     return lstrlenW(dest)+1;
    830 }
    831 
    832 /*************************************************************************
    833  *      SHLWAPI_357 [SHLWAPI.357]
     822        LPCWSTR src,
     823        LPWSTR dest,
     824        int len)
     825{
     826        FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
     827        lstrcpynW(dest, src, len);
     828        return lstrlenW(dest)+1;
     829}
     830
     831/*************************************************************************
     832 *      SHLWAPI_357     [SHLWAPI.357]
    834833 *
    835834 * Late bound call to shell32.SHGetNewLinkInfoW
     
    845844
    846845/*************************************************************************
    847  *      SHLWAPI_358 [SHLWAPI.358]
     846 *      SHLWAPI_358     [SHLWAPI.358]
    848847 *
    849848 * Late bound call to shell32.SHDefExtractIconW
     
    860859
    861860/*************************************************************************
    862  *      SHLWAPI_364 [SHLWAPI.364]
     861 *      SHLWAPI_364     [SHLWAPI.364]
    863862 *
    864863 * Wrapper for lstrcpynA with src and dst swapped.
     
    871870
    872871/*************************************************************************
    873  *      SHLWAPI_370 [SHLWAPI.370]
     872 *      SHLWAPI_370     [SHLWAPI.370]
    874873 *
    875874 * Late bound call to shell32.ExtractIconW
     
    885884
    886885/*************************************************************************
    887  *      SHLWAPI_376 [SHLWAPI.376]
     886 *      SHLWAPI_376     [SHLWAPI.376]
    888887 */
    889888DWORD WINAPI SHLWAPI_376 (LONG x)
    890889{
    891     FIXME("(0x%08lx)stub\n", x );
     890        FIXME("(0x%08lx)stub\n", x );
    892891  /* FIXME: This should be a forward in the .spec file to the win2k function
    893892   * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
     
    897896#ifndef __WIN32OS2__
    898897/*************************************************************************
    899  *      SHLWAPI_377 [SHLWAPI.377]
     898 *      SHLWAPI_377     [SHLWAPI.377]
    900899 */
    901900DWORD WINAPI SHLWAPI_377 (LPVOID x, LPVOID y, LPVOID z)
    902901{
    903     FIXME("(%p %p %p)stub\n", x,y,z);
    904     return 0xabba1246;
    905 }
    906 #endif
    907 /*************************************************************************
    908  *      SHLWAPI_378 [SHLWAPI.378]
     902        FIXME("(%p %p %p)stub\n", x,y,z);
     903        return 0xabba1246;
     904}
     905#endif
     906/*************************************************************************
     907 *      SHLWAPI_378     [SHLWAPI.378]
    909908 */
    910909DWORD WINAPI SHLWAPI_378 (
    911     LPSTR x,
    912     LPVOID y, /* [???] 0x50000000 */
    913     LPVOID z) /* [???] 4 */
    914 {
    915     FIXME("(%s %p %p)stub\n", x,y,z);
    916     return LoadLibraryA(x);
    917 }
    918 
    919 /*************************************************************************
    920  *      SHLWAPI_389 [SHLWAPI.389]
     910        LPSTR x,
     911        LPVOID y, /* [???] 0x50000000 */
     912        LPVOID z) /* [???] 4 */
     913{
     914        FIXME("(%s %p %p)stub\n", x,y,z);
     915        return LoadLibraryA(x);
     916}
     917
     918/*************************************************************************
     919 *      SHLWAPI_389     [SHLWAPI.389]
    921920 *
    922921 * Late bound call to comdlg32.GetSaveFileNameW
     
    931930
    932931/*************************************************************************
    933  *      SHLWAPI_390 [SHLWAPI.390]
     932 *      SHLWAPI_390     [SHLWAPI.390]
    934933 *
    935934 * Late bound call to mpr.WNetRestoreConnectionW
     
    945944
    946945/*************************************************************************
    947  *      SHLWAPI_391 [SHLWAPI.391]
     946 *      SHLWAPI_391     [SHLWAPI.391]
    948947 *
    949948 * Late bound call to mpr.WNetGetLastErrorW
     
    960959
    961960/*************************************************************************
    962  *      SHLWAPI_401 [SHLWAPI.401]
     961 *      SHLWAPI_401     [SHLWAPI.401]
    963962 *
    964963 * Late bound call to comdlg32.PageSetupDlgW
     
    973972
    974973/*************************************************************************
    975  *      SHLWAPI_402 [SHLWAPI.402]
     974 *      SHLWAPI_402     [SHLWAPI.402]
    976975 *
    977976 * Late bound call to comdlg32.PrintDlgW
     
    986985
    987986/*************************************************************************
    988  *      SHLWAPI_403 [SHLWAPI.403]
     987 *      SHLWAPI_403     [SHLWAPI.403]
    989988 *
    990989 * Late bound call to comdlg32.GetOpenFileNameW
     
    10171016
    10181017/*************************************************************************
    1019  *      ColorHLSToRGB   [SHLWAPI.404]
     1018 *      ColorHLSToRGB   [SHLWAPI.404]
    10201019 *
    10211020 * Convert from HLS color space into an RGB COLORREF.
     
    10511050
    10521051/*************************************************************************
    1053  *      SHLWAPI_431 [SHLWAPI.431]
     1052 *      SHLWAPI_431     [SHLWAPI.431]
    10541053 */
    10551054DWORD WINAPI SHLWAPI_431 (DWORD x)
    10561055{
    1057     FIXME("(0x%08lx)stub\n", x);
    1058     return 0xabba1247;
     1056        FIXME("(0x%08lx)stub\n", x);
     1057        return 0xabba1247;
    10591058}
    10601059
    10611060#ifndef __WIN32OS2__
    10621061/*************************************************************************
    1063  *      SHLWAPI_437 [SHLWAPI.437]
     1062 *      SHLWAPI_437     [SHLWAPI.437]
    10641063 *
    10651064 * NOTES
     
    10741073DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
    10751074{
    1076     FIXME("(0x%08lx)stub\n", functionToCall);
    1077     return 0xabba1247;
    1078 }
    1079 #endif
    1080 
    1081 /*************************************************************************
    1082  *      SHCreateShellPalette    [SHLWAPI.@]
     1075        FIXME("(0x%08lx)stub\n", functionToCall);
     1076        return 0xabba1247;
     1077}
     1078#endif
     1079
     1080/*************************************************************************
     1081 *      SHCreateShellPalette    [SHLWAPI.@]
    10831082 */
    10841083HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
    10851084{
    1086     FIXME("stub\n");
    1087     return CreateHalftonePalette(hdc);
    1088 }
    1089 
    1090 /*************************************************************************
    1091  *  SHGetInverseCMAP
     1085        FIXME("stub\n");
     1086        return CreateHalftonePalette(hdc);
     1087}
     1088
     1089/*************************************************************************
     1090 *      SHGetInverseCMAP
    10921091 */
    10931092DWORD WINAPI SHGetInverseCMAP (LPVOID x, DWORD why)
    10941093{
    1095     FIXME("(%p, %#lx)stub\n", x, why);
    1096     return 0;
     1094        FIXME("(%p, %#lx)stub\n", x, why);
     1095        return 0;
    10971096}
    10981097#ifndef __WIN32OS2__
    10991098/*************************************************************************
    1100  *      SHIsLowMemoryMachine    [SHLWAPI.@]
     1099 *      SHIsLowMemoryMachine    [SHLWAPI.@]
    11011100 */
    11021101DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
    11031102{
    1104     FIXME("0x%08lx\n", x);
    1105     return 0;
    1106 }
    1107 #endif
    1108 
    1109 /*************************************************************************
    1110  *      GetMenuPosFromID    [SHLWAPI.@]
     1103        FIXME("0x%08lx\n", x);
     1104        return 0;
     1105}
     1106#endif
     1107
     1108/*************************************************************************
     1109 *      GetMenuPosFromID        [SHLWAPI.@]
    11111110 */
    11121111INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
     
    11261125
    11271126/*************************************************************************
    1128  *      _SHGetInstanceExplorer  [SHLWAPI.@]
     1127 *      _SHGetInstanceExplorer  [SHLWAPI.@]
    11291128 *
    11301129 * Late bound call to shell32.SHGetInstanceExplorer.
  • trunk/src/shlwapi/path.c

    r6650 r6712  
    1 /* $Id: path.c,v 1.14 2001-09-05 13:48:38 bird Exp $ */
    21/*
    32 * Path Functions
     
    4342#define isSlash(x) ((x)=='\\' || (x)=='/')
    4443/*
    45     ########## Combining and Constructing paths ##########
     44        ########## Combining and Constructing paths ##########
    4645*/
    4746
    4847/*************************************************************************
    49  * PathAppendA      [SHLWAPI.@]
    50  *
     48 * PathAppendA          [SHLWAPI.@]
     49 * 
    5150 * NOTES
    5251 *  concat path lpszPath2 onto lpszPath1
     
    5655 */
    5756BOOL WINAPI PathAppendA(
    58     LPSTR lpszPath1,
    59     LPCSTR lpszPath2)
    60 {
    61     TRACE("%s %s\n",lpszPath1, lpszPath2);
    62     while (lpszPath2[0]=='\\') lpszPath2++;
    63     PathCombineA(lpszPath1,lpszPath1,lpszPath2);
    64     return TRUE;
    65 }
    66 
    67 /*************************************************************************
    68  * PathAppendW      [SHLWAPI.@]
     57        LPSTR lpszPath1,
     58        LPCSTR lpszPath2)
     59{
     60        TRACE("%s %s\n",lpszPath1, lpszPath2);
     61        while (lpszPath2[0]=='\\') lpszPath2++;
     62        PathCombineA(lpszPath1,lpszPath1,lpszPath2);
     63        return TRUE;
     64}
     65
     66/*************************************************************************
     67 * PathAppendW          [SHLWAPI.@]
    6968 */
    7069BOOL WINAPI PathAppendW(
    71     LPWSTR lpszPath1,
    72     LPCWSTR lpszPath2)
    73 {
    74     TRACE("%s %s\n",debugstr_w(lpszPath1), debugstr_w(lpszPath2));
    75     while (lpszPath2[0]=='\\') lpszPath2++;
    76     PathCombineW(lpszPath1,lpszPath1,lpszPath2);
    77     return TRUE;
    78 }
    79 
    80 /*************************************************************************
    81  * PathCombineA     [SHLWAPI.@]
    82  *
     70        LPWSTR lpszPath1,
     71        LPCWSTR lpszPath2)
     72{
     73        TRACE("%s %s\n",debugstr_w(lpszPath1), debugstr_w(lpszPath2));
     74        while (lpszPath2[0]=='\\') lpszPath2++;
     75        PathCombineW(lpszPath1,lpszPath1,lpszPath2);
     76        return TRUE;
     77}
     78
     79/*************************************************************************
     80 * PathCombineA         [SHLWAPI.@]
     81 * 
    8382 * NOTES
    8483 *  if lpszFile='.' skip it
     
    8988 */
    9089LPSTR WINAPI PathCombineA(
    91     LPSTR szDest,
    92     LPCSTR lpszDir,
    93     LPCSTR lpszFile)
    94 {
    95     char sTemp[MAX_PATH];
    96     TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, lpszDir, lpszFile, lpszFile);
    97 
    98 
    99     if (!lpszFile || !lpszFile[0] || (lpszFile[0]=='.' && !lpszFile[1]) )
    100     {
    101       strcpy(szDest,lpszDir);
    102       return szDest;
    103     }
    104 
    105     /*  if lpszFile is a complete path don't care about lpszDir */
    106     if (PathGetDriveNumberA(lpszFile) != -1)
    107     {
    108       strcpy(szDest,lpszFile);
    109     }
    110     else if (lpszFile[0] == '\\' )
    111     {
    112       strcpy(sTemp,lpszDir);
    113       PathStripToRootA(sTemp);
    114       strcat(sTemp,lpszFile);
    115       strcpy(szDest,sTemp);
    116     }
    117     else
    118     {
    119       strcpy(sTemp,lpszDir);
    120       PathAddBackslashA(sTemp);
    121       strcat(sTemp,lpszFile);
    122       strcpy(szDest,sTemp);
    123     }
    124     return szDest;
    125 }
    126 
    127 /*************************************************************************
    128  * PathCombineW      [SHLWAPI.@]
     90        LPSTR szDest,
     91        LPCSTR lpszDir,
     92        LPCSTR lpszFile)
     93{
     94        char sTemp[MAX_PATH];
     95        TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, lpszDir, lpszFile, lpszFile);
     96       
     97       
     98        if (!lpszFile || !lpszFile[0] || (lpszFile[0]=='.' && !lpszFile[1]) )
     99        {
     100          strcpy(szDest,lpszDir);
     101          return szDest;
     102        }
     103
     104        /*  if lpszFile is a complete path don't care about lpszDir */
     105        if (PathGetDriveNumberA(lpszFile) != -1)
     106        {
     107          strcpy(szDest,lpszFile);
     108        }
     109        else if (lpszFile[0] == '\\' )
     110        {
     111          strcpy(sTemp,lpszDir);
     112          PathStripToRootA(sTemp);
     113          strcat(sTemp,lpszFile);
     114          strcpy(szDest,sTemp);
     115        }
     116        else
     117        {
     118          strcpy(sTemp,lpszDir);
     119          PathAddBackslashA(sTemp);
     120          strcat(sTemp,lpszFile);
     121          strcpy(szDest,sTemp);
     122        }
     123        return szDest;
     124}
     125
     126/*************************************************************************
     127 * PathCombineW          [SHLWAPI.@]
    129128 */
    130129LPWSTR WINAPI PathCombineW(
    131     LPWSTR szDest,
    132     LPCWSTR lpszDir,
    133     LPCWSTR lpszFile)
    134 {
    135     WCHAR sTemp[MAX_PATH];
    136     TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, debugstr_w(lpszDir),
    137             lpszFile, debugstr_w(lpszFile));
    138 
    139 
    140     if (!lpszFile || !lpszFile[0] || (lpszFile[0]==(WCHAR)'.' && !lpszFile[1]) )
    141     {
     130        LPWSTR szDest,
     131        LPCWSTR lpszDir,
     132        LPCWSTR lpszFile)
     133{
     134        WCHAR sTemp[MAX_PATH];
     135        TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, debugstr_w(lpszDir),
     136                        lpszFile, debugstr_w(lpszFile));
     137       
     138       
     139        if (!lpszFile || !lpszFile[0] || (lpszFile[0]==(WCHAR)'.' && !lpszFile[1]) )
     140        {
    142141          strcpyW(szDest,lpszDir);
    143       return szDest;
    144     }
    145 
    146     /*  if lpszFile is a complete path don't care about lpszDir */
    147     if (PathGetDriveNumberW(lpszFile) != -1)
    148     {
     142          return szDest;
     143        }
     144
     145        /*  if lpszFile is a complete path don't care about lpszDir */
     146        if (PathGetDriveNumberW(lpszFile) != -1)
     147        {
    149148            strcpyW(szDest,lpszFile);
    150     }
    151     else if (lpszFile[0] == (WCHAR)'\\' )
    152     {
    153       strcpyW(sTemp,lpszDir);
    154       PathStripToRootW(sTemp);
    155       strcatW(sTemp,lpszFile);
    156       strcpyW(szDest,sTemp);
    157     }
    158     else
    159     {
    160       strcpyW(sTemp,lpszDir);
    161       PathAddBackslashW(sTemp);
    162       strcatW(sTemp,lpszFile);
    163       strcpyW(szDest,sTemp);
    164     }
    165     return szDest;
    166 }
    167 
    168 /*************************************************************************
    169  * PathAddBackslashA    [SHLWAPI.@]
     149        }
     150        else if (lpszFile[0] == (WCHAR)'\\' )
     151        {
     152          strcpyW(sTemp,lpszDir);
     153          PathStripToRootW(sTemp);
     154          strcatW(sTemp,lpszFile);
     155          strcpyW(szDest,sTemp);
     156        }
     157        else
     158        {
     159          strcpyW(sTemp,lpszDir);
     160          PathAddBackslashW(sTemp);
     161          strcatW(sTemp,lpszFile);
     162          strcpyW(szDest,sTemp);
     163        }
     164        return szDest;
     165}
     166
     167/*************************************************************************
     168 * PathAddBackslashA    [SHLWAPI.@]
    170169 *
    171170 * NOTES
     
    174173LPSTR WINAPI PathAddBackslashA(LPSTR lpszPath)
    175174{
    176     int len;
    177     TRACE("%p->%s\n",lpszPath,lpszPath);
    178 
    179     len = strlen(lpszPath);
    180     if (len && lpszPath[len-1]!='\\')
    181     {
    182       lpszPath[len]  = '\\';
    183       lpszPath[len+1]= 0x00;
    184       return lpszPath+len+1;
    185     }
    186     return lpszPath+len;
    187 }
    188 
    189 /*************************************************************************
    190  * PathAddBackslashW    [SHLWAPI.@]
     175        int len;
     176        TRACE("%p->%s\n",lpszPath,lpszPath);
     177
     178        len = strlen(lpszPath);
     179        if (len && lpszPath[len-1]!='\\')
     180        {
     181          lpszPath[len]  = '\\';
     182          lpszPath[len+1]= 0x00;
     183          return lpszPath+len+1;
     184        }
     185        return lpszPath+len;
     186}
     187
     188/*************************************************************************
     189 * PathAddBackslashW    [SHLWAPI.@]
    191190 */
    192191LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
    193192{
    194     int len;
    195     TRACE("%p->%s\n",lpszPath,debugstr_w(lpszPath));
    196 
    197     len = strlenW(lpszPath);
    198     if (len && lpszPath[len-1]!=(WCHAR)'\\')
    199     {
    200       lpszPath[len]  = (WCHAR)'\\';
    201       lpszPath[len+1]= 0x00;
    202       return lpszPath+len+1;
    203     }
    204     return lpszPath+len;
    205 }
    206 
    207 /*************************************************************************
    208  * PathBuildRootA       [SHLWAPI.@]
    209  */
    210 LPSTR WINAPI PathBuildRootA(LPSTR lpszPath, int drive)
    211 {
    212     TRACE("%p %i\n",lpszPath, drive);
    213 
    214     strcpy(lpszPath,"A:\\");
    215     lpszPath[0]+=drive;
    216     return lpszPath;
    217 }
    218 
    219 /*************************************************************************
    220  * PathBuildRootW       [SHLWAPI.@]
    221  */
    222 LPWSTR WINAPI PathBuildRootW(LPWSTR lpszPath, int drive)
    223 {
    224     lpszPath[0] = 'A' + drive;
    225     lpszPath[1] = ':';
    226     lpszPath[2] = '\\';
    227     lpszPath[3] = 0;
    228     TRACE("%p %i\n",debugstr_w(lpszPath), drive);
    229     return lpszPath;
     193        int len;
     194        TRACE("%p->%s\n",lpszPath,debugstr_w(lpszPath));
     195
     196        len = strlenW(lpszPath);
     197        if (len && lpszPath[len-1]!=(WCHAR)'\\')
     198        {
     199          lpszPath[len]  = (WCHAR)'\\';
     200          lpszPath[len+1]= 0x00;
     201          return lpszPath+len+1;
     202        }
     203        return lpszPath+len;
     204}
     205
     206/*************************************************************************
     207 * PathBuildRootA               [SHLWAPI.@]
     208 */
     209LPSTR WINAPI PathBuildRootA(LPSTR lpszPath, int drive) 
     210{
     211        TRACE("%p %i\n",lpszPath, drive);
     212
     213        strcpy(lpszPath,"A:\\");
     214        lpszPath[0]+=drive;
     215        return lpszPath;
     216}
     217
     218/*************************************************************************
     219 * PathBuildRootW               [SHLWAPI.@]
     220 */
     221LPWSTR WINAPI PathBuildRootW(LPWSTR lpszPath, int drive) 
     222{
     223        lpszPath[0] = 'A' + drive;
     224        lpszPath[1] = ':';
     225        lpszPath[2] = '\\';
     226        lpszPath[3] = 0;
     227        TRACE("%p %i\n",debugstr_w(lpszPath), drive);
     228        return lpszPath;
    230229}
    231230
    232231/*
    233     Extracting Component Parts
     232        Extracting Component Parts
    234233*/
    235234
    236235/*************************************************************************
    237  * PathFindFileNameA    [SHLWAPI.@]
     236 * PathFindFileNameA    [SHLWAPI.@]
    238237 */
    239238LPSTR WINAPI PathFindFileNameA(LPCSTR lpszPath)
    240239{
    241     LPCSTR lastSlash = lpszPath;
    242 
    243     TRACE("%s\n",lpszPath);
    244     while (*lpszPath)
    245     {
    246       if ( isSlash(lpszPath[0]) && lpszPath[1])
    247           lastSlash = lpszPath+1;
    248       lpszPath = CharNextA(lpszPath);
    249     }
    250     return (LPSTR)lastSlash;
    251 
    252 }
    253 
    254 /*************************************************************************
    255  * PathFindFileNameW    [SHLWAPI.@]
     240        LPCSTR lastSlash = lpszPath;
     241
     242        TRACE("%s\n",lpszPath);
     243        while (*lpszPath)
     244        {
     245          if ( isSlash(lpszPath[0]) && lpszPath[1])
     246              lastSlash = lpszPath+1;
     247          lpszPath = CharNextA(lpszPath);
     248        }
     249        return (LPSTR)lastSlash;
     250
     251}
     252
     253/*************************************************************************
     254 * PathFindFileNameW    [SHLWAPI.@]
    256255 */
    257256LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
    258257{
    259     LPCWSTR wslash;
    260     wslash = lpszPath;
    261 
    262     TRACE("%s\n",debugstr_w(wslash));
    263     while (lpszPath[0])
    264     {
    265       if (((lpszPath[0]=='\\') || (lpszPath[0]==':')) && lpszPath[1] && lpszPath[1]!='\\')
    266         wslash = lpszPath+1;
    267       lpszPath = CharNextW(lpszPath);
    268     }
    269     return (LPWSTR)wslash;
    270 }
    271 
    272 /*************************************************************************
    273  * PathFindExtensionA   [SHLWAPI.@]
     258        LPCWSTR wslash;
     259        wslash = lpszPath;
     260
     261        TRACE("%s\n",debugstr_w(wslash));
     262        while (lpszPath[0])
     263        {
     264          if (((lpszPath[0]=='\\') || (lpszPath[0]==':')) && lpszPath[1] && lpszPath[1]!='\\')
     265            wslash = lpszPath+1;
     266          lpszPath = CharNextW(lpszPath);
     267        }
     268        return (LPWSTR)wslash; 
     269}
     270
     271/*************************************************************************
     272 * PathFindExtensionA   [SHLWAPI.@]
    274273 *
    275274 * NOTES
     
    277276 */
    278277
    279 LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
    280 {
    281     LPCSTR   lastpoint = NULL;
    282 
    283     TRACE("%p %s\n",lpszPath,lpszPath);
    284 
    285     while (*lpszPath)
    286     {
    287       if (*lpszPath=='\\'||*lpszPath==' ')
    288         lastpoint=NULL;
    289       if (*lpszPath=='.')
    290         lastpoint=lpszPath;
    291       lpszPath = CharNextA(lpszPath);
    292     }
    293     return (LPSTR)(lastpoint?lastpoint:lpszPath);
    294 }
    295 
    296 /*************************************************************************
    297  * PathFindExtensionW   [SHLWAPI.@]
    298  */
    299 LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
    300 {
    301     LPCWSTR   lastpoint = NULL;
    302 
    303     TRACE("(%p %s)\n",lpszPath,debugstr_w(lpszPath));
    304 
    305     while (*lpszPath)
    306     {
    307       if (*lpszPath==(WCHAR)'\\'||*lpszPath==(WCHAR)' ')
    308         lastpoint=NULL;
    309       if (*lpszPath==(WCHAR)'.')
    310         lastpoint=lpszPath;
    311       lpszPath = CharNextW(lpszPath);
    312     }
    313     return (LPWSTR)(lastpoint?lastpoint:lpszPath);
    314 }
    315 
    316 /*************************************************************************
    317  * PathGetArgsA     [SHLWAPI.@]
     278LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath) 
     279{
     280        LPCSTR   lastpoint = NULL;
     281
     282        TRACE("%p %s\n",lpszPath,lpszPath);
     283
     284        while (*lpszPath)
     285        {
     286          if (*lpszPath=='\\'||*lpszPath==' ')
     287            lastpoint=NULL;
     288          if (*lpszPath=='.')
     289            lastpoint=lpszPath;
     290          lpszPath = CharNextA(lpszPath);
     291        }
     292        return (LPSTR)(lastpoint?lastpoint:lpszPath);
     293}
     294
     295/*************************************************************************
     296 * PathFindExtensionW   [SHLWAPI.@]
     297 */
     298LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath) 
     299{
     300        LPCWSTR   lastpoint = NULL;
     301
     302        TRACE("(%p %s)\n",lpszPath,debugstr_w(lpszPath));
     303
     304        while (*lpszPath)
     305        {
     306          if (*lpszPath==(WCHAR)'\\'||*lpszPath==(WCHAR)' ')
     307            lastpoint=NULL;
     308          if (*lpszPath==(WCHAR)'.')
     309            lastpoint=lpszPath;
     310          lpszPath = CharNextW(lpszPath);
     311        }
     312        return (LPWSTR)(lastpoint?lastpoint:lpszPath);
     313}
     314
     315/*************************************************************************
     316 * PathGetArgsA         [SHLWAPI.@]
    318317 *
    319318 * NOTES
     
    324323 *     quoting by '\'
    325324 */
    326 LPSTR WINAPI PathGetArgsA(LPCSTR lpszPath)
    327 {
    328     BOOL    qflag = FALSE;
    329 
    330     TRACE("%s\n",lpszPath);
    331 
    332     while (*lpszPath)
    333     {
    334       if ((*lpszPath==' ') && !qflag)
    335         return (LPSTR)lpszPath+1;
    336       if (*lpszPath=='"')
    337         qflag=!qflag;
    338       lpszPath = CharNextA(lpszPath);
    339     }
    340     return (LPSTR)lpszPath;
    341 }
    342 
    343 /*************************************************************************
    344  * PathGetArgsW     [SHLWAPI.@]
    345  */
    346 LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath)
    347 {
    348     BOOL    qflag = FALSE;
    349 
    350     TRACE("%s\n",debugstr_w(lpszPath));
    351 
    352     while (*lpszPath)
    353     {
    354       if ((*lpszPath==' ') && !qflag)
    355         return (LPWSTR)lpszPath+1;
    356       if (*lpszPath=='"')
    357         qflag=!qflag;
    358       lpszPath = CharNextW(lpszPath);
    359     }
    360     return (LPWSTR)lpszPath;
    361 }
    362 
    363 /*************************************************************************
    364  * PathGetDriveNumberA  [SHLWAPI.@]
     325LPSTR WINAPI PathGetArgsA(LPCSTR lpszPath) 
     326{
     327        BOOL    qflag = FALSE;
     328
     329        TRACE("%s\n",lpszPath);
     330
     331        while (*lpszPath)
     332        {
     333          if ((*lpszPath==' ') && !qflag)
     334            return (LPSTR)lpszPath+1;
     335          if (*lpszPath=='"')
     336            qflag=!qflag;
     337          lpszPath = CharNextA(lpszPath);
     338        }
     339        return (LPSTR)lpszPath;
     340}
     341
     342/*************************************************************************
     343 * PathGetArgsW         [SHLWAPI.@]
     344 */
     345LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath) 
     346{
     347        BOOL    qflag = FALSE;
     348
     349        TRACE("%s\n",debugstr_w(lpszPath));
     350
     351        while (*lpszPath)
     352        {
     353          if ((*lpszPath==' ') && !qflag)
     354            return (LPWSTR)lpszPath+1;
     355          if (*lpszPath=='"')
     356            qflag=!qflag;
     357          lpszPath = CharNextW(lpszPath);
     358        }
     359        return (LPWSTR)lpszPath;
     360}
     361
     362/*************************************************************************
     363 * PathGetDriveNumberA  [SHLWAPI.@]
    365364 */
    366365int WINAPI PathGetDriveNumberA(LPCSTR lpszPath)
    367366{
    368     int chr = tolower(lpszPath[0]);
    369 
    370     TRACE ("%s\n",debugstr_a(lpszPath));
    371 
    372     if (!lpszPath || lpszPath[1]!=':' || chr < 'a' || chr > 'z') return -1;
    373     return tolower(lpszPath[0]) - 'a' ;
    374 }
    375 
    376 /*************************************************************************
    377  * PathGetDriveNumberW  [SHLWAPI.@]
     367        int chr = tolower(lpszPath[0]);
     368       
     369        TRACE ("%s\n",debugstr_a(lpszPath));
     370
     371        if (!lpszPath || lpszPath[1]!=':' || chr < 'a' || chr > 'z') return -1;
     372        return tolower(lpszPath[0]) - 'a' ;
     373}
     374
     375/*************************************************************************
     376 * PathGetDriveNumberW  [SHLWAPI.@]
    378377 */
    379378int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath)
    380379{
    381     int chr = tolowerW(lpszPath[0]);
    382 
    383     TRACE ("%s\n",debugstr_w(lpszPath));
    384 
    385     if (!lpszPath || lpszPath[1]!=':' || chr < 'a' || chr > 'z') return -1;
    386     return tolowerW(lpszPath[0]) - 'a' ;
    387 }
    388 
    389 /*************************************************************************
    390  * PathRemoveFileSpecA  [SHLWAPI.@]
    391  *
     380        int chr = tolowerW(lpszPath[0]);
     381       
     382        TRACE ("%s\n",debugstr_w(lpszPath));
     383
     384        if (!lpszPath || lpszPath[1]!=':' || chr < 'a' || chr > 'z') return -1;
     385        return tolowerW(lpszPath[0]) - 'a' ;
     386}
     387
     388/*************************************************************************
     389 * PathRemoveFileSpecA  [SHLWAPI.@]
     390 * 
    392391 * NOTES
    393392 *     truncates passed argument to a valid path
     
    395394 *     "\foo\xx\foo"-> "\foo\xx"
    396395 *     "\" -> "\"
    397  *     "a:\foo" -> "a:\"
     396 *     "a:\foo" -> "a:\"
    398397 */
    399398BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
    400399{
    401     LPSTR cutplace = lpszPath;
    402     BOOL ret = FALSE;
    403 
    404     TRACE("%s\n",lpszPath);
    405 
    406     if(lpszPath)
    407     {
    408       while (*lpszPath == '\\') cutplace = ++lpszPath;
    409 
    410       while (*lpszPath)
    411       {
    412         if(lpszPath[0] == '\\') cutplace = lpszPath;
    413 
    414         if(lpszPath[0] == ':')
    415         {
    416           cutplace = lpszPath + 1;
    417           if (lpszPath[1] == '\\') cutplace++;
    418           lpszPath++;
    419         }
    420         lpszPath = CharNextA(lpszPath);
    421         if (!lpszPath) break;
    422       }
    423 
    424       ret = (*cutplace!='\0');
    425       *cutplace = '\0';
    426     }
    427     return ret;
    428 }
    429 
    430 /*************************************************************************
    431  * PathRemoveFileSpecW  [SHLWAPI.@]
     400        LPSTR cutplace = lpszPath;
     401        BOOL ret = FALSE;
     402       
     403        TRACE("%s\n",lpszPath);
     404
     405        if(lpszPath)
     406        {
     407          while (*lpszPath == '\\') cutplace = ++lpszPath;
     408         
     409          while (*lpszPath)
     410          {
     411            if(lpszPath[0] == '\\') cutplace = lpszPath;
     412         
     413            if(lpszPath[0] == ':')
     414            {
     415              cutplace = lpszPath + 1;
     416              if (lpszPath[1] == '\\') cutplace++;
     417              lpszPath++;
     418            }
     419            lpszPath = CharNextA(lpszPath);
     420            if (!lpszPath) break;
     421          }
     422         
     423          ret = (*cutplace!='\0');
     424          *cutplace = '\0';
     425        }
     426        return ret;
     427}
     428
     429/*************************************************************************
     430 * PathRemoveFileSpecW  [SHLWAPI.@]
    432431 */
    433432BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
    434433{
    435     LPWSTR cutplace = lpszPath;
    436     BOOL ret = FALSE;
    437 
    438     TRACE("%s\n",debugstr_w(lpszPath));
    439 
    440     if(lpszPath)
    441     {
    442       while (*lpszPath == '\\') cutplace = ++lpszPath;
    443 
    444       while (*lpszPath)
    445       {
    446         if(lpszPath[0] == '\\') cutplace = lpszPath;
    447 
    448         if(lpszPath[0] == ':')
    449         {
    450           cutplace = lpszPath + 1;
    451           if (lpszPath[1] == '\\') cutplace++;
    452           lpszPath++;
    453         }
    454         lpszPath = CharNextW(lpszPath);
    455         if (!lpszPath) break;
    456       }
    457 
    458       ret = (*cutplace!='\0');
    459       *cutplace = '\0';
    460     }
    461     return ret;
    462 }
    463 
    464 /*************************************************************************
    465  * PathStripPathA   [SHELLWAPI.@]
    466  *
     434        LPWSTR cutplace = lpszPath;
     435        BOOL ret = FALSE;
     436
     437        TRACE("%s\n",debugstr_w(lpszPath));
     438
     439        if(lpszPath)
     440        {
     441          while (*lpszPath == '\\') cutplace = ++lpszPath;
     442         
     443          while (*lpszPath)
     444          {
     445            if(lpszPath[0] == '\\') cutplace = lpszPath;
     446         
     447            if(lpszPath[0] == ':')
     448            {
     449              cutplace = lpszPath + 1;
     450              if (lpszPath[1] == '\\') cutplace++;
     451              lpszPath++;
     452            }
     453            lpszPath = CharNextW(lpszPath);
     454            if (!lpszPath) break;
     455          }
     456         
     457          ret = (*cutplace!='\0');
     458          *cutplace = '\0';
     459        }
     460        return ret;
     461}
     462
     463/*************************************************************************
     464 * PathStripPathA       [SHELLWAPI.@]
     465 * 
    467466 * NOTES
    468467 *  removes the path from the beginning of a filename
     
    470469void WINAPI PathStripPathA(LPSTR lpszPath)
    471470{
    472     LPSTR lpszFileName = PathFindFileNameA(lpszPath);
    473 
    474     TRACE("%s\n", lpszPath);
    475 
    476     if(lpszFileName)
    477       RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)+1);
    478 }
    479 
    480 /*************************************************************************
    481  * PathStripPathW   [SHELLWAPI.@]
     471        LPSTR lpszFileName = PathFindFileNameA(lpszPath);
     472
     473        TRACE("%s\n", lpszPath);
     474
     475        if(lpszFileName)
     476          RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)+1);
     477}
     478
     479/*************************************************************************
     480 * PathStripPathW       [SHELLWAPI.@]
    482481 */
    483482void WINAPI PathStripPathW(LPWSTR lpszPath)
    484483{
    485     LPWSTR lpszFileName = PathFindFileNameW(lpszPath);
    486 
    487     TRACE("%s\n", debugstr_w(lpszPath));
    488     if(lpszFileName)
    489       RtlMoveMemory(lpszPath, lpszFileName, (strlenW(lpszFileName)+1)*sizeof(WCHAR));
    490 }
    491 
    492 /*************************************************************************
    493  * PathStripToRootA [SHLWAPI.@]
     484        LPWSTR lpszFileName = PathFindFileNameW(lpszPath);
     485
     486        TRACE("%s\n", debugstr_w(lpszPath));
     487        if(lpszFileName)
     488          RtlMoveMemory(lpszPath, lpszFileName, (strlenW(lpszFileName)+1)*sizeof(WCHAR));
     489}
     490
     491/*************************************************************************
     492 * PathStripToRootA     [SHLWAPI.@]
    494493 */
    495494BOOL WINAPI PathStripToRootA(LPSTR lpszPath)
    496495{
    497     TRACE("%s\n", lpszPath);
    498 
    499     if (!lpszPath) return FALSE;
    500     while(!PathIsRootA(lpszPath))
    501       if (!PathRemoveFileSpecA(lpszPath)) return FALSE;
    502     return TRUE;
    503 }
    504 
    505 /*************************************************************************
    506  * PathStripToRootW [SHLWAPI.@]
     496        TRACE("%s\n", lpszPath);
     497
     498        if (!lpszPath) return FALSE;
     499        while(!PathIsRootA(lpszPath))
     500          if (!PathRemoveFileSpecA(lpszPath)) return FALSE;
     501        return TRUE;
     502}
     503
     504/*************************************************************************
     505 * PathStripToRootW     [SHLWAPI.@]
    507506 */
    508507BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
    509508{
    510     TRACE("%s\n", debugstr_w(lpszPath));
    511 
    512     if (!lpszPath) return FALSE;
    513     while(!PathIsRootW(lpszPath))
    514       if (!PathRemoveFileSpecW(lpszPath)) return FALSE;
    515     return TRUE;
    516 }
    517 
    518 /*************************************************************************
    519  * PathRemoveArgsA  [SHLWAPI.@]
     509        TRACE("%s\n", debugstr_w(lpszPath));
     510
     511        if (!lpszPath) return FALSE;
     512        while(!PathIsRootW(lpszPath))
     513          if (!PathRemoveFileSpecW(lpszPath)) return FALSE;
     514        return TRUE;
     515}
     516
     517/*************************************************************************
     518 * PathRemoveArgsA      [SHLWAPI.@]
    520519 *
    521520 */
    522521void WINAPI PathRemoveArgsA(LPSTR lpszPath)
    523522{
    524     TRACE("%s\n",lpszPath);
    525 
    526     if(lpszPath)
    527     {
    528       LPSTR lpszArgs = PathGetArgsA(lpszPath);
    529       if (!*lpszArgs)
    530       {
    531         LPSTR lpszLastChar = CharPrevA(lpszPath, lpszArgs);
    532         if(*lpszLastChar==' ') *lpszLastChar = '\0';
    533       }
    534     }
    535 }
    536 
    537 /*************************************************************************
    538  * PathRemoveArgsW  [SHLWAPI.@]
     523        TRACE("%s\n",lpszPath);
     524       
     525        if(lpszPath)
     526        {
     527          LPSTR lpszArgs = PathGetArgsA(lpszPath);
     528          if (!*lpszArgs)
     529          {
     530            LPSTR lpszLastChar = CharPrevA(lpszPath, lpszArgs);
     531            if(*lpszLastChar==' ') *lpszLastChar = '\0';
     532          }
     533        }
     534}
     535
     536/*************************************************************************
     537 * PathRemoveArgsW      [SHLWAPI.@]
    539538 */
    540539void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
    541540{
    542     TRACE("%s\n", debugstr_w(lpszPath));
    543 
    544     if(lpszPath)
    545     {
    546       LPWSTR lpszArgs = PathGetArgsW(lpszPath);
    547       if (!*lpszArgs)
    548       {
    549         LPWSTR lpszLastChar = CharPrevW(lpszPath, lpszArgs);
    550         if(*lpszLastChar==' ') *lpszLastChar = '\0';
    551       }
    552     }
    553 }
    554 
    555 /*************************************************************************
    556  * PathRemoveExtensionA     [SHLWAPI.@]
     541        TRACE("%s\n", debugstr_w(lpszPath));
     542
     543        if(lpszPath)
     544        {
     545          LPWSTR lpszArgs = PathGetArgsW(lpszPath);
     546          if (!*lpszArgs)
     547          {
     548            LPWSTR lpszLastChar = CharPrevW(lpszPath, lpszArgs);
     549            if(*lpszLastChar==' ') *lpszLastChar = '\0';
     550          }
     551        }
     552}
     553
     554/*************************************************************************
     555 * PathRemoveExtensionA         [SHLWAPI.@]
    557556 */
    558557void WINAPI PathRemoveExtensionA(LPSTR lpszPath)
    559558{
    560     LPSTR lpszExtension = PathFindExtensionA(lpszPath);
    561 
    562     TRACE("%s\n", lpszPath);
    563 
    564     if (lpszExtension) *lpszExtension='\0';
    565 }
    566 
    567 /*************************************************************************
    568  * PathRemoveExtensionW     [SHLWAPI.@]
     559        LPSTR lpszExtension = PathFindExtensionA(lpszPath);
     560
     561        TRACE("%s\n", lpszPath);
     562
     563        if (lpszExtension) *lpszExtension='\0';
     564}
     565
     566/*************************************************************************
     567 * PathRemoveExtensionW         [SHLWAPI.@]
    569568 */
    570569void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
    571570{
    572     LPWSTR lpszExtension = PathFindExtensionW(lpszPath);
    573 
    574     TRACE("%s\n", debugstr_w(lpszPath));
    575 
    576     if (lpszExtension) *lpszExtension='\0';
    577 }
    578 
    579 /*************************************************************************
    580  * PathRemoveBackslashA [SHLWAPI.@]
     571        LPWSTR lpszExtension = PathFindExtensionW(lpszPath);
     572
     573        TRACE("%s\n", debugstr_w(lpszPath));
     574
     575        if (lpszExtension) *lpszExtension='\0';
     576}
     577
     578/*************************************************************************
     579 * PathRemoveBackslashA [SHLWAPI.@]
    581580 *
    582581 * If the path ends in a backslash it is replaced by a NULL
    583582 * and the address of the NULL is returned
    584  * Otherwise
     583 * Otherwise 
    585584 * the address of the last character is returned.
    586585 *
     
    590589LPSTR WINAPI PathRemoveBackslashA( LPSTR lpszPath )
    591590{
    592     int len;
    593     LPSTR szTemp = NULL;
    594 
    595     if(lpszPath)
    596     {
    597       len = strlen(lpszPath);
    598       szTemp = CharPrevA(lpszPath, lpszPath+len);
    599       if (! PathIsRootA(lpszPath))
    600       {
    601         if (*szTemp == '\\') *szTemp = '\0';
    602       }
    603     }
    604     return szTemp;
    605 }
    606 
    607 /*************************************************************************
    608  * PathRemoveBackslashW [SHLWAPI.@]
     591        int len;
     592        LPSTR szTemp = NULL;
     593       
     594        if(lpszPath)
     595        {
     596          len = strlen(lpszPath);
     597          szTemp = CharPrevA(lpszPath, lpszPath+len);
     598          if (! PathIsRootA(lpszPath))
     599          {
     600            if (*szTemp == '\\') *szTemp = '\0';
     601          }
     602        }
     603        return szTemp;
     604}
     605
     606/*************************************************************************
     607 * PathRemoveBackslashW [SHLWAPI.@]
    609608 */
    610609LPWSTR WINAPI PathRemoveBackslashW( LPWSTR lpszPath )
    611610{
    612     int len;
    613     LPWSTR szTemp = NULL;
    614 
    615     if(lpszPath)
    616     {
    617       len = strlenW(lpszPath);
    618       szTemp = CharPrevW(lpszPath, lpszPath+len);
    619       if (! PathIsRootW(lpszPath))
    620       {
    621         if (*szTemp == '\\') *szTemp = '\0';
    622       }
    623     }
    624     return szTemp;
     611        int len;
     612        LPWSTR szTemp = NULL;
     613       
     614        if(lpszPath)
     615        {
     616          len = strlenW(lpszPath);
     617          szTemp = CharPrevW(lpszPath, lpszPath+len);
     618          if (! PathIsRootW(lpszPath))
     619          {
     620            if (*szTemp == '\\') *szTemp = '\0';
     621          }
     622        }
     623        return szTemp;
    625624}
    626625
    627626
    628627/*
    629     Path Manipulations
     628        Path Manipulations
    630629*/
    631630
    632631/*************************************************************************
    633632 * PathRemoveBlanksA [SHLWAPI.@]
    634  *
     633 * 
    635634 * NOTES
    636635 *     remove spaces from beginning and end of passed string
     
    638637void WINAPI PathRemoveBlanksA(LPSTR str)
    639638{
    640     LPSTR x = str;
    641 
    642     TRACE("%s\n",str);
    643 
    644     if(str)
    645     {
    646       while (*x==' ') x = CharNextA(x);
    647       if (x!=str) strcpy(str,x);
    648       x=str+strlen(str)-1;
    649       while (*x==' ') x = CharPrevA(str, x);
    650       if (*x==' ') *x='\0';
    651     }
     639        LPSTR x = str;
     640
     641        TRACE("%s\n",str);
     642
     643        if(str)
     644        {
     645          while (*x==' ') x = CharNextA(x);
     646          if (x!=str) strcpy(str,x);
     647          x=str+strlen(str)-1;
     648          while (*x==' ') x = CharPrevA(str, x);
     649          if (*x==' ') *x='\0';
     650        }
    652651}
    653652
     
    657656void WINAPI PathRemoveBlanksW(LPWSTR str)
    658657{
    659     LPWSTR x = str;
    660 
    661     TRACE("%s\n",debugstr_w(str));
    662 
    663     if(str)
    664     {
    665       while (*x==' ') x = CharNextW(x);
    666       if (x!=str) strcpyW(str,x);
    667       x=str+strlenW(str)-1;
    668       while (*x==' ') x = CharPrevW(str, x);
    669       if (*x==' ') *x='\0';
    670     }
     658        LPWSTR x = str;
     659
     660        TRACE("%s\n",debugstr_w(str));
     661
     662        if(str)
     663        {
     664          while (*x==' ') x = CharNextW(x);
     665          if (x!=str) strcpyW(str,x);
     666          x=str+strlenW(str)-1;
     667          while (*x==' ') x = CharPrevW(str, x);
     668          if (*x==' ') *x='\0';
     669        }
    671670}
    672671
    673672/*************************************************************************
    674673 * PathQuoteSpacesA [SHLWAPI.@]
    675  *
     674 * 
    676675 */
    677676LPSTR WINAPI PathQuoteSpacesA(LPSTR lpszPath)
    678677{
    679     TRACE("%s\n",lpszPath);
    680 
    681     if(StrChrA(lpszPath,' '))
    682     {
    683       int len = strlen(lpszPath);
    684       RtlMoveMemory(lpszPath+1, lpszPath, len);
    685       *(lpszPath++) = '"';
    686       lpszPath += len;
    687       *(lpszPath++) = '"';
    688       *(lpszPath) = '\0';
    689       return --lpszPath;
    690     }
    691     return 0;
     678        TRACE("%s\n",lpszPath);
     679
     680        if(StrChrA(lpszPath,' '))
     681        {
     682          int len = strlen(lpszPath);
     683          RtlMoveMemory(lpszPath+1, lpszPath, len);
     684          *(lpszPath++) = '"';
     685          lpszPath += len;
     686          *(lpszPath++) = '"';
     687          *(lpszPath) = '\0';
     688          return --lpszPath;
     689        }
     690        return 0;
    692691}
    693692
     
    697696LPWSTR WINAPI PathQuoteSpacesW(LPWSTR lpszPath)
    698697{
    699     TRACE("%s\n",debugstr_w(lpszPath));
    700 
    701     if(StrChrW(lpszPath,' '))
    702     {
    703       int len = strlenW(lpszPath);
    704       RtlMoveMemory(lpszPath+1, lpszPath, len*sizeof(WCHAR));
    705       *(lpszPath++) = '"';
    706       lpszPath += len;
    707       *(lpszPath++) = '"';
    708       *(lpszPath) = '\0';
    709       return --lpszPath;
    710     }
    711     return 0;
     698        TRACE("%s\n",debugstr_w(lpszPath));
     699
     700        if(StrChrW(lpszPath,' '))
     701        {
     702          int len = strlenW(lpszPath);
     703          RtlMoveMemory(lpszPath+1, lpszPath, len*sizeof(WCHAR));
     704          *(lpszPath++) = '"';
     705          lpszPath += len;
     706          *(lpszPath++) = '"';
     707          *(lpszPath) = '\0';
     708          return --lpszPath;
     709        }
     710        return 0;
    712711}
    713712
    714713/*************************************************************************
    715714 * PathUnquoteSpacesA [SHLWAPI.@]
    716  *
     715 * 
    717716 * NOTES
    718717 *     unquote string (remove ")
    719718 */
    720 VOID WINAPI PathUnquoteSpacesA(LPSTR str)
    721 {
    722     DWORD len = strlen(str);
    723 
    724     TRACE("%s\n",str);
    725 
    726     if (*str!='"')
    727       return;
    728     if (str[len-1]!='"')
    729       return;
    730     str[len-1]='\0';
    731     strcpy(str,str+1);
    732     return;
     719VOID WINAPI PathUnquoteSpacesA(LPSTR str) 
     720{
     721        DWORD len = strlen(str);
     722
     723        TRACE("%s\n",str);
     724
     725        if (*str!='"')
     726          return;
     727        if (str[len-1]!='"')
     728          return;
     729        str[len-1]='\0';
     730        strcpy(str,str+1);
     731        return;
    733732}
    734733
     
    736735 * PathUnquoteSpacesW [SHLWAPI.@]
    737736 */
    738 VOID WINAPI PathUnquoteSpacesW(LPWSTR str)
    739 {
    740     DWORD len = strlenW(str);
    741 
    742     TRACE("%s\n",debugstr_w(str));
    743 
    744     if (*str!='"')
    745       return;
    746     if (str[len-1]!='"')
    747       return;
    748     str[len-1]='\0';
    749     strcpyW(str,str+1);
    750     return;
    751 }
    752 
    753 /*************************************************************************
    754  * PathParseIconLocationA   [SHLWAPI.@]
     737VOID WINAPI PathUnquoteSpacesW(LPWSTR str) 
     738{
     739        DWORD len = strlenW(str);
     740
     741        TRACE("%s\n",debugstr_w(str));
     742
     743        if (*str!='"')
     744          return;
     745        if (str[len-1]!='"')
     746          return;
     747        str[len-1]='\0';
     748        strcpyW(str,str+1);
     749        return;
     750}
     751
     752/*************************************************************************
     753 * PathParseIconLocationA       [SHLWAPI.@]
    755754 */
    756755int WINAPI PathParseIconLocationA(LPSTR lpszPath)
    757756{
    758     LPSTR lpstrComma = strchr(lpszPath, ',');
    759 
    760     FIXME("%s stub\n", debugstr_a(lpszPath));
    761 
    762     if (lpstrComma && lpstrComma[1])
    763     {
    764       lpstrComma[0]='\0';
    765 /*    return atoi(&lpstrComma[1]);  FIXME */
    766     }
    767 
    768     PathUnquoteSpacesA(lpszPath);
    769     return 0;
    770 }
    771 
    772 /*************************************************************************
    773  * PathParseIconLocationW   [SHLWAPI.@]
     757        LPSTR lpstrComma = strchr(lpszPath, ',');
     758       
     759        FIXME("%s stub\n", debugstr_a(lpszPath));
     760
     761        if (lpstrComma && lpstrComma[1])
     762        {
     763          lpstrComma[0]='\0';
     764/*        return atoi(&lpstrComma[1]);  FIXME */
     765        }
     766       
     767        PathUnquoteSpacesA(lpszPath);
     768        return 0;
     769}
     770
     771/*************************************************************************
     772 * PathParseIconLocationW       [SHLWAPI.@]
    774773 */
    775774int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
    776775{
    777     LPWSTR lpstrComma = strchrW(lpszPath, ',');
    778 
    779     FIXME("%s stub\n", debugstr_w(lpszPath));
    780 
    781     if (lpstrComma && lpstrComma[1])
    782     {
    783       lpstrComma[0]='\0';
    784 /*    return _wtoi(&lpstrComma[1]); FIXME */
    785     }
    786     PathUnquoteSpacesW(lpszPath);
    787     return 0;
     776        LPWSTR lpstrComma = strchrW(lpszPath, ',');
     777       
     778        FIXME("%s stub\n", debugstr_w(lpszPath));
     779
     780        if (lpstrComma && lpstrComma[1])
     781        {
     782          lpstrComma[0]='\0';
     783/*        return _wtoi(&lpstrComma[1]); FIXME */
     784        }
     785        PathUnquoteSpacesW(lpszPath);
     786        return 0;
    788787}
    789788
    790789/*
    791     ########## cleaning and resolving paths ##########
    792  */
    793 
    794 /*************************************************************************
    795  * PathFindOnPathA  [SHLWAPI.@]
     790        ########## cleaning and resolving paths ##########
     791 */
     792
     793/*************************************************************************
     794 * PathFindOnPathA      [SHLWAPI.@]
    796795 */
    797796BOOL WINAPI PathFindOnPathA(LPSTR sFile, LPCSTR sOtherDirs)
    798797{
    799     FIXME("%s %s\n",sFile, sOtherDirs);
    800     return FALSE;
    801 }
    802 
    803 /*************************************************************************
    804  * PathFindOnPathW  [SHLWAPI.@]
     798        FIXME("%s %s\n",sFile, sOtherDirs);
     799        return FALSE;
     800}
     801
     802/*************************************************************************
     803 * PathFindOnPathW      [SHLWAPI.@]
    805804 */
    806805BOOL WINAPI PathFindOnPathW(LPWSTR sFile, LPCWSTR sOtherDirs)
    807806{
    808     FIXME("%s %s\n",debugstr_w(sFile), debugstr_w(sOtherDirs));
    809     return FALSE;
    810 }
    811 
    812 /*************************************************************************
    813  *  PathCompactPathExA   [SHLWAPI.@]
     807        FIXME("%s %s\n",debugstr_w(sFile), debugstr_w(sOtherDirs));
     808        return FALSE;
     809}
     810
     811/*************************************************************************
     812 *      PathCompactPathExA   [SHLWAPI.@]
    814813 */
    815814BOOL WINAPI PathCompactPathExA(
    816     LPSTR pszOut,
    817     LPCSTR pszSrc,
    818     UINT cchMax,
    819     DWORD dwFlags)
    820 {
    821     FIXME("%p %s 0x%08x 0x%08lx\n", pszOut, pszSrc, cchMax, dwFlags);
    822     return FALSE;
    823 }
    824 
    825 /*************************************************************************
    826  *  PathCompactPathExW   [SHLWAPI.@]
     815        LPSTR pszOut,
     816        LPCSTR pszSrc,
     817        UINT cchMax,
     818        DWORD dwFlags)
     819{
     820        FIXME("%p %s 0x%08x 0x%08lx\n", pszOut, pszSrc, cchMax, dwFlags);
     821        return FALSE;
     822}
     823
     824/*************************************************************************
     825 *      PathCompactPathExW   [SHLWAPI.@]
    827826 */
    828827BOOL WINAPI PathCompactPathExW(
    829     LPWSTR pszOut,
    830     LPCWSTR pszSrc,
    831     UINT cchMax,
    832     DWORD dwFlags)
    833 {
    834     FIXME("%p %s 0x%08x 0x%08lx\n", pszOut, debugstr_w(pszSrc), cchMax, dwFlags);
    835     return FALSE;
     828        LPWSTR pszOut,
     829        LPCWSTR pszSrc,
     830        UINT cchMax,
     831        DWORD dwFlags)
     832{
     833        FIXME("%p %s 0x%08x 0x%08lx\n", pszOut, debugstr_w(pszSrc), cchMax, dwFlags);
     834        return FALSE;
    836835}
    837836
    838837/*
    839     ########## Path Testing ##########
     838        ########## Path Testing ##########
    840839*/
    841840
    842841/*************************************************************************
    843  * PathIsUNCA       [SHLWAPI.@]
    844  *
     842 * PathIsUNCA           [SHLWAPI.@]
     843 * 
    845844 * NOTES
    846845 *     PathIsUNC(char*path);
    847846 */
    848 BOOL WINAPI PathIsUNCA(LPCSTR lpszPath)
    849 {
    850     TRACE("%s\n",lpszPath);
    851 
    852     return (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'));
    853 }
    854 
    855 /*************************************************************************
    856  * PathIsUNCW       [SHLWAPI.@]
    857  */
    858 BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
    859 {
    860     TRACE("%s\n",debugstr_w(lpszPath));
    861 
    862     return (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'));
    863 }
    864 
    865 /*************************************************************************
    866  *  PathIsRelativeA [SHLWAPI.@]
     847BOOL WINAPI PathIsUNCA(LPCSTR lpszPath) 
     848{
     849        TRACE("%s\n",lpszPath);
     850
     851        return (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'));
     852}
     853
     854/*************************************************************************
     855 * PathIsUNCW           [SHLWAPI.@]
     856 */
     857BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath) 
     858{
     859        TRACE("%s\n",debugstr_w(lpszPath));
     860
     861        return (lpszPath && (lpszPath[0]=='\\') && (lpszPath[1]=='\\'));
     862}
     863
     864/*************************************************************************
     865 *  PathIsRelativeA     [SHLWAPI.@]
    867866 */
    868867BOOL WINAPI PathIsRelativeA (LPCSTR lpszPath)
    869868{
    870     TRACE("lpszPath=%s\n",lpszPath);
    871 
    872     return (lpszPath && (lpszPath[0]!='\\' && lpszPath[1]!=':'));
    873 }
    874 
    875 /*************************************************************************
    876  *  PathIsRelativeW [SHLWAPI.@]
     869        TRACE("lpszPath=%s\n",lpszPath);
     870
     871        return (lpszPath && (lpszPath[0]!='\\' && lpszPath[1]!=':'));
     872}
     873
     874/*************************************************************************
     875 *  PathIsRelativeW     [SHLWAPI.@]
    877876 */
    878877BOOL WINAPI PathIsRelativeW (LPCWSTR lpszPath)
    879878{
    880     TRACE("lpszPath=%s\n",debugstr_w(lpszPath));
    881 
    882     return (lpszPath && (lpszPath[0]!='\\' && lpszPath[1]!=':'));
    883 }
    884 
    885 /*************************************************************************
    886  * PathIsRootA      [SHLWAPI.@]
     879        TRACE("lpszPath=%s\n",debugstr_w(lpszPath));
     880
     881        return (lpszPath && (lpszPath[0]!='\\' && lpszPath[1]!=':'));
     882}
     883
     884/*************************************************************************
     885 * PathIsRootA          [SHLWAPI.@]
    887886 *
    888887 * notes
     
    891890BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
    892891{
    893     TRACE("%s\n",lpszPath);
    894 
    895     /* X:\ */
    896     if (lpszPath[1]==':' && lpszPath[2]=='\\' && lpszPath[3]=='\0')
    897       return TRUE;
    898 
    899     /* "\" */
    900     if (lpszPath[0]=='\\' && lpszPath[1]=='\0')
    901       return TRUE;
    902 
    903     /* UNC "\\<computer>\<share>" */
    904     if (lpszPath[0]=='\\' && lpszPath[1]=='\\')
    905     {
    906       int foundbackslash = 0;
    907       lpszPath += 2;
    908       while (*lpszPath)
    909       {
    910         if (*lpszPath=='\\') foundbackslash++;
    911         lpszPath = CharNextA(lpszPath);
    912       }
    913       if (foundbackslash <= 1)
    914         return TRUE;
    915     }
    916     return FALSE;
    917 }
    918 
    919 /*************************************************************************
    920  * PathIsRootW      [SHLWAPI.@]
    921  */
    922 BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
    923 {
    924     TRACE("%s\n",debugstr_w(lpszPath));
    925 
    926     /* X:\ */
    927     if (lpszPath[1]==':' && lpszPath[2]=='\\' && lpszPath[3]=='\0')
    928       return TRUE;
    929 
    930     /* "\" */
    931     if (lpszPath[0]=='\\' && lpszPath[1]=='\0')
    932       return TRUE;
    933 
    934     /* UNC "\\<computer>\<share>" */
    935     if (lpszPath[0]=='\\' && lpszPath[1]=='\\')
    936     {
    937       int foundbackslash = 0;
    938       lpszPath += 2;
    939       while (*lpszPath)
    940       {
    941         if (*lpszPath=='\\') foundbackslash++;
    942         lpszPath = CharNextW(lpszPath);
    943       }
    944       if (foundbackslash <= 1)
    945         return TRUE;
    946     }
    947     return FALSE;
    948 
    949 }
    950 
    951 /*************************************************************************
    952  * PathIsDirectoryA [SHLWAPI.@]
     892        TRACE("%s\n",lpszPath);
     893
     894        /* X:\ */
     895        if (lpszPath[1]==':' && lpszPath[2]=='\\' && lpszPath[3]=='\0')
     896          return TRUE;
     897
     898        /* "\" */
     899        if (lpszPath[0]=='\\' && lpszPath[1]=='\0')
     900          return TRUE;
     901
     902        /* UNC "\\<computer>\<share>" */
     903        if (lpszPath[0]=='\\' && lpszPath[1]=='\\')             
     904        {
     905          int foundbackslash = 0;
     906          lpszPath += 2;
     907          while (*lpszPath)
     908          {
     909            if (*lpszPath=='\\') foundbackslash++;
     910            lpszPath = CharNextA(lpszPath);
     911          }
     912          if (foundbackslash <= 1)
     913            return TRUE;
     914        }
     915        return FALSE;
     916}
     917
     918/*************************************************************************
     919 * PathIsRootW          [SHLWAPI.@]
     920 */
     921BOOL WINAPI PathIsRootW(LPCWSTR lpszPath) 
     922{
     923        TRACE("%s\n",debugstr_w(lpszPath));
     924
     925        /* X:\ */
     926        if (lpszPath[1]==':' && lpszPath[2]=='\\' && lpszPath[3]=='\0')
     927          return TRUE;
     928
     929        /* "\" */
     930        if (lpszPath[0]=='\\' && lpszPath[1]=='\0')
     931          return TRUE;
     932
     933        /* UNC "\\<computer>\<share>" */
     934        if (lpszPath[0]=='\\' && lpszPath[1]=='\\')             
     935        {
     936          int foundbackslash = 0;
     937          lpszPath += 2;
     938          while (*lpszPath)
     939          {
     940            if (*lpszPath=='\\') foundbackslash++;
     941            lpszPath = CharNextW(lpszPath);
     942          }
     943          if (foundbackslash <= 1)
     944            return TRUE;
     945        }
     946        return FALSE;
     947
     948}
     949
     950/*************************************************************************
     951 * PathIsDirectoryA     [SHLWAPI.@]
    953952 */
    954953BOOL WINAPI PathIsDirectoryA(LPCSTR lpszPath)
    955954{
    956     DWORD dwAttr;
    957 
    958     TRACE("%s\n", debugstr_a(lpszPath));
    959 
    960     dwAttr = GetFileAttributesA(lpszPath);
    961     return  (dwAttr != -1) ? dwAttr & FILE_ATTRIBUTE_DIRECTORY : 0;
    962 }
    963 
    964 /*************************************************************************
    965  * PathIsDirectoryW [SHLWAPI.@]
     955        DWORD dwAttr;
     956
     957        TRACE("%s\n", debugstr_a(lpszPath));
     958
     959        dwAttr = GetFileAttributesA(lpszPath);
     960        return  (dwAttr != -1) ? dwAttr & FILE_ATTRIBUTE_DIRECTORY : 0;
     961}
     962
     963/*************************************************************************
     964 * PathIsDirectoryW     [SHLWAPI.@]
    966965 */
    967966BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
    968967{
    969     DWORD dwAttr;
    970 
    971     TRACE("%s\n", debugstr_w(lpszPath));
    972 
    973     dwAttr = GetFileAttributesW(lpszPath);
    974     return  (dwAttr != -1) ? dwAttr & FILE_ATTRIBUTE_DIRECTORY : 0;
    975 }
    976 
    977 /*************************************************************************
    978  * PathFileExistsA  [SHLWAPI.@]
    979  *
     968        DWORD dwAttr;
     969       
     970        TRACE("%s\n", debugstr_w(lpszPath));
     971
     972        dwAttr = GetFileAttributesW(lpszPath);
     973        return  (dwAttr != -1) ? dwAttr & FILE_ATTRIBUTE_DIRECTORY : 0;
     974}
     975
     976/*************************************************************************
     977 * PathFileExistsA      [SHLWAPI.@]
     978 * 
    980979 * NOTES
    981980 *     file_exists(char *fn);
    982981 */
    983 BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
    984 {
    985     TRACE("%s\n",lpszPath);
    986     return  (GetFileAttributesA(lpszPath)!=-1);
    987 }
    988 
    989 /*************************************************************************
    990  * PathFileExistsW  [SHLWAPI.@]
    991  */
    992 BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
    993 {
    994     TRACE("%s\n",debugstr_w(lpszPath));
    995     return  (GetFileAttributesW(lpszPath)!=-1);
    996 }
    997 
    998 /*************************************************************************
    999  * PathMatchSingleMaskA [internal]
    1000  *
     982BOOL WINAPI PathFileExistsA(LPCSTR lpszPath) 
     983{
     984        TRACE("%s\n",lpszPath);
     985        return  (GetFileAttributesA(lpszPath)!=-1);
     986}
     987
     988/*************************************************************************
     989 * PathFileExistsW      [SHLWAPI.@]
     990 */
     991BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath) 
     992{
     993        TRACE("%s\n",debugstr_w(lpszPath));
     994        return  (GetFileAttributesW(lpszPath)!=-1);
     995}
     996
     997/*************************************************************************
     998 * PathMatchSingleMaskA [internal]
     999 * 
    10011000 * NOTES
    10021001 *     internal (used by PathMatchSpec)
     
    10041003static BOOL PathMatchSingleMaskA(LPCSTR name, LPCSTR mask)
    10051004{
    1006     while (*name && *mask && *mask!=';')
    1007     {
    1008       if (*mask=='*')
    1009       {
    1010         do
    1011         {
    1012           if (PathMatchSingleMaskA(name,mask+1)) return 1;  /* try substrings */
    1013         } while (*name++);
    1014         return 0;
    1015       }
    1016       if (toupper(*mask)!=toupper(*name) && *mask!='?') return 0;
    1017       name = CharNextA(name);
    1018       mask = CharNextA(mask);
    1019     }
    1020     if (!*name)
    1021     {
    1022       while (*mask=='*') mask++;
    1023       if (!*mask || *mask==';') return 1;
    1024     }
    1025     return 0;
    1026 }
    1027 
    1028 /*************************************************************************
    1029  * PathMatchSingleMaskW [internal]
     1005        while (*name && *mask && *mask!=';')
     1006        {
     1007          if (*mask=='*')
     1008          {
     1009            do
     1010            {
     1011              if (PathMatchSingleMaskA(name,mask+1)) return 1;  /* try substrings */
     1012            } while (*name++);
     1013            return 0;
     1014          }
     1015          if (toupper(*mask)!=toupper(*name) && *mask!='?') return 0;
     1016          name = CharNextA(name);
     1017          mask = CharNextA(mask);
     1018        }
     1019        if (!*name)
     1020        {
     1021          while (*mask=='*') mask++;
     1022          if (!*mask || *mask==';') return 1;
     1023        }
     1024        return 0;
     1025}
     1026
     1027/*************************************************************************
     1028 * PathMatchSingleMaskW [internal]
    10301029 */
    10311030static BOOL PathMatchSingleMaskW(LPCWSTR name, LPCWSTR mask)
    10321031{
    1033     while (*name && *mask && *mask!=';')
    1034     {
    1035       if (*mask=='*')
    1036       {
    1037         do
    1038         {
    1039           if (PathMatchSingleMaskW(name,mask+1)) return 1;  /* try substrings */
    1040         } while (*name++);
    1041         return 0;
    1042       }
    1043       if (toupperW(*mask)!=toupperW(*name) && *mask!='?') return 0;
    1044       name = CharNextW(name);
    1045       mask = CharNextW(mask);
    1046     }
    1047     if (!*name)
    1048     {
    1049       while (*mask=='*') mask++;
    1050       if (!*mask || *mask==';') return 1;
    1051     }
    1052     return 0;
    1053 }
    1054 /*************************************************************************
    1055  * PathMatchSpecA   [SHLWAPI.@]
    1056  *
     1032        while (*name && *mask && *mask!=';')
     1033        {
     1034          if (*mask=='*')
     1035          {
     1036            do
     1037            {
     1038              if (PathMatchSingleMaskW(name,mask+1)) return 1;  /* try substrings */
     1039            } while (*name++);
     1040            return 0;
     1041          }
     1042          if (toupperW(*mask)!=toupperW(*name) && *mask!='?') return 0;
     1043          name = CharNextW(name);
     1044          mask = CharNextW(mask);
     1045        }
     1046        if (!*name)
     1047        {
     1048          while (*mask=='*') mask++;
     1049          if (!*mask || *mask==';') return 1;
     1050        }
     1051        return 0;
     1052}
     1053/*************************************************************************
     1054 * PathMatchSpecA       [SHLWAPI.@]
     1055 * 
    10571056 * NOTES
    10581057 *     used from COMDLG32
    10591058 */
    1060 BOOL WINAPI PathMatchSpecA(LPCSTR name, LPCSTR mask)
    1061 {
    1062     TRACE("%s %s\n",name,mask);
    1063 
    1064     if (!lstrcmpA( mask, "*.*" )) return 1;   /* we don't require a period */
    1065 
    1066     while (*mask)
    1067     {
    1068       if (PathMatchSingleMaskA(name,mask)) return 1;    /* helper function */
    1069       while (*mask && *mask!=';') mask = CharNextA(mask);
    1070       if (*mask==';')
    1071       {
    1072         mask++;
    1073         while (*mask==' ') mask++;      /*  masks may be separated by "; " */
    1074       }
    1075     }
    1076     return 0;
    1077 }
    1078 
    1079 /*************************************************************************
    1080  * PathMatchSpecW   [SHLWAPI.@]
    1081  */
    1082 BOOL WINAPI PathMatchSpecW(LPCWSTR name, LPCWSTR mask)
     1059BOOL WINAPI PathMatchSpecA(LPCSTR name, LPCSTR mask) 
     1060{
     1061        TRACE("%s %s\n",name,mask);
     1062
     1063        if (!lstrcmpA( mask, "*.*" )) return 1;   /* we don't require a period */
     1064
     1065        while (*mask)
     1066        {
     1067          if (PathMatchSingleMaskA(name,mask)) return 1;    /* helper function */
     1068          while (*mask && *mask!=';') mask = CharNextA(mask);
     1069          if (*mask==';')
     1070          {
     1071            mask++;
     1072            while (*mask==' ') mask++;      /*  masks may be separated by "; " */
     1073          }
     1074        }
     1075        return 0;
     1076}
     1077
     1078/*************************************************************************
     1079 * PathMatchSpecW       [SHLWAPI.@]
     1080 */
     1081BOOL WINAPI PathMatchSpecW(LPCWSTR name, LPCWSTR mask) 
    10831082{
    10841083    static const WCHAR stemp[] = { '*','.','*',0 };
    1085     TRACE("%s %s\n",debugstr_w(name),debugstr_w(mask));
    1086 
    1087     if (!lstrcmpW( mask, stemp )) return 1;   /* we don't require a period */
    1088 
    1089     while (*mask)
    1090     {
    1091       if (PathMatchSingleMaskW(name,mask)) return 1;    /* helper function */
    1092       while (*mask && *mask!=';') mask = CharNextW(mask);
    1093       if (*mask==';')
    1094       {
    1095         mask++;
    1096         while (*mask==' ') mask++;       /* masks may be separated by "; " */
    1097       }
    1098     }
    1099     return 0;
    1100 }
    1101 
    1102 /*************************************************************************
    1103  * PathIsSameRootA  [SHLWAPI.@]
     1084        TRACE("%s %s\n",debugstr_w(name),debugstr_w(mask));
     1085
     1086        if (!lstrcmpW( mask, stemp )) return 1;   /* we don't require a period */
     1087
     1088        while (*mask)
     1089        {
     1090          if (PathMatchSingleMaskW(name,mask)) return 1;    /* helper function */
     1091          while (*mask && *mask!=';') mask = CharNextW(mask);
     1092          if (*mask==';')
     1093          {
     1094            mask++;
     1095            while (*mask==' ') mask++;       /* masks may be separated by "; " */
     1096          }
     1097        }
     1098        return 0;
     1099}
     1100
     1101/*************************************************************************
     1102 * PathIsSameRootA      [SHLWAPI.@]
    11041103 *
    11051104 * FIXME
     
    11081107BOOL WINAPI PathIsSameRootA(LPCSTR lpszPath1, LPCSTR lpszPath2)
    11091108{
    1110     TRACE("%s %s\n", lpszPath1, lpszPath2);
    1111 
    1112     if (PathIsRelativeA(lpszPath1) || PathIsRelativeA(lpszPath2)) return FALSE;
    1113 
    1114     /* usual path */
    1115     if ( toupper(lpszPath1[0])==toupper(lpszPath2[0]) &&
    1116          lpszPath1[1]==':' && lpszPath2[1]==':' &&
    1117          lpszPath1[2]=='\\' && lpszPath2[2]=='\\')
    1118       return TRUE;
    1119 
    1120     /* UNC */
    1121     if (lpszPath1[0]=='\\' && lpszPath2[0]=='\\' &&
    1122         lpszPath1[1]=='\\' && lpszPath2[1]=='\\')
    1123     {
    1124       int pos=2, bsfound=0;
    1125       while (lpszPath1[pos] && lpszPath2[pos] &&
    1126             (lpszPath1[pos] == lpszPath2[pos]))
    1127       {
    1128         if (lpszPath1[pos]=='\\') bsfound++;
    1129         if (bsfound == 2) return TRUE;
    1130         pos++; /* fixme: use CharNext*/
    1131       }
    1132       return (lpszPath1[pos] == lpszPath2[pos]);
    1133     }
    1134     return FALSE;
    1135 }
    1136 
    1137 /*************************************************************************
    1138  * PathIsSameRootW  [SHLWAPI.@]
     1109        TRACE("%s %s\n", lpszPath1, lpszPath2);
     1110       
     1111        if (PathIsRelativeA(lpszPath1) || PathIsRelativeA(lpszPath2)) return FALSE;
     1112
     1113        /* usual path */
     1114        if ( toupper(lpszPath1[0])==toupper(lpszPath2[0]) &&
     1115             lpszPath1[1]==':' && lpszPath2[1]==':' &&
     1116             lpszPath1[2]=='\\' && lpszPath2[2]=='\\')
     1117          return TRUE;
     1118
     1119        /* UNC */
     1120        if (lpszPath1[0]=='\\' && lpszPath2[0]=='\\' &&
     1121            lpszPath1[1]=='\\' && lpszPath2[1]=='\\')
     1122        {
     1123          int pos=2, bsfound=0;
     1124          while (lpszPath1[pos] && lpszPath2[pos] &&
     1125                (lpszPath1[pos] == lpszPath2[pos]))
     1126          {
     1127            if (lpszPath1[pos]=='\\') bsfound++;
     1128            if (bsfound == 2) return TRUE;
     1129            pos++; /* fixme: use CharNext*/
     1130          }
     1131          return (lpszPath1[pos] == lpszPath2[pos]);
     1132        }
     1133        return FALSE;
     1134}
     1135
     1136/*************************************************************************
     1137 * PathIsSameRootW      [SHLWAPI.@]
    11391138 */
    11401139BOOL WINAPI PathIsSameRootW(LPCWSTR lpszPath1, LPCWSTR lpszPath2)
    11411140{
    1142     TRACE("%s %s\n", debugstr_w(lpszPath1), debugstr_w(lpszPath2));
    1143 
    1144     if (PathIsRelativeW(lpszPath1) || PathIsRelativeW(lpszPath2)) return FALSE;
    1145 
    1146     /* usual path */
    1147     if ( toupperW(lpszPath1[0])==toupperW(lpszPath2[0]) &&
    1148          lpszPath1[1]==':' && lpszPath2[1]==':' &&
    1149          lpszPath1[2]=='\\' && lpszPath2[2]=='\\')
    1150       return TRUE;
    1151 
    1152     /* UNC */
    1153     if (lpszPath1[0]=='\\' && lpszPath2[0]=='\\' &&
    1154         lpszPath1[1]=='\\' && lpszPath2[1]=='\\')
    1155     {
    1156       int pos=2, bsfound=0;
    1157       while (lpszPath1[pos] && lpszPath2[pos] &&
    1158             (lpszPath1[pos] == lpszPath2[pos]))
    1159       {
    1160         if (lpszPath1[pos]=='\\') bsfound++;
    1161         if (bsfound == 2) return TRUE;
    1162         pos++;/* fixme: use CharNext*/
    1163       }
    1164       return (lpszPath1[pos] == lpszPath2[pos]);
    1165     }
    1166     return FALSE;
     1141        TRACE("%s %s\n", debugstr_w(lpszPath1), debugstr_w(lpszPath2));
     1142       
     1143        if (PathIsRelativeW(lpszPath1) || PathIsRelativeW(lpszPath2)) return FALSE;
     1144
     1145        /* usual path */
     1146        if ( toupperW(lpszPath1[0])==toupperW(lpszPath2[0]) &&
     1147             lpszPath1[1]==':' && lpszPath2[1]==':' &&
     1148             lpszPath1[2]=='\\' && lpszPath2[2]=='\\')
     1149          return TRUE;
     1150
     1151        /* UNC */
     1152        if (lpszPath1[0]=='\\' && lpszPath2[0]=='\\' &&
     1153            lpszPath1[1]=='\\' && lpszPath2[1]=='\\')
     1154        {
     1155          int pos=2, bsfound=0;
     1156          while (lpszPath1[pos] && lpszPath2[pos] &&
     1157                (lpszPath1[pos] == lpszPath2[pos]))
     1158          {
     1159            if (lpszPath1[pos]=='\\') bsfound++;
     1160            if (bsfound == 2) return TRUE;
     1161            pos++;/* fixme: use CharNext*/
     1162          }
     1163          return (lpszPath1[pos] == lpszPath2[pos]);
     1164        }
     1165        return FALSE;
    11671166}
    11681167
     
    11801179  // DWORD dwUnknown = SHREG_xxx; // 0x18
    11811180  // return SHLWAPI_1(lpstrPath, &dwUnknown);
    1182 
    1183 
    1184     LPSTR lpstrRes;
    1185     int iSize, i=0;
    1186     static LPSTR SupportedProtocol[] =
    1187       {"http","https","ftp","gopher","file","mailto",NULL};
    1188 
    1189     if(!lpstrPath) return FALSE;
    1190 
    1191     /* get protocol        */
    1192     lpstrRes = strchr(lpstrPath,':');
    1193     if(!lpstrRes) return FALSE;
    1194     iSize = lpstrRes - lpstrPath;
    1195 
    1196     while(SupportedProtocol[i])
    1197     {
    1198       if (iSize == strlen(SupportedProtocol[i]))
    1199         if(!strncasecmp(lpstrPath, SupportedProtocol[i], iSize))
    1200           return TRUE;
    1201       i++;
    1202     }
    1203 
    1204     return FALSE;
    1205 }
     1181 
     1182 
     1183        LPSTR lpstrRes;
     1184        int iSize, i=0;
     1185        static LPSTR SupportedProtocol[] =
     1186          {"http","https","ftp","gopher","file","mailto",NULL};
     1187
     1188        if(!lpstrPath) return FALSE;
     1189
     1190        /* get protocol        */
     1191        lpstrRes = strchr(lpstrPath,':');
     1192        if(!lpstrRes) return FALSE;
     1193        iSize = lpstrRes - lpstrPath;
     1194
     1195        while(SupportedProtocol[i])
     1196        {
     1197          if (iSize == strlen(SupportedProtocol[i]))
     1198            if(!strncasecmp(lpstrPath, SupportedProtocol[i], iSize))
     1199              return TRUE;
     1200          i++;
     1201        }
     1202
     1203        return FALSE;
     1204} 
    12061205
    12071206/*************************************************************************
     
    12101209BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
    12111210{
    1212     LPWSTR lpstrRes;
    1213     int iSize, i=0;
    1214     static WCHAR SupportedProtocol[7][7] =
    1215       {{'h','t','t','p','\0'},{'h','t','t','p','s','\0'},{'f','t','p','\0'},
    1216       {'g','o','p','h','e','r','\0'},{'f','i','l','e','\0'},
    1217       {'m','a','i','l','t','o','\0'},{0}};
    1218 
    1219     if(!lpstrPath) return FALSE;
    1220 
    1221     /* get protocol        */
    1222     lpstrRes = strchrW(lpstrPath,':');
    1223     if(!lpstrRes) return FALSE;
    1224     iSize = lpstrRes - lpstrPath;
    1225 
    1226     while(SupportedProtocol[i])
    1227     {
    1228       if (iSize == strlenW(SupportedProtocol[i]))
    1229         if(!strncmpiW(lpstrPath, SupportedProtocol[i], iSize))
    1230           return TRUE;
    1231       i++;
    1232     }
    1233 
    1234     return FALSE;
    1235 }
    1236 
    1237 
    1238 /*************************************************************************
    1239  *  PathIsContentTypeA   [SHLWAPI.@]
     1211        LPWSTR lpstrRes;
     1212        int iSize, i=0;
     1213        static WCHAR SupportedProtocol[7][7] =
     1214          {{'h','t','t','p','\0'},{'h','t','t','p','s','\0'},{'f','t','p','\0'},
     1215          {'g','o','p','h','e','r','\0'},{'f','i','l','e','\0'},
     1216          {'m','a','i','l','t','o','\0'},{0}};
     1217
     1218        if(!lpstrPath) return FALSE;
     1219
     1220        /* get protocol        */
     1221        lpstrRes = strchrW(lpstrPath,':');
     1222        if(!lpstrRes) return FALSE;
     1223        iSize = lpstrRes - lpstrPath;
     1224
     1225        while(SupportedProtocol[i])
     1226        {
     1227          if (iSize == strlenW(SupportedProtocol[i]))
     1228            if(!strncmpiW(lpstrPath, SupportedProtocol[i], iSize))
     1229              return TRUE;
     1230          i++;
     1231        }
     1232
     1233        return FALSE;
     1234} 
     1235
     1236
     1237/*************************************************************************
     1238 *      PathIsContentTypeA   [SHLWAPI.@]
    12401239 */
    12411240BOOL WINAPI PathIsContentTypeA(LPCSTR pszPath, LPCSTR pszContentType)
    12421241{
    1243     FIXME("%s %s\n", pszPath, pszContentType);
    1244     return FALSE;
    1245 }
    1246 
    1247 /*************************************************************************
    1248  *  PathIsContentTypeW   [SHLWAPI.@]
     1242        FIXME("%s %s\n", pszPath, pszContentType);
     1243        return FALSE;
     1244}
     1245
     1246/*************************************************************************
     1247 *      PathIsContentTypeW   [SHLWAPI.@]
    12491248 */
    12501249BOOL WINAPI PathIsContentTypeW(LPCWSTR pszPath, LPCWSTR pszContentType)
    12511250{
    1252     FIXME("%s %s\n", debugstr_w(pszPath), debugstr_w(pszContentType));
    1253     return FALSE;
    1254 }
    1255 
    1256 /*************************************************************************
    1257  *  PathIsFileSpecA   [SHLWAPI.@]
     1251        FIXME("%s %s\n", debugstr_w(pszPath), debugstr_w(pszContentType));
     1252        return FALSE;
     1253}
     1254
     1255/*************************************************************************
     1256 *      PathIsFileSpecA   [SHLWAPI.@]
    12581257 */
    12591258BOOL WINAPI PathIsFileSpecA(LPCSTR pszPath)
    12601259{
    1261     FIXME("%s\n", pszPath);
    1262     return FALSE;
    1263 }
    1264 
    1265 /*************************************************************************
    1266  *  PathIsFileSpecW   [SHLWAPI.@]
     1260        FIXME("%s\n", pszPath);
     1261        return FALSE;
     1262}
     1263
     1264/*************************************************************************
     1265 *      PathIsFileSpecW   [SHLWAPI.@]
    12671266 */
    12681267BOOL WINAPI PathIsFileSpecW(LPCWSTR pszPath)
    12691268{
    1270     FIXME("%s\n", debugstr_w(pszPath));
    1271     return FALSE;
    1272 }
    1273 
    1274 /*************************************************************************
    1275  *  PathIsPrefixA   [SHLWAPI.@]
     1269        FIXME("%s\n", debugstr_w(pszPath));
     1270        return FALSE;
     1271}
     1272
     1273/*************************************************************************
     1274 *      PathIsPrefixA   [SHLWAPI.@]
    12761275 */
    12771276BOOL WINAPI PathIsPrefixA(LPCSTR pszPrefix, LPCSTR pszPath)
    12781277{
    1279     FIXME("%s %s\n", pszPrefix, pszPath);
    1280     return FALSE;
    1281 }
    1282 
    1283 /*************************************************************************
    1284  *  PathIsPrefixW   [SHLWAPI.@]
     1278        FIXME("%s %s\n", pszPrefix, pszPath);
     1279        return FALSE;
     1280}
     1281
     1282/*************************************************************************
     1283 *      PathIsPrefixW   [SHLWAPI.@]
    12851284 */
    12861285BOOL WINAPI PathIsPrefixW(LPCWSTR pszPrefix, LPCWSTR pszPath)
    12871286{
    1288     FIXME("%s %s\n", debugstr_w(pszPrefix), debugstr_w(pszPath));
    1289     return FALSE;
    1290 }
    1291 
    1292 /*************************************************************************
    1293  *  PathIsSystemFolderA   [SHLWAPI.@]
     1287        FIXME("%s %s\n", debugstr_w(pszPrefix), debugstr_w(pszPath));
     1288        return FALSE;
     1289}
     1290
     1291/*************************************************************************
     1292 *      PathIsSystemFolderA   [SHLWAPI.@]
    12941293 */
    12951294BOOL WINAPI PathIsSystemFolderA(LPCSTR pszPath, DWORD dwAttrb)
    12961295{
    1297     FIXME("%s 0x%08lx\n", pszPath, dwAttrb);
    1298     return FALSE;
    1299 }
    1300 
    1301 /*************************************************************************
    1302  *  PathIsSystemFolderW   [SHLWAPI.@]
     1296        FIXME("%s 0x%08lx\n", pszPath, dwAttrb);
     1297        return FALSE;
     1298}
     1299
     1300/*************************************************************************
     1301 *      PathIsSystemFolderW   [SHLWAPI.@]
    13031302 */
    13041303BOOL WINAPI PathIsSystemFolderW(LPCWSTR pszPath, DWORD dwAttrb)
    13051304{
    1306     FIXME("%s 0x%08lx\n", debugstr_w(pszPath), dwAttrb);
    1307     return FALSE;
    1308 }
    1309 
    1310 /*************************************************************************
    1311  *  PathIsUNCServerA   [SHLWAPI.@]
     1305        FIXME("%s 0x%08lx\n", debugstr_w(pszPath), dwAttrb);
     1306        return FALSE;
     1307}
     1308
     1309/*************************************************************************
     1310 *      PathIsUNCServerA   [SHLWAPI.@]
    13121311 */
    13131312BOOL WINAPI PathIsUNCServerA(
    1314     LPCSTR pszPath)
    1315 {
    1316     FIXME("%s\n", pszPath);
    1317     return FALSE;
    1318 }
    1319 
    1320 /*************************************************************************
    1321  *  PathIsUNCServerW   [SHLWAPI.@]
     1313        LPCSTR pszPath)
     1314{
     1315        FIXME("%s\n", pszPath);
     1316        return FALSE;
     1317}
     1318
     1319/*************************************************************************
     1320 *      PathIsUNCServerW   [SHLWAPI.@]
    13221321 */
    13231322BOOL WINAPI PathIsUNCServerW(
    1324     LPCWSTR pszPath)
    1325 {
    1326     FIXME("%s\n", debugstr_w(pszPath));
    1327     return FALSE;
    1328 }
    1329 
    1330 /*************************************************************************
    1331  *  PathIsUNCServerShareA   [SHLWAPI.@]
     1323        LPCWSTR pszPath)
     1324{
     1325        FIXME("%s\n", debugstr_w(pszPath));
     1326        return FALSE;
     1327}
     1328
     1329/*************************************************************************
     1330 *      PathIsUNCServerShareA   [SHLWAPI.@]
    13321331 */
    13331332BOOL WINAPI PathIsUNCServerShareA(
    1334     LPCSTR pszPath)
    1335 {
    1336     FIXME("%s\n", pszPath);
    1337     return FALSE;
    1338 }
    1339 
    1340 /*************************************************************************
    1341  *  PathIsUNCServerShareW   [SHLWAPI.@]
     1333        LPCSTR pszPath)
     1334{
     1335        FIXME("%s\n", pszPath);
     1336        return FALSE;
     1337}
     1338
     1339/*************************************************************************
     1340 *      PathIsUNCServerShareW   [SHLWAPI.@]
    13421341 */
    13431342BOOL WINAPI PathIsUNCServerShareW(
    1344     LPCWSTR pszPath)
    1345 {
    1346     FIXME("%s\n", debugstr_w(pszPath));
    1347     return FALSE;
     1343        LPCWSTR pszPath)
     1344{
     1345        FIXME("%s\n", debugstr_w(pszPath));
     1346        return FALSE;
    13481347}
    13491348
     
    13541353 *   returnvalue, use CharNext
    13551354 */
    1356 
     1355 
    13571356BOOL WINAPI PathCanonicalizeA(LPSTR pszBuf, LPCSTR pszPath)
    13581357{
    1359     int OffsetMin = 0, OffsetSrc = 0, OffsetDst = 0, LenSrc = strlen(pszPath);
    1360     BOOL bModifyed = FALSE;
    1361 
    1362     TRACE("%p %s\n", pszBuf, pszPath);
    1363 
    1364     pszBuf[OffsetDst]='\0';
    1365 
    1366     /* keep the root of the path */
    1367     if( LenSrc && (pszPath[OffsetSrc]=='\\'))
    1368     {
    1369       pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1370     }
    1371     else if ( (LenSrc >= 2) && (pszPath[OffsetSrc+1] == ':'))
    1372     {
    1373       pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1374       pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1375       if (LenSrc && (pszPath[OffsetSrc] == '\\'))
    1376       {
    1377         pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1378         if (LenSrc == 1 && pszPath[OffsetSrc]=='.')
    1379         {
    1380           /* C:\. */
    1381           OffsetSrc++; LenSrc--; bModifyed = TRUE;
    1382         }
    1383         else if (LenSrc == 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='.')
    1384         {
    1385           /* C:\.. */
    1386           OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
    1387         }
     1358        int OffsetMin = 0, OffsetSrc = 0, OffsetDst = 0, LenSrc = strlen(pszPath);
     1359        BOOL bModifyed = FALSE;
     1360
     1361        TRACE("%p %s\n", pszBuf, pszPath);
     1362       
     1363        pszBuf[OffsetDst]='\0';
     1364
     1365        /* keep the root of the path */
     1366        if( LenSrc && (pszPath[OffsetSrc]=='\\'))
     1367        {
     1368          pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1369        }
     1370        else if ( (LenSrc >= 2) && (pszPath[OffsetSrc+1] == ':'))
     1371        {
     1372          pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1373          pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1374          if (LenSrc && (pszPath[OffsetSrc] == '\\'))
     1375          {
     1376            pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1377            if (LenSrc == 1 && pszPath[OffsetSrc]=='.')
     1378            {
     1379              /* C:\. */
     1380              OffsetSrc++; LenSrc--; bModifyed = TRUE;
     1381            }
     1382            else if (LenSrc == 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='.')
     1383            {
     1384              /* C:\.. */
     1385              OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
     1386            }
    13881387          }
    1389     }
    1390 
    1391     /* ".\" at the beginning of the path */
    1392     if (LenSrc >= 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='\\')
    1393     {
    1394       OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
    1395     }
    1396 
    1397     while ( LenSrc )
    1398     {
    1399       if((LenSrc>=3) && (pszPath[OffsetSrc]=='\\') && (pszPath[OffsetSrc+1]=='.') && (pszPath[OffsetSrc+2]=='.'))
    1400       {
    1401         /* "\.." found, go one deeper */
    1402         while((OffsetDst > OffsetMin) && (pszBuf[OffsetDst]!='\\')) OffsetDst--;
    1403         OffsetSrc += 3; LenSrc -= 3; bModifyed = TRUE;
    1404         if(OffsetDst == OffsetMin && pszPath[OffsetSrc]=='\\') OffsetSrc++;
    1405         pszBuf[OffsetDst] = '\0';           /* important for \..\.. */
    1406       }
    1407       else if(LenSrc>=2 && pszPath[OffsetSrc]=='\\' && pszPath[OffsetSrc+1]=='.' )
    1408       {
    1409         /* "\." found, skip it */
    1410         OffsetSrc += 2; LenSrc-=2; bModifyed = TRUE;
    1411       }
    1412       else
    1413       {
    1414         pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; LenSrc--;
    1415       }
    1416     }
    1417     pszBuf[OffsetDst] = '\0';
    1418     TRACE("-- %s %u\n", pszBuf, bModifyed);
    1419     return bModifyed;
     1388        }
     1389       
     1390        /* ".\" at the beginning of the path */
     1391        if (LenSrc >= 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='\\')
     1392        {
     1393          OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
     1394        }
     1395       
     1396        while ( LenSrc )
     1397        {
     1398          if((LenSrc>=3) && (pszPath[OffsetSrc]=='\\') && (pszPath[OffsetSrc+1]=='.') && (pszPath[OffsetSrc+2]=='.'))
     1399          {
     1400            /* "\.." found, go one deeper */
     1401            while((OffsetDst > OffsetMin) && (pszBuf[OffsetDst]!='\\')) OffsetDst--;
     1402            OffsetSrc += 3; LenSrc -= 3; bModifyed = TRUE;
     1403            if(OffsetDst == OffsetMin && pszPath[OffsetSrc]=='\\') OffsetSrc++;
     1404            pszBuf[OffsetDst] = '\0';                   /* important for \..\.. */
     1405          }
     1406          else if(LenSrc>=2 && pszPath[OffsetSrc]=='\\' && pszPath[OffsetSrc+1]=='.' )
     1407          {
     1408            /* "\." found, skip it */
     1409            OffsetSrc += 2; LenSrc-=2; bModifyed = TRUE;
     1410          }
     1411          else
     1412          {
     1413            pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; LenSrc--;
     1414          }
     1415        }
     1416        pszBuf[OffsetDst] = '\0';
     1417        TRACE("-- %s %u\n", pszBuf, bModifyed);
     1418        return bModifyed;
    14201419}
    14211420
     
    14291428BOOL WINAPI PathCanonicalizeW(LPWSTR pszBuf, LPCWSTR pszPath)
    14301429{
    1431     int OffsetMin = 0, OffsetSrc = 0, OffsetDst = 0, LenSrc = strlenW(pszPath);
    1432     BOOL bModifyed = FALSE;
    1433 
    1434     TRACE("%p %s\n", pszBuf, debugstr_w(pszPath));
    1435 
    1436     pszBuf[OffsetDst]='\0';
    1437 
    1438     /* keep the root of the path */
    1439     if( LenSrc && (pszPath[OffsetSrc]=='\\'))
    1440     {
    1441       pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1442     }
    1443     else if ( (LenSrc >= 2) && (pszPath[OffsetSrc+1] == ':'))
    1444     {
    1445       pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1446       pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1447       if (LenSrc && (pszPath[OffsetSrc] == '\\'))
    1448       {
    1449         pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
    1450         if (LenSrc == 1 && pszPath[OffsetSrc]=='.')
    1451         {
    1452           /* C:\. */
    1453           OffsetSrc++; LenSrc--; bModifyed = TRUE;
    1454         }
    1455         else if (LenSrc == 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='.')
    1456         {
    1457           /* C:\.. */
    1458           OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
    1459         }
     1430        int OffsetMin = 0, OffsetSrc = 0, OffsetDst = 0, LenSrc = strlenW(pszPath);
     1431        BOOL bModifyed = FALSE;
     1432
     1433        TRACE("%p %s\n", pszBuf, debugstr_w(pszPath));
     1434       
     1435        pszBuf[OffsetDst]='\0';
     1436
     1437        /* keep the root of the path */
     1438        if( LenSrc && (pszPath[OffsetSrc]=='\\'))
     1439        {
     1440          pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1441        }
     1442        else if ( (LenSrc >= 2) && (pszPath[OffsetSrc+1] == ':'))
     1443        {
     1444          pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1445          pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1446          if (LenSrc && (pszPath[OffsetSrc] == '\\'))
     1447          {
     1448            pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; OffsetMin++; LenSrc--;
     1449            if (LenSrc == 1 && pszPath[OffsetSrc]=='.')
     1450            {
     1451              /* C:\. */
     1452              OffsetSrc++; LenSrc--; bModifyed = TRUE;
     1453            }
     1454            else if (LenSrc == 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='.')
     1455            {
     1456              /* C:\.. */
     1457              OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
     1458            }
    14601459          }
    1461     }
    1462 
    1463     /* ".\" at the beginning of the path */
    1464     if (LenSrc >= 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='\\')
    1465     {
    1466       OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
    1467     }
    1468 
    1469     while ( LenSrc )
    1470     {
    1471       if((LenSrc>=3) && (pszPath[OffsetSrc]=='\\') && (pszPath[OffsetSrc+1]=='.') && (pszPath[OffsetSrc+2]=='.'))
    1472       {
    1473         /* "\.." found, go one deeper */
    1474         while((OffsetDst > OffsetMin) && (pszBuf[OffsetDst]!='\\')) OffsetDst--;
    1475         OffsetSrc += 3; LenSrc -= 3; bModifyed = TRUE;
    1476         if(OffsetDst == OffsetMin && pszPath[OffsetSrc]=='\\') OffsetSrc++;
    1477         pszBuf[OffsetDst] = '\0';           /* important for \..\.. */
    1478       }
    1479       else if(LenSrc>=2 && pszPath[OffsetSrc]=='\\' && pszPath[OffsetSrc+1]=='.' )
    1480       {
    1481         /* "\." found, skip it */
    1482         OffsetSrc += 2; LenSrc-=2; bModifyed = TRUE;
    1483       }
    1484       else
    1485       {
    1486         pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; LenSrc--;
    1487       }
    1488     }
    1489     pszBuf[OffsetDst] = '\0';
    1490     TRACE("-- %s %u\n", debugstr_w(pszBuf), bModifyed);
    1491     return bModifyed;
     1460        }
     1461       
     1462        /* ".\" at the beginning of the path */
     1463        if (LenSrc >= 2 && pszPath[OffsetSrc]=='.' && pszPath[OffsetSrc+1]=='\\')
     1464        {
     1465          OffsetSrc+=2; LenSrc-=2; bModifyed = TRUE;
     1466        }
     1467       
     1468        while ( LenSrc )
     1469        {
     1470          if((LenSrc>=3) && (pszPath[OffsetSrc]=='\\') && (pszPath[OffsetSrc+1]=='.') && (pszPath[OffsetSrc+2]=='.'))
     1471          {
     1472            /* "\.." found, go one deeper */
     1473            while((OffsetDst > OffsetMin) && (pszBuf[OffsetDst]!='\\')) OffsetDst--;
     1474            OffsetSrc += 3; LenSrc -= 3; bModifyed = TRUE;
     1475            if(OffsetDst == OffsetMin && pszPath[OffsetSrc]=='\\') OffsetSrc++;
     1476            pszBuf[OffsetDst] = '\0';                   /* important for \..\.. */
     1477          }
     1478          else if(LenSrc>=2 && pszPath[OffsetSrc]=='\\' && pszPath[OffsetSrc+1]=='.' )
     1479          {
     1480            /* "\." found, skip it */
     1481            OffsetSrc += 2; LenSrc-=2; bModifyed = TRUE;
     1482          }
     1483          else
     1484          {
     1485            pszBuf[OffsetDst++] = pszPath[OffsetSrc++]; LenSrc--;
     1486          }
     1487        }
     1488        pszBuf[OffsetDst] = '\0';
     1489        TRACE("-- %s %u\n", debugstr_w(pszBuf), bModifyed);
     1490        return bModifyed;
    14921491}
    14931492
     
    14971496 * NOTES
    14981497 * special cases:
    1499  *  ""              null
    1500  *  aa              "" (pointer to traling NULL)
    1501  *  aa\             "" (pointer to traling NULL)
    1502  *  aa\\            "" (pointer to traling NULL)
    1503  *  aa\\bb          bb
    1504  *  aa\\\bb         \bb
    1505  *  c:\aa\          "aa\"
    1506  *  \\aa            aa
    1507  *  \\aa\b          aa\b
     1498 *      ""              null
     1499 *      aa              "" (pointer to traling NULL)
     1500 *      aa\             "" (pointer to traling NULL)
     1501 *      aa\\            "" (pointer to traling NULL)
     1502 *      aa\\bb          bb
     1503 *      aa\\\bb         \bb
     1504 *      c:\aa\          "aa\"
     1505 *      \\aa            aa
     1506 *      \\aa\b          aa\b
    15081507*/
    15091508LPSTR WINAPI PathFindNextComponentA(LPCSTR pszPath)
    15101509{
    1511     LPSTR pos;
    1512 
    1513     TRACE("%s\n", pszPath);
    1514 
    1515     if(!pszPath || !*pszPath) return NULL;
    1516     if(!(pos = StrChrA(pszPath, '\\')))
    1517       return (LPSTR) pszPath + strlen(pszPath);
    1518     pos++;
    1519     if(pos[0] == '\\') pos++;
    1520     return pos;
     1510        LPSTR pos;
     1511
     1512        TRACE("%s\n", pszPath);
     1513
     1514        if(!pszPath || !*pszPath) return NULL;
     1515        if(!(pos = StrChrA(pszPath, '\\')))
     1516          return (LPSTR) pszPath + strlen(pszPath);
     1517        pos++;
     1518        if(pos[0] == '\\') pos++;
     1519        return pos;
    15211520}
    15221521
     
    15261525LPWSTR WINAPI PathFindNextComponentW(LPCWSTR pszPath)
    15271526{
    1528     LPWSTR pos;
    1529 
    1530     TRACE("%s\n", debugstr_w(pszPath));
    1531 
    1532     if(!pszPath || !*pszPath) return NULL;
    1533     if (!(pos = StrChrW(pszPath, '\\')))
    1534       return (LPWSTR) pszPath + strlenW(pszPath);
    1535     pos++;
    1536     if(pos[0] == '\\') pos++;
    1537     return pos;
     1527        LPWSTR pos;
     1528
     1529        TRACE("%s\n", debugstr_w(pszPath));
     1530       
     1531        if(!pszPath || !*pszPath) return NULL;
     1532        if (!(pos = StrChrW(pszPath, '\\')))
     1533          return (LPWSTR) pszPath + strlenW(pszPath);
     1534        pos++;
     1535        if(pos[0] == '\\') pos++;
     1536        return pos;
    15381537}
    15391538
     
    15441543 *  it adds never a dot
    15451544 */
    1546 
     1545 
    15471546BOOL WINAPI PathAddExtensionA(
    1548     LPSTR  pszPath,
    1549     LPCSTR pszExtension)
    1550 {
    1551     if (*pszPath)
    1552     {
    1553       if (*(PathFindExtensionA(pszPath))) return FALSE;
    1554 
    1555       if (!pszExtension || *pszExtension=='\0')
    1556         strcat(pszPath, "exe");
    1557       else
    1558         strcat(pszPath, pszExtension);
    1559     }
    1560 
    1561     return TRUE;
    1562 }
    1563 
    1564 /*************************************************************************
    1565  *  PathAddExtensionW   [SHLWAPI.@]
     1547        LPSTR  pszPath,
     1548        LPCSTR pszExtension)
     1549{
     1550        if (*pszPath)
     1551        {
     1552          if (*(PathFindExtensionA(pszPath))) return FALSE;
     1553
     1554          if (!pszExtension || *pszExtension=='\0')
     1555            strcat(pszPath, "exe");
     1556          else
     1557            strcat(pszPath, pszExtension);
     1558        }
     1559
     1560        return TRUE;
     1561}
     1562
     1563/*************************************************************************
     1564 *      PathAddExtensionW   [SHLWAPI.@]
    15661565 */
    15671566BOOL WINAPI PathAddExtensionW(
    1568     LPWSTR  pszPath,
    1569     LPCWSTR pszExtension)
    1570 {
    1571     static const WCHAR ext[] = { 'e','x','e',0 };
    1572 
    1573     if (*pszPath)
    1574     {
    1575       if (*(PathFindExtensionW(pszPath))) return FALSE;
    1576 
    1577       if (!pszExtension || *pszExtension=='\0')
    1578         strcatW(pszPath, ext);
    1579       else
    1580         strcatW(pszPath, pszExtension);
    1581     }
    1582     return TRUE;
    1583 
    1584 }
    1585 
    1586 /*************************************************************************
    1587  *  PathMakePrettyA   [SHLWAPI.@]
     1567        LPWSTR  pszPath,
     1568        LPCWSTR pszExtension)
     1569{
     1570        static const WCHAR ext[] = { 'e','x','e',0 };
     1571
     1572        if (*pszPath)
     1573        {
     1574          if (*(PathFindExtensionW(pszPath))) return FALSE;
     1575
     1576          if (!pszExtension || *pszExtension=='\0')
     1577            strcatW(pszPath, ext);
     1578          else
     1579            strcatW(pszPath, pszExtension);
     1580        }
     1581        return TRUE;
     1582
     1583}
     1584
     1585/*************************************************************************
     1586 *      PathMakePrettyA   [SHLWAPI.@]
    15881587 */
    15891588BOOL WINAPI PathMakePrettyA(
    1590     LPSTR lpPath)
    1591 {
    1592     FIXME("%s\n", lpPath);
    1593     return TRUE;
    1594 }
    1595 
    1596 /*************************************************************************
    1597  *  PathMakePrettyW   [SHLWAPI.@]
     1589        LPSTR lpPath)
     1590{
     1591        FIXME("%s\n", lpPath);
     1592        return TRUE;
     1593}
     1594
     1595/*************************************************************************
     1596 *      PathMakePrettyW   [SHLWAPI.@]
    15981597 */
    15991598BOOL WINAPI PathMakePrettyW(
    1600     LPWSTR lpPath)
    1601 {
    1602     FIXME("%s\n", debugstr_w(lpPath));
    1603     return TRUE;
    1604 
    1605 }
    1606 
    1607 /*************************************************************************
    1608  *  PathCommonPrefixA   [SHLWAPI.@]
     1599        LPWSTR lpPath)
     1600{
     1601        FIXME("%s\n", debugstr_w(lpPath));
     1602        return TRUE;
     1603
     1604}
     1605
     1606/*************************************************************************
     1607 *      PathCommonPrefixA   [SHLWAPI.@]
    16091608 */
    16101609int WINAPI PathCommonPrefixA(
    1611     LPCSTR pszFile1,
    1612     LPCSTR pszFile2,
    1613     LPSTR achPath)
    1614 {
    1615     FIXME("%s %s %p\n", pszFile1, pszFile2, achPath);
    1616     return 0;
    1617 }
    1618 
    1619 /*************************************************************************
    1620  *  PathCommonPrefixW   [SHLWAPI.@]
     1610        LPCSTR pszFile1,
     1611        LPCSTR pszFile2,
     1612        LPSTR achPath)
     1613{
     1614        FIXME("%s %s %p\n", pszFile1, pszFile2, achPath);
     1615        return 0;
     1616}
     1617
     1618/*************************************************************************
     1619 *      PathCommonPrefixW   [SHLWAPI.@]
    16211620 */
    16221621int WINAPI PathCommonPrefixW(
    1623     LPCWSTR pszFile1,
    1624     LPCWSTR pszFile2,
    1625     LPWSTR achPath)
    1626 {
    1627     FIXME("%s %s %p\n", debugstr_w(pszFile1), debugstr_w(pszFile2),achPath );
    1628     return 0;
    1629 }
    1630 
    1631 /*************************************************************************
    1632  *  PathCompactPathA   [SHLWAPI.@]
     1622        LPCWSTR pszFile1,
     1623        LPCWSTR pszFile2,
     1624        LPWSTR achPath)
     1625{
     1626        FIXME("%s %s %p\n", debugstr_w(pszFile1), debugstr_w(pszFile2),achPath );
     1627        return 0;
     1628}
     1629
     1630/*************************************************************************
     1631 *      PathCompactPathA   [SHLWAPI.@]
    16331632 */
    16341633BOOL WINAPI PathCompactPathA(HDC hDC, LPSTR pszPath, UINT dx)
    16351634{
    1636     FIXME("0x%08x %s 0x%08x\n", hDC, pszPath, dx);
    1637     return FALSE;
    1638 }
    1639 
    1640 /*************************************************************************
    1641  *  PathCompactPathW   [SHLWAPI.@]
     1635        FIXME("0x%08x %s 0x%08x\n", hDC, pszPath, dx);
     1636        return FALSE;
     1637}
     1638
     1639/*************************************************************************
     1640 *      PathCompactPathW   [SHLWAPI.@]
    16421641 */
    16431642BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR pszPath, UINT dx)
    16441643{
    1645     FIXME("0x%08x %s 0x%08x\n", hDC, debugstr_w(pszPath), dx);
    1646     return FALSE;
    1647 }
    1648 
    1649 /*************************************************************************
    1650  *  PathGetCharTypeA   [SHLWAPI.@]
     1644        FIXME("0x%08x %s 0x%08x\n", hDC, debugstr_w(pszPath), dx);
     1645        return FALSE;
     1646}
     1647
     1648/*************************************************************************
     1649 *      PathGetCharTypeA   [SHLWAPI.@]
    16511650 */
    16521651UINT WINAPI PathGetCharTypeA(UCHAR ch)
     
    16541653        UINT flags = 0;
    16551654
    1656     TRACE("%c\n", ch);
    1657 
    1658     /* We could use them in filenames, but this would confuse 'ls' */
    1659     if (iscntrl(ch))
    1660         return GCT_INVALID;
    1661     if ((ch == '*') || (ch=='?'))
    1662         return GCT_WILD;
    1663     if ((ch == '\\') || (ch=='/'))
    1664         return GCT_SEPARATOR;
    1665     flags = 0;
    1666     /* all normal characters, no lower case letters */
    1667     if ((ch > ' ') && (ch < 0x7f) && !islower(ch))
    1668         flags |= GCT_SHORTCHAR;
    1669     /* All other characters are valid in long filenames, even umlauts */
    1670     return flags | GCT_LFNCHAR;
    1671 }
    1672 
    1673 /*************************************************************************
    1674  *  PathGetCharTypeW   [SHLWAPI.@]
     1655        TRACE("%c\n", ch);
     1656
     1657        /* We could use them in filenames, but this would confuse 'ls' */
     1658        if (iscntrl(ch))
     1659            return GCT_INVALID;
     1660        if ((ch == '*') || (ch=='?'))
     1661            return GCT_WILD;
     1662        if ((ch == '\\') || (ch=='/'))
     1663            return GCT_SEPARATOR;
     1664        flags = 0;
     1665        /* all normal characters, no lower case letters */
     1666        if ((ch > ' ') && (ch < 0x7f) && !islower(ch))
     1667            flags |= GCT_SHORTCHAR;
     1668        /* All other characters are valid in long filenames, even umlauts */
     1669        return flags | GCT_LFNCHAR;
     1670}
     1671
     1672/*************************************************************************
     1673 *      PathGetCharTypeW   [SHLWAPI.@]
    16751674 */
    16761675UINT WINAPI PathGetCharTypeW(WCHAR ch)
    16771676{
    1678     FIXME("%c, using ascii version\n", ch);
    1679     return PathGetCharTypeA(ch);
    1680 }
    1681 
    1682 /*************************************************************************
    1683  *  PathMakeSystemFolderA   [SHLWAPI.@]
     1677        FIXME("%c, using ascii version\n", ch);
     1678        return PathGetCharTypeA(ch);
     1679}
     1680
     1681/*************************************************************************
     1682 *      PathMakeSystemFolderA   [SHLWAPI.@]
    16841683 */
    16851684BOOL WINAPI PathMakeSystemFolderA(LPCSTR pszPath)
    16861685{
    1687     FIXME("%s\n", pszPath);
    1688     return FALSE;
    1689 }
    1690 
    1691 /*************************************************************************
    1692  *  PathMakeSystemFolderW   [SHLWAPI.@]
     1686        FIXME("%s\n", pszPath);
     1687        return FALSE;
     1688}
     1689
     1690/*************************************************************************
     1691 *      PathMakeSystemFolderW   [SHLWAPI.@]
    16931692 */
    16941693BOOL WINAPI PathMakeSystemFolderW(LPCWSTR pszPath)
    16951694{
    1696     FIXME("%s\n", debugstr_w(pszPath));
    1697     return FALSE;
    1698 }
    1699 
    1700 /*************************************************************************
    1701  *  PathRenameExtensionA   [SHLWAPI.@]
     1695        FIXME("%s\n", debugstr_w(pszPath));
     1696        return FALSE;
     1697}
     1698
     1699/*************************************************************************
     1700 *      PathRenameExtensionA   [SHLWAPI.@]
    17021701 */
    17031702BOOL WINAPI PathRenameExtensionA(LPSTR pszPath, LPCSTR pszExt)
    17041703{
    1705     FIXME("%s %s\n", pszPath, pszExt);
    1706     return FALSE;
    1707 }
    1708 
    1709 /*************************************************************************
    1710  *  PathRenameExtensionW   [SHLWAPI.@]
     1704        FIXME("%s %s\n", pszPath, pszExt);
     1705        return FALSE;
     1706}
     1707
     1708/*************************************************************************
     1709 *      PathRenameExtensionW   [SHLWAPI.@]
    17111710 */
    17121711BOOL WINAPI PathRenameExtensionW(LPWSTR pszPath, LPCWSTR pszExt)
    17131712{
    1714     FIXME("%s %s\n", debugstr_w(pszPath), debugstr_w(pszExt));
    1715     return FALSE;
    1716 }
    1717 
    1718 /*************************************************************************
    1719  *  PathSearchAndQualifyA   [SHLWAPI.@]
     1713        FIXME("%s %s\n", debugstr_w(pszPath), debugstr_w(pszExt));
     1714        return FALSE;
     1715}
     1716
     1717/*************************************************************************
     1718 *      PathSearchAndQualifyA   [SHLWAPI.@]
    17201719 */
    17211720BOOL WINAPI PathSearchAndQualifyA(
    1722     LPCSTR pszPath,
    1723     LPSTR pszBuf,
    1724     UINT cchBuf)
    1725 {
    1726     FIXME("%s %s 0x%08x\n", pszPath, pszBuf, cchBuf);
    1727     return FALSE;
    1728 }
    1729 
    1730 /*************************************************************************
    1731  *  PathSearchAndQualifyW   [SHLWAPI.@]
     1721        LPCSTR pszPath,
     1722        LPSTR pszBuf,
     1723        UINT cchBuf)
     1724{
     1725        FIXME("%s %s 0x%08x\n", pszPath, pszBuf, cchBuf);
     1726        return FALSE;
     1727}
     1728
     1729/*************************************************************************
     1730 *      PathSearchAndQualifyW   [SHLWAPI.@]
    17321731 */
    17331732BOOL WINAPI PathSearchAndQualifyW(
    1734     LPCWSTR pszPath,
    1735     LPWSTR pszBuf,
    1736     UINT cchBuf)
    1737 {
    1738     FIXME("%s %s 0x%08x\n", debugstr_w(pszPath), debugstr_w(pszBuf), cchBuf);
    1739     return FALSE;
     1733        LPCWSTR pszPath,
     1734        LPWSTR pszBuf,
     1735        UINT cchBuf)
     1736{
     1737        FIXME("%s %s 0x%08x\n", debugstr_w(pszPath), debugstr_w(pszBuf), cchBuf);
     1738        return FALSE;
    17401739}
    17411740
    17421741#ifndef __WIN32OS2__
    17431742/*************************************************************************
    1744  *  PathSkipRootA   [SHLWAPI.@]
     1743 *      PathSkipRootA   [SHLWAPI.@]
    17451744 */
    17461745LPSTR WINAPI PathSkipRootA(LPCSTR pszPath)
    17471746{
    1748     FIXME("%s\n", pszPath);
    1749     return (LPSTR)pszPath;
    1750 }
    1751 
    1752 /*************************************************************************
    1753  *  PathSkipRootW   [SHLWAPI.@]
     1747        FIXME("%s\n", pszPath);
     1748        return (LPSTR)pszPath;
     1749}
     1750
     1751/*************************************************************************
     1752 *      PathSkipRootW   [SHLWAPI.@]
    17541753 */
    17551754LPWSTR WINAPI PathSkipRootW(LPCWSTR pszPath)
    17561755{
    1757     FIXME("%s\n", debugstr_w(pszPath));
    1758     return (LPWSTR)pszPath;
     1756        FIXME("%s\n", debugstr_w(pszPath));
     1757        return (LPWSTR)pszPath;
    17591758}
    17601759#endif
    17611760
    17621761/*************************************************************************
    1763  *  PathCreateFromUrlA   [SHLWAPI.@]
     1762 *      PathCreateFromUrlA   [SHLWAPI.@]
    17641763 */
    17651764HRESULT WINAPI PathCreateFromUrlA(
    1766     LPCSTR pszUrl,
    1767     LPSTR pszPath,
    1768     LPDWORD pcchPath,
    1769     DWORD dwFlags)
    1770 {
    1771     FIXME("%s %p %p 0x%08lx\n",
    1772       pszUrl, pszPath, pcchPath, dwFlags);
    1773     return S_OK;
    1774 }
    1775 
    1776 /*************************************************************************
    1777  *  PathCreateFromUrlW   [SHLWAPI.@]
     1765        LPCSTR pszUrl,
     1766        LPSTR pszPath,
     1767        LPDWORD pcchPath,
     1768        DWORD dwFlags)
     1769{
     1770        FIXME("%s %p %p 0x%08lx\n",
     1771          pszUrl, pszPath, pcchPath, dwFlags);
     1772        return S_OK;
     1773}
     1774
     1775/*************************************************************************
     1776 *      PathCreateFromUrlW   [SHLWAPI.@]
    17781777 */
    17791778HRESULT WINAPI PathCreateFromUrlW(
    1780     LPCWSTR pszUrl,
    1781     LPWSTR pszPath,
    1782     LPDWORD pcchPath,
    1783     DWORD dwFlags)
    1784 {
    1785     FIXME("%s %p %p 0x%08lx\n",
    1786       debugstr_w(pszUrl), pszPath, pcchPath, dwFlags);
    1787     return S_OK;
    1788 }
    1789 
    1790 /*************************************************************************
    1791  *  PathRelativePathToA   [SHLWAPI.@]
     1779        LPCWSTR pszUrl,
     1780        LPWSTR pszPath,
     1781        LPDWORD pcchPath,
     1782        DWORD dwFlags)
     1783{
     1784        FIXME("%s %p %p 0x%08lx\n",
     1785          debugstr_w(pszUrl), pszPath, pcchPath, dwFlags);
     1786        return S_OK;
     1787}
     1788
     1789/*************************************************************************
     1790 *      PathRelativePathToA   [SHLWAPI.@]
    17921791 */
    17931792BOOL WINAPI PathRelativePathToA(
    1794     LPSTR pszPath,
    1795     LPCSTR pszFrom,
    1796     DWORD dwAttrFrom,
    1797     LPCSTR pszTo,
    1798     DWORD dwAttrTo)
    1799 {
    1800     FIXME("%s %s 0x%08lx %s 0x%08lx\n",
    1801       pszPath, pszFrom, dwAttrFrom, pszTo, dwAttrTo);
    1802     return FALSE;
    1803 }
    1804 
    1805 /*************************************************************************
    1806  *  PathRelativePathToW   [SHLWAPI.@]
     1793        LPSTR pszPath,
     1794        LPCSTR pszFrom,
     1795        DWORD dwAttrFrom,
     1796        LPCSTR pszTo,
     1797        DWORD dwAttrTo)
     1798{
     1799        FIXME("%s %s 0x%08lx %s 0x%08lx\n",
     1800          pszPath, pszFrom, dwAttrFrom, pszTo, dwAttrTo);
     1801        return FALSE;
     1802}
     1803
     1804/*************************************************************************
     1805 *      PathRelativePathToW   [SHLWAPI.@]
    18071806 */
    18081807BOOL WINAPI PathRelativePathToW(
    1809     LPWSTR pszPath,
    1810     LPCWSTR pszFrom,
    1811     DWORD dwAttrFrom,
    1812     LPCWSTR pszTo,
    1813     DWORD dwAttrTo)
    1814 {
    1815     FIXME("%s %s 0x%08lx %s 0x%08lx\n",
    1816       debugstr_w(pszPath), debugstr_w(pszFrom), dwAttrFrom, debugstr_w(pszTo), dwAttrTo);
    1817     return FALSE;
    1818 }
    1819 
    1820 /*************************************************************************
    1821  *  PathUnmakeSystemFolderA   [SHLWAPI.@]
     1808        LPWSTR pszPath,
     1809        LPCWSTR pszFrom,
     1810        DWORD dwAttrFrom,
     1811        LPCWSTR pszTo,
     1812        DWORD dwAttrTo)
     1813{
     1814        FIXME("%s %s 0x%08lx %s 0x%08lx\n",
     1815          debugstr_w(pszPath), debugstr_w(pszFrom), dwAttrFrom, debugstr_w(pszTo), dwAttrTo);
     1816        return FALSE;
     1817}
     1818
     1819/*************************************************************************
     1820 *      PathUnmakeSystemFolderA   [SHLWAPI.@]
    18221821 */
    18231822BOOL WINAPI PathUnmakeSystemFolderA(LPCSTR pszPath)
    18241823{
    1825     FIXME("%s\n", pszPath);
    1826     return FALSE;
    1827 }
    1828 
    1829 /*************************************************************************
    1830  *  PathUnmakeSystemFolderW   [SHLWAPI.@]
     1824        FIXME("%s\n", pszPath);
     1825        return FALSE;
     1826}
     1827
     1828/*************************************************************************
     1829 *      PathUnmakeSystemFolderW   [SHLWAPI.@]
    18311830 */
    18321831BOOL WINAPI PathUnmakeSystemFolderW(LPCWSTR pszPath)
    18331832{
    1834     FIXME("%s\n", debugstr_w(pszPath));
    1835     return FALSE;
     1833        FIXME("%s\n", debugstr_w(pszPath));
     1834        return FALSE;
    18361835}
    18371836
    18381837/*
    1839     ########## special ##########
     1838        ########## special ##########
    18401839*/
    18411840
     
    18461845 *  use PathCompactPath to make sure, the path fits into the control
    18471846 */
    1848 BOOL WINAPI PathSetDlgItemPathA(HWND hDlg, int id, LPCSTR pszPath)
    1849 {   TRACE("%x %x %s\n",hDlg, id, pszPath);
    1850     return SetDlgItemTextA(hDlg, id, pszPath);
     1847BOOL WINAPI PathSetDlgItemPathA(HWND hDlg, int id, LPCSTR pszPath) 
     1848{       TRACE("%x %x %s\n",hDlg, id, pszPath);
     1849        return SetDlgItemTextA(hDlg, id, pszPath);
    18511850}
    18521851
     
    18541853 * PathSetDlgItemPathW   [SHLWAPI.@]
    18551854 */
    1856 BOOL WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR pszPath)
    1857 {   TRACE("%x %x %s\n",hDlg, id, debugstr_w(pszPath));
    1858     return SetDlgItemTextW(hDlg, id, pszPath);
    1859 }
     1855BOOL WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR pszPath) 
     1856{       TRACE("%x %x %s\n",hDlg, id, debugstr_w(pszPath));
     1857        return SetDlgItemTextW(hDlg, id, pszPath);
     1858}
  • trunk/src/shlwapi/reg.c

    r6650 r6712  
    1 /* $Id: reg.c,v 1.5 2001-09-05 13:48:38 bird Exp $ */
    21/*
    32 * SHLWAPI registry functions
     
    3332
    3433/*************************************************************************
    35  * SHRegGetUSValueA [SHLWAPI.@]
     34 * SHRegGetUSValueA     [SHLWAPI.@]
    3635 *
    3736 * Gets a user-specific registry value
    3837 */
    3938LONG WINAPI SHRegGetUSValueA(
    40     LPCSTR   pSubKey,
    41     LPCSTR   pValue,
    42     LPDWORD  pwType,
    43     LPVOID   pvData,
    44     LPDWORD  pbData,
    45     BOOL     fIgnoreHKCU,
    46     LPVOID   pDefaultData,
    47     DWORD    wDefaultDataSize)
    48 {
    49     FIXME("(%p),stub!\n", pSubKey);
    50     return ERROR_SUCCESS;  /* return success */
    51 }
    52 
    53 /*************************************************************************
    54  * SHRegGetUSValueW [SHLWAPI.@]
     39        LPCSTR   pSubKey,
     40        LPCSTR   pValue,
     41        LPDWORD  pwType,
     42        LPVOID   pvData,
     43        LPDWORD  pbData,
     44        BOOL     fIgnoreHKCU,
     45        LPVOID   pDefaultData,
     46        DWORD    wDefaultDataSize)
     47{
     48        FIXME("(%p),stub!\n", pSubKey);
     49        return ERROR_SUCCESS;  /* return success */
     50}
     51
     52/*************************************************************************
     53 * SHRegGetUSValueW     [SHLWAPI.@]
    5554 *
    5655 * Gets a user-specific registry value
    5756 */
    5857LONG WINAPI SHRegGetUSValueW(
    59     LPCWSTR  pSubKey,
    60     LPCWSTR  pValue,
    61     LPDWORD  pwType,
    62     LPVOID   pvData,
    63     LPDWORD  pbData,
    64     BOOL     flagIgnoreHKCU,
    65     LPVOID   pDefaultData,
    66     DWORD    wDefaultDataSize)
    67 {
    68     FIXME("(%p),stub!\n", pSubKey);
    69     return ERROR_SUCCESS;  /* return success */
    70 }
    71 
    72 /*************************************************************************
    73  * SHRegOpenUSKeyA  [SHLWAPI.@]
     58        LPCWSTR  pSubKey,
     59        LPCWSTR  pValue,
     60        LPDWORD  pwType,
     61        LPVOID   pvData,
     62        LPDWORD  pbData,
     63        BOOL     flagIgnoreHKCU,
     64        LPVOID   pDefaultData,
     65        DWORD    wDefaultDataSize)
     66{
     67        FIXME("(%p),stub!\n", pSubKey);
     68        return ERROR_SUCCESS;  /* return success */
     69}
     70
     71/*************************************************************************
     72 * SHRegOpenUSKeyA      [SHLWAPI.@]
    7473 *
    7574 * Openss a user-specific registry key
     
    8281        BOOL fIgnoreHKCU)
    8382{
    84     FIXME("stub!\n");
    85     return ERROR_SUCCESS;  /* return success */
    86 }
    87 
    88 /*************************************************************************
    89  * SHRegOpenUSKeyW  [SHLWAPI.@]
     83        FIXME("stub!\n");
     84        return ERROR_SUCCESS;  /* return success */
     85}
     86
     87/*************************************************************************
     88 * SHRegOpenUSKeyW      [SHLWAPI.@]
    9089 *
    9190 * Openss a user-specific registry key
     
    9897        BOOL fIgnoreHKCU)
    9998{
    100     FIXME("stub!\n");
    101     return ERROR_SUCCESS;  /* return success */
     99        FIXME("stub!\n");
     100        return ERROR_SUCCESS;  /* return success */
    102101}
    103102
     
    107106 */
    108107BOOL WINAPI SHRegGetBoolUSValueA(
    109     LPCSTR pszSubKey,
    110     LPCSTR pszValue,
    111     BOOL fIgnoreHKCU,
    112     BOOL fDefault)
    113 {
    114     FIXME("%s %s\n", pszSubKey,pszValue);
    115     return fDefault;
    116 }
    117 
    118 /*************************************************************************
    119  * SHRegGetBoolUSValueW   [SHLWAPI.@]
     108        LPCSTR pszSubKey,
     109        LPCSTR pszValue,
     110        BOOL fIgnoreHKCU,
     111        BOOL fDefault)
     112{
     113        FIXME("%s %s\n", pszSubKey,pszValue);
     114        return fDefault;
     115}
     116
     117/*************************************************************************
     118 * SHRegGetBoolUSValueW   [SHLWAPI.@]
    120119 */
    121120BOOL WINAPI SHRegGetBoolUSValueW(
    122     LPCWSTR pszSubKey,
    123     LPCWSTR pszValue,
    124     BOOL fIgnoreHKCU,
    125     BOOL fDefault)
    126 {
    127     FIXME("%s %s\n", debugstr_w(pszSubKey),debugstr_w(pszValue));
    128     return fDefault;
     121        LPCWSTR pszSubKey,
     122        LPCWSTR pszValue,
     123        BOOL fIgnoreHKCU,
     124        BOOL fDefault)
     125{
     126        FIXME("%s %s\n", debugstr_w(pszSubKey),debugstr_w(pszValue));
     127        return fDefault;
    129128}
    130129#endif
    131130
    132131/*************************************************************************
    133  *      SHRegQueryUSValueA  [SHLWAPI]
     132 *      SHRegQueryUSValueA      [SHLWAPI]
    134133 */
    135134LONG WINAPI SHRegQueryUSValueA(
    136     HUSKEY hUSKey,             /* [in] FIXME: HUSKEY */
    137     LPCSTR pszValue,
    138     LPDWORD pdwType,
    139     LPVOID pvData,
    140     LPDWORD pcbData,
    141     BOOL fIgnoreHKCU,
    142     LPVOID pvDefaultData,
    143     DWORD dwDefaultDataSize)
    144 {
    145     FIXME("%s stub\n",pszValue);
    146     return 1;
    147 }
    148 
    149 /*************************************************************************
    150  *      SHRegQueryUSValueA  [SHLWAPI]
     135        HUSKEY hUSKey,             /* [in] FIXME: HUSKEY */
     136        LPCSTR pszValue,
     137        LPDWORD pdwType,
     138        LPVOID pvData,
     139        LPDWORD pcbData,
     140        BOOL fIgnoreHKCU,
     141        LPVOID pvDefaultData,
     142        DWORD dwDefaultDataSize)
     143{
     144        FIXME("%s stub\n",pszValue);
     145        return 1;
     146}
     147
     148/*************************************************************************
     149 *      SHRegQueryUSValueA      [SHLWAPI]
    151150 */
    152151LONG WINAPI SHRegQueryUSValueW(
    153     HUSKEY hUSKey,             /* [in] FIXME: HUSKEY */
    154     LPCSTR pszValue,
    155     LPDWORD pdwType,
    156     void *pvData,
    157     LPDWORD pcbData,
    158     BOOL fIgnoreHKCU,
    159     void *pvDefaultData,
    160     DWORD dwDefaultDataSize)
    161 {
    162     FIXME("%s stub\n",pszValue);
    163     return 1;
     152        HUSKEY hUSKey,             /* [in] FIXME: HUSKEY */
     153        LPCSTR pszValue,
     154        LPDWORD pdwType,
     155        void *pvData,
     156        LPDWORD pcbData,
     157        BOOL fIgnoreHKCU,
     158        void *pvDefaultData,
     159        DWORD dwDefaultDataSize)
     160{
     161        FIXME("%s stub\n",pszValue);
     162        return 1;
    164163}
    165164
     
    168167 */
    169168DWORD WINAPI SHRegGetPathA(
    170     HKEY hKey,
    171     LPCSTR pcszSubKey,
    172     LPCSTR pcszValue,
    173     LPSTR pszPath,
    174     DWORD dwFlags)
    175 {
    176     FIXME("%s %s\n", pcszSubKey, pcszValue);
    177     return 0;
     169        HKEY hKey,
     170        LPCSTR pcszSubKey,
     171        LPCSTR pcszValue,
     172        LPSTR pszPath,
     173        DWORD dwFlags)
     174{
     175        FIXME("%s %s\n", pcszSubKey, pcszValue);
     176        return 0;
    178177}
    179178
     
    182181 */
    183182DWORD WINAPI SHRegGetPathW(
    184     HKEY hKey,
    185     LPCWSTR pcszSubKey,
    186     LPCWSTR pcszValue,
    187     LPWSTR pszPath,
    188     DWORD dwFlags)
    189 {
    190     FIXME("%s %s\n", debugstr_w(pcszSubKey), debugstr_w(pcszValue));
    191     return 0;
     183        HKEY hKey,
     184        LPCWSTR pcszSubKey,
     185        LPCWSTR pcszValue,
     186        LPWSTR pszPath,
     187        DWORD dwFlags)
     188{
     189        FIXME("%s %s\n", debugstr_w(pcszSubKey), debugstr_w(pcszValue));
     190        return 0;
    192191}
    193192
     
    198197 */
    199198DWORD WINAPI SHGetValueA(
    200     HKEY     hkey,
    201     LPCSTR   pSubKey,
    202     LPCSTR   pValue,
    203     LPDWORD  pwType,
    204     LPVOID   pvData,
    205     LPDWORD  pbData)
    206 {
    207     HKEY hSubKey;
    208     DWORD res;
    209 
    210     TRACE("(%s %s)\n", pSubKey, pValue);
    211 
    212     if((res = RegOpenKeyA(hkey, pSubKey, &hSubKey))) return res;
    213     res = RegQueryValueExA(hSubKey, pValue, 0, pwType, pvData, pbData);
    214     RegCloseKey( hSubKey );
    215 
    216     return res;
     199        HKEY     hkey,
     200        LPCSTR   pSubKey,
     201        LPCSTR   pValue,
     202        LPDWORD  pwType,
     203        LPVOID   pvData,
     204        LPDWORD  pbData)
     205{
     206        HKEY hSubKey;
     207        DWORD res;
     208
     209        TRACE("(%s %s)\n", pSubKey, pValue);
     210
     211        if((res = RegOpenKeyA(hkey, pSubKey, &hSubKey))) return res;
     212        res = RegQueryValueExA(hSubKey, pValue, 0, pwType, pvData, pbData);
     213        RegCloseKey( hSubKey );
     214
     215        return res;
    217216}
    218217
     
    223222 */
    224223DWORD WINAPI SHGetValueW(
    225     HKEY     hkey,
    226     LPCWSTR  pSubKey,
    227     LPCWSTR  pValue,
    228     LPDWORD  pwType,
    229     LPVOID   pvData,
    230     LPDWORD  pbData)
    231 {
    232     HKEY hSubKey;
    233     DWORD res;
    234 
    235     TRACE("(%s %s)\n", debugstr_w(pSubKey), debugstr_w(pValue));
    236 
    237     if((res = RegOpenKeyW(hkey, pSubKey, &hSubKey))) return res;
    238     res = RegQueryValueExW(hSubKey, pValue, 0, pwType, pvData, pbData);
    239     RegCloseKey( hSubKey );
    240 
    241     return res;
     224        HKEY     hkey,
     225        LPCWSTR  pSubKey,
     226        LPCWSTR  pValue,
     227        LPDWORD  pwType,
     228        LPVOID   pvData,
     229        LPDWORD  pbData)
     230{
     231        HKEY hSubKey;
     232        DWORD res;
     233
     234        TRACE("(%s %s)\n", debugstr_w(pSubKey), debugstr_w(pValue));
     235
     236        if((res = RegOpenKeyW(hkey, pSubKey, &hSubKey))) return res;
     237        res = RegQueryValueExW(hSubKey, pValue, 0, pwType, pvData, pbData);
     238        RegCloseKey( hSubKey );
     239
     240        return res;
    242241}
    243242
     
    246245 */
    247246HRESULT WINAPI SHSetValueA(
    248     HKEY hkey,
    249     LPCSTR pszSubKey,
    250     LPCSTR pszValue,
    251     DWORD dwType,
    252     LPCVOID pvData,
    253     DWORD cbData)
    254 {
    255     HKEY    subkey;
    256     HRESULT hres;
     247        HKEY hkey,
     248        LPCSTR pszSubKey,
     249        LPCSTR pszValue,
     250        DWORD dwType,
     251        LPCVOID pvData,
     252        DWORD cbData)
     253{
     254    HKEY        subkey;
     255    HRESULT     hres;
    257256
    258257    hres = RegCreateKeyA(hkey,pszSubKey,&subkey);
    259258    if (!hres)
    260     return hres;
     259        return hres;
    261260    hres = RegSetValueExA(subkey,pszValue,0,dwType,pvData,cbData);
    262261    RegCloseKey(subkey);
     
    268267 */
    269268HRESULT WINAPI SHSetValueW(
    270     HKEY hkey,
    271     LPCWSTR pszSubKey,
    272     LPCWSTR pszValue,
    273     DWORD dwType,
    274     LPCVOID pvData,
    275     DWORD cbData)
    276 {
    277     HKEY    subkey;
    278     HRESULT hres;
     269        HKEY hkey,
     270        LPCWSTR pszSubKey,
     271        LPCWSTR pszValue,
     272        DWORD dwType,
     273        LPCVOID pvData,
     274        DWORD cbData)
     275{
     276    HKEY        subkey;
     277    HRESULT     hres;
    279278
    280279    hres = RegCreateKeyW(hkey,pszSubKey,&subkey);
    281280    if (!hres)
    282     return hres;
     281        return hres;
    283282    hres = RegSetValueExW(subkey,pszValue,0,dwType,pvData,cbData);
    284283    RegCloseKey(subkey);
     
    287286
    288287/*************************************************************************
    289  * SHQueryValueExA      [SHLWAPI.@]
     288 * SHQueryValueExA              [SHLWAPI.@]
    290289 *
    291290 */
    292291HRESULT WINAPI SHQueryValueExA(
    293     HKEY hkey,
    294     LPSTR lpValueName,
    295     LPDWORD lpReserved,
    296     LPDWORD lpType,
    297     LPBYTE lpData,
    298     LPDWORD lpcbData)
    299 {
    300     TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
    301     return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
     292        HKEY hkey,
     293        LPSTR lpValueName,
     294        LPDWORD lpReserved,
     295        LPDWORD lpType,
     296        LPBYTE lpData,
     297        LPDWORD lpcbData)
     298{
     299        TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
     300        return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
    302301}
    303302
     
    306305 * SHQueryValueExW   [SHLWAPI.@]
    307306 *
    308  * FIXME
     307 * FIXME 
    309308 *  if the datatype REG_EXPAND_SZ then expand the string and change
    310309 *  *pdwType to REG_SZ.
    311310 */
    312311HRESULT WINAPI SHQueryValueExW (
    313     HKEY hkey,
    314     LPWSTR pszValue,
    315     LPDWORD pdwReserved,
    316     LPDWORD pdwType,
    317     LPVOID pvData,
    318     LPDWORD pcbData)
    319 {
    320     WARN("0x%04x %s %p %p %p %p semi-stub\n",
     312        HKEY hkey,
     313        LPWSTR pszValue,
     314        LPDWORD pdwReserved,
     315        LPDWORD pdwType,
     316        LPVOID pvData,
     317        LPDWORD pcbData)
     318{
     319        WARN("0x%04x %s %p %p %p %p semi-stub\n",
    321320             hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
    322     return RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
     321        return RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
    323322}
    324323
     
    333332 */
    334333HRESULT WINAPI SHDeleteKeyA(
    335     HKEY hKey,
    336     LPCSTR lpszSubKey)
     334        HKEY hKey,
     335        LPCSTR lpszSubKey)
    337336{
    338337    DWORD r, dwKeyCount, dwSize, i, dwMaxSubkeyLen;
     
    399398 */
    400399HRESULT WINAPI SHDeleteKeyW(
    401     HKEY hkey,
    402     LPCWSTR pszSubKey)
    403 {
    404     FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
    405     return 0;
     400        HKEY hkey,
     401        LPCWSTR pszSubKey)
     402{
     403        FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
     404        return 0;
    406405}
    407406
     
    412411 */
    413412HRESULT WINAPI SHDeleteValueA(HKEY hkey, LPCSTR pszSubKey, LPCSTR pszValue) {
    414     HKEY    subkey;
    415     HRESULT hres;
     413    HKEY        subkey;
     414    HRESULT     hres;
    416415
    417416    hres = RegOpenKeyA(hkey,pszSubKey,&subkey);
    418417    if (hres)
    419     return hres;
     418        return hres;
    420419    hres = RegDeleteValueA(subkey,pszValue);
    421420    RegCloseKey(subkey);
     
    429428 */
    430429HRESULT WINAPI SHDeleteValueW(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue) {
    431     HKEY    subkey;
    432     HRESULT hres;
     430    HKEY        subkey;
     431    HRESULT     hres;
    433432
    434433    hres = RegOpenKeyW(hkey,pszSubKey,&subkey);
    435434    if (hres)
    436     return hres;
     435        return hres;
    437436    hres = RegDeleteValueW(subkey,pszValue);
    438437    RegCloseKey(subkey);
  • trunk/src/shlwapi/regstream.c

    r6650 r6712  
    1 /* $Id: regstream.c,v 1.3 2001-09-05 13:48:38 bird Exp $ */
    21/*
    3  *  SHRegOpenStream
     2 *      SHRegOpenStream
    43 */
    54#ifdef __WIN32OS2__
     
    2928DEFAULT_DEBUG_CHANNEL(shell);
    3029
    31 typedef struct
    32 {   ICOM_VFIELD(IStream);
    33     DWORD       ref;
    34     HKEY        hKey;
    35     LPBYTE      pbBuffer;
    36     DWORD       dwLength;
    37     DWORD       dwPos;
     30typedef struct 
     31{       ICOM_VFIELD(IStream);
     32        DWORD           ref;
     33        HKEY            hKey;
     34        LPBYTE          pbBuffer;
     35        DWORD           dwLength;
     36        DWORD           dwPos;
    3837} ISHRegStream;
    3938
     
    4140
    4241/**************************************************************************
    43 *   IStream_ConstructorA    [internal]
     42*   IStream_ConstructorA        [internal]
    4443*/
    4544static IStream *IStream_ConstructorA(HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, DWORD grfMode)
    4645{
    47     ISHRegStream*   rstr;
    48     DWORD       dwType;
    49 
    50     rstr = (ISHRegStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHRegStream));
    51 
    52     ICOM_VTBL(rstr)=&rstvt;
    53     rstr->ref = 1;
    54 
    55     if (!(RegOpenKeyExA (hKey, pszSubKey, 0, KEY_READ, &(rstr->hKey))))
    56     {
    57       if (!(RegQueryValueExA(rstr->hKey, pszValue,0,0,0,&(rstr->dwLength))))
    58       {
    59         /* read the binary data into the buffer */
    60         if((rstr->pbBuffer = HeapAlloc(GetProcessHeap(),0,rstr->dwLength)))
    61         {
    62           if (!(RegQueryValueExA(rstr->hKey, pszValue,0,&dwType,rstr->pbBuffer,&(rstr->dwLength))))
    63           {
    64             if (dwType == REG_BINARY )
    65             {
    66               TRACE ("%p\n", rstr);
    67               return (IStream*)rstr;
    68             }
    69           }
    70           HeapFree (GetProcessHeap(),0,rstr->pbBuffer);
    71         }
    72       }
    73       RegCloseKey(rstr->hKey);
    74     }
    75     HeapFree (GetProcessHeap(),0,rstr);
    76     return NULL;
    77 }
    78 
    79 /**************************************************************************
    80 *   IStream_ConstructorW    [internal]
     46        ISHRegStream*   rstr;
     47        DWORD           dwType;
     48       
     49        rstr = (ISHRegStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHRegStream));
     50
     51        ICOM_VTBL(rstr)=&rstvt;
     52        rstr->ref = 1;
     53
     54        if (!(RegOpenKeyExA (hKey, pszSubKey, 0, KEY_READ, &(rstr->hKey))))
     55        {
     56          if (!(RegQueryValueExA(rstr->hKey, pszValue,0,0,0,&(rstr->dwLength))))
     57          {
     58            /* read the binary data into the buffer */
     59            if((rstr->pbBuffer = HeapAlloc(GetProcessHeap(),0,rstr->dwLength)))
     60            {
     61              if (!(RegQueryValueExA(rstr->hKey, pszValue,0,&dwType,rstr->pbBuffer,&(rstr->dwLength))))
     62              {
     63                if (dwType == REG_BINARY )
     64                {
     65                  TRACE ("%p\n", rstr);
     66                  return (IStream*)rstr;
     67                }
     68              }
     69              HeapFree (GetProcessHeap(),0,rstr->pbBuffer);
     70            }
     71          }
     72          RegCloseKey(rstr->hKey);
     73        }
     74        HeapFree (GetProcessHeap(),0,rstr);
     75        return NULL;
     76}
     77
     78/**************************************************************************
     79*   IStream_ConstructorW        [internal]
    8180*/
    8281static IStream *IStream_ConstructorW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD grfMode)
    8382{
    84     ISHRegStream*   rstr;
    85     DWORD       dwType;
    86 
    87     rstr = (ISHRegStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHRegStream));
    88 
    89     ICOM_VTBL(rstr)=&rstvt;
    90     rstr->ref = 1;
    91 
    92     if (!(RegOpenKeyExW (hKey, pszSubKey, 0, KEY_READ, &(rstr->hKey))))
    93     {
    94       if (!(RegQueryValueExW(rstr->hKey, pszValue,0,0,0,&(rstr->dwLength))))
    95       {
    96         /* read the binary data into the buffer */
    97         if((rstr->pbBuffer = HeapAlloc(GetProcessHeap(),0,rstr->dwLength)))
    98         {
    99           if (!(RegQueryValueExW(rstr->hKey, pszValue,0,&dwType,rstr->pbBuffer,&(rstr->dwLength))))
    100           {
    101             if (dwType == REG_BINARY )
    102             {
    103               TRACE ("%p\n", rstr);
    104               return (IStream*)rstr;
    105             }
    106           }
    107           HeapFree (GetProcessHeap(),0,rstr->pbBuffer);
    108         }
    109       }
    110       RegCloseKey(rstr->hKey);
    111     }
    112     HeapFree (GetProcessHeap(),0,rstr);
    113     return NULL;
     83        ISHRegStream*   rstr;
     84        DWORD           dwType;
     85       
     86        rstr = (ISHRegStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHRegStream));
     87
     88        ICOM_VTBL(rstr)=&rstvt;
     89        rstr->ref = 1;
     90
     91        if (!(RegOpenKeyExW (hKey, pszSubKey, 0, KEY_READ, &(rstr->hKey))))
     92        {
     93          if (!(RegQueryValueExW(rstr->hKey, pszValue,0,0,0,&(rstr->dwLength))))
     94          {
     95            /* read the binary data into the buffer */
     96            if((rstr->pbBuffer = HeapAlloc(GetProcessHeap(),0,rstr->dwLength)))
     97            {
     98              if (!(RegQueryValueExW(rstr->hKey, pszValue,0,&dwType,rstr->pbBuffer,&(rstr->dwLength))))
     99              {
     100                if (dwType == REG_BINARY )
     101                {
     102                  TRACE ("%p\n", rstr);
     103                  return (IStream*)rstr;
     104                }
     105              }
     106              HeapFree (GetProcessHeap(),0,rstr->pbBuffer);
     107            }
     108          }
     109          RegCloseKey(rstr->hKey);
     110        }
     111        HeapFree (GetProcessHeap(),0,rstr);
     112        return NULL;
    114113}
    115114
     
    119118static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
    120119{
    121     ICOM_THIS(ISHRegStream, iface);
    122 
    123 ////    TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
    124 
    125     *ppvObj = NULL;
    126 
    127     if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
    128     { *ppvObj = This;
    129     }
    130     else if(IsEqualIID(riid, &IID_IStream)) /*IStream*/
    131     { *ppvObj = This;
    132     }
    133 
    134     if(*ppvObj)
    135     {
    136       IStream_AddRef((IStream*)*ppvObj);
    137       TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
    138       return S_OK;
    139     }
    140     TRACE("-- Interface: E_NOINTERFACE\n");
    141     return E_NOINTERFACE;
     120        ICOM_THIS(ISHRegStream, iface);
     121
     122////    TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
     123
     124        *ppvObj = NULL;
     125
     126        if(IsEqualIID(riid, &IID_IUnknown))     /*IUnknown*/
     127        { *ppvObj = This;
     128        }
     129        else if(IsEqualIID(riid, &IID_IStream)) /*IStream*/
     130        { *ppvObj = This;
     131        }   
     132
     133        if(*ppvObj)
     134        {
     135          IStream_AddRef((IStream*)*ppvObj);     
     136          TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
     137          return S_OK;
     138        }
     139        TRACE("-- Interface: E_NOINTERFACE\n");
     140        return E_NOINTERFACE;
    142141}
    143142
     
    147146static ULONG WINAPI IStream_fnAddRef(IStream *iface)
    148147{
    149     ICOM_THIS(ISHRegStream, iface);
    150 
    151     TRACE("(%p)->(count=%lu)\n",This, This->ref);
    152 
    153     return ++(This->ref);
     148        ICOM_THIS(ISHRegStream, iface);
     149
     150        TRACE("(%p)->(count=%lu)\n",This, This->ref);
     151
     152        return ++(This->ref);
    154153}
    155154
     
    159158static ULONG WINAPI IStream_fnRelease(IStream *iface)
    160159{
    161     ICOM_THIS(ISHRegStream, iface);
    162 
    163     TRACE("(%p)->()\n",This);
    164 
    165     if (!--(This->ref))
    166     { TRACE(" destroying SHReg IStream (%p)\n",This);
    167 
    168       if (This->pbBuffer)
    169         HeapFree(GetProcessHeap(),0,This->pbBuffer);
    170 
    171       if (This->hKey)
    172         RegCloseKey(This->hKey);
    173 
    174       HeapFree(GetProcessHeap(),0,This);
    175       return 0;
    176     }
    177     return This->ref;
     160        ICOM_THIS(ISHRegStream, iface);
     161
     162        TRACE("(%p)->()\n",This);
     163
     164        if (!--(This->ref))
     165        { TRACE(" destroying SHReg IStream (%p)\n",This);
     166
     167          if (This->pbBuffer)
     168            HeapFree(GetProcessHeap(),0,This->pbBuffer);
     169
     170          if (This->hKey)
     171            RegCloseKey(This->hKey);
     172
     173          HeapFree(GetProcessHeap(),0,This);
     174          return 0;
     175        }
     176        return This->ref;
    178177}
    179178
    180179static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead)
    181180{
    182     ICOM_THIS(ISHRegStream, iface);
    183 
    184     DWORD dwBytesToRead, dwBytesLeft;
    185 
    186     TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
    187 
    188     if ( !pv )
    189       return STG_E_INVALIDPOINTER;
    190 
    191     dwBytesLeft = This->dwLength - This->dwPos;
    192 
    193     if ( 0 >= dwBytesLeft )                     /* end of buffer */
    194       return S_FALSE;
    195 
    196     dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
    197 
    198     memmove ( pv, (This->pbBuffer) + (This->dwPos), dwBytesToRead);
    199 
    200     This->dwPos += dwBytesToRead;                   /* adjust pointer */
    201 
    202     if (pcbRead)
    203       *pcbRead = dwBytesToRead;
    204 
    205     return S_OK;
     181        ICOM_THIS(ISHRegStream, iface);
     182
     183        DWORD dwBytesToRead, dwBytesLeft;
     184       
     185        TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
     186       
     187        if ( !pv )
     188          return STG_E_INVALIDPOINTER;
     189         
     190        dwBytesLeft = This->dwLength - This->dwPos;
     191
     192        if ( 0 >= dwBytesLeft )                                         /* end of buffer */
     193          return S_FALSE;
     194       
     195        dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
     196
     197        memmove ( pv, (This->pbBuffer) + (This->dwPos), dwBytesToRead);
     198       
     199        This->dwPos += dwBytesToRead;                                   /* adjust pointer */
     200
     201        if (pcbRead)
     202          *pcbRead = dwBytesToRead;
     203
     204        return S_OK;
    206205}
    207206static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten)
    208207{
    209     ICOM_THIS(ISHRegStream, iface);
    210 
    211     TRACE("(%p)\n",This);
    212 
    213     return E_NOTIMPL;
     208        ICOM_THIS(ISHRegStream, iface);
     209
     210        TRACE("(%p)\n",This);
     211
     212        return E_NOTIMPL;
    214213}
    215214static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
    216215{
    217     ICOM_THIS(ISHRegStream, iface);
    218 
    219     TRACE("(%p)\n",This);
    220 
    221     return E_NOTIMPL;
     216        ICOM_THIS(ISHRegStream, iface);
     217
     218        TRACE("(%p)\n",This);
     219
     220        return E_NOTIMPL;
    222221}
    223222static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize)
    224223{
    225     ICOM_THIS(ISHRegStream, iface);
    226 
    227     TRACE("(%p)\n",This);
    228 
    229     return E_NOTIMPL;
     224        ICOM_THIS(ISHRegStream, iface);
     225
     226        TRACE("(%p)\n",This);
     227
     228        return E_NOTIMPL;
    230229}
    231230static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
    232231{
    233     ICOM_THIS(ISHRegStream, iface);
    234 
    235     TRACE("(%p)\n",This);
    236 
    237     return E_NOTIMPL;
     232        ICOM_THIS(ISHRegStream, iface);
     233
     234        TRACE("(%p)\n",This);
     235
     236        return E_NOTIMPL;
    238237}
    239238static HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags)
    240239{
    241     ICOM_THIS(ISHRegStream, iface);
    242 
    243     TRACE("(%p)\n",This);
    244 
    245     return E_NOTIMPL;
     240        ICOM_THIS(ISHRegStream, iface);
     241
     242        TRACE("(%p)\n",This);
     243
     244        return E_NOTIMPL;
    246245}
    247246static HRESULT WINAPI IStream_fnRevert (IStream * iface)
    248247{
    249     ICOM_THIS(ISHRegStream, iface);
    250 
    251     TRACE("(%p)\n",This);
    252 
    253     return E_NOTIMPL;
     248        ICOM_THIS(ISHRegStream, iface);
     249
     250        TRACE("(%p)\n",This);
     251
     252        return E_NOTIMPL;
    254253}
    255254static HRESULT WINAPI IStream_fnLockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
    256255{
    257     ICOM_THIS(ISHRegStream, iface);
    258 
    259     TRACE("(%p)\n",This);
    260 
    261     return E_NOTIMPL;
     256        ICOM_THIS(ISHRegStream, iface);
     257
     258        TRACE("(%p)\n",This);
     259
     260        return E_NOTIMPL;
    262261}
    263262static HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
    264263{
    265     ICOM_THIS(ISHRegStream, iface);
    266 
    267     TRACE("(%p)\n",This);
    268 
    269     return E_NOTIMPL;
     264        ICOM_THIS(ISHRegStream, iface);
     265
     266        TRACE("(%p)\n",This);
     267
     268        return E_NOTIMPL;
    270269}
    271270static HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG*   pstatstg, DWORD grfStatFlag)
    272271{
    273     ICOM_THIS(ISHRegStream, iface);
    274 
    275     TRACE("(%p)\n",This);
    276 
    277     return E_NOTIMPL;
     272        ICOM_THIS(ISHRegStream, iface);
     273
     274        TRACE("(%p)\n",This);
     275
     276        return E_NOTIMPL;
    278277}
    279278static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm)
    280279{
    281     ICOM_THIS(ISHRegStream, iface);
    282 
    283     TRACE("(%p)\n",This);
    284 
    285     return E_NOTIMPL;
    286 }
    287 
    288 static struct ICOM_VTABLE(IStream) rstvt =
    289 {
    290     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    291     IStream_fnQueryInterface,
    292     IStream_fnAddRef,
    293     IStream_fnRelease,
    294     IStream_fnRead,
    295     IStream_fnWrite,
    296     IStream_fnSeek,
    297     IStream_fnSetSize,
    298     IStream_fnCopyTo,
    299     IStream_fnCommit,
    300     IStream_fnRevert,
    301     IStream_fnLockRegion,
    302     IStream_fnUnlockRegion,
    303     IStream_fnStat,
    304     IStream_fnClone
    305 
     280        ICOM_THIS(ISHRegStream, iface);
     281
     282        TRACE("(%p)\n",This);
     283
     284        return E_NOTIMPL;
     285}
     286
     287static struct ICOM_VTABLE(IStream) rstvt = 
     288{       
     289        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     290        IStream_fnQueryInterface,
     291        IStream_fnAddRef,
     292        IStream_fnRelease,
     293        IStream_fnRead,
     294        IStream_fnWrite,
     295        IStream_fnSeek,
     296        IStream_fnSetSize,
     297        IStream_fnCopyTo,
     298        IStream_fnCommit,
     299        IStream_fnRevert,
     300        IStream_fnLockRegion,
     301        IStream_fnUnlockRegion,
     302        IStream_fnStat,
     303        IStream_fnClone
     304       
    306305};
    307306
    308307/*************************************************************************
    309  * SHOpenRegStreamA             [SHLWAPI.@]
     308 * SHOpenRegStreamA                             [SHLWAPI.@]
    310309 */
    311310IStream * WINAPI SHOpenRegStreamA(
    312     HKEY hkey,
    313     LPCSTR pszSubkey,
    314     LPCSTR pszValue,
    315     DWORD grfMode)
    316 {
    317     TRACE("(0x%08x,%s,%s,0x%08lx)\n",
    318     hkey, pszSubkey, pszValue, grfMode);
    319 
    320     return IStream_ConstructorA(hkey, pszSubkey, pszValue, grfMode);
     311        HKEY hkey,
     312        LPCSTR pszSubkey,
     313        LPCSTR pszValue,
     314        DWORD grfMode)
     315{
     316        TRACE("(0x%08x,%s,%s,0x%08lx)\n",
     317        hkey, pszSubkey, pszValue, grfMode);
     318
     319        return IStream_ConstructorA(hkey, pszSubkey, pszValue, grfMode);
    321320}
    322321
    323322/*************************************************************************
    324  * SHOpenRegStreamW             [SHLWAPI.@]
     323 * SHOpenRegStreamW                             [SHLWAPI.@]
    325324 */
    326325IStream * WINAPI SHOpenRegStreamW(
    327     HKEY hkey,
    328     LPCWSTR pszSubkey,
    329     LPCWSTR pszValue,
    330     DWORD grfMode)
    331 {
    332     TRACE("(0x%08x,%s,%s,0x%08lx)\n",
    333     hkey, debugstr_w(pszSubkey), debugstr_w(pszValue), grfMode);
    334 
    335     return IStream_ConstructorW(hkey, pszSubkey, pszValue, grfMode);
    336 }
     326        HKEY hkey,
     327        LPCWSTR pszSubkey,
     328        LPCWSTR pszValue,
     329        DWORD grfMode)
     330{
     331        TRACE("(0x%08x,%s,%s,0x%08lx)\n",
     332        hkey, debugstr_w(pszSubkey), debugstr_w(pszValue), grfMode);
     333
     334        return IStream_ConstructorW(hkey, pszSubkey, pszValue, grfMode);
     335}
  • trunk/src/shlwapi/shlwapiguid.c

    r6650 r6712  
    1 /* $Id: shlwapiguid.c,v 1.2 2001-09-05 13:48:38 bird Exp $ */
    21/*
    3  *  SHRegOpenStream
     2 *      SHRegOpenStream
    43 */
    54#ifdef __WIN32OS2__
  • trunk/src/shlwapi/string.c

    r6650 r6712  
    1 /* $Id: string.c,v 1.5 2001-09-05 13:48:39 bird Exp $ */
    21//Note: Odin changes marked by #ifdef __WIN32OS2__!
    32#ifdef __WIN32OS2__
     
    1615#endif
    1716#include <ctype.h>
    18 #include <stdlib.h>
     17#include <stdlib.h> 
    1918#include <stdio.h>
    2019#include <string.h>
     
    4241
    4342/*************************************************************************
    44  * StrChrA                  [SHLWAPI]
     43 * StrChrA                                      [SHLWAPI]
    4544 */
    4645LPSTR WINAPI StrChrA (LPCSTR str, WORD c)
    4746{
    48     TRACE("%s %i\n", str,c);
    49     return strchr(str, c);
    50 }
    51 
    52 /*************************************************************************
    53  * StrChrW                  [SHLWAPI]
     47        TRACE("%s %i\n", str,c);
     48        return strchr(str, c);
     49}
     50
     51/*************************************************************************
     52 * StrChrW                                      [SHLWAPI]
    5453 *
    5554 */
    5655LPWSTR WINAPI StrChrW (LPCWSTR str, WCHAR x )
    5756{
    58     TRACE("%s 0x%04x\n",debugstr_w(str),x);
    59     return strchrW(str, x);
     57        TRACE("%s 0x%04x\n",debugstr_w(str),x);
     58        return strchrW(str, x);
    6059}
    6160#ifndef __WIN32OS2__
    6261/*************************************************************************
    63  * StrCmpIW                 [SHLWAPI]
     62 * StrCmpIW                                     [SHLWAPI]
    6463 */
    6564int WINAPI StrCmpIW ( LPCWSTR wstr1, LPCWSTR wstr2 )
     
    7170
    7271/*************************************************************************
    73  * StrCmpNA                 [SHLWAPI]
     72 * StrCmpNA                                     [SHLWAPI]
    7473 */
    7574INT WINAPI StrCmpNA ( LPCSTR str1, LPCSTR str2, INT len)
    7675{
    77     TRACE("%s %s %i stub\n", str1,str2,len);
    78     return strncmp(str1, str2, len);
    79 }
    80 
    81 /*************************************************************************
    82  * StrCmpNW                 [SHLWAPI]
     76        TRACE("%s %s %i stub\n", str1,str2,len);
     77        return strncmp(str1, str2, len);
     78}
     79
     80/*************************************************************************
     81 * StrCmpNW                                     [SHLWAPI]
    8382 */
    8483INT WINAPI StrCmpNW ( LPCWSTR wstr1, LPCWSTR wstr2, INT len)
    8584{
    86     TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
    87     return strncmpW(wstr1, wstr2, len);
    88 }
    89 
    90 /*************************************************************************
    91  * StrCmpNIA                    [SHLWAPI]
     85        TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
     86        return strncmpW(wstr1, wstr2, len);
     87}
     88
     89/*************************************************************************
     90 * StrCmpNIA                                    [SHLWAPI]
    9291 */
    9392int WINAPI StrCmpNIA ( LPCSTR str1, LPCSTR str2, int len)
    9493{
    95     TRACE("%s %s %i stub\n", str1,str2,len);
    96     return strncasecmp(str1, str2, len);
    97 }
    98 
    99 /*************************************************************************
    100  * StrCmpNIW                    [SHLWAPI]
     94        TRACE("%s %s %i stub\n", str1,str2,len);
     95        return strncasecmp(str1, str2, len);
     96}
     97
     98/*************************************************************************
     99 * StrCmpNIW                                    [SHLWAPI]
    101100 */
    102101int WINAPI StrCmpNIW ( LPCWSTR wstr1, LPCWSTR wstr2, int len)
    103102{
    104     TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
    105     return strncmpiW(wstr1, wstr2, len);
    106 }
    107 
    108 /*************************************************************************
    109  * StrCmpW                  [SHLWAPI]
     103        TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
     104        return strncmpiW(wstr1, wstr2, len);
     105}
     106
     107/*************************************************************************
     108 * StrCmpW                                      [SHLWAPI]
    110109 */
    111110int WINAPI StrCmpW ( LPCWSTR wstr1, LPCWSTR wstr2 )
     
    116115
    117116/*************************************************************************
    118  * StrCatW                  [SHLWAPI]
     117 * StrCatW                                      [SHLWAPI]
    119118 */
    120119LPWSTR WINAPI StrCatW( LPWSTR wstr1, LPCWSTR wstr2 )
     
    125124
    126125/*************************************************************************
    127  * StrCpyW                  [SHLWAPI]
     126 * StrCpyW                                      [SHLWAPI]
    128127 */
    129128LPWSTR WINAPI StrCpyW( LPWSTR wstr1, LPCWSTR wstr2 )
     
    134133
    135134/*************************************************************************
    136  * StrCpyNW                 [SHLWAPI]
     135 * StrCpyNW                                     [SHLWAPI]
    137136 */
    138137LPWSTR WINAPI StrCpyNW( LPWSTR wstr1, LPCWSTR wstr2, int n )
     
    143142
    144143/*************************************************************************
    145  * StrStrA                  [SHLWAPI]
     144 * StrStrA                                      [SHLWAPI]
    146145 */
    147146LPSTR WINAPI StrStrA(LPCSTR lpFirst, LPCSTR lpSrch)
     
    158157
    159158/*************************************************************************
    160  * StrStrW                  [SHLWAPI]
     159 * StrStrW                                      [SHLWAPI]
    161160 */
    162161LPWSTR WINAPI StrStrW(LPCWSTR lpFirst, LPCWSTR lpSrch)
     
    173172
    174173/*************************************************************************
    175  * StrStrIA                 [SHLWAPI]
     174 * StrStrIA                                     [SHLWAPI]
    176175 */
    177176LPSTR WINAPI StrStrIA(LPCSTR lpFirst, LPCSTR lpSrch)
     
    188187
    189188/*************************************************************************
    190  * StrStrIW                 [SHLWAPI]
     189 * StrStrIW                                     [SHLWAPI]
    191190 */
    192191LPWSTR WINAPI StrStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch)
     
    203202
    204203/*************************************************************************
    205  *  StrToIntA           [SHLWAPI]
     204 *      StrToIntA                       [SHLWAPI]
    206205 */
    207206int WINAPI StrToIntA(LPCSTR lpSrc)
    208207{
    209     TRACE("%s\n", lpSrc);
    210     return atol(lpSrc);
    211 }
    212 
    213 /*************************************************************************
    214  *  StrToIntW           [SHLWAPI]
     208        TRACE("%s\n", lpSrc);
     209        return atol(lpSrc);
     210}
     211
     212/*************************************************************************
     213 *      StrToIntW                       [SHLWAPI]
    215214 */
    216215int WINAPI StrToIntW(LPCWSTR lpSrc)
     
    225224
    226225/*************************************************************************
    227  *  StrToIntExA         [SHLWAPI]
     226 *      StrToIntExA                     [SHLWAPI]
    228227 */
    229228BOOL WINAPI StrToIntExA( LPCSTR pszString, DWORD dwFlags, LPINT piRet)
    230229{
    231     TRACE("%s %ld stub !\n", debugstr_a(pszString), dwFlags);
    232     piRet = (LPINT) StrToIntA(pszString);
    233     return TRUE;
    234 }
    235 
    236 /*************************************************************************
    237  *  StrToIntExW         [SHLWAPI]
     230        TRACE("%s %ld stub !\n", debugstr_a(pszString), dwFlags);
     231        piRet = (LPINT) StrToIntA(pszString);
     232        return TRUE;
     233}
     234
     235/*************************************************************************
     236 *      StrToIntExW                     [SHLWAPI]
    238237 */
    239238BOOL WINAPI StrToIntExW( LPCWSTR pszString, DWORD dwFlags, LPINT piRet)
    240239{
    241     TRACE("%s %ld stub !\n", debugstr_w(pszString), dwFlags);
    242     piRet = (LPINT) StrToIntW(pszString);
    243     return TRUE;
    244 }
    245 
    246 /*************************************************************************
    247  *  StrDupA         [SHLWAPI]
     240        TRACE("%s %ld stub !\n", debugstr_w(pszString), dwFlags);
     241        piRet = (LPINT) StrToIntW(pszString);
     242        return TRUE;
     243}
     244
     245/*************************************************************************
     246 *      StrDupA                 [SHLWAPI]
    248247 */
    249248LPSTR WINAPI StrDupA (LPCSTR lpSrc)
    250249{
    251     int len = strlen(lpSrc);
    252     LPSTR lpDest = (LPSTR) LocalAlloc(LMEM_FIXED, len+1);
    253 
    254     TRACE("%s\n", lpSrc);
    255 
    256     if (lpDest) strcpy(lpDest, lpSrc);
    257     return lpDest;
    258 }
    259 
    260 /*************************************************************************
    261  *  StrDupW         [SHLWAPI]
     250        int len = strlen(lpSrc);
     251        LPSTR lpDest = (LPSTR) LocalAlloc(LMEM_FIXED, len+1);
     252       
     253        TRACE("%s\n", lpSrc);
     254
     255        if (lpDest) strcpy(lpDest, lpSrc);
     256        return lpDest;
     257}
     258
     259/*************************************************************************
     260 *      StrDupW                 [SHLWAPI]
    262261 */
    263262LPWSTR WINAPI StrDupW (LPCWSTR lpSrc)
    264263{
    265     int len = strlenW(lpSrc);
    266     LPWSTR lpDest = (LPWSTR) LocalAlloc(LMEM_FIXED, sizeof(WCHAR) * (len+1));
    267 
    268     TRACE("%s\n", debugstr_w(lpSrc));
    269 
    270     if (lpDest) strcpyW(lpDest, lpSrc);
    271     return lpDest;
    272 }
    273 
    274 /*************************************************************************
    275  *  StrCSpnA        [SHLWAPI]
     264        int len = strlenW(lpSrc);
     265        LPWSTR lpDest = (LPWSTR) LocalAlloc(LMEM_FIXED, sizeof(WCHAR) * (len+1));
     266       
     267        TRACE("%s\n", debugstr_w(lpSrc));
     268
     269        if (lpDest) strcpyW(lpDest, lpSrc);
     270        return lpDest;
     271}
     272
     273/*************************************************************************
     274 *      StrCSpnA                [SHLWAPI]
    276275 */
    277276int WINAPI StrCSpnA (LPCSTR lpStr, LPCSTR lpSet)
    278277{
    279     int i,j, pos = strlen(lpStr);
    280 
    281     TRACE("(%p %s  %p %s)\n",
    282        lpStr, debugstr_a(lpStr), lpSet, debugstr_a(lpSet));
    283 
    284     for (i=0; i < strlen(lpSet) ; i++ )
    285     {
    286       for (j = 0; j < pos;j++)
    287       {
    288         if (lpStr[j] == lpSet[i])
    289         {
    290           pos = j;
    291         }
    292       }
    293     }
    294     TRACE("-- %u\n", pos);
    295     return pos;
    296 }
    297 
    298 /*************************************************************************
    299  *  StrCSpnW        [SHLWAPI]
     278        int i,j, pos = strlen(lpStr);
     279
     280        TRACE("(%p %s  %p %s)\n",
     281           lpStr, debugstr_a(lpStr), lpSet, debugstr_a(lpSet));
     282
     283        for (i=0; i < strlen(lpSet) ; i++ )
     284        {
     285          for (j = 0; j < pos;j++)
     286          {
     287            if (lpStr[j] == lpSet[i])
     288            {
     289              pos = j;
     290            }
     291          }
     292        }     
     293        TRACE("-- %u\n", pos);
     294        return pos;     
     295}
     296
     297/*************************************************************************
     298 *      StrCSpnW                [SHLWAPI]
    300299 */
    301300int WINAPI StrCSpnW (LPCWSTR lpStr, LPCWSTR lpSet)
    302301{
    303     int i,j, pos = strlenW(lpStr);
    304 
    305     TRACE("(%p %s %p %s)\n",
    306        lpStr, debugstr_w(lpStr), lpSet, debugstr_w(lpSet));
    307 
    308     for (i=0; i < strlenW(lpSet) ; i++ )
    309     {
    310       for (j = 0; j < pos;j++)
    311       {
    312         if (lpStr[j] == lpSet[i])
    313         {
    314           pos = j;
    315         }
    316       }
    317     }
    318     TRACE("-- %u\n", pos);
    319     return pos;
     302        int i,j, pos = strlenW(lpStr);
     303
     304        TRACE("(%p %s %p %s)\n",
     305           lpStr, debugstr_w(lpStr), lpSet, debugstr_w(lpSet));
     306
     307        for (i=0; i < strlenW(lpSet) ; i++ )
     308        {
     309          for (j = 0; j < pos;j++)
     310          {
     311            if (lpStr[j] == lpSet[i])
     312            {
     313              pos = j;
     314            }
     315          }
     316        }     
     317        TRACE("-- %u\n", pos);
     318        return pos;     
    320319}
    321320
     
    338337        if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
    339338        lpGotIt = lpStart;
    340     }
     339    }   
    341340    return (LPSTR)lpGotIt;
    342341}
     
    362361
    363362/*************************************************************************
    364  *  StrCatBuffA     [SHLWAPI]
     363 *      StrCatBuffA             [SHLWAPI]
    365364 *
    366365 * Appends back onto front, stopping when front is size-1 characters long.
     
    380379
    381380/*************************************************************************
    382  *  StrCatBuffW     [SHLWAPI]
     381 *      StrCatBuffW             [SHLWAPI]
    383382 *
    384383 * Appends back onto front, stopping when front is size-1 characters long.
     
    398397
    399398/*************************************************************************
    400  * StrRetToBufA                 [SHLWAPI.@]
    401  *
     399 * StrRetToBufA                                 [SHLWAPI.@]
     400 * 
    402401 * converts a STRRET to a normal string
    403402 *
     
    407406HRESULT WINAPI StrRetToBufA (LPSTRRET src, const ITEMIDLIST *pidl, LPSTR dest, DWORD len)
    408407{
    409     TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
    410 
    411     switch (src->uType)
    412     {
    413       case STRRET_WSTR:
    414         WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
    415 /*      SHFree(src->u.pOleStr);  FIXME: is this right? */
    416         break;
    417 
    418       case STRRET_CSTRA:
    419         lstrcpynA((LPSTR)dest, src->u.cStr, len);
    420         break;
    421 
    422       case STRRET_OFFSETA:
    423         lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
    424         break;
    425 
    426       default:
    427         FIXME("unknown type!\n");
    428         if (len)
    429         {
    430           *(LPSTR)dest = '\0';
    431         }
    432         return(FALSE);
    433     }
    434     return S_OK;
    435 }
    436 
    437 /*************************************************************************
    438  * StrRetToBufW                 [SHLWAPI.@]
    439  *
     408        TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
     409
     410        switch (src->uType)
     411        {
     412          case STRRET_WSTR:
     413            WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
     414/*          SHFree(src->u.pOleStr);  FIXME: is this right? */
     415            break;
     416
     417          case STRRET_CSTRA:
     418            lstrcpynA((LPSTR)dest, src->u.cStr, len);
     419            break;
     420
     421          case STRRET_OFFSETA:
     422            lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
     423            break;
     424
     425          default:
     426            FIXME("unknown type!\n");
     427            if (len)
     428            {
     429              *(LPSTR)dest = '\0';
     430            }
     431            return(FALSE);
     432        }
     433        return S_OK;
     434}
     435
     436/*************************************************************************
     437 * StrRetToBufW                                 [SHLWAPI.@]
     438 * 
    440439 * converts a STRRET to a normal string
    441440 *
     
    445444HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, DWORD len)
    446445{
    447     TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
    448 
    449     switch (src->uType)
    450     {
    451       case STRRET_WSTR:
    452         lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
    453 /*      SHFree(src->u.pOleStr);  FIXME: is this right? */
    454         break;
    455 
    456       case STRRET_CSTRA:
     446        TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
     447
     448        switch (src->uType)
     449        {
     450          case STRRET_WSTR:
     451            lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
     452/*          SHFree(src->u.pOleStr);  FIXME: is this right? */
     453            break;
     454
     455          case STRRET_CSTRA:
    457456              if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
    458457                  dest[len-1] = 0;
    459         break;
    460 
    461       case STRRET_OFFSETA:
    462         if (pidl)
    463         {
     458            break;
     459
     460          case STRRET_OFFSETA:
     461            if (pidl)
     462            {
    464463              if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
    465464                                        dest, len ) && len)
    466465                  dest[len-1] = 0;
    467         }
    468         break;
    469 
    470       default:
    471         FIXME("unknown type!\n");
    472         if (len)
    473         { *(LPSTR)dest = '\0';
    474         }
    475         return(FALSE);
    476     }
    477     return S_OK;
    478 }
    479 
    480 /*************************************************************************
    481  * StrFormatByteSizeA               [SHLWAPI]
     466            }
     467            break;
     468
     469          default:
     470            FIXME("unknown type!\n");
     471            if (len)
     472            { *(LPSTR)dest = '\0';
     473            }
     474            return(FALSE);
     475        }
     476        return S_OK;
     477}
     478
     479/*************************************************************************
     480 * StrFormatByteSizeA                           [SHLWAPI]
    482481 */
    483482LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
    484 {   char buf[64];
    485     TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
    486     if ( dw<1024L )
    487     { sprintf (buf,"%ld bytes", dw);
    488     }
    489     else if ( dw<1048576L)
    490     { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
    491     }
    492     else if ( dw < 1073741824L)
    493     { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
    494     }
    495     else
    496     { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
    497     }
    498     lstrcpynA (pszBuf, buf, cchBuf);
    499     return pszBuf;
    500 }
    501 
    502 /*************************************************************************
    503  * StrFormatByteSizeW               [SHLWAPI]
     483{       char buf[64];
     484        TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
     485        if ( dw<1024L )
     486        { sprintf (buf,"%ld bytes", dw);
     487        }
     488        else if ( dw<1048576L)
     489        { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
     490        }
     491        else if ( dw < 1073741824L)
     492        { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
     493        }
     494        else
     495        { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
     496        }
     497        lstrcpynA (pszBuf, buf, cchBuf);
     498        return pszBuf; 
     499}
     500
     501/*************************************************************************
     502 * StrFormatByteSizeW                           [SHLWAPI]
    504503 */
    505504LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
     
    513512
    514513/*************************************************************************
    515  *      StrNCatA    [SHLWAPI]
     514 *      StrNCatA        [SHLWAPI]
    516515 */
    517516LPSTR WINAPI StrNCatA(LPSTR front, LPCSTR back, INT cchMax)
    518517{
    519     TRACE("%s %s %i stub\n", debugstr_a(front),debugstr_a(back),cchMax);
    520     return (front);
    521 }
    522 
    523 /*************************************************************************
    524  *      StrNCatW    [SHLWAPI]
     518        TRACE("%s %s %i stub\n", debugstr_a(front),debugstr_a(back),cchMax);
     519        return (front);
     520}
     521
     522/*************************************************************************
     523 *      StrNCatW        [SHLWAPI]
    525524 */
    526525LPWSTR WINAPI StrNCatW(LPWSTR front, LPCWSTR back, INT cchMax)
    527526{
    528     TRACE("%s %s %i stub\n", debugstr_w(front),debugstr_w(back),cchMax);
    529     return (front);
    530 }
    531 
    532 /*************************************************************************
    533  *      StrTrimA    [SHLWAPI.@]
     527        TRACE("%s %s %i stub\n", debugstr_w(front),debugstr_w(back),cchMax);
     528        return (front);
     529}
     530
     531/*************************************************************************
     532 *      StrTrimA        [SHLWAPI.@]
    534533 */
    535534BOOL WINAPI StrTrimA(LPSTR pszSource, LPCSTR pszTrimChars)
     
    542541    for (pTrim = pszTrimChars; *pTrim; pTrim++)
    543542    {
    544     for (pSrc = pszSource; *pSrc; pSrc++)
    545          if (*pSrc == *pTrim)
    546          {
    547         /* match -> remove this char.
    548           * strlen(pSrc) equiv. to the correct strlen(pSrc+1)+1 */
    549         memmove(pSrc, pSrc+1, strlen(pSrc));
    550         trimmed = TRUE;
    551          }
     543        for (pSrc = pszSource; *pSrc; pSrc++)
     544             if (*pSrc == *pTrim)
     545             {
     546                /* match -> remove this char.
     547                  * strlen(pSrc) equiv. to the correct strlen(pSrc+1)+1 */
     548                memmove(pSrc, pSrc+1, strlen(pSrc));
     549                trimmed = TRUE;
     550             }
    552551    }
    553552    TRACE("<- '%s'\n", pszSource);
     
    556555
    557556/*************************************************************************
    558  *      wnsprintfA  [SHLWAPI]
     557 *      wnsprintfA      [SHLWAPI]
    559558 */
    560559int WINAPIV wnsprintfA(LPSTR lpOut, int cchLimitIn, LPCSTR lpFmt, ...)
     
    570569
    571570/*************************************************************************
    572  *      wnsprintfW  [SHLWAPI]
     571 *      wnsprintfW      [SHLWAPI]
    573572 */
    574573int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt, ...)
  • trunk/src/shlwapi/url.c

    r6650 r6712  
    1 /* $Id: url.c,v 1.4 2001-09-05 13:48:39 bird Exp $ */
    21/*
    32 * Url functions
     
    5453    if(dwFlags & URL_ESCAPE_SPACES_ONLY) {
    5554        if(ch == ' ')
    56         return TRUE;
    57     else
    58         return FALSE;
     55            return TRUE;
     56        else
     57            return FALSE;
    5958    }
    6059
    6160    if (ch <= 31 || ch >= 127)
    62     return TRUE;
     61        return TRUE;
    6362
    6463    else {
    6564        switch (ch) {
    66     case ' ':
    67     case '<':
    68     case '>':
    69     case '\"':
    70     case '{':
    71     case '}':
    72     case '|':
    73     case '\\':
    74     case '^':
    75     case ']':
    76     case '[':
    77     case '`':
    78     case '&':
    79         return TRUE;
    80 
    81     default:
    82         return FALSE;
    83     }
     65        case ' ':
     66        case '<':
     67        case '>':
     68        case '\"':
     69        case '{':
     70        case '}':
     71        case '|':
     72        case '\\':
     73        case '^':
     74        case ']':
     75        case '[':
     76        case '`':
     77        case '&':
     78            return TRUE;
     79
     80        default:
     81            return FALSE;
     82        }
    8483    }
    8584}
     
    8988 */
    9089HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
    91     LPDWORD pcchCanonicalized, DWORD dwFlags)
     90        LPDWORD pcchCanonicalized, DWORD dwFlags)
    9291{
    9392    HRESULT hr = S_OK;
     
    9796
    9897    TRACE("(%s %p %p 0x%08lx)\n", debugstr_a(pszUrl), pszCanonicalized,
    99       pcchCanonicalized, dwFlags);
     98          pcchCanonicalized, dwFlags);
    10099
    101100    nLen = strlen(pszUrl);
     
    114113    if(dwFlags & (URL_ESCAPE_UNSAFE | URL_ESCAPE_SPACES_ONLY)) {
    115114        DWORD EscapeFlags = dwFlags & (URL_ESCAPE_SPACES_ONLY
    116                        /* | URL_ESCAPE_PERCENT */);
    117     hr = UrlEscapeA(lpszUrlCpy, pszCanonicalized, pcchCanonicalized,
    118             EscapeFlags);
     115                                       /* | URL_ESCAPE_PERCENT */);
     116        hr = UrlEscapeA(lpszUrlCpy, pszCanonicalized, pcchCanonicalized,
     117                        EscapeFlags);
    119118    } else { /* No escapping needed, just copy the string */
    120119        nLen = strlen(lpszUrlCpy);
    121     if(nLen < *pcchCanonicalized)
    122         memcpy(pszCanonicalized, lpszUrlCpy, nLen + 1);
    123     else {
    124         hr = E_POINTER;
    125         nLen++;
    126     }
    127     *pcchCanonicalized = nLen;
     120        if(nLen < *pcchCanonicalized)
     121            memcpy(pszCanonicalized, lpszUrlCpy, nLen + 1);
     122        else {
     123            hr = E_POINTER;
     124            nLen++;
     125        }
     126        *pcchCanonicalized = nLen;
    128127    }
    129128
    130129    HeapFree(GetProcessHeap(), 0, lpszUrlCpy);
    131 
     130 
    132131    return hr;
    133132}
     
    136135 *        UrlCanonicalizeW     [SHLWAPI]
    137136 */
    138 HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
    139                 LPDWORD pcchCanonicalized, DWORD dwFlags)
     137HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, 
     138                                LPDWORD pcchCanonicalized, DWORD dwFlags)
    140139{
    141140    FIXME("(%s %p %p 0x%08lx): stub\n",debugstr_w(pszUrl),
    142       pszCanonicalized, pcchCanonicalized, dwFlags);
     141          pszCanonicalized, pcchCanonicalized, dwFlags);
    143142    return E_NOTIMPL;
    144143}
    145144
    146145/*************************************************************************
    147  *      UrlEscapeA  [SHLWAPI]
     146 *      UrlEscapeA      [SHLWAPI]
    148147 *
    149148 * Converts unsafe characters into their escape sequences.
     
    173172 */
    174173HRESULT WINAPI UrlEscapeA(
    175     LPCSTR pszUrl,
    176     LPSTR pszEscaped,
    177     LPDWORD pcchEscaped,
    178     DWORD dwFlags)
     174        LPCSTR pszUrl,
     175        LPSTR pszEscaped,
     176        LPDWORD pcchEscaped,
     177        DWORD dwFlags)
    179178{
    180179    LPCSTR src;
     
    186185
    187186    TRACE("(%s %p %p 0x%08lx)\n", debugstr_a(pszUrl), pszEscaped,
    188       pcchEscaped, dwFlags);
     187          pcchEscaped, dwFlags);
    189188
    190189    if(dwFlags & ~URL_ESCAPE_SPACES_ONLY)
     
    193192    for(src = pszUrl; *src; src++) {
    194193        if(!(dwFlags & URL_ESCAPE_SPACES_ONLY) &&
    195        (*src == '#' || *src == '?'))
    196         stop_escapping = TRUE;
    197 
    198     if(URL_NeedEscape(*src, dwFlags) && stop_escapping == FALSE) {
    199         next[0] = '%';
    200         next[1] = hex[(*src >> 4) & 0xf];
    201         next[2] = hex[*src & 0xf];
    202         len = 3;
    203     } else {
    204         next[0] = *src;
    205         len = 1;
    206     }
    207 
    208     if(needed + len <= *pcchEscaped) {
    209         memcpy(dst, next, len);
    210         dst += len;
    211     }
    212     needed += len;
     194           (*src == '#' || *src == '?'))
     195            stop_escapping = TRUE;
     196
     197        if(URL_NeedEscape(*src, dwFlags) && stop_escapping == FALSE) {
     198            next[0] = '%';
     199            next[1] = hex[(*src >> 4) & 0xf];
     200            next[2] = hex[*src & 0xf];
     201            len = 3;
     202        } else {
     203            next[0] = *src;
     204            len = 1;
     205        }
     206
     207        if(needed + len <= *pcchEscaped) {
     208            memcpy(dst, next, len);
     209            dst += len;
     210        }
     211        needed += len;
    213212    }
    214213
    215214    if(needed < *pcchEscaped) {
    216215        *dst = '\0';
    217     ret = S_OK;
     216        ret = S_OK;
    218217    } else {
    219218        needed++; /* add one for the '\0' */
    220     ret = E_POINTER;
     219        ret = E_POINTER;
    221220    }
    222221    *pcchEscaped = needed;
    223222    return ret;
    224 }
    225 
    226 /*************************************************************************
    227  *      UrlEscapeW  [SHLWAPI]
     223}       
     224
     225/*************************************************************************
     226 *      UrlEscapeW      [SHLWAPI]
    228227 */
    229228HRESULT WINAPI UrlEscapeW(
    230     LPCWSTR pszUrl,
    231     LPWSTR pszEscaped,
    232     LPDWORD pcchEscaped,
    233     DWORD dwFlags)
     229        LPCWSTR pszUrl,
     230        LPWSTR pszEscaped,
     231        LPDWORD pcchEscaped,
     232        DWORD dwFlags)
    234233{
    235234    FIXME("(%s %p %p 0x%08lx): stub\n",debugstr_w(pszUrl),
    236       pszEscaped, pcchEscaped, dwFlags);
     235          pszEscaped, pcchEscaped, dwFlags);
    237236    return E_NOTIMPL;
    238237}
     
    240239
    241240/*************************************************************************
    242  *      UrlUnescapeA    [SHLWAPI]
     241 *      UrlUnescapeA    [SHLWAPI]
    243242 *
    244243 * Converts escape sequences back to ordinary characters.
    245  *
     244 * 
    246245 * If URL_ESCAPE_INPLACE is set in dwFlags then pszUnescaped and
    247246 * pcchUnescaped are ignored and the converted string is returned in
     
    257256 */
    258257HRESULT WINAPI UrlUnescapeA(
    259     LPCSTR pszUrl,
    260     LPSTR pszUnescaped,
    261     LPDWORD pcchUnescaped,
    262     DWORD dwFlags)
     258        LPCSTR pszUrl,
     259        LPSTR pszUnescaped,
     260        LPDWORD pcchUnescaped,
     261        DWORD dwFlags)
    263262{
    264263    char *dst, next;
     
    269268
    270269    TRACE("(%s, %p, %p, %08lx): stub\n", debugstr_a(pszUrl), pszUnescaped,
    271       pcchUnescaped, dwFlags);
     270          pcchUnescaped, dwFlags);
    272271
    273272    if(dwFlags & URL_UNESCAPE_INPLACE)
     
    278277    for(src = pszUrl, needed = 0; *src; src++, needed++) {
    279278        if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO &&
    280        (*src == '#' || *src == '?')) {
    281         stop_unescapping = TRUE;
    282         next = *src;
    283     } else if(*src == '%' && isxdigit(*(src + 1)) && isxdigit(*(src + 2))
    284           && stop_unescapping == FALSE) {
    285         INT ih;
    286         char buf[3];
    287         memcpy(buf, src + 1, 2);
    288         buf[2] = '\0';
    289         ih = strtol(buf, NULL, 16);
    290         next = (CHAR) ih;
    291         src += 2; /* Advance to end of escape */
    292     } else
    293         next = *src;
    294 
    295     if(dwFlags & URL_UNESCAPE_INPLACE || needed < *pcchUnescaped)
    296         *dst++ = next;
     279           (*src == '#' || *src == '?')) {
     280            stop_unescapping = TRUE;
     281            next = *src;
     282        } else if(*src == '%' && isxdigit(*(src + 1)) && isxdigit(*(src + 2))
     283                  && stop_unescapping == FALSE) {
     284            INT ih;
     285            char buf[3];
     286            memcpy(buf, src + 1, 2);
     287            buf[2] = '\0';
     288            ih = strtol(buf, NULL, 16);
     289            next = (CHAR) ih;
     290            src += 2; /* Advance to end of escape */
     291        } else
     292            next = *src;
     293
     294        if(dwFlags & URL_UNESCAPE_INPLACE || needed < *pcchUnescaped)
     295            *dst++ = next;
    297296    }
    298297
    299298    if(dwFlags & URL_UNESCAPE_INPLACE || needed < *pcchUnescaped) {
    300299        *dst = '\0';
    301     ret = S_OK;
     300        ret = S_OK;
    302301    } else {
    303302        needed++; /* add one for the '\0' */
    304     ret = E_POINTER;
     303        ret = E_POINTER;
    305304    }
    306305    if(!(dwFlags & URL_UNESCAPE_INPLACE))
     
    311310
    312311/*************************************************************************
    313  *      UrlUnescapeW    [SHLWAPI]
     312 *      UrlUnescapeW    [SHLWAPI]
    314313 */
    315314HRESULT WINAPI UrlUnescapeW(
    316     LPCWSTR pszUrl,
    317     LPWSTR pszUnescaped,
    318     LPDWORD pcchUnescaped,
    319     DWORD dwFlags)
     315        LPCWSTR pszUrl,
     316        LPWSTR pszUnescaped,
     317        LPDWORD pcchUnescaped,
     318        DWORD dwFlags)
    320319{
    321320    FIXME("(%s, %p, %p, %08lx): stub\n", debugstr_w(pszUrl), pszUnescaped,
    322       pcchUnescaped, dwFlags);
     321          pcchUnescaped, dwFlags);
    323322    return E_NOTIMPL;
    324323}
    325324
    326325/*************************************************************************
    327  *      HashData    [SHLWAPI]
     326 *      HashData        [SHLWAPI]
    328327 *
    329328 * Hash an input block into a variable sized digest.
     
    358357
    359358/*************************************************************************
    360  *      UrlHashA    [SHLWAPI]
     359 *      UrlHashA        [SHLWAPI]
    361360 *
    362361 * Hash an ASCII URL.
     
    372371
    373372/*************************************************************************
    374  *      UrlApplySchemeW [SHLWAPI.@]
     373 *      UrlApplySchemeW [SHLWAPI.@]
    375374 */
    376375HRESULT WINAPI UrlApplySchemeW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, DWORD dwFlags)
  • trunk/src/wininet/http.c

    r6640 r6712  
    1 /* $Id: http.c,v 1.3 2001-09-05 10:31:45 bird Exp $
    2  *
     1/*
    32 * Wininet - Http Implementation
    43 *
  • trunk/src/wininet/wininet_main.c

    r6640 r6712  
    1 /* $Id: wininet_main.c,v 1.2 2001-09-05 10:31:47 bird Exp $
    2  *
     1/*
    32 * WinInet
    43 *
     
    1514
    1615/***********************************************************************
    17  *      WININET_DllInstall (WININET.@)
     16 *              WININET_DllInstall (WININET.@)
    1817 */
    1918HRESULT WINAPI WININET_DllInstall(BOOL bInstall, LPCWSTR cmdline)
    2019{
    21   FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
    22     debugstr_w(cmdline));
     20  FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", 
     21        debugstr_w(cmdline));
    2322
    2423  return S_OK;
  • trunk/src/winmm/driver.c

    r6639 r6712  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
    22
    3 /* $Id: driver.c,v 1.2 2001-09-05 10:30:21 bird Exp $
    4  *
     3/*
    54 * WINE Drivers functions
    65 *
     
    3332DEFAULT_DEBUG_CHANNEL(driver);
    3433
    35 static LPWINE_DRIVER    lpDrvItemList = NULL;
     34static LPWINE_DRIVER    lpDrvItemList = NULL;
    3635
    3736/* TODO list :
    38  *  - LoadModule count and clean up is not handled correctly (it's not a
    39  *    problem as long as FreeLibrary is not working correctly)
    40  */
    41 
    42 /**************************************************************************
    43  *          DRIVER_GetNumberOfModuleRefs        [internal]
     37 *      - LoadModule count and clean up is not handled correctly (it's not a
     38 *        problem as long as FreeLibrary is not working correctly)
     39 */
     40
     41/**************************************************************************
     42 *                      DRIVER_GetNumberOfModuleRefs            [internal]
    4443 *
    4544 * Returns the number of open drivers which share the same module.
    4645 */
    47 static  WORD    DRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv)
    48 {
    49     LPWINE_DRIVER   lpDrv;
    50     WORD        count = 0;
     46static  WORD    DRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv)
     47{
     48    LPWINE_DRIVER       lpDrv;
     49    WORD                count = 0;
    5150
    5251    if (lpNewDrv->dwFlags & WINE_GDF_16BIT) ERR("OOOch");
    5352    for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) {
    54     if (!(lpDrv->dwFlags & WINE_GDF_16BIT) &&
    55         lpDrv->d.d32.hModule == lpNewDrv->d.d32.hModule) {
    56         count++;
    57     }
     53        if (!(lpDrv->dwFlags & WINE_GDF_16BIT) &&
     54            lpDrv->d.d32.hModule == lpNewDrv->d.d32.hModule) {
     55            count++;
     56        }
    5857    }
    5958    return count;
     
    6160
    6261/**************************************************************************
    63  *              DRIVER_FindFromHDrvr        [internal]
    64  *
     62 *                              DRIVER_FindFromHDrvr            [internal]
     63 * 
    6564 * From a hDrvr being 32 bits, returns the WINE internal structure.
    6665 */
    67 LPWINE_DRIVER   DRIVER_FindFromHDrvr(HDRVR hDrvr)
    68 {
    69     LPWINE_DRIVER   d = (LPWINE_DRIVER)hDrvr;
     66LPWINE_DRIVER   DRIVER_FindFromHDrvr(HDRVR hDrvr)
     67{   
     68    LPWINE_DRIVER       d = (LPWINE_DRIVER)hDrvr;
    7069
    7170    if (hDrvr && HeapValidate(GetProcessHeap(), 0, d) && d->dwMagic == WINE_DI_MAGIC) {
    72     return d;
     71        return d;
    7372    }
    7473    return NULL;
     
    7776#ifndef __WIN32OS2__
    7877/**************************************************************************
    79  *              DRIVER_MapMsg32To16     [internal]
     78 *                              DRIVER_MapMsg32To16             [internal]
    8079 *
    8180 * Map a 32 bit driver message to a 16 bit driver message.
     
    8786static int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
    8887{
    89     int ret = -1;
    90 
     88    int ret = -1;
     89   
    9190    switch (wMsg) {
    9291    case DRV_LOAD:
     
    9796    case DRV_REMOVE:
    9897    case DRV_EXITSESSION:
    99     case DRV_EXITAPPLICATION:
     98    case DRV_EXITAPPLICATION:   
    10099    case DRV_POWER:
    101     case DRV_CLOSE: /* should be 0/0 */
    102     case DRV_OPEN:  /* pass thru */
    103     /* lParam1 and lParam2 are not used */
    104     ret = 0;
    105     break;
    106     break;
     100    case DRV_CLOSE:     /* should be 0/0 */
     101    case DRV_OPEN:      /* pass thru */
     102        /* lParam1 and lParam2 are not used */
     103        ret = 0;
     104        break;
     105        break;
    107106    case DRV_CONFIGURE:
    108107    case DRV_INSTALL:
    109     /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used,
    110      * lParam2 is a pointer to DRVCONFIGINFO
    111     */
    112     if (*lParam2) {
    113             LPDRVCONFIGINFO16   dci16 = (LPDRVCONFIGINFO16)SEGPTR_ALLOC(sizeof(DRVCONFIGINFO16));
    114             LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2);
    115 
    116         if (dci16) {
    117         LPSTR   str1, str2;
    118 
    119         dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
    120 
    121         if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL &&
    122             (str2 = SEGPTR_STRDUP(str1)) != NULL) {
    123             dci16->lpszDCISectionName = SEGPTR_GET(str2);
    124             if (!HeapFree(GetProcessHeap(), 0, str1))
    125             FIXME("bad free line=%d\n", __LINE__);
    126         } else {
    127             return -2;
    128         }
    129         if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL &&
    130             (str2 = SEGPTR_STRDUP(str1)) != NULL) {
    131             dci16->lpszDCIAliasName = SEGPTR_GET(str2);
    132             if (!HeapFree(GetProcessHeap(), 0, str1))
    133             FIXME("bad free line=%d\n", __LINE__);
    134         } else {
    135             return -2;
    136         }
    137         } else {
    138         return -2;
    139         }
    140         *lParam2 = (LPARAM)SEGPTR_GET(dci16);
    141         ret = 1;
    142     } else {
    143         ret = 0;
    144     }
    145     break;
     108        /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used,
     109         * lParam2 is a pointer to DRVCONFIGINFO
     110        */
     111        if (*lParam2) {
     112            LPDRVCONFIGINFO16   dci16 = (LPDRVCONFIGINFO16)SEGPTR_ALLOC(sizeof(DRVCONFIGINFO16));
     113            LPDRVCONFIGINFO     dci32 = (LPDRVCONFIGINFO)(*lParam2);
     114           
     115            if (dci16) {
     116                LPSTR   str1, str2;
     117               
     118                dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
     119               
     120                if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL &&
     121                    (str2 = SEGPTR_STRDUP(str1)) != NULL) {
     122                    dci16->lpszDCISectionName = SEGPTR_GET(str2);
     123                    if (!HeapFree(GetProcessHeap(), 0, str1))
     124                        FIXME("bad free line=%d\n", __LINE__);
     125                } else {
     126                    return -2;
     127                }
     128                if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL &&
     129                    (str2 = SEGPTR_STRDUP(str1)) != NULL) {
     130                    dci16->lpszDCIAliasName = SEGPTR_GET(str2);
     131                    if (!HeapFree(GetProcessHeap(), 0, str1))
     132                        FIXME("bad free line=%d\n", __LINE__);
     133                } else {
     134                    return -2;
     135                }
     136            } else {
     137                return -2;
     138            }
     139            *lParam2 = (LPARAM)SEGPTR_GET(dci16);
     140            ret = 1;
     141        } else {
     142            ret = 0;
     143        }
     144        break;
    146145    default:
    147     if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
    148        FIXME("Unknown message 0x%04x\n", wMsg);
    149     }
    150     ret = 0;
     146        if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
     147           FIXME("Unknown message 0x%04x\n", wMsg);
     148        }
     149        ret = 0;
    151150    }
    152151    return ret;
     
    154153
    155154/**************************************************************************
    156  *              DRIVER_UnMapMsg32To16       [internal]
     155 *                              DRIVER_UnMapMsg32To16           [internal]
    157156 *
    158157 * UnMap a 32 bit driver message to a 16 bit driver message.
     
    163162static int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
    164163{
    165     int ret = -1;
    166 
     164    int ret = -1;
     165   
    167166    switch (wMsg) {
    168167    case DRV_LOAD:
     
    177176    case DRV_OPEN:
    178177    case DRV_CLOSE:
    179     /* lParam1 and lParam2 are not used */
    180     break;
    181     case DRV_CONFIGURE:
     178        /* lParam1 and lParam2 are not used */
     179        break;
     180    case DRV_CONFIGURE: 
    182181    case DRV_INSTALL:
    183     /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
    184     if (lParam2) {
    185         LPDRVCONFIGINFO16   dci16 = MapSL(lParam2);
    186 
    187         if (!SEGPTR_FREE(MapSL(dci16->lpszDCISectionName)))
    188         FIXME("bad free line=%d\n", __LINE__);
    189         if (!SEGPTR_FREE(MapSL(dci16->lpszDCIAliasName)))
    190         FIXME("bad free line=%d\n", __LINE__);
    191         if (!SEGPTR_FREE(dci16))
    192         FIXME("bad free line=%d\n", __LINE__);
    193     }
    194     ret = 0;
    195     break;
     182        /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
     183        if (lParam2) {
     184            LPDRVCONFIGINFO16   dci16 = MapSL(lParam2);
     185           
     186            if (!SEGPTR_FREE(MapSL(dci16->lpszDCISectionName)))
     187                FIXME("bad free line=%d\n", __LINE__);
     188            if (!SEGPTR_FREE(MapSL(dci16->lpszDCIAliasName)))
     189                FIXME("bad free line=%d\n", __LINE__);
     190            if (!SEGPTR_FREE(dci16))
     191                FIXME("bad free line=%d\n", __LINE__);
     192        }
     193        ret = 0;
     194        break;
    196195    default:
    197     if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
    198         FIXME("Unknown message 0x%04x\n", wMsg);
    199     }
    200     ret = 0;
     196        if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
     197            FIXME("Unknown message 0x%04x\n", wMsg);
     198        }
     199        ret = 0;
    201200    }
    202201    return ret;
     
    205204
    206205/**************************************************************************
    207  *              DRIVER_SendMessage      [internal]
    208  */
    209 static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg,
    210                     LPARAM lParam1, LPARAM lParam2)
     206 *                              DRIVER_SendMessage              [internal]
     207 */
     208static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, 
     209                                        LPARAM lParam1, LPARAM lParam2)
    211210{
    212211#ifndef __WIN32OS2__
    213212    if (lpDrv->dwFlags & WINE_GDF_16BIT) {
    214     LRESULT     ret;
    215     int     map = 0;
    216     TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n",
    217           lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
    218 
    219     if ((map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) >= 0) {
    220         ret = SendDriverMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
    221         if (map == 1)
    222         DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
     213        LRESULT         ret;
     214        int             map = 0;
     215        TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n",
     216              lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
     217
     218        if ((map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) >= 0) {
     219            ret = SendDriverMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
     220            if (map == 1)
     221                DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
     222        } else {
     223            ret = 0;
     224        }
     225        return ret;
     226    }
     227#endif
     228    TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n",
     229          lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
     230    return lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
     231}
     232
     233/**************************************************************************
     234 *                              SendDriverMessage               [WINMM.19]
     235 */
     236LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
     237                                 LPARAM lParam2)
     238{
     239    LPWINE_DRIVER       lpDrv;
     240    LRESULT             retval = 0;
     241   
     242    TRACE("(%04x, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
     243   
     244    if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) {
     245        retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2);
    223246    } else {
    224         ret = 0;
    225     }
    226     return ret;
    227     }
    228 #endif
    229     TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n",
    230       lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
    231     return lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
    232 }
    233 
    234 /**************************************************************************
    235  *              SendDriverMessage       [WINMM.19]
    236  */
    237 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
    238                  LPARAM lParam2)
    239 {
    240     LPWINE_DRIVER   lpDrv;
    241     LRESULT         retval = 0;
    242 
    243     TRACE("(%04x, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
    244 
    245     if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) {
    246     retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2);
    247     } else {
    248     WARN("Bad driver handle %u\n", hDriver);
     247        WARN("Bad driver handle %u\n", hDriver);
    249248    }
    250249    TRACE("retval = %ld\n", retval);
    251 
     250   
    252251    return retval;
    253252}
    254253
    255254/**************************************************************************
    256  *              DRIVER_RemoveFromList       [internal]
     255 *                              DRIVER_RemoveFromList           [internal]
    257256 *
    258257 * Generates all the logic to handle driver closure / deletion
    259258 * Removes a driver struct to the list of open drivers.
    260259 */
    261 static  BOOL    DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)
     260static  BOOL    DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)
    262261{
    263262    if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) {
    264     if (DRIVER_GetNumberOfModuleRefs(lpDrv) == 1) {
    265         DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L);
    266         DRIVER_SendMessage(lpDrv, DRV_FREE,    0L, 0L);
    267     }
    268     }
    269 
     263        if (DRIVER_GetNumberOfModuleRefs(lpDrv) == 1) {
     264            DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L);
     265            DRIVER_SendMessage(lpDrv, DRV_FREE,    0L, 0L);
     266        }
     267    }
     268   
    270269    if (lpDrv->lpPrevItem)
    271     lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
     270        lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
    272271    else
    273     lpDrvItemList = lpDrv->lpNextItem;
     272        lpDrvItemList = lpDrv->lpNextItem;
    274273    if (lpDrv->lpNextItem)
    275     lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
     274        lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
    276275
    277276    return TRUE;
     
    279278
    280279/**************************************************************************
    281  *              DRIVER_AddToList        [internal]
     280 *                              DRIVER_AddToList                [internal]
    282281 *
    283282 * Adds a driver struct to the list of open drivers.
    284283 * Generates all the logic to handle driver creation / open.
    285284 */
    286 static  BOOL    DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)
     285static  BOOL    DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)
    287286{
    288287    lpNewDrv->dwMagic = WINE_DI_MAGIC;
    289288    /* First driver to be loaded for this module, need to load correctly the module */
    290289    if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) {
    291     if (DRIVER_GetNumberOfModuleRefs(lpNewDrv) == 0) {
    292         if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
    293         TRACE("DRV_LOAD failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
    294         return FALSE;
    295         }
    296         /* returned value is not checked */
    297         DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L);
    298     }
     290        if (DRIVER_GetNumberOfModuleRefs(lpNewDrv) == 0) {
     291            if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
     292                TRACE("DRV_LOAD failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
     293                return FALSE;
     294            }
     295            /* returned value is not checked */
     296            DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L);
     297        }
    299298    }
    300299
    301300    lpNewDrv->lpNextItem = NULL;
    302301    if (lpDrvItemList == NULL) {
    303     lpDrvItemList = lpNewDrv;
    304     lpNewDrv->lpPrevItem = NULL;
     302        lpDrvItemList = lpNewDrv;
     303        lpNewDrv->lpPrevItem = NULL;
    305304    } else {
    306     LPWINE_DRIVER   lpDrv = lpDrvItemList;  /* find end of list */
    307     while (lpDrv->lpNextItem != NULL)
    308         lpDrv = lpDrv->lpNextItem;
    309 
    310     lpDrv->lpNextItem = lpNewDrv;
    311     lpNewDrv->lpPrevItem = lpDrv;
     305        LPWINE_DRIVER   lpDrv = lpDrvItemList;  /* find end of list */
     306        while (lpDrv->lpNextItem != NULL)
     307            lpDrv = lpDrv->lpNextItem;
     308       
     309        lpDrv->lpNextItem = lpNewDrv;
     310        lpNewDrv->lpPrevItem = lpDrv;
    312311    }
    313312
    314313    if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) {
    315     /* Now just open a new instance of a driver on this module */
    316     lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2);
    317 
    318     if (lpNewDrv->d.d32.dwDriverID == 0) {
    319         TRACE("DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
    320         DRIVER_RemoveFromList(lpNewDrv);
    321         return FALSE;
    322     }
     314        /* Now just open a new instance of a driver on this module */
     315        lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2);
     316
     317        if (lpNewDrv->d.d32.dwDriverID == 0) {
     318            TRACE("DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
     319            DRIVER_RemoveFromList(lpNewDrv);
     320            return FALSE;
     321        }
    323322    }
    324323    return TRUE;
     
    326325
    327326/**************************************************************************
    328  *              DRIVER_GetLibName       [internal]
    329  *
    330  */
    331 BOOL    DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz)
     327 *                              DRIVER_GetLibName               [internal]
     328 *
     329 */
     330BOOL    DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz)
    332331{
    333332    /* should also do some registry diving */
     
    336335
    337336/**************************************************************************
    338  *              DRIVER_TryOpenDriver32      [internal]
     337 *                              DRIVER_TryOpenDriver32          [internal]
    339338 *
    340339 * Tries to load a 32 bit driver whose DLL's (module) name is fn
    341340 */
    342 LPWINE_DRIVER   DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2)
    343 {
    344     LPWINE_DRIVER   lpDrv = NULL;
    345     HMODULE     hModule = 0;
    346     LPSTR       ptr;
    347     LPCSTR      cause = 0;
     341LPWINE_DRIVER   DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2)
     342{
     343    LPWINE_DRIVER       lpDrv = NULL;
     344    HMODULE             hModule = 0;
     345    LPSTR               ptr;
     346    LPCSTR              cause = 0;
    348347
    349348    TRACE("('%s', %08lX);\n", fn, lParam2);
    350 
     349   
    351350    if ((ptr = strchr(fn, ' ')) != NULL) {
    352     *ptr++ = '\0';
    353     while (*ptr == ' ') ptr++;
    354     if (*ptr == '\0') ptr = NULL;
     351        *ptr++ = '\0';
     352        while (*ptr == ' ') ptr++;
     353        if (*ptr == '\0') ptr = NULL;
    355354    }
    356355
     
    379378#ifdef __WIN32OS2__
    380379/**************************************************************************
    381  *              DRIVER_OpenDriverA              [internal]
     380 *                              DRIVER_OpenDriverA                      [internal]
    382381 * (0,1,DRV_LOAD  ,0       ,0)
    383382 * (0,1,DRV_ENABLE,0       ,0)
     
    385384 *
    386385 */
    387 static  LPWINE_DRIVER   DRIVER_TryOpenDriver16(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam)
     386static  LPWINE_DRIVER   DRIVER_TryOpenDriver16(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam)
    388387{
    389388  LPWINE_DRIVER lpDrv = NULL;
    390   char      drvName[128];
     389  char          drvName[128];
    391390  LPCSTR        cause = 0;
    392 
     391 
    393392  TRACE("Entering DRIVER_OpenDriverA: lpDriverName: %s lpSectionName: %s\n",lpDriverName,lpSectionName);
    394393
     
    397396
    398397  if (lpSectionName == NULL) {
    399     lstrcpynA(drvName, lpDriverName, sizeof(drvName));
    400     lpDrv = DRIVER_TryOpenDriver32(lpDriverName, lParam);
    401     if (!lpDrv) {
     398        lstrcpynA(drvName, lpDriverName, sizeof(drvName));
     399        lpDrv = DRIVER_TryOpenDriver32(lpDriverName, lParam);
     400        if (!lpDrv) {
    402401      if (GetPrivateProfileStringA("Drivers32", lpDriverName, "", drvName,
    403402                                   sizeof(drvName), "SYSTEM.INI")) {
    404403
    405         lpDrv = DRIVER_TryOpenDriver32(drvName, lParam);
     404                lpDrv = DRIVER_TryOpenDriver32(drvName, lParam);               
    406405      }
    407     }
     406        }
    408407  } else {/* of if (lpSectionName == NULL) */
    409408    //dprintf(("driver name %x '%s'\n",drvName,drvName));
    410     drvName[0]=0;
    411 
    412     if (GetPrivateProfileStringA(lpSectionName, lpDriverName, "", drvName,
     409    drvName[0]=0;   
     410
     411        if (GetPrivateProfileStringA(lpSectionName, lpDriverName, "", drvName,
    413412                                 sizeof(drvName)-1, "SYSTEM.INI")) {
    414413#if 0
    415414      dprintf(("driver name %x '%s'\n",drvName,drvName));
    416 #endif
     415#endif     
    417416      lpDrv = DRIVER_TryOpenDriver32(drvName, lParam);
    418     }/* GetPrivate... */
     417        }/* GetPrivate... */
    419418  }
    420419  if (!lpDrv)
    421     TRACE("OpenDriverA: Failed to open driver %s from section %s\n", lpDriverName, lpSectionName);
    422 
    423   else
    424     TRACE("OpenDriverA success: Driver handle => %08x\n", lpDrv);
     420        TRACE("OpenDriverA: Failed to open driver %s from section %s\n", lpDriverName, lpSectionName);
     421
     422  else 
     423        TRACE("OpenDriverA success: Driver handle => %08x\n", lpDrv);
    425424
    426425  return lpDrv;
     
    433432#else
    434433/**************************************************************************
    435  *              DRIVER_TryOpenDriver16      [internal]
     434 *                              DRIVER_TryOpenDriver16          [internal]
    436435 *
    437436 * Tries to load a 16 bit driver whose DLL's (module) name is lpFileName.
    438437 */
    439 static  LPWINE_DRIVER   DRIVER_TryOpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)
    440 {
    441     LPWINE_DRIVER   lpDrv = NULL;
    442     LPCSTR      cause = 0;
     438static  LPWINE_DRIVER   DRIVER_TryOpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)
     439{
     440    LPWINE_DRIVER       lpDrv = NULL;
     441    LPCSTR              cause = 0;
    443442
    444443    TRACE("('%s', %08lX);\n", sn, lParam2);
    445 
     444   
    446445    lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
    447446    if (lpDrv == NULL) {cause = "OOM"; goto exit;}
    448447
    449448    /* FIXME: shall we do some black magic here on sn ?
    450      *  drivers32 => drivers
    451      *  mci32 => mci
     449     *  drivers32 => drivers
     450     *  mci32 => mci
    452451     * ...
    453452     */
     
    468467
    469468/**************************************************************************
    470  *              OpenDriverA             [WINMM.15]
     469 *                              OpenDriverA                     [WINMM.15]
    471470 * (0,1,DRV_LOAD  ,0       ,0)
    472471 * (0,1,DRV_ENABLE,0       ,0)
    473472 * (0,1,DRV_OPEN  ,buf[256],0)
    474473 */
    475 HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam2)
    476 {
    477     LPWINE_DRIVER   lpDrv = NULL;
    478     char        libName[128];
    479     LPCSTR      lsn = lpSectionName;
     474HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam2) 
     475{
     476    LPWINE_DRIVER       lpDrv = NULL;
     477    char                libName[128];
     478    LPCSTR              lsn = lpSectionName;
    480479
    481480    TRACE("(%s, %s, 0x%08lx);\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName), lParam2);
    482 
     481   
    483482    if (lsn == NULL) {
    484     lstrcpynA(libName, lpDriverName, sizeof(libName));
    485 
    486     if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
    487         goto the_end;
    488     lsn = "Drivers32";
     483        lstrcpynA(libName, lpDriverName, sizeof(libName));
     484
     485        if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
     486            goto the_end;
     487        lsn = "Drivers32";
    489488    }
    490489    if (DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) &&
    491     (lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
    492     goto the_end;
     490        (lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
     491        goto the_end;
    493492
    494493    if (!(lpDrv = DRIVER_TryOpenDriver16(lpDriverName, lpSectionName, lParam2)))
    495     TRACE("Failed to open driver %s from system.ini file, section %s\n", lpDriverName, lpSectionName);
     494        TRACE("Failed to open driver %s from system.ini file, section %s\n", lpDriverName, lpSectionName);
    496495
    497496 the_end:
    498     if (lpDrv)  TRACE("=> %08lx\n", (DWORD)lpDrv);
     497    if (lpDrv)  TRACE("=> %08lx\n", (DWORD)lpDrv);
    499498    return (DWORD)lpDrv;
    500499}
    501500
    502501/**************************************************************************
    503  *              OpenDriverW             [WINMM.15]
     502 *                              OpenDriverW                     [WINMM.15]
    504503 */
    505504HDRVR WINAPI OpenDriverW(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
    506505{
    507     LPSTR       dn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDriverName);
    508     LPSTR       sn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpSectionName);
    509     HDRVR       ret = OpenDriverA(dn, sn, lParam);
    510 
     506    LPSTR               dn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDriverName);
     507    LPSTR               sn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpSectionName);
     508    HDRVR               ret = OpenDriverA(dn, sn, lParam);
     509   
    511510    if (dn) HeapFree(GetProcessHeap(), 0, dn);
    512511    if (sn) HeapFree(GetProcessHeap(), 0, sn);
     
    515514
    516515/**************************************************************************
    517  *          CloseDriver             [WINMM.4]
     516 *                      CloseDriver                             [WINMM.4]
    518517 */
    519518LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
    520519{
    521     LPWINE_DRIVER   lpDrv;
     520    LPWINE_DRIVER       lpDrv;
    522521
    523522    TRACE("(%04x, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
    524 
     523   
    525524    if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
    526525#ifndef __WIN32OS2__
    527     if (lpDrv->dwFlags & WINE_GDF_16BIT)
    528         CloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2);
    529     else
     526        if (lpDrv->dwFlags & WINE_GDF_16BIT)
     527            CloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2);
     528        else
    530529#endif
    531         DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2);
    532     if (DRIVER_RemoveFromList(lpDrv)) {
    533         HeapFree(GetProcessHeap(), 0, lpDrv);
    534         return TRUE;
    535     }
     530            DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2);
     531        if (DRIVER_RemoveFromList(lpDrv)) {
     532            HeapFree(GetProcessHeap(), 0, lpDrv);
     533            return TRUE;
     534        }
    536535    }
    537536    WARN("Failed to close driver\n");
     
    540539
    541540/**************************************************************************
    542  *              GetDriverFlags      [WINMM.13]
     541 *                              GetDriverFlags          [WINMM.13]
    543542 * [in] hDrvr handle to the driver
    544543 *
    545544 * Returns:
    546  *  0x00000000 if hDrvr is an invalid handle
    547  *  0x80000000 if hDrvr is a valid 32 bit driver
    548  *  0x90000000 if hDrvr is a valid 16 bit driver
     545 *      0x00000000 if hDrvr is an invalid handle
     546 *      0x80000000 if hDrvr is a valid 32 bit driver
     547 *      0x90000000 if hDrvr is a valid 16 bit driver
    549548 *
    550549 * native WINMM doesn't return those flags
    551  *  0x80000000 for a valid 32 bit driver and that's it
    552  *  (I may have mixed up the two flags :-(
    553  */
    554 DWORD   WINAPI GetDriverFlags(HDRVR hDrvr)
    555 {
    556     LPWINE_DRIVER   lpDrv;
    557     DWORD       ret = 0;
     550 *      0x80000000 for a valid 32 bit driver and that's it
     551 *      (I may have mixed up the two flags :-(
     552 */
     553DWORD   WINAPI GetDriverFlags(HDRVR hDrvr)
     554{
     555    LPWINE_DRIVER       lpDrv;
     556    DWORD               ret = 0;
    558557
    559558    TRACE("(%04x)\n", hDrvr);
    560559
    561560    if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
    562     ret = WINE_GDF_EXIST | lpDrv->dwFlags;
     561        ret = WINE_GDF_EXIST | lpDrv->dwFlags;
    563562    }
    564563    return ret;
     
    566565
    567566/**************************************************************************
    568  *              GetDriverModuleHandle   [WINMM.14]
     567 *                              GetDriverModuleHandle   [WINMM.14]
    569568 */
    570569HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr)
    571570{
    572     LPWINE_DRIVER   lpDrv;
    573     HMODULE     hModule = 0;
    574 
     571    LPWINE_DRIVER       lpDrv;
     572    HMODULE             hModule = 0;
     573   
    575574    TRACE("(%04x);\n", hDrvr);
    576 
     575   
    577576    if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
    578     if (!(lpDrv->dwFlags & WINE_GDF_16BIT))
    579         hModule = lpDrv->d.d32.hModule;
     577        if (!(lpDrv->dwFlags & WINE_GDF_16BIT))
     578            hModule = lpDrv->d.d32.hModule;
    580579    }
    581580    TRACE("=> %04x\n", hModule);
     
    585584#ifndef __WIN32OS2__
    586585/**************************************************************************
    587  *              DrvOpen             [MMSYSTEM.1100]
     586 *                              DrvOpen                 [MMSYSTEM.1100]
    588587 */
    589588HDRVR16 WINAPI DrvOpen16(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
     
    593592
    594593/**************************************************************************
    595  *              DrvClose            [MMSYSTEM.1101]
     594 *                              DrvClose                [MMSYSTEM.1101]
    596595 */
    597596LRESULT WINAPI DrvClose16(HDRVR16 hDrv, LPARAM lParam1, LPARAM lParam2)
     
    601600
    602601/**************************************************************************
    603  *              DrvSendMessage      [MMSYSTEM.1102]
     602 *                              DrvSendMessage          [MMSYSTEM.1102]
    604603 */
    605604LRESULT WINAPI DrvSendMessage16(HDRVR16 hDrv, WORD msg, LPARAM lParam1,
    606                 LPARAM lParam2)
     605                                LPARAM lParam2)
    607606{
    608607    return SendDriverMessage16(hDrv, msg, lParam1, lParam2);
     
    610609
    611610/**************************************************************************
    612  *              DrvGetModuleHandle  [MMSYSTEM.1103]
     611 *                              DrvGetModuleHandle      [MMSYSTEM.1103]
    613612 */
    614613HANDLE16 WINAPI DrvGetModuleHandle16(HDRVR16 hDrv)
     
    618617
    619618/**************************************************************************
    620  *              DrvDefDriverProc    [MMSYSTEM.1104]
    621  */
    622 LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg,
    623                   DWORD dwParam1, DWORD dwParam2)
     619 *                              DrvDefDriverProc        [MMSYSTEM.1104]
     620 */
     621LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg, 
     622                                  DWORD dwParam1, DWORD dwParam2)
    624623{
    625624    return DefDriverProc16(dwDriverID, hDrv, wMsg, dwParam1, dwParam2);
     
    628627
    629628/**************************************************************************
    630  *              DefDriverProc             [WINMM.5]
     629 *                              DefDriverProc                     [WINMM.5]
    631630 */
    632631LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hDrv,
    633                  UINT Msg, LPARAM lParam1, LPARAM lParam2)
     632                             UINT Msg, LPARAM lParam1, LPARAM lParam2)
    634633{
    635634    switch (Msg) {
     
    649648#ifndef __WIN32OS2__
    650649/**************************************************************************
    651  *              DriverProc          [MMSYSTEM.6]
    652  */
    653 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg,
    654                 DWORD dwParam1, DWORD dwParam2)
     650 *                              DriverProc                      [MMSYSTEM.6]
     651 */
     652LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg, 
     653                            DWORD dwParam1, DWORD dwParam2)
    655654{
    656655    TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n",
    657       dwDevID, hDrv, wMsg, dwParam1, dwParam2);
     656          dwDevID, hDrv, wMsg, dwParam1, dwParam2);
    658657
    659658    return DrvDefDriverProc16(dwDevID, hDrv, wMsg, dwParam1, dwParam2);
     
    663662#ifdef __WIN32OS2__
    664663/**************************************************************************
    665  *              DriverCallback          [MMSYSTEM.31]
    666  */
    667 BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
    668                UINT wMsg, DWORD dwUser, DWORD dwParam1,
    669                DWORD dwParam2)
     664 *                              DriverCallback                  [MMSYSTEM.31]
     665 */
     666BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, 
     667                           UINT wMsg, DWORD dwUser, DWORD dwParam1,
     668                           DWORD dwParam2)
    670669{
    671670    TRACE("DriverCallback (%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
    672       dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
     671          dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
    673672
    674673    switch (uFlags & DCB_TYPEMASK) {
    675674    case DCB_NULL:
    676     TRACE("Null !\n");
    677     if (dwCallBack)
    678         WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack);
    679     break;
     675        TRACE("Null !\n");
     676        if (dwCallBack)
     677            WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack);
     678        break;
    680679    case DCB_WINDOW:
    681     TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev);
    682     if (!IsWindow(dwCallBack))
    683         return FALSE;
    684     PostMessageA((HWND)dwCallBack, wMsg, hDev, dwParam1);
    685     break;
     680        TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev);
     681        if (!IsWindow(dwCallBack))
     682            return FALSE;
     683        PostMessageA((HWND)dwCallBack, wMsg, hDev, dwParam1);
     684        break;
    686685    case DCB_TASK: /* aka DCB_THREAD */
    687     TRACE("Task(%04lx) !\n", dwCallBack);
    688     PostThreadMessageA(dwCallBack, wMsg, hDev, dwParam1);
    689     break;
     686        TRACE("Task(%04lx) !\n", dwCallBack);
     687        PostThreadMessageA(dwCallBack, wMsg, hDev, dwParam1);
     688        break;
    690689    case DCB_FUNCTION:
    691     TRACE("Function (32 bit) !\n");
    692     ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
    693     break;
     690        TRACE("Function (32 bit) !\n");
     691        ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
     692        break;
    694693    case DCB_EVENT:
    695     TRACE("Event(%08lx) !\n", dwCallBack);
    696     SetEvent((HANDLE)dwCallBack);
    697     break;
     694        TRACE("Event(%08lx) !\n", dwCallBack);
     695        SetEvent((HANDLE)dwCallBack);
     696        break;
    698697    case 6: /* I would dub it DCB_MMTHREADSIGNAL */
    699     /* this is an undocumented DCB_ value used for mmThreads
    700     * loword of dwCallBack contains the handle of the lpMMThd block
    701     * which dwSignalCount has to be incremented
    702     */
    703     {
     698        /* this is an undocumented DCB_ value used for mmThreads
     699        * loword of dwCallBack contains the handle of the lpMMThd block
     700        * which dwSignalCount has to be incremented
     701        */
     702        {
    704703#ifdef __WIN32OS2__
    705         WINE_MMTHREAD*  lpMMThd = (WINE_MMTHREAD*)dwCallBack;
     704            WINE_MMTHREAD*      lpMMThd = (WINE_MMTHREAD*)dwCallBack;
    706705#else
    707         WINE_MMTHREAD*  lpMMThd = MapSL( MAKESEGPTR(LOWORD(dwCallBack), 0) );
     706            WINE_MMTHREAD*      lpMMThd = MapSL( MAKESEGPTR(LOWORD(dwCallBack), 0) );
    708707#endif
    709708
    710         TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
    711         /* same as mmThreadSignal16 */
    712         InterlockedIncrement(&lpMMThd->dwSignalCount);
    713         SetEvent(lpMMThd->hEvent);
    714         /* some other stuff on lpMMThd->hVxD */
    715     }
    716     break;
     709            TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
     710            /* same as mmThreadSignal16 */
     711            InterlockedIncrement(&lpMMThd->dwSignalCount);
     712            SetEvent(lpMMThd->hEvent);
     713            /* some other stuff on lpMMThd->hVxD */
     714        }
     715        break; 
    717716#if 0
    718717    case 4:
    719     /* this is an undocumented DCB_ value for... I don't know */
    720     break;
     718        /* this is an undocumented DCB_ value for... I don't know */
     719        break;
    721720#endif
    722721    default:
    723     WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
    724     return FALSE;
     722        WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
     723        return FALSE;
    725724    }
    726725    TRACE("Done\n");
Note: See TracChangeset for help on using the changeset viewer.