Changeset 6711 for trunk/src


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

restored old version + wine update

Location:
trunk/src
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/antimoniker.c

    r6648 r6711  
    1 /* $Id: antimoniker.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/***************************************************************************************
    3  *                        AntiMonikers implementation
     2 *                            AntiMonikers implementation
    43 *
    54 *               Copyright 1999  Noomen Hamza
     
    1615#include "debugtools.h"
    1716
     17#ifdef __WIN32OS2__
     18#undef FIXME
     19#undef TRACE
     20#ifdef DEBUG
     21#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     22#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     23#else
     24#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     25#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     26#endif
     27#endif
     28
    1829DEFAULT_DEBUG_CHANNEL(ole);
    1930
     
    2334    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2435
    25     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     36    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    2637     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    2738     */
     
    129140{
    130141    ICOM_THIS(AntiMonikerImpl,iface);
    131 
     142 
    132143  TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    133144
    134145  /* Perform a sanity check on the parameters.*/
    135146    if ( (This==0) || (ppvObject==0) )
    136     return E_INVALIDARG;
    137 
     147        return E_INVALIDARG;
     148 
    138149  /* Initialize the return parameter */
    139150  *ppvObject = 0;
     
    152163    if ((*ppvObject)==0)
    153164        return E_NOINTERFACE;
    154 
     165 
    155166   /* Query Interface always increases the reference count by one when it is successful */
    156167  AntiMonikerImpl_AddRef(iface);
     
    201212    if (pClassID==NULL)
    202213        return E_POINTER;
    203 
     214           
    204215    *pClassID = CLSID_AntiMoniker;
    205 
     216       
    206217    return S_OK;
    207218}
     
    245256    DWORD constant=1;
    246257    HRESULT res;
    247 
     258   
    248259    /* data writen by this function is only a DWORD constant seted to 1 ! */
    249260    res=IStream_Write(pStm,&constant,sizeof(constant),NULL);
     
    264275
    265276    /* for more details see AntiMonikerImpl_Save coments */
    266 
     277   
    267278    /* Normaly the sizemax must be the  size of DWORD ! but I tested this function it ususlly return 16 bytes */
    268279    /* more than the number of bytes used by AntiMoniker::Save function */
     
    343354
    344355    *ppmkReduced=iface;
    345 
     356   
    346357    return MK_S_REDUCED_TO_SELF;
    347358}
     
    358369
    359370    if ((ppmkComposite==NULL)||(pmkRight==NULL))
    360     return E_POINTER;
     371        return E_POINTER;
    361372
    362373    *ppmkComposite=0;
    363 
     374   
    364375    if (fOnlyIfNotGeneric)
    365376        return MK_E_NEEDGENERIC;
     
    377388    if (ppenumMoniker == NULL)
    378389        return E_POINTER;
    379 
     390   
    380391    *ppenumMoniker = NULL;
    381392
     
    389400{
    390401    DWORD mkSys;
    391 
     402   
    392403    TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
    393404
    394405    if (pmkOtherMoniker==NULL)
    395406        return S_FALSE;
    396 
     407   
    397408    IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys);
    398409
     
    477488{
    478489    DWORD mkSys;
    479 
     490   
    480491    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
    481492
     
    487498
    488499        IMoniker_AddRef(iface);
    489 
     500       
    490501        return MK_S_US;
    491502    }
     
    520531{
    521532    WCHAR back[]={'\\','.','.',0};
    522 
     533   
    523534    TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
    524535
     
    537548
    538549    strcpyW(*ppszDisplayName,back);
    539 
     550   
    540551    return S_OK;
    541552}
     
    564575    if (!pwdMksys)
    565576        return E_POINTER;
    566 
     577   
    567578    (*pwdMksys)=MKSYS_ANTIMONIKER;
    568579
     
    601612{
    602613    ICOM_THIS_From_IROTData(IMoniker, iface);
    603 
     614   
    604615    TRACE("(%p)\n",iface);
    605616
     
    620631
    621632/******************************************************************************
    622  *        CreateAntiMoniker [OLE.55]
     633 *        CreateAntiMoniker     [OLE.55]
    623634 ******************************************************************************/
    624635HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
     
    627638    HRESULT        hr = S_OK;
    628639    IID riid=IID_IMoniker;
    629 
     640   
    630641    TRACE("(%p)\n",ppmk);
    631642
  • trunk/src/ole32/bindctx.c

    r6648 r6711  
    1 /* $Id: bindctx.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/***************************************************************************************
    3  *                        BindCtx implementation
     2 *                            BindCtx implementation
    43 *
    54 *  Copyright 1999  Noomen Hamza
     
    1817#include "heap.h"
    1918
     19#ifdef __WIN32OS2__
     20#undef FIXME
     21#undef TRACE
     22#ifdef DEBUG
     23#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     24#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     25#else
     26#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     27#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     28#endif
     29#endif
     30
    2031DEFAULT_DEBUG_CHANNEL(ole);
    2132
    2233/* represent the first size table and it's increment block size */
    23 #define  BLOCK_TAB_SIZE 10
     34#define  BLOCK_TAB_SIZE 10 
    2435#define  MAX_TAB_SIZE   0xFFFFFFFF
    2536
     
    3950
    4051    ICOM_VFIELD(IBindCtx); /* VTable relative to the IBindCtx interface.*/
    41 
     52                                     
    4253    ULONG ref; /* reference counter for this object */
    4354
     
    103114  if ( (This==0) || (ppvObject==0) )
    104115      return E_INVALIDARG;
    105 
     116 
    106117  /* Initialize the return parameter.*/
    107118  *ppvObject = 0;
     
    117128  if ((*ppvObject)==0)
    118129      return E_NOINTERFACE;
    119 
     130 
    120131   /* Query Interface always increases the reference count by one when it is successful */
    121132  BindCtxImpl_AddRef(iface);
     
    224235    if (punk==NULL)
    225236        return E_POINTER;
    226 
     237   
    227238    IUnknown_AddRef(punk);
    228 
     239   
    229240    /* put the object in the first free element in the table */
    230241    This->bindCtxTable[lastIndex].pObj = punk;
     
    264275    /* check if the object was registred or not */
    265276    if (BindCtxImpl_GetObjectIndex(This,punk,NULL,&index)==S_FALSE)
    266 
     277       
    267278        return MK_E_NOTBOUND;
    268279
    269280    IUnknown_Release(This->bindCtxTable[index].pObj);
    270 
     281   
    271282    /* left-shift all elements in the right side of the current revoked object */
    272283    for(j=index; j<This->bindCtxTableLastIndex-1; j++)
    273284        This->bindCtxTable[j]= This->bindCtxTable[j+1];
    274 
     285   
    275286    This->bindCtxTableLastIndex--;
    276287
     
    308319    if (pbindopts==NULL)
    309320        return E_POINTER;
    310 
     321   
    311322    if (pbindopts->cbStruct > sizeof(BIND_OPTS2))
    312323    {
     
    352363    if (pprot==NULL)
    353364        return E_POINTER;
    354 
     365   
    355366    res=GetRunningObjectTable(0, pprot);
    356367
     
    369380    if (punk==NULL)
    370381        return E_INVALIDARG;
    371 
     382   
    372383    IUnknown_AddRef(punk);
    373384
     
    390401
    391402    This->bindCtxTableLastIndex++;
    392 
     403   
    393404    if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */
    394405
     
    420431
    421432    *punk=0;
    422 
     433   
    423434    if (BindCtxImpl_GetObjectIndex(This,NULL,pszkey,&index)==S_FALSE)
    424435        return E_FAIL;
    425436
    426437    IUnknown_AddRef(This->bindCtxTable[index].pObj);
    427 
     438   
    428439    *punk = This->bindCtxTable[index].pObj;
    429440
     
    447458    /* release the object if it's found */
    448459    IUnknown_Release(This->bindCtxTable[index].pObj);
    449 
     460   
    450461    /* remove the object from the table with a left-shifting of all objects in the right side */
    451462    for(j=index; j<This->bindCtxTableLastIndex-1; j++)
    452463        This->bindCtxTable[j]= This->bindCtxTable[j+1];
    453 
     464   
    454465    This->bindCtxTableLastIndex--;
    455466
     
    477488    DWORD i;
    478489    BYTE found=0;
    479 
     490   
    480491    TRACE("(%p,%p,%p,%p)\n",This,punk,pszkey,index);
    481492
  • trunk/src/ole32/clipboard.c

    r6648 r6711  
    1 /* $Id: clipboard.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/*
    32 *  OLE 2 clipboard support
     
    8281
    8382  /*
    84    * The hidden OLE clipboard window. This window is used as the bridge between the
     83   * The hidden OLE clipboard window. This window is used as the bridge between the 
    8584   * the OLE and windows clipboard API. (Windows creates one such window per process)
    8685   */
     
    115114*   DO NOT add any members before the VTables declaration!
    116115*/
    117 typedef struct
     116typedef struct 
    118117{
    119118  /* IEnumFORMATETC VTable */
    120119  ICOM_VFIELD(IEnumFORMATETC);
    121 
     120 
    122121  /* IEnumFORMATETC fields */
    123122  UINT                         posFmt;    /* current enumerator position */
     
    134133   */
    135134  IUnknown*                    pUnkDataObj;
    136 
     135 
    137136} IEnumFORMATETCImpl;
    138137
     
    173172            REFIID           riid,
    174173            void**           ppvObject);
    175 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef(
     174static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 
    176175            IDataObject*     iface);
    177 static ULONG WINAPI OLEClipbrd_IDataObject_Release(
     176static ULONG WINAPI OLEClipbrd_IDataObject_Release( 
    178177            IDataObject*     iface);
    179178static HRESULT WINAPI OLEClipbrd_IDataObject_GetData(
    180         IDataObject*     iface,
    181         LPFORMATETC      pformatetcIn,
    182         STGMEDIUM*       pmedium);
     179            IDataObject*     iface,
     180            LPFORMATETC      pformatetcIn,
     181            STGMEDIUM*       pmedium);
    183182static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere(
    184         IDataObject*     iface,
    185         LPFORMATETC      pformatetc,
    186         STGMEDIUM*       pmedium);
     183            IDataObject*     iface,
     184            LPFORMATETC      pformatetc,
     185            STGMEDIUM*       pmedium);
    187186static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData(
    188         IDataObject*     iface,
    189         LPFORMATETC      pformatetc);
     187            IDataObject*     iface,
     188            LPFORMATETC      pformatetc);
    190189static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc(
    191         IDataObject*     iface,
    192         LPFORMATETC      pformatectIn,
    193         LPFORMATETC      pformatetcOut);
     190            IDataObject*     iface,
     191            LPFORMATETC      pformatectIn,
     192            LPFORMATETC      pformatetcOut);
    194193static HRESULT WINAPI OLEClipbrd_IDataObject_SetData(
    195         IDataObject*     iface,
    196         LPFORMATETC      pformatetc,
    197         STGMEDIUM*       pmedium,
    198         BOOL             fRelease);
     194            IDataObject*     iface,
     195            LPFORMATETC      pformatetc,
     196            STGMEDIUM*       pmedium,
     197            BOOL             fRelease);
    199198static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc(
    200         IDataObject*     iface,
    201         DWORD            dwDirection,
    202         IEnumFORMATETC** ppenumFormatEtc);
     199            IDataObject*     iface,       
     200            DWORD            dwDirection,
     201            IEnumFORMATETC** ppenumFormatEtc);
    203202static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise(
    204         IDataObject*     iface,
    205         FORMATETC*       pformatetc,
    206         DWORD            advf,
    207         IAdviseSink*     pAdvSink,
    208         DWORD*           pdwConnection);
     203            IDataObject*     iface,
     204            FORMATETC*       pformatetc,
     205            DWORD            advf,
     206            IAdviseSink*     pAdvSink,
     207            DWORD*           pdwConnection);
    209208static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise(
    210         IDataObject*     iface,
    211         DWORD            dwConnection);
     209            IDataObject*     iface,
     210            DWORD            dwConnection);
    212211static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise(
    213         IDataObject*     iface,
    214         IEnumSTATDATA**  ppenumAdvise);
     212            IDataObject*     iface,
     213            IEnumSTATDATA**  ppenumAdvise);
    215214
    216215/*
     
    266265
    267266/*
    268  * Name of our registered OLE clipboard window class
     267 * Name of our registered OLE clipboard window class 
    269268 */
    270269CHAR OLEClipbrd_WNDCLASS[] = "CLIPBRDWNDCLASS";
     
    280279
    281280/*---------------------------------------------------------------------*
    282  *           Win32 OLE clipboard API
     281 *           Win32 OLE clipboard API 
    283282 *---------------------------------------------------------------------*/
    284283
     
    291290 *
    292291 *    S_OK                  IDataObject pointer placed on the clipboard
    293  *    CLIPBRD_E_CANT_OPEN   OpenClipboard failed
    294  *    CLIPBRD_E_CANT_EMPTY  EmptyClipboard failed
     292 *    CLIPBRD_E_CANT_OPEN   OpenClipboard failed 
     293 *    CLIPBRD_E_CANT_EMPTY  EmptyClipboard failed 
    295294 *    CLIPBRD_E_CANT_CLOSE  CloseClipboard failed
    296295 *    CLIPBRD_E_CANT_SET    SetClipboard failed
     
    307306  OLEClipbrd **ppDataObject;
    308307*/
    309 
     308 
    310309  TRACE("(%p)\n", pDataObj);
    311 
     310 
    312311  /*
    313312   * Make sure we have a clipboard object
     
    332331  /*
    333332   * Empty the current clipboard and make our window the clipboard owner
    334    * NOTE: This will trigger a WM_DESTROYCLIPBOARD message
     333   * NOTE: This will trigger a WM_DESTROYCLIPBOARD message 
    335334   */
    336335  if ( !EmptyClipboard() )
     
    357356
    358357  /*
    359    * Enumerate all HGLOBAL formats supported by the source and make
     358   * Enumerate all HGLOBAL formats supported by the source and make 
    360359   * those formats available using delayed rendering using SetClipboardData.
    361    * Only global memory based data items may be made available to non-OLE
    362    * applications via the standard Windows clipboard API. Data based on other
     360   * Only global memory based data items may be made available to non-OLE 
     361   * applications via the standard Windows clipboard API. Data based on other 
    363362   * mediums(non TYMED_HGLOBAL) can only be accessed via the Ole Clipboard API.
    364363   *
     
    374373      HANDLE_ERROR( hr );
    375374    }
    376 
     375     
    377376    while ( S_OK == IEnumFORMATETC_Next(penumFormatetc, 1, &rgelt, NULL) )
    378377    {
     
    383382              GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1)
    384383                ? szFmtName : "");
    385 
     384 
    386385        SetClipboardData( rgelt.cfFormat, (HANDLE)NULL);
    387386      }
     
    392391  /*
    393392   * Windows additionally creates a new "DataObject" clipboard format
    394    * and stores in on the clipboard. We could possibly store a pointer
     393   * and stores in on the clipboard. We could possibly store a pointer 
    395394   * to our internal IDataObject interface on the clipboard. I'm not
    396395   * sure what the use of this is though.
     
    403402   if (hDataObject==0)
    404403     HANDLE_ERROR( E_OUTOFMEMORY );
    405 
     404   
    406405   ppDataObject = (OLEClipbrd**)GlobalLock(hDataObject);
    407406   *ppDataObject = theOleClipboard;
     
    411410     HANDLE_ERROR( CLIPBRD_E_CANT_SET );
    412411*/
    413 
     412 
    414413  hr = S_OK;
    415414
     
    440439/***********************************************************************
    441440 * OleGetClipboard [OLE32.105]
    442  * Returns a pointer to our internal IDataObject which represents the conceptual
    443  * state of the Windows clipboard. If the current clipboard already contains
     441 * Returns a pointer to our internal IDataObject which represents the conceptual 
     442 * state of the Windows clipboard. If the current clipboard already contains 
    444443 * an IDataObject, our internal IDataObject will delegate to this object.
    445444 */
     
    448447  HRESULT hr = S_OK;
    449448  TRACE("()\n");
    450 
     449   
    451450  /*
    452451   * Make sure we have a clipboard object
     
    489488  BOOL bClipboardOpen = FALSE;
    490489  IDataObject* pIDataObjectSrc = NULL;
    491 
     490 
    492491  TRACE("()\n");
    493492
     
    509508  pIDataObjectSrc = theOleClipboard->pIDataObjectSrc;
    510509  IDataObject_AddRef(pIDataObjectSrc);
    511 
     510 
    512511  /*
    513512   * Open the Windows clipboard
     
    549548    }
    550549  }
    551 
     550 
    552551  IEnumFORMATETC_Release(penumFormatetc);
    553 
     552 
    554553  /*
    555554   * Release the source data object we are holding on to
     
    572571 *           OleIsCurrentClipboard [OLE32.110]
    573572 */
    574 HRESULT WINAPI OleIsCurrentClipboard (  IDataObject *pDataObject)
     573HRESULT WINAPI OleIsCurrentClipboard (  IDataObject *pDataObject) 
    575574{
    576575  TRACE("()\n");
     
    588587
    589588/*---------------------------------------------------------------------*
    590  *           Internal implementation methods for the OLE clipboard
     589 *           Internal implementation methods for the OLE clipboard 
    591590 *---------------------------------------------------------------------*/
    592591
    593592/***********************************************************************
    594593 * OLEClipbrd_Initialize()
    595  * Initializes the OLE clipboard.
     594 * Initializes the OLE clipboard. 
    596595 */
    597596void OLEClipbrd_Initialize()
    598597{
    599598  /*
    600    * Create the clipboard if necessary
     599   * Create the clipboard if necessary 
    601600   */
    602601  if ( !theOleClipboard )
     
    610609/***********************************************************************
    611610 * OLEClipbrd_UnInitialize()
    612  * Un-Initializes the OLE clipboard
     611 * Un-Initializes the OLE clipboard 
    613612 */
    614613void OLEClipbrd_UnInitialize()
     
    637636  OLEClipbrd* newObject = NULL;
    638637  HGLOBAL hNewObject = 0;
    639 
     638 
    640639  /*
    641640   * Allocate space for the object. We use GlobalAlloc since we need
     
    651650   */
    652651  newObject = GlobalLock(hNewObject);
    653 
     652 
    654653  /*
    655654   * Initialize the virtual function table.
     
    658657
    659658  /*
    660    * Start with one reference count. The caller of this function
     659   * Start with one reference count. The caller of this function 
    661660   * must release the interface pointer when it is done.
    662661   */
     
    664663
    665664  newObject->hSelf = hNewObject;
    666 
     665 
    667666  /*
    668667   * The Ole clipboard is a singleton - save the global handle and pointer
     
    677676{
    678677  TRACE("()\n");
    679 
     678   
    680679  if ( !ptrToDestroy )
    681680    return;
    682681
    683682  /*
    684    * Destroy the Ole clipboard window
     683   * Destroy the Ole clipboard window 
    685684   */
    686685  if ( ptrToDestroy->hWndClipboard )
     
    704703/***********************************************************************
    705704 * OLEClipbrd_CreateWindow()
    706  * Create the clipboard window
     705 * Create the clipboard window 
    707706 */
    708707static HWND OLEClipbrd_CreateWindow()
     
    711710  WNDCLASSEXA wcex;
    712711
    713   /*
    714    * Register the clipboard window class if necessary
     712  /* 
     713   * Register the clipboard window class if necessary 
    715714   */
    716715    ZeroMemory( &wcex, sizeof(WNDCLASSEXA));
     
    728727
    729728  /*
    730    * Create a hidden window to receive OLE clipboard messages
     729   * Create a hidden window to receive OLE clipboard messages 
    731730   */
    732731
     
    738737 */
    739738
    740   hwnd = CreateWindowA(OLEClipbrd_WNDCLASS,
    741                     "ClipboardWindow",
    742                     WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED,
    743                     CW_USEDEFAULT, CW_USEDEFAULT,
    744                     CW_USEDEFAULT, CW_USEDEFAULT,
    745                     0,
    746                     0,
    747                     0,
    748                     0 /*(LPVOID)&clipboardInfo */);
     739  hwnd = CreateWindowA(OLEClipbrd_WNDCLASS, 
     740                                    "ClipboardWindow",
     741                                    WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED,
     742                                    CW_USEDEFAULT, CW_USEDEFAULT,
     743                                    CW_USEDEFAULT, CW_USEDEFAULT,
     744                                    0,
     745                                    0,
     746                                    0,
     747                                    0 /*(LPVOID)&clipboardInfo */);
    749748
    750749  return hwnd;
     
    757756static void OLEClipbrd_DestroyWindow(HWND hwnd)
    758757{
    759   /*
    760    * Destroy clipboard window and unregister its WNDCLASS
     758  /* 
     759   * Destroy clipboard window and unregister its WNDCLASS 
    761760   */
    762761  DestroyWindow(hwnd);
     
    766765/***********************************************************************
    767766 * OLEClipbrd_WndProc(HWND, unsigned, WORD, LONG)
    768  * Processes messages sent to the OLE clipboard window.
    769  * Note that we will intercept messages in our WndProc only when data
    770  * has been placed in the clipboard via OleSetClipboard().
     767 * Processes messages sent to the OLE clipboard window. 
     768 * Note that we will intercept messages in our WndProc only when data 
     769 * has been placed in the clipboard via OleSetClipboard(). 
    771770 * i.e. Only when OLE owns the windows clipboard.
    772771 */
     
    774773  (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    775774{
    776   switch (message)
     775  switch (message) 
    777776  {
    778777    /*
    779      * WM_RENDERFORMAT
     778     * WM_RENDERFORMAT 
    780779     * We receive this message to allow us to handle delayed rendering of
    781      * a specific clipboard format when an application requests data in
     780     * a specific clipboard format when an application requests data in 
    782781     * that format by calling GetClipboardData.
    783      * (Recall that in OleSetClipboard, we used SetClipboardData to
     782     * (Recall that in OleSetClipboard, we used SetClipboardData to 
    784783     * make all HGLOBAL formats supported by the source IDataObject
    785784     * available using delayed rendering)
    786      * On receiving this mesage we must actually render the data in the
    787      * specified format and place it on the clipboard by calling the
    788      * SetClipboardData function.
     785     * On receiving this mesage we must actually render the data in the 
     786     * specified format and place it on the clipboard by calling the 
     787     * SetClipboardData function. 
    789788     */
    790789    case WM_RENDERFORMAT:
    791790    {
    792791      FORMATETC rgelt;
    793 
     792       
    794793      ZeroMemory( &rgelt, sizeof(FORMATETC));
    795794
     
    803802
    804803      TRACE("(): WM_RENDERFORMAT(cfFormat=%d)\n", rgelt.cfFormat);
    805 
     804     
    806805      /*
    807806       * Render the clipboard data.
     
    827826      IEnumFORMATETC* penumFormatetc = NULL;
    828827      FORMATETC rgelt;
    829 
     828     
    830829      TRACE("(): WM_RENDERALLFORMATS\n");
    831 
     830     
    832831      /*
    833832       * Render all HGLOBAL formats supported by the source into
     
    846845        {
    847846          /*
    848            * Render the clipboard data.
     847           * Render the clipboard data. 
    849848           */
    850849          if ( FAILED(OLEClipbrd_RenderFormat( (IDataObject*)&(theOleClipboard->lpvtbl1), &rgelt )) )
    851850            continue;
    852 
     851       
    853852          TRACE("(): WM_RENDERALLFORMATS(cfFormat=%d)\n", rgelt.cfFormat);
    854853        }
    855854      }
    856 
     855     
    857856      IEnumFORMATETC_Release(penumFormatetc);
    858857
     
    993992
    994993        HeapFree(GetProcessHeap(), 0, mfBits);
    995 
     994 
    996995        GlobalUnlock(std2.u.hMetaFilePict);
    997996
     
    10211020   *  Put a copy of the rendered data back on the clipboard
    10221021   */
    1023 
     1022 
    10241023  if ( !(hDup = OLEClipbrd_GlobalDupMem(hStorage)) )
    10251024    HANDLE_ERROR( E_OUTOFMEMORY );
    1026 
     1025       
    10271026  if ( !SetClipboardData( pFormatetc->cfFormat, hDup ) )
    10281027  {
     
    10321031
    10331032CLEANUP:
    1034 
     1033 
    10351034  ReleaseStgMedium(&std);
    1036 
     1035 
    10371036  return hr;
    10381037}
     
    10481047    PVOID pGlobalSrc, pGlobalDest;
    10491048    DWORD cBytes;
    1050 
     1049   
    10511050    if ( !hGlobalSrc )
    10521051      return 0;
     
    10551054    if ( 0 == cBytes )
    10561055      return 0;
    1057 
     1056       
    10581057    hGlobalDest = GlobalAlloc( GMEM_DDESHARE|GMEM_MOVEABLE,
    10591058                               cBytes );
    10601059    if ( !hGlobalDest )
    10611060      return 0;
    1062 
     1061   
    10631062    pGlobalSrc = GlobalLock(hGlobalSrc);
    10641063    pGlobalDest = GlobalLock(hGlobalDest);
     
    10671066
    10681067    memcpy(pGlobalDest, pGlobalSrc, cBytes);
    1069 
     1068       
    10701069    GlobalUnlock(hGlobalSrc);
    10711070    GlobalUnlock(hGlobalDest);
     
    10761075
    10771076/*---------------------------------------------------------------------*
    1078  *  Implementation of the internal IDataObject interface exposed by
     1077 *  Implementation of the internal IDataObject interface exposed by 
    10791078 *  the OLE clipboard.
    10801079 *---------------------------------------------------------------------*/
     
    10911090            void**           ppvObject)
    10921091{
    1093   /*
    1094    * Declare "This" pointer
     1092  /* 
     1093   * Declare "This" pointer 
    10951094   */
    10961095  ICOM_THIS(OLEClipbrd, iface);
    10971096  TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObject);
    1098 
     1097 
    10991098  /*
    11001099   * Perform a sanity check on the parameters.
     
    11021101  if ( (This==0) || (ppvObject==0) )
    11031102    return E_INVALIDARG;
    1104 
     1103 
    11051104  /*
    11061105   * Initialize the return parameter.
     
    11111110   * Compare the riid with the interface IDs implemented by this object.
    11121111   */
    1113   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     1112  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    11141113  {
    11151114    *ppvObject = iface;
    11161115  }
    1117   else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
     1116  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 
    11181117  {
    11191118    *ppvObject = (IDataObject*)&(This->lpvtbl1);
     
    11241123    return E_NOINTERFACE;
    11251124  }
    1126 
     1125 
    11271126  /*
    11281127   * Query Interface always increases the reference count by one when it is
    1129    * successful.
     1128   * successful. 
    11301129   */
    11311130  IUnknown_AddRef((IUnknown*)*ppvObject);
     
    11391138 * See Windows documentation for more details on IUnknown methods.
    11401139 */
    1141 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef(
     1140static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 
    11421141            IDataObject*     iface)
    11431142{
    1144   /*
    1145    * Declare "This" pointer
     1143  /* 
     1144   * Declare "This" pointer 
    11461145   */
    11471146  ICOM_THIS(OLEClipbrd, iface);
    11481147
    11491148  TRACE("(%p)->(count=%lu)\n",This, This->ref);
    1150 
     1149 
    11511150  This->ref++;
    11521151
     
    11591158 * See Windows documentation for more details on IUnknown methods.
    11601159 */
    1161 static ULONG WINAPI OLEClipbrd_IDataObject_Release(
     1160static ULONG WINAPI OLEClipbrd_IDataObject_Release( 
    11621161            IDataObject*     iface)
    11631162{
    1164   /*
    1165    * Declare "This" pointer
     1163  /* 
     1164   * Declare "This" pointer 
    11661165   */
    11671166  ICOM_THIS(OLEClipbrd, iface);
    11681167
    11691168  TRACE("(%p)->(count=%lu)\n",This, This->ref);
    1170 
     1169 
    11711170  /*
    11721171   * Decrease the reference count on this object.
     
    11811180    OLEClipbrd_Destroy(This);
    11821181  }
    1183 
     1182 
    11841183  return This->ref;
    11851184}
    11861185
    1187 
     1186 
    11881187/************************************************************************
    11891188 * OLEClipbrd_IDataObject_GetData (IDataObject)
    11901189 *
    1191  * The OLE Clipboard's implementation of this method delegates to
     1190 * The OLE Clipboard's implementation of this method delegates to 
    11921191 * a data source if there is one or wraps around the windows clipboard
    11931192 *
     
    11951194 */
    11961195static HRESULT WINAPI OLEClipbrd_IDataObject_GetData(
    1197         IDataObject*     iface,
    1198         LPFORMATETC      pformatetcIn,
    1199         STGMEDIUM*       pmedium)
     1196            IDataObject*     iface,
     1197            LPFORMATETC      pformatetcIn,
     1198            STGMEDIUM*       pmedium)
    12001199{
    12011200  HANDLE      hData = 0;
     
    12041203
    12051204  /*
    1206    * Declare "This" pointer
     1205   * Declare "This" pointer 
    12071206   */
    12081207  ICOM_THIS(OLEClipbrd, iface);
    1209 
     1208 
    12101209  TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium);
    12111210
     
    12331232*/
    12341233
    1235   /*
     1234  /* 
    12361235   * Otherwise, get the data from the windows clipboard using GetClipboardData
    12371236   */
     
    12411240  hData = GetClipboardData(pformatetcIn->cfFormat);
    12421241
    1243   /*
     1242  /* 
    12441243   * Return the clipboard data in the storage medium structure
    12451244   */
     
    12471246  pmedium->u.hGlobal = (HGLOBAL)hData;
    12481247  pmedium->pUnkForRelease = NULL;
    1249 
     1248 
    12501249  hr = S_OK;
    1251 
     1250 
    12521251CLEANUP:
    12531252  /*
     
    12631262
    12641263static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere(
    1265         IDataObject*     iface,
    1266         LPFORMATETC      pformatetc,
    1267         STGMEDIUM*       pmedium)
     1264            IDataObject*     iface,
     1265            LPFORMATETC      pformatetc,
     1266            STGMEDIUM*       pmedium)
    12681267{
    12691268  FIXME(": Stub\n");
     
    12741273 * OLEClipbrd_IDataObject_QueryGetData (IDataObject)
    12751274 *
    1276  * The OLE Clipboard's implementation of this method delegates to
     1275 * The OLE Clipboard's implementation of this method delegates to 
    12771276 * a data source if there is one or wraps around the windows clipboard
    12781277 * function IsClipboardFormatAvailable() otherwise.
     
    12811280 */
    12821281static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData(
    1283         IDataObject*     iface,
    1284         LPFORMATETC      pformatetc)
    1285 {
    1286   /*
    1287    * Declare "This" pointer
     1282            IDataObject*     iface,
     1283            LPFORMATETC      pformatetc)
     1284{
     1285  /* 
     1286   * Declare "This" pointer 
    12881287   */
    12891288  ICOM_THIS(OLEClipbrd, iface);
     
    13151314  if ( pformatetc->tymed != TYMED_HGLOBAL )
    13161315    return DV_E_TYMED;
    1317 
     1316         
    13181317  /*
    13191318   * Delegate to the Windows clipboard function IsClipboardFormatAvailable
     
    13281327 */
    13291328static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc(
    1330         IDataObject*     iface,
    1331         LPFORMATETC      pformatectIn,
    1332         LPFORMATETC      pformatetcOut)
     1329            IDataObject*     iface,
     1330            LPFORMATETC      pformatectIn,
     1331            LPFORMATETC      pformatetcOut)
    13331332{
    13341333  TRACE("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
     
    13441343 * OLEClipbrd_IDataObject_SetData (IDataObject)
    13451344 *
    1346  * The OLE Clipboard's does not implement this method
     1345 * The OLE Clipboard's does not implement this method 
    13471346 *
    13481347 * See Windows documentation for more details on IDataObject methods.
    13491348 */
    13501349static HRESULT WINAPI OLEClipbrd_IDataObject_SetData(
    1351         IDataObject*     iface,
    1352         LPFORMATETC      pformatetc,
    1353         STGMEDIUM*       pmedium,
    1354         BOOL             fRelease)
     1350            IDataObject*     iface,
     1351            LPFORMATETC      pformatetc,
     1352            STGMEDIUM*       pmedium,
     1353            BOOL             fRelease)
    13551354{
    13561355  TRACE("\n");
     
    13641363 */
    13651364static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc(
    1366         IDataObject*     iface,
    1367         DWORD            dwDirection,
    1368         IEnumFORMATETC** ppenumFormatEtc)
     1365            IDataObject*     iface,
     1366            DWORD            dwDirection,
     1367            IEnumFORMATETC** ppenumFormatEtc)
    13691368{
    13701369  HRESULT hr = S_OK;
     
    13731372  UINT format;
    13741373  BOOL bClipboardOpen;
    1375 
    1376   /*
    1377    * Declare "This" pointer
     1374 
     1375  /* 
     1376   * Declare "This" pointer 
    13781377   */
    13791378  ICOM_THIS(OLEClipbrd, iface);
     
    14281427      HANDLE_ERROR( E_FAIL );
    14291428    }
    1430 
     1429   
    14311430    /* Init the FORMATETC struct */
    14321431    afmt[i].cfFormat = format;
     
    14471446  if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenumFormatEtc)))
    14481447    HANDLE_ERROR( hr );
    1449 
     1448     
    14501449  hr = S_OK;
    1451 
     1450 
    14521451CLEANUP:
    14531452  /*
     
    14561455  if (afmt)
    14571456    HeapFree(GetProcessHeap(), 0, afmt);
    1458 
     1457 
    14591458  /*
    14601459   * Close Windows clipboard
     
    14691468 * OLEClipbrd_IDataObject_DAdvise (IDataObject)
    14701469 *
    1471  * The OLE Clipboard's does not implement this method
     1470 * The OLE Clipboard's does not implement this method 
    14721471 *
    14731472 * See Windows documentation for more details on IDataObject methods.
    14741473 */
    14751474static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise(
    1476         IDataObject*     iface,
    1477         FORMATETC*       pformatetc,
    1478         DWORD            advf,
    1479         IAdviseSink*     pAdvSink,
    1480         DWORD*           pdwConnection)
     1475            IDataObject*     iface,
     1476            FORMATETC*       pformatetc,
     1477            DWORD            advf,
     1478            IAdviseSink*     pAdvSink,
     1479            DWORD*           pdwConnection)
    14811480{
    14821481  TRACE("\n");
     
    14871486 * OLEClipbrd_IDataObject_DUnadvise (IDataObject)
    14881487 *
    1489  * The OLE Clipboard's does not implement this method
     1488 * The OLE Clipboard's does not implement this method 
    14901489 *
    14911490 * See Windows documentation for more details on IDataObject methods.
    14921491 */
    14931492static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise(
    1494         IDataObject*     iface,
    1495         DWORD            dwConnection)
     1493            IDataObject*     iface,
     1494            DWORD            dwConnection)
    14961495{
    14971496  TRACE("\n");
     
    15071506 */
    15081507static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise(
    1509         IDataObject*     iface,
    1510         IEnumSTATDATA**  ppenumAdvise)
     1508            IDataObject*     iface,
     1509            IEnumSTATDATA**  ppenumAdvise)
    15111510{
    15121511  TRACE("\n");
     
    15341533  DWORD size=cfmt * sizeof(FORMATETC);
    15351534  LPMALLOC pIMalloc;
    1536 
     1535 
    15371536  ef = (IEnumFORMATETCImpl*)HeapAlloc(GetProcessHeap(),
    15381537                                      HEAP_ZERO_MEMORY,
     
    15401539  if (!ef)
    15411540    return NULL;
    1542 
     1541 
    15431542  ef->ref = 0;
    15441543  ICOM_VTBL(ef) = &efvt;
    15451544  ef->pUnkDataObj = pUnkDataObj;
    1546 
     1545 
    15471546  ef->posFmt = 0;
    15481547  ef->countFmt = cfmt;
     
    15511550  ef->pFmt = (LPFORMATETC)IMalloc_Alloc(pIMalloc, size);
    15521551  IMalloc_Release(pIMalloc);
    1553 
     1552 
    15541553  if (ef->pFmt)
    15551554    memcpy(ef->pFmt, afmt, size);
    1556 
     1555 
    15571556  TRACE("(%p)->()\n",ef);
    15581557  return (LPENUMFORMATETC)ef;
     
    15761575   * we only need to support the IUnknown and IEnumFORMATETC interfaces
    15771576   */
    1578 
     1577 
    15791578  *ppvObj = NULL;
    1580 
     1579 
    15811580  if(IsEqualIID(riid, &IID_IUnknown))
    15821581  {
     
    15861585  {
    15871586    *ppvObj = (IDataObject*)This;
    1588   }
    1589 
     1587  }   
     1588 
    15901589  if(*ppvObj)
    15911590  {
     
    15941593    return S_OK;
    15951594  }
    1596 
     1595 
    15971596  TRACE("-- Interface: E_NOINTERFACE\n");
    15981597  return E_NOINTERFACE;
     
    16151614  if (This->pUnkDataObj)
    16161615    IUnknown_AddRef(This->pUnkDataObj);
    1617 
     1616 
    16181617  return ++(This->ref);
    16191618}
     
    16331632  if (This->pUnkDataObj)
    16341633    IUnknown_Release(This->pUnkDataObj);  /* Release parent data object */
    1635 
    1636   if (!--(This->ref))
     1634 
     1635  if (!--(This->ref)) 
    16371636  {
    16381637    TRACE("() - destroying IEnumFORMATETC(%p)\n",This);
     
    16421641      IMalloc_Release(pIMalloc);
    16431642    }
    1644 
     1643     
    16451644    HeapFree(GetProcessHeap(),0,This);
    16461645    return 0;
     
    16611660  UINT cfetch;
    16621661  HRESULT hres = S_FALSE;
    1663 
     1662 
    16641663  TRACE("(%p)->(pos=%u)\n", This, This->posFmt);
    1665 
     1664 
    16661665  if (This->posFmt < This->countFmt)
    16671666  {
     
    16721671      hres = S_OK;
    16731672    }
    1674 
     1673   
    16751674    memcpy(rgelt, &This->pFmt[This->posFmt], cfetch * sizeof(FORMATETC));
    16761675    This->posFmt += cfetch;
     
    16801679    cfetch = 0;
    16811680  }
    1682 
     1681 
    16831682  if (pceltFethed)
    16841683  {
    16851684    *pceltFethed = cfetch;
    16861685  }
    1687 
     1686 
    16881687  return hres;
    16891688}
     
    16981697  ICOM_THIS(IEnumFORMATETCImpl,iface);
    16991698  TRACE("(%p)->(num=%lu)\n", This, celt);
    1700 
     1699 
    17011700  This->posFmt += celt;
    17021701  if (This->posFmt > This->countFmt)
     
    17171716  ICOM_THIS(IEnumFORMATETCImpl,iface);
    17181717  TRACE("(%p)->()\n", This);
    1719 
     1718 
    17201719  This->posFmt = 0;
    17211720  return S_OK;
     
    17321731  ICOM_THIS(IEnumFORMATETCImpl,iface);
    17331732  HRESULT hr = S_OK;
    1734 
     1733 
    17351734  TRACE("(%p)->(ppenum=%p)\n", This, ppenum);
    17361735
     
    17441743  if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenum)))
    17451744    return ( hr );
    1746 
     1745 
    17471746  return (*ppenum) ? S_OK : E_OUTOFMEMORY;
    17481747}
  • trunk/src/ole32/compobj.c

    r6648 r6711  
    1 /* $Id: compobj.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/*
    3  *  COMPOBJ library
    4  *
    5  *  Copyright 1995  Martin von Loewis
    6  *  Copyright 1998  Justin Bradford
     2 *      COMPOBJ library
     3 *
     4 *      Copyright 1995  Martin von Loewis
     5 *      Copyright 1998  Justin Bradford
    76 *      Copyright 1999  Francis Beaudet
    87 *  Copyright 1999  Sylvain St-Germain
     
    3837#ifdef __WIN32OS2__
    3938#include <heapstring.h>
     39
     40#undef FIXME
     41#undef TRACE
     42#ifdef DEBUG
     43#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     44#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     45#else
     46#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     47#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     48#endif
    4049#endif
    4150
     
    4554 *  COM External Lock structures and methods declaration
    4655 *
    47  *  This api provides a linked list to managed external references to
    48  *  COM objects.
    49  *
    50  *  The public interface consists of three calls:
     56 *  This api provides a linked list to managed external references to 
     57 *  COM objects. 
     58 *
     59 *  The public interface consists of three calls: 
    5160 *      COM_ExternalLockAddRef
    5261 *      COM_ExternalLockRelease
     
    5867
    5968/*
    60  * Declaration of the static structure that manage the
     69 * Declaration of the static structure that manage the 
    6170 * external lock to COM  objects.
    6271 */
     
    8392
    8493/*
    85  * Public Interface to the external lock list
     94 * Public Interface to the external lock list   
    8695 */
    8796static void COM_ExternalLockFreeList();
     
    91100
    92101/*
    93  * Private methods used to managed the linked list
     102 * Private methods used to managed the linked list   
    94103 */
    95104static BOOL COM_ExternalLockInsert(
     
    153162 */
    154163typedef struct tagOpenDll {
    155   HINSTANCE hLibrary;
     164  HINSTANCE hLibrary;       
    156165  struct tagOpenDll *next;
    157166} OpenDll;
     
    164173 */
    165174static HRESULT COM_GetRegisteredClassObject(REFCLSID    rclsid,
    166                         DWORD       dwClsContext,
    167                         LPUNKNOWN*  ppUnk);
     175                                            DWORD       dwClsContext,
     176                                            LPUNKNOWN*  ppUnk);
    168177
    169178static void COM_RevokeAllClasses();
     
    174183 *
    175184 * RETURNS
    176  *  Current build version, hiword is majornumber, loword is minornumber
     185 *      Current build version, hiword is majornumber, loword is minornumber
    177186 */
    178187DWORD WINAPI CoBuildVersion(void)
     
    184193#ifndef __WIN32OS2__
    185194/******************************************************************************
    186  *      CoInitialize16  [COMPOBJ.2]
     195 *              CoInitialize16  [COMPOBJ.2]
    187196 * Set the win16 IMalloc used for memory management
    188197 */
    189198HRESULT WINAPI CoInitialize16(
    190     LPVOID lpReserved   /* [in] pointer to win16 malloc interface */
     199        LPVOID lpReserved       /* [in] pointer to win16 malloc interface */
    191200) {
    192201    currentMalloc16 = (LPMALLOC16)lpReserved;
     
    196205
    197206/******************************************************************************
    198  *      CoInitialize    [OLE32.26]
     207 *              CoInitialize    [OLE32.26]
    199208 *
    200209 * Initializes the COM libraries.
     
    203212 */
    204213HRESULT WINAPI CoInitialize(
    205     LPVOID lpReserved   /* [in] pointer to win32 malloc interface
     214        LPVOID lpReserved       /* [in] pointer to win32 malloc interface
    206215                                   (obsolete, should be NULL) */
    207 )
     216) 
    208217{
    209218  /*
     
    214223
    215224/******************************************************************************
    216  *      CoInitializeEx  [OLE32.163]
     225 *              CoInitializeEx  [OLE32.163]
    217226 *
    218227 * Initializes the COM libraries. The behavior used to set the win32 IMalloc
     
    226235 *
    227236 * BUGS
    228  * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE
     237 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 
    229238 * is never returned.
    230239 *
     
    232241 */
    233242HRESULT WINAPI CoInitializeEx(
    234     LPVOID lpReserved,  /* [in] pointer to win32 malloc interface
     243        LPVOID lpReserved,      /* [in] pointer to win32 malloc interface
    235244                                   (obsolete, should be NULL) */
    236     DWORD dwCoInit      /* [in] A value from COINIT specifies the threading model */
    237 )
     245        DWORD dwCoInit          /* [in] A value from COINIT specifies the threading model */
     246) 
    238247{
    239248  HRESULT hr;
     
    249258   * Check for unsupported features.
    250259   */
    251   if (dwCoInit!=COINIT_APARTMENTTHREADED)
     260  if (dwCoInit!=COINIT_APARTMENTTHREADED) 
    252261  {
    253262    FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit);
     
    284293/***********************************************************************
    285294 *           CoUninitialize16   [COMPOBJ.3]
    286  * Don't know what it does.
     295 * Don't know what it does. 
    287296 * 3-Nov-98 -- this was originally misspelled, I changed it to what I
    288297 *   believe is the correct spelling
     
    305314{
    306315  TRACE("()\n");
    307 
     316 
    308317  /*
    309318   * Decrease the reference count.
    310319   */
    311320  s_COMLockCount--;
    312 
     321 
    313322  /*
    314323   * If we are back to 0 locks on the COM library, make sure we free
     
    344353 *           CoGetMalloc16    [COMPOBJ.4]
    345354 * RETURNS
    346  *  The current win16 IMalloc
     355 *      The current win16 IMalloc
    347356 */
    348357HRESULT WINAPI CoGetMalloc16(
    349     DWORD dwMemContext, /* [in] unknown */
    350     LPMALLOC16 * lpMalloc   /* [out] current win16 malloc interface */
     358        DWORD dwMemContext,     /* [in] unknown */
     359        LPMALLOC16 * lpMalloc   /* [out] current win16 malloc interface */
    351360) {
    352361    if(!currentMalloc16)
    353     currentMalloc16 = IMalloc16_Constructor();
     362        currentMalloc16 = IMalloc16_Constructor();
    354363    *lpMalloc = currentMalloc16;
    355364    return S_OK;
     
    358367
    359368/******************************************************************************
    360  *      CoGetMalloc [OLE32.20]
     369 *              CoGetMalloc     [OLE32.20]
    361370 *
    362371 * RETURNS
    363  *  The current win32 IMalloc
     372 *      The current win32 IMalloc
    364373 */
    365374HRESULT WINAPI CoGetMalloc(
    366     DWORD dwMemContext, /* [in] unknown */
    367     LPMALLOC *lpMalloc  /* [out] current win32 malloc interface */
     375        DWORD dwMemContext,     /* [in] unknown */
     376        LPMALLOC *lpMalloc      /* [out] current win32 malloc interface */
    368377) {
    369378    if(!currentMalloc32)
    370     currentMalloc32 = IMalloc_Constructor();
     379        currentMalloc32 = IMalloc_Constructor();
    371380    *lpMalloc = currentMalloc32;
    372381    return S_OK;
     
    378387 */
    379388HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
    380                       LPMALLOC16 *lpMalloc)
     389                                          LPMALLOC16 *lpMalloc)
    381390{
    382391    /* FIXME: docu says we shouldn't return the same allocator as in
     
    387396
    388397/******************************************************************************
    389  *      CoDisconnectObject  [COMPOBJ.15]
     398 *              CoDisconnectObject      [COMPOBJ.15]
    390399 */
    391400HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
     
    401410 *
    402411 * RETURNS
    403  *  TRUE if equal
     412 *      TRUE if equal
    404413 */
    405414BOOL16 WINAPI IsEqualGUID16(
    406     GUID* g1,   /* [in] unique id 1 */
    407     GUID* g2    /* [in] unique id 2 */
     415        GUID* g1,       /* [in] unique id 1 */
     416        GUID* g2        /* [in] unique id 2 */
    408417) {
    409418    return !memcmp( g1, g2, sizeof(GUID) );
     
    412421
    413422/******************************************************************************
    414  *      CLSIDFromString16   [COMPOBJ.20]
    415  * Converts a unique identifier from its string representation into
     423 *              CLSIDFromString16       [COMPOBJ.20]
     424 * Converts a unique identifier from its string representation into 
    416425 * the GUID struct.
    417426 *
    418  * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
     427 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 
    419428 *
    420429 * RETURNS
    421  *  the converted GUID
     430 *      the converted GUID
    422431 */
    423432HRESULT WINAPI CLSIDFromString16(
    424     LPCOLESTR16 idstr,  /* [in] string representation of guid */
    425     CLSID *id       /* [out] GUID converted from string */
     433        LPCOLESTR16 idstr,      /* [in] string representation of guid */
     434        CLSID *id               /* [out] GUID converted from string */
    426435) {
    427436  BYTE *s = (BYTE *) idstr;
    428437  BYTE *p;
    429   int   i;
     438  int   i;
    430439  BYTE table[256];
    431440
    432441  if (!s)
    433       s = "{00000000-0000-0000-0000-000000000000}";
     442          s = "{00000000-0000-0000-0000-000000000000}";
    434443  else {  /* validate the CLSID string */
    435444
     
    468477  p = (BYTE *) id;
    469478
    470   s++;  /* skip leading brace  */
     479  s++;  /* skip leading brace  */
    471480  for (i = 0; i < 4; i++) {
    472481    p[3 - i] = table[*s]<<4 | table[*(s+1)];
     
    474483  }
    475484  p += 4;
    476   s++;  /* skip - */
     485  s++;  /* skip - */
    477486
    478487  for (i = 0; i < 2; i++) {
     
    481490  }
    482491  p += 2;
    483   s++;  /* skip - */
     492  s++;  /* skip - */
    484493
    485494  for (i = 0; i < 2; i++) {
     
    488497  }
    489498  p += 2;
    490   s++;  /* skip - */
     499  s++;  /* skip - */
    491500
    492501  /* these are just sequential bytes */
     
    495504    s += 2;
    496505  }
    497   s++;  /* skip - */
     506  s++;  /* skip - */
    498507
    499508  for (i = 0; i < 6; i++) {
     
    506515
    507516/******************************************************************************
    508  *      CoCreateGuid[OLE32.6]
     517 *              CoCreateGuid[OLE32.6]
    509518 *
    510519 */
    511520HRESULT WINAPI CoCreateGuid(
    512     GUID *pguid /* [out] points to the GUID to initialize */
     521        GUID *pguid /* [out] points to the GUID to initialize */
    513522) {
    514523    return UuidCreate(pguid);
     
    516525
    517526/******************************************************************************
    518  *      CLSIDFromString [OLE32.3]
    519  * Converts a unique identifier from its string representation into
     527 *              CLSIDFromString [OLE32.3]
     528 * Converts a unique identifier from its string representation into 
    520529 * the GUID struct.
    521530 *
     
    524533 *
    525534 * RETURNS
    526  *  the converted GUID
     535 *      the converted GUID
    527536 */
    528537HRESULT WINAPI CLSIDFromString(
    529     LPCOLESTR idstr,    /* [in] string representation of GUID */
    530     CLSID *id       /* [out] GUID represented by above string */
     538        LPCOLESTR idstr,        /* [in] string representation of GUID */
     539        CLSID *id               /* [out] GUID represented by above string */
    531540) {
    532541    LPOLESTR16      xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr);
     
    541550
    542551/******************************************************************************
    543  *      WINE_StringFromCLSID    [Internal]
     552 *              WINE_StringFromCLSID    [Internal]
    544553 * Converts a GUID into the respective string representation.
    545554 *
     
    547556 *
    548557 * RETURNS
    549  *  the string representation and HRESULT
     558 *      the string representation and HRESULT
    550559 */
    551560#ifdef __WIN32OS2__
    552561HRESULT WINAPI WINE_StringFromCLSID(
    553     const CLSID *id,    /* [in] GUID to be converted */
    554     LPSTR idstr     /* [out] pointer to buffer to contain converted guid */
     562        const CLSID *id,        /* [in] GUID to be converted */
     563        LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
    555564#else
    556565static HRESULT WINE_StringFromCLSID(
    557     const CLSID *id,    /* [in] GUID to be converted */
    558     LPSTR idstr     /* [out] pointer to buffer to contain converted guid */
     566        const CLSID *id,        /* [in] GUID to be converted */
     567        LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
    559568#endif
    560569) {
    561570  static const char *hex = "0123456789ABCDEF";
    562571  char *s;
    563   int   i;
     572  int   i;
    564573
    565574  if (!id)
    566     { ERR("called with id=Null\n");
    567       *idstr = 0x00;
    568       return E_FAIL;
    569     }
    570 
     575        { ERR("called with id=Null\n");
     576          *idstr = 0x00;
     577          return E_FAIL;
     578        }
     579       
    571580  sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-",
    572       id->Data1, id->Data2, id->Data3,
    573       id->Data4[0], id->Data4[1]);
     581          id->Data1, id->Data2, id->Data3,
     582          id->Data4[0], id->Data4[1]);
    574583  s = &idstr[25];
    575584
     
    589598#ifndef __WIN32OS2__
    590599/******************************************************************************
    591  *      StringFromCLSID16   [COMPOBJ.19]
     600 *              StringFromCLSID16       [COMPOBJ.19]
    592601 * Converts a GUID into the respective string representation.
    593602 * The target string is allocated using the OLE IMalloc.
    594603 * RETURNS
    595  *  the string representation and HRESULT
     604 *      the string representation and HRESULT
    596605 */
    597606HRESULT WINAPI StringFromCLSID16(
    598607        REFCLSID id,            /* [in] the GUID to be converted */
    599     LPOLESTR16 *idstr   /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
     608        LPOLESTR16 *idstr       /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
    600609
    601610) {
    602611    extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
    603612                                           DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode );
    604     LPMALLOC16  mllc;
    605     HRESULT ret;
    606     DWORD   args[2];
     613    LPMALLOC16  mllc;
     614    HRESULT     ret;
     615    DWORD       args[2];
    607616
    608617    ret = CoGetMalloc16(0,&mllc);
     
    616625     */
    617626    if (!K32WOWCallback16Ex(
    618         (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL(
     627        (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL(
    619628            (SEGPTR)ICOM_VTBL(((LPMALLOC16)MapSL((SEGPTR)mllc))))
    620     )->Alloc,
    621     WCB16_CDECL,
    622     2*sizeof(DWORD),
    623     (LPVOID)args,
    624     (LPDWORD)idstr
     629        )->Alloc,
     630        WCB16_CDECL,
     631        2*sizeof(DWORD),
     632        (LPVOID)args,
     633        (LPDWORD)idstr
    625634    )) {
    626         WARN("CallTo16 IMalloc16 failed\n");
    627         return E_FAIL;
     635        WARN("CallTo16 IMalloc16 failed\n");
     636        return E_FAIL;
    628637    }
    629638    return WINE_StringFromCLSID(id,MapSL((SEGPTR)*idstr));
     
    631640#endif
    632641/******************************************************************************
    633  *      StringFromCLSID [OLE32.151]
     642 *              StringFromCLSID [OLE32.151]
    634643 * Converts a GUID into the respective string representation.
    635644 * The target string is allocated using the OLE IMalloc.
    636645 * RETURNS
    637  *  the string representation and HRESULT
     646 *      the string representation and HRESULT
    638647 */
    639648HRESULT WINAPI StringFromCLSID(
    640649        REFCLSID id,            /* [in] the GUID to be converted */
    641     LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
     650        LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
    642651) {
    643     char            buf[80];
    644     HRESULT       ret;
    645     LPMALLOC    mllc;
    646 
    647     if ((ret=CoGetMalloc(0,&mllc)))
    648         return ret;
    649 
    650     ret=WINE_StringFromCLSID(id,buf);
    651     if (!ret) {
     652        char            buf[80];
     653        HRESULT       ret;
     654        LPMALLOC        mllc;
     655
     656        if ((ret=CoGetMalloc(0,&mllc)))
     657                return ret;
     658
     659        ret=WINE_StringFromCLSID(id,buf);
     660        if (!ret) {
    652661            DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 );
    653662            *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) );
    654663            MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len );
    655     }
    656     return ret;
    657 }
    658 
    659 /******************************************************************************
    660  *      StringFromGUID2 [COMPOBJ.76] [OLE32.152]
     664        }
     665        return ret;
     666}
     667
     668/******************************************************************************
     669 *              StringFromGUID2 [COMPOBJ.76] [OLE32.152]
    661670 *
    662671 * Converts a global unique identifier into a string of an API-
     
    664673 *
    665674 * RETURNS
    666  *  The (UNICODE) string representation of the GUID in 'str'
    667  *  The length of the resulting string, 0 if there was any problem.
     675 *      The (UNICODE) string representation of the GUID in 'str'
     676 *      The length of the resulting string, 0 if there was any problem.
    668677 */
    669678INT WINAPI
    670679StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
    671680{
    672   char      xguid[80];
     681  char          xguid[80];
    673682
    674683  if (WINE_StringFromCLSID(id,xguid))
    675     return 0;
     684        return 0;
    676685  return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
    677686}
     
    730739
    731740/******************************************************************************
    732  *      CLSIDFromProgID16   [COMPOBJ.61]
     741 *              CLSIDFromProgID16       [COMPOBJ.61]
    733742 * Converts a program id into the respective GUID. (By using a registry lookup)
    734743 * RETURNS
    735  *  riid associated with the progid
     744 *      riid associated with the progid
    736745 */
    737746HRESULT WINAPI CLSIDFromProgID16(
    738     LPCOLESTR16 progid, /* [in] program id as found in registry */
    739     LPCLSID riid        /* [out] associated CLSID */
     747        LPCOLESTR16 progid,     /* [in] program id as found in registry */
     748        LPCLSID riid            /* [out] associated CLSID */
    740749) {
    741     char    *buf,buf2[80];
    742     DWORD   buf2len;
    743     HRESULT err;
    744     HKEY    xhkey;
    745 
    746     buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
    747     sprintf(buf,"%s\\CLSID",progid);
    748     if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
    749         HeapFree(GetProcessHeap(),0,buf);
     750        char    *buf,buf2[80];
     751        DWORD   buf2len;
     752        HRESULT err;
     753        HKEY    xhkey;
     754
     755        buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
     756        sprintf(buf,"%s\\CLSID",progid);
     757        if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
     758                HeapFree(GetProcessHeap(),0,buf);
    750759                return CO_E_CLASSSTRING;
    751     }
    752     HeapFree(GetProcessHeap(),0,buf);
    753     buf2len = sizeof(buf2);
    754     if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
    755         RegCloseKey(xhkey);
     760        }
     761        HeapFree(GetProcessHeap(),0,buf);
     762        buf2len = sizeof(buf2);
     763        if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
     764                RegCloseKey(xhkey);
    756765                return CO_E_CLASSSTRING;
    757     }
    758     RegCloseKey(xhkey);
    759     return CLSIDFromString16(buf2,riid);
    760 }
    761 
    762 /******************************************************************************
    763  *      CLSIDFromProgID [OLE32.2]
     766        }
     767        RegCloseKey(xhkey);
     768        return CLSIDFromString16(buf2,riid);
     769}
     770
     771/******************************************************************************
     772 *              CLSIDFromProgID [OLE32.2]
    764773 * Converts a program id into the respective GUID. (By using a registry lookup)
    765774 * RETURNS
    766  *  riid associated with the progid
     775 *      riid associated with the progid
    767776 */
    768777HRESULT WINAPI CLSIDFromProgID(
    769     LPCOLESTR progid,   /* [in] program id as found in registry */
    770     LPCLSID riid        /* [out] associated CLSID */
     778        LPCOLESTR progid,       /* [in] program id as found in registry */
     779        LPCLSID riid            /* [out] associated CLSID */
    771780) {
    772     LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
    773     HRESULT       ret = CLSIDFromProgID16(pid,riid);
    774 
    775     HeapFree(GetProcessHeap(),0,pid);
    776     return ret;
     781        LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
     782        HRESULT       ret = CLSIDFromProgID16(pid,riid);
     783
     784        HeapFree(GetProcessHeap(),0,pid);
     785        return ret;
    777786}
    778787
     
    783792 *
    784793 * This function returns the CLSID of the DLL that implements the proxy and stub
    785  * for the specified interface.
    786  *
    787  * It determines this by searching the
     794 * for the specified interface. 
     795 *
     796 * It determines this by searching the 
    788797 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry
    789798 * and any interface id registered by CoRegisterPSClsid within the current process.
    790  *
     799 * 
    791800 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid.
    792801 */
     
    823832
    824833    /* ... Once we have the key, query the registry to get the
    825        value of CLSID as a string, and convert it into a
     834       value of CLSID as a string, and convert it into a 
    826835       proper CLSID structure to be passed back to the app */
    827836    buf2len = sizeof(buf2);
     
    847856
    848857/***********************************************************************
    849  *      WriteClassStm
     858 *              WriteClassStm
    850859 *
    851860 * This function write a CLSID on stream
     
    862871
    863872/***********************************************************************
    864  *      ReadClassStm
     873 *              ReadClassStm
    865874 *
    866875 * This function read a CLSID from a stream
     
    870879    ULONG nbByte;
    871880    HRESULT res;
    872 
     881   
    873882    TRACE("(%p,%p)\n",pStm,rclsid);
    874883
    875884    if (rclsid==NULL)
    876885        return E_INVALIDARG;
    877 
     886   
    878887    res = IStream_Read(pStm,(void*)rclsid,sizeof(CLSID),&nbByte);
    879888
    880889    if (FAILED(res))
    881890        return res;
    882 
     891   
    883892    if (nbByte != sizeof(CLSID))
    884893        return S_FALSE;
     
    893902 */
    894903HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) {
    895     FIXME("(%p,%p),stub!\n",hTask,p);
    896     if ((*hTask = GetCurrentTask()) == hETask) {
    897         memcpy(p, Table_ETask, sizeof(Table_ETask));
    898     }
    899     return 0;
     904        FIXME("(%p,%p),stub!\n",hTask,p);
     905        if ((*hTask = GetCurrentTask()) == hETask) {
     906                memcpy(p, Table_ETask, sizeof(Table_ETask));
     907        }
     908        return 0;
    900909}
    901910
     
    906915HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) {
    907916        FIXME("(%04x,%p),stub!\n",hTask,p);
    908     hETask = hTask;
    909     return 0;
     917        hETask = hTask;
     918        return 0;
    910919}
    911920
     
    915924 */
    916925HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
    917     FIXME("(%p,%p),stub!\n",p1,p2);
    918     return 0;
    919 }
    920 
    921 /******************************************************************************
    922  *      CoRegisterClassObject16 [COMPOBJ.5]
     926        FIXME("(%p,%p),stub!\n",p1,p2);
     927        return 0;
     928}
     929
     930/******************************************************************************
     931 *              CoRegisterClassObject16 [COMPOBJ.5]
    923932 *
    924933 * Don't know where it registers it ...
    925934 */
    926935HRESULT WINAPI CoRegisterClassObject16(
    927     REFCLSID rclsid,
    928     LPUNKNOWN pUnk,
    929     DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
    930     DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
    931     LPDWORD lpdwRegister
     936        REFCLSID rclsid,
     937        LPUNKNOWN pUnk,
     938        DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
     939        DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
     940        LPDWORD lpdwRegister
    932941) {
    933     char    buf[80];
    934 
    935     WINE_StringFromCLSID(rclsid,buf);
    936 
    937     FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
    938         buf,pUnk,dwClsContext,flags,lpdwRegister
    939     );
    940     return 0;
     942        char    buf[80];
     943
     944        WINE_StringFromCLSID(rclsid,buf);
     945
     946        FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
     947                buf,pUnk,dwClsContext,flags,lpdwRegister
     948        );
     949        return 0;
    941950}
    942951
     
    957966 * COM_GetRegisteredClassObject
    958967 *
    959  * This internal method is used to scan the registered class list to
     968 * This internal method is used to scan the registered class list to 
    960969 * find a class object.
    961970 *
    962  * Params:
     971 * Params: 
    963972 *   rclsid        Class ID of the class to find.
    964973 *   dwClsContext  Class context to match.
     
    968977 */
    969978static HRESULT COM_GetRegisteredClassObject(
    970     REFCLSID    rclsid,
    971     DWORD       dwClsContext,
    972     LPUNKNOWN*  ppUnk)
     979        REFCLSID    rclsid,
     980        DWORD       dwClsContext,
     981        LPUNKNOWN*  ppUnk)
    973982{
    974983  RegisteredClass* curClass;
     
    10191028
    10201029/******************************************************************************
    1021  *      CoRegisterClassObject   [OLE32.36]
     1030 *              CoRegisterClassObject   [OLE32.36]
    10221031 *
    10231032 * This method will register the class object for a given class ID.
     
    10261035 */
    10271036HRESULT WINAPI CoRegisterClassObject(
    1028     REFCLSID rclsid,
    1029     LPUNKNOWN pUnk,
    1030     DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
    1031     DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
    1032     LPDWORD lpdwRegister
    1033 )
     1037        REFCLSID rclsid,
     1038        LPUNKNOWN pUnk,
     1039        DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
     1040        DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
     1041        LPDWORD lpdwRegister
     1042) 
    10341043{
    10351044  RegisteredClass* newClass;
     
    10411050
    10421051  TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n",
    1043     buf,pUnk,dwClsContext,flags,lpdwRegister);
     1052        buf,pUnk,dwClsContext,flags,lpdwRegister);
    10441053
    10451054  /*
     
    10721081    return CO_E_OBJISREG;
    10731082  }
    1074 
     1083   
    10751084  /*
    10761085   * If it is not registered, we must create a new entry for this class and
     
    11031112   */
    11041113  *lpdwRegister = newClass->dwCookie;
    1105 
     1114   
    11061115  /*
    11071116   * We're successful Yippee!
     
    11181127 */
    11191128HRESULT WINAPI CoRevokeClassObject(
    1120         DWORD dwRegister)
     1129        DWORD dwRegister) 
    11211130{
    11221131  RegisteredClass** prevClassLink;
     
    11761185    REFIID iid, LPVOID *ppv
    11771186) {
    1178     LPUNKNOWN   regClassObject;
    1179     HRESULT hres = E_UNEXPECTED;
    1180     char    xclsid[80];
     1187    LPUNKNOWN   regClassObject;
     1188    HRESULT     hres = E_UNEXPECTED;
     1189    char        xclsid[80];
    11811190    WCHAR dllName[MAX_PATH+1];
    11821191    DWORD dllNameLen = sizeof(dllName);
    11831192    HINSTANCE hLibrary;
    11841193#ifdef __WIN32OS2__
    1185     typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid,
    1186                  REFIID iid, LPVOID *ppv);
     1194    typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 
     1195                             REFIID iid, LPVOID *ppv);
    11871196#else
    1188     typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid,
    1189                  REFIID iid, LPVOID *ppv);
     1197    typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 
     1198                             REFIID iid, LPVOID *ppv);
    11901199#endif
    11911200    DllGetClassObjectFunc DllGetClassObject;
     
    11941203
    11951204    TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",
    1196     debugstr_guid(rclsid),
    1197     debugstr_guid(iid)
     1205        debugstr_guid(rclsid),
     1206        debugstr_guid(iid)
    11981207    );
    11991208
    12001209    if (pServerInfo) {
    1201     FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
    1202     FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
     1210        FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
     1211        FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
    12031212    }
    12041213
    12051214    /*
    1206      * First, try and see if we can't match the class ID with one of the
     1215     * First, try and see if we can't match the class ID with one of the 
    12071216     * registered classes.
    12081217     */
     
    12291238    ){
    12301239        FIXME("%s %s not supported!\n",
    1231         (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",
    1232         (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""
    1233     );
    1234     return E_ACCESSDENIED;
     1240                (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",
     1241                (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""
     1242        );
     1243        return E_ACCESSDENIED;
    12351244    }
    12361245
    12371246    if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) {
    12381247        HKEY key;
    1239     char buf[200];
    1240 
    1241     sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);
     1248        char buf[200];
     1249
     1250        sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);
    12421251        hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key);
    12431252
    1244     if (hres != ERROR_SUCCESS) {
    1245         return REGDB_E_CLASSNOTREG;
    1246     }
    1247 
    1248     memset(dllName,0,sizeof(dllName));
    1249     hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
    1250     if (hres)
    1251         return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
    1252     RegCloseKey(key);
    1253     TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));
    1254 
    1255     /* open dll, call DllGetClassObject */
    1256     hLibrary = CoLoadLibrary(dllName, TRUE);
    1257     if (hLibrary == 0) {
    1258         FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));
    1259         return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
    1260     }
    1261     DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");
    1262     if (!DllGetClassObject) {
    1263         /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
    1264         FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName));
    1265         return E_ACCESSDENIED;
    1266     }
    1267 
    1268     /*
    1269     * Ask the DLL for its class object. (there was a note here about class
    1270     * factories but this is good.
    1271     */
    1272     return DllGetClassObject(rclsid, iid, ppv);
     1253        if (hres != ERROR_SUCCESS) {
     1254            return REGDB_E_CLASSNOTREG;
     1255        }
     1256
     1257        memset(dllName,0,sizeof(dllName));
     1258        hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
     1259        if (hres)
     1260                return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
     1261        RegCloseKey(key);
     1262        TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));
     1263
     1264        /* open dll, call DllGetClassObject */
     1265        hLibrary = CoLoadLibrary(dllName, TRUE);
     1266        if (hLibrary == 0) {
     1267            FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));
     1268            return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
     1269        }
     1270        DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");
     1271        if (!DllGetClassObject) {
     1272            /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
     1273            FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName));
     1274            return E_ACCESSDENIED;
     1275        }
     1276
     1277        /*
     1278        * Ask the DLL for its class object. (there was a note here about class
     1279        * factories but this is good.
     1280        */
     1281        return DllGetClassObject(rclsid, iid, ppv);
    12731282    }
    12741283    return hres;
     
    12821291HRESULT WINAPI CoResumeClassObjects(void)
    12831292{
    1284     FIXME("\n");
    1285     return S_OK;
     1293        FIXME("\n");
     1294        return S_OK;
    12861295}
    12871296
     
    13171326       pattern in the registry. this case is not frequently used ! so I present only the psodocode for
    13181327       this case
    1319 
     1328       
    13201329     for(i=0;i<nFileTypes;i++)
    13211330
     
    13501359    length=lstrlenW(absFile);
    13511360    for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--);
    1352 
     1361       
    13531362    /* get the progId associated to the extension */
    13541363    progId=CoTaskMemAlloc(sizeProgId);
     
    13781387#ifndef __WIN32OS2__
    13791388/******************************************************************************
    1380  *      CoRegisterMessageFilter16   [COMPOBJ.27]
     1389 *              CoRegisterMessageFilter16       [COMPOBJ.27]
    13811390 */
    13821391HRESULT WINAPI CoRegisterMessageFilter16(
    1383     LPMESSAGEFILTER lpMessageFilter,
    1384     LPMESSAGEFILTER *lplpMessageFilter
     1392        LPMESSAGEFILTER lpMessageFilter,
     1393        LPMESSAGEFILTER *lplpMessageFilter
    13851394) {
    1386     FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
    1387     return 0;
     1395        FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
     1396        return 0;
    13881397}
    13891398#endif
     
    13931402 */
    13941403HRESULT WINAPI CoCreateInstance(
    1395     REFCLSID rclsid,
    1396     LPUNKNOWN pUnkOuter,
    1397     DWORD dwClsContext,
    1398     REFIID iid,
    1399     LPVOID *ppv)
    1400 {
    1401     HRESULT hres;
    1402     LPCLASSFACTORY lpclf = 0;
     1404        REFCLSID rclsid,
     1405        LPUNKNOWN pUnkOuter,
     1406        DWORD dwClsContext,
     1407        REFIID iid,
     1408        LPVOID *ppv)
     1409{
     1410        HRESULT hres;
     1411        LPCLASSFACTORY lpclf = 0;
    14031412
    14041413  /*
     
    14121421   */
    14131422  *ppv = 0;
    1414 
     1423 
    14151424  /*
    14161425   * Get a class factory to construct the object we want.
    14171426   */
    14181427  hres = CoGetClassObject(rclsid,
    1419               dwClsContext,
    1420               NULL,
    1421               &IID_IClassFactory,
    1422               (LPVOID)&lpclf);
     1428                          dwClsContext,
     1429                          NULL,
     1430                          &IID_IClassFactory,
     1431                          (LPVOID)&lpclf);
    14231432
    14241433  if (FAILED(hres)) {
     
    14301439   * Create the object and don't forget to release the factory
    14311440   */
    1432     hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
    1433     IClassFactory_Release(lpclf);
    1434 
    1435     return hres;
     1441        hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
     1442        IClassFactory_Release(lpclf);
     1443
     1444        return hres;
    14361445}
    14371446
     
    14401449 */
    14411450HRESULT WINAPI CoCreateInstanceEx(
    1442   REFCLSID      rclsid,
     1451  REFCLSID      rclsid, 
    14431452  LPUNKNOWN     pUnkOuter,
    1444   DWORD         dwClsContext,
     1453  DWORD         dwClsContext, 
    14451454  COSERVERINFO* pServerInfo,
    14461455  ULONG         cmq,
     
    14731482   * Get the object and get its IUnknown pointer.
    14741483   */
    1475   hr = CoCreateInstance(rclsid,
    1476             pUnkOuter,
    1477             dwClsContext,
    1478             &IID_IUnknown,
    1479             (VOID**)&pUnk);
     1484  hr = CoCreateInstance(rclsid, 
     1485                        pUnkOuter,
     1486                        dwClsContext,
     1487                        &IID_IUnknown,
     1488                        (VOID**)&pUnk);
    14801489
    14811490  if (hr)
     
    14881497  {
    14891498    pResults[index].hr = IUnknown_QueryInterface(pUnk,
    1490                         pResults[index].pIID,
    1491                         (VOID**)&(pResults[index].pItf));
     1499                                                pResults[index].pIID,
     1500                                                (VOID**)&(pResults[index].pItf));
    14921501
    14931502    if (pResults[index].hr == S_OK)
     
    15201529    prev = NULL;
    15211530    for (ptr = openDllList; ptr != NULL; ptr=ptr->next) {
    1522     if (ptr->hLibrary == hLibrary) {
    1523         break;
    1524     }
    1525     prev = ptr;
     1531        if (ptr->hLibrary == hLibrary) {
     1532            break;
     1533        }
     1534        prev = ptr;
    15261535    }
    15271536
    15281537    if (ptr == NULL) {
    1529     /* shouldn't happen if user passed in a valid hLibrary */
    1530     return;
     1538        /* shouldn't happen if user passed in a valid hLibrary */
     1539        return;
    15311540    }
    15321541    /* assert: ptr points to the library entry to free */
     
    15351544    FreeLibrary(hLibrary);
    15361545    if (ptr == openDllList) {
    1537     tmp = openDllList->next;
    1538     HeapFree(GetProcessHeap(), 0, openDllList);
    1539     openDllList = tmp;
     1546        tmp = openDllList->next;
     1547        HeapFree(GetProcessHeap(), 0, openDllList);
     1548        openDllList = tmp;
    15401549    } else {
    1541     tmp = ptr->next;
    1542     HeapFree(GetProcessHeap(), 0, ptr);
    1543     prev->next = tmp;
     1550        tmp = ptr->next;
     1551        HeapFree(GetProcessHeap(), 0, ptr);
     1552        prev->next = tmp;
    15441553    }
    15451554
     
    15551564
    15561565    for (ptr = openDllList; ptr != NULL; ) {
    1557     tmp=ptr->next;
    1558     CoFreeLibrary(ptr->hLibrary);
    1559     ptr = tmp;
     1566        tmp=ptr->next;
     1567        CoFreeLibrary(ptr->hLibrary);
     1568        ptr = tmp;
    15601569    }
    15611570}
     
    15731582
    15741583    for (ptr = openDllList; ptr != NULL; ) {
    1575     DllCanUnloadNow = (DllCanUnloadNowFunc)
    1576         GetProcAddress(ptr->hLibrary, "DllCanUnloadNow");
    1577 
    1578     if ( (DllCanUnloadNow != NULL) &&
    1579          (DllCanUnloadNow() == S_OK) ) {
    1580         tmp=ptr->next;
    1581         CoFreeLibrary(ptr->hLibrary);
    1582         ptr = tmp;
    1583     } else {
    1584         ptr=ptr->next;
    1585     }
     1584        DllCanUnloadNow = (DllCanUnloadNowFunc)
     1585            GetProcAddress(ptr->hLibrary, "DllCanUnloadNow");
     1586       
     1587        if ( (DllCanUnloadNow != NULL) &&
     1588             (DllCanUnloadNow() == S_OK) ) {
     1589            tmp=ptr->next;
     1590            CoFreeLibrary(ptr->hLibrary);
     1591            ptr = tmp;
     1592        } else {
     1593            ptr=ptr->next;
     1594        }
    15861595    }
    15871596}
     
    15901599 *           CoFileTimeNow [COMPOBJ.82, OLE32.10]
    15911600 * RETURNS
    1592  *  the current system time in lpFileTime
     1601 *      the current system time in lpFileTime
    15931602 */
    15941603HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time */
     
    16011610 *           CoTaskMemAlloc (OLE32.43)
    16021611 * RETURNS
    1603  *  pointer to newly allocated block
     1612 *      pointer to newly allocated block
    16041613 */
    16051614LPVOID WINAPI CoTaskMemAlloc(
    1606     ULONG size  /* [in] size of memoryblock to be allocated */
     1615        ULONG size      /* [in] size of memoryblock to be allocated */
    16071616) {
    1608     LPMALLOC    lpmalloc;
    1609     HRESULT ret = CoGetMalloc(0,&lpmalloc);
    1610 
    1611     if (FAILED(ret))
    1612     return NULL;
     1617    LPMALLOC    lpmalloc;
     1618    HRESULT     ret = CoGetMalloc(0,&lpmalloc);
     1619
     1620    if (FAILED(ret)) 
     1621        return NULL;
    16131622
    16141623    return IMalloc_Alloc(lpmalloc,size);
     
    16181627 */
    16191628VOID WINAPI CoTaskMemFree(
    1620     LPVOID ptr  /* [in] pointer to be freed */
     1629        LPVOID ptr      /* [in] pointer to be freed */
    16211630) {
    1622     LPMALLOC    lpmalloc;
    1623     HRESULT ret = CoGetMalloc(0,&lpmalloc);
    1624 
    1625     if (FAILED(ret))
     1631    LPMALLOC    lpmalloc;
     1632    HRESULT     ret = CoGetMalloc(0,&lpmalloc);
     1633
     1634    if (FAILED(ret)) 
    16261635      return;
    16271636
     
    16321641 *           CoTaskMemRealloc (OLE32.45)
    16331642 * RETURNS
    1634  *  pointer to newly allocated block
     1643 *      pointer to newly allocated block
    16351644 */
    16361645LPVOID WINAPI CoTaskMemRealloc(
    16371646  LPVOID pvOld,
    1638   ULONG  size)  /* [in] size of memoryblock to be allocated */
     1647  ULONG  size)  /* [in] size of memoryblock to be allocated */
    16391648{
    16401649  LPMALLOC lpmalloc;
    16411650  HRESULT  ret = CoGetMalloc(0,&lpmalloc);
    1642 
    1643   if (FAILED(ret))
     1651 
     1652  if (FAILED(ret)) 
    16441653    return NULL;
    16451654
     
    16551664    OpenDll *ptr;
    16561665    OpenDll *tmp;
    1657 
     1666 
    16581667    TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree);
    16591668
     
    16611670
    16621671    if (!bAutoFree)
    1663     return hLibrary;
     1672        return hLibrary;
    16641673
    16651674    if (openDllList == NULL) {
    16661675        /* empty list -- add first node */
    16671676        openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
    1668     openDllList->hLibrary=hLibrary;
    1669     openDllList->next = NULL;
     1677        openDllList->hLibrary=hLibrary;
     1678        openDllList->next = NULL;
    16701679    } else {
    16711680        /* search for this dll */
    16721681        int found = FALSE;
    16731682        for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) {
    1674         if (ptr->hLibrary == hLibrary) {
    1675             found = TRUE;
    1676         break;
     1683            if (ptr->hLibrary == hLibrary) {
     1684                found = TRUE;
     1685                break;
     1686            }
    16771687        }
    1678         }
    1679     if (!found) {
    1680         /* dll not found, add it */
    1681         tmp = openDllList;
    1682         openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
    1683         openDllList->hLibrary = hLibrary;
    1684         openDllList->next = tmp;
    1685     }
    1686     }
    1687 
     1688        if (!found) {
     1689            /* dll not found, add it */
     1690            tmp = openDllList;
     1691            openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
     1692            openDllList->hLibrary = hLibrary;
     1693            openDllList->next = tmp;
     1694        }
     1695    }
     1696     
    16881697    return hLibrary;
    16891698}
     
    16991708#ifndef __WIN32OS2__
    17001709/******************************************************************************
    1701  *      CoLockObjectExternal16  [COMPOBJ.63]
     1710 *              CoLockObjectExternal16  [COMPOBJ.63]
    17021711 */
    17031712HRESULT WINAPI CoLockObjectExternal16(
    1704     LPUNKNOWN pUnk,     /* [in] object to be locked */
    1705     BOOL16 fLock,       /* [in] do lock */
    1706     BOOL16 fLastUnlockReleases  /* [in] ? */
     1713    LPUNKNOWN pUnk,             /* [in] object to be locked */
     1714    BOOL16 fLock,               /* [in] do lock */
     1715    BOOL16 fLastUnlockReleases  /* [in] ? */
    17071716) {
    17081717    FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases);
     
    17121721
    17131722/******************************************************************************
    1714  *      CoLockObjectExternal    [OLE32.31]
     1723 *              CoLockObjectExternal    [OLE32.31]
    17151724 */
    17161725HRESULT WINAPI CoLockObjectExternal(
    1717     LPUNKNOWN pUnk,     /* [in] object to be locked */
    1718     BOOL fLock,     /* [in] do lock */
     1726    LPUNKNOWN pUnk,             /* [in] object to be locked */
     1727    BOOL fLock,         /* [in] do lock */
    17191728    BOOL fLastUnlockReleases) /* [in] unlock all */
    17201729{
    17211730
    1722   if (fLock)
     1731  if (fLock) 
    17231732  {
    1724     /*
     1733    /* 
    17251734     * Increment the external lock coutner, COM_ExternalLockAddRef also
    17261735     * increment the object's internal lock counter.
    17271736     */
    1728     COM_ExternalLockAddRef( pUnk);
     1737    COM_ExternalLockAddRef( pUnk); 
    17291738  }
    17301739  else
    17311740  {
    1732     /*
     1741    /* 
    17331742     * Decrement the external lock coutner, COM_ExternalLockRelease also
    17341743     * decrement the object's internal lock counter.
     
    17661775{
    17671776   FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal);
    1768 
     1777   
    17691778   return S_OK;
    17701779}
     
    17751784 */
    17761785HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
    1777 {
    1778     FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
    1779     *ppv = NULL;
    1780     return CLASS_E_CLASSNOTAVAILABLE;
     1786{       
     1787        FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
     1788        *ppv = NULL;
     1789        return CLASS_E_CLASSNOTAVAILABLE;
    17811790}
    17821791
     
    17851794 * COM_RevokeAllClasses
    17861795 *
    1787  * This method is called when the COM libraries are uninitialized to
     1796 * This method is called when the COM libraries are uninitialized to 
    17881797 * release all the references to the class objects registered with
    17891798 * the library
     
    18021811
    18031812/****************************************************************************
    1804  * Public - Method that increments the count for a IUnknown* in the linked
     1813 * Public - Method that increments the count for a IUnknown* in the linked 
    18051814 * list.  The item is inserted if not already in the list.
    18061815 */
     
    18231832   * Add an internal lock to the object
    18241833   */
    1825   IUnknown_AddRef(pUnk);
     1834  IUnknown_AddRef(pUnk); 
    18261835}
    18271836
    18281837/****************************************************************************
    1829  * Public - Method that decrements the count for a IUnknown* in the linked
     1838 * Public - Method that decrements the count for a IUnknown* in the linked 
    18301839 * list.  The item is removed from the list if its count end up at zero or if
    18311840 * bRelAll is TRUE.
     
    18441853      IUnknown_Release(pUnk);     /* release local locks as well */
    18451854
    1846       if ( bRelAll == FALSE )
     1855      if ( bRelAll == FALSE ) 
    18471856        break;  /* perform single release */
    18481857
    1849     } while ( externalLock->uRefCount > 0 );
     1858    } while ( externalLock->uRefCount > 0 ); 
    18501859
    18511860    if ( externalLock->uRefCount == 0 )  /* get rid of the list entry */
     
    18651874    COM_ExternalLockDelete(head);     /* get rid of the head stuff       */
    18661875
    1867     head = elList.head;               /* get the new head...             */
     1876    head = elList.head;               /* get the new head...             */ 
    18681877  }
    18691878}
     
    18811890  {
    18821891      DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount);
    1883 
    1884     /* Skip to the next item */
     1892 
     1893    /* Skip to the next item */ 
    18851894    current = current->next;
    1886   }
     1895  } 
    18871896
    18881897}
     
    19041913  IUnknown         *pUnk)
    19051914{
    1906   if ( element == EL_END_OF_LIST )
     1915  if ( element == EL_END_OF_LIST ) 
    19071916    return EL_NOT_FOUND;
    19081917
     
    19101919    return element;
    19111920
    1912   else                                 /* Not the right guy, keep on looking */
     1921  else                                 /* Not the right guy, keep on looking */ 
    19131922    return COM_ExternalLockLocate( element->next, pUnk);
    19141923}
     
    19301939  if (newLock!=NULL)
    19311940  {
    1932     if ( elList.head == EL_END_OF_LIST )
     1941    if ( elList.head == EL_END_OF_LIST ) 
    19331942    {
    19341943      elList.head = newLock;    /* The list is empty */
    19351944    }
    1936     else
     1945    else 
    19371946    {
    1938       /*
     1947      /* 
    19391948       * insert does it at the head
    19401949       */
     
    19441953
    19451954    /*
    1946      * Set new list item data member
     1955     * Set new list item data member 
    19471956     */
    19481957    newLock->pUnk      = pUnk;
    19491958    newLock->uRefCount = 1;
    19501959    newLock->next      = previousHead;
    1951 
     1960   
    19521961    return TRUE;
    19531962  }
     
    19661975  if ( current == itemList )
    19671976  {
    1968     /*
    1969      * this section handles the deletion of the first node
     1977    /* 
     1978     * this section handles the deletion of the first node 
    19701979     */
    19711980    elList.head = itemList->next;
    1972     HeapFree( GetProcessHeap(), 0, itemList);
     1981    HeapFree( GetProcessHeap(), 0, itemList); 
    19731982  }
    19741983  else
    19751984  {
    1976     do
     1985    do 
    19771986    {
    19781987      if ( current->next == itemList )   /* We found the item to free  */
    19791988      {
    19801989        current->next = itemList->next;  /* readjust the list pointers */
    1981 
    1982         HeapFree( GetProcessHeap(), 0, itemList);
    1983         break;
     1990 
     1991        HeapFree( GetProcessHeap(), 0, itemList); 
     1992        break; 
    19841993      }
    1985 
    1986       /* Skip to the next item */
     1994 
     1995      /* Skip to the next item */ 
    19871996      current = current->next;
    1988 
     1997 
    19891998    } while ( current != EL_END_OF_LIST );
    19901999  }
     
    20322041    {
    20332042        res = REGDB_E_CLASSNOTREG;
    2034     goto done;
     2043        goto done;
    20352044    }
    20362045    len = 200;
     
    20402049    {
    20412050        res = REGDB_E_KEYMISSING;
    2042     goto done;
     2051        goto done;
    20432052    }
    20442053    MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) );
     
    20652074    {
    20662075        res = REGDB_E_CLASSNOTREG;
    2067     goto done;
     2076        goto done;
    20682077    }
    20692078    if (RegCreateKeyA(hkey, "AutoConvertTo", &hkeyConvert))
    20702079    {
    20712080        res = REGDB_E_WRITEREGDB;
    2072     goto done;
     2081        goto done;
    20732082    }
    20742083    if (RegSetValueExA(hkeyConvert, NULL, 0,
     
    20762085    {
    20772086        res = REGDB_E_WRITEREGDB;
    2078     goto done;
     2087        goto done;
    20792088    }
    20802089
     
    20922101 *
    20932102 * RETURNS
    2094  *  TRUE if equal
     2103 *      TRUE if equal
    20952104 */
    20962105#undef IsEqualGUID
     
    21112120
    21122121HRESULT WIN32API CLSIDFromStringA(
    2113     LPCSTR      lpsz,       // [in] - ASCII string CLSID
    2114     LPCLSID     pclsid)     // [out] - Binary CLSID
     2122    LPCSTR              lpsz,           // [in] - ASCII string CLSID
     2123    LPCLSID             pclsid)         // [out] - Binary CLSID
    21152124{
    21162125    return CLSIDFromString16(lpsz, pclsid);
  • trunk/src/ole32/compositemoniker.c

    r6648 r6711  
    1 /* $Id: compositemoniker.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
    21/***************************************************************************************
    3  *                        CompositeMonikers implementation
     2 *                            CompositeMonikers implementation
    43 *
    54 *               Copyright 1999  Noomen Hamza
     
    1817#include "ole2.h"
    1918
     19#ifdef __WIN32OS2__
     20#undef FIXME
     21#undef TRACE
     22#ifdef DEBUG
     23#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     24#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     25#else
     26#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     27#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     28#endif
     29#endif
     30
    2031DEFAULT_DEBUG_CHANNEL(ole);
    2132
     
    2738    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2839
    29     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     40    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    3041     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3142     */
     
    187198{
    188199    ICOM_THIS(CompositeMonikerImpl,iface);
    189 
     200 
    190201    TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    191202
    192203    /* Perform a sanity check on the parameters.*/
    193204    if ( (This==0) || (ppvObject==0) )
    194     return E_INVALIDARG;
    195 
     205        return E_INVALIDARG;
     206 
    196207    /* Initialize the return parameter */
    197208    *ppvObject = 0;
     
    236247    ICOM_THIS(CompositeMonikerImpl,iface);
    237248    ULONG i;
    238 
     249   
    239250    TRACE("(%p)\n",This);
    240251
     
    247258        for (i=0;i<This->tabLastIndex;i++)
    248259            IMoniker_Release(This->tabMoniker[i]);
    249 
     260       
    250261        CompositeMonikerImpl_Destroy(This);
    251262
     
    264275    if (pClassID==NULL)
    265276        return E_POINTER;
    266 
     277           
    267278    *pClassID = CLSID_CompositeMoniker;
    268 
     279       
    269280    return S_OK;
    270281}
     
    293304    CLSID clsid;
    294305    WCHAR string[1]={0};
    295 
    296     ICOM_THIS(CompositeMonikerImpl,iface);
     306   
     307    ICOM_THIS(CompositeMonikerImpl,iface);   
    297308
    298309    TRACE("(%p,%p)\n",iface,pStm);
     
    350361        /* resize the table if needed */
    351362        if (++This->tabLastIndex==This->tabSize){
    352 
     363               
    353364            This->tabSize+=BLOCK_TAB_SIZE;
    354365            This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
     
    371382    IMoniker *pmk;
    372383    DWORD constant=3;
    373 
     384   
    374385    TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
    375386
     
    446457    IMoniker *tempMk;
    447458    HRESULT res;
    448 
     459   
    449460    TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest);
    450461
     
    472483
    473484        IMoniker_Enum(pmkFirst,TRUE,&enumMoniker);
    474 
     485       
    475486        while(IEnumMoniker_Next(enumMoniker,1,&This->tabMoniker[This->tabLastIndex],NULL)==S_OK){
    476487
    477488
    478489            if (++This->tabLastIndex==This->tabSize){
    479 
     490               
    480491                This->tabSize+=BLOCK_TAB_SIZE;
    481492                This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
     
    492503
    493504    IMoniker_IsSystemMoniker(pmkRest,&mkSys);
    494 
     505   
    495506    if (mkSys!=MKSYS_GENERICCOMPOSITE){
    496507
     
    499510        res=IMoniker_ComposeWith(This->tabMoniker[This->tabLastIndex-1],pmkRest,TRUE,&tempMk);
    500511
    501         if (res==MK_E_NEEDGENERIC){
     512        if (res==MK_E_NEEDGENERIC){ 
    502513
    503514            /* there's no simplification in this case */
     
    508519            IMoniker_AddRef(pmkRest);
    509520        }
    510         else if (tempMk==NULL){
     521        else if (tempMk==NULL){ 
    511522
    512523            /* we have an antimoniker after a simple moniker so we can make a simplification in this case */
     
    526537        /* resize tabMoniker if needed */
    527538        if (This->tabLastIndex==This->tabSize){
    528 
     539               
    529540            This->tabSize+=BLOCK_TAB_SIZE;
    530541
     
    563574
    564575            if (This->tabLastIndex==This->tabSize){
    565 
     576               
    566577                This->tabSize+=BLOCK_TAB_SIZE;
    567578
     
    606617    IMoniker *tempMk,*antiMk,*mostRigthMk;
    607618    IEnumMoniker *enumMoniker;
    608 
     619   
    609620    TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
    610621
    611622    if (ppvResult==NULL)
    612623        return E_POINTER;
    613 
     624   
    614625    *ppvResult=0;
    615626    /* If pmkToLeft is NULL, this method looks for the moniker in the ROT, and if found, queries the retrieved */
     
    635646        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    636647        IEnumMoniker_Release(enumMoniker);
    637 
     648       
    638649        res=CreateAntiMoniker(&antiMk);
    639650        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
    640651        IMoniker_Release(antiMk);
    641 
     652       
    642653        res=CompositeMonikerImpl_BindToObject(mostRigthMk,pbc,tempMk,riid,ppvResult);
    643654
     
    670681
    671682    if (pmkToLeft!=NULL){
    672 
     683       
    673684        IMoniker_Enum(iface,FALSE,&enumMoniker);
    674685        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    675686        IEnumMoniker_Release(enumMoniker);
    676 
     687       
    677688        res=CreateAntiMoniker(&antiMk);
    678689        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
    679690        IMoniker_Release(antiMk);
    680 
     691       
    681692        res=CompositeMonikerImpl_BindToStorage(mostRigthMk,pbc,tempMk,riid,ppvResult);
    682693
     
    716727        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    717728        IEnumMoniker_Release(enumMoniker);
    718 
     729       
    719730        res=CreateAntiMoniker(&antiMk);
    720731        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
     
    733744        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    734745        IEnumMoniker_Release(enumMoniker);
    735 
     746       
    736747        res=CreateAntiMoniker(&antiMk);
    737748        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
     
    769780
    770781    if ((ppmkComposite==NULL)||(pmkRight==NULL))
    771     return E_POINTER;
     782        return E_POINTER;
    772783
    773784    *ppmkComposite=0;
     
    776787    /* otherwise, the method returns the result of combining the two monikers by calling the */
    777788    /* CreateGenericComposite function */
    778 
     789   
    779790    if (fOnlyIfNotGeneric)
    780791        return MK_E_NEEDGENERIC;
    781 
     792   
    782793    return CreateGenericComposite(iface,pmkRight,ppmkComposite);
    783794}
     
    794805    if (ppenumMoniker == NULL)
    795806        return E_POINTER;
    796 
     807   
    797808    return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabLastIndex,0,fForward,ppenumMoniker);
    798809}
     
    806817    IMoniker *tempMk1,*tempMk2;
    807818    HRESULT res1,res2,res;
    808 
     819   
    809820    TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
    810821
     
    818829    if (enumMoniker1==NULL)
    819830        return S_FALSE;
    820 
     831   
    821832    IMoniker_Enum(iface,TRUE,&enumMoniker2);
    822833
     
    825836        res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
    826837        res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL);
    827 
     838       
    828839        if((res1==S_OK)&&(res2==S_OK)){
    829840
     
    895906        /* If pmkToLeft is NULL, this method returns S_OK if pmkNewlyRunning is non-NULL and is equal */
    896907        /* to this moniker */
    897 
     908       
    898909        if (pmkNewlyRunning!=NULL)
    899910
     
    913924            /* IMoniker::IsRunning on the rightmost component of the composite, passing the remainder of */
    914925            /* the composite as the pmkToLeft parameter for that call.                                   */
    915 
     926           
    916927             res=IBindCtx_GetRunningObjectTable(pbc,&rot);
    917928
     
    957968    IMoniker *tempMk,*antiMk,*mostRigthMk;
    958969    IEnumMoniker *enumMoniker;
    959 
     970   
    960971    TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pCompositeTime);
    961972
     
    10541065    IEnumMoniker *enumMoniker1,*enumMoniker2;
    10551066    ULONG i,nbCommonMk=0;
    1056 
     1067   
    10571068    /* If the other moniker is a composite, this method compares the components of each composite from left  */
    10581069    /* to right. The returned common prefix moniker might also be a composite moniker, depending on how many */
     
    10611072    if (ppmkPrefix==NULL)
    10621073        return E_POINTER;
    1063 
     1074   
    10641075    *ppmkPrefix=0;
    10651076
    10661077    if (pmkOther==NULL)
    10671078        return MK_E_NOPREFIX;
    1068 
     1079   
    10691080    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
    10701081
     
    11301141            IMoniker_Release(tempMk1);
    11311142            IMoniker_Release(tempMk2);
    1132 
     1143           
    11331144            /* compose all common monikers in a composite moniker */
    11341145            for(i=0;i<nbCommonMk;i++){
     
    11411152
    11421153                IMoniker_Release(tempMk1);
    1143 
     1154               
    11441155                *ppmkPrefix=tempMk2;
    11451156            }
     
    11821193    DWORD mkSys;
    11831194    HRESULT res1,res2;
    1184 
     1195   
    11851196    *restMk=0;
    11861197
     
    12801291
    12811292    /* finds the common prefix of the two monikers */
    1282     res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk);
     1293    res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk);   
    12831294
    12841295    /* if there's no common prefix or the two moniker are equal the relative is the other moniker */
     
    13371348    if (ppszDisplayName==NULL)
    13381349        return E_POINTER;
    1339 
     1350   
    13401351    *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR));
    13411352
     
    13491360
    13501361    IMoniker_Enum(iface,TRUE,&enumMoniker);
    1351 
     1362   
    13521363    while(IEnumMoniker_Next(enumMoniker,1,&tempMk,NULL)==S_OK){
    13531364
     
    14091420    if (!pwdMksys)
    14101421        return E_POINTER;
    1411 
     1422   
    14121423    (*pwdMksys)=MKSYS_GENERICCOMPOSITE;
    14131424
     
    14461457{
    14471458    ICOM_THIS_From_IROTData(IMoniker, iface);
    1448 
     1459   
    14491460    TRACE("(%p)\n",iface);
    14501461
     
    14701481{
    14711482    ICOM_THIS(EnumMonikerImpl,iface);
    1472 
     1483 
    14731484    TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    14741485
    14751486    /* Perform a sanity check on the parameters.*/
    14761487    if ( (This==0) || (ppvObject==0) )
    1477     return E_INVALIDARG;
    1478 
     1488        return E_INVALIDARG;
     1489 
    14791490    /* Initialize the return parameter */
    14801491    *ppvObject = 0;
     
    15211532    /* destroy the object if there's no more reference on it */
    15221533    if (This->ref==0){
    1523 
     1534       
    15241535        for(i=0;i<This->tabSize;i++)
    15251536            IMoniker_Release(This->tabMoniker[i]);
     
    15481559    if (pceltFethed!=NULL)
    15491560        *pceltFethed= i;
    1550 
     1561   
    15511562    if (i==celt)
    15521563        return S_OK;
     
    15661577
    15671578    This->currentPos+=celt;
    1568 
     1579   
    15691580    return S_OK;
    15701581}
     
    16121623    if (currentPos > tabSize)
    16131624        return E_INVALIDARG;
    1614 
     1625   
    16151626    /* Initialize the virtual function table. */
    16161627    ICOM_VTBL(newEnumMoniker)    = &VT_EnumMonikerImpl;
     
    16441655
    16451656/******************************************************************************
    1646  *        CreateGenericComposite    [OLE.55]
     1657 *        CreateGenericComposite        [OLE.55]
    16471658 ******************************************************************************/
    16481659HRESULT WINAPI CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest, LPMONIKER* ppmkComposite)
     
    16551666    if (ppmkComposite==NULL)
    16561667        return E_POINTER;
    1657 
     1668   
    16581669    *ppmkComposite=0;
    16591670
     
    16931704
    16941705/******************************************************************************
    1695  *        MonikerCommonPrefixWith   [OLE.55]
     1706 *        MonikerCommonPrefixWith       [OLE.55]
    16961707 ******************************************************************************/
    16971708HRESULT WINAPI MonikerCommonPrefixWith(IMoniker* pmkThis,IMoniker* pmkOther,IMoniker** ppmkCommon)
  • trunk/src/ole32/datacache.c

    r6648 r6711  
    1 /* $Id: datacache.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
    21/*
    3  *  OLE 2 Data cache
     2 *      OLE 2 Data cache
    43 *
    54 *      Copyright 1999  Francis Beaudet
     
    1817 *  -  This implementation of the datacache will let your application
    1918 *     load documents that have embedded OLE objects in them and it will
    20  *     also retrieve the metafile representation of those objects.
     19 *     also retrieve the metafile representation of those objects. 
    2120 *  -  This implementation of the datacache will also allow your
    2221 *     application to save new documents with OLE objects in them.
    23  *  -  The main thing that it doesn't do is allow you to activate
     22 *  -  The main thing that it doesn't do is allow you to activate 
    2423 *     or modify the OLE objects in any way.
    2524 *  -  I haven't found any good documentation on the real usage of
     
    2827 *     "\002OlePresXXX". It appears to just be a counter.
    2928 *  -  Also, I don't know the real content of the presentation stream
    30  *     header. I was able to figure-out where the extent of the object
     29 *     header. I was able to figure-out where the extent of the object 
    3130 *     was stored and the aspect, but that's about it.
    3231 */
     
    6160typedef struct PresentationDataHeader
    6261{
    63   DWORD unknown1;   /* -1 */
    64   DWORD unknown2;   /* 3, possibly CF_METAFILEPICT */
    65   DWORD unknown3;   /* 4, possibly TYMED_ISTREAM */
     62  DWORD unknown1;       /* -1 */
     63  DWORD unknown2;       /* 3, possibly CF_METAFILEPICT */
     64  DWORD unknown3;       /* 4, possibly TYMED_ISTREAM */
    6665  DVASPECT dvAspect;
    67   DWORD unknown5;   /* -1 */
     66  DWORD unknown5;       /* -1 */
    6867
    6968  DWORD unknown6;
    70   DWORD unknown7;   /* 0 */
     69  DWORD unknown7;       /* 0 */
    7170  DWORD dwObjectExtentX;
    7271  DWORD dwObjectExtentY;
     
    8281   * List all interface VTables here
    8382   */
    84   ICOM_VTABLE(IDataObject)*      lpvtbl1;
     83  ICOM_VTABLE(IDataObject)*      lpvtbl1; 
    8584  ICOM_VTABLE(IUnknown)*         lpvtbl2;
    8685  ICOM_VTABLE(IPersistStorage)*  lpvtbl3;
    87   ICOM_VTABLE(IViewObject2)*     lpvtbl4;
     86  ICOM_VTABLE(IViewObject2)*     lpvtbl4; 
    8887  ICOM_VTABLE(IOleCache2)*       lpvtbl5;
    8988  ICOM_VTABLE(IOleCacheControl)* lpvtbl6;
     
    120119
    121120/*
    122  * Here, I define utility macros to help with the casting of the
     121 * Here, I define utility macros to help with the casting of the 
    123122 * "this" parameter.
    124123 * There is a version to accomodate all of the VTables implemented
     
    126125 */
    127126#define _ICOM_THIS_From_IDataObject(class,name)       class* this = (class*)name;
    128 #define _ICOM_THIS_From_NDIUnknown(class, name)       class* this = (class*)(((char*)name)-sizeof(void*));
    129 #define _ICOM_THIS_From_IPersistStorage(class, name)  class* this = (class*)(((char*)name)-2*sizeof(void*));
    130 #define _ICOM_THIS_From_IViewObject2(class, name)     class* this = (class*)(((char*)name)-3*sizeof(void*));
    131 #define _ICOM_THIS_From_IOleCache2(class, name)       class* this = (class*)(((char*)name)-4*sizeof(void*));
    132 #define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*));
     127#define _ICOM_THIS_From_NDIUnknown(class, name)       class* this = (class*)(((char*)name)-sizeof(void*)); 
     128#define _ICOM_THIS_From_IPersistStorage(class, name)  class* this = (class*)(((char*)name)-2*sizeof(void*)); 
     129#define _ICOM_THIS_From_IViewObject2(class, name)     class* this = (class*)(((char*)name)-3*sizeof(void*)); 
     130#define _ICOM_THIS_From_IOleCache2(class, name)       class* this = (class*)(((char*)name)-4*sizeof(void*)); 
     131#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*)); 
    133132
    134133/*
     
    136135 */
    137136static DataCache* DataCache_Construct(REFCLSID  clsid,
    138                       LPUNKNOWN pUnkOuter);
     137                                      LPUNKNOWN pUnkOuter);
    139138static void       DataCache_Destroy(DataCache* ptrToDestroy);
    140139static HRESULT    DataCache_ReadPresentationData(DataCache*              this,
    141                         DWORD                   drawAspect,
    142                         PresentationDataHeader* header);
     140                                                DWORD                   drawAspect,
     141                                                PresentationDataHeader* header);
    143142static HRESULT    DataCache_OpenPresStream(DataCache *this,
    144                        DWORD      drawAspect,
    145                        IStream  **pStm);
     143                                           DWORD      drawAspect,
     144                                           IStream  **pStm);
    146145static HMETAFILE  DataCache_ReadPresMetafile(DataCache* this,
    147                          DWORD      drawAspect);
     146                                             DWORD      drawAspect);
    148147static void       DataCache_FireOnViewChange(DataCache* this,
    149                          DWORD      aspect,
    150                          LONG       lindex);
     148                                             DWORD      aspect,
     149                                             LONG       lindex);
    151150
    152151/*
     
    158157            REFIID         riid,
    159158            void**         ppvObject);
    160 static ULONG WINAPI DataCache_NDIUnknown_AddRef(
     159static ULONG WINAPI DataCache_NDIUnknown_AddRef( 
    161160            IUnknown*      iface);
    162 static ULONG WINAPI DataCache_NDIUnknown_Release(
     161static ULONG WINAPI DataCache_NDIUnknown_Release( 
    163162            IUnknown*      iface);
    164163
     
    171170            REFIID           riid,
    172171            void**           ppvObject);
    173 static ULONG WINAPI DataCache_IDataObject_AddRef(
     172static ULONG WINAPI DataCache_IDataObject_AddRef( 
    174173            IDataObject*     iface);
    175 static ULONG WINAPI DataCache_IDataObject_Release(
     174static ULONG WINAPI DataCache_IDataObject_Release( 
    176175            IDataObject*     iface);
    177176static HRESULT WINAPI DataCache_GetData(
    178         IDataObject*     iface,
    179         LPFORMATETC      pformatetcIn,
    180         STGMEDIUM*       pmedium);
     177            IDataObject*     iface,
     178            LPFORMATETC      pformatetcIn,
     179            STGMEDIUM*       pmedium);
    181180static HRESULT WINAPI DataCache_GetDataHere(
    182         IDataObject*     iface,
    183         LPFORMATETC      pformatetc,
    184         STGMEDIUM*       pmedium);
     181            IDataObject*     iface,
     182            LPFORMATETC      pformatetc,
     183            STGMEDIUM*       pmedium);
    185184static HRESULT WINAPI DataCache_QueryGetData(
    186         IDataObject*     iface,
    187         LPFORMATETC      pformatetc);
     185            IDataObject*     iface,
     186            LPFORMATETC      pformatetc);
    188187static HRESULT WINAPI DataCache_GetCanonicalFormatEtc(
    189         IDataObject*     iface,
    190         LPFORMATETC      pformatectIn,
    191         LPFORMATETC      pformatetcOut);
     188            IDataObject*     iface,
     189            LPFORMATETC      pformatectIn,
     190            LPFORMATETC      pformatetcOut);
    192191static HRESULT WINAPI DataCache_IDataObject_SetData(
    193         IDataObject*     iface,
    194         LPFORMATETC      pformatetc,
    195         STGMEDIUM*       pmedium,
    196         BOOL             fRelease);
     192            IDataObject*     iface,
     193            LPFORMATETC      pformatetc,
     194            STGMEDIUM*       pmedium,
     195            BOOL             fRelease);
    197196static HRESULT WINAPI DataCache_EnumFormatEtc(
    198         IDataObject*     iface,
    199         DWORD            dwDirection,
    200         IEnumFORMATETC** ppenumFormatEtc);
     197            IDataObject*     iface,       
     198            DWORD            dwDirection,
     199            IEnumFORMATETC** ppenumFormatEtc);
    201200static HRESULT WINAPI DataCache_DAdvise(
    202         IDataObject*     iface,
    203         FORMATETC*       pformatetc,
    204         DWORD            advf,
    205         IAdviseSink*     pAdvSink,
    206         DWORD*           pdwConnection);
     201            IDataObject*     iface,
     202            FORMATETC*       pformatetc,
     203            DWORD            advf,
     204            IAdviseSink*     pAdvSink,
     205            DWORD*           pdwConnection);
    207206static HRESULT WINAPI DataCache_DUnadvise(
    208         IDataObject*     iface,
    209         DWORD            dwConnection);
     207            IDataObject*     iface,
     208            DWORD            dwConnection);
    210209static HRESULT WINAPI DataCache_EnumDAdvise(
    211         IDataObject*     iface,
    212         IEnumSTATDATA**  ppenumAdvise);
     210            IDataObject*     iface,
     211            IEnumSTATDATA**  ppenumAdvise);
    213212
    214213/*
     
    220219            REFIID           riid,
    221220            void**           ppvObject);
    222 static ULONG WINAPI DataCache_IPersistStorage_AddRef(
     221static ULONG WINAPI DataCache_IPersistStorage_AddRef( 
    223222            IPersistStorage* iface);
    224 static ULONG WINAPI DataCache_IPersistStorage_Release(
     223static ULONG WINAPI DataCache_IPersistStorage_Release( 
    225224            IPersistStorage* iface);
    226 static HRESULT WINAPI DataCache_GetClassID(
     225static HRESULT WINAPI DataCache_GetClassID( 
    227226            IPersistStorage* iface,
    228         CLSID*           pClassID);
    229 static HRESULT WINAPI DataCache_IsDirty(
     227            CLSID*           pClassID);
     228static HRESULT WINAPI DataCache_IsDirty( 
    230229            IPersistStorage* iface);
    231 static HRESULT WINAPI DataCache_InitNew(
     230static HRESULT WINAPI DataCache_InitNew(
     231            IPersistStorage* iface,
     232            IStorage*        pStg);
     233static HRESULT WINAPI DataCache_Load(
    232234            IPersistStorage* iface,
    233         IStorage*        pStg);
    234 static HRESULT WINAPI DataCache_Load(
     235            IStorage*        pStg);
     236static HRESULT WINAPI DataCache_Save(
    235237            IPersistStorage* iface,
    236         IStorage*        pStg);
    237 static HRESULT WINAPI DataCache_Save(
    238             IPersistStorage* iface,
    239         IStorage*        pStg,
    240         BOOL             fSameAsLoad);
    241 static HRESULT WINAPI DataCache_SaveCompleted(
    242             IPersistStorage* iface,
    243         IStorage*        pStgNew);
     238            IStorage*        pStg,
     239            BOOL             fSameAsLoad);
     240static HRESULT WINAPI DataCache_SaveCompleted(
     241            IPersistStorage* iface, 
     242            IStorage*        pStgNew);
    244243static HRESULT WINAPI DataCache_HandsOffStorage(
    245244            IPersistStorage* iface);
     
    253252            REFIID           riid,
    254253            void**           ppvObject);
    255 static ULONG WINAPI DataCache_IViewObject2_AddRef(
     254static ULONG WINAPI DataCache_IViewObject2_AddRef( 
    256255            IViewObject2* iface);
    257 static ULONG WINAPI DataCache_IViewObject2_Release(
     256static ULONG WINAPI DataCache_IViewObject2_Release( 
    258257            IViewObject2* iface);
    259258static HRESULT WINAPI DataCache_Draw(
    260259            IViewObject2*    iface,
    261         DWORD            dwDrawAspect,
    262         LONG             lindex,
    263         void*            pvAspect,
    264         DVTARGETDEVICE*  ptd,
    265         HDC              hdcTargetDev,
    266         HDC              hdcDraw,
    267         LPCRECTL         lprcBounds,
    268         LPCRECTL         lprcWBounds,
    269         IVO_ContCallback pfnContinue,
    270         DWORD            dwContinue);
     260            DWORD            dwDrawAspect,
     261            LONG             lindex,
     262            void*            pvAspect,
     263            DVTARGETDEVICE*  ptd,
     264            HDC              hdcTargetDev,
     265            HDC              hdcDraw,
     266            LPCRECTL         lprcBounds,
     267            LPCRECTL         lprcWBounds,
     268            IVO_ContCallback pfnContinue,
     269            DWORD            dwContinue);
    271270static HRESULT WINAPI DataCache_GetColorSet(
    272             IViewObject2*   iface,
    273         DWORD           dwDrawAspect,
    274         LONG            lindex,
    275         void*           pvAspect,
    276         DVTARGETDEVICE* ptd,
    277         HDC             hicTargetDevice,
    278         LOGPALETTE**    ppColorSet);
     271            IViewObject2*   iface, 
     272            DWORD           dwDrawAspect,
     273            LONG            lindex,
     274            void*           pvAspect,
     275            DVTARGETDEVICE* ptd,
     276            HDC             hicTargetDevice,
     277            LOGPALETTE**    ppColorSet);
    279278static HRESULT WINAPI DataCache_Freeze(
    280279            IViewObject2*   iface,
    281         DWORD           dwDrawAspect,
    282         LONG            lindex,
    283         void*           pvAspect,
    284         DWORD*          pdwFreeze);
     280            DWORD           dwDrawAspect,
     281            LONG            lindex,
     282            void*           pvAspect,
     283            DWORD*          pdwFreeze);
    285284static HRESULT WINAPI DataCache_Unfreeze(
    286285            IViewObject2*   iface,
    287         DWORD           dwFreeze);
     286            DWORD           dwFreeze);
    288287static HRESULT WINAPI DataCache_SetAdvise(
    289288            IViewObject2*   iface,
    290         DWORD           aspects,
    291         DWORD           advf,
    292         IAdviseSink*    pAdvSink);
     289            DWORD           aspects,
     290            DWORD           advf,
     291            IAdviseSink*    pAdvSink);
    293292static HRESULT WINAPI DataCache_GetAdvise(
    294             IViewObject2*   iface,
    295         DWORD*          pAspects,
    296         DWORD*          pAdvf,
    297         IAdviseSink**   ppAdvSink);
     293            IViewObject2*   iface, 
     294            DWORD*          pAspects,
     295            DWORD*          pAdvf,
     296            IAdviseSink**   ppAdvSink);
    298297static HRESULT WINAPI DataCache_GetExtent(
    299             IViewObject2*   iface,
    300         DWORD           dwDrawAspect,
    301         LONG            lindex,
    302         DVTARGETDEVICE* ptd,
    303         LPSIZEL         lpsizel);
     298            IViewObject2*   iface, 
     299            DWORD           dwDrawAspect,
     300            LONG            lindex,
     301            DVTARGETDEVICE* ptd,
     302            LPSIZEL         lpsizel);
    304303
    305304/*
     
    311310            REFIID          riid,
    312311            void**          ppvObject);
    313 static ULONG WINAPI DataCache_IOleCache2_AddRef(
     312static ULONG WINAPI DataCache_IOleCache2_AddRef( 
    314313            IOleCache2*     iface);
    315 static ULONG WINAPI DataCache_IOleCache2_Release(
     314static ULONG WINAPI DataCache_IOleCache2_Release( 
    316315            IOleCache2*     iface);
    317316static HRESULT WINAPI DataCache_Cache(
    318317            IOleCache2*     iface,
    319         FORMATETC*      pformatetc,
    320         DWORD           advf,
    321         DWORD*          pdwConnection);
     318            FORMATETC*      pformatetc,
     319            DWORD           advf,
     320            DWORD*          pdwConnection);
    322321static HRESULT WINAPI DataCache_Uncache(
    323         IOleCache2*     iface,
    324         DWORD           dwConnection);
     322            IOleCache2*     iface,
     323            DWORD           dwConnection);
    325324static HRESULT WINAPI DataCache_EnumCache(
    326325            IOleCache2*     iface,
    327         IEnumSTATDATA** ppenumSTATDATA);
     326            IEnumSTATDATA** ppenumSTATDATA);
    328327static HRESULT WINAPI DataCache_InitCache(
    329         IOleCache2*     iface,
    330         IDataObject*    pDataObject);
     328            IOleCache2*     iface,
     329            IDataObject*    pDataObject);
    331330static HRESULT WINAPI DataCache_IOleCache2_SetData(
    332331            IOleCache2*     iface,
    333         FORMATETC*      pformatetc,
    334         STGMEDIUM*      pmedium,
    335         BOOL            fRelease);
     332            FORMATETC*      pformatetc,
     333            STGMEDIUM*      pmedium,
     334            BOOL            fRelease);
    336335static HRESULT WINAPI DataCache_UpdateCache(
    337336            IOleCache2*     iface,
    338         LPDATAOBJECT    pDataObject,
    339         DWORD           grfUpdf,
    340         LPVOID          pReserved);
     337            LPDATAOBJECT    pDataObject,
     338            DWORD           grfUpdf,
     339            LPVOID          pReserved);
    341340static HRESULT WINAPI DataCache_DiscardCache(
    342341            IOleCache2*     iface,
    343         DWORD           dwDiscardOptions);
     342            DWORD           dwDiscardOptions);
    344343
    345344/*
     
    351350            REFIID            riid,
    352351            void**            ppvObject);
    353 static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
     352static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 
    354353            IOleCacheControl* iface);
    355 static ULONG WINAPI DataCache_IOleCacheControl_Release(
     354static ULONG WINAPI DataCache_IOleCacheControl_Release( 
    356355            IOleCacheControl* iface);
    357356static HRESULT WINAPI DataCache_OnRun(
    358         IOleCacheControl* iface,
    359         LPDATAOBJECT      pDataObject);
     357            IOleCacheControl* iface,
     358            LPDATAOBJECT      pDataObject);
    360359static HRESULT WINAPI DataCache_OnStop(
    361         IOleCacheControl* iface);
     360            IOleCacheControl* iface);
    362361
    363362/*
     
    448447 */
    449448HRESULT WINAPI CreateDataCache(
    450   LPUNKNOWN pUnkOuter,
    451   REFCLSID  rclsid,
    452   REFIID    riid,
     449  LPUNKNOWN pUnkOuter, 
     450  REFCLSID  rclsid, 
     451  REFIID    riid, 
    453452  LPVOID*   ppvObj)
    454453{
     
    472471   * IUnknown pointer can be returned to the outside.
    473472   */
    474   if ( (pUnkOuter!=NULL) &&
     473  if ( (pUnkOuter!=NULL) && 
    475474       (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
    476475    return CLASS_E_NOAGGREGATION;
     
    479478   * Try to construct a new instance of the class.
    480479   */
    481   newCache = DataCache_Construct(rclsid,
    482                 pUnkOuter);
     480  newCache = DataCache_Construct(rclsid, 
     481                                pUnkOuter);
    483482
    484483  if (newCache == 0)
     
    515514  if (newObject==0)
    516515    return newObject;
    517 
     516 
    518517  /*
    519518   * Initialize the virtual function table.
     
    525524  newObject->lpvtbl5 = &DataCache_IOleCache2_VTable;
    526525  newObject->lpvtbl6 = &DataCache_IOleCacheControl_VTable;
    527 
    528   /*
    529    * Start with one reference count. The caller of this function
     526 
     527  /*
     528   * Start with one reference count. The caller of this function 
    530529   * must release the interface pointer when it is done.
    531530   */
     
    534533  /*
    535534   * Initialize the outer unknown
    536    * We don't keep a reference on the outer unknown since, the way
     535   * We don't keep a reference on the outer unknown since, the way 
    537536   * aggregation works, our lifetime is at least as large as it's
    538537   * lifetime.
     
    580579 * DataCache_ReadPresentationData
    581580 *
    582  * This method will read information for the requested presentation
     581 * This method will read information for the requested presentation 
    583582 * into the given structure.
    584583 *
     
    602601  hres = DataCache_OpenPresStream(
    603602           this,
    604        drawAspect,
    605        &presStream);
     603           drawAspect,
     604           &presStream);
    606605
    607606  if (FAILED(hres))
     
    614613  hres = IStream_Read(
    615614           presStream,
    616        header,
    617        sizeof(PresentationDataHeader),
    618        NULL);
     615           header,
     616           sizeof(PresentationDataHeader),
     617           NULL);
    619618
    620619  /*
     
    658657    {
    659658      IAdviseSink_OnViewChange(this->sinkInterface,
    660                    aspect,
    661                    lindex);
     659                               aspect,
     660                               lindex);
    662661
    663662      /*
     
    667666      if ( (this->sinkAdviseFlag & ADVF_ONLYONCE) != 0)
    668667      {
    669     IAdviseSink_Release(this->sinkInterface);
    670 
    671     this->sinkInterface  = NULL;
    672     this->sinkAspects    = 0;
    673     this->sinkAdviseFlag = 0;
     668        IAdviseSink_Release(this->sinkInterface);
     669
     670        this->sinkInterface  = NULL;
     671        this->sinkAspects    = 0;
     672        this->sinkAdviseFlag = 0;
    674673      }
    675674    }
     
    687686
    688687    return (elem->type == STGTY_STREAM)
    689     && (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader))
    690     && (strlenW(name) == 11)
    691     && (strncmpW(name, OlePres, 8) == 0)
    692     && (name[8] >= '0') && (name[8] <= '9')
    693     && (name[9] >= '0') && (name[9] <= '9')
    694     && (name[10] >= '0') && (name[10] <= '9');
     688        && (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader))
     689        && (strlenW(name) == 11)
     690        && (strncmpW(name, OlePres, 8) == 0)
     691        && (name[8] >= '0') && (name[8] <= '9')
     692        && (name[9] >= '0') && (name[9] <= '9')
     693        && (name[10] >= '0') && (name[10] <= '9');
    695694}
    696695
     
    708707 *
    709708 * Errors:
    710  *   S_OK       The requested stream has been opened.
    711  *   OLE_E_BLANK    The requested stream could not be found.
     709 *   S_OK               The requested stream has been opened.
     710 *   OLE_E_BLANK        The requested stream could not be found.
    712711 *   Quite a few others I'm too lazy to map correctly.
    713712 *
    714713 * Notes:
    715  *   Algorithm: Scan the elements of the presentation storage, looking
    716  *      for presentation streams. For each presentation stream,
    717  *      load the header and check to see if the aspect maches.
     714 *   Algorithm: Scan the elements of the presentation storage, looking
     715 *              for presentation streams. For each presentation stream,
     716 *              load the header and check to see if the aspect maches.
    718717 *
    719718 *   If a fallback is desired, just opening the first presentation stream
     
    736735    while ((hr = IEnumSTATSTG_Next(pEnum, 1, &elem, NULL)) == S_OK)
    737736    {
    738     if (DataCache_IsPresentationStream(&elem))
    739     {
    740         IStream *pStm;
    741 
    742         hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName,
    743                      NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0,
    744                      &pStm);
    745         if (SUCCEEDED(hr))
    746         {
    747         PresentationDataHeader header;
    748         ULONG actual_read;
    749 
    750         hr = IStream_Read(pStm, &header, sizeof(header), &actual_read);
    751 
    752         /* can't use SUCCEEDED(hr): S_FALSE counts as an error */
    753         if (hr == S_OK && actual_read == sizeof(header)
    754             && header.dvAspect == drawAspect)
    755         {
    756             /* Rewind the stream before returning it. */
    757             LARGE_INTEGER offset;
    758             offset.s.LowPart = 0;
    759             offset.s.HighPart = 0;
    760             IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL);
    761 
    762             *ppStm = pStm;
    763 
    764             CoTaskMemFree(elem.pwcsName);
    765             IEnumSTATSTG_Release(pEnum);
    766 
    767             return S_OK;
    768         }
    769 
    770         IStream_Release(pStm);
    771         }
     737        if (DataCache_IsPresentationStream(&elem))
     738        {
     739            IStream *pStm;
     740
     741            hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName,
     742                                     NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0,
     743                                     &pStm);
     744            if (SUCCEEDED(hr))
     745            {
     746                PresentationDataHeader header;
     747                ULONG actual_read;
     748
     749                hr = IStream_Read(pStm, &header, sizeof(header), &actual_read);
     750
     751                /* can't use SUCCEEDED(hr): S_FALSE counts as an error */
     752                if (hr == S_OK && actual_read == sizeof(header)
     753                    && header.dvAspect == drawAspect)
     754                {
     755                    /* Rewind the stream before returning it. */
     756                    LARGE_INTEGER offset;
     757                    offset.s.LowPart = 0;
     758                    offset.s.HighPart = 0;
     759                    IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL);
     760
     761                    *ppStm = pStm;
     762
     763                    CoTaskMemFree(elem.pwcsName);
     764                    IEnumSTATSTG_Release(pEnum);
     765
     766                    return S_OK;
     767                }
     768
     769                IStream_Release(pStm);
     770            }
     771        }
     772
     773        CoTaskMemFree(elem.pwcsName);
    772774    }
    773775
    774     CoTaskMemFree(elem.pwcsName);
    775     }
    776 
    777776    IEnumSTATSTG_Release(pEnum);
    778777
     
    783782 * DataCache_ReadPresentationData
    784783 *
    785  * This method will read information for the requested presentation
     784 * This method will read information for the requested presentation 
    786785 * into the given structure.
    787786 *
     
    809808   */
    810809  hres = DataCache_OpenPresStream(
    811            this,
    812        drawAspect,
    813        &presStream);
     810           this, 
     811           drawAspect,
     812           &presStream);
    814813
    815814  if (FAILED(hres))
     
    820819   */
    821820  hres = IStream_Stat(presStream,
    822               &streamInfo,
    823               STATFLAG_NONAME);
     821                      &streamInfo,
     822                      STATFLAG_NONAME);
    824823
    825824  /*
     
    831830  hres = IStream_Seek(
    832831           presStream,
    833        offset,
    834        STREAM_SEEK_SET,
    835        NULL);
     832           offset,
     833           STREAM_SEEK_SET,
     834           NULL);
    836835
    837836  streamInfo.cbSize.s.LowPart -= offset.s.LowPart;
     
    840839   * Allocate a buffer for the metafile bits.
    841840   */
    842   metafileBits = HeapAlloc(GetProcessHeap(),
    843                0,
    844                streamInfo.cbSize.s.LowPart);
     841  metafileBits = HeapAlloc(GetProcessHeap(), 
     842                           0,
     843                           streamInfo.cbSize.s.LowPart);
    845844
    846845  /*
     
    848847   */
    849848  hres = IStream_Read(
    850        presStream,
    851        metafileBits,
    852        streamInfo.cbSize.s.LowPart,
    853        NULL);
     849           presStream,
     850           metafileBits,
     851           streamInfo.cbSize.s.LowPart,
     852           NULL);
    854853
    855854  /*
     
    898897  if ( (this==0) || (ppvObject==0) )
    899898    return E_INVALIDARG;
    900 
     899 
    901900  /*
    902901   * Initialize the return parameter.
     
    907906   * Compare the riid with the interface IDs implemented by this object.
    908907   */
    909   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     908  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    910909  {
    911910    *ppvObject = iface;
    912911  }
    913   else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
     912  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 
    914913  {
    915914    *ppvObject = (IDataObject*)&(this->lpvtbl1);
    916915  }
    917916  else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0)  ||
    918         (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
     917            (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
    919918  {
    920919    *ppvObject = (IPersistStorage*)&(this->lpvtbl3);
    921920  }
    922921  else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) ||
    923         (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
     922            (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
    924923  {
    925924    *ppvObject = (IViewObject2*)&(this->lpvtbl4);
    926925  }
    927926  else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) ||
    928         (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
     927            (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
    929928  {
    930929    *ppvObject = (IOleCache2*)&(this->lpvtbl5);
    931930  }
    932   else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0)
     931  else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0) 
    933932  {
    934933    *ppvObject = (IOleCacheControl*)&(this->lpvtbl6);
     
    943942    return E_NOINTERFACE;
    944943  }
    945 
     944 
    946945  /*
    947946   * Query Interface always increases the reference count by one when it is
    948    * successful.
     947   * successful. 
    949948   */
    950949  IUnknown_AddRef((IUnknown*)*ppvObject);
    951950
    952   return S_OK;;
     951  return S_OK;; 
    953952}
    954953
     
    961960 * to the outer unknown.
    962961 */
    963 static ULONG WINAPI DataCache_NDIUnknown_AddRef(
     962static ULONG WINAPI DataCache_NDIUnknown_AddRef( 
    964963            IUnknown*      iface)
    965964{
     
    979978 * to the outer unknown.
    980979 */
    981 static ULONG WINAPI DataCache_NDIUnknown_Release(
     980static ULONG WINAPI DataCache_NDIUnknown_Release( 
    982981            IUnknown*      iface)
    983982{
     
    998997    return 0;
    999998  }
    1000 
     999 
    10011000  return this->ref;
    10021001}
     
    10191018  _ICOM_THIS_From_IDataObject(DataCache, iface);
    10201019
    1021   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1020  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    10221021}
    10231022
     
    10271026 * See Windows documentation for more details on IUnknown methods.
    10281027 */
    1029 static ULONG WINAPI DataCache_IDataObject_AddRef(
     1028static ULONG WINAPI DataCache_IDataObject_AddRef( 
    10301029            IDataObject*     iface)
    10311030{
    10321031  _ICOM_THIS_From_IDataObject(DataCache, iface);
    10331032
    1034   return IUnknown_AddRef(this->outerUnknown);
     1033  return IUnknown_AddRef(this->outerUnknown); 
    10351034}
    10361035
     
    10401039 * See Windows documentation for more details on IUnknown methods.
    10411040 */
    1042 static ULONG WINAPI DataCache_IDataObject_Release(
     1041static ULONG WINAPI DataCache_IDataObject_Release( 
    10431042            IDataObject*     iface)
    10441043{
    10451044  _ICOM_THIS_From_IDataObject(DataCache, iface);
    10461045
    1047   return IUnknown_Release(this->outerUnknown);
     1046  return IUnknown_Release(this->outerUnknown); 
    10481047}
    10491048
     
    10561055 */
    10571056static HRESULT WINAPI DataCache_GetData(
    1058         IDataObject*     iface,
    1059         LPFORMATETC      pformatetcIn,
    1060         STGMEDIUM*       pmedium)
     1057            IDataObject*     iface,
     1058            LPFORMATETC      pformatetcIn,
     1059            STGMEDIUM*       pmedium)
    10611060{
    10621061  HRESULT hr = 0;
     
    11551154
    11561155static HRESULT WINAPI DataCache_GetDataHere(
    1157         IDataObject*     iface,
    1158         LPFORMATETC      pformatetc,
    1159         STGMEDIUM*       pmedium)
     1156            IDataObject*     iface,
     1157            LPFORMATETC      pformatetc,
     1158            STGMEDIUM*       pmedium)
    11601159{
    11611160  FIXME("stub\n");
     
    11641163
    11651164static HRESULT WINAPI DataCache_QueryGetData(
    1166         IDataObject*     iface,
    1167         LPFORMATETC      pformatetc)
     1165            IDataObject*     iface,
     1166            LPFORMATETC      pformatetc)
    11681167{
    11691168  FIXME("stub\n");
     
    11791178 */
    11801179static HRESULT WINAPI DataCache_GetCanonicalFormatEtc(
    1181         IDataObject*     iface,
    1182         LPFORMATETC      pformatectIn,
    1183         LPFORMATETC      pformatetcOut)
     1180            IDataObject*     iface,
     1181            LPFORMATETC      pformatectIn,
     1182            LPFORMATETC      pformatetcOut)
    11841183{
    11851184  TRACE("()\n");
     
    11951194 */
    11961195static HRESULT WINAPI DataCache_IDataObject_SetData(
    1197         IDataObject*     iface,
    1198         LPFORMATETC      pformatetc,
    1199         STGMEDIUM*       pmedium,
    1200         BOOL             fRelease)
     1196            IDataObject*     iface,
     1197            LPFORMATETC      pformatetc,
     1198            STGMEDIUM*       pmedium,
     1199            BOOL             fRelease)
    12011200{
    12021201  IOleCache2* oleCache = NULL;
     
    12251224 */
    12261225static HRESULT WINAPI DataCache_EnumFormatEtc(
    1227         IDataObject*     iface,
    1228         DWORD            dwDirection,
    1229         IEnumFORMATETC** ppenumFormatEtc)
     1226            IDataObject*     iface,       
     1227            DWORD            dwDirection,
     1228            IEnumFORMATETC** ppenumFormatEtc)
    12301229{
    12311230  TRACE("()\n");
     
    12411240 */
    12421241static HRESULT WINAPI DataCache_DAdvise(
    1243         IDataObject*     iface,
    1244         FORMATETC*       pformatetc,
    1245         DWORD            advf,
    1246         IAdviseSink*     pAdvSink,
    1247         DWORD*           pdwConnection)
     1242            IDataObject*     iface,
     1243            FORMATETC*       pformatetc,
     1244            DWORD            advf,
     1245            IAdviseSink*     pAdvSink,
     1246            DWORD*           pdwConnection)
    12481247{
    12491248  TRACE("()\n");
     
    12591258 */
    12601259static HRESULT WINAPI DataCache_DUnadvise(
    1261         IDataObject*     iface,
    1262         DWORD            dwConnection)
     1260            IDataObject*     iface,
     1261            DWORD            dwConnection)
    12631262{
    12641263  TRACE("()\n");
     
    12741273 */
    12751274static HRESULT WINAPI DataCache_EnumDAdvise(
    1276         IDataObject*     iface,
    1277         IEnumSTATDATA**  ppenumAdvise)
     1275            IDataObject*     iface,
     1276            IEnumSTATDATA**  ppenumAdvise)
    12781277{
    12791278  TRACE("()\n");
     
    12981297  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    12991298
    1300   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1299  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    13011300}
    13021301
     
    13061305 * See Windows documentation for more details on IUnknown methods.
    13071306 */
    1308 static ULONG WINAPI DataCache_IPersistStorage_AddRef(
     1307static ULONG WINAPI DataCache_IPersistStorage_AddRef( 
    13091308            IPersistStorage* iface)
    13101309{
    13111310  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    13121311
    1313   return IUnknown_AddRef(this->outerUnknown);
     1312  return IUnknown_AddRef(this->outerUnknown); 
    13141313}
    13151314
     
    13191318 * See Windows documentation for more details on IUnknown methods.
    13201319 */
    1321 static ULONG WINAPI DataCache_IPersistStorage_Release(
     1320static ULONG WINAPI DataCache_IPersistStorage_Release( 
    13221321            IPersistStorage* iface)
    13231322{
    13241323  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    13251324
    1326   return IUnknown_Release(this->outerUnknown);
     1325  return IUnknown_Release(this->outerUnknown); 
    13271326}
    13281327
     
    13341333 * See Windows documentation for more details on IPersistStorage methods.
    13351334 */
    1336 static HRESULT WINAPI DataCache_GetClassID(
     1335static HRESULT WINAPI DataCache_GetClassID( 
    13371336            IPersistStorage* iface,
    1338         CLSID*           pClassID)
     1337            CLSID*           pClassID)
    13391338{
    13401339  TRACE("(%p, %p)\n", iface, pClassID);
     
    13451344 * DataCache_IsDirty (IPersistStorage)
    13461345 *
    1347  * Until we actully connect to a running object and retrieve new
     1346 * Until we actully connect to a running object and retrieve new 
    13481347 * information to it, we never get dirty.
    13491348 *
    13501349 * See Windows documentation for more details on IPersistStorage methods.
    13511350 */
    1352 static HRESULT WINAPI DataCache_IsDirty(
     1351static HRESULT WINAPI DataCache_IsDirty( 
    13531352            IPersistStorage* iface)
    13541353{
     
    13661365 * See Windows documentation for more details on IPersistStorage methods.
    13671366 */
    1368 static HRESULT WINAPI DataCache_InitNew(
     1367static HRESULT WINAPI DataCache_InitNew(
     1368            IPersistStorage* iface,
     1369            IStorage*        pStg)
     1370{
     1371  TRACE("(%p, %p)\n", iface, pStg);
     1372
     1373  return DataCache_Load(iface, pStg);
     1374}
     1375
     1376/************************************************************************
     1377 * DataCache_Load (IPersistStorage)
     1378 *
     1379 * The data cache implementation of IPersistStorage_Load doesn't
     1380 * actually load anything. Instead, it holds on to the storage pointer
     1381 * and it will load the presentation information when the
     1382 * IDataObject_GetData or IViewObject2_Draw methods are called.
     1383 *
     1384 * See Windows documentation for more details on IPersistStorage methods.
     1385 */
     1386static HRESULT WINAPI DataCache_Load(
    13691387            IPersistStorage* iface,
    1370         IStorage*        pStg)
    1371 {
     1388            IStorage*        pStg)
     1389{
     1390  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
     1391
    13721392  TRACE("(%p, %p)\n", iface, pStg);
    13731393
    1374   return DataCache_Load(iface, pStg);
    1375 }
    1376 
    1377 /************************************************************************
    1378  * DataCache_Load (IPersistStorage)
    1379  *
    1380  * The data cache implementation of IPersistStorage_Load doesn't
    1381  * actually load anything. Instead, it holds on to the storage pointer
    1382  * and it will load the presentation information when the
    1383  * IDataObject_GetData or IViewObject2_Draw methods are called.
    1384  *
    1385  * See Windows documentation for more details on IPersistStorage methods.
    1386  */
    1387 static HRESULT WINAPI DataCache_Load(
    1388             IPersistStorage* iface,
    1389         IStorage*        pStg)
    1390 {
    1391   _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    1392 
    1393   TRACE("(%p, %p)\n", iface, pStg);
    1394 
    13951394  if (this->presentationStorage != NULL)
    13961395  {
     
    14101409 * DataCache_Save (IPersistStorage)
    14111410 *
    1412  * Until we actully connect to a running object and retrieve new
     1411 * Until we actully connect to a running object and retrieve new 
    14131412 * information to it, we never have to save anything. However, it is
    14141413 * our responsability to copy the information when saving to a new
     
    14171416 * See Windows documentation for more details on IPersistStorage methods.
    14181417 */
    1419 static HRESULT WINAPI DataCache_Save(
     1418static HRESULT WINAPI DataCache_Save( 
    14201419            IPersistStorage* iface,
    1421         IStorage*        pStg,
    1422         BOOL             fSameAsLoad)
     1420            IStorage*        pStg,
     1421            BOOL             fSameAsLoad)
    14231422{
    14241423  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
     
    14261425  TRACE("(%p, %p, %d)\n", iface, pStg, fSameAsLoad);
    14271426
    1428   if ( (!fSameAsLoad) &&
     1427  if ( (!fSameAsLoad) && 
    14291428       (this->presentationStorage!=NULL) )
    14301429  {
    14311430    return IStorage_CopyTo(this->presentationStorage,
    1432                0,
    1433                NULL,
    1434                NULL,
    1435                pStg);
     1431                           0,
     1432                           NULL,
     1433                           NULL,
     1434                           pStg);
    14361435  }
    14371436
     
    14471446 * See Windows documentation for more details on IPersistStorage methods.
    14481447 */
    1449 static HRESULT WINAPI DataCache_SaveCompleted(
    1450             IPersistStorage* iface,
    1451         IStorage*        pStgNew)
     1448static HRESULT WINAPI DataCache_SaveCompleted( 
     1449            IPersistStorage* iface, 
     1450            IStorage*        pStgNew)
    14521451{
    14531452  TRACE("(%p, %p)\n", iface, pStgNew);
     
    15121511  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    15131512
    1514   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1513  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    15151514}
    15161515
     
    15201519 * See Windows documentation for more details on IUnknown methods.
    15211520 */
    1522 static ULONG WINAPI DataCache_IViewObject2_AddRef(
     1521static ULONG WINAPI DataCache_IViewObject2_AddRef( 
    15231522            IViewObject2* iface)
    15241523{
    15251524  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    15261525
    1527   return IUnknown_AddRef(this->outerUnknown);
     1526  return IUnknown_AddRef(this->outerUnknown); 
    15281527}
    15291528
     
    15331532 * See Windows documentation for more details on IUnknown methods.
    15341533 */
    1535 static ULONG WINAPI DataCache_IViewObject2_Release(
     1534static ULONG WINAPI DataCache_IViewObject2_Release( 
    15361535            IViewObject2* iface)
    15371536{
    15381537  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    15391538
    1540   return IUnknown_Release(this->outerUnknown);
     1539  return IUnknown_Release(this->outerUnknown); 
    15411540}
    15421541
     
    15511550static HRESULT WINAPI DataCache_Draw(
    15521551            IViewObject2*    iface,
    1553         DWORD            dwDrawAspect,
    1554         LONG             lindex,
    1555         void*            pvAspect,
    1556         DVTARGETDEVICE*  ptd,
    1557         HDC              hdcTargetDev,
    1558         HDC              hdcDraw,
    1559         LPCRECTL         lprcBounds,
    1560         LPCRECTL         lprcWBounds,
    1561         IVO_ContCallback pfnContinue,
    1562         DWORD            dwContinue)
     1552            DWORD            dwDrawAspect,
     1553            LONG             lindex,
     1554            void*            pvAspect,
     1555            DVTARGETDEVICE*  ptd,
     1556            HDC              hdcTargetDev,
     1557            HDC              hdcDraw,
     1558            LPCRECTL         lprcBounds,
     1559            LPCRECTL         lprcWBounds,
     1560            IVO_ContCallback pfnContinue,
     1561            DWORD            dwContinue)
    15631562{
    15641563  PresentationDataHeader presData;
     
    15691568
    15701569  TRACE("(%p, %lx, %ld, %p, %x, %x, %p, %p, %p, %lx)\n",
    1571     iface,
    1572     dwDrawAspect,
    1573     lindex,
    1574     pvAspect,
    1575     hdcTargetDev,
    1576     hdcDraw,
    1577     lprcBounds,
    1578     lprcWBounds,
    1579     pfnContinue,
    1580     dwContinue);
     1570        iface,
     1571        dwDrawAspect,
     1572        lindex,
     1573        pvAspect,
     1574        hdcTargetDev,
     1575        hdcDraw,
     1576        lprcBounds,
     1577        lprcWBounds,
     1578        pfnContinue,
     1579        dwContinue);
    15811580
    15821581  /*
     
    15911590   */
    15921591  hres = DataCache_ReadPresentationData(this,
    1593                     dwDrawAspect,
    1594                     &presData);
     1592                                        dwDrawAspect,
     1593                                        &presData);
    15951594
    15961595  if (FAILED(hres))
     
    16051604   */
    16061605  presMetafile = DataCache_ReadPresMetafile(this,
    1607                         dwDrawAspect);
     1606                                            dwDrawAspect);
    16081607
    16091608  /*
     
    16201619
    16211620    SetWindowExtEx(hdcDraw,
    1622            presData.dwObjectExtentX,
    1623            presData.dwObjectExtentY,
    1624            &oldWindowExt);
    1625 
    1626     SetViewportExtEx(hdcDraw,
    1627              lprcBounds->right - lprcBounds->left,
    1628              lprcBounds->bottom - lprcBounds->top,
    1629              &oldViewportExt);
     1621                   presData.dwObjectExtentX,
     1622                   presData.dwObjectExtentY,
     1623                   &oldWindowExt);
     1624
     1625    SetViewportExtEx(hdcDraw, 
     1626                     lprcBounds->right - lprcBounds->left,
     1627                     lprcBounds->bottom - lprcBounds->top,
     1628                     &oldViewportExt);
    16301629
    16311630    SetViewportOrgEx(hdcDraw,
    1632              lprcBounds->left,
    1633              lprcBounds->top,
    1634              &oldViewportOrg);
     1631                     lprcBounds->left,
     1632                     lprcBounds->top,
     1633                     &oldViewportOrg);
    16351634
    16361635    PlayMetaFile(hdcDraw, presMetafile);
    16371636
    16381637    SetWindowExtEx(hdcDraw,
    1639            oldWindowExt.cx,
    1640            oldWindowExt.cy,
    1641            NULL);
    1642 
    1643     SetViewportExtEx(hdcDraw,
    1644              oldViewportExt.cx,
    1645              oldViewportExt.cy,
    1646              NULL);
     1638                   oldWindowExt.cx,
     1639                   oldWindowExt.cy,
     1640                   NULL);
     1641
     1642    SetViewportExtEx(hdcDraw, 
     1643                     oldViewportExt.cx,
     1644                     oldViewportExt.cy,
     1645                     NULL);
    16471646
    16481647    SetViewportOrgEx(hdcDraw,
    1649              oldViewportOrg.x,
    1650              oldViewportOrg.y,
    1651              NULL);
     1648                     oldViewportOrg.x,
     1649                     oldViewportOrg.y,
     1650                     NULL);
    16521651
    16531652    SetMapMode(hdcDraw, prevMapMode);
     
    16601659
    16611660static HRESULT WINAPI DataCache_GetColorSet(
    1662             IViewObject2*   iface,
    1663         DWORD           dwDrawAspect,
    1664         LONG            lindex,
    1665         void*           pvAspect,
    1666         DVTARGETDEVICE* ptd,
    1667         HDC             hicTargetDevice,
    1668         LOGPALETTE**    ppColorSet)
     1661            IViewObject2*   iface, 
     1662            DWORD           dwDrawAspect,
     1663            LONG            lindex,
     1664            void*           pvAspect,
     1665            DVTARGETDEVICE* ptd,
     1666            HDC             hicTargetDevice,
     1667            LOGPALETTE**    ppColorSet)
    16691668{
    16701669  FIXME("stub\n");
     
    16741673static HRESULT WINAPI DataCache_Freeze(
    16751674            IViewObject2*   iface,
    1676         DWORD           dwDrawAspect,
    1677         LONG            lindex,
    1678         void*           pvAspect,
    1679         DWORD*          pdwFreeze)
     1675            DWORD           dwDrawAspect,
     1676            LONG            lindex,
     1677            void*           pvAspect,
     1678            DWORD*          pdwFreeze)
    16801679{
    16811680  FIXME("stub\n");
     
    16851684static HRESULT WINAPI DataCache_Unfreeze(
    16861685            IViewObject2*   iface,
    1687         DWORD           dwFreeze)
     1686            DWORD           dwFreeze)
    16881687{
    16891688  FIXME("stub\n");
     
    17011700static HRESULT WINAPI DataCache_SetAdvise(
    17021701            IViewObject2*   iface,
    1703         DWORD           aspects,
    1704         DWORD           advf,
    1705         IAdviseSink*    pAdvSink)
     1702            DWORD           aspects,
     1703            DWORD           advf,
     1704            IAdviseSink*    pAdvSink)
    17061705{
    17071706  _ICOM_THIS_From_IViewObject2(DataCache, iface);
     
    17161715    IAdviseSink_Release(this->sinkInterface);
    17171716    this->sinkInterface  = NULL;
    1718     this->sinkAspects    = 0;
     1717    this->sinkAspects    = 0; 
    17191718    this->sinkAdviseFlag = 0;
    17201719  }
     
    17261725  {
    17271726    this->sinkInterface  = pAdvSink;
    1728     this->sinkAspects    = aspects;
    1729     this->sinkAdviseFlag = advf;
     1727    this->sinkAspects    = aspects; 
     1728    this->sinkAdviseFlag = advf;   
    17301729
    17311730    IAdviseSink_AddRef(this->sinkInterface);
     
    17391738  {
    17401739    DataCache_FireOnViewChange(this,
    1741                    DVASPECT_CONTENT,
    1742                    -1);
     1740                               DVASPECT_CONTENT,
     1741                               -1);
    17431742  }
    17441743
     
    17491748 * DataCache_GetAdvise (IViewObject2)
    17501749 *
    1751  * This method queries the current state of the advise sink
     1750 * This method queries the current state of the advise sink 
    17521751 * installed on the data cache.
    17531752 *
     
    17551754 */
    17561755static HRESULT WINAPI DataCache_GetAdvise(
    1757             IViewObject2*   iface,
    1758         DWORD*          pAspects,
    1759         DWORD*          pAdvf,
    1760         IAdviseSink**   ppAdvSink)
     1756            IViewObject2*   iface, 
     1757            DWORD*          pAspects,
     1758            DWORD*          pAdvf,
     1759            IAdviseSink**   ppAdvSink)
    17611760{
    17621761  _ICOM_THIS_From_IViewObject2(DataCache, iface);
     
    17751774  if (ppAdvSink!=NULL)
    17761775  {
    1777     IAdviseSink_QueryInterface(this->sinkInterface,
    1778                    &IID_IAdviseSink,
    1779                    (void**)ppAdvSink);
     1776    IAdviseSink_QueryInterface(this->sinkInterface, 
     1777                               &IID_IAdviseSink,
     1778                               (void**)ppAdvSink);
    17801779  }
    17811780
     
    17911790 */
    17921791static HRESULT WINAPI DataCache_GetExtent(
    1793             IViewObject2*   iface,
    1794         DWORD           dwDrawAspect,
    1795         LONG            lindex,
    1796         DVTARGETDEVICE* ptd,
    1797         LPSIZEL         lpsizel)
     1792            IViewObject2*   iface, 
     1793            DWORD           dwDrawAspect,
     1794            LONG            lindex,
     1795            DVTARGETDEVICE* ptd,
     1796            LPSIZEL         lpsizel)
    17981797{
    17991798  PresentationDataHeader presData;
     
    18021801  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    18031802
    1804   TRACE("(%p, %lx, %ld, %p, %p)\n",
    1805     iface, dwDrawAspect, lindex, ptd, lpsizel);
     1803  TRACE("(%p, %lx, %ld, %p, %p)\n", 
     1804        iface, dwDrawAspect, lindex, ptd, lpsizel);
    18061805
    18071806  /*
     
    18291828  if (ptd!=NULL)
    18301829    FIXME("Unimplemented ptd = %p\n", ptd);
    1831 
    1832   /*
    1833    * Get the presentation information from the
     1830 
     1831  /*
     1832   * Get the presentation information from the 
    18341833   * cache.
    18351834   */
    18361835  hres = DataCache_ReadPresentationData(this,
    1837                     dwDrawAspect,
    1838                     &presData);
     1836                                        dwDrawAspect,
     1837                                        &presData);
    18391838
    18401839  if (SUCCEEDED(hres))
     
    18711870  _ICOM_THIS_From_IOleCache2(DataCache, iface);
    18721871
    1873   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1872  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    18741873}
    18751874
     
    18791878 * See Windows documentation for more details on IUnknown methods.
    18801879 */
    1881 static ULONG WINAPI DataCache_IOleCache2_AddRef(
     1880static ULONG WINAPI DataCache_IOleCache2_AddRef( 
    18821881            IOleCache2*     iface)
    18831882{
    18841883  _ICOM_THIS_From_IOleCache2(DataCache, iface);
    18851884
    1886   return IUnknown_AddRef(this->outerUnknown);
     1885  return IUnknown_AddRef(this->outerUnknown); 
    18871886}
    18881887
     
    18921891 * See Windows documentation for more details on IUnknown methods.
    18931892 */
    1894 static ULONG WINAPI DataCache_IOleCache2_Release(
     1893static ULONG WINAPI DataCache_IOleCache2_Release( 
    18951894            IOleCache2*     iface)
    18961895{
    18971896  _ICOM_THIS_From_IOleCache2(DataCache, iface);
    18981897
    1899   return IUnknown_Release(this->outerUnknown);
     1898  return IUnknown_Release(this->outerUnknown); 
    19001899}
    19011900
    19021901static HRESULT WINAPI DataCache_Cache(
    19031902            IOleCache2*     iface,
    1904         FORMATETC*      pformatetc,
    1905         DWORD           advf,
    1906         DWORD*          pdwConnection)
     1903            FORMATETC*      pformatetc,
     1904            DWORD           advf,
     1905            DWORD*          pdwConnection)
    19071906{
    19081907  FIXME("stub\n");
     
    19111910
    19121911static HRESULT WINAPI DataCache_Uncache(
    1913         IOleCache2*     iface,
    1914         DWORD           dwConnection)
     1912            IOleCache2*     iface,
     1913            DWORD           dwConnection)
    19151914{
    19161915  FIXME("stub\n");
     
    19201919static HRESULT WINAPI DataCache_EnumCache(
    19211920            IOleCache2*     iface,
    1922         IEnumSTATDATA** ppenumSTATDATA)
     1921            IEnumSTATDATA** ppenumSTATDATA)
    19231922{
    19241923  FIXME("stub\n");
     
    19271926
    19281927static HRESULT WINAPI DataCache_InitCache(
    1929         IOleCache2*     iface,
    1930         IDataObject*    pDataObject)
     1928            IOleCache2*     iface,
     1929            IDataObject*    pDataObject)
    19311930{
    19321931  FIXME("stub\n");
     
    19361935static HRESULT WINAPI DataCache_IOleCache2_SetData(
    19371936            IOleCache2*     iface,
    1938         FORMATETC*      pformatetc,
    1939         STGMEDIUM*      pmedium,
    1940         BOOL            fRelease)
     1937            FORMATETC*      pformatetc,
     1938            STGMEDIUM*      pmedium,
     1939            BOOL            fRelease)
    19411940{
    19421941  FIXME("stub\n");
     
    19461945static HRESULT WINAPI DataCache_UpdateCache(
    19471946            IOleCache2*     iface,
    1948         LPDATAOBJECT    pDataObject,
    1949         DWORD           grfUpdf,
    1950         LPVOID          pReserved)
     1947            LPDATAOBJECT    pDataObject,
     1948            DWORD           grfUpdf,
     1949            LPVOID          pReserved)
    19511950{
    19521951  FIXME("stub\n");
     
    19561955static HRESULT WINAPI DataCache_DiscardCache(
    19571956            IOleCache2*     iface,
    1958         DWORD           dwDiscardOptions)
     1957            DWORD           dwDiscardOptions)
    19591958{
    19601959  FIXME("stub\n");
     
    19801979  _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
    19811980
    1982   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1981  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    19831982}
    19841983
     
    19881987 * See Windows documentation for more details on IUnknown methods.
    19891988 */
    1990 static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
     1989static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 
    19911990            IOleCacheControl* iface)
    19921991{
    19931992  _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
    19941993
    1995   return IUnknown_AddRef(this->outerUnknown);
     1994  return IUnknown_AddRef(this->outerUnknown); 
    19961995}
    19971996
     
    20012000 * See Windows documentation for more details on IUnknown methods.
    20022001 */
    2003 static ULONG WINAPI DataCache_IOleCacheControl_Release(
     2002static ULONG WINAPI DataCache_IOleCacheControl_Release( 
    20042003            IOleCacheControl* iface)
    20052004{
    20062005  _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
    20072006
    2008   return IUnknown_Release(this->outerUnknown);
     2007  return IUnknown_Release(this->outerUnknown); 
    20092008}
    20102009
    20112010static HRESULT WINAPI DataCache_OnRun(
    2012         IOleCacheControl* iface,
    2013         LPDATAOBJECT      pDataObject)
     2011            IOleCacheControl* iface,
     2012            LPDATAOBJECT      pDataObject)
    20142013{
    20152014  FIXME("stub\n");
     
    20182017
    20192018static HRESULT WINAPI DataCache_OnStop(
    2020         IOleCacheControl* iface)
     2019            IOleCacheControl* iface)
    20212020{
    20222021  FIXME("stub\n");
  • trunk/src/ole32/defaulthandler.c

    r6648 r6711  
    1 /* $Id: defaulthandler.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
    21/*
    3  *  OLE 2 default object handler
     2 *      OLE 2 default object handler
    43 *
    54 *      Copyright 1999  Francis Beaudet
     
    2625 *   done in this area.
    2726 *
    28  * - Some functions still return E_NOTIMPL they have to be
     27 * - Some functions still return E_NOTIMPL they have to be 
    2928 *   implemented. Most of those are related to the running of the
    3029 *   actual server.
     
    5453   * List all interface VTables here
    5554   */
    56   ICOM_VTABLE(IOleObject)*      lpvtbl1;
     55  ICOM_VTABLE(IOleObject)*      lpvtbl1; 
    5756  ICOM_VTABLE(IUnknown)*        lpvtbl2;
    5857  ICOM_VTABLE(IDataObject)*     lpvtbl3;
     
    9190
    9291  /*
    93    * The IDataAdviseHolder maintains the data
     92   * The IDataAdviseHolder maintains the data 
    9493   * connections on behalf of the default handler.
    9594   */
     
    9998   * Name of the container and object contained
    10099   */
    101   LPWSTR containerApp;
     100  LPWSTR containerApp; 
    102101  LPWSTR containerObj;
    103102
     
    107106
    108107/*
    109  * Here, I define utility macros to help with the casting of the
     108 * Here, I define utility macros to help with the casting of the 
    110109 * "this" parameter.
    111110 * There is a version to accomodate all of the VTables implemented
     
    113112 */
    114113#define _ICOM_THIS_From_IOleObject(class,name)       class* this = (class*)name;
    115 #define _ICOM_THIS_From_NDIUnknown(class, name)      class* this = (class*)(((char*)name)-sizeof(void*));
    116 #define _ICOM_THIS_From_IDataObject(class, name)     class* this = (class*)(((char*)name)-2*sizeof(void*));
    117 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
     114#define _ICOM_THIS_From_NDIUnknown(class, name)      class* this = (class*)(((char*)name)-sizeof(void*)); 
     115#define _ICOM_THIS_From_IDataObject(class, name)     class* this = (class*)(((char*)name)-2*sizeof(void*)); 
     116#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 
    118117
    119118/*
     
    121120 */
    122121static DefaultHandler* DefaultHandler_Construct(REFCLSID  clsid,
    123                         LPUNKNOWN pUnkOuter);
     122                                                LPUNKNOWN pUnkOuter);
    124123static void            DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
    125124
     
    132131            REFIID         riid,
    133132            void**         ppvObject);
    134 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
     133static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 
    135134            IUnknown*      iface);
    136 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
     135static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 
    137136            IUnknown*      iface);
    138137
     
    145144            REFIID           riid,
    146145            void**           ppvObject);
    147 static ULONG WINAPI DefaultHandler_AddRef(
     146static ULONG WINAPI DefaultHandler_AddRef( 
    148147            IOleObject*        iface);
    149 static ULONG WINAPI DefaultHandler_Release(
     148static ULONG WINAPI DefaultHandler_Release( 
    150149            IOleObject*        iface);
    151150static HRESULT WINAPI DefaultHandler_SetClientSite(
    152         IOleObject*        iface,
    153         IOleClientSite*    pClientSite);
     151            IOleObject*        iface,
     152            IOleClientSite*    pClientSite);
    154153static HRESULT WINAPI DefaultHandler_GetClientSite(
    155         IOleObject*        iface,
    156         IOleClientSite**   ppClientSite);
     154            IOleObject*        iface,
     155            IOleClientSite**   ppClientSite);
    157156static HRESULT WINAPI DefaultHandler_SetHostNames(
    158         IOleObject*        iface,
    159         LPCOLESTR          szContainerApp,
    160         LPCOLESTR          szContainerObj);
     157            IOleObject*        iface,
     158            LPCOLESTR          szContainerApp,
     159            LPCOLESTR          szContainerObj);
    161160static HRESULT WINAPI DefaultHandler_Close(
    162         IOleObject*        iface,
    163         DWORD              dwSaveOption);
     161            IOleObject*        iface,
     162            DWORD              dwSaveOption);
    164163static HRESULT WINAPI DefaultHandler_SetMoniker(
    165         IOleObject*        iface,
    166         DWORD              dwWhichMoniker,
    167         IMoniker*          pmk);
     164            IOleObject*        iface,
     165            DWORD              dwWhichMoniker,
     166            IMoniker*          pmk);
    168167static HRESULT WINAPI DefaultHandler_GetMoniker(
    169         IOleObject*        iface,
    170         DWORD              dwAssign,
    171         DWORD              dwWhichMoniker,
    172         IMoniker**         ppmk);
     168            IOleObject*        iface,
     169            DWORD              dwAssign,
     170            DWORD              dwWhichMoniker,
     171            IMoniker**         ppmk);
    173172static HRESULT WINAPI DefaultHandler_InitFromData(
    174         IOleObject*        iface,
    175         IDataObject*       pDataObject,
    176         BOOL               fCreation,
    177         DWORD              dwReserved);
     173            IOleObject*        iface,
     174            IDataObject*       pDataObject,
     175            BOOL               fCreation,
     176            DWORD              dwReserved);
    178177static HRESULT WINAPI DefaultHandler_GetClipboardData(
    179         IOleObject*        iface,
    180         DWORD              dwReserved,
    181         IDataObject**      ppDataObject);
     178            IOleObject*        iface,
     179            DWORD              dwReserved,
     180            IDataObject**      ppDataObject);
    182181static HRESULT WINAPI DefaultHandler_DoVerb(
    183         IOleObject*        iface,
    184         LONG               iVerb,
     182            IOleObject*        iface,
     183            LONG               iVerb,
    185184#ifdef __WIN32OS2__
    186         LPMSG              lpmsg,
     185            LPMSG              lpmsg,
    187186#else
    188         struct tagMSG*     lpmsg,
     187            struct tagMSG*     lpmsg,
    189188#endif
    190         IOleClientSite*    pActiveSite,
    191         LONG               lindex,
    192         HWND               hwndParent,
    193         LPCRECT            lprcPosRect);
     189            IOleClientSite*    pActiveSite,
     190            LONG               lindex,
     191            HWND               hwndParent,
     192            LPCRECT            lprcPosRect);
    194193static HRESULT WINAPI DefaultHandler_EnumVerbs(
    195         IOleObject*        iface,
    196         IEnumOLEVERB**     ppEnumOleVerb);
     194            IOleObject*        iface,
     195            IEnumOLEVERB**     ppEnumOleVerb);
    197196static HRESULT WINAPI DefaultHandler_Update(
    198         IOleObject*        iface);
     197            IOleObject*        iface);
    199198static HRESULT WINAPI DefaultHandler_IsUpToDate(
    200         IOleObject*        iface);
     199            IOleObject*        iface);
    201200static HRESULT WINAPI DefaultHandler_GetUserClassID(
    202         IOleObject*        iface,
    203         CLSID*             pClsid);
     201            IOleObject*        iface,
     202            CLSID*             pClsid);
    204203static HRESULT WINAPI DefaultHandler_GetUserType(
    205         IOleObject*        iface,
    206         DWORD              dwFormOfType,
    207         LPOLESTR*          pszUserType);
     204            IOleObject*        iface,
     205            DWORD              dwFormOfType,
     206            LPOLESTR*          pszUserType);
    208207static HRESULT WINAPI DefaultHandler_SetExtent(
    209         IOleObject*        iface,
    210         DWORD              dwDrawAspect,
    211         SIZEL*             psizel);
     208            IOleObject*        iface,
     209            DWORD              dwDrawAspect,
     210            SIZEL*             psizel);
    212211static HRESULT WINAPI DefaultHandler_GetExtent(
    213         IOleObject*        iface,
    214         DWORD              dwDrawAspect,
    215         SIZEL*             psizel);
     212            IOleObject*        iface,
     213            DWORD              dwDrawAspect,
     214            SIZEL*             psizel);
    216215static HRESULT WINAPI DefaultHandler_Advise(
    217         IOleObject*        iface,
    218         IAdviseSink*       pAdvSink,
    219         DWORD*             pdwConnection);
     216            IOleObject*        iface,
     217            IAdviseSink*       pAdvSink,
     218            DWORD*             pdwConnection);
    220219static HRESULT WINAPI DefaultHandler_Unadvise(
    221         IOleObject*        iface,
    222         DWORD              dwConnection);
     220            IOleObject*        iface,
     221            DWORD              dwConnection);
    223222static HRESULT WINAPI DefaultHandler_EnumAdvise(
    224         IOleObject*        iface,
    225         IEnumSTATDATA**    ppenumAdvise);
     223            IOleObject*        iface,
     224            IEnumSTATDATA**    ppenumAdvise);
    226225static HRESULT WINAPI DefaultHandler_GetMiscStatus(
    227         IOleObject*        iface,
    228         DWORD              dwAspect,
    229         DWORD*             pdwStatus);
     226            IOleObject*        iface,
     227            DWORD              dwAspect,
     228            DWORD*             pdwStatus);
    230229static HRESULT WINAPI DefaultHandler_SetColorScheme(
    231         IOleObject*           iface,
    232         struct tagLOGPALETTE* pLogpal);
     230            IOleObject*           iface,
     231            struct tagLOGPALETTE* pLogpal);
    233232
    234233/*
     
    240239            REFIID           riid,
    241240            void**           ppvObject);
    242 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
     241static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 
    243242            IDataObject*     iface);
    244 static ULONG WINAPI DefaultHandler_IDataObject_Release(
     243static ULONG WINAPI DefaultHandler_IDataObject_Release( 
    245244            IDataObject*     iface);
    246245static HRESULT WINAPI DefaultHandler_GetData(
    247         IDataObject*     iface,
    248         LPFORMATETC      pformatetcIn,
    249         STGMEDIUM*       pmedium);
     246            IDataObject*     iface,
     247            LPFORMATETC      pformatetcIn,
     248            STGMEDIUM*       pmedium);
    250249static HRESULT WINAPI DefaultHandler_GetDataHere(
    251         IDataObject*     iface,
    252         LPFORMATETC      pformatetc,
    253         STGMEDIUM*       pmedium);
     250            IDataObject*     iface,
     251            LPFORMATETC      pformatetc,
     252            STGMEDIUM*       pmedium);
    254253static HRESULT WINAPI DefaultHandler_QueryGetData(
    255         IDataObject*     iface,
    256         LPFORMATETC      pformatetc);
     254            IDataObject*     iface,
     255            LPFORMATETC      pformatetc);
    257256static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
    258         IDataObject*     iface,
    259         LPFORMATETC      pformatectIn,
    260         LPFORMATETC      pformatetcOut);
     257            IDataObject*     iface,
     258            LPFORMATETC      pformatectIn,
     259            LPFORMATETC      pformatetcOut);
    261260static HRESULT WINAPI DefaultHandler_SetData(
    262         IDataObject*     iface,
    263         LPFORMATETC      pformatetc,
    264         STGMEDIUM*       pmedium,
    265         BOOL             fRelease);
     261            IDataObject*     iface,
     262            LPFORMATETC      pformatetc,
     263            STGMEDIUM*       pmedium,
     264            BOOL             fRelease);
    266265static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
    267         IDataObject*     iface,
    268         DWORD            dwDirection,
    269         IEnumFORMATETC** ppenumFormatEtc);
     266            IDataObject*     iface,       
     267            DWORD            dwDirection,
     268            IEnumFORMATETC** ppenumFormatEtc);
    270269static HRESULT WINAPI DefaultHandler_DAdvise(
    271         IDataObject*     iface,
    272         FORMATETC*       pformatetc,
    273         DWORD            advf,
    274         IAdviseSink*     pAdvSink,
    275         DWORD*           pdwConnection);
     270            IDataObject*     iface,
     271            FORMATETC*       pformatetc,
     272            DWORD            advf,
     273            IAdviseSink*     pAdvSink,
     274            DWORD*           pdwConnection);
    276275static HRESULT WINAPI DefaultHandler_DUnadvise(
    277         IDataObject*     iface,
    278         DWORD            dwConnection);
     276            IDataObject*     iface,
     277            DWORD            dwConnection);
    279278static HRESULT WINAPI DefaultHandler_EnumDAdvise(
    280         IDataObject*     iface,
    281         IEnumSTATDATA**  ppenumAdvise);
     279            IDataObject*     iface,
     280            IEnumSTATDATA**  ppenumAdvise);
    282281
    283282/*
     
    289288            REFIID               riid,
    290289            void**               ppvObject);
    291 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
     290static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 
    292291            IRunnableObject*     iface);
    293 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
     292static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 
    294293            IRunnableObject*     iface);
    295 static HRESULT WINAPI DefaultHandler_GetRunningClass(
     294static HRESULT WINAPI DefaultHandler_GetRunningClass(
     295            IRunnableObject*     iface,   
     296            LPCLSID              lpClsid);
     297static HRESULT WINAPI DefaultHandler_Run(
    296298            IRunnableObject*     iface,
    297         LPCLSID              lpClsid);
    298 static HRESULT WINAPI DefaultHandler_Run(
    299             IRunnableObject*     iface,
    300         IBindCtx*            pbc);
    301 static BOOL    WINAPI DefaultHandler_IsRunning(
     299            IBindCtx*            pbc);
     300static BOOL    WINAPI DefaultHandler_IsRunning(
    302301            IRunnableObject*     iface);
    303 static HRESULT WINAPI DefaultHandler_LockRunning(
    304             IRunnableObject*     iface,
    305         BOOL                 fLock,
    306         BOOL                 fLastUnlockCloses);
    307 static HRESULT WINAPI DefaultHandler_SetContainedObject(
    308             IRunnableObject*     iface,
    309         BOOL                 fContained);
     302static HRESULT WINAPI DefaultHandler_LockRunning( 
     303            IRunnableObject*     iface, 
     304            BOOL                 fLock,
     305            BOOL                 fLastUnlockCloses);
     306static HRESULT WINAPI DefaultHandler_SetContainedObject( 
     307            IRunnableObject*     iface, 
     308            BOOL                 fContained);
    310309
    311310
     
    408407   * IUnknown pointer can be returned to the outside.
    409408   */
    410   if ( (pUnkOuter!=NULL) &&
     409  if ( (pUnkOuter!=NULL) && 
    411410       (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
    412411    return CLASS_E_NOAGGREGATION;
     
    415414   * Try to construct a new instance of the class.
    416415   */
    417   newHandler = DefaultHandler_Construct(clsid,
    418                     pUnkOuter);
     416  newHandler = DefaultHandler_Construct(clsid, 
     417                                        pUnkOuter);
    419418
    420419  if (newHandler == 0)
     
    451450  if (newObject==0)
    452451    return newObject;
    453 
     452 
    454453  /*
    455454   * Initialize the virtual function table.
     
    461460
    462461  /*
    463    * Start with one reference count. The caller of this function
     462   * Start with one reference count. The caller of this function 
    464463   * must release the interface pointer when it is done.
    465464   */
     
    468467  /*
    469468   * Initialize the outer unknown
    470    * We don't keep a reference on the outer unknown since, the way
     469   * We don't keep a reference on the outer unknown since, the way 
    471470   * aggregation works, our lifetime is at least as large as it's
    472471   * lifetime.
     
    480479   * Create a datacache object.
    481480   * We aggregate with the datacache. Make sure we pass our outer
    482    * unknown as the datacache's outer unknown.
     481   * unknown as the datacache's outer unknown. 
    483482   */
    484483  CreateDataCache(newObject->outerUnknown,
    485           clsid,
    486           &IID_IUnknown,
    487           (void**)&newObject->dataCache);
     484                  clsid,
     485                  &IID_IUnknown,
     486                  (void**)&newObject->dataCache);
    488487
    489488  /*
     
    517516    ptrToDestroy->containerObj = NULL;
    518517  }
    519 
     518 
    520519  /*
    521520   * Release our reference to the data cache.
     
    586585  if ( (this==0) || (ppvObject==0) )
    587586    return E_INVALIDARG;
    588 
     587 
    589588  /*
    590589   * Initialize the return parameter.
     
    595594   * Compare the riid with the interface IDs implemented by this object.
    596595   */
    597   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     596  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    598597  {
    599598    *ppvObject = iface;
    600599  }
    601   else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
     600  else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0) 
    602601  {
    603602    *ppvObject = (IOleObject*)&(this->lpvtbl1);
    604603  }
    605   else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
     604  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 
    606605  {
    607606    *ppvObject = (IDataObject*)&(this->lpvtbl3);
    608607  }
    609   else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
     608  else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0) 
    610609  {
    611610    *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
     
    617616     */
    618617    if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
    619     return S_OK;
    620   }
    621 
     618        return S_OK;
     619  }
     620 
    622621  /*
    623622   * Check that we obtained an interface.
     
    628627    return E_NOINTERFACE;
    629628  }
    630 
     629 
    631630  /*
    632631   * Query Interface always increases the reference count by one when it is
    633    * successful.
     632   * successful. 
    634633   */
    635634  IUnknown_AddRef((IUnknown*)*ppvObject);
    636635
    637   return S_OK;;
     636  return S_OK;; 
    638637}
    639638
     
    646645 * to the outer unknown.
    647646 */
    648 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
     647static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 
    649648            IUnknown*      iface)
    650649{
     
    664663 * to the outer unknown.
    665664 */
    666 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
     665static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 
    667666            IUnknown*      iface)
    668667{
     
    683682    return 0;
    684683  }
    685 
     684 
    686685  return this->ref;
    687686}
     
    704703  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
    705704
    706   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     705  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    707706}
    708707
     
    712711 * See Windows documentation for more details on IUnknown methods.
    713712 */
    714 static ULONG WINAPI DefaultHandler_AddRef(
     713static ULONG WINAPI DefaultHandler_AddRef( 
    715714            IOleObject*        iface)
    716715{
     
    725724 * See Windows documentation for more details on IUnknown methods.
    726725 */
    727 static ULONG WINAPI DefaultHandler_Release(
     726static ULONG WINAPI DefaultHandler_Release( 
    728727            IOleObject*        iface)
    729728{
     
    742741 */
    743742static HRESULT WINAPI DefaultHandler_SetClientSite(
    744         IOleObject*        iface,
    745         IOleClientSite*    pClientSite)
     743            IOleObject*        iface,
     744            IOleClientSite*    pClientSite)
    746745{
    747746  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    777776 */
    778777static HRESULT WINAPI DefaultHandler_GetClientSite(
    779         IOleObject*        iface,
    780         IOleClientSite**   ppClientSite)
     778            IOleObject*        iface,
     779            IOleClientSite**   ppClientSite)
    781780{
    782781  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    807806 */
    808807static HRESULT WINAPI DefaultHandler_SetHostNames(
    809         IOleObject*        iface,
    810         LPCOLESTR          szContainerApp,
    811         LPCOLESTR          szContainerObj)
     808            IOleObject*        iface,
     809            LPCOLESTR          szContainerApp,
     810            LPCOLESTR          szContainerObj)
    812811{
    813812  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
    814813
    815814  TRACE("(%p, %s, %s)\n",
    816     iface,
    817     debugstr_w(szContainerApp),
    818     debugstr_w(szContainerObj));
     815        iface,
     816        debugstr_w(szContainerApp),
     817        debugstr_w(szContainerObj));
    819818
    820819  /*
    821820   * Be sure to cleanup before re-assinging the strings.
    822    */
     821   */ 
    823822  if (this->containerApp!=NULL)
    824823  {
     
    861860 */
    862861static HRESULT WINAPI DefaultHandler_Close(
    863         IOleObject*        iface,
    864         DWORD              dwSaveOption)
     862            IOleObject*        iface,
     863            DWORD              dwSaveOption)
    865864{
    866865  TRACE("()\n");
     
    876875 */
    877876static HRESULT WINAPI DefaultHandler_SetMoniker(
    878         IOleObject*        iface,
    879         DWORD              dwWhichMoniker,
    880         IMoniker*          pmk)
     877            IOleObject*        iface,
     878            DWORD              dwWhichMoniker,
     879            IMoniker*          pmk)
    881880{
    882881  TRACE("(%p, %ld, %p)\n",
    883     iface,
    884     dwWhichMoniker,
    885     pmk);
     882        iface,
     883        dwWhichMoniker,
     884        pmk);
    886885
    887886  return S_OK;
     
    896895 */
    897896static HRESULT WINAPI DefaultHandler_GetMoniker(
    898         IOleObject*        iface,
    899         DWORD              dwAssign,
    900         DWORD              dwWhichMoniker,
    901         IMoniker**         ppmk)
     897            IOleObject*        iface,
     898            DWORD              dwAssign,
     899            DWORD              dwWhichMoniker,
     900            IMoniker**         ppmk)
    902901{
    903902  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
    904903
    905904  TRACE("(%p, %ld, %ld, %p)\n",
    906     iface, dwAssign, dwWhichMoniker, ppmk);
     905        iface, dwAssign, dwWhichMoniker, ppmk);
    907906
    908907  if (this->clientSite)
    909908  {
    910909    return IOleClientSite_GetMoniker(this->clientSite,
    911                      dwAssign,
    912                      dwWhichMoniker,
    913                      ppmk);
    914 
     910                                     dwAssign,
     911                                     dwWhichMoniker,
     912                                     ppmk);
     913                             
    915914  }
    916915
     
    922921 *
    923922 * This method is meaningless if the server is not running
    924  *
     923 * 
    925924 * See Windows documentation for more details on IOleObject methods.
    926925 */
    927926static HRESULT WINAPI DefaultHandler_InitFromData(
    928         IOleObject*        iface,
    929         IDataObject*       pDataObject,
    930         BOOL               fCreation,
    931         DWORD              dwReserved)
     927            IOleObject*        iface,
     928            IDataObject*       pDataObject,
     929            BOOL               fCreation,
     930            DWORD              dwReserved)
    932931{
    933932  TRACE("(%p, %p, %d, %ld)\n",
    934     iface, pDataObject, fCreation, dwReserved);
     933        iface, pDataObject, fCreation, dwReserved);
    935934
    936935  return OLE_E_NOTRUNNING;
     
    941940 *
    942941 * This method is meaningless if the server is not running
    943  *
     942 * 
    944943 * See Windows documentation for more details on IOleObject methods.
    945944 */
    946945static HRESULT WINAPI DefaultHandler_GetClipboardData(
    947         IOleObject*        iface,
    948         DWORD              dwReserved,
    949         IDataObject**      ppDataObject)
     946            IOleObject*        iface,
     947            DWORD              dwReserved,
     948            IDataObject**      ppDataObject)
    950949{
    951950  TRACE("(%p, %ld, %p)\n",
    952     iface, dwReserved, ppDataObject);
     951        iface, dwReserved, ppDataObject);
    953952
    954953  return OLE_E_NOTRUNNING;
     
    956955
    957956static HRESULT WINAPI DefaultHandler_DoVerb(
    958         IOleObject*        iface,
    959         LONG               iVerb,
     957            IOleObject*        iface,
     958            LONG               iVerb,
    960959#ifdef __WIN32OS2__
    961         LPMSG              lpmsg,
     960            LPMSG              lpmsg,
    962961#else
    963         struct tagMSG*     lpmsg,
     962            struct tagMSG*     lpmsg,
    964963#endif
    965         IOleClientSite*    pActiveSite,
    966         LONG               lindex,
    967         HWND               hwndParent,
    968         LPCRECT            lprcPosRect)
     964            IOleClientSite*    pActiveSite,
     965            LONG               lindex,
     966            HWND               hwndParent,
     967            LPCRECT            lprcPosRect)
    969968{
    970969  FIXME(": Stub\n");
     
    977976 * The default handler implementation of this method simply delegates
    978977 * to OleRegEnumVerbs
    979  *
     978 * 
    980979 * See Windows documentation for more details on IOleObject methods.
    981980 */
    982981static HRESULT WINAPI DefaultHandler_EnumVerbs(
    983         IOleObject*        iface,
    984         IEnumOLEVERB**     ppEnumOleVerb)
     982            IOleObject*        iface,
     983            IEnumOLEVERB**     ppEnumOleVerb)
    985984{
    986985  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    992991
    993992static HRESULT WINAPI DefaultHandler_Update(
    994         IOleObject*        iface)
     993            IOleObject*        iface)
    995994{
    996995  FIXME(": Stub\n");
     
    10021001 *
    10031002 * This method is meaningless if the server is not running
    1004  *
     1003 * 
    10051004 * See Windows documentation for more details on IOleObject methods.
    10061005 */
    10071006static HRESULT WINAPI DefaultHandler_IsUpToDate(
    1008         IOleObject*        iface)
     1007            IOleObject*        iface)
    10091008{
    10101009  TRACE("(%p)\n", iface);
     
    10171016 *
    10181017 * TODO: Map to a new class ID if emulation is active.
    1019  *
     1018 * 
    10201019 * See Windows documentation for more details on IOleObject methods.
    10211020 */
    10221021static HRESULT WINAPI DefaultHandler_GetUserClassID(
    1023         IOleObject*        iface,
    1024         CLSID*             pClsid)
     1022            IOleObject*        iface,
     1023            CLSID*             pClsid)
    10251024{
    10261025  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    10441043 * The default handler implementation of this method simply delegates
    10451044 * to OleRegGetUserType
    1046  *
     1045 * 
    10471046 * See Windows documentation for more details on IOleObject methods.
    10481047 */
    10491048static HRESULT WINAPI DefaultHandler_GetUserType(
    1050         IOleObject*        iface,
    1051         DWORD              dwFormOfType,
    1052         LPOLESTR*          pszUserType)
     1049            IOleObject*        iface,
     1050            DWORD              dwFormOfType,
     1051            LPOLESTR*          pszUserType)
    10531052{
    10541053  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    10671066 */
    10681067static HRESULT WINAPI DefaultHandler_SetExtent(
    1069         IOleObject*        iface,
    1070         DWORD              dwDrawAspect,
    1071         SIZEL*             psizel)
     1068            IOleObject*        iface,
     1069            DWORD              dwDrawAspect,
     1070            SIZEL*             psizel)
    10721071{
    10731072  TRACE("(%p, %lx, (%ld x %ld))\n", iface,
     
    10851084 */
    10861085static HRESULT WINAPI DefaultHandler_GetExtent(
    1087         IOleObject*        iface,
    1088         DWORD              dwDrawAspect,
    1089         SIZEL*             psizel)
     1086            IOleObject*        iface,
     1087            DWORD              dwDrawAspect,
     1088            SIZEL*             psizel)
    10901089{
    10911090  DVTARGETDEVICE* targetDevice;
     
    10931092  HRESULT         hres;
    10941093
    1095   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1094  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    10961095
    10971096  TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
     
    11061105   *
    11071106   * Here we would build a valid DVTARGETDEVICE structure
    1108    * but, since we are calling into the data cache, we
    1109    * know it's implementation and we'll skip this
     1107   * but, since we are calling into the data cache, we 
     1108   * know it's implementation and we'll skip this 
    11101109   * extra work until later.
    11111110   */
     
    11131112
    11141113  hres = IViewObject2_GetExtent(cacheView,
    1115                 dwDrawAspect,
    1116                 -1,
    1117                 targetDevice,
    1118                 psizel);
     1114                                dwDrawAspect,
     1115                                -1,
     1116                                targetDevice,
     1117                                psizel);
    11191118
    11201119  /*
     
    11351134 */
    11361135static HRESULT WINAPI DefaultHandler_Advise(
    1137         IOleObject*        iface,
    1138         IAdviseSink*       pAdvSink,
    1139         DWORD*             pdwConnection)
     1136            IOleObject*        iface,
     1137            IAdviseSink*       pAdvSink,
     1138            DWORD*             pdwConnection)
    11401139{
    11411140  HRESULT hres = S_OK;
    1142   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1141  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    11431142
    11441143  TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
     
    11541153  if (SUCCEEDED(hres))
    11551154  {
    1156     hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
    1157                    pAdvSink,
    1158                    pdwConnection);
     1155    hres = IOleAdviseHolder_Advise(this->oleAdviseHolder, 
     1156                                   pAdvSink,
     1157                                   pdwConnection);
    11591158  }
    11601159
     
    11711170 */
    11721171static HRESULT WINAPI DefaultHandler_Unadvise(
    1173         IOleObject*        iface,
    1174         DWORD              dwConnection)
    1175 {
    1176   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1172            IOleObject*        iface,
     1173            DWORD              dwConnection)
     1174{
     1175  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    11771176
    11781177  TRACE("(%p, %ld)\n", iface, dwConnection);
     
    11861185
    11871186  return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
    1188                    dwConnection);
     1187                                   dwConnection);
    11891188}
    11901189
     
    11981197 */
    11991198static HRESULT WINAPI DefaultHandler_EnumAdvise(
    1200         IOleObject*        iface,
    1201         IEnumSTATDATA**    ppenumAdvise)
    1202 {
    1203   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1199            IOleObject*        iface,
     1200            IEnumSTATDATA**    ppenumAdvise)
     1201{
     1202  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    12041203
    12051204  TRACE("(%p, %p)\n", iface, ppenumAdvise);
     
    12181217  if (this->oleAdviseHolder==NULL)
    12191218    return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
    1220                        ppenumAdvise);
     1219                                       ppenumAdvise);
    12211220
    12221221  return S_OK;
     
    12321231 */
    12331232static HRESULT WINAPI DefaultHandler_GetMiscStatus(
    1234         IOleObject*        iface,
    1235         DWORD              dwAspect,
    1236         DWORD*             pdwStatus)
     1233            IOleObject*        iface,
     1234            DWORD              dwAspect,
     1235            DWORD*             pdwStatus)
    12371236{
    12381237  HRESULT hres;
     
    12571256 */
    12581257static HRESULT WINAPI DefaultHandler_SetColorScheme(
    1259         IOleObject*           iface,
    1260         struct tagLOGPALETTE* pLogpal)
     1258            IOleObject*           iface,
     1259            struct tagLOGPALETTE* pLogpal)
    12611260{
    12621261  TRACE("(%p, %p))\n", iface, pLogpal);
     
    12751274 */
    12761275static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
    1277             IDataObject*     iface,
     1276            IDataObject*     iface, 
    12781277           REFIID           riid,
    12791278            void**           ppvObject)
     
    12811280  _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    12821281
    1283   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1282  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    12841283}
    12851284
     
    12891288 * See Windows documentation for more details on IUnknown methods.
    12901289 */
    1291 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
     1290static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 
    12921291            IDataObject*     iface)
    12931292{
    12941293  _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    12951294
    1296   return IUnknown_AddRef(this->outerUnknown);
     1295  return IUnknown_AddRef(this->outerUnknown); 
    12971296}
    12981297
     
    13021301 * See Windows documentation for more details on IUnknown methods.
    13031302 */
    1304 static ULONG WINAPI DefaultHandler_IDataObject_Release(
     1303static ULONG WINAPI DefaultHandler_IDataObject_Release( 
    13051304            IDataObject*     iface)
    13061305{
    13071306  _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    13081307
    1309   return IUnknown_Release(this->outerUnknown);
     1308  return IUnknown_Release(this->outerUnknown); 
    13101309}
    13111310
     
    13181317 */
    13191318static HRESULT WINAPI DefaultHandler_GetData(
    1320         IDataObject*     iface,
    1321         LPFORMATETC      pformatetcIn,
    1322         STGMEDIUM*       pmedium)
     1319            IDataObject*     iface,
     1320            LPFORMATETC      pformatetcIn,
     1321            STGMEDIUM*       pmedium)
    13231322{
    13241323  IDataObject* cacheDataObject = NULL;
     
    13291328  TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
    13301329
    1331   hres = IUnknown_QueryInterface(this->dataCache,
    1332                 &IID_IDataObject,
    1333                 (void**)&cacheDataObject);
     1330  hres = IUnknown_QueryInterface(this->dataCache, 
     1331                                &IID_IDataObject,
     1332                                (void**)&cacheDataObject);
    13341333
    13351334  if (FAILED(hres))
     
    13371336
    13381337  hres = IDataObject_GetData(cacheDataObject,
    1339                  pformatetcIn,
    1340                  pmedium);
    1341 
     1338                             pformatetcIn,
     1339                             pmedium);
     1340 
    13421341  IDataObject_Release(cacheDataObject);
    1343 
     1342 
    13441343  return hres;
    13451344}
    13461345
    13471346static HRESULT WINAPI DefaultHandler_GetDataHere(
    1348         IDataObject*     iface,
    1349         LPFORMATETC      pformatetc,
    1350         STGMEDIUM*       pmedium)
     1347            IDataObject*     iface,
     1348            LPFORMATETC      pformatetc,
     1349            STGMEDIUM*       pmedium)
    13511350{
    13521351  FIXME(": Stub\n");
     
    13571356 * DefaultHandler_QueryGetData (IDataObject)
    13581357 *
    1359  * The default handler's implementation of this method delegates to
     1358 * The default handler's implementation of this method delegates to 
    13601359 * the cache.
    13611360 *
     
    13631362 */
    13641363static HRESULT WINAPI DefaultHandler_QueryGetData(
    1365         IDataObject*     iface,
    1366         LPFORMATETC      pformatetc)
     1364            IDataObject*     iface,
     1365            LPFORMATETC      pformatetc)
    13671366{
    13681367  IDataObject* cacheDataObject = NULL;
     
    13731372  TRACE("(%p, %p)\n", iface, pformatetc);
    13741373
    1375   hres = IUnknown_QueryInterface(this->dataCache,
    1376                 &IID_IDataObject,
    1377                 (void**)&cacheDataObject);
     1374  hres = IUnknown_QueryInterface(this->dataCache, 
     1375                                &IID_IDataObject,
     1376                                (void**)&cacheDataObject);
    13781377
    13791378  if (FAILED(hres))
     
    13811380
    13821381  hres = IDataObject_QueryGetData(cacheDataObject,
    1383                   pformatetc);
     1382                                  pformatetc);
    13841383
    13851384  IDataObject_Release(cacheDataObject);
    1386 
     1385 
    13871386  return hres;
    13881387}
     
    13961395 */
    13971396static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
    1398         IDataObject*     iface,
    1399         LPFORMATETC      pformatectIn,
    1400         LPFORMATETC      pformatetcOut)
     1397            IDataObject*     iface,
     1398            LPFORMATETC      pformatectIn,
     1399            LPFORMATETC      pformatetcOut)
    14011400{
    14021401  FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
     
    14081407 * DefaultHandler_SetData (IDataObject)
    14091408 *
    1410  * The default handler's implementation of this method delegates to
     1409 * The default handler's implementation of this method delegates to 
    14111410 * the cache.
    14121411 *
     
    14141413 */
    14151414static HRESULT WINAPI DefaultHandler_SetData(
    1416         IDataObject*     iface,
    1417         LPFORMATETC      pformatetc,
    1418         STGMEDIUM*       pmedium,
    1419         BOOL             fRelease)
     1415            IDataObject*     iface,
     1416            LPFORMATETC      pformatetc,
     1417            STGMEDIUM*       pmedium,
     1418            BOOL             fRelease)
    14201419{
    14211420  IDataObject* cacheDataObject = NULL;
     
    14261425  TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
    14271426
    1428   hres = IUnknown_QueryInterface(this->dataCache,
    1429                 &IID_IDataObject,
    1430                 (void**)&cacheDataObject);
     1427  hres = IUnknown_QueryInterface(this->dataCache, 
     1428                                &IID_IDataObject,
     1429                                (void**)&cacheDataObject);
    14311430
    14321431  if (FAILED(hres))
     
    14341433
    14351434  hres = IDataObject_SetData(cacheDataObject,
    1436                  pformatetc,
    1437                  pmedium,
    1438                  fRelease);
    1439 
     1435                             pformatetc,
     1436                             pmedium,
     1437                             fRelease);
     1438 
    14401439  IDataObject_Release(cacheDataObject);
    1441 
     1440 
    14421441  return hres;
    14431442}
     
    14521451 */
    14531452static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
    1454         IDataObject*     iface,
    1455         DWORD            dwDirection,
    1456         IEnumFORMATETC** ppenumFormatEtc)
     1453            IDataObject*     iface,       
     1454            DWORD            dwDirection,
     1455            IEnumFORMATETC** ppenumFormatEtc)
    14571456{
    14581457  HRESULT hres;
     
    14751474 */
    14761475static HRESULT WINAPI DefaultHandler_DAdvise(
    1477         IDataObject*     iface,
    1478         FORMATETC*       pformatetc,
    1479         DWORD            advf,
    1480         IAdviseSink*     pAdvSink,
    1481         DWORD*           pdwConnection)
     1476            IDataObject*     iface,
     1477            FORMATETC*       pformatetc,
     1478            DWORD            advf,
     1479            IAdviseSink*     pAdvSink,
     1480            DWORD*           pdwConnection)
    14821481{
    14831482  HRESULT hres = S_OK;
    1484   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    1485 
    1486   TRACE("(%p, %p, %ld, %p, %p)\n",
    1487     iface, pformatetc, advf, pAdvSink, pdwConnection);
     1483  _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 
     1484
     1485  TRACE("(%p, %p, %ld, %p, %p)\n", 
     1486        iface, pformatetc, advf, pAdvSink, pdwConnection);
    14881487
    14891488  /*
     
    14971496  if (SUCCEEDED(hres))
    14981497  {
    1499     hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
    1500                     iface,
    1501                     pformatetc,
    1502                     advf,
    1503                     pAdvSink,
    1504                     pdwConnection);
     1498    hres = IDataAdviseHolder_Advise(this->dataAdviseHolder, 
     1499                                    iface,
     1500                                    pformatetc,
     1501                                    advf,
     1502                                    pAdvSink,
     1503                                    pdwConnection);
    15051504  }
    15061505
     
    15171516 */
    15181517static HRESULT WINAPI DefaultHandler_DUnadvise(
    1519         IDataObject*     iface,
    1520         DWORD            dwConnection)
    1521 {
    1522   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
     1518            IDataObject*     iface,
     1519            DWORD            dwConnection)
     1520{
     1521  _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 
    15231522
    15241523  TRACE("(%p, %ld)\n", iface, dwConnection);
     
    15331532  }
    15341533
    1535   return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
    1536                     dwConnection);
     1534  return IDataAdviseHolder_Unadvise(this->dataAdviseHolder, 
     1535                                    dwConnection);
    15371536}
    15381537
     
    15461545 */
    15471546static HRESULT WINAPI DefaultHandler_EnumDAdvise(
    1548         IDataObject*     iface,
    1549         IEnumSTATDATA**  ppenumAdvise)
    1550 {
    1551   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
     1547            IDataObject*     iface,
     1548            IEnumSTATDATA**  ppenumAdvise)
     1549{
     1550  _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 
    15521551
    15531552  TRACE("(%p, %p)\n", iface, ppenumAdvise);
     
    15691568  if (this->dataAdviseHolder!=NULL)
    15701569  {
    1571     return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
    1572                     ppenumAdvise);
     1570    return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder, 
     1571                                        ppenumAdvise);
    15731572  }
    15741573
     
    15771576
    15781577/*********************************************************
    1579  * Methods implementation for the IRunnableObject part
     1578 * Methods implementation for the IRunnableObject part 
    15801579 * of the DefaultHandler class.
    15811580 */
     
    15931592  _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
    15941593
    1595   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1594  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    15961595}
    15971596
     
    16011600 * See Windows documentation for more details on IUnknown methods.
    16021601 */
    1603 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
     1602static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 
    16041603            IRunnableObject*     iface)
    16051604{
     
    16141613 * See Windows documentation for more details on IUnknown methods.
    16151614 */
    1616 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
     1615static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 
    16171616            IRunnableObject*     iface)
    16181617{
     
    16251624 * DefaultHandler_GetRunningClass (IRunnableObject)
    16261625 *
    1627  * According to Brockscmidt, Chapter 19, the default handler's
     1626 * According to Brockscmidt, Chapter 19, the default handler's 
    16281627 * implementation of IRunnableobject does nothing until the object
    16291628 * is actually running.
     
    16311630 * See Windows documentation for more details on IRunnableObject methods.
    16321631 */
    1633 static HRESULT WINAPI DefaultHandler_GetRunningClass(
    1634             IRunnableObject*     iface,
    1635         LPCLSID              lpClsid)
     1632static HRESULT WINAPI DefaultHandler_GetRunningClass( 
     1633            IRunnableObject*     iface,   
     1634            LPCLSID              lpClsid)
    16361635{
    16371636  TRACE("()\n");
     
    16391638}
    16401639
    1641 static HRESULT WINAPI DefaultHandler_Run(
     1640static HRESULT WINAPI DefaultHandler_Run( 
    16421641            IRunnableObject*     iface,
    1643         IBindCtx*            pbc)
     1642            IBindCtx*            pbc)
    16441643{
    16451644  FIXME(": Stub\n");
     
    16501649 * DefaultHandler_IsRunning (IRunnableObject)
    16511650 *
    1652  * According to Brockscmidt, Chapter 19, the default handler's
     1651 * According to Brockscmidt, Chapter 19, the default handler's 
    16531652 * implementation of IRunnableobject does nothing until the object
    16541653 * is actually running.
     
    16561655 * See Windows documentation for more details on IRunnableObject methods.
    16571656 */
    1658 static BOOL    WINAPI DefaultHandler_IsRunning(
     1657static BOOL    WINAPI DefaultHandler_IsRunning( 
    16591658            IRunnableObject*     iface)
    16601659{
     
    16661665 * DefaultHandler_LockRunning (IRunnableObject)
    16671666 *
    1668  * According to Brockscmidt, Chapter 19, the default handler's
     1667 * According to Brockscmidt, Chapter 19, the default handler's 
    16691668 * implementation of IRunnableobject does nothing until the object
    16701669 * is actually running.
     
    16721671 * See Windows documentation for more details on IRunnableObject methods.
    16731672 */
    1674 static HRESULT WINAPI DefaultHandler_LockRunning(
    1675             IRunnableObject*     iface,
    1676         BOOL                 fLock,
    1677         BOOL                 fLastUnlockCloses)
     1673static HRESULT WINAPI DefaultHandler_LockRunning( 
     1674            IRunnableObject*     iface, 
     1675            BOOL                 fLock,
     1676            BOOL                 fLastUnlockCloses)
    16781677{
    16791678  TRACE("()\n");
     
    16841683 * DefaultHandler_SetContainedObject (IRunnableObject)
    16851684 *
    1686  * According to Brockscmidt, Chapter 19, the default handler's
     1685 * According to Brockscmidt, Chapter 19, the default handler's 
    16871686 * implementation of IRunnableobject does nothing until the object
    16881687 * is actually running.
     
    16901689 * See Windows documentation for more details on IRunnableObject methods.
    16911690 */
    1692 static HRESULT WINAPI DefaultHandler_SetContainedObject(
    1693             IRunnableObject*     iface,
    1694         BOOL                 fContained)
     1691static HRESULT WINAPI DefaultHandler_SetContainedObject( 
     1692            IRunnableObject*     iface, 
     1693            BOOL                 fContained)
    16951694{
    16961695  TRACE("()\n");
  • trunk/src/ole32/errorinfo.c

    r6648 r6711  
    1 /* $Id: errorinfo.c,v 1.3 2001-09-05 13:17:09 bird Exp $ */
    21/*
    32 * ErrorInfo API
     
    65 *
    76 *
    8  * The errorinfo is a per-thread object. The reference is stored in the
     7 * The errorinfo is a per-thread object. The reference is stored in the 
    98 * TEB at offset 0xf80
    109 */
     
    3130    WCHAR* stringBuffer;
    3231    DWORD len;
    33 
     32   
    3433    if (in == NULL)
    35     return NULL;
     34        return NULL;
    3635    /*
    3736     * Find the lenth of the buffer passed-in in bytes.
     
    9089{
    9190    DWORD* bufferPointer;
    92 
     91   
    9392    /* NULL is a valid parameter */
    9493    if(!in) return;
     
    112111typedef struct ErrorInfoImpl
    113112{
    114     ICOM_VTABLE(IErrorInfo)     *lpvtei;
    115     ICOM_VTABLE(ICreateErrorInfo)   *lpvtcei;
    116     ICOM_VTABLE(ISupportErrorInfo)  *lpvtsei;
    117     DWORD               ref;
    118 
    119     GUID m_Guid;
    120     BSTR bstrSource;
    121     BSTR bstrDescription;
    122     BSTR bstrHelpFile;
    123     DWORD m_dwHelpContext;
     113        ICOM_VTABLE(IErrorInfo)         *lpvtei;
     114        ICOM_VTABLE(ICreateErrorInfo)   *lpvtcei;
     115        ICOM_VTABLE(ISupportErrorInfo)  *lpvtsei;
     116        DWORD                           ref;
     117       
     118        GUID m_Guid;
     119        BSTR bstrSource;
     120        BSTR bstrDescription;
     121        BSTR bstrHelpFile;
     122        DWORD m_dwHelpContext;
    124123} ErrorInfoImpl;
    125124
    126 static ICOM_VTABLE(IErrorInfo)      IErrorInfoImpl_VTable;
    127 static ICOM_VTABLE(ICreateErrorInfo)    ICreateErrorInfoImpl_VTable;
    128 static ICOM_VTABLE(ISupportErrorInfo)   ISupportErrorInfoImpl_VTable;
     125static ICOM_VTABLE(IErrorInfo)          IErrorInfoImpl_VTable;
     126static ICOM_VTABLE(ICreateErrorInfo)    ICreateErrorInfoImpl_VTable;
     127static ICOM_VTABLE(ISupportErrorInfo)   ISupportErrorInfoImpl_VTable;
    129128
    130129/*
    131130 converts a objectpointer to This
    132131 */
    133 #define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei)))
    134 #define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset);
    135 
    136 #define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei)))
    137 #define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset);
    138 
    139 #define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei)))
    140 #define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset);
     132#define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei))) 
     133#define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset); 
     134
     135#define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei))) 
     136#define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset); 
     137
     138#define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei))) 
     139#define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset); 
    141140
    142141/*
    143142 converts This to a objectpointer
    144143 */
    145 #define _IErrorInfo_(This)      (IErrorInfo*)&(This->lpvtei)
    146 #define _ICreateErrorInfo_(This)    (ICreateErrorInfo*)&(This->lpvtcei)
    147 #define _ISupportErrorInfo_(This)   (ISupportErrorInfo*)&(This->lpvtsei)
     144#define _IErrorInfo_(This)              (IErrorInfo*)&(This->lpvtei)
     145#define _ICreateErrorInfo_(This)        (ICreateErrorInfo*)&(This->lpvtcei)
     146#define _ISupportErrorInfo_(This)       (ISupportErrorInfo*)&(This->lpvtsei)
    148147
    149148IErrorInfo * IErrorInfoImpl_Constructor()
    150149{
    151     ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl));
    152     if (ei)
    153     {
    154       ei->lpvtei = &IErrorInfoImpl_VTable;
    155       ei->lpvtcei = &ICreateErrorInfoImpl_VTable;
    156       ei->lpvtsei = &ISupportErrorInfoImpl_VTable;
    157       ei->ref = 1;
    158       ei->bstrSource = NULL;
    159       ei->bstrDescription = NULL;
    160       ei->bstrHelpFile = NULL;
    161       ei->m_dwHelpContext = 0;
    162     }
    163     return (IErrorInfo *)ei;
     150        ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl));
     151        if (ei)
     152        {
     153          ei->lpvtei = &IErrorInfoImpl_VTable;
     154          ei->lpvtcei = &ICreateErrorInfoImpl_VTable;
     155          ei->lpvtsei = &ISupportErrorInfoImpl_VTable;
     156          ei->ref = 1;
     157          ei->bstrSource = NULL;
     158          ei->bstrDescription = NULL;
     159          ei->bstrHelpFile = NULL;
     160          ei->m_dwHelpContext = 0;
     161        }
     162        return (IErrorInfo *)ei;
    164163}
    165164
    166165
    167166static HRESULT WINAPI IErrorInfoImpl_QueryInterface(
    168     IErrorInfo* iface,
    169     REFIID     riid,
    170     VOID**     ppvoid)
    171 {
    172     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    173     TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid);
    174 
    175     *ppvoid = NULL;
    176 
    177     if(IsEqualIID(riid, &IID_IErrorInfo))
    178     {
    179       *ppvoid = _IErrorInfo_(This);
    180     }
    181     else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
    182     {
    183       *ppvoid = _ICreateErrorInfo_(This);
    184     }
    185     else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
    186     {
    187       *ppvoid = _ISupportErrorInfo_(This);
    188     }
    189 
    190     if(*ppvoid)
    191     {
    192       IUnknown_AddRef( (IUnknown*)*ppvoid );
    193       TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
    194       return S_OK;
    195     }
    196     TRACE("-- Interface: E_NOINTERFACE\n");
    197     return E_NOINTERFACE;
     167        IErrorInfo* iface,
     168        REFIID     riid,
     169        VOID**     ppvoid)
     170{
     171        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     172        TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid);
     173
     174        *ppvoid = NULL;
     175
     176        if(IsEqualIID(riid, &IID_IErrorInfo))
     177        {
     178          *ppvoid = _IErrorInfo_(This);
     179        }
     180        else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
     181        {
     182          *ppvoid = _ICreateErrorInfo_(This);
     183        }
     184        else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
     185        {
     186          *ppvoid = _ISupportErrorInfo_(This);
     187        }
     188
     189        if(*ppvoid)
     190        {
     191          IUnknown_AddRef( (IUnknown*)*ppvoid );
     192          TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
     193          return S_OK;
     194        }
     195        TRACE("-- Interface: E_NOINTERFACE\n");
     196        return E_NOINTERFACE;
    198197}
    199198
    200199static ULONG WINAPI IErrorInfoImpl_AddRef(
    201     IErrorInfo* iface)
    202 {
    203     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    204     TRACE("(%p)->(count=%lu)\n",This,This->ref);
    205     return InterlockedIncrement(&This->ref);
     200        IErrorInfo* iface)
     201{
     202        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     203        TRACE("(%p)->(count=%lu)\n",This,This->ref);
     204        return InterlockedIncrement(&This->ref);
    206205}
    207206
    208207static ULONG WINAPI IErrorInfoImpl_Release(
    209     IErrorInfo* iface)
    210 {
    211     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    212     TRACE("(%p)->(count=%lu)\n",This,This->ref);
    213 
    214     if (!InterlockedDecrement(&This->ref))
    215     {
    216       TRACE("-- destroying IErrorInfo(%p)\n",This);
    217       HeapFree(GetProcessHeap(),0,This);
    218       return 0;
    219     }
    220     return This->ref;
     208        IErrorInfo* iface)
     209{
     210        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     211        TRACE("(%p)->(count=%lu)\n",This,This->ref);
     212
     213        if (!InterlockedDecrement(&This->ref))
     214        {
     215          TRACE("-- destroying IErrorInfo(%p)\n",This);
     216          HeapFree(GetProcessHeap(),0,This);
     217          return 0;
     218        }
     219        return This->ref;
    221220}
    222221
    223222static HRESULT WINAPI IErrorInfoImpl_GetGUID(
    224     IErrorInfo* iface,
    225     GUID * pGUID)
    226 {
    227     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    228     TRACE("(%p)->(count=%lu)\n",This,This->ref);
    229     if(!pGUID )return E_INVALIDARG;
    230     memcpy(pGUID, &This->m_Guid, sizeof(GUID));
    231     return S_OK;
     223        IErrorInfo* iface,
     224        GUID * pGUID)
     225{
     226        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     227        TRACE("(%p)->(count=%lu)\n",This,This->ref);
     228        if(!pGUID )return E_INVALIDARG;
     229        memcpy(pGUID, &This->m_Guid, sizeof(GUID));
     230        return S_OK;
    232231}
    233232
    234233static HRESULT WINAPI IErrorInfoImpl_GetSource(
    235     IErrorInfo* iface,
    236     BSTR *pBstrSource)
    237 {
    238     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    239     TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
    240     if (pBstrSource == NULL)
    241         return E_INVALIDARG;
    242     *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource);
    243     return S_OK;
     234        IErrorInfo* iface,
     235        BSTR *pBstrSource)
     236{
     237        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     238        TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
     239        if (pBstrSource == NULL)
     240            return E_INVALIDARG;
     241        *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource);
     242        return S_OK;
    244243}
    245244
    246245static HRESULT WINAPI IErrorInfoImpl_GetDescription(
    247     IErrorInfo* iface,
    248     BSTR *pBstrDescription)
    249 {
    250     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    251 
    252     TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
    253     if (pBstrDescription == NULL)
    254         return E_INVALIDARG;
    255     *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription);
    256 
    257     return S_OK;
     246        IErrorInfo* iface,
     247        BSTR *pBstrDescription)
     248{
     249        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     250
     251        TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
     252        if (pBstrDescription == NULL)
     253            return E_INVALIDARG;
     254        *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription);
     255       
     256        return S_OK;
    258257}
    259258
    260259static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(
    261     IErrorInfo* iface,
    262     BSTR *pBstrHelpFile)
    263 {
    264     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    265 
    266     TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
    267     if (pBstrHelpFile == NULL)
    268         return E_INVALIDARG;
    269     *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile);
    270 
    271     return S_OK;
     260        IErrorInfo* iface,
     261        BSTR *pBstrHelpFile)
     262{
     263        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     264
     265        TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
     266        if (pBstrHelpFile == NULL)
     267            return E_INVALIDARG;
     268        *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile);
     269       
     270        return S_OK;
    272271}
    273272
    274273static HRESULT WINAPI IErrorInfoImpl_GetHelpContext(
    275     IErrorInfo* iface,
    276     DWORD *pdwHelpContext)
    277 {
    278     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    279     TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
    280     if (pdwHelpContext == NULL)
    281         return E_INVALIDARG;
    282     *pdwHelpContext = This->m_dwHelpContext;
    283 
    284     return S_OK;
     274        IErrorInfo* iface,
     275        DWORD *pdwHelpContext)
     276{
     277        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     278        TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
     279        if (pdwHelpContext == NULL)
     280            return E_INVALIDARG;
     281        *pdwHelpContext = This->m_dwHelpContext;
     282       
     283        return S_OK;
    285284}
    286285
     
    291290  IErrorInfoImpl_AddRef,
    292291  IErrorInfoImpl_Release,
    293 
     292 
    294293  IErrorInfoImpl_GetGUID,
    295294  IErrorInfoImpl_GetSource,
     
    301300
    302301static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface(
    303     ICreateErrorInfo* iface,
    304     REFIID     riid,
    305     VOID**     ppvoid)
    306 {
    307     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    308     TRACE("(%p)\n", This);
    309     return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
     302        ICreateErrorInfo* iface,
     303        REFIID     riid,
     304        VOID**     ppvoid)
     305{
     306        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     307        TRACE("(%p)\n", This);
     308        return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
    310309}
    311310
    312311static ULONG WINAPI ICreateErrorInfoImpl_AddRef(
    313     ICreateErrorInfo* iface)
    314 {
    315     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    316     TRACE("(%p)\n", This);
    317     return IErrorInfo_AddRef(_IErrorInfo_(This));
     312        ICreateErrorInfo* iface)
     313{
     314        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     315        TRACE("(%p)\n", This);
     316        return IErrorInfo_AddRef(_IErrorInfo_(This));
    318317}
    319318
    320319static ULONG WINAPI ICreateErrorInfoImpl_Release(
    321     ICreateErrorInfo* iface)
    322 {
    323     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    324     TRACE("(%p)\n", This);
    325     return IErrorInfo_Release(_IErrorInfo_(This));
     320        ICreateErrorInfo* iface)
     321{
     322        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     323        TRACE("(%p)\n", This);
     324        return IErrorInfo_Release(_IErrorInfo_(This));
    326325}
    327326
    328327
    329328static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID(
    330     ICreateErrorInfo* iface,
    331     REFGUID rguid)
    332 {
    333     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    334     TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
    335     memcpy(&This->m_Guid,  rguid, sizeof(GUID));
    336     return S_OK;
     329        ICreateErrorInfo* iface,
     330        REFGUID rguid)
     331{
     332        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     333        TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
     334        memcpy(&This->m_Guid,  rguid, sizeof(GUID));
     335        return S_OK;
    337336}
    338337
    339338static HRESULT WINAPI ICreateErrorInfoImpl_SetSource(
    340     ICreateErrorInfo* iface,
    341     LPOLESTR szSource)
    342 {
    343     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    344     TRACE("(%p)\n",This);
    345     if (This->bstrSource != NULL)
    346         ERRORINFO_SysFreeString(This->bstrSource);
    347     This->bstrSource = ERRORINFO_SysAllocString(szSource);
    348 
    349     return S_OK;
     339        ICreateErrorInfo* iface,
     340        LPOLESTR szSource)
     341{
     342        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     343        TRACE("(%p)\n",This);
     344        if (This->bstrSource != NULL)
     345            ERRORINFO_SysFreeString(This->bstrSource);
     346        This->bstrSource = ERRORINFO_SysAllocString(szSource);
     347       
     348        return S_OK;
    350349}
    351350
    352351static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription(
    353     ICreateErrorInfo* iface,
    354     LPOLESTR szDescription)
    355 {
    356     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    357     TRACE("(%p)\n",This);
    358     if (This->bstrDescription != NULL)
    359         ERRORINFO_SysFreeString(This->bstrDescription);
    360     This->bstrDescription = ERRORINFO_SysAllocString(szDescription);
    361 
    362     return S_OK;
     352        ICreateErrorInfo* iface,
     353        LPOLESTR szDescription)
     354{
     355        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     356        TRACE("(%p)\n",This);
     357        if (This->bstrDescription != NULL)
     358            ERRORINFO_SysFreeString(This->bstrDescription);
     359        This->bstrDescription = ERRORINFO_SysAllocString(szDescription);
     360       
     361        return S_OK;
    363362}
    364363
    365364static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(
    366     ICreateErrorInfo* iface,
    367     LPOLESTR szHelpFile)
    368 {
    369     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    370     TRACE("(%p)\n",This);
    371     if (This->bstrHelpFile != NULL)
    372         ERRORINFO_SysFreeString(This->bstrHelpFile);
    373     This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile);
    374 
    375     return S_OK;
     365        ICreateErrorInfo* iface,
     366        LPOLESTR szHelpFile)
     367{
     368        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     369        TRACE("(%p)\n",This);
     370        if (This->bstrHelpFile != NULL)
     371            ERRORINFO_SysFreeString(This->bstrHelpFile);
     372        This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile);
     373
     374        return S_OK;
    376375}
    377376
    378377static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext(
    379     ICreateErrorInfo* iface,
    380     DWORD dwHelpContext)
    381 {
    382     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    383     TRACE("(%p)\n",This);
    384     This->m_dwHelpContext = dwHelpContext;
    385 
    386     return S_OK;
     378        ICreateErrorInfo* iface,
     379        DWORD dwHelpContext)
     380{
     381        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     382        TRACE("(%p)\n",This);
     383        This->m_dwHelpContext = dwHelpContext;
     384       
     385        return S_OK;
    387386}
    388387
     
    402401
    403402static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface(
    404     ISupportErrorInfo* iface,
    405     REFIID     riid,
    406     VOID**     ppvoid)
    407 {
    408     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    409     TRACE("(%p)\n", This);
    410 
    411     return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
     403        ISupportErrorInfo* iface,
     404        REFIID     riid,
     405        VOID**     ppvoid)
     406{
     407        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     408        TRACE("(%p)\n", This);
     409       
     410        return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
    412411}
    413412
    414413static ULONG WINAPI ISupportErrorInfoImpl_AddRef(
    415     ISupportErrorInfo* iface)
    416 {
    417     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    418     TRACE("(%p)\n", This);
    419     return IErrorInfo_AddRef(_IErrorInfo_(This));
     414        ISupportErrorInfo* iface)
     415{
     416        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     417        TRACE("(%p)\n", This);
     418        return IErrorInfo_AddRef(_IErrorInfo_(This));
    420419}
    421420
    422421static ULONG WINAPI ISupportErrorInfoImpl_Release(
    423     ISupportErrorInfo* iface)
    424 {
    425     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    426     TRACE("(%p)\n", This);
    427     return IErrorInfo_Release(_IErrorInfo_(This));
     422        ISupportErrorInfo* iface)
     423{
     424        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     425        TRACE("(%p)\n", This);
     426        return IErrorInfo_Release(_IErrorInfo_(This));
    428427}
    429428
    430429
    431430static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo(
    432     ISupportErrorInfo* iface,
    433     REFIID riid)
    434 {
    435     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    436     TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
    437     return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
     431        ISupportErrorInfo* iface,
     432        REFIID riid)
     433{
     434        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     435        TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
     436        return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
    438437}
    439438
     
    449448};
    450449/***********************************************************************
    451  *      CreateErrorInfo
     450 *              CreateErrorInfo
    452451 */
    453452HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **pperrinfo)
    454453{
    455     IErrorInfo * pei;
    456     HRESULT res;
    457     TRACE("(%p): stub:\n", pperrinfo);
    458     if(! pperrinfo ) return E_INVALIDARG;
    459     if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
    460 
    461     res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
    462     IErrorInfo_Release(pei);
    463     return res;
     454        IErrorInfo * pei;
     455        HRESULT res;
     456        TRACE("(%p): stub:\n", pperrinfo);
     457        if(! pperrinfo ) return E_INVALIDARG;
     458        if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
     459       
     460        res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
     461        IErrorInfo_Release(pei);
     462        return res;
    464463}
    465464
    466465/***********************************************************************
    467  *      GetErrorInfo
     466 *              GetErrorInfo
    468467 */
    469468HRESULT WINAPI GetErrorInfo(ULONG dwReserved, IErrorInfo **pperrinfo)
    470469{
    471     TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo);
    472 
    473     if(! pperrinfo ) return E_INVALIDARG;
    474     if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE;
    475 
    476     /* clear thread error state */
    477     NtCurrentTeb()->ErrorInfo = NULL;
    478     return S_OK;
     470        TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo);
     471
     472        if(! pperrinfo ) return E_INVALIDARG;
     473        if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE;
     474
     475        /* clear thread error state */
     476        NtCurrentTeb()->ErrorInfo = NULL;
     477        return S_OK;
    479478}
    480479
    481480/***********************************************************************
    482  *      SetErrorInfo
     481 *              SetErrorInfo
    483482 */
    484483HRESULT WINAPI SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo)
    485484{
    486     IErrorInfo * pei;
    487     TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo);
    488 
    489     /* release old errorinfo */
    490     pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo;
    491     if(pei) IErrorInfo_Release(pei);
    492 
    493     /* set to new value */
    494     NtCurrentTeb()->ErrorInfo = perrinfo;
    495     if(perrinfo) IErrorInfo_AddRef(perrinfo);
    496     return S_OK;
    497 }
     485        IErrorInfo * pei;
     486        TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo);
     487
     488        /* release old errorinfo */
     489        pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo;
     490        if(pei) IErrorInfo_Release(pei);
     491
     492        /* set to new value */
     493        NtCurrentTeb()->ErrorInfo = perrinfo;
     494        if(perrinfo) IErrorInfo_AddRef(perrinfo);
     495        return S_OK;
     496}
  • trunk/src/ole32/filemoniker.c

    r6648 r6711  
    1 /* $Id: filemoniker.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    21/***************************************************************************************
    3  *                        FileMonikers implementation
     2 *                            FileMonikers implementation
    43 *
    54 *               Copyright 1999  Noomen Hamza
     
    2726    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2827
    29     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     28    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    3029     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3130     */
     
    137136{
    138137    ICOM_THIS(FileMonikerImpl,iface);
    139 
     138 
    140139  TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    141140
    142141    /* Perform a sanity check on the parameters.*/
    143142    if ( (This==0) || (ppvObject==0) )
    144     return E_INVALIDARG;
    145 
     143        return E_INVALIDARG;
     144 
    146145    /* Initialize the return parameter */
    147146  *ppvObject = 0;
     
    154153       )
    155154        *ppvObject = iface;
    156 
     155   
    157156    else if (IsEqualIID(&IID_IROTData, riid))
    158157        *ppvObject = (IROTData*)&(This->lpvtbl2);
     
    161160    if ((*ppvObject)==0)
    162161        return E_NOINTERFACE;
    163 
     162 
    164163    /* Query Interface always increases the reference count by one when it is successful */
    165164  FileMonikerImpl_AddRef(iface);
     
    213212
    214213    *pClassID = CLSID_FileMoniker;
    215 
     214       
    216215    return S_OK;
    217216}
     
    253252    if (bread!=sizeof(WORD) || wbuffer!=0)
    254253        return E_FAIL;
    255 
     254   
    256255    /* read filePath string length (plus one) */
    257256    res=IStream_Read(pStm,&length,sizeof(DWORD),&bread);
     
    269268    if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
    270269        return E_FAIL;
    271 
     270       
    272271    length--;
    273 
     272       
    274273    for(i=0;i<10;i++){
    275274        res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
     
    277276            return E_FAIL;
    278277    }
    279 
     278   
    280279    if (length>8)
    281280        length=0;
    282 
     281       
    283282    doubleLenHex=doubleLenDec=2*length;
    284283    if (length > 5)
     
    291290    if (length==0)
    292291        return res;
    293 
     292       
    294293    res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
    295294    if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex)
     
    312311
    313312    HeapFree(GetProcessHeap(),0,filePathA);
    314 
     313   
    315314    return res;
    316315}
     
    325324    /* this function saves data of this object. In the begining I thougth that I have just to write
    326325     * the filePath string on Stream. But, when I tested this function whith windows programs samples !
    327      * I noted that it was not the case. So I analysed data written by this function on Windows system and
     326     * I noted that it was not the case. So I analysed data written by this function on Windows system and 
    328327     * what did this function do exactly ! but I have no idear a bout its logic !
    329328     * I guessed data who must be written on stream wich is:
     
    334333     */
    335334
    336     ICOM_THIS(FileMonikerImpl,iface);
     335    ICOM_THIS(FileMonikerImpl,iface);       
    337336
    338337    HRESULT res;
     
    369368    /* write a DWORD set to 0xDEADFFFF: constant */
    370369    res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL);
    371 
     370       
    372371    len--;
    373372    /* write 10 times a DWORD set to 0 : constants */
    374373    for(i=0;i<10;i++)
    375374        res=IStream_Write(pStm,&zero,sizeof(WORD),NULL);
    376 
     375       
    377376    if (len>8)
    378377        len=0;
    379 
     378       
    380379    doubleLenHex=doubleLenDec=2*len;
    381380    if (len > 5)
     
    416415
    417416    /* for more details see FileMonikerImpl_Save coments */
    418 
     417   
    419418    sizeMAx =  sizeof(WORD) +           /* first WORD is 0 */
    420419               sizeof(DWORD)+           /* length of filePath including "\0" in the end of the string */
     
    426425    if (len==0 || len > 8)
    427426        return S_OK;
    428 
     427   
    429428    sizeMAx += sizeof(DWORD)+           /* size of the unicode filePath: "\0" not included */
    430429               sizeof(WORD)+            /* constant : 0x3 */
    431430               len*sizeof(WCHAR);       /* unicde filePath string */
    432 
     431   
    433432    pcbSize->s.LowPart=sizeMAx;
    434433    pcbSize->s.HighPart=0;
     
    448447    WCHAR bkSlash[]={'\\',0};
    449448    BYTE addBkSlash;
    450 
     449   
    451450    TRACE("(%p,%p)\n",This,lpszPathName);
    452451
     
    493492
    494493        *This->filePathName=0;
    495 
     494   
    496495        for(i=0;tabStr[i]!=NULL;i++)
    497496            strcatW(This->filePathName,tabStr[i]);
    498 
     497   
    499498        if (addBkSlash)
    500499            strcatW(This->filePathName,bkSlash);
     
    539538    IClassFactory *pcf=0;
    540539    IClassActivator *pca=0;
    541 
    542     ICOM_THIS(FileMonikerImpl,iface);
     540   
     541    ICOM_THIS(FileMonikerImpl,iface);   
    543542
    544543    *ppvResult=0;
     
    547546
    548547    if(pmkToLeft==NULL){
    549 
     548       
    550549        res=IBindCtx_GetRunningObjectTable(pbc,&prot);
    551550
     
    579578
    580579            res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
    581 
     580       
    582581            if (res==E_NOINTERFACE)
    583582                return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
     
    598597
    599598            FIXME("()");
    600 
     599           
    601600            /*res=GetClassFile(This->filePathName,&clsID);
    602601
     
    634633    if (pcf!=NULL)
    635634        IClassFactory_Release(pcf);
    636 
     635   
    637636    return res;
    638637}
     
    737736
    738737    if (pmkRight==NULL)
    739     return E_INVALIDARG;
     738        return E_INVALIDARG;
    740739
    741740    *ppmkComposite=0;
    742 
     741   
    743742    IMoniker_IsSystemMoniker(pmkRight,&mkSys);
    744743
     
    769768        /* the length of the composed path string  is raised by the sum of the two paths lengths  */
    770769        newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
    771 
    772       if (newStr==NULL)
    773         return E_OUTOFMEMORY;
     770       
     771          if (newStr==NULL)
     772                return E_OUTOFMEMORY;
    774773
    775774        /* new path is the concatenation of the rest of str1 and str2 */
     
    779778        if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
    780779            strcatW(newStr,bkSlash);
    781 
     780           
    782781        for(j=i;j<=lastIdx2;j++)
    783782            strcatW(newStr,strDec2[j]);
    784 
     783       
    785784        /* create a new moniker with the new string */
    786785        res=CreateFileMoniker(newStr,ppmkComposite);
     
    858857
    859858    IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath);
    860 
     859   
    861860    if (lstrcmpiW(filePath,
    862861                  This->filePathName)!=0)
    863862
    864863        return S_FALSE;
    865 
     864   
    866865    return S_OK;
    867866}
     
    880879    if (pdwHash==NULL)
    881880        return E_POINTER;
    882 
     881   
    883882    val =  This->filePathName;
    884883    len = lstrlenW(val);
     
    887886        for (i = len ; i > 0; i--) {
    888887            h = (h * 37) + val[off++];
    889     }
     888        }
    890889    } else {
    891890        /* only sample some characters */
    892     skip = len / 8;
    893     for (i = len ; i > 0; i -= skip, off += skip) {
     891        skip = len / 8;
     892        for (i = len ; i > 0; i -= skip, off += skip) {
    894893            h = (h * 39) + val[off];
    895     }
     894        }
    896895}
    897896
     
    964963        if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
    965964            return MK_E_NOOBJECT;
    966 
     965       
    967966        *pFileTime=info.ftLastWriteTime;
    968967}
     
    999998    if (pmkOther==NULL)
    1000999        return E_INVALIDARG;
    1001 
     1000   
    10021001    *ppmkPrefix=0;
    1003 
     1002   
    10041003    /* check if we have the same type of moniker */
    10051004    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
     
    10231022
    10241023        *commonPath=0;
    1025 
     1024       
    10261025        for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
    10271026                         (stringTable2[sameIdx]!=NULL) &&
     
    10421041        if (machimeNameCase && *stringTable1[sameIdx-1]=='\\')
    10431042            sameIdx--;
    1044 
     1043       
    10451044        if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
    10461045            return MK_E_NOPREFIX;
     
    10481047        for(i=0;i<sameIdx;i++)
    10491048            strcatW(commonPath,stringTable1[i]);
    1050 
     1049       
    10511050        for(i=0;i<nb1;i++)
    10521051            CoTaskMemFree(stringTable1[i]);
     
    10601059
    10611060        HeapFree(GetProcessHeap(),0,commonPath);
    1062 
     1061       
    10631062        return CreateFileMoniker(commonPath,ppmkPrefix);
    10641063    }
     
    10801079
    10811080    strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
    1082 
     1081   
    10831082    if (strgtable==NULL)
    1084     return E_OUTOFMEMORY;
    1085 
     1083        return E_OUTOFMEMORY;
     1084   
    10861085    while(str[i]!=0){
    10871086
     
    10911090
    10921091            if (strgtable[tabIndex]==NULL)
    1093             return E_OUTOFMEMORY;
     1092                return E_OUTOFMEMORY;
    10941093
    10951094            strcpyW(strgtable[tabIndex++],bSlash);
     
    11141113    }
    11151114    strgtable[tabIndex]=NULL;
    1116 
     1115   
    11171116    *stringTable=strgtable;
    1118 
     1117   
    11191118    return tabIndex;
    11201119}
     
    11301129    DWORD len1=0,len2=0,sameIdx=0,j=0;
    11311130    WCHAR back[] ={'.','.','\\',0};
    1132 
     1131   
    11331132    TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
    11341133
     
    11381137    if (pmOther==NULL)
    11391138        return E_INVALIDARG;
    1140 
     1139   
    11411140    res=CreateBindCtx(0,&bind);
    11421141    if (FAILED(res))
    1143     return res;
     1142        return res;
    11441143
    11451144    res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
    11461145    if (FAILED(res))
    1147     return res;
     1146        return res;
    11481147    res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
    11491148    if (FAILED(res))
    1150     return res;
     1149        return res;
    11511150
    11521151    len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
     
    11541153
    11551154    if (FAILED(len1) || FAILED(len2))
    1156     return E_OUTOFMEMORY;
    1157 
     1155        return E_OUTOFMEMORY;
     1156       
    11581157    /* count the number of similar items from the begin of the two paths */
    11591158    for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
    1160            (tabStr2[sameIdx]!=NULL) &&
     1159                   (tabStr2[sameIdx]!=NULL) &&
    11611160               (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
    11621161
     
    11761175    for(j=sameIdx;tabStr2[j]!=NULL;j++)
    11771176        strcatW(relPath,tabStr2[j]);
    1178 
     1177   
    11791178    res=CreateFileMoniker(relPath,ppmkRelPath);
    1180 
     1179   
    11811180    for(j=0; tabStr1[j]!=NULL;j++)
    11821181        CoTaskMemFree(tabStr1[j]);
     
    12201219
    12211220    strcpyW(*ppszDisplayName,This->filePathName);
    1222 
     1221   
    12231222    return S_OK;
    12241223}
     
    12471246    if (!pwdMksys)
    12481247        return E_POINTER;
    1249 
     1248   
    12501249    (*pwdMksys)=MKSYS_FILEMONIKER;
    12511250
     
    12841283{
    12851284    ICOM_THIS_From_IROTData(IMoniker, iface);
    1286 
     1285   
    12871286    TRACE("(%p)\n",This);
    12881287
     
    13281327    if(lpszPathName==NULL)
    13291328        return MK_E_SYNTAX;
    1330 
     1329           
    13311330    *ppmk=0;
    1332 
     1331       
    13331332    newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
    13341333
     
    13391338
    13401339    if (SUCCEEDED(hr))
    1341     hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);
     1340        hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);
    13421341    else
    13431342        HeapFree(GetProcessHeap(),0,newFileMoniker);
  • trunk/src/ole32/hglobalstream.c

    r6648 r6711  
    1 /* $Id: hglobalstream.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    21/*
    32 * HGLOBAL Stream implementation
     
    3029{
    3130  ICOM_VFIELD(IStream);  /* Needs to be the first item in the stuct
    32               * since we want to cast this in a IStream pointer */
    33 
     31                          * since we want to cast this in a IStream pointer */
     32 
    3433  /*
    3534   * Reference count
    3635   */
    37   ULONG          ref;
     36  ULONG              ref;
    3837
    3938  /*
     
    6564 */
    6665HGLOBALStreamImpl* HGLOBALStreamImpl_Construct(
    67         HGLOBAL  hGlobal,
    68         BOOL     fDeleteOnRelease);
     66                HGLOBAL  hGlobal,
     67                BOOL     fDeleteOnRelease);
    6968
    7069void HGLOBALStreamImpl_Destroy(
     
    7574
    7675HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
    77         IStream*      iface,
    78         REFIID         riid,        /* [in] */
    79         void**         ppvObject);  /* [iid_is][out] */
    80 
     76                IStream*      iface,
     77                REFIID         riid,            /* [in] */         
     78                void**         ppvObject);  /* [iid_is][out] */
     79       
    8180ULONG WINAPI HGLOBALStreamImpl_AddRef(
    82         IStream*      iface);
    83 
     81                IStream*      iface);
     82       
    8483ULONG WINAPI HGLOBALStreamImpl_Release(
    85         IStream*      iface);
    86 
    87 HRESULT WINAPI HGLOBALStreamImpl_Read(
    88             IStream*      iface,
    89         void*          pv,        /* [length_is][size_is][out] */
    90         ULONG          cb,        /* [in] */
    91         ULONG*         pcbRead);  /* [out] */
    92 
     84                IStream*      iface);
     85       
     86HRESULT WINAPI HGLOBALStreamImpl_Read( 
     87                IStream*      iface,
     88                void*          pv,        /* [length_is][size_is][out] */
     89                ULONG          cb,        /* [in] */                     
     90                ULONG*         pcbRead);  /* [out] */                   
     91       
    9392HRESULT WINAPI HGLOBALStreamImpl_Write(
    94         IStream*      iface,
    95         const void*    pv,          /* [size_is][in] */
    96         ULONG          cb,          /* [in] */
    97         ULONG*         pcbWritten); /* [out] */
    98 
    99 HRESULT WINAPI HGLOBALStreamImpl_Seek(
    100         IStream*      iface,
    101         LARGE_INTEGER   dlibMove,         /* [in] */
    102         DWORD           dwOrigin,         /* [in] */
    103         ULARGE_INTEGER* plibNewPosition); /* [out] */
    104 
    105 HRESULT WINAPI HGLOBALStreamImpl_SetSize(
    106             IStream*      iface,
    107         ULARGE_INTEGER  libNewSize);  /* [in] */
    108 
    109 HRESULT WINAPI HGLOBALStreamImpl_CopyTo(
    110         IStream*      iface,
    111         IStream*      pstm,         /* [unique][in] */
    112         ULARGE_INTEGER  cb,           /* [in] */
    113         ULARGE_INTEGER* pcbRead,      /* [out] */
    114         ULARGE_INTEGER* pcbWritten);  /* [out] */
    115 
    116 HRESULT WINAPI HGLOBALStreamImpl_Commit(
    117             IStream*      iface,
    118         DWORD           grfCommitFlags); /* [in] */
    119 
    120 HRESULT WINAPI HGLOBALStreamImpl_Revert(
    121         IStream*  iface);
    122 
    123 HRESULT WINAPI HGLOBALStreamImpl_LockRegion(
    124         IStream*     iface,
    125         ULARGE_INTEGER libOffset,   /* [in] */
    126         ULARGE_INTEGER cb,          /* [in] */
    127         DWORD          dwLockType); /* [in] */
    128 
    129 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion(
    130         IStream*     iface,
    131         ULARGE_INTEGER libOffset,   /* [in] */
    132             ULARGE_INTEGER cb,          /* [in] */
    133         DWORD          dwLockType); /* [in] */
    134 
    135 HRESULT WINAPI HGLOBALStreamImpl_Stat(
    136         IStream*     iface,
    137             STATSTG*       pstatstg,     /* [out] */
    138             DWORD          grfStatFlag); /* [in] */
    139 
    140 HRESULT WINAPI HGLOBALStreamImpl_Clone(
    141         IStream*     iface,
    142         IStream**    ppstm);       /* [out] */
     93                IStream*      iface,
     94                const void*    pv,          /* [size_is][in] */
     95                ULONG          cb,          /* [in] */         
     96                ULONG*         pcbWritten); /* [out] */         
     97       
     98HRESULT WINAPI HGLOBALStreamImpl_Seek( 
     99                IStream*      iface,
     100                LARGE_INTEGER   dlibMove,         /* [in] */
     101                DWORD           dwOrigin,         /* [in] */
     102                ULARGE_INTEGER* plibNewPosition); /* [out] */
     103       
     104HRESULT WINAPI HGLOBALStreamImpl_SetSize( 
     105                IStream*      iface,
     106                ULARGE_INTEGER  libNewSize);  /* [in] */
     107       
     108HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 
     109                IStream*      iface,
     110                IStream*      pstm,         /* [unique][in] */
     111                ULARGE_INTEGER  cb,           /* [in] */         
     112                ULARGE_INTEGER* pcbRead,      /* [out] */       
     113                ULARGE_INTEGER* pcbWritten);  /* [out] */       
     114
     115HRESULT WINAPI HGLOBALStreamImpl_Commit( 
     116                IStream*      iface,
     117                DWORD           grfCommitFlags); /* [in] */
     118       
     119HRESULT WINAPI HGLOBALStreamImpl_Revert( 
     120                IStream*  iface);
     121       
     122HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 
     123                IStream*     iface,
     124                ULARGE_INTEGER libOffset,   /* [in] */
     125                ULARGE_INTEGER cb,          /* [in] */
     126                DWORD          dwLockType); /* [in] */
     127       
     128HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 
     129                IStream*     iface,
     130                ULARGE_INTEGER libOffset,   /* [in] */
     131                ULARGE_INTEGER cb,          /* [in] */
     132                DWORD          dwLockType); /* [in] */
     133       
     134HRESULT WINAPI HGLOBALStreamImpl_Stat( 
     135                IStream*     iface,
     136                STATSTG*       pstatstg,     /* [out] */
     137                DWORD          grfStatFlag); /* [in] */
     138       
     139HRESULT WINAPI HGLOBALStreamImpl_Clone( 
     140                IStream*     iface,
     141                IStream**    ppstm);       /* [out] */
    143142
    144143
     
    169168 */
    170169HRESULT WINAPI CreateStreamOnHGlobal(
    171         HGLOBAL   hGlobal,
    172         BOOL      fDeleteOnRelease,
    173         LPSTREAM* ppstm)
     170                HGLOBAL   hGlobal,
     171                BOOL      fDeleteOnRelease,
     172                LPSTREAM* ppstm)
    174173{
    175174  HGLOBALStreamImpl* newStream;
    176175
    177176  newStream = HGLOBALStreamImpl_Construct(hGlobal,
    178                       fDeleteOnRelease);
     177                                          fDeleteOnRelease);
    179178
    180179  if (newStream!=NULL)
    181180  {
    182     return IUnknown_QueryInterface((IUnknown*)newStream,
    183                    &IID_IStream,
    184                    (void**)ppstm);
     181    return IUnknown_QueryInterface((IUnknown*)newStream, 
     182                                   &IID_IStream,
     183                                   (void**)ppstm);
    185184  }
    186185
     
    223222 * Params:
    224223 *    hGlobal          - Handle that will support the stream. can be NULL.
    225  *    fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released
     224 *    fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released 
    226225 *                       when the IStream object is destroyed.
    227226 */
    228227HGLOBALStreamImpl* HGLOBALStreamImpl_Construct(
    229         HGLOBAL  hGlobal,
    230         BOOL     fDeleteOnRelease)
     228                HGLOBAL  hGlobal,
     229                BOOL     fDeleteOnRelease)
    231230{
    232231  HGLOBALStreamImpl* newStream;
    233232
    234233  newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl));
    235 
     234 
    236235  if (newStream!=0)
    237236  {
     
    241240    ICOM_VTBL(newStream) = &HGLOBALStreamImpl_Vtbl;
    242241    newStream->ref    = 0;
    243 
     242   
    244243    /*
    245244     * Initialize the support.
     
    254253    {
    255254      newStream->supportHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD |
    256                          GMEM_SHARE, 0);
     255                                             GMEM_SHARE, 0);
    257256    }
    258 
     257   
    259258    /*
    260259     * Start the stream at the begining.
     
    262261    newStream->currentPosition.s.HighPart = 0;
    263262    newStream->currentPosition.s.LowPart = 0;
    264 
     263   
    265264    /*
    266265     * Initialize the size of the stream to the size of the handle.
     
    269268    newStream->streamSize.s.LowPart  = GlobalSize(newStream->supportHandle);
    270269  }
    271 
     270 
    272271  return newStream;
    273272}
     
    276275 * This is the destructor of the HGLOBALStreamImpl class.
    277276 *
    278  * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl
     277 * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl 
    279278 * class. The pointer passed-in to this function will be freed and will not
    280279 * be valid anymore.
     
    296295   * Finally, free the memory used-up by the class.
    297296   */
    298   HeapFree(GetProcessHeap(), 0, This);
     297  HeapFree(GetProcessHeap(), 0, This); 
    299298}
    300299
     
    304303 */
    305304HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
    306           IStream*     iface,
    307           REFIID         riid,        /* [in] */
    308           void**         ppvObject)   /* [iid_is][out] */
     305                  IStream*     iface,
     306                  REFIID         riid,        /* [in] */         
     307                  void**         ppvObject)   /* [iid_is][out] */
    309308{
    310309  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    315314  if (ppvObject==0)
    316315    return E_INVALIDARG;
    317 
     316 
    318317  /*
    319318   * Initialize the return parameter.
    320319   */
    321320  *ppvObject = 0;
    322 
     321 
    323322  /*
    324323   * Compare the riid with the interface IDs implemented by this object.
    325324   */
    326   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     325  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    327326  {
    328327    *ppvObject = (IStream*)This;
    329328  }
    330   else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0)
     329  else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 
    331330  {
    332331    *ppvObject = (IStream*)This;
    333332  }
    334 
     333 
    335334  /*
    336335   * Check that we obtained an interface.
     
    338337  if ((*ppvObject)==0)
    339338    return E_NOINTERFACE;
    340 
     339 
    341340  /*
    342341   * Query Interface always increases the reference count by one when it is
     
    344343   */
    345344  HGLOBALStreamImpl_AddRef(iface);
    346 
     345 
    347346  return S_OK;;
    348347}
     
    353352 */
    354353ULONG WINAPI HGLOBALStreamImpl_AddRef(
    355         IStream* iface)
     354                IStream* iface)
    356355{
    357356  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
    358357
    359358  This->ref++;
    360 
     359 
    361360  return This->ref;
    362361}
     
    367366 */
    368367ULONG WINAPI HGLOBALStreamImpl_Release(
    369         IStream* iface)
     368                IStream* iface)
    370369{
    371370  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
    372371
    373372  ULONG newRef;
    374 
     373 
    375374  This->ref--;
    376 
     375 
    377376  newRef = This->ref;
    378 
     377 
    379378  /*
    380379   * If the reference count goes down to 0, perform suicide.
     
    384383    HGLOBALStreamImpl_Destroy(This);
    385384  }
    386 
     385 
    387386  return newRef;
    388387}
     
    397396 * See the documentation of ISequentialStream for more info.
    398397 */
    399 HRESULT WINAPI HGLOBALStreamImpl_Read(
    400           IStream*     iface,
    401           void*          pv,        /* [length_is][size_is][out] */
    402           ULONG          cb,        /* [in] */
    403           ULONG*         pcbRead)   /* [out] */
     398HRESULT WINAPI HGLOBALStreamImpl_Read( 
     399                  IStream*     iface,
     400                  void*          pv,        /* [length_is][size_is][out] */
     401                  ULONG          cb,        /* [in] */                     
     402                  ULONG*         pcbRead)   /* [out] */                   
    404403{
    405404  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    410409
    411410  TRACE("(%p, %p, %ld, %p)\n", iface,
    412     pv, cb, pcbRead);
    413 
    414   /*
     411        pv, cb, pcbRead);
     412 
     413  /* 
    415414   * If the caller is not interested in the nubmer of bytes read,
    416415   * we use another buffer to avoid "if" statements in the code.
     
    418417  if (pcbRead==0)
    419418    pcbRead = &bytesReadBuffer;
    420 
     419 
    421420  /*
    422421   * Using the known size of the stream, calculate the number of bytes
     
    446445   */
    447446  GlobalUnlock(This->supportHandle);
    448 
     447 
    449448  /*
    450449   * The function returns S_OK if the buffer was filled completely
     
    454453  if(*pcbRead == cb)
    455454    return S_OK;
    456 
     455 
    457456  return S_FALSE;
    458457}
    459 
     458       
    460459/***
    461460 * This method is part of the ISequentialStream interface.
     
    469468 */
    470469HRESULT WINAPI HGLOBALStreamImpl_Write(
    471               IStream*     iface,
    472           const void*    pv,          /* [size_is][in] */
    473           ULONG          cb,          /* [in] */
    474           ULONG*         pcbWritten)  /* [out] */
     470                  IStream*     iface,
     471                  const void*    pv,          /* [size_is][in] */
     472                  ULONG          cb,          /* [in] */         
     473                  ULONG*         pcbWritten)  /* [out] */         
    475474{
    476475  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    481480
    482481  TRACE("(%p, %p, %ld, %p)\n", iface,
    483     pv, cb, pcbWritten);
    484 
     482        pv, cb, pcbWritten);
     483 
    485484  /*
    486485   * If the caller is not interested in the number of bytes written,
     
    489488  if (pcbWritten == 0)
    490489    pcbWritten = &bytesWritten;
    491 
     490 
    492491  if (cb == 0)
    493492  {
     
    499498    newSize.s.LowPart = This->currentPosition.s.LowPart + cb;
    500499  }
    501 
     500 
    502501  /*
    503502   * Verify if we need to grow the stream
     
    508507   IStream_SetSize(iface, newSize);
    509508  }
    510 
     509 
    511510  /*
    512511   * Lock the buffer in position and copy the data.
     
    514513  supportBuffer = GlobalLock(This->supportHandle);
    515514
    516   memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb);
     515  memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb); 
    517516
    518517  /*
     
    530529   */
    531530  GlobalUnlock(This->supportHandle);
    532 
     531 
    533532  return S_OK;
    534533}
     
    541540 *
    542541 * See the documentation of IStream for more info.
    543  */
    544 HRESULT WINAPI HGLOBALStreamImpl_Seek(
    545           IStream*      iface,
    546           LARGE_INTEGER   dlibMove,         /* [in] */
    547           DWORD           dwOrigin,         /* [in] */
    548           ULARGE_INTEGER* plibNewPosition) /* [out] */
     542 */       
     543HRESULT WINAPI HGLOBALStreamImpl_Seek( 
     544                  IStream*      iface,
     545                  LARGE_INTEGER   dlibMove,         /* [in] */
     546                  DWORD           dwOrigin,         /* [in] */
     547                  ULARGE_INTEGER* plibNewPosition) /* [out] */
    549548{
    550549  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    553552
    554553  TRACE("(%p, %ld, %ld, %p)\n", iface,
    555     dlibMove.s.LowPart, dwOrigin, plibNewPosition);
    556 
    557   /*
     554        dlibMove.s.LowPart, dwOrigin, plibNewPosition);
     555
     556  /* 
    558557   * The caller is allowed to pass in NULL as the new position return value.
    559558   * If it happens, we assign it to a dynamic variable to avoid special cases
     
    609608  plibNewPosition->s.LowPart += dlibMove.s.LowPart;
    610609  This->currentPosition = *plibNewPosition;
    611 
     610 
    612611  return S_OK;
    613612}
     
    622621 * See the documentation of IStream for more info.
    623622 */
    624 HRESULT WINAPI HGLOBALStreamImpl_SetSize(
    625                      IStream*      iface,
    626                      ULARGE_INTEGER  libNewSize)   /* [in] */
     623HRESULT WINAPI HGLOBALStreamImpl_SetSize( 
     624                                     IStream*      iface,
     625                                     ULARGE_INTEGER  libNewSize)   /* [in] */
    627626{
    628627  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    635634  if (libNewSize.s.HighPart != 0)
    636635    return STG_E_INVALIDFUNCTION;
    637 
     636 
    638637  if (This->streamSize.s.LowPart == libNewSize.s.LowPart)
    639638    return S_OK;
     
    642641   * Re allocate the HGlobal to fit the new size of the stream.
    643642   */
    644   This->supportHandle = GlobalReAlloc(This->supportHandle,
    645                       libNewSize.s.LowPart,
    646                       0);
     643  This->supportHandle = GlobalReAlloc(This->supportHandle, 
     644                                      libNewSize.s.LowPart,
     645                                      0);
    647646
    648647  This->streamSize.s.LowPart = libNewSize.s.LowPart;
    649 
     648 
    650649  return S_OK;
    651650}
    652 
     651       
    653652/***
    654653 * This method is part of the IStream interface.
     
    658657 * See the documentation of IStream for more info.
    659658 */
    660 HRESULT WINAPI HGLOBALStreamImpl_CopyTo(
    661                     IStream*      iface,
    662                     IStream*      pstm,         /* [unique][in] */
    663                     ULARGE_INTEGER  cb,           /* [in] */
    664                     ULARGE_INTEGER* pcbRead,      /* [out] */
    665                     ULARGE_INTEGER* pcbWritten)   /* [out] */
     659HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 
     660                                    IStream*      iface,
     661                                    IStream*      pstm,         /* [unique][in] */
     662                                    ULARGE_INTEGER  cb,           /* [in] */         
     663                                    ULARGE_INTEGER* pcbRead,      /* [out] */       
     664                                    ULARGE_INTEGER* pcbWritten)   /* [out] */       
    666665{
    667666  HRESULT        hr = S_OK;
     
    671670  ULARGE_INTEGER totalBytesWritten;
    672671
    673   TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm,
    674     cb.s.LowPart, pcbRead, pcbWritten);
     672  TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm, 
     673        cb.s.LowPart, pcbRead, pcbWritten);
    675674
    676675  /*
     
    694693    else
    695694      copySize = cb.s.LowPart;
    696 
     695   
    697696    IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
    698697
    699698    totalBytesRead.s.LowPart += bytesRead;
    700 
     699   
    701700    IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
    702701
     
    711710      break;
    712711    }
    713 
     712   
    714713    if (bytesRead!=copySize)
    715714      cb.s.LowPart = 0;
     
    738737 * This method is part of the IStream interface.
    739738 *
    740  * For streams supported by HGLOBALS, this function does nothing.
     739 * For streams supported by HGLOBALS, this function does nothing. 
    741740 * This is what the documentation tells us.
    742741 *
    743742 * See the documentation of IStream for more info.
    744  */
    745 HRESULT WINAPI HGLOBALStreamImpl_Commit(
    746           IStream*      iface,
    747           DWORD         grfCommitFlags)  /* [in] */
     743 */       
     744HRESULT WINAPI HGLOBALStreamImpl_Commit( 
     745                  IStream*      iface,
     746                  DWORD         grfCommitFlags)  /* [in] */
    748747{
    749748  return S_OK;
     
    753752 * This method is part of the IStream interface.
    754753 *
    755  * For streams supported by HGLOBALS, this function does nothing.
     754 * For streams supported by HGLOBALS, this function does nothing. 
    756755 * This is what the documentation tells us.
    757756 *
    758757 * See the documentation of IStream for more info.
    759  */
    760 HRESULT WINAPI HGLOBALStreamImpl_Revert(
    761           IStream* iface)
     758 */       
     759HRESULT WINAPI HGLOBALStreamImpl_Revert( 
     760                  IStream* iface)
    762761{
    763762  return S_OK;
     
    767766 * This method is part of the IStream interface.
    768767 *
    769  * For streams supported by HGLOBALS, this function does nothing.
     768 * For streams supported by HGLOBALS, this function does nothing. 
    770769 * This is what the documentation tells us.
    771770 *
    772771 * See the documentation of IStream for more info.
    773  */
    774 HRESULT WINAPI HGLOBALStreamImpl_LockRegion(
    775           IStream*       iface,
    776           ULARGE_INTEGER libOffset,   /* [in] */
    777           ULARGE_INTEGER cb,          /* [in] */
    778           DWORD          dwLockType)  /* [in] */
     772 */       
     773HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 
     774                  IStream*       iface,
     775                  ULARGE_INTEGER libOffset,   /* [in] */
     776                  ULARGE_INTEGER cb,          /* [in] */
     777                  DWORD          dwLockType)  /* [in] */
    779778{
    780779  return S_OK;
     
    784783 * This method is part of the IStream interface.
    785784 *
    786  * For streams supported by HGLOBALS, this function does nothing.
     785 * For streams supported by HGLOBALS, this function does nothing. 
    787786 * This is what the documentation tells us.
    788787 *
    789788 * See the documentation of IStream for more info.
    790  */
    791 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion(
    792           IStream*       iface,
    793           ULARGE_INTEGER libOffset,   /* [in] */
    794           ULARGE_INTEGER cb,          /* [in] */
    795           DWORD          dwLockType)  /* [in] */
     789 */       
     790HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 
     791                  IStream*       iface,
     792                  ULARGE_INTEGER libOffset,   /* [in] */
     793                  ULARGE_INTEGER cb,          /* [in] */
     794                  DWORD          dwLockType)  /* [in] */
    796795{
    797796  return S_OK;
     
    805804 *
    806805 * See the documentation of IStream for more info.
    807  */
    808 HRESULT WINAPI HGLOBALStreamImpl_Stat(
    809           IStream*     iface,
    810           STATSTG*     pstatstg,     /* [out] */
    811           DWORD        grfStatFlag)  /* [in] */
     806 */       
     807HRESULT WINAPI HGLOBALStreamImpl_Stat( 
     808                  IStream*     iface,
     809                  STATSTG*     pstatstg,     /* [out] */
     810                  DWORD        grfStatFlag)  /* [in] */
    812811{
    813812  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    821820  return S_OK;
    822821}
    823 
    824 HRESULT WINAPI HGLOBALStreamImpl_Clone(
    825           IStream*     iface,
    826           IStream**    ppstm) /* [out] */
     822       
     823HRESULT WINAPI HGLOBALStreamImpl_Clone( 
     824                  IStream*     iface,
     825                  IStream**    ppstm) /* [out] */
    827826{
    828827  FIXME("not implemented!\n");
  • trunk/src/ole32/ifs.c

    r6648 r6711  
    1 /* $Id: ifs.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    21/*
    3  *  basic interfaces
     2 *      basic interfaces
    43 *
    5  *  Copyright 1997  Marcus Meissner
     4 *      Copyright 1997  Marcus Meissner
    65 */
    76
     
    3130
    3231/******************************************************************************
    33  *      IUnknown_AddRef [VTABLE:IUNKNOWN.1]
    34  */
    35 static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) {
    36     ICOM_THIS(IUnknownImpl,iface);
    37     TRACE("(%p)->AddRef()\n",This);
    38     return ++(This->ref);
     32 *              IUnknown_AddRef [VTABLE:IUNKNOWN.1]
     33 */
     34static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) { 
     35        ICOM_THIS(IUnknownImpl,iface);
     36        TRACE("(%p)->AddRef()\n",This);
     37        return ++(This->ref);
    3938}
    4039
     
    4342 */
    4443static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) {
    45     ICOM_THIS(IUnknownImpl,iface);
    46     TRACE("(%p)->Release()\n",This);
    47     if (!--(This->ref)) {
    48         HeapFree(GetProcessHeap(),0,This);
    49         return 0;
    50     }
    51     return This->ref;
     44        ICOM_THIS(IUnknownImpl,iface);
     45        TRACE("(%p)->Release()\n",This);
     46        if (!--(This->ref)) {
     47                HeapFree(GetProcessHeap(),0,This);
     48                return 0;
     49        }
     50        return This->ref;
    5251}
    5352
     
    5655 */
    5756static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) {
    58     ICOM_THIS(IUnknownImpl,iface);
    59 
    60     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    61 
    62     if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
    63         *obj = This;
    64         return 0;
    65     }
    66     return OLE_E_ENUM_NOMORE;
    67 }
    68 
    69 static ICOM_VTABLE(IUnknown) uvt =
    70 {
    71     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    72     IUnknown_fnQueryInterface,
    73     IUnknown_fnAddRef,
    74     IUnknown_fnRelease
     57        ICOM_THIS(IUnknownImpl,iface);
     58
     59        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     60
     61        if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
     62                *obj = This;
     63                return 0;
     64        }
     65        return OLE_E_ENUM_NOMORE;
     66}
     67
     68static ICOM_VTABLE(IUnknown) uvt = 
     69{
     70        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     71        IUnknown_fnQueryInterface,
     72        IUnknown_fnAddRef,
     73        IUnknown_fnRelease
    7574};
    7675
     
    8079LPUNKNOWN
    8180IUnknown_Constructor() {
    82     IUnknownImpl*   unk;
    83 
    84     unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl));
    85     ICOM_VTBL(unk)  = &uvt;
    86     unk->ref    = 1;
    87     return (LPUNKNOWN)unk;
     81        IUnknownImpl*   unk;
     82
     83        unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl));
     84        ICOM_VTBL(unk)  = &uvt;
     85        unk->ref        = 1;
     86        return (LPUNKNOWN)unk;
    8887}
    8988
     
    101100
    102101/******************************************************************************
    103  *      IMalloc16_QueryInterface    [COMPOBJ.500]
     102 *              IMalloc16_QueryInterface        [COMPOBJ.500]
    104103 */
    105104HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
    106105        ICOM_THIS(IMalloc16Impl,iface);
    107106
    108     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    109     if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
    110         !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
    111     ) {
    112         *obj = This;
    113         return 0;
    114     }
    115     return OLE_E_ENUM_NOMORE;
    116 }
    117 
    118 /******************************************************************************
    119  *      IMalloc16_AddRef    [COMPOBJ.501]
     107        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     108        if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
     109                !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
     110        ) {
     111                *obj = This;
     112                return 0;
     113        }
     114        return OLE_E_ENUM_NOMORE;
     115}
     116
     117/******************************************************************************
     118 *              IMalloc16_AddRef        [COMPOBJ.501]
    120119 */
    121120ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) {
    122121        ICOM_THIS(IMalloc16Impl,iface);
    123     TRACE("(%p)->AddRef()\n",This);
    124     return 1; /* cannot be freed */
    125 }
    126 
    127 /******************************************************************************
    128  *      IMalloc16_Release   [COMPOBJ.502]
     122        TRACE("(%p)->AddRef()\n",This);
     123        return 1; /* cannot be freed */
     124}
     125
     126/******************************************************************************
     127 *              IMalloc16_Release       [COMPOBJ.502]
    129128 */
    130129ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) {
    131130        ICOM_THIS(IMalloc16Impl,iface);
    132     TRACE("(%p)->Release()\n",This);
    133     return 1; /* cannot be freed */
     131        TRACE("(%p)->Release()\n",This);
     132        return 1; /* cannot be freed */
    134133}
    135134
     
    139138SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
    140139        ICOM_THIS(IMalloc16Impl,iface);
    141     TRACE("(%p)->Alloc(%ld)\n",This,cb);
     140        TRACE("(%p)->Alloc(%ld)\n",This,cb);
    142141        return MapLS( HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, cb ) );
    143142}
     
    166165DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,SEGPTR pv)
    167166{
    168     ICOM_CTHIS(IMalloc16Impl,iface);
     167        ICOM_CTHIS(IMalloc16Impl,iface);
    169168        TRACE("(%p)->GetSize(%08lx)\n",This,pv);
    170169        return HeapSize( GetProcessHeap(), HEAP_WINE_SEGPTR, MapSL(pv) );
     
    176175INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) {
    177176        ICOM_CTHIS(IMalloc16,iface);
    178     TRACE("(%p)->DidAlloc(%p)\n",This,pv);
    179     return (INT16)-1;
     177        TRACE("(%p)->DidAlloc(%p)\n",This,pv);
     178        return (INT16)-1;
    180179}
    181180
     
    185184LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) {
    186185        ICOM_THIS(IMalloc16Impl,iface);
    187     TRACE("(%p)->HeapMinimize()\n",This);
    188     return NULL;
     186        TRACE("(%p)->HeapMinimize()\n",This);
     187        return NULL;
    189188}
    190189
     
    196195LPMALLOC16
    197196IMalloc16_Constructor() {
    198     IMalloc16Impl*  This;
    199         HMODULE16   hcomp = GetModuleHandle16("COMPOBJ");
    200 
    201     This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);
     197        IMalloc16Impl*  This;
     198        HMODULE16       hcomp = GetModuleHandle16("COMPOBJ");
     199
     200        This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);
    202201        if (!msegvt16) {
    203202            msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16));
     
    214213            VTENT(HeapMinimize);
    215214#undef VTENT
    216     }
     215        }
    217216        ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16);
    218     This->ref = 1;
    219     return (LPMALLOC16)SEGPTR_GET(This);
     217        This->ref = 1;
     218        return (LPMALLOC16)SEGPTR_GET(This);
    220219}
    221220#endif
     
    231230
    232231/******************************************************************************
    233  *      IMalloc32_QueryInterface    [VTABLE]
     232 *              IMalloc32_QueryInterface        [VTABLE]
    234233 */
    235234static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) {
    236     ICOM_THIS(IMalloc32Impl,iface);
    237 
    238     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    239     if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
    240         !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
    241     ) {
    242         *obj = This;
    243         return S_OK;
    244     }
    245     return OLE_E_ENUM_NOMORE;
    246 }
    247 
    248 /******************************************************************************
    249  *      IMalloc32_AddRef    [VTABLE]
     235        ICOM_THIS(IMalloc32Impl,iface);
     236
     237        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     238        if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
     239                !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
     240        ) {
     241                *obj = This;
     242                return S_OK;
     243        }
     244        return OLE_E_ENUM_NOMORE;
     245}
     246
     247/******************************************************************************
     248 *              IMalloc32_AddRef        [VTABLE]
    250249 */
    251250static ULONG WINAPI IMalloc_fnAddRef(LPMALLOC iface) {
    252     ICOM_THIS(IMalloc32Impl,iface);
    253     TRACE("(%p)->AddRef()\n",This);
    254     return 1; /* cannot be freed */
    255 }
    256 
    257 /******************************************************************************
    258  *      IMalloc32_Release   [VTABLE]
     251        ICOM_THIS(IMalloc32Impl,iface);
     252        TRACE("(%p)->AddRef()\n",This);
     253        return 1; /* cannot be freed */
     254}
     255
     256/******************************************************************************
     257 *              IMalloc32_Release       [VTABLE]
    259258 */
    260259static ULONG WINAPI IMalloc_fnRelease(LPMALLOC iface) {
    261     ICOM_THIS(IMalloc32Impl,iface);
    262     TRACE("(%p)->Release()\n",This);
    263     return 1; /* cannot be freed */
     260        ICOM_THIS(IMalloc32Impl,iface);
     261        TRACE("(%p)->Release()\n",This);
     262        return 1; /* cannot be freed */
    264263}
    265264
     
    268267 */
    269268static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface,DWORD cb) {
    270     LPVOID addr;
    271     ICOM_THIS(IMalloc32Impl,iface);
    272     addr = HeapAlloc(GetProcessHeap(),0,cb);
    273     TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr);
    274     return addr;
     269        LPVOID addr;
     270        ICOM_THIS(IMalloc32Impl,iface);
     271        addr = HeapAlloc(GetProcessHeap(),0,cb);
     272        TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr);
     273        return addr;
    275274}
    276275
     
    279278 */
    280279static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) {
    281     ICOM_THIS(IMalloc32Impl,iface);
    282     TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);
    283     return HeapReAlloc(GetProcessHeap(),0,pv,cb);
     280        ICOM_THIS(IMalloc32Impl,iface);
     281        TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);
     282        return HeapReAlloc(GetProcessHeap(),0,pv,cb);
    284283}
    285284
     
    288287 */
    289288static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) {
    290     ICOM_THIS(IMalloc32Impl,iface);
    291     TRACE("(%p)->Free(%p)\n",This,pv);
    292     HeapFree(GetProcessHeap(),0,pv);
     289        ICOM_THIS(IMalloc32Impl,iface);
     290        TRACE("(%p)->Free(%p)\n",This,pv);
     291        HeapFree(GetProcessHeap(),0,pv);
    293292}
    294293
     
    297296 */
    298297static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) {
    299     ICOM_CTHIS(IMalloc,iface);
    300     TRACE("(%p)->GetSize(%p)\n",This,pv);
    301     return HeapSize(GetProcessHeap(),0,pv);
     298        ICOM_CTHIS(IMalloc,iface);
     299        TRACE("(%p)->GetSize(%p)\n",This,pv);
     300        return HeapSize(GetProcessHeap(),0,pv);
    302301}
    303302
     
    306305 */
    307306static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) {
    308     ICOM_CTHIS(IMalloc32Impl,iface);
    309     TRACE("(%p)->DidAlloc(%p)\n",This,pv);
    310     return -1;
     307        ICOM_CTHIS(IMalloc32Impl,iface);
     308        TRACE("(%p)->DidAlloc(%p)\n",This,pv);
     309        return -1;
    311310}
    312311
     
    315314 */
    316315static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) {
    317     ICOM_THIS(IMalloc32Impl,iface);
    318     TRACE("(%p)->HeapMinimize()\n",This);
    319 }
    320 
    321 static ICOM_VTABLE(IMalloc) VT_IMalloc32 =
     316        ICOM_THIS(IMalloc32Impl,iface);
     317        TRACE("(%p)->HeapMinimize()\n",This);
     318}
     319
     320static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 
    322321{
    323322    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    338337LPMALLOC
    339338IMalloc_Constructor() {
    340     IMalloc32Impl* This;
    341 
    342     This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl));
    343     ICOM_VTBL(This) = &VT_IMalloc32;
    344     This->ref = 1;
    345     return (LPMALLOC)This;
     339        IMalloc32Impl* This;
     340
     341        This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl));
     342        ICOM_VTBL(This) = &VT_IMalloc32;
     343        This->ref = 1;
     344        return (LPMALLOC)This;
    346345}
    347346
     
    351350
    352351/******************************************************************************
    353  *      IsValidInterface    [OLE32.78]
     352 *              IsValidInterface        [OLE32.78]
    354353 *
    355354 * RETURNS
     
    357356 */
    358357BOOL WINAPI IsValidInterface(
    359     LPUNKNOWN punk  /* [in] interface to be tested */
     358        LPUNKNOWN punk  /* [in] interface to be tested */
    360359) {
    361     return !(
    362         IsBadReadPtr(punk,4)                    ||
    363         IsBadReadPtr(ICOM_VTBL(punk),4)             ||
     360        return !(
     361                IsBadReadPtr(punk,4)                                    ||
     362                IsBadReadPtr(ICOM_VTBL(punk),4)                         ||
    364363#ifdef __WIN32OS2__
    365         IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9)   ||
    366         IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface)
     364                IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9)       ||
     365                IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface)
    367366#else
    368         IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9) ||
    369         IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface)
     367                IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9) ||
     368                IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface)
    370369#endif
    371     );
    372 }
     370        );
     371}
  • trunk/src/ole32/initole32.cpp

    r6648 r6711  
    1 /* $Id: initole32.cpp,v 1.3 2001-09-05 13:17:10 bird Exp $
     1/*
    22 * DLL entry point
    33 *
     
    5252   case DLL_THREAD_ATTACH:
    5353   case DLL_THREAD_DETACH:
    54     return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
     54        return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    5555
    5656   case DLL_PROCESS_DETACH:
    5757        OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    58     return TRUE;
     58        return TRUE;
    5959   }
    6060   return FALSE;
     
    8282      case 0 :
    8383      {
    84     dllHandle = RegisterLxDll(hModule, LibMainOLE32, (PVOID)&ole32os2_PEResTab);
    85          if(dllHandle == 0)
    86         return 0UL;
     84        dllHandle = RegisterLxDll(hModule, LibMainOLE32, (PVOID)&ole32os2_PEResTab);
     85         if(dllHandle == 0) 
     86                return 0UL;
    8787
    8888         break;
     
    9090      case 1 :
    9191         if(dllHandle) {
    92         UnregisterLxDll(dllHandle);
     92                UnregisterLxDll(dllHandle);
    9393         }
    9494         break;
  • trunk/src/ole32/initterm.cpp

    r6648 r6711  
    1 /* $Id: initterm.cpp,v 1.11 2001-09-05 13:17:10 bird Exp $
    2  *
     1/*
    32 * DLL entry point
    43 *
  • trunk/src/ole32/itemmoniker.c

    r6648 r6711  
    1 /* $Id: itemmoniker.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */
    21/***************************************************************************************
    3  *                        ItemMonikers implementation
     2 *                            ItemMonikers implementation
    43 *
    54 *           Copyright 1999  Noomen Hamza
     
    2625    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2726
    28     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     27    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    2928     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3029     */
     
    3635
    3736    LPOLESTR itemDelimiter; /* Delimiter string */
    38 
     37   
    3938} ItemMonikerImpl;
    4039
     
    141140  /* Perform a sanity check on the parameters.*/
    142141    if ( (This==0) || (ppvObject==0) )
    143     return E_INVALIDARG;
    144 
     142        return E_INVALIDARG;
     143 
    145144  /* Initialize the return parameter */
    146145  *ppvObject = 0;
     
    153152     )
    154153      *ppvObject = iface;
    155 
     154 
    156155    else if (IsEqualIID(&IID_IROTData, riid))
    157156        *ppvObject = (IROTData*)&(This->lpvtbl2);
     
    160159    if ((*ppvObject)==0)
    161160        return E_NOINTERFACE;
    162 
     161 
    163162   /* Query Interface always increases the reference count by one when it is successful */
    164163  ItemMonikerImpl_AddRef(iface);
     
    209208    if (pClassID==NULL)
    210209        return E_POINTER;
    211 
     210           
    212211    *pClassID = CLSID_ItemMoniker;
    213 
     212       
    214213    return S_OK;
    215214}
     
    343342
    344343    /* for more details see ItemMonikerImpl_Save coments */
    345 
     344   
    346345    pcbSize->s.LowPart =  sizeof(DWORD) + /* DWORD which contains delimiter length */
    347346                        delimiterLength + /* item delimiter string */
     
    363362    int sizeStr1=lstrlenW(lpszItem), sizeStr2;
    364363    static const OLECHAR emptystr[1];
    365     LPCOLESTR   delim;
     364    LPCOLESTR   delim;
    366365
    367366    TRACE("(%p,%p)\n",This,lpszItem);
     
    374373    This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1));
    375374    if (!This->itemName)
    376     return E_OUTOFMEMORY;
     375        return E_OUTOFMEMORY;
    377376    strcpyW(This->itemName,lpszItem);
    378377
    379378    if (!lpszDelim)
    380     FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
     379        FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
    381380
    382381    delim = lpszDelim ? lpszDelim : emptystr;
     
    385384    This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1));
    386385    if (!This->itemDelimiter) {
    387     HeapFree(GetProcessHeap(),0,This->itemName);
    388     return E_OUTOFMEMORY;
     386        HeapFree(GetProcessHeap(),0,This->itemName);
     387        return E_OUTOFMEMORY;
    389388    }
    390389    strcpyW(This->itemDelimiter,delim);
     
    420419{
    421420    ICOM_THIS(ItemMonikerImpl,iface);
    422 
     421   
    423422    HRESULT   res;
    424423    IID    refid=IID_IOleItemContainer;
     
    467466    if(pmkToLeft==NULL)
    468467        return E_INVALIDARG;
    469 
     468       
    470469    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
    471470
     
    497496
    498497    *ppmkReduced=iface;
    499 
     498   
    500499    return MK_S_REDUCED_TO_SELF;
    501500}
     
    517516
    518517    if ((ppmkComposite==NULL)||(pmkRight==NULL))
    519     return E_POINTER;
     518        return E_POINTER;
    520519
    521520    *ppmkComposite=0;
    522 
     521   
    523522    IMoniker_IsSystemMoniker(pmkRight,&mkSys);
    524523
     
    530529        /* if pmkRight is a composite whose leftmost component is an anti-moniker,           */
    531530        /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
    532 
     531       
    533532         if(mkSys==MKSYS_GENERICCOMPOSITE){
    534533
     
    548547                tempMkComposite=iface;
    549548                IMoniker_AddRef(iface);
    550 
     549               
    551550                while(IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL)==S_OK){
    552551
     
    605604    if (pmkOtherMoniker==NULL)
    606605        return S_FALSE;
    607 
     606   
    608607    /* This method returns S_OK if both monikers are item monikers and their display names are */
    609608    /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */
     
    620619    IMoniker_GetDisplayName(iface,bind,NULL,&dispName1);
    621620    IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2);
    622 
     621   
    623622    if (lstrcmpW(dispName1,dispName2)!=0)
    624623        return S_FALSE;
    625 
     624   
    626625    return S_OK;
    627626}
     
    640639    if (pdwHash==NULL)
    641640        return E_POINTER;
    642 
     641   
    643642    val =  This->itemName;
    644643    len = lstrlenW(val);
     
    650649    } else {
    651650        /* only sample some characters */
    652     skip = len / 8;
    653     for (i = len ; i > 0; i -= skip, off += skip) {
     651        skip = len / 8;
     652        for (i = len ; i > 0; i -= skip, off += skip) {
    654653            h = (h * 39) + val[off];
    655     }
     654        }
    656655    }
    657656
     
    699698        /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/
    700699        /* passing the string contained within this moniker. */
    701 
     700       
    702701        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
    703702
     
    780779
    781780        *ppmkPrefix=iface;
    782 
     781       
    783782        IMoniker_AddRef(iface);
    784 
     783       
    785784        return MK_S_US;
    786785    }
     
    802801
    803802    *ppmkRelPath=0;
    804 
     803   
    805804    return MK_E_NOTBINDABLE;
    806805}
     
    832831    strcpyW(*ppszDisplayName,This->itemDelimiter);
    833832    strcatW(*ppszDisplayName,This->itemName);
    834 
     833   
    835834    return S_OK;
    836835}
     
    886885    if (!pwdMksys)
    887886        return E_POINTER;
    888 
     887   
    889888    (*pwdMksys)=MKSYS_ITEMMONIKER;
    890889
     
    923922{
    924923    ICOM_THIS_From_IROTData(IMoniker, iface);
    925 
     924   
    926925    TRACE("(%p)\n",iface);
    927926
     
    942941
    943942/******************************************************************************
    944  *        CreateItemMoniker16   [OLE2.28]
     943 *        CreateItemMoniker16   [OLE2.28]
    945944 ******************************************************************************/
    946945HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR  lpszItem,LPMONIKER* ppmk)
     
    953952
    954953/******************************************************************************
    955  *        CreateItemMoniker [OLE.55]
     954 *        CreateItemMoniker     [OLE.55]
    956955 ******************************************************************************/
    957956HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR  lpszItem, LPMONIKER * ppmk)
  • trunk/src/ole32/memlockbytes.c

    r6648 r6711  
    1 /* $Id: memlockbytes.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */
    21/******************************************************************************
    32 *
     
    2625{
    2726  /*
    28    * Needs to be the first item in the stuct
     27   * Needs to be the first item in the stuct 
    2928   * since we want to cast this in an ILockBytes pointer
    3029   */
     
    189188  HGLOBALLockBytesImpl* newLockBytes;
    190189  newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl));
    191 
     190 
    192191  if (newLockBytes!=0)
    193192  {
     
    197196    ICOM_VTBL(newLockBytes) = &HGLOBALLockBytesImpl_Vtbl;
    198197    newLockBytes->ref    = 0;
    199 
     198 
    200199    /*
    201200     * Initialize the support.
     
    399398   * The function returns S_OK if the specified number of bytes were read
    400399   * or the end of the array was reached.
    401    * It returns STG_E_READFAULT if the number of bytes to read does not equal
     400   * It returns STG_E_READFAULT if the number of bytes to read does not equal 
    402401   * the number of bytes actually read.
    403402   */
     
    504503  if (libNewSize.s.HighPart != 0)
    505504    return STG_E_INVALIDFUNCTION;
    506 
     505 
    507506  if (This->byteArraySize.s.LowPart == libNewSize.s.LowPart)
    508507    return S_OK;
     
    519518
    520519  This->byteArraySize.s.LowPart = libNewSize.s.LowPart;
    521 
     520 
    522521  return S_OK;
    523522}
  • trunk/src/ole32/moniker.c

    r6648 r6711  
    1 /* $Id: moniker.c,v 1.3 2001-09-05 13:17:10 bird Exp $ */
    21/*
    3  *  Monikers
     2 *      Monikers
    43 *
    5  *  Copyright 1998  Marcus Meissner
     4 *      Copyright 1998  Marcus Meissner
    65 *      Copyright 1999  Noomen Hamza
    76 */
     
    2322#include "compobj_private.h"
    2423
     24#ifdef __WIN32OS2__
     25#undef FIXME
     26#undef TRACE
     27#ifdef DEBUG
     28#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     29#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     30#else
     31#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     32#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     33#endif
     34#endif
     35
    2536DEFAULT_DEBUG_CHANNEL(ole);
    2637
     
    4758    DWORD      runObjTabLastIndx;  /* first free index element in the table.        */
    4859    DWORD      runObjTabRegister; /* registration key of the next registered object */
    49 
     60   
    5061} RunningObjectTableImpl;
    5162
     
    137148{
    138149    TRACE("()\n");
    139 
     150   
    140151    if (runningObjectTableInstance==NULL)
    141152        return E_INVALIDARG;
     
    170181            if (( This->runObjTab[i].regTypeObj &  ROTFLAGS_REGISTRATIONKEEPSALIVE) != 0)
    171182                IUnknown_Release(This->runObjTab[i].pObj);
    172 
     183 
    173184            IMoniker_Release(This->runObjTab[i].pmkObj);
    174185        }
     
    230241    if (runningObjectTableInstance==NULL)
    231242        return E_POINTER;
    232 
     243   
    233244    RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance);
    234245
     
    271282    This->runObjTab[This->runObjTabLastIndx].identRegObj = This->runObjTabRegister;
    272283    CoFileTimeNow(&(This->runObjTab[This->runObjTabLastIndx].lastModifObj));
    273 
     284   
    274285    /* gives a registration identifier to the registered object*/
    275286    (*pdwRegister)= This->runObjTabRegister;
     
    278289
    279290        FIXME("runObjTabRegister: %ld is out of data limite \n",This->runObjTabRegister);
    280     return E_FAIL;
     291        return E_FAIL;
    281292}
    282293    This->runObjTabRegister++;
    283294    This->runObjTabLastIndx++;
    284 
     295   
    285296    if (This->runObjTabLastIndx == This->runObjTabSize){ /* table is full ! so it must be resized */
    286297
     
    296307
    297308    IMoniker_AddRef(pmkObjectName);
    298 
     309   
    299310    return res;
    300311}
     
    322333
    323334    IMoniker_Release(This->runObjTab[index].pmkObj);
    324 
     335   
    325336    /* remove the object from the table */
    326337    for(j=index; j<This->runObjTabLastIndx-1; j++)
    327338        This->runObjTab[j]= This->runObjTab[j+1];
    328 
     339   
    329340    This->runObjTabLastIndx--;
    330341
     
    337348HRESULT WINAPI RunningObjectTableImpl_IsRunning(  IRunningObjectTable* iface,
    338349                                                  IMoniker *pmkObjectName)  /* Pointer to the moniker of the object whose status is desired */
    339 {
     350{   
    340351    ICOM_THIS(RunningObjectTableImpl,iface);
    341352
     
    359370    if (ppunkObject==NULL)
    360371        return E_POINTER;
    361 
     372   
    362373    *ppunkObject=0;
    363374
     
    394405    return S_OK;
    395406}
    396 
     407   
    397408/***********************************************************************
    398409 *        RunningObjectTable_GetTimeOfLastChange
     
    448459        /* search object identified by a register identifier */
    449460        for(i=0;((i<This->runObjTabLastIndx)&&(This->runObjTab[i].identRegObj!=identReg));i++);
    450 
     461   
    451462    if (i==This->runObjTabLastIndx)  return S_FALSE;
    452463
     
    457468
    458469/******************************************************************************
    459  *      GetRunningObjectTable16 [OLE2.30]
     470 *              GetRunningObjectTable16 [OLE2.30]
    460471 */
    461472HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
    462473{
    463     FIXME("(%ld,%p),stub!\n",reserved,pprot);
     474        FIXME("(%ld,%p),stub!\n",reserved,pprot);
    464475    return E_NOTIMPL;
    465476}
     
    491502HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
    492503{
    493   IRunnableObject   *runable;
     504  IRunnableObject       *runable;
    494505  ICOM_THIS(IRunnableObject,pUnknown);
    495   LRESULT       ret;
     506  LRESULT               ret;
    496507
    497508#ifdef __WIN32OS2__
     
    502513
    503514  ret = IRunnableObject_QueryInterface(This,&IID_IRunnableObject,(LPVOID*)&runable);
    504   if (ret)
    505     return 0; /* Appears to return no error. */
     515  if (ret) 
     516        return 0; /* Appears to return no error. */
    506517  ret  = IRunnableObject_Run(runable,NULL);
    507518  IRunnableObject_Release(runable);
     
    513524 */
    514525HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
    515                 LPDWORD pchEaten, LPMONIKER *ppmk)
     526                                LPDWORD pchEaten, LPMONIKER *ppmk)
    516527{
    517528    FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk);
    518529    if (!(IsValidInterface((LPUNKNOWN) pbc)))
    519     return E_INVALIDARG;
     530        return E_INVALIDARG;
    520531
    521532    return MK_E_SYNTAX;
  • trunk/src/ole32/ole2.c

    r6648 r6711  
    1 /* $Id: ole2.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    3  *  OLE2 library
    4  *
    5  *  Copyright 1995  Martin von Loewis
     2 *      OLE2 library
     3 *
     4 *      Copyright 1995  Martin von Loewis
    65 *      Copyright 1999  Francis Beaudet
    7  *      Copyright 1999  Noel Borthwick
     6 *      Copyright 1999  Noel Borthwick 
    87 */
    98
     
    3332
    3433/******************************************************************************
    35  * These are static/global variables and internal data structures that the
     34 * These are static/global variables and internal data structures that the 
    3635 * OLE module uses to maintain it's state.
    3736 */
     
    9594
    9695/******************************************************************************
    97  * These are the prototypes of miscelaneous utility methods
     96 * These are the prototypes of miscelaneous utility methods 
    9897 */
    9998static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue);
     
    124123static void            OLEDD_UnInitialize();
    125124static void            OLEDD_InsertDropTarget(
    126             DropTargetNode* nodeToAdd);
     125                        DropTargetNode* nodeToAdd);
    127126static DropTargetNode* OLEDD_ExtractDropTarget(
    128127                         HWND hwndOfTarget);
     
    130129                         HWND hwndOfTarget);
    131130static LRESULT WINAPI  OLEDD_DragTrackerWindowProc(
    132              HWND   hwnd,
    133             UINT   uMsg,
    134              WPARAM wParam,
    135             LPARAM   lParam);
     131                         HWND   hwnd,
     132                        UINT   uMsg,
     133                         WPARAM wParam,
     134                        LPARAM   lParam);
    136135static void OLEDD_TrackMouseMove(
    137136                         TrackerWindowInfo* trackerInfo,
    138             POINT            mousePos,
    139             DWORD              keyState);
     137                        POINT            mousePos,
     138                        DWORD              keyState);
    140139static void OLEDD_TrackStateChange(
    141140                         TrackerWindowInfo* trackerInfo,
    142             POINT            mousePos,
    143             DWORD              keyState);
     141                        POINT            mousePos,
     142                        DWORD              keyState);
    144143static DWORD OLEDD_GetButtonState();
    145144
    146145
    147146/******************************************************************************
    148  *      OleBuildVersion [OLE2.1]
     147 *              OleBuildVersion [OLE2.1]
    149148 */
    150149DWORD WINAPI OleBuildVersion(void)
     
    169168
    170169  /*
    171    * If the CoInitializeEx call failed, the OLE libraries can't be
     170   * If the CoInitializeEx call failed, the OLE libraries can't be 
    172171   * initialized.
    173172   */
    174173  if (FAILED(hr))
    175     return hr;
     174    return hr;   
    176175
    177176  /*
     
    185184  if (OLE_moduleLockCount==0)
    186185{
    187     /*
     186    /* 
    188187     * Initialize the libraries.
    189188     */
     
    209208   * Then, we increase the lock count on the OLE module.
    210209   */
    211   OLE_moduleLockCount++;
     210  OLE_moduleLockCount++; 
    212211
    213212  return hr;
     
    215214
    216215/******************************************************************************
    217  *      CoGetCurrentProcess [COMPOBJ.34] [OLE2.2][OLE32.108]
     216 *              CoGetCurrentProcess     [COMPOBJ.34] [OLE2.2][OLE32.108]
    218217 *
    219218 * NOTES
     
    222221DWORD WINAPI CoGetCurrentProcess(void)
    223222{
    224     return GetCurrentProcessId();
     223        return GetCurrentProcessId();
    225224}
    226225
    227226/******************************************************************************
    228  *      OleUninitialize [OLE2.3] [OLE32.131]
     227 *              OleUninitialize [OLE2.3] [OLE32.131]
    229228 */
    230229void WINAPI OleUninitialize(void)
     
    256255     */
    257256    OLEDD_UnInitialize();
    258 
     257   
    259258    /*
    260259     * OLE shared menu
     
    262261    OLEMenu_UnInitialize();
    263262  }
    264 
     263 
    265264  /*
    266265   * Then, uninitialize the COM libraries.
     
    272271//imessagefilter.cpp
    273272/******************************************************************************
    274  *      CoRegisterMessageFilter [OLE32.38]
     273 *              CoRegisterMessageFilter [OLE32.38]
    275274 */
    276275HRESULT WINAPI CoRegisterMessageFilter(
    277     LPMESSAGEFILTER lpMessageFilter,    /* [in] Pointer to interface */
    278     LPMESSAGEFILTER *lplpMessageFilter  /* [out] Indirect pointer to prior instance if non-NULL */
     276    LPMESSAGEFILTER lpMessageFilter,    /* [in] Pointer to interface */
     277    LPMESSAGEFILTER *lplpMessageFilter  /* [out] Indirect pointer to prior instance if non-NULL */
    279278) {
    280279    FIXME("stub\n");
    281280    if (lplpMessageFilter) {
    282     *lplpMessageFilter = NULL;
     281        *lplpMessageFilter = NULL;
    283282    }
    284283    return S_OK;
     
    287286
    288287/******************************************************************************
    289  *      OleInitializeWOW    [OLE32.109]
     288 *              OleInitializeWOW        [OLE32.109]
    290289 */
    291290HRESULT WINAPI OleInitializeWOW(DWORD x) {
     
    298297 */
    299298HRESULT WINAPI RegisterDragDrop16(
    300     HWND16 hwnd,
    301     LPDROPTARGET pDropTarget
     299        HWND16 hwnd,
     300        LPDROPTARGET pDropTarget
    302301) {
    303     FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
    304     return S_OK;
     302        FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
     303        return S_OK;
    305304}
    306305
     
    309308 */
    310309HRESULT WINAPI RegisterDragDrop(
    311     HWND hwnd,
    312     LPDROPTARGET pDropTarget)
     310        HWND hwnd,
     311        LPDROPTARGET pDropTarget)
    313312{
    314313  DropTargetNode* dropTargetInfo;
     
    342341  dropTargetInfo->dropTarget  = pDropTarget;
    343342  IDropTarget_AddRef(dropTargetInfo->dropTarget);
    344 
     343 
    345344  OLEDD_InsertDropTarget(dropTargetInfo);
    346345
    347     return S_OK;
     346        return S_OK;
    348347}
    349348
     
    352351 */
    353352HRESULT WINAPI RevokeDragDrop16(
    354     HWND16 hwnd
     353        HWND16 hwnd
    355354) {
    356     FIXME("(0x%04x),stub!\n",hwnd);
    357     return S_OK;
     355        FIXME("(0x%04x),stub!\n",hwnd);
     356        return S_OK;
    358357}
    359358
     
    362361 */
    363362HRESULT WINAPI RevokeDragDrop(
    364     HWND hwnd)
     363        HWND hwnd)
    365364{
    366365  DropTargetNode* dropTargetInfo;
     
    384383   */
    385384  IDropTarget_Release(dropTargetInfo->dropTarget);
    386   HeapFree(GetProcessHeap(), 0, dropTargetInfo);
    387 
    388     return S_OK;
     385  HeapFree(GetProcessHeap(), 0, dropTargetInfo); 
     386
     387        return S_OK;
    389388}
    390389
     
    397396 * way they are registered.
    398397 */
    399 HRESULT WINAPI OleRegGetUserType(
    400     REFCLSID clsid,
    401     DWORD dwFormOfType,
    402     LPOLESTR* pszUserType)
     398HRESULT WINAPI OleRegGetUserType( 
     399        REFCLSID clsid,
     400        DWORD dwFormOfType,
     401        LPOLESTR* pszUserType)
    403402{
    404403  char    keyName[60];
     
    428427   */
    429428  hres = RegOpenKeyA(HKEY_CLASSES_ROOT,
    430              keyName,
    431              &clsidKey);
     429                     keyName,
     430                     &clsidKey);
    432431
    433432  if (hres != ERROR_SUCCESS)
     
    440439
    441440  hres = RegQueryValueExA(clsidKey,
    442               "",
    443               NULL,
    444               &dwKeyType,
    445               NULL,
    446               &cbData);
     441                          "",
     442                          NULL,
     443                          &dwKeyType,
     444                          NULL,
     445                          &cbData);
    447446
    448447  if (hres!=ERROR_SUCCESS)
     
    474473
    475474  hres = RegQueryValueExA(clsidKey,
    476               "",
    477               NULL,
    478               &dwKeyType,
    479               buffer,
    480               &cbData);
     475                          "",
     476                          NULL,
     477                          &dwKeyType,
     478                          buffer,
     479                          &cbData);
    481480
    482481  RegCloseKey(clsidKey);
    483482
    484 
     483 
    485484  if (hres!=ERROR_SUCCESS)
    486485  {
     
    528527
    529528  hwndTrackWindow = CreateWindowA(OLEDD_DRAGTRACKERCLASS,
    530                     "TrackerWindow",
    531                     WS_POPUP,
    532                     CW_USEDEFAULT, CW_USEDEFAULT,
    533                     CW_USEDEFAULT, CW_USEDEFAULT,
    534                     0,
    535                     0,
    536                     0,
    537                     (LPVOID)&trackerInfo);
     529                                    "TrackerWindow",
     530                                    WS_POPUP,
     531                                    CW_USEDEFAULT, CW_USEDEFAULT,
     532                                    CW_USEDEFAULT, CW_USEDEFAULT,
     533                                    0,
     534                                    0,
     535                                    0,
     536                                    (LPVOID)&trackerInfo);
    538537
    539538  if (hwndTrackWindow!=0)
     
    549548    while (!trackerInfo.trackingDone && GetMessageA(&msg, 0, 0, 0) )
    550549    {
    551       if ( (msg.message >= WM_KEYFIRST) &&
    552        (msg.message <= WM_KEYLAST) )
     550      if ( (msg.message >= WM_KEYFIRST) && 
     551           (msg.message <= WM_KEYLAST) )
    553552      {
    554     /*
    555     * When keyboard messages are sent to windows on this thread, we
    556     * want to ignore notify the drop source that the state changed.
    557     * in the case of the Escape key, we also notify the drop source
    558     * we give it a special meaning.
    559     */
    560     if ( (msg.message==WM_KEYDOWN) &&
    561          (msg.wParam==VK_ESCAPE) )
    562     {
    563       trackerInfo.escPressed = TRUE;
    564     }
    565 
    566     /*
    567     * Notify the drop source.
    568      */
    569     OLEDD_TrackStateChange(&trackerInfo,
    570                    msg.pt,
    571                    OLEDD_GetButtonState());
     553        /*
     554        * When keyboard messages are sent to windows on this thread, we
     555        * want to ignore notify the drop source that the state changed.
     556        * in the case of the Escape key, we also notify the drop source
     557        * we give it a special meaning.
     558        */
     559        if ( (msg.message==WM_KEYDOWN) &&
     560             (msg.wParam==VK_ESCAPE) )
     561        {
     562          trackerInfo.escPressed = TRUE;
     563        }
     564
     565        /*
     566        * Notify the drop source.
     567         */       
     568        OLEDD_TrackStateChange(&trackerInfo,
     569                               msg.pt,
     570                               OLEDD_GetButtonState());
    572571      }
    573572      else
    574573      {
    575     /*
    576     * Dispatch the messages only when it's not a keyboard message.
    577     */
    578     DispatchMessageA(&msg);
     574        /*
     575        * Dispatch the messages only when it's not a keyboard message.
     576        */
     577        DispatchMessageA(&msg);
    579578      }
    580579    }
     
    634633   */
    635634  result = RegOpenKeyA(HKEY_CLASSES_ROOT,
    636                keyName,
    637                &clsidKey);
     635                       keyName,
     636                       &clsidKey);
    638637
    639638  if (result != ERROR_SUCCESS)
     
    644643   */
    645644  result = RegOpenKeyA(clsidKey,
    646                "MiscStatus",
    647                &miscStatusKey);
    648 
    649 
     645                       "MiscStatus",
     646                       &miscStatusKey);
     647
     648 
    650649  if (result != ERROR_SUCCESS)
    651650  {
     
    665664
    666665  result = RegOpenKeyA(miscStatusKey,
    667                keyName,
    668                &aspectKey);
    669 
     666                       keyName,
     667                       &aspectKey);
     668 
    670669  if (result == ERROR_SUCCESS)
    671670  {
     
    687686 */
    688687HRESULT WINAPI OleSetContainedObject(
    689   LPUNKNOWN pUnknown,
     688  LPUNKNOWN pUnknown, 
    690689  BOOL      fContained)
    691690{
     
    696695
    697696  hres = IUnknown_QueryInterface(pUnknown,
    698                 &IID_IRunnableObject,
    699                 (void**)&runnable);
     697                                &IID_IRunnableObject,
     698                                (void**)&runnable);
    700699
    701700  if (SUCCEEDED(hres))
     
    715714 */
    716715HRESULT WINAPI OleLoad(
    717   LPSTORAGE       pStg,
    718   REFIID          riid,
    719   LPOLECLIENTSITE pClientSite,
     716  LPSTORAGE       pStg, 
     717  REFIID          riid, 
     718  LPOLECLIENTSITE pClientSite, 
    720719  LPVOID*         ppvObj)
    721720{
     
    726725
    727726  TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj);
    728 
     727 
    729728  /*
    730729   * TODO, Conversion ... OleDoAutoConvert
     
    740739   */
    741740  hres = CoCreateInstance(&storageInfo.clsid,
    742               NULL,
    743               CLSCTX_INPROC_HANDLER,
    744               &IID_IOleObject,
    745               (void**)&oleObject);
     741                          NULL,
     742                          CLSCTX_INPROC_HANDLER,
     743                          &IID_IOleObject,
     744                          (void**)&oleObject);
    746745
    747746  /*
     
    752751  {
    753752    hres = OleCreateDefaultHandler(&storageInfo.clsid,
    754                    NULL,
    755                    &IID_IOleObject,
    756                    (void**)&oleObject);
     753                                   NULL,
     754                                   &IID_IOleObject,
     755                                   (void**)&oleObject);
    757756  }
    758757
     
    772771   */
    773772  hres = IOleObject_QueryInterface(oleObject,
    774                    &IID_IPersistStorage,
    775                    (void**)&persistStorage);
    776 
    777   if (SUCCEEDED(hres))
     773                                   &IID_IPersistStorage,
     774                                   (void**)&persistStorage);
     775
     776  if (SUCCEEDED(hres)) 
    778777  {
    779778    IPersistStorage_Load(persistStorage, pStg);
     
    828827  {
    829828    IStorage_Commit(pStg,
    830             STGC_DEFAULT);
    831   }
    832 
     829                    STGC_DEFAULT);
     830  }
     831 
    833832  return hres;
    834833}
     
    838837 *              OleLockRunning        [OLE32.114]
    839838 */
    840 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses)
     839HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 
    841840{
    842841  IRunnableObject* runnable = NULL;
     
    846845
    847846  hres = IUnknown_QueryInterface(pUnknown,
    848                 &IID_IRunnableObject,
    849                 (void**)&runnable);
     847                                &IID_IRunnableObject,
     848                                (void**)&runnable);
    850849
    851850  if (SUCCEEDED(hres))
     
    903902  pHookItem->tid = tid;
    904903  pHookItem->hHeap = GetProcessHeap();
    905 
     904 
    906905  /* Install a thread scope message hook for WH_GETMESSAGE */
    907906  pHookItem->GetMsg_hHook = SetWindowsHookExA( WH_GETMESSAGE, OLEMenu_GetMsgProc,
     
    919918  pHookItem->next = hook_list;
    920919  hook_list = pHookItem;
    921 
     920 
    922921  return TRUE;
    923 
     922 
    924923CLEANUP:
    925924  /* Unhook any hooks */
     
    930929  /* Release the hook table entry */
    931930  HeapFree(pHookItem->hHeap, 0, pHookItem );
    932 
     931 
    933932  return FALSE;
    934933}
     
    995994      return pHookItem;
    996995  }
    997 
     996 
    998997  return NULL;
    999998}
     
    10161015  {
    10171016    HMENU hsubmenu;
    1018 
     1017     
    10191018    /*  Is the current item a submenu? */
    10201019    if ( (hsubmenu = GetSubMenu(hMainMenu, i)) )
     
    10631062  if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor->hmenuCombined, hmenu,  &nPos ) )
    10641063    return FALSE;
    1065 
     1064 
    10661065  /* The group widths array has counts for the number of elements
    10671066   * in the groups File, Edit, Container, Object, Window, Help.
     
    10961095  OleMenuHookItem *pHookItem = NULL;
    10971096  WORD fuFlags;
    1098 
     1097 
    10991098  TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam );
    11001099
     
    11021101  if ( HC_ACTION != code )
    11031102    goto NEXTHOOK;
    1104 
     1103     
    11051104  /* Retrieve the current message being dispatched from lParam */
    11061105  pMsg = (LPCWPSTRUCT)lParam;
     
    11321131      goto NEXTHOOK;
    11331132    }
    1134 
     1133   
    11351134    case WM_INITMENUPOPUP:
    11361135    {
     
    11391138      break;
    11401139    }
    1141 
     1140   
    11421141    case WM_MENUSELECT:
    11431142    {
     
    11521151      break;
    11531152    }
    1154 
     1153   
    11551154    case WM_DRAWITEM:
    11561155    {
     
    11721171                  pMsg->message, pMsg->wParam, pMsg->lParam );
    11731172  }
    1174 
     1173   
    11751174NEXTHOOK:
    11761175  if ( pOleMenuDescriptor )
    11771176    GlobalUnlock( hOleMenu );
    1178 
     1177 
    11791178  /* Lookup the hook item for the current thread */
    11801179  if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
     
    11841183    return 0;
    11851184  }
    1186 
     1185 
    11871186  /* Pass on the message to the next hooker */
    11881187  return CallNextHookEx( pHookItem->CallWndProc_hHook, code, wParam, lParam );
     
    12011200  OleMenuHookItem *pHookItem = NULL;
    12021201  WORD wCode;
    1203 
     1202 
    12041203  TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam );
    12051204
     
    12071206  if ( HC_ACTION != code )
    12081207    goto NEXTHOOK;
    1209 
     1208     
    12101209  /* Retrieve the current message being dispatched from lParam */
    12111210  pMsg = (LPMSG)lParam;
     
    12461245    pMsg->hwnd = pOleMenuDescriptor->hwndActiveObject;
    12471246  }
    1248 
     1247   
    12491248NEXTHOOK:
    12501249  if ( pOleMenuDescriptor )
    12511250    GlobalUnlock( hOleMenu );
    1252 
     1251 
    12531252  /* Lookup the hook item for the current thread */
    12541253  if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
     
    12581257    return FALSE;
    12591258  }
    1260 
     1259 
    12611260  /* Pass on the message to the next hooker */
    12621261  return CallNextHookEx( pHookItem->GetMsg_hHook, code, wParam, lParam );
     
    12961295  for ( i = 0; i < 6; i++ )
    12971296    pOleMenuDescriptor->mgw.width[i] = lpMenuWidths->width[i];
    1298 
     1297 
    12991298  pOleMenuDescriptor->hmenuCombined = hmenuCombined;
    13001299  pOleMenuDescriptor->bIsServerItem = FALSE;
    13011300  GlobalUnlock( hOleMenu );
    1302 
     1301     
    13031302  return hOleMenu;
    13041303}
     
    13131312  if ( hmenuDescriptor )
    13141313    GlobalFree( hmenuDescriptor );
    1315     return S_OK;
     1314        return S_OK;
    13161315}
    13171316
     
    13221321 * OLE should install context sensitive help F1 filtering for the app when
    13231322 * these are non null.
    1324  *
     1323 * 
    13251324 * PARAMS:
    13261325 *     hOleMenu         Handle to composite menu descriptor
     
    13501349  {
    13511350     FIXME("(%x, %x, %x, %p, %p), Context sensitive help filtering not implemented!\n",
    1352     (unsigned int)hOleMenu,
    1353     hwndFrame,
    1354     hwndActiveObject,
    1355     lpFrame,
    1356     lpActiveObject);
     1351        (unsigned int)hOleMenu,
     1352        hwndFrame,
     1353        hwndActiveObject,
     1354        lpFrame,
     1355        lpActiveObject);
    13571356  }
    13581357
     
    13701369    if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) )
    13711370  return E_FAIL;
    1372 
     1371       
    13731372    /* Get the menu descriptor */
    13741373    pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu );
     
    13821381    GlobalUnlock( hOleMenu );
    13831382    pOleMenuDescriptor = NULL;
    1384 
     1383   
    13851384    /* Add a menu descriptor windows property to the frame window */
    13861385    SetPropA( hwndFrame, "PROP_OLEMenuDescriptor", hOleMenu );
     
    13951394    if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) )
    13961395      return E_FAIL;
    1397 
     1396   
    13981397    /* Remove the menu descriptor property from the frame window */
    13991398    RemovePropA( hwndFrame, "PROP_OLEMenuDescriptor" );
    14001399  }
    1401 
     1400     
    14021401  return S_OK;
    14031402}
     
    14201419#endif
    14211420    {
    1422     WARN_(accel)("invalid accel handle=%04x\n", hAccel);
    1423     return FALSE;
     1421        WARN_(accel)("invalid accel handle=%04x\n", hAccel);
     1422        return FALSE;
    14241423    }
    14251424    if((lpMsg->message != WM_KEYDOWN &&
    1426     lpMsg->message != WM_KEYUP &&
    1427     lpMsg->message != WM_SYSKEYDOWN &&
    1428     lpMsg->message != WM_SYSKEYUP &&
    1429     lpMsg->message != WM_CHAR)) return FALSE;
     1425        lpMsg->message != WM_KEYUP &&
     1426        lpMsg->message != WM_SYSKEYDOWN &&
     1427        lpMsg->message != WM_SYSKEYUP &&
     1428        lpMsg->message != WM_CHAR)) return FALSE;
    14301429
    14311430    TRACE_(accel)("hAccel=%04x, cAccelEntries=%d,"
    1432         "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n",
    1433         hAccel, cAccelEntries,
    1434         lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
     1431                "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n",
     1432                hAccel, cAccelEntries,
     1433                lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
    14351434    for(i = 0; i < cAccelEntries; i++)
    14361435    {
    1437     if(lpAccelTbl[i].key != lpMsg->wParam)
    1438         continue;
    1439 
    1440     if(lpMsg->message == WM_CHAR)
    1441     {
    1442         if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY))
    1443         {
    1444         TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff);
    1445         goto found;
    1446         }
    1447     }
    1448     else
    1449     {
    1450         if(lpAccelTbl[i].fVirt & FVIRTKEY)
    1451         {
    1452         INT mask = 0;
    1453         TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
    1454                 lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff);
    1455         if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
    1456         if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
    1457         if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
    1458         if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
    1459         TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n");
    1460         }
    1461         else
    1462         {
    1463         if(!(lpMsg->lParam & 0x01000000))  /* no special_key */
    1464         {
    1465             if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000))
    1466             {                              /* ^^ ALT pressed */
    1467             TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff);
    1468             goto found;
    1469             }
    1470         }
    1471         }
    1472     }
    1473     }
     1436        if(lpAccelTbl[i].key != lpMsg->wParam)
     1437            continue;
     1438
     1439        if(lpMsg->message == WM_CHAR)
     1440        {
     1441            if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY))
     1442            {
     1443                TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff);
     1444                goto found;
     1445            }
     1446        }
     1447        else
     1448        {
     1449            if(lpAccelTbl[i].fVirt & FVIRTKEY)
     1450            {
     1451                INT mask = 0;
     1452                TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
     1453                                lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff);
     1454                if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
     1455                if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
     1456                if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
     1457                if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
     1458                TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n");
     1459            }
     1460            else
     1461            {
     1462                if(!(lpMsg->lParam & 0x01000000))  /* no special_key */
     1463                {
     1464                    if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000))
     1465                    {                                                  /* ^^ ALT pressed */
     1466                        TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff);
     1467                        goto found;
     1468                    }
     1469                }
     1470            }
     1471        }
     1472    }   
    14741473
    14751474    WARN_(accel)("couldn't translate accelerator key\n");
     
    14911490    case TYMED_HGLOBAL:
    14921491    {
    1493       if ( (pmedium->pUnkForRelease==0) &&
    1494        (pmedium->u.hGlobal!=0) )
    1495     GlobalFree(pmedium->u.hGlobal);
     1492      if ( (pmedium->pUnkForRelease==0) && 
     1493           (pmedium->u.hGlobal!=0) )
     1494        GlobalFree(pmedium->u.hGlobal);
    14961495
    14971496      pmedium->u.hGlobal = 0;
     
    15021501      if (pmedium->u.lpszFileName!=0)
    15031502      {
    1504     if (pmedium->pUnkForRelease==0)
    1505     {
    1506       DeleteFileW(pmedium->u.lpszFileName);
    1507     }
    1508 
    1509     CoTaskMemFree(pmedium->u.lpszFileName);
     1503        if (pmedium->pUnkForRelease==0)
     1504        {
     1505          DeleteFileW(pmedium->u.lpszFileName);
     1506        }
     1507       
     1508        CoTaskMemFree(pmedium->u.lpszFileName);
    15101509      }
    15111510
     
    15171516      if (pmedium->u.pstm!=0)
    15181517      {
    1519     IStream_Release(pmedium->u.pstm);
     1518        IStream_Release(pmedium->u.pstm);
    15201519      }
    15211520
     
    15271526      if (pmedium->u.pstg!=0)
    15281527      {
    1529     IStorage_Release(pmedium->u.pstg);
     1528        IStorage_Release(pmedium->u.pstg);
    15301529      }
    15311530
     
    15351534    case TYMED_GDI:
    15361535    {
    1537       if ( (pmedium->pUnkForRelease==0) &&
    1538        (pmedium->u.hGlobal!=0) )
    1539     DeleteObject(pmedium->u.hGlobal);
     1536      if ( (pmedium->pUnkForRelease==0) && 
     1537           (pmedium->u.hGlobal!=0) )
     1538        DeleteObject(pmedium->u.hGlobal);
    15401539
    15411540      pmedium->u.hGlobal = 0;
     
    15441543    case TYMED_MFPICT:
    15451544    {
    1546       if ( (pmedium->pUnkForRelease==0) &&
    1547        (pmedium->u.hMetaFilePict!=0) )
     1545      if ( (pmedium->pUnkForRelease==0) && 
     1546           (pmedium->u.hMetaFilePict!=0) )
    15481547      {
    1549     LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict);
    1550     DeleteMetaFile(pMP->hMF);
    1551     GlobalUnlock(pmedium->u.hMetaFilePict);
    1552     GlobalFree(pmedium->u.hMetaFilePict);
     1548        LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict);
     1549        DeleteMetaFile(pMP->hMF);
     1550        GlobalUnlock(pmedium->u.hMetaFilePict);
     1551        GlobalFree(pmedium->u.hMetaFilePict);
    15531552      }
    15541553
     
    15581557    case TYMED_ENHMF:
    15591558    {
    1560       if ( (pmedium->pUnkForRelease==0) &&
    1561        (pmedium->u.hEnhMetaFile!=0) )
     1559      if ( (pmedium->pUnkForRelease==0) && 
     1560           (pmedium->u.hEnhMetaFile!=0) )
    15621561      {
    1563     DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
     1562        DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
    15641563      }
    15651564
     
    15991598    wndClass.hbrBackground = 0;
    16001599    wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS;
    1601 
     1600 
    16021601    RegisterClassA (&wndClass);
    16031602}
     
    16651664  /*
    16661665   * If we get here, we have found a spot for our item. The parentNodeLink
    1667    * pointer points to the pointer that we have to modify.
     1666   * pointer points to the pointer that we have to modify. 
    16681667   * The curNode should be NULL. We just have to establish the link and Voila!
    16691668   */
     
    17121711    {
    17131712      /*
    1714        * The item was found in the list. Detach it from it's parent and
     1713       * The item was found in the list. Detach it from it's parent and 
    17151714       * re-insert it's kids in the tree.
    17161715       */
     
    17281727      if (curNode->nextDropTarget!=NULL)
    17291728      {
    1730     OLEDD_InsertDropTarget(curNode->nextDropTarget);
     1729        OLEDD_InsertDropTarget(curNode->nextDropTarget);
    17311730      }
    17321731
     
    18021801 */
    18031802static LRESULT WINAPI OLEDD_DragTrackerWindowProc(
    1804              HWND   hwnd,
    1805             UINT   uMsg,
    1806              WPARAM wParam,
    1807             LPARAM   lParam)
     1803                         HWND   hwnd,
     1804                        UINT   uMsg,
     1805                         WPARAM wParam,
     1806                        LPARAM   lParam)
    18081807{
    18091808  switch (uMsg)
     
    18131812      LPCREATESTRUCTA createStruct = (LPCREATESTRUCTA)lParam;
    18141813
    1815       SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams);
    1816 
    1817 
     1814      SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 
     1815
     1816     
    18181817      break;
    18191818    }
     
    19101909   * DragOver notification
    19111910   */
    1912   if ( (trackerInfo->curDragTarget != 0) &&
     1911  if ( (trackerInfo->curDragTarget != 0) && 
    19131912       (trackerInfo->curDragTargetHWND==hwndNewTarget) )
    19141913  {
    19151914    POINTL  mousePosParam;
    1916 
     1915   
    19171916    /*
    19181917     * The documentation tells me that the coordinate should be in the target
     
    19221921    mousePosParam.x = mousePos.x;
    19231922    mousePosParam.y = mousePos.y;
    1924 
     1923   
    19251924    IDropTarget_DragOver(trackerInfo->curDragTarget,
    1926             keyState,
    1927             mousePosParam,
    1928             trackerInfo->pdwEffect);
     1925                        keyState,
     1926                        mousePosParam,
     1927                        trackerInfo->pdwEffect);
    19291928  }
    19301929  else
    19311930  {
    19321931    DropTargetNode* newDropTargetNode = 0;
    1933 
     1932   
    19341933    /*
    19351934     * If we changed window, we have to notify our old target and check for
     
    19401939      IDropTarget_DragLeave(trackerInfo->curDragTarget);
    19411940    }
    1942 
     1941   
    19431942    /*
    19441943     * Make sure we're hovering over a window.
     
    19511950      HWND nexttar = hwndNewTarget;
    19521951      do {
    1953     newDropTargetNode = OLEDD_FindDropTarget(nexttar);
     1952        newDropTargetNode = OLEDD_FindDropTarget(nexttar);
    19541953      } while (!newDropTargetNode && (nexttar = GetParent(nexttar)) != 0);
    19551954      if(nexttar) hwndNewTarget = nexttar;
     
    19571956      trackerInfo->curDragTargetHWND = hwndNewTarget;
    19581957      trackerInfo->curDragTarget     = newDropTargetNode ? newDropTargetNode->dropTarget : 0;
    1959 
     1958     
    19601959      /*
    19611960       * If there is, notify it that we just dragged-in
     
    19631962      if (trackerInfo->curDragTarget!=0)
    19641963      {
    1965     POINTL  mousePosParam;
    1966 
    1967     /*
    1968     * The documentation tells me that the coordinate should be in the target
    1969     * window's coordinate space. However, the tests I made tell me the
    1970     * coordinates should be in screen coordinates.
    1971     */
    1972     mousePosParam.x = mousePos.x;
    1973     mousePosParam.y = mousePos.y;
    1974 
    1975     IDropTarget_DragEnter(trackerInfo->curDragTarget,
    1976                   trackerInfo->dataObject,
    1977                   keyState,
    1978                   mousePosParam,
    1979                   trackerInfo->pdwEffect);
     1964        POINTL  mousePosParam;
     1965       
     1966        /*
     1967        * The documentation tells me that the coordinate should be in the target
     1968        * window's coordinate space. However, the tests I made tell me the
     1969        * coordinates should be in screen coordinates.
     1970        */
     1971        mousePosParam.x = mousePos.x;
     1972        mousePosParam.y = mousePos.y;
     1973       
     1974        IDropTarget_DragEnter(trackerInfo->curDragTarget,
     1975                              trackerInfo->dataObject,
     1976                              keyState,
     1977                              mousePosParam,
     1978                              trackerInfo->pdwEffect);
    19801979      }
    19811980    }
     
    19911990
    19921991  /*
    1993    * Now that we have done that, we have to tell the source to give
    1994    * us feedback on the work being done by the target.  If we don't
     1992   * Now that we have done that, we have to tell the source to give 
     1993   * us feedback on the work being done by the target.  If we don't 
    19951994   * have a target, simulate no effect.
    19961995   */
     
    20012000
    20022001  hr = IDropSource_GiveFeedback(trackerInfo->dropSource,
    2003                 *trackerInfo->pdwEffect);
     2002                                *trackerInfo->pdwEffect);
    20042003
    20052004  /*
     
    20272026      SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0)));
    20282027    }
    2029   }
     2028  } 
    20302029}
    20312030
     
    20552054   */
    20562055  trackerInfo->returnValue = IDropSource_QueryContinueDrag(
    2057                    trackerInfo->dropSource,
    2058                    trackerInfo->escPressed,
    2059                    keyState);
    2060 
     2056                               trackerInfo->dropSource,
     2057                               trackerInfo->escPressed,
     2058                               keyState);
     2059 
    20612060  /*
    20622061   * All the return valued will stop the operation except the S_OK
     
    20712070
    20722071    /*
    2073      * Release the mouse in case the drop target decides to show a popup
     2072     * Release the mouse in case the drop target decides to show a popup 
    20742073     * or a menu or something.
    20752074     */
    20762075    ReleaseCapture();
    2077 
     2076   
    20782077    /*
    2079      * If we end-up over a target, drop the object in the target or
     2078     * If we end-up over a target, drop the object in the target or 
    20802079     * inform the target that the operation was cancelled.
    20812080     */
     
    20842083      switch (trackerInfo->returnValue)
    20852084      {
    2086     /*
    2087      * If the source wants us to complete the operation, we tell
    2088     * the drop target that we just dropped the object in it.
    2089     */
     2085        /*
     2086         * If the source wants us to complete the operation, we tell
     2087        * the drop target that we just dropped the object in it.
     2088        */
    20902089        case DRAGDROP_S_DROP:
    2091     {
    2092       POINTL  mousePosParam;
    2093 
    2094       /*
    2095        * The documentation tells me that the coordinate should be
    2096        * in the target window's coordinate space. However, the tests
    2097        * I made tell me the coordinates should be in screen coordinates.
    2098        */
    2099       mousePosParam.x = mousePos.x;
    2100       mousePosParam.y = mousePos.y;
    2101 
    2102       IDropTarget_Drop(trackerInfo->curDragTarget,
    2103                trackerInfo->dataObject,
    2104                keyState,
    2105                mousePosParam,
    2106                trackerInfo->pdwEffect);
    2107       break;
    2108     }
    2109     /*
    2110      * If the source told us that we should cancel, fool the drop
    2111     * target by telling it that the mouse left it's window.
    2112      * Also set the drop effect to "NONE" in case the application
    2113     * ignores the result of DoDragDrop.
    2114     */
     2090        {
     2091          POINTL  mousePosParam;
     2092       
     2093          /*
     2094           * The documentation tells me that the coordinate should be
     2095           * in the target window's coordinate space. However, the tests
     2096           * I made tell me the coordinates should be in screen coordinates.
     2097           */
     2098          mousePosParam.x = mousePos.x;
     2099          mousePosParam.y = mousePos.y;
     2100         
     2101          IDropTarget_Drop(trackerInfo->curDragTarget,
     2102                           trackerInfo->dataObject,
     2103                           keyState,
     2104                           mousePosParam,
     2105                           trackerInfo->pdwEffect);
     2106          break;
     2107        }
     2108        /*
     2109         * If the source told us that we should cancel, fool the drop
     2110        * target by telling it that the mouse left it's window.
     2111         * Also set the drop effect to "NONE" in case the application
     2112        * ignores the result of DoDragDrop.
     2113        */
    21152114        case DRAGDROP_S_CANCEL:
    2116       IDropTarget_DragLeave(trackerInfo->curDragTarget);
    2117       *trackerInfo->pdwEffect = DROPEFFECT_NONE;
    2118       break;
     2115          IDropTarget_DragLeave(trackerInfo->curDragTarget);
     2116          *trackerInfo->pdwEffect = DROPEFFECT_NONE;
     2117          break;
    21192118      }
    21202119    }
     
    21632162 * params:
    21642163 *     regKey   - Key to read the default value from
    2165  *     pdwValue - Pointer to the location where the DWORD
     2164 *     pdwValue - Pointer to the location where the DWORD 
    21662165 *                value is returned. This value is not modified
    21672166 *                if the value is not found.
     
    21692168
    21702169static void OLEUTL_ReadRegistryDWORDValue(
    2171   HKEY   regKey,
     2170  HKEY   regKey, 
    21722171  DWORD* pdwValue)
    21732172{
     
    21782177
    21792178  lres = RegQueryValueExA(regKey,
    2180               "",
    2181               NULL,
    2182               &dwKeyType,
    2183               (LPBYTE)buffer,
    2184               &cbData);
     2179                          "",
     2180                          NULL,
     2181                          &dwKeyType,
     2182                          (LPBYTE)buffer,
     2183                          &cbData);
    21852184
    21862185  if (lres==ERROR_SUCCESS)
     
    21892188    {
    21902189      case REG_DWORD:
    2191     *pdwValue = *(DWORD*)buffer;
    2192     break;
     2190        *pdwValue = *(DWORD*)buffer;
     2191        break;
    21932192      case REG_EXPAND_SZ:
    21942193      case REG_MULTI_SZ:
    21952194      case REG_SZ:
    2196     *pdwValue = (DWORD)strtoul(buffer, NULL, 10);
    2197     break;
     2195        *pdwValue = (DWORD)strtoul(buffer, NULL, 10);
     2196        break;
    21982197    }
    21992198  }
     
    22102209 */
    22112210HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16(
    2212     HICON16 hIcon,
    2213     LPCOLESTR16 lpszLabel,
    2214     LPCOLESTR16 lpszSourceFile,
    2215     UINT16 iIconIndex
     2211        HICON16 hIcon,
     2212        LPCOLESTR16 lpszLabel,
     2213        LPCOLESTR16 lpszSourceFile,
     2214        UINT16 iIconIndex
    22162215) {
    22172216    METAFILEPICT16 *mf;
     
    22232222    if (!hIcon) {
    22242223        if (lpszSourceFile) {
    2225         HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
    2226 
    2227         /* load the icon at index from lpszSourceFile */
    2228         hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex);
    2229         FreeLibrary16(hInstance);
    2230     } else
    2231         return (HGLOBAL)NULL;
     2224            HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
     2225
     2226            /* load the icon at index from lpszSourceFile */
     2227            hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex);
     2228            FreeLibrary16(hInstance);
     2229        } else
     2230            return (HGLOBAL)NULL;
    22322231    }
    22332232
  • trunk/src/ole32/ole2impl.c

    r6648 r6711  
    1 /* $Id: ole2impl.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    32 * Ole 2 Create functions implementation
  • trunk/src/ole32/ole2stubs.c

    r6648 r6711  
    1 /* $Id: ole2stubs.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    32 * Temporary place for ole2 stubs.
     
    2019 */
    2120HRESULT WINAPI  OleCreateLinkToFile(LPCOLESTR lpszFileName, REFIID riid,
    22             DWORD renderopt, LPFORMATETC lpFormatEtc,
    23             LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj)
     21                        DWORD renderopt, LPFORMATETC lpFormatEtc,
     22                        LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj)
    2423{
    2524    FIXME("(%p,%p,%li,%p,%p,%p,%p), stub!\n",lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj);
     
    3231 */
    3332HRESULT WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat,
    34                               UINT uiFlags)
     33                                  UINT uiFlags)
    3534{
    3635    FIXME("(%x,%x,%x), stub!\n", hSrc, cfFormat, uiFlags);
     
    3837}
    3938
    40 
     39 
    4140/***********************************************************************
    4241 *               WriteFmtUserTypeStg (OLE32.160)
    4342 */
    4443HRESULT WINAPI WriteFmtUserTypeStg(
    45       LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
     44          LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
    4645{
    4746    FIXME("(%p,%x,%s) stub!\n",pstg,cf,debugstr_w(lpszUserType));
     
    8281 */
    8382HRESULT WINAPI OleCreate(
    84     REFCLSID rclsid,
    85     REFIID riid,
    86     DWORD renderopt,
    87     LPFORMATETC pFormatEtc,
    88     LPOLECLIENTSITE pClientSite,
    89     LPSTORAGE pStg,
    90     LPVOID* ppvObj)
     83        REFCLSID rclsid,
     84        REFIID riid,
     85        DWORD renderopt,
     86        LPFORMATETC pFormatEtc,
     87        LPOLECLIENTSITE pClientSite,
     88        LPSTORAGE pStg,
     89        LPVOID* ppvObj)
    9190{
    9291  HRESULT hres, hres1;
    9392  IUnknown * pUnk = NULL;
    94 
     93   
    9594  FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid));
    9695
     
    106105        hres1 = IOleObject_SetClientSite(pOE, pClientSite);
    107106        TRACE("-- result 0x%08lx\n", hres1);
    108     IOleObject_Release(pOE);
     107        IOleObject_Release(pOE);
    109108      }
    110109      if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS))))
    111110      {
    112111        TRACE("trying to set stg %p\n", pStg);
    113     hres1 = IPersistStorage_InitNew(pPS, pStg);
     112        hres1 = IPersistStorage_InitNew(pPS, pStg);
    114113        TRACE("-- result 0x%08lx\n", hres1);
    115     IPersistStorage_Release(pPS);
     114        IPersistStorage_Release(pPS);
    116115      }
    117116    }
     
    209208 */
    210209HRESULT     WINAPI OleRegEnumFormatEtc (
    211   REFCLSID clsid,
     210  REFCLSID clsid, 
    212211  DWORD    dwDirection,
    213212  LPENUMFORMATETC* ppenumFormatetc)
     
    219218
    220219/***********************************************************************
    221  *           PropVariantClear               [OLE32.166]
     220 *           PropVariantClear                       [OLE32.166]
    222221 */
    223222HRESULT WINAPI PropVariantClear(void *pvar) /* [in/out] FIXME: PROPVARIANT * */
    224223{
    225     FIXME("(%p): stub:\n", pvar);
    226 
    227     *(LPWORD)pvar = 0;
    228     /* sets at least the vt field to VT_EMPTY */
    229     return S_OK;
    230 }
    231 
    232 /***********************************************************************
    233  *           PropVariantCopy                [OLE32.246]
     224        FIXME("(%p): stub:\n", pvar);
     225
     226        *(LPWORD)pvar = 0;
     227        /* sets at least the vt field to VT_EMPTY */
     228        return S_OK;
     229}
     230
     231/***********************************************************************
     232 *           PropVariantCopy                        [OLE32.246]
    234233 */
    235234HRESULT WINAPI PropVariantCopy(void *pvarDest,      /* [out] FIXME: PROPVARIANT * */
    236                    const void *pvarSrc) /* [in] FIXME: const PROPVARIANT * */
    237 {
    238     FIXME("(%p, %p): stub:\n", pvarDest, pvarSrc);
    239 
    240     return S_OK;
    241 }
    242 
    243 /***********************************************************************
    244  *           FreePropVariantArray               [OLE32.195]
     235                               const void *pvarSrc) /* [in] FIXME: const PROPVARIANT * */
     236{
     237        FIXME("(%p, %p): stub:\n", pvarDest, pvarSrc);
     238
     239        return S_OK;
     240}
     241
     242/***********************************************************************
     243 *           FreePropVariantArray                           [OLE32.195]
    245244 */
    246245HRESULT WINAPI FreePropVariantArray(ULONG cVariants, /* [in] */
    247                     void *rgvars)    /* [in/out] FIXME: PROPVARIANT * */
    248 {
    249     FIXME("(%lu, %p): stub:\n", cVariants, rgvars);
    250 
    251     return S_OK;
     246                                    void *rgvars)    /* [in/out] FIXME: PROPVARIANT * */
     247{
     248        FIXME("(%lu, %p): stub:\n", cVariants, rgvars);
     249
     250        return S_OK;
    252251}
    253252
  • trunk/src/ole32/ole32_main.c

    r6648 r6711  
    1 /* $Id: ole32_main.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    32 *  OLE32 Initialization
     
    1716
    1817/***********************************************************************
    19  *      DllEntryPoint (OLE32.@)
     18 *              DllEntryPoint (OLE32.@)
    2019 */
    2120
     
    2726    case DLL_PROCESS_ATTACH:
    2827        OLE32_hInstance = hinstDLL;
    29     break;
     28        break;
    3029
    3130    case DLL_PROCESS_DETACH:
    3231        OLE32_hInstance = 0;
    33     break;
     32        break;
    3433    }
    3534    return TRUE;
     
    3736
    3837/***********************************************************************
    39  *      DllRegisterServer (OLE32.@)
     38 *              DllRegisterServer (OLE32.@)
    4039 */
    4140HRESULT WINAPI OLE32_DllRegisterServer() {
  • trunk/src/ole32/oleobj.c

    r6648 r6711  
    1 /* $Id: oleobj.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    3  *  OLE2 COM objects
     2 *      OLE2 COM objects
    43 *
    5  *  Copyright 1998 Eric Kohl
     4 *      Copyright 1998 Eric Kohl
    65 *      Copyright 1999 Francis Beaudet
    76 */
     
    1312#include "debugtools.h"
    1413#include "oleidl.h"
     14
     15#ifdef __WIN32OS2__
     16#undef FIXME
     17#undef TRACE
     18#ifdef DEBUG
     19#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     20#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     21#else
     22#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     23#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     24#endif
     25#endif
    1526
    1627DEFAULT_DEBUG_CHANNEL(ole);
     
    7283
    7384  lpoah= (OleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(),
    74                     0,
    75                     sizeof(OleAdviseHolderImpl));
    76 
     85                                        0,
     86                                        sizeof(OleAdviseHolderImpl));
     87 
    7788  ICOM_VTBL(lpoah) = &oahvt;
    7889  lpoah->ref = 1;
    7990  lpoah->maxSinks = INITIAL_SINKS;
    8091  lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(),
    81                   0,
    82                   lpoah->maxSinks * sizeof(IAdviseSink*));
     92                                  0,
     93                                  lpoah->maxSinks * sizeof(IAdviseSink*));
    8394
    8495  for (index = 0; index < lpoah->maxSinks; index++)
     
    106117    }
    107118  }
    108 
     119 
    109120  HeapFree(GetProcessHeap(),
    110        0,
    111        ptrToDestroy->arrayOfSinks);
    112 
     121           0,
     122           ptrToDestroy->arrayOfSinks);
     123 
    113124
    114125  HeapFree(GetProcessHeap(),
    115        0,
    116        ptrToDestroy);
     126           0,
     127           ptrToDestroy);
    117128}
    118129
     
    122133static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface(
    123134  LPOLEADVISEHOLDER iface,
    124   REFIID            riid,
     135  REFIID            riid, 
    125136  LPVOID*           ppvObj)
    126137{
    127   ICOM_THIS(OleAdviseHolderImpl, iface);
     138  ICOM_THIS(OleAdviseHolderImpl, iface); 
    128139  TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObj);
    129140  /*
     
    135146  *ppvObj = NULL;
    136147
    137   if (IsEqualIID(riid, &IID_IUnknown))
     148  if (IsEqualIID(riid, &IID_IUnknown)) 
    138149  {
    139150    /* IUnknown */
    140     *ppvObj = This;
    141   }
    142   else if(IsEqualIID(riid, &IID_IOleAdviseHolder))
     151    *ppvObj = This; 
     152  }
     153  else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 
    143154  {
    144155    /* IOleAdviseHolder */
     
    148159  if(*ppvObj == NULL)
    149160    return E_NOINTERFACE;
    150 
     161 
    151162  /*
    152163   * A successful QI always increments the reference count.
     
    163174  LPOLEADVISEHOLDER iface)
    164175{
    165   ICOM_THIS(OleAdviseHolderImpl, iface);
    166   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
     176  ICOM_THIS(OleAdviseHolderImpl, iface); 
     177  TRACE("(%p)->(ref=%ld)\n", This, This->ref); 
    167178  return ++(This->ref);
    168179}
     
    174185  LPOLEADVISEHOLDER iface)
    175186{
    176   ICOM_THIS(OleAdviseHolderImpl, iface);
    177   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
     187  ICOM_THIS(OleAdviseHolderImpl, iface); 
     188  TRACE("(%p)->(ref=%ld)\n", This, This->ref); 
    178189  This->ref--;
    179190
     
    197208{
    198209  DWORD index;
    199 
    200   ICOM_THIS(OleAdviseHolderImpl, iface);
     210 
     211  ICOM_THIS(OleAdviseHolderImpl, iface); 
    201212
    202213  TRACE("(%p)->(%p, %p)\n", This, pAdvise, pdwConnection);
     
    207218  if (pdwConnection==NULL)
    208219    return E_POINTER;
    209 
     220 
    210221  *pdwConnection = 0;
    211222
     
    228239    This->maxSinks+=INITIAL_SINKS;
    229240
    230     This->arrayOfSinks = HeapReAlloc(GetProcessHeap(),
    231                      0,
    232                      This->arrayOfSinks,
    233                      This->maxSinks*sizeof(IAdviseSink*));
     241    This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 
     242                                     0,
     243                                     This->arrayOfSinks,
     244                                     This->maxSinks*sizeof(IAdviseSink*));
    234245
    235246    for (i=index;i < This->maxSinks; i++)
    236       This->arrayOfSinks[i]=0;
     247      This->arrayOfSinks[i]=0;     
    237248  }
    238249
     
    259270 */
    260271static HRESULT WINAPI OleAdviseHolderImpl_Unadvise(
    261   LPOLEADVISEHOLDER iface,
     272  LPOLEADVISEHOLDER iface, 
    262273  DWORD             dwConnection)
    263274{
    264   ICOM_THIS(OleAdviseHolderImpl, iface);
     275  ICOM_THIS(OleAdviseHolderImpl, iface); 
    265276
    266277  TRACE("(%p)->(%lu)\n", This, dwConnection);
    267278
    268279  /*
    269    * So we don't return 0 as a cookie, the index was
     280   * So we don't return 0 as a cookie, the index was 
    270281   * incremented by 1 in OleAdviseHolderImpl_Advise
    271282   * we have to compensate.
    272283   */
    273284  dwConnection--;
    274 
     285 
    275286  /*
    276287   * Check for invalid cookies.
    277288   */
    278   if ( (dwConnection < 0) ||
     289  if ( (dwConnection < 0) || 
    279290       (dwConnection >= This->maxSinks) )
    280291    return OLE_E_NOCONNECTION;
     
    298309OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise)
    299310{
    300     ICOM_THIS(OleAdviseHolderImpl, iface);
     311    ICOM_THIS(OleAdviseHolderImpl, iface); 
    301312    FIXME("(%p)->(%p)\n", This, ppenumAdvise);
    302313
     
    312323OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk)
    313324{
    314     ICOM_THIS(OleAdviseHolderImpl, iface);
     325    ICOM_THIS(OleAdviseHolderImpl, iface); 
    315326    FIXME("(%p)->(%p)\n", This, pmk);
    316327
     
    325336OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface)
    326337{
    327     ICOM_THIS(OleAdviseHolderImpl, iface);
     338    ICOM_THIS(OleAdviseHolderImpl, iface); 
    328339    FIXME("(%p)\n", This);
    329340
     
    337348OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface)
    338349{
    339     ICOM_THIS(OleAdviseHolderImpl, iface);
     350    ICOM_THIS(OleAdviseHolderImpl, iface); 
    340351    FIXME("(%p)\n", This);
    341352
     
    351362  FORMATETC fmat;
    352363  DWORD advf;
    353 } DataAdviseConnection;
     364} DataAdviseConnection; 
    354365
    355366typedef struct DataAdviseHolder
     
    368379static void               DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy);
    369380static HRESULT WINAPI     DataAdviseHolder_QueryInterface(
    370                 IDataAdviseHolder*      iface,
    371                 REFIID                  riid,
    372                 void**                  ppvObject);
    373 static ULONG WINAPI       DataAdviseHolder_AddRef(
     381                            IDataAdviseHolder*      iface,
     382                            REFIID                  riid,
     383                            void**                  ppvObject);
     384static ULONG WINAPI       DataAdviseHolder_AddRef( 
    374385                            IDataAdviseHolder*      iface);
    375 static ULONG WINAPI       DataAdviseHolder_Release(
     386static ULONG WINAPI       DataAdviseHolder_Release( 
    376387                            IDataAdviseHolder*      iface);
    377 static HRESULT WINAPI     DataAdviseHolder_Advise(
     388static HRESULT WINAPI     DataAdviseHolder_Advise( 
    378389                            IDataAdviseHolder*      iface,
    379                 IDataObject*            pDataObject,
    380                 FORMATETC*              pFetc,
    381                 DWORD                   advf,
    382                 IAdviseSink*            pAdvise,
    383                 DWORD*                  pdwConnection);
    384 static HRESULT WINAPI     DataAdviseHolder_Unadvise(
     390                            IDataObject*            pDataObject,
     391                            FORMATETC*              pFetc,
     392                            DWORD                   advf,
     393                            IAdviseSink*            pAdvise,
     394                            DWORD*                  pdwConnection);
     395static HRESULT WINAPI     DataAdviseHolder_Unadvise( 
    385396                            IDataAdviseHolder*      iface,
    386                 DWORD                   dwConnection);
    387 static HRESULT WINAPI     DataAdviseHolder_EnumAdvise(
    388                             IDataAdviseHolder*      iface,
    389                 IEnumSTATDATA**         ppenumAdvise);
    390 static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange(
    391                             IDataAdviseHolder*      iface,
    392                 IDataObject*            pDataObject,
    393                 DWORD                   dwReserved,
    394                 DWORD                   advf);
     397                            DWORD                   dwConnection);
     398static HRESULT WINAPI     DataAdviseHolder_EnumAdvise( 
     399                            IDataAdviseHolder*      iface,       
     400                            IEnumSTATDATA**         ppenumAdvise);
     401static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange( 
     402                            IDataAdviseHolder*      iface, 
     403                            IDataObject*            pDataObject,
     404                            DWORD                   dwReserved,
     405                            DWORD                   advf);
    395406
    396407/**************************************************************************
     
    417428
    418429  newHolder = (DataAdviseHolder*)HeapAlloc(GetProcessHeap(),
    419                        0,
    420                        sizeof(DataAdviseHolder));
    421 
     430                                           0,
     431                                           sizeof(DataAdviseHolder));
     432 
    422433  ICOM_VTBL(newHolder) = &DataAdviseHolderImpl_VTable;
    423434  newHolder->ref = 1;
    424435  newHolder->maxCons = INITIAL_SINKS;
    425436  newHolder->Connections = HeapAlloc(GetProcessHeap(),
    426                      HEAP_ZERO_MEMORY,
    427                      newHolder->maxCons *
    428                      sizeof(DataAdviseConnection));
     437                                     HEAP_ZERO_MEMORY,
     438                                     newHolder->maxCons *
     439                                     sizeof(DataAdviseConnection));
    429440
    430441  TRACE("returning %p\n", newHolder);
     
    448459    }
    449460  }
    450 
     461 
    451462  HeapFree(GetProcessHeap(), 0, ptrToDestroy->Connections);
    452463  HeapFree(GetProcessHeap(), 0, ptrToDestroy);
     
    463474  void**                  ppvObject)
    464475{
    465   ICOM_THIS(DataAdviseHolder, iface);
     476  ICOM_THIS(DataAdviseHolder, iface); 
    466477  TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
    467478  /*
     
    470481  if ( (This==0) || (ppvObject==0) )
    471482    return E_INVALIDARG;
    472 
     483 
    473484  /*
    474485   * Initialize the return parameter.
     
    484495    *ppvObject = iface;
    485496  }
    486 
     497 
    487498  /*
    488499   * Check that we obtained an interface.
     
    492503    return E_NOINTERFACE;
    493504  }
    494 
     505 
    495506  /*
    496507   * Query Interface always increases the reference count by one when it is
    497    * successful.
     508   * successful. 
    498509   */
    499510  IUnknown_AddRef((IUnknown*)*ppvObject);
    500511
    501   return S_OK;;
     512  return S_OK;; 
    502513}
    503514
     
    507518 * See Windows documentation for more details on IUnknown methods.
    508519 */
    509 static ULONG WINAPI       DataAdviseHolder_AddRef(
     520static ULONG WINAPI       DataAdviseHolder_AddRef(                             
    510521  IDataAdviseHolder*      iface)
    511522{
    512   ICOM_THIS(DataAdviseHolder, iface);
     523  ICOM_THIS(DataAdviseHolder, iface); 
    513524  TRACE("(%p) (ref=%ld)\n", This, This->ref);
    514525  This->ref++;
     
    522533 * See Windows documentation for more details on IUnknown methods.
    523534 */
    524 static ULONG WINAPI DataAdviseHolder_Release(
     535static ULONG WINAPI DataAdviseHolder_Release( 
    525536  IDataAdviseHolder*      iface)
    526537{
     
    542553    return 0;
    543554  }
    544 
     555 
    545556  return This->ref;
    546557}
     
    552563static HRESULT WINAPI DataAdviseHolder_Advise(
    553564  IDataAdviseHolder*      iface,
    554   IDataObject*            pDataObject,
    555   FORMATETC*              pFetc,
    556   DWORD                   advf,
    557   IAdviseSink*            pAdvise,
     565  IDataObject*            pDataObject, 
     566  FORMATETC*              pFetc, 
     567  DWORD                   advf, 
     568  IAdviseSink*            pAdvise, 
    558569  DWORD*                  pdwConnection)
    559570{
    560571  DWORD index;
    561 
    562   ICOM_THIS(DataAdviseHolder, iface);
     572 
     573  ICOM_THIS(DataAdviseHolder, iface); 
    563574
    564575  TRACE("(%p)->(%p, %p, %08lx, %p, %p)\n", This, pDataObject, pFetc, advf,
    565     pAdvise, pdwConnection);
     576        pAdvise, pdwConnection);
    566577  /*
    567578   * Sanity check
     
    569580  if (pdwConnection==NULL)
    570581    return E_POINTER;
    571 
     582 
    572583  *pdwConnection = 0;
    573584
     
    588599    This->maxCons+=INITIAL_SINKS;
    589600    This->Connections = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    590                     This->Connections,
    591                     This->maxCons*sizeof(DataAdviseConnection));
     601                                    This->Connections,
     602                                    This->maxCons*sizeof(DataAdviseConnection));
    592603  }
    593604  /*
     
    617628 * DataAdviseHolder_Unadvise
    618629 */
    619 static HRESULT WINAPI     DataAdviseHolder_Unadvise(
     630static HRESULT WINAPI     DataAdviseHolder_Unadvise( 
    620631  IDataAdviseHolder*      iface,
    621632  DWORD                   dwConnection)
    622633{
    623   ICOM_THIS(DataAdviseHolder, iface);
     634  ICOM_THIS(DataAdviseHolder, iface); 
    624635
    625636  TRACE("(%p)->(%lu)\n", This, dwConnection);
    626637
    627638  /*
    628    * So we don't return 0 as a cookie, the index was
     639   * So we don't return 0 as a cookie, the index was 
    629640   * incremented by 1 in OleAdviseHolderImpl_Advise
    630641   * we have to compensate.
    631642   */
    632643  dwConnection--;
    633 
     644 
    634645  /*
    635646   * Check for invalid cookies.
    636647   */
    637   if ( (dwConnection < 0) ||
     648  if ( (dwConnection < 0) || 
    638649       (dwConnection >= This->maxCons) )
    639650    return OLE_E_NOCONNECTION;
     
    650661}
    651662
    652 static HRESULT WINAPI     DataAdviseHolder_EnumAdvise(
    653   IDataAdviseHolder*      iface,
     663static HRESULT WINAPI     DataAdviseHolder_EnumAdvise( 
     664  IDataAdviseHolder*      iface,       
    654665  IEnumSTATDATA**         ppenumAdvise)
    655666{
    656   ICOM_THIS(DataAdviseHolder, iface);
     667  ICOM_THIS(DataAdviseHolder, iface); 
    657668
    658669  FIXME("(%p)->(%p)\n", This, ppenumAdvise);
     
    663674 * DataAdviseHolder_SendOnDataChange
    664675 */
    665 static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange(
    666   IDataAdviseHolder*      iface,
    667   IDataObject*            pDataObject,
    668   DWORD                   dwReserved,
     676static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange( 
     677  IDataAdviseHolder*      iface, 
     678  IDataObject*            pDataObject, 
     679  DWORD                   dwReserved, 
    669680  DWORD                   advf)
    670681{
    671   ICOM_THIS(DataAdviseHolder, iface);
     682  ICOM_THIS(DataAdviseHolder, iface); 
    672683  DWORD index;
    673684  STGMEDIUM stg;
     
    679690    if(This->Connections[index].sink != NULL) {
    680691      if(!(This->Connections[index].advf & ADVF_NODATA)) {
    681     TRACE("Calling IDataObject_GetData\n");
    682     res = IDataObject_GetData(pDataObject,
    683                   &(This->Connections[index].fmat),
    684                   &stg);
    685     TRACE("returns %08lx\n", res);
     692        TRACE("Calling IDataObject_GetData\n");
     693        res = IDataObject_GetData(pDataObject,
     694                                  &(This->Connections[index].fmat),
     695                                  &stg);
     696        TRACE("returns %08lx\n", res);
    686697      }
    687698      TRACE("Calling IAdviseSink_OnDataChange\n");
    688699      IAdviseSink_OnDataChange(This->Connections[index].sink,
    689                      &(This->Connections[index].fmat),
    690                      &stg);
     700                                     &(This->Connections[index].fmat),
     701                                     &stg);
    691702      TRACE("Done IAdviseSink_OnDataChange\n");
    692703      if(This->Connections[index].advf & ADVF_ONLYONCE) {
    693     TRACE("Removing connection\n");
    694     DataAdviseHolder_Unadvise(iface, index+1);
     704        TRACE("Removing connection\n");
     705        DataAdviseHolder_Unadvise(iface, index+1);
    695706      }
    696707    }
  • trunk/src/ole32/stg_bigblockfile.c

    r6648 r6711  
    1 /* $Id: stg_bigblockfile.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/******************************************************************************
    32 *
    43 * BigBlockFile
    54 *
    6  * This is the implementation of a file that consists of blocks of
     5 * This is the implementation of a file that consists of blocks of 
    76 * a predetermined size.
    8  * This class is used in the Compound File implementation of the
    9  * IStorage and IStream interfaces. It provides the functionality
    10  * to read and write any blocks in the file as well as setting and
     7 * This class is used in the Compound File implementation of the 
     8 * IStorage and IStream interfaces. It provides the functionality 
     9 * to read and write any blocks in the file as well as setting and 
    1110 * obtaining the size of the file.
    1211 * The blocks are indexed sequentially from the start of the file
    1312 * starting with -1.
    14  *
     13 * 
    1514 * TODO:
    1615 * - Support for a transacted mode
     
    4544#include "debugtools.h"
    4645
     46#ifdef __WIN32OS2__
     47#undef FIXME
     48#undef TRACE
     49#ifdef DEBUG
     50#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     51#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     52#else
     53#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     54#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     55#endif
     56#endif
     57
    4758DEFAULT_DEBUG_CHANNEL(storage);
    4859
     
    7081/***
    7182 * This structure identifies the paged that are mapped
    72  * from the file and their position in memory. It is
     83 * from the file and their position in memory. It is 
    7384 * also used to hold a reference count to those pages.
    7485 *
     
    103114                                                 ULONG          index,
    104115                                                 DWORD          desired_access);
    105 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
    106                            void*         pBlock);
     116static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 
     117                                                   void*         pBlock);
    107118static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
    108                        ULONG page_index);
     119                                           ULONG page_index);
    109120static DWORD     BIGBLOCKFILE_GetProtectMode(DWORD openFlags);
    110121static BOOL      BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile);
     
    119130 */
    120131static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb,
    121                     unsigned int index)
     132                                        unsigned int index)
    122133{
    123134    unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
     
    151162 *      BIGBLOCKFILE_Construct
    152163 *
    153  * Construct a big block file. Create the file mapping object.
     164 * Construct a big block file. Create the file mapping object. 
    154165 * Create the read only mapped pages list, the writable mapped page list
    155166 * and the blocks in use list.
     
    231242
    232243  This->filesize.s.LowPart = GetFileSize(This->hfile,
    233                     &This->filesize.s.HighPart);
     244                                        &This->filesize.s.HighPart);
    234245
    235246  This->maplist = NULL;
     
    324335  /*
    325336   * validate the block index
    326    *
     337   * 
    327338   */
    328339  if (This->blocksize * (index + 1)
     
    330341  {
    331342    TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1),
    332       This->filesize.s.LowPart);
     343          This->filesize.s.LowPart);
    333344    return NULL;
    334345  }
     
    380391
    381392    if (pBlock == NULL)
    382     return;
     393        return;
    383394
    384395    page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock);
    385396
    386397    if (page == NULL)
    387     return;
     398        return;
    388399
    389400    BIGBLOCKFILE_ReleaseMappedPage(This, page);
     
    394405 *
    395406 * Sets the size of the file.
    396  *
     407 * 
    397408 */
    398409void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
     
    406417   */
    407418  BIGBLOCKFILE_UnmapAllMappedPages(This);
    408 
     419 
    409420  if (This->fileBased)
    410421  {
     
    424435     *
    425436     * The problem is that the SetFilePointer-SetEndOfFile combo below
    426      * doesn't always succeed. The file is not grown. It seems like the
     437     * doesn't always succeed. The file is not grown. It seems like the 
    427438     * operation is cached. By doing the WriteFile, the file is actually
    428439     * grown on disk.
     
    433444    WriteFile(This->hfile, buf, 10, NULL, NULL);
    434445    /*
    435      * END HACK
     446     * END HACK 
    436447     */
    437448
     
    441452    SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
    442453    SetEndOfFile(This->hfile);
    443 
     454 
    444455    /*
    445456     * re-create the file mapping object
     
    448459                                        NULL,
    449460                                        This->flProtect,
    450                                         0, 0,
     461                                        0, 0, 
    451462                                        NULL);
    452463  }
     
    477488 *
    478489 * Returns the size of the file.
    479  *
     490 * 
    480491 */
    481492ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This)
     
    490501 */
    491502static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index,
    492                      DWORD desired_access)
     503                                     DWORD desired_access)
    493504{
    494505    assert(block_index < BLOCKS_PER_PAGE);
     
    496507    if (desired_access == FILE_MAP_READ)
    497508    {
    498     if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
    499         return FALSE;
    500 
    501     BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
     509        if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
     510            return FALSE;
     511
     512        BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
    502513    }
    503514    else
    504515    {
    505     assert(desired_access == FILE_MAP_WRITE);
    506 
    507     if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
    508         return FALSE;
    509 
    510     BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
     516        assert(desired_access == FILE_MAP_WRITE);
     517
     518        if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
     519            return FALSE;
     520
     521        BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
    511522    }
    512523
     
    520531 */
    521532static void* BIGBLOCKFILE_GetBigBlockPointer(
    522   LPBIGBLOCKFILE This,
    523   ULONG          block_index,
     533  LPBIGBLOCKFILE This, 
     534  ULONG          block_index, 
    524535  DWORD          desired_access)
    525536{
     
    532543    if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access))
    533544    {
    534     BIGBLOCKFILE_ReleaseMappedPage(This, page);
    535     return NULL;
     545        BIGBLOCKFILE_ReleaseMappedPage(This, page);
     546        return NULL;
    536547    }
    537548
     
    548559 */
    549560static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
    550                            void *pBlock)
     561                                                   void *pBlock)
    551562{
    552563    MappedPage *page;
     
    554565    for (page = This->maplist; page != NULL; page = page->next)
    555566    {
    556     if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
    557         && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
    558         break;
     567        if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
     568            && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
     569            break;
    559570
    560571    }
     
    568579 */
    569580static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head,
    570                            ULONG page_index)
     581                                               ULONG page_index)
    571582{
    572583    for (; head != NULL; head = head->next)
    573584    {
    574     if (head->page_index == page_index)
    575     {
    576         InterlockedIncrement(&head->refcnt);
    577         break;
    578     }
     585        if (head->page_index == page_index)
     586        {
     587            InterlockedIncrement(&head->refcnt);
     588            break;
     589        }
    579590    }
    580591
     
    612623    if (!page)
    613624    {
    614     page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
     625        page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
     626        if (page)
     627        {
     628            This->num_victim_pages--;
     629
     630            BIGBLOCKFILE_Zero(&page->readable_blocks);
     631            BIGBLOCKFILE_Zero(&page->writable_blocks);
     632        }
     633    }
     634
    615635    if (page)
    616636    {
    617         This->num_victim_pages--;
    618 
    619         BIGBLOCKFILE_Zero(&page->readable_blocks);
    620         BIGBLOCKFILE_Zero(&page->writable_blocks);
    621     }
    622     }
    623 
    624     if (page)
    625     {
    626     /* If the page is not already at the head of the list, move
    627      * it there. (Also moves pages from victim to main list.) */
    628     if (This->maplist != page)
    629     {
    630         if (This->victimhead == page) This->victimhead = page->next;
    631         if (This->victimtail == page) This->victimtail = page->prev;
    632 
    633         BIGBLOCKFILE_UnlinkPage(page);
    634 
    635         BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
    636     }
    637 
    638     return page;
     637        /* If the page is not already at the head of the list, move
     638         * it there. (Also moves pages from victim to main list.) */
     639        if (This->maplist != page)
     640        {
     641            if (This->victimhead == page) This->victimhead = page->next;
     642            if (This->victimtail == page) This->victimtail = page->prev;
     643
     644            BIGBLOCKFILE_UnlinkPage(page);
     645
     646            BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
     647        }
     648
     649        return page;
    639650    }
    640651
     
    653664    if (This->fileBased)
    654665    {
    655     DWORD numBytesToMap;
    656     DWORD desired_access;
    657 
    658     if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
    659         numBytesToMap = This->filesize.s.LowPart - lowoffset;
     666        DWORD numBytesToMap;
     667        DWORD desired_access;
     668
     669        if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
     670            numBytesToMap = This->filesize.s.LowPart - lowoffset;
     671        else
     672            numBytesToMap = PAGE_SIZE;
     673
     674        if (This->flProtect == PAGE_READONLY)
     675            desired_access = FILE_MAP_READ;
     676        else
     677            desired_access = FILE_MAP_WRITE;
     678
     679        page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
     680                                      lowoffset, numBytesToMap);
     681    }
    660682    else
    661         numBytesToMap = PAGE_SIZE;
    662 
    663     if (This->flProtect == PAGE_READONLY)
    664         desired_access = FILE_MAP_READ;
    665     else
    666         desired_access = FILE_MAP_WRITE;
    667 
    668     page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
    669                       lowoffset, numBytesToMap);
    670     }
    671     else
    672     {
    673     page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
     683    {
     684        page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
    674685    }
    675686
     
    680691
    681692static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
    682                        ULONG page_index)
     693                                           ULONG page_index)
    683694{
    684695    MappedPage *page;
     
    706717    TRACE("%ld at %p\n", page->page_index, page->lpBytes);
    707718    if (page->refcnt > 0)
    708     ERR("unmapping inuse page %p\n", page->lpBytes);
     719        ERR("unmapping inuse page %p\n", page->lpBytes);
    709720
    710721    if (This->fileBased && page->lpBytes)
    711     UnmapViewOfFile(page->lpBytes);
     722        UnmapViewOfFile(page->lpBytes);
    712723
    713724    page->lpBytes = NULL;
     
    737748    if (!InterlockedDecrement(&page->refcnt))
    738749    {
    739     if (This->maplist == page) This->maplist = page->next;
    740 
    741     BIGBLOCKFILE_UnlinkPage(page);
    742 
    743     if (MAX_VICTIM_PAGES > 0)
    744     {
    745         if (This->num_victim_pages >= MAX_VICTIM_PAGES)
    746         {
    747         MappedPage *victim = This->victimtail;
    748         if (victim)
    749         {
    750             This->victimtail = victim->prev;
    751             if (This->victimhead == victim)
    752             This->victimhead = victim->next;
    753 
    754             BIGBLOCKFILE_UnlinkPage(victim);
    755             BIGBLOCKFILE_DeletePage(This, victim);
    756         }
    757         }
    758         else This->num_victim_pages++;
    759 
    760         BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
    761         if (This->victimtail == NULL) This->victimtail = page;
    762     }
    763     else
    764         BIGBLOCKFILE_DeletePage(This, page);
     750        if (This->maplist == page) This->maplist = page->next;
     751
     752        BIGBLOCKFILE_UnlinkPage(page);
     753
     754        if (MAX_VICTIM_PAGES > 0)
     755        {
     756            if (This->num_victim_pages >= MAX_VICTIM_PAGES)
     757            {
     758                MappedPage *victim = This->victimtail;
     759                if (victim)
     760                {
     761                    This->victimtail = victim->prev;
     762                    if (This->victimhead == victim)
     763                        This->victimhead = victim->next;
     764
     765                    BIGBLOCKFILE_UnlinkPage(victim);
     766                    BIGBLOCKFILE_DeletePage(This, victim);
     767                }
     768            }
     769            else This->num_victim_pages++;
     770
     771            BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
     772            if (This->victimtail == NULL) This->victimtail = page;
     773        }
     774        else
     775            BIGBLOCKFILE_DeletePage(This, page);
    765776    }
    766777}
     
    770781    while (list != NULL)
    771782    {
    772     MappedPage *next = list->next;
    773 
    774     BIGBLOCKFILE_DeletePage(This, list);
    775 
    776     list = next;
     783        MappedPage *next = list->next;
     784
     785        BIGBLOCKFILE_DeletePage(This, list);
     786
     787        list = next;
    777788    }
    778789}
     
    800811    for (; list != NULL; list = list->next)
    801812    {
    802     BIGBLOCKFILE_UnmapPage(This, list);
     813        BIGBLOCKFILE_UnmapPage(This, list);
    803814    }
    804815}
     
    814825    while (list != NULL)
    815826    {
    816     MappedPage *next = list->next;
    817 
    818     if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
    819     {
    820         TRACE("discarding %lu\n", list->page_index);
    821 
    822         /* page is entirely outside of the file, delete it */
    823         BIGBLOCKFILE_UnlinkPage(list);
    824         BIGBLOCKFILE_DeletePage(This, list);
    825     }
    826     else
    827     {
    828         /* otherwise, remap it */
    829         BIGBLOCKFILE_MapPage(This, list);
    830     }
    831 
    832     list = next;
     827        MappedPage *next = list->next;
     828
     829        if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
     830        {
     831            TRACE("discarding %lu\n", list->page_index);
     832
     833            /* page is entirely outside of the file, delete it */
     834            BIGBLOCKFILE_UnlinkPage(list);
     835            BIGBLOCKFILE_DeletePage(This, list);
     836        }
     837        else
     838        {
     839            /* otherwise, remap it */
     840            BIGBLOCKFILE_MapPage(This, list);
     841        }
     842
     843        list = next;
    833844    }
    834845}
     
    849860{
    850861    if (openFlags & (STGM_WRITE | STGM_READWRITE))
    851     return PAGE_READWRITE;
     862        return PAGE_READWRITE;
    852863    else
    853     return PAGE_READONLY;
    854 }
     864        return PAGE_READONLY;
     865}
  • trunk/src/ole32/stg_stream.c

    r6648 r6711  
    1 /* $Id: stg_stream.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/*
    32 * Compound Storage (32 bit version)
     
    2827
    2928#include "storage32.h"
     29
     30#ifdef __WIN32OS2__
     31#undef FIXME
     32#undef TRACE
     33#ifdef DEBUG
     34#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     35#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     36#else
     37#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     38#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     39#endif
     40#endif
    3041
    3142DEFAULT_DEBUG_CHANNEL(storage);
     
    6677 */
    6778StgStreamImpl* StgStreamImpl_Construct(
    68         StorageBaseImpl* parentStorage,
     79                StorageBaseImpl* parentStorage,
    6980    DWORD            grfMode,
    7081    ULONG            ownerProperty)
     
    7384
    7485  newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl));
    75 
     86 
    7687  if (newStream!=0)
    7788  {
     
    8192    ICOM_VTBL(newStream) = &StgStreamImpl_Vtbl;
    8293    newStream->ref       = 0;
    83 
     94   
    8495    /*
    8596     * We want to nail-down the reference to the storage in case the
     
    89100    IStorage_AddRef((IStorage*)newStream->parentStorage);
    90101
    91     newStream->grfMode = grfMode;
     102    newStream->grfMode = grfMode;   
    92103    newStream->ownerProperty = ownerProperty;
    93 
     104   
    94105    /*
    95106     * Start the stream at the begining.
     
    97108    newStream->currentPosition.s.HighPart = 0;
    98109    newStream->currentPosition.s.LowPart = 0;
    99 
     110   
    100111    /*
    101112     * Initialize the rest of the data.
     
    105116    newStream->bigBlockChain       = 0;
    106117    newStream->smallBlockChain     = 0;
    107 
     118   
    108119    /*
    109120     * Read the size from the property and determine if the blocks forming
     
    112123    StgStreamImpl_OpenBlockChain(newStream);
    113124  }
    114 
     125 
    115126  return newStream;
    116127}
     
    119130 * This is the destructor of the StgStreamImpl class.
    120131 *
    121  * This method will clean-up all the resources used-up by the given StgStreamImpl
     132 * This method will clean-up all the resources used-up by the given StgStreamImpl 
    122133 * class. The pointer passed-in to this function will be freed and will not
    123134 * be valid anymore.
     
    151162   * Finally, free the memory used-up by the class.
    152163   */
    153   HeapFree(GetProcessHeap(), 0, This);
     164  HeapFree(GetProcessHeap(), 0, This); 
    154165}
    155166
     
    159170 */
    160171HRESULT WINAPI StgStreamImpl_QueryInterface(
    161           IStream*     iface,
    162           REFIID         riid,        /* [in] */
    163           void**         ppvObject)   /* [iid_is][out] */
     172                  IStream*     iface,
     173                  REFIID         riid,        /* [in] */         
     174                  void**         ppvObject)   /* [iid_is][out] */
    164175{
    165176  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    170181  if (ppvObject==0)
    171182    return E_INVALIDARG;
    172 
     183 
    173184  /*
    174185   * Initialize the return parameter.
    175186   */
    176187  *ppvObject = 0;
    177 
     188 
    178189  /*
    179190   * Compare the riid with the interface IDs implemented by this object.
    180191   */
    181   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     192  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    182193  {
    183194    *ppvObject = (IStream*)This;
    184195  }
    185   else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0)
     196  else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 
    186197  {
    187198    *ppvObject = (IStream*)This;
    188199  }
    189 
     200 
    190201  /*
    191202   * Check that we obtained an interface.
     
    193204  if ((*ppvObject)==0)
    194205    return E_NOINTERFACE;
    195 
     206 
    196207  /*
    197208   * Query Interface always increases the reference count by one when it is
     
    199210   */
    200211  StgStreamImpl_AddRef(iface);
    201 
     212 
    202213  return S_OK;;
    203214}
     
    208219 */
    209220ULONG WINAPI StgStreamImpl_AddRef(
    210         IStream* iface)
     221                IStream* iface)
    211222{
    212223  StgStreamImpl* const This=(StgStreamImpl*)iface;
    213224
    214225  This->ref++;
    215 
     226 
    216227  return This->ref;
    217228}
     
    222233 */
    223234ULONG WINAPI StgStreamImpl_Release(
    224         IStream* iface)
     235                IStream* iface)
    225236{
    226237  StgStreamImpl* const This=(StgStreamImpl*)iface;
    227238
    228239  ULONG newRef;
    229 
     240 
    230241  This->ref--;
    231 
     242 
    232243  newRef = This->ref;
    233 
     244 
    234245  /*
    235246   * If the reference count goes down to 0, perform suicide.
     
    239250    StgStreamImpl_Destroy(This);
    240251  }
    241 
     252 
    242253  return newRef;
    243254}
     
    273284   */
    274285  readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
    275                          This->ownerProperty,
    276                          &curProperty);
    277 
     286                                             This->ownerProperty,
     287                                             &curProperty);
     288 
    278289  if (readSucessful)
    279290  {
    280291    This->streamSize = curProperty.size;
    281 
     292   
    282293    /*
    283294     * This code supports only streams that are <32 bits in size.
    284295     */
    285296    assert(This->streamSize.s.HighPart == 0);
    286 
     297   
    287298    if(curProperty.startingBlock == BLOCK_END_OF_CHAIN)
    288299    {
     
    292303    {
    293304      if ( (This->streamSize.s.HighPart == 0) &&
    294        (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
     305           (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
    295306      {
    296     This->smallBlockChain = SmallBlockChainStream_Construct(
    297                                 This->parentStorage->ancestorStorage,
    298                                 This->ownerProperty);
     307        This->smallBlockChain = SmallBlockChainStream_Construct(
     308                                                                This->parentStorage->ancestorStorage,   
     309                                                                This->ownerProperty);
    299310      }
    300311      else
    301312      {
    302     This->bigBlockChain = BlockChainStream_Construct(
    303                             This->parentStorage->ancestorStorage,
    304                             NULL,
    305                             This->ownerProperty);
     313        This->bigBlockChain = BlockChainStream_Construct(
     314                                                        This->parentStorage->ancestorStorage,
     315                                                        NULL,
     316                                                        This->ownerProperty);
    306317      }
    307318    }
     
    318329 * See the documentation of ISequentialStream for more info.
    319330 */
    320 HRESULT WINAPI StgStreamImpl_Read(
    321           IStream*     iface,
    322           void*          pv,        /* [length_is][size_is][out] */
    323           ULONG          cb,        /* [in] */
    324           ULONG*         pcbRead)   /* [out] */
     331HRESULT WINAPI StgStreamImpl_Read( 
     332                  IStream*     iface,
     333                  void*          pv,        /* [length_is][size_is][out] */
     334                  ULONG          cb,        /* [in] */                     
     335                  ULONG*         pcbRead)   /* [out] */                   
    325336{
    326337  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    330341
    331342  TRACE("(%p, %p, %ld, %p)\n",
    332     iface, pv, cb, pcbRead);
    333 
    334   /*
     343        iface, pv, cb, pcbRead);
     344
     345  /* 
    335346   * If the caller is not interested in the nubmer of bytes read,
    336347   * we use another buffer to avoid "if" statements in the code.
     
    338349  if (pcbRead==0)
    339350    pcbRead = &bytesReadBuffer;
    340 
     351 
    341352  /*
    342353   * Using the known size of the stream, calculate the number of bytes
     
    344355   */
    345356  bytesToReadFromBuffer = min( This->streamSize.s.LowPart - This->currentPosition.s.LowPart, cb);
    346 
     357 
    347358  /*
    348359   * Depending on the type of chain that was opened when the stream was constructed,
     
    352363  {
    353364    SmallBlockChainStream_ReadAt(This->smallBlockChain,
    354                 This->currentPosition,
    355                 bytesToReadFromBuffer,
    356                 pv,
    357                 pcbRead);
    358 
     365                                This->currentPosition,
     366                                bytesToReadFromBuffer,
     367                                pv,
     368                                pcbRead);
     369   
    359370  }
    360371  else if (This->bigBlockChain!=0)
    361372  {
    362373    BlockChainStream_ReadAt(This->bigBlockChain,
    363                 This->currentPosition,
    364                 bytesToReadFromBuffer,
    365                 pv,
    366                 pcbRead);
     374                            This->currentPosition,
     375                            bytesToReadFromBuffer,
     376                            pv,
     377                            pcbRead);
    367378  }
    368379  else
     
    387398   */
    388399  This->currentPosition.s.LowPart += *pcbRead;
    389 
     400 
    390401  /*
    391402   * The function returns S_OK if the buffer was filled completely
     
    395406  if(*pcbRead == cb)
    396407    return S_OK;
    397 
     408 
    398409  return S_FALSE;
    399410}
    400 
     411       
    401412/***
    402413 * This method is part of the ISequentialStream interface.
     
    410421 */
    411422HRESULT WINAPI StgStreamImpl_Write(
    412               IStream*     iface,
    413           const void*    pv,          /* [size_is][in] */
    414           ULONG          cb,          /* [in] */
    415           ULONG*         pcbWritten)  /* [out] */
     423                  IStream*     iface,
     424                  const void*    pv,          /* [size_is][in] */
     425                  ULONG          cb,          /* [in] */         
     426                  ULONG*         pcbWritten)  /* [out] */         
    416427{
    417428  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    421432
    422433  TRACE("(%p, %p, %ld, %p)\n",
    423     iface, pv, cb, pcbWritten);
    424 
     434        iface, pv, cb, pcbWritten);
     435 
    425436  /*
    426437   * Do we have permission to write to this stream?
     
    436447  if (pcbWritten == 0)
    437448    pcbWritten = &bytesWritten;
    438 
     449 
    439450  /*
    440451   * Initialize the out parameter
     
    451462    newSize.s.LowPart = This->currentPosition.s.LowPart + cb;
    452463  }
    453 
     464 
    454465  /*
    455466   * Verify if we need to grow the stream
     
    460471    IStream_SetSize(iface, newSize);
    461472  }
    462 
     473 
    463474  /*
    464475   * Depending on the type of chain that was opened when the stream was constructed,
     
    468479  {
    469480    SmallBlockChainStream_WriteAt(This->smallBlockChain,
    470                   This->currentPosition,
    471                   cb,
    472                   pv,
    473                   pcbWritten);
    474 
     481                                  This->currentPosition,
     482                                  cb,
     483                                  pv,
     484                                  pcbWritten);
     485   
    475486  }
    476487  else if (This->bigBlockChain!=0)
    477488  {
    478489    BlockChainStream_WriteAt(This->bigBlockChain,
    479                  This->currentPosition,
    480                  cb,
    481                  pv,
    482                  pcbWritten);
     490                             This->currentPosition,
     491                             cb,
     492                             pv,
     493                             pcbWritten);
    483494  }
    484495  else
    485496    assert(FALSE);
    486 
     497 
    487498  /*
    488499   * Advance the position pointer for the number of positions written.
    489500   */
    490501  This->currentPosition.s.LowPart += *pcbWritten;
    491 
     502 
    492503  return S_OK;
    493504}
     
    500511 *
    501512 * See the documentation of IStream for more info.
    502  */
    503 HRESULT WINAPI StgStreamImpl_Seek(
    504           IStream*      iface,
    505           LARGE_INTEGER   dlibMove,         /* [in] */
    506           DWORD           dwOrigin,         /* [in] */
    507           ULARGE_INTEGER* plibNewPosition) /* [out] */
     513 */       
     514HRESULT WINAPI StgStreamImpl_Seek( 
     515                  IStream*      iface,
     516                  LARGE_INTEGER   dlibMove,         /* [in] */
     517                  DWORD           dwOrigin,         /* [in] */
     518                  ULARGE_INTEGER* plibNewPosition) /* [out] */
    508519{
    509520  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    512523
    513524  TRACE("(%p, %ld, %ld, %p)\n",
    514     iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition);
    515 
    516   /*
     525        iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition);
     526
     527  /* 
    517528   * The caller is allowed to pass in NULL as the new position return value.
    518529   * If it happens, we assign it to a dynamic variable to avoid special cases
     
    556567      /* ... and subtract with carry */
    557568      if (dlibMove.s.LowPart > plibNewPosition->s.LowPart) {
    558       /* carry needed, This accounts for any underflows at [1]*/
    559       plibNewPosition->s.HighPart -= 1;
     569          /* carry needed, This accounts for any underflows at [1]*/
     570          plibNewPosition->s.HighPart -= 1;
    560571      }
    561572      plibNewPosition->s.LowPart -= dlibMove.s.LowPart; /* [1] */
    562       plibNewPosition->s.HighPart -= dlibMove.s.HighPart;
     573      plibNewPosition->s.HighPart -= dlibMove.s.HighPart; 
    563574  } else {
    564575      /* add directly */
     
    566577      plibNewPosition->s.LowPart += dlibMove.s.LowPart;
    567578      if((plibNewPosition->s.LowPart < initialLowPart) ||
    568     (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) {
    569       /* LowPart has rolled over => add the carry digit to HighPart */
    570       plibNewPosition->s.HighPart++;
     579        (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) {
     580          /* LowPart has rolled over => add the carry digit to HighPart */
     581          plibNewPosition->s.HighPart++;
    571582      }
    572       plibNewPosition->s.HighPart += dlibMove.s.HighPart;
    573   }
    574   /*
    575    * Check if we end-up before the beginning of the file. That should
     583      plibNewPosition->s.HighPart += dlibMove.s.HighPart; 
     584  }
     585  /*
     586   * Check if we end-up before the beginning of the file. That should 
    576587   * trigger an error.
    577588   */
     
    581592
    582593    /*
    583    * We currently don't support files with offsets of >32 bits.
     594   * We currently don't support files with offsets of >32 bits. 
    584595   * Note that we have checked for a negative offset already
    585596     */
     
    594605   */
    595606  This->currentPosition = *plibNewPosition;
    596 
     607 
    597608  return S_OK;
    598609}
     
    607618 * See the documentation of IStream for more info.
    608619 */
    609 HRESULT WINAPI StgStreamImpl_SetSize(
    610                      IStream*      iface,
    611                      ULARGE_INTEGER  libNewSize)   /* [in] */
     620HRESULT WINAPI StgStreamImpl_SetSize( 
     621                                     IStream*      iface,
     622                                     ULARGE_INTEGER  libNewSize)   /* [in] */
    612623{
    613624  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    658669  Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
    659670                                       This->ownerProperty,
    660                                        &curProperty);
     671                                       &curProperty); 
    661672  /*
    662673   * Determine if we have to switch from small to big blocks or vice versa
    663    */
    664   if ( (This->smallBlockChain!=0) &&
     674   */ 
     675  if ( (This->smallBlockChain!=0) && 
    665676       (curProperty.size.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
    666677  {
     
    694705  curProperty.size.s.HighPart = libNewSize.s.HighPart;
    695706  curProperty.size.s.LowPart = libNewSize.s.LowPart;
    696 
     707 
    697708  if (Success)
    698709  {
    699710    StorageImpl_WriteProperty(This->parentStorage->ancestorStorage,
    700                 This->ownerProperty,
    701                 &curProperty);
    702   }
    703 
     711                                This->ownerProperty,
     712                                &curProperty);
     713  }
     714 
    704715  This->streamSize = libNewSize;
    705 
     716 
    706717  return S_OK;
    707718}
    708 
     719       
    709720/***
    710721 * This method is part of the IStream interface.
     
    714725 * See the documentation of IStream for more info.
    715726 */
    716 HRESULT WINAPI StgStreamImpl_CopyTo(
    717                     IStream*      iface,
    718                     IStream*      pstm,         /* [unique][in] */
    719                     ULARGE_INTEGER  cb,           /* [in] */
    720                     ULARGE_INTEGER* pcbRead,      /* [out] */
    721                     ULARGE_INTEGER* pcbWritten)   /* [out] */
     727HRESULT WINAPI StgStreamImpl_CopyTo( 
     728                                    IStream*      iface,
     729                                    IStream*      pstm,         /* [unique][in] */
     730                                    ULARGE_INTEGER  cb,           /* [in] */         
     731                                    ULARGE_INTEGER* pcbRead,      /* [out] */       
     732                                    ULARGE_INTEGER* pcbWritten)   /* [out] */       
    722733{
    723734  HRESULT        hr = S_OK;
     
    727738  ULARGE_INTEGER totalBytesWritten;
    728739
    729   TRACE("(%p, %p, %ld, %p, %p)\n",
    730     iface, pstm, cb.s.LowPart, pcbRead, pcbWritten);
     740  TRACE("(%p, %p, %ld, %p, %p)\n", 
     741        iface, pstm, cb.s.LowPart, pcbRead, pcbWritten);
    731742
    732743  /*
     
    750761    else
    751762      copySize = cb.s.LowPart;
    752 
     763   
    753764    IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
    754765
    755766    totalBytesRead.s.LowPart += bytesRead;
    756 
     767   
    757768    IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
    758769
     
    767778      break;
    768779    }
    769 
     780   
    770781    if (bytesRead!=copySize)
    771782      cb.s.LowPart = 0;
     
    798809 *
    799810 * See the documentation of IStream for more info.
    800  */
    801 HRESULT WINAPI StgStreamImpl_Commit(
    802           IStream*      iface,
    803           DWORD           grfCommitFlags)  /* [in] */
     811 */       
     812HRESULT WINAPI StgStreamImpl_Commit( 
     813                  IStream*      iface,
     814                  DWORD           grfCommitFlags)  /* [in] */
    804815{
    805816  return S_OK;
     
    813824 *
    814825 * See the documentation of IStream for more info.
    815  */
    816 HRESULT WINAPI StgStreamImpl_Revert(
    817           IStream* iface)
     826 */       
     827HRESULT WINAPI StgStreamImpl_Revert( 
     828                  IStream* iface)
    818829{
    819830  return S_OK;
    820831}
    821832
    822 HRESULT WINAPI StgStreamImpl_LockRegion(
    823                     IStream*     iface,
    824                     ULARGE_INTEGER libOffset,   /* [in] */
    825                     ULARGE_INTEGER cb,          /* [in] */
    826                     DWORD          dwLockType)  /* [in] */
     833HRESULT WINAPI StgStreamImpl_LockRegion( 
     834                                        IStream*     iface,
     835                                        ULARGE_INTEGER libOffset,   /* [in] */
     836                                        ULARGE_INTEGER cb,          /* [in] */
     837                                        DWORD          dwLockType)  /* [in] */
    827838{
    828839  FIXME("not implemented!\n");
     
    830841}
    831842
    832 HRESULT WINAPI StgStreamImpl_UnlockRegion(
    833                       IStream*     iface,
    834                       ULARGE_INTEGER libOffset,   /* [in] */
    835                       ULARGE_INTEGER cb,          /* [in] */
    836                       DWORD          dwLockType)  /* [in] */
     843HRESULT WINAPI StgStreamImpl_UnlockRegion( 
     844                                          IStream*     iface,
     845                                          ULARGE_INTEGER libOffset,   /* [in] */
     846                                          ULARGE_INTEGER cb,          /* [in] */
     847                                          DWORD          dwLockType)  /* [in] */
    837848{
    838849  FIXME("not implemented!\n");
     
    847858 *
    848859 * See the documentation of IStream for more info.
    849  */
    850 HRESULT WINAPI StgStreamImpl_Stat(
    851           IStream*     iface,
    852           STATSTG*       pstatstg,     /* [out] */
    853           DWORD          grfStatFlag)  /* [in] */
     860 */       
     861HRESULT WINAPI StgStreamImpl_Stat( 
     862                  IStream*     iface,
     863                  STATSTG*       pstatstg,     /* [out] */
     864                  DWORD          grfStatFlag)  /* [in] */
    854865{
    855866  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    857868  StgProperty    curProperty;
    858869  BOOL         readSucessful;
    859 
     870 
    860871  /*
    861872   * Read the information from the property.
    862873   */
    863874  readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
    864                          This->ownerProperty,
    865                          &curProperty);
    866 
     875                                             This->ownerProperty,
     876                                             &curProperty);
     877 
    867878  if (readSucessful)
    868879  {
    869     StorageUtl_CopyPropertyToSTATSTG(pstatstg,
    870                      &curProperty,
    871                      grfStatFlag);
     880    StorageUtl_CopyPropertyToSTATSTG(pstatstg, 
     881                                     &curProperty,
     882                                     grfStatFlag);
    872883
    873884    pstatstg->grfMode = This->grfMode;
    874 
     885   
    875886    return S_OK;
    876887  }
    877 
     888 
    878889  return E_FAIL;
    879890}
    880 
    881 HRESULT WINAPI StgStreamImpl_Clone(
    882                    IStream*     iface,
    883                    IStream**    ppstm) /* [out] */
    884 {
    885   FIXME("not implemented!\n");
    886   return E_NOTIMPL;
    887 }
     891       
     892/***
     893 * This method is part of the IStream interface.
     894 *
     895 * This method returns a clone of the interface that allows for
     896 * another seek pointer
     897 *
     898 * See the documentation of IStream for more info.
     899 *
     900 * I am not totally sure what I am doing here but I presume that this
     901 * should be basically as simple as creating a new stream with the same
     902 * parent etc and positioning its seek cursor.
     903 */       
     904HRESULT WINAPI StgStreamImpl_Clone(
     905                                   IStream*     iface,
     906                                   IStream**    ppstm) /* [out] */
     907{
     908  StgStreamImpl* const This=(StgStreamImpl*)iface;
     909  HRESULT hres;
     910  StgStreamImpl* new_stream;
     911  LARGE_INTEGER seek_pos;
     912
     913  /*
     914   * Sanity check
     915   */
     916  if ( ppstm == 0 )
     917    return STG_E_INVALIDPOINTER;
     918
     919  new_stream = StgStreamImpl_Construct (This->parentStorage, This->grfMode, This->ownerProperty);
     920
     921  if (!new_stream)
     922    return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */
     923
     924  *ppstm = (IStream*) new_stream;
     925  seek_pos.QuadPart = This->currentPosition.QuadPart;
     926 
     927  hres=StgStreamImpl_Seek (*ppstm, seek_pos, STREAM_SEEK_SET, NULL);
     928 
     929  assert (SUCCEEDED(hres));
     930
     931  return S_OK;
     932}
  • trunk/src/ole32/storage32.c

    r6648 r6711  
    1 /* $Id: storage32.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/*
    32 * Compound Storage (32 bit version)
     
    3837#define FILE_BEGIN 0
    3938
     39#ifdef __WIN32OS2__
     40#undef FIXME
     41#undef TRACE
     42#ifdef DEBUG
     43#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     44#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     45#else
     46#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     47#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     48#endif
     49#endif
     50
    4051
    4152/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
     
    4859/* OLESTREAM memory structure to use for Get and Put Routines */
    4960/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
    50 typedef struct
     61typedef struct 
    5162{
    5263    DWORD dwOleID;
     
    8697    DWORD dwExtentX;
    8798    DWORD dwExtentY;
    88     DWORD dwSize;
     99    DWORD dwSize; 
    89100    BYTE *pData;
    90101}OLECONVERT_ISTORAGE_OLEPRES;
     
    111122  INT         typeOfRelation);
    112123
    113 static HRESULT adjustPropertyChain(
     124static HRESULT adjustPropertyChain( 
    114125  StorageImpl *This,
    115126  StgProperty   propertyToDelete,
     
    138149 * Declaration of miscellaneous functions...
    139150 */
    140 static HRESULT validateSTGM(DWORD stgmValue);
     151static HRESULT validateSTGM(DWORD stgmValue); 
    141152
    142153static DWORD GetShareModeFromSTGM(DWORD stgm);
     
    224235 * This method implements the common QueryInterface for all IStorage32
    225236 * implementations contained in this file.
    226  *
     237 * 
    227238 * See Windows documentation for more details on IUnknown methods.
    228239 */
     
    238249  if ( (This==0) || (ppvObject==0) )
    239250    return E_INVALIDARG;
    240 
     251 
    241252  /*
    242253   * Initialize the return parameter.
    243254   */
    244255  *ppvObject = 0;
    245 
     256 
    246257  /*
    247258   * Compare the riid with the interface IDs implemented by this object.
    248259   */
    249   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     260  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    250261  {
    251262    *ppvObject = (IStorage*)This;
    252263  }
    253   else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0)
     264  else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 
    254265  {
    255266    *ppvObject = (IStorage*)This;
    256267  }
    257 
     268 
    258269  /*
    259270   * Check that we obtained an interface.
     
    261272  if ((*ppvObject)==0)
    262273    return E_NOINTERFACE;
    263 
     274 
    264275  /*
    265276   * Query Interface always increases the reference count by one when it is
     
    270281  return S_OK;
    271282}
    272 
     283       
    273284/************************************************************************
    274285 * Storage32BaseImpl_AddRef (IUnknown)
     
    276287 * This method implements the common AddRef for all IStorage32
    277288 * implementations contained in this file.
    278  *
     289 * 
    279290 * See Windows documentation for more details on IUnknown methods.
    280291 */
    281 ULONG WINAPI StorageBaseImpl_AddRef(
     292ULONG WINAPI StorageBaseImpl_AddRef( 
    282293            IStorage* iface)
    283294{
     
    287298  return This->ref;
    288299}
    289 
     300       
    290301/************************************************************************
    291302 * Storage32BaseImpl_Release (IUnknown)
     
    293304 * This method implements the common Release for all IStorage32
    294305 * implementations contained in this file.
    295  *
     306 * 
    296307 * See Windows documentation for more details on IUnknown methods.
    297308 */
    298 ULONG WINAPI StorageBaseImpl_Release(
     309ULONG WINAPI StorageBaseImpl_Release( 
    299310      IStorage* iface)
    300311{
     
    311322  {
    312323    /*
    313      * Since we are using a system of base-classes, we want to call the
    314      * destructor of the appropriate derived class. To do this, we are
     324     * Since we are using a system of base-classes, we want to call the 
     325     * destructor of the appropriate derived class. To do this, we are 
    315326     * using virtual functions to implement the destructor.
    316327     */
     
    319330    return 0;
    320331  }
    321 
     332 
    322333  return This->ref;
    323334}
     
    330341 * See Windows documentation for more details on IStorage methods.
    331342 */
    332 HRESULT WINAPI StorageBaseImpl_OpenStream(
     343HRESULT WINAPI StorageBaseImpl_OpenStream( 
    333344  IStorage*        iface,
    334345  const OLECHAR*   pwcsName,  /* [string][in] */
    335346  void*            reserved1, /* [unique][in] */
    336   DWORD            grfMode,   /* [in]  */
    337   DWORD            reserved2, /* [in]  */
    338   IStream**        ppstm)     /* [out] */
     347  DWORD            grfMode,   /* [in]  */       
     348  DWORD            reserved2, /* [in]  */       
     349  IStream**        ppstm)     /* [out] */       
    339350{
    340351  ICOM_THIS(StorageBaseImpl,iface);
     
    344355  ULONG             foundPropertyIndex;
    345356
    346   TRACE("(%p, %s, %p, %lx, %ld, %p)\n",
    347     iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
     357  TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 
     358        iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
    348359
    349360  /*
     
    352363  if ( (pwcsName==NULL) || (ppstm==0) )
    353364    return E_INVALIDARG;
    354 
     365 
    355366  /*
    356367   * Initialize the out parameter
    357368   */
    358369  *ppstm = 0;
    359 
     370 
    360371  /*
    361372   * Validate the STGM flags
     
    376387   */
    377388  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    378     This->ancestorStorage,
     389    This->ancestorStorage, 
    379390    This->rootPropertySetIndex);
    380 
     391 
    381392  /*
    382393   * Search the enumeration for the property with the given name
     
    386397    pwcsName,
    387398    &currentProperty);
    388 
     399 
    389400  /*
    390401   * Delete the property enumeration since we don't need it anymore
    391402   */
    392403  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    393 
     404 
    394405  /*
    395406   * If it was found, construct the stream object and return a pointer to it.
    396407   */
    397   if ( (foundPropertyIndex!=PROPERTY_NULL) &&
     408  if ( (foundPropertyIndex!=PROPERTY_NULL) && 
    398409       (currentProperty.propertyType==PROPTYPE_STREAM) )
    399410  {
    400411    newStream = StgStreamImpl_Construct(This, grfMode, foundPropertyIndex);
    401 
     412   
    402413    if (newStream!=0)
    403414    {
     
    406417
    407418      /*
    408        * Since we are returning a pointer to the interface, we have to
     419       * Since we are returning a pointer to the interface, we have to 
    409420       * nail down the reference.
    410421       */
    411422      StgStreamImpl_AddRef(*ppstm);
    412 
     423     
    413424      return S_OK;
    414425    }
    415 
     426   
    416427    return E_OUTOFMEMORY;
    417428  }
    418 
     429 
    419430  return STG_E_FILENOTFOUND;
    420431}
     
    424435 *
    425436 * This method will open a new storage object from the current storage.
    426  *
     437 * 
    427438 * See Windows documentation for more details on IStorage methods.
    428  */
    429 HRESULT WINAPI StorageBaseImpl_OpenStorage(
     439 */       
     440HRESULT WINAPI StorageBaseImpl_OpenStorage( 
    430441  IStorage*        iface,
    431   const OLECHAR*   pwcsName,      /* [string][unique][in] */
    432   IStorage*        pstgPriority,  /* [unique][in] */
    433   DWORD            grfMode,       /* [in] */
    434   SNB              snbExclude,    /* [unique][in] */
    435   DWORD            reserved,      /* [in] */
    436   IStorage**       ppstg)         /* [out] */
     442  const OLECHAR*   pwcsName,      /* [string][unique][in] */ 
     443  IStorage*        pstgPriority,  /* [unique][in] */         
     444  DWORD            grfMode,       /* [in] */                 
     445  SNB              snbExclude,    /* [unique][in] */         
     446  DWORD            reserved,      /* [in] */                 
     447  IStorage**       ppstg)         /* [out] */                       
    437448{
    438449  ICOM_THIS(StorageBaseImpl,iface);
     
    442453  ULONG                  foundPropertyIndex;
    443454
    444   TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n",
    445     iface, debugstr_w(pwcsName), pstgPriority,
    446     grfMode, snbExclude, reserved, ppstg);
    447 
     455  TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 
     456        iface, debugstr_w(pwcsName), pstgPriority,
     457        grfMode, snbExclude, reserved, ppstg);
     458 
    448459  /*
    449460   * Perform a sanity check on the parameters.
     
    451462  if ( (This==0) || (pwcsName==NULL) || (ppstg==0) )
    452463    return E_INVALIDARG;
    453 
     464 
    454465  /*
    455466   * Validate the STGM flags
     
    461472   * As documented.
    462473   */
    463   if ( !(grfMode & STGM_SHARE_EXCLUSIVE) ||
     474  if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 
    464475        (grfMode & STGM_DELETEONRELEASE) ||
    465476        (grfMode & STGM_PRIORITY) )
     
    470481   */
    471482  *ppstg = 0;
    472 
     483 
    473484  /*
    474485   * Create a property enumeration to search the properties
    475486   */
    476487  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    477                           This->ancestorStorage,
     488                          This->ancestorStorage, 
    478489                          This->rootPropertySetIndex);
    479 
     490 
    480491  /*
    481492   * Search the enumeration for the property with the given name
     
    485496                         pwcsName,
    486497                         &currentProperty);
    487 
     498 
    488499  /*
    489500   * Delete the property enumeration since we don't need it anymore
    490501   */
    491502  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    492 
     503 
    493504  /*
    494505   * If it was found, construct the stream object and return a pointer to it.
    495506   */
    496   if ( (foundPropertyIndex!=PROPERTY_NULL) &&
     507  if ( (foundPropertyIndex!=PROPERTY_NULL) && 
    497508       (currentProperty.propertyType==PROPTYPE_STORAGE) )
    498509  {
     
    503514                   This->ancestorStorage,
    504515                   foundPropertyIndex);
    505 
     516   
    506517    if (newStorage != 0)
    507518    {
     
    509520
    510521      /*
    511        * Since we are returning a pointer to the interface,
     522       * Since we are returning a pointer to the interface, 
    512523       * we have to nail down the reference.
    513524       */
    514525      StorageBaseImpl_AddRef(*ppstg);
    515 
     526     
    516527      return S_OK;
    517528    }
    518 
     529   
    519530    return STG_E_INSUFFICIENTMEMORY;
    520531  }
    521 
     532 
    522533  return STG_E_FILENOTFOUND;
    523534}
     
    526537 * Storage32BaseImpl_EnumElements (IStorage)
    527538 *
    528  * This method will create an enumerator object that can be used to
     539 * This method will create an enumerator object that can be used to 
    529540 * retrieve informatino about all the properties in the storage object.
    530  *
     541 * 
    531542 * See Windows documentation for more details on IStorage methods.
    532  */
    533 HRESULT WINAPI StorageBaseImpl_EnumElements(
     543 */       
     544HRESULT WINAPI StorageBaseImpl_EnumElements( 
    534545  IStorage*       iface,
    535   DWORD           reserved1, /* [in] */
    536   void*           reserved2, /* [size_is][unique][in] */
    537   DWORD           reserved3, /* [in] */
    538   IEnumSTATSTG**  ppenum)    /* [out] */
     546  DWORD           reserved1, /* [in] */                 
     547  void*           reserved2, /* [size_is][unique][in] */ 
     548  DWORD           reserved3, /* [in] */                 
     549  IEnumSTATSTG**  ppenum)    /* [out] */                 
    539550{
    540551  ICOM_THIS(StorageBaseImpl,iface);
    541552  IEnumSTATSTGImpl* newEnum;
    542553
    543   TRACE("(%p, %ld, %p, %ld, %p)\n",
    544     iface, reserved1, reserved2, reserved3, ppenum);
     554  TRACE("(%p, %ld, %p, %ld, %p)\n", 
     555        iface, reserved1, reserved2, reserved3, ppenum);
    545556
    546557  /*
     
    549560  if ( (This==0) || (ppenum==0))
    550561    return E_INVALIDARG;
    551 
     562 
    552563  /*
    553564   * Construct the enumerator.
     
    566577     */
    567578    IEnumSTATSTGImpl_AddRef(*ppenum);
    568 
     579   
    569580    return S_OK;
    570581  }
     
    577588 *
    578589 * This method will retrieve information about this storage object.
    579  *
     590 * 
    580591 * See Windows documentation for more details on IStorage methods.
    581  */
    582 HRESULT WINAPI StorageBaseImpl_Stat(
     592 */       
     593HRESULT WINAPI StorageBaseImpl_Stat( 
    583594  IStorage*        iface,
    584   STATSTG*         pstatstg,     /* [out] */
    585   DWORD            grfStatFlag)  /* [in] */
     595  STATSTG*         pstatstg,     /* [out] */ 
     596  DWORD            grfStatFlag)  /* [in] */ 
    586597{
    587598  ICOM_THIS(StorageBaseImpl,iface);
     
    589600  BOOL         readSuccessful;
    590601
    591   TRACE("(%p, %p, %lx)\n",
    592     iface, pstatstg, grfStatFlag);
     602  TRACE("(%p, %p, %lx)\n", 
     603        iface, pstatstg, grfStatFlag);
    593604
    594605  /*
     
    609620  {
    610621    StorageUtl_CopyPropertyToSTATSTG(
    611       pstatstg,
    612       &curProperty,
     622      pstatstg, 
     623      &curProperty, 
    613624      grfStatFlag);
    614 
     625   
    615626    return S_OK;
    616627  }
    617 
     628 
    618629  return E_FAIL;
    619630}
     
    622633 * Storage32BaseImpl_RenameElement (IStorage)
    623634 *
    624  * This method will rename the specified element.
     635 * This method will rename the specified element. 
    625636 *
    626637 * See Windows documentation for more details on IStorage methods.
    627  *
    628  * Implementation notes: The method used to rename consists of creating a clone
    629  *    of the deleted StgProperty object setting it with the new name and to
     638 * 
     639 * Implementation notes: The method used to rename consists of creating a clone 
     640 *    of the deleted StgProperty object setting it with the new name and to 
    630641 *    perform a DestroyElement of the old StgProperty.
    631642 */
     
    640651  ULONG             foundPropertyIndex;
    641652
    642   TRACE("(%p, %s, %s)\n",
    643     iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
     653  TRACE("(%p, %s, %s)\n", 
     654        iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
    644655
    645656  /*
     
    687698     * Setup a new property for the renamed property
    688699     */
    689     renamedProperty.sizeOfNameString =
     700    renamedProperty.sizeOfNameString = 
    690701      ( lstrlenW(pwcsNewName)+1 ) * sizeof(WCHAR);
    691 
     702 
    692703    if (renamedProperty.sizeOfNameString > PROPERTY_NAME_BUFFER_LEN)
    693704      return STG_E_INVALIDNAME;
    694 
     705 
    695706    strcpyW(renamedProperty.name, pwcsNewName);
    696 
     707 
    697708    renamedProperty.propertyType  = currentProperty.propertyType;
    698709    renamedProperty.startingBlock = currentProperty.startingBlock;
    699710    renamedProperty.size.s.LowPart  = currentProperty.size.s.LowPart;
    700711    renamedProperty.size.s.HighPart = currentProperty.size.s.HighPart;
    701 
     712 
    702713    renamedProperty.previousProperty = PROPERTY_NULL;
    703714    renamedProperty.nextProperty     = PROPERTY_NULL;
    704 
     715 
    705716    /*
    706717     * Bring the dirProperty link in case it is a storage and in which
     
    708719     */
    709720    renamedProperty.dirProperty = currentProperty.dirProperty;
    710 
    711     /* call CoFileTime to get the current time
     721 
     722    /* call CoFileTime to get the current time 
    712723    renamedProperty.timeStampS1
    713724    renamedProperty.timeStampD1
    714725    renamedProperty.timeStampS2
    715726    renamedProperty.timeStampD2
    716     renamedProperty.propertyUniqueID
     727    renamedProperty.propertyUniqueID 
    717728    */
    718 
    719     /*
     729 
     730    /* 
    720731     * Obtain a free property in the property chain
    721732     */
    722733    renamedPropertyIndex = getFreeProperty(This->ancestorStorage);
    723 
     734 
    724735    /*
    725736     * Save the new property into the new property spot
    726      */
     737     */ 
    727738    StorageImpl_WriteProperty(
    728739      This->ancestorStorage,
    729       renamedPropertyIndex,
     740      renamedPropertyIndex, 
    730741      &renamedProperty);
    731 
    732     /*
     742 
     743    /* 
    733744     * Find a spot in the property chain for our newly created property.
    734745     */
    735746    updatePropertyChain(
    736747      (StorageImpl*)This,
    737       renamedPropertyIndex,
     748      renamedPropertyIndex, 
    738749      renamedProperty);
    739750
    740751    /*
    741      * At this point the renamed property has been inserted in the tree,
    742      * now, before to Destroy the old property we must zeroed it's dirProperty
    743      * otherwise the DestroyProperty below will zap it all and we do not want
     752     * At this point the renamed property has been inserted in the tree, 
     753     * now, before to Destroy the old property we must zeroed it's dirProperty 
     754     * otherwise the DestroyProperty below will zap it all and we do not want 
    744755     * this to happen.
    745756     * Also, we fake that the old property is a storage so the DestroyProperty
    746757     * will not do a SetSize(0) on the stream data.
    747      *
     758     * 
    748759     * This means that we need to tweek the StgProperty if it is a stream or a
    749760     * non empty storage.
     
    757768    StorageImpl_WriteProperty(
    758769      This->ancestorStorage,
    759       foundPropertyIndex,
     770      foundPropertyIndex, 
    760771      &currentProperty);
    761772
    762     /*
    763      * Invoke Destroy to get rid of the ole property and automatically redo
    764      * the linking of it's previous and next members...
    765      */
    766     StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName);
     773    /* 
     774     * Invoke Destroy to get rid of the ole property and automatically redo 
     775     * the linking of it's previous and next members... 
     776     */ 
     777    StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName); 
    767778
    768779  }
     
    781792 * Storage32BaseImpl_CreateStream (IStorage)
    782793 *
    783  * This method will create a stream object within this storage
     794 * This method will create a stream object within this storage 
    784795 *
    785796 * See Windows documentation for more details on IStorage methods.
     
    799810  ULONG             foundPropertyIndex, newPropertyIndex;
    800811
    801   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
    802     iface, debugstr_w(pwcsName), grfMode,
    803     reserved1, reserved2, ppstm);
     812  TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 
     813        iface, debugstr_w(pwcsName), grfMode,
     814        reserved1, reserved2, ppstm);
    804815
    805816  /*
     
    846857  {
    847858    /*
    848      * An element with this name already exists
     859     * An element with this name already exists 
    849860     */
    850861    if (grfMode & STGM_CREATE)
    851862    {
    852       IStorage_DestroyElement(iface, pwcsName);
    853     }
    854     else
     863      IStorage_DestroyElement(iface, pwcsName); 
     864    }
     865    else 
    855866      return STG_E_FILEALREADYEXISTS;
    856867  }
    857868
    858   /*
    859    * memset the empty property
     869  /* 
     870   * memset the empty property 
    860871   */
    861872  memset(&newStreamProperty, 0, sizeof(StgProperty));
     
    878889  newStreamProperty.dirProperty      = PROPERTY_NULL;
    879890
    880   /* call CoFileTime to get the current time
     891  /* call CoFileTime to get the current time 
    881892  newStreamProperty.timeStampS1
    882893  newStreamProperty.timeStampD1
     
    888899
    889900  /*
    890    * Get a free property or create a new one
     901   * Get a free property or create a new one 
    891902   */
    892903  newPropertyIndex = getFreeProperty(This->ancestorStorage);
     
    894905  /*
    895906   * Save the new property into the new property spot
    896    */
     907   */ 
    897908  StorageImpl_WriteProperty(
    898909    This->ancestorStorage,
    899     newPropertyIndex,
     910    newPropertyIndex, 
    900911    &newStreamProperty);
    901912
    902   /*
     913  /* 
    903914   * Find a spot in the property chain for our newly created property.
    904915   */
    905916  updatePropertyChain(
    906917    (StorageImpl*)This,
    907     newPropertyIndex,
     918    newPropertyIndex, 
    908919    newStreamProperty);
    909920
    910   /*
     921  /* 
    911922   * Open the stream to return it.
    912923   */
     
    934945 * Storage32BaseImpl_SetClass (IStorage)
    935946 *
    936  * This method will write the specified CLSID in the property of this
     947 * This method will write the specified CLSID in the property of this 
    937948 * storage.
    938949 *
     
    949960
    950961  TRACE("(%p, %p)\n", iface, clsid);
    951 
     962 
    952963  success = StorageImpl_ReadProperty(This->ancestorStorage,
    953964                                       This->rootPropertySetIndex,
     
    970981** Storage32Impl implementation
    971982*/
    972 
     983       
    973984/************************************************************************
    974985 * Storage32Impl_CreateStorage (IStorage)
     
    978989 * See Windows documentation for more details on IStorage methods.
    979990 */
    980 HRESULT WINAPI StorageImpl_CreateStorage(
     991HRESULT WINAPI StorageImpl_CreateStorage( 
    981992  IStorage*      iface,
    982   const OLECHAR  *pwcsName, /* [string][in] */
    983   DWORD            grfMode,   /* [in] */
    984   DWORD            reserved1, /* [in] */
    985   DWORD            reserved2, /* [in] */
    986   IStorage       **ppstg)   /* [out] */
     993  const OLECHAR  *pwcsName, /* [string][in] */ 
     994  DWORD            grfMode,   /* [in] */ 
     995  DWORD            reserved1, /* [in] */ 
     996  DWORD            reserved2, /* [in] */ 
     997  IStorage       **ppstg)   /* [out] */ 
    987998{
    988999  StorageImpl* const This=(StorageImpl*)iface;
     
    9951006  HRESULT          hr;
    9961007
    997   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
    998     iface, debugstr_w(pwcsName), grfMode,
    999     reserved1, reserved2, ppstg);
    1000 
     1008  TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 
     1009        iface, debugstr_w(pwcsName), grfMode,
     1010        reserved1, reserved2, ppstg);
     1011 
    10011012  /*
    10021013   * Validate parameters
     
    10341045  {
    10351046    /*
    1036      * An element with this name already exists
     1047     * An element with this name already exists 
    10371048     */
    10381049    if (grfMode & STGM_CREATE)
    1039       IStorage_DestroyElement(iface, pwcsName);
    1040     else
     1050      IStorage_DestroyElement(iface, pwcsName); 
     1051    else 
    10411052      return STG_E_FILEALREADYEXISTS;
    10421053  }
    10431054
    1044   /*
    1045    * memset the empty property
     1055  /* 
     1056   * memset the empty property 
    10461057   */
    10471058  memset(&newProperty, 0, sizeof(StgProperty));
     
    10631074  newProperty.dirProperty      = PROPERTY_NULL;
    10641075
    1065   /* call CoFileTime to get the current time
     1076  /* call CoFileTime to get the current time 
    10661077  newProperty.timeStampS1
    10671078  newProperty.timeStampD1
     
    10721083  /*  newStorageProperty.propertyUniqueID */
    10731084
    1074   /*
     1085  /* 
    10751086   * Obtain a free property in the property chain
    10761087   */
     
    10791090  /*
    10801091   * Save the new property into the new property spot
    1081    */
     1092   */ 
    10821093  StorageImpl_WriteProperty(
    10831094    This->ancestorStorage,
    1084     newPropertyIndex,
     1095    newPropertyIndex, 
    10851096    &newProperty);
    10861097
    1087   /*
     1098  /* 
    10881099   * Find a spot in the property chain for our newly created property.
    10891100   */
    10901101  updatePropertyChain(
    10911102    This,
    1092     newPropertyIndex,
     1103    newPropertyIndex, 
    10931104    newProperty);
    10941105
    1095   /*
     1106  /* 
    10961107   * Open it to get a pointer to return.
    10971108   */
     
    11101121  }
    11111122
    1112 
     1123 
    11131124  return S_OK;
    11141125}
     
    11411152      if (currentProperty.sizeOfNameString == 0)
    11421153      {
    1143         /*
     1154        /* 
    11441155         * The property existis and is available, we found it.
    11451156         */
     
    11581169  } while (newPropertyIndex == PROPERTY_NULL);
    11591170
    1160   /*
    1161    * grow the property chain
     1171  /* 
     1172   * grow the property chain 
    11621173   */
    11631174  if (! readSuccessful)
     
    11691180    ULONG          blockCount    = 0;
    11701181
    1171     /*
    1172      * obtain the new count of property blocks
     1182    /* 
     1183     * obtain the new count of property blocks 
    11731184     */
    11741185    blockCount = BlockChainStream_GetCount(
    11751186                   storage->ancestorStorage->rootBlockChain)+1;
    11761187
    1177     /*
    1178      * initialize the size used by the property stream
     1188    /* 
     1189     * initialize the size used by the property stream 
    11791190     */
    11801191    newSize.s.HighPart = 0;
    11811192    newSize.s.LowPart  = storage->bigBlockSize * blockCount;
    11821193
    1183     /*
    1184      * add a property block to the property chain
     1194    /* 
     1195     * add a property block to the property chain 
    11851196     */
    11861197    BlockChainStream_SetSize(storage->ancestorStorage->rootBlockChain, newSize);
    11871198
    1188     /*
    1189      * memset the empty property in order to initialize the unused newly
     1199    /* 
     1200     * memset the empty property in order to initialize the unused newly 
    11901201     * created property
    11911202     */
    11921203    memset(&emptyProperty, 0, sizeof(StgProperty));
    11931204
    1194     /*
     1205    /* 
    11951206     * initialize them
    11961207     */
    1197     lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount;
    1198 
     1208    lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 
     1209   
    11991210    for(
    12001211      propertyIndex = newPropertyIndex;
     
    12041215      StorageImpl_WriteProperty(
    12051216        storage->ancestorStorage,
    1206         propertyIndex,
     1217        propertyIndex, 
    12071218        &emptyProperty);
    12081219    }
     
    12161227 * Internal Method
    12171228 *
    1218  * Case insensitive comparaison of StgProperty.name by first considering
     1229 * Case insensitive comparaison of StgProperty.name by first considering 
    12191230 * their size.
    12201231 *
     
    12291240  LONG diff      = lstrlenW(newProperty) - lstrlenW(currentProperty);
    12301241
    1231   if (diff == 0)
    1232   {
    1233     /*
     1242  if (diff == 0) 
     1243  {
     1244    /* 
    12341245     * We compare the string themselves only when they are of the same lenght
    12351246     */
     
    12371248  }
    12381249
    1239   return diff;
     1250  return diff; 
    12401251}
    12411252
     
    12491260  StorageImpl *storage,
    12501261  ULONG         newPropertyIndex,
    1251   StgProperty   newProperty)
     1262  StgProperty   newProperty) 
    12521263{
    12531264  StgProperty currentProperty;
     
    12621273  if (currentProperty.dirProperty != PROPERTY_NULL)
    12631274  {
    1264     /*
     1275    /* 
    12651276     * The root storage contains some element, therefore, start the research
    12661277     * for the appropriate location.
     
    12751286
    12761287    /*
    1277      * Read
     1288     * Read 
    12781289     */
    12791290    StorageImpl_ReadProperty(storage->ancestorStorage,
     
    12881299    {
    12891300      LONG diff = propertyNameCmp( newProperty.name, currentProperty.name);
    1290 
     1301 
    12911302      if (diff < 0)
    12921303      {
     
    13271338      else
    13281339      {
    1329     /*
    1330     * Trying to insert an item with the same name in the
    1331     * subtree structure.
    1332     */
    1333     assert(FALSE);
     1340        /*
     1341        * Trying to insert an item with the same name in the
     1342        * subtree structure.
     1343        */
     1344        assert(FALSE);
    13341345      }
    13351346
     
    13401351  else
    13411352  {
    1342     /*
     1353    /* 
    13431354     * The root storage is empty, link the new property to it's dir property
    13441355     */
     
    13501361}
    13511362
    1352 
     1363     
    13531364/*************************************************************************
    13541365 * CopyTo (IStorage)
    13551366 */
    1356 HRESULT WINAPI StorageImpl_CopyTo(
     1367HRESULT WINAPI StorageImpl_CopyTo( 
    13571368  IStorage*   iface,
    1358   DWORD       ciidExclude,  /* [in] */
    1359   const IID*  rgiidExclude, /* [size_is][unique][in] */
    1360   SNB         snbExclude,   /* [unique][in] */
    1361   IStorage*   pstgDest)     /* [unique][in] */
     1369  DWORD       ciidExclude,  /* [in] */ 
     1370  const IID*  rgiidExclude, /* [size_is][unique][in] */ 
     1371  SNB         snbExclude,   /* [unique][in] */ 
     1372  IStorage*   pstgDest)     /* [unique][in] */ 
    13621373{
    13631374  IEnumSTATSTG *elements     = 0;
     
    13701381    FIXME("Exclude option not implemented\n");
    13711382
    1372   TRACE("(%p, %ld, %p, %p, %p)\n",
    1373     iface, ciidExclude, rgiidExclude,
    1374     snbExclude, pstgDest);
     1383  TRACE("(%p, %ld, %p, %p, %p)\n", 
     1384        iface, ciidExclude, rgiidExclude,
     1385        snbExclude, pstgDest);
    13751386
    13761387  /*
     
    13801391    return STG_E_INVALIDPOINTER;
    13811392
    1382   /*
     1393  /* 
    13831394   * Enumerate the elements
    13841395   */
     
    13931404  IStorage_Stat( iface, &curElement, STATFLAG_NONAME);
    13941405  IStorage_SetClass( pstgDest, &curElement.clsid );
    1395 
     1406 
    13961407  do
    13971408  {
     
    14131424       */
    14141425      hr = IStorage_OpenStorage( iface, curElement.pwcsName, NULL,
    1415                 STGM_READ|STGM_SHARE_EXCLUSIVE,
    1416                 NULL, 0, &pstgChild );
     1426                                STGM_READ|STGM_SHARE_EXCLUSIVE,
     1427                                NULL, 0, &pstgChild );
    14171428
    14181429      if (hr != S_OK)
     
    14251436      if (pstgChild == pstgDest)
    14261437      {
    1427     IEnumSTATSTG_Release(elements);
    1428 
    1429     return STG_E_ACCESSDENIED;
     1438        IEnumSTATSTG_Release(elements);
     1439
     1440        return STG_E_ACCESSDENIED;
    14301441      }
    1431 
     1442           
    14321443      /*
    14331444       * create a new storage in destination storage
     
    14351446      hr = IStorage_CreateStorage( pstgDest, curElement.pwcsName,
    14361447                                   STGM_FAILIFTHERE|STGM_WRITE|STGM_SHARE_EXCLUSIVE,
    1437                    0, 0,
     1448                                   0, 0,
    14381449                                   &pstgTmp );
    14391450      /*
     
    14461457                                   NULL, 0, &pstgTmp );
    14471458      }
    1448 
     1459       
    14491460      if (hr != S_OK)
    14501461        break;
    14511462
    1452 
     1463       
    14531464      /*
    14541465       * do the copy recursively
     
    14561467      hr = IStorage_CopyTo( pstgChild, ciidExclude, rgiidExclude,
    14571468                               snbExclude, pstgTmp );
    1458 
     1469                               
    14591470      IStorage_Release( pstgTmp );
    14601471      IStorage_Release( pstgChild );
     
    14771488       */
    14781489      hr = IStorage_OpenStream( iface, curElement.pwcsName, NULL,
    1479                 STGM_READ|STGM_SHARE_EXCLUSIVE,
    1480                 0, &pstrChild );
     1490                                STGM_READ|STGM_SHARE_EXCLUSIVE,
     1491                                0, &pstrChild );
    14811492
    14821493      if (hr != S_OK)
     
    14921503       */
    14931504      IStream_SetSize(pstrTmp, strStat.cbSize);
    1494 
     1505     
    14951506      /*
    14961507       * do the copy
     
    14981509      hr = IStream_CopyTo( pstrChild, pstrTmp, strStat.cbSize,
    14991510                           NULL, NULL );
    1500 
     1511                               
    15011512      IStream_Release( pstrTmp );
    15021513      IStream_Release( pstrChild );
     
    15131524   */
    15141525  IEnumSTATSTG_Release(elements);
    1515 
     1526 
    15161527  return hr;
    15171528}
    1518 
     1529       
    15191530/*************************************************************************
    15201531 * MoveElementTo (IStorage)
    15211532 */
    1522 HRESULT WINAPI StorageImpl_MoveElementTo(
     1533HRESULT WINAPI StorageImpl_MoveElementTo( 
    15231534  IStorage*     iface,
    1524   const OLECHAR *pwcsName,   /* [string][in] */
    1525   IStorage      *pstgDest,   /* [unique][in] */
    1526   const OLECHAR *pwcsNewName,/* [string][in] */
    1527   DWORD           grfFlags)    /* [in] */
     1535  const OLECHAR *pwcsName,   /* [string][in] */ 
     1536  IStorage      *pstgDest,   /* [unique][in] */ 
     1537  const OLECHAR *pwcsNewName,/* [string][in] */ 
     1538  DWORD           grfFlags)    /* [in] */ 
    15281539{
    15291540  FIXME("not implemented!\n");
    15301541  return E_NOTIMPL;
    15311542}
    1532 
     1543       
    15331544/*************************************************************************
    15341545 * Commit (IStorage)
    15351546 */
    1536 HRESULT WINAPI StorageImpl_Commit(
     1547HRESULT WINAPI StorageImpl_Commit( 
    15371548  IStorage*   iface,
    1538   DWORD         grfCommitFlags)/* [in] */
     1549  DWORD         grfCommitFlags)/* [in] */ 
    15391550{
    15401551  FIXME("(%ld): stub!\n", grfCommitFlags);
    15411552  return S_OK;
    15421553}
    1543 
     1554       
    15441555/*************************************************************************
    15451556 * Revert (IStorage)
    15461557 */
    1547 HRESULT WINAPI StorageImpl_Revert(
     1558HRESULT WINAPI StorageImpl_Revert( 
    15481559  IStorage* iface)
    15491560{
     
    15551566 * DestroyElement (IStorage)
    15561567 *
    1557  * Stategy: This implementation is build this way for simplicity not for speed.
     1568 * Stategy: This implementation is build this way for simplicity not for speed. 
    15581569 *          I always delete the top most element of the enumeration and adjust
    1559  *          the deleted element pointer all the time.  This takes longer to
    1560  *          do but allow to reinvoke DestroyElement whenever we encounter a
     1570 *          the deleted element pointer all the time.  This takes longer to 
     1571 *          do but allow to reinvoke DestroyElement whenever we encounter a 
    15611572 *          storage object.  The optimisation reside in the usage of another
    1562  *          enumeration stategy that would give all the leaves of a storage
     1573 *          enumeration stategy that would give all the leaves of a storage 
    15631574 *          first. (postfix order)
    15641575 */
    1565 HRESULT WINAPI StorageImpl_DestroyElement(
     1576HRESULT WINAPI StorageImpl_DestroyElement( 
    15661577  IStorage*     iface,
    1567   const OLECHAR *pwcsName)/* [string][in] */
     1578  const OLECHAR *pwcsName)/* [string][in] */ 
    15681579{
    15691580  StorageImpl* const This=(StorageImpl*)iface;
     
    15781589  ULONG             parentPropertyId;
    15791590
    1580   TRACE("(%p, %s)\n",
    1581     iface, debugstr_w(pwcsName));
     1591  TRACE("(%p, %s)\n", 
     1592        iface, debugstr_w(pwcsName));
    15821593
    15831594  /*
    15841595   * Perform a sanity check on the parameters.
    15851596   */
    1586   if (pwcsName==NULL)
     1597  if (pwcsName==NULL) 
    15871598    return STG_E_INVALIDPOINTER;
    1588 
     1599 
    15891600  /*
    15901601   * Create a property enumeration to search the property with the given name
    15911602   */
    15921603  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    1593     This->ancestorStorage,
     1604    This->ancestorStorage, 
    15941605    This->rootPropertySetIndex);
    1595 
     1606 
    15961607  foundPropertyIndexToDelete = IEnumSTATSTGImpl_FindProperty(
    15971608    propertyEnumeration,
     
    16011612  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    16021613
    1603   if ( foundPropertyIndexToDelete == PROPERTY_NULL )
     1614  if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 
    16041615  {
    16051616    return STG_E_FILENOTFOUND;
    16061617  }
    16071618
    1608   /*
    1609    * Find the parent property of the property to delete (the one that
    1610    * link to it).  If This->dirProperty == foundPropertyIndexToDelete,
     1619  /* 
     1620   * Find the parent property of the property to delete (the one that 
     1621   * link to it).  If This->dirProperty == foundPropertyIndexToDelete, 
    16111622   * the parent is This. Otherwise, the parent is one of it's sibling...
    16121623   */
    16131624
    1614   /*
     1625  /* 
    16151626   * First, read This's StgProperty..
    16161627   */
    1617   res = StorageImpl_ReadProperty(
     1628  res = StorageImpl_ReadProperty( 
    16181629          This->ancestorStorage,
    16191630          This->rootPropertySetIndex,
     
    16221633  assert(res==TRUE);
    16231634
    1624   /*
     1635  /* 
    16251636   * Second, check to see if by any chance the actual storage (This) is not
    16261637   * the parent of the property to delete... We never know...
     
    16281639  if ( parentProperty.dirProperty == foundPropertyIndexToDelete )
    16291640  {
    1630     /*
     1641    /* 
    16311642     * Set data as it would have been done in the else part...
    16321643     */
     
    16341645    parentPropertyId = This->rootPropertySetIndex;
    16351646  }
    1636   else
    1637   {
    1638     /*
    1639      * Create a property enumeration to search the parent properties, and
     1647  else 
     1648  { 
     1649    /*
     1650     * Create a property enumeration to search the parent properties, and 
    16401651     * delete it once done.
    16411652     */
     
    16431654
    16441655    propertyEnumeration2 = IEnumSTATSTGImpl_Construct(
    1645       This->ancestorStorage,
     1656      This->ancestorStorage, 
    16461657      This->rootPropertySetIndex);
    1647 
     1658 
    16481659    typeOfRelation = IEnumSTATSTGImpl_FindParentProperty(
    16491660      propertyEnumeration2,
     
    16551666  }
    16561667
    1657   if ( propertyToDelete.propertyType == PROPTYPE_STORAGE )
     1668  if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 
    16581669  {
    16591670    hr = deleteStorageProperty(
    1660            This,
     1671           This, 
    16611672           foundPropertyIndexToDelete,
    16621673           propertyToDelete);
    1663   }
     1674  } 
    16641675  else if ( propertyToDelete.propertyType == PROPTYPE_STREAM )
    16651676  {
    16661677    hr = deleteStreamProperty(
    1667            This,
     1678           This, 
    16681679           foundPropertyIndexToDelete,
    16691680           propertyToDelete);
    16701681  }
    16711682
    1672   if (hr!=S_OK)
     1683  if (hr!=S_OK) 
    16731684    return hr;
    16741685
     
    16781689  hr = adjustPropertyChain(
    16791690        This,
    1680         propertyToDelete,
     1691        propertyToDelete, 
    16811692        parentProperty,
    16821693        parentPropertyId,
     
    17221733  }
    17231734
    1724   /*
     1735  /* 
    17251736   * Enumerate the elements
    17261737   */
     
    17361747    {
    17371748      destroyHr = StorageImpl_DestroyElement(
    1738                     (IStorage*)childStorage,
     1749                    (IStorage*)childStorage, 
    17391750                    (OLECHAR*)currentElement.pwcsName);
    17401751
     
    17611772  IStorage_Release(childStorage);
    17621773  IEnumSTATSTG_Release(elements);
    1763 
     1774   
    17641775  return destroyHr;
    17651776}
     
    17911802         0,
    17921803         &pis);
    1793 
     1804   
    17941805  if (hr!=S_OK)
    17951806  {
     
    17971808  }
    17981809
    1799   /*
    1800    * Zap the stream
    1801    */
    1802   hr = IStream_SetSize(pis, size);
     1810  /* 
     1811   * Zap the stream 
     1812   */ 
     1813  hr = IStream_SetSize(pis, size); 
    18031814
    18041815  if(hr != S_OK)
     
    18121823  IStream_Release(pis);
    18131824
    1814   /*
     1825  /* 
    18151826   * Invalidate the property by zeroing it's name member.
    18161827   */
    18171828  propertyToDelete.sizeOfNameString = 0;
    18181829
    1819   /*
     1830  /* 
    18201831   * Here we should re-read the property so we get the updated pointer
    18211832   * but since we are here to zap it, I don't do it...
    18221833   */
    18231834  StorageImpl_WriteProperty(
    1824     parentStorage->ancestorStorage,
     1835    parentStorage->ancestorStorage, 
    18251836    indexOfPropertyToDelete,
    18261837    &propertyToDelete);
     
    18511862  res = StorageImpl_ReadProperty(
    18521863          storage->ancestorStorage,
    1853           storePropertyIndex,
     1864          storePropertyIndex, 
    18541865          &storeProperty);
    18551866
     
    18651876      return findPlaceholder(
    18661877               storage,
    1867                propertyIndexToStore,
     1878               propertyIndexToStore, 
    18681879               storeProperty.previousProperty,
    18691880               typeOfRelation);
     
    18801891      return findPlaceholder(
    18811892               storage,
    1882                propertyIndexToStore,
     1893               propertyIndexToStore, 
    18831894               storeProperty.nextProperty,
    18841895               typeOfRelation);
     
    18881899      storeProperty.nextProperty = propertyIndexToStore;
    18891900    }
    1890   }
     1901  } 
    18911902  else if (typeOfRelation == PROPERTY_RELATION_DIR)
    18921903  {
     
    18951906      return findPlaceholder(
    18961907               storage,
    1897                propertyIndexToStore,
     1908               propertyIndexToStore, 
    18981909               storeProperty.dirProperty,
    18991910               typeOfRelation);
     
    19071918  hr = StorageImpl_WriteProperty(
    19081919         storage->ancestorStorage,
    1909          storePropertyIndex,
     1920         storePropertyIndex, 
    19101921         &storeProperty);
    19111922
     
    19221933 * Internal Method
    19231934 *
    1924  * This method takes the previous and the next property link of a property
     1935 * This method takes the previous and the next property link of a property 
    19251936 * to be deleted and find them a place in the Storage.
    19261937 */
    1927 static HRESULT adjustPropertyChain(
     1938static HRESULT adjustPropertyChain( 
    19281939  StorageImpl *This,
    19291940  StgProperty   propertyToDelete,
     
    19391950  HRESULT hr                     = S_OK;
    19401951  BOOL  res                    = TRUE;
    1941 
    1942   if (typeOfRelation == PROPERTY_RELATION_PREVIOUS)
    1943   {
    1944     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    1945     {
    1946       /*
     1952 
     1953  if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 
     1954  {
     1955    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     1956    {
     1957      /* 
    19471958       * Set the parent previous to the property to delete previous
    19481959       */
    19491960      newLinkProperty = propertyToDelete.previousProperty;
    19501961
    1951       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     1962      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    19521963      {
    19531964        /*
    1954          * We also need to find a storage for the other link, setup variables
     1965         * We also need to find a storage for the other link, setup variables 
    19551966         * to do this at the end...
    1956          */
     1967         */     
    19571968        needToFindAPlaceholder = TRUE;
    19581969        storeNode              = propertyToDelete.previousProperty;
     
    19601971        relationType           = PROPERTY_RELATION_NEXT;
    19611972      }
    1962     }
    1963     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    1964     {
    1965       /*
     1973    } 
     1974    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     1975    {
     1976      /* 
    19661977       * Set the parent previous to the property to delete next
    19671978       */
    19681979      newLinkProperty = propertyToDelete.nextProperty;
    19691980    }
    1970 
    1971     /*
     1981   
     1982    /* 
    19721983     * Link it for real...
    1973      */
     1984     */ 
    19741985    parentProperty.previousProperty = newLinkProperty;
    1975 
    1976   }
    1977   else if (typeOfRelation == PROPERTY_RELATION_NEXT)
    1978   {
    1979     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    1980     {
    1981       /*
     1986 
     1987  } 
     1988  else if (typeOfRelation == PROPERTY_RELATION_NEXT) 
     1989  {
     1990    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     1991    {
     1992      /* 
    19821993       * Set the parent next to the property to delete next previous
    19831994       */
    19841995      newLinkProperty = propertyToDelete.previousProperty;
    1985 
    1986       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     1996     
     1997      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    19871998      {
    19881999        /*
    1989          * We also need to find a storage for the other link, setup variables
     2000         * We also need to find a storage for the other link, setup variables 
    19902001         * to do this at the end...
    1991          */
     2002         */     
    19922003        needToFindAPlaceholder = TRUE;
    19932004        storeNode              = propertyToDelete.previousProperty;
     
    19952006        relationType           = PROPERTY_RELATION_NEXT;
    19962007      }
    1997     }
    1998     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    1999     {
    2000       /*
     2008    } 
     2009    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     2010    {
     2011      /* 
    20012012       * Set the parent next to the property to delete next
    20022013       */
     
    20042015    }
    20052016
    2006     /*
     2017    /* 
    20072018     * Link it for real...
    2008      */
     2019     */ 
    20092020    parentProperty.nextProperty = newLinkProperty;
    2010   }
     2021  } 
    20112022  else /* (typeOfRelation == PROPERTY_RELATION_DIR) */
    20122023  {
    2013     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    2014     {
    2015       /*
     2024    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     2025    {
     2026      /* 
    20162027       * Set the parent dir to the property to delete previous
    20172028       */
    20182029      newLinkProperty = propertyToDelete.previousProperty;
    20192030
    2020       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     2031      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    20212032      {
    20222033        /*
    2023          * We also need to find a storage for the other link, setup variables
     2034         * We also need to find a storage for the other link, setup variables 
    20242035         * to do this at the end...
    2025          */
     2036         */     
    20262037        needToFindAPlaceholder = TRUE;
    20272038        storeNode              = propertyToDelete.previousProperty;
     
    20292040        relationType           = PROPERTY_RELATION_NEXT;
    20302041      }
    2031     }
    2032     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    2033     {
    2034       /*
     2042    } 
     2043    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     2044    {
     2045      /* 
    20352046       * Set the parent dir to the property to delete next
    20362047       */
     
    20382049    }
    20392050
    2040     /*
     2051    /* 
    20412052     * Link it for real...
    2042      */
     2053     */ 
    20432054    parentProperty.dirProperty = newLinkProperty;
    20442055  }
    20452056
    2046   /*
    2047    * Write back the parent property
     2057  /* 
     2058   * Write back the parent property   
    20482059   */
    20492060  res = StorageImpl_WriteProperty(
    2050           This->ancestorStorage,
     2061          This->ancestorStorage, 
    20512062          parentPropertyId,
    20522063          &parentProperty);
     
    20572068
    20582069  /*
    2059    * If a placeholder is required for the other link, then, find one and
     2070   * If a placeholder is required for the other link, then, find one and 
    20602071   * get out of here...
    20612072   */
    2062   if (needToFindAPlaceholder)
     2073  if (needToFindAPlaceholder) 
    20632074  {
    20642075    hr = findPlaceholder(
    2065            This,
    2066            toStoreNode,
     2076           This, 
     2077           toStoreNode, 
    20672078           storeNode,
    20682079           relationType);
     
    20762087 * SetElementTimes (IStorage)
    20772088 */
    2078 HRESULT WINAPI StorageImpl_SetElementTimes(
     2089HRESULT WINAPI StorageImpl_SetElementTimes( 
    20792090  IStorage*     iface,
    2080   const OLECHAR *pwcsName,/* [string][in] */
    2081   const FILETIME  *pctime,  /* [in] */
    2082   const FILETIME  *patime,  /* [in] */
    2083   const FILETIME  *pmtime)  /* [in] */
     2091  const OLECHAR *pwcsName,/* [string][in] */ 
     2092  const FILETIME  *pctime,  /* [in] */ 
     2093  const FILETIME  *patime,  /* [in] */ 
     2094  const FILETIME  *pmtime)  /* [in] */ 
    20842095{
    20852096  FIXME("not implemented!\n");
     
    20902101 * SetStateBits (IStorage)
    20912102 */
    2092 HRESULT WINAPI StorageImpl_SetStateBits(
     2103HRESULT WINAPI StorageImpl_SetStateBits( 
    20932104  IStorage*   iface,
    2094   DWORD         grfStateBits,/* [in] */
    2095   DWORD         grfMask)     /* [in] */
     2105  DWORD         grfStateBits,/* [in] */ 
     2106  DWORD         grfMask)     /* [in] */ 
    20962107{
    20972108  FIXME("not implemented!\n");
     
    21112122  BOOL      readSuccessful;
    21122123  ULONG       currentPropertyIndex;
    2113 
     2124 
    21142125  if ( FAILED( validateSTGM(openFlags) ))
    21152126    return STG_E_INVALIDFLAG;
    21162127
    21172128  memset(This, 0, sizeof(StorageImpl));
    2118 
     2129 
    21192130  /*
    21202131   * Initialize the virtual fgunction table.
     
    21222133  ICOM_VTBL(This)    = &Storage32Impl_Vtbl;
    21232134  This->v_destructor = &StorageImpl_Destroy;
    2124 
     2135 
    21252136  /*
    21262137   * This is the top-level storage so initialize the ancester pointer
     
    21282139   */
    21292140  This->ancestorStorage = This;
    2130 
     2141 
    21312142  /*
    21322143   * Initialize the physical support of the storage.
    21332144   */
    21342145  This->hFile = hFile;
    2135 
     2146 
    21362147  /*
    21372148   * Initialize the big block cache.
     
    21472158  if (This->bigBlockFile == 0)
    21482159    return E_FAIL;
    2149 
     2160 
    21502161  if (fileCreate)
    21512162  {
     
    21592170     * - There is no small block depot
    21602171     */
    2161     memset( This->bigBlockDepotStart,
    2162             BLOCK_UNUSED,
     2172    memset( This->bigBlockDepotStart,     
     2173            BLOCK_UNUSED, 
    21632174            sizeof(This->bigBlockDepotStart));
    21642175
     
    22142225   */
    22152226  This->prevFreeBlock = 0;
    2216 
     2227 
    22172228  /*
    22182229   * Create the block chain abstractions.
    22192230   */
    2220   This->rootBlockChain =
     2231  This->rootBlockChain = 
    22212232    BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL);
    22222233
    22232234  This->smallBlockDepotChain = BlockChainStream_Construct(
    2224                                  This,
    2225                                  &This->smallBlockDepotStart,
     2235                                 This, 
     2236                                 &This->smallBlockDepotStart, 
    22262237                                 PROPERTY_NULL);
    22272238
    22282239  /*
    2229    * Write the root property
     2240   * Write the root property 
    22302241   */
    22312242  if (fileCreate)
     
    22542265   */
    22552266  currentPropertyIndex = 0;
    2256 
     2267 
    22572268  do
    22582269  {
    22592270    readSuccessful = StorageImpl_ReadProperty(
    2260                       This,
    2261                       currentPropertyIndex,
     2271                      This, 
     2272                      currentPropertyIndex, 
    22622273                      &currentProperty);
    2263 
     2274   
    22642275    if (readSuccessful)
    22652276    {
     
    22722283
    22732284    currentPropertyIndex++;
    2274 
     2285   
    22752286  } while (readSuccessful && (This->rootPropertySetIndex == PROPERTY_NULL) );
    2276 
     2287 
    22772288  if (!readSuccessful)
    22782289  {
     
    22852296   */
    22862297  This->smallBlockRootChain = BlockChainStream_Construct(
    2287                                 This,
    2288                                 NULL,
     2298                                This, 
     2299                                NULL, 
    22892300                                This->rootPropertySetIndex);
    2290 
     2301 
    22912302  return hr;
    22922303}
     
    28212832
    28222833    StorageUtl_ReadWord(
    2823       headerBigBlock,
    2824       OFFSET_BIGBLOCKSIZEBITS,
     2834      headerBigBlock, 
     2835      OFFSET_BIGBLOCKSIZEBITS,   
    28252836      &This->bigBlockSizeBits);
    28262837
    28272838    StorageUtl_ReadWord(
    2828       headerBigBlock,
    2829       OFFSET_SMALLBLOCKSIZEBITS,
     2839      headerBigBlock, 
     2840      OFFSET_SMALLBLOCKSIZEBITS, 
    28302841      &This->smallBlockSizeBits);
    28312842
    28322843    StorageUtl_ReadDWord(
    2833       headerBigBlock,
    2834       OFFSET_BBDEPOTCOUNT,
     2844      headerBigBlock, 
     2845      OFFSET_BBDEPOTCOUNT,     
    28352846      &This->bigBlockDepotCount);
    28362847
    28372848    StorageUtl_ReadDWord(
    2838       headerBigBlock,
    2839       OFFSET_ROOTSTARTBLOCK,
     2849      headerBigBlock, 
     2850      OFFSET_ROOTSTARTBLOCK,   
    28402851      &This->rootStartBlock);
    28412852
    28422853    StorageUtl_ReadDWord(
    2843       headerBigBlock,
    2844       OFFSET_SBDEPOTSTART,
     2854      headerBigBlock, 
     2855      OFFSET_SBDEPOTSTART,     
    28452856      &This->smallBlockDepotStart);
    28462857
     2858    StorageUtl_ReadDWord(
     2859      headerBigBlock,
     2860      OFFSET_EXTBBDEPOTSTART,   
     2861      &This->extBigBlockDepotStart);
     2862
    28472863    StorageUtl_ReadDWord(
    2848       headerBigBlock,
    2849       OFFSET_EXTBBDEPOTSTART,
    2850       &This->extBigBlockDepotStart);
    2851 
    2852     StorageUtl_ReadDWord(
    2853       headerBigBlock,
    2854       OFFSET_EXTBBDEPOTCOUNT,
     2864      headerBigBlock,
     2865      OFFSET_EXTBBDEPOTCOUNT,   
    28552866      &This->extBigBlockDepotCount);
    2856 
     2867   
    28572868    for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
    28582869    {
    28592870      StorageUtl_ReadDWord(
    2860         headerBigBlock,
     2871        headerBigBlock, 
    28612872        OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    28622873        &(This->bigBlockDepotStart[index]));
    28632874    }
    2864 
     2875   
    28652876    /*
    28662877     * Make the bitwise arithmetic to get the size of the blocks in bytes.
     
    28762887      This->smallBlockSize = 0x000000001 >> (DWORD)This->smallBlockSizeBits;
    28772888    }
    2878 
    2879     /*
    2880      * Right now, the code is making some assumptions about the size of the
     2889   
     2890    /*
     2891     * Right now, the code is making some assumptions about the size of the 
    28812892     * blocks, just make sure they are what we're expecting.
    28822893     */
    2883     assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) &&
     2894    assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 
    28842895            (This->smallBlockSize==DEF_SMALL_BLOCK_SIZE));
    2885 
     2896   
    28862897    /*
    28872898     * Release the block.
     
    28912902    hr = S_OK;
    28922903  }
    2893 
     2904 
    28942905  return hr;
    28952906}
     
    29112922   */
    29122923  success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock);
    2913 
     2924 
    29142925  /*
    29152926   * If the block read failed, the file is probably new.
     
    29212932     */
    29222933    memset(headerBigBlock, 0, BIG_BLOCK_SIZE);
    2923 
     2934   
    29242935    /*
    29252936     * Initialize the magic number.
    29262937     */
    29272938    memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
    2928 
     2939   
    29292940    /*
    29302941     * And a bunch of things we don't know what they mean
     
    29362947    StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);
    29372948  }
    2938 
     2949 
    29392950  /*
    29402951   * Write the information to the header.
     
    29432954  {
    29442955    StorageUtl_WriteWord(
    2945       headerBigBlock,
    2946       OFFSET_BIGBLOCKSIZEBITS,
     2956      headerBigBlock, 
     2957      OFFSET_BIGBLOCKSIZEBITS,   
    29472958      This->bigBlockSizeBits);
    29482959
    29492960    StorageUtl_WriteWord(
    2950       headerBigBlock,
    2951       OFFSET_SMALLBLOCKSIZEBITS,
     2961      headerBigBlock, 
     2962      OFFSET_SMALLBLOCKSIZEBITS, 
    29522963      This->smallBlockSizeBits);
    29532964
    29542965    StorageUtl_WriteDWord(
    2955       headerBigBlock,
    2956       OFFSET_BBDEPOTCOUNT,
     2966      headerBigBlock, 
     2967      OFFSET_BBDEPOTCOUNT,     
    29572968      This->bigBlockDepotCount);
    29582969
    29592970    StorageUtl_WriteDWord(
    2960       headerBigBlock,
    2961       OFFSET_ROOTSTARTBLOCK,
     2971      headerBigBlock, 
     2972      OFFSET_ROOTSTARTBLOCK,   
    29622973      This->rootStartBlock);
    29632974
    29642975    StorageUtl_WriteDWord(
    2965       headerBigBlock,
    2966       OFFSET_SBDEPOTSTART,
     2976      headerBigBlock, 
     2977      OFFSET_SBDEPOTSTART,     
    29672978      This->smallBlockDepotStart);
    29682979
    29692980    StorageUtl_WriteDWord(
    2970       headerBigBlock,
    2971       OFFSET_EXTBBDEPOTSTART,
     2981      headerBigBlock, 
     2982      OFFSET_EXTBBDEPOTSTART,   
    29722983      This->extBigBlockDepotStart);
    29732984
    29742985    StorageUtl_WriteDWord(
    2975       headerBigBlock,
    2976       OFFSET_EXTBBDEPOTCOUNT,
     2986      headerBigBlock, 
     2987      OFFSET_EXTBBDEPOTCOUNT,   
    29772988      This->extBigBlockDepotCount);
    29782989
     
    29802991    {
    29812992      StorageUtl_WriteDWord(
    2982         headerBigBlock,
     2993        headerBigBlock, 
    29832994        OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    29842995        (This->bigBlockDepotStart[index]));
    29852996    }
    29862997  }
    2987 
     2998 
    29882999  /*
    29893000   * Write the big block back to the file.
     
    30093020  offsetInPropSet.s.HighPart = 0;
    30103021  offsetInPropSet.s.LowPart  = index * PROPSET_BLOCK_SIZE;
    3011 
     3022 
    30123023  readSuccessful = BlockChainStream_ReadAt(
    30133024                    This->rootBlockChain,
     
    30163027                    currentProperty,
    30173028                    &bytesRead);
    3018 
     3029 
    30193030  if (readSuccessful)
    30203031  {
    30213032    memset(buffer->name, 0, sizeof(buffer->name));
    30223033    memcpy(
    3023       buffer->name,
    3024       currentProperty+OFFSET_PS_NAME,
     3034      buffer->name, 
     3035      currentProperty+OFFSET_PS_NAME, 
    30253036      PROPERTY_NAME_BUFFER_LEN );
    30263037
    30273038    memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1);
    3028 
     3039   
    30293040    StorageUtl_ReadWord(
    3030       currentProperty,
    3031       OFFSET_PS_NAMELENGTH,
     3041      currentProperty, 
     3042      OFFSET_PS_NAMELENGTH, 
    30323043      &buffer->sizeOfNameString);
    30333044
    30343045    StorageUtl_ReadDWord(
    3035       currentProperty,
    3036       OFFSET_PS_PREVIOUSPROP,
     3046      currentProperty, 
     3047      OFFSET_PS_PREVIOUSPROP, 
    30373048      &buffer->previousProperty);
    30383049
    30393050    StorageUtl_ReadDWord(
    3040       currentProperty,
    3041       OFFSET_PS_NEXTPROP,
     3051      currentProperty, 
     3052      OFFSET_PS_NEXTPROP,     
    30423053      &buffer->nextProperty);
    30433054
    30443055    StorageUtl_ReadDWord(
    3045       currentProperty,
    3046       OFFSET_PS_DIRPROP,
     3056      currentProperty, 
     3057      OFFSET_PS_DIRPROP,     
    30473058      &buffer->dirProperty);
    30483059
    30493060    StorageUtl_ReadGUID(
    3050       currentProperty,
    3051       OFFSET_PS_GUID,
     3061      currentProperty, 
     3062      OFFSET_PS_GUID,       
    30523063      &buffer->propertyUniqueID);
    30533064
    30543065    StorageUtl_ReadDWord(
    3055       currentProperty,
    3056       OFFSET_PS_TSS1,
     3066      currentProperty, 
     3067      OFFSET_PS_TSS1,         
    30573068      &buffer->timeStampS1);
    30583069
    30593070    StorageUtl_ReadDWord(
    3060       currentProperty,
    3061       OFFSET_PS_TSD1,
     3071      currentProperty, 
     3072      OFFSET_PS_TSD1,         
    30623073      &buffer->timeStampD1);
    30633074
    30643075    StorageUtl_ReadDWord(
    3065       currentProperty,
    3066       OFFSET_PS_TSS2,
     3076      currentProperty, 
     3077      OFFSET_PS_TSS2,         
    30673078      &buffer->timeStampS2);
    30683079
    30693080    StorageUtl_ReadDWord(
    3070       currentProperty,
    3071       OFFSET_PS_TSD2,
     3081      currentProperty, 
     3082      OFFSET_PS_TSD2,         
    30723083      &buffer->timeStampD2);
    30733084
    30743085    StorageUtl_ReadDWord(
    3075       currentProperty,
    3076       OFFSET_PS_STARTBLOCK,
     3086      currentProperty, 
     3087      OFFSET_PS_STARTBLOCK,   
    30773088      &buffer->startingBlock);
    30783089
    30793090    StorageUtl_ReadDWord(
    3080       currentProperty,
    3081       OFFSET_PS_SIZE,
     3091      currentProperty, 
     3092      OFFSET_PS_SIZE,         
    30823093      &buffer->size.s.LowPart);
    30833094
     
    31073118
    31083119  memcpy(
    3109     currentProperty + OFFSET_PS_NAME,
    3110     buffer->name,
     3120    currentProperty + OFFSET_PS_NAME, 
     3121    buffer->name, 
    31113122    PROPERTY_NAME_BUFFER_LEN );
    31123123
     
    31143125
    31153126  StorageUtl_WriteWord(
    3116     currentProperty,
    3117       OFFSET_PS_NAMELENGTH,
     3127    currentProperty, 
     3128      OFFSET_PS_NAMELENGTH,   
    31183129      buffer->sizeOfNameString);
    31193130
    31203131  StorageUtl_WriteDWord(
    3121     currentProperty,
    3122       OFFSET_PS_PREVIOUSPROP,
     3132    currentProperty, 
     3133      OFFSET_PS_PREVIOUSPROP, 
    31233134      buffer->previousProperty);
    31243135
    31253136  StorageUtl_WriteDWord(
    3126     currentProperty,
    3127       OFFSET_PS_NEXTPROP,
     3137    currentProperty, 
     3138      OFFSET_PS_NEXTPROP,     
    31283139      buffer->nextProperty);
    31293140
    31303141  StorageUtl_WriteDWord(
    3131     currentProperty,
    3132       OFFSET_PS_DIRPROP,
     3142    currentProperty, 
     3143      OFFSET_PS_DIRPROP,     
    31333144      buffer->dirProperty);
    31343145
    31353146  StorageUtl_WriteGUID(
    3136     currentProperty,
    3137       OFFSET_PS_GUID,
     3147    currentProperty, 
     3148      OFFSET_PS_GUID,       
    31383149      &buffer->propertyUniqueID);
    31393150
    31403151  StorageUtl_WriteDWord(
    3141     currentProperty,
    3142       OFFSET_PS_TSS1,
     3152    currentProperty, 
     3153      OFFSET_PS_TSS1,         
    31433154      buffer->timeStampS1);
    31443155
    31453156  StorageUtl_WriteDWord(
    3146     currentProperty,
    3147       OFFSET_PS_TSD1,
     3157    currentProperty, 
     3158      OFFSET_PS_TSD1,         
    31483159      buffer->timeStampD1);
    31493160
    31503161  StorageUtl_WriteDWord(
    3151     currentProperty,
    3152       OFFSET_PS_TSS2,
     3162    currentProperty, 
     3163      OFFSET_PS_TSS2,         
    31533164      buffer->timeStampS2);
    31543165
    31553166  StorageUtl_WriteDWord(
    3156     currentProperty,
    3157       OFFSET_PS_TSD2,
     3167    currentProperty, 
     3168      OFFSET_PS_TSD2,         
    31583169      buffer->timeStampD2);
    31593170
    31603171  StorageUtl_WriteDWord(
    3161     currentProperty,
    3162       OFFSET_PS_STARTBLOCK,
     3172    currentProperty, 
     3173      OFFSET_PS_STARTBLOCK,   
    31633174      buffer->startingBlock);
    31643175
    31653176  StorageUtl_WriteDWord(
    3166     currentProperty,
    3167       OFFSET_PS_SIZE,
     3177    currentProperty, 
     3178      OFFSET_PS_SIZE,         
    31683179      buffer->size.s.LowPart);
    31693180
     
    32113222
    32123223    StorageImpl_ReleaseBigBlock(This, bigBlockBuffer);
    3213 
     3224   
    32143225    return TRUE;
    32153226  }
    3216 
     3227 
    32173228  return FALSE;
    32183229}
     
    33443355
    33453356StorageInternalImpl* StorageInternalImpl_Construct(
    3346   StorageImpl* ancestorStorage,
     3357  StorageImpl* ancestorStorage, 
    33473358  ULONG          rootPropertyIndex)
    33483359{
     
    33953406** does nothing.
    33963407*/
    3397 HRESULT WINAPI StorageInternalImpl_Commit(
     3408HRESULT WINAPI StorageInternalImpl_Commit( 
    33983409  IStorage*            iface,
    3399   DWORD                  grfCommitFlags)  /* [in] */
     3410  DWORD                  grfCommitFlags)  /* [in] */ 
    34003411{
    34013412  return S_OK;
    34023413}
    3403 
     3414       
    34043415/******************************************************************************
    34053416**
     
    34093420** does nothing.
    34103421*/
    3411 HRESULT WINAPI StorageInternalImpl_Revert(
     3422HRESULT WINAPI StorageInternalImpl_Revert( 
    34123423  IStorage*            iface)
    34133424{
     
    34263437
    34273438  newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl));
    3428 
     3439 
    34293440  if (newEnumeration!=0)
    34303441  {
     
    34343445    ICOM_VTBL(newEnumeration) = &IEnumSTATSTGImpl_Vtbl;
    34353446    newEnumeration->ref       = 0;
    3436 
     3447   
    34373448    /*
    34383449     * We want to nail-down the reference to the storage in case the
     
    34413452    newEnumeration->parentStorage = parentStorage;
    34423453    IStorage_AddRef((IStorage*)newEnumeration->parentStorage);
    3443 
     3454   
    34443455    newEnumeration->firstPropertyNode   = firstPropertyNode;
    3445 
     3456   
    34463457    /*
    34473458     * Initialize the search stack
     
    34493460    newEnumeration->stackSize    = 0;
    34503461    newEnumeration->stackMaxSize = ENUMSTATSGT_SIZE_INCREMENT;
    3451     newEnumeration->stackToVisit =
     3462    newEnumeration->stackToVisit = 
    34523463      HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG)*ENUMSTATSGT_SIZE_INCREMENT);
    3453 
     3464   
    34543465    /*
    34553466     * Make sure the current node of the iterator is the first one.
     
    34573468    IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration);
    34583469  }
    3459 
     3470 
    34603471  return newEnumeration;
    34613472}
     
    34893500   * Compare the riid with the interface IDs implemented by this object.
    34903501   */
    3491   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     3502  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    34923503  {
    34933504    *ppvObject = (IEnumSTATSTG*)This;
    34943505  }
    3495   else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0)
     3506  else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 
    34963507  {
    34973508    *ppvObject = (IEnumSTATSTG*)This;
     
    35123523  return S_OK;
    35133524}
    3514 
     3525       
    35153526ULONG   WINAPI IEnumSTATSTGImpl_AddRef(
    35163527  IEnumSTATSTG* iface)
     
    35213532  return This->ref;
    35223533}
    3523 
     3534       
    35243535ULONG   WINAPI IEnumSTATSTGImpl_Release(
    35253536  IEnumSTATSTG* iface)
     
    35603571   */
    35613572  if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) )
    3562     return E_INVALIDARG;
    3563 
     3573    return E_INVALIDARG; 
     3574 
    35643575  /*
    35653576   * To avoid the special case, get another pointer to a ULONG value if
     
    35683579  if (pceltFetched==0)
    35693580    pceltFetched = &objectFetched;
    3570 
     3581 
    35713582  /*
    35723583   * Start the iteration, we will iterate until we hit the end of the
     
    35803591  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    35813592
    3582   while ( ( *pceltFetched < celt) &&
     3593  while ( ( *pceltFetched < celt) && 
    35833594          ( currentSearchNode!=PROPERTY_NULL) )
    35843595  {
    3585     /*
     3596    /* 
    35863597     * Remove the top node from the stack
    35873598     */
     
    35923603     */
    35933604    StorageImpl_ReadProperty(This->parentStorage,
    3594       currentSearchNode,
     3605      currentSearchNode, 
    35953606      &currentProperty);
    35963607
     
    36013612      &currentProperty,
    36023613      STATFLAG_DEFAULT);
    3603 
     3614       
    36043615    /*
    36053616     * Step to the next item in the iteration
     
    36253636}
    36263637
    3627 
     3638       
    36283639HRESULT WINAPI IEnumSTATSTGImpl_Skip(
    36293640  IEnumSTATSTG* iface,
     
    36413652  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    36423653
    3643   while ( (objectFetched < celt) &&
     3654  while ( (objectFetched < celt) && 
    36443655          (currentSearchNode!=PROPERTY_NULL) )
    36453656  {
    3646     /*
     3657    /* 
    36473658     * Remove the top node from the stack
    36483659     */
     
    36533664     */
    36543665    StorageImpl_ReadProperty(This->parentStorage,
    3655       currentSearchNode,
     3666      currentSearchNode, 
    36563667      &currentProperty);
    3657 
     3668   
    36583669    /*
    36593670     * Step to the next item in the iteration
     
    36773688  return S_FALSE;
    36783689}
    3679 
     3690       
    36803691HRESULT WINAPI IEnumSTATSTGImpl_Reset(
    36813692  IEnumSTATSTG* iface)
     
    36963707  readSuccessful = StorageImpl_ReadProperty(
    36973708                    This->parentStorage,
    3698                     This->firstPropertyNode,
     3709                    This->firstPropertyNode, 
    36993710                    &rootProperty);
    37003711
     
    37113722  return S_OK;
    37123723}
    3713 
     3724       
    37143725HRESULT WINAPI IEnumSTATSTGImpl_Clone(
    37153726  IEnumSTATSTG* iface,
     
    37253736  if (ppenum==0)
    37263737    return E_INVALIDARG;
    3727 
     3738 
    37283739  newClone = IEnumSTATSTGImpl_Construct(This->parentStorage,
    37293740               This->firstPropertyNode);
    37303741
    3731 
     3742 
    37323743  /*
    37333744   * The new clone enumeration must point to the same current node as
     
    37363747  newClone->stackSize    = This->stackSize    ;
    37373748  newClone->stackMaxSize = This->stackMaxSize ;
    3738   newClone->stackToVisit =
     3749  newClone->stackToVisit = 
    37393750    HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * newClone->stackMaxSize);
    37403751
    37413752  memcpy(
    3742     newClone->stackToVisit,
    3743     This->stackToVisit,
     3753    newClone->stackToVisit, 
     3754    This->stackToVisit, 
    37443755    sizeof(ULONG) * newClone->stackSize);
    37453756
     
    37573768INT IEnumSTATSTGImpl_FindParentProperty(
    37583769  IEnumSTATSTGImpl *This,
    3759   ULONG             childProperty,
     3770  ULONG             childProperty, 
    37603771  StgProperty      *currentProperty,
    37613772  ULONG            *thisNodeId)
     
    37753786   */
    37763787  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    3777 
     3788 
    37783789
    37793790  while (currentSearchNode!=PROPERTY_NULL)
     
    37843795    *thisNodeId = currentSearchNode;
    37853796
    3786     /*
     3797    /* 
    37873798     * Remove the top node from the stack
    37883799     */
     
    37943805    StorageImpl_ReadProperty(
    37953806      This->parentStorage,
    3796       currentSearchNode,
     3807      currentSearchNode, 
    37973808      currentProperty);
    3798 
     3809     
    37993810    if (currentProperty->previousProperty == childProperty)
    38003811      return PROPERTY_RELATION_PREVIOUS;
    38013812
    3802     else if (currentProperty->nextProperty == childProperty)
     3813    else if (currentProperty->nextProperty == childProperty) 
    38033814      return PROPERTY_RELATION_NEXT;
    3804 
     3815 
    38053816    else if (currentProperty->dirProperty == childProperty)
    38063817      return PROPERTY_RELATION_DIR;
    3807 
     3818       
    38083819    /*
    38093820     * Push the next search node in the search stack.
     
    38343845  while (currentSearchNode!=PROPERTY_NULL)
    38353846  {
    3836     /*
     3847    /* 
    38373848     * Remove the top node from the stack
    38383849     */
     
    38433854     */
    38443855    StorageImpl_ReadProperty(This->parentStorage,
    3845       currentSearchNode,
     3856      currentSearchNode, 
    38463857      currentProperty);
    38473858
    38483859    if ( propertyNameCmp(
    3849           (OLECHAR*)currentProperty->name,
     3860          (OLECHAR*)currentProperty->name, 
    38503861          (OLECHAR*)lpszPropName) == 0)
    38513862      return currentSearchNode;
     
    38863897
    38873898    This->stackToVisit = HeapReAlloc(
    3888                            GetProcessHeap(),
     3899                           GetProcessHeap(), 
    38893900                           0,
    38903901                           This->stackToVisit,
     
    39003911  readSuccessful = StorageImpl_ReadProperty(
    39013912                    This->parentStorage,
    3902                     nodeToPush,
     3913                    nodeToPush, 
    39033914                    &rootProperty);
    39043915
     
    39873998  else
    39883999  {
    3989     destination->pwcsName =
     4000    destination->pwcsName = 
    39904001      CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR));
    39914002
    39924003    strcpyW((LPWSTR)destination->pwcsName, source->name);
    39934004  }
    3994 
     4005 
    39954006  switch (source->propertyType)
    39964007  {
     
    40044015    default:
    40054016      destination->type = STGTY_STREAM;
    4006       break;
     4017      break;       
    40074018  }
    40084019
    40094020  destination->cbSize            = source->size;
    4010 /*
     4021/*   
    40114022  currentReturnStruct->mtime     = {0}; TODO
    40124023  currentReturnStruct->ctime     = {0};
    4013   currentReturnStruct->atime     = {0};
     4024  currentReturnStruct->atime     = {0}; 
    40144025*/
    40154026  destination->grfMode           = 0;
    4016   destination->grfLocksSupported = 0;
     4027  destination->grfLocksSupported = 0; 
    40174028  destination->clsid             = source->propertyUniqueID;
    4018   destination->grfStateBits      = 0;
    4019   destination->reserved          = 0;
     4029  destination->grfStateBits      = 0; 
     4030  destination->reserved          = 0; 
    40204031}
    40214032
     
    40254036
    40264037BlockChainStream* BlockChainStream_Construct(
    4027   StorageImpl* parentStorage,
     4038  StorageImpl* parentStorage, 
    40284039  ULONG*         headOfStreamPlaceHolder,
    40294040  ULONG          propertyIndex)
     
    40984109 * Returns the number of blocks that comprises this chain.
    40994110 * This is not the size of the stream as the last block may not be full!
    4100  *
     4111 * 
    41014112 */
    41024113ULONG BlockChainStream_GetCount(BlockChainStream* This)
     
    41124123
    41134124    blockIndex = StorageImpl_GetNextBlockInChain(
    4114                    This->parentStorage,
     4125                   This->parentStorage, 
    41154126                   blockIndex);
    41164127  }
     
    41204131
    41214132/******************************************************************************
    4122  *      BlockChainStream_ReadAt
     4133 *      BlockChainStream_ReadAt 
    41234134 *
    41244135 * Reads a specified number of bytes from this chain at the specified offset.
     
    41604171  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    41614172  {
    4162     blockIndex =
     4173    blockIndex = 
    41634174      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4164 
     4175   
    41654176    blockNoInSequence--;
    41664177  }
     
    41734184  *bytesRead   = 0;
    41744185  bufferWalker = buffer;
    4175 
     4186 
    41764187  while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
    41774188  {
     
    41794190     * Calculate how many bytes we can copy from this big block.
    41804191     */
    4181     bytesToReadInBuffer =
     4192    bytesToReadInBuffer = 
    41824193      min(This->parentStorage->bigBlockSize - offsetInBlock, size);
    4183 
     4194   
    41844195    /*
    41854196     * Copy those bytes to the buffer
    41864197     */
    4187     bigBlockBuffer =
     4198    bigBlockBuffer = 
    41884199      StorageImpl_GetROBigBlock(This->parentStorage, blockIndex);
    4189 
     4200   
    41904201    memcpy(bufferWalker, bigBlockBuffer + offsetInBlock, bytesToReadInBuffer);
    4191 
     4202   
    41924203    StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer);
    4193 
     4204   
    41944205    /*
    41954206     * Step to the next big block.
    41964207     */
    4197     blockIndex    =
     4208    blockIndex    = 
    41984209      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    41994210
     
    42044215
    42054216  }
    4206 
     4217 
    42074218  return (size == 0);
    42084219}
     
    42494260  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    42504261  {
    4251     blockIndex =
     4262    blockIndex = 
    42524263      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4253 
     4264   
    42544265    blockNoInSequence--;
    42554266  }
     
    42694280     * Calculate how many bytes we can copy from this big block.
    42704281     */
    4271     bytesToWrite =
     4282    bytesToWrite = 
    42724283      min(This->parentStorage->bigBlockSize - offsetInBlock, size);
    4273 
     4284   
    42744285    /*
    42754286     * Copy those bytes to the buffer
    42764287     */
    42774288    bigBlockBuffer = StorageImpl_GetBigBlock(This->parentStorage, blockIndex);
    4278 
     4289   
    42794290    memcpy(bigBlockBuffer + offsetInBlock, bufferWalker, bytesToWrite);
    4280 
     4291   
    42814292    StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer);
    4282 
     4293   
    42834294    /*
    42844295     * Step to the next big block.
    42854296     */
    4286     blockIndex    =
     4297    blockIndex    = 
    42874298      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    42884299
     
    42924303    offsetInBlock  = 0;      /* There is no offset on the next block */
    42934304  }
    4294 
     4305 
    42954306  return (size == 0);
    42964307}
     
    43294340  while (count < numBlocks)
    43304341  {
    4331     blockIndex =
     4342    blockIndex = 
    43324343      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    43334344
     
    43364347
    43374348  /* Get the next block before marking the new end */
    4338   extraBlock =
     4349  extraBlock = 
    43394350    StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    43404351
    43414352  /* Mark the new end of chain */
    43424353  StorageImpl_SetNextBlockInChain(
    4343     This->parentStorage,
    4344     blockIndex,
     4354    This->parentStorage, 
     4355    blockIndex, 
    43454356    BLOCK_END_OF_CHAIN);
    43464357
     
    43534364  while (extraBlock != BLOCK_END_OF_CHAIN)
    43544365  {
    4355     blockIndex =
     4366    blockIndex = 
    43564367      StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock);
    43574368
     
    43974408
    43984409      StorageImpl_ReadProperty(
    4399         This->parentStorage,
     4410        This->parentStorage, 
    44004411        This->ownerPropertyIndex,
    44014412        &chainProp);
    44024413
    4403       chainProp.startingBlock = blockIndex;
     4414      chainProp.startingBlock = blockIndex; 
    44044415
    44054416      StorageImpl_WriteProperty(
    4406         This->parentStorage,
     4417        This->parentStorage, 
    44074418        This->ownerPropertyIndex,
    44084419        &chainProp);
     
    44534464
    44544465      StorageImpl_SetNextBlockInChain(
    4455     This->parentStorage,
    4456     currentBlock,
    4457     blockIndex);
     4466        This->parentStorage,
     4467        currentBlock,
     4468        blockIndex);
    44584469
    44594470      StorageImpl_SetNextBlockInChain(
    4460         This->parentStorage,
    4461     blockIndex,
    4462     BLOCK_END_OF_CHAIN);
     4471        This->parentStorage, 
     4472        blockIndex,
     4473        BLOCK_END_OF_CHAIN);
    44634474
    44644475      currentBlock = blockIndex;
     
    44814492 * TODO: Free the actual blocks in the file when we shrink the chain.
    44824493 *       Currently, the blocks are still in the file. So the file size
    4483  *       doesn't shrink even if we shrink streams.
     4494 *       doesn't shrink even if we shrink streams. 
    44844495 */
    44854496BOOL BlockChainStream_SetSize(
     
    44984509  else
    44994510  {
    4500     ULARGE_INTEGER fileSize =
     4511    ULARGE_INTEGER fileSize = 
    45014512      BIGBLOCKFILE_GetSize(This->parentStorage->bigBlockFile);
    45024513
     
    45074518     */
    45084519    if ((diff % This->parentStorage->bigBlockSize) != 0)
    4509       diff += (This->parentStorage->bigBlockSize -
     4520      diff += (This->parentStorage->bigBlockSize - 
    45104521                (diff % This->parentStorage->bigBlockSize) );
    45114522
     
    45314542  if(This->headOfStreamPlaceHolder == NULL)
    45324543  {
    4533     /*
    4534      * This chain is a data stream read the property and return
     4544    /* 
     4545     * This chain is a data stream read the property and return 
    45354546     * the appropriate size
    45364547     */
     
    45454556  {
    45464557    /*
    4547      * this chain is a chain that does not have a property, figure out the
    4548      * size by making the product number of used blocks times the
     4558     * this chain is a chain that does not have a property, figure out the 
     4559     * size by making the product number of used blocks times the 
    45494560     * size of them
    45504561     */
     
    45524563    result.s.HighPart = 0;
    45534564
    4554     result.s.LowPart  =
    4555       BlockChainStream_GetCount(This) *
     4565    result.s.LowPart  = 
     4566      BlockChainStream_GetCount(This) * 
    45564567      This->parentStorage->bigBlockSize;
    45574568
     
    45654576
    45664577SmallBlockChainStream* SmallBlockChainStream_Construct(
    4567   StorageImpl* parentStorage,
     4578  StorageImpl* parentStorage, 
    45684579  ULONG          propertyIndex)
    45694580{
     
    46164627 *
    46174628 * Returns the index of the next small block in this chain.
    4618  *
     4629 * 
    46194630 * Return Values:
    46204631 *    - BLOCK_END_OF_CHAIN: end of this chain
     
    47434754    else
    47444755    {
    4745       ULONG count =
     4756      ULONG count = 
    47464757        BlockChainStream_GetCount(This->parentStorage->smallBlockDepotChain);
    47474758
     
    47544765      {
    47554766        sbdIndex = nextBlock;
    4756         nextBlock =
     4767        nextBlock = 
    47574768          StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex);
    47584769      }
     
    47614772      if (sbdIndex != BLOCK_END_OF_CHAIN)
    47624773        StorageImpl_SetNextBlockInChain(
    4763           This->parentStorage,
    4764           sbdIndex,
     4774          This->parentStorage, 
     4775          sbdIndex, 
    47654776          newsbdIndex);
    47664777
    47674778      StorageImpl_SetNextBlockInChain(
    4768         This->parentStorage,
    4769         newsbdIndex,
     4779        This->parentStorage, 
     4780        newsbdIndex, 
    47704781        BLOCK_END_OF_CHAIN);
    47714782
     
    47734784       * Initialize all the small blocks to free
    47744785       */
    4775       smallBlockDepot =
     4786      smallBlockDepot = 
    47764787        StorageImpl_GetBigBlock(This->parentStorage, newsbdIndex);
    47774788
     
    47854796         */
    47864797        StgProperty rootProp;
    4787         ULONG sbStartIndex;
     4798        ULONG sbStartIndex; 
    47884799
    47894800        /*
     
    47944805
    47954806        /*
    4796          * And allocate the first big block that will contain small blocks
     4807         * And allocate the first big block that will contain small blocks 
    47974808         */
    4798         sbStartIndex =
     4809        sbStartIndex = 
    47994810          StorageImpl_GetNextFreeBigBlock(This->parentStorage);
    48004811
    48014812        StorageImpl_SetNextBlockInChain(
    4802           This->parentStorage,
    4803           sbStartIndex,
     4813          This->parentStorage, 
     4814          sbStartIndex, 
    48044815          BLOCK_END_OF_CHAIN);
    48054816
    48064817        StorageImpl_ReadProperty(
    4807           This->parentStorage,
    4808           This->parentStorage->rootPropertySetIndex,
     4818          This->parentStorage, 
     4819          This->parentStorage->rootPropertySetIndex, 
    48094820          &rootProp);
    48104821
     
    48144825
    48154826        StorageImpl_WriteProperty(
    4816           This->parentStorage,
    4817           This->parentStorage->rootPropertySetIndex,
     4827          This->parentStorage, 
     4828          This->parentStorage->rootPropertySetIndex, 
    48184829          &rootProp);
    48194830      }
     
    48214832  }
    48224833
    4823   smallBlocksPerBigBlock =
     4834  smallBlocksPerBigBlock = 
    48244835    This->parentStorage->bigBlockSize / This->parentStorage->smallBlockSize;
    48254836
     
    48334844
    48344845    StorageImpl_ReadProperty(
    4835       This->parentStorage,
    4836       This->parentStorage->rootPropertySetIndex,
     4846      This->parentStorage, 
     4847      This->parentStorage->rootPropertySetIndex, 
    48374848      &rootProp);
    48384849
    4839     if (rootProp.size.s.LowPart <
     4850    if (rootProp.size.s.LowPart < 
    48404851       (blocksRequired * This->parentStorage->bigBlockSize))
    48414852    {
     
    48434854
    48444855      BlockChainStream_SetSize(
    4845         This->parentStorage->smallBlockRootChain,
     4856        This->parentStorage->smallBlockRootChain, 
    48464857        rootProp.size);
    48474858
    48484859      StorageImpl_WriteProperty(
    4849         This->parentStorage,
    4850         This->parentStorage->rootPropertySetIndex,
     4860        This->parentStorage, 
     4861        This->parentStorage->rootPropertySetIndex, 
    48514862        &rootProp);
    48524863    }
     
    48614872 * Reads a specified number of bytes from this chain at the specified offset.
    48624873 * bytesRead may be NULL.
    4863  * Failure will be returned if the specified number of bytes has not been read.
     4874 * Failure will be returned if the specified number of bytes has not been read. 
    48644875 */
    48654876BOOL SmallBlockChainStream_ReadAt(
     
    48714882{
    48724883  ULARGE_INTEGER offsetInBigBlockFile;
    4873   ULONG blockNoInSequence =
     4884  ULONG blockNoInSequence = 
    48744885    offset.s.LowPart / This->parentStorage->smallBlockSize;
    48754886
     
    49084919     * Calculate how many bytes we can copy from this small block.
    49094920     */
    4910     bytesToReadInBuffer =
     4921    bytesToReadInBuffer = 
    49114922      min(This->parentStorage->smallBlockSize - offsetInBlock, size);
    49124923
     
    49154926     */
    49164927    offsetInBigBlockFile.s.HighPart  = 0;
    4917     offsetInBigBlockFile.s.LowPart   =
     4928    offsetInBigBlockFile.s.LowPart   = 
    49184929      blockIndex * This->parentStorage->smallBlockSize;
    49194930
     
    49594970{
    49604971  ULARGE_INTEGER offsetInBigBlockFile;
    4961   ULONG blockNoInSequence =
     4972  ULONG blockNoInSequence = 
    49624973    offset.s.LowPart / This->parentStorage->smallBlockSize;
    49634974
     
    49674978  ULONG bytesWrittenFromBigBlockFile;
    49684979  BYTE* bufferWalker;
    4969 
     4980 
    49704981  /*
    49714982   * This should never happen on a small block file.
    49724983   */
    49734984  assert(offset.s.HighPart==0);
    4974 
     4985 
    49754986  /*
    49764987   * Find the first block in the stream that contains part of the buffer.
    49774988   */
    49784989  blockIndex = SmallBlockChainStream_GetHeadOfChain(This);
    4979 
     4990 
    49804991  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    49814992  {
    49824993    blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    4983 
     4994   
    49844995    blockNoInSequence--;
    49854996  }
    4986 
     4997 
    49874998  /*
    49884999   * Start writing the buffer.
     
    49985009     * Calculate how many bytes we can copy to this small block.
    49995010     */
    5000     bytesToWriteInBuffer =
     5011    bytesToWriteInBuffer = 
    50015012      min(This->parentStorage->smallBlockSize - offsetInBlock, size);
    5002 
     5013   
    50035014    /*
    50045015     * Calculate the offset of the small block in the small block file.
    50055016     */
    50065017    offsetInBigBlockFile.s.HighPart  = 0;
    5007     offsetInBigBlockFile.s.LowPart   =
     5018    offsetInBigBlockFile.s.LowPart   = 
    50085019      blockIndex * This->parentStorage->smallBlockSize;
    50095020
    50105021    offsetInBigBlockFile.s.LowPart  += offsetInBlock;
    5011 
     5022   
    50125023    /*
    50135024     * Write those bytes in the buffer to the small block file.
     
    50185029      bufferWalker,
    50195030      &bytesWrittenFromBigBlockFile);
    5020 
     5031   
    50215032    assert(bytesWrittenFromBigBlockFile == bytesToWriteInBuffer);
    5022 
     5033   
    50235034    /*
    50245035     * Step to the next big block.
     
    50305041    offsetInBlock  = 0;     /* There is no offset on the next block */
    50315042  }
    5032 
     5043 
    50335044  return (size == 0);
    50345045}
     
    50375048 *       SmallBlockChainStream_Shrink
    50385049 *
    5039  * Shrinks this chain in the small block depot.
     5050 * Shrinks this chain in the small block depot. 
    50405051 */
    50415052BOOL SmallBlockChainStream_Shrink(
     
    50655076  /*
    50665077   * If the count is 0, we have a special case, the head of the chain was
    5067    * just freed.
     5078   * just freed. 
    50685079   */
    50695080  if (count == 0)
     
    50715082    StgProperty chainProp;
    50725083
    5073     StorageImpl_ReadProperty(This->parentStorage,
    5074                  This->ownerPropertyIndex,
    5075                  &chainProp);
     5084    StorageImpl_ReadProperty(This->parentStorage, 
     5085                             This->ownerPropertyIndex,
     5086                             &chainProp);
    50765087
    50775088    chainProp.startingBlock = BLOCK_END_OF_CHAIN;
    50785089
    50795090    StorageImpl_WriteProperty(This->parentStorage,
    5080                   This->ownerPropertyIndex,
    5081                   &chainProp);
     5091                              This->ownerPropertyIndex,
     5092                              &chainProp);
    50825093
    50835094    /*
     
    50935104    /* Mark the new end of chain */
    50945105    SmallBlockChainStream_SetNextBlockInChain(
    5095       This,
    5096       blockIndex,
     5106      This, 
     5107      blockIndex, 
    50975108      BLOCK_END_OF_CHAIN);
    50985109  }
     
    51085119  }
    51095120
    5110   return TRUE;
     5121  return TRUE; 
    51115122}
    51125123
     
    51445155    blockIndex = chainProp.startingBlock;
    51455156    SmallBlockChainStream_SetNextBlockInChain(
    5146       This,
    5147       blockIndex,
     5157      This, 
     5158      blockIndex, 
    51485159      BLOCK_END_OF_CHAIN);
    51495160  }
     
    51785189
    51795190    SmallBlockChainStream_SetNextBlockInChain(
    5180       This,
    5181       blockIndex,
     5191      This, 
     5192      blockIndex, 
    51825193      BLOCK_END_OF_CHAIN);
    51835194
     
    52205231 * TODO: Free the actual blocks in the file when we shrink the chain.
    52215232 *       Currently, the blocks are still in the file. So the file size
    5222  *       doesn't shrink even if we shrink streams.
     5233 *       doesn't shrink even if we shrink streams. 
    52235234 */
    52245235BOOL SmallBlockChainStream_SetSize(
     
    52785289  WCHAR          tempFileName[MAX_PATH];
    52795290
    5280   TRACE("(%s, %lx, %ld, %p)\n",
    5281     debugstr_w(pwcsName), grfMode,
    5282     reserved, ppstgOpen);
     5291  TRACE("(%s, %lx, %ld, %p)\n", 
     5292        debugstr_w(pwcsName), grfMode,
     5293        reserved, ppstgOpen);
    52835294
    52845295  /*
     
    53265337
    53275338  /*
    5328    * Interpret the STGM value grfMode
     5339   * Interpret the STGM value grfMode 
    53295340   */
    53305341  shareMode    = GetShareModeFromSTGM(grfMode);
     
    53515362                        fileAttributes,
    53525363            0);
    5353 
     5364 
    53545365  if (hFile == INVALID_HANDLE_VALUE)
    53555366  {
     
    53615372   */
    53625373  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5363 
     5374 
    53645375  if (newStorage == 0)
    53655376    return STG_E_INSUFFICIENTMEMORY;
     
    53725383         TRUE,
    53735384         TRUE);
    5374 
     5385 
    53755386  if (FAILED(hr))
    53765387  {
     
    53985409  DWORD           grfMode,
    53995410  SNB           snbExclude,
    5400   DWORD           reserved,
     5411  DWORD           reserved, 
    54015412  IStorage      **ppstgOpen)
    54025413{
     
    54075418  DWORD          accessMode;
    54085419
    5409   TRACE("(%s, %p, %lx, %p, %ld, %p)\n",
    5410     debugstr_w(pwcsName), pstgPriority, grfMode,
    5411     snbExclude, reserved, ppstgOpen);
     5420  TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 
     5421        debugstr_w(pwcsName), pstgPriority, grfMode,
     5422        snbExclude, reserved, ppstgOpen);
    54125423
    54135424  /*
     
    54335444   */
    54345445  *ppstgOpen = 0;
    5435 
    5436   hFile = CreateFileW( pwcsName,
     5446 
     5447  hFile = CreateFileW( pwcsName, 
    54375448                       accessMode,
    54385449                       shareMode,
     
    54415452                       FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
    54425453                       0);
    5443 
    5444 
     5454 
     5455 
    54455456  if (hFile==INVALID_HANDLE_VALUE)
    54465457  {
     
    54785489   */
    54795490  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5480 
     5491 
    54815492  if (newStorage == 0)
    54825493    return STG_E_INSUFFICIENTMEMORY;
     
    54895500         TRUE,
    54905501         FALSE);
    5491 
     5502 
    54925503  if (FAILED(hr))
    54935504  {
     
    54975508     */
    54985509    if(hr == STG_E_INVALIDHEADER)
    5499     return STG_E_FILEALREADYEXISTS;
     5510        return STG_E_FILEALREADYEXISTS;
    55005511    return hr;
    55015512  }
    5502 
     5513 
    55035514  /*
    55045515   * Get an "out" pointer for the caller.
     
    55085519         (REFIID)&IID_IStorage,
    55095520         (void**)ppstgOpen);
    5510 
     5521 
    55115522  return hr;
    55125523}
     
    55605571         (void**)ppstgOpen);
    55615572
    5562   return hr;
     5573  return hr; 
    55635574}
    55645575
     
    55985609   */
    55995610  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5600 
     5611 
    56015612  if (newStorage == 0)
    56025613    return STG_E_INSUFFICIENTMEMORY;
     
    56345645HRESULT WINAPI StgSetTimes(WCHAR * str, FILETIME * a, FILETIME * b, FILETIME *c )
    56355646{
    5636 
     5647 
    56375648  FIXME("(%p, %p, %p, %p),stub!\n", str, a, b, c);
    56385649  return FALSE;
     
    56855696    STATSTG pstatstg;
    56865697    HRESULT hRes;
    5687 
     5698   
    56885699    TRACE("()\n");
    56895700
     
    57085719HRESULT  WINAPI OleLoadFromStream(IStream *pStm,REFIID iidInterface,void** ppvObj)
    57095720{
    5710     CLSID   clsid;
    5711     HRESULT res;
    5712     LPPERSISTSTREAM xstm;
     5721    CLSID       clsid;
     5722    HRESULT     res;
     5723    LPPERSISTSTREAM     xstm;
    57135724
    57145725    TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj);
     
    57165727    res=ReadClassStm(pStm,&clsid);
    57175728    if (!SUCCEEDED(res))
    5718     return res;
     5729        return res;
    57195730    res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj);
    57205731    if (!SUCCEEDED(res))
    5721     return res;
     5732        return res;
    57225733    res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm);
    57235734    if (!SUCCEEDED(res)) {
    5724     IUnknown_Release((IUnknown*)*ppvObj);
    5725     return res;
     5735        IUnknown_Release((IUnknown*)*ppvObj);
     5736        return res;
    57265737    }
    57275738    res=IPersistStream_Load(xstm,pStm);
    57285739    IPersistStream_Release(xstm);
    57295740    /* FIXME: all refcounts ok at this point? I think they should be:
    5730      *      pStm    : unchanged
    5731      *      ppvObj  : 1
    5732      *      xstm    : 0 (released)
     5741     *          pStm    : unchanged
     5742     *          ppvObj  : 1
     5743     *          xstm    : 0 (released)
    57335744     */
    57345745    return res;
     
    57465757    CLSID clsid;
    57475758    HRESULT res;
    5748 
     5759   
    57495760    TRACE("(%p,%p)\n",pPStm,pStm);
    57505761
     
    57525763
    57535764    if (SUCCEEDED(res)){
    5754 
     5765       
    57555766        res=WriteClassStm(pStm,&clsid);
    57565767
     
    57705781 * STGM_TRANSACTED           0x00010000
    57715782 * STGM_SIMPLE               0x08000000
    5772  *
     5783 * 
    57735784 * STGM_READ                 0x00000000
    57745785 * STGM_WRITE                0x00000001
    57755786 * STGM_READWRITE            0x00000002
    5776  *
     5787 * 
    57775788 * STGM_SHARE_DENY_NONE      0x00000040
    57785789 * STGM_SHARE_DENY_READ      0x00000030
    57795790 * STGM_SHARE_DENY_WRITE     0x00000020
    57805791 * STGM_SHARE_EXCLUSIVE      0x00000010
    5781  *
     5792 * 
    57825793 * STGM_PRIORITY             0x00040000
    57835794 * STGM_DELETEONRELEASE      0x04000000
     
    57955806  BOOL bSTGM_SIMPLE           = ((stgm & STGM_SIMPLE) == STGM_SIMPLE);
    57965807  BOOL bSTGM_DIRECT           = ! (bSTGM_TRANSACTED || bSTGM_SIMPLE);
    5797 
     5808   
    57985809  BOOL bSTGM_WRITE            = ((stgm & STGM_WRITE) == STGM_WRITE);
    57995810  BOOL bSTGM_READWRITE        = ((stgm & STGM_READWRITE) == STGM_READWRITE);
    58005811  BOOL bSTGM_READ             = ! (bSTGM_WRITE || bSTGM_READWRITE);
    5801 
     5812   
    58025813  BOOL bSTGM_SHARE_DENY_NONE  =
    58035814                     ((stgm & STGM_SHARE_DENY_NONE)  == STGM_SHARE_DENY_NONE);
     
    58145825  BOOL bSTGM_CREATE           = ((stgm & STGM_CREATE) == STGM_CREATE);
    58155826  BOOL bSTGM_CONVERT          = ((stgm & STGM_CONVERT) == STGM_CONVERT);
    5816 
     5827   
    58175828  BOOL bSTGM_NOSCRATCH        = ((stgm & STGM_NOSCRATCH) == STGM_NOSCRATCH);
    58185829  BOOL bSTGM_NOSNAPSHOT       = ((stgm & STGM_NOSNAPSHOT) == STGM_NOSNAPSHOT);
    58195830
    5820   /*
     5831  /* 
    58215832   * STGM_DIRECT | STGM_TRANSACTED | STGM_SIMPLE
    58225833   */
     
    58255836      return E_FAIL;
    58265837
    5827   /*
     5838  /* 
    58285839   * STGM_WRITE |  STGM_READWRITE | STGM_READ
    58295840   */
     
    58335844
    58345845  /*
    5835    * STGM_SHARE_DENY_NONE | others
     5846   * STGM_SHARE_DENY_NONE | others 
    58365847   * (I assume here that DENY_READ implies DENY_WRITE)
    58375848   */
    58385849  if ( bSTGM_SHARE_DENY_NONE )
    58395850    if ( bSTGM_SHARE_DENY_READ ||
    5840          bSTGM_SHARE_DENY_WRITE ||
    5841          bSTGM_SHARE_EXCLUSIVE)
     5851         bSTGM_SHARE_DENY_WRITE || 
     5852         bSTGM_SHARE_EXCLUSIVE) 
    58425853      return E_FAIL;
    58435854
     
    58545865  if ( bSTGM_NOSCRATCH && ! bSTGM_TRANSACTED )
    58555866    return E_FAIL;
    5856 
    5857   /*
    5858    * STGM_NOSNAPSHOT requires STGM_TRANSACTED and
     5867 
     5868  /*
     5869   * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 
    58595870   * not STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE`
    58605871   */
    58615872  if (bSTGM_NOSNAPSHOT)
    58625873  {
    5863     if ( ! ( bSTGM_TRANSACTED &&
     5874    if ( ! ( bSTGM_TRANSACTED && 
    58645875           !(bSTGM_SHARE_EXCLUSIVE || bSTGM_SHARE_DENY_WRITE)) )
    58655876    return E_FAIL;
     
    58735884 *
    58745885 * This method will return a share mode flag from a STGM value.
    5875  * The STGM value is assumed valid.
     5886 * The STGM value is assumed valid. 
    58765887 */
    58775888static DWORD GetShareModeFromSTGM(DWORD stgm)
     
    59435954  /* All other cases */
    59445955  if (stgm & ~ (STGM_CREATE|STGM_CONVERT))
    5945     FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));
     5956        FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));
    59465957  return CREATE_NEW;
    59475958}
     
    59495960
    59505961/*************************************************************************
    5951  * OLECONVERT_LoadOLE10 [Internal]
    5952  *
    5953  * Loads the OLE10 STREAM to memory
     5962 * OLECONVERT_LoadOLE10 [Internal] 
     5963 *
     5964 * Loads the OLE10 STREAM to memory 
    59545965 *
    59555966 * PARAMS
     
    59645975 * NOTES
    59655976 *     This function is used by OleConvertOLESTREAMToIStorage only.
    5966  *
     5977 *     
    59675978 *     Memory allocated for pData must be freed by the caller
    59685979 */
    59695980HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1)
    59705981{
    5971     DWORD dwSize;
    5972     HRESULT hRes = S_OK;
    5973     int nTryCnt=0;
    5974     int max_try = 6;
    5975 
    5976     pData->pData = NULL;
    5977     pData->pstrOleObjFileName = (CHAR *) NULL;
    5978 
    5979     for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
    5980     {
    5981     /* Get the OleID */
    5982     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
    5983     if(dwSize != sizeof(pData->dwOleID))
    5984     {
    5985         hRes = CONVERT10_E_OLESTREAM_GET;
    5986     }
    5987     else if(pData->dwOleID != OLESTREAM_ID)
    5988     {
    5989         hRes = CONVERT10_E_OLESTREAM_FMT;
    5990     }
    5991         else
    5992         {
    5993             hRes = S_OK;
    5994             break;
    5995         }
    5996     }
    5997 
    5998     if(hRes == S_OK)
    5999     {
    6000         /* Get the TypeID...more info needed for this field */
    6001         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
    6002         if(dwSize != sizeof(pData->dwTypeID))
    6003         {
    6004             hRes = CONVERT10_E_OLESTREAM_GET;
    6005         }
    6006     }
    6007     if(hRes == S_OK)
    6008     {
    6009         if(pData->dwTypeID != 0)
    6010         {
    6011             /* Get the lenght of the OleTypeName */
    6012             dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
    6013             if(dwSize != sizeof(pData->dwOleTypeNameLength))
    6014             {
    6015                 hRes = CONVERT10_E_OLESTREAM_GET;
    6016             }
    6017 
    6018             if(hRes == S_OK)
    6019             {
    6020                 if(pData->dwOleTypeNameLength > 0)
    6021                 {
    6022                     /* Get the OleTypeName */
    6023                     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);
    6024                     if(dwSize != pData->dwOleTypeNameLength)
    6025                     {
    6026                         hRes = CONVERT10_E_OLESTREAM_GET;
    6027                     }
    6028                 }
    6029             }
    6030             if(bStrem1)
    6031             {
    6032                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
    6033                 if(dwSize != sizeof(pData->dwOleObjFileNameLength))
    6034                 {
    6035                     hRes = CONVERT10_E_OLESTREAM_GET;
    6036                 }
    6037             if(hRes == S_OK)
    6038             {
    6039                     if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
    6040                         pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
    6041                     pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
    6042                     if(pData->pstrOleObjFileName)
    6043                     {
    6044                         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
    6045                         if(dwSize != pData->dwOleObjFileNameLength)
    6046                         {
    6047                             hRes = CONVERT10_E_OLESTREAM_GET;
    6048                         }
    6049                     }
    6050                     else
    6051                         hRes = CONVERT10_E_OLESTREAM_GET;
    6052                 }
    6053             }
    6054             else
    6055             {
    6056                 /* Get the Width of the Metafile */
    6057                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
    6058                 if(dwSize != sizeof(pData->dwMetaFileWidth))
    6059                 {
    6060                     hRes = CONVERT10_E_OLESTREAM_GET;
    6061                 }
    6062             if(hRes == S_OK)
    6063             {
    6064                 /* Get the Height of the Metafile */
    6065                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
    6066                 if(dwSize != sizeof(pData->dwMetaFileHeight))
    6067                 {
    6068                     hRes = CONVERT10_E_OLESTREAM_GET;
    6069                 }
    6070             }
    6071             }
    6072             if(hRes == S_OK)
    6073             {
    6074                 /* Get the Lenght of the Data */
    6075                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
    6076                 if(dwSize != sizeof(pData->dwDataLength))
    6077                 {
    6078                     hRes = CONVERT10_E_OLESTREAM_GET;
    6079                 }
    6080             }
    6081 
    6082             if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */
    6083             {
    6084                 if(!bStrem1) /* if it is a second OLE stream data */
    6085                 {
    6086                     pData->dwDataLength -= 8;
    6087                     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
    6088                     if(dwSize != sizeof(pData->strUnknown))
    6089                     {
    6090                         hRes = CONVERT10_E_OLESTREAM_GET;
    6091                     }
    6092                 }
    6093             }
    6094             if(hRes == S_OK)
    6095             {
    6096                 if(pData->dwDataLength > 0)
    6097                 {
    6098                     pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
    6099 
    6100                     /* Get Data (ex. IStorage, Metafile, or BMP) */
    6101                     if(pData->pData)
    6102                     {
    6103                         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
    6104                         if(dwSize != pData->dwDataLength)
    6105                         {
    6106                             hRes = CONVERT10_E_OLESTREAM_GET;
    6107                         }
    6108                     }
    6109                     else
    6110                     {
    6111                         hRes = CONVERT10_E_OLESTREAM_GET;
    6112                     }
    6113                 }
    6114             }
    6115         }
    6116     }
    6117     return hRes;
     5982        DWORD dwSize;
     5983        HRESULT hRes = S_OK;
     5984        int nTryCnt=0;
     5985        int max_try = 6;
     5986
     5987        pData->pData = NULL;
     5988        pData->pstrOleObjFileName = (CHAR *) NULL;
     5989
     5990        for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
     5991        {
     5992        /* Get the OleID */
     5993        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
     5994        if(dwSize != sizeof(pData->dwOleID))
     5995        {
     5996                hRes = CONVERT10_E_OLESTREAM_GET;
     5997        }
     5998        else if(pData->dwOleID != OLESTREAM_ID)
     5999        {
     6000                hRes = CONVERT10_E_OLESTREAM_FMT;
     6001        }
     6002                else
     6003                {
     6004                        hRes = S_OK;
     6005                        break;
     6006                }
     6007        }
     6008
     6009        if(hRes == S_OK)
     6010        {
     6011                /* Get the TypeID...more info needed for this field */
     6012                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
     6013                if(dwSize != sizeof(pData->dwTypeID))
     6014                {
     6015                        hRes = CONVERT10_E_OLESTREAM_GET;
     6016                }
     6017        }
     6018        if(hRes == S_OK)
     6019        {
     6020                if(pData->dwTypeID != 0)
     6021                {
     6022                        /* Get the lenght of the OleTypeName */
     6023                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
     6024                        if(dwSize != sizeof(pData->dwOleTypeNameLength))
     6025                        {
     6026                                hRes = CONVERT10_E_OLESTREAM_GET;
     6027                        }
     6028
     6029                        if(hRes == S_OK)
     6030                        {
     6031                                if(pData->dwOleTypeNameLength > 0)
     6032                                {
     6033                                        /* Get the OleTypeName */
     6034                                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);
     6035                                        if(dwSize != pData->dwOleTypeNameLength)
     6036                                        {
     6037                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6038                                        }
     6039                                }
     6040                        }
     6041                        if(bStrem1)
     6042                        {
     6043                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
     6044                                if(dwSize != sizeof(pData->dwOleObjFileNameLength))
     6045                                {
     6046                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6047                                }
     6048                        if(hRes == S_OK)
     6049                        {
     6050                                        if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
     6051                                                pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
     6052                                        pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
     6053                                        if(pData->pstrOleObjFileName)
     6054                                        {
     6055                                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
     6056                                                if(dwSize != pData->dwOleObjFileNameLength)
     6057                                                {
     6058                                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6059                                                }
     6060                                        }
     6061                                        else
     6062                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6063                                }
     6064                        }
     6065                        else
     6066                        {
     6067                                /* Get the Width of the Metafile */
     6068                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
     6069                                if(dwSize != sizeof(pData->dwMetaFileWidth))
     6070                                {
     6071                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6072                                }
     6073                        if(hRes == S_OK)
     6074                        {
     6075                                /* Get the Height of the Metafile */
     6076                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
     6077                                if(dwSize != sizeof(pData->dwMetaFileHeight))
     6078                                {
     6079                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6080                                }
     6081                        }
     6082                        }
     6083                        if(hRes == S_OK)
     6084                        {
     6085                                /* Get the Lenght of the Data */
     6086                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
     6087                                if(dwSize != sizeof(pData->dwDataLength))
     6088                                {
     6089                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6090                                }
     6091                        }
     6092
     6093                        if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */
     6094                        {
     6095                                if(!bStrem1) /* if it is a second OLE stream data */
     6096                                {
     6097                                        pData->dwDataLength -= 8;
     6098                                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
     6099                                        if(dwSize != sizeof(pData->strUnknown))
     6100                                        {
     6101                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6102                                        }
     6103                                }
     6104                        }
     6105                        if(hRes == S_OK)
     6106                        {
     6107                                if(pData->dwDataLength > 0)
     6108                                {
     6109                                        pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
     6110
     6111                                        /* Get Data (ex. IStorage, Metafile, or BMP) */
     6112                                        if(pData->pData)
     6113                                        {
     6114                                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
     6115                                                if(dwSize != pData->dwDataLength)
     6116                                                {
     6117                                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6118                                                }
     6119                                        }
     6120                                        else
     6121                                        {
     6122                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6123                                        }
     6124                                }
     6125                        }
     6126                }
     6127        }
     6128        return hRes;
    61186129}
    61196130
    61206131/*************************************************************************
    6121  * OLECONVERT_SaveOLE10 [Internal]
    6122  *
    6123  * Saves the OLE10 STREAM From memory
     6132 * OLECONVERT_SaveOLE10 [Internal] 
     6133 *
     6134 * Saves the OLE10 STREAM From memory 
    61246135 *
    61256136 * PARAMS
     
    61336144 * NOTES
    61346145 *     This function is used by OleConvertIStorageToOLESTREAM only.
    6135  *
     6146 *     
    61366147 */
    61376148HRESULT OLECONVERT_SaveOLE10(OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream)
     
    62276238
    62286239/*************************************************************************
    6229  * OLECONVERT_GetOLE20FromOLE10[Internal]
     6240 * OLECONVERT_GetOLE20FromOLE10[Internal] 
    62306241 *
    62316242 * This function copies OLE10 Data (the IStorage in the OLESTREAM) to disk,
    6232  * opens it, and copies the content to the dest IStorage for
     6243 * opens it, and copies the content to the dest IStorage for 
    62336244 * OleConvertOLESTREAMToIStorage
    6234  *
     6245 * 
    62356246 *
    62366247 * PARAMS
     
    62436254 *
    62446255 * NOTES
    6245  *
    6246  *
     6256 *     
     6257 *     
    62476258 */
    62486259void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, BYTE *pBuffer, DWORD nBufferLength)
     
    62796290
    62806291/*************************************************************************
    6281  * OLECONVERT_WriteOLE20ToBuffer [Internal]
    6282  *
    6283  * Saves the OLE10 STREAM From memory
     6292 * OLECONVERT_WriteOLE20ToBuffer [Internal] 
     6293 *
     6294 * Saves the OLE10 STREAM From memory 
    62846295 *
    62856296 * PARAMS
     
    62946305 *
    62956306 *     Used by OleConvertIStorageToOLESTREAM only.
    6296  *
     6307 *     
    62976308 */
    62986309DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
     
    63066317
    63076318    *pData = NULL;
    6308 
     6319   
    63096320    /* Create temp Storage */
    63106321    GetTempPathW(MAX_PATH, wstrTempDir);
     
    63336344
    63346345/*************************************************************************
    6335  * OLECONVERT_CreateOleStream [Internal]
     6346 * OLECONVERT_CreateOleStream [Internal] 
    63366347 *
    63376348 * Creates the "\001OLE" stream in the IStorage if neccessary.
     
    63486359 *     This stream is still unknown, MS Word seems to have extra data
    63496360 *     but since the data is stored in the OLESTREAM there should be
    6350  *     no need to recreate the stream.  If the stream is manually
     6361 *     no need to recreate the stream.  If the stream is manually 
    63516362 *     deleted it will create it with this default data.
    6352  *
     6363 *     
    63536364 */
    63546365void OLECONVERT_CreateOleStream(LPSTORAGE pStorage)
     
    63576368    IStream *pStream;
    63586369    WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0};
    6359     BYTE pOleStreamHeader [] =
    6360     {
    6361         0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
    6362         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    6363         0x00, 0x00, 0x00, 0x00
     6370    BYTE pOleStreamHeader [] = 
     6371    {
     6372        0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 
     6373        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
     6374        0x00, 0x00, 0x00, 0x00 
    63646375    };
    6365 
     6376   
    63666377    /* Create stream if not present */
    6367     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6378    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    63686379        STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    63696380
     
    63786389
    63796390/*************************************************************************
    6380  * OLECONVERT_CreateCompObjStream [Internal]
     6391 * OLECONVERT_CreateCompObjStream [Internal] 
    63816392 *
    63826393 * Creates a "\001CompObj" is the destination IStorage if necessary.
    63836394 *
    63846395 * PARAMS
    6385  *     pStorage       [I] The dest IStorage to create the CompObj Stream
     6396 *     pStorage       [I] The dest IStorage to create the CompObj Stream 
    63866397 *                        if necessary.
    63876398 *     strOleTypeName [I] The ProgID
     
    63956406 *
    63966407 *     The stream data is stored in the OLESTREAM and there should be
    6397  *     no need to recreate the stream.  If the stream is manually
     6408 *     no need to recreate the stream.  If the stream is manually 
    63986409 *     deleted it will attempt to create it by querying the registry.
    63996410 *
    6400  *
     6411 *     
    64016412 */
    64026413HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName)
     
    64176428
    64186429    /*  Create a CompObj stream if it doesn't exist */
    6419     hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6430    hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    64206431        STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    64216432    if(hStorageRes == S_OK)
     
    64386449            LONG hErr;
    64396450            /* Get the CLSID Default Name from the Registry */
    6440             hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey);
     6451            hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 
    64416452            if(hErr == ERROR_SUCCESS)
    64426453            {
     
    64806491
    64816492/*************************************************************************
    6482  * OLECONVERT_CreateOlePresStream[Internal]
     6493 * OLECONVERT_CreateOlePresStream[Internal] 
    64836494 *
    64846495 * Creates the "\002OlePres000" Stream with the Metafile data
     
    64876498 *     pStorage     [I] The dest IStorage to create \002OLEPres000 stream in.
    64886499 *     dwExtentX    [I] Width of the Metafile
    6489  *     dwExtentY    [I] Height of the Metafile
     6500 *     dwExtentY    [I] Height of the Metafile 
    64906501 *     pData        [I] Metafile data
    64916502 *     dwDataLength [I] Size of the Metafile data
     
    64976508 * NOTES
    64986509 *     This function is used by OleConvertOLESTREAMToIStorage only.
    6499  *
     6510 *     
    65006511 */
    65016512void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY , BYTE *pData, DWORD dwDataLength)
     
    65046515    IStream *pStream;
    65056516    WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
    6506     BYTE pOlePresStreamHeader [] =
    6507     {
    6508         0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
    6509         0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     6517    BYTE pOlePresStreamHeader [] = 
     6518    {
     6519        0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 
     6520        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    65106521        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    65116522        0x00, 0x00, 0x00, 0x00
    65126523    };
    65136524
    6514     BYTE pOlePresStreamHeaderEmpty [] =
    6515     {
    6516         0x00, 0x00, 0x00, 0x00,
    6517         0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     6525    BYTE pOlePresStreamHeaderEmpty [] = 
     6526    {
     6527        0x00, 0x00, 0x00, 0x00, 
     6528        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    65186529        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    65196530        0x00, 0x00, 0x00, 0x00
    65206531    };
    6521 
     6532     
    65226533    /* Create the OlePres000 Stream */
    6523     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6534    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    65246535        STGM_CREATE | STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    65256536
     
    65656576
    65666577/*************************************************************************
    6567  * OLECONVERT_CreateOle10NativeStream [Internal]
     6578 * OLECONVERT_CreateOle10NativeStream [Internal] 
    65686579 *
    65696580 * Creates the "\001Ole10Native" Stream (should contain a BMP)
     
    65816592 *
    65826593 *     Might need to verify the data and return appropriate error message
    6583  *
     6594 *     
    65846595 */
    65856596void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, BYTE *pData, DWORD dwDataLength)
     
    65886599    IStream *pStream;
    65896600    WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
    6590 
     6601   
    65916602    /* Create the Ole10Native Stream */
    6592     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6603    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    65936604        STGM_CREATE | STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    65946605
     
    66046615
    66056616/*************************************************************************
    6606  * OLECONVERT_GetOLE10ProgID [Internal]
     6617 * OLECONVERT_GetOLE10ProgID [Internal] 
    66076618 *
    66086619 * Finds the ProgID (or OleTypeID) from the IStorage
     
    66206631 *     This function is used by OleConvertIStorageToOLESTREAM only.
    66216632 *
    6622  *
     6633 *     
    66236634 */
    66246635HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DWORD *dwSize)
     
    66316642
    66326643    /* Open the CompObj Stream */
    6633     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6644    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    66346645        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    66356646    if(hRes == S_OK)
     
    66686679            *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE);
    66696680        }
    6670 
     6681 
    66716682    }
    66726683    return hRes;
     
    66746685
    66756686/*************************************************************************
    6676  * OLECONVERT_GetOle10PresData [Internal]
     6687 * OLECONVERT_GetOle10PresData [Internal] 
    66776688 *
    66786689 * Converts IStorage "/001Ole10Native" stream to a OLE10 Stream
     
    66896700 *
    66906701 *     Memory allocated for pData must be freed by the caller
    6691  *
    6692  *
     6702 *     
     6703 *     
    66936704 */
    66946705void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
     
    67106721
    67116722    /* Open Ole10Native Stream */
    6712     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6723    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    67136724        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    67146725    if(hRes == S_OK)
     
    67296740
    67306741/*************************************************************************
    6731  * OLECONVERT_GetOle20PresData[Internal]
     6742 * OLECONVERT_GetOle20PresData[Internal] 
    67326743 *
    67336744 * Converts IStorage "/002OlePres000" stream to a OLE10 Stream
     
    67426753 * NOTES
    67436754 *     This function is used by OleConvertIStorageToOLESTREAM only.
    6744  *
     6755 *     
    67456756 *     Memory allocated for pData must be freed by the caller
    67466757 */
     
    67696780
    67706781    /* Open OlePress000 stream */
    6771     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6782    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    67726783        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    67736784    if(hRes == S_OK)
     
    68176828
    68186829/*************************************************************************
    6819  * OleConvertOLESTREAMToIStorage [OLE32.87]
     6830 * OleConvertOLESTREAMToIStorage [OLE32.87] 
    68206831 *
    68216832 * Read info on MSDN
     
    68266837 *      Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj",
    68276838 *      and "\001OLE" streams
    6828  *
     6839 *     
    68296840 */
    68306841HRESULT WINAPI OleConvertOLESTREAMToIStorage (
    6831     LPOLESTREAM pOleStream,
    6832     LPSTORAGE pstg,
     6842    LPOLESTREAM pOleStream, 
     6843    LPSTORAGE pstg, 
    68336844    const DVTARGETDEVICE* ptd)
    68346845{
     
    69026913        }
    69036914        if(pOleStreamData[i].pstrOleObjFileName != NULL)
    6904     {
    6905             HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
    6906             pOleStreamData[i].pstrOleObjFileName = NULL;
    6907     }
     6915        {
     6916                HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
     6917                pOleStreamData[i].pstrOleObjFileName = NULL;
     6918        }
    69086919    }
    69096920    return hRes;
     
    69216932 *      Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj",
    69226933 *      and "\001OLE" streams.
    6923  *
     6934 *     
    69246935 */
    69256936HRESULT WINAPI OleConvertIStorageToOLESTREAM (
    6926     LPSTORAGE pstg,
     6937    LPSTORAGE pstg, 
    69276938    LPOLESTREAM pOleStream)
    69286939{
     
    69496960    {
    69506961        /*Was it originaly Ole10 */
    6951         hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
     6962        hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);   
    69526963        if(hRes == S_OK)
    69536964        {
     
    69846995
    69856996/***********************************************************************
    6986  *      GetConvertStg (OLE32.68)
     6997 *              GetConvertStg (OLE32.68)
    69876998 */
    69886999HRESULT WINAPI GetConvertStg(LPGUID guid) {
     
    69987009 */
    69997010HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
    7000     HFILE       hf;
    7001     OFSTRUCT    ofs;
    7002     BYTE        magic[24];
    7003 
    7004     TRACE("(\'%s\')\n",fn);
    7005     hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);
    7006     if (hf==HFILE_ERROR)
    7007         return STG_E_FILENOTFOUND;
    7008     if (24!=_lread(hf,magic,24)) {
    7009         WARN(" too short\n");
    7010         _lclose(hf);
    7011         return S_FALSE;
    7012     }
    7013     if (!memcmp(magic,STORAGE_magic,8)) {
    7014         WARN(" -> YES\n");
    7015         _lclose(hf);
    7016         return S_OK;
    7017     }
    7018     if (!memcmp(magic,STORAGE_notmagic,8)) {
    7019         WARN(" -> NO\n");
    7020         _lclose(hf);
    7021         return S_FALSE;
    7022     }
    7023     if (!memcmp(magic,STORAGE_oldmagic,8)) {
    7024         WARN(" -> old format\n");
    7025         _lclose(hf);
    7026         return STG_E_OLDFORMAT;
    7027     }
    7028     WARN(" -> Invalid header.\n");
    7029     _lclose(hf);
    7030     return STG_E_INVALIDHEADER;
     7011        HFILE           hf;
     7012        OFSTRUCT        ofs;
     7013        BYTE            magic[24];
     7014
     7015        TRACE("(\'%s\')\n",fn);
     7016        hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);
     7017        if (hf==HFILE_ERROR)
     7018                return STG_E_FILENOTFOUND;
     7019        if (24!=_lread(hf,magic,24)) {
     7020                WARN(" too short\n");
     7021                _lclose(hf);
     7022                return S_FALSE;
     7023        }
     7024        if (!memcmp(magic,STORAGE_magic,8)) {
     7025                WARN(" -> YES\n");
     7026                _lclose(hf);
     7027                return S_OK;
     7028        }
     7029        if (!memcmp(magic,STORAGE_notmagic,8)) {
     7030                WARN(" -> NO\n");
     7031                _lclose(hf);
     7032                return S_FALSE;
     7033        }
     7034        if (!memcmp(magic,STORAGE_oldmagic,8)) {
     7035                WARN(" -> old format\n");
     7036                _lclose(hf);
     7037                return STG_E_OLDFORMAT;
     7038        }
     7039        WARN(" -> Invalid header.\n");
     7040        _lclose(hf);
     7041        return STG_E_INVALIDHEADER;
    70317042}
    70327043
     
    70347045 * StgIsStorageFile [OLE32.146]
    70357046 */
    7036 HRESULT WINAPI
    7037 StgIsStorageFile(LPCOLESTR fn)
    7038 {
    7039     LPOLESTR16  xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
    7040     HRESULT ret = StgIsStorageFile16(xfn);
    7041 
    7042     HeapFree(GetProcessHeap(),0,xfn);
    7043     return ret;
     7047HRESULT WINAPI 
     7048StgIsStorageFile(LPCOLESTR fn) 
     7049{
     7050        LPOLESTR16      xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
     7051        HRESULT ret = StgIsStorageFile16(xfn);
     7052
     7053        HeapFree(GetProcessHeap(),0,xfn);
     7054        return ret;
    70447055}
    70457056#endif
  • trunk/src/oleaut32/connpt.c

    r6689 r6711  
    7272  CONNECTDATA *pCD;
    7373  DWORD nConns;
    74 
     74 
    7575  /* Next connection to enumerate from */
    7676  DWORD nCur;
     
    7979
    8080static EnumConnectionsImpl *EnumConnectionsImpl_Construct(IUnknown *pUnk,
    81                               DWORD nSinks,
    82                               CONNECTDATA *pCD);
     81                                                          DWORD nSinks,
     82                                                          CONNECTDATA *pCD);
    8383
    8484
     
    8787 */
    8888static ConnectionPointImpl *ConnectionPointImpl_Construct(IUnknown *pUnk,
    89                               REFIID riid)
     89                                                          REFIID riid)
    9090{
    9191  ConnectionPointImpl *Obj;
     
    9797  Obj->iid =  *riid;
    9898  Obj->maxSinks = MAXSINKS;
    99   Obj->sinks = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    100             sizeof(IUnknown*) * MAXSINKS);
     99  Obj->sinks = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
     100                        sizeof(IUnknown*) * MAXSINKS);
    101101  Obj->nSinks = 0;
    102102  return Obj;
     
    139139  if ( (This==0) || (ppvObject==0) )
    140140    return E_INVALIDARG;
    141 
     141 
    142142  /*
    143143   * Initialize the return parameter.
    144144   */
    145145  *ppvObject = 0;
    146 
     146 
    147147  /*
    148148   * Compare the riid with the interface IDs implemented by this object.
    149149   */
    150   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     150  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    151151  {
    152152    *ppvObject = (IConnectionPoint*)This;
    153153  }
    154   else if (memcmp(&IID_IConnectionPoint, riid, sizeof(IID_IConnectionPoint)) == 0)
     154  else if (memcmp(&IID_IConnectionPoint, riid, sizeof(IID_IConnectionPoint)) == 0) 
    155155  {
    156156    *ppvObject = (IConnectionPoint*)This;
    157157  }
    158 
     158 
    159159  /*
    160160   * Check that we obtained an interface.
     
    165165    return E_NOINTERFACE;
    166166  }
    167 
     167 
    168168  /*
    169169   * Query Interface always increases the reference count by one when it is
     
    189189  return This->ref;
    190190}
    191 
     191       
    192192/************************************************************************
    193193 * ConnectionPointImpl_Release (IUnknown)
     
    195195 * See Windows documentation for more details on IUnknown methods.
    196196 */
    197 static ULONG WINAPI ConnectionPointImpl_Release(
     197static ULONG WINAPI ConnectionPointImpl_Release( 
    198198      IConnectionPoint* iface)
    199199{
     
    215215    return 0;
    216216  }
    217 
     217 
    218218  return This->ref;
    219219}
     
    224224 */
    225225static HRESULT WINAPI ConnectionPointImpl_GetConnectionInterface(
    226                            IConnectionPoint *iface,
    227                            IID              *piid)
     226                                               IConnectionPoint *iface,
     227                                               IID              *piid)
    228228{
    229229  ICOM_THIS(ConnectionPointImpl, iface);
     
    238238 */
    239239static HRESULT WINAPI ConnectionPointImpl_GetConnectionPointContainer(
    240                       IConnectionPoint           *iface,
    241                       IConnectionPointContainer  **ppCPC)
     240                                      IConnectionPoint           *iface,
     241                                      IConnectionPointContainer  **ppCPC)
    242242{
    243243  ICOM_THIS(ConnectionPointImpl, iface);
     
    245245
    246246  return IUnknown_QueryInterface(This->Obj,
    247                 &IID_IConnectionPointContainer,
    248                 (LPVOID)ppCPC);
     247                                &IID_IConnectionPointContainer,
     248                                (LPVOID)ppCPC);
    249249}
    250250
     
    254254 */
    255255static HRESULT WINAPI ConnectionPointImpl_Advise(IConnectionPoint *iface,
    256                         IUnknown *lpUnk,
    257                         DWORD *pdwCookie)
     256                                                IUnknown *lpUnk,
     257                                                DWORD *pdwCookie)
    258258{
    259259  DWORD i;
     
    273273    This->maxSinks += MAXSINKS;
    274274    This->sinks = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->sinks,
    275                   This->maxSinks * sizeof(IUnknown *));
     275                              This->maxSinks * sizeof(IUnknown *));
    276276  }
    277277  This->sinks[i] = lpSink;
     
    287287 */
    288288static HRESULT WINAPI ConnectionPointImpl_Unadvise(IConnectionPoint *iface,
    289                            DWORD dwCookie)
     289                                                   DWORD dwCookie)
    290290{
    291291  ICOM_THIS(ConnectionPointImpl, iface);
     
    307307 */
    308308static HRESULT WINAPI ConnectionPointImpl_EnumConnections(
    309                             IConnectionPoint *iface,
    310                             LPENUMCONNECTIONS *ppEnum)
    311 {
     309                                                    IConnectionPoint *iface,
     310                                                    LPENUMCONNECTIONS *ppEnum)
     311{ 
    312312  ICOM_THIS(ConnectionPointImpl, iface);
    313313  CONNECTDATA *pCD;
     
    317317
    318318  TRACE("(%p)->(%p)\n", This, ppEnum);
    319 
     319 
    320320  *ppEnum = NULL;
    321321
     
    339339  EnumObj = EnumConnectionsImpl_Construct((IUnknown*)This, This->nSinks, pCD);
    340340  hr = IEnumConnections_QueryInterface((IEnumConnections*)EnumObj,
    341                   &IID_IEnumConnections, (LPVOID)ppEnum);
     341                                  &IID_IEnumConnections, (LPVOID)ppEnum);
    342342  IEnumConnections_Release((IEnumConnections*)EnumObj);
    343343
     
    367367 */
    368368static EnumConnectionsImpl *EnumConnectionsImpl_Construct(IUnknown *pUnk,
    369                               DWORD nSinks,
    370                               CONNECTDATA *pCD)
     369                                                          DWORD nSinks,
     370                                                          CONNECTDATA *pCD)
    371371{
    372372  EnumConnectionsImpl *Obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*Obj));
     
    420420  if ( (This==0) || (ppvObject==0) )
    421421    return E_INVALIDARG;
    422 
     422 
    423423  /*
    424424   * Initialize the return parameter.
    425425   */
    426426  *ppvObject = 0;
    427 
     427 
    428428  /*
    429429   * Compare the riid with the interface IDs implemented by this object.
    430430   */
    431   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     431  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    432432  {
    433433    *ppvObject = (IEnumConnections*)This;
    434434  }
    435   else if (memcmp(&IID_IEnumConnections, riid, sizeof(IID_IEnumConnections)) == 0)
     435  else if (memcmp(&IID_IEnumConnections, riid, sizeof(IID_IEnumConnections)) == 0) 
    436436  {
    437437    *ppvObject = (IEnumConnections*)This;
    438438  }
    439 
     439 
    440440  /*
    441441   * Check that we obtained an interface.
     
    446446    return E_NOINTERFACE;
    447447  }
    448 
     448 
    449449  /*
    450450   * Query Interface always increases the reference count by one when it is
     
    470470  return This->ref;
    471471}
    472 
     472       
    473473/************************************************************************
    474474 * EnumConnectionsImpl_Release (IUnknown)
     
    497497    return 0;
    498498  }
    499 
     499 
    500500  return This->ref;
    501501}
     
    506506 */
    507507static HRESULT WINAPI EnumConnectionsImpl_Next(IEnumConnections* iface,
    508                            ULONG cConn, LPCONNECTDATA pCD,
    509                            ULONG *pEnum)
     508                                               ULONG cConn, LPCONNECTDATA pCD,
     509                                               ULONG *pEnum)
    510510{
    511511  ICOM_THIS(EnumConnectionsImpl, iface);
     
    542542 */
    543543static HRESULT WINAPI EnumConnectionsImpl_Skip(IEnumConnections* iface,
    544                            ULONG cSkip)
     544                                               ULONG cSkip)
    545545{
    546546  ICOM_THIS(EnumConnectionsImpl, iface);
     
    576576 */
    577577static HRESULT WINAPI EnumConnectionsImpl_Clone(IEnumConnections* iface,
    578                         LPENUMCONNECTIONS *ppEnum)
     578                                                LPENUMCONNECTIONS *ppEnum)
    579579{
    580580  ICOM_THIS(EnumConnectionsImpl, iface);
    581581  EnumConnectionsImpl *newObj;
    582582  TRACE("(%p)->(%p)\n", This, ppEnum);
    583 
     583 
    584584  newObj = EnumConnectionsImpl_Construct(This->pUnk, This->nConns, This->pCD);
    585585  newObj->nCur = This->nCur;
     
    588588  return S_OK;
    589589}
    590 
     590 
    591591static ICOM_VTABLE(IEnumConnections) EnumConnectionsImpl_VTable =
    592592{
     
    616616 */
    617617HRESULT CreateConnectionPoint(IUnknown *pUnk, REFIID riid,
    618                   IConnectionPoint **pCP)
     618                              IConnectionPoint **pCP)
    619619{
    620620  ConnectionPointImpl *Obj;
     
    624624  if(!Obj) return E_OUTOFMEMORY;
    625625
    626   hr = IConnectionPoint_QueryInterface((IConnectionPoint *)Obj,
    627                        &IID_IConnectionPoint, (LPVOID)pCP);
     626  hr = IConnectionPoint_QueryInterface((IConnectionPoint *)Obj, 
     627                                       &IID_IConnectionPoint, (LPVOID)pCP);
    628628  IConnectionPoint_Release((IConnectionPoint *)Obj);
    629629  return hr;
  • trunk/src/oleaut32/dispatch.c

    r6689 r6711  
    3737 *
    3838 * NOTES
    39  *      - Defer method invocation to ITypeInfo::Invoke()
     39 *              - Defer method invocation to ITypeInfo::Invoke()
    4040 *
    4141 * RETURNS
    4242 *
    43  *      S_OK on success.
     43 *              S_OK on success.
    4444 */
    4545HRESULT WINAPI
     
    7676 *         DispGetIDsOfNames (OLEAUT32.29)
    7777 *
    78  * Convert a set of names to dispids, based on information
     78 * Convert a set of names to dispids, based on information 
    7979 * contained in object's type library.
    80  *
     80 * 
    8181 * NOTES
    82  *      - Defers to ITypeInfo::GetIDsOfNames()
     82 *              - Defers to ITypeInfo::GetIDsOfNames()
    8383 *
    8484 * RETURNS
    8585 *
    86  *      S_OK on success.
     86 *              S_OK on success.
    8787 */
    8888HRESULT WINAPI
     
    109109 *
    110110 * NOTES
    111  *      Coercion is done using system (0) locale.
     111 *              Coercion is done using system (0) locale.
    112112 *
    113113 * RETURNS
    114114 *
    115  *      S_OK on success.
     115 *              S_OK on success.
    116116 */
    117117HRESULT WINAPI DispGetParam(DISPPARAMS* pdispparams, UINT position,
  • trunk/src/oleaut32/initterm.cpp

    r6689 r6711  
    5959   {
    6060   case DLL_PROCESS_ATTACH:
    61     return TRUE;
     61        return TRUE;
    6262
    6363   case DLL_THREAD_ATTACH:
    6464   case DLL_THREAD_DETACH:
    65     return TRUE;
     65        return TRUE;
    6666
    6767   case DLL_PROCESS_DETACH:
    68     ctordtorTerm();
    69     ClosePrivateLogFiles();
    70     return TRUE;
     68        ctordtorTerm();
     69        ClosePrivateLogFiles();
     70        return TRUE;
    7171   }
    7272   return FALSE;
     
    9595      case 0 :
    9696      {
    97     loadNr = globLoadNr++;
     97        loadNr = globLoadNr++;
    9898
    99     DosQueryModuleName(hModule, sizeof(oleaut32Path), oleaut32Path);
    100     char *endofpath = strrchr(oleaut32Path, '\\');
    101     *(endofpath+1) = 0;
     99        DosQueryModuleName(hModule, sizeof(oleaut32Path), oleaut32Path);
     100        char *endofpath = strrchr(oleaut32Path, '\\');
     101        *(endofpath+1) = 0;
    102102
    103103         ctordtorInit();
     
    105105         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    106106
    107     dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
    108          if(dllHandle == 0)
    109         return 0UL;
     107        dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     108         if(dllHandle == 0) 
     109                return 0UL;
    110110
    111111#ifdef DEFAULT_LOGGING_OFF
    112         if(getenv("WIN32LOG_ENABLED")) {
     112        if(getenv("WIN32LOG_ENABLED")) {
    113113#else
    114         if(!getenv("NOWIN32LOG")) {
     114        if(!getenv("NOWIN32LOG")) {
    115115#endif
    116             OpenPrivateLogFiles();
    117     }
     116                OpenPrivateLogFiles();
     117        }
    118118         Hash_Initialise();
    119119
     
    122122      case 1 :
    123123         if(dllHandle) {
    124         UnregisterLxDll(dllHandle);
     124                UnregisterLxDll(dllHandle);
    125125         }
    126126         break;
  • trunk/src/oleaut32/ole2disp.c

    r6689 r6711  
    11/*
    2  *  OLE2DISP library
     2 *      OLE2DISP library
    33 *
    4  *  Copyright 1995  Martin von Loewis
     4 *      Copyright 1995  Martin von Loewis
    55 */
    66#ifdef __WIN32OS2__
     
    3131
    3232/******************************************************************************
    33  *      BSTR_AllocBytes [Internal]
     33 *              BSTR_AllocBytes [Internal]
    3434 */
    3535static BSTR16 BSTR_AllocBytes(int n)
     
    5656
    5757/******************************************************************************
    58  *      SysAllocString16    [OLE2DISP.2]
     58 *              SysAllocString16        [OLE2DISP.2]
    5959 */
    6060BSTR16 WINAPI SysAllocString16(LPCOLESTR16 in)
    6161{
    62     BSTR16 out;
    63 
     62        BSTR16 out;
     63   
     64        if (!in) return 0;
     65   
     66        out = BSTR_AllocBytes(strlen(in)+1);
     67        if(!out)return 0;
     68        strcpy(BSTR_GetAddr(out),in);
     69        return out;
     70}
     71#endif
     72
     73/******************************************************************************
     74 *              SysAllocString  [OLEAUT32.2]
     75 */
     76BSTR WINAPI SysAllocString(LPCOLESTR in)
     77{
    6478    if (!in) return 0;
    65 
    66     out = BSTR_AllocBytes(strlen(in)+1);
    67     if(!out)return 0;
    68     strcpy(BSTR_GetAddr(out),in);
    69     return out;
    70 }
    71 #endif
    72 
    73 /******************************************************************************
    74  *      SysAllocString  [OLEAUT32.2]
    75  */
    76 BSTR WINAPI SysAllocString(LPCOLESTR in)
    77 {
    78     if (!in) return 0;
    79 
     79   
    8080    /* Delegate this to the SysAllocStringLen32 method. */
    8181    return SysAllocStringLen(in, lstrlenW(in));
     
    8484#ifndef __WIN32OS2__
    8585/******************************************************************************
    86  *      SysReAllocString16  [OLE2DISP.3]
     86 *              SysReAllocString16      [OLE2DISP.3]
    8787 */
    8888INT16 WINAPI SysReAllocString16(LPBSTR16 old,LPCOLESTR16 in)
    8989{
    90     BSTR16 new=SysAllocString16(in);
    91     BSTR_Free(*old);
    92     *old=new;
    93     return 1;
    94 }
    95 #endif
    96 
    97 /******************************************************************************
    98  *      SysReAllocString    [OLEAUT32.3]
     90        BSTR16 new=SysAllocString16(in);
     91        BSTR_Free(*old);
     92        *old=new;
     93        return 1;
     94}
     95#endif
     96
     97/******************************************************************************
     98 *              SysReAllocString        [OLEAUT32.3]
    9999 */
    100100INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR in)
     
    103103     * Sanity check
    104104     */
    105     if (old==NULL)
     105    if (old==NULL) 
    106106      return 0;
    107107
     
    109109     * Make sure we free the old string.
    110110     */
    111     if (*old!=NULL)
     111    if (*old!=NULL)     
    112112      SysFreeString(*old);
    113113
     
    122122#ifndef __WIN32OS2__
    123123/******************************************************************************
    124  *      SysAllocStringLen16 [OLE2DISP.4]
     124 *              SysAllocStringLen16     [OLE2DISP.4]
    125125 */
    126126BSTR16 WINAPI SysAllocStringLen16(const char *in, int len)
    127127{
    128     BSTR16 out=BSTR_AllocBytes(len+1);
    129 
    130     if (!out)
    131         return 0;
     128        BSTR16 out=BSTR_AllocBytes(len+1);
     129
     130        if (!out)
     131                return 0;
    132132
    133133    /*
     
    137137     */
    138138    if (in != 0)
    139     strcpy(BSTR_GetAddr(out),in);
     139        strcpy(BSTR_GetAddr(out),in);
    140140    else
    141141      memset(BSTR_GetAddr(out), 0, len+1);
    142142
    143     return out;
     143        return out;
    144144}
    145145#endif
     
    152152 * he describes it as a "DWORD count of characters". By experimenting with
    153153 * a windows application, this count seems to be a DWORD count of bytes in
    154  * the string. Meaning that the count is double the number of wide
     154 * the string. Meaning that the count is double the number of wide 
    155155 * characters in the string.
    156156 */
     
    214214#ifndef __WIN32OS2__
    215215/******************************************************************************
    216  *      SysReAllocStringLen16   [OLE2DISP.5]
     216 *              SysReAllocStringLen16   [OLE2DISP.5]
    217217 */
    218218int WINAPI SysReAllocStringLen16(BSTR16 *old,const char *in,int len)
    219219{
    220     BSTR16 new=SysAllocStringLen16(in,len);
    221     BSTR_Free(*old);
    222     *old=new;
     220        BSTR16 new=SysAllocStringLen16(in,len);
     221        BSTR_Free(*old);
     222        *old=new;
     223        return 1;
     224}
     225#endif
     226
     227 
     228/******************************************************************************
     229 *             SysReAllocStringLen   [OLEAUT32.5]
     230 */
     231int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* in, unsigned int len)
     232{
     233    /*
     234     * Sanity check
     235     */
     236    if (old==NULL)
     237      return 0;
     238
     239    /*
     240     * Make sure we free the old string.
     241     */
     242    if (*old!=NULL)     
     243      SysFreeString(*old);
     244
     245    /*
     246     * Allocate the new string
     247     */
     248    *old = SysAllocStringLen(in, len);
     249
    223250    return 1;
    224251}
    225 #endif
    226 
    227 
    228 /******************************************************************************
    229  *             SysReAllocStringLen   [OLEAUT32.5]
    230  */
    231 int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* in, unsigned int len)
    232 {
    233     /*
    234      * Sanity check
    235      */
    236     if (old==NULL)
    237       return 0;
    238 
    239     /*
    240      * Make sure we free the old string.
    241      */
    242     if (*old!=NULL)
    243       SysFreeString(*old);
    244 
    245     /*
    246      * Allocate the new string
    247      */
    248     *old = SysAllocStringLen(in, len);
    249 
    250     return 1;
    251 }
    252 
    253 #ifndef __WIN32OS2__
    254 /******************************************************************************
    255  *      SysFreeString16 [OLE2DISP.6]
     252
     253#ifndef __WIN32OS2__
     254/******************************************************************************
     255 *              SysFreeString16 [OLE2DISP.6]
    256256 */
    257257void WINAPI SysFreeString16(BSTR16 in)
    258258{
    259     BSTR_Free(in);
    260 }
    261 #endif
    262 
    263 /******************************************************************************
    264  *      SysFreeString   [OLEAUT32.6]
     259        BSTR_Free(in);
     260}
     261#endif
     262
     263/******************************************************************************
     264 *              SysFreeString   [OLEAUT32.6]
    265265 */
    266266void WINAPI SysFreeString(BSTR in)
    267267{
    268268    DWORD* bufferPointer;
    269 
     269   
    270270    /* NULL is a valid parameter */
    271271    if(!in) return;
     
    288288#ifndef __WIN32OS2__
    289289/******************************************************************************
    290  *      SysStringLen16  [OLE2DISP.7]
     290 *              SysStringLen16  [OLE2DISP.7]
    291291 */
    292292int WINAPI SysStringLen16(BSTR16 str)
    293293{
    294     return strlen(BSTR_GetAddr(str));
     294        return strlen(BSTR_GetAddr(str));
    295295}
    296296#endif
     
    310310     if (!str) return 0;
    311311    /*
    312      * The length of the string (in bytes) is contained in a DWORD placed
     312     * The length of the string (in bytes) is contained in a DWORD placed 
    313313     * just before the BSTR pointer
    314314     */
     
    334334     if (!str) return 0;
    335335    /*
    336      * The length of the string (in bytes) is contained in a DWORD placed
     336     * The length of the string (in bytes) is contained in a DWORD placed 
    337337     * just before the BSTR pointer
    338338     */
     
    349349 */
    350350HRESULT WINAPI CreateDispTypeInfo16(
    351     INTERFACEDATA *pidata,
    352     LCID lcid,
    353     ITypeInfo **pptinfo)
    354 {
    355     FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
    356     return 0;
     351        INTERFACEDATA *pidata,
     352        LCID lcid,
     353        ITypeInfo **pptinfo)
     354{
     355        FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
     356        return 0;
    357357}
    358358#endif
     
    362362 */
    363363HRESULT WINAPI CreateDispTypeInfo(
    364     INTERFACEDATA *pidata,
    365     LCID lcid,
    366     ITypeInfo **pptinfo)
    367 {
    368     FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
    369     return 0;
     364        INTERFACEDATA *pidata,
     365        LCID lcid,
     366        ITypeInfo **pptinfo)
     367{
     368        FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
     369        return 0;
    370370}
    371371
     
    377377        IUnknown* punkOuter,
    378378        void* pvThis,
    379     ITypeInfo* ptinfo,
    380     IUnknown** ppunkStdDisp)
    381 {
    382     FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
     379        ITypeInfo* ptinfo,
     380        IUnknown** ppunkStdDisp)
     381{
     382        FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
    383383               ppunkStdDisp);
    384     return 0;
     384        return 0;
    385385}
    386386#endif
     
    392392        IUnknown* punkOuter,
    393393        void* pvThis,
    394     ITypeInfo* ptinfo,
    395     IUnknown** ppunkStdDisp)
    396 {
    397     FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
     394        ITypeInfo* ptinfo,
     395        IUnknown** ppunkStdDisp)
     396{
     397        FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
    398398               ppunkStdDisp);
    399     return 0;
     399        return 0;
    400400}
    401401
     
    405405 */
    406406HRESULT WINAPI RegisterActiveObject16(
    407     IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister
     407        IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister
    408408) {
    409     FIXME("(%p,%s,0x%08lx,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister);
    410     return 0;
    411 }
    412 #endif
    413 
    414 /******************************************************************************
    415  *      OleTranslateColor   [OLEAUT32.421]
     409        FIXME("(%p,%s,0x%08lx,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister);
     410        return 0;
     411}
     412#endif
     413
     414/******************************************************************************
     415 *              OleTranslateColor       [OLEAUT32.421]
    416416 *
    417417 * Converts an OLE_COLOR to a COLORREF.
    418418 * See the documentation for conversion rules.
    419  * pColorRef can be NULL. In that case the user only wants to test the
     419 * pColorRef can be NULL. In that case the user only wants to test the 
    420420 * conversion.
    421421 */
  • trunk/src/oleaut32/oleaut.c

    r6689 r6711  
    11/*
    2  *  OLEAUT32
     2 *      OLEAUT32
    33 *
    44 */
     
    1717DEFAULT_DEBUG_CHANNEL(ole);
    1818
    19 static WCHAR    _delimiter[2] = {'!',0}; /* default delimiter apparently */
    20 static WCHAR    *pdelimiter = &_delimiter[0];
     19static WCHAR    _delimiter[2] = {'!',0}; /* default delimiter apparently */
     20static WCHAR    *pdelimiter = &_delimiter[0];
    2121
    2222/***********************************************************************
    23  *      RegisterActiveObject (OLEAUT32.33)
     23 *              RegisterActiveObject (OLEAUT32.33)
    2424 */
    2525HRESULT WINAPI RegisterActiveObject(
    26     LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister
     26        LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister
    2727) {
    28     WCHAR           guidbuf[80];
    29     HRESULT         ret;
    30     LPRUNNINGOBJECTTABLE    runobtable;
    31     LPMONIKER       moniker;
     28        WCHAR                   guidbuf[80];
     29        HRESULT                 ret;
     30        LPRUNNINGOBJECTTABLE    runobtable;
     31        LPMONIKER               moniker;
    3232
    33     StringFromGUID2(rcid,guidbuf,39);
     33        StringFromGUID2(rcid,guidbuf,39);
    3434#ifdef __WIN32OS2__
    3535        dprintf(("RegisterActiveObject %x %ls (%x) %x %x", punk, guidbuf, rcid, dwFlags, pdwRegister));
    3636#endif
    37     ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
    38     if (FAILED(ret))
    39         return ret;
    40     ret = GetRunningObjectTable(0,&runobtable);
    41     if (FAILED(ret)) {
    42         IMoniker_Release(moniker);
    43         return ret;
    44     }
    45     ret = IRunningObjectTable_Register(runobtable,dwFlags,punk,moniker,pdwRegister);
    46     IRunningObjectTable_Release(runobtable);
    47     IMoniker_Release(moniker);
    48     return ret;
     37        ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
     38        if (FAILED(ret))
     39                return ret;
     40        ret = GetRunningObjectTable(0,&runobtable);
     41        if (FAILED(ret)) {
     42                IMoniker_Release(moniker);
     43                return ret;
     44        }
     45        ret = IRunningObjectTable_Register(runobtable,dwFlags,punk,moniker,pdwRegister);
     46        IRunningObjectTable_Release(runobtable);
     47        IMoniker_Release(moniker);
     48        return ret;
    4949}
    5050
    5151/***********************************************************************
    52  *      RevokeActiveObject (OLEAUT32.34)
     52 *              RevokeActiveObject (OLEAUT32.34)
    5353 */
    5454HRESULT WINAPI RevokeActiveObject(DWORD xregister,LPVOID reserved)
    5555{
    56     LPRUNNINGOBJECTTABLE    runobtable;
    57     HRESULT         ret;
     56        LPRUNNINGOBJECTTABLE    runobtable;
     57        HRESULT                 ret;
    5858
    5959#ifdef __WIN32OS2__
     
    6161#endif
    6262
    63     ret = GetRunningObjectTable(0,&runobtable);
    64     if (FAILED(ret)) return ret;
    65     ret = IRunningObjectTable_Revoke(runobtable,xregister);
    66     if (SUCCEEDED(ret)) ret = S_OK;
    67     IRunningObjectTable_Release(runobtable);
    68     return ret;
     63        ret = GetRunningObjectTable(0,&runobtable);
     64        if (FAILED(ret)) return ret;
     65        ret = IRunningObjectTable_Revoke(runobtable,xregister);
     66        if (SUCCEEDED(ret)) ret = S_OK;
     67        IRunningObjectTable_Release(runobtable);
     68        return ret;
    6969}
    7070
    7171/***********************************************************************
    72  *      GetActiveObject (OLEAUT32.35)
     72 *              GetActiveObject (OLEAUT32.35)
    7373 */
    7474HRESULT WINAPI GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk)
    7575{
    76     WCHAR           guidbuf[80];
    77     HRESULT         ret;
    78     LPRUNNINGOBJECTTABLE    runobtable;
    79     LPMONIKER       moniker;
     76        WCHAR                   guidbuf[80];
     77        HRESULT                 ret;
     78        LPRUNNINGOBJECTTABLE    runobtable;
     79        LPMONIKER               moniker;
    8080
    81     StringFromGUID2(rcid,guidbuf,39);
     81        StringFromGUID2(rcid,guidbuf,39);
    8282#ifdef __WIN32OS2__
    8383        dprintf(("GetActiveObject %ls (%x) %x %x", guidbuf, rcid, preserved, ppunk));
    8484#endif
    85     ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
    86     if (FAILED(ret))
    87         return ret;
    88     ret = GetRunningObjectTable(0,&runobtable);
    89     if (FAILED(ret)) {
    90         IMoniker_Release(moniker);
    91         return ret;
    92     }
    93     ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk);
    94     IRunningObjectTable_Release(runobtable);
    95     IMoniker_Release(moniker);
    96     return ret;
     85        ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
     86        if (FAILED(ret))
     87                return ret;
     88        ret = GetRunningObjectTable(0,&runobtable);
     89        if (FAILED(ret)) {
     90                IMoniker_Release(moniker);
     91                return ret;
     92        }
     93        ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk);
     94        IRunningObjectTable_Release(runobtable);
     95        IMoniker_Release(moniker);
     96        return ret;
    9797}
    9898
     
    101101 *
    102102 * known OLEAUT32.DLL versions:
    103  * OLE 2.1  NT              1993-95 10     3023
    104  * OLE 2.1                  10     3027
    105  * OLE 2.20 W95/NT          1993-96 20     4112
    106  * OLE 2.20 W95/NT          1993-96 20     4118
    107  * OLE 2.20 W95/NT          1993-96 20     4122
    108  * OLE 2.30 W95/NT          1993-98 30     4265
    109  * OLE 2.40 NT??            1993-98 40     4267
    110  * OLE 2.40 W98 SE orig. file       1993-98 40     4275
     103 * OLE 2.1  NT                          1993-95 10     3023
     104 * OLE 2.1                                      10     3027
     105 * OLE 2.20 W95/NT                      1993-96 20     4112
     106 * OLE 2.20 W95/NT                      1993-96 20     4118
     107 * OLE 2.20 W95/NT                      1993-96 20     4122
     108 * OLE 2.30 W95/NT                      1993-98 30     4265
     109 * OLE 2.40 NT??                        1993-98 40     4267
     110 * OLE 2.40 W98 SE orig. file           1993-98 40     4275
    111111 */
    112112UINT WINAPI OaBuildVersion()
     
    120120    {
    121121    case 0x80000a03:  /* WIN31 */
    122         return MAKELONG(4049, 20); /* from Win32s 1.1e */
     122                return MAKELONG(4049, 20); /* from Win32s 1.1e */
    123123    case 0x80000004:  /* WIN95 */
    124         return MAKELONG(4265, 30);
     124                return MAKELONG(4265, 30);
    125125    case 0x80000a04:  /* WIN98 */
    126         return MAKELONG(4275, 40); /* value of W98 SE; orig. W98 AFAIK has 4265, 30 just as W95 */
     126                return MAKELONG(4275, 40); /* value of W98 SE; orig. W98 AFAIK has 4265, 30 just as W95 */
    127127    case 0x00003303:  /* NT351 */
    128         return MAKELONG(4265, 30); /* value borrowed from Win95 */
     128                return MAKELONG(4265, 30); /* value borrowed from Win95 */
    129129    case 0x00000004:  /* NT40 */
    130130#ifdef __WIN32OS2__
    131131                return 0x2810b5; //returned by NT4, SP6
    132132#else
    133         return MAKELONG(4122, 20); /* ouch ! Quite old, I guess */
     133                return MAKELONG(4122, 20); /* ouch ! Quite old, I guess */
    134134#endif
    135135    default:
    136         ERR("Version value not known yet. Please investigate it !\n");
    137         return 0x0;
     136                ERR("Version value not known yet. Please investigate it !\n");
     137                return 0x0;
    138138    }
    139139}
     
    141141#ifndef __WIN32OS2__
    142142/***********************************************************************
    143  *      DllRegisterServer
     143 *              DllRegisterServer
    144144 */
    145 HRESULT WINAPI OLEAUT32_DllRegisterServer() {
     145HRESULT WINAPI OLEAUT32_DllRegisterServer() { 
    146146    FIXME("stub!\n");
    147147    return S_OK;
     
    149149
    150150/***********************************************************************
    151  *      DllUnregisterServer
     151 *              DllUnregisterServer
    152152 */
    153153HRESULT WINAPI OLEAUT32_DllUnregisterServer() {
  • trunk/src/oleaut32/olefont.c

    r6689 r6711  
    4646{
    4747  /*
    48    * This class supports many interfaces. IUnknown, IFont,
     48   * This class supports many interfaces. IUnknown, IFont, 
    4949   * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
    5050   * The first two are supported by the first vtable, the next two are
     
    8585
    8686/*
    87  * Here, I define utility macros to help with the casting of the
     87 * Here, I define utility macros to help with the casting of the 
    8888 * "this" parameter.
    8989 * There is a version to accomodate all of the VTables implemented
     
    9191 */
    9292#define _ICOM_THIS(class,name) class* this = (class*)name;
    93 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
    94 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
    95 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
     93#define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 
     94#define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 
     95#define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 
    9696
    9797
     
    134134 * interface
    135135 */
    136 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
    137                             REFIID     riid,
    138                             VOID**     ppvoid);
     136static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 
     137                                                    REFIID     riid,
     138                                                    VOID**     ppvoid);
    139139static ULONG   WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
    140140static ULONG   WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
    141 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface,
    142                                unsigned int* pctinfo);
    143 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface,
    144                               UINT      iTInfo,
    145                               LCID        lcid,
    146                               ITypeInfo** ppTInfo);
     141static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface, 
     142                                                   unsigned int* pctinfo);
     143static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface, 
     144                                              UINT      iTInfo,
     145                                              LCID        lcid,
     146                                              ITypeInfo** ppTInfo);
    147147static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch*  iface,
    148                             REFIID      riid,
    149                             LPOLESTR* rgszNames,
    150                             UINT      cNames,
    151                             LCID        lcid,
    152                             DISPID*     rgDispId);
     148                                                REFIID      riid,
     149                                                LPOLESTR* rgszNames,
     150                                                UINT      cNames,
     151                                                LCID        lcid,
     152                                                DISPID*     rgDispId);
    153153static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch*  iface,
    154                          DISPID      dispIdMember,
    155                          REFIID      riid,
    156                          LCID        lcid,
    157                          WORD        wFlags,
    158                          DISPPARAMS* pDispParams,
    159                          VARIANT*    pVarResult,
    160                          EXCEPINFO*  pExepInfo,
    161                          UINT*     puArgErr);
     154                                         DISPID      dispIdMember,
     155                                         REFIID      riid,
     156                                         LCID        lcid,
     157                                         WORD        wFlags,
     158                                         DISPPARAMS* pDispParams,
     159                                         VARIANT*    pVarResult,
     160                                         EXCEPINFO*  pExepInfo,
     161                                         UINT*     puArgErr);
    162162
    163163/***********************************************************************
     
    165165 * interface
    166166 */
    167 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
    168                             REFIID     riid,
    169                             VOID**     ppvoid);
     167static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 
     168                                                    REFIID     riid,
     169                                                    VOID**     ppvoid);
    170170static ULONG   WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
    171171static ULONG   WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
    172 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
    173                          CLSID*                pClassID);
     172static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 
     173                                             CLSID*                pClassID);
    174174static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream*  iface);
    175175static HRESULT WINAPI OLEFontImpl_Load(IPersistStream*  iface,
    176                        IStream*         pLoadStream);
     176                                       IStream*         pLoadStream);
    177177static HRESULT WINAPI OLEFontImpl_Save(IPersistStream*  iface,
    178                        IStream*         pOutStream,
    179                        BOOL             fClearDirty);
     178                                       IStream*         pOutStream,
     179                                       BOOL             fClearDirty);
    180180static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream*  iface,
    181                          ULARGE_INTEGER*  pcbSize);
     181                                             ULARGE_INTEGER*  pcbSize);
    182182
    183183/***********************************************************************
     
    186186 */
    187187static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
    188                         IConnectionPointContainer* iface,
    189                         REFIID     riid,
    190                         VOID**     ppvoid);
     188                                            IConnectionPointContainer* iface,
     189                                            REFIID     riid,
     190                                            VOID**     ppvoid);
    191191static ULONG   WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
    192                         IConnectionPointContainer* iface);
     192                                            IConnectionPointContainer* iface);
    193193static ULONG   WINAPI OLEFontImpl_IConnectionPointContainer_Release(
    194                         IConnectionPointContainer* iface);
     194                                            IConnectionPointContainer* iface);
    195195static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
    196                         IConnectionPointContainer* iface,
    197                         IEnumConnectionPoints **ppEnum);
     196                                            IConnectionPointContainer* iface,
     197                                            IEnumConnectionPoints **ppEnum);
    198198static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
    199                         IConnectionPointContainer* iface,
    200                         REFIID riid,
    201                         IConnectionPoint **ppCp);
     199                                            IConnectionPointContainer* iface,
     200                                            REFIID riid,
     201                                            IConnectionPoint **ppCp);
    202202
    203203/*
     
    227227  OLEFontImpl_put_Charset,
    228228  OLEFontImpl_get_hFont,
    229   OLEFontImpl_Clone,
     229  OLEFontImpl_Clone, 
    230230  OLEFontImpl_IsEqual,
    231231  OLEFontImpl_SetRatio,
     
    273273
    274274/******************************************************************************
    275  *      OleCreateFontIndirect   [OLEAUT32.420]
     275 *              OleCreateFontIndirect   [OLEAUT32.420]
    276276 */
    277277HRESULT WINAPI OleCreateFontIndirect(
     
    331331
    332332  IConnectionPoint_EnumConnections(this->pCP, &pEnum);
    333 
     333 
    334334  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
    335335    IPropertyNotifySink *sink;
     
    343343  return;
    344344}
    345 
     345 
    346346/************************************************************************
    347347 * OLEFontImpl_Construct
     
    364364  if (newObject==0)
    365365    return newObject;
    366 
     366 
    367367  /*
    368368   * Initialize the virtual function table.
     
    372372  newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
    373373  newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable;
    374 
    375   /*
    376    * Start with one reference count. The caller of this function
     374 
     375  /*
     376   * Start with one reference count. The caller of this function 
    377377   * must release the interface pointer when it is done.
    378378   */
     
    386386  newObject->description.cbSizeofstruct = sizeof(FONTDESC);
    387387  newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
    388                            0,
    389                            (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
     388                                               0,
     389                                               (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
    390390  strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
    391391  newObject->description.cySize         = fontDesc->cySize;
     
    448448  if ( (this==0) || (ppvObject==0) )
    449449    return E_INVALIDARG;
    450 
     450 
    451451  /*
    452452   * Initialize the return parameter.
    453453   */
    454454  *ppvObject = 0;
    455 
     455 
    456456  /*
    457457   * Compare the riid with the interface IDs implemented by this object.
    458458   */
    459   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     459  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    460460  {
    461461    *ppvObject = (IFont*)this;
    462462  }
    463   else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0)
     463  else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 
    464464  {
    465465    *ppvObject = (IFont*)this;
    466466  }
    467   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
     467  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
    468468  {
    469469    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    470470  }
    471   else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0)
     471  else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 
    472472  {
    473473    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    474474  }
    475   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
     475  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
    476476  {
    477477    *ppvObject = (IPersistStream*)&(this->lpvtbl3);
    478478  }
    479479  else if (memcmp(&IID_IConnectionPointContainer, riid,
    480           sizeof(IID_IConnectionPointContainer)) == 0)
     480                  sizeof(IID_IConnectionPointContainer)) == 0)
    481481  {
    482482    *ppvObject = (IPersistStream*)&(this->lpvtbl4);
    483483  }
    484 
     484 
    485485  /*
    486486   * Check that we obtained an interface.
     
    491491    return E_NOINTERFACE;
    492492  }
    493 
     493 
    494494  /*
    495495   * Query Interface always increases the reference count by one when it is
     
    500500  return S_OK;;
    501501}
    502 
     502       
    503503/************************************************************************
    504504 * OLEFontImpl_AddRef (IUnknown)
     
    506506 * See Windows documentation for more details on IUnknown methods.
    507507 */
    508 ULONG WINAPI OLEFontImpl_AddRef(
     508ULONG WINAPI OLEFontImpl_AddRef( 
    509509  IFont* iface)
    510510{
     
    515515  return this->ref;
    516516}
    517 
     517       
    518518/************************************************************************
    519519 * OLEFontImpl_Release (IUnknown)
     
    521521 * See Windows documentation for more details on IUnknown methods.
    522522 */
    523 ULONG WINAPI OLEFontImpl_Release(
     523ULONG WINAPI OLEFontImpl_Release( 
    524524      IFont* iface)
    525525{
     
    541541    return 0;
    542542  }
    543 
     543 
    544544  return this->ref;
    545545}
    546 
     546       
    547547/************************************************************************
    548548 * OLEFontImpl_get_Name (IFont)
     
    551551 */
    552552static HRESULT WINAPI OLEFontImpl_get_Name(
    553   IFont*  iface,
     553  IFont*  iface, 
    554554  BSTR* pname)
    555555{
     
    576576 */
    577577static HRESULT WINAPI OLEFontImpl_put_Name(
    578   IFont* iface,
     578  IFont* iface, 
    579579  BSTR name)
    580580{
     
    585585  {
    586586    this->description.lpstrName = HeapAlloc(GetProcessHeap(),
    587                         0,
    588                         (lstrlenW(name)+1) * sizeof(WCHAR));
     587                                            0,
     588                                            (lstrlenW(name)+1) * sizeof(WCHAR));
    589589  }
    590590  else
    591591  {
    592592    this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
    593                           0,
    594                           this->description.lpstrName,
    595                           (lstrlenW(name)+1) * sizeof(WCHAR));
     593                                              0,
     594                                              this->description.lpstrName,
     595                                              (lstrlenW(name)+1) * sizeof(WCHAR));
    596596  }
    597597
     
    611611 */
    612612static HRESULT WINAPI OLEFontImpl_get_Size(
    613   IFont* iface,
     613  IFont* iface, 
    614614  CY*    psize)
    615615{
     
    635635 */
    636636static HRESULT WINAPI OLEFontImpl_put_Size(
    637   IFont* iface,
     637  IFont* iface, 
    638638  CY     size)
    639639{
     
    653653 */
    654654static HRESULT WINAPI OLEFontImpl_get_Bold(
    655   IFont*  iface,
     655  IFont*  iface, 
    656656  BOOL* pbold)
    657657{
     
    692692 */
    693693static HRESULT WINAPI OLEFontImpl_get_Italic(
    694   IFont*  iface,
     694  IFont*  iface, 
    695695  BOOL* pitalic)
    696696{
     
    714714 */
    715715static HRESULT WINAPI OLEFontImpl_put_Italic(
    716   IFont* iface,
     716  IFont* iface, 
    717717  BOOL italic)
    718718{
     
    732732 */
    733733static HRESULT WINAPI OLEFontImpl_get_Underline(
    734   IFont*  iface,
     734  IFont*  iface, 
    735735  BOOL* punderline)
    736736{
     
    773773 */
    774774static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
    775   IFont*  iface,
     775  IFont*  iface, 
    776776  BOOL* pstrikethrough)
    777777{
     
    796796 */
    797797static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
    798  IFont* iface,
     798 IFont* iface, 
    799799 BOOL strikethrough)
    800800{
     
    814814 */
    815815static HRESULT WINAPI OLEFontImpl_get_Weight(
    816   IFont* iface,
     816  IFont* iface, 
    817817  short* pweight)
    818818{
     
    837837 */
    838838static HRESULT WINAPI OLEFontImpl_put_Weight(
    839   IFont* iface,
     839  IFont* iface, 
    840840  short  weight)
    841841{
     
    855855 */
    856856static HRESULT WINAPI OLEFontImpl_get_Charset(
    857   IFont* iface,
     857  IFont* iface, 
    858858  short* pcharset)
    859859{
     
    878878 */
    879879static HRESULT WINAPI OLEFontImpl_put_Charset(
    880   IFont* iface,
     880  IFont* iface, 
    881881  short charset)
    882882{
     
    912912    INT      fontHeight;
    913913    CY       cySize;
    914 
     914   
    915915    /*
    916916     * The height of the font returned by the get_Size property is the
     
    982982   */
    983983  newObject->description.lpstrName = HeapAlloc(
    984     GetProcessHeap(),0,
    985     (1+strlenW(this->description.lpstrName))*2
     984        GetProcessHeap(),0,
     985        (1+strlenW(this->description.lpstrName))*2
    986986  );
    987987  /* We need to clone the HFONT too. This is just cut & paste from above */
     
    994994
    995995  logFont.lfHeight          = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
    996                                 (-fontHeight/10000L);
     996                                                            (-fontHeight/10000L);
    997997  logFont.lfItalic          = this->description.fItalic;
    998998  logFont.lfUnderline       = this->description.fUnderline;
     
    10231023 */
    10241024static HRESULT WINAPI OLEFontImpl_IsEqual(
    1025   IFont* iface,
     1025  IFont* iface, 
    10261026  IFont* pFontOther)
    10271027{
     
    10551055 */
    10561056static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics(
    1057   IFont*         iface,
     1057  IFont*         iface, 
    10581058  TEXTMETRICOLE* ptm)
    10591059{
     
    10681068 */
    10691069static HRESULT WINAPI OLEFontImpl_AddRefHfont(
    1070   IFont*  iface,
     1070  IFont*  iface, 
    10711071  HFONT hfont)
    10721072{
     
    11071107  {
    11081108    DeleteObject(this->gdiFont);
    1109     this->gdiFont = 0;
     1109    this->gdiFont = 0; 
    11101110  }
    11111111
     
    11741174 */
    11751175static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
    1176   IDispatch*    iface,
     1176  IDispatch*    iface, 
    11771177  unsigned int* pctinfo)
    11781178{
     
    11891189 */
    11901190static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
    1191   IDispatch*  iface,
     1191  IDispatch*  iface, 
    11921192  UINT      iTInfo,
    1193   LCID        lcid,
     1193  LCID        lcid, 
    11941194  ITypeInfo** ppTInfo)
    11951195{
     
    12071207static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
    12081208  IDispatch*  iface,
    1209   REFIID      riid,
    1210   LPOLESTR* rgszNames,
    1211   UINT      cNames,
     1209  REFIID      riid, 
     1210  LPOLESTR* rgszNames, 
     1211  UINT      cNames, 
    12121212  LCID        lcid,
    12131213  DISPID*     rgDispId)
     
    12261226static HRESULT WINAPI OLEFontImpl_Invoke(
    12271227  IDispatch*  iface,
    1228   DISPID      dispIdMember,
    1229   REFIID      riid,
    1230   LCID        lcid,
     1228  DISPID      dispIdMember, 
     1229  REFIID      riid, 
     1230  LCID        lcid, 
    12311231  WORD        wFlags,
    12321232  DISPPARAMS* pDispParams,
    1233   VARIANT*    pVarResult,
     1233  VARIANT*    pVarResult, 
    12341234  EXCEPINFO*  pExepInfo,
    12351235  UINT*     puArgErr)
     
    12891289 */
    12901290static HRESULT WINAPI OLEFontImpl_GetClassID(
    1291   IPersistStream* iface,
     1291  IPersistStream* iface, 
    12921292  CLSID*                pClassID)
    12931293{
     
    13431343
    13441344  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    1345 
     1345 
    13461346  /*
    13471347   * Read the version byte
     
    13721372  this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
    13731373  this->description.fUnderline     = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
    1374 
     1374   
    13751375  /*
    13761376   * Weight
     
    14081408    HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
    14091409
    1410   this->description.lpstrName = HEAP_strdupAtoW(GetProcessHeap(),
    1411                             HEAP_ZERO_MEMORY,
    1412                             readBuffer);
     1410  this->description.lpstrName = HEAP_strdupAtoW(GetProcessHeap(), 
     1411                                                    HEAP_ZERO_MEMORY,
     1412                                                    readBuffer);
    14131413
    14141414  return S_OK;
     
    14301430  BYTE  bAttributes;
    14311431  BYTE  bStringSize;
    1432 
     1432 
    14331433  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    14341434
     
    14591459  if (this->description.fStrikethrough)
    14601460    bAttributes |= FONTPERSIST_STRIKETHROUGH;
    1461 
     1461 
    14621462  if (this->description.fUnderline)
    14631463    bAttributes |= FONTPERSIST_UNDERLINE;
     
    14671467  if (cbWritten!=1)
    14681468    return E_FAIL;
    1469 
     1469 
    14701470  /*
    14711471   * Weight
     
    14991499  if (bStringSize!=0)
    15001500  {
    1501     writeBuffer = HEAP_strdupWtoA(GetProcessHeap(),
    1502                   HEAP_ZERO_MEMORY,
    1503                   this->description.lpstrName);
     1501    writeBuffer = HEAP_strdupWtoA(GetProcessHeap(), 
     1502                                  HEAP_ZERO_MEMORY,
     1503                                  this->description.lpstrName);
    15041504
    15051505    if (writeBuffer==0)
     
    15071507
    15081508    IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten);
    1509 
     1509   
    15101510    HeapFree(GetProcessHeap(), 0, writeBuffer);
    15111511
     
    16201620  if(memcmp(riid, &IID_IPropertyNotifySink, sizeof(IID_IPropertyNotifySink)) == 0) {
    16211621    return IConnectionPoint_QueryInterface(this->pCP, &IID_IConnectionPoint,
    1622                        (LPVOID)ppCp);
     1622                                           (LPVOID)ppCp);
    16231623  } else {
    16241624    FIXME("Tried to find connection point on %s\n", debugstr_guid(riid));
     
    16371637} IClassFactoryImpl;
    16381638
    1639 static HRESULT WINAPI
     1639static HRESULT WINAPI 
    16401640SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
    1641     ICOM_THIS(IClassFactoryImpl,iface);
    1642 
    1643     FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
    1644     return E_NOINTERFACE;
     1641        ICOM_THIS(IClassFactoryImpl,iface);
     1642
     1643        FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
     1644        return E_NOINTERFACE;
    16451645}
    16461646
    16471647static ULONG WINAPI
    16481648SFCF_AddRef(LPCLASSFACTORY iface) {
    1649     ICOM_THIS(IClassFactoryImpl,iface);
    1650     return ++(This->ref);
     1649        ICOM_THIS(IClassFactoryImpl,iface);
     1650        return ++(This->ref);
    16511651}
    16521652
    16531653static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
    1654     ICOM_THIS(IClassFactoryImpl,iface);
    1655     /* static class, won't be  freed */
    1656     return --(This->ref);
     1654        ICOM_THIS(IClassFactoryImpl,iface);
     1655        /* static class, won't be  freed */
     1656        return --(This->ref);
    16571657}
    16581658
    16591659static HRESULT WINAPI SFCF_CreateInstance(
    1660     LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
     1660        LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
    16611661) {
    1662     ICOM_THIS(IClassFactoryImpl,iface);
    1663 
    1664     if (IsEqualGUID(riid,&IID_IFont)) {
    1665         FONTDESC fd;
    1666 
    1667         WCHAR fname[] = { 'S','y','s','t','e','m',0 };
    1668 
    1669         fd.cbSizeofstruct = sizeof(fd);
    1670         fd.lpstrName      = fname;
    1671         fd.cySize.s.Lo    = 80000;
    1672         fd.cySize.s.Hi    = 0;
    1673         fd.sWeight        = 0;
    1674         fd.sCharset       = 0;
    1675         fd.fItalic        = 0;
    1676         fd.fUnderline     = 0;
    1677         fd.fStrikethrough = 0;
    1678         return OleCreateFontIndirect(&fd,riid,ppobj);
    1679     }
    1680 
    1681     FIXME("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
    1682     return E_NOINTERFACE;
     1662        ICOM_THIS(IClassFactoryImpl,iface);
     1663
     1664        if (IsEqualGUID(riid,&IID_IFont)) {
     1665            FONTDESC fd;
     1666
     1667            WCHAR fname[] = { 'S','y','s','t','e','m',0 };
     1668
     1669            fd.cbSizeofstruct = sizeof(fd);
     1670            fd.lpstrName      = fname;
     1671            fd.cySize.s.Lo    = 80000;
     1672            fd.cySize.s.Hi    = 0;
     1673            fd.sWeight        = 0;
     1674            fd.sCharset       = 0;
     1675            fd.fItalic        = 0;
     1676            fd.fUnderline     = 0;
     1677            fd.fStrikethrough = 0;
     1678            return OleCreateFontIndirect(&fd,riid,ppobj);
     1679        }
     1680
     1681        FIXME("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
     1682        return E_NOINTERFACE;
    16831683}
    16841684
    16851685static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
    1686     ICOM_THIS(IClassFactoryImpl,iface);
    1687     FIXME("(%p)->(%d),stub!\n",This,dolock);
    1688     return S_OK;
     1686        ICOM_THIS(IClassFactoryImpl,iface);
     1687        FIXME("(%p)->(%d),stub!\n",This,dolock);
     1688        return S_OK;
    16891689}
    16901690
    16911691static ICOM_VTABLE(IClassFactory) SFCF_Vtbl = {
    1692     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    1693     SFCF_QueryInterface,
    1694     SFCF_AddRef,
    1695     SFCF_Release,
    1696     SFCF_CreateInstance,
    1697     SFCF_LockServer
     1692        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     1693        SFCF_QueryInterface,
     1694        SFCF_AddRef,
     1695        SFCF_Release,
     1696        SFCF_CreateInstance,
     1697        SFCF_LockServer
    16981698};
    16991699static IClassFactoryImpl STDFONT_CF = {&SFCF_Vtbl, 1 };
  • trunk/src/oleaut32/olepicture.c

    r6689 r6711  
    5050#ifdef HAVE_LIBJPEG
    5151/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
    52 #define XMD_H
     52#define XMD_H 
    5353#ifdef HAVE_JPEGLIB_H
    5454# include <jpeglib.h>
     
    9090  /* We own the object and must destroy it ourselves */
    9191    BOOL fOwn;
    92 
     92 
    9393  /* Picture description */
    9494    PICTDESC desc;
     
    105105
    106106    BOOL keepOrigFormat;
    107     HDC hDCCur;
     107    HDC hDCCur;
    108108} OLEPictureImpl;
    109109
     
    174174  if (newObject==0)
    175175    return newObject;
    176 
     176 
    177177  /*
    178178   * Initialize the virtual function table.
     
    186186
    187187  /*
    188    * Start with one reference count. The caller of this function
     188   * Start with one reference count. The caller of this function 
    189189   * must release the interface pointer when it is done.
    190190   */
    191   newObject->ref    = 1;
    192   newObject->hDCCur = 0;
    193 
    194   newObject->fOwn   = fOwn;
     191  newObject->ref        = 1;
     192  newObject->hDCCur     = 0;
     193
     194  newObject->fOwn       = fOwn;
    195195
    196196  /* dunno about original value */
     
    199199  if (pictDesc) {
    200200      if(pictDesc->cbSizeofstruct != sizeof(PICTDESC)) {
    201       FIXME("struct size = %d\n", pictDesc->cbSizeofstruct);
     201          FIXME("struct size = %d\n", pictDesc->cbSizeofstruct);
    202202      }
    203203      memcpy(&newObject->desc, pictDesc, sizeof(PICTDESC));
     
    206206      switch(pictDesc->picType) {
    207207      case PICTYPE_BITMAP:
    208     OLEPictureImpl_SetBitmap(newObject);
    209     break;
     208        OLEPictureImpl_SetBitmap(newObject);
     209        break;
    210210
    211211      case PICTYPE_METAFILE:
    212     TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
    213     newObject->himetricWidth = pictDesc->u.wmf.xExt;
    214     newObject->himetricHeight = pictDesc->u.wmf.yExt;
    215     break;
     212        TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
     213        newObject->himetricWidth = pictDesc->u.wmf.xExt;
     214        newObject->himetricHeight = pictDesc->u.wmf.yExt;
     215        break;
    216216
    217217      case PICTYPE_ICON:
    218218      case PICTYPE_ENHMETAFILE:
    219219      default:
    220     FIXME("Unsupported type %d\n", pictDesc->picType);
    221     newObject->himetricWidth = newObject->himetricHeight = 0;
    222     break;
     220        FIXME("Unsupported type %d\n", pictDesc->picType);
     221        newObject->himetricWidth = newObject->himetricHeight = 0;
     222        break;
    223223      }
    224224  } else {
    225225      newObject->desc.picType = PICTYPE_UNINITIALIZED;
    226226  }
    227 
     227   
    228228  TRACE("returning %p\n", newObject);
    229229  return newObject;
     
    237237 * this object.  */
    238238static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj)
    239 {
     239{ 
    240240  TRACE("(%p)\n", Obj);
    241241
     
    282282  if ( (This==0) || (ppvObject==0) )
    283283    return E_INVALIDARG;
    284 
     284 
    285285  /*
    286286   * Initialize the return parameter.
    287287   */
    288288  *ppvObject = 0;
    289 
     289 
    290290  /*
    291291   * Compare the riid with the interface IDs implemented by this object.
    292292   */
    293   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     293  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    294294  {
    295295    *ppvObject = (IPicture*)This;
    296296  }
    297   else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0)
     297  else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0) 
    298298  {
    299299    *ppvObject = (IPicture*)This;
    300300  }
    301   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
     301  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
    302302  {
    303303    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    304304  }
    305   else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0)
     305  else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0) 
    306306  {
    307307    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    308308  }
    309   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
     309  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
    310310  {
    311311  *ppvObject = (IPersistStream*)&(This->lpvtbl3);
    312312  }
    313   else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0)
     313  else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0) 
    314314  {
    315315  *ppvObject = (IConnectionPointContainer*)&(This->lpvtbl4);
     
    323323    return E_NOINTERFACE;
    324324  }
    325 
     325 
    326326  /*
    327327   * Query Interface always increases the reference count by one when it is
     
    362362 * See Windows documentation for more details on IUnknown methods.
    363363 */
    364 static ULONG WINAPI OLEPictureImpl_AddRef(
     364static ULONG WINAPI OLEPictureImpl_AddRef( 
    365365  IPicture* iface)
    366366{
     
    371371  return This->ref;
    372372}
    373 
     373       
    374374/************************************************************************
    375375 * OLEPictureImpl_Release (IUnknown)
     
    377377 * See Windows documentation for more details on IUnknown methods.
    378378 */
    379 static ULONG WINAPI OLEPictureImpl_Release(
     379static ULONG WINAPI OLEPictureImpl_Release( 
    380380      IPicture* iface)
    381381{
     
    397397    return 0;
    398398  }
    399 
     399 
    400400  return This->ref;
    401401}
     
    404404/************************************************************************
    405405 * OLEPictureImpl_get_Handle
    406  */
     406 */ 
    407407static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface,
    408                         OLE_HANDLE *phandle)
     408                                                OLE_HANDLE *phandle)
    409409{
    410410  ICOM_THIS(OLEPictureImpl, iface);
     
    433433/************************************************************************
    434434 * OLEPictureImpl_get_hPal
    435  */
     435 */ 
    436436static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface,
    437                           OLE_HANDLE *phandle)
     437                                              OLE_HANDLE *phandle)
    438438{
    439439  ICOM_THIS(OLEPictureImpl, iface);
     
    444444/************************************************************************
    445445 * OLEPictureImpl_get_Type
    446  */
     446 */ 
    447447static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface,
    448                           short *ptype)
     448                                              short *ptype)
    449449{
    450450  ICOM_THIS(OLEPictureImpl, iface);
     
    456456/************************************************************************
    457457 * OLEPictureImpl_get_Width
    458  */
     458 */ 
    459459static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface,
    460                            OLE_XSIZE_HIMETRIC *pwidth)
     460                                               OLE_XSIZE_HIMETRIC *pwidth)
    461461{
    462462  ICOM_THIS(OLEPictureImpl, iface);
     
    468468/************************************************************************
    469469 * OLEPictureImpl_get_Height
    470  */
     470 */ 
    471471static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface,
    472                         OLE_YSIZE_HIMETRIC *pheight)
     472                                                OLE_YSIZE_HIMETRIC *pheight)
    473473{
    474474  ICOM_THIS(OLEPictureImpl, iface);
     
    480480/************************************************************************
    481481 * OLEPictureImpl_Render
    482  */
     482 */ 
    483483static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc,
    484                         long x, long y, long cx, long cy,
    485                         OLE_XPOS_HIMETRIC xSrc,
    486                         OLE_YPOS_HIMETRIC ySrc,
    487                         OLE_XSIZE_HIMETRIC cxSrc,
    488                         OLE_YSIZE_HIMETRIC cySrc,
    489                         LPCRECT prcWBounds)
     484                                            long x, long y, long cx, long cy,
     485                                            OLE_XPOS_HIMETRIC xSrc,
     486                                            OLE_YPOS_HIMETRIC ySrc,
     487                                            OLE_XSIZE_HIMETRIC cxSrc,
     488                                            OLE_YSIZE_HIMETRIC cySrc,
     489                                            LPCRECT prcWBounds)
    490490{
    491491  ICOM_THIS(OLEPictureImpl, iface);
    492492  TRACE("(%p)->(%08x, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n",
    493     This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
     493        This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
    494494  if(prcWBounds)
    495495    TRACE("prcWBounds (%d,%d) - (%d,%d)\n", prcWBounds->left, prcWBounds->top,
    496       prcWBounds->right, prcWBounds->bottom);
     496          prcWBounds->right, prcWBounds->bottom);
    497497
    498498  /*
     
    542542/************************************************************************
    543543 * OLEPictureImpl_set_hPal
    544  */
     544 */ 
    545545static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface,
    546                           OLE_HANDLE hpal)
     546                                              OLE_HANDLE hpal)
    547547{
    548548  ICOM_THIS(OLEPictureImpl, iface);
     
    554554/************************************************************************
    555555 * OLEPictureImpl_get_CurDC
    556  */
     556 */ 
    557557static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface,
    558                            HDC *phdc)
     558                                               HDC *phdc)
    559559{
    560560  ICOM_THIS(OLEPictureImpl, iface);
     
    566566/************************************************************************
    567567 * OLEPictureImpl_SelectPicture
    568  */
     568 */ 
    569569static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface,
    570                            HDC hdcIn,
    571                            HDC *phdcOut,
    572                            OLE_HANDLE *phbmpOut)
     570                                                   HDC hdcIn,
     571                                                   HDC *phdcOut,
     572                                                   OLE_HANDLE *phbmpOut)
    573573{
    574574  ICOM_THIS(OLEPictureImpl, iface);
     
    578578
    579579      if (phdcOut)
    580       *phdcOut = This->hDCCur;
     580          *phdcOut = This->hDCCur;
    581581      This->hDCCur = hdcIn;
    582582      if (phbmpOut)
    583       *phbmpOut = This->desc.u.bmp.hbitmap;
     583          *phbmpOut = This->desc.u.bmp.hbitmap;
    584584      return S_OK;
    585585  } else {
     
    591591/************************************************************************
    592592 * OLEPictureImpl_get_KeepOriginalFormat
    593  */
     593 */ 
    594594static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface,
    595                                 BOOL *pfKeep)
     595                                                            BOOL *pfKeep)
    596596{
    597597  ICOM_THIS(OLEPictureImpl, iface);
     
    605605/************************************************************************
    606606 * OLEPictureImpl_put_KeepOriginalFormat
    607  */
     607 */ 
    608608static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface,
    609                                 BOOL keep)
     609                                                            BOOL keep)
    610610{
    611611  ICOM_THIS(OLEPictureImpl, iface);
     
    618618/************************************************************************
    619619 * OLEPictureImpl_PictureChanged
    620  */
     620 */ 
    621621static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
    622622{
     
    629629/************************************************************************
    630630 * OLEPictureImpl_SaveAsFile
    631  */
     631 */ 
    632632static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
    633                         IStream *pstream,
    634                         BOOL SaveMemCopy,
    635                         LONG *pcbSize)
     633                                                IStream *pstream,
     634                                                BOOL SaveMemCopy,
     635                                                LONG *pcbSize)
    636636{
    637637  ICOM_THIS(OLEPictureImpl, iface);
     
    642642/************************************************************************
    643643 * OLEPictureImpl_get_Attributes
    644  */
     644 */ 
    645645static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface,
    646                             DWORD *pdwAttr)
     646                                                    DWORD *pdwAttr)
    647647{
    648648  ICOM_THIS(OLEPictureImpl, iface);
     
    650650  *pdwAttr = 0;
    651651  switch (This->desc.picType) {
    652   case PICTYPE_BITMAP:  break;  /* not 'truely' scalable, see MSDN. */
     652  case PICTYPE_BITMAP:  break;  /* not 'truely' scalable, see MSDN. */
    653653  case PICTYPE_ICON: *pdwAttr     = PICTURE_TRANSPARENT;break;
    654654  case PICTYPE_METAFILE: *pdwAttr = PICTURE_TRANSPARENT|PICTURE_SCALABLE;break;
     
    706706  ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl, iface);
    707707  TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
    708   if (!ppCP)
     708  if (!ppCP) 
    709709      return E_POINTER;
    710710  *ppCP = NULL;
     
    805805 * Loads the binary data from the IStream. Starts at current position.
    806806 * There appears to be an 2 DWORD header:
    807  *  DWORD magic;
    808  *  DWORD len;
     807 *      DWORD magic;
     808 *      DWORD len;
    809809 *
    810810 * Currently implemented: BITMAP, ICON, JPEG.
    811811 */
    812812static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) {
    813   HRESULT   hr = E_FAIL;
    814   ULONG     xread;
    815   BYTE      *xbuf;
    816   DWORD     header[2];
    817   WORD      magic;
     813  HRESULT       hr = E_FAIL;
     814  ULONG         xread;
     815  BYTE          *xbuf;
     816  DWORD         header[2];
     817  WORD          magic;
    818818  ICOM_THIS_From_IPersistStream(OLEPictureImpl, iface);
    819819
     
    828828  xbuf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
    829829  while (xread < header[1]) {
    830     ULONG nread;
     830    ULONG nread; 
    831831    hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread);
    832832    xread+=nread;
     
    841841  case 0xd8ff: { /* JPEG */
    842842#ifdef HAVE_LIBJPEG
    843     struct jpeg_decompress_struct   jd;
    844     struct jpeg_error_mgr       jerr;
    845     int                 ret;
    846     JDIMENSION              x;
    847     JSAMPROW                samprow;
    848     BITMAPINFOHEADER            bmi;
    849     LPBYTE              bits;
    850     HDC                 hdcref;
    851     struct jpeg_source_mgr      xjsm;
     843    struct jpeg_decompress_struct       jd;
     844    struct jpeg_error_mgr               jerr;
     845    int                                 ret;
     846    JDIMENSION                          x;
     847    JSAMPROW                            samprow;
     848    BITMAPINFOHEADER                    bmi;
     849    LPBYTE                              bits;
     850    HDC                                 hdcref;
     851    struct jpeg_source_mgr              xjsm;
    852852
    853853    /* This is basically so we can use in-memory data for jpeg decompression.
    854854     * We need to have all the functions.
    855855     */
    856     xjsm.next_input_byte    = xbuf;
    857     xjsm.bytes_in_buffer    = xread;
    858     xjsm.init_source        = _jpeg_init_source;
    859     xjsm.fill_input_buffer  = _jpeg_fill_input_buffer;
    860     xjsm.skip_input_data    = _jpeg_skip_input_data;
    861     xjsm.resync_to_restart  = _jpeg_resync_to_restart;
    862     xjsm.term_source        = _jpeg_term_source;
     856    xjsm.next_input_byte        = xbuf;
     857    xjsm.bytes_in_buffer        = xread;
     858    xjsm.init_source            = _jpeg_init_source;
     859    xjsm.fill_input_buffer      = _jpeg_fill_input_buffer;
     860    xjsm.skip_input_data        = _jpeg_skip_input_data;
     861    xjsm.resync_to_restart      = _jpeg_resync_to_restart;
     862    xjsm.term_source            = _jpeg_term_source;
    863863
    864864    jd.err = jpeg_std_error(&jerr);
     
    868868    jpeg_start_decompress(&jd);
    869869    if (ret != JPEG_HEADER_OK) {
    870     ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
    871     HeapFree(GetProcessHeap(),0,xbuf);
    872     return E_FAIL;
     870        ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
     871        HeapFree(GetProcessHeap(),0,xbuf);
     872        return E_FAIL;
    873873    }
    874874    bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(jd.output_height+1)*jd.output_width*jd.output_components);
     
    877877      x = jpeg_read_scanlines(&jd,&samprow,1);
    878878      if (x != 1) {
    879     FIXME("failed to read current scanline?\n");
    880     break;
     879        FIXME("failed to read current scanline?\n");
     880        break;
    881881      }
    882882      memcpy( bits+jd.output_scanline*jd.output_width*jd.output_components,
    883           samprow,
    884               jd.output_width*jd.output_components
     883              samprow,
     884              jd.output_width*jd.output_components
    885885      );
    886886    }
    887     bmi.biSize      = sizeof(bmi);
    888     bmi.biWidth     =  jd.output_width;
    889     bmi.biHeight    = -jd.output_height;
    890     bmi.biPlanes    = 1;
    891     bmi.biBitCount  = jd.output_components<<3;
    892     bmi.biCompression   = BI_RGB;
    893     bmi.biSizeImage = jd.output_height*jd.output_width*jd.output_components;
    894     bmi.biXPelsPerMeter = 0;
    895     bmi.biYPelsPerMeter = 0;
    896     bmi.biClrUsed   = 0;
    897     bmi.biClrImportant  = 0;
     887    bmi.biSize          = sizeof(bmi);
     888    bmi.biWidth         =  jd.output_width;
     889    bmi.biHeight        = -jd.output_height;
     890    bmi.biPlanes        = 1;
     891    bmi.biBitCount      = jd.output_components<<3;
     892    bmi.biCompression   = BI_RGB;
     893    bmi.biSizeImage     = jd.output_height*jd.output_width*jd.output_components;
     894    bmi.biXPelsPerMeter = 0;
     895    bmi.biYPelsPerMeter = 0;
     896    bmi.biClrUsed       = 0;
     897    bmi.biClrImportant  = 0;
    898898
    899899    HeapFree(GetProcessHeap(),0,samprow);
     
    902902    hdcref = GetDC(0);
    903903    This->desc.u.bmp.hbitmap=CreateDIBitmap(
    904         hdcref,
    905         &bmi,
    906         CBM_INIT,
    907         bits,
    908         (BITMAPINFO*)&bmi,
    909         DIB_RGB_COLORS
     904            hdcref,
     905            &bmi,
     906            CBM_INIT,
     907            bits,
     908            (BITMAPINFO*)&bmi,
     909            DIB_RGB_COLORS
    910910    );
    911911    DeleteDC(hdcref);
     
    921921  }
    922922  case 0x4d42: { /* Bitmap */
    923     BITMAPFILEHEADER    *bfh = (BITMAPFILEHEADER*)xbuf;
    924     BITMAPINFO      *bi = (BITMAPINFO*)(bfh+1);
    925     HDC         hdcref;
     923    BITMAPFILEHEADER    *bfh = (BITMAPFILEHEADER*)xbuf;
     924    BITMAPINFO          *bi = (BITMAPINFO*)(bfh+1);
     925    HDC                 hdcref;
    926926
    927927    /* Does not matter whether this is a coreheader or not, we only use
     
    930930    hdcref = GetDC(0);
    931931    This->desc.u.bmp.hbitmap = CreateDIBitmap(
    932     hdcref,
    933     &(bi->bmiHeader),
    934     CBM_INIT,
    935     xbuf+bfh->bfOffBits,
    936     bi,
    937     (bi->bmiHeader.biBitCount<=8)?DIB_PAL_COLORS:DIB_RGB_COLORS
     932        hdcref,
     933        &(bi->bmiHeader),
     934        CBM_INIT,
     935        xbuf+bfh->bfOffBits,
     936        bi,
     937        (bi->bmiHeader.biBitCount<=8)?DIB_PAL_COLORS:DIB_RGB_COLORS
    938938    );
    939939    DeleteDC(hdcref);
     
    945945  case 0x0000: { /* ICON , first word is dwReserved */
    946946    HICON hicon;
    947     CURSORICONFILEDIR   *cifd = (CURSORICONFILEDIR*)xbuf;
    948     int i;
     947    CURSORICONFILEDIR   *cifd = (CURSORICONFILEDIR*)xbuf;
     948    int i;
    949949
    950950    /*
     
    954954
    955955    for (i=0;i<cifd->idCount;i++) {
    956     FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
    957     FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
    958     FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
    959     FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
    960     FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
    961     FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
    962     FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
    963     FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
     956        FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
     957        FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
     958        FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
     959        FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
     960        FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
     961        FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
     962        FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
     963        FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
    964964    }
    965965    */
     
    969969     */
    970970    if (cifd->idCount!=1) {
    971     for (i=0;i<cifd->idCount;i++) {
    972         if (cifd->idEntries[i].bWidth == 32)
    973         break;
     971        for (i=0;i<cifd->idCount;i++) {
     972            if (cifd->idEntries[i].bWidth == 32)
     973                break;
     974        }
     975        if (i==cifd->idCount) i=0;
    974976    }
    975     if (i==cifd->idCount) i=0;
    976     }
    977977
    978978    hicon = CreateIconFromResourceEx(
    979         xbuf+cifd->idEntries[i].dwDIBOffset,
    980         cifd->idEntries[i].dwDIBSize,
    981         TRUE, /* is icon */
    982         0x00030000,
    983         cifd->idEntries[i].bWidth,
    984         cifd->idEntries[i].bHeight,
    985         0
     979                xbuf+cifd->idEntries[i].dwDIBOffset,
     980                cifd->idEntries[i].dwDIBSize,
     981                TRUE, /* is icon */
     982                0x00030000,
     983                cifd->idEntries[i].bWidth,
     984                cifd->idEntries[i].bHeight,
     985                0
    986986    );
    987987    if (!hicon) {
    988     FIXME("CreateIcon failed.\n");
    989     hr = E_FAIL;
     988        FIXME("CreateIcon failed.\n");
     989        hr = E_FAIL;
    990990    } else {
    991     This->desc.picType = PICTYPE_ICON;
    992     This->desc.u.icon.hicon = hicon;
    993     hr = S_OK;
     991        This->desc.picType = PICTYPE_ICON;
     992        This->desc.u.icon.hicon = hicon;
     993        hr = S_OK;
    994994    }
    995995    break;
     
    10741074 */
    10751075static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount(
    1076   IDispatch*    iface,
     1076  IDispatch*    iface, 
    10771077  unsigned int* pctinfo)
    10781078{
     
    10881088 */
    10891089static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(
    1090   IDispatch*  iface,
     1090  IDispatch*  iface, 
    10911091  UINT      iTInfo,
    1092   LCID        lcid,
     1092  LCID        lcid, 
    10931093  ITypeInfo** ppTInfo)
    10941094{
     
    11051105static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames(
    11061106  IDispatch*  iface,
    1107   REFIID      riid,
    1108   LPOLESTR* rgszNames,
    1109   UINT      cNames,
     1107  REFIID      riid, 
     1108  LPOLESTR* rgszNames, 
     1109  UINT      cNames, 
    11101110  LCID        lcid,
    11111111  DISPID*     rgDispId)
     
    11231123static HRESULT WINAPI OLEPictureImpl_Invoke(
    11241124  IDispatch*  iface,
    1125   DISPID      dispIdMember,
    1126   REFIID      riid,
    1127   LCID        lcid,
     1125  DISPID      dispIdMember, 
     1126  REFIID      riid, 
     1127  LCID        lcid, 
    11281128  WORD        wFlags,
    11291129  DISPPARAMS* pDispParams,
    1130   VARIANT*    pVarResult,
     1130  VARIANT*    pVarResult, 
    11311131  EXCEPINFO*  pExepInfo,
    11321132  UINT*     puArgErr)
     
    12021202 */
    12031203HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid,
    1204                     BOOL fOwn, LPVOID *ppvObj )
     1204                            BOOL fOwn, LPVOID *ppvObj )
    12051205{
    12061206  OLEPictureImpl* newPict = NULL;
     
    12441244 */
    12451245HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
    1246                     REFIID riid, LPVOID *ppvObj )
     1246                            REFIID riid, LPVOID *ppvObj )
    12471247{
    12481248  LPPERSISTSTREAM ps;
    1249   IPicture  *newpic;
     1249  IPicture      *newpic;
    12501250  HRESULT hr;
    12511251
    12521252  TRACE("(%p,%ld,%d,%s,%p), partially implemented.\n",
    1253     lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
     1253        lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
    12541254
    12551255  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
     
    12761276 */
    12771277HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
    1278                     REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
     1278                            REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
    12791279{
    12801280  FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n",
    1281     lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
     1281        lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
    12821282  return S_OK;
    12831283}
    1284 
     1284 
    12851285#ifdef __WIN32OS2__
    12861286
     
    13081308// ----------------------------------------------------------------------
    13091309HRESULT WIN32API OleLoadPicturePath
    1310    (LPOLESTR        szURLorPath,
    1311     LPUNKNOWN       punkCaller,
    1312     DWORD           dwReserved,
    1313     OLE_COLOR       clrReserved,
    1314     REFIID          riid,
    1315     LPVOID *        ppvRet )
     1310   (LPOLESTR            szURLorPath,
     1311    LPUNKNOWN           punkCaller,
     1312    DWORD               dwReserved,
     1313    OLE_COLOR           clrReserved,
     1314    REFIID              riid,
     1315    LPVOID *            ppvRet )
    13161316{
    13171317    dprintf(("OLEAUT32: OleLoadPicturePath - stub"));
  • trunk/src/oleaut32/parsedt.c

    r6689 r6711  
    2626 *
    2727 * dt.c--
    28  *    Functions for the built-in type "dt".
     28 *        Functions for the built-in type "dt".
    2929 *
    3030 * Copyright (c) 1994, Regents of the University of California
     
    4545
    4646static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
    47 static int  DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
     47static int      DecodeDate(char *str, int fmask, int *tmask, struct tm * tm);
    4848static int DecodeNumber(int flen, char *field,
    49             int fmask, int *tmask, struct tm * tm, double *fsec);
     49                        int fmask, int *tmask, struct tm * tm, double *fsec);
    5050static int DecodeNumberField(int len, char *str,
    51                   int fmask, int *tmask, struct tm * tm, double *fsec);
    52 static int  DecodeSpecial(int field, char *lowtoken, int *val);
     51                                  int fmask, int *tmask, struct tm * tm, double *fsec);
     52static int      DecodeSpecial(int field, char *lowtoken, int *val);
    5353static int DecodeTime(char *str, int fmask, int *tmask,
    54            struct tm * tm, double *fsec);
    55 static int  DecodeTimezone(char *str, int *tzp);
     54                   struct tm * tm, double *fsec);
     55static int      DecodeTimezone(char *str, int *tzp);
    5656
    5757#define USE_DATE_CACHE 1
     
    6666"Thursday", "Friday", "Saturday", NULL};
    6767
    68 /* those three vars are useless, and not even initialized, so
     68/* those three vars are useless, and not even initialized, so 
    6969 * I'd rather remove them all (EPP)
    7070 */
    71 int DateStyle;
    72 bool    EuroDates;
    73 int CTimeZone;
     71int     DateStyle;
     72bool    EuroDates;
     73int     CTimeZone;
    7474
    7575#define UTIME_MINYEAR (1901)
     
    9191
    9292/*****************************************************************************
    93  *   PRIVATE ROUTINES                                                        *
     93 *       PRIVATE ROUTINES                                                                                                                *
    9494 *****************************************************************************/
    9595
    9696/* definitions for squeezing values into "value" */
    97 #define ABS_SIGNBIT     (char) 0200
    98 #define VALMASK         (char) 0177
    99 #define NEG(n)          ((n)|ABS_SIGNBIT)
    100 #define SIGNEDCHAR(c)   ((c)&ABS_SIGNBIT? -((c)&VALMASK): (c))
    101 #define FROMVAL(tp)     (-SIGNEDCHAR((tp)->value) * 10) /* uncompress */
    102 #define TOVAL(tp, v)    ((tp)->value = ((v) < 0? NEG((-(v))/10): (v)/10))
     97#define ABS_SIGNBIT             (char) 0200
     98#define VALMASK                 (char) 0177
     99#define NEG(n)                  ((n)|ABS_SIGNBIT)
     100#define SIGNEDCHAR(c)   ((c)&ABS_SIGNBIT? -((c)&VALMASK): (c))
     101#define FROMVAL(tp)             (-SIGNEDCHAR((tp)->value) * 10) /* uncompress */
     102#define TOVAL(tp, v)    ((tp)->value = ((v) < 0? NEG((-(v))/10): (v)/10))
    103103
    104104/*
     
    108108 */
    109109static datetkn datetktbl[] = {
    110 /*      text            token   lexval */
    111     {EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
    112     {"acsst", DTZ, 63},         /* Cent. Australia */
    113     {"acst", TZ, 57},           /* Cent. Australia */
    114     {DA_D, ADBC, AD},           /* "ad" for years >= 0 */
    115     {"abstime", IGNOREFIELD, 0},        /* "abstime" for pre-v6.1 "Invalid
    116                                 * Abstime" */
    117     {"adt", DTZ, NEG(18)},      /* Atlantic Daylight Time */
    118     {"aesst", DTZ, 66},         /* E. Australia */
    119     {"aest", TZ, 60},           /* Australia Eastern Std Time */
    120     {"ahst", TZ, 60},           /* Alaska-Hawaii Std Time */
    121     {"allballs", RESERV, DTK_ZULU},     /* 00:00:00 */
    122     {"am", AMPM, AM},
    123     {"apr", MONTH, 4},
    124     {"april", MONTH, 4},
    125     {"ast", TZ, NEG(24)},       /* Atlantic Std Time (Canada) */
    126     {"at", IGNOREFIELD, 0},         /* "at" (throwaway) */
    127     {"aug", MONTH, 8},
    128     {"august", MONTH, 8},
    129     {"awsst", DTZ, 54},         /* W. Australia */
    130     {"awst", TZ, 48},           /* W. Australia */
    131     {DB_C, ADBC, BC},           /* "bc" for years < 0 */
    132     {"bst", TZ, 6},             /* British Summer Time */
    133     {"bt", TZ, 18},             /* Baghdad Time */
    134     {"cadt", DTZ, 63},          /* Central Australian DST */
    135     {"cast", TZ, 57},           /* Central Australian ST */
    136     {"cat", TZ, NEG(60)},       /* Central Alaska Time */
    137     {"cct", TZ, 48},            /* China Coast */
    138     {"cdt", DTZ, NEG(30)},      /* Central Daylight Time */
    139     {"cet", TZ, 6},             /* Central European Time */
    140     {"cetdst", DTZ, 12},        /* Central European Dayl.Time */
    141     {"cst", TZ, NEG(36)},       /* Central Standard Time */
    142     {DCURRENT, RESERV, DTK_CURRENT},    /* "current" is always now */
    143     {"dec", MONTH, 12},
    144     {"december", MONTH, 12},
    145     {"dnt", TZ, 6},             /* Dansk Normal Tid */
    146     {"dow", RESERV, DTK_DOW},   /* day of week */
    147     {"doy", RESERV, DTK_DOY},   /* day of year */
    148     {"dst", DTZMOD, 6},
    149     {"east", TZ, NEG(60)},      /* East Australian Std Time */
    150     {"edt", DTZ, NEG(24)},      /* Eastern Daylight Time */
    151     {"eet", TZ, 12},            /* East. Europe, USSR Zone 1 */
    152     {"eetdst", DTZ, 18},        /* Eastern Europe */
    153     {EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */
     110/*              text                    token   lexval */
     111        {EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
     112        {"acsst", DTZ, 63},                     /* Cent. Australia */
     113        {"acst", TZ, 57},                       /* Cent. Australia */
     114        {DA_D, ADBC, AD},                       /* "ad" for years >= 0 */
     115        {"abstime", IGNOREFIELD, 0},            /* "abstime" for pre-v6.1 "Invalid
     116                                                                * Abstime" */
     117        {"adt", DTZ, NEG(18)},          /* Atlantic Daylight Time */
     118        {"aesst", DTZ, 66},                     /* E. Australia */
     119        {"aest", TZ, 60},                       /* Australia Eastern Std Time */
     120        {"ahst", TZ, 60},                       /* Alaska-Hawaii Std Time */
     121        {"allballs", RESERV, DTK_ZULU},         /* 00:00:00 */
     122        {"am", AMPM, AM},
     123        {"apr", MONTH, 4},
     124        {"april", MONTH, 4},
     125        {"ast", TZ, NEG(24)},           /* Atlantic Std Time (Canada) */
     126        {"at", IGNOREFIELD, 0},                 /* "at" (throwaway) */
     127        {"aug", MONTH, 8},
     128        {"august", MONTH, 8},
     129        {"awsst", DTZ, 54},                     /* W. Australia */
     130        {"awst", TZ, 48},                       /* W. Australia */
     131        {DB_C, ADBC, BC},                       /* "bc" for years < 0 */
     132        {"bst", TZ, 6},                         /* British Summer Time */
     133        {"bt", TZ, 18},                         /* Baghdad Time */
     134        {"cadt", DTZ, 63},                      /* Central Australian DST */
     135        {"cast", TZ, 57},                       /* Central Australian ST */
     136        {"cat", TZ, NEG(60)},           /* Central Alaska Time */
     137        {"cct", TZ, 48},                        /* China Coast */
     138        {"cdt", DTZ, NEG(30)},          /* Central Daylight Time */
     139        {"cet", TZ, 6},                         /* Central European Time */
     140        {"cetdst", DTZ, 12},            /* Central European Dayl.Time */
     141        {"cst", TZ, NEG(36)},           /* Central Standard Time */
     142        {DCURRENT, RESERV, DTK_CURRENT},        /* "current" is always now */
     143        {"dec", MONTH, 12},
     144        {"december", MONTH, 12},
     145        {"dnt", TZ, 6},                         /* Dansk Normal Tid */
     146        {"dow", RESERV, DTK_DOW},       /* day of week */
     147        {"doy", RESERV, DTK_DOY},       /* day of year */
     148        {"dst", DTZMOD, 6},
     149        {"east", TZ, NEG(60)},          /* East Australian Std Time */
     150        {"edt", DTZ, NEG(24)},          /* Eastern Daylight Time */
     151        {"eet", TZ, 12},                        /* East. Europe, USSR Zone 1 */
     152        {"eetdst", DTZ, 18},            /* Eastern Europe */
     153        {EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */
    154154#if USE_AUSTRALIAN_RULES
    155     {"est", TZ, 60},            /* Australia Eastern Std Time */
     155        {"est", TZ, 60},                        /* Australia Eastern Std Time */
    156156#else
    157     {"est", TZ, NEG(30)},       /* Eastern Standard Time */
    158 #endif
    159     {"feb", MONTH, 2},
    160     {"february", MONTH, 2},
    161     {"fri", DOW, 5},
    162     {"friday", DOW, 5},
    163     {"fst", TZ, 6},             /* French Summer Time */
    164     {"fwt", DTZ, 12},           /* French Winter Time  */
    165     {"gmt", TZ, 0},             /* Greenwish Mean Time */
    166     {"gst", TZ, 60},            /* Guam Std Time, USSR Zone 9 */
    167     {"hdt", DTZ, NEG(54)},      /* Hawaii/Alaska */
    168     {"hmt", DTZ, 18},           /* Hellas ? ? */
    169     {"hst", TZ, NEG(60)},       /* Hawaii Std Time */
    170     {"idle", TZ, 72},           /* Intl. Date Line, East */
    171     {"idlw", TZ, NEG(72)},      /* Intl. Date Line,,    est */
    172     {LATE, RESERV, DTK_LATE},   /* "infinity" reserved for "late time" */
    173     {INVALID, RESERV, DTK_INVALID},     /* "invalid" reserved for invalid
    174                                         * time */
    175     {"ist", TZ, 12},            /* Israel */
    176     {"it", TZ, 22},             /* Iran Time */
    177     {"jan", MONTH, 1},
    178     {"january", MONTH, 1},
    179     {"jst", TZ, 54},            /* Japan Std Time,USSR Zone 8 */
    180     {"jt", TZ, 45},             /* Java Time */
    181     {"jul", MONTH, 7},
    182     {"july", MONTH, 7},
    183     {"jun", MONTH, 6},
    184     {"june", MONTH, 6},
    185     {"kst", TZ, 54},            /* Korea Standard Time */
    186     {"ligt", TZ, 60},           /* From Melbourne, Australia */
    187     {"mar", MONTH, 3},
    188     {"march", MONTH, 3},
    189     {"may", MONTH, 5},
    190     {"mdt", DTZ, NEG(36)},      /* Mountain Daylight Time */
    191     {"mest", DTZ, 12},          /* Middle Europe Summer Time */
    192     {"met", TZ, 6},             /* Middle Europe Time */
    193     {"metdst", DTZ, 12},        /* Middle Europe Daylight Time */
    194     {"mewt", TZ, 6},            /* Middle Europe Winter Time */
    195     {"mez", TZ, 6},             /* Middle Europe Zone */
    196     {"mon", DOW, 1},
    197     {"monday", DOW, 1},
    198     {"mst", TZ, NEG(42)},       /* Mountain Standard Time */
    199     {"mt", TZ, 51},             /* Moluccas Time */
    200     {"ndt", DTZ, NEG(15)},      /* Nfld. Daylight Time */
    201     {"nft", TZ, NEG(21)},       /* Newfoundland Standard Time */
    202     {"nor", TZ, 6},             /* Norway Standard Time */
    203     {"nov", MONTH, 11},
    204     {"november", MONTH, 11},
    205     {NOW, RESERV, DTK_NOW},     /* current transaction time */
    206     {"nst", TZ, NEG(21)},       /* Nfld. Standard Time */
    207     {"nt", TZ, NEG(66)},        /* Nome Time */
    208     {"nzdt", DTZ, 78},          /* New Zealand Daylight Time */
    209     {"nzst", TZ, 72},           /* New Zealand Standard Time */
    210     {"nzt", TZ, 72},            /* New Zealand Time */
    211     {"oct", MONTH, 10},
    212     {"october", MONTH, 10},
    213     {"on", IGNOREFIELD, 0},         /* "on" (throwaway) */
    214     {"pdt", DTZ, NEG(42)},      /* Pacific Daylight Time */
    215     {"pm", AMPM, PM},
    216     {"pst", TZ, NEG(48)},       /* Pacific Standard Time */
    217     {"sadt", DTZ, 63},          /* S. Australian Dayl. Time */
    218     {"sast", TZ, 57},           /* South Australian Std Time */
    219     {"sat", DOW, 6},
    220     {"saturday", DOW, 6},
    221     {"sep", MONTH, 9},
    222     {"sept", MONTH, 9},
    223     {"september", MONTH, 9},
    224     {"set", TZ, NEG(6)},        /* Seychelles Time ?? */
    225     {"sst", DTZ, 12},           /* Swedish Summer Time */
    226     {"sun", DOW, 0},
    227     {"sunday", DOW, 0},
    228     {"swt", TZ, 6},             /* Swedish Winter Time  */
    229     {"thu", DOW, 4},
    230     {"thur", DOW, 4},
    231     {"thurs", DOW, 4},
    232     {"thursday", DOW, 4},
    233     {TODAY, RESERV, DTK_TODAY}, /* midnight */
    234     {TOMORROW, RESERV, DTK_TOMORROW},   /* tomorrow midnight */
    235     {"tue", DOW, 2},
    236     {"tues", DOW, 2},
    237     {"tuesday", DOW, 2},
    238     {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid
    239                                         * time */
    240     {"ut", TZ, 0},
    241     {"utc", TZ, 0},
    242     {"wadt", DTZ, 48},          /* West Australian DST */
    243     {"wast", TZ, 42},           /* West Australian Std Time */
    244     {"wat", TZ, NEG(6)},        /* West Africa Time */
    245     {"wdt", DTZ, 54},           /* West Australian DST */
    246     {"wed", DOW, 3},
    247     {"wednesday", DOW, 3},
    248     {"weds", DOW, 3},
    249     {"wet", TZ, 0},             /* Western Europe */
    250     {"wetdst", DTZ, 6},         /* Western Europe */
    251     {"wst", TZ, 48},            /* West Australian Std Time */
    252     {"ydt", DTZ, NEG(48)},      /* Yukon Daylight Time */
    253     {YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */
    254     {"yst", TZ, NEG(54)},       /* Yukon Standard Time */
    255     {"zp4", TZ, NEG(24)},       /* GMT +4  hours. */
    256     {"zp5", TZ, NEG(30)},       /* GMT +5  hours. */
    257     {"zp6", TZ, NEG(36)},       /* GMT +6  hours. */
    258     {"z", RESERV, DTK_ZULU},    /* 00:00:00 */
    259     {ZULU, RESERV, DTK_ZULU},   /* 00:00:00 */
     157        {"est", TZ, NEG(30)},           /* Eastern Standard Time */
     158#endif
     159        {"feb", MONTH, 2},
     160        {"february", MONTH, 2},
     161        {"fri", DOW, 5},
     162        {"friday", DOW, 5},
     163        {"fst", TZ, 6},                         /* French Summer Time */
     164        {"fwt", DTZ, 12},                       /* French Winter Time  */
     165        {"gmt", TZ, 0},                         /* Greenwish Mean Time */
     166        {"gst", TZ, 60},                        /* Guam Std Time, USSR Zone 9 */
     167        {"hdt", DTZ, NEG(54)},          /* Hawaii/Alaska */
     168        {"hmt", DTZ, 18},                       /* Hellas ? ? */
     169        {"hst", TZ, NEG(60)},           /* Hawaii Std Time */
     170        {"idle", TZ, 72},                       /* Intl. Date Line, East */
     171        {"idlw", TZ, NEG(72)},          /* Intl. Date Line,,    est */
     172        {LATE, RESERV, DTK_LATE},       /* "infinity" reserved for "late time" */
     173        {INVALID, RESERV, DTK_INVALID},         /* "invalid" reserved for invalid
     174                                                                                * time */
     175        {"ist", TZ, 12},                        /* Israel */
     176        {"it", TZ, 22},                         /* Iran Time */
     177        {"jan", MONTH, 1},
     178        {"january", MONTH, 1},
     179        {"jst", TZ, 54},                        /* Japan Std Time,USSR Zone 8 */
     180        {"jt", TZ, 45},                         /* Java Time */
     181        {"jul", MONTH, 7},
     182        {"july", MONTH, 7},
     183        {"jun", MONTH, 6},
     184        {"june", MONTH, 6},
     185        {"kst", TZ, 54},                        /* Korea Standard Time */
     186        {"ligt", TZ, 60},                       /* From Melbourne, Australia */
     187        {"mar", MONTH, 3},
     188        {"march", MONTH, 3},
     189        {"may", MONTH, 5},
     190        {"mdt", DTZ, NEG(36)},          /* Mountain Daylight Time */
     191        {"mest", DTZ, 12},                      /* Middle Europe Summer Time */
     192        {"met", TZ, 6},                         /* Middle Europe Time */
     193        {"metdst", DTZ, 12},            /* Middle Europe Daylight Time */
     194        {"mewt", TZ, 6},                        /* Middle Europe Winter Time */
     195        {"mez", TZ, 6},                         /* Middle Europe Zone */
     196        {"mon", DOW, 1},
     197        {"monday", DOW, 1},
     198        {"mst", TZ, NEG(42)},           /* Mountain Standard Time */
     199        {"mt", TZ, 51},                         /* Moluccas Time */
     200        {"ndt", DTZ, NEG(15)},          /* Nfld. Daylight Time */
     201        {"nft", TZ, NEG(21)},           /* Newfoundland Standard Time */
     202        {"nor", TZ, 6},                         /* Norway Standard Time */
     203        {"nov", MONTH, 11},
     204        {"november", MONTH, 11},
     205        {NOW, RESERV, DTK_NOW},         /* current transaction time */
     206        {"nst", TZ, NEG(21)},           /* Nfld. Standard Time */
     207        {"nt", TZ, NEG(66)},            /* Nome Time */
     208        {"nzdt", DTZ, 78},                      /* New Zealand Daylight Time */
     209        {"nzst", TZ, 72},                       /* New Zealand Standard Time */
     210        {"nzt", TZ, 72},                        /* New Zealand Time */
     211        {"oct", MONTH, 10},
     212        {"october", MONTH, 10},
     213        {"on", IGNOREFIELD, 0},                 /* "on" (throwaway) */
     214        {"pdt", DTZ, NEG(42)},          /* Pacific Daylight Time */
     215        {"pm", AMPM, PM},
     216        {"pst", TZ, NEG(48)},           /* Pacific Standard Time */
     217        {"sadt", DTZ, 63},                      /* S. Australian Dayl. Time */
     218        {"sast", TZ, 57},                       /* South Australian Std Time */
     219        {"sat", DOW, 6},
     220        {"saturday", DOW, 6},
     221        {"sep", MONTH, 9},
     222        {"sept", MONTH, 9},
     223        {"september", MONTH, 9},
     224        {"set", TZ, NEG(6)},            /* Seychelles Time ?? */
     225        {"sst", DTZ, 12},                       /* Swedish Summer Time */
     226        {"sun", DOW, 0},
     227        {"sunday", DOW, 0},
     228        {"swt", TZ, 6},                         /* Swedish Winter Time  */
     229        {"thu", DOW, 4},
     230        {"thur", DOW, 4},
     231        {"thurs", DOW, 4},
     232        {"thursday", DOW, 4},
     233        {TODAY, RESERV, DTK_TODAY}, /* midnight */
     234        {TOMORROW, RESERV, DTK_TOMORROW},       /* tomorrow midnight */
     235        {"tue", DOW, 2},
     236        {"tues", DOW, 2},
     237        {"tuesday", DOW, 2},
     238        {"undefined", RESERV, DTK_INVALID}, /* "undefined" pre-v6.1 invalid
     239                                                                                * time */
     240        {"ut", TZ, 0},
     241        {"utc", TZ, 0},
     242        {"wadt", DTZ, 48},                      /* West Australian DST */
     243        {"wast", TZ, 42},                       /* West Australian Std Time */
     244        {"wat", TZ, NEG(6)},            /* West Africa Time */
     245        {"wdt", DTZ, 54},                       /* West Australian DST */
     246        {"wed", DOW, 3},
     247        {"wednesday", DOW, 3},
     248        {"weds", DOW, 3},
     249        {"wet", TZ, 0},                         /* Western Europe */
     250        {"wetdst", DTZ, 6},                     /* Western Europe */
     251        {"wst", TZ, 48},                        /* West Australian Std Time */
     252        {"ydt", DTZ, NEG(48)},          /* Yukon Daylight Time */
     253        {YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */
     254        {"yst", TZ, NEG(54)},           /* Yukon Standard Time */
     255        {"zp4", TZ, NEG(24)},           /* GMT +4  hours. */
     256        {"zp5", TZ, NEG(30)},           /* GMT +5  hours. */
     257        {"zp6", TZ, NEG(36)},           /* GMT +6  hours. */
     258        {"z", RESERV, DTK_ZULU},        /* 00:00:00 */
     259        {ZULU, RESERV, DTK_ZULU},       /* 00:00:00 */
    260260};
    261261
     
    275275 * Calendar time to Julian date conversions.
    276276 * Julian date is commonly used in astronomical applications,
    277  *  since it is numerically accurate and computationally simple.
     277 *      since it is numerically accurate and computationally simple.
    278278 * The algorithms here will accurately convert between Julian day
    279  *  and calendar date for all non-negative Julian days
    280  *  (i.e. from Nov 23, -4713 on).
     279 *      and calendar date for all non-negative Julian days
     280 *      (i.e. from Nov 23, -4713 on).
    281281 *
    282282 * Ref: Explanatory Supplement to the Astronomical Almanac, 1992.
    283  *  University Science Books, 20 Edgehill Rd. Mill Valley CA 94941.
     283 *      University Science Books, 20 Edgehill Rd. Mill Valley CA 94941.
    284284 *
    285285 * Use the algorithm by Henry Fliegel, a former NASA/JPL colleague
    286  *  now at Aerospace Corp. (hi, Henry!)
     286 *      now at Aerospace Corp. (hi, Henry!)
    287287 *
    288288 * These routines will be used by other date/time packages - tgl 97/02/25
     
    290290
    291291/* Set the minimum year to one greater than the year of the first valid day
    292  *  to avoid having to check year and day both. - tgl 97/05/08
     292 *      to avoid having to check year and day both. - tgl 97/05/08
    293293 */
    294294
     
    304304date2j(int y, int m, int d)
    305305{
    306     int         m12 = (m - 14) / 12;
    307 
    308     return ((1461 * (y + 4800 + m12)) / 4 + (367 * (m - 2 - 12 * (m12))) / 12
    309             - (3 * ((y + 4900 + m12) / 100)) / 4 + d - 32075);
    310 }   /* date2j() */
     306        int                     m12 = (m - 14) / 12;
     307
     308        return ((1461 * (y + 4800 + m12)) / 4 + (367 * (m - 2 - 12 * (m12))) / 12
     309                        - (3 * ((y + 4900 + m12) / 100)) / 4 + d - 32075);
     310}       /* date2j() */
    311311
    312312void
    313313j2date(int jd, int *year, int *month, int *day)
    314314{
    315     int         j,
    316                 y,
    317                 m,
    318                 d;
    319 
    320     int         i,
    321                 l,
    322                 n;
    323 
    324     l = jd + 68569;
    325     n = (4 * l) / 146097;
    326     l -= (146097 * n + 3) / 4;
    327     i = (4000 * (l + 1)) / 1461001;
    328     l += 31 - (1461 * i) / 4;
    329     j = (80 * l) / 2447;
    330     d = l - (2447 * j) / 80;
    331     l = j / 11;
    332     m = (j + 2) - (12 * l);
    333     y = 100 * (n - 49) + i + l;
    334 
    335     *year = y;
    336     *month = m;
    337     *day = d;
    338     return;
    339 }   /* j2date() */
     315        int                     j,
     316                                y,
     317                                m,
     318                                d;
     319
     320        int                     i,
     321                                l,
     322                                n;
     323
     324        l = jd + 68569;
     325        n = (4 * l) / 146097;
     326        l -= (146097 * n + 3) / 4;
     327        i = (4000 * (l + 1)) / 1461001;
     328        l += 31 - (1461 * i) / 4;
     329        j = (80 * l) / 2447;
     330        d = l - (2447 * j) / 80;
     331        l = j / 11;
     332        m = (j + 2) - (12 * l);
     333        y = 100 * (n - 49) + i + l;
     334
     335        *year = y;
     336        *month = m;
     337        *day = d;
     338        return;
     339}       /* j2date() */
    340340
    341341
     
    353353int
    354354ParseDateTime(char *timestr, char *lowstr,
    355               char **field, int *ftype, int maxfields, int *numfields)
     355                          char **field, int *ftype, int maxfields, int *numfields)
    356356{
    357     int         nf = 0;
    358     char       *cp = timestr;
    359     char       *lp = lowstr;
    360 
    361 #ifdef DATEDEBUG
    362     printf("ParseDateTime- input string is %s\n", timestr);
    363 #endif
    364     /* outer loop through fields */
    365     while (*cp != '\0')
    366     {
    367         field[nf] = lp;
    368 
    369         /* leading digit? then date or time */
    370         if (isdigit(*cp) || (*cp == '.'))
    371         {
    372             *lp++ = *cp++;
    373             while (isdigit(*cp))
    374                 *lp++ = *cp++;
    375             /* time field? */
    376             if (*cp == ':')
    377             {
    378                 ftype[nf] = DTK_TIME;
    379                 while (isdigit(*cp) || (*cp == ':') || (*cp == '.'))
    380                     *lp++ = *cp++;
    381 
    382             }
    383             /* date field? allow embedded text month */
    384             else if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
    385             {
    386                 ftype[nf] = DTK_DATE;
    387                 while (isalnum(*cp) || (*cp == '-') || (*cp == '/') || (*cp == '.'))
    388                     *lp++ = tolower(*cp++);
    389 
    390             }
    391 
    392             /*
    393             * otherwise, number only and will determine year, month, or
    394             * day later
    395             */
    396             else
    397                 ftype[nf] = DTK_NUMBER;
    398 
    399         }
    400 
    401         /*
    402         * text? then date string, month, day of week, special, or
    403         * timezone
    404         */
    405         else if (isalpha(*cp))
    406         {
    407             ftype[nf] = DTK_STRING;
    408             *lp++ = tolower(*cp++);
    409             while (isalpha(*cp))
    410                 *lp++ = tolower(*cp++);
    411 
    412             /* full date string with leading text month? */
    413             if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
    414             {
    415                 ftype[nf] = DTK_DATE;
    416                 while (isdigit(*cp) || (*cp == '-') || (*cp == '/') || (*cp == '.'))
    417                     *lp++ = tolower(*cp++);
    418             }
    419 
    420             /* skip leading spaces */
    421         }
    422         else if (isspace(*cp))
    423         {
    424             cp++;
    425             continue;
    426 
    427             /* sign? then special or numeric timezone */
    428         }
    429         else if ((*cp == '+') || (*cp == '-'))
    430         {
    431             *lp++ = *cp++;
    432             /* soak up leading whitespace */
    433             while (isspace(*cp))
    434                 cp++;
    435             /* numeric timezone? */
    436             if (isdigit(*cp))
    437             {
    438                 ftype[nf] = DTK_TZ;
    439                 *lp++ = *cp++;
    440                 while (isdigit(*cp) || (*cp == ':'))
    441                     *lp++ = *cp++;
    442 
    443                 /* special? */
    444             }
    445             else if (isalpha(*cp))
    446             {
    447                 ftype[nf] = DTK_SPECIAL;
    448                 *lp++ = tolower(*cp++);
    449                 while (isalpha(*cp))
    450                     *lp++ = tolower(*cp++);
    451 
    452                 /* otherwise something wrong... */
    453             }
    454             else
    455                 return -1;
    456 
    457             /* ignore punctuation but use as delimiter */
    458         }
    459         else if (ispunct(*cp))
    460         {
    461             cp++;
    462             continue;
    463 
    464         }
    465         else
    466             return -1;
    467 
    468         /* force in a delimiter */
    469         *lp++ = '\0';
    470         nf++;
    471         if (nf > MAXDATEFIELDS)
    472             return -1;
    473 #ifdef DATEDEBUG
    474         printf("ParseDateTime- set field[%d] to %s type %d\n", (nf - 1), field[nf - 1], ftype[nf - 1]);
    475 #endif
    476     }
    477 
    478     *numfields = nf;
    479 
    480     return 0;
    481 }   /* ParseDateTime() */
     357        int                     nf = 0;
     358        char       *cp = timestr;
     359        char       *lp = lowstr;
     360
     361#ifdef DATEDEBUG
     362        printf("ParseDateTime- input string is %s\n", timestr);
     363#endif
     364        /* outer loop through fields */
     365        while (*cp != '\0')
     366        {
     367                field[nf] = lp;
     368
     369                /* leading digit? then date or time */
     370                if (isdigit(*cp) || (*cp == '.'))
     371                {
     372                        *lp++ = *cp++;
     373                        while (isdigit(*cp))
     374                                *lp++ = *cp++;
     375                        /* time field? */
     376                        if (*cp == ':')
     377                        {
     378                                ftype[nf] = DTK_TIME;
     379                                while (isdigit(*cp) || (*cp == ':') || (*cp == '.'))
     380                                        *lp++ = *cp++;
     381
     382                        }
     383                        /* date field? allow embedded text month */
     384                        else if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
     385                        {
     386                                ftype[nf] = DTK_DATE;
     387                                while (isalnum(*cp) || (*cp == '-') || (*cp == '/') || (*cp == '.'))
     388                                        *lp++ = tolower(*cp++);
     389
     390                        }
     391
     392                        /*
     393                        * otherwise, number only and will determine year, month, or
     394                        * day later
     395                        */
     396                        else
     397                                ftype[nf] = DTK_NUMBER;
     398
     399                }
     400
     401                /*
     402                * text? then date string, month, day of week, special, or
     403                * timezone
     404                */
     405                else if (isalpha(*cp))
     406                {
     407                        ftype[nf] = DTK_STRING;
     408                        *lp++ = tolower(*cp++);
     409                        while (isalpha(*cp))
     410                                *lp++ = tolower(*cp++);
     411
     412                        /* full date string with leading text month? */
     413                        if ((*cp == '-') || (*cp == '/') || (*cp == '.'))
     414                        {
     415                                ftype[nf] = DTK_DATE;
     416                                while (isdigit(*cp) || (*cp == '-') || (*cp == '/') || (*cp == '.'))
     417                                        *lp++ = tolower(*cp++);
     418                        }
     419
     420                        /* skip leading spaces */
     421                }
     422                else if (isspace(*cp))
     423                {
     424                        cp++;
     425                        continue;
     426
     427                        /* sign? then special or numeric timezone */
     428                }
     429                else if ((*cp == '+') || (*cp == '-'))
     430                {
     431                        *lp++ = *cp++;
     432                        /* soak up leading whitespace */
     433                        while (isspace(*cp))
     434                                cp++;
     435                        /* numeric timezone? */
     436                        if (isdigit(*cp))
     437                        {
     438                                ftype[nf] = DTK_TZ;
     439                                *lp++ = *cp++;
     440                                while (isdigit(*cp) || (*cp == ':'))
     441                                        *lp++ = *cp++;
     442
     443                                /* special? */
     444                        }
     445                        else if (isalpha(*cp))
     446                        {
     447                                ftype[nf] = DTK_SPECIAL;
     448                                *lp++ = tolower(*cp++);
     449                                while (isalpha(*cp))
     450                                        *lp++ = tolower(*cp++);
     451
     452                                /* otherwise something wrong... */
     453                        }
     454                        else
     455                                return -1;
     456
     457                        /* ignore punctuation but use as delimiter */
     458                }
     459                else if (ispunct(*cp))
     460                {
     461                        cp++;
     462                        continue;
     463
     464                }
     465                else
     466                        return -1;
     467
     468                /* force in a delimiter */
     469                *lp++ = '\0';
     470                nf++;
     471                if (nf > MAXDATEFIELDS)
     472                        return -1;
     473#ifdef DATEDEBUG
     474                printf("ParseDateTime- set field[%d] to %s type %d\n", (nf - 1), field[nf - 1], ftype[nf - 1]);
     475#endif
     476        }
     477
     478        *numfields = nf;
     479
     480        return 0;
     481}       /* ParseDateTime() */
    482482
    483483
     
    485485 * Interpret previously parsed fields for general date and time.
    486486 * Return 0 if full date, 1 if only time, and -1 if problems.
    487  *      External format(s):
    488  *              "<weekday> <month>-<day>-<year> <hour>:<minute>:<second>"
    489  *              "Fri Feb-7-1997 15:23:27"
    490  *              "Feb-7-1997 15:23:27"
    491  *              "2-7-1997 15:23:27"
    492  *              "1997-2-7 15:23:27"
    493  *              "1997.038 15:23:27"     (day of year 1-366)
    494  *      Also supports input in compact time:
    495  *              "970207 152327"
    496  *              "97038 152327"
     487 *              External format(s):
     488 *                              "<weekday> <month>-<day>-<year> <hour>:<minute>:<second>"
     489 *                              "Fri Feb-7-1997 15:23:27"
     490 *                              "Feb-7-1997 15:23:27"
     491 *                              "2-7-1997 15:23:27"
     492 *                              "1997-2-7 15:23:27"
     493 *                              "1997.038 15:23:27"             (day of year 1-366)
     494 *              Also supports input in compact time:
     495 *                              "970207 152327"
     496 *                              "97038 152327"
    497497 *
    498498 * Use the system-provided functions to get the current time zone
    499  *  if not specified in the input string.
     499 *      if not specified in the input string.
    500500 * If the date is outside the time_t system-supported time range,
    501  *  then assume GMT time zone. - tgl 97/05/27
     501 *      then assume GMT time zone. - tgl 97/05/27
    502502 */
    503503int
    504504DecodeDateTime(char **field, int *ftype, int nf,
    505                int *dtype, struct tm * tm, double *fsec, int *tzp)
     505                           int *dtype, struct tm * tm, double *fsec, int *tzp)
    506506{
    507     int         fmask = 0,
    508                 tmask,
    509                 type;
    510     int         i;
    511     int         flen,
    512                 val;
    513     int         mer = HR24;
    514     int         bc = FALSE;
    515 
    516     *dtype = DTK_DATE;
    517     tm->tm_hour = 0;
    518     tm->tm_min = 0;
    519     tm->tm_sec = 0;
    520     *fsec = 0;
    521     tm->tm_isdst = -1;          /* don't know daylight savings time status
    522                                 * apriori */
    523     if (tzp != NULL)
    524         *tzp = 0;
    525 
    526     for (i = 0; i < nf; i++)
    527     {
    528 #ifdef DATEDEBUG
    529         printf("DecodeDateTime- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
    530 #endif
    531         switch (ftype[i])
    532         {
    533             case DTK_DATE:
    534                 if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
    535                     return -1;
    536                 break;
    537 
    538             case DTK_TIME:
    539                 if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
    540                     return -1;
    541 
    542                 /*
    543                 * check upper limit on hours; other limits checked in
    544                 * DecodeTime()
    545                 */
    546                 if (tm->tm_hour > 23)
    547                     return -1;
    548                 break;
    549 
    550             case DTK_TZ:
    551                 if (tzp == NULL)
    552                     return -1;
    553                 if (DecodeTimezone(field[i], tzp) != 0)
    554                     return -1;
    555                 tmask = DTK_M(TZ);
    556                 break;
    557 
    558             case DTK_NUMBER:
    559                 flen = strlen(field[i]);
    560 
    561                 if (flen > 4)
    562                 {
    563                     if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0)
    564                         return -1;
    565 
    566                 }
    567                 else
    568                 {
    569                     if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec) != 0)
    570                         return -1;
    571                 }
    572                 break;
    573 
    574             case DTK_STRING:
    575             case DTK_SPECIAL:
    576                 type = DecodeSpecial(i, field[i], &val);
    577 #ifdef DATEDEBUG
    578                 printf("DecodeDateTime- special field[%d] %s type=%d value=%d\n", i, field[i], type, val);
    579 #endif
    580                 if (type == IGNOREFIELD)
    581                     continue;
    582 
    583                 tmask = DTK_M(type);
    584                 switch (type)
    585                 {
    586                     case RESERV:
    587 #ifdef DATEDEBUG
    588                         printf("DecodeDateTime- RESERV field %s value is %d\n", field[i], val);
    589 #endif
    590                         switch (val)
    591                         {
    592 
    593                             default:
    594                                 *dtype = val;
    595                         }
    596 
    597                         break;
    598 
    599                     case MONTH:
    600 #ifdef DATEDEBUG
    601                         printf("DecodeDateTime- month field %s value is %d\n", field[i], val);
    602 #endif
    603                         tm->tm_mon = val;
    604                         break;
    605 
    606                         /*
    607                         * daylight savings time modifier (solves "MET
    608                         * DST" syntax)
    609                         */
    610                     case DTZMOD:
    611                         tmask |= DTK_M(DTZ);
    612                         tm->tm_isdst = 1;
    613                         if (tzp == NULL)
    614                             return -1;
    615                         *tzp += val * 60;
    616                         break;
    617 
    618                     case DTZ:
    619 
    620                         /*
    621                         * set mask for TZ here _or_ check for DTZ later
    622                         * when getting default timezone
    623                         */
    624                         tmask |= DTK_M(TZ);
    625                         tm->tm_isdst = 1;
    626                         if (tzp == NULL)
    627                             return -1;
    628                         *tzp = val * 60;
    629                         break;
    630 
    631                     case TZ:
    632                         tm->tm_isdst = 0;
    633                         if (tzp == NULL)
    634                             return -1;
    635                         *tzp = val * 60;
    636                         break;
    637 
    638                     case IGNOREFIELD:
    639                         break;
    640 
    641                     case AMPM:
    642                         mer = val;
    643                         break;
    644 
    645                     case ADBC:
    646                         bc = (val == BC);
    647                         break;
    648 
    649                     case DOW:
    650                         tm->tm_wday = val;
    651                         break;
    652 
    653                     default:
    654                         return -1;
    655                 }
    656                 break;
    657 
    658             default:
    659                 return -1;
    660         }
    661 
    662 #ifdef DATEDEBUG
    663         printf("DecodeDateTime- field[%d] %s (%08x/%08x) value is %d\n",
    664                i, field[i], fmask, tmask, val);
    665 #endif
    666 
    667         if (tmask & fmask)
    668             return -1;
    669         fmask |= tmask;
    670     }
    671 
    672     /* there is no year zero in AD/BC notation; i.e. "1 BC" == year 0 */
    673     if (bc)
    674         tm->tm_year = -(tm->tm_year - 1);
    675 
    676     if ((mer != HR24) && (tm->tm_hour > 12))
    677         return -1;
    678     if ((mer == AM) && (tm->tm_hour == 12))
    679         tm->tm_hour = 0;
    680     else if ((mer == PM) && (tm->tm_hour != 12))
    681         tm->tm_hour += 12;
    682 
    683 #ifdef DATEDEBUG
    684     printf("DecodeDateTime- mask %08x (%08x)", fmask, DTK_DATE_M);
    685     printf(" set y%04d m%02d d%02d", tm->tm_year, tm->tm_mon, tm->tm_mday);
    686     printf(" %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
    687 #endif
    688 
    689     if ((*dtype == DTK_DATE) && ((fmask & DTK_DATE_M) != DTK_DATE_M))
    690         return ((fmask & DTK_TIME_M) == DTK_TIME_M) ? 1 : -1;
    691 
    692     /* timezone not specified? then find local timezone if possible */
    693     if ((*dtype == DTK_DATE) && ((fmask & DTK_DATE_M) == DTK_DATE_M)
    694         && (tzp != NULL) && (!(fmask & DTK_M(TZ))))
    695     {
    696 
    697         /*
    698         * daylight savings time modifier but no standard timezone? then
    699         * error
    700         */
    701         if (fmask & DTK_M(DTZMOD))
    702             return -1;
    703 
    704         if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
    705         {
     507        int                     fmask = 0,
     508                                tmask,
     509                                type;
     510        int                     i;
     511        int                     flen,
     512                                val;
     513        int                     mer = HR24;
     514        int                     bc = FALSE;
     515
     516        *dtype = DTK_DATE;
     517        tm->tm_hour = 0;
     518        tm->tm_min = 0;
     519        tm->tm_sec = 0;
     520        *fsec = 0;
     521        tm->tm_isdst = -1;                      /* don't know daylight savings time status
     522                                                                * apriori */
     523        if (tzp != NULL)
     524                *tzp = 0;
     525
     526        for (i = 0; i < nf; i++)
     527        {
     528#ifdef DATEDEBUG
     529                printf("DecodeDateTime- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
     530#endif
     531                switch (ftype[i])
     532                {
     533                        case DTK_DATE:
     534                                if (DecodeDate(field[i], fmask, &tmask, tm) != 0)
     535                                        return -1;
     536                                break;
     537
     538                        case DTK_TIME:
     539                                if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
     540                                        return -1;
     541
     542                                /*
     543                                * check upper limit on hours; other limits checked in
     544                                * DecodeTime()
     545                                */
     546                                if (tm->tm_hour > 23)
     547                                        return -1;
     548                                break;
     549
     550                        case DTK_TZ:
     551                                if (tzp == NULL)
     552                                        return -1;
     553                                if (DecodeTimezone(field[i], tzp) != 0)
     554                                        return -1;
     555                                tmask = DTK_M(TZ);
     556                                break;
     557
     558                        case DTK_NUMBER:
     559                                flen = strlen(field[i]);
     560
     561                                if (flen > 4)
     562                                {
     563                                        if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0)
     564                                                return -1;
     565
     566                                }
     567                                else
     568                                {
     569                                        if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec) != 0)
     570                                                return -1;
     571                                }
     572                                break;
     573
     574                        case DTK_STRING:
     575                        case DTK_SPECIAL:
     576                                type = DecodeSpecial(i, field[i], &val);
     577#ifdef DATEDEBUG
     578                                printf("DecodeDateTime- special field[%d] %s type=%d value=%d\n", i, field[i], type, val);
     579#endif
     580                                if (type == IGNOREFIELD)
     581                                        continue;
     582
     583                                tmask = DTK_M(type);
     584                                switch (type)
     585                                {
     586                                        case RESERV:
     587#ifdef DATEDEBUG
     588                                                printf("DecodeDateTime- RESERV field %s value is %d\n", field[i], val);
     589#endif
     590                                                switch (val)
     591                                                {
     592
     593                                                        default:
     594                                                                *dtype = val;
     595                                                }
     596
     597                                                break;
     598
     599                                        case MONTH:
     600#ifdef DATEDEBUG
     601                                                printf("DecodeDateTime- month field %s value is %d\n", field[i], val);
     602#endif
     603                                                tm->tm_mon = val;
     604                                                break;
     605
     606                                                /*
     607                                                * daylight savings time modifier (solves "MET
     608                                                * DST" syntax)
     609                                                */
     610                                        case DTZMOD:
     611                                                tmask |= DTK_M(DTZ);
     612                                                tm->tm_isdst = 1;
     613                                                if (tzp == NULL)
     614                                                        return -1;
     615                                                *tzp += val * 60;
     616                                                break;
     617
     618                                        case DTZ:
     619
     620                                                /*
     621                                                * set mask for TZ here _or_ check for DTZ later
     622                                                * when getting default timezone
     623                                                */
     624                                                tmask |= DTK_M(TZ);
     625                                                tm->tm_isdst = 1;
     626                                                if (tzp == NULL)
     627                                                        return -1;
     628                                                *tzp = val * 60;
     629                                                break;
     630
     631                                        case TZ:
     632                                                tm->tm_isdst = 0;
     633                                                if (tzp == NULL)
     634                                                        return -1;
     635                                                *tzp = val * 60;
     636                                                break;
     637
     638                                        case IGNOREFIELD:
     639                                                break;
     640
     641                                        case AMPM:
     642                                                mer = val;
     643                                                break;
     644
     645                                        case ADBC:
     646                                                bc = (val == BC);
     647                                                break;
     648
     649                                        case DOW:
     650                                                tm->tm_wday = val;
     651                                                break;
     652
     653                                        default:
     654                                                return -1;
     655                                }
     656                                break;
     657
     658                        default:
     659                                return -1;
     660                }
     661
     662#ifdef DATEDEBUG
     663                printf("DecodeDateTime- field[%d] %s (%08x/%08x) value is %d\n",
     664                           i, field[i], fmask, tmask, val);
     665#endif
     666
     667                if (tmask & fmask)
     668                        return -1;
     669                fmask |= tmask;
     670        }
     671
     672        /* there is no year zero in AD/BC notation; i.e. "1 BC" == year 0 */
     673        if (bc)
     674                tm->tm_year = -(tm->tm_year - 1);
     675
     676        if ((mer != HR24) && (tm->tm_hour > 12))
     677                return -1;
     678        if ((mer == AM) && (tm->tm_hour == 12))
     679                tm->tm_hour = 0;
     680        else if ((mer == PM) && (tm->tm_hour != 12))
     681                tm->tm_hour += 12;
     682
     683#ifdef DATEDEBUG
     684        printf("DecodeDateTime- mask %08x (%08x)", fmask, DTK_DATE_M);
     685        printf(" set y%04d m%02d d%02d", tm->tm_year, tm->tm_mon, tm->tm_mday);
     686        printf(" %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
     687#endif
     688
     689        if ((*dtype == DTK_DATE) && ((fmask & DTK_DATE_M) != DTK_DATE_M))
     690                return ((fmask & DTK_TIME_M) == DTK_TIME_M) ? 1 : -1;
     691
     692        /* timezone not specified? then find local timezone if possible */
     693        if ((*dtype == DTK_DATE) && ((fmask & DTK_DATE_M) == DTK_DATE_M)
     694                && (tzp != NULL) && (!(fmask & DTK_M(TZ))))
     695        {
     696
     697                /*
     698                * daylight savings time modifier but no standard timezone? then
     699                * error
     700                */
     701                if (fmask & DTK_M(DTZMOD))
     702                        return -1;
     703
     704                if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
     705                {
    706706#ifdef USE_POSIX_TIME
    707             tm->tm_year -= 1900;
    708             tm->tm_mon -= 1;
    709             tm->tm_isdst = -1;
    710             mktime(tm);
    711             tm->tm_year += 1900;
    712             tm->tm_mon += 1;
     707                        tm->tm_year -= 1900;
     708                        tm->tm_mon -= 1;
     709                        tm->tm_isdst = -1;
     710                        mktime(tm);
     711                        tm->tm_year += 1900;
     712                        tm->tm_mon += 1;
    713713
    714714#ifdef HAVE_INT_TIMEZONE
    715             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
    716 
    717 #else                           /* !HAVE_INT_TIMEZONE */
    718             *tzp = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
    719 #endif
    720 
    721 #else                           /* !USE_POSIX_TIME */
    722             *tzp = CTimeZone;
    723 #endif
    724         }
    725         else
    726         {
    727             tm->tm_isdst = 0;
    728             *tzp = 0;
    729         }
    730     }
    731 
    732     return 0;
    733 }   /* DecodeDateTime() */
     715                        *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
     716
     717#else                                                   /* !HAVE_INT_TIMEZONE */
     718                        *tzp = -(tm->tm_gmtoff);        /* tm_gmtoff is Sun/DEC-ism */
     719#endif
     720
     721#else                                                   /* !USE_POSIX_TIME */
     722                        *tzp = CTimeZone;
     723#endif
     724                }
     725                else
     726                {
     727                        tm->tm_isdst = 0;
     728                        *tzp = 0;
     729                }
     730        }
     731
     732        return 0;
     733}       /* DecodeDateTime() */
    734734
    735735
     
    740740DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, struct tm * tm, double *fsec)
    741741{
    742     int         fmask,
    743                 tmask,
    744                 type;
    745     int         i;
    746     int         flen,
    747                 val;
    748     int         mer = HR24;
    749 
    750     *dtype = DTK_TIME;
    751     tm->tm_hour = 0;
    752     tm->tm_min = 0;
    753     tm->tm_sec = 0;
    754     tm->tm_isdst = -1;          /* don't know daylight savings time status
    755                                 * apriori */
    756     *fsec = 0;
    757 
    758     fmask = DTK_DATE_M;
    759 
    760     for (i = 0; i < nf; i++)
    761     {
    762 #ifdef DATEDEBUG
    763         printf("DecodeTimeOnly- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
    764 #endif
    765         switch (ftype[i])
    766         {
    767             case DTK_TIME:
    768                 if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
    769                     return -1;
    770                 break;
    771 
    772             case DTK_NUMBER:
    773                 flen = strlen(field[i]);
    774 
    775                 if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0)
    776                     return -1;
    777                 break;
    778 
    779             case DTK_STRING:
    780             case DTK_SPECIAL:
    781                 type = DecodeSpecial(i, field[i], &val);
    782 #ifdef DATEDEBUG
    783                 printf("DecodeTimeOnly- special field[%d] %s type=%d value=%d\n", i, field[i], type, val);
    784 #endif
    785                 if (type == IGNOREFIELD)
    786                     continue;
    787 
    788                 tmask = DTK_M(type);
    789                 switch (type)
    790                 {
    791                     case RESERV:
    792 #ifdef DATEDEBUG
    793                         printf("DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val);
    794 #endif
    795                         switch (val)
    796                         {
    797 
    798                             default:
    799                                 return -1;
    800                         }
    801 
    802                         break;
    803 
    804                     case IGNOREFIELD:
    805                         break;
    806 
    807                     case AMPM:
    808                         mer = val;
    809                         break;
    810 
    811                     default:
    812                         return -1;
    813                 }
    814                 break;
    815 
    816             default:
    817                 return -1;
    818         }
    819 
    820         if (tmask & fmask)
    821             return -1;
    822         fmask |= tmask;
    823 
    824 #ifdef DATEDEBUG
    825         printf("DecodeTimeOnly- field[%d] %s value is %d\n", i, field[i], val);
    826 #endif
    827     }
    828 
    829 #ifdef DATEDEBUG
    830     printf("DecodeTimeOnly- mask %08x (%08x)", fmask, DTK_TIME_M);
    831     printf(" %02d:%02d:%02d (%f)\n", tm->tm_hour, tm->tm_min, tm->tm_sec, *fsec);
    832 #endif
    833 
    834     if ((mer != HR24) && (tm->tm_hour > 12))
    835         return -1;
    836     if ((mer == AM) && (tm->tm_hour == 12))
    837         tm->tm_hour = 0;
    838     else if ((mer == PM) && (tm->tm_hour != 12))
    839         tm->tm_hour += 12;
    840 
    841     if ((fmask & DTK_TIME_M) != DTK_TIME_M)
    842         return -1;
    843 
    844     return 0;
    845 }   /* DecodeTimeOnly() */
     742        int                     fmask,
     743                                tmask,
     744                                type;
     745        int                     i;
     746        int                     flen,
     747                                val;
     748        int                     mer = HR24;
     749
     750        *dtype = DTK_TIME;
     751        tm->tm_hour = 0;
     752        tm->tm_min = 0;
     753        tm->tm_sec = 0;
     754        tm->tm_isdst = -1;                      /* don't know daylight savings time status
     755                                                                * apriori */
     756        *fsec = 0;
     757
     758        fmask = DTK_DATE_M;
     759
     760        for (i = 0; i < nf; i++)
     761        {
     762#ifdef DATEDEBUG
     763                printf("DecodeTimeOnly- field[%d] is %s (type %d)\n", i, field[i], ftype[i]);
     764#endif
     765                switch (ftype[i])
     766                {
     767                        case DTK_TIME:
     768                                if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
     769                                        return -1;
     770                                break;
     771
     772                        case DTK_NUMBER:
     773                                flen = strlen(field[i]);
     774
     775                                if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0)
     776                                        return -1;
     777                                break;
     778
     779                        case DTK_STRING:
     780                        case DTK_SPECIAL:
     781                                type = DecodeSpecial(i, field[i], &val);
     782#ifdef DATEDEBUG
     783                                printf("DecodeTimeOnly- special field[%d] %s type=%d value=%d\n", i, field[i], type, val);
     784#endif
     785                                if (type == IGNOREFIELD)
     786                                        continue;
     787
     788                                tmask = DTK_M(type);
     789                                switch (type)
     790                                {
     791                                        case RESERV:
     792#ifdef DATEDEBUG
     793                                                printf("DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val);
     794#endif
     795                                                switch (val)
     796                                                {
     797
     798                                                        default:
     799                                                                return -1;
     800                                                }
     801
     802                                                break;
     803
     804                                        case IGNOREFIELD:
     805                                                break;
     806
     807                                        case AMPM:
     808                                                mer = val;
     809                                                break;
     810
     811                                        default:
     812                                                return -1;
     813                                }
     814                                break;
     815
     816                        default:
     817                                return -1;
     818                }
     819
     820                if (tmask & fmask)
     821                        return -1;
     822                fmask |= tmask;
     823
     824#ifdef DATEDEBUG
     825                printf("DecodeTimeOnly- field[%d] %s value is %d\n", i, field[i], val);
     826#endif
     827        }
     828
     829#ifdef DATEDEBUG
     830        printf("DecodeTimeOnly- mask %08x (%08x)", fmask, DTK_TIME_M);
     831        printf(" %02d:%02d:%02d (%f)\n", tm->tm_hour, tm->tm_min, tm->tm_sec, *fsec);
     832#endif
     833
     834        if ((mer != HR24) && (tm->tm_hour > 12))
     835                return -1;
     836        if ((mer == AM) && (tm->tm_hour == 12))
     837                tm->tm_hour = 0;
     838        else if ((mer == PM) && (tm->tm_hour != 12))
     839                tm->tm_hour += 12;
     840
     841        if ((fmask & DTK_TIME_M) != DTK_TIME_M)
     842                return -1;
     843
     844        return 0;
     845}       /* DecodeTimeOnly() */
    846846
    847847
     
    853853DecodeDate(char *str, int fmask, int *tmask, struct tm * tm)
    854854{
    855     double      fsec;
    856 
    857     int         nf = 0;
    858     int         i,
    859                 len;
    860     int         type,
    861                 val,
    862                 dmask = 0;
    863     char       *field[MAXDATEFIELDS];
    864 
    865     /* parse this string... */
    866     while ((*str != '\0') && (nf < MAXDATEFIELDS))
    867     {
    868         /* skip field separators */
    869         while (!isalnum(*str))
    870             str++;
    871 
    872         field[nf] = str;
    873         if (isdigit(*str))
    874         {
    875             while (isdigit(*str))
    876                 str++;
    877         }
    878         else if (isalpha(*str))
    879         {
    880             while (isalpha(*str))
    881                 str++;
    882         }
    883 
    884         if (*str != '\0')
    885             *str++ = '\0';
    886         nf++;
    887     }
    888 
    889     /* don't allow too many fields */
    890     if (nf > 3)
    891         return -1;
    892 
    893     *tmask = 0;
    894 
    895     /* look first for text fields, since that will be unambiguous month */
    896     for (i = 0; i < nf; i++)
    897     {
    898         if (isalpha(*field[i]))
    899         {
    900             type = DecodeSpecial(i, field[i], &val);
    901             if (type == IGNOREFIELD)
    902                 continue;
    903 
    904             dmask = DTK_M(type);
    905             switch (type)
    906             {
    907                 case MONTH:
    908 #ifdef DATEDEBUG
    909                     printf("DecodeDate- month field %s value is %d\n", field[i], val);
    910 #endif
    911                     tm->tm_mon = val;
    912                     break;
    913 
    914                 default:
    915 #ifdef DATEDEBUG
    916                     printf("DecodeDate- illegal field %s value is %d\n", field[i], val);
    917 #endif
    918                     return -1;
    919             }
    920             if (fmask & dmask)
    921                 return -1;
    922 
    923             fmask |= dmask;
    924             *tmask |= dmask;
    925 
    926             /* mark this field as being completed */
    927             field[i] = NULL;
    928         }
    929     }
    930 
    931     /* now pick up remaining numeric fields */
    932     for (i = 0; i < nf; i++)
    933     {
    934         if (field[i] == NULL)
    935             continue;
    936 
    937         if ((len = strlen(field[i])) <= 0)
    938             return -1;
    939 
    940         if (DecodeNumber(len, field[i], fmask, &dmask, tm, &fsec) != 0)
    941             return -1;
    942 
    943         if (fmask & dmask)
    944             return -1;
    945 
    946         fmask |= dmask;
    947         *tmask |= dmask;
    948     }
    949 
    950     return 0;
    951 }   /* DecodeDate() */
     855        double          fsec;
     856
     857        int                     nf = 0;
     858        int                     i,
     859                                len;
     860        int                     type,
     861                                val,
     862                                dmask = 0;
     863        char       *field[MAXDATEFIELDS];
     864
     865        /* parse this string... */
     866        while ((*str != '\0') && (nf < MAXDATEFIELDS))
     867        {
     868                /* skip field separators */
     869                while (!isalnum(*str))
     870                        str++;
     871
     872                field[nf] = str;
     873                if (isdigit(*str))
     874                {
     875                        while (isdigit(*str))
     876                                str++;
     877                }
     878                else if (isalpha(*str))
     879                {
     880                        while (isalpha(*str))
     881                                str++;
     882                }
     883
     884                if (*str != '\0')
     885                        *str++ = '\0';
     886                nf++;
     887        }
     888
     889        /* don't allow too many fields */
     890        if (nf > 3)
     891                return -1;
     892
     893        *tmask = 0;
     894
     895        /* look first for text fields, since that will be unambiguous month */
     896        for (i = 0; i < nf; i++)
     897        {
     898                if (isalpha(*field[i]))
     899                {
     900                        type = DecodeSpecial(i, field[i], &val);
     901                        if (type == IGNOREFIELD)
     902                                continue;
     903
     904                        dmask = DTK_M(type);
     905                        switch (type)
     906                        {
     907                                case MONTH:
     908#ifdef DATEDEBUG
     909                                        printf("DecodeDate- month field %s value is %d\n", field[i], val);
     910#endif
     911                                        tm->tm_mon = val;
     912                                        break;
     913
     914                                default:
     915#ifdef DATEDEBUG
     916                                        printf("DecodeDate- illegal field %s value is %d\n", field[i], val);
     917#endif
     918                                        return -1;
     919                        }
     920                        if (fmask & dmask)
     921                                return -1;
     922
     923                        fmask |= dmask;
     924                        *tmask |= dmask;
     925
     926                        /* mark this field as being completed */
     927                        field[i] = NULL;
     928                }
     929        }
     930
     931        /* now pick up remaining numeric fields */
     932        for (i = 0; i < nf; i++)
     933        {
     934                if (field[i] == NULL)
     935                        continue;
     936
     937                if ((len = strlen(field[i])) <= 0)
     938                        return -1;
     939
     940                if (DecodeNumber(len, field[i], fmask, &dmask, tm, &fsec) != 0)
     941                        return -1;
     942
     943                if (fmask & dmask)
     944                        return -1;
     945
     946                fmask |= dmask;
     947                *tmask |= dmask;
     948        }
     949
     950        return 0;
     951}       /* DecodeDate() */
    952952
    953953
     
    955955 * Decode time string which includes delimiters.
    956956 * Only check the lower limit on hours, since this same code
    957  *  can be used to represent time spans.
     957 *      can be used to represent time spans.
    958958 */
    959959static int
    960960DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec)
    961961{
    962     char       *cp;
    963 
    964     *tmask = DTK_TIME_M;
    965 
    966     tm->tm_hour = strtol(str, &cp, 10);
    967     if (*cp != ':')
    968         return -1;
    969     str = cp + 1;
    970     tm->tm_min = strtol(str, &cp, 10);
    971     if (*cp == '\0')
    972     {
    973         tm->tm_sec = 0;
    974         *fsec = 0;
    975 
    976     }
    977     else if (*cp != ':')
    978     {
    979         return -1;
    980 
    981     }
    982     else
    983     {
    984         str = cp + 1;
    985         tm->tm_sec = strtol(str, &cp, 10);
    986         if (*cp == '\0')
    987             *fsec = 0;
    988         else if (*cp == '.')
    989         {
    990             str = cp;
    991             *fsec = strtod(str, &cp);
    992             if (cp == str)
    993                 return -1;
    994         }
    995         else
    996             return -1;
    997     }
    998 
    999     /* do a sanity check */
    1000     if ((tm->tm_hour < 0)
    1001         || (tm->tm_min < 0) || (tm->tm_min > 59)
    1002         || (tm->tm_sec < 0) || (tm->tm_sec > 59))
    1003         return -1;
    1004 
    1005     return 0;
    1006 }   /* DecodeTime() */
     962        char       *cp;
     963
     964        *tmask = DTK_TIME_M;
     965
     966        tm->tm_hour = strtol(str, &cp, 10);
     967        if (*cp != ':')
     968                return -1;
     969        str = cp + 1;
     970        tm->tm_min = strtol(str, &cp, 10);
     971        if (*cp == '\0')
     972        {
     973                tm->tm_sec = 0;
     974                *fsec = 0;
     975
     976        }
     977        else if (*cp != ':')
     978        {
     979                return -1;
     980
     981        }
     982        else
     983        {
     984                str = cp + 1;
     985                tm->tm_sec = strtol(str, &cp, 10);
     986                if (*cp == '\0')
     987                        *fsec = 0;
     988                else if (*cp == '.')
     989                {
     990                        str = cp;
     991                        *fsec = strtod(str, &cp);
     992                        if (cp == str)
     993                                return -1;
     994                }
     995                else
     996                        return -1;
     997        }
     998
     999        /* do a sanity check */
     1000        if ((tm->tm_hour < 0)
     1001                || (tm->tm_min < 0) || (tm->tm_min > 59)
     1002                || (tm->tm_sec < 0) || (tm->tm_sec > 59))
     1003                return -1;
     1004
     1005        return 0;
     1006}       /* DecodeTime() */
    10071007
    10081008
     
    10131013DecodeNumber(int flen, char *str, int fmask, int *tmask, struct tm * tm, double *fsec)
    10141014{
    1015     int         val;
    1016     char       *cp;
    1017 
    1018     *tmask = 0;
    1019 
    1020     val = strtol(str, &cp, 10);
    1021     if (cp == str)
    1022         return -1;
    1023     if (*cp == '.')
    1024     {
    1025         *fsec = strtod(cp, &cp);
    1026         if (*cp != '\0')
    1027             return -1;
    1028     }
    1029 
    1030 #ifdef DATEDEBUG
    1031     printf("DecodeNumber- %s is %d fmask=%08x tmask=%08x\n", str, val, fmask, *tmask);
    1032 #endif
    1033 
    1034     /* enough digits to be unequivocal year? */
    1035     if (flen == 4)
    1036     {
    1037 #ifdef DATEDEBUG
    1038         printf("DecodeNumber- match %d (%s) as year\n", val, str);
    1039 #endif
    1040         *tmask = DTK_M(YEAR);
    1041 
    1042         /* already have a year? then see if we can substitute... */
    1043         if (fmask & DTK_M(YEAR))
    1044         {
    1045             if ((!(fmask & DTK_M(DAY)))
    1046                 && ((tm->tm_year >= 1) && (tm->tm_year <= 31)))
    1047             {
    1048 #ifdef DATEDEBUG
    1049                 printf("DecodeNumber- misidentified year previously; swap with day %d\n", tm->tm_mday);
    1050 #endif
    1051                 tm->tm_mday = tm->tm_year;
    1052                 *tmask = DTK_M(DAY);
    1053             }
    1054         }
    1055 
    1056         tm->tm_year = val;
    1057 
    1058         /* special case day of year? */
    1059     }
    1060     else if ((flen == 3) && (fmask & DTK_M(YEAR))
    1061             && ((val >= 1) && (val <= 366)))
    1062     {
    1063         *tmask = (DTK_M(DOY) | DTK_M(MONTH) | DTK_M(DAY));
    1064         tm->tm_yday = val;
    1065         j2date((date2j(tm->tm_year, 1, 1) + tm->tm_yday - 1),
    1066                &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
    1067 
    1068         /* already have year? then could be month */
    1069     }
    1070     else if ((fmask & DTK_M(YEAR)) && (!(fmask & DTK_M(MONTH)))
    1071             && ((val >= 1) && (val <= 12)))
    1072     {
    1073 #ifdef DATEDEBUG
    1074         printf("DecodeNumber- match %d (%s) as month\n", val, str);
    1075 #endif
    1076         *tmask = DTK_M(MONTH);
    1077         tm->tm_mon = val;
    1078 
    1079         /* no year and EuroDates enabled? then could be day */
    1080     }
    1081     else if ((EuroDates || (fmask & DTK_M(MONTH)))
    1082             && (!(fmask & DTK_M(YEAR)) && !(fmask & DTK_M(DAY)))
    1083             && ((val >= 1) && (val <= 31)))
    1084     {
    1085 #ifdef DATEDEBUG
    1086         printf("DecodeNumber- match %d (%s) as day\n", val, str);
    1087 #endif
    1088         *tmask = DTK_M(DAY);
    1089         tm->tm_mday = val;
    1090 
    1091     }
    1092     else if ((!(fmask & DTK_M(MONTH)))
    1093             && ((val >= 1) && (val <= 12)))
    1094     {
    1095 #ifdef DATEDEBUG
    1096         printf("DecodeNumber- (2) match %d (%s) as month\n", val, str);
    1097 #endif
    1098         *tmask = DTK_M(MONTH);
    1099         tm->tm_mon = val;
    1100 
    1101     }
    1102     else if ((!(fmask & DTK_M(DAY)))
    1103             && ((val >= 1) && (val <= 31)))
    1104     {
    1105 #ifdef DATEDEBUG
    1106         printf("DecodeNumber- (2) match %d (%s) as day\n", val, str);
    1107 #endif
    1108         *tmask = DTK_M(DAY);
    1109         tm->tm_mday = val;
    1110 
    1111     }
    1112     else if (!(fmask & DTK_M(YEAR)))
    1113     {
    1114 #ifdef DATEDEBUG
    1115         printf("DecodeNumber- (2) match %d (%s) as year\n", val, str);
    1116 #endif
    1117         *tmask = DTK_M(YEAR);
    1118         tm->tm_year = val;
    1119         if (tm->tm_year < 70)
    1120             tm->tm_year += 2000;
    1121         else if (tm->tm_year < 100)
    1122             tm->tm_year += 1900;
    1123 
    1124     }
    1125     else
    1126         return -1;
    1127 
    1128     return 0;
    1129 }   /* DecodeNumber() */
     1015        int                     val;
     1016        char       *cp;
     1017
     1018        *tmask = 0;
     1019
     1020        val = strtol(str, &cp, 10);
     1021        if (cp == str)
     1022                return -1;
     1023        if (*cp == '.')
     1024        {
     1025                *fsec = strtod(cp, &cp);
     1026                if (*cp != '\0')
     1027                        return -1;
     1028        }
     1029
     1030#ifdef DATEDEBUG
     1031        printf("DecodeNumber- %s is %d fmask=%08x tmask=%08x\n", str, val, fmask, *tmask);
     1032#endif
     1033
     1034        /* enough digits to be unequivocal year? */
     1035        if (flen == 4)
     1036        {
     1037#ifdef DATEDEBUG
     1038                printf("DecodeNumber- match %d (%s) as year\n", val, str);
     1039#endif
     1040                *tmask = DTK_M(YEAR);
     1041
     1042                /* already have a year? then see if we can substitute... */
     1043                if (fmask & DTK_M(YEAR))
     1044                {
     1045                        if ((!(fmask & DTK_M(DAY)))
     1046                                && ((tm->tm_year >= 1) && (tm->tm_year <= 31)))
     1047                        {
     1048#ifdef DATEDEBUG
     1049                                printf("DecodeNumber- misidentified year previously; swap with day %d\n", tm->tm_mday);
     1050#endif
     1051                                tm->tm_mday = tm->tm_year;
     1052                                *tmask = DTK_M(DAY);
     1053                        }
     1054                }
     1055
     1056                tm->tm_year = val;
     1057
     1058                /* special case day of year? */
     1059        }
     1060        else if ((flen == 3) && (fmask & DTK_M(YEAR))
     1061                        && ((val >= 1) && (val <= 366)))
     1062        {
     1063                *tmask = (DTK_M(DOY) | DTK_M(MONTH) | DTK_M(DAY));
     1064                tm->tm_yday = val;
     1065                j2date((date2j(tm->tm_year, 1, 1) + tm->tm_yday - 1),
     1066                           &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
     1067
     1068                /* already have year? then could be month */
     1069        }
     1070        else if ((fmask & DTK_M(YEAR)) && (!(fmask & DTK_M(MONTH)))
     1071                        && ((val >= 1) && (val <= 12)))
     1072        {
     1073#ifdef DATEDEBUG
     1074                printf("DecodeNumber- match %d (%s) as month\n", val, str);
     1075#endif
     1076                *tmask = DTK_M(MONTH);
     1077                tm->tm_mon = val;
     1078
     1079                /* no year and EuroDates enabled? then could be day */
     1080        }
     1081        else if ((EuroDates || (fmask & DTK_M(MONTH)))
     1082                        && (!(fmask & DTK_M(YEAR)) && !(fmask & DTK_M(DAY)))
     1083                        && ((val >= 1) && (val <= 31)))
     1084        {
     1085#ifdef DATEDEBUG
     1086                printf("DecodeNumber- match %d (%s) as day\n", val, str);
     1087#endif
     1088                *tmask = DTK_M(DAY);
     1089                tm->tm_mday = val;
     1090
     1091        }
     1092        else if ((!(fmask & DTK_M(MONTH)))
     1093                        && ((val >= 1) && (val <= 12)))
     1094        {
     1095#ifdef DATEDEBUG
     1096                printf("DecodeNumber- (2) match %d (%s) as month\n", val, str);
     1097#endif
     1098                *tmask = DTK_M(MONTH);
     1099                tm->tm_mon = val;
     1100
     1101        }
     1102        else if ((!(fmask & DTK_M(DAY)))
     1103                        && ((val >= 1) && (val <= 31)))
     1104        {
     1105#ifdef DATEDEBUG
     1106                printf("DecodeNumber- (2) match %d (%s) as day\n", val, str);
     1107#endif
     1108                *tmask = DTK_M(DAY);
     1109                tm->tm_mday = val;
     1110
     1111        }
     1112        else if (!(fmask & DTK_M(YEAR)))
     1113        {
     1114#ifdef DATEDEBUG
     1115                printf("DecodeNumber- (2) match %d (%s) as year\n", val, str);
     1116#endif
     1117                *tmask = DTK_M(YEAR);
     1118                tm->tm_year = val;
     1119                if (tm->tm_year < 70)
     1120                        tm->tm_year += 2000;
     1121                else if (tm->tm_year < 100)
     1122                        tm->tm_year += 1900;
     1123
     1124        }
     1125        else
     1126                return -1;
     1127
     1128        return 0;
     1129}       /* DecodeNumber() */
    11301130
    11311131
     
    11361136DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, double *fsec)
    11371137{
    1138     char       *cp;
    1139 
    1140     /* yyyymmdd? */
    1141     if (len == 8)
    1142     {
    1143 #ifdef DATEDEBUG
    1144         printf("DecodeNumberField- %s is 8 character date fmask=%08x tmask=%08x\n", str, fmask, *tmask);
    1145 #endif
    1146 
    1147         *tmask = DTK_DATE_M;
    1148 
    1149         tm->tm_mday = atoi(str + 6);
    1150         *(str + 6) = '\0';
    1151         tm->tm_mon = atoi(str + 4);
    1152         *(str + 4) = '\0';
    1153         tm->tm_year = atoi(str + 0);
    1154 
    1155         /* yymmdd or hhmmss? */
    1156     }
    1157     else if (len == 6)
    1158     {
    1159 #ifdef DATEDEBUG
    1160         printf("DecodeNumberField- %s is 6 characters fmask=%08x tmask=%08x\n", str, fmask, *tmask);
    1161 #endif
    1162         if (fmask & DTK_DATE_M)
    1163         {
    1164 #ifdef DATEDEBUG
    1165             printf("DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
    1166 #endif
    1167             *tmask = DTK_TIME_M;
    1168             tm->tm_sec = atoi(str + 4);
    1169             *(str + 4) = '\0';
    1170             tm->tm_min = atoi(str + 2);
    1171             *(str + 2) = '\0';
    1172             tm->tm_hour = atoi(str + 0);
    1173 
    1174         }
    1175         else
    1176         {
    1177 #ifdef DATEDEBUG
    1178             printf("DecodeNumberField- %s is date field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
    1179 #endif
    1180             *tmask = DTK_DATE_M;
    1181             tm->tm_mday = atoi(str + 4);
    1182             *(str + 4) = '\0';
    1183             tm->tm_mon = atoi(str + 2);
    1184             *(str + 2) = '\0';
    1185             tm->tm_year = atoi(str + 0);
    1186         }
    1187 
    1188     }
    1189     else if (strchr(str, '.') != NULL)
    1190     {
    1191 #ifdef DATEDEBUG
    1192         printf("DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
    1193 #endif
    1194         *tmask = DTK_TIME_M;
    1195         tm->tm_sec = strtod((str + 4), &cp);
    1196         if (cp == (str + 4))
    1197             return -1;
    1198         if (*cp == '.')
    1199             *fsec = strtod(cp, NULL);
    1200         *(str + 4) = '\0';
    1201         tm->tm_min = strtod((str + 2), &cp);
    1202         *(str + 2) = '\0';
    1203         tm->tm_hour = strtod((str + 0), &cp);
    1204 
    1205     }
    1206     else
    1207         return -1;
    1208 
    1209     return 0;
    1210 }   /* DecodeNumberField() */
     1138        char       *cp;
     1139
     1140        /* yyyymmdd? */
     1141        if (len == 8)
     1142        {
     1143#ifdef DATEDEBUG
     1144                printf("DecodeNumberField- %s is 8 character date fmask=%08x tmask=%08x\n", str, fmask, *tmask);
     1145#endif
     1146
     1147                *tmask = DTK_DATE_M;
     1148
     1149                tm->tm_mday = atoi(str + 6);
     1150                *(str + 6) = '\0';
     1151                tm->tm_mon = atoi(str + 4);
     1152                *(str + 4) = '\0';
     1153                tm->tm_year = atoi(str + 0);
     1154
     1155                /* yymmdd or hhmmss? */
     1156        }
     1157        else if (len == 6)
     1158        {
     1159#ifdef DATEDEBUG
     1160                printf("DecodeNumberField- %s is 6 characters fmask=%08x tmask=%08x\n", str, fmask, *tmask);
     1161#endif
     1162                if (fmask & DTK_DATE_M)
     1163                {
     1164#ifdef DATEDEBUG
     1165                        printf("DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
     1166#endif
     1167                        *tmask = DTK_TIME_M;
     1168                        tm->tm_sec = atoi(str + 4);
     1169                        *(str + 4) = '\0';
     1170                        tm->tm_min = atoi(str + 2);
     1171                        *(str + 2) = '\0';
     1172                        tm->tm_hour = atoi(str + 0);
     1173
     1174                }
     1175                else
     1176                {
     1177#ifdef DATEDEBUG
     1178                        printf("DecodeNumberField- %s is date field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
     1179#endif
     1180                        *tmask = DTK_DATE_M;
     1181                        tm->tm_mday = atoi(str + 4);
     1182                        *(str + 4) = '\0';
     1183                        tm->tm_mon = atoi(str + 2);
     1184                        *(str + 2) = '\0';
     1185                        tm->tm_year = atoi(str + 0);
     1186                }
     1187
     1188        }
     1189        else if (strchr(str, '.') != NULL)
     1190        {
     1191#ifdef DATEDEBUG
     1192                printf("DecodeNumberField- %s is time field fmask=%08x tmask=%08x\n", str, fmask, *tmask);
     1193#endif
     1194                *tmask = DTK_TIME_M;
     1195                tm->tm_sec = strtod((str + 4), &cp);
     1196                if (cp == (str + 4))
     1197                        return -1;
     1198                if (*cp == '.')
     1199                        *fsec = strtod(cp, NULL);
     1200                *(str + 4) = '\0';
     1201                tm->tm_min = strtod((str + 2), &cp);
     1202                *(str + 2) = '\0';
     1203                tm->tm_hour = strtod((str + 0), &cp);
     1204
     1205        }
     1206        else
     1207                return -1;
     1208
     1209        return 0;
     1210}       /* DecodeNumberField() */
    12111211
    12121212
     
    12171217DecodeTimezone(char *str, int *tzp)
    12181218{
    1219     int         tz;
    1220     int         hr,
    1221                 min;
    1222     char       *cp;
    1223     int         len;
    1224 
    1225     /* assume leading character is "+" or "-" */
    1226     hr = strtol((str + 1), &cp, 10);
    1227 
    1228     /* explicit delimiter? */
    1229     if (*cp == ':')
    1230     {
    1231         min = strtol((cp + 1), &cp, 10);
    1232 
    1233         /* otherwise, might have run things together... */
    1234     }
    1235     else if ((*cp == '\0') && ((len = strlen(str)) > 3))
    1236     {
    1237         min = strtol((str + len - 2), &cp, 10);
    1238         *(str + len - 2) = '\0';
    1239         hr = strtol((str + 1), &cp, 10);
    1240 
    1241     }
    1242     else
    1243         min = 0;
    1244 
    1245     tz = (hr * 60 + min) * 60;
    1246     if (*str == '-')
    1247         tz = -tz;
    1248 
    1249     *tzp = -tz;
    1250     return *cp != '\0';
    1251 }   /* DecodeTimezone() */
     1219        int                     tz;
     1220        int                     hr,
     1221                                min;
     1222        char       *cp;
     1223        int                     len;
     1224
     1225        /* assume leading character is "+" or "-" */
     1226        hr = strtol((str + 1), &cp, 10);
     1227
     1228        /* explicit delimiter? */
     1229        if (*cp == ':')
     1230        {
     1231                min = strtol((cp + 1), &cp, 10);
     1232
     1233                /* otherwise, might have run things together... */
     1234        }
     1235        else if ((*cp == '\0') && ((len = strlen(str)) > 3))
     1236        {
     1237                min = strtol((str + len - 2), &cp, 10);
     1238                *(str + len - 2) = '\0';
     1239                hr = strtol((str + 1), &cp, 10);
     1240
     1241        }
     1242        else
     1243                min = 0;
     1244
     1245        tz = (hr * 60 + min) * 60;
     1246        if (*str == '-')
     1247                tz = -tz;
     1248
     1249        *tzp = -tz;
     1250        return *cp != '\0';
     1251}       /* DecodeTimezone() */
    12521252
    12531253
     
    12551255 * Decode text string using lookup table.
    12561256 * Implement a cache lookup since it is likely that dates
    1257  *  will be related in format.
     1257 *      will be related in format.
    12581258 */
    12591259static int
    12601260DecodeSpecial(int field, char *lowtoken, int *val)
    12611261{
    1262     int         type;
    1263     datetkn    *tp;
     1262        int                     type;
     1263        datetkn    *tp;
    12641264
    12651265#if USE_DATE_CACHE
    1266     if ((datecache[field] != NULL)
    1267         && (strncmp(lowtoken, datecache[field]->token, TOKMAXLEN) == 0))
    1268         tp = datecache[field];
    1269     else
    1270     {
    1271 #endif
    1272         tp = datebsearch(lowtoken, datetktbl, szdatetktbl);
     1266        if ((datecache[field] != NULL)
     1267                && (strncmp(lowtoken, datecache[field]->token, TOKMAXLEN) == 0))
     1268                tp = datecache[field];
     1269        else
     1270        {
     1271#endif
     1272                tp = datebsearch(lowtoken, datetktbl, szdatetktbl);
    12731273#if USE_DATE_CACHE
    1274     }
    1275     datecache[field] = tp;
    1276 #endif
    1277     if (tp == NULL)
    1278     {
    1279         type = IGNOREFIELD;
    1280         *val = 0;
    1281     }
    1282     else
    1283     {
    1284         type = tp->type;
    1285         switch (type)
    1286         {
    1287             case TZ:
    1288             case DTZ:
    1289             case DTZMOD:
    1290                 *val = FROMVAL(tp);
    1291                 break;
    1292 
    1293             default:
    1294                 *val = tp->value;
    1295                 break;
    1296         }
    1297     }
    1298 
    1299     return type;
    1300 }   /* DecodeSpecial() */
     1274        }
     1275        datecache[field] = tp;
     1276#endif
     1277        if (tp == NULL)
     1278        {
     1279                type = IGNOREFIELD;
     1280                *val = 0;
     1281        }
     1282        else
     1283        {
     1284                type = tp->type;
     1285                switch (type)
     1286                {
     1287                        case TZ:
     1288                        case DTZ:
     1289                        case DTZMOD:
     1290                                *val = FROMVAL(tp);
     1291                                break;
     1292
     1293                        default:
     1294                                *val = tp->value;
     1295                                break;
     1296                }
     1297        }
     1298
     1299        return type;
     1300}       /* DecodeSpecial() */
    13011301
    13021302
     
    13091309datebsearch(char *key, datetkn *base, unsigned int nel)
    13101310{
    1311     datetkn    *last = base + nel - 1,
    1312                *position;
    1313     int         result;
    1314 
    1315     while (last >= base)
    1316     {
    1317         position = base + ((last - base) >> 1);
    1318         result = key[0] - position->token[0];
    1319         if (result == 0)
    1320         {
    1321             result = strncmp(key, position->token, TOKMAXLEN);
    1322             if (result == 0)
    1323                 return position;
    1324         }
    1325         if (result < 0)
    1326             last = position - 1;
    1327         else
    1328             base = position + 1;
    1329     }
    1330     return NULL;
     1311        datetkn    *last = base + nel - 1,
     1312                           *position;
     1313        int                     result;
     1314
     1315        while (last >= base)
     1316        {
     1317                position = base + ((last - base) >> 1);
     1318                result = key[0] - position->token[0];
     1319                if (result == 0)
     1320                {
     1321                        result = strncmp(key, position->token, TOKMAXLEN);
     1322                        if (result == 0)
     1323                                return position;
     1324                }
     1325                if (result < 0)
     1326                        last = position - 1;
     1327                else
     1328                        base = position + 1;
     1329        }
     1330        return NULL;
    13311331}
    13321332
  • trunk/src/oleaut32/safearray.c

    r6689 r6711  
    2525
    2626/* Localy used methods */
    27 static INT
     27static INT 
    2828endOfDim(LONG *coor, SAFEARRAYBOUND *mat, LONG dim, LONG realDim);
    2929
    30 static ULONG
     30static ULONG   
    3131calcDisplacement(LONG *coor, SAFEARRAYBOUND *mat, LONG dim);
    3232
    33 static BOOL
     33static BOOL 
    3434isPointer(USHORT feature);
    3535
    36 static INT
     36static INT   
    3737getFeatures(VARTYPE vt);
    3838
    39 static BOOL
     39static BOOL 
    4040validCoordinate(LONG *coor, SAFEARRAY *psa);
    4141
    42 static BOOL
     42static BOOL 
    4343resizeSafeArray(SAFEARRAY *psa, LONG lDelta);
    4444
    45 static BOOL
     45static BOOL 
    4646validArg(SAFEARRAY *psa);
    4747
    48 static ULONG
     48static ULONG   
    4949getArraySize(SAFEARRAY *psa);
    5050
    51 static HRESULT
     51static HRESULT 
    5252duplicateData(SAFEARRAY *psa, SAFEARRAY **ppsaOut);
    5353
     
    5959{
    6060  /* this is taken from wtypes.h.  Only [S]es are supported by the SafeArray */
    61 VARTYPE_NOT_SUPPORTED,  /* VT_EMPTY    [V]   [P]    nothing         */
    62 VARTYPE_NOT_SUPPORTED,  /* VT_NULL     [V]   [P]    SQL style Nul   */
    63 2,                      /* VT_I2       [V][T][P][S] 2 byte signed int */
    64 4,                      /* VT_I4       [V][T][P][S] 4 byte signed int */
    65 4,                      /* VT_R4       [V][T][P][S] 4 byte real */
    66 8,                      /* VT_R8       [V][T][P][S] 8 byte real */
     61VARTYPE_NOT_SUPPORTED,  /* VT_EMPTY    [V]   [P]    nothing                     */
     62VARTYPE_NOT_SUPPORTED,  /* VT_NULL     [V]   [P]    SQL style Nul       */
     632,                          /* VT_I2       [V][T][P][S] 2 byte signed int */
     644,                          /* VT_I4       [V][T][P][S] 4 byte signed int */
     654,                          /* VT_R4       [V][T][P][S] 4 byte real     */
     668,                          /* VT_R8       [V][T][P][S] 8 byte real     */
    67678,                      /* VT_CY       [V][T][P][S] currency */
    68 8,                      /* VT_DATE     [V][T][P][S] date */
    69 4,                      /* VT_BSTR     [V][T][P][S] OLE Automation string*/
    70 4,                      /* VT_DISPATCH [V][T][P][S] IDispatch * */
    71 4,                      /* VT_ERROR    [V][T]   [S] SCODE   */
    72 4,                      /* VT_BOOL     [V][T][P][S] True=-1, False=0*/
    73 24,                     /* VT_VARIANT  [V][T][P][S] VARIANT *   */
    74 4,                      /* VT_UNKNOWN  [V][T]   [S] IUnknown * */
    75 16,                     /* VT_DECIMAL  [V][T]   [S] 16 byte fixed point */
     688,                          /* VT_DATE     [V][T][P][S] date */
     694,                          /* VT_BSTR     [V][T][P][S] OLE Automation string*/
     704,                          /* VT_DISPATCH [V][T][P][S] IDispatch *     */
     714,                      /* VT_ERROR    [V][T]   [S] SCODE       */
     724,                          /* VT_BOOL     [V][T][P][S] True=-1, False=0*/
     7324,                     /* VT_VARIANT  [V][T][P][S] VARIANT *   */
     744,                          /* VT_UNKNOWN  [V][T]   [S] IUnknown * */
     7516,                         /* VT_DECIMAL  [V][T]   [S] 16 byte fixed point     */
    7676VARTYPE_NOT_SUPPORTED,                         /* no VARTYPE here..... */
    77 VARTYPE_NOT_SUPPORTED,  /* VT_I1          [T]       signed char */
    78 1,                      /* VT_UI1      [V][T][P][S] unsigned char           */
    79 VARTYPE_NOT_SUPPORTED,  /* VT_UI2         [T][P]    unsigned short  */
    80 VARTYPE_NOT_SUPPORTED,  /* VT_UI4         [T][P]    unsigned short  */
    81 VARTYPE_NOT_SUPPORTED,  /* VT_I8          [T][P]    signed 64-bit int           */
    82 VARTYPE_NOT_SUPPORTED,  /* VT_UI8         [T][P]    unsigned 64-bit int     */
    83 VARTYPE_NOT_SUPPORTED,  /* VT_INT         [T]       signed machine int      */
    84 VARTYPE_NOT_SUPPORTED,  /* VT_UINT        [T]       unsigned machine int    */
    85 VARTYPE_NOT_SUPPORTED,  /* VT_VOID        [T]       C style void            */
    86 VARTYPE_NOT_SUPPORTED,  /* VT_HRESULT     [T]       Standard return type    */
    87 VARTYPE_NOT_SUPPORTED,  /* VT_PTR         [T]       pointer type            */
    88 VARTYPE_NOT_SUPPORTED,  /* VT_SAFEARRAY   [T]       (use VT_ARRAY in VARIANT)*/
    89 VARTYPE_NOT_SUPPORTED,  /* VT_CARRAY      [T]       C style array           */
    90 VARTYPE_NOT_SUPPORTED,  /* VT_USERDEFINED [T]       user defined type           */
    91 VARTYPE_NOT_SUPPORTED,  /* VT_LPSTR       [T][P]    null terminated string  */
    92 VARTYPE_NOT_SUPPORTED,  /* VT_LPWSTR      [T][P]    wide null term string       */
    93 VARTYPE_NOT_SUPPORTED,  /* VT_FILETIME       [P]    FILETIME            */
    94 VARTYPE_NOT_SUPPORTED,  /* VT_BLOB           [P]    Length prefixed bytes */
    95 VARTYPE_NOT_SUPPORTED,  /* VT_STREAM         [P]    Name of stream follows      */
    96 VARTYPE_NOT_SUPPORTED,  /* VT_STORAGE        [P]    Name of storage follows */
    97 VARTYPE_NOT_SUPPORTED,  /* VT_STREAMED_OBJECT[P]    Stream contains an object*/
    98 VARTYPE_NOT_SUPPORTED,  /* VT_STORED_OBJECT  [P]    Storage contains object*/
    99 VARTYPE_NOT_SUPPORTED,  /* VT_BLOB_OBJECT    [P]    Blob contains an object*/
    100 VARTYPE_NOT_SUPPORTED,  /* VT_CF             [P]    Clipboard format            */
    101 VARTYPE_NOT_SUPPORTED,  /* VT_CLSID          [P]    A Class ID          */
    102 VARTYPE_NOT_SUPPORTED,  /* VT_VECTOR         [P]    simple counted array        */
    103 VARTYPE_NOT_SUPPORTED,  /* VT_ARRAY    [V]          SAFEARRAY*          */
    104 VARTYPE_NOT_SUPPORTED   /* VT_BYREF    [V]          void* for local use */
     77VARTYPE_NOT_SUPPORTED,  /* VT_I1          [T]       signed char */
     781,                          /* VT_UI1      [V][T][P][S] unsigned char                   */
     79VARTYPE_NOT_SUPPORTED,  /* VT_UI2         [T][P]    unsigned short      */
     80VARTYPE_NOT_SUPPORTED,  /* VT_UI4         [T][P]    unsigned short      */
     81VARTYPE_NOT_SUPPORTED,  /* VT_I8          [T][P]    signed 64-bit int                   */
     82VARTYPE_NOT_SUPPORTED,  /* VT_UI8         [T][P]    unsigned 64-bit int         */
     83VARTYPE_NOT_SUPPORTED,  /* VT_INT         [T]       signed machine int          */
     84VARTYPE_NOT_SUPPORTED,  /* VT_UINT        [T]       unsigned machine int        */
     85VARTYPE_NOT_SUPPORTED,  /* VT_VOID        [T]       C style void                        */
     86VARTYPE_NOT_SUPPORTED,  /* VT_HRESULT     [T]       Standard return type        */
     87VARTYPE_NOT_SUPPORTED,  /* VT_PTR         [T]       pointer type                        */
     88VARTYPE_NOT_SUPPORTED,  /* VT_SAFEARRAY   [T]       (use VT_ARRAY in VARIANT)*/
     89VARTYPE_NOT_SUPPORTED,  /* VT_CARRAY      [T]       C style array                       */
     90VARTYPE_NOT_SUPPORTED,  /* VT_USERDEFINED [T]       user defined type                   */
     91VARTYPE_NOT_SUPPORTED,  /* VT_LPSTR       [T][P]    null terminated string      */
     92VARTYPE_NOT_SUPPORTED,  /* VT_LPWSTR      [T][P]    wide null term string               */
     93VARTYPE_NOT_SUPPORTED,  /* VT_FILETIME       [P]    FILETIME                    */
     94VARTYPE_NOT_SUPPORTED,  /* VT_BLOB           [P]    Length prefixed bytes */
     95VARTYPE_NOT_SUPPORTED,  /* VT_STREAM         [P]    Name of stream follows              */
     96VARTYPE_NOT_SUPPORTED,  /* VT_STORAGE        [P]    Name of storage follows     */
     97VARTYPE_NOT_SUPPORTED,  /* VT_STREAMED_OBJECT[P]    Stream contains an object*/
     98VARTYPE_NOT_SUPPORTED,  /* VT_STORED_OBJECT  [P]    Storage contains object*/
     99VARTYPE_NOT_SUPPORTED,  /* VT_BLOB_OBJECT    [P]    Blob contains an object*/
     100VARTYPE_NOT_SUPPORTED,  /* VT_CF             [P]    Clipboard format                    */
     101VARTYPE_NOT_SUPPORTED,  /* VT_CLSID          [P]    A Class ID                  */
     102VARTYPE_NOT_SUPPORTED,  /* VT_VECTOR         [P]    simple counted array                */
     103VARTYPE_NOT_SUPPORTED,  /* VT_ARRAY    [V]          SAFEARRAY*                  */
     104VARTYPE_NOT_SUPPORTED   /* VT_BYREF    [V]          void* for local use */
    105105};
    106106
     
    109109
    110110/*************************************************************************
    111  *      SafeArrayAllocDescriptor
     111 *              SafeArrayAllocDescriptor
    112112 * Allocate the appropriate amount of memory for the SafeArray descriptor
    113113 */
    114 HRESULT WINAPI SafeArrayAllocDescriptor(
    115   UINT    cDims,
    116   SAFEARRAY **ppsaOut)
     114HRESULT WINAPI SafeArrayAllocDescriptor( 
     115  UINT    cDims, 
     116  SAFEARRAY **ppsaOut) 
    117117{
    118118  SAFEARRAYBOUND *sab;
     
    124124
    125125  /* Allocate memory for SAFEARRAY struc */
    126   if(( (*ppsaOut)=HeapAlloc(
     126  if(( (*ppsaOut)=HeapAlloc( 
    127127        GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize)) == NULL){
    128128    return(E_UNEXPECTED);
     
    134134
    135135/*************************************************************************
    136  *      SafeArrayAllocData
     136 *              SafeArrayAllocData
    137137 * Allocate the appropriate amount of data for the SafeArray data
    138138 */
    139139HRESULT WINAPI SafeArrayAllocData(
    140   SAFEARRAY *psa)
     140  SAFEARRAY *psa) 
    141141{
    142142  ULONG  ulWholeArraySize;   /* to store the size of the whole thing */
     
    144144  dprintf(("SafeArrayAllocData %x", psa));
    145145
    146   if(! validArg(psa))
     146  if(! validArg(psa)) 
    147147    return E_INVALIDARG;
    148148
     
    150150
    151151  /* Allocate memory for the data itself */
    152   if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
     152  if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 
    153153        psa->cbElements*ulWholeArraySize)) == NULL)
    154154    return(E_UNEXPECTED);
    155155
    156   TRACE("SafeArray: %lu bytes allocated for data at %p (%lu objects).\n",
     156  TRACE("SafeArray: %lu bytes allocated for data at %p (%lu objects).\n", 
    157157    psa->cbElements*ulWholeArraySize, psa->pvData, ulWholeArraySize);
    158158
     
    161161
    162162/*************************************************************************
    163  *      SafeArrayCreate
    164  * Create a SafeArray object by encapsulating AllocDescriptor and AllocData
     163 *              SafeArrayCreate
     164 * Create a SafeArray object by encapsulating AllocDescriptor and AllocData 
    165165 */
    166166SAFEARRAY* WINAPI SafeArrayCreate(
    167   VARTYPE        vt,
    168   UINT         cDims,
     167  VARTYPE        vt, 
     168  UINT         cDims, 
    169169  SAFEARRAYBOUND *rgsabound)
    170170{
     
    184184    return NULL;
    185185
    186   /* setup data members... */
     186  /* setup data members... */ 
    187187  psa->cDims     = cDims;
    188188  psa->fFeatures = getFeatures(vt);
     
    197197  }
    198198
    199   /* allocate memory for the data... */
     199  /* allocate memory for the data... */ 
    200200  if( FAILED( hRes = SafeArrayAllocData(psa))) {
    201     SafeArrayDestroyDescriptor(psa);
     201    SafeArrayDestroyDescriptor(psa); 
    202202    ERR("() : Failed to allocate the Safe Array data\n");
    203203    return NULL;
    204204  }
    205205
    206   return(psa);
    207 }
    208 
    209 /*************************************************************************
    210  *      SafeArrayDestroyDescriptor
     206  return(psa); 
     207}
     208
     209/*************************************************************************
     210 *              SafeArrayDestroyDescriptor
    211211 * Frees the memory associated with the descriptor.
    212212 */
     
    217217
    218218  /* Check for lockness before to free... */
    219   if(psa->cLocks > 0)
     219  if(psa->cLocks > 0) 
    220220    return DISP_E_ARRAYISLOCKED;
    221221
    222222  /* The array is unlocked, then, deallocate memory */
    223   if(HeapFree( GetProcessHeap(), 0, psa) == FALSE)
     223  if(HeapFree( GetProcessHeap(), 0, psa) == FALSE) 
    224224    return E_UNEXPECTED;
    225 
     225 
    226226  return(S_OK);
    227227}
     
    229229
    230230/*************************************************************************
    231  *      SafeArrayLock
     231 *              SafeArrayLock
    232232 * Increment the lock counter
    233233 *
    234234 * Doc says (MSDN Library ) that psa->pvData should be made available (!= NULL)
    235  * only when psa->cLocks is > 0... I don't get it since pvData is allocated
    236  * before the array is locked, therefore
     235 * only when psa->cLocks is > 0... I don't get it since pvData is allocated 
     236 * before the array is locked, therefore 
    237237 */
    238238HRESULT WINAPI SafeArrayLock(
     
    241241  dprintf(("SafeArrayLock %x", psa));
    242242
    243   if(! validArg(psa))
     243  if(! validArg(psa))     
    244244    return E_INVALIDARG;
    245245
     
    250250
    251251/*************************************************************************
    252  *      SafeArrayUnlock
     252 *              SafeArrayUnlock
    253253 * Decrement the lock counter
    254254 */
     
    258258  dprintf(("SafeArrayUnlock %x", psa));
    259259
    260   if(! validArg(psa))
    261     return E_INVALIDARG;
    262 
    263   if (psa->cLocks > 0)
     260  if(! validArg(psa)) 
     261    return E_INVALIDARG;
     262
     263  if (psa->cLocks > 0) 
    264264    psa->cLocks--;
    265265
     
    269269
    270270/*************************************************************************
    271  *      SafeArrayPutElement
     271 *              SafeArrayPutElement
    272272 * Set the data at the given coordinate
    273273 */
    274274HRESULT WINAPI SafeArrayPutElement(
    275   SAFEARRAY *psa,
    276   LONG      *rgIndices,
     275  SAFEARRAY *psa, 
     276  LONG      *rgIndices, 
    277277  void      *pv)
    278278{
    279   ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to
     279  ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to 
    280280                                         the desired one... */
    281281  PVOID elementStorageAddress = NULL; /* Adress to store the data */
     
    285285
    286286  /* Validate the index given */
    287   if(! validCoordinate(rgIndices, psa))
     287  if(! validCoordinate(rgIndices, psa)) 
    288288    return DISP_E_BADINDEX;
    289289  if(! validArg(psa))
     
    294294    /* Figure out the number of items to skip */
    295295    stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    296 
     296 
    297297    /* Figure out the number of byte to skip ... */
    298298    elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    299 
     299 
    300300    if(isPointer(psa->fFeatures)) { /* increment ref count for this pointer */
    301301
    302       *((VOID**)elementStorageAddress) = *(VOID**)pv;
     302      *((VOID**)elementStorageAddress) = *(VOID**)pv; 
    303303      IUnknown_AddRef( *(IUnknown**)pv);
    304304
    305     } else {
     305    } else { 
    306306
    307307      if(psa->fFeatures == FADF_BSTR) { /* Create a new object */
    308308
    309309        if((pbstrReAllocStr = SysAllocString( (OLECHAR*)pv )) == NULL) {
    310           SafeArrayUnlock(psa);
     310          SafeArrayUnlock(psa); 
    311311          return E_OUTOFMEMORY;
    312         } else
     312        } else 
    313313          *((BSTR*)elementStorageAddress) = pbstrReAllocStr;
    314314
     
    323323
    324324  TRACE("SafeArray: item put at adress %p.\n",elementStorageAddress);
    325   return SafeArrayUnlock(psa);
    326 }
    327 
    328 
    329 /*************************************************************************
    330  *      SafeArrayGetElement
     325  return SafeArrayUnlock(psa); 
     326}
     327
     328
     329/*************************************************************************
     330 *              SafeArrayGetElement
    331331 * Return the data element corresponding the the given coordinate
    332332 */
    333333HRESULT WINAPI SafeArrayGetElement(
    334   SAFEARRAY *psa,
    335   LONG      *rgIndices,
     334  SAFEARRAY *psa, 
     335  LONG      *rgIndices, 
    336336  void      *pv)
    337337{
    338   ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to
     338  ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to 
    339339                                         the desired one... */
    340340  PVOID elementStorageAddress = NULL; /* Adress to store the data */
     
    343343  dprintf(("SafeArrayGetElement %x %x %x", psa, rgIndices, pv));
    344344
    345   if(! validArg(psa))
    346     return E_INVALIDARG;
    347 
     345  if(! validArg(psa)) 
     346    return E_INVALIDARG;
     347 
    348348  if(! validCoordinate(rgIndices, psa)) /* Validate the index given */
    349349    return(DISP_E_BADINDEX);
     
    353353    /* Figure out the number of items to skip */
    354354    stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    355 
     355 
    356356    /* Figure out the number of byte to skip ... */
    357357    elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    358 
     358 
    359359    if( psa->fFeatures == FADF_BSTR) {           /* reallocate the obj */
    360       if( (pbstrReturnedStr =
     360      if( (pbstrReturnedStr = 
    361361          SysAllocString( *(OLECHAR**)elementStorageAddress )) == NULL) {
    362362        SafeArrayUnlock(psa);
    363363        return E_OUTOFMEMORY;
    364       } else
    365         *((BSTR*)pv) = pbstrReturnedStr;
    366 
     364      } else 
     365        *((BSTR*)pv) = pbstrReturnedStr; 
     366       
    367367    } else if( isPointer(psa->fFeatures) )       /* simply copy the pointer */
    368        pv = *((PVOID*)elementStorageAddress);
     368       pv = *((PVOID*)elementStorageAddress); 
    369369    else                                         /* copy the bytes */
    370370      memcpy(pv, elementStorageAddress, SafeArrayGetElemsize(psa) );
     
    375375  }
    376376
    377   return( SafeArrayUnlock(psa) );
    378 }
    379 
    380 /*************************************************************************
    381  *      SafeArrayGetUBound
     377  return( SafeArrayUnlock(psa) ); 
     378}
     379
     380/*************************************************************************
     381 *              SafeArrayGetUBound
    382382 * return the UP bound for a given array dimension
    383383 */
    384384HRESULT WINAPI SafeArrayGetUBound(
    385   SAFEARRAY *psa,
     385  SAFEARRAY *psa, 
    386386  UINT    nDim,
    387387  LONG      *plUbound)
     
    390390  dprintf(("SafeArrayGetUBound %x %x %x", psa, nDim, plUbound));
    391391
    392   if(! validArg(psa))
    393     return E_INVALIDARG;
    394 
    395   if(nDim > psa->cDims)
     392  if(! validArg(psa))   
     393    return E_INVALIDARG;
     394
     395  if(nDim > psa->cDims) 
    396396    return DISP_E_BADINDEX;
    397397
    398   *plUbound = psa->rgsabound[nDim-1].lLbound +
     398  *plUbound = psa->rgsabound[nDim-1].lLbound + 
    399399              psa->rgsabound[nDim-1].cElements - 1;
    400400
     
    403403
    404404/*************************************************************************
    405  *      SafeArrayGetLBound
    406  * Return the LO bound for a given array dimension
     405 *              SafeArrayGetLBound
     406 * Return the LO bound for a given array dimension 
    407407 */
    408408HRESULT WINAPI SafeArrayGetLBound(
    409409  SAFEARRAY *psa,
    410   UINT    nDim,
     410  UINT    nDim, 
    411411  LONG      *plLbound)
    412412{
    413   if(! validArg(psa))
    414     return E_INVALIDARG;
    415 
    416   if(nDim > psa->cDims)
     413  if(! validArg(psa))   
     414    return E_INVALIDARG;
     415
     416  if(nDim > psa->cDims) 
    417417    return DISP_E_BADINDEX;
    418418
     
    422422
    423423/*************************************************************************
    424  *      SafeArrayGetDim
     424 *              SafeArrayGetDim
    425425 * returns the number of dimension in the array
    426426 */
    427427UINT WINAPI SafeArrayGetDim(
    428428  SAFEARRAY * psa)
    429 {
     429{ 
    430430  /*
    431431   * A quick test in Windows shows that the behavior here for an invalid
    432432   * pointer is to return 0.
    433433   */
    434   if(! validArg(psa))
     434  if(! validArg(psa)) 
    435435    return 0;
    436436
     
    439439
    440440/*************************************************************************
    441  *      SafeArrayGetElemsize
     441 *              SafeArrayGetElemsize
    442442 * Return the size of the element in the array
    443443 */
    444444UINT WINAPI SafeArrayGetElemsize(
    445445  SAFEARRAY * psa)
    446 {
     446{ 
    447447  /*
    448448   * A quick test in Windows shows that the behavior here for an invalid
    449449   * pointer is to return 0.
    450450   */
    451   if(! validArg(psa))
     451  if(! validArg(psa)) 
    452452    return 0;
    453453
     
    456456
    457457/*************************************************************************
    458  *      SafeArrayAccessData
    459  * increment the access count and return the data
     458 *              SafeArrayAccessData
     459 * increment the access count and return the data 
    460460 */
    461461HRESULT WINAPI SafeArrayAccessData(
    462   SAFEARRAY *psa,
     462  SAFEARRAY *psa, 
    463463  void      **ppvData)
    464 {
     464{ 
    465465  HRESULT hRes;
    466466
    467   if(! validArg(psa))
     467  if(! validArg(psa)) 
    468468    return E_INVALIDARG;
    469469
     
    471471
    472472  switch (hRes) {
    473     case S_OK:
     473    case S_OK: 
    474474      (*ppvData) = psa->pvData;
    475475      break;
     
    478478      return E_INVALIDARG;
    479479  }
    480 
     480 
    481481  return S_OK;
    482482}
     
    484484
    485485/*************************************************************************
    486  *      SafeArrayUnaccessData
     486 *              SafeArrayUnaccessData
    487487 * Decrement the access count
    488488 */
    489489HRESULT WINAPI SafeArrayUnaccessData(
    490490  SAFEARRAY * psa)
    491 {
    492   if(! validArg(psa))
     491{ 
     492  if(! validArg(psa)) 
    493493    return E_INVALIDARG;
    494494
     
    496496}
    497497
    498 /************************************************************************
    499  *      SafeArrayPtrOfIndex
     498/************************************************************************ 
     499 *              SafeArrayPtrOfIndex
    500500 * Return a pointer to the element at rgIndices
    501501 */
    502502HRESULT WINAPI SafeArrayPtrOfIndex(
    503   SAFEARRAY *psa,
    504   LONG      *rgIndices,
     503  SAFEARRAY *psa, 
     504  LONG      *rgIndices, 
    505505  void      **ppvData)
    506 {
    507   ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to
     506{ 
     507  ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to 
    508508                                         the desired one... */
    509509
    510   if(! validArg(psa))
    511     return E_INVALIDARG;
    512 
    513   if(! validCoordinate(rgIndices, psa))
     510  if(! validArg(psa))                   
     511    return E_INVALIDARG;
     512
     513  if(! validCoordinate(rgIndices, psa)) 
    514514    return DISP_E_BADINDEX;
    515515
    516516  /* Figure out the number of items to skip */
    517517  stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    518 
     518 
    519519  *ppvData = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    520520
     
    522522}
    523523
    524 /************************************************************************
    525  *      SafeArrayDestroyData
     524/************************************************************************ 
     525 *              SafeArrayDestroyData
    526526 * Frees the memory data bloc
    527527 */
    528528HRESULT WINAPI SafeArrayDestroyData(
    529529  SAFEARRAY *psa)
    530 {
     530{ 
    531531  HRESULT  hRes;
    532532  ULONG    ulWholeArraySize; /* count spot in array  */
     
    535535  BSTR   bstr;
    536536
    537   if(! validArg(psa))
    538     return E_INVALIDARG;
    539 
    540   if(psa->cLocks > 0)
     537  if(! validArg(psa)) 
     538    return E_INVALIDARG;
     539
     540  if(psa->cLocks > 0) 
    541541    return DISP_E_ARRAYISLOCKED;
    542542
     
    546546
    547547    for(ulDataIter=0; ulDataIter < ulWholeArraySize; ulDataIter++) {
    548       punk = *(IUnknown**)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));
    549 
    550       if( punk != NULL)
     548      punk = *(IUnknown**)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));       
     549
     550      if( punk != NULL) 
    551551        IUnknown_Release(punk);
    552552    }
     
    557557      bstr = *(BSTR*)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));
    558558
    559       if( bstr != NULL)
     559      if( bstr != NULL) 
    560560        SysFreeString( bstr );
    561561    }
    562562  }
    563 
    564   /* check if this array is a Vector, in which case do not free the data
     563     
     564  /* check if this array is a Vector, in which case do not free the data 
    565565     block since it has been allocated by AllocDescriptor and therefore
    566566     deserve to be freed by DestroyDescriptor */
     
    573573    psa->pvData = NULL;
    574574  }
    575 
     575 
    576576  return S_OK;
    577577}
    578578
    579 /************************************************************************
    580  *      SafeArrayCopyData
     579/************************************************************************ 
     580 *              SafeArrayCopyData
    581581 * Copy the psaSource's data block into psaTarget if dimension and size
    582582 * permits it.
     
    585585  SAFEARRAY *psaSource,
    586586  SAFEARRAY **psaTarget)
    587 {
     587{ 
    588588  USHORT   cDimCount;        /* looper */
    589589  LONG     lDelta;           /* looper */
    590   IUnknown *punk;
     590  IUnknown *punk;   
    591591  ULONG    ulWholeArraySize; /* Number of item in SA */
    592592  BSTR   bstr;
    593593
    594   if(! (validArg(psaSource) && validArg(*psaTarget)) )
     594  if(! (validArg(psaSource) && validArg(*psaTarget)) ) 
    595595    return E_INVALIDARG;
    596596
     
    598598    return E_INVALIDARG;
    599599
    600   ulWholeArraySize = getArraySize(psaSource);
     600  ulWholeArraySize = getArraySize(psaSource); 
    601601
    602602  /* The two arrays boundaries must be of same lenght */
    603603  for(cDimCount=0;cDimCount < psaSource->cDims; cDimCount++)
    604     if( psaSource->rgsabound[cDimCount].cElements !=
     604    if( psaSource->rgsabound[cDimCount].cElements != 
    605605      (*psaTarget)->rgsabound[cDimCount].cElements)
    606606      return E_INVALIDARG;
    607607
    608   if( isPointer((*psaTarget)->fFeatures) ) {         /* the target contains ptr
     608  if( isPointer((*psaTarget)->fFeatures) ) {         /* the target contains ptr 
    609609                                                        that must be released */
    610610    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
     
    612612        ((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements));
    613613
    614       if( punk != NULL)
     614      if( punk != NULL) 
    615615        IUnknown_Release(punk);
    616616    }
    617617
    618618  } else if( (*psaTarget)->fFeatures & FADF_BSTR) {  /* the target contain BSTR
    619                                                         that must be freed */
     619                                                        that must be freed */ 
    620620    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
    621       bstr =
     621      bstr = 
    622622        *(BSTR*)((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements));
    623623
    624       if( bstr != NULL)
     624      if( bstr != NULL) 
    625625        SysFreeString( bstr );
    626626    }
     
    630630}
    631631
    632 /************************************************************************
    633  *      SafeArrayDestroy
     632/************************************************************************ 
     633 *              SafeArrayDestroy
    634634 * Deallocates all memory reserved for the SafeArray
    635635 */
    636636HRESULT WINAPI SafeArrayDestroy(
    637637  SAFEARRAY * psa)
    638 {
     638{ 
    639639  HRESULT hRes;
    640640
    641   if(! validArg(psa))
    642     return E_INVALIDARG;
    643 
    644   if(psa->cLocks > 0)
     641  if(! validArg(psa)) 
     642    return E_INVALIDARG;
     643
     644  if(psa->cLocks > 0) 
    645645    return DISP_E_ARRAYISLOCKED;
    646646
     
    652652}
    653653
    654 /************************************************************************
    655  *      SafeArrayCopy
     654/************************************************************************ 
     655 *              SafeArrayCopy
    656656 * Make a dupplicate of a SafeArray
    657657 */
    658658HRESULT WINAPI SafeArrayCopy(
    659   SAFEARRAY *psa,
     659  SAFEARRAY *psa, 
    660660  SAFEARRAY **ppsaOut)
    661 {
     661{ 
    662662  HRESULT hRes;
    663663  DWORD   dAllocSize;
    664664  ULONG   ulWholeArraySize; /* size of the thing */
    665665
    666   if(! validArg(psa))
     666  if(! validArg(psa)) 
    667667    return E_INVALIDARG;
    668668
     
    670670
    671671    /* Duplicate the SAFEARRAY struc */
    672     memcpy(*ppsaOut, psa,
     672    memcpy(*ppsaOut, psa, 
    673673            sizeof(*psa)+(sizeof(*(psa->rgsabound))*(psa->cDims-1)));
    674674
     
    677677    /* make sure the new safe array doesn't have the FADF_CREATEVECTOR flag,
    678678       because the data has not been allocated with the descriptor. */
    679     (*ppsaOut)->fFeatures &= ~FADF_CREATEVECTOR;
    680 
    681     /* Get the allocated memory size for source and allocate it for target */
     679    (*ppsaOut)->fFeatures &= ~FADF_CREATEVECTOR; 
     680 
     681    /* Get the allocated memory size for source and allocate it for target */ 
    682682    ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
    683683    dAllocSize = ulWholeArraySize*psa->cbElements;
    684684
    685     (*ppsaOut)->pvData =
     685    (*ppsaOut)->pvData = 
    686686      HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dAllocSize);
    687687    if( (*ppsaOut)->pvData != NULL) {   /* HeapAlloc succeed */
     
    693693        return hRes;
    694694      }
    695 
     695       
    696696    } else { /* failed to allocate or dupplicate... */
    697697      SafeArrayDestroyDescriptor(*ppsaOut);
     
    705705}
    706706
    707 /************************************************************************
    708  *      SafeArrayCreateVector
    709  * Creates a one dimension safearray where the data is next to the
     707/************************************************************************ 
     708 *              SafeArrayCreateVector
     709 * Creates a one dimension safearray where the data is next to the 
    710710 * SAFEARRAY structure.
    711711 */
    712712SAFEARRAY* WINAPI SafeArrayCreateVector(
    713   VARTYPE vt,
    714   LONG    lLbound,
    715   ULONG   cElements)
    716 {
     713  VARTYPE vt, 
     714  LONG    lLbound, 
     715  ULONG   cElements) 
     716{ 
    717717  SAFEARRAY *psa;
    718718
     
    723723
    724724  /* Allocate memory for the array descriptor and data contiguously  */
    725   if( FAILED( psa = HeapAlloc( GetProcessHeap(),
    726                       HEAP_ZERO_MEMORY,
     725  if( FAILED( psa = HeapAlloc( GetProcessHeap(), 
     726                      HEAP_ZERO_MEMORY, 
    727727                      (sizeof(*psa) + (VARTYPE_SIZE[vt] * cElements))))) {
    728728    return NULL;
    729729  }
    730 
    731   /* setup data members... */
     730                                                                               
     731  /* setup data members... */ 
    732732  psa->cDims      = 1; /* always and forever */
    733733  psa->fFeatures  = getFeatures(vt) | FADF_CREATEVECTOR;  /* undocumented flag used by Microsoft */
     
    739739  psa->rgsabound[0].lLbound   = lLbound;
    740740
    741   return(psa);
    742 }
    743 
    744 /************************************************************************
    745  *      SafeArrayRedim
     741  return(psa);                           
     742} 
     743
     744/************************************************************************ 
     745 *              SafeArrayRedim
    746746 * Changes the caracteristics of the last dimension of the SafeArray
    747747 */
    748748HRESULT WINAPI SafeArrayRedim(
    749   SAFEARRAY      *psa,
     749  SAFEARRAY      *psa, 
    750750  SAFEARRAYBOUND *psaboundNew)
    751 {
     751{ 
    752752  LONG   lDelta;  /* hold difference in size */
    753753  USHORT cDims=1; /* dims counter */
    754754
    755   if( !validArg(psa) )
    756     return E_INVALIDARG;
    757 
    758   if( psa->cLocks > 0 )
     755  if( !validArg(psa) )                   
     756    return E_INVALIDARG;
     757
     758  if( psa->cLocks > 0 )                   
    759759    return DISP_E_ARRAYISLOCKED;
    760760
    761   if( psa->fFeatures & FADF_FIXEDSIZE )
    762     return E_INVALIDARG;
    763 
    764   if( SafeArrayLock(psa)==E_UNEXPECTED )
     761  if( psa->fFeatures & FADF_FIXEDSIZE )   
     762    return E_INVALIDARG;
     763
     764  if( SafeArrayLock(psa)==E_UNEXPECTED ) 
    765765    return E_UNEXPECTED;/* UNDOC error condition */
    766766
     
    774774
    775775  } else /* need to enlarge (lDelta +) reduce (lDelta -) */
    776     if(! resizeSafeArray(psa, lDelta))
     776    if(! resizeSafeArray(psa, lDelta)) 
    777777      return E_UNEXPECTED; /* UNDOC error condition */
    778778
    779   /* the only modifyable dimension sits in [0] as the dimensions were reversed
     779  /* the only modifyable dimension sits in [0] as the dimensions were reversed 
    780780     at array creation time... */
    781781  psa->rgsabound[0].cElements = psaboundNew->cElements;
     
    789789 ************************************************************************/
    790790
    791 /************************************************************************
     791/************************************************************************ 
    792792 * Used to validate the SAFEARRAY type of arg
    793793 */
    794794static BOOL validArg(
    795   SAFEARRAY *psa)
     795  SAFEARRAY *psa) 
    796796{
    797797  SAFEARRAYBOUND *sab;
     
    822822}
    823823
    824 /************************************************************************
     824/************************************************************************ 
    825825 * Used to reallocate memory
    826826 */
    827827static BOOL resizeSafeArray(
    828   SAFEARRAY *psa,
     828  SAFEARRAY *psa, 
    829829  LONG lDelta)
    830830{
    831831  ULONG    ulWholeArraySize;  /* use as multiplicator */
    832   PVOID    pvNewBlock = NULL;
     832  PVOID    pvNewBlock = NULL; 
    833833  IUnknown *punk;
    834834  BSTR   bstr;
     
    838838  if(lDelta < 0) {                    /* array needs to be shorthen  */
    839839    if( isPointer(psa->fFeatures))    /* ptr that need to be released */
    840         for(;lDelta < 0; lDelta++) {
    841           punk = *(IUnknown**)
     840            for(;lDelta < 0; lDelta++) {
     841              punk = *(IUnknown**)
    842842          ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements));
    843 
     843       
    844844        if( punk != NULL )
    845845          IUnknown_Release(punk);
    846         }
     846            }
    847847
    848848    else if(psa->fFeatures & FADF_BSTR)  /* BSTR that need to be freed */
    849         for(;lDelta < 0; lDelta++) {
     849            for(;lDelta < 0; lDelta++) {
    850850        bstr = *(BSTR*)
    851851          ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements));
     
    858858  if (!(psa->fFeatures & FADF_CREATEVECTOR))
    859859  {
    860     /* Ok now, if we are enlarging the array, we *MUST* move the whole block
     860    /* Ok now, if we are enlarging the array, we *MUST* move the whole block 
    861861       pointed to by pvData.   If we are shorthening the array, this move is
    862        optional but we do it anyway becuase the benefit is that we are
     862       optional but we do it anyway becuase the benefit is that we are 
    863863       releasing to the system the unused memory */
    864864
    865     if((pvNewBlock = HeapReAlloc(GetProcessHeap(), 0, psa->pvData,
    866        (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL)
     865    if((pvNewBlock = HeapReAlloc(GetProcessHeap(), 0, psa->pvData, 
     866       (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL) 
    867867        return FALSE; /* TODO If we get here it means:
    868868                         SHRINK situation :  we've deleted the undesired
     
    873873  else
    874874  {
    875     /* Allocate a new block, because the previous data has been allocated with
     875    /* Allocate a new block, because the previous data has been allocated with 
    876876       the descriptor in SafeArrayCreateVector function. */
    877877
    878878    if((pvNewBlock = HeapAlloc(GetProcessHeap(), 0,
    879        ulWholeArraySize * psa->cbElements)) == NULL)
     879       ulWholeArraySize * psa->cbElements)) == NULL) 
    880880        return FALSE;
    881881
     
    887887}
    888888
    889 /************************************************************************
    890  * Used to set the fFeatures data member of the SAFEARRAY structure.
     889/************************************************************************ 
     890 * Used to set the fFeatures data member of the SAFEARRAY structure. 
    891891 */
    892892static INT getFeatures(
    893   VARTYPE vt)
     893  VARTYPE vt) 
    894894{
    895895  switch(vt) {
     
    901901}
    902902
    903 /************************************************************************
    904  * Used to figure out if the fFeatures data member of the SAFEARRAY
    905  * structure contain any information about the type of data stored...
     903/************************************************************************ 
     904 * Used to figure out if the fFeatures data member of the SAFEARRAY 
     905 * structure contain any information about the type of data stored... 
    906906 */
    907907static BOOL isPointer(
    908   USHORT feature)
     908  USHORT feature) 
    909909{
    910910  switch(feature) {
     
    915915}
    916916
    917 /************************************************************************
    918  * Used to calculate the displacement when accessing or modifying
     917/************************************************************************ 
     918 * Used to calculate the displacement when accessing or modifying 
    919919 * safearray data set.
    920920 *
     
    926926 */
    927927static ULONG calcDisplacement(
    928   LONG           *coor,
    929   SAFEARRAYBOUND *mat,
    930   LONG           dim)
     928  LONG           *coor, 
     929  SAFEARRAYBOUND *mat, 
     930  LONG           dim) 
    931931{
    932932  ULONG res = 0;
    933933  LONG  iterDim;
    934934
    935   for(iterDim=0; iterDim<dim; iterDim++)
     935  for(iterDim=0; iterDim<dim; iterDim++) 
    936936    /* the -mat[dim] bring coor[dim] relative to 0 for calculation */
    937     res += ((coor[iterDim]-mat[iterDim].lLbound) *
     937    res += ((coor[iterDim]-mat[iterDim].lLbound) * 
    938938            endOfDim(coor, mat, iterDim+1, dim));
    939939
     
    942942}
    943943
    944 /************************************************************************
    945  * Recursivity agent for calcDisplacement method.  Used within Put and
     944/************************************************************************ 
     945 * Recursivity agent for calcDisplacement method.  Used within Put and 
    946946 * Get methods.
    947947 */
    948948static INT endOfDim(
    949   LONG           *coor,
    950   SAFEARRAYBOUND *mat,
    951   LONG           dim,
    952   LONG           realDim)
    953 {
    954   if(dim==realDim)
     949  LONG           *coor, 
     950  SAFEARRAYBOUND *mat, 
     951  LONG           dim, 
     952  LONG           realDim) 
     953{
     954  if(dim==realDim) 
    955955    return 1;
    956   else
     956  else 
    957957    return (endOfDim(coor, mat, dim+1, realDim) * mat[dim].cElements);
    958958}
    959959
    960960
    961 /************************************************************************
    962  * Method used to validate the coordinate received in Put and Get
     961/************************************************************************ 
     962 * Method used to validate the coordinate received in Put and Get 
    963963 * methods.
    964964 */
    965965static BOOL validCoordinate(
    966   LONG      *coor,
    967   SAFEARRAY *psa)
     966  LONG      *coor, 
     967  SAFEARRAY *psa) 
    968968{
    969969  INT   iter=0;
     
    977977    if((hRes = SafeArrayGetUBound(psa, iter, &lUBound)) != S_OK)
    978978      return FALSE;
    979 
    980     if(lLBound == lUBound)
    981       return FALSE;
    982 
     979 
     980    if(lLBound == lUBound) 
     981      return FALSE; 
     982   
    983983    if((coor[iter] >= lLBound) && (coor[iter] <= lUBound))
    984984      return TRUE;
     
    987987  }
    988988  return FALSE;
    989 }
    990 
    991 /************************************************************************
     989} 
     990
     991/************************************************************************ 
    992992 * Method used to calculate the number of cells of the SA
    993993 */
    994994static ULONG getArraySize(
    995   SAFEARRAY *psa)
    996 {
    997   USHORT cCount;
     995  SAFEARRAY *psa) 
     996{
     997  USHORT cCount; 
    998998  ULONG  ulWholeArraySize = 1;
    999999
     
    10011001    ulWholeArraySize *= psa->rgsabound[cCount].cElements;
    10021002
    1003   return ulWholeArraySize;
    1004 }
    1005 
    1006 
    1007 /************************************************************************
     1003  return ulWholeArraySize; 
     1004}
     1005
     1006
     1007/************************************************************************ 
    10081008 * Method used to handle data space dupplication for Copy32 and CopyData32
    10091009 */
    10101010static HRESULT duplicateData(
    1011   SAFEARRAY *psa,
    1012   SAFEARRAY **ppsaOut)
     1011  SAFEARRAY *psa, 
     1012  SAFEARRAY **ppsaOut) 
    10131013{
    10141014  ULONG    ulWholeArraySize; /* size of the thing */
     
    10181018
    10191019  ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
    1020 
     1020 
    10211021  SafeArrayLock(*ppsaOut);
    10221022
    1023   if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment
     1023  if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment 
    10241024                                        object's reference count */
    10251025
     
    10321032
    10331033    /* Copy the source array data into target array */
    1034     memcpy((*ppsaOut)->pvData, psa->pvData,
     1034    memcpy((*ppsaOut)->pvData, psa->pvData, 
    10351035      ulWholeArraySize*psa->cbElements);
    10361036
    1037   } else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate
     1037  } else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate 
    10381038                                               the BSTR in the new array */
    10391039
     
    10461046      }
    10471047
    1048       *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) =
     1048      *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) = 
    10491049        pbstrReAllocStr;
    10501050    }
     
    10521052  } else { /* Simply copy the source array data into target array */
    10531053
    1054     memcpy((*ppsaOut)->pvData, psa->pvData,
     1054    memcpy((*ppsaOut)->pvData, psa->pvData, 
    10551055      ulWholeArraySize*psa->cbElements);
    10561056  }
     
    10621062
    10631063
    1064 /************************************************************************
    1065  *      SafeArrayGetVarType
     1064/************************************************************************ 
     1065 *              SafeArrayGetVarType
    10661066 * Returns the VARTYPE stored in the given safearray
    10671067 */
     
    10991099    hr = S_OK;
    11001100  }
    1101 
     1101 
    11021102  TRACE("HRESULT = %08lx", hr);
    11031103  return hr;
  • trunk/src/oleaut32/typelib.c

    r6689 r6711  
    23942394}
    23952395
    2396 static void SLTG_ProcessCoClass(char *pBlk, ITypeInfoImpl *pTI,
    2397                                 char *pNameTable)
     2396static SLTG_TypeInfoTail *SLTG_ProcessCoClass(char *pBlk, ITypeInfoImpl *pTI,
     2397                                              char *pNameTable)
    23982398{
    23992399    SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk;
     
    24152415    }
    24162416
    2417     return;
    2418 }
    2419 
    2420 
    2421 static void SLTG_ProcessInterface(char *pBlk, ITypeInfoImpl *pTI,
    2422                                   char *pNameTable)
     2417    return (SLTG_TypeInfoTail*)(pFirstItem + pMemHeader->cbExtra);
     2418}
     2419
     2420
     2421static SLTG_TypeInfoTail *SLTG_ProcessInterface(char *pBlk, ITypeInfoImpl *pTI,
     2422                                                char *pNameTable)
    24232423{
    24242424    SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk;
     
    24512451           pFunc->magic != SLTG_FUNCTION_WITH_FLAGS_MAGIC) {
    24522452            FIXME("func magic = %02x\n", pFunc->magic);
    2453             return;
     2453            return NULL;
    24542454        }
    24552455        *ppFuncDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
     
    25302530    pTI->TypeAttr.cFuncs = num;
    25312531    dump_TLBFuncDesc(pTI->funclist);
    2532 }
    2533 
    2534 static void SLTG_ProcessRecord(char *pBlk, ITypeInfoImpl *pTI, char *pNameTable)
     2532    return (SLTG_TypeInfoTail*)(pFirstItem + pMemHeader->cbExtra);
     2533}
     2534
     2535static SLTG_TypeInfoTail *SLTG_ProcessRecord(char *pBlk, ITypeInfoImpl *pTI,
     2536                                             char *pNameTable)
    25352537{
    25362538  SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk;
     
    25502552      if(pItem->magic != SLTG_RECORD_MAGIC) {
    25512553          FIXME("record magic = %02x\n", pItem->magic);
    2552           return;
     2554          return NULL;
    25532555      }
    25542556      *ppVarDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
     
    25792581  }
    25802582  pTI->TypeAttr.cVars = num;
    2581 }
    2582 
    2583 static void SLTG_ProcessEnum(char *pBlk, ITypeInfoImpl *pTI, char *pNameTable)
     2583  return (SLTG_TypeInfoTail*)(pFirstItem + pMemHeader->cbExtra);
     2584}
     2585
     2586static SLTG_TypeInfoTail *SLTG_ProcessEnum(char *pBlk, ITypeInfoImpl *pTI,
     2587                                           char *pNameTable)
    25842588{
    25852589  SLTG_TypeInfoHeader *pTIHeader = (SLTG_TypeInfoHeader*)pBlk;
     
    26162620  }
    26172621  pTI->TypeAttr.cVars = num;
     2622  return (SLTG_TypeInfoTail*)(pFirstItem + pMemHeader->cbExtra);
    26182623}
    26192624
     
    28012806
    28022807      SLTG_TypeInfoHeader *pTIHeader;
     2808      SLTG_TypeInfoTail *pTITail;
    28032809
    28042810      if(strcmp(pBlkEntry[order].index_string + (char*)pMagic,
     
    28412847      switch(pTIHeader->typekind) {
    28422848      case TKIND_ENUM:
    2843         SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable);
     2849        pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable);
    28442850        break;
    28452851
    28462852      case TKIND_RECORD:
    2847         SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable);
     2853        pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable);
    28482854        break;
    28492855
    28502856      case TKIND_INTERFACE:
    2851         SLTG_ProcessInterface(pBlk, *ppTypeInfoImpl, pNameTable);
     2857        pTITail = SLTG_ProcessInterface(pBlk, *ppTypeInfoImpl, pNameTable);
    28522858        break;
    28532859
    28542860      case TKIND_COCLASS:
    2855         SLTG_ProcessCoClass(pBlk, *ppTypeInfoImpl, pNameTable);
     2861        pTITail = SLTG_ProcessCoClass(pBlk, *ppTypeInfoImpl, pNameTable);
    28562862        break;
    28572863
    28582864      default:
    28592865        FIXME("Not processing typekind %d\n", pTIHeader->typekind);
     2866        pTITail = NULL;
    28602867        break;
    28612868
    28622869      }
    28632870
     2871      if(pTITail) { /* could get cFuncs, cVars and cImplTypes from here
     2872                       but we've already set those */
     2873          (*ppTypeInfoImpl)->TypeAttr.cbAlignment = pTITail->cbAlignment;
     2874          (*ppTypeInfoImpl)->TypeAttr.cbSizeInstance = pTITail->cbSizeInstance;
     2875          (*ppTypeInfoImpl)->TypeAttr.cbSizeVft = pTITail->cbSizeVft;
     2876      }
    28642877      ppTypeInfoImpl = &((*ppTypeInfoImpl)->next);
    28652878#ifdef __WIN32OS2__
     
    30983111    ICOM_THIS( ITypeLibImpl, iface);
    30993112    TRACE("(%p)\n",This);
    3100     /* FIXME: must do a copy here */
    3101     *ppTLibAttr=&This->LibAttr;
     3113    *ppTLibAttr = HeapAlloc(GetProcessHeap(), 0, sizeof(**ppTLibAttr));
     3114    memcpy(*ppTLibAttr, &This->LibAttr, sizeof(**ppTLibAttr));
    31023115    return S_OK;
    31033116}
     
    32943307    ICOM_THIS( ITypeLibImpl, iface);
    32953308    TRACE("freeing (%p)\n",This);
    3296     /* nothing to do */
     3309    HeapFree(GetProcessHeap(),0,pTLibAttr);
     3310
    32973311}
    32983312
  • trunk/src/oleaut32/typelib.h

    r6689 r6711  
    2323
    2424/* There are two known file formats, those created with ICreateTypeLib
    25  * have the signature "SLGT" as their first four bytes, while those created
     25 * have the signature "SLTG" as their first four bytes, while those created
    2626 * with ICreateTypeLib2 have "MSFT".
    2727 */
     
    377377
    378378typedef struct {
     379/*00*/  WORD cFuncs;
     380/*02*/  WORD cVars;
     381/*04*/  WORD cImplTypes;
     382/*06*/  WORD res06;
     383/*08*/  WORD res08;
     384/*0a*/  WORD res0a;
     385/*0c*/  WORD res0c;
     386/*0e*/  WORD res0e;
     387/*10*/  WORD res10;
     388/*12*/  WORD res12;
     389/*14*/  WORD res14;
     390/*16*/  WORD res16;
     391/*18*/  WORD res18;
     392/*1a*/  WORD res1a;
     393/*1c*/  WORD res1c;
     394/*1e*/  WORD res1e;
     395/*20*/  WORD cbSizeInstance;
     396/*22*/  WORD cbAlignment;
     397/*24*/  WORD res24;
     398/*26*/  WORD res26;
     399/*28*/  WORD cbSizeVft;
     400/*2a*/  WORD res2a;
     401/*2c*/  WORD res2c;
     402/*2e*/  WORD res2e;
     403/*30*/  WORD res30;
     404/*32*/  WORD res32;
     405/*34*/  WORD res34;
     406} SLTG_TypeInfoTail;
     407
     408typedef struct {
    379409/*00*/ WORD res00; /* 0x0001 sometimes 0x0003 ?? */
    380410/*02*/ WORD res02; /* 0xffff */
  • trunk/src/oleaut32/variant.c

    r6689 r6711  
    2828
    2929#include "config.h"
    30 
     30 
    3131#include <string.h>
    3232#include <stdlib.h>
     
    106106
    107107/******************************************************************************
    108  *     DateTimeStringToTm   [INTERNAL]
     108 *         DateTimeStringToTm   [INTERNAL]
    109109 *
    110110 * Converts a string representation of a date and/or time to a tm structure.
     
    122122static BOOL DateTimeStringToTm( OLECHAR* strIn, DWORD dwFlags, struct tm* pTm )
    123123{
    124     BOOL res = FALSE;
    125     double      fsec;
    126     int         tzp;
    127     int         dtype;
    128     int         nf;
    129     char       *field[MAXDATEFIELDS];
    130     int         ftype[MAXDATEFIELDS];
    131     char        lowstr[MAXDATELEN + 1];
    132     char* strDateTime = NULL;
    133 
    134     /* Convert the string to ASCII since this is the only format
    135     * postgesql can handle.
    136     */
    137     strDateTime = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    138 
    139     if( strDateTime != NULL )
    140     {
    141         /* Make sure we don't go over the maximum length
    142         * accepted by postgesql.
    143         */
    144         if( strlen( strDateTime ) <= MAXDATELEN )
    145         {
    146             if( ParseDateTime( strDateTime, lowstr, field, ftype, MAXDATEFIELDS, &nf) == 0 )
    147             {
    148                 if( dwFlags & VAR_DATEVALUEONLY )
    149                 {
    150                     /* Get the date information.
    151                     * It returns 0 if date information was
    152                     * present and 1 if only time information was present.
    153                     * -1 if an error occures.
    154                     */
    155                     if( DecodeDateTime(field, ftype, nf, &dtype, pTm, &fsec, &tzp) == 0 )
    156                     {
    157                         /* Eliminate the time information since we
    158                         * were asked to get date information only.
    159                         */
    160                         pTm->tm_sec = 0;
    161                         pTm->tm_min = 0;
    162                         pTm->tm_hour = 0;
    163                         res = TRUE;
    164                     }
    165                 }
    166                 if( dwFlags & VAR_TIMEVALUEONLY )
    167                 {
    168                     /* Get time information only.
    169                     */
    170                     if( DecodeTimeOnly(field, ftype, nf, &dtype, pTm, &fsec) == 0 )
    171                     {
    172                         res = TRUE;
    173                     }
    174                 }
    175                 else
    176                 {
    177                     /* Get both date and time information.
    178                     * It returns 0 if date information was
    179                     * present and 1 if only time information was present.
    180                     * -1 if an error occures.
    181                     */
    182                     if( DecodeDateTime(field, ftype, nf, &dtype, pTm, &fsec, &tzp) != -1 )
    183                     {
    184                         res = TRUE;
    185                     }
    186                 }
    187             }
    188         }
    189         HeapFree( GetProcessHeap(), 0, strDateTime );
    190     }
    191 
    192     return res;
    193 }
    194 
    195 
    196 
    197 
    198 
    199 
    200 /******************************************************************************
    201  *     TmToDATE     [INTERNAL]
     124        BOOL res = FALSE;
     125        double          fsec;
     126        int             tzp;
     127        int             dtype;
     128        int             nf;
     129        char       *field[MAXDATEFIELDS];
     130        int             ftype[MAXDATEFIELDS];
     131        char            lowstr[MAXDATELEN + 1];
     132        char* strDateTime = NULL;
     133
     134        /* Convert the string to ASCII since this is the only format
     135        * postgesql can handle.
     136        */
     137        strDateTime = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     138
     139        if( strDateTime != NULL )
     140        {
     141                /* Make sure we don't go over the maximum length
     142                * accepted by postgesql.
     143                */
     144                if( strlen( strDateTime ) <= MAXDATELEN )
     145                {
     146                        if( ParseDateTime( strDateTime, lowstr, field, ftype, MAXDATEFIELDS, &nf) == 0 )
     147                        {
     148                                if( dwFlags & VAR_DATEVALUEONLY )
     149                                {
     150                                        /* Get the date information.
     151                                        * It returns 0 if date information was
     152                                        * present and 1 if only time information was present.
     153                                        * -1 if an error occures.
     154                                        */
     155                                        if( DecodeDateTime(field, ftype, nf, &dtype, pTm, &fsec, &tzp) == 0 )
     156                                        {
     157                                                /* Eliminate the time information since we
     158                                                * were asked to get date information only.
     159                                                */
     160                                                pTm->tm_sec = 0;
     161                                                pTm->tm_min = 0;
     162                                                pTm->tm_hour = 0;
     163                                                res = TRUE;
     164                                        }
     165                                }
     166                                if( dwFlags & VAR_TIMEVALUEONLY )
     167                                {
     168                                        /* Get time information only.
     169                                        */
     170                                        if( DecodeTimeOnly(field, ftype, nf, &dtype, pTm, &fsec) == 0 )
     171                                        {
     172                                                res = TRUE;
     173                                        }
     174                                }
     175                                else
     176                                {
     177                                        /* Get both date and time information.
     178                                        * It returns 0 if date information was
     179                                        * present and 1 if only time information was present.
     180                                        * -1 if an error occures.
     181                                        */
     182                                        if( DecodeDateTime(field, ftype, nf, &dtype, pTm, &fsec, &tzp) != -1 )
     183                                        {
     184                                                res = TRUE;
     185                                        }
     186                                }
     187                        }
     188                }
     189                HeapFree( GetProcessHeap(), 0, strDateTime );
     190        }
     191
     192        return res;
     193}
     194
     195
     196
     197
     198
     199
     200/******************************************************************************
     201 *         TmToDATE     [INTERNAL]
    202202 *
    203203 * The date is implemented using an 8 byte floating-point number.
     
    216216 * The tm structure is as follows:
    217217 * struct tm {
    218  *        int tm_sec;      seconds after the minute - [0,59]
    219  *        int tm_min;      minutes after the hour - [0,59]
    220  *        int tm_hour;     hours since midnight - [0,23]
    221  *        int tm_mday;     day of the month - [1,31]
    222  *        int tm_mon;      months since January - [0,11]
    223  *        int tm_year;     years
    224  *        int tm_wday;     days since Sunday - [0,6]
    225  *        int tm_yday;     days since January 1 - [0,365]
    226  *        int tm_isdst;    daylight savings time flag
    227  *        };
     218 *                int tm_sec;      seconds after the minute - [0,59]
     219 *                int tm_min;      minutes after the hour - [0,59]
     220 *                int tm_hour;     hours since midnight - [0,23]
     221 *                int tm_mday;     day of the month - [1,31]
     222 *                int tm_mon;      months since January - [0,11]
     223 *                int tm_year;     years
     224 *                int tm_wday;     days since Sunday - [0,6]
     225 *                int tm_yday;     days since January 1 - [0,365]
     226 *                int tm_isdst;    daylight savings time flag
     227 *                };
    228228 *
    229229 * Note: This function does not use the tm_wday, tm_yday, tm_wday,
     
    235235static BOOL TmToDATE( struct tm* pTm, DATE *pDateOut )
    236236{
    237     if( (pTm->tm_year - 1900) >= 0 )
    238     {
    239         int leapYear = 0;
    240 
    241         /* Start at 1. This is the way DATE is defined.
    242         * January 1, 1900 at Midnight is 1.00.
    243         * January 1, 1900 at 6AM is 1.25.
    244         * and so on.
    245         */
    246         *pDateOut = 1;
    247 
    248         /* Add the number of days corresponding to
    249         * tm_year.
    250         */
    251         *pDateOut += (pTm->tm_year - 1900) * 365;
    252 
    253         /* Add the leap days in the previous years between now and 1900.
    254         * Note a leap year is one that is a multiple of 4
    255         * but not of a 100.  Except if it is a multiple of
    256         * 400 then it is a leap year.
    257         */
    258         *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
    259         *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
    260         *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
    261 
    262         /* Set the leap year flag if the
    263         * current year specified by tm_year is a
    264         * leap year. This will be used to add a day
    265         * to the day count.
    266         */
    267         if( isleap( pTm->tm_year ) )
    268             leapYear = 1;
    269 
    270         /* Add the number of days corresponding to
    271         * the month.
    272         */
    273         switch( pTm->tm_mon )
    274         {
    275         case 2:
    276             *pDateOut += 31;
    277             break;
    278         case 3:
    279             *pDateOut += ( 59 + leapYear );
    280             break;
    281         case 4:
    282             *pDateOut += ( 90 + leapYear );
    283             break;
    284         case 5:
    285             *pDateOut += ( 120 + leapYear );
    286             break;
    287         case 6:
    288             *pDateOut += ( 151 + leapYear );
    289             break;
    290         case 7:
    291             *pDateOut += ( 181 + leapYear );
    292             break;
    293         case 8:
    294             *pDateOut += ( 212 + leapYear );
    295             break;
    296         case 9:
    297             *pDateOut += ( 243 + leapYear );
    298             break;
    299         case 10:
    300             *pDateOut += ( 273 + leapYear );
    301             break;
    302         case 11:
    303             *pDateOut += ( 304 + leapYear );
    304             break;
    305         case 12:
    306             *pDateOut += ( 334 + leapYear );
    307             break;
    308         }
    309         /* Add the number of days in this month.
    310         */
    311         *pDateOut += pTm->tm_mday;
    312 
    313         /* Add the number of seconds, minutes, and hours
    314         * to the DATE. Note these are the fracionnal part
    315         * of the DATE so seconds / number of seconds in a day.
    316         */
    317         *pDateOut += pTm->tm_hour / 24.0;
    318         *pDateOut += pTm->tm_min / 1440.0;
    319         *pDateOut += pTm->tm_sec / 86400.0;
    320         return TRUE;
    321     }
    322     return FALSE;
    323 }
    324 
    325 /******************************************************************************
    326  *     DateToTm     [INTERNAL]
     237        if( (pTm->tm_year - 1900) >= 0 )
     238        {
     239                int leapYear = 0;
     240               
     241                /* Start at 1. This is the way DATE is defined.
     242                * January 1, 1900 at Midnight is 1.00.
     243                * January 1, 1900 at 6AM is 1.25.
     244                * and so on.
     245                */
     246                *pDateOut = 1;
     247
     248                /* Add the number of days corresponding to
     249                * tm_year.
     250                */
     251                *pDateOut += (pTm->tm_year - 1900) * 365;
     252
     253                /* Add the leap days in the previous years between now and 1900.
     254                * Note a leap year is one that is a multiple of 4
     255                * but not of a 100.  Except if it is a multiple of
     256                * 400 then it is a leap year.
     257                */
     258                *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
     259                *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
     260                *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
     261
     262                /* Set the leap year flag if the
     263                * current year specified by tm_year is a
     264                * leap year. This will be used to add a day
     265                * to the day count.
     266                */
     267                if( isleap( pTm->tm_year ) )
     268                        leapYear = 1;
     269               
     270                /* Add the number of days corresponding to
     271                * the month.
     272                */
     273                switch( pTm->tm_mon )
     274                {
     275                case 2:
     276                        *pDateOut += 31;
     277                        break;
     278                case 3:
     279                        *pDateOut += ( 59 + leapYear );
     280                        break;
     281                case 4:
     282                        *pDateOut += ( 90 + leapYear );
     283                        break;
     284                case 5:
     285                        *pDateOut += ( 120 + leapYear );
     286                        break;
     287                case 6:
     288                        *pDateOut += ( 151 + leapYear );
     289                        break;
     290                case 7:
     291                        *pDateOut += ( 181 + leapYear );
     292                        break;
     293                case 8:
     294                        *pDateOut += ( 212 + leapYear );
     295                        break;
     296                case 9:
     297                        *pDateOut += ( 243 + leapYear );
     298                        break;
     299                case 10:
     300                        *pDateOut += ( 273 + leapYear );
     301                        break;
     302                case 11:
     303                        *pDateOut += ( 304 + leapYear );
     304                        break;
     305                case 12:
     306                        *pDateOut += ( 334 + leapYear );
     307                        break;
     308                }
     309                /* Add the number of days in this month.
     310                */
     311                *pDateOut += pTm->tm_mday;
     312       
     313                /* Add the number of seconds, minutes, and hours
     314                * to the DATE. Note these are the fracionnal part
     315                * of the DATE so seconds / number of seconds in a day.
     316                */
     317                *pDateOut += pTm->tm_hour / 24.0;
     318                *pDateOut += pTm->tm_min / 1440.0;
     319                *pDateOut += pTm->tm_sec / 86400.0;
     320                return TRUE;
     321        }
     322        return FALSE;
     323}
     324
     325/******************************************************************************
     326 *         DateToTm     [INTERNAL]
    327327 *
    328328 * This function converts a windows DATE to a tm structure.
     
    339339static BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
    340340{
    341     /* Do not process dates smaller than January 1, 1900.
    342     * Which corresponds to 2.0 in the windows DATE format.
    343     */
    344     if( dateIn >= 2.0 )
    345     {
    346         double decimalPart = 0.0;
    347         double wholePart = 0.0;
    348 
    349         memset(pTm,0,sizeof(*pTm));
    350 
    351         /* Because of the nature of DATE format which
    352         * associates 2.0 to January 1, 1900. We will
    353         * remove 1.0 from the whole part of the DATE
    354         * so that in the following code 1.0
    355         * will correspond to January 1, 1900.
    356         * This simplifies the processing of the DATE value.
    357         */
    358         dateIn -= 1.0;
    359 
    360         wholePart = (double) floor( dateIn );
    361         decimalPart = fmod( dateIn, wholePart );
    362 
    363         if( !(dwFlags & VAR_TIMEVALUEONLY) )
    364         {
    365             int nDay = 0;
    366             int leapYear = 0;
    367             double yearsSince1900 = 0;
    368             /* Start at 1900, this is where the DATE time 0.0 starts.
    369             */
    370             pTm->tm_year = 1900;
    371             /* find in what year the day in the "wholePart" falls into.
    372             * add the value to the year field.
    373             */
    374             yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
    375             pTm->tm_year += yearsSince1900;
    376             /* determine if this is a leap year.
    377             */
    378             if( isleap( pTm->tm_year ) )
    379             {
    380                 leapYear = 1;
    381                 wholePart++;
    382             }
    383 
    384             /* find what day of that year the "wholePart" corresponds to.
    385             * Note: nDay is in [1-366] format
    386             */
    387             nDay = (int) ( wholePart - floor( yearsSince1900 * DAYS_IN_ONE_YEAR ) );
    388             /* Set the tm_yday value.
    389             * Note: The day must be converted from [1-366] to [0-365]
    390             */
    391             /*pTm->tm_yday = nDay - 1;*/
    392             /* find which month this day corresponds to.
    393             */
    394             if( nDay <= 31 )
    395             {
    396                 pTm->tm_mday = nDay;
    397                 pTm->tm_mon = 0;
    398             }
    399             else if( nDay <= ( 59 + leapYear ) )
    400             {
    401                 pTm->tm_mday = nDay - 31;
    402                 pTm->tm_mon = 1;
    403             }
    404             else if( nDay <= ( 90 + leapYear ) )
    405             {
    406                 pTm->tm_mday = nDay - ( 59 + leapYear );
    407                 pTm->tm_mon = 2;
    408             }
    409             else if( nDay <= ( 120 + leapYear ) )
    410             {
    411                 pTm->tm_mday = nDay - ( 90 + leapYear );
    412                 pTm->tm_mon = 3;
    413             }
    414             else if( nDay <= ( 151 + leapYear ) )
    415             {
    416                 pTm->tm_mday = nDay - ( 120 + leapYear );
    417                 pTm->tm_mon = 4;
    418             }
    419             else if( nDay <= ( 181 + leapYear ) )
    420             {
    421                 pTm->tm_mday = nDay - ( 151 + leapYear );
    422                 pTm->tm_mon = 5;
    423             }
    424             else if( nDay <= ( 212 + leapYear ) )
    425             {
    426                 pTm->tm_mday = nDay - ( 181 + leapYear );
    427                 pTm->tm_mon = 6;
    428             }
    429             else if( nDay <= ( 243 + leapYear ) )
    430             {
    431                 pTm->tm_mday = nDay - ( 212 + leapYear );
    432                 pTm->tm_mon = 7;
    433             }
    434             else if( nDay <= ( 273 + leapYear ) )
    435             {
    436                 pTm->tm_mday = nDay - ( 243 + leapYear );
    437                 pTm->tm_mon = 8;
    438             }
    439             else if( nDay <= ( 304 + leapYear ) )
    440             {
    441                 pTm->tm_mday = nDay - ( 273 + leapYear );
    442                 pTm->tm_mon = 9;
    443             }
    444             else if( nDay <= ( 334 + leapYear ) )
    445             {
    446                 pTm->tm_mday = nDay - ( 304 + leapYear );
    447                 pTm->tm_mon = 10;
    448             }
    449             else if( nDay <= ( 365 + leapYear ) )
    450             {
    451                 pTm->tm_mday = nDay - ( 334 + leapYear );
    452                 pTm->tm_mon = 11;
    453             }
    454         }
    455         if( !(dwFlags & VAR_DATEVALUEONLY) )
    456         {
    457             /* find the number of seconds in this day.
    458             * fractional part times, hours, minutes, seconds.
    459             */
    460             pTm->tm_hour = (int) ( decimalPart * 24 );
    461             pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 );
    462             pTm->tm_sec = (int) ( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 );
    463         }
    464         return TRUE;
    465     }
    466     return FALSE;
    467 }
    468 
    469 
    470 
    471 /******************************************************************************
    472  *     SizeOfVariantData    [INTERNAL]
     341        /* Do not process dates smaller than January 1, 1900.
     342        * Which corresponds to 2.0 in the windows DATE format.
     343        */
     344        if( dateIn >= 2.0 )
     345        {
     346                double decimalPart = 0.0;
     347                double wholePart = 0.0;
     348
     349                memset(pTm,0,sizeof(*pTm));
     350       
     351                /* Because of the nature of DATE format which
     352                * associates 2.0 to January 1, 1900. We will
     353                * remove 1.0 from the whole part of the DATE
     354                * so that in the following code 1.0
     355                * will correspond to January 1, 1900.
     356                * This simplifies the processing of the DATE value.
     357                */
     358                dateIn -= 1.0;
     359
     360                wholePart = (double) floor( dateIn );
     361                decimalPart = fmod( dateIn, wholePart );
     362
     363                if( !(dwFlags & VAR_TIMEVALUEONLY) )
     364                {
     365                        int nDay = 0;
     366                        int leapYear = 0;
     367                        double yearsSince1900 = 0;
     368                        /* Start at 1900, this is where the DATE time 0.0 starts.
     369                        */
     370                        pTm->tm_year = 1900;
     371                        /* find in what year the day in the "wholePart" falls into.
     372                        * add the value to the year field.
     373                        */
     374                        yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
     375                        pTm->tm_year += yearsSince1900;
     376                        /* determine if this is a leap year.
     377                        */
     378                        if( isleap( pTm->tm_year ) )
     379                        {
     380                                leapYear = 1;
     381                                wholePart++;
     382                        }
     383
     384                        /* find what day of that year the "wholePart" corresponds to.
     385                        * Note: nDay is in [1-366] format
     386                        */
     387                        nDay = (int) ( wholePart - floor( yearsSince1900 * DAYS_IN_ONE_YEAR ) );
     388                        /* Set the tm_yday value.
     389                        * Note: The day must be converted from [1-366] to [0-365]
     390                        */
     391                        /*pTm->tm_yday = nDay - 1;*/
     392                        /* find which month this day corresponds to.
     393                        */
     394                        if( nDay <= 31 )
     395                        {
     396                                pTm->tm_mday = nDay;
     397                                pTm->tm_mon = 0;
     398                        }
     399                        else if( nDay <= ( 59 + leapYear ) )
     400                        {
     401                                pTm->tm_mday = nDay - 31;
     402                                pTm->tm_mon = 1;
     403                        }
     404                        else if( nDay <= ( 90 + leapYear ) )
     405                        {
     406                                pTm->tm_mday = nDay - ( 59 + leapYear );
     407                                pTm->tm_mon = 2;
     408                        }
     409                        else if( nDay <= ( 120 + leapYear ) )
     410                        {
     411                                pTm->tm_mday = nDay - ( 90 + leapYear );
     412                                pTm->tm_mon = 3;
     413                        }
     414                        else if( nDay <= ( 151 + leapYear ) )
     415                        {
     416                                pTm->tm_mday = nDay - ( 120 + leapYear );
     417                                pTm->tm_mon = 4;
     418                        }
     419                        else if( nDay <= ( 181 + leapYear ) )
     420                        {
     421                                pTm->tm_mday = nDay - ( 151 + leapYear );
     422                                pTm->tm_mon = 5;
     423                        }
     424                        else if( nDay <= ( 212 + leapYear ) )
     425                        {
     426                                pTm->tm_mday = nDay - ( 181 + leapYear );
     427                                pTm->tm_mon = 6;
     428                        }
     429                        else if( nDay <= ( 243 + leapYear ) )
     430                        {
     431                                pTm->tm_mday = nDay - ( 212 + leapYear );
     432                                pTm->tm_mon = 7;
     433                        }
     434                        else if( nDay <= ( 273 + leapYear ) )
     435                        {
     436                                pTm->tm_mday = nDay - ( 243 + leapYear );
     437                                pTm->tm_mon = 8;
     438                        }
     439                        else if( nDay <= ( 304 + leapYear ) )
     440                        {
     441                                pTm->tm_mday = nDay - ( 273 + leapYear );
     442                                pTm->tm_mon = 9;
     443                        }
     444                        else if( nDay <= ( 334 + leapYear ) )
     445                        {
     446                                pTm->tm_mday = nDay - ( 304 + leapYear );
     447                                pTm->tm_mon = 10;
     448                        }
     449                        else if( nDay <= ( 365 + leapYear ) )
     450                        {
     451                                pTm->tm_mday = nDay - ( 334 + leapYear );
     452                                pTm->tm_mon = 11;
     453                        }
     454                }
     455                if( !(dwFlags & VAR_DATEVALUEONLY) )
     456                {
     457                        /* find the number of seconds in this day.
     458                        * fractional part times, hours, minutes, seconds.
     459                        */
     460                        pTm->tm_hour = (int) ( decimalPart * 24 );
     461                        pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 );
     462                        pTm->tm_sec = (int) ( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 );
     463                }
     464                return TRUE;
     465        }
     466        return FALSE;
     467}
     468
     469
     470
     471/******************************************************************************
     472 *         SizeOfVariantData    [INTERNAL]
    473473 *
    474474 * This function finds the size of the data referenced by a Variant based
     
    528528}
    529529/******************************************************************************
    530  *     StringDupAtoBstr     [INTERNAL]
    531  *
     530 *         StringDupAtoBstr             [INTERNAL]
     531 * 
    532532 */
    533533static BSTR StringDupAtoBstr( char* strIn )
    534534{
    535     BSTR bstr = NULL;
    536     OLECHAR* pNewString = NULL;
    537     pNewString = HEAP_strdupAtoW( GetProcessHeap(), 0, strIn );
    538     bstr = SysAllocString( pNewString );
    539     HeapFree( GetProcessHeap(), 0, pNewString );
    540     return bstr;
    541 }
    542 
    543 /******************************************************************************
    544  *      round       [INTERNAL]
     535        BSTR bstr = NULL;
     536        OLECHAR* pNewString = NULL;
     537        pNewString = HEAP_strdupAtoW( GetProcessHeap(), 0, strIn );
     538        bstr = SysAllocString( pNewString );
     539        HeapFree( GetProcessHeap(), 0, pNewString );
     540        return bstr;
     541}
     542
     543/******************************************************************************
     544 *              round           [INTERNAL]
    545545 *
    546546 * Round the double value to the nearest integer value.
     
    556556   nSign = (d >= 0.0) ? 1 : -1;
    557557    d = fabs( d );
    558 
    559     /* Remove the decimals.
    560     */
     558   
     559        /* Remove the decimals.
     560        */
    561561   integerValue = floor( d );
    562562
     
    573573    decimals = d - integerValue;
    574574
    575     /* Note: Ceil returns the smallest integer that is greater that x.
    576     * and floor returns the largest integer that is less than or equal to x.
    577     */
     575        /* Note: Ceil returns the smallest integer that is greater that x.
     576        * and floor returns the largest integer that is less than or equal to x.
     577        */
    578578    if( decimals > 0.5 )
    579579    {
     
    603603    }
    604604
    605     return roundedValue * nSign;
    606 }
    607 
    608 /******************************************************************************
    609  *      RemoveCharacterFromString       [INTERNAL]
     605        return roundedValue * nSign;
     606}
     607
     608/******************************************************************************
     609 *              RemoveCharacterFromString               [INTERNAL]
    610610 *
    611611 * Removes any of the characters in "strOfCharToRemove" from the "str" argument.
     
    613613static void RemoveCharacterFromString( LPSTR str, LPSTR strOfCharToRemove )
    614614{
    615     LPSTR pNewString = NULL;
    616     LPSTR strToken = NULL;
    617 
    618 
    619     /* Check if we have a valid argument
    620     */
    621     if( str != NULL )
    622     {
    623         pNewString = strdup( str );
    624         str[0] = '\0';
    625         strToken = strtok( pNewString, strOfCharToRemove );
    626         while( strToken != NULL ) {
    627             strcat( str, strToken );
    628             strToken = strtok( NULL, strOfCharToRemove );
    629         }
    630         free( pNewString );
    631     }
    632     return;
    633 }
    634 
    635 /******************************************************************************
    636  *      GetValidRealString      [INTERNAL]
     615        LPSTR pNewString = NULL;
     616        LPSTR strToken = NULL;
     617
     618
     619        /* Check if we have a valid argument
     620        */
     621        if( str != NULL )
     622        {
     623                pNewString = strdup( str );
     624                str[0] = '\0';
     625                strToken = strtok( pNewString, strOfCharToRemove );
     626                while( strToken != NULL ) {
     627                        strcat( str, strToken );
     628                        strToken = strtok( NULL, strOfCharToRemove );
     629                }
     630                free( pNewString );
     631        }
     632        return;
     633}
     634
     635/******************************************************************************
     636 *              GetValidRealString              [INTERNAL]
    637637 *
    638638 * Checks if the string is of proper format to be converted to a real value.
     
    640640static BOOL IsValidRealString( LPSTR strRealString )
    641641{
    642     /* Real values that have a decimal point are required to either have
    643     * digits before or after the decimal point.  We will assume that
    644     * we do not have any digits at either position. If we do encounter
    645     * some we will disable this flag.
    646     */
    647     BOOL bDigitsRequired = TRUE;
    648     /* Processed fields in the string representation of the real number.
    649     */
    650     BOOL bWhiteSpaceProcessed = FALSE;
    651     BOOL bFirstSignProcessed = FALSE;
    652     BOOL bFirstDigitsProcessed = FALSE;
    653     BOOL bDecimalPointProcessed = FALSE;
    654     BOOL bSecondDigitsProcessed = FALSE;
    655     BOOL bExponentProcessed = FALSE;
    656     BOOL bSecondSignProcessed = FALSE;
    657     BOOL bThirdDigitsProcessed = FALSE;
    658     /* Assume string parameter "strRealString" is valid and try to disprove it.
    659     */
    660     BOOL bValidRealString = TRUE;
    661 
    662     /* Used to count the number of tokens in the "strRealString".
    663     */
    664     LPSTR strToken = NULL;
    665     int nTokens = 0;
    666     LPSTR pChar = NULL;
    667 
    668     /* Check if we have a valid argument
    669     */
    670     if( strRealString == NULL )
    671     {
    672         bValidRealString = FALSE;
    673     }
    674 
    675     if( bValidRealString == TRUE )
    676     {
    677         /* Make sure we only have ONE token in the string.
    678         */
    679         strToken = strtok( strRealString, " " );
    680         while( strToken != NULL ) {
    681             nTokens++;
    682             strToken = strtok( NULL, " " );
    683         }
    684 
    685         if( nTokens != 1 )
    686         {
    687             bValidRealString = FALSE;
    688         }
    689     }
    690 
    691 
    692     /* Make sure this token contains only valid characters.
    693     * The string argument to atof has the following form:
    694     * [whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits]
    695     * Whitespace consists of space and|or <TAB> characters, which are ignored.
     642        /* Real values that have a decimal point are required to either have
     643        * digits before or after the decimal point.  We will assume that
     644        * we do not have any digits at either position. If we do encounter
     645        * some we will disable this flag.
     646        */
     647        BOOL bDigitsRequired = TRUE;
     648        /* Processed fields in the string representation of the real number.
     649        */
     650        BOOL bWhiteSpaceProcessed = FALSE;
     651        BOOL bFirstSignProcessed = FALSE;
     652        BOOL bFirstDigitsProcessed = FALSE;
     653        BOOL bDecimalPointProcessed = FALSE;
     654        BOOL bSecondDigitsProcessed = FALSE;
     655        BOOL bExponentProcessed = FALSE;
     656        BOOL bSecondSignProcessed = FALSE;
     657        BOOL bThirdDigitsProcessed = FALSE;
     658        /* Assume string parameter "strRealString" is valid and try to disprove it.
     659        */
     660        BOOL bValidRealString = TRUE;
     661
     662        /* Used to count the number of tokens in the "strRealString".
     663        */
     664        LPSTR strToken = NULL;
     665        int nTokens = 0;
     666        LPSTR pChar = NULL;
     667       
     668        /* Check if we have a valid argument
     669        */
     670        if( strRealString == NULL )
     671        {
     672                bValidRealString = FALSE;
     673        }
     674
     675        if( bValidRealString == TRUE )
     676        {
     677                /* Make sure we only have ONE token in the string.
     678                */
     679                strToken = strtok( strRealString, " " );
     680                while( strToken != NULL ) {
     681                        nTokens++;             
     682                        strToken = strtok( NULL, " " );
     683                }
     684
     685                if( nTokens != 1 )
     686                {
     687                        bValidRealString = FALSE;
     688                }
     689        }
     690
     691
     692        /* Make sure this token contains only valid characters.
     693        * The string argument to atof has the following form:
     694        * [whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits]
     695        * Whitespace consists of space and|or <TAB> characters, which are ignored.
    696696     * Sign is either plus '+' or minus '-'.
    697697     * Digits are one or more decimal digits.
     
    700700     * The decimal digits may be followed by an exponent.
    701701     * An Exponent consists of an introductory letter ( D, d, E, or e) and
    702     * an optionally signed decimal integer.
    703     */
    704     pChar = strRealString;
    705     while( bValidRealString == TRUE && *pChar != '\0' )
    706     {
    707         switch( *pChar )
    708         {
    709         /* If whitespace...
    710         */
    711         case ' ':
    712         case '\t':
    713             if( bWhiteSpaceProcessed ||
    714                 bFirstSignProcessed ||
    715                 bFirstDigitsProcessed ||
    716                 bDecimalPointProcessed ||
    717                 bSecondDigitsProcessed ||
    718                 bExponentProcessed ||
    719                 bSecondSignProcessed ||
    720                 bThirdDigitsProcessed )
    721             {
    722                 bValidRealString = FALSE;
    723             }
    724             break;
    725         /* If sign...
    726         */
    727         case '+':
    728         case '-':
    729             if( bFirstSignProcessed == FALSE )
    730             {
    731                 if( bFirstDigitsProcessed ||
    732                     bDecimalPointProcessed ||
    733                     bSecondDigitsProcessed ||
    734                     bExponentProcessed ||
    735                     bSecondSignProcessed ||
    736                     bThirdDigitsProcessed )
    737                 {
    738                     bValidRealString = FALSE;
    739                 }
    740                 bWhiteSpaceProcessed = TRUE;
    741                 bFirstSignProcessed = TRUE;
    742             }
    743             else if( bSecondSignProcessed == FALSE )
    744             {
     702        * an optionally signed decimal integer.
     703        */
     704        pChar = strRealString;
     705        while( bValidRealString == TRUE && *pChar != '\0' )
     706        {
     707                switch( *pChar )
     708                {
     709                /* If whitespace...
     710                */
     711                case ' ':
     712                case '\t':
     713                        if( bWhiteSpaceProcessed ||
     714                                bFirstSignProcessed ||
     715                                bFirstDigitsProcessed ||
     716                                bDecimalPointProcessed ||
     717                                bSecondDigitsProcessed ||
     718                                bExponentProcessed ||
     719                                bSecondSignProcessed ||
     720                                bThirdDigitsProcessed )
     721                        {
     722                                bValidRealString = FALSE;
     723                        }
     724                        break;
     725                /* If sign...
     726                */
     727                case '+':
     728                case '-':
     729                        if( bFirstSignProcessed == FALSE )
     730                        {
     731                                if( bFirstDigitsProcessed ||
     732                                        bDecimalPointProcessed ||
     733                                        bSecondDigitsProcessed ||
     734                                        bExponentProcessed ||
     735                                        bSecondSignProcessed ||
     736                                        bThirdDigitsProcessed )
     737                                {
     738                                        bValidRealString = FALSE;
     739                                }
     740                                bWhiteSpaceProcessed = TRUE;
     741                                bFirstSignProcessed = TRUE;
     742                        }
     743                        else if( bSecondSignProcessed == FALSE )
     744                        {
    745745                /* Note: The exponent must be present in
    746                 * order to accept the second sign...
    747                 */
    748                 if( bExponentProcessed == FALSE ||
    749                     bThirdDigitsProcessed ||
    750                     bDigitsRequired )
    751                 {
    752                     bValidRealString = FALSE;
    753                 }
    754                 bFirstSignProcessed = TRUE;
    755                 bWhiteSpaceProcessed = TRUE;
    756                 bFirstDigitsProcessed = TRUE;
    757                 bDecimalPointProcessed = TRUE;
    758                 bSecondDigitsProcessed = TRUE;
    759                 bSecondSignProcessed = TRUE;
    760             }
    761             break;
    762 
    763         /* If decimals...
    764         */
    765         case '0':
    766         case '1':
    767         case '2':
    768         case '3':
    769         case '4':
    770         case '5':
    771         case '6':
    772         case '7':
    773         case '8':
    774         case '9':
    775             if( bFirstDigitsProcessed == FALSE )
    776             {
    777                 if( bDecimalPointProcessed ||
    778                     bSecondDigitsProcessed ||
    779                     bExponentProcessed ||
    780                     bSecondSignProcessed ||
    781                     bThirdDigitsProcessed )
    782                 {
    783                     bValidRealString = FALSE;
    784                 }
    785                 bFirstSignProcessed = TRUE;
    786                 bWhiteSpaceProcessed = TRUE;
    787                 /* We have found some digits before the decimal point
    788                 * so disable the "Digits required" flag.
    789                 */
    790                 bDigitsRequired = FALSE;
    791             }
    792             else if( bSecondDigitsProcessed == FALSE )
    793             {
    794                 if( bExponentProcessed ||
    795                     bSecondSignProcessed ||
    796                     bThirdDigitsProcessed )
    797                 {
    798                     bValidRealString = FALSE;
    799                 }
    800                 bFirstSignProcessed = TRUE;
    801                 bWhiteSpaceProcessed = TRUE;
    802                 bFirstDigitsProcessed = TRUE;
    803                 bDecimalPointProcessed = TRUE;
    804                 /* We have found some digits after the decimal point
    805                 * so disable the "Digits required" flag.
    806                 */
    807                 bDigitsRequired = FALSE;
    808             }
    809             else if( bThirdDigitsProcessed == FALSE )
    810             {
    811                 /* Getting here means everything else should be processed.
     746                                * order to accept the second sign...
     747                                */
     748                                if( bExponentProcessed == FALSE ||
     749                                        bThirdDigitsProcessed ||
     750                                        bDigitsRequired )
     751                                {
     752                                        bValidRealString = FALSE;
     753                                }
     754                                bFirstSignProcessed = TRUE;
     755                                bWhiteSpaceProcessed = TRUE;
     756                                bFirstDigitsProcessed = TRUE;
     757                                bDecimalPointProcessed = TRUE;
     758                                bSecondDigitsProcessed = TRUE;
     759                                bSecondSignProcessed = TRUE;
     760                        }
     761                        break;
     762
     763                /* If decimals...
     764                */
     765                case '0':
     766                case '1':
     767                case '2':
     768                case '3':
     769                case '4':
     770                case '5':
     771                case '6':
     772                case '7':
     773                case '8':
     774                case '9':
     775                        if( bFirstDigitsProcessed == FALSE )
     776                        {
     777                                if( bDecimalPointProcessed ||
     778                                        bSecondDigitsProcessed ||
     779                                        bExponentProcessed ||
     780                                        bSecondSignProcessed ||
     781                                        bThirdDigitsProcessed )
     782                                {
     783                                        bValidRealString = FALSE;
     784                                }
     785                                bFirstSignProcessed = TRUE;
     786                                bWhiteSpaceProcessed = TRUE;
     787                                /* We have found some digits before the decimal point
     788                                * so disable the "Digits required" flag.
     789                                */
     790                                bDigitsRequired = FALSE;
     791                        }
     792                        else if( bSecondDigitsProcessed == FALSE )
     793                        {
     794                                if( bExponentProcessed ||
     795                                        bSecondSignProcessed ||
     796                                        bThirdDigitsProcessed )
     797                                {
     798                                        bValidRealString = FALSE;
     799                                }
     800                                bFirstSignProcessed = TRUE;
     801                                bWhiteSpaceProcessed = TRUE;
     802                                bFirstDigitsProcessed = TRUE;
     803                                bDecimalPointProcessed = TRUE;
     804                                /* We have found some digits after the decimal point
     805                                * so disable the "Digits required" flag.
     806                                */
     807                                bDigitsRequired = FALSE;
     808                        }
     809                        else if( bThirdDigitsProcessed == FALSE )
     810                        {
     811                                /* Getting here means everything else should be processed.
    812812                 * If we get anything else than a decimal following this
    813813                 * digit it will be flagged by the other cases, so
    814                 * we do not really need to do anything in here.
    815                 */
    816             }
    817             break;
    818         /* If DecimalPoint...
    819         */
    820         case '.':
    821             if( bDecimalPointProcessed ||
    822                 bSecondDigitsProcessed ||
    823                 bExponentProcessed ||
    824                 bSecondSignProcessed ||
    825                 bThirdDigitsProcessed )
    826             {
    827                 bValidRealString = FALSE;
    828             }
    829             bFirstSignProcessed = TRUE;
    830             bWhiteSpaceProcessed = TRUE;
    831             bFirstDigitsProcessed = TRUE;
    832             bDecimalPointProcessed = TRUE;
    833             break;
    834         /* If Exponent...
    835         */
    836         case 'e':
    837         case 'E':
    838         case 'd':
    839         case 'D':
    840             if( bExponentProcessed ||
    841                 bSecondSignProcessed ||
    842                 bThirdDigitsProcessed ||
    843                 bDigitsRequired )
    844             {
    845                 bValidRealString = FALSE;
    846             }
    847             bFirstSignProcessed = TRUE;
    848             bWhiteSpaceProcessed = TRUE;
    849             bFirstDigitsProcessed = TRUE;
    850             bDecimalPointProcessed = TRUE;
    851             bSecondDigitsProcessed = TRUE;
    852             bExponentProcessed = TRUE;
    853             break;
    854         default:
    855             bValidRealString = FALSE;
    856             break;
    857         }
    858         /* Process next character.
    859         */
    860         pChar++;
    861     }
    862 
    863     /* If the required digits were not present we have an invalid
    864     * string representation of a real number.
    865     */
    866     if( bDigitsRequired == TRUE )
    867     {
    868         bValidRealString = FALSE;
    869     }
    870 
    871     return bValidRealString;
    872 }
    873 
    874 
    875 /******************************************************************************
    876  *      Coerce  [INTERNAL]
     814                                * we do not really need to do anything in here.
     815                                */
     816                        }
     817                        break;
     818                /* If DecimalPoint...
     819                */
     820                case '.':
     821                        if( bDecimalPointProcessed ||
     822                                bSecondDigitsProcessed ||
     823                                bExponentProcessed ||
     824                                bSecondSignProcessed ||
     825                                bThirdDigitsProcessed )
     826                        {
     827                                bValidRealString = FALSE;
     828                        }
     829                        bFirstSignProcessed = TRUE;
     830                        bWhiteSpaceProcessed = TRUE;
     831                        bFirstDigitsProcessed = TRUE;
     832                        bDecimalPointProcessed = TRUE;
     833                        break;
     834                /* If Exponent...
     835                */
     836                case 'e':
     837                case 'E':
     838                case 'd':
     839                case 'D':
     840                        if( bExponentProcessed ||
     841                                bSecondSignProcessed ||
     842                                bThirdDigitsProcessed ||
     843                                bDigitsRequired )
     844                        {
     845                                bValidRealString = FALSE;
     846                        }
     847                        bFirstSignProcessed = TRUE;
     848                        bWhiteSpaceProcessed = TRUE;
     849                        bFirstDigitsProcessed = TRUE;
     850                        bDecimalPointProcessed = TRUE;
     851                        bSecondDigitsProcessed = TRUE;
     852                        bExponentProcessed = TRUE;
     853                        break;
     854                default:
     855                        bValidRealString = FALSE;
     856                        break;
     857                }
     858                /* Process next character.
     859                */
     860                pChar++;
     861        }
     862
     863        /* If the required digits were not present we have an invalid
     864        * string representation of a real number.
     865        */
     866        if( bDigitsRequired == TRUE )
     867        {
     868                bValidRealString = FALSE;
     869        }
     870
     871        return bValidRealString;
     872}
     873
     874
     875/******************************************************************************
     876 *              Coerce  [INTERNAL]
    877877 *
    878878 * This function dispatches execution to the proper conversion API
     
    880880 *
    881881 * FIXME: Passing down dwFlags to the conversion functions is wrong, this
    882  *    is a different flagmask. Check MSDN.
     882 *        is a different flagmask. Check MSDN.
    883883 */
    884884static HRESULT Coerce( VARIANTARG* pd, LCID lcid, ULONG dwFlags, VARIANTARG* ps, VARTYPE vt )
    885885{
    886     HRESULT res = S_OK;
    887     unsigned short vtFrom = 0;
    888     vtFrom = V_VT(ps) & VT_TYPEMASK;
    889 
    890 
    891     /* Note: Since "long" and "int" values both have 4 bytes and are
    892     * both signed integers "int" will be treated as "long" in the
    893     * following code.
    894     * The same goes for their unsigned versions.
    895     */
    896 
    897     /* Trivial Case: If the coercion is from two types that are
    898     * identical then we can blindly copy from one argument to another.*/
    899     if ((vt==vtFrom))
    900     {
    901        return VariantCopy(pd,ps);
    902     }
    903 
    904     /* Cases requiring thought*/
    905     switch( vt )
    906     {
     886        HRESULT res = S_OK;
     887        unsigned short vtFrom = 0;
     888        vtFrom = V_VT(ps) & VT_TYPEMASK;
     889
     890       
     891        /* Note: Since "long" and "int" values both have 4 bytes and are
     892        * both signed integers "int" will be treated as "long" in the
     893        * following code.
     894        * The same goes for their unsigned versions.
     895        */
     896
     897        /* Trivial Case: If the coercion is from two types that are
     898        * identical then we can blindly copy from one argument to another.*/
     899        if ((vt==vtFrom))
     900        {
     901           return VariantCopy(pd,ps);
     902        }
     903
     904        /* Cases requiring thought*/
     905        switch( vt )
     906        {
    907907
    908908    case( VT_EMPTY ):
     
    916916        }
    917917        break;
    918     case( VT_I1 ):
    919         switch( vtFrom )
     918        case( VT_I1 ):
     919                switch( vtFrom )
    920920        {
    921921        case( VT_I1 ):
    922922            res = VariantCopy( pd, ps );
    923923            break;
    924         case( VT_I2 ):
    925             res = VarI1FromI2( V_UNION(ps,iVal), &V_UNION(pd,cVal) );
    926             break;
    927         case( VT_INT ):
    928         case( VT_I4 ):
    929             res = VarI1FromI4( V_UNION(ps,lVal), &V_UNION(pd,cVal) );
    930             break;
    931         case( VT_UI1 ):
    932             res = VarI1FromUI1( V_UNION(ps,bVal), &V_UNION(pd,cVal) );
    933             break;
    934         case( VT_UI2 ):
    935             res = VarI1FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,cVal) );
    936             break;
    937         case( VT_UINT ):
    938         case( VT_UI4 ):
    939             res = VarI1FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,cVal) );
    940             break;
    941         case( VT_R4 ):
    942             res = VarI1FromR4( V_UNION(ps,fltVal), &V_UNION(pd,cVal) );
    943             break;
    944         case( VT_R8 ):
    945             res = VarI1FromR8( V_UNION(ps,dblVal), &V_UNION(pd,cVal) );
    946             break;
    947         case( VT_DATE ):
    948             res = VarI1FromDate( V_UNION(ps,date), &V_UNION(pd,cVal) );
    949             break;
    950         case( VT_BOOL ):
    951             res = VarI1FromBool( V_UNION(ps,boolVal), &V_UNION(pd,cVal) );
    952             break;
    953         case( VT_BSTR ):
    954             res = VarI1FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,cVal) );
    955             break;
    956         case( VT_CY ):
    957             res = VarI1FromCy( V_UNION(ps,cyVal), &V_UNION(pd,cVal) );
    958             break;
    959         case( VT_DISPATCH ):
    960             /*res = VarI1FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,cVal) );*/
    961         case( VT_DECIMAL ):
    962             /*res = VarI1FromDec( V_UNION(ps,decVal), &V_UNION(pd,cVal) );*/
    963         case( VT_UNKNOWN ):
    964         default:
    965             res = DISP_E_TYPEMISMATCH;
    966             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    967             break;
    968         }
    969         break;
    970 
    971     case( VT_I2 ):
    972         switch( vtFrom )
    973         {
    974         case( VT_I1 ):
    975             res = VarI2FromI1( V_UNION(ps,cVal), &V_UNION(pd,iVal) );
    976             break;
     924                case( VT_I2 ):
     925                        res = VarI1FromI2( V_UNION(ps,iVal), &V_UNION(pd,cVal) );
     926                        break;
     927                case( VT_INT ):
     928                case( VT_I4 ):
     929                        res = VarI1FromI4( V_UNION(ps,lVal), &V_UNION(pd,cVal) );
     930                        break;
     931                case( VT_UI1 ):
     932                        res = VarI1FromUI1( V_UNION(ps,bVal), &V_UNION(pd,cVal) );
     933                        break;
     934                case( VT_UI2 ):
     935                        res = VarI1FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,cVal) );
     936                        break;
     937                case( VT_UINT ):
     938                case( VT_UI4 ):
     939                        res = VarI1FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,cVal) );
     940                        break;
     941                case( VT_R4 ):
     942                        res = VarI1FromR4( V_UNION(ps,fltVal), &V_UNION(pd,cVal) );
     943                        break;
     944                case( VT_R8 ):
     945                        res = VarI1FromR8( V_UNION(ps,dblVal), &V_UNION(pd,cVal) );
     946                        break;
     947                case( VT_DATE ):
     948                        res = VarI1FromDate( V_UNION(ps,date), &V_UNION(pd,cVal) );
     949                        break;
     950                case( VT_BOOL ):
     951                        res = VarI1FromBool( V_UNION(ps,boolVal), &V_UNION(pd,cVal) );
     952                        break;
     953                case( VT_BSTR ):
     954                        res = VarI1FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,cVal) );
     955                        break;
     956                case( VT_CY ):
     957                        res = VarI1FromCy( V_UNION(ps,cyVal), &V_UNION(pd,cVal) );
     958                        break;
     959                case( VT_DISPATCH ):
     960                        /*res = VarI1FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,cVal) );*/
     961                case( VT_DECIMAL ):
     962                        /*res = VarI1FromDec( V_UNION(ps,decVal), &V_UNION(pd,cVal) );*/
     963                case( VT_UNKNOWN ):
     964                default:
     965                        res = DISP_E_TYPEMISMATCH;
     966                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     967                        break;
     968                }
     969                break;
     970
     971        case( VT_I2 ):
     972                switch( vtFrom )
     973                {
     974                case( VT_I1 ):
     975                        res = VarI2FromI1( V_UNION(ps,cVal), &V_UNION(pd,iVal) );
     976                        break;
    977977        case( VT_I2 ):
    978978            res = VariantCopy( pd, ps );
    979979            break;
    980         case( VT_INT ):
    981         case( VT_I4 ):
    982             res = VarI2FromI4( V_UNION(ps,lVal), &V_UNION(pd,iVal) );
    983             break;
    984         case( VT_UI1 ):
    985             res = VarI2FromUI1( V_UNION(ps,bVal), &V_UNION(pd,iVal) );
    986             break;
    987         case( VT_UI2 ):
    988             res = VarI2FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,iVal) );
    989             break;
    990         case( VT_UINT ):
    991         case( VT_UI4 ):
    992             res = VarI2FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,iVal) );
    993             break;
    994         case( VT_R4 ):
    995             res = VarI2FromR4( V_UNION(ps,fltVal), &V_UNION(pd,iVal) );
    996             break;
    997         case( VT_R8 ):
    998             res = VarI2FromR8( V_UNION(ps,dblVal), &V_UNION(pd,iVal) );
    999             break;
    1000         case( VT_DATE ):
    1001             res = VarI2FromDate( V_UNION(ps,date), &V_UNION(pd,iVal) );
    1002             break;
    1003         case( VT_BOOL ):
    1004             res = VarI2FromBool( V_UNION(ps,boolVal), &V_UNION(pd,iVal) );
    1005             break;
    1006         case( VT_BSTR ):
    1007             res = VarI2FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,iVal) );
    1008             break;
    1009         case( VT_CY ):
    1010             res = VarI2FromCy( V_UNION(ps,cyVal), &V_UNION(pd,iVal) );
    1011             break;
    1012         case( VT_DISPATCH ):
    1013             /*res = VarI2FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,iVal) );*/
    1014         case( VT_DECIMAL ):
    1015             /*res = VarI2FromDec( V_UNION(ps,deiVal), &V_UNION(pd,iVal) );*/
    1016         case( VT_UNKNOWN ):
    1017         default:
    1018             res = DISP_E_TYPEMISMATCH;
    1019             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1020             break;
    1021         }
    1022         break;
    1023 
    1024     case( VT_INT ):
    1025     case( VT_I4 ):
    1026         switch( vtFrom )
    1027         {
    1028         case( VT_I1 ):
    1029             res = VarI4FromI1( V_UNION(ps,cVal), &V_UNION(pd,lVal) );
    1030             break;
    1031         case( VT_I2 ):
    1032             res = VarI4FromI2( V_UNION(ps,iVal), &V_UNION(pd,lVal) );
     980                case( VT_INT ):
     981                case( VT_I4 ):
     982                        res = VarI2FromI4( V_UNION(ps,lVal), &V_UNION(pd,iVal) );
     983                        break;
     984                case( VT_UI1 ):
     985                        res = VarI2FromUI1( V_UNION(ps,bVal), &V_UNION(pd,iVal) );
     986                        break;
     987                case( VT_UI2 ):
     988                        res = VarI2FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,iVal) );
     989                        break;
     990                case( VT_UINT ):
     991                case( VT_UI4 ):
     992                        res = VarI2FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,iVal) );
     993                        break;
     994                case( VT_R4 ):
     995                        res = VarI2FromR4( V_UNION(ps,fltVal), &V_UNION(pd,iVal) );
     996                        break;
     997                case( VT_R8 ):
     998                        res = VarI2FromR8( V_UNION(ps,dblVal), &V_UNION(pd,iVal) );
     999                        break;
     1000                case( VT_DATE ):
     1001                        res = VarI2FromDate( V_UNION(ps,date), &V_UNION(pd,iVal) );
     1002                        break;
     1003                case( VT_BOOL ):
     1004                        res = VarI2FromBool( V_UNION(ps,boolVal), &V_UNION(pd,iVal) );
     1005                        break;
     1006                case( VT_BSTR ):
     1007                        res = VarI2FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,iVal) );
     1008                        break;
     1009                case( VT_CY ):
     1010                        res = VarI2FromCy( V_UNION(ps,cyVal), &V_UNION(pd,iVal) );
     1011                        break;
     1012                case( VT_DISPATCH ):
     1013                        /*res = VarI2FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,iVal) );*/
     1014                case( VT_DECIMAL ):
     1015                        /*res = VarI2FromDec( V_UNION(ps,deiVal), &V_UNION(pd,iVal) );*/
     1016                case( VT_UNKNOWN ):
     1017                default:
     1018                        res = DISP_E_TYPEMISMATCH;
     1019                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1020                        break;
     1021                }
     1022                break;
     1023
     1024        case( VT_INT ):
     1025        case( VT_I4 ):
     1026                switch( vtFrom )
     1027                {
     1028                case( VT_I1 ):
     1029                        res = VarI4FromI1( V_UNION(ps,cVal), &V_UNION(pd,lVal) );
     1030                        break;
     1031                case( VT_I2 ):
     1032                        res = VarI4FromI2( V_UNION(ps,iVal), &V_UNION(pd,lVal) );
    10331033            break;
    10341034        case( VT_INT ):
     
    10391039            res = VariantCopy( pd, ps );
    10401040            break;
    1041         case( VT_UI1 ):
    1042             res = VarI4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,lVal) );
    1043             break;
    1044         case( VT_UI2 ):
    1045             res = VarI4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,lVal) );
    1046             break;
    1047         case( VT_UINT ):
    1048         case( VT_UI4 ):
    1049             res = VarI4FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,lVal) );
    1050             break;
    1051         case( VT_R4 ):
    1052             res = VarI4FromR4( V_UNION(ps,fltVal), &V_UNION(pd,lVal) );
    1053             break;
    1054         case( VT_R8 ):
    1055             res = VarI4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,lVal) );
    1056             break;
    1057         case( VT_DATE ):
    1058             res = VarI4FromDate( V_UNION(ps,date), &V_UNION(pd,lVal) );
    1059             break;
    1060         case( VT_BOOL ):
    1061             res = VarI4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,lVal) );
    1062             break;
    1063         case( VT_BSTR ):
    1064             res = VarI4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,lVal) );
    1065             break;
    1066         case( VT_CY ):
    1067             res = VarI4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,lVal) );
    1068             break;
    1069         case( VT_DISPATCH ):
    1070             /*res = VarI4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,lVal) );*/
    1071         case( VT_DECIMAL ):
    1072             /*res = VarI4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,lVal) );*/
    1073         case( VT_UNKNOWN ):
    1074         default:
    1075             res = DISP_E_TYPEMISMATCH;
    1076             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1077             break;
    1078         }
    1079         break;
    1080 
    1081     case( VT_UI1 ):
    1082         switch( vtFrom )
    1083         {
    1084         case( VT_I1 ):
    1085             res = VarUI1FromI1( V_UNION(ps,cVal), &V_UNION(pd,bVal) );
    1086             break;
    1087         case( VT_I2 ):
    1088             res = VarUI1FromI2( V_UNION(ps,iVal), &V_UNION(pd,bVal) );
    1089             break;
    1090         case( VT_INT ):
    1091         case( VT_I4 ):
    1092             res = VarUI1FromI4( V_UNION(ps,lVal), &V_UNION(pd,bVal) );
    1093             break;
     1041                case( VT_UI1 ):
     1042                        res = VarI4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,lVal) );
     1043                        break;
     1044                case( VT_UI2 ):
     1045                        res = VarI4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,lVal) );
     1046                        break;
     1047                case( VT_UINT ):
     1048                case( VT_UI4 ):
     1049                        res = VarI4FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,lVal) );
     1050                        break;
     1051                case( VT_R4 ):
     1052                        res = VarI4FromR4( V_UNION(ps,fltVal), &V_UNION(pd,lVal) );
     1053                        break;
     1054                case( VT_R8 ):
     1055                        res = VarI4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,lVal) );
     1056                        break;
     1057                case( VT_DATE ):
     1058                        res = VarI4FromDate( V_UNION(ps,date), &V_UNION(pd,lVal) );
     1059                        break;
     1060                case( VT_BOOL ):
     1061                        res = VarI4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,lVal) );
     1062                        break;
     1063                case( VT_BSTR ):
     1064                        res = VarI4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,lVal) );
     1065                        break;
     1066                case( VT_CY ):
     1067                        res = VarI4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,lVal) );
     1068                        break;
     1069                case( VT_DISPATCH ):
     1070                        /*res = VarI4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,lVal) );*/
     1071                case( VT_DECIMAL ):
     1072                        /*res = VarI4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,lVal) );*/
     1073                case( VT_UNKNOWN ):
     1074                default:
     1075                        res = DISP_E_TYPEMISMATCH;
     1076                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1077                        break;
     1078                }
     1079                break;
     1080
     1081        case( VT_UI1 ):
     1082                switch( vtFrom )
     1083                {
     1084                case( VT_I1 ):
     1085                        res = VarUI1FromI1( V_UNION(ps,cVal), &V_UNION(pd,bVal) );
     1086                        break;
     1087                case( VT_I2 ):
     1088                        res = VarUI1FromI2( V_UNION(ps,iVal), &V_UNION(pd,bVal) );
     1089                        break;
     1090                case( VT_INT ):
     1091                case( VT_I4 ):
     1092                        res = VarUI1FromI4( V_UNION(ps,lVal), &V_UNION(pd,bVal) );
     1093                        break;
    10941094        case( VT_UI1 ):
    10951095            res = VariantCopy( pd, ps );
    10961096            break;
    1097         case( VT_UI2 ):
    1098             res = VarUI1FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,bVal) );
    1099             break;
    1100         case( VT_UINT ):
    1101         case( VT_UI4 ):
    1102             res = VarUI1FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,bVal) );
    1103             break;
    1104         case( VT_R4 ):
    1105             res = VarUI1FromR4( V_UNION(ps,fltVal), &V_UNION(pd,bVal) );
    1106             break;
    1107         case( VT_R8 ):
    1108             res = VarUI1FromR8( V_UNION(ps,dblVal), &V_UNION(pd,bVal) );
    1109             break;
    1110         case( VT_DATE ):
    1111             res = VarUI1FromDate( V_UNION(ps,date), &V_UNION(pd,bVal) );
    1112             break;
    1113         case( VT_BOOL ):
    1114             res = VarUI1FromBool( V_UNION(ps,boolVal), &V_UNION(pd,bVal) );
    1115             break;
    1116         case( VT_BSTR ):
    1117             res = VarUI1FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,bVal) );
    1118             break;
    1119         case( VT_CY ):
    1120             res = VarUI1FromCy( V_UNION(ps,cyVal), &V_UNION(pd,bVal) );
    1121             break;
    1122         case( VT_DISPATCH ):
    1123             /*res = VarUI1FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,bVal) );*/
    1124         case( VT_DECIMAL ):
    1125             /*res = VarUI1FromDec( V_UNION(ps,deiVal), &V_UNION(pd,bVal) );*/
    1126         case( VT_UNKNOWN ):
    1127         default:
    1128             res = DISP_E_TYPEMISMATCH;
    1129             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1130             break;
    1131         }
    1132         break;
    1133 
    1134     case( VT_UI2 ):
    1135         switch( vtFrom )
    1136         {
    1137         case( VT_I1 ):
    1138             res = VarUI2FromI1( V_UNION(ps,cVal), &V_UNION(pd,uiVal) );
    1139             break;
    1140         case( VT_I2 ):
    1141             res = VarUI2FromI2( V_UNION(ps,iVal), &V_UNION(pd,uiVal) );
    1142             break;
    1143         case( VT_INT ):
    1144         case( VT_I4 ):
    1145             res = VarUI2FromI4( V_UNION(ps,lVal), &V_UNION(pd,uiVal) );
    1146             break;
    1147         case( VT_UI1 ):
    1148             res = VarUI2FromUI1( V_UNION(ps,bVal), &V_UNION(pd,uiVal) );
    1149             break;
     1097                case( VT_UI2 ):
     1098                        res = VarUI1FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,bVal) );
     1099                        break;
     1100                case( VT_UINT ):
     1101                case( VT_UI4 ):
     1102                        res = VarUI1FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,bVal) );
     1103                        break;
     1104                case( VT_R4 ):
     1105                        res = VarUI1FromR4( V_UNION(ps,fltVal), &V_UNION(pd,bVal) );
     1106                        break;
     1107                case( VT_R8 ):
     1108                        res = VarUI1FromR8( V_UNION(ps,dblVal), &V_UNION(pd,bVal) );
     1109                        break;
     1110                case( VT_DATE ):
     1111                        res = VarUI1FromDate( V_UNION(ps,date), &V_UNION(pd,bVal) );
     1112                        break;
     1113                case( VT_BOOL ):
     1114                        res = VarUI1FromBool( V_UNION(ps,boolVal), &V_UNION(pd,bVal) );
     1115                        break;
     1116                case( VT_BSTR ):
     1117                        res = VarUI1FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,bVal) );
     1118                        break;
     1119                case( VT_CY ):
     1120                        res = VarUI1FromCy( V_UNION(ps,cyVal), &V_UNION(pd,bVal) );
     1121                        break;
     1122                case( VT_DISPATCH ):
     1123                        /*res = VarUI1FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,bVal) );*/
     1124                case( VT_DECIMAL ):
     1125                        /*res = VarUI1FromDec( V_UNION(ps,deiVal), &V_UNION(pd,bVal) );*/
     1126                case( VT_UNKNOWN ):
     1127                default:
     1128                        res = DISP_E_TYPEMISMATCH;
     1129                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1130                        break;
     1131                }
     1132                break;
     1133
     1134        case( VT_UI2 ):
     1135                switch( vtFrom )
     1136                {
     1137                case( VT_I1 ):
     1138                        res = VarUI2FromI1( V_UNION(ps,cVal), &V_UNION(pd,uiVal) );
     1139                        break;
     1140                case( VT_I2 ):
     1141                        res = VarUI2FromI2( V_UNION(ps,iVal), &V_UNION(pd,uiVal) );
     1142                        break;
     1143                case( VT_INT ):
     1144                case( VT_I4 ):
     1145                        res = VarUI2FromI4( V_UNION(ps,lVal), &V_UNION(pd,uiVal) );
     1146                        break;
     1147                case( VT_UI1 ):
     1148                        res = VarUI2FromUI1( V_UNION(ps,bVal), &V_UNION(pd,uiVal) );
     1149                        break;
    11501150        case( VT_UI2 ):
    11511151            res = VariantCopy( pd, ps );
    11521152            break;
    1153         case( VT_UINT ):
    1154         case( VT_UI4 ):
    1155             res = VarUI2FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,uiVal) );
    1156             break;
    1157         case( VT_R4 ):
    1158             res = VarUI2FromR4( V_UNION(ps,fltVal), &V_UNION(pd,uiVal) );
    1159             break;
    1160         case( VT_R8 ):
    1161             res = VarUI2FromR8( V_UNION(ps,dblVal), &V_UNION(pd,uiVal) );
    1162             break;
    1163         case( VT_DATE ):
    1164             res = VarUI2FromDate( V_UNION(ps,date), &V_UNION(pd,uiVal) );
    1165             break;
    1166         case( VT_BOOL ):
    1167             res = VarUI2FromBool( V_UNION(ps,boolVal), &V_UNION(pd,uiVal) );
    1168             break;
    1169         case( VT_BSTR ):
    1170             res = VarUI2FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,uiVal) );
    1171             break;
    1172         case( VT_CY ):
    1173             res = VarUI2FromCy( V_UNION(ps,cyVal), &V_UNION(pd,uiVal) );
    1174             break;
    1175         case( VT_DISPATCH ):
    1176             /*res = VarUI2FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,uiVal) );*/
    1177         case( VT_DECIMAL ):
    1178             /*res = VarUI2FromDec( V_UNION(ps,deiVal), &V_UNION(pd,uiVal) );*/
    1179         case( VT_UNKNOWN ):
    1180         default:
    1181             res = DISP_E_TYPEMISMATCH;
    1182             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1183             break;
    1184         }
    1185         break;
    1186 
    1187     case( VT_UINT ):
    1188     case( VT_UI4 ):
    1189         switch( vtFrom )
    1190         {
    1191         case( VT_I1 ):
    1192             res = VarUI4FromI1( V_UNION(ps,cVal), &V_UNION(pd,ulVal) );
    1193             break;
    1194         case( VT_I2 ):
    1195             res = VarUI4FromI2( V_UNION(ps,iVal), &V_UNION(pd,ulVal) );
    1196             break;
    1197         case( VT_INT ):
    1198         case( VT_I4 ):
    1199             res = VarUI4FromI4( V_UNION(ps,lVal), &V_UNION(pd,ulVal) );
    1200             break;
    1201         case( VT_UI1 ):
    1202             res = VarUI4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,ulVal) );
    1203             break;
    1204         case( VT_UI2 ):
    1205             res = VarUI4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,ulVal) );
    1206             break;
     1153                case( VT_UINT ):
     1154                case( VT_UI4 ):
     1155                        res = VarUI2FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,uiVal) );
     1156                        break;
     1157                case( VT_R4 ):
     1158                        res = VarUI2FromR4( V_UNION(ps,fltVal), &V_UNION(pd,uiVal) );
     1159                        break;
     1160                case( VT_R8 ):
     1161                        res = VarUI2FromR8( V_UNION(ps,dblVal), &V_UNION(pd,uiVal) );
     1162                        break;
     1163                case( VT_DATE ):
     1164                        res = VarUI2FromDate( V_UNION(ps,date), &V_UNION(pd,uiVal) );
     1165                        break;
     1166                case( VT_BOOL ):
     1167                        res = VarUI2FromBool( V_UNION(ps,boolVal), &V_UNION(pd,uiVal) );
     1168                        break;
     1169                case( VT_BSTR ):
     1170                        res = VarUI2FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,uiVal) );
     1171                        break;
     1172                case( VT_CY ):
     1173                        res = VarUI2FromCy( V_UNION(ps,cyVal), &V_UNION(pd,uiVal) );
     1174                        break;
     1175                case( VT_DISPATCH ):
     1176                        /*res = VarUI2FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,uiVal) );*/
     1177                case( VT_DECIMAL ):
     1178                        /*res = VarUI2FromDec( V_UNION(ps,deiVal), &V_UNION(pd,uiVal) );*/
     1179                case( VT_UNKNOWN ):
     1180                default:
     1181                        res = DISP_E_TYPEMISMATCH;
     1182                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1183                        break;
     1184                }
     1185                break;
     1186
     1187        case( VT_UINT ):
     1188        case( VT_UI4 ):
     1189                switch( vtFrom )
     1190                {
     1191                case( VT_I1 ):
     1192                        res = VarUI4FromI1( V_UNION(ps,cVal), &V_UNION(pd,ulVal) );
     1193                        break;
     1194                case( VT_I2 ):
     1195                        res = VarUI4FromI2( V_UNION(ps,iVal), &V_UNION(pd,ulVal) );
     1196                        break;
     1197                case( VT_INT ):
     1198                case( VT_I4 ):
     1199                        res = VarUI4FromI4( V_UNION(ps,lVal), &V_UNION(pd,ulVal) );
     1200                        break;
     1201                case( VT_UI1 ):
     1202                        res = VarUI4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,ulVal) );
     1203                        break;
     1204                case( VT_UI2 ):
     1205                        res = VarUI4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,ulVal) );
     1206                        break;
    12071207        case( VT_UI4 ):
    12081208            res = VariantCopy( pd, ps );
    12091209            break;
    1210         case( VT_R4 ):
    1211             res = VarUI4FromR4( V_UNION(ps,fltVal), &V_UNION(pd,ulVal) );
    1212             break;
    1213         case( VT_R8 ):
    1214             res = VarUI4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,ulVal) );
    1215             break;
    1216         case( VT_DATE ):
    1217             res = VarUI4FromDate( V_UNION(ps,date), &V_UNION(pd,ulVal) );
    1218             break;
    1219         case( VT_BOOL ):
    1220             res = VarUI4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,ulVal) );
    1221             break;
    1222         case( VT_BSTR ):
    1223             res = VarUI4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,ulVal) );
    1224             break;
    1225         case( VT_CY ):
    1226             res = VarUI4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,ulVal) );
    1227             break;
    1228         case( VT_DISPATCH ):
    1229             /*res = VarUI4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,ulVal) );*/
    1230         case( VT_DECIMAL ):
    1231             /*res = VarUI4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,ulVal) );*/
    1232         case( VT_UNKNOWN ):
    1233         default:
    1234             res = DISP_E_TYPEMISMATCH;
    1235             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1236             break;
    1237         }
    1238         break;
    1239 
    1240     case( VT_R4 ):
    1241         switch( vtFrom )
    1242         {
    1243         case( VT_I1 ):
    1244             res = VarR4FromI1( V_UNION(ps,cVal), &V_UNION(pd,fltVal) );
    1245             break;
    1246         case( VT_I2 ):
    1247             res = VarR4FromI2( V_UNION(ps,iVal), &V_UNION(pd,fltVal) );
    1248             break;
    1249         case( VT_INT ):
    1250         case( VT_I4 ):
    1251             res = VarR4FromI4( V_UNION(ps,lVal), &V_UNION(pd,fltVal) );
    1252             break;
    1253         case( VT_UI1 ):
    1254             res = VarR4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,fltVal) );
    1255             break;
    1256         case( VT_UI2 ):
    1257             res = VarR4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,fltVal) );
    1258             break;
    1259         case( VT_UINT ):
    1260         case( VT_UI4 ):
    1261             res = VarR4FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,fltVal) );
    1262             break;
     1210                case( VT_R4 ):
     1211                        res = VarUI4FromR4( V_UNION(ps,fltVal), &V_UNION(pd,ulVal) );
     1212                        break;
     1213                case( VT_R8 ):
     1214                        res = VarUI4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,ulVal) );
     1215                        break;
     1216                case( VT_DATE ):
     1217                        res = VarUI4FromDate( V_UNION(ps,date), &V_UNION(pd,ulVal) );
     1218                        break;
     1219                case( VT_BOOL ):
     1220                        res = VarUI4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,ulVal) );
     1221                        break;
     1222                case( VT_BSTR ):
     1223                        res = VarUI4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,ulVal) );
     1224                        break;
     1225                case( VT_CY ):
     1226                        res = VarUI4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,ulVal) );
     1227                        break;
     1228                case( VT_DISPATCH ):
     1229                        /*res = VarUI4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,ulVal) );*/
     1230                case( VT_DECIMAL ):
     1231                        /*res = VarUI4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,ulVal) );*/
     1232                case( VT_UNKNOWN ):
     1233                default:
     1234                        res = DISP_E_TYPEMISMATCH;
     1235                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1236                        break;
     1237                }
     1238                break;
     1239               
     1240        case( VT_R4 ):
     1241                switch( vtFrom )
     1242                {
     1243                case( VT_I1 ):
     1244                        res = VarR4FromI1( V_UNION(ps,cVal), &V_UNION(pd,fltVal) );
     1245                        break;
     1246                case( VT_I2 ):
     1247                        res = VarR4FromI2( V_UNION(ps,iVal), &V_UNION(pd,fltVal) );
     1248                        break;
     1249                case( VT_INT ):
     1250                case( VT_I4 ):
     1251                        res = VarR4FromI4( V_UNION(ps,lVal), &V_UNION(pd,fltVal) );
     1252                        break;
     1253                case( VT_UI1 ):
     1254                        res = VarR4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,fltVal) );
     1255                        break;
     1256                case( VT_UI2 ):
     1257                        res = VarR4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,fltVal) );
     1258                        break;
     1259                case( VT_UINT ):
     1260                case( VT_UI4 ):
     1261                        res = VarR4FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,fltVal) );
     1262                        break;
    12631263        case( VT_R4 ):
    12641264            res = VariantCopy( pd, ps );
    12651265            break;
    1266         case( VT_R8 ):
    1267             res = VarR4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,fltVal) );
    1268             break;
    1269         case( VT_DATE ):
    1270             res = VarR4FromDate( V_UNION(ps,date), &V_UNION(pd,fltVal) );
    1271             break;
    1272         case( VT_BOOL ):
    1273             res = VarR4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,fltVal) );
    1274             break;
    1275         case( VT_BSTR ):
    1276             res = VarR4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,fltVal) );
    1277             break;
    1278         case( VT_CY ):
    1279             res = VarR4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,fltVal) );
    1280             break;
    1281         case( VT_DISPATCH ):
    1282             /*res = VarR4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,fltVal) );*/
    1283         case( VT_DECIMAL ):
    1284             /*res = VarR4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,fltVal) );*/
    1285         case( VT_UNKNOWN ):
    1286         default:
    1287             res = DISP_E_TYPEMISMATCH;
    1288             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1289             break;
    1290         }
    1291         break;
    1292 
    1293     case( VT_R8 ):
    1294         switch( vtFrom )
    1295         {
    1296         case( VT_I1 ):
    1297             res = VarR8FromI1( V_UNION(ps,cVal), &V_UNION(pd,dblVal) );
    1298             break;
    1299         case( VT_I2 ):
    1300             res = VarR8FromI2( V_UNION(ps,iVal), &V_UNION(pd,dblVal) );
    1301             break;
    1302         case( VT_INT ):
    1303         case( VT_I4 ):
    1304             res = VarR8FromI4( V_UNION(ps,lVal), &V_UNION(pd,dblVal) );
    1305             break;
    1306         case( VT_UI1 ):
    1307             res = VarR8FromUI1( V_UNION(ps,bVal), &V_UNION(pd,dblVal) );
    1308             break;
    1309         case( VT_UI2 ):
    1310             res = VarR8FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,dblVal) );
    1311             break;
    1312         case( VT_UINT ):
    1313         case( VT_UI4 ):
    1314             res = VarR8FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,dblVal) );
    1315             break;
    1316         case( VT_R4 ):
    1317             res = VarR8FromR4( V_UNION(ps,fltVal), &V_UNION(pd,dblVal) );
    1318             break;
     1266                case( VT_R8 ):
     1267                        res = VarR4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,fltVal) );
     1268                        break;
     1269                case( VT_DATE ):
     1270                        res = VarR4FromDate( V_UNION(ps,date), &V_UNION(pd,fltVal) );
     1271                        break;
     1272                case( VT_BOOL ):
     1273                        res = VarR4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,fltVal) );
     1274                        break;
     1275                case( VT_BSTR ):
     1276                        res = VarR4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,fltVal) );
     1277                        break;
     1278                case( VT_CY ):
     1279                        res = VarR4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,fltVal) );
     1280                        break;
     1281                case( VT_DISPATCH ):
     1282                        /*res = VarR4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,fltVal) );*/
     1283                case( VT_DECIMAL ):
     1284                        /*res = VarR4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,fltVal) );*/
     1285                case( VT_UNKNOWN ):
     1286                default:
     1287                        res = DISP_E_TYPEMISMATCH;
     1288                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1289                        break;
     1290                }
     1291                break;
     1292
     1293        case( VT_R8 ):
     1294                switch( vtFrom )
     1295                {
     1296                case( VT_I1 ):
     1297                        res = VarR8FromI1( V_UNION(ps,cVal), &V_UNION(pd,dblVal) );
     1298                        break;
     1299                case( VT_I2 ):
     1300                        res = VarR8FromI2( V_UNION(ps,iVal), &V_UNION(pd,dblVal) );
     1301                        break;
     1302                case( VT_INT ):
     1303                case( VT_I4 ):
     1304                        res = VarR8FromI4( V_UNION(ps,lVal), &V_UNION(pd,dblVal) );
     1305                        break;
     1306                case( VT_UI1 ):
     1307                        res = VarR8FromUI1( V_UNION(ps,bVal), &V_UNION(pd,dblVal) );
     1308                        break;
     1309                case( VT_UI2 ):
     1310                        res = VarR8FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,dblVal) );
     1311                        break;
     1312                case( VT_UINT ):
     1313                case( VT_UI4 ):
     1314                        res = VarR8FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,dblVal) );
     1315                        break;
     1316                case( VT_R4 ):
     1317                        res = VarR8FromR4( V_UNION(ps,fltVal), &V_UNION(pd,dblVal) );
     1318                        break;
    13191319        case( VT_R8 ):
    13201320            res = VariantCopy( pd, ps );
    13211321            break;
    1322         case( VT_DATE ):
    1323             res = VarR8FromDate( V_UNION(ps,date), &V_UNION(pd,dblVal) );
    1324             break;
    1325         case( VT_BOOL ):
    1326             res = VarR8FromBool( V_UNION(ps,boolVal), &V_UNION(pd,dblVal) );
    1327             break;
    1328         case( VT_BSTR ):
    1329             res = VarR8FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,dblVal) );
    1330             break;
    1331         case( VT_CY ):
    1332             res = VarR8FromCy( V_UNION(ps,cyVal), &V_UNION(pd,dblVal) );
    1333             break;
    1334         case( VT_DISPATCH ):
    1335             /*res = VarR8FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,dblVal) );*/
    1336         case( VT_DECIMAL ):
    1337             /*res = VarR8FromDec( V_UNION(ps,deiVal), &V_UNION(pd,dblVal) );*/
    1338         case( VT_UNKNOWN ):
    1339         default:
    1340             res = DISP_E_TYPEMISMATCH;
    1341             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1342             break;
    1343         }
    1344         break;
    1345 
    1346     case( VT_DATE ):
    1347         switch( vtFrom )
    1348         {
    1349         case( VT_I1 ):
    1350             res = VarDateFromI1( V_UNION(ps,cVal), &V_UNION(pd,date) );
    1351             break;
    1352         case( VT_I2 ):
    1353             res = VarDateFromI2( V_UNION(ps,iVal), &V_UNION(pd,date) );
    1354             break;
    1355         case( VT_INT ):
    1356             res = VarDateFromInt( V_UNION(ps,intVal), &V_UNION(pd,date) );
    1357             break;
    1358         case( VT_I4 ):
    1359             res = VarDateFromI4( V_UNION(ps,lVal), &V_UNION(pd,date) );
    1360             break;
    1361         case( VT_UI1 ):
    1362             res = VarDateFromUI1( V_UNION(ps,bVal), &V_UNION(pd,date) );
    1363             break;
    1364         case( VT_UI2 ):
    1365             res = VarDateFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,date) );
    1366             break;
    1367         case( VT_UINT ):
    1368             res = VarDateFromUint( V_UNION(ps,uintVal), &V_UNION(pd,date) );
    1369             break;
    1370         case( VT_UI4 ):
    1371             res = VarDateFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,date) );
    1372             break;
    1373         case( VT_R4 ):
    1374             res = VarDateFromR4( V_UNION(ps,fltVal), &V_UNION(pd,date) );
    1375             break;
    1376         case( VT_R8 ):
    1377             res = VarDateFromR8( V_UNION(ps,dblVal), &V_UNION(pd,date) );
    1378             break;
     1322                case( VT_DATE ):
     1323                        res = VarR8FromDate( V_UNION(ps,date), &V_UNION(pd,dblVal) );
     1324                        break;
     1325                case( VT_BOOL ):
     1326                        res = VarR8FromBool( V_UNION(ps,boolVal), &V_UNION(pd,dblVal) );
     1327                        break;
     1328                case( VT_BSTR ):
     1329                        res = VarR8FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,dblVal) );
     1330                        break;
     1331                case( VT_CY ):
     1332                        res = VarR8FromCy( V_UNION(ps,cyVal), &V_UNION(pd,dblVal) );
     1333                        break;
     1334                case( VT_DISPATCH ):
     1335                        /*res = VarR8FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,dblVal) );*/
     1336                case( VT_DECIMAL ):
     1337                        /*res = VarR8FromDec( V_UNION(ps,deiVal), &V_UNION(pd,dblVal) );*/
     1338                case( VT_UNKNOWN ):
     1339                default:
     1340                        res = DISP_E_TYPEMISMATCH;
     1341                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1342                        break;
     1343                }
     1344                break;
     1345
     1346        case( VT_DATE ):
     1347                switch( vtFrom )
     1348                {
     1349                case( VT_I1 ):
     1350                        res = VarDateFromI1( V_UNION(ps,cVal), &V_UNION(pd,date) );
     1351                        break;
     1352                case( VT_I2 ):
     1353                        res = VarDateFromI2( V_UNION(ps,iVal), &V_UNION(pd,date) );
     1354                        break;
     1355                case( VT_INT ):
     1356                        res = VarDateFromInt( V_UNION(ps,intVal), &V_UNION(pd,date) );
     1357                        break;
     1358                case( VT_I4 ):
     1359                        res = VarDateFromI4( V_UNION(ps,lVal), &V_UNION(pd,date) );
     1360                        break;
     1361                case( VT_UI1 ):
     1362                        res = VarDateFromUI1( V_UNION(ps,bVal), &V_UNION(pd,date) );
     1363                        break;
     1364                case( VT_UI2 ):
     1365                        res = VarDateFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,date) );
     1366                        break;
     1367                case( VT_UINT ):
     1368                        res = VarDateFromUint( V_UNION(ps,uintVal), &V_UNION(pd,date) );
     1369                        break;
     1370                case( VT_UI4 ):
     1371                        res = VarDateFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,date) );
     1372                        break;
     1373                case( VT_R4 ):
     1374                        res = VarDateFromR4( V_UNION(ps,fltVal), &V_UNION(pd,date) );
     1375                        break;
     1376                case( VT_R8 ):
     1377                        res = VarDateFromR8( V_UNION(ps,dblVal), &V_UNION(pd,date) );
     1378                        break;
    13791379        case( VT_DATE ):
    13801380            res = VariantCopy( pd, ps );
    13811381            break;
    1382         case( VT_BOOL ):
    1383             res = VarDateFromBool( V_UNION(ps,boolVal), &V_UNION(pd,date) );
    1384             break;
    1385         case( VT_BSTR ):
    1386             res = VarDateFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,date) );
    1387             break;
    1388         case( VT_CY ):
    1389             res = VarDateFromCy( V_UNION(ps,cyVal), &V_UNION(pd,date) );
    1390             break;
    1391         case( VT_DISPATCH ):
    1392             /*res = VarDateFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,date) );*/
    1393         case( VT_DECIMAL ):
    1394             /*res = VarDateFromDec( V_UNION(ps,deiVal), &V_UNION(pd,date) );*/
    1395         case( VT_UNKNOWN ):
    1396         default:
    1397             res = DISP_E_TYPEMISMATCH;
    1398             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1399             break;
    1400         }
    1401         break;
    1402 
    1403     case( VT_BOOL ):
    1404         switch( vtFrom )
    1405         {
    1406         case( VT_I1 ):
    1407             res = VarBoolFromI1( V_UNION(ps,cVal), &V_UNION(pd,boolVal) );
    1408             break;
    1409         case( VT_I2 ):
    1410             res = VarBoolFromI2( V_UNION(ps,iVal), &V_UNION(pd,boolVal) );
    1411             break;
    1412         case( VT_INT ):
    1413             res = VarBoolFromInt( V_UNION(ps,intVal), &V_UNION(pd,boolVal) );
    1414             break;
    1415         case( VT_I4 ):
    1416             res = VarBoolFromI4( V_UNION(ps,lVal), &V_UNION(pd,boolVal) );
    1417             break;
    1418         case( VT_UI1 ):
    1419             res = VarBoolFromUI1( V_UNION(ps,bVal), &V_UNION(pd,boolVal) );
    1420             break;
    1421         case( VT_UI2 ):
    1422             res = VarBoolFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,boolVal) );
    1423             break;
    1424         case( VT_UINT ):
    1425             res = VarBoolFromUint( V_UNION(ps,uintVal), &V_UNION(pd,boolVal) );
    1426             break;
    1427         case( VT_UI4 ):
    1428             res = VarBoolFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,boolVal) );
    1429             break;
    1430         case( VT_R4 ):
    1431             res = VarBoolFromR4( V_UNION(ps,fltVal), &V_UNION(pd,boolVal) );
    1432             break;
    1433         case( VT_R8 ):
    1434             res = VarBoolFromR8( V_UNION(ps,dblVal), &V_UNION(pd,boolVal) );
    1435             break;
    1436         case( VT_DATE ):
    1437             res = VarBoolFromDate( V_UNION(ps,date), &V_UNION(pd,boolVal) );
    1438             break;
     1382                case( VT_BOOL ):
     1383                        res = VarDateFromBool( V_UNION(ps,boolVal), &V_UNION(pd,date) );
     1384                        break;
     1385                case( VT_BSTR ):
     1386                        res = VarDateFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,date) );
     1387                        break;
     1388                case( VT_CY ):
     1389                        res = VarDateFromCy( V_UNION(ps,cyVal), &V_UNION(pd,date) );
     1390                        break;
     1391                case( VT_DISPATCH ):
     1392                        /*res = VarDateFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,date) );*/
     1393                case( VT_DECIMAL ):
     1394                        /*res = VarDateFromDec( V_UNION(ps,deiVal), &V_UNION(pd,date) );*/
     1395                case( VT_UNKNOWN ):
     1396                default:
     1397                        res = DISP_E_TYPEMISMATCH;
     1398                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1399                        break;
     1400                }
     1401                break;
     1402
     1403        case( VT_BOOL ):
     1404                switch( vtFrom )
     1405                {
     1406                case( VT_I1 ):
     1407                        res = VarBoolFromI1( V_UNION(ps,cVal), &V_UNION(pd,boolVal) );
     1408                        break;
     1409                case( VT_I2 ):
     1410                        res = VarBoolFromI2( V_UNION(ps,iVal), &V_UNION(pd,boolVal) );
     1411                        break;
     1412                case( VT_INT ):
     1413                        res = VarBoolFromInt( V_UNION(ps,intVal), &V_UNION(pd,boolVal) );
     1414                        break;
     1415                case( VT_I4 ):
     1416                        res = VarBoolFromI4( V_UNION(ps,lVal), &V_UNION(pd,boolVal) );
     1417                        break;
     1418                case( VT_UI1 ):
     1419                        res = VarBoolFromUI1( V_UNION(ps,bVal), &V_UNION(pd,boolVal) );
     1420                        break;
     1421                case( VT_UI2 ):
     1422                        res = VarBoolFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,boolVal) );
     1423                        break;
     1424                case( VT_UINT ):
     1425                        res = VarBoolFromUint( V_UNION(ps,uintVal), &V_UNION(pd,boolVal) );
     1426                        break;
     1427                case( VT_UI4 ):
     1428                        res = VarBoolFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,boolVal) );
     1429                        break;
     1430                case( VT_R4 ):
     1431                        res = VarBoolFromR4( V_UNION(ps,fltVal), &V_UNION(pd,boolVal) );
     1432                        break;
     1433                case( VT_R8 ):
     1434                        res = VarBoolFromR8( V_UNION(ps,dblVal), &V_UNION(pd,boolVal) );
     1435                        break;
     1436                case( VT_DATE ):
     1437                        res = VarBoolFromDate( V_UNION(ps,date), &V_UNION(pd,boolVal) );
     1438                        break;
    14391439        case( VT_BOOL ):
    14401440            res = VariantCopy( pd, ps );
    14411441            break;
    1442         case( VT_BSTR ):
    1443             res = VarBoolFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,boolVal) );
    1444             break;
    1445         case( VT_CY ):
    1446             res = VarBoolFromCy( V_UNION(ps,cyVal), &V_UNION(pd,boolVal) );
    1447             break;
    1448         case( VT_DISPATCH ):
    1449             /*res = VarBoolFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,boolVal) );*/
    1450         case( VT_DECIMAL ):
    1451             /*res = VarBoolFromDec( V_UNION(ps,deiVal), &V_UNION(pd,boolVal) );*/
    1452         case( VT_UNKNOWN ):
    1453         default:
    1454             res = DISP_E_TYPEMISMATCH;
    1455             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1456             break;
    1457         }
    1458         break;
    1459 
    1460     case( VT_BSTR ):
    1461         switch( vtFrom )
    1462         {
    1463         case( VT_EMPTY ):
    1464             if ((V_UNION(pd,bstrVal) = SysAllocStringLen(NULL, 0)))
    1465                 res = S_OK;
    1466             else
    1467                 res = E_OUTOFMEMORY;
    1468             break;
    1469         case( VT_I1 ):
    1470             res = VarBstrFromI1( V_UNION(ps,cVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1471             break;
    1472         case( VT_I2 ):
    1473             res = VarBstrFromI2( V_UNION(ps,iVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1474             break;
    1475         case( VT_INT ):
    1476             res = VarBstrFromInt( V_UNION(ps,intVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1477             break;
    1478         case( VT_I4 ):
    1479             res = VarBstrFromI4( V_UNION(ps,lVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1480             break;
    1481         case( VT_UI1 ):
    1482             res = VarBstrFromUI1( V_UNION(ps,bVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1483             break;
    1484         case( VT_UI2 ):
    1485             res = VarBstrFromUI2( V_UNION(ps,uiVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1486             break;
    1487         case( VT_UINT ):
    1488             res = VarBstrFromUint( V_UNION(ps,uintVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1489             break;
    1490         case( VT_UI4 ):
    1491             res = VarBstrFromUI4( V_UNION(ps,ulVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1492             break;
    1493         case( VT_R4 ):
    1494             res = VarBstrFromR4( V_UNION(ps,fltVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1495             break;
    1496         case( VT_R8 ):
    1497             res = VarBstrFromR8( V_UNION(ps,dblVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1498             break;
    1499         case( VT_DATE ):
    1500             res = VarBstrFromDate( V_UNION(ps,date), lcid, 0, &V_UNION(pd,bstrVal) );
    1501             break;
    1502         case( VT_BOOL ):
    1503             res = VarBstrFromBool( V_UNION(ps,boolVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1504             break;
    1505         case( VT_BSTR ):
    1506             res = VariantCopy( pd, ps );
    1507             break;
    1508         case( VT_CY ):
    1509             res = VarBstrFromCy( V_UNION(ps,cyVal), lcid, 0, &V_UNION(pd,bstrVal) );
    1510             break;
    1511         case( VT_DISPATCH ):
    1512             /*res = VarBstrFromDisp( V_UNION(ps,pdispVal), lcid, 0, &(pd,bstrVal) );*/
    1513         case( VT_DECIMAL ):
    1514             /*res = VarBstrFromDec( V_UNION(ps,deiVal), lcid, 0, &(pd,bstrVal) );*/
    1515         case( VT_UNKNOWN ):
    1516         default:
    1517             res = DISP_E_TYPEMISMATCH;
    1518             FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1519             break;
    1520         }
    1521         break;
     1442                case( VT_BSTR ):
     1443                        res = VarBoolFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,boolVal) );
     1444                        break;
     1445                case( VT_CY ):
     1446                        res = VarBoolFromCy( V_UNION(ps,cyVal), &V_UNION(pd,boolVal) );
     1447                        break;
     1448                case( VT_DISPATCH ):
     1449                        /*res = VarBoolFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,boolVal) );*/
     1450                case( VT_DECIMAL ):
     1451                        /*res = VarBoolFromDec( V_UNION(ps,deiVal), &V_UNION(pd,boolVal) );*/
     1452                case( VT_UNKNOWN ):
     1453                default:
     1454                        res = DISP_E_TYPEMISMATCH;
     1455                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1456                        break;
     1457                }
     1458                break;
     1459
     1460        case( VT_BSTR ):
     1461                switch( vtFrom )
     1462                {
     1463                case( VT_EMPTY ):
     1464                        if ((V_UNION(pd,bstrVal) = SysAllocStringLen(NULL, 0)))
     1465                                res = S_OK;
     1466                        else
     1467                                res = E_OUTOFMEMORY;
     1468                        break;
     1469                case( VT_I1 ):
     1470                        res = VarBstrFromI1( V_UNION(ps,cVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1471                        break;
     1472                case( VT_I2 ):
     1473                        res = VarBstrFromI2( V_UNION(ps,iVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1474                        break;
     1475                case( VT_INT ):
     1476                        res = VarBstrFromInt( V_UNION(ps,intVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1477                        break;
     1478                case( VT_I4 ):
     1479                        res = VarBstrFromI4( V_UNION(ps,lVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1480                        break;
     1481                case( VT_UI1 ):
     1482                        res = VarBstrFromUI1( V_UNION(ps,bVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1483                        break;
     1484                case( VT_UI2 ):
     1485                        res = VarBstrFromUI2( V_UNION(ps,uiVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1486                        break;
     1487                case( VT_UINT ):
     1488                        res = VarBstrFromUint( V_UNION(ps,uintVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1489                        break;
     1490                case( VT_UI4 ):
     1491                        res = VarBstrFromUI4( V_UNION(ps,ulVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1492                        break;
     1493                case( VT_R4 ):
     1494                        res = VarBstrFromR4( V_UNION(ps,fltVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1495                        break;
     1496                case( VT_R8 ):
     1497                        res = VarBstrFromR8( V_UNION(ps,dblVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1498                        break;
     1499                case( VT_DATE ):
     1500                        res = VarBstrFromDate( V_UNION(ps,date), lcid, 0, &V_UNION(pd,bstrVal) );
     1501                        break;
     1502                case( VT_BOOL ):
     1503                        res = VarBstrFromBool( V_UNION(ps,boolVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1504                        break;
     1505                case( VT_BSTR ):
     1506                        res = VariantCopy( pd, ps );
     1507                        break;
     1508                case( VT_CY ):
     1509                        res = VarBstrFromCy( V_UNION(ps,cyVal), lcid, 0, &V_UNION(pd,bstrVal) );
     1510                        break;
     1511                case( VT_DISPATCH ):
     1512                        /*res = VarBstrFromDisp( V_UNION(ps,pdispVal), lcid, 0, &(pd,bstrVal) );*/
     1513                case( VT_DECIMAL ):
     1514                        /*res = VarBstrFromDec( V_UNION(ps,deiVal), lcid, 0, &(pd,bstrVal) );*/
     1515                case( VT_UNKNOWN ):
     1516                default:
     1517                        res = DISP_E_TYPEMISMATCH;
     1518                        FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1519                        break;
     1520                }
     1521                break;
    15221522
    15231523     case( VT_CY ):
    1524     switch( vtFrom )
    1525       {
    1526       case( VT_I1 ):
    1527          res = VarCyFromI1( V_UNION(ps,cVal), &V_UNION(pd,cyVal) );
    1528          break;
    1529       case( VT_I2 ):
    1530          res = VarCyFromI2( V_UNION(ps,iVal), &V_UNION(pd,cyVal) );
    1531          break;
    1532       case( VT_INT ):
    1533          res = VarCyFromInt( V_UNION(ps,intVal), &V_UNION(pd,cyVal) );
    1534          break;
    1535       case( VT_I4 ):
    1536          res = VarCyFromI4( V_UNION(ps,lVal), &V_UNION(pd,cyVal) );
    1537          break;
    1538       case( VT_UI1 ):
    1539          res = VarCyFromUI1( V_UNION(ps,bVal), &V_UNION(pd,cyVal) );
    1540          break;
    1541       case( VT_UI2 ):
    1542          res = VarCyFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,cyVal) );
    1543          break;
    1544       case( VT_UINT ):
    1545          res = VarCyFromUint( V_UNION(ps,uintVal), &V_UNION(pd,cyVal) );
    1546          break;
    1547       case( VT_UI4 ):
    1548          res = VarCyFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,cyVal) );
    1549          break;
    1550       case( VT_R4 ):
    1551          res = VarCyFromR4( V_UNION(ps,fltVal), &V_UNION(pd,cyVal) );
    1552          break;
    1553       case( VT_R8 ):
    1554          res = VarCyFromR8( V_UNION(ps,dblVal), &V_UNION(pd,cyVal) );
    1555          break;
    1556       case( VT_DATE ):
    1557          res = VarCyFromDate( V_UNION(ps,date), &V_UNION(pd,cyVal) );
    1558          break;
    1559       case( VT_BOOL ):
    1560          res = VarCyFromBool( V_UNION(ps,date), &V_UNION(pd,cyVal) );
    1561          break;
    1562       case( VT_CY ):
    1563          res = VariantCopy( pd, ps );
    1564          break;
    1565       case( VT_BSTR ):
    1566          res = VarCyFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,cyVal) );
    1567          break;
    1568       case( VT_DISPATCH ):
    1569          /*res = VarCyFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,cyVal) );*/
    1570       case( VT_DECIMAL ):
    1571          /*res = VarCyFromDec( V_UNION(ps,deiVal), &V_UNION(pd,cyVal) );*/
    1572          break;
    1573       case( VT_UNKNOWN ):
    1574       default:
    1575          res = DISP_E_TYPEMISMATCH;
    1576          FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1577          break;
    1578       }
    1579     break;
    1580 
    1581     default:
    1582         res = DISP_E_TYPEMISMATCH;
    1583         FIXME("Coercion from %d to %d\n", vtFrom, vt );
    1584         break;
    1585     }
    1586 
    1587     return res;
    1588 }
    1589 
    1590 /******************************************************************************
    1591  *      ValidateVtRange [INTERNAL]
     1524        switch( vtFrom )
     1525          {
     1526          case( VT_I1 ):
     1527             res = VarCyFromI1( V_UNION(ps,cVal), &V_UNION(pd,cyVal) );
     1528             break;
     1529          case( VT_I2 ):
     1530             res = VarCyFromI2( V_UNION(ps,iVal), &V_UNION(pd,cyVal) );
     1531             break;
     1532          case( VT_INT ):
     1533             res = VarCyFromInt( V_UNION(ps,intVal), &V_UNION(pd,cyVal) );
     1534             break;
     1535          case( VT_I4 ):
     1536             res = VarCyFromI4( V_UNION(ps,lVal), &V_UNION(pd,cyVal) );
     1537             break;
     1538          case( VT_UI1 ):
     1539             res = VarCyFromUI1( V_UNION(ps,bVal), &V_UNION(pd,cyVal) );
     1540             break;
     1541          case( VT_UI2 ):
     1542             res = VarCyFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,cyVal) );
     1543             break;
     1544          case( VT_UINT ):
     1545             res = VarCyFromUint( V_UNION(ps,uintVal), &V_UNION(pd,cyVal) );
     1546             break;
     1547          case( VT_UI4 ):
     1548             res = VarCyFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,cyVal) );
     1549             break;
     1550          case( VT_R4 ):
     1551             res = VarCyFromR4( V_UNION(ps,fltVal), &V_UNION(pd,cyVal) );
     1552             break;
     1553          case( VT_R8 ):
     1554             res = VarCyFromR8( V_UNION(ps,dblVal), &V_UNION(pd,cyVal) );
     1555             break;
     1556          case( VT_DATE ):
     1557             res = VarCyFromDate( V_UNION(ps,date), &V_UNION(pd,cyVal) );
     1558             break;
     1559          case( VT_BOOL ):
     1560             res = VarCyFromBool( V_UNION(ps,date), &V_UNION(pd,cyVal) );
     1561             break;
     1562          case( VT_CY ):
     1563             res = VariantCopy( pd, ps );
     1564             break;
     1565          case( VT_BSTR ):
     1566             res = VarCyFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,cyVal) );
     1567             break;
     1568          case( VT_DISPATCH ):
     1569             /*res = VarCyFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,cyVal) );*/
     1570          case( VT_DECIMAL ):
     1571             /*res = VarCyFromDec( V_UNION(ps,deiVal), &V_UNION(pd,cyVal) );*/
     1572             break;
     1573          case( VT_UNKNOWN ):
     1574          default:
     1575             res = DISP_E_TYPEMISMATCH;
     1576             FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1577             break;
     1578          }
     1579        break;
     1580
     1581        default:
     1582                res = DISP_E_TYPEMISMATCH;
     1583                FIXME("Coercion from %d to %d\n", vtFrom, vt );
     1584                break;
     1585        }
     1586       
     1587        return res;
     1588}
     1589
     1590/******************************************************************************
     1591 *              ValidateVtRange [INTERNAL]
    15921592 *
    15931593 * Used internally by the hi-level Variant API to determine
     
    16081608
    16091609/******************************************************************************
    1610  *      ValidateVartype [INTERNAL]
     1610 *              ValidateVartype [INTERNAL]
    16111611 *
    16121612 * Used internally by the hi-level Variant API to determine
     
    16151615static HRESULT WINAPI ValidateVariantType( VARTYPE vt )
    16161616{
    1617     HRESULT res = S_OK;
    1618 
    1619     /* check if we have a valid argument.
    1620     */
    1621     if( vt & VT_BYREF )
     1617        HRESULT res = S_OK;
     1618
     1619        /* check if we have a valid argument.
     1620        */
     1621        if( vt & VT_BYREF )
    16221622    {
    16231623        /* if by reference check that the type is in
     
    16261626        if( ( vt & VT_TYPEMASK ) == VT_EMPTY ||
    16271627            ( vt & VT_TYPEMASK ) == VT_NULL ||
    1628             ( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
    1629         {
    1630             res = E_INVALIDARG;
    1631         }
    1632 
     1628                        ( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
     1629                {
     1630                        res = E_INVALIDARG;
     1631                }
     1632                       
    16331633    }
    16341634    else
     
    16361636        res = ValidateVtRange( vt );
    16371637    }
    1638 
    1639     return res;
    1640 }
    1641 
    1642 /******************************************************************************
    1643  *      ValidateVt  [INTERNAL]
     1638               
     1639        return res;
     1640}
     1641
     1642/******************************************************************************
     1643 *              ValidateVt      [INTERNAL]
    16441644 *
    16451645 * Used internally by the hi-level Variant API to determine
     
    16481648static HRESULT WINAPI ValidateVt( VARTYPE vt )
    16491649{
    1650     HRESULT res = S_OK;
    1651 
    1652     /* check if we have a valid argument.
    1653     */
    1654     if( vt & VT_BYREF )
     1650        HRESULT res = S_OK;
     1651
     1652        /* check if we have a valid argument.
     1653        */
     1654        if( vt & VT_BYREF )
    16551655    {
    16561656        /* if by reference check that the type is in
     
    16591659        if( ( vt & VT_TYPEMASK ) == VT_EMPTY ||
    16601660            ( vt & VT_TYPEMASK ) == VT_NULL ||
    1661             ( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
    1662         {
    1663             res = DISP_E_BADVARTYPE;
    1664         }
    1665 
     1661                        ( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
     1662                {
     1663                        res = DISP_E_BADVARTYPE;
     1664                }
     1665                       
    16661666    }
    16671667    else
     
    16691669        res = ValidateVtRange( vt );
    16701670    }
    1671 
    1672     return res;
    1673 }
    1674 
    1675 
    1676 
    1677 
    1678 
    1679 /******************************************************************************
    1680  *      VariantInit [OLEAUT32.8]
     1671               
     1672        return res;
     1673}
     1674
     1675
     1676
     1677
     1678
     1679/******************************************************************************
     1680 *              VariantInit     [OLEAUT32.8]
    16811681 *
    16821682 * Initializes the Variant.  Unlike VariantClear it does not interpret the current
     
    16941694
    16951695/******************************************************************************
    1696  *      VariantClear    [OLEAUT32.9]
     1696 *              VariantClear    [OLEAUT32.9]
    16971697 *
    16981698 * This function clears the VARIANT by setting the vt field to VT_EMPTY. It also
    1699  * sets the wReservedX field to 0.  The current contents of the VARIANT are
     1699 * sets the wReservedX field to 0.      The current contents of the VARIANT are
    17001700 * freed.  If the vt is VT_BSTR the string is freed. If VT_DISPATCH the object is
    17011701 * released. If VT_ARRAY the array is freed.
     
    17161716      if ( (V_VT(pvarg) & VT_ARRAY) != 0)
    17171717      {
    1718     SafeArrayDestroy(V_UNION(pvarg,parray));
     1718        SafeArrayDestroy(V_UNION(pvarg,parray));
    17191719      }
    17201720      else
    17211721      {
    1722     switch( V_VT(pvarg) & VT_TYPEMASK )
    1723     {
    1724       case( VT_BSTR ):
    1725         SysFreeString( V_UNION(pvarg,bstrVal) );
    1726         break;
    1727       case( VT_DISPATCH ):
    1728         if(V_UNION(pvarg,pdispVal)!=NULL)
    1729           ICOM_CALL(Release,V_UNION(pvarg,pdispVal));
    1730         break;
    1731       case( VT_VARIANT ):
    1732         VariantClear(V_UNION(pvarg,pvarVal));
    1733         break;
    1734       case( VT_UNKNOWN ):
    1735         if(V_UNION(pvarg,punkVal)!=NULL)
    1736           ICOM_CALL(Release,V_UNION(pvarg,punkVal));
    1737         break;
    1738       case( VT_SAFEARRAY ):
    1739         SafeArrayDestroy(V_UNION(pvarg,parray));
    1740         break;
    1741       default:
    1742         break;
    1743     }
     1722        switch( V_VT(pvarg) & VT_TYPEMASK )
     1723        {
     1724          case( VT_BSTR ):
     1725            SysFreeString( V_UNION(pvarg,bstrVal) );
     1726            break;
     1727          case( VT_DISPATCH ):
     1728            if(V_UNION(pvarg,pdispVal)!=NULL)
     1729              ICOM_CALL(Release,V_UNION(pvarg,pdispVal));
     1730            break;
     1731          case( VT_VARIANT ):
     1732            VariantClear(V_UNION(pvarg,pvarVal));
     1733            break;
     1734          case( VT_UNKNOWN ):
     1735            if(V_UNION(pvarg,punkVal)!=NULL)
     1736              ICOM_CALL(Release,V_UNION(pvarg,punkVal));
     1737            break;
     1738          case( VT_SAFEARRAY ):
     1739            SafeArrayDestroy(V_UNION(pvarg,parray));
     1740            break;
     1741          default:
     1742            break;
     1743        }
    17441744      }
    17451745    }
    1746 
     1746       
    17471747    /*
    17481748     * Empty all the fields and mark the type as empty.
     
    17561756
    17571757/******************************************************************************
    1758  *      VariantCopy [OLEAUT32.10]
     1758 *              VariantCopy     [OLEAUT32.10]
    17591759 *
    17601760 * Frees up the designation variant and makes a copy of the source.
     
    17741774  {
    17751775    res = VariantClear( pvargDest );
    1776 
     1776               
    17771777    if( res == S_OK )
    17781778    {
    17791779      if( V_VT(pvargSrc) & VT_BYREF )
    17801780      {
    1781     /* In the case of byreference we only need
    1782     * to copy the pointer.
    1783     */
    1784     pvargDest->n1.n2.n3 = pvargSrc->n1.n2.n3;
    1785     V_VT(pvargDest) = V_VT(pvargSrc);
     1781        /* In the case of byreference we only need
     1782        * to copy the pointer.
     1783        */
     1784        pvargDest->n1.n2.n3 = pvargSrc->n1.n2.n3;
     1785        V_VT(pvargDest) = V_VT(pvargSrc);
    17861786      }
    17871787      else
    17881788      {
    1789     /*
    1790     * The VT_ARRAY flag is another way to designate a safe array.
    1791     */
    1792     if (V_VT(pvargSrc) & VT_ARRAY)
    1793     {
    1794       SafeArrayCopy(V_UNION(pvargSrc,parray), &V_UNION(pvargDest,parray));
    1795     }
    1796     else
    1797     {
    1798       /* In the case of by value we need to
    1799        * copy the actuall value. In the case of
    1800        * VT_BSTR a copy of the string is made,
    1801        * if VT_DISPATCH or VT_IUNKNOWN AddReff is
    1802        * called to increment the object's reference count.
    1803        */
    1804       switch( V_VT(pvargSrc) & VT_TYPEMASK )
    1805       {
    1806         case( VT_BSTR ):
    1807           V_UNION(pvargDest,bstrVal) = SysAllocString( V_UNION(pvargSrc,bstrVal) );
    1808           break;
    1809         case( VT_DISPATCH ):
    1810           V_UNION(pvargDest,pdispVal) = V_UNION(pvargSrc,pdispVal);
    1811           if (V_UNION(pvargDest,pdispVal)!=NULL)
    1812         ICOM_CALL(AddRef,V_UNION(pvargDest,pdispVal));
    1813           break;
    1814         case( VT_VARIANT ):
    1815           VariantCopy(V_UNION(pvargDest,pvarVal),V_UNION(pvargSrc,pvarVal));
    1816           break;
    1817         case( VT_UNKNOWN ):
    1818           V_UNION(pvargDest,punkVal) = V_UNION(pvargSrc,punkVal);
    1819           if (V_UNION(pvargDest,pdispVal)!=NULL)
    1820         ICOM_CALL(AddRef,V_UNION(pvargDest,punkVal));
    1821           break;
    1822         case( VT_SAFEARRAY ):
    1823           SafeArrayCopy(V_UNION(pvargSrc,parray), &V_UNION(pvargDest,parray));
    1824           break;
    1825         default:
    1826           pvargDest->n1.n2.n3 = pvargSrc->n1.n2.n3;
    1827           break;
    1828       }
    1829     }
    1830 
    1831     V_VT(pvargDest) = V_VT(pvargSrc);
    1832       }
     1789        /*
     1790        * The VT_ARRAY flag is another way to designate a safe array.
     1791        */
     1792        if (V_VT(pvargSrc) & VT_ARRAY)
     1793        {
     1794          SafeArrayCopy(V_UNION(pvargSrc,parray), &V_UNION(pvargDest,parray));
     1795        }
     1796        else
     1797        {
     1798          /* In the case of by value we need to
     1799           * copy the actuall value. In the case of
     1800           * VT_BSTR a copy of the string is made,
     1801           * if VT_DISPATCH or VT_IUNKNOWN AddReff is
     1802           * called to increment the object's reference count.
     1803           */
     1804          switch( V_VT(pvargSrc) & VT_TYPEMASK )
     1805          {
     1806            case( VT_BSTR ):
     1807              V_UNION(pvargDest,bstrVal) = SysAllocString( V_UNION(pvargSrc,bstrVal) );
     1808              break;
     1809            case( VT_DISPATCH ):
     1810              V_UNION(pvargDest,pdispVal) = V_UNION(pvargSrc,pdispVal);
     1811              if (V_UNION(pvargDest,pdispVal)!=NULL)
     1812                ICOM_CALL(AddRef,V_UNION(pvargDest,pdispVal));
     1813              break;
     1814            case( VT_VARIANT ):
     1815              VariantCopy(V_UNION(pvargDest,pvarVal),V_UNION(pvargSrc,pvarVal));
     1816              break;
     1817            case( VT_UNKNOWN ):
     1818              V_UNION(pvargDest,punkVal) = V_UNION(pvargSrc,punkVal);
     1819              if (V_UNION(pvargDest,pdispVal)!=NULL)
     1820                ICOM_CALL(AddRef,V_UNION(pvargDest,punkVal));
     1821              break;
     1822            case( VT_SAFEARRAY ):
     1823              SafeArrayCopy(V_UNION(pvargSrc,parray), &V_UNION(pvargDest,parray));
     1824              break;
     1825            default:
     1826              pvargDest->n1.n2.n3 = pvargSrc->n1.n2.n3;
     1827              break;
     1828          }
     1829        }
     1830       
     1831        V_VT(pvargDest) = V_VT(pvargSrc);
     1832      }     
    18331833    }
    18341834  }
     
    18391839
    18401840/******************************************************************************
    1841  *      VariantCopyInd  [OLEAUT32.11]
     1841 *              VariantCopyInd  [OLEAUT32.11]
    18421842 *
    18431843 * Frees up the destination variant and makes a copy of the source.  If
     
    18541854  if( res != S_OK )
    18551855    return res;
    1856 
     1856 
    18571857  if( V_VT(pvargSrc) & VT_BYREF )
    18581858  {
     
    18761876      if( res == S_OK )
    18771877      {
    1878     /*
    1879     * The VT_ARRAY flag is another way to designate a safearray variant.
    1880     */
    1881     if ( V_VT(pvargSrc) & VT_ARRAY)
    1882     {
    1883       SafeArrayCopy(*V_UNION(pvargSrc,pparray), &V_UNION(pvargDest,parray));
    1884     }
    1885     else
    1886     {
    1887       /* In the case of by reference we need
    1888        * to copy the date pointed to by the variant.
    1889        */
    1890 
    1891       /* Get the variant type.
    1892        */
    1893       switch( V_VT(pvargSrc) & VT_TYPEMASK )
    1894       {
    1895         case( VT_BSTR ):
    1896           V_UNION(pvargDest,bstrVal) = SysAllocString( *(V_UNION(pvargSrc,pbstrVal)) );
    1897           break;
    1898         case( VT_DISPATCH ):
    1899           break;
    1900         case( VT_VARIANT ):
    1901           {
    1902         /* Prevent from cycling.  According to tests on
    1903         * VariantCopyInd in Windows and the documentation
    1904         * this API dereferences the inner Variants to only one depth.
    1905         * If the inner Variant itself contains an
    1906         * other inner variant the E_INVALIDARG error is
    1907          * returned.
    1908         */
    1909         if( pvargSrc->n1.n2.wReserved1 & PROCESSING_INNER_VARIANT )
    1910         {
    1911           /* If we get here we are attempting to deference
    1912            * an inner variant that that is itself contained
    1913            * in an inner variant so report E_INVALIDARG error.
    1914            */
    1915           res = E_INVALIDARG;
    1916         }
    1917         else
    1918         {
    1919           /* Set the processing inner variant flag.
    1920            * We will set this flag in the inner variant
    1921            * that will be passed to the VariantCopyInd function.
    1922            */
    1923           (V_UNION(pvargSrc,pvarVal))->n1.n2.wReserved1 |= PROCESSING_INNER_VARIANT;
    1924 
    1925           /* Dereference the inner variant.
    1926            */
    1927           res = VariantCopyInd( pvargDest, V_UNION(pvargSrc,pvarVal) );
    1928           /* We must also copy its type, I think.
    1929            */
    1930           V_VT(pvargSrc) = V_VT(V_UNION(pvargSrc,pvarVal));
    1931         }
    1932           }
    1933           break;
    1934         case( VT_UNKNOWN ):
    1935           break;
    1936         case( VT_SAFEARRAY ):
    1937           SafeArrayCopy(*V_UNION(pvargSrc,pparray), &V_UNION(pvargDest,parray));
    1938           break;
    1939         default:
    1940           /* This is a by reference Variant which means that the union
    1941            * part of the Variant contains a pointer to some data of
    1942            * type "V_VT(pvargSrc) & VT_TYPEMASK".
    1943            * We will deference this data in a generic fashion using
    1944            * the void pointer "Variant.u.byref".
    1945            * We will copy this data into the union of the destination
    1946            * Variant.
    1947            */
    1948           memcpy( &pvargDest->n1.n2, V_UNION(pvargSrc,byref), SizeOfVariantData( pvargSrc ) );
    1949           break;
    1950       }
    1951     }
    1952 
    1953     V_VT(pvargDest) = V_VT(pvargSrc) & VT_TYPEMASK;
     1878        /*
     1879        * The VT_ARRAY flag is another way to designate a safearray variant.
     1880        */
     1881        if ( V_VT(pvargSrc) & VT_ARRAY)
     1882        {
     1883          SafeArrayCopy(*V_UNION(pvargSrc,pparray), &V_UNION(pvargDest,parray));
     1884        }
     1885        else
     1886        {
     1887          /* In the case of by reference we need
     1888           * to copy the date pointed to by the variant.
     1889           */
     1890
     1891          /* Get the variant type.
     1892           */
     1893          switch( V_VT(pvargSrc) & VT_TYPEMASK )
     1894          {
     1895            case( VT_BSTR ):
     1896              V_UNION(pvargDest,bstrVal) = SysAllocString( *(V_UNION(pvargSrc,pbstrVal)) );
     1897              break;
     1898            case( VT_DISPATCH ):
     1899              break;
     1900            case( VT_VARIANT ):
     1901              {
     1902                /* Prevent from cycling.  According to tests on
     1903                * VariantCopyInd in Windows and the documentation
     1904                * this API dereferences the inner Variants to only one depth.
     1905                * If the inner Variant itself contains an
     1906                * other inner variant the E_INVALIDARG error is
     1907                 * returned.
     1908                */
     1909                if( pvargSrc->n1.n2.wReserved1 & PROCESSING_INNER_VARIANT )
     1910                {
     1911                  /* If we get here we are attempting to deference
     1912                   * an inner variant that that is itself contained
     1913                   * in an inner variant so report E_INVALIDARG error.
     1914                   */
     1915                  res = E_INVALIDARG;
     1916                }
     1917                else
     1918                {
     1919                  /* Set the processing inner variant flag.
     1920                   * We will set this flag in the inner variant
     1921                   * that will be passed to the VariantCopyInd function.
     1922                   */
     1923                  (V_UNION(pvargSrc,pvarVal))->n1.n2.wReserved1 |= PROCESSING_INNER_VARIANT;
     1924                 
     1925                  /* Dereference the inner variant.
     1926                   */
     1927                  res = VariantCopyInd( pvargDest, V_UNION(pvargSrc,pvarVal) );
     1928                  /* We must also copy its type, I think.
     1929                   */
     1930                  V_VT(pvargSrc) = V_VT(V_UNION(pvargSrc,pvarVal));
     1931                }
     1932              }
     1933              break;
     1934            case( VT_UNKNOWN ):
     1935              break;
     1936            case( VT_SAFEARRAY ):
     1937              SafeArrayCopy(*V_UNION(pvargSrc,pparray), &V_UNION(pvargDest,parray));
     1938              break;
     1939            default:
     1940              /* This is a by reference Variant which means that the union
     1941               * part of the Variant contains a pointer to some data of
     1942               * type "V_VT(pvargSrc) & VT_TYPEMASK".
     1943               * We will deference this data in a generic fashion using
     1944               * the void pointer "Variant.u.byref".
     1945               * We will copy this data into the union of the destination
     1946               * Variant.
     1947               */
     1948              memcpy( &pvargDest->n1.n2, V_UNION(pvargSrc,byref), SizeOfVariantData( pvargSrc ) );
     1949              break;
     1950          }
     1951        }
     1952       
     1953        V_VT(pvargDest) = V_VT(pvargSrc) & VT_TYPEMASK;
    19541954      }
    19551955    }
     
    19681968
    19691969/******************************************************************************
    1970  *      VariantChangeType   [OLEAUT32.12]
     1970 *              VariantChangeType       [OLEAUT32.12]
    19711971 */
    19721972HRESULT WINAPI VariantChangeType(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
    1973                             USHORT wFlags, VARTYPE vt)
    1974 {
    1975     return VariantChangeTypeEx( pvargDest, pvargSrc, 0, wFlags, vt );
    1976 }
    1977 
    1978 /******************************************************************************
    1979  *      VariantChangeTypeEx [OLEAUT32.147]
     1973                                                        USHORT wFlags, VARTYPE vt)
     1974{
     1975        return VariantChangeTypeEx( pvargDest, pvargSrc, 0, wFlags, vt );
     1976}
     1977
     1978/******************************************************************************
     1979 *              VariantChangeTypeEx     [OLEAUT32.147]
    19801980 */
    19811981HRESULT WINAPI VariantChangeTypeEx(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
    1982                               LCID lcid, USHORT wFlags, VARTYPE vt)
    1983 {
    1984     HRESULT res = S_OK;
    1985     VARIANTARG varg;
    1986     VariantInit( &varg );
    1987 
    1988     TRACE("(%p, %p, %ld, %u, %u),stub\n", pvargDest, pvargSrc, lcid, wFlags, vt);
    1989 
    1990     /* validate our source argument.
    1991     */
    1992     res = ValidateVariantType( V_VT(pvargSrc) );
    1993 
    1994     /* validate the vartype.
    1995     */
    1996     if( res == S_OK )
    1997     {
    1998         res = ValidateVt( vt );
    1999     }
    2000 
    2001     /* if we are doing an in-place conversion make a copy of the source.
    2002     */
    2003     if( res == S_OK && pvargDest == pvargSrc )
    2004     {
    2005         res = VariantCopy( &varg, pvargSrc );
    2006         pvargSrc = &varg;
    2007     }
    2008 
    2009     if( res == S_OK )
    2010     {
    2011         /* free up the destination variant.
    2012         */
    2013         res = VariantClear( pvargDest );
    2014     }
    2015 
    2016     if( res == S_OK )
    2017     {
    2018         if( V_VT(pvargSrc) & VT_BYREF )
    2019         {
    2020             /* Convert the source variant to a "byvalue" variant.
    2021             */
    2022             VARIANTARG Variant;
    2023             VariantInit( &Variant );
    2024             res = VariantCopyInd( &Variant, pvargSrc );
    2025             if( res == S_OK )
    2026             {
    2027                 res = Coerce( pvargDest, lcid, wFlags, &Variant, vt );
    2028                 /* this should not fail.
    2029                 */
    2030                 VariantClear( &Variant );
    2031             }
    2032 
    2033         }
    2034         else
    2035         {
    2036             /* Use the current "byvalue" source variant.
    2037             */
    2038             res = Coerce( pvargDest, lcid, wFlags, pvargSrc, vt );
    2039         }
    2040     }
    2041     /* this should not fail.
    2042     */
    2043     VariantClear( &varg );
    2044 
    2045     /* set the type of the destination
    2046     */
    2047     if ( res == S_OK )
    2048         V_VT(pvargDest) = vt;
    2049 
    2050     return res;
    2051 }
    2052 
    2053 
    2054 
    2055 
    2056 /******************************************************************************
    2057  *      VarUI1FromI2        [OLEAUT32.130]
     1982                                                          LCID lcid, USHORT wFlags, VARTYPE vt)
     1983{
     1984        HRESULT res = S_OK;
     1985        VARIANTARG varg;
     1986        VariantInit( &varg );
     1987       
     1988        TRACE("(%p, %p, %ld, %u, %u),stub\n", pvargDest, pvargSrc, lcid, wFlags, vt);
     1989
     1990        /* validate our source argument.
     1991        */
     1992        res = ValidateVariantType( V_VT(pvargSrc) );
     1993
     1994        /* validate the vartype.
     1995        */
     1996        if( res == S_OK )
     1997        {
     1998                res = ValidateVt( vt );
     1999        }
     2000
     2001        /* if we are doing an in-place conversion make a copy of the source.
     2002        */
     2003        if( res == S_OK && pvargDest == pvargSrc )
     2004        {
     2005                res = VariantCopy( &varg, pvargSrc );
     2006                pvargSrc = &varg;
     2007        }
     2008
     2009        if( res == S_OK )
     2010        {
     2011                /* free up the destination variant.
     2012                */
     2013                res = VariantClear( pvargDest );
     2014        }
     2015
     2016        if( res == S_OK )
     2017        {
     2018                if( V_VT(pvargSrc) & VT_BYREF )
     2019                {
     2020                        /* Convert the source variant to a "byvalue" variant.
     2021                        */
     2022                        VARIANTARG Variant;
     2023                        VariantInit( &Variant );
     2024                        res = VariantCopyInd( &Variant, pvargSrc );
     2025                        if( res == S_OK )
     2026                        {
     2027                                res = Coerce( pvargDest, lcid, wFlags, &Variant, vt );
     2028                                /* this should not fail.
     2029                                */
     2030                                VariantClear( &Variant );
     2031                        }
     2032       
     2033                }
     2034                else
     2035                {
     2036                        /* Use the current "byvalue" source variant.
     2037                        */
     2038                        res = Coerce( pvargDest, lcid, wFlags, pvargSrc, vt );
     2039                }
     2040        }
     2041        /* this should not fail.
     2042        */
     2043        VariantClear( &varg );
     2044       
     2045        /* set the type of the destination
     2046        */
     2047        if ( res == S_OK )
     2048                V_VT(pvargDest) = vt;
     2049
     2050        return res;
     2051}
     2052
     2053
     2054
     2055
     2056/******************************************************************************
     2057 *              VarUI1FromI2            [OLEAUT32.130]
    20582058 */
    20592059HRESULT WINAPI VarUI1FromI2(short sIn, BYTE* pbOut)
    20602060{
    2061     TRACE("( %d, %p ), stub\n", sIn, pbOut );
    2062 
    2063     /* Check range of value.
    2064     */
    2065     if( sIn < UI1_MIN || sIn > UI1_MAX )
    2066     {
    2067         return DISP_E_OVERFLOW;
    2068     }
    2069 
    2070     *pbOut = (BYTE) sIn;
    2071 
    2072     return S_OK;
    2073 }
    2074 
    2075 /******************************************************************************
    2076  *      VarUI1FromI4        [OLEAUT32.131]
     2061        TRACE("( %d, %p ), stub\n", sIn, pbOut );
     2062
     2063        /* Check range of value.
     2064        */
     2065        if( sIn < UI1_MIN || sIn > UI1_MAX )
     2066        {
     2067                return DISP_E_OVERFLOW;
     2068        }
     2069
     2070        *pbOut = (BYTE) sIn;
     2071       
     2072        return S_OK;
     2073}
     2074
     2075/******************************************************************************
     2076 *              VarUI1FromI4            [OLEAUT32.131]
    20772077 */
    20782078HRESULT WINAPI VarUI1FromI4(LONG lIn, BYTE* pbOut)
    20792079{
    2080     TRACE("( %ld, %p ), stub\n", lIn, pbOut );
    2081 
    2082     /* Check range of value.
    2083     */
    2084     if( lIn < UI1_MIN || lIn > UI1_MAX )
    2085     {
    2086         return DISP_E_OVERFLOW;
    2087     }
    2088 
    2089     *pbOut = (BYTE) lIn;
    2090 
    2091     return S_OK;
    2092 }
    2093 
    2094 
    2095 /******************************************************************************
    2096  *      VarUI1FromR4        [OLEAUT32.132]
     2080        TRACE("( %ld, %p ), stub\n", lIn, pbOut );
     2081
     2082        /* Check range of value.
     2083        */
     2084        if( lIn < UI1_MIN || lIn > UI1_MAX )
     2085        {
     2086                return DISP_E_OVERFLOW;
     2087        }
     2088
     2089        *pbOut = (BYTE) lIn;
     2090       
     2091        return S_OK;
     2092}
     2093
     2094
     2095/******************************************************************************
     2096 *              VarUI1FromR4            [OLEAUT32.132]
    20972097 */
    20982098HRESULT WINAPI VarUI1FromR4(FLOAT fltIn, BYTE* pbOut)
    20992099{
    2100     TRACE("( %f, %p ), stub\n", fltIn, pbOut );
    2101 
    2102     /* Check range of value.
     2100        TRACE("( %f, %p ), stub\n", fltIn, pbOut );
     2101
     2102        /* Check range of value.
    21032103     */
    21042104    fltIn = round( fltIn );
    2105     if( fltIn < UI1_MIN || fltIn > UI1_MAX )
    2106     {
    2107         return DISP_E_OVERFLOW;
    2108     }
    2109 
    2110     *pbOut = (BYTE) fltIn;
    2111 
    2112     return S_OK;
    2113 }
    2114 
    2115 /******************************************************************************
    2116  *      VarUI1FromR8        [OLEAUT32.133]
     2105        if( fltIn < UI1_MIN || fltIn > UI1_MAX )
     2106        {
     2107                return DISP_E_OVERFLOW;
     2108        }
     2109
     2110        *pbOut = (BYTE) fltIn;
     2111       
     2112        return S_OK;
     2113}
     2114
     2115/******************************************************************************
     2116 *              VarUI1FromR8            [OLEAUT32.133]
    21172117 */
    21182118HRESULT WINAPI VarUI1FromR8(double dblIn, BYTE* pbOut)
    21192119{
    2120     TRACE("( %f, %p ), stub\n", dblIn, pbOut );
    2121 
    2122     /* Check range of value.
     2120        TRACE("( %f, %p ), stub\n", dblIn, pbOut );
     2121
     2122        /* Check range of value.
    21232123     */
    21242124    dblIn = round( dblIn );
    2125     if( dblIn < UI1_MIN || dblIn > UI1_MAX )
    2126     {
    2127         return DISP_E_OVERFLOW;
    2128     }
    2129 
    2130     *pbOut = (BYTE) dblIn;
    2131 
    2132     return S_OK;
    2133 }
    2134 
    2135 /******************************************************************************
    2136  *      VarUI1FromDate      [OLEAUT32.135]
     2125        if( dblIn < UI1_MIN || dblIn > UI1_MAX )
     2126        {
     2127                return DISP_E_OVERFLOW;
     2128        }
     2129
     2130        *pbOut = (BYTE) dblIn;
     2131
     2132        return S_OK;
     2133}
     2134
     2135/******************************************************************************
     2136 *              VarUI1FromDate          [OLEAUT32.135]
    21372137 */
    21382138HRESULT WINAPI VarUI1FromDate(DATE dateIn, BYTE* pbOut)
    21392139{
    2140     TRACE("( %f, %p ), stub\n", dateIn, pbOut );
    2141 
    2142     /* Check range of value.
     2140        TRACE("( %f, %p ), stub\n", dateIn, pbOut );
     2141
     2142        /* Check range of value.
    21432143     */
    21442144    dateIn = round( dateIn );
    2145     if( dateIn < UI1_MIN || dateIn > UI1_MAX )
    2146     {
    2147         return DISP_E_OVERFLOW;
    2148     }
    2149 
    2150     *pbOut = (BYTE) dateIn;
    2151 
    2152     return S_OK;
    2153 }
    2154 
    2155 /******************************************************************************
    2156  *      VarUI1FromBool      [OLEAUT32.138]
     2145        if( dateIn < UI1_MIN || dateIn > UI1_MAX )
     2146        {
     2147                return DISP_E_OVERFLOW;
     2148        }
     2149
     2150        *pbOut = (BYTE) dateIn;
     2151
     2152        return S_OK;
     2153}
     2154
     2155/******************************************************************************
     2156 *              VarUI1FromBool          [OLEAUT32.138]
    21572157 */
    21582158HRESULT WINAPI VarUI1FromBool(VARIANT_BOOL boolIn, BYTE* pbOut)
    21592159{
    2160     TRACE("( %d, %p ), stub\n", boolIn, pbOut );
    2161 
    2162     *pbOut = (BYTE) boolIn;
    2163 
    2164     return S_OK;
    2165 }
    2166 
    2167 /******************************************************************************
    2168  *      VarUI1FromI1        [OLEAUT32.237]
     2160        TRACE("( %d, %p ), stub\n", boolIn, pbOut );
     2161
     2162        *pbOut = (BYTE) boolIn;
     2163
     2164        return S_OK;
     2165}
     2166
     2167/******************************************************************************
     2168 *              VarUI1FromI1            [OLEAUT32.237]
    21692169 */
    21702170HRESULT WINAPI VarUI1FromI1(CHAR cIn, BYTE* pbOut)
    21712171{
    2172     TRACE("( %c, %p ), stub\n", cIn, pbOut );
    2173 
    2174     *pbOut = cIn;
    2175 
    2176     return S_OK;
    2177 }
    2178 
    2179 /******************************************************************************
    2180  *      VarUI1FromUI2       [OLEAUT32.238]
     2172        TRACE("( %c, %p ), stub\n", cIn, pbOut );
     2173
     2174        *pbOut = cIn;
     2175
     2176        return S_OK;
     2177}
     2178
     2179/******************************************************************************
     2180 *              VarUI1FromUI2           [OLEAUT32.238]
    21812181 */
    21822182HRESULT WINAPI VarUI1FromUI2(USHORT uiIn, BYTE* pbOut)
    21832183{
    2184     TRACE("( %d, %p ), stub\n", uiIn, pbOut );
    2185 
    2186     /* Check range of value.
    2187     */
    2188     if( uiIn > UI1_MAX )
    2189     {
    2190         return DISP_E_OVERFLOW;
    2191     }
    2192 
    2193     *pbOut = (BYTE) uiIn;
    2194 
    2195     return S_OK;
    2196 }
    2197 
    2198 /******************************************************************************
    2199  *      VarUI1FromUI4       [OLEAUT32.239]
     2184        TRACE("( %d, %p ), stub\n", uiIn, pbOut );
     2185
     2186        /* Check range of value.
     2187        */
     2188        if( uiIn > UI1_MAX )
     2189        {
     2190                return DISP_E_OVERFLOW;
     2191        }
     2192
     2193        *pbOut = (BYTE) uiIn;
     2194
     2195        return S_OK;
     2196}
     2197
     2198/******************************************************************************
     2199 *              VarUI1FromUI4           [OLEAUT32.239]
    22002200 */
    22012201HRESULT WINAPI VarUI1FromUI4(ULONG ulIn, BYTE* pbOut)
    22022202{
    2203     TRACE("( %ld, %p ), stub\n", ulIn, pbOut );
    2204 
    2205     /* Check range of value.
    2206     */
    2207     if( ulIn > UI1_MAX )
    2208     {
    2209         return DISP_E_OVERFLOW;
    2210     }
    2211 
    2212     *pbOut = (BYTE) ulIn;
    2213 
    2214     return S_OK;
    2215 }
    2216 
    2217 
    2218 /******************************************************************************
    2219  *      VarUI1FromStr       [OLEAUT32.136]
     2203        TRACE("( %ld, %p ), stub\n", ulIn, pbOut );
     2204
     2205        /* Check range of value.
     2206        */
     2207        if( ulIn > UI1_MAX )
     2208        {
     2209                return DISP_E_OVERFLOW;
     2210        }
     2211
     2212        *pbOut = (BYTE) ulIn;
     2213
     2214        return S_OK;
     2215}
     2216
     2217
     2218/******************************************************************************
     2219 *              VarUI1FromStr           [OLEAUT32.136]
    22202220 */
    22212221HRESULT WINAPI VarUI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, BYTE* pbOut)
    22222222{
    2223     double dValue = 0.0;
    2224     LPSTR pNewString = NULL;
    2225 
    2226     TRACE("( %p, 0x%08lx, 0x%08lx, %p ), stub\n", strIn, lcid, dwFlags, pbOut );
    2227 
    2228     /* Check if we have a valid argument
    2229     */
    2230     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    2231     RemoveCharacterFromString( pNewString, "," );
    2232     if( IsValidRealString( pNewString ) == FALSE )
    2233     {
    2234         return DISP_E_TYPEMISMATCH;
    2235     }
    2236 
    2237     /* Convert the valid string to a floating point number.
    2238     */
    2239     dValue = atof( pNewString );
    2240 
    2241     /* We don't need the string anymore so free it.
    2242     */
    2243     HeapFree( GetProcessHeap(), 0 , pNewString );
    2244 
    2245     /* Check range of value.
     2223        double dValue = 0.0;
     2224        LPSTR pNewString = NULL;
     2225
     2226        TRACE("( %p, 0x%08lx, 0x%08lx, %p ), stub\n", strIn, lcid, dwFlags, pbOut );
     2227
     2228        /* Check if we have a valid argument
     2229        */
     2230        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     2231        RemoveCharacterFromString( pNewString, "," );
     2232        if( IsValidRealString( pNewString ) == FALSE )
     2233        {
     2234                return DISP_E_TYPEMISMATCH;
     2235        }
     2236
     2237        /* Convert the valid string to a floating point number.
     2238        */
     2239        dValue = atof( pNewString );
     2240       
     2241        /* We don't need the string anymore so free it.
     2242        */
     2243        HeapFree( GetProcessHeap(), 0 , pNewString );
     2244
     2245        /* Check range of value.
    22462246     */
    22472247    dValue = round( dValue );
    2248     if( dValue < UI1_MIN || dValue > UI1_MAX )
    2249     {
    2250         return DISP_E_OVERFLOW;
    2251     }
    2252 
    2253     *pbOut = (BYTE) dValue;
    2254 
    2255     return S_OK;
     2248        if( dValue < UI1_MIN || dValue > UI1_MAX )
     2249        {
     2250                return DISP_E_OVERFLOW;
     2251        }
     2252
     2253        *pbOut = (BYTE) dValue;
     2254
     2255        return S_OK;
    22562256}
    22572257
     
    22622262HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) {
    22632263   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2264 
     2264   
    22652265   if (t > UI1_MAX || t < UI1_MIN) return DISP_E_OVERFLOW;
    2266 
     2266   
    22672267   *pbOut = (BYTE)t;
    22682268   return S_OK;
     
    22702270
    22712271/******************************************************************************
    2272  *      VarI2FromUI1        [OLEAUT32.48]
     2272 *              VarI2FromUI1            [OLEAUT32.48]
    22732273 */
    22742274HRESULT WINAPI VarI2FromUI1(BYTE bIn, short* psOut)
    22752275{
    2276     TRACE("( 0x%08x, %p ), stub\n", bIn, psOut );
    2277 
    2278     *psOut = (short) bIn;
    2279 
    2280     return S_OK;
    2281 }
    2282 
    2283 /******************************************************************************
    2284  *      VarI2FromI4     [OLEAUT32.49]
     2276        TRACE("( 0x%08x, %p ), stub\n", bIn, psOut );
     2277
     2278        *psOut = (short) bIn;
     2279       
     2280        return S_OK;
     2281}
     2282
     2283/******************************************************************************
     2284 *              VarI2FromI4             [OLEAUT32.49]
    22852285 */
    22862286HRESULT WINAPI VarI2FromI4(LONG lIn, short* psOut)
    22872287{
    2288     TRACE("( %lx, %p ), stub\n", lIn, psOut );
    2289 
    2290     /* Check range of value.
    2291     */
    2292     if( lIn < I2_MIN || lIn > I2_MAX )
    2293     {
    2294         return DISP_E_OVERFLOW;
    2295     }
    2296 
    2297     *psOut = (short) lIn;
    2298 
    2299     return S_OK;
    2300 }
    2301 
    2302 /******************************************************************************
    2303  *      VarI2FromR4     [OLEAUT32.50]
     2288        TRACE("( %lx, %p ), stub\n", lIn, psOut );
     2289
     2290        /* Check range of value.
     2291        */
     2292        if( lIn < I2_MIN || lIn > I2_MAX )
     2293        {
     2294                return DISP_E_OVERFLOW;
     2295        }
     2296
     2297        *psOut = (short) lIn;
     2298       
     2299        return S_OK;
     2300}
     2301
     2302/******************************************************************************
     2303 *              VarI2FromR4             [OLEAUT32.50]
    23042304 */
    23052305HRESULT WINAPI VarI2FromR4(FLOAT fltIn, short* psOut)
    23062306{
    2307     TRACE("( %f, %p ), stub\n", fltIn, psOut );
    2308 
    2309     /* Check range of value.
     2307        TRACE("( %f, %p ), stub\n", fltIn, psOut );
     2308
     2309        /* Check range of value.
    23102310     */
    23112311    fltIn = round( fltIn );
    2312     if( fltIn < I2_MIN || fltIn > I2_MAX )
    2313     {
    2314         return DISP_E_OVERFLOW;
    2315     }
    2316 
    2317     *psOut = (short) fltIn;
    2318 
    2319     return S_OK;
    2320 }
    2321 
    2322 /******************************************************************************
    2323  *      VarI2FromR8     [OLEAUT32.51]
     2312        if( fltIn < I2_MIN || fltIn > I2_MAX )
     2313        {
     2314                return DISP_E_OVERFLOW;
     2315        }
     2316
     2317        *psOut = (short) fltIn;
     2318
     2319        return S_OK;
     2320}
     2321
     2322/******************************************************************************
     2323 *              VarI2FromR8             [OLEAUT32.51]
    23242324 */
    23252325HRESULT WINAPI VarI2FromR8(double dblIn, short* psOut)
    23262326{
    2327     TRACE("( %f, %p ), stub\n", dblIn, psOut );
    2328 
    2329     /* Check range of value.
     2327        TRACE("( %f, %p ), stub\n", dblIn, psOut );
     2328
     2329        /* Check range of value.
    23302330     */
    23312331    dblIn = round( dblIn );
    2332     if( dblIn < I2_MIN || dblIn > I2_MAX )
    2333     {
    2334         return DISP_E_OVERFLOW;
    2335     }
    2336 
    2337     *psOut = (short) dblIn;
    2338 
    2339     return S_OK;
    2340 }
    2341 
    2342 /******************************************************************************
    2343  *      VarI2FromDate       [OLEAUT32.53]
     2332        if( dblIn < I2_MIN || dblIn > I2_MAX )
     2333        {
     2334                return DISP_E_OVERFLOW;
     2335        }
     2336
     2337        *psOut = (short) dblIn;
     2338
     2339        return S_OK;
     2340}
     2341
     2342/******************************************************************************
     2343 *              VarI2FromDate           [OLEAUT32.53]
    23442344 */
    23452345HRESULT WINAPI VarI2FromDate(DATE dateIn, short* psOut)
    23462346{
    2347     TRACE("( %f, %p ), stub\n", dateIn, psOut );
    2348 
    2349     /* Check range of value.
     2347        TRACE("( %f, %p ), stub\n", dateIn, psOut );
     2348
     2349        /* Check range of value.
    23502350     */
    23512351    dateIn = round( dateIn );
    2352     if( dateIn < I2_MIN || dateIn > I2_MAX )
    2353     {
    2354         return DISP_E_OVERFLOW;
    2355     }
    2356 
    2357     *psOut = (short) dateIn;
    2358 
    2359     return S_OK;
    2360 }
    2361 
    2362 /******************************************************************************
    2363  *      VarI2FromBool       [OLEAUT32.56]
     2352        if( dateIn < I2_MIN || dateIn > I2_MAX )
     2353        {
     2354                return DISP_E_OVERFLOW;
     2355        }
     2356
     2357        *psOut = (short) dateIn;
     2358
     2359        return S_OK;
     2360}
     2361
     2362/******************************************************************************
     2363 *              VarI2FromBool           [OLEAUT32.56]
    23642364 */
    23652365HRESULT WINAPI VarI2FromBool(VARIANT_BOOL boolIn, short* psOut)
    23662366{
    2367     TRACE("( %d, %p ), stub\n", boolIn, psOut );
    2368 
    2369     *psOut = (short) boolIn;
    2370 
    2371     return S_OK;
    2372 }
    2373 
    2374 /******************************************************************************
    2375  *      VarI2FromI1     [OLEAUT32.205]
     2367        TRACE("( %d, %p ), stub\n", boolIn, psOut );
     2368
     2369        *psOut = (short) boolIn;
     2370
     2371        return S_OK;
     2372}
     2373
     2374/******************************************************************************
     2375 *              VarI2FromI1             [OLEAUT32.205]
    23762376 */
    23772377HRESULT WINAPI VarI2FromI1(CHAR cIn, short* psOut)
    23782378{
    2379     TRACE("( %c, %p ), stub\n", cIn, psOut );
    2380 
    2381     *psOut = (short) cIn;
    2382 
    2383     return S_OK;
    2384 }
    2385 
    2386 /******************************************************************************
    2387  *      VarI2FromUI2        [OLEAUT32.206]
     2379        TRACE("( %c, %p ), stub\n", cIn, psOut );
     2380
     2381        *psOut = (short) cIn;
     2382
     2383        return S_OK;
     2384}
     2385
     2386/******************************************************************************
     2387 *              VarI2FromUI2            [OLEAUT32.206]
    23882388 */
    23892389HRESULT WINAPI VarI2FromUI2(USHORT uiIn, short* psOut)
    23902390{
    2391     TRACE("( %d, %p ), stub\n", uiIn, psOut );
    2392 
    2393     /* Check range of value.
    2394     */
    2395     if( uiIn > I2_MAX )
    2396     {
    2397         return DISP_E_OVERFLOW;
    2398     }
    2399 
    2400     *psOut = (short) uiIn;
    2401 
    2402     return S_OK;
    2403 }
    2404 
    2405 /******************************************************************************
    2406  *      VarI2FromUI4        [OLEAUT32.207]
     2391        TRACE("( %d, %p ), stub\n", uiIn, psOut );
     2392
     2393        /* Check range of value.
     2394        */
     2395        if( uiIn > I2_MAX )
     2396        {
     2397                return DISP_E_OVERFLOW;
     2398        }
     2399
     2400        *psOut = (short) uiIn;
     2401
     2402        return S_OK;
     2403}
     2404
     2405/******************************************************************************
     2406 *              VarI2FromUI4            [OLEAUT32.207]
    24072407 */
    24082408HRESULT WINAPI VarI2FromUI4(ULONG ulIn, short* psOut)
    24092409{
    2410     TRACE("( %lx, %p ), stub\n", ulIn, psOut );
    2411 
    2412     /* Check range of value.
    2413     */
    2414     if( ulIn < I2_MIN || ulIn > I2_MAX )
    2415     {
    2416         return DISP_E_OVERFLOW;
    2417     }
    2418 
    2419     *psOut = (short) ulIn;
    2420 
    2421     return S_OK;
    2422 }
    2423 
    2424 /******************************************************************************
    2425  *      VarI2FromStr        [OLEAUT32.54]
     2410        TRACE("( %lx, %p ), stub\n", ulIn, psOut );
     2411
     2412        /* Check range of value.
     2413        */
     2414        if( ulIn < I2_MIN || ulIn > I2_MAX )
     2415        {
     2416                return DISP_E_OVERFLOW;
     2417        }
     2418
     2419        *psOut = (short) ulIn;
     2420
     2421        return S_OK;
     2422}
     2423
     2424/******************************************************************************
     2425 *              VarI2FromStr            [OLEAUT32.54]
    24262426 */
    24272427HRESULT WINAPI VarI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, short* psOut)
    24282428{
    2429     double dValue = 0.0;
    2430     LPSTR pNewString = NULL;
    2431 
    2432     TRACE("( %p, 0x%08lx, 0x%08lx, %p ), stub\n", strIn, lcid, dwFlags, psOut );
    2433 
    2434     /* Check if we have a valid argument
    2435     */
    2436     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    2437     RemoveCharacterFromString( pNewString, "," );
    2438     if( IsValidRealString( pNewString ) == FALSE )
    2439     {
    2440         return DISP_E_TYPEMISMATCH;
    2441     }
    2442 
    2443     /* Convert the valid string to a floating point number.
    2444     */
    2445     dValue = atof( pNewString );
    2446 
    2447     /* We don't need the string anymore so free it.
    2448     */
    2449     HeapFree( GetProcessHeap(), 0, pNewString );
    2450 
    2451     /* Check range of value.
     2429        double dValue = 0.0;
     2430        LPSTR pNewString = NULL;
     2431
     2432        TRACE("( %p, 0x%08lx, 0x%08lx, %p ), stub\n", strIn, lcid, dwFlags, psOut );
     2433
     2434        /* Check if we have a valid argument
     2435        */
     2436        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     2437        RemoveCharacterFromString( pNewString, "," );
     2438        if( IsValidRealString( pNewString ) == FALSE )
     2439        {
     2440                return DISP_E_TYPEMISMATCH;
     2441        }
     2442
     2443        /* Convert the valid string to a floating point number.
     2444        */
     2445        dValue = atof( pNewString );
     2446       
     2447        /* We don't need the string anymore so free it.
     2448        */
     2449        HeapFree( GetProcessHeap(), 0, pNewString );
     2450
     2451        /* Check range of value.
    24522452     */
    24532453    dValue = round( dValue );
    2454     if( dValue < I2_MIN || dValue > I2_MAX )
    2455     {
    2456         return DISP_E_OVERFLOW;
    2457     }
    2458 
    2459     *psOut = (short)  dValue;
    2460 
    2461     return S_OK;
     2454        if( dValue < I2_MIN || dValue > I2_MAX )
     2455        {
     2456                return DISP_E_OVERFLOW;
     2457        }
     2458
     2459        *psOut = (short)  dValue;
     2460
     2461        return S_OK;
    24622462}
    24632463
     
    24682468HRESULT WINAPI VarI2FromCy(CY cyIn, short* psOut) {
    24692469   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2470 
     2470   
    24712471   if (t > I2_MAX || t < I2_MIN) return DISP_E_OVERFLOW;
    2472 
     2472   
    24732473   *psOut = (SHORT)t;
    24742474   return S_OK;
     
    24762476
    24772477/******************************************************************************
    2478  *      VarI4FromUI1        [OLEAUT32.58]
     2478 *              VarI4FromUI1            [OLEAUT32.58]
    24792479 */
    24802480HRESULT WINAPI VarI4FromUI1(BYTE bIn, LONG* plOut)
    24812481{
    2482     TRACE("( %X, %p ), stub\n", bIn, plOut );
    2483 
    2484     *plOut = (LONG) bIn;
    2485 
    2486     return S_OK;
    2487 }
    2488 
    2489 
    2490 /******************************************************************************
    2491  *      VarI4FromR4     [OLEAUT32.60]
     2482        TRACE("( %X, %p ), stub\n", bIn, plOut );
     2483
     2484        *plOut = (LONG) bIn;
     2485
     2486        return S_OK;
     2487}
     2488
     2489
     2490/******************************************************************************
     2491 *              VarI4FromR4             [OLEAUT32.60]
    24922492 */
    24932493HRESULT WINAPI VarI4FromR4(FLOAT fltIn, LONG* plOut)
    24942494{
    2495     TRACE("( %f, %p ), stub\n", fltIn, plOut );
    2496 
    2497     /* Check range of value.
     2495        TRACE("( %f, %p ), stub\n", fltIn, plOut );
     2496
     2497        /* Check range of value.
    24982498     */
    24992499    fltIn = round( fltIn );
    2500     if( fltIn < I4_MIN || fltIn > I4_MAX )
    2501     {
    2502         return DISP_E_OVERFLOW;
    2503     }
    2504 
    2505     *plOut = (LONG) fltIn;
    2506 
    2507     return S_OK;
    2508 }
    2509 
    2510 /******************************************************************************
    2511  *      VarI4FromR8     [OLEAUT32.61]
     2500        if( fltIn < I4_MIN || fltIn > I4_MAX )
     2501        {
     2502                return DISP_E_OVERFLOW;
     2503        }
     2504
     2505        *plOut = (LONG) fltIn;
     2506
     2507        return S_OK;
     2508}
     2509
     2510/******************************************************************************
     2511 *              VarI4FromR8             [OLEAUT32.61]
    25122512 */
    25132513HRESULT WINAPI VarI4FromR8(double dblIn, LONG* plOut)
    25142514{
    2515     TRACE("( %f, %p ), stub\n", dblIn, plOut );
    2516 
    2517     /* Check range of value.
     2515        TRACE("( %f, %p ), stub\n", dblIn, plOut );
     2516
     2517        /* Check range of value.
    25182518     */
    25192519    dblIn = round( dblIn );
    2520     if( dblIn < I4_MIN || dblIn > I4_MAX )
    2521     {
    2522         return DISP_E_OVERFLOW;
    2523     }
    2524 
    2525     *plOut = (LONG) dblIn;
    2526 
    2527     return S_OK;
    2528 }
    2529 
    2530 /******************************************************************************
    2531  *      VarI4FromDate       [OLEAUT32.63]
     2520        if( dblIn < I4_MIN || dblIn > I4_MAX )
     2521        {
     2522                return DISP_E_OVERFLOW;
     2523        }
     2524
     2525        *plOut = (LONG) dblIn;
     2526
     2527        return S_OK;
     2528}
     2529
     2530/******************************************************************************
     2531 *              VarI4FromDate           [OLEAUT32.63]
    25322532 */
    25332533HRESULT WINAPI VarI4FromDate(DATE dateIn, LONG* plOut)
    25342534{
    2535     TRACE("( %f, %p ), stub\n", dateIn, plOut );
    2536 
    2537     /* Check range of value.
     2535        TRACE("( %f, %p ), stub\n", dateIn, plOut );
     2536
     2537        /* Check range of value.
    25382538     */
    25392539    dateIn = round( dateIn );
    2540     if( dateIn < I4_MIN || dateIn > I4_MAX )
    2541     {
    2542         return DISP_E_OVERFLOW;
    2543     }
    2544 
    2545     *plOut = (LONG) dateIn;
    2546 
    2547     return S_OK;
    2548 }
    2549 
    2550 /******************************************************************************
    2551  *      VarI4FromBool       [OLEAUT32.66]
     2540        if( dateIn < I4_MIN || dateIn > I4_MAX )
     2541        {
     2542                return DISP_E_OVERFLOW;
     2543        }
     2544
     2545        *plOut = (LONG) dateIn;
     2546
     2547        return S_OK;
     2548}
     2549
     2550/******************************************************************************
     2551 *              VarI4FromBool           [OLEAUT32.66]
    25522552 */
    25532553HRESULT WINAPI VarI4FromBool(VARIANT_BOOL boolIn, LONG* plOut)
    25542554{
    2555     TRACE("( %d, %p ), stub\n", boolIn, plOut );
    2556 
    2557     *plOut = (LONG) boolIn;
    2558 
    2559     return S_OK;
    2560 }
    2561 
    2562 /******************************************************************************
    2563  *      VarI4FromI1     [OLEAUT32.209]
     2555        TRACE("( %d, %p ), stub\n", boolIn, plOut );
     2556
     2557        *plOut = (LONG) boolIn;
     2558
     2559        return S_OK;
     2560}
     2561
     2562/******************************************************************************
     2563 *              VarI4FromI1             [OLEAUT32.209]
    25642564 */
    25652565HRESULT WINAPI VarI4FromI1(CHAR cIn, LONG* plOut)
    25662566{
    2567     TRACE("( %c, %p ), stub\n", cIn, plOut );
    2568 
    2569     *plOut = (LONG) cIn;
    2570 
    2571     return S_OK;
    2572 }
    2573 
    2574 /******************************************************************************
    2575  *      VarI4FromUI2        [OLEAUT32.210]
     2567        TRACE("( %c, %p ), stub\n", cIn, plOut );
     2568
     2569        *plOut = (LONG) cIn;
     2570
     2571        return S_OK;
     2572}
     2573
     2574/******************************************************************************
     2575 *              VarI4FromUI2            [OLEAUT32.210]
    25762576 */
    25772577HRESULT WINAPI VarI4FromUI2(USHORT uiIn, LONG* plOut)
    25782578{
    2579     TRACE("( %d, %p ), stub\n", uiIn, plOut );
    2580 
    2581     *plOut = (LONG) uiIn;
    2582 
    2583     return S_OK;
    2584 }
    2585 
    2586 /******************************************************************************
    2587  *      VarI4FromUI4        [OLEAUT32.211]
     2579        TRACE("( %d, %p ), stub\n", uiIn, plOut );
     2580
     2581        *plOut = (LONG) uiIn;
     2582
     2583        return S_OK;
     2584}
     2585
     2586/******************************************************************************
     2587 *              VarI4FromUI4            [OLEAUT32.211]
    25882588 */
    25892589HRESULT WINAPI VarI4FromUI4(ULONG ulIn, LONG* plOut)
    25902590{
    2591     TRACE("( %lx, %p ), stub\n", ulIn, plOut );
    2592 
    2593     /* Check range of value.
    2594     */
    2595     if( ulIn < I4_MIN || ulIn > I4_MAX )
    2596     {
    2597         return DISP_E_OVERFLOW;
    2598     }
    2599 
    2600     *plOut = (LONG) ulIn;
    2601 
    2602     return S_OK;
    2603 }
    2604 
    2605 /******************************************************************************
    2606  *      VarI4FromI2     [OLEAUT32.59]
     2591        TRACE("( %lx, %p ), stub\n", ulIn, plOut );
     2592
     2593        /* Check range of value.
     2594        */
     2595        if( ulIn < I4_MIN || ulIn > I4_MAX )
     2596        {
     2597                return DISP_E_OVERFLOW;
     2598        }
     2599
     2600        *plOut = (LONG) ulIn;
     2601
     2602        return S_OK;
     2603}
     2604
     2605/******************************************************************************
     2606 *              VarI4FromI2             [OLEAUT32.59]
    26072607 */
    26082608HRESULT WINAPI VarI4FromI2(short sIn, LONG* plOut)
    26092609{
    2610     TRACE("( %d, %p ), stub\n", sIn, plOut );
    2611 
    2612     *plOut = (LONG) sIn;
    2613 
    2614     return S_OK;
    2615 }
    2616 
    2617 /******************************************************************************
    2618  *      VarI4FromStr        [OLEAUT32.64]
     2610        TRACE("( %d, %p ), stub\n", sIn, plOut );
     2611
     2612        *plOut = (LONG) sIn;
     2613
     2614        return S_OK;
     2615}
     2616
     2617/******************************************************************************
     2618 *              VarI4FromStr            [OLEAUT32.64]
    26192619 */
    26202620HRESULT WINAPI VarI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, LONG* plOut)
    26212621{
    2622     double dValue = 0.0;
    2623     LPSTR pNewString = NULL;
    2624 
    2625     TRACE("( %p, 0x%08lx, 0x%08lx, %p ), stub\n", strIn, lcid, dwFlags, plOut );
    2626 
    2627     /* Check if we have a valid argument
    2628     */
    2629     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    2630     RemoveCharacterFromString( pNewString, "," );
    2631     if( IsValidRealString( pNewString ) == FALSE )
    2632     {
    2633         return DISP_E_TYPEMISMATCH;
    2634     }
    2635 
    2636     /* Convert the valid string to a floating point number.
    2637     */
    2638     dValue = atof( pNewString );
    2639 
    2640     /* We don't need the string anymore so free it.
    2641     */
    2642     HeapFree( GetProcessHeap(), 0, pNewString );
    2643 
    2644     /* Check range of value.
     2622        double dValue = 0.0;
     2623        LPSTR pNewString = NULL;
     2624
     2625        TRACE("( %p, 0x%08lx, 0x%08lx, %p ), stub\n", strIn, lcid, dwFlags, plOut );
     2626
     2627        /* Check if we have a valid argument
     2628        */
     2629        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     2630        RemoveCharacterFromString( pNewString, "," );
     2631        if( IsValidRealString( pNewString ) == FALSE )
     2632        {
     2633                return DISP_E_TYPEMISMATCH;
     2634        }
     2635
     2636        /* Convert the valid string to a floating point number.
     2637        */
     2638        dValue = atof( pNewString );
     2639       
     2640        /* We don't need the string anymore so free it.
     2641        */
     2642        HeapFree( GetProcessHeap(), 0, pNewString );
     2643
     2644        /* Check range of value.
    26452645     */
    26462646    dValue = round( dValue );
    2647     if( dValue < I4_MIN || dValue > I4_MAX )
    2648     {
    2649         return DISP_E_OVERFLOW;
    2650     }
    2651 
    2652     *plOut = (LONG) dValue;
    2653 
    2654     return S_OK;
     2647        if( dValue < I4_MIN || dValue > I4_MAX )
     2648        {
     2649                return DISP_E_OVERFLOW;
     2650        }
     2651
     2652        *plOut = (LONG) dValue;
     2653
     2654        return S_OK;
    26552655}
    26562656
     
    26612661HRESULT WINAPI VarI4FromCy(CY cyIn, LONG* plOut) {
    26622662   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2663 
     2663   
    26642664   if (t > I4_MAX || t < I4_MIN) return DISP_E_OVERFLOW;
    2665 
     2665   
    26662666   *plOut = (LONG)t;
    26672667   return S_OK;
     
    26692669
    26702670/******************************************************************************
    2671  *      VarR4FromUI1        [OLEAUT32.68]
     2671 *              VarR4FromUI1            [OLEAUT32.68]
    26722672 */
    26732673HRESULT WINAPI VarR4FromUI1(BYTE bIn, FLOAT* pfltOut)
    26742674{
    2675     TRACE("( %X, %p ), stub\n", bIn, pfltOut );
    2676 
    2677     *pfltOut = (FLOAT) bIn;
    2678 
    2679     return S_OK;
    2680 }
    2681 
    2682 /******************************************************************************
    2683  *      VarR4FromI2     [OLEAUT32.69]
     2675        TRACE("( %X, %p ), stub\n", bIn, pfltOut );
     2676
     2677        *pfltOut = (FLOAT) bIn;
     2678
     2679        return S_OK;
     2680}
     2681
     2682/******************************************************************************
     2683 *              VarR4FromI2             [OLEAUT32.69]
    26842684 */
    26852685HRESULT WINAPI VarR4FromI2(short sIn, FLOAT* pfltOut)
    26862686{
    2687     TRACE("( %d, %p ), stub\n", sIn, pfltOut );
    2688 
    2689     *pfltOut = (FLOAT) sIn;
    2690 
    2691     return S_OK;
    2692 }
    2693 
    2694 /******************************************************************************
    2695  *      VarR4FromI4     [OLEAUT32.70]
     2687        TRACE("( %d, %p ), stub\n", sIn, pfltOut );
     2688
     2689        *pfltOut = (FLOAT) sIn;
     2690
     2691        return S_OK;
     2692}
     2693
     2694/******************************************************************************
     2695 *              VarR4FromI4             [OLEAUT32.70]
    26962696 */
    26972697HRESULT WINAPI VarR4FromI4(LONG lIn, FLOAT* pfltOut)
    26982698{
    2699     TRACE("( %lx, %p ), stub\n", lIn, pfltOut );
    2700 
    2701     *pfltOut = (FLOAT) lIn;
    2702 
    2703     return S_OK;
    2704 }
    2705 
    2706 /******************************************************************************
    2707  *      VarR4FromR8     [OLEAUT32.71]
     2699        TRACE("( %lx, %p ), stub\n", lIn, pfltOut );
     2700
     2701        *pfltOut = (FLOAT) lIn;
     2702
     2703        return S_OK;
     2704}
     2705
     2706/******************************************************************************
     2707 *              VarR4FromR8             [OLEAUT32.71]
    27082708 */
    27092709HRESULT WINAPI VarR4FromR8(double dblIn, FLOAT* pfltOut)
    27102710{
    2711     TRACE("( %f, %p ), stub\n", dblIn, pfltOut );
    2712 
    2713     /* Check range of value.
    2714     */
    2715     if( dblIn < -(FLT_MAX) || dblIn > FLT_MAX )
    2716     {
    2717         return DISP_E_OVERFLOW;
    2718     }
    2719 
    2720     *pfltOut = (FLOAT) dblIn;
    2721 
    2722     return S_OK;
    2723 }
    2724 
    2725 /******************************************************************************
    2726  *      VarR4FromDate       [OLEAUT32.73]
     2711        TRACE("( %f, %p ), stub\n", dblIn, pfltOut );
     2712
     2713        /* Check range of value.
     2714        */
     2715        if( dblIn < -(FLT_MAX) || dblIn > FLT_MAX )
     2716        {
     2717                return DISP_E_OVERFLOW;
     2718        }
     2719
     2720        *pfltOut = (FLOAT) dblIn;
     2721
     2722        return S_OK;
     2723}
     2724
     2725/******************************************************************************
     2726 *              VarR4FromDate           [OLEAUT32.73]
    27272727 */
    27282728HRESULT WINAPI VarR4FromDate(DATE dateIn, FLOAT* pfltOut)
    27292729{
    2730     TRACE("( %f, %p ), stub\n", dateIn, pfltOut );
    2731 
    2732     /* Check range of value.
    2733     */
    2734     if( dateIn < -(FLT_MAX) || dateIn > FLT_MAX )
    2735     {
    2736         return DISP_E_OVERFLOW;
    2737     }
    2738 
    2739     *pfltOut = (FLOAT) dateIn;
    2740 
    2741     return S_OK;
    2742 }
    2743 
    2744 /******************************************************************************
    2745  *      VarR4FromBool       [OLEAUT32.76]
     2730        TRACE("( %f, %p ), stub\n", dateIn, pfltOut );
     2731
     2732        /* Check range of value.
     2733        */
     2734        if( dateIn < -(FLT_MAX) || dateIn > FLT_MAX )
     2735        {
     2736                return DISP_E_OVERFLOW;
     2737        }
     2738
     2739        *pfltOut = (FLOAT) dateIn;
     2740
     2741        return S_OK;
     2742}
     2743
     2744/******************************************************************************
     2745 *              VarR4FromBool           [OLEAUT32.76]
    27462746 */
    27472747HRESULT WINAPI VarR4FromBool(VARIANT_BOOL boolIn, FLOAT* pfltOut)
    27482748{
    2749     TRACE("( %d, %p ), stub\n", boolIn, pfltOut );
    2750 
    2751     *pfltOut = (FLOAT) boolIn;
    2752 
    2753     return S_OK;
    2754 }
    2755 
    2756 /******************************************************************************
    2757  *      VarR4FromI1     [OLEAUT32.213]
     2749        TRACE("( %d, %p ), stub\n", boolIn, pfltOut );
     2750
     2751        *pfltOut = (FLOAT) boolIn;
     2752
     2753        return S_OK;
     2754}
     2755
     2756/******************************************************************************
     2757 *              VarR4FromI1             [OLEAUT32.213]
    27582758 */
    27592759HRESULT WINAPI VarR4FromI1(CHAR cIn, FLOAT* pfltOut)
    27602760{
    2761     TRACE("( %c, %p ), stub\n", cIn, pfltOut );
    2762 
    2763     *pfltOut = (FLOAT) cIn;
    2764 
    2765     return S_OK;
    2766 }
    2767 
    2768 /******************************************************************************
    2769  *      VarR4FromUI2        [OLEAUT32.214]
     2761        TRACE("( %c, %p ), stub\n", cIn, pfltOut );
     2762
     2763        *pfltOut = (FLOAT) cIn;
     2764
     2765        return S_OK;
     2766}
     2767
     2768/******************************************************************************
     2769 *              VarR4FromUI2            [OLEAUT32.214]
    27702770 */
    27712771HRESULT WINAPI VarR4FromUI2(USHORT uiIn, FLOAT* pfltOut)
    27722772{
    2773     TRACE("( %d, %p ), stub\n", uiIn, pfltOut );
    2774 
    2775     *pfltOut = (FLOAT) uiIn;
    2776 
    2777     return S_OK;
    2778 }
    2779 
    2780 /******************************************************************************
    2781  *      VarR4FromUI4        [OLEAUT32.215]
     2773        TRACE("( %d, %p ), stub\n", uiIn, pfltOut );
     2774
     2775        *pfltOut = (FLOAT) uiIn;
     2776
     2777        return S_OK;
     2778}
     2779
     2780/******************************************************************************
     2781 *              VarR4FromUI4            [OLEAUT32.215]
    27822782 */
    27832783HRESULT WINAPI VarR4FromUI4(ULONG ulIn, FLOAT* pfltOut)
    27842784{
    2785     TRACE("( %ld, %p ), stub\n", ulIn, pfltOut );
    2786 
    2787     *pfltOut = (FLOAT) ulIn;
    2788 
    2789     return S_OK;
    2790 }
    2791 
    2792 /******************************************************************************
    2793  *      VarR4FromStr        [OLEAUT32.74]
     2785        TRACE("( %ld, %p ), stub\n", ulIn, pfltOut );
     2786
     2787        *pfltOut = (FLOAT) ulIn;
     2788
     2789        return S_OK;
     2790}
     2791
     2792/******************************************************************************
     2793 *              VarR4FromStr            [OLEAUT32.74]
    27942794 */
    27952795HRESULT WINAPI VarR4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, FLOAT* pfltOut)
    27962796{
    2797     double dValue = 0.0;
    2798     LPSTR pNewString = NULL;
    2799 
    2800     TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pfltOut );
    2801 
    2802     /* Check if we have a valid argument
    2803     */
    2804     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    2805     RemoveCharacterFromString( pNewString, "," );
    2806     if( IsValidRealString( pNewString ) == FALSE )
    2807     {
    2808         return DISP_E_TYPEMISMATCH;
    2809     }
    2810 
    2811     /* Convert the valid string to a floating point number.
    2812     */
    2813     dValue = atof( pNewString );
    2814 
    2815     /* We don't need the string anymore so free it.
    2816     */
    2817     HeapFree( GetProcessHeap(), 0, pNewString );
    2818 
    2819     /* Check range of value.
    2820     */
    2821     if( dValue < -(FLT_MAX) || dValue > FLT_MAX )
    2822     {
    2823         return DISP_E_OVERFLOW;
    2824     }
    2825 
    2826     *pfltOut = (FLOAT) dValue;
    2827 
    2828     return S_OK;
     2797        double dValue = 0.0;
     2798        LPSTR pNewString = NULL;
     2799
     2800        TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pfltOut );
     2801
     2802        /* Check if we have a valid argument
     2803        */
     2804        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     2805        RemoveCharacterFromString( pNewString, "," );
     2806        if( IsValidRealString( pNewString ) == FALSE )
     2807        {
     2808                return DISP_E_TYPEMISMATCH;
     2809        }
     2810
     2811        /* Convert the valid string to a floating point number.
     2812        */
     2813        dValue = atof( pNewString );
     2814       
     2815        /* We don't need the string anymore so free it.
     2816        */
     2817        HeapFree( GetProcessHeap(), 0, pNewString );
     2818
     2819        /* Check range of value.
     2820        */
     2821        if( dValue < -(FLT_MAX) || dValue > FLT_MAX )
     2822        {
     2823                return DISP_E_OVERFLOW;
     2824        }
     2825
     2826        *pfltOut = (FLOAT) dValue;
     2827
     2828        return S_OK;
    28292829}
    28302830
     
    28352835HRESULT WINAPI VarR4FromCy(CY cyIn, FLOAT* pfltOut) {
    28362836   *pfltOut = (FLOAT)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2837 
     2837   
    28382838   return S_OK;
    28392839}
    28402840
    28412841/******************************************************************************
    2842  *      VarR8FromUI1        [OLEAUT32.78]
     2842 *              VarR8FromUI1            [OLEAUT32.78]
    28432843 */
    28442844HRESULT WINAPI VarR8FromUI1(BYTE bIn, double* pdblOut)
    28452845{
    2846     TRACE("( %d, %p ), stub\n", bIn, pdblOut );
    2847 
    2848     *pdblOut = (double) bIn;
    2849 
    2850     return S_OK;
    2851 }
    2852 
    2853 /******************************************************************************
    2854  *      VarR8FromI2     [OLEAUT32.79]
     2846        TRACE("( %d, %p ), stub\n", bIn, pdblOut );
     2847
     2848        *pdblOut = (double) bIn;
     2849
     2850        return S_OK;
     2851}
     2852
     2853/******************************************************************************
     2854 *              VarR8FromI2             [OLEAUT32.79]
    28552855 */
    28562856HRESULT WINAPI VarR8FromI2(short sIn, double* pdblOut)
    28572857{
    2858     TRACE("( %d, %p ), stub\n", sIn, pdblOut );
    2859 
    2860     *pdblOut = (double) sIn;
    2861 
    2862     return S_OK;
    2863 }
    2864 
    2865 /******************************************************************************
    2866  *      VarR8FromI4     [OLEAUT32.80]
     2858        TRACE("( %d, %p ), stub\n", sIn, pdblOut );
     2859
     2860        *pdblOut = (double) sIn;
     2861
     2862        return S_OK;
     2863}
     2864
     2865/******************************************************************************
     2866 *              VarR8FromI4             [OLEAUT32.80]
    28672867 */
    28682868HRESULT WINAPI VarR8FromI4(LONG lIn, double* pdblOut)
    28692869{
    2870     TRACE("( %ld, %p ), stub\n", lIn, pdblOut );
    2871 
    2872     *pdblOut = (double) lIn;
    2873 
    2874     return S_OK;
    2875 }
    2876 
    2877 /******************************************************************************
    2878  *      VarR8FromR4     [OLEAUT32.81]
     2870        TRACE("( %ld, %p ), stub\n", lIn, pdblOut );
     2871
     2872        *pdblOut = (double) lIn;
     2873
     2874        return S_OK;
     2875}
     2876
     2877/******************************************************************************
     2878 *              VarR8FromR4             [OLEAUT32.81]
    28792879 */
    28802880HRESULT WINAPI VarR8FromR4(FLOAT fltIn, double* pdblOut)
    28812881{
    2882     TRACE("( %f, %p ), stub\n", fltIn, pdblOut );
    2883 
    2884     *pdblOut = (double) fltIn;
    2885 
    2886     return S_OK;
    2887 }
    2888 
    2889 /******************************************************************************
    2890  *      VarR8FromDate       [OLEAUT32.83]
     2882        TRACE("( %f, %p ), stub\n", fltIn, pdblOut );
     2883
     2884        *pdblOut = (double) fltIn;
     2885
     2886        return S_OK;
     2887}
     2888
     2889/******************************************************************************
     2890 *              VarR8FromDate           [OLEAUT32.83]
    28912891 */
    28922892HRESULT WINAPI VarR8FromDate(DATE dateIn, double* pdblOut)
    28932893{
    2894     TRACE("( %f, %p ), stub\n", dateIn, pdblOut );
    2895 
    2896     *pdblOut = (double) dateIn;
    2897 
    2898     return S_OK;
    2899 }
    2900 
    2901 /******************************************************************************
    2902  *      VarR8FromBool       [OLEAUT32.86]
     2894        TRACE("( %f, %p ), stub\n", dateIn, pdblOut );
     2895
     2896        *pdblOut = (double) dateIn;
     2897
     2898        return S_OK;
     2899}
     2900
     2901/******************************************************************************
     2902 *              VarR8FromBool           [OLEAUT32.86]
    29032903 */
    29042904HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double* pdblOut)
    29052905{
    2906     TRACE("( %d, %p ), stub\n", boolIn, pdblOut );
    2907 
    2908     *pdblOut = (double) boolIn;
    2909 
    2910     return S_OK;
    2911 }
    2912 
    2913 /******************************************************************************
    2914  *      VarR8FromI1     [OLEAUT32.217]
     2906        TRACE("( %d, %p ), stub\n", boolIn, pdblOut );
     2907
     2908        *pdblOut = (double) boolIn;
     2909
     2910        return S_OK;
     2911}
     2912
     2913/******************************************************************************
     2914 *              VarR8FromI1             [OLEAUT32.217]
    29152915 */
    29162916HRESULT WINAPI VarR8FromI1(CHAR cIn, double* pdblOut)
    29172917{
    2918     TRACE("( %c, %p ), stub\n", cIn, pdblOut );
    2919 
    2920     *pdblOut = (double) cIn;
    2921 
    2922     return S_OK;
    2923 }
    2924 
    2925 /******************************************************************************
    2926  *      VarR8FromUI2        [OLEAUT32.218]
     2918        TRACE("( %c, %p ), stub\n", cIn, pdblOut );
     2919
     2920        *pdblOut = (double) cIn;
     2921
     2922        return S_OK;
     2923}
     2924
     2925/******************************************************************************
     2926 *              VarR8FromUI2            [OLEAUT32.218]
    29272927 */
    29282928HRESULT WINAPI VarR8FromUI2(USHORT uiIn, double* pdblOut)
    29292929{
    2930     TRACE("( %d, %p ), stub\n", uiIn, pdblOut );
    2931 
    2932     *pdblOut = (double) uiIn;
    2933 
    2934     return S_OK;
    2935 }
    2936 
    2937 /******************************************************************************
    2938  *      VarR8FromUI4        [OLEAUT32.219]
     2930        TRACE("( %d, %p ), stub\n", uiIn, pdblOut );
     2931
     2932        *pdblOut = (double) uiIn;
     2933
     2934        return S_OK;
     2935}
     2936
     2937/******************************************************************************
     2938 *              VarR8FromUI4            [OLEAUT32.219]
    29392939 */
    29402940HRESULT WINAPI VarR8FromUI4(ULONG ulIn, double* pdblOut)
    29412941{
    2942     TRACE("( %ld, %p ), stub\n", ulIn, pdblOut );
    2943 
    2944     *pdblOut = (double) ulIn;
    2945 
    2946     return S_OK;
    2947 }
    2948 
    2949 /******************************************************************************
    2950  *      VarR8FromStr        [OLEAUT32.84]
     2942        TRACE("( %ld, %p ), stub\n", ulIn, pdblOut );
     2943
     2944        *pdblOut = (double) ulIn;
     2945
     2946        return S_OK;
     2947}
     2948
     2949/******************************************************************************
     2950 *              VarR8FromStr            [OLEAUT32.84]
    29512951 */
    29522952HRESULT WINAPI VarR8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, double* pdblOut)
    29532953{
    2954     double dValue = 0.0;
    2955     LPSTR pNewString = NULL;
    2956 
    2957     TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pdblOut );
    2958 
    2959     /* Check if we have a valid argument
    2960     */
    2961     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    2962     RemoveCharacterFromString( pNewString, "," );
    2963     if( IsValidRealString( pNewString ) == FALSE )
    2964     {
    2965         return DISP_E_TYPEMISMATCH;
    2966     }
    2967 
    2968     /* Convert the valid string to a floating point number.
    2969     */
    2970     dValue = atof( pNewString );
    2971 
    2972     /* We don't need the string anymore so free it.
    2973     */
    2974     HeapFree( GetProcessHeap(), 0, pNewString );
    2975 
    2976     *pdblOut = dValue;
    2977 
    2978     return S_OK;
     2954        double dValue = 0.0;
     2955        LPSTR pNewString = NULL;
     2956
     2957        TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pdblOut );
     2958
     2959        /* Check if we have a valid argument
     2960        */
     2961        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     2962        RemoveCharacterFromString( pNewString, "," );
     2963        if( IsValidRealString( pNewString ) == FALSE )
     2964        {
     2965                return DISP_E_TYPEMISMATCH;
     2966        }
     2967
     2968        /* Convert the valid string to a floating point number.
     2969        */
     2970        dValue = atof( pNewString );
     2971       
     2972        /* We don't need the string anymore so free it.
     2973        */
     2974        HeapFree( GetProcessHeap(), 0, pNewString );
     2975
     2976        *pdblOut = dValue;
     2977
     2978        return S_OK;
    29792979}
    29802980
     
    29852985HRESULT WINAPI VarR8FromCy(CY cyIn, double* pdblOut) {
    29862986   *pdblOut = (double)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2987 
     2987   
    29882988   return S_OK;
    29892989}
    29902990
    29912991/******************************************************************************
    2992  *      VarDateFromUI1      [OLEAUT32.88]
     2992 *              VarDateFromUI1          [OLEAUT32.88]
    29932993 */
    29942994HRESULT WINAPI VarDateFromUI1(BYTE bIn, DATE* pdateOut)
    29952995{
    2996     TRACE("( %d, %p ), stub\n", bIn, pdateOut );
    2997 
    2998     *pdateOut = (DATE) bIn;
    2999 
    3000     return S_OK;
    3001 }
    3002 
    3003 /******************************************************************************
    3004  *      VarDateFromI2       [OLEAUT32.89]
     2996        TRACE("( %d, %p ), stub\n", bIn, pdateOut );
     2997
     2998        *pdateOut = (DATE) bIn;
     2999
     3000        return S_OK;
     3001}
     3002
     3003/******************************************************************************
     3004 *              VarDateFromI2           [OLEAUT32.89]
    30053005 */
    30063006HRESULT WINAPI VarDateFromI2(short sIn, DATE* pdateOut)
    30073007{
    3008     TRACE("( %d, %p ), stub\n", sIn, pdateOut );
    3009 
    3010     *pdateOut = (DATE) sIn;
    3011 
    3012     return S_OK;
    3013 }
    3014 
    3015 /******************************************************************************
    3016  *      VarDateFromI4       [OLEAUT32.90]
     3008        TRACE("( %d, %p ), stub\n", sIn, pdateOut );
     3009
     3010        *pdateOut = (DATE) sIn;
     3011
     3012        return S_OK;
     3013}
     3014
     3015/******************************************************************************
     3016 *              VarDateFromI4           [OLEAUT32.90]
    30173017 */
    30183018HRESULT WINAPI VarDateFromI4(LONG lIn, DATE* pdateOut)
    30193019{
    3020     TRACE("( %ld, %p ), stub\n", lIn, pdateOut );
    3021 
    3022     if( lIn < DATE_MIN || lIn > DATE_MAX )
    3023     {
    3024         return DISP_E_OVERFLOW;
    3025     }
    3026 
    3027     *pdateOut = (DATE) lIn;
    3028 
    3029     return S_OK;
    3030 }
    3031 
    3032 /******************************************************************************
    3033  *      VarDateFromR4       [OLEAUT32.91]
     3020        TRACE("( %ld, %p ), stub\n", lIn, pdateOut );
     3021
     3022        if( lIn < DATE_MIN || lIn > DATE_MAX )
     3023        {
     3024                return DISP_E_OVERFLOW;
     3025        }
     3026
     3027        *pdateOut = (DATE) lIn;
     3028
     3029        return S_OK;
     3030}
     3031
     3032/******************************************************************************
     3033 *              VarDateFromR4           [OLEAUT32.91]
    30343034 */
    30353035HRESULT WINAPI VarDateFromR4(FLOAT fltIn, DATE* pdateOut)
     
    30383038
    30393039    if( ceil(fltIn) < DATE_MIN || floor(fltIn) > DATE_MAX )
    3040     {
    3041         return DISP_E_OVERFLOW;
    3042     }
    3043 
    3044     *pdateOut = (DATE) fltIn;
    3045 
    3046     return S_OK;
    3047 }
    3048 
    3049 /******************************************************************************
    3050  *      VarDateFromR8       [OLEAUT32.92]
     3040        {
     3041                return DISP_E_OVERFLOW;
     3042        }
     3043
     3044        *pdateOut = (DATE) fltIn;
     3045
     3046        return S_OK;
     3047}
     3048
     3049/******************************************************************************
     3050 *              VarDateFromR8           [OLEAUT32.92]
    30513051 */
    30523052HRESULT WINAPI VarDateFromR8(double dblIn, DATE* pdateOut)
     
    30543054    TRACE("( %f, %p ), stub\n", dblIn, pdateOut );
    30553055
    3056     if( ceil(dblIn) < DATE_MIN || floor(dblIn) > DATE_MAX )
    3057     {
    3058         return DISP_E_OVERFLOW;
    3059     }
    3060 
    3061     *pdateOut = (DATE) dblIn;
    3062 
    3063     return S_OK;
    3064 }
    3065 
    3066 /******************************************************************************
    3067  *      VarDateFromStr      [OLEAUT32.94]
     3056        if( ceil(dblIn) < DATE_MIN || floor(dblIn) > DATE_MAX )
     3057        {
     3058                return DISP_E_OVERFLOW;
     3059        }
     3060
     3061        *pdateOut = (DATE) dblIn;
     3062
     3063        return S_OK;
     3064}
     3065
     3066/******************************************************************************
     3067 *              VarDateFromStr          [OLEAUT32.94]
    30683068 * The string representing the date is composed of two parts, a date and time.
    30693069 *
     
    30743074 *
    30753075 * The formats for the date part are has follows:
    3076  * mm/[dd/][yy]yy
     3076 * mm/[dd/][yy]yy 
    30773077 * [dd/]mm/[yy]yy
    3078  * [yy]yy/mm/dd
     3078 * [yy]yy/mm/dd 
    30793079 * January dd[,] [yy]yy
    30803080 * dd January [yy]yy
     
    30833083 *
    30843084 * The formats for the date and time string are has follows.
    3085  * date[whitespace][time]
     3085 * date[whitespace][time] 
    30863086 * [time][whitespace]date
    30873087 *
     
    31113111
    31123112
    3113     return ret;
    3114 }
    3115 
    3116 /******************************************************************************
    3117  *      VarDateFromI1       [OLEAUT32.221]
     3113        return ret;
     3114}
     3115
     3116/******************************************************************************
     3117 *              VarDateFromI1           [OLEAUT32.221]
    31183118 */
    31193119HRESULT WINAPI VarDateFromI1(CHAR cIn, DATE* pdateOut)
    31203120{
    3121     TRACE("( %c, %p ), stub\n", cIn, pdateOut );
    3122 
    3123     *pdateOut = (DATE) cIn;
    3124 
    3125     return S_OK;
    3126 }
    3127 
    3128 /******************************************************************************
    3129  *      VarDateFromUI2      [OLEAUT32.222]
     3121        TRACE("( %c, %p ), stub\n", cIn, pdateOut );
     3122
     3123        *pdateOut = (DATE) cIn;
     3124
     3125        return S_OK;
     3126}
     3127
     3128/******************************************************************************
     3129 *              VarDateFromUI2          [OLEAUT32.222]
    31303130 */
    31313131HRESULT WINAPI VarDateFromUI2(USHORT uiIn, DATE* pdateOut)
    31323132{
    3133     TRACE("( %d, %p ), stub\n", uiIn, pdateOut );
    3134 
    3135     if( uiIn > DATE_MAX )
    3136     {
    3137         return DISP_E_OVERFLOW;
    3138     }
    3139 
    3140     *pdateOut = (DATE) uiIn;
    3141 
    3142     return S_OK;
    3143 }
    3144 
    3145 /******************************************************************************
    3146  *      VarDateFromUI4      [OLEAUT32.223]
     3133        TRACE("( %d, %p ), stub\n", uiIn, pdateOut );
     3134
     3135        if( uiIn > DATE_MAX )
     3136        {
     3137                return DISP_E_OVERFLOW;
     3138        }
     3139
     3140        *pdateOut = (DATE) uiIn;
     3141
     3142        return S_OK;
     3143}
     3144
     3145/******************************************************************************
     3146 *              VarDateFromUI4          [OLEAUT32.223]
    31473147 */
    31483148HRESULT WINAPI VarDateFromUI4(ULONG ulIn, DATE* pdateOut)
    31493149{
    3150     TRACE("( %ld, %p ), stub\n", ulIn, pdateOut );
    3151 
    3152     if( ulIn < DATE_MIN || ulIn > DATE_MAX )
    3153     {
    3154         return DISP_E_OVERFLOW;
    3155     }
    3156 
    3157     *pdateOut = (DATE) ulIn;
    3158 
    3159     return S_OK;
    3160 }
    3161 
    3162 /******************************************************************************
    3163  *      VarDateFromBool     [OLEAUT32.96]
     3150        TRACE("( %ld, %p ), stub\n", ulIn, pdateOut );
     3151
     3152        if( ulIn < DATE_MIN || ulIn > DATE_MAX )
     3153        {
     3154                return DISP_E_OVERFLOW;
     3155        }
     3156
     3157        *pdateOut = (DATE) ulIn;
     3158
     3159        return S_OK;
     3160}
     3161
     3162/******************************************************************************
     3163 *              VarDateFromBool         [OLEAUT32.96]
    31643164 */
    31653165HRESULT WINAPI VarDateFromBool(VARIANT_BOOL boolIn, DATE* pdateOut)
    31663166{
    3167     TRACE("( %d, %p ), stub\n", boolIn, pdateOut );
    3168 
    3169     *pdateOut = (DATE) boolIn;
    3170 
    3171     return S_OK;
     3167        TRACE("( %d, %p ), stub\n", boolIn, pdateOut );
     3168
     3169        *pdateOut = (DATE) boolIn;
     3170
     3171        return S_OK;
    31723172}
    31733173
     
    31843184
    31853185/******************************************************************************
    3186  *      VarBstrFromUI1      [OLEAUT32.108]
     3186 *              VarBstrFromUI1          [OLEAUT32.108]
    31873187 */
    31883188HRESULT WINAPI VarBstrFromUI1(BYTE bVal, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    31893189{
    3190     TRACE("( %d, %ld, %ld, %p ), stub\n", bVal, lcid, dwFlags, pbstrOut );
    3191     sprintf( pBuffer, "%d", bVal );
    3192 
    3193     *pbstrOut =  StringDupAtoBstr( pBuffer );
    3194 
    3195     return S_OK;
    3196 }
    3197 
    3198 /******************************************************************************
    3199  *      VarBstrFromI2       [OLEAUT32.109]
     3190        TRACE("( %d, %ld, %ld, %p ), stub\n", bVal, lcid, dwFlags, pbstrOut );
     3191        sprintf( pBuffer, "%d", bVal );
     3192
     3193        *pbstrOut =  StringDupAtoBstr( pBuffer );
     3194       
     3195        return S_OK;
     3196}
     3197
     3198/******************************************************************************
     3199 *              VarBstrFromI2           [OLEAUT32.109]
    32003200 */
    32013201HRESULT WINAPI VarBstrFromI2(short iVal, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    32023202{
    3203     TRACE("( %d, %ld, %ld, %p ), stub\n", iVal, lcid, dwFlags, pbstrOut );
    3204     sprintf( pBuffer, "%d", iVal );
    3205     *pbstrOut = StringDupAtoBstr( pBuffer );
    3206 
    3207     return S_OK;
    3208 }
    3209 
    3210 /******************************************************************************
    3211  *      VarBstrFromI4       [OLEAUT32.110]
     3203        TRACE("( %d, %ld, %ld, %p ), stub\n", iVal, lcid, dwFlags, pbstrOut );
     3204        sprintf( pBuffer, "%d", iVal );
     3205        *pbstrOut = StringDupAtoBstr( pBuffer );
     3206
     3207        return S_OK;
     3208}
     3209
     3210/******************************************************************************
     3211 *              VarBstrFromI4           [OLEAUT32.110]
    32123212 */
    32133213HRESULT WINAPI VarBstrFromI4(LONG lIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    32143214{
    3215     TRACE("( %ld, %ld, %ld, %p ), stub\n", lIn, lcid, dwFlags, pbstrOut );
    3216 
    3217     sprintf( pBuffer, "%ld", lIn );
    3218     *pbstrOut = StringDupAtoBstr( pBuffer );
    3219 
    3220     return S_OK;
    3221 }
    3222 
    3223 /******************************************************************************
    3224  *      VarBstrFromR4       [OLEAUT32.111]
     3215        TRACE("( %ld, %ld, %ld, %p ), stub\n", lIn, lcid, dwFlags, pbstrOut );
     3216
     3217        sprintf( pBuffer, "%ld", lIn );
     3218        *pbstrOut = StringDupAtoBstr( pBuffer );
     3219
     3220        return S_OK;
     3221}
     3222
     3223/******************************************************************************
     3224 *              VarBstrFromR4           [OLEAUT32.111]
    32253225 */
    32263226HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    32273227{
    3228     TRACE("( %f, %ld, %ld, %p ), stub\n", fltIn, lcid, dwFlags, pbstrOut );
    3229 
    3230     sprintf( pBuffer, "%.7g", fltIn );
    3231     *pbstrOut = StringDupAtoBstr( pBuffer );
    3232 
    3233     return S_OK;
    3234 }
    3235 
    3236 /******************************************************************************
    3237  *      VarBstrFromR8       [OLEAUT32.112]
     3228        TRACE("( %f, %ld, %ld, %p ), stub\n", fltIn, lcid, dwFlags, pbstrOut );
     3229
     3230        sprintf( pBuffer, "%.7g", fltIn );
     3231        *pbstrOut = StringDupAtoBstr( pBuffer );
     3232
     3233        return S_OK;
     3234}
     3235
     3236/******************************************************************************
     3237 *              VarBstrFromR8           [OLEAUT32.112]
    32383238 */
    32393239HRESULT WINAPI VarBstrFromR8(double dblIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    32403240{
    3241     TRACE("( %f, %ld, %ld, %p ), stub\n", dblIn, lcid, dwFlags, pbstrOut );
    3242 
    3243     sprintf( pBuffer, "%.15g", dblIn );
    3244     *pbstrOut = StringDupAtoBstr( pBuffer );
    3245 
    3246     return S_OK;
     3241        TRACE("( %f, %ld, %ld, %p ), stub\n", dblIn, lcid, dwFlags, pbstrOut );
     3242
     3243        sprintf( pBuffer, "%.15g", dblIn );
     3244        *pbstrOut = StringDupAtoBstr( pBuffer );
     3245
     3246        return S_OK;
    32473247}
    32483248
     
    32513251 */
    32523252HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut) {
    3253                 /* FIXME */
    3254     return E_NOTIMPL;
    3255 }
    3256 
    3257 
    3258 /******************************************************************************
    3259  *      VarBstrFromDate     [OLEAUT32.114]
     3253                                /* FIXME */
     3254        return E_NOTIMPL;
     3255}
     3256
     3257 
     3258/******************************************************************************
     3259 *              VarBstrFromDate         [OLEAUT32.114]
    32603260 *
    32613261 * The date is implemented using an 8 byte floating-point number.
     
    32743274 * The tm structure is as follows:
    32753275 * struct tm {
    3276  *        int tm_sec;      seconds after the minute - [0,59]
    3277  *        int tm_min;      minutes after the hour - [0,59]
    3278  *        int tm_hour;     hours since midnight - [0,23]
    3279  *        int tm_mday;     day of the month - [1,31]
    3280  *        int tm_mon;      months since January - [0,11]
    3281  *        int tm_year;     years
    3282  *        int tm_wday;     days since Sunday - [0,6]
    3283  *        int tm_yday;     days since January 1 - [0,365]
    3284  *        int tm_isdst;    daylight savings time flag
    3285  *        };
     3276 *                int tm_sec;      seconds after the minute - [0,59]
     3277 *                int tm_min;      minutes after the hour - [0,59]
     3278 *                int tm_hour;     hours since midnight - [0,23]
     3279 *                int tm_mday;     day of the month - [1,31]
     3280 *                int tm_mon;      months since January - [0,11]
     3281 *                int tm_year;     years
     3282 *                int tm_wday;     days since Sunday - [0,6]
     3283 *                int tm_yday;     days since January 1 - [0,365]
     3284 *                int tm_isdst;    daylight savings time flag
     3285 *                };
    32863286 */
    32873287HRESULT WINAPI VarBstrFromDate(DATE dateIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
     
    32933293
    32943294    if( DateToTm( dateIn, dwFlags, &TM ) == FALSE )
    3295             {
     3295                        {
    32963296        return E_INVALIDARG;
    3297         }
     3297                }
    32983298
    32993299    if( dwFlags & VAR_DATEVALUEONLY )
    3300             strftime( pBuffer, BUFFER_MAX, "%x", &TM );
     3300                        strftime( pBuffer, BUFFER_MAX, "%x", &TM );
    33013301    else if( dwFlags & VAR_TIMEVALUEONLY )
    3302             strftime( pBuffer, BUFFER_MAX, "%X", &TM );
    3303         else
     3302                        strftime( pBuffer, BUFFER_MAX, "%X", &TM );
     3303                else
    33043304        strftime( pBuffer, BUFFER_MAX, "%x %X", &TM );
    33053305
    3306         *pbstrOut = StringDupAtoBstr( pBuffer );
    3307 
    3308     return S_OK;
    3309 }
    3310 
    3311 /******************************************************************************
    3312  *      VarBstrFromBool     [OLEAUT32.116]
     3306                *pbstrOut = StringDupAtoBstr( pBuffer );
     3307
     3308        return S_OK;
     3309}
     3310
     3311/******************************************************************************
     3312 *              VarBstrFromBool         [OLEAUT32.116]
    33133313 */
    33143314HRESULT WINAPI VarBstrFromBool(VARIANT_BOOL boolIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    33153315{
    3316     TRACE("( %d, %ld, %ld, %p ), stub\n", boolIn, lcid, dwFlags, pbstrOut );
    3317 
    3318     if( boolIn == VARIANT_FALSE )
    3319     {
    3320         sprintf( pBuffer, "False" );
    3321     }
    3322     else
    3323     {
    3324         sprintf( pBuffer, "True" );
    3325     }
    3326 
    3327     *pbstrOut = StringDupAtoBstr( pBuffer );
    3328 
    3329     return S_OK;
    3330 }
    3331 
    3332 /******************************************************************************
    3333  *      VarBstrFromI1       [OLEAUT32.229]
     3316        TRACE("( %d, %ld, %ld, %p ), stub\n", boolIn, lcid, dwFlags, pbstrOut );
     3317
     3318        if( boolIn == VARIANT_FALSE )
     3319        {
     3320                sprintf( pBuffer, "False" );
     3321        }
     3322        else
     3323        {
     3324                sprintf( pBuffer, "True" );
     3325        }
     3326
     3327        *pbstrOut = StringDupAtoBstr( pBuffer );
     3328
     3329        return S_OK;
     3330}
     3331
     3332/******************************************************************************
     3333 *              VarBstrFromI1           [OLEAUT32.229]
    33343334 */
    33353335HRESULT WINAPI VarBstrFromI1(CHAR cIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    33363336{
    3337     TRACE("( %c, %ld, %ld, %p ), stub\n", cIn, lcid, dwFlags, pbstrOut );
    3338     sprintf( pBuffer, "%d", cIn );
    3339     *pbstrOut = StringDupAtoBstr( pBuffer );
    3340 
    3341     return S_OK;
    3342 }
    3343 
    3344 /******************************************************************************
    3345  *      VarBstrFromUI2      [OLEAUT32.230]
     3337        TRACE("( %c, %ld, %ld, %p ), stub\n", cIn, lcid, dwFlags, pbstrOut );
     3338        sprintf( pBuffer, "%d", cIn );
     3339        *pbstrOut = StringDupAtoBstr( pBuffer );
     3340
     3341        return S_OK;
     3342}
     3343
     3344/******************************************************************************
     3345 *              VarBstrFromUI2          [OLEAUT32.230]
    33463346 */
    33473347HRESULT WINAPI VarBstrFromUI2(USHORT uiIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    33483348{
    3349     TRACE("( %d, %ld, %ld, %p ), stub\n", uiIn, lcid, dwFlags, pbstrOut );
    3350     sprintf( pBuffer, "%d", uiIn );
    3351     *pbstrOut = StringDupAtoBstr( pBuffer );
    3352 
    3353     return S_OK;
    3354 }
    3355 
    3356 /******************************************************************************
    3357  *      VarBstrFromUI4      [OLEAUT32.231]
     3349        TRACE("( %d, %ld, %ld, %p ), stub\n", uiIn, lcid, dwFlags, pbstrOut );
     3350        sprintf( pBuffer, "%d", uiIn );
     3351        *pbstrOut = StringDupAtoBstr( pBuffer );
     3352
     3353        return S_OK;
     3354}
     3355
     3356/******************************************************************************
     3357 *              VarBstrFromUI4          [OLEAUT32.231]
    33583358 */
    33593359HRESULT WINAPI VarBstrFromUI4(ULONG ulIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
    33603360{
    3361     TRACE("( %ld, %ld, %ld, %p ), stub\n", ulIn, lcid, dwFlags, pbstrOut );
    3362     sprintf( pBuffer, "%ld", ulIn );
    3363     *pbstrOut = StringDupAtoBstr( pBuffer );
    3364 
    3365     return S_OK;
    3366 }
    3367 
    3368 /******************************************************************************
    3369  *      VarBoolFromUI1      [OLEAUT32.118]
     3361        TRACE("( %ld, %ld, %ld, %p ), stub\n", ulIn, lcid, dwFlags, pbstrOut );
     3362        sprintf( pBuffer, "%ld", ulIn );
     3363        *pbstrOut = StringDupAtoBstr( pBuffer );
     3364
     3365        return S_OK;
     3366}
     3367
     3368/******************************************************************************
     3369 *              VarBoolFromUI1          [OLEAUT32.118]
    33703370 */
    33713371HRESULT WINAPI VarBoolFromUI1(BYTE bIn, VARIANT_BOOL* pboolOut)
    33723372{
    3373     TRACE("( %d, %p ), stub\n", bIn, pboolOut );
    3374 
    3375     if( bIn == 0 )
    3376     {
    3377         *pboolOut = VARIANT_FALSE;
    3378     }
    3379     else
    3380     {
    3381         *pboolOut = VARIANT_TRUE;
    3382     }
    3383 
    3384     return S_OK;
    3385 }
    3386 
    3387 /******************************************************************************
    3388  *      VarBoolFromI2       [OLEAUT32.119]
     3373        TRACE("( %d, %p ), stub\n", bIn, pboolOut );
     3374
     3375        if( bIn == 0 )
     3376        {
     3377                *pboolOut = VARIANT_FALSE;
     3378        }
     3379        else
     3380        {
     3381                *pboolOut = VARIANT_TRUE;
     3382        }
     3383
     3384        return S_OK;
     3385}
     3386
     3387/******************************************************************************
     3388 *              VarBoolFromI2           [OLEAUT32.119]
    33893389 */
    33903390HRESULT WINAPI VarBoolFromI2(short sIn, VARIANT_BOOL* pboolOut)
    33913391{
    3392     TRACE("( %d, %p ), stub\n", sIn, pboolOut );
    3393 
    3394     if( sIn == 0 )
    3395     {
    3396         *pboolOut = VARIANT_FALSE;
    3397     }
    3398     else
    3399     {
    3400         *pboolOut = VARIANT_TRUE;
    3401     }
    3402 
    3403     return S_OK;
    3404 }
    3405 
    3406 /******************************************************************************
    3407  *      VarBoolFromI4       [OLEAUT32.120]
     3392        TRACE("( %d, %p ), stub\n", sIn, pboolOut );
     3393
     3394        if( sIn == 0 )
     3395        {
     3396                *pboolOut = VARIANT_FALSE;
     3397        }
     3398        else
     3399        {
     3400                *pboolOut = VARIANT_TRUE;
     3401        }
     3402
     3403        return S_OK;
     3404}
     3405
     3406/******************************************************************************
     3407 *              VarBoolFromI4           [OLEAUT32.120]
    34083408 */
    34093409HRESULT WINAPI VarBoolFromI4(LONG lIn, VARIANT_BOOL* pboolOut)
    34103410{
    3411     TRACE("( %ld, %p ), stub\n", lIn, pboolOut );
    3412 
    3413     if( lIn == 0 )
    3414     {
    3415         *pboolOut = VARIANT_FALSE;
    3416     }
    3417     else
    3418     {
    3419         *pboolOut = VARIANT_TRUE;
    3420     }
    3421 
    3422     return S_OK;
    3423 }
    3424 
    3425 /******************************************************************************
    3426  *      VarBoolFromR4       [OLEAUT32.121]
     3411        TRACE("( %ld, %p ), stub\n", lIn, pboolOut );
     3412
     3413        if( lIn == 0 )
     3414        {
     3415                *pboolOut = VARIANT_FALSE;
     3416        }
     3417        else
     3418        {
     3419                *pboolOut = VARIANT_TRUE;
     3420        }
     3421
     3422        return S_OK;
     3423}
     3424
     3425/******************************************************************************
     3426 *              VarBoolFromR4           [OLEAUT32.121]
    34273427 */
    34283428HRESULT WINAPI VarBoolFromR4(FLOAT fltIn, VARIANT_BOOL* pboolOut)
    34293429{
    3430     TRACE("( %f, %p ), stub\n", fltIn, pboolOut );
    3431 
    3432     if( fltIn == 0.0 )
    3433     {
    3434         *pboolOut = VARIANT_FALSE;
    3435     }
    3436     else
    3437     {
    3438         *pboolOut = VARIANT_TRUE;
    3439     }
    3440 
    3441     return S_OK;
    3442 }
    3443 
    3444 /******************************************************************************
    3445  *      VarBoolFromR8       [OLEAUT32.122]
     3430        TRACE("( %f, %p ), stub\n", fltIn, pboolOut );
     3431
     3432        if( fltIn == 0.0 )
     3433        {
     3434                *pboolOut = VARIANT_FALSE;
     3435        }
     3436        else
     3437        {
     3438                *pboolOut = VARIANT_TRUE;
     3439        }
     3440
     3441        return S_OK;
     3442}
     3443
     3444/******************************************************************************
     3445 *              VarBoolFromR8           [OLEAUT32.122]
    34463446 */
    34473447HRESULT WINAPI VarBoolFromR8(double dblIn, VARIANT_BOOL* pboolOut)
    34483448{
    3449     TRACE("( %f, %p ), stub\n", dblIn, pboolOut );
    3450 
    3451     if( dblIn == 0.0 )
    3452     {
    3453         *pboolOut = VARIANT_FALSE;
    3454     }
    3455     else
    3456     {
    3457         *pboolOut = VARIANT_TRUE;
    3458     }
    3459 
    3460     return S_OK;
    3461 }
    3462 
    3463 /******************************************************************************
    3464  *      VarBoolFromDate     [OLEAUT32.123]
     3449        TRACE("( %f, %p ), stub\n", dblIn, pboolOut );
     3450
     3451        if( dblIn == 0.0 )
     3452        {
     3453                *pboolOut = VARIANT_FALSE;
     3454        }
     3455        else
     3456        {
     3457                *pboolOut = VARIANT_TRUE;
     3458        }
     3459
     3460        return S_OK;
     3461}
     3462
     3463/******************************************************************************
     3464 *              VarBoolFromDate         [OLEAUT32.123]
    34653465 */
    34663466HRESULT WINAPI VarBoolFromDate(DATE dateIn, VARIANT_BOOL* pboolOut)
    34673467{
    3468     TRACE("( %f, %p ), stub\n", dateIn, pboolOut );
    3469 
    3470     if( dateIn == 0.0 )
    3471     {
    3472         *pboolOut = VARIANT_FALSE;
    3473     }
    3474     else
    3475     {
    3476         *pboolOut = VARIANT_TRUE;
    3477     }
    3478 
    3479     return S_OK;
    3480 }
    3481 
    3482 /******************************************************************************
    3483  *      VarBoolFromStr      [OLEAUT32.125]
     3468        TRACE("( %f, %p ), stub\n", dateIn, pboolOut );
     3469
     3470        if( dateIn == 0.0 )
     3471        {
     3472                *pboolOut = VARIANT_FALSE;
     3473        }
     3474        else
     3475        {
     3476                *pboolOut = VARIANT_TRUE;
     3477        }
     3478
     3479        return S_OK;
     3480}
     3481
     3482/******************************************************************************
     3483 *              VarBoolFromStr          [OLEAUT32.125]
    34843484 */
    34853485HRESULT WINAPI VarBoolFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL* pboolOut)
    34863486{
    3487     HRESULT ret = S_OK;
    3488     char* pNewString = NULL;
    3489 
    3490     TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pboolOut );
     3487        HRESULT ret = S_OK;
     3488        char* pNewString = NULL;
     3489
     3490        TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pboolOut );
    34913491
    34923492    pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    34933493
    3494     if( pNewString == NULL || strlen( pNewString ) == 0 )
    3495     {
    3496         ret = DISP_E_TYPEMISMATCH;
    3497     }
    3498 
    3499     if( ret == S_OK )
    3500     {
    3501         if( strncasecmp( pNewString, "True", strlen( pNewString ) ) == 0 )
    3502         {
    3503             *pboolOut = VARIANT_TRUE;
    3504         }
    3505         else if( strncasecmp( pNewString, "False", strlen( pNewString ) ) == 0 )
    3506         {
    3507             *pboolOut = VARIANT_FALSE;
    3508         }
    3509         else
    3510         {
    3511             /* Try converting the string to a floating point number.
    3512             */
    3513             double dValue = 0.0;
    3514             HRESULT res = VarR8FromStr( strIn, lcid, dwFlags, &dValue );
    3515             if( res != S_OK )
    3516             {
    3517                 ret = DISP_E_TYPEMISMATCH;
    3518             }
    3519             else if( dValue == 0.0 )
    3520             {
    3521                 *pboolOut = VARIANT_FALSE;
    3522             }
    3523             else
    3524             {
    3525                 *pboolOut = VARIANT_TRUE;
    3526             }
    3527         }
    3528     }
    3529 
    3530     HeapFree( GetProcessHeap(), 0, pNewString );
    3531 
    3532     return ret;
    3533 }
    3534 
    3535 /******************************************************************************
    3536  *      VarBoolFromI1       [OLEAUT32.233]
     3494        if( pNewString == NULL || strlen( pNewString ) == 0 )
     3495        {
     3496                ret = DISP_E_TYPEMISMATCH;
     3497        }
     3498
     3499        if( ret == S_OK )
     3500        {
     3501                if( strncasecmp( pNewString, "True", strlen( pNewString ) ) == 0 )
     3502                {
     3503                        *pboolOut = VARIANT_TRUE;
     3504                }
     3505                else if( strncasecmp( pNewString, "False", strlen( pNewString ) ) == 0 )
     3506                {
     3507                        *pboolOut = VARIANT_FALSE;
     3508                }
     3509                else
     3510                {
     3511                        /* Try converting the string to a floating point number.
     3512                        */
     3513                        double dValue = 0.0;
     3514                        HRESULT res = VarR8FromStr( strIn, lcid, dwFlags, &dValue );
     3515                        if( res != S_OK )
     3516                        {
     3517                                ret = DISP_E_TYPEMISMATCH;
     3518                        }
     3519                        else if( dValue == 0.0 )
     3520                        {
     3521                                *pboolOut = VARIANT_FALSE;
     3522                        }
     3523                        else
     3524                        {
     3525                                *pboolOut = VARIANT_TRUE;
     3526                        }
     3527                }
     3528        }
     3529
     3530        HeapFree( GetProcessHeap(), 0, pNewString );
     3531       
     3532        return ret;
     3533}
     3534
     3535/******************************************************************************
     3536 *              VarBoolFromI1           [OLEAUT32.233]
    35373537 */
    35383538HRESULT WINAPI VarBoolFromI1(CHAR cIn, VARIANT_BOOL* pboolOut)
    35393539{
    3540     TRACE("( %c, %p ), stub\n", cIn, pboolOut );
    3541 
    3542     if( cIn == 0 )
    3543     {
    3544         *pboolOut = VARIANT_FALSE;
    3545     }
    3546     else
    3547     {
    3548         *pboolOut = VARIANT_TRUE;
    3549     }
    3550 
    3551     return S_OK;
    3552 }
    3553 
    3554 /******************************************************************************
    3555  *      VarBoolFromUI2      [OLEAUT32.234]
     3540        TRACE("( %c, %p ), stub\n", cIn, pboolOut );
     3541
     3542        if( cIn == 0 )
     3543        {
     3544                *pboolOut = VARIANT_FALSE;
     3545        }
     3546        else
     3547        {
     3548                *pboolOut = VARIANT_TRUE;
     3549        }
     3550
     3551        return S_OK;
     3552}
     3553
     3554/******************************************************************************
     3555 *              VarBoolFromUI2          [OLEAUT32.234]
    35563556 */
    35573557HRESULT WINAPI VarBoolFromUI2(USHORT uiIn, VARIANT_BOOL* pboolOut)
    35583558{
    3559     TRACE("( %d, %p ), stub\n", uiIn, pboolOut );
    3560 
    3561     if( uiIn == 0 )
    3562     {
    3563         *pboolOut = VARIANT_FALSE;
    3564     }
    3565     else
    3566     {
    3567         *pboolOut = VARIANT_TRUE;
    3568     }
    3569 
    3570     return S_OK;
    3571 }
    3572 
    3573 /******************************************************************************
    3574  *      VarBoolFromUI4      [OLEAUT32.235]
     3559        TRACE("( %d, %p ), stub\n", uiIn, pboolOut );
     3560
     3561        if( uiIn == 0 )
     3562        {
     3563                *pboolOut = VARIANT_FALSE;
     3564        }
     3565        else
     3566        {
     3567                *pboolOut = VARIANT_TRUE;
     3568        }
     3569
     3570        return S_OK;
     3571}
     3572
     3573/******************************************************************************
     3574 *              VarBoolFromUI4          [OLEAUT32.235]
    35753575 */
    35763576HRESULT WINAPI VarBoolFromUI4(ULONG ulIn, VARIANT_BOOL* pboolOut)
    35773577{
    3578     TRACE("( %ld, %p ), stub\n", ulIn, pboolOut );
    3579 
    3580     if( ulIn == 0 )
    3581     {
    3582         *pboolOut = VARIANT_FALSE;
    3583     }
    3584     else
    3585     {
    3586         *pboolOut = VARIANT_TRUE;
    3587     }
    3588 
    3589     return S_OK;
     3578        TRACE("( %ld, %p ), stub\n", ulIn, pboolOut );
     3579
     3580        if( ulIn == 0 )
     3581        {
     3582                *pboolOut = VARIANT_FALSE;
     3583        }
     3584        else
     3585        {
     3586                *pboolOut = VARIANT_TRUE;
     3587        }
     3588
     3589        return S_OK;
    35903590}
    35913591
     
    35973597      if (cyIn.s.Hi || cyIn.s.Lo) *pboolOut = -1;
    35983598      else *pboolOut = 0;
    3599 
     3599     
    36003600      return S_OK;
    36013601}
    36023602
    36033603/******************************************************************************
    3604  *      VarI1FromUI1        [OLEAUT32.244]
     3604 *              VarI1FromUI1            [OLEAUT32.244]
    36053605 */
    36063606HRESULT WINAPI VarI1FromUI1(BYTE bIn, CHAR* pcOut)
    36073607{
    3608     TRACE("( %d, %p ), stub\n", bIn, pcOut );
    3609 
    3610     /* Check range of value.
    3611     */
    3612     if( bIn > CHAR_MAX )
    3613     {
    3614         return DISP_E_OVERFLOW;
    3615     }
    3616 
    3617     *pcOut = (CHAR) bIn;
    3618 
    3619     return S_OK;
    3620 }
    3621 
    3622 /******************************************************************************
    3623  *      VarI1FromI2     [OLEAUT32.245]
     3608        TRACE("( %d, %p ), stub\n", bIn, pcOut );
     3609
     3610        /* Check range of value.
     3611        */
     3612        if( bIn > CHAR_MAX )
     3613        {
     3614                return DISP_E_OVERFLOW;
     3615        }
     3616
     3617        *pcOut = (CHAR) bIn;
     3618
     3619        return S_OK;
     3620}
     3621
     3622/******************************************************************************
     3623 *              VarI1FromI2             [OLEAUT32.245]
    36243624 */
    36253625HRESULT WINAPI VarI1FromI2(short uiIn, CHAR* pcOut)
    36263626{
    3627     TRACE("( %d, %p ), stub\n", uiIn, pcOut );
    3628 
    3629     if( uiIn > CHAR_MAX )
    3630     {
    3631         return DISP_E_OVERFLOW;
    3632     }
    3633 
    3634     *pcOut = (CHAR) uiIn;
    3635 
    3636     return S_OK;
    3637 }
    3638 
    3639 /******************************************************************************
    3640  *      VarI1FromI4     [OLEAUT32.246]
     3627        TRACE("( %d, %p ), stub\n", uiIn, pcOut );
     3628
     3629        if( uiIn > CHAR_MAX )
     3630        {
     3631                return DISP_E_OVERFLOW;
     3632        }
     3633
     3634        *pcOut = (CHAR) uiIn;
     3635
     3636        return S_OK;
     3637}
     3638
     3639/******************************************************************************
     3640 *              VarI1FromI4             [OLEAUT32.246]
    36413641 */
    36423642HRESULT WINAPI VarI1FromI4(LONG lIn, CHAR* pcOut)
    36433643{
    3644     TRACE("( %ld, %p ), stub\n", lIn, pcOut );
    3645 
    3646     if( lIn < CHAR_MIN || lIn > CHAR_MAX )
    3647     {
    3648         return DISP_E_OVERFLOW;
    3649     }
    3650 
    3651     *pcOut = (CHAR) lIn;
    3652 
    3653     return S_OK;
    3654 }
    3655 
    3656 /******************************************************************************
    3657  *      VarI1FromR4     [OLEAUT32.247]
     3644        TRACE("( %ld, %p ), stub\n", lIn, pcOut );
     3645
     3646        if( lIn < CHAR_MIN || lIn > CHAR_MAX )
     3647        {
     3648                return DISP_E_OVERFLOW;
     3649        }
     3650
     3651        *pcOut = (CHAR) lIn;
     3652
     3653        return S_OK;
     3654}
     3655
     3656/******************************************************************************
     3657 *              VarI1FromR4             [OLEAUT32.247]
    36583658 */
    36593659HRESULT WINAPI VarI1FromR4(FLOAT fltIn, CHAR* pcOut)
    36603660{
    3661     TRACE("( %f, %p ), stub\n", fltIn, pcOut );
     3661        TRACE("( %f, %p ), stub\n", fltIn, pcOut );
    36623662
    36633663    fltIn = round( fltIn );
    3664     if( fltIn < CHAR_MIN || fltIn > CHAR_MAX )
    3665     {
    3666         return DISP_E_OVERFLOW;
    3667     }
    3668 
    3669     *pcOut = (CHAR) fltIn;
    3670 
    3671     return S_OK;
    3672 }
    3673 
    3674 /******************************************************************************
    3675  *      VarI1FromR8     [OLEAUT32.248]
     3664        if( fltIn < CHAR_MIN || fltIn > CHAR_MAX )
     3665        {
     3666                return DISP_E_OVERFLOW;
     3667        }
     3668
     3669        *pcOut = (CHAR) fltIn;
     3670
     3671        return S_OK;
     3672}
     3673
     3674/******************************************************************************
     3675 *              VarI1FromR8             [OLEAUT32.248]
    36763676 */
    36773677HRESULT WINAPI VarI1FromR8(double dblIn, CHAR* pcOut)
    36783678{
    3679     TRACE("( %f, %p ), stub\n", dblIn, pcOut );
     3679        TRACE("( %f, %p ), stub\n", dblIn, pcOut );
    36803680
    36813681    dblIn = round( dblIn );
    36823682    if( dblIn < CHAR_MIN || dblIn > CHAR_MAX )
    3683     {
    3684         return DISP_E_OVERFLOW;
    3685     }
    3686 
    3687     *pcOut = (CHAR) dblIn;
    3688 
    3689     return S_OK;
    3690 }
    3691 
    3692 /******************************************************************************
    3693  *      VarI1FromDate       [OLEAUT32.249]
     3683        {
     3684                return DISP_E_OVERFLOW;
     3685        }
     3686
     3687        *pcOut = (CHAR) dblIn;
     3688
     3689        return S_OK;
     3690}
     3691
     3692/******************************************************************************
     3693 *              VarI1FromDate           [OLEAUT32.249]
    36943694 */
    36953695HRESULT WINAPI VarI1FromDate(DATE dateIn, CHAR* pcOut)
    36963696{
    3697     TRACE("( %f, %p ), stub\n", dateIn, pcOut );
     3697        TRACE("( %f, %p ), stub\n", dateIn, pcOut );
    36983698
    36993699    dateIn = round( dateIn );
    3700     if( dateIn < CHAR_MIN || dateIn > CHAR_MAX )
    3701     {
    3702         return DISP_E_OVERFLOW;
    3703     }
    3704 
    3705     *pcOut = (CHAR) dateIn;
    3706 
    3707     return S_OK;
    3708 }
    3709 
    3710 /******************************************************************************
    3711  *      VarI1FromStr        [OLEAUT32.251]
     3700        if( dateIn < CHAR_MIN || dateIn > CHAR_MAX )
     3701        {
     3702                return DISP_E_OVERFLOW;
     3703        }
     3704
     3705        *pcOut = (CHAR) dateIn;
     3706
     3707        return S_OK;
     3708}
     3709
     3710/******************************************************************************
     3711 *              VarI1FromStr            [OLEAUT32.251]
    37123712 */
    37133713HRESULT WINAPI VarI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, CHAR* pcOut)
    37143714{
    3715     double dValue = 0.0;
    3716     LPSTR pNewString = NULL;
    3717 
    3718     TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pcOut );
    3719 
    3720     /* Check if we have a valid argument
    3721     */
    3722     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    3723     RemoveCharacterFromString( pNewString, "," );
    3724     if( IsValidRealString( pNewString ) == FALSE )
    3725     {
    3726         return DISP_E_TYPEMISMATCH;
    3727     }
    3728 
    3729     /* Convert the valid string to a floating point number.
    3730     */
    3731     dValue = atof( pNewString );
    3732 
    3733     /* We don't need the string anymore so free it.
    3734     */
    3735     HeapFree( GetProcessHeap(), 0, pNewString );
    3736 
    3737     /* Check range of value.
     3715        double dValue = 0.0;
     3716        LPSTR pNewString = NULL;
     3717
     3718        TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pcOut );
     3719
     3720        /* Check if we have a valid argument
     3721        */
     3722        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     3723        RemoveCharacterFromString( pNewString, "," );
     3724        if( IsValidRealString( pNewString ) == FALSE )
     3725        {
     3726                return DISP_E_TYPEMISMATCH;
     3727        }
     3728
     3729        /* Convert the valid string to a floating point number.
     3730        */
     3731        dValue = atof( pNewString );
     3732 
     3733        /* We don't need the string anymore so free it.
     3734        */
     3735        HeapFree( GetProcessHeap(), 0, pNewString );
     3736
     3737        /* Check range of value.
    37383738     */
    37393739    dValue = round( dValue );
    3740     if( dValue < CHAR_MIN || dValue > CHAR_MAX )
    3741     {
    3742         return DISP_E_OVERFLOW;
    3743     }
    3744 
    3745     *pcOut = (CHAR) dValue;
    3746 
    3747     return S_OK;
    3748 }
    3749 
    3750 /******************************************************************************
    3751  *      VarI1FromBool       [OLEAUT32.253]
     3740        if( dValue < CHAR_MIN || dValue > CHAR_MAX )
     3741        {
     3742                return DISP_E_OVERFLOW;
     3743        }
     3744
     3745        *pcOut = (CHAR) dValue;
     3746
     3747        return S_OK;
     3748}
     3749
     3750/******************************************************************************
     3751 *              VarI1FromBool           [OLEAUT32.253]
    37523752 */
    37533753HRESULT WINAPI VarI1FromBool(VARIANT_BOOL boolIn, CHAR* pcOut)
    37543754{
    3755     TRACE("( %d, %p ), stub\n", boolIn, pcOut );
    3756 
    3757     *pcOut = (CHAR) boolIn;
    3758 
    3759     return S_OK;
    3760 }
    3761 
    3762 /******************************************************************************
    3763  *      VarI1FromUI2        [OLEAUT32.254]
     3755        TRACE("( %d, %p ), stub\n", boolIn, pcOut );
     3756
     3757        *pcOut = (CHAR) boolIn;
     3758
     3759        return S_OK;
     3760}
     3761
     3762/******************************************************************************
     3763 *              VarI1FromUI2            [OLEAUT32.254]
    37643764 */
    37653765HRESULT WINAPI VarI1FromUI2(USHORT uiIn, CHAR* pcOut)
    37663766{
    3767     TRACE("( %d, %p ), stub\n", uiIn, pcOut );
    3768 
    3769     if( uiIn > CHAR_MAX )
    3770     {
    3771         return DISP_E_OVERFLOW;
    3772     }
    3773 
    3774     *pcOut = (CHAR) uiIn;
    3775 
    3776     return S_OK;
    3777 }
    3778 
    3779 /******************************************************************************
    3780  *      VarI1FromUI4        [OLEAUT32.255]
     3767        TRACE("( %d, %p ), stub\n", uiIn, pcOut );
     3768
     3769        if( uiIn > CHAR_MAX )
     3770        {
     3771                return DISP_E_OVERFLOW;
     3772        }
     3773
     3774        *pcOut = (CHAR) uiIn;
     3775
     3776        return S_OK;
     3777}
     3778
     3779/******************************************************************************
     3780 *              VarI1FromUI4            [OLEAUT32.255]
    37813781 */
    37823782HRESULT WINAPI VarI1FromUI4(ULONG ulIn, CHAR* pcOut)
    37833783{
    3784     TRACE("( %ld, %p ), stub\n", ulIn, pcOut );
    3785 
    3786     if( ulIn > CHAR_MAX )
    3787     {
    3788         return DISP_E_OVERFLOW;
    3789     }
    3790 
    3791     *pcOut = (CHAR) ulIn;
    3792 
    3793     return S_OK;
     3784        TRACE("( %ld, %p ), stub\n", ulIn, pcOut );
     3785
     3786        if( ulIn > CHAR_MAX )
     3787        {
     3788                return DISP_E_OVERFLOW;
     3789        }
     3790
     3791        *pcOut = (CHAR) ulIn;
     3792
     3793        return S_OK;
    37943794}
    37953795
     
    38003800HRESULT WINAPI VarI1FromCy(CY cyIn, CHAR* pcOut) {
    38013801   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    3802 
     3802   
    38033803   if (t > CHAR_MAX || t < CHAR_MIN) return DISP_E_OVERFLOW;
    3804 
     3804   
    38053805   *pcOut = (CHAR)t;
    38063806   return S_OK;
     
    38083808
    38093809/******************************************************************************
    3810  *      VarUI2FromUI1       [OLEAUT32.257]
     3810 *              VarUI2FromUI1           [OLEAUT32.257]
    38113811 */
    38123812HRESULT WINAPI VarUI2FromUI1(BYTE bIn, USHORT* puiOut)
    38133813{
    3814     TRACE("( %d, %p ), stub\n", bIn, puiOut );
    3815 
    3816     *puiOut = (USHORT) bIn;
    3817 
    3818     return S_OK;
    3819 }
    3820 
    3821 /******************************************************************************
    3822  *      VarUI2FromI2        [OLEAUT32.258]
     3814        TRACE("( %d, %p ), stub\n", bIn, puiOut );
     3815
     3816        *puiOut = (USHORT) bIn;
     3817
     3818        return S_OK;
     3819}
     3820
     3821/******************************************************************************
     3822 *              VarUI2FromI2            [OLEAUT32.258]
    38233823 */
    38243824HRESULT WINAPI VarUI2FromI2(short uiIn, USHORT* puiOut)
    38253825{
    3826     TRACE("( %d, %p ), stub\n", uiIn, puiOut );
    3827 
    3828     if( uiIn < UI2_MIN )
    3829     {
    3830         return DISP_E_OVERFLOW;
    3831     }
    3832 
    3833     *puiOut = (USHORT) uiIn;
    3834 
    3835     return S_OK;
    3836 }
    3837 
    3838 /******************************************************************************
    3839  *      VarUI2FromI4        [OLEAUT32.259]
     3826        TRACE("( %d, %p ), stub\n", uiIn, puiOut );
     3827
     3828        if( uiIn < UI2_MIN )
     3829        {
     3830                return DISP_E_OVERFLOW;
     3831        }
     3832
     3833        *puiOut = (USHORT) uiIn;
     3834
     3835        return S_OK;
     3836}
     3837
     3838/******************************************************************************
     3839 *              VarUI2FromI4            [OLEAUT32.259]
    38403840 */
    38413841HRESULT WINAPI VarUI2FromI4(LONG lIn, USHORT* puiOut)
    38423842{
    3843     TRACE("( %ld, %p ), stub\n", lIn, puiOut );
    3844 
    3845     if( lIn < UI2_MIN || lIn > UI2_MAX )
    3846     {
    3847         return DISP_E_OVERFLOW;
    3848     }
    3849 
    3850     *puiOut = (USHORT) lIn;
    3851 
    3852     return S_OK;
    3853 }
    3854 
    3855 /******************************************************************************
    3856  *      VarUI2FromR4        [OLEAUT32.260]
     3843        TRACE("( %ld, %p ), stub\n", lIn, puiOut );
     3844
     3845        if( lIn < UI2_MIN || lIn > UI2_MAX )
     3846        {
     3847                return DISP_E_OVERFLOW;
     3848        }
     3849
     3850        *puiOut = (USHORT) lIn;
     3851
     3852        return S_OK;
     3853}
     3854
     3855/******************************************************************************
     3856 *              VarUI2FromR4            [OLEAUT32.260]
    38573857 */
    38583858HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT* puiOut)
    38593859{
    3860     TRACE("( %f, %p ), stub\n", fltIn, puiOut );
     3860        TRACE("( %f, %p ), stub\n", fltIn, puiOut );
    38613861
    38623862    fltIn = round( fltIn );
    3863     if( fltIn < UI2_MIN || fltIn > UI2_MAX )
    3864     {
    3865         return DISP_E_OVERFLOW;
    3866     }
    3867 
    3868     *puiOut = (USHORT) fltIn;
    3869 
    3870     return S_OK;
    3871 }
    3872 
    3873 /******************************************************************************
    3874  *      VarUI2FromR8        [OLEAUT32.261]
     3863        if( fltIn < UI2_MIN || fltIn > UI2_MAX )
     3864        {
     3865                return DISP_E_OVERFLOW;
     3866        }
     3867
     3868        *puiOut = (USHORT) fltIn;
     3869
     3870        return S_OK;
     3871}
     3872
     3873/******************************************************************************
     3874 *              VarUI2FromR8            [OLEAUT32.261]
    38753875 */
    38763876HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT* puiOut)
    38773877{
    3878     TRACE("( %f, %p ), stub\n", dblIn, puiOut );
     3878        TRACE("( %f, %p ), stub\n", dblIn, puiOut );
    38793879
    38803880    dblIn = round( dblIn );
    38813881    if( dblIn < UI2_MIN || dblIn > UI2_MAX )
    3882     {
    3883         return DISP_E_OVERFLOW;
    3884     }
    3885 
    3886     *puiOut = (USHORT) dblIn;
    3887 
    3888     return S_OK;
    3889 }
    3890 
    3891 /******************************************************************************
    3892  *      VarUI2FromDate      [OLEAUT32.262]
     3882        {
     3883                return DISP_E_OVERFLOW;
     3884        }
     3885
     3886        *puiOut = (USHORT) dblIn;
     3887
     3888        return S_OK;
     3889}
     3890
     3891/******************************************************************************
     3892 *              VarUI2FromDate          [OLEAUT32.262]
    38933893 */
    38943894HRESULT WINAPI VarUI2FromDate(DATE dateIn, USHORT* puiOut)
    38953895{
    3896     TRACE("( %f, %p ), stub\n", dateIn, puiOut );
     3896        TRACE("( %f, %p ), stub\n", dateIn, puiOut );
    38973897
    38983898    dateIn = round( dateIn );
    3899     if( dateIn < UI2_MIN || dateIn > UI2_MAX )
    3900     {
    3901         return DISP_E_OVERFLOW;
    3902     }
    3903 
    3904     *puiOut = (USHORT) dateIn;
    3905 
    3906     return S_OK;
    3907 }
    3908 
    3909 /******************************************************************************
    3910  *      VarUI2FromStr       [OLEAUT32.264]
     3899        if( dateIn < UI2_MIN || dateIn > UI2_MAX )
     3900        {
     3901                return DISP_E_OVERFLOW;
     3902        }
     3903
     3904        *puiOut = (USHORT) dateIn;
     3905
     3906        return S_OK;
     3907}
     3908
     3909/******************************************************************************
     3910 *              VarUI2FromStr           [OLEAUT32.264]
    39113911 */
    39123912HRESULT WINAPI VarUI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, USHORT* puiOut)
    39133913{
    3914     double dValue = 0.0;
    3915     LPSTR pNewString = NULL;
    3916 
    3917     TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, puiOut );
    3918 
    3919     /* Check if we have a valid argument
    3920     */
    3921     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    3922     RemoveCharacterFromString( pNewString, "," );
    3923     if( IsValidRealString( pNewString ) == FALSE )
    3924     {
    3925         return DISP_E_TYPEMISMATCH;
    3926     }
    3927 
    3928     /* Convert the valid string to a floating point number.
    3929     */
    3930     dValue = atof( pNewString );
    3931 
    3932     /* We don't need the string anymore so free it.
    3933     */
    3934     HeapFree( GetProcessHeap(), 0, pNewString );
    3935 
    3936     /* Check range of value.
     3914        double dValue = 0.0;
     3915        LPSTR pNewString = NULL;
     3916
     3917        TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, puiOut );
     3918
     3919        /* Check if we have a valid argument
     3920        */
     3921        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     3922        RemoveCharacterFromString( pNewString, "," );
     3923        if( IsValidRealString( pNewString ) == FALSE )
     3924        {
     3925                return DISP_E_TYPEMISMATCH;
     3926        }
     3927
     3928        /* Convert the valid string to a floating point number.
     3929        */
     3930        dValue = atof( pNewString );
     3931 
     3932        /* We don't need the string anymore so free it.
     3933        */
     3934        HeapFree( GetProcessHeap(), 0, pNewString );
     3935
     3936        /* Check range of value.
    39373937     */
    39383938    dValue = round( dValue );
    3939     if( dValue < UI2_MIN || dValue > UI2_MAX )
    3940     {
    3941         return DISP_E_OVERFLOW;
    3942     }
    3943 
    3944     *puiOut = (USHORT) dValue;
    3945 
    3946     return S_OK;
    3947 }
    3948 
    3949 /******************************************************************************
    3950  *      VarUI2FromBool      [OLEAUT32.266]
     3939        if( dValue < UI2_MIN || dValue > UI2_MAX )
     3940        {
     3941                return DISP_E_OVERFLOW;
     3942        }
     3943
     3944        *puiOut = (USHORT) dValue;
     3945
     3946        return S_OK;
     3947}
     3948
     3949/******************************************************************************
     3950 *              VarUI2FromBool          [OLEAUT32.266]
    39513951 */
    39523952HRESULT WINAPI VarUI2FromBool(VARIANT_BOOL boolIn, USHORT* puiOut)
    39533953{
    3954     TRACE("( %d, %p ), stub\n", boolIn, puiOut );
    3955 
    3956     *puiOut = (USHORT) boolIn;
    3957 
    3958     return S_OK;
    3959 }
    3960 
    3961 /******************************************************************************
    3962  *      VarUI2FromI1        [OLEAUT32.267]
     3954        TRACE("( %d, %p ), stub\n", boolIn, puiOut );
     3955
     3956        *puiOut = (USHORT) boolIn;
     3957
     3958        return S_OK;
     3959}
     3960
     3961/******************************************************************************
     3962 *              VarUI2FromI1            [OLEAUT32.267]
    39633963 */
    39643964HRESULT WINAPI VarUI2FromI1(CHAR cIn, USHORT* puiOut)
    39653965{
    3966     TRACE("( %c, %p ), stub\n", cIn, puiOut );
    3967 
    3968     *puiOut = (USHORT) cIn;
    3969 
    3970     return S_OK;
    3971 }
    3972 
    3973 /******************************************************************************
    3974  *      VarUI2FromUI4       [OLEAUT32.268]
     3966        TRACE("( %c, %p ), stub\n", cIn, puiOut );
     3967
     3968        *puiOut = (USHORT) cIn;
     3969
     3970        return S_OK;
     3971}
     3972
     3973/******************************************************************************
     3974 *              VarUI2FromUI4           [OLEAUT32.268]
    39753975 */
    39763976HRESULT WINAPI VarUI2FromUI4(ULONG ulIn, USHORT* puiOut)
    39773977{
    3978     TRACE("( %ld, %p ), stub\n", ulIn, puiOut );
    3979 
    3980     if( ulIn < UI2_MIN || ulIn > UI2_MAX )
    3981     {
    3982         return DISP_E_OVERFLOW;
    3983     }
    3984 
    3985     *puiOut = (USHORT) ulIn;
    3986 
    3987     return S_OK;
    3988 }
    3989 
    3990 /******************************************************************************
    3991  *      VarUI4FromStr       [OLEAUT32.277]
     3978        TRACE("( %ld, %p ), stub\n", ulIn, puiOut );
     3979
     3980        if( ulIn < UI2_MIN || ulIn > UI2_MAX )
     3981        {
     3982                return DISP_E_OVERFLOW;
     3983        }
     3984
     3985        *puiOut = (USHORT) ulIn;
     3986
     3987        return S_OK;
     3988}
     3989
     3990/******************************************************************************
     3991 *              VarUI4FromStr           [OLEAUT32.277]
    39923992 */
    39933993HRESULT WINAPI VarUI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, ULONG* pulOut)
    39943994{
    3995     double dValue = 0.0;
    3996     LPSTR pNewString = NULL;
    3997 
    3998     TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pulOut );
    3999 
    4000     /* Check if we have a valid argument
    4001     */
    4002     pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    4003     RemoveCharacterFromString( pNewString, "," );
    4004     if( IsValidRealString( pNewString ) == FALSE )
    4005     {
    4006         return DISP_E_TYPEMISMATCH;
    4007     }
    4008 
    4009     /* Convert the valid string to a floating point number.
    4010     */
    4011     dValue = atof( pNewString );
    4012 
    4013     /* We don't need the string anymore so free it.
    4014     */
    4015     HeapFree( GetProcessHeap(), 0, pNewString );
    4016 
    4017     /* Check range of value.
     3995        double dValue = 0.0;
     3996        LPSTR pNewString = NULL;
     3997
     3998        TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pulOut );
     3999
     4000        /* Check if we have a valid argument
     4001        */
     4002        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     4003        RemoveCharacterFromString( pNewString, "," );
     4004        if( IsValidRealString( pNewString ) == FALSE )
     4005        {
     4006                return DISP_E_TYPEMISMATCH;
     4007        }
     4008
     4009        /* Convert the valid string to a floating point number.
     4010        */
     4011        dValue = atof( pNewString );
     4012 
     4013        /* We don't need the string anymore so free it.
     4014        */
     4015        HeapFree( GetProcessHeap(), 0, pNewString );
     4016
     4017        /* Check range of value.
    40184018     */
    40194019    dValue = round( dValue );
    4020     if( dValue < UI4_MIN || dValue > UI4_MAX )
    4021     {
    4022         return DISP_E_OVERFLOW;
    4023     }
    4024 
    4025     *pulOut = (ULONG) dValue;
    4026 
    4027     return S_OK;
     4020        if( dValue < UI4_MIN || dValue > UI4_MAX )
     4021        {
     4022                return DISP_E_OVERFLOW;
     4023        }
     4024
     4025        *pulOut = (ULONG) dValue;
     4026
     4027        return S_OK;
    40284028}
    40294029
     
    40344034HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) {
    40354035   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    4036 
     4036   
    40374037   if (t > UI2_MAX || t < UI2_MIN) return DISP_E_OVERFLOW;
    4038 
     4038     
    40394039   *pusOut = (USHORT)t;
    4040 
     4040   
    40414041   return S_OK;
    40424042}
    40434043
    40444044/******************************************************************************
    4045  *      VarUI4FromUI1       [OLEAUT32.270]
     4045 *              VarUI4FromUI1           [OLEAUT32.270]
    40464046 */
    40474047HRESULT WINAPI VarUI4FromUI1(BYTE bIn, ULONG* pulOut)
    40484048{
    4049     TRACE("( %d, %p ), stub\n", bIn, pulOut );
    4050 
    4051     *pulOut = (USHORT) bIn;
    4052 
    4053     return S_OK;
    4054 }
    4055 
    4056 /******************************************************************************
    4057  *      VarUI4FromI2        [OLEAUT32.271]
     4049        TRACE("( %d, %p ), stub\n", bIn, pulOut );
     4050
     4051        *pulOut = (USHORT) bIn;
     4052
     4053        return S_OK;
     4054}
     4055
     4056/******************************************************************************
     4057 *              VarUI4FromI2            [OLEAUT32.271]
    40584058 */
    40594059HRESULT WINAPI VarUI4FromI2(short uiIn, ULONG* pulOut)
    40604060{
    4061     TRACE("( %d, %p ), stub\n", uiIn, pulOut );
    4062 
    4063     if( uiIn < UI4_MIN )
    4064     {
    4065         return DISP_E_OVERFLOW;
    4066     }
    4067 
    4068     *pulOut = (ULONG) uiIn;
    4069 
    4070     return S_OK;
    4071 }
    4072 
    4073 /******************************************************************************
    4074  *      VarUI4FromI4        [OLEAUT32.272]
     4061        TRACE("( %d, %p ), stub\n", uiIn, pulOut );
     4062
     4063        if( uiIn < UI4_MIN )
     4064        {
     4065                return DISP_E_OVERFLOW;
     4066        }
     4067
     4068        *pulOut = (ULONG) uiIn;
     4069
     4070        return S_OK;
     4071}
     4072
     4073/******************************************************************************
     4074 *              VarUI4FromI4            [OLEAUT32.272]
    40754075 */
    40764076HRESULT WINAPI VarUI4FromI4(LONG lIn, ULONG* pulOut)
    40774077{
    4078     TRACE("( %ld, %p ), stub\n", lIn, pulOut );
    4079 
    4080     if( lIn < UI4_MIN )
    4081     {
    4082         return DISP_E_OVERFLOW;
    4083     }
    4084 
    4085     *pulOut = (ULONG) lIn;
    4086 
    4087     return S_OK;
    4088 }
    4089 
    4090 /******************************************************************************
    4091  *      VarUI4FromR4        [OLEAUT32.273]
     4078        TRACE("( %ld, %p ), stub\n", lIn, pulOut );
     4079
     4080        if( lIn < UI4_MIN )
     4081        {
     4082                return DISP_E_OVERFLOW;
     4083        }
     4084
     4085        *pulOut = (ULONG) lIn;
     4086
     4087        return S_OK;
     4088}
     4089
     4090/******************************************************************************
     4091 *              VarUI4FromR4            [OLEAUT32.273]
    40924092 */
    40934093HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG* pulOut)
     
    40954095    fltIn = round( fltIn );
    40964096    if( fltIn < UI4_MIN || fltIn > UI4_MAX )
    4097     {
    4098         return DISP_E_OVERFLOW;
     4097        {
     4098                return DISP_E_OVERFLOW;
     4099        }
     4100
     4101        *pulOut = (ULONG) fltIn;
     4102
     4103        return S_OK;
     4104}
     4105
     4106/******************************************************************************
     4107 *              VarUI4FromR8            [OLEAUT32.274]
     4108 */
     4109HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG* pulOut)
     4110{
     4111        TRACE("( %f, %p ), stub\n", dblIn, pulOut );
     4112
     4113    dblIn = round( dblIn );
     4114        if( dblIn < UI4_MIN || dblIn > UI4_MAX )
     4115        {
     4116                return DISP_E_OVERFLOW;
    40994117    }
    41004118
    4101     *pulOut = (ULONG) fltIn;
    4102 
    4103     return S_OK;
    4104 }
    4105 
    4106 /******************************************************************************
    4107  *      VarUI4FromR8        [OLEAUT32.274]
    4108  */
    4109 HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG* pulOut)
    4110 {
    4111     TRACE("( %f, %p ), stub\n", dblIn, pulOut );
    4112 
    4113     dblIn = round( dblIn );
    4114     if( dblIn < UI4_MIN || dblIn > UI4_MAX )
    4115     {
    4116         return DISP_E_OVERFLOW;
    4117     }
    4118 
    4119     *pulOut = (ULONG) dblIn;
    4120 
    4121     return S_OK;
    4122 }
    4123 
    4124 /******************************************************************************
    4125  *      VarUI4FromDate      [OLEAUT32.275]
     4119        *pulOut = (ULONG) dblIn;
     4120
     4121        return S_OK;
     4122}
     4123
     4124/******************************************************************************
     4125 *              VarUI4FromDate          [OLEAUT32.275]
    41264126 */
    41274127HRESULT WINAPI VarUI4FromDate(DATE dateIn, ULONG* pulOut)
    41284128{
    4129     TRACE("( %f, %p ), stub\n", dateIn, pulOut );
     4129        TRACE("( %f, %p ), stub\n", dateIn, pulOut );
    41304130
    41314131    dateIn = round( dateIn );
    41324132    if( dateIn < UI4_MIN || dateIn > UI4_MAX )
    4133     {
    4134         return DISP_E_OVERFLOW;
    4135     }
    4136 
    4137     *pulOut = (ULONG) dateIn;
    4138 
    4139     return S_OK;
    4140 }
    4141 
    4142 /******************************************************************************
    4143  *      VarUI4FromBool      [OLEAUT32.279]
     4133        {
     4134                return DISP_E_OVERFLOW;
     4135        }
     4136
     4137        *pulOut = (ULONG) dateIn;
     4138
     4139        return S_OK;
     4140}
     4141
     4142/******************************************************************************
     4143 *              VarUI4FromBool          [OLEAUT32.279]
    41444144 */
    41454145HRESULT WINAPI VarUI4FromBool(VARIANT_BOOL boolIn, ULONG* pulOut)
    41464146{
    4147     TRACE("( %d, %p ), stub\n", boolIn, pulOut );
    4148 
    4149     *pulOut = (ULONG) boolIn;
    4150 
    4151     return S_OK;
    4152 }
    4153 
    4154 /******************************************************************************
    4155  *      VarUI4FromI1        [OLEAUT32.280]
     4147        TRACE("( %d, %p ), stub\n", boolIn, pulOut );
     4148
     4149        *pulOut = (ULONG) boolIn;
     4150
     4151        return S_OK;
     4152}
     4153
     4154/******************************************************************************
     4155 *              VarUI4FromI1            [OLEAUT32.280]
    41564156 */
    41574157HRESULT WINAPI VarUI4FromI1(CHAR cIn, ULONG* pulOut)
    41584158{
    4159     TRACE("( %c, %p ), stub\n", cIn, pulOut );
    4160 
    4161     *pulOut = (ULONG) cIn;
    4162 
    4163     return S_OK;
    4164 }
    4165 
    4166 /******************************************************************************
    4167  *      VarUI4FromUI2       [OLEAUT32.281]
     4159        TRACE("( %c, %p ), stub\n", cIn, pulOut );
     4160
     4161        *pulOut = (ULONG) cIn;
     4162
     4163        return S_OK;
     4164}
     4165
     4166/******************************************************************************
     4167 *              VarUI4FromUI2           [OLEAUT32.281]
    41684168 */
    41694169HRESULT WINAPI VarUI4FromUI2(USHORT uiIn, ULONG* pulOut)
    41704170{
    4171     TRACE("( %d, %p ), stub\n", uiIn, pulOut );
    4172 
    4173     *pulOut = (ULONG) uiIn;
    4174 
    4175     return S_OK;
     4171        TRACE("( %d, %p ), stub\n", uiIn, pulOut );
     4172
     4173        *pulOut = (ULONG) uiIn;
     4174
     4175        return S_OK;
    41764176}
    41774177
     
    41824182HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG* pulOut) {
    41834183   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    4184 
     4184   
    41854185   if (t > UI4_MAX || t < UI4_MIN) return DISP_E_OVERFLOW;
    41864186
     
    41974197   pcyOut->s.Hi = 0;
    41984198   pcyOut->s.Lo = ((ULONG)bIn) * 10000;
    4199 
     4199   
    42004200   return S_OK;
    42014201}
     
    42094209   else pcyOut->s.Hi = 0;
    42104210   pcyOut->s.Lo = ((ULONG)sIn) * 10000;
    4211 
     4211   
    42124212   return S_OK;
    42134213}
     
    42224222      pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    42234223      if (lIn < 0) pcyOut->s.Hi--;
    4224 
     4224   
    42254225      return S_OK;
    42264226}
     
    42354235   pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    42364236   if (fltIn < 0) pcyOut->s.Hi--;
    4237 
     4237   
    42384238   return S_OK;
    42394239}
     
    42694269 */
    42704270HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pcyOut) {
    4271                 /* FIXME */
    4272         return E_NOTIMPL;
    4273 }
    4274 
    4275 
     4271                                /* FIXME */
     4272                return E_NOTIMPL;
     4273}
     4274
     4275 
    42764276/**********************************************************************
    42774277 *              VarCyFromBool [OLEAUT32.106]
     
    42824282   else pcyOut->s.Hi = 0;
    42834283   pcyOut->s.Lo = (ULONG)boolIn * (ULONG)10000;
    4284 
     4284   
    42854285   return S_OK;
    42864286}
     
    42944294   else pcyOut->s.Hi = 0;
    42954295   pcyOut->s.Lo = (ULONG)cIn * (ULONG)10000;
    4296 
     4296   
    42974297   return S_OK;
    42984298}
     
    43054305   pcyOut->s.Hi = 0;
    43064306   pcyOut->s.Lo = (ULONG)usIn * (ULONG)10000;
    4307 
     4307   
    43084308   return S_OK;
    43094309}
     
    43174317   pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
    43184318   pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    4319 
     4319     
    43204320   return S_OK;
    43214321}
     
    43334333
    43344334    TRACE("( 0x%x, 0x%x, 0x%p ), stub\n", wDosDate, wDosTime, pvtime );
    4335 
     4335   
    43364336    t.tm_sec = (wDosTime & 0x001f) * 2;
    43374337    t.tm_min = (wDosTime & 0x07e0) >> 5;
    43384338    t.tm_hour = (wDosTime & 0xf800) >> 11;
    4339 
     4339   
    43404340    t.tm_mday = (wDosDate & 0x001f);
    43414341    t.tm_mon = (wDosDate & 0x01e0) >> 5;
     
    43634363    cDig = 0;
    43644364    for (i=0; strIn[i] ;i++) {
    4365     if ((strIn[i]>='0') && (strIn[i]<='9')) {
    4366         if (pnumprs->cDig > cDig) {
    4367         *(rgbDig++)=strIn[i]-'0';
    4368         cDig++;
    4369         lastent = i;
    4370         }
     4365        if ((strIn[i]>='0') && (strIn[i]<='9')) {
     4366            if (pnumprs->cDig > cDig) {
     4367                *(rgbDig++)=strIn[i]-'0';
     4368                cDig++;
     4369                lastent = i;
     4370            }
     4371        }
    43714372    }
    4372     }
    4373     pnumprs->cDig   = cDig;
     4373    pnumprs->cDig       = cDig;
    43744374
    43754375    /* FIXME: Just patching some values in */
    4376     pnumprs->nPwr10 = 0;
    4377     pnumprs->nBaseShift = 0;
    4378     pnumprs->cchUsed    = lastent;
    4379     pnumprs->dwOutFlags = NUMPRS_DECIMAL;
     4376    pnumprs->nPwr10     = 0;
     4377    pnumprs->nBaseShift = 0;
     4378    pnumprs->cchUsed    = lastent;
     4379    pnumprs->dwOutFlags = NUMPRS_DECIMAL;
    43804380    return S_OK;
    43814381}
     
    43944394    xint = 0;
    43954395    for (i=0;i<pnumprs->cDig;i++)
    4396     xint = xint*10 + rgbDig[i];
     4396        xint = xint*10 + rgbDig[i];
    43974397
    43984398    VariantInit(pvar);
    43994399    if (dwVtBits & VTBIT_I4) {
    4400     V_VT(pvar) = VT_I4;
    4401     V_UNION(pvar,intVal) = xint;
    4402     return S_OK;
     4400        V_VT(pvar) = VT_I4;
     4401        V_UNION(pvar,intVal) = xint;
     4402        return S_OK;
    44034403    }
    44044404    if (dwVtBits & VTBIT_R8) {
    4405     V_VT(pvar) = VT_R8;
    4406     V_UNION(pvar,dblVal) = xint;
    4407     return S_OK;
     4405        V_VT(pvar) = VT_R8;
     4406        V_UNION(pvar,dblVal) = xint;
     4407        return S_OK;
    44084408    } else {
    4409     FIXME("vtbitmask is unsupported %lx\n",dwVtBits);
    4410     return E_FAIL;
     4409        FIXME("vtbitmask is unsupported %lx\n",dwVtBits);
     4410        return E_FAIL;
    44114411    }
    44124412}
     
    46594659 *              VarBstrCmp [OLEAUT32.440]
    46604660 *
    4661  * flags can be:
     4661 * flags can be: 
    46624662 *   NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS
    46634663 *   NORM_IGNORESTRINGWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA
Note: See TracChangeset for help on using the changeset viewer.