Changeset 9400 for trunk/src/oleaut32


Ignore:
Timestamp:
Nov 12, 2002, 6:07:48 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

Location:
trunk/src/oleaut32
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/oleaut32/dbgwrap.cpp

    r8450 r9400  
    303303NODEF_DEBUGWRAP16(VarBstrCmp)
    304304DEBUGWRAP12(VarCat)
    305 
    306 
     305NODEF_DEBUGWRAP8(SafeArrayGetVartype)
     306NODEF_DEBUGWRAP24(VarFormat)
     307NODEF_DEBUGWRAP16(VarFormatDateTime)
     308//NODEF_DEBUGWRAP28(VarFormatNumber)
     309//NODEF_DEBUGWRAP28(VarFormatPercent)
     310NODEF_DEBUGWRAP28(VarFormatCurrency)
     311NODEF_DEBUGWRAP24(VarFormatFromTokens)
     312NODEF_DEBUGWRAP28(VarTokenizeFormatString)
     313DEBUGWRAP12(VarAnd)
     314DEBUGWRAP8(VarNot)
     315DEBUGWRAP16(VarCmp)
     316NODEF_DEBUGWRAP16(VarCyMulI4)
     317
  • trunk/src/oleaut32/ole2disp.c

    r8450 r9400  
    7676{
    7777        BSTR16 out;
    78    
     78
    7979        if (!in) return 0;
    80    
     80
    8181        out = BSTR_AllocBytes(strlen(in)+1);
    8282        if (!out) return 0;
     
    9595{
    9696    if (!in) return 0;
    97    
     97
    9898    /* Delegate this to the SysAllocStringLen32 method. */
    9999    return SysAllocStringLen(in, lstrlenW(in));
     
    119119     * Sanity check
    120120     */
    121     if (old==NULL) 
     121    if (old==NULL)
    122122      return 0;
    123123
     
    125125     * Make sure we free the old string.
    126126     */
    127     if (*old!=NULL)     
     127    if (*old!=NULL)
    128128      SysFreeString(*old);
    129129
     
    166166 * he describes it as a "DWORD count of characters". By experimenting with
    167167 * a windows application, this count seems to be a DWORD count of bytes in
    168  * the string. Meaning that the count is double the number of wide 
     168 * the string. Meaning that the count is double the number of wide
    169169 * characters in the string.
    170170 */
     
    237237}
    238238
    239  
     239
    240240/******************************************************************************
    241241 *             SysReAllocStringLen   [OLEAUT32.5]
     
    246246     * Sanity check
    247247     */
    248     if (old==NULL) 
     248    if (old==NULL)
    249249      return 0;
    250250
     
    252252     * Make sure we free the old string.
    253253     */
    254     if (*old!=NULL)     
     254    if (*old!=NULL)
    255255      SysFreeString(*old);
    256256
     
    277277{
    278278    DWORD* bufferPointer;
    279    
     279
    280280    /* NULL is a valid parameter */
    281281    if(!in) return;
     
    318318     if (!str) return 0;
    319319    /*
    320      * The length of the string (in bytes) is contained in a DWORD placed 
     320     * The length of the string (in bytes) is contained in a DWORD placed
    321321     * just before the BSTR pointer
    322322     */
     
    342342     if (!str) return 0;
    343343    /*
    344      * The length of the string (in bytes) is contained in a DWORD placed 
     344     * The length of the string (in bytes) is contained in a DWORD placed
    345345     * just before the BSTR pointer
    346346     */
     
    419419 * Converts an OLE_COLOR to a COLORREF.
    420420 * See the documentation for conversion rules.
    421  * pColorRef can be NULL. In that case the user only wants to test the 
     421 * pColorRef can be NULL. In that case the user only wants to test the
    422422 * conversion.
    423423 */
     
    430430  BYTE b = HIBYTE(HIWORD(clr));
    431431
    432   TRACE("(%08lx, %d, %p):stub\n", clr, hpal, pColorRef);
     432  TRACE("(%08lx, %p, %p):stub\n", clr, hpal, pColorRef);
    433433
    434434  /*
  • trunk/src/oleaut32/oleaut32.def

    r7916 r9400  
    1 ;/* $Id: oleaut32.def,v 1.9 2002-02-15 15:07:37 sandervl Exp $ */
     1;/* $Id: oleaut32.def,v 1.10 2002-11-12 17:07:46 sandervl Exp $ */
    22LIBRARY OLAUTOS2 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - OleAut32'
     
    55
    66EXPORTS
    7 DllGetClassObject = _OLEAUT32_DllGetClassObject@12  @1
    8 SysAllocString = _SysAllocString@4  @2
    9 SysReAllocString = _SysReAllocString@8  @3
    10 SysAllocStringLen = _SysAllocStringLen@8  @4
    11 SysReAllocStringLen = _SysReAllocStringLen@12  @5
    12 SysFreeString = _SysFreeString@4  @6
    13 SysStringLen = _SysStringLen@4  @7
    14 VariantInit = _VariantInit@4  @8
    15 VariantClear = _VariantClear@4  @9
    16 VariantCopy = _VariantCopy@8  @10
    17 VariantCopyInd = _VariantCopyInd@8  @11
    18 VariantChangeType = _VariantChangeType@16  @12
    19 VariantTimeToDosDateTime = _VariantTimeToDosDateTime@16  @13
    20 DosDateTimeToVariantTime = _DosDateTimeToVariantTime@12  @14
    21 SafeArrayCreate = _SafeArrayCreate@12  @15
    22 SafeArrayDestroy = _SafeArrayDestroy@4  @16
    23 SafeArrayGetDim = _SafeArrayGetDim@4  @17
    24 SafeArrayGetElemsize = _SafeArrayGetElemsize@4  @18
    25 SafeArrayGetUBound = _SafeArrayGetUBound@12  @19
    26 SafeArrayGetLBound = _SafeArrayGetLBound@12  @20
    27 SafeArrayLock = _SafeArrayLock@4  @21
    28 SafeArrayUnlock = _SafeArrayUnlock@4  @22
    29 SafeArrayAccessData = _SafeArrayAccessData@8  @23
    30 SafeArrayUnaccessData = _SafeArrayUnaccessData@4  @24
    31 SafeArrayGetElement = _SafeArrayGetElement@12  @25
    32 SafeArrayPutElement = _SafeArrayPutElement@12  @26
    33 SafeArrayCopy = _SafeArrayCopy@8  @27
    34 DispGetParam = _DispGetParam@20  @28
    35 DispGetIDsOfNames = _DispGetIDsOfNames@16  @29
    36 DispInvoke = _DispInvoke@32  @30
    37 CreateDispTypeInfo = _CreateDispTypeInfo@12  @31
    38 CreateStdDispatch = _CreateStdDispatch@16  @32
    39 RegisterActiveObject = _RegisterActiveObject@16  @33
    40 RevokeActiveObject = _RevokeActiveObject@8  @34
    41 GetActiveObject = _GetActiveObject@12  @35
    42 SafeArrayAllocDescriptor = _SafeArrayAllocDescriptor@8  @36
    43 SafeArrayAllocData = _SafeArrayAllocData@4  @37
    44 SafeArrayDestroyDescriptor = _SafeArrayDestroyDescriptor@4  @38
    45 SafeArrayDestroyData = _SafeArrayDestroyData@4  @39
    46 SafeArrayRedim = _SafeArrayRedim@8  @40
    47 OACreateTypeLib2 = _OACreateTypeLib2@0  @41
    48 VarParseNumFromStr = _VarParseNumFromStr@20  @46
    49 VarNumFromParseNum = _VarNumFromParseNum@16  @47
    50 VarI2FromUI1 = _VarI2FromUI1@8  @48
    51 VarI2FromI4 = _VarI2FromI4@8  @49
    52 VarI2FromR4 = _VarI2FromR4@8  @50
    53 VarI2FromR8 = _VarI2FromR8@12  @51
    54 VarI2FromCy = _VarI2FromCy@12  @52
    55 VarI2FromDate = _VarI2FromDate@12  @53
    56 VarI2FromStr = _VarI2FromStr@16  @54
    57 VarI2FromDisp = _VarI2FromDisp@12  @55
    58 VarI2FromBool = _VarI2FromBool@8  @56
    59 VarI4FromUI1 = _VarI4FromUI1@8  @58
    60 VarI4FromI2 = _VarI4FromI2@8  @59
    61 VarI4FromR4 = _VarI4FromR4@8  @60
    62 VarI4FromR8 = _VarI4FromR8@12  @61
    63 VarI4FromCy = _VarI4FromCy@12  @62
    64 VarI4FromDate = _VarI4FromDate@12  @63
    65 VarI4FromStr = _VarI4FromStr@16  @64
    66 VarI4FromDisp = _VarI4FromDisp@12  @65
    67 VarI4FromBool = _VarI4FromBool@8  @66
    68 VarR4FromUI1 = _VarR4FromUI1@8  @68
    69 VarR4FromI2 = _VarR4FromI2@8  @69
    70 VarR4FromI4 = _VarR4FromI4@8  @70
    71 VarR4FromR8 = _VarR4FromR8@12  @71
    72 VarR4FromCy = _VarR4FromCy@12  @72
    73 VarR4FromDate = _VarR4FromDate@12  @73
    74 VarR4FromStr = _VarR4FromStr@16  @74
    75 VarR4FromDisp = _VarR4FromDisp@12  @75
    76 VarR4FromBool = _VarR4FromBool@8  @76
    77 VarR8FromUI1 = _VarR8FromUI1@8  @78
    78 VarR8FromI2 = _VarR8FromI2@8  @79
    79 VarR8FromI4 = _VarR8FromI4@8  @80
    80 VarR8FromR4 = _VarR8FromR4@8  @81
    81 VarR8FromCy = _VarR8FromCy@12  @82
    82 VarR8FromDate = _VarR8FromDate@12  @83
    83 VarR8FromStr = _VarR8FromStr@16  @84
    84 VarR8FromDisp = _VarR8FromDisp@12  @85
    85 VarR8FromBool = _VarR8FromBool@8  @86
    86 VarDateFromUI1 = _VarDateFromUI1@8  @88
    87 VarDateFromI2 = _VarDateFromI2@8  @89
    88 VarDateFromI4 = _VarDateFromI4@8  @90
    89 VarDateFromR4 = _VarDateFromR4@8  @91
    90 VarDateFromR8 = _VarDateFromR8@12  @92
    91 VarDateFromCy = _VarDateFromCy@12  @93
    92 VarDateFromStr = _VarDateFromStr@16  @94
    93 VarDateFromDisp = _VarDateFromDisp@12  @95
    94 VarDateFromBool = _VarDateFromBool@8  @96
    95 VarCyFromUI1 = _VarCyFromUI1@8  @98
    96 VarCyFromI2 = _VarCyFromI2@8  @99
    97 VarCyFromI4 = _VarCyFromI4@8  @100
    98 VarCyFromR4 = _VarCyFromR4@8  @101
    99 VarCyFromR8 = _VarCyFromR8@12  @102
    100 VarCyFromDate = _VarCyFromDate@12  @103
    101 VarCyFromStr = _VarCyFromStr@16  @104
    102 VarCyFromDisp = _VarCyFromDisp@12  @105
    103 VarCyFromBool = _VarCyFromBool@8  @106
    104 VarBstrFromUI1 = _VarBstrFromUI1@16  @108
    105 VarBstrFromI2 = _VarBstrFromI2@16  @109
    106 VarBstrFromI4 = _VarBstrFromI4@16  @110
    107 VarBstrFromR4 = _VarBstrFromR4@16  @111
    108 VarBstrFromR8 = _VarBstrFromR8@20  @112
    109 VarBstrFromCy = _VarBstrFromCy@20  @113
    110 VarBstrFromDate = _VarBstrFromDate@20  @114
    111 VarBstrFromDisp = _VarBstrFromDisp@16  @115
    112 VarBstrFromBool = _VarBstrFromBool@16  @116
    113 VarBoolFromUI1 = _VarBoolFromUI1@8  @118
    114 VarBoolFromI2 = _VarBoolFromI2@8  @119
    115 VarBoolFromI4 = _VarBoolFromI4@8  @120
    116 VarBoolFromR4 = _VarBoolFromR4@8  @121
    117 VarBoolFromR8 = _VarBoolFromR8@12  @122
    118 VarBoolFromDate = _VarBoolFromDate@12  @123
    119 VarBoolFromCy = _VarBoolFromCy@12  @124
    120 VarBoolFromStr = _VarBoolFromStr@16  @125
    121 VarBoolFromDisp = _VarBoolFromDisp@12  @126
    122 VarUI1FromI2 = _VarUI1FromI2@8  @130
    123 VarUI1FromI4 = _VarUI1FromI4@8  @131
    124 VarUI1FromR4 = _VarUI1FromR4@8  @132
    125 VarUI1FromR8 = _VarUI1FromR8@12  @133
    126 VarUI1FromCy = _VarUI1FromCy@12  @134
    127 VarUI1FromDate = _VarUI1FromDate@12  @135
    128 VarUI1FromStr = _VarUI1FromStr@16  @136
    129 VarUI1FromDisp = _VarUI1FromDisp@12  @137
    130 VarUI1FromBool = _VarUI1FromBool@8  @138
    131 DispCallFunc = _DispCallFunc@32  @146
    132 VariantChangeTypeEx = _VariantChangeTypeEx@20  @147
    133 SafeArrayPtrOfIndex = _SafeArrayPtrOfIndex@12  @148
    134 SysStringByteLen = _SysStringByteLen@4  @149
    135 SysAllocStringByteLen = _SysAllocStringByteLen@8  @150
    136 CreateTypeLib = _CreateTypeLib@12  @160
    137 LoadTypeLib = _LoadTypeLib@8  @161
    138 LoadRegTypeLib = _LoadRegTypeLib@20  @162
    139 RegisterTypeLib = _RegisterTypeLib@12  @163
    140 QueryPathOfRegTypeLib = _QueryPathOfRegTypeLib@20  @164
    141 LHashValOfNameSys = _LHashValOfNameSys@12  @165
    142 LHashValOfNameSysA = _LHashValOfNameSysA@12  @166
    143 OaBuildVersion = _OaBuildVersion@0  @170
    144 ClearCustData = _ClearCustData@4  @171
    145 CreateTypeLib2 = _CreateTypeLib2@12  @180
    146 LoadTypeLibEx = _LoadTypeLibEx@12  @183
    147 SystemTimeToVariantTime = _SystemTimeToVariantTime@8  @184
    148 VariantTimeToSystemTime = _VariantTimeToSystemTime@12  @185
    149 UnRegisterTypeLib = _UnRegisterTypeLib@20  @186
    150 VarDecFromUI1 = _VarDecFromUI1@8  @190
    151 VarDecFromI2 = _VarDecFromI2@8  @191
    152 VarDecFromI4 = _VarDecFromI4@8  @192
    153 VarDecFromR4 = _VarDecFromR4@8  @193
    154 VarDecFromR8 = _VarDecFromR8@12  @194
    155 VarDecFromDate = _VarDecFromDate@12  @195
    156 VarDecFromCy = _VarDecFromCy@12  @196
    157 VarDecFromStr = _VarDecFromStr@16  @197
    158 VarDecFromDisp = _VarDecFromDisp@12  @198
    159 VarDecFromBool = _VarDecFromBool@8  @199
    160 GetErrorInfo = _GetErrorInfo@8  @200
    161 SetErrorInfo = _SetErrorInfo@8  @201
    162 CreateErrorInfo = _CreateErrorInfo@4  @202
    163 VarI2FromI1 = _VarI2FromI1@8  @205
    164 VarI2FromUI2 = _VarI2FromUI2@8  @206
    165 VarI2FromUI4 = _VarI2FromUI4@8  @207
    166 VarI2FromDec = _VarI2FromDec@8  @208
    167 VarI4FromI1 = _VarI4FromI1@8  @209
    168 VarI4FromUI2 = _VarI4FromUI2@8  @210
    169 VarI4FromUI4 = _VarI4FromUI4@8  @211
    170 VarI4FromDec = _VarI4FromDec@8  @212
    171 VarR4FromI1 = _VarR4FromI1@8  @213
    172 VarR4FromUI2 = _VarR4FromUI2@8  @214
    173 VarR4FromUI4 = _VarR4FromUI4@8  @215
    174 VarR4FromDec = _VarR4FromDec@8  @216
    175 VarR8FromI1 = _VarR8FromI1@8  @217
    176 VarR8FromUI2 = _VarR8FromUI2@8  @218
    177 VarR8FromUI4 = _VarR8FromUI4@8  @219
    178 VarR8FromDec = _VarR8FromDec@8  @220
    179 VarDateFromI1 = _VarDateFromI1@8  @221
    180 VarDateFromUI2 = _VarDateFromUI2@8  @222
    181 VarDateFromUI4 = _VarDateFromUI4@8  @223
    182 VarDateFromDec = _VarDateFromDec@8  @224
    183 VarCyFromI1 = _VarCyFromI1@8  @225
    184 VarCyFromUI2 = _VarCyFromUI2@8  @226
    185 VarCyFromUI4 = _VarCyFromUI4@8  @227
    186 VarCyFromDec = _VarCyFromDec@8  @228
    187 VarBstrFromI1 = _VarBstrFromI1@16  @229
     7  DllGetClassObject = _OLEAUT32_DllGetClassObject@12  @1
     8  SysAllocString = _SysAllocString@4  @2
     9  SysReAllocString = _SysReAllocString@8  @3
     10  SysAllocStringLen = _SysAllocStringLen@8  @4
     11  SysReAllocStringLen = _SysReAllocStringLen@12  @5
     12  SysFreeString = _SysFreeString@4  @6
     13  SysStringLen = _SysStringLen@4  @7
     14  VariantInit = _VariantInit@4  @8
     15  VariantClear = _VariantClear@4  @9
     16  VariantCopy = _VariantCopy@8  @10
     17  VariantCopyInd = _VariantCopyInd@8  @11
     18  VariantChangeType = _VariantChangeType@16  @12
     19  VariantTimeToDosDateTime = _VariantTimeToDosDateTime@16  @13
     20  DosDateTimeToVariantTime = _DosDateTimeToVariantTime@12  @14
     21  SafeArrayCreate = _SafeArrayCreate@12  @15
     22  SafeArrayDestroy = _SafeArrayDestroy@4  @16
     23  SafeArrayGetDim = _SafeArrayGetDim@4  @17
     24  SafeArrayGetElemsize = _SafeArrayGetElemsize@4  @18
     25  SafeArrayGetUBound = _SafeArrayGetUBound@12  @19
     26  SafeArrayGetLBound = _SafeArrayGetLBound@12  @20
     27  SafeArrayLock = _SafeArrayLock@4  @21
     28  SafeArrayUnlock = _SafeArrayUnlock@4  @22
     29  SafeArrayAccessData = _SafeArrayAccessData@8  @23
     30  SafeArrayUnaccessData = _SafeArrayUnaccessData@4  @24
     31  SafeArrayGetElement = _SafeArrayGetElement@12  @25
     32  SafeArrayPutElement = _SafeArrayPutElement@12  @26
     33  SafeArrayCopy = _SafeArrayCopy@8  @27
     34  DispGetParam = _DispGetParam@20  @28
     35  DispGetIDsOfNames = _DispGetIDsOfNames@16  @29
     36  DispInvoke = _DispInvoke@32  @30
     37  CreateDispTypeInfo = _CreateDispTypeInfo@12  @31
     38  CreateStdDispatch = _CreateStdDispatch@16  @32
     39  RegisterActiveObject = _RegisterActiveObject@16  @33
     40  RevokeActiveObject = _RevokeActiveObject@8  @34
     41  GetActiveObject = _GetActiveObject@12  @35
     42  SafeArrayAllocDescriptor = _SafeArrayAllocDescriptor@8  @36
     43  SafeArrayAllocData = _SafeArrayAllocData@4  @37
     44  SafeArrayDestroyDescriptor = _SafeArrayDestroyDescriptor@4  @38
     45  SafeArrayDestroyData = _SafeArrayDestroyData@4  @39
     46  SafeArrayRedim = _SafeArrayRedim@8  @40
     47  OACreateTypeLib2 = _OACreateTypeLib2@0  @41
     48  VarParseNumFromStr = _VarParseNumFromStr@20  @46
     49  VarNumFromParseNum = _VarNumFromParseNum@16  @47
     50  VarI2FromUI1 = _VarI2FromUI1@8  @48
     51  VarI2FromI4 = _VarI2FromI4@8  @49
     52  VarI2FromR4 = _VarI2FromR4@8  @50
     53  VarI2FromR8 = _VarI2FromR8@12  @51
     54  VarI2FromCy = _VarI2FromCy@12  @52
     55  VarI2FromDate = _VarI2FromDate@12  @53
     56  VarI2FromStr = _VarI2FromStr@16  @54
     57  VarI2FromDisp = _VarI2FromDisp@12  @55
     58  VarI2FromBool = _VarI2FromBool@8  @56
     59  VarI4FromUI1 = _VarI4FromUI1@8  @58
     60  VarI4FromI2 = _VarI4FromI2@8  @59
     61  VarI4FromR4 = _VarI4FromR4@8  @60
     62  VarI4FromR8 = _VarI4FromR8@12  @61
     63  VarI4FromCy = _VarI4FromCy@12  @62
     64  VarI4FromDate = _VarI4FromDate@12  @63
     65  VarI4FromStr = _VarI4FromStr@16  @64
     66  VarI4FromDisp = _VarI4FromDisp@12  @65
     67  VarI4FromBool = _VarI4FromBool@8  @66
     68  VarR4FromUI1 = _VarR4FromUI1@8  @68
     69  VarR4FromI2 = _VarR4FromI2@8  @69
     70
     71  VarR4FromI4                 = _VarR4FromI4@8                  @70
     72  VarR4FromR8                 = _VarR4FromR8@12                 @71
     73  VarR4FromCy                 = _VarR4FromCy@12                 @72
     74  VarR4FromDate               = _VarR4FromDate@12               @73
     75  VarR4FromStr                = _VarR4FromStr@16                @74
     76  VarR4FromDisp               = _VarR4FromDisp@12               @75
     77  VarR4FromBool               = _VarR4FromBool@8                @76
     78  SafeArrayGetVartype         = _SafeArrayGetVartype@8          @77
     79  VarR8FromUI1                = _VarR8FromUI1@8                 @78
     80  VarR8FromI2                 = _VarR8FromI2@8                  @79
     81
     82  VarR8FromI4                 = _VarR8FromI4@8                  @80
     83  VarR8FromR4                 = _VarR8FromR4@8                  @81
     84  VarR8FromCy                 = _VarR8FromCy@12                 @82
     85  VarR8FromDate               = _VarR8FromDate@12               @83
     86  VarR8FromStr                = _VarR8FromStr@16                @84
     87  VarR8FromDisp               = _VarR8FromDisp@12               @85
     88  VarR8FromBool               = _VarR8FromBool@8                @86
     89  VarFormat                   = _VarFormat@24                   @87
     90  VarDateFromUI1              = _VarDateFromUI1@8               @88
     91  VarDateFromI2               = _VarDateFromI2@8                @89
     92
     93  VarDateFromI4               = _VarDateFromI4@8                @90
     94  VarDateFromR4               = _VarDateFromR4@8                @91
     95  VarDateFromR8               = _VarDateFromR8@12               @92
     96  VarDateFromCy               = _VarDateFromCy@12               @93
     97  VarDateFromStr              = _VarDateFromStr@16              @94
     98  VarDateFromDisp             = _VarDateFromDisp@12             @95
     99  VarDateFromBool             = _VarDateFromBool@8              @96
     100  VarFormatDateTime           = _VarFormatDateTime@16           @97
     101  VarCyFromUI1                = _VarCyFromUI1@8                 @98
     102  VarCyFromI2                 = _VarCyFromI2@8                  @99
     103
     104  VarCyFromI4                 = _VarCyFromI4@8                  @100
     105  VarCyFromR4                 = _VarCyFromR4@8                  @101
     106  VarCyFromR8                 = _VarCyFromR8@12                 @102
     107  VarCyFromDate               = _VarCyFromDate@12               @103
     108  VarCyFromStr                = _VarCyFromStr@16                @104
     109  VarCyFromDisp               = _VarCyFromDisp@12               @105
     110  VarCyFromBool               = _VarCyFromBool@8                @106
     111;;  VarFormatNumber             = _VarFormatNumber@28             @107
     112  VarBstrFromUI1              = _VarBstrFromUI1@16              @108
     113  VarBstrFromI2               = _VarBstrFromI2@16               @109
     114
     115  VarBstrFromI4               = _VarBstrFromI4@16               @110
     116  VarBstrFromR4               = _VarBstrFromR4@16               @111
     117  VarBstrFromR8               = _VarBstrFromR8@20               @112
     118  VarBstrFromCy               = _VarBstrFromCy@20               @113
     119  VarBstrFromDate             = _VarBstrFromDate@20             @114
     120  VarBstrFromDisp             = _VarBstrFromDisp@16             @115
     121  VarBstrFromBool             = _VarBstrFromBool@16             @116
     122;;  VarFormatPercent            = _VarFormatPercent@28            @117
     123  VarBoolFromUI1              = _VarBoolFromUI1@8               @118
     124  VarBoolFromI2               = _VarBoolFromI2@8                @119
     125
     126  VarBoolFromI4               = _VarBoolFromI4@8                @120
     127  VarBoolFromR4               = _VarBoolFromR4@8                @121
     128  VarBoolFromR8               = _VarBoolFromR8@12               @122
     129  VarBoolFromDate             = _VarBoolFromDate@12             @123
     130  VarBoolFromCy               = _VarBoolFromCy@12               @124
     131  VarBoolFromStr              = _VarBoolFromStr@16              @125
     132  VarBoolFromDisp             = _VarBoolFromDisp@12             @126
     133  VarFormatCurrency           = _VarFormatCurrency@28           @127
     134
     135  VarUI1FromI2                = _VarUI1FromI2@8                 @130
     136  VarUI1FromI4                = _VarUI1FromI4@8                 @131
     137  VarUI1FromR4                = _VarUI1FromR4@8                 @132
     138  VarUI1FromR8                = _VarUI1FromR8@12                @133
     139  VarUI1FromCy                = _VarUI1FromCy@12                @134
     140  VarUI1FromDate              = _VarUI1FromDate@12              @135
     141  VarUI1FromStr               = _VarUI1FromStr@16               @136
     142  VarUI1FromDisp              = _VarUI1FromDisp@12              @137
     143  VarUI1FromBool              = _VarUI1FromBool@8               @138
     144  VarFormatFromTokens         = _VarFormatFromTokens@24         @139
     145
     146  VarTokenizeFormatString     = _VarTokenizeFormatString@28     @140
     147  VarAnd                      = _VarAnd@12                      @142
     148
     149  DispCallFunc                = _DispCallFunc@32                @146
     150  VariantChangeTypeEx         = _VariantChangeTypeEx@20         @147
     151  SafeArrayPtrOfIndex         = _SafeArrayPtrOfIndex@12         @148
     152  SysStringByteLen            = _SysStringByteLen@4             @149
     153
     154  SysAllocStringByteLen       = _SysAllocStringByteLen@8        @150
     155
     156  CreateTypeLib               = _CreateTypeLib@12               @160
     157  LoadTypeLib                 = _LoadTypeLib@8                  @161
     158  LoadRegTypeLib              = _LoadRegTypeLib@20              @162
     159  RegisterTypeLib             = _RegisterTypeLib@12             @163
     160  QueryPathOfRegTypeLib       = _QueryPathOfRegTypeLib@20       @164
     161  LHashValOfNameSys           = _LHashValOfNameSys@12           @165
     162  LHashValOfNameSysA          = _LHashValOfNameSysA@12          @166
     163
     164  OaBuildVersion              = _OaBuildVersion@0               @170
     165  ClearCustData               = _ClearCustData@4                @171
     166  VarNot                      = _VarNot@8                       @174
     167  VarCmp                      = _VarCmp@16                      @176
     168
     169  CreateTypeLib2              = _CreateTypeLib2@12              @180
     170  LoadTypeLibEx               = _LoadTypeLibEx@12               @183
     171  SystemTimeToVariantTime     = _SystemTimeToVariantTime@8      @184
     172  VariantTimeToSystemTime     = _VariantTimeToSystemTime@12     @185
     173  UnRegisterTypeLib           = _UnRegisterTypeLib@20           @186
     174
     175  VarDecFromUI1               = _VarDecFromUI1@8                @190
     176  VarDecFromI2                = _VarDecFromI2@8                 @191
     177  VarDecFromI4                = _VarDecFromI4@8                 @192
     178  VarDecFromR4                = _VarDecFromR4@8                 @193
     179  VarDecFromR8                = _VarDecFromR8@12                @194
     180  VarDecFromDate              = _VarDecFromDate@12              @195
     181  VarDecFromCy                = _VarDecFromCy@12                @196
     182  VarDecFromStr               = _VarDecFromStr@16               @197
     183  VarDecFromDisp              = _VarDecFromDisp@12              @198
     184  VarDecFromBool              = _VarDecFromBool@8               @199
     185
     186  GetErrorInfo = _GetErrorInfo@8  @200
     187  SetErrorInfo = _SetErrorInfo@8  @201
     188  CreateErrorInfo = _CreateErrorInfo@4  @202
     189  VarI2FromI1 = _VarI2FromI1@8  @205
     190  VarI2FromUI2 = _VarI2FromUI2@8  @206
     191  VarI2FromUI4 = _VarI2FromUI4@8  @207
     192  VarI2FromDec = _VarI2FromDec@8  @208
     193  VarI4FromI1 = _VarI4FromI1@8  @209
     194  VarI4FromUI2 = _VarI4FromUI2@8  @210
     195
     196  VarI4FromUI4 = _VarI4FromUI4@8  @211
     197  VarI4FromDec = _VarI4FromDec@8  @212
     198  VarR4FromI1 = _VarR4FromI1@8  @213
     199  VarR4FromUI2 = _VarR4FromUI2@8  @214
     200  VarR4FromUI4 = _VarR4FromUI4@8  @215
     201  VarR4FromDec = _VarR4FromDec@8  @216
     202  VarR8FromI1 = _VarR8FromI1@8  @217
     203  VarR8FromUI2 = _VarR8FromUI2@8  @218
     204  VarR8FromUI4 = _VarR8FromUI4@8  @219
     205
     206  VarR8FromDec = _VarR8FromDec@8  @220
     207  VarDateFromI1 = _VarDateFromI1@8  @221
     208  VarDateFromUI2 = _VarDateFromUI2@8  @222
     209  VarDateFromUI4 = _VarDateFromUI4@8  @223
     210  VarDateFromDec = _VarDateFromDec@8  @224
     211  VarCyFromI1 = _VarCyFromI1@8  @225
     212  VarCyFromUI2 = _VarCyFromUI2@8  @226
     213  VarCyFromUI4 = _VarCyFromUI4@8  @227
     214  VarCyFromDec = _VarCyFromDec@8  @228
     215  VarBstrFromI1 = _VarBstrFromI1@16  @229
     216
    188217VarBstrFromUI2 = _VarBstrFromUI2@16  @230
    189218VarBstrFromUI4 = _VarBstrFromUI4@16  @231
     
    254283LPSAFEARRAY_Marshal = _LPSAFEARRAY_Marshal@0  @296
    255284LPSAFEARRAY_Unmarshal = _LPSAFEARRAY_Unmarshal@0  @297
     285
     286  VarCyMulI4               = _VarCyMulI4@16                    @304
     287
     288  VarBstrCat               = _VarBstrCat@12                    @313
     289  VarBstrCmp               = _VarBstrCmp@16                    @314
     290  VarCat                   = _VarCat@12                        @318
     291
    256292DllRegisterServer = _OLEAUT32_DllRegisterServer@0  @320
    257293DllUnregisterServer = _OLEAUT32_DllUnregisterServer@0  @321
     294
    258295VarDateFromUdate = _VarDateFromUdate@12  @330
    259296VarUdateFromDate = _VarUdateFromDate@16  @331
     
    279316UserMSG_free_inst = _UserMSG_free_inst@0  @398
    280317UserMSG_free_local = _UserMSG_free_local@0  @399
     318
    281319DllCanUnloadNow = _OLEAUT32_DllCanUnloadNow@0  @410
    282320SafeArrayCreateVector = _SafeArrayCreateVector@12  @411
     
    303341SafeArrayAllocDescriptorEx = _SafeArrayAllocDescriptorEx@12 @429
    304342
    305 ;430 stub SafeArrayCreateEx
    306 ;431 stub SafeArrayCreateVectorEx
    307 ;432 stub SafeArrayGetIID
    308 ;433 stub SafeArrayGetRecordInfo
    309 ;434 stub SafeArraySetIID
    310 ;435 stub SafeArraySetRecordInfo
    311 ;436 stub VarAbs ; stdcall (ptr ptr)
    312 ;437 stub VarAdd ; stdcall (ptr ptr ptr)
    313 ;438 stub VarAnd ; stdcall (ptr ptr ptr)
    314 VarBstrCat          = _VarBstrCat@12                    @439
    315 VarBstrCmp          = _VarBstrCmp@16                    @440
    316 VarCat              = _VarCat@12                        @441
    317 
    318 ;442 stub VarCmp ; stdcall (ptr ptr long long)
    319 ;443 stub VarCyAbs
    320 ;444 stub VarCyAdd
    321 ;445 stub VarCyCmp
    322 ;446 stub VarCyCmpR8
    323 ;447 stub VarCyFix
    324 ;448 stub VarCyInt
    325 ;449 stub VarCyMul
    326 ;450 stub VarCyMulI4
    327 ;451 stub VarCyNeg
    328 ;452 stub VarCyRound
    329 ;453 stub VarCySub
    330 ;454 stub VarDateFromUdateEx ; stdcall (ptr long long ptr)
    331 ;455 stub VarDecAbs ; stdcall (ptr ptr)
    332 ;456 stub VarDecAdd ; stdcall (ptr ptr ptr)
    333 ;457 stub VarDecCmp ; stdcall (ptr ptr)
    334 ;458 stub VarDecCmpR8 ; stdcall (ptr double)
    335 ;459 stub VarDecDiv ; stdcall (ptr ptr ptr)
    336 ;460 stub VarDecFix ; stdcall (ptr ptr)
    337 ;461 stub VarDecInt ; stdcall (ptr ptr)
    338 ;462 stub VarDecMul ; stdcall (ptr ptr ptr)
    339 ;463 stub VarDecNeg ; stdcall (ptr ptr)
    340 ;464 stub VarDecRound ; stdcall (ptr long ptr)
    341 ;465 stub VarDecSub ; stdcall (ptr ptr ptr)
    342 ;466 stub VarDiv ; stdcall (ptr ptr ptr)
    343 ;467 stub VarEqv ; stdcall (ptr ptr ptr)
    344 ;468 stub VarFix ; stdcall (ptr ptr)
    345 ;469 stub VarFormat ; stdcall (ptr ptr long long long ptr)
    346 ;470 stub VarFormatCurrency ; stdcall (ptr long long long long long ptr)
    347 ;471 stub VarFormatDateTime ; stdcall (ptr long long ptr)
    348 ;472 stub VarFormatFromTokens ; stdcall (ptr ptr ptr long ptr long)
    349 ;473 stub VarFormatNumber ; stdcall (ptr long long long long long ptr)
    350 ;474 stub VarFormatPercent ; stdcall (ptr long long long long long ptr)
    351 ;475 stub VarIdiv ; stdcall (ptr ptr ptr)
    352 ;476 stub VarImp ; stdcall (ptr ptr ptr)
    353 ;477 stub VarInt ; stdcall (ptr ptr)
    354 ;478 stub VarMod ; stdcall (ptr ptr ptr)
    355 ;479 stub VarMonthName ; stdcall (long long long ptr)
    356 ;480 stub VarMul ; stdcall (ptr ptr ptr)
    357 ;481 stub VarNeg ; stdcall (ptr ptr)
    358 ;482 stub VarNot ; stdcall (ptr ptr)
    359 ;483 stub VarOr ; stdcall (ptr ptr ptr)
    360 ;484 stub VarPow ; stdcall (ptr ptr ptr)
    361 ;485 stub VarR4CmpR8
    362 ;486 stub VarR8Pow ; stdcall (double double ptr)
    363 ;487 stub VarR8Round ; stdcall (double long ptr)
    364 ;488 stub VarRound ; stdcall (ptr long ptr)
    365 ;489 stub VarSub ; stdcall (ptr ptr ptr)
    366 ;490 stub VarTokenizeFormatString ; stdcall (ptr ptr long long long long ptr)
    367 ;491 stub VarWeekdayName ; stdcall (long long long long ptr)
    368 ;492 stub VarXor ; stdcall (ptr ptr ptr)
     343
  • trunk/src/oleaut32/oleaut32dbg.def

    r7919 r9400  
    1 ;/* $Id: oleaut32dbg.def,v 1.2 2002-02-15 15:23:43 sandervl Exp $ */
     1;/* $Id: oleaut32dbg.def,v 1.3 2002-11-12 17:07:46 sandervl Exp $ */
    22LIBRARY OLAUTOS2 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - OleAut32'
     
    6868VarR4FromUI1 = _DbgVarR4FromUI1@8  @68
    6969VarR4FromI2 = _DbgVarR4FromI2@8  @69
    70 VarR4FromI4 = _DbgVarR4FromI4@8  @70
    71 VarR4FromR8 = _DbgVarR4FromR8@12  @71
    72 VarR4FromCy = _DbgVarR4FromCy@12  @72
    73 VarR4FromDate = _DbgVarR4FromDate@12  @73
    74 VarR4FromStr = _DbgVarR4FromStr@16  @74
    75 VarR4FromDisp = _DbgVarR4FromDisp@12  @75
    76 VarR4FromBool = _DbgVarR4FromBool@8  @76
    77 VarR8FromUI1 = _DbgVarR8FromUI1@8  @78
    78 VarR8FromI2 = _DbgVarR8FromI2@8  @79
    79 VarR8FromI4 = _DbgVarR8FromI4@8  @80
    80 VarR8FromR4 = _DbgVarR8FromR4@8  @81
    81 VarR8FromCy = _DbgVarR8FromCy@12  @82
    82 VarR8FromDate = _DbgVarR8FromDate@12  @83
    83 VarR8FromStr = _DbgVarR8FromStr@16  @84
    84 VarR8FromDisp = _DbgVarR8FromDisp@12  @85
    85 VarR8FromBool = _DbgVarR8FromBool@8  @86
    86 VarDateFromUI1 = _DbgVarDateFromUI1@8  @88
    87 VarDateFromI2 = _DbgVarDateFromI2@8  @89
    88 VarDateFromI4 = _DbgVarDateFromI4@8  @90
    89 VarDateFromR4 = _DbgVarDateFromR4@8  @91
    90 VarDateFromR8 = _DbgVarDateFromR8@12  @92
    91 VarDateFromCy = _DbgVarDateFromCy@12  @93
    92 VarDateFromStr = _DbgVarDateFromStr@16  @94
    93 VarDateFromDisp = _DbgVarDateFromDisp@12  @95
    94 VarDateFromBool = _DbgVarDateFromBool@8  @96
    95 VarCyFromUI1 = _DbgVarCyFromUI1@8  @98
    96 VarCyFromI2 = _DbgVarCyFromI2@8  @99
    97 VarCyFromI4 = _DbgVarCyFromI4@8  @100
    98 VarCyFromR4 = _DbgVarCyFromR4@8  @101
    99 VarCyFromR8 = _DbgVarCyFromR8@12  @102
    100 VarCyFromDate = _DbgVarCyFromDate@12  @103
    101 VarCyFromStr = _DbgVarCyFromStr@16  @104
    102 VarCyFromDisp = _DbgVarCyFromDisp@12  @105
    103 VarCyFromBool = _DbgVarCyFromBool@8  @106
    104 VarBstrFromUI1 = _DbgVarBstrFromUI1@16  @108
    105 VarBstrFromI2 = _DbgVarBstrFromI2@16  @109
    106 VarBstrFromI4 = _DbgVarBstrFromI4@16  @110
    107 VarBstrFromR4 = _DbgVarBstrFromR4@16  @111
    108 VarBstrFromR8 = _DbgVarBstrFromR8@20  @112
    109 VarBstrFromCy = _DbgVarBstrFromCy@20  @113
    110 VarBstrFromDate = _DbgVarBstrFromDate@20  @114
    111 VarBstrFromDisp = _DbgVarBstrFromDisp@16  @115
    112 VarBstrFromBool = _DbgVarBstrFromBool@16  @116
    113 VarBoolFromUI1 = _DbgVarBoolFromUI1@8  @118
    114 VarBoolFromI2 = _DbgVarBoolFromI2@8  @119
    115 VarBoolFromI4 = _DbgVarBoolFromI4@8  @120
    116 VarBoolFromR4 = _DbgVarBoolFromR4@8  @121
    117 VarBoolFromR8 = _DbgVarBoolFromR8@12  @122
    118 VarBoolFromDate = _DbgVarBoolFromDate@12  @123
    119 VarBoolFromCy = _DbgVarBoolFromCy@12  @124
    120 VarBoolFromStr = _DbgVarBoolFromStr@16  @125
    121 VarBoolFromDisp = _DbgVarBoolFromDisp@12  @126
    122 VarUI1FromI2 = _DbgVarUI1FromI2@8  @130
    123 VarUI1FromI4 = _DbgVarUI1FromI4@8  @131
    124 VarUI1FromR4 = _DbgVarUI1FromR4@8  @132
    125 VarUI1FromR8 = _DbgVarUI1FromR8@12  @133
    126 VarUI1FromCy = _DbgVarUI1FromCy@12  @134
    127 VarUI1FromDate = _DbgVarUI1FromDate@12  @135
    128 VarUI1FromStr = _DbgVarUI1FromStr@16  @136
    129 VarUI1FromDisp = _DbgVarUI1FromDisp@12  @137
    130 VarUI1FromBool = _DbgVarUI1FromBool@8  @138
    131 DispCallFunc = _DbgDispCallFunc@32  @146
    132 VariantChangeTypeEx = _DbgVariantChangeTypeEx@20  @147
    133 SafeArrayPtrOfIndex = _DbgSafeArrayPtrOfIndex@12  @148
    134 SysStringByteLen = _DbgSysStringByteLen@4  @149
    135 SysAllocStringByteLen = _DbgSysAllocStringByteLen@8  @150
    136 CreateTypeLib = _DbgCreateTypeLib@12  @160
    137 LoadTypeLib = _DbgLoadTypeLib@8  @161
    138 LoadRegTypeLib = _DbgLoadRegTypeLib@20  @162
    139 RegisterTypeLib = _DbgRegisterTypeLib@12  @163
    140 QueryPathOfRegTypeLib = _DbgQueryPathOfRegTypeLib@20  @164
    141 LHashValOfNameSys = _DbgLHashValOfNameSys@12  @165
    142 LHashValOfNameSysA = _DbgLHashValOfNameSysA@12  @166
    143 OaBuildVersion = _DbgOaBuildVersion@0  @170
    144 ClearCustData = _DbgClearCustData@4  @171
    145 CreateTypeLib2 = _DbgCreateTypeLib2@12  @180
    146 LoadTypeLibEx = _DbgLoadTypeLibEx@12  @183
    147 SystemTimeToVariantTime = _DbgSystemTimeToVariantTime@8  @184
    148 VariantTimeToSystemTime = _DbgVariantTimeToSystemTime@12  @185
    149 UnRegisterTypeLib = _DbgUnRegisterTypeLib@20  @186
    150 VarDecFromUI1 = _DbgVarDecFromUI1@8  @190
    151 VarDecFromI2 = _DbgVarDecFromI2@8  @191
    152 VarDecFromI4 = _DbgVarDecFromI4@8  @192
    153 VarDecFromR4 = _DbgVarDecFromR4@8  @193
    154 VarDecFromR8 = _DbgVarDecFromR8@12  @194
    155 VarDecFromDate = _DbgVarDecFromDate@12  @195
    156 VarDecFromCy = _DbgVarDecFromCy@12  @196
    157 VarDecFromStr = _DbgVarDecFromStr@16  @197
    158 VarDecFromDisp = _DbgVarDecFromDisp@12  @198
    159 VarDecFromBool = _DbgVarDecFromBool@8  @199
     70
     71  VarR4FromI4                 = _DbgVarR4FromI4@8                  @70
     72  VarR4FromR8                 = _DbgVarR4FromR8@12                 @71
     73  VarR4FromCy                 = _DbgVarR4FromCy@12                 @72
     74  VarR4FromDate               = _DbgVarR4FromDate@12               @73
     75  VarR4FromStr                = _DbgVarR4FromStr@16                @74
     76  VarR4FromDisp               = _DbgVarR4FromDisp@12               @75
     77  VarR4FromBool               = _DbgVarR4FromBool@8                @76
     78  SafeArrayGetVartype         = _DbgSafeArrayGetVartype@8          @77
     79  VarR8FromUI1                = _DbgVarR8FromUI1@8                 @78
     80  VarR8FromI2                 = _DbgVarR8FromI2@8                  @79
     81
     82  VarR8FromI4                 = _DbgVarR8FromI4@8                  @80
     83  VarR8FromR4                 = _DbgVarR8FromR4@8                  @81
     84  VarR8FromCy                 = _DbgVarR8FromCy@12                 @82
     85  VarR8FromDate               = _DbgVarR8FromDate@12               @83
     86  VarR8FromStr                = _DbgVarR8FromStr@16                @84
     87  VarR8FromDisp               = _DbgVarR8FromDisp@12               @85
     88  VarR8FromBool               = _DbgVarR8FromBool@8                @86
     89  VarFormat                   = _DbgVarFormat@24                   @87
     90  VarDateFromUI1              = _DbgVarDateFromUI1@8               @88
     91  VarDateFromI2               = _DbgVarDateFromI2@8                @89
     92
     93  VarDateFromI4               = _DbgVarDateFromI4@8                @90
     94  VarDateFromR4               = _DbgVarDateFromR4@8                @91
     95  VarDateFromR8               = _DbgVarDateFromR8@12               @92
     96  VarDateFromCy               = _DbgVarDateFromCy@12               @93
     97  VarDateFromStr              = _DbgVarDateFromStr@16              @94
     98  VarDateFromDisp             = _DbgVarDateFromDisp@12             @95
     99  VarDateFromBool             = _DbgVarDateFromBool@8              @96
     100  VarFormatDateTime           = _DbgVarFormatDateTime@16           @97
     101  VarCyFromUI1                = _DbgVarCyFromUI1@8                 @98
     102  VarCyFromI2                 = _DbgVarCyFromI2@8                  @99
     103
     104  VarCyFromI4                 = _DbgVarCyFromI4@8                  @100
     105  VarCyFromR4                 = _DbgVarCyFromR4@8                  @101
     106  VarCyFromR8                 = _DbgVarCyFromR8@12                 @102
     107  VarCyFromDate               = _DbgVarCyFromDate@12               @103
     108  VarCyFromStr                = _DbgVarCyFromStr@16                @104
     109  VarCyFromDisp               = _DbgVarCyFromDisp@12               @105
     110  VarCyFromBool               = _DbgVarCyFromBool@8                @106
     111;;  VarFormatNumber             = _DbgVarFormatNumber@28             @107
     112  VarBstrFromUI1              = _DbgVarBstrFromUI1@16              @108
     113  VarBstrFromI2               = _DbgVarBstrFromI2@16               @109
     114
     115  VarBstrFromI4               = _DbgVarBstrFromI4@16               @110
     116  VarBstrFromR4               = _DbgVarBstrFromR4@16               @111
     117  VarBstrFromR8               = _DbgVarBstrFromR8@20               @112
     118  VarBstrFromCy               = _DbgVarBstrFromCy@20               @113
     119  VarBstrFromDate             = _DbgVarBstrFromDate@20             @114
     120  VarBstrFromDisp             = _DbgVarBstrFromDisp@16             @115
     121  VarBstrFromBool             = _DbgVarBstrFromBool@16             @116
     122;;  VarFormatPercent            = _DbgVarFormatPercent@28            @117
     123  VarBoolFromUI1              = _DbgVarBoolFromUI1@8               @118
     124  VarBoolFromI2               = _DbgVarBoolFromI2@8                @119
     125
     126  VarBoolFromI4               = _DbgVarBoolFromI4@8                @120
     127  VarBoolFromR4               = _DbgVarBoolFromR4@8                @121
     128  VarBoolFromR8               = _DbgVarBoolFromR8@12               @122
     129  VarBoolFromDate             = _DbgVarBoolFromDate@12             @123
     130  VarBoolFromCy               = _DbgVarBoolFromCy@12               @124
     131  VarBoolFromStr              = _DbgVarBoolFromStr@16              @125
     132  VarBoolFromDisp             = _DbgVarBoolFromDisp@12             @126
     133  VarFormatCurrency           = _DbgVarFormatCurrency@28           @127
     134
     135  VarUI1FromI2                = _DbgVarUI1FromI2@8                 @130
     136  VarUI1FromI4                = _DbgVarUI1FromI4@8                 @131
     137  VarUI1FromR4                = _DbgVarUI1FromR4@8                 @132
     138  VarUI1FromR8                = _DbgVarUI1FromR8@12                @133
     139  VarUI1FromCy                = _DbgVarUI1FromCy@12                @134
     140  VarUI1FromDate              = _DbgVarUI1FromDate@12              @135
     141  VarUI1FromStr               = _DbgVarUI1FromStr@16               @136
     142  VarUI1FromDisp              = _DbgVarUI1FromDisp@12              @137
     143  VarUI1FromBool              = _DbgVarUI1FromBool@8               @138
     144  VarFormatFromTokens         = _DbgVarFormatFromTokens@24         @139
     145
     146  VarTokenizeFormatString     = _DbgVarTokenizeFormatString@28     @140
     147  VarAnd                      = _DbgVarAnd@12                      @142
     148
     149  DispCallFunc                = _DbgDispCallFunc@32                @146
     150  VariantChangeTypeEx         = _DbgVariantChangeTypeEx@20         @147
     151  SafeArrayPtrOfIndex         = _DbgSafeArrayPtrOfIndex@12         @148
     152  SysStringByteLen            = _DbgSysStringByteLen@4             @149
     153
     154  SysAllocStringByteLen       = _DbgSysAllocStringByteLen@8        @150
     155
     156  CreateTypeLib               = _DbgCreateTypeLib@12               @160
     157  LoadTypeLib                 = _DbgLoadTypeLib@8                  @161
     158  LoadRegTypeLib              = _DbgLoadRegTypeLib@20              @162
     159  RegisterTypeLib             = _DbgRegisterTypeLib@12             @163
     160  QueryPathOfRegTypeLib       = _DbgQueryPathOfRegTypeLib@20       @164
     161  LHashValOfNameSys           = _DbgLHashValOfNameSys@12           @165
     162  LHashValOfNameSysA          = _DbgLHashValOfNameSysA@12          @166
     163
     164  OaBuildVersion              = _DbgOaBuildVersion@0               @170
     165  ClearCustData               = _DbgClearCustData@4                @171
     166  VarNot                      = _DbgVarNot@8                       @174
     167  VarCmp                      = _DbgVarCmp@16                      @176
     168
     169  CreateTypeLib2              = _DbgCreateTypeLib2@12              @180
     170  LoadTypeLibEx               = _DbgLoadTypeLibEx@12               @183
     171  SystemTimeToVariantTime     = _DbgSystemTimeToVariantTime@8      @184
     172  VariantTimeToSystemTime     = _DbgVariantTimeToSystemTime@12     @185
     173  UnRegisterTypeLib           = _DbgUnRegisterTypeLib@20           @186
     174
     175  VarDecFromUI1               = _DbgVarDecFromUI1@8                @190
     176  VarDecFromI2                = _DbgVarDecFromI2@8                 @191
     177  VarDecFromI4                = _DbgVarDecFromI4@8                 @192
     178  VarDecFromR4                = _DbgVarDecFromR4@8                 @193
     179  VarDecFromR8                = _DbgVarDecFromR8@12                @194
     180  VarDecFromDate              = _DbgVarDecFromDate@12              @195
     181  VarDecFromCy                = _DbgVarDecFromCy@12                @196
     182  VarDecFromStr               = _DbgVarDecFromStr@16               @197
     183  VarDecFromDisp              = _DbgVarDecFromDisp@12              @198
     184  VarDecFromBool              = _DbgVarDecFromBool@8               @199
     185
    160186GetErrorInfo = _GetErrorInfo@8  @200
    161187SetErrorInfo = _SetErrorInfo@8  @201
     
    254280LPSAFEARRAY_Marshal = _DbgLPSAFEARRAY_Marshal@0  @296
    255281LPSAFEARRAY_Unmarshal = _DbgLPSAFEARRAY_Unmarshal@0  @297
     282
     283  VarCyMulI4               = _DbgVarCyMulI4@16                    @304
     284
     285  VarBstrCat               = _DbgVarBstrCat@12                    @313
     286  VarBstrCmp               = _DbgVarBstrCmp@16                    @314
     287  VarCat                   = _DbgVarCat@12                        @318
     288
    256289DllRegisterServer = _DbgOLEAUT32_DllRegisterServer@0  @320
    257290DllUnregisterServer = _DbgOLEAUT32_DllUnregisterServer@0  @321
     
    303336SafeArrayAllocDescriptorEx = _DbgSafeArrayAllocDescriptorEx@12 @429
    304337
    305 ;430 stub SafeArrayCreateEx
    306 ;431 stub SafeArrayCreateVectorEx
    307 ;432 stub SafeArrayGetIID
    308 ;433 stub SafeArrayGetRecordInfo
    309 ;434 stub SafeArraySetIID
    310 ;435 stub SafeArraySetRecordInfo
    311 ;436 stub VarAbs ; stdcall (ptr ptr)
    312 ;437 stub VarAdd ; stdcall (ptr ptr ptr)
    313 ;438 stub VarAnd ; stdcall (ptr ptr ptr)
    314 VarBstrCat          = _DbgVarBstrCat@12                    @439
    315 VarBstrCmp          = _DbgVarBstrCmp@16                    @440
    316 VarCat              = _DbgVarCat@12                        @441
    317 
    318 ;442 stub VarCmp ; stdcall (ptr ptr long long)
    319 ;443 stub VarCyAbs
    320 ;444 stub VarCyAdd
    321 ;445 stub VarCyCmp
    322 ;446 stub VarCyCmpR8
    323 ;447 stub VarCyFix
    324 ;448 stub VarCyInt
    325 ;449 stub VarCyMul
    326 ;450 stub VarCyMulI4
    327 ;451 stub VarCyNeg
    328 ;452 stub VarCyRound
    329 ;453 stub VarCySub
    330 ;454 stub VarDateFromUdateEx ; stdcall (ptr long long ptr)
    331 ;455 stub VarDecAbs ; stdcall (ptr ptr)
    332 ;456 stub VarDecAdd ; stdcall (ptr ptr ptr)
    333 ;457 stub VarDecCmp ; stdcall (ptr ptr)
    334 ;458 stub VarDecCmpR8 ; stdcall (ptr double)
    335 ;459 stub VarDecDiv ; stdcall (ptr ptr ptr)
    336 ;460 stub VarDecFix ; stdcall (ptr ptr)
    337 ;461 stub VarDecInt ; stdcall (ptr ptr)
    338 ;462 stub VarDecMul ; stdcall (ptr ptr ptr)
    339 ;463 stub VarDecNeg ; stdcall (ptr ptr)
    340 ;464 stub VarDecRound ; stdcall (ptr long ptr)
    341 ;465 stub VarDecSub ; stdcall (ptr ptr ptr)
    342 ;466 stub VarDiv ; stdcall (ptr ptr ptr)
    343 ;467 stub VarEqv ; stdcall (ptr ptr ptr)
    344 ;468 stub VarFix ; stdcall (ptr ptr)
    345 ;469 stub VarFormat ; stdcall (ptr ptr long long long ptr)
    346 ;470 stub VarFormatCurrency ; stdcall (ptr long long long long long ptr)
    347 ;471 stub VarFormatDateTime ; stdcall (ptr long long ptr)
    348 ;472 stub VarFormatFromTokens ; stdcall (ptr ptr ptr long ptr long)
    349 ;473 stub VarFormatNumber ; stdcall (ptr long long long long long ptr)
    350 ;474 stub VarFormatPercent ; stdcall (ptr long long long long long ptr)
    351 ;475 stub VarIdiv ; stdcall (ptr ptr ptr)
    352 ;476 stub VarImp ; stdcall (ptr ptr ptr)
    353 ;477 stub VarInt ; stdcall (ptr ptr)
    354 ;478 stub VarMod ; stdcall (ptr ptr ptr)
    355 ;479 stub VarMonthName ; stdcall (long long long ptr)
    356 ;480 stub VarMul ; stdcall (ptr ptr ptr)
    357 ;481 stub VarNeg ; stdcall (ptr ptr)
    358 ;482 stub VarNot ; stdcall (ptr ptr)
    359 ;483 stub VarOr ; stdcall (ptr ptr ptr)
    360 ;484 stub VarPow ; stdcall (ptr ptr ptr)
    361 ;485 stub VarR4CmpR8
    362 ;486 stub VarR8Pow ; stdcall (double double ptr)
    363 ;487 stub VarR8Round ; stdcall (double long ptr)
    364 ;488 stub VarRound ; stdcall (ptr long ptr)
    365 ;489 stub VarSub ; stdcall (ptr ptr ptr)
    366 ;490 stub VarTokenizeFormatString ; stdcall (ptr ptr long long long long ptr)
    367 ;491 stub VarWeekdayName ; stdcall (long long long long ptr)
    368 ;492 stub VarXor ; stdcall (ptr ptr ptr)
  • trunk/src/oleaut32/olefont.c

    r8450 r9400  
    2525#include "oleaut32.h"
    2626#endif
    27 
    2827#include <assert.h>
    2928#include <string.h>
     
    5958{
    6059  /*
    61    * This class supports many interfaces. IUnknown, IFont, 
     60   * This class supports many interfaces. IUnknown, IFont,
    6261   * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
    6362   * The first two are supported by the first vtable, the next two are
     
    9897
    9998/*
    100  * Here, I define utility macros to help with the casting of the 
     99 * Here, I define utility macros to help with the casting of the
    101100 * "this" parameter.
    102101 * There is a version to accomodate all of the VTables implemented
     
    104103 */
    105104#define _ICOM_THIS(class,name) class* this = (class*)name;
    106 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 
    107 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 
    108 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 
     105#define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
     106#define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
     107#define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
    109108
    110109
     
    147146 * interface
    148147 */
    149 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 
    150                                                     REFIID     riid, 
     148static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
     149                                                    REFIID     riid,
    151150                                                    VOID**     ppvoid);
    152151static ULONG   WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
    153152static ULONG   WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
    154 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface, 
     153static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface,
    155154                                                   unsigned int* pctinfo);
    156 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface, 
     155static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface,
    157156                                              UINT      iTInfo,
    158                                               LCID        lcid, 
     157                                              LCID        lcid,
    159158                                              ITypeInfo** ppTInfo);
    160159static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch*  iface,
    161                                                 REFIID      riid, 
    162                                                 LPOLESTR* rgszNames, 
    163                                                 UINT      cNames, 
     160                                                REFIID      riid,
     161                                                LPOLESTR* rgszNames,
     162                                                UINT      cNames,
    164163                                                LCID        lcid,
    165164                                                DISPID*     rgDispId);
    166165static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch*  iface,
    167                                          DISPID      dispIdMember, 
    168                                          REFIID      riid, 
    169                                          LCID        lcid, 
     166                                         DISPID      dispIdMember,
     167                                         REFIID      riid,
     168                                         LCID        lcid,
    170169                                         WORD        wFlags,
    171170                                         DISPPARAMS* pDispParams,
    172                                          VARIANT*    pVarResult, 
     171                                         VARIANT*    pVarResult,
    173172                                         EXCEPINFO*  pExepInfo,
    174                                          UINT*     puArgErr); 
     173                                         UINT*     puArgErr);
    175174
    176175/***********************************************************************
     
    178177 * interface
    179178 */
    180 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 
    181                                                     REFIID     riid, 
     179static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
     180                                                    REFIID     riid,
    182181                                                    VOID**     ppvoid);
    183182static ULONG   WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
    184183static ULONG   WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
    185 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 
     184static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
    186185                                             CLSID*                pClassID);
    187186static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream*  iface);
     
    190189static HRESULT WINAPI OLEFontImpl_Save(IPersistStream*  iface,
    191190                                       IStream*         pOutStream,
    192                                        BOOL             fClearDirty); 
     191                                       BOOL             fClearDirty);
    193192static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream*  iface,
    194                                              ULARGE_INTEGER*  pcbSize); 
     193                                             ULARGE_INTEGER*  pcbSize);
    195194
    196195/***********************************************************************
     
    199198 */
    200199static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
    201                                             IConnectionPointContainer* iface, 
    202                                             REFIID     riid, 
     200                                            IConnectionPointContainer* iface,
     201                                            REFIID     riid,
    203202                                            VOID**     ppvoid);
    204203static ULONG   WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
     
    240239  OLEFontImpl_put_Charset,
    241240  OLEFontImpl_get_hFont,
    242   OLEFontImpl_Clone, 
     241  OLEFontImpl_Clone,
    243242  OLEFontImpl_IsEqual,
    244243  OLEFontImpl_SetRatio,
     
    347346
    348347  IConnectionPoint_EnumConnections(this->pCP, &pEnum);
    349  
     348
    350349  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
    351350    IPropertyNotifySink *sink;
     
    359358  return;
    360359}
    361  
     360
    362361/************************************************************************
    363362 * OLEFontImpl_Construct
     
    380379  if (newObject==0)
    381380    return newObject;
    382  
     381
    383382  /*
    384383   * Initialize the virtual function table.
     
    388387  newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
    389388  newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable;
    390  
    391   /*
    392    * Start with one reference count. The caller of this function 
     389
     390  /*
     391   * Start with one reference count. The caller of this function
    393392   * must release the interface pointer when it is done.
    394393   */
     
    402401  newObject->description.cbSizeofstruct = sizeof(FONTDESC);
    403402  newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
    404                                                0, 
     403                                               0,
    405404                                               (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
    406405  strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
     
    464463  if ( (this==0) || (ppvObject==0) )
    465464    return E_INVALIDARG;
    466  
     465
    467466  /*
    468467   * Initialize the return parameter.
    469468   */
    470469  *ppvObject = 0;
    471  
     470
    472471  /*
    473472   * Compare the riid with the interface IDs implemented by this object.
    474473   */
    475   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
     474  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
    476475  {
    477476    *ppvObject = (IFont*)this;
    478477  }
    479   else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 
     478  else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0)
    480479  {
    481480    *ppvObject = (IFont*)this;
    482481  }
    483   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
     482  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
    484483  {
    485484    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    486485  }
    487   else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 
     486  else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0)
    488487  {
    489488    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    490489  }
    491   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
     490  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
    492491  {
    493492    *ppvObject = (IPersistStream*)&(this->lpvtbl3);
    494493  }
    495494  else if (memcmp(&IID_IConnectionPointContainer, riid,
    496                   sizeof(IID_IConnectionPointContainer)) == 0) 
     495                  sizeof(IID_IConnectionPointContainer)) == 0)
    497496  {
    498497    *ppvObject = (IPersistStream*)&(this->lpvtbl4);
    499498  }
    500  
     499
    501500  /*
    502501   * Check that we obtained an interface.
     
    507506    return E_NOINTERFACE;
    508507  }
    509  
     508
    510509  /*
    511510   * Query Interface always increases the reference count by one when it is
     
    514513  OLEFontImpl_AddRef((IFont*)this);
    515514
    516   return S_OK;;
    517 }
    518        
     515  return S_OK;
     516}
     517
    519518/************************************************************************
    520519 * OLEFontImpl_AddRef (IUnknown)
     
    522521 * See Windows documentation for more details on IUnknown methods.
    523522 */
    524 ULONG WINAPI OLEFontImpl_AddRef( 
     523ULONG WINAPI OLEFontImpl_AddRef(
    525524  IFont* iface)
    526525{
     
    531530  return this->ref;
    532531}
    533        
     532
    534533/************************************************************************
    535534 * OLEFontImpl_Release (IUnknown)
     
    537536 * See Windows documentation for more details on IUnknown methods.
    538537 */
    539 ULONG WINAPI OLEFontImpl_Release( 
     538ULONG WINAPI OLEFontImpl_Release(
    540539      IFont* iface)
    541540{
     
    557556    return 0;
    558557  }
    559  
     558
    560559  return this->ref;
    561560}
    562        
     561
    563562/************************************************************************
    564563 * OLEFontImpl_get_Name (IFont)
     
    567566 */
    568567static HRESULT WINAPI OLEFontImpl_get_Name(
    569   IFont*  iface, 
     568  IFont*  iface,
    570569  BSTR* pname)
    571570{
     
    592591 */
    593592static HRESULT WINAPI OLEFontImpl_put_Name(
    594   IFont* iface, 
     593  IFont* iface,
    595594  BSTR name)
    596595{
     
    601600  {
    602601    this->description.lpstrName = HeapAlloc(GetProcessHeap(),
    603                                             0, 
     602                                            0,
    604603                                            (lstrlenW(name)+1) * sizeof(WCHAR));
    605604  }
     
    607606  {
    608607    this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
    609                                               0, 
     608                                              0,
    610609                                              this->description.lpstrName,
    611610                                              (lstrlenW(name)+1) * sizeof(WCHAR));
     
    627626 */
    628627static HRESULT WINAPI OLEFontImpl_get_Size(
    629   IFont* iface, 
     628  IFont* iface,
    630629  CY*    psize)
    631630{
     
    651650 */
    652651static HRESULT WINAPI OLEFontImpl_put_Size(
    653   IFont* iface, 
     652  IFont* iface,
    654653  CY     size)
    655654{
     
    669668 */
    670669static HRESULT WINAPI OLEFontImpl_get_Bold(
    671   IFont*  iface, 
     670  IFont*  iface,
    672671  BOOL* pbold)
    673672{
     
    708707 */
    709708static HRESULT WINAPI OLEFontImpl_get_Italic(
    710   IFont*  iface, 
     709  IFont*  iface,
    711710  BOOL* pitalic)
    712711{
     
    730729 */
    731730static HRESULT WINAPI OLEFontImpl_put_Italic(
    732   IFont* iface, 
     731  IFont* iface,
    733732  BOOL italic)
    734733{
     
    748747 */
    749748static HRESULT WINAPI OLEFontImpl_get_Underline(
    750   IFont*  iface, 
     749  IFont*  iface,
    751750  BOOL* punderline)
    752751{
     
    789788 */
    790789static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
    791   IFont*  iface, 
     790  IFont*  iface,
    792791  BOOL* pstrikethrough)
    793792{
     
    812811 */
    813812static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
    814  IFont* iface, 
     813 IFont* iface,
    815814 BOOL strikethrough)
    816815{
     
    830829 */
    831830static HRESULT WINAPI OLEFontImpl_get_Weight(
    832   IFont* iface, 
     831  IFont* iface,
    833832  short* pweight)
    834833{
     
    853852 */
    854853static HRESULT WINAPI OLEFontImpl_put_Weight(
    855   IFont* iface, 
     854  IFont* iface,
    856855  short  weight)
    857856{
     
    871870 */
    872871static HRESULT WINAPI OLEFontImpl_get_Charset(
    873   IFont* iface, 
     872  IFont* iface,
    874873  short* pcharset)
    875874{
     
    894893 */
    895894static HRESULT WINAPI OLEFontImpl_put_Charset(
    896   IFont* iface, 
     895  IFont* iface,
    897896  short charset)
    898897{
     
    928927    INT      fontHeight;
    929928    CY       cySize;
    930    
     929
    931930    /*
    932931     * The height of the font returned by the get_Size property is the
     
    959958
    960959  *phfont = this->gdiFont;
    961   TRACE("Returning %08x\n", *phfont);
     960  TRACE("Returning %p\n", *phfont);
    962961  return S_OK;
    963962}
     
    10011000        (1+strlenW(this->description.lpstrName))*2
    10021001  );
     1002  strcpyW(newObject->description.lpstrName, this->description.lpstrName);
    10031003  /* We need to clone the HFONT too. This is just cut & paste from above */
    10041004  IFont_get_Size(iface, &cySize);
     
    10391039 */
    10401040static HRESULT WINAPI OLEFontImpl_IsEqual(
    1041   IFont* iface, 
     1041  IFont* iface,
    10421042  IFont* pFontOther)
    10431043{
     
    10711071 */
    10721072static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics(
    1073   IFont*         iface, 
     1073  IFont*         iface,
    10741074  TEXTMETRICOLE* ptm)
    10751075{
     
    10841084 */
    10851085static HRESULT WINAPI OLEFontImpl_AddRefHfont(
    1086   IFont*  iface, 
     1086  IFont*  iface,
    10871087  HFONT hfont)
    10881088{
    10891089  _ICOM_THIS(OLEFontImpl, iface);
    1090   TRACE("(%p)->(%08x) (lock=%ld)\n", this, hfont, this->fontLock);
     1090  TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
    10911091
    10921092  if ( (hfont == 0) ||
     
    11091109{
    11101110  _ICOM_THIS(OLEFontImpl, iface);
    1111   TRACE("(%p)->(%08x) (lock=%ld)\n", this, hfont, this->fontLock);
     1111  TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
    11121112
    11131113  if ( (hfont == 0) ||
     
    11231123  {
    11241124    DeleteObject(this->gdiFont);
    1125     this->gdiFont = 0; 
     1125    this->gdiFont = 0;
    11261126  }
    11271127
     
    11391139{
    11401140  _ICOM_THIS(OLEFontImpl, iface);
    1141   FIXME("(%p)->(%08x): Stub\n", this, hdc);
     1141  FIXME("(%p)->(%p): Stub\n", this, hdc);
    11421142  return E_NOTIMPL;
    11431143}
     
    11901190 */
    11911191static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
    1192   IDispatch*    iface, 
     1192  IDispatch*    iface,
    11931193  unsigned int* pctinfo)
    11941194{
     
    12051205 */
    12061206static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
    1207   IDispatch*  iface, 
     1207  IDispatch*  iface,
    12081208  UINT      iTInfo,
    1209   LCID        lcid, 
     1209  LCID        lcid,
    12101210  ITypeInfo** ppTInfo)
    12111211{
     
    12231223static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
    12241224  IDispatch*  iface,
    1225   REFIID      riid, 
    1226   LPOLESTR* rgszNames, 
    1227   UINT      cNames, 
     1225  REFIID      riid,
     1226  LPOLESTR* rgszNames,
     1227  UINT      cNames,
    12281228  LCID        lcid,
    12291229  DISPID*     rgDispId)
     
    12421242static HRESULT WINAPI OLEFontImpl_Invoke(
    12431243  IDispatch*  iface,
    1244   DISPID      dispIdMember, 
    1245   REFIID      riid, 
    1246   LCID        lcid, 
     1244  DISPID      dispIdMember,
     1245  REFIID      riid,
     1246  LCID        lcid,
    12471247  WORD        wFlags,
    12481248  DISPPARAMS* pDispParams,
    1249   VARIANT*    pVarResult, 
     1249  VARIANT*    pVarResult,
    12501250  EXCEPINFO*  pExepInfo,
    12511251  UINT*     puArgErr)
     
    13051305 */
    13061306static HRESULT WINAPI OLEFontImpl_GetClassID(
    1307   IPersistStream* iface, 
     1307  IPersistStream* iface,
    13081308  CLSID*                pClassID)
    13091309{
     
    13601360
    13611361  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    1362  
     1362
    13631363  /*
    13641364   * Read the version byte
     
    13891389  this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
    13901390  this->description.fUnderline     = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
    1391    
     1391
    13921392  /*
    13931393   * Weight
     
    14281428  MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
    14291429  this->description.lpstrName[len] = 0;
     1430
     1431  /* Ensure use of this font causes a new one to be created @@@@ */
     1432  DeleteObject(this->gdiFont);
     1433  this->gdiFont = 0;
    14301434
    14311435  return S_OK;
     
    14471451  BYTE  bAttributes;
    14481452  BYTE  bStringSize;
    1449  
     1453
    14501454  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    14511455
     
    14761480  if (this->description.fStrikethrough)
    14771481    bAttributes |= FONTPERSIST_STRIKETHROUGH;
    1478  
     1482
    14791483  if (this->description.fUnderline)
    14801484    bAttributes |= FONTPERSIST_UNDERLINE;
     
    14841488  if (cbWritten!=1)
    14851489    return E_FAIL;
    1486  
     1490
    14871491  /*
    14881492   * Weight
     
    16521656} IClassFactoryImpl;
    16531657
    1654 static HRESULT WINAPI 
     1658static HRESULT WINAPI
    16551659SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
    16561660        ICOM_THIS(IClassFactoryImpl,iface);
  • trunk/src/oleaut32/olepicture.c

    r8450 r9400  
    3838#include "config.h"
    3939
    40 #include <unistd.h>
     40#ifdef HAVE_UNISTD_H
     41# include <unistd.h>
     42#endif
    4143#include <stdio.h>
    4244#include <string.h>
     
    5860#ifdef HAVE_LIBJPEG
    5961/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
    60 #define XMD_H
     62#define XMD_H
     63#define UINT8 JPEG_UINT8
    6164#define UINT16 JPEG_UINT16
    6265#ifdef HAVE_JPEGLIB_H
     
    8891  /* We own the object and must destroy it ourselves */
    8992    BOOL fOwn;
    90  
     93
    9194  /* Picture description */
    9295    PICTDESC desc;
     
    104107    BOOL keepOrigFormat;
    105108    HDC hDCCur;
     109
     110  /* data */
     111    void* data;
     112    int datalen;
    106113} OLEPictureImpl;
    107114
     
    132139  HDC hdcRef;
    133140
    134   TRACE("bitmap handle %08x\n", This->desc.u.bmp.hbitmap);
     141  TRACE("bitmap handle %p\n", This->desc.u.bmp.hbitmap);
    135142  if(GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
    136143    ERR("GetObject fails\n");
     
    168175   * Allocate space for the object.
    169176   */
    170   newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEPictureImpl));
     177  newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl));
    171178
    172179  if (newObject==0)
    173180    return newObject;
    174  
     181
    175182  /*
    176183   * Initialize the virtual function table.
     
    184191
    185192  /*
    186    * Start with one reference count. The caller of this function 
     193   * Start with one reference count. The caller of this function
    187194   * must release the interface pointer when it is done.
    188195   */
     
    208215
    209216      case PICTYPE_METAFILE:
    210         TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
     217        TRACE("metafile handle %p\n", pictDesc->u.wmf.hmeta);
    211218        newObject->himetricWidth = pictDesc->u.wmf.xExt;
    212219        newObject->himetricHeight = pictDesc->u.wmf.yExt;
     
    223230      newObject->desc.picType = PICTYPE_UNINITIALIZED;
    224231  }
    225    
     232
    226233  TRACE("returning %p\n", newObject);
    227234  return newObject;
     
    235242 * this object.  */
    236243static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj)
    237 { 
     244{
    238245  TRACE("(%p)\n", Obj);
    239246
     
    257264    }
    258265  }
     266  if (Obj->data) HeapFree(GetProcessHeap(), 0, Obj->data);
    259267  HeapFree(GetProcessHeap(), 0, Obj);
    260268}
     
    280288  if ( (This==0) || (ppvObject==0) )
    281289    return E_INVALIDARG;
    282  
     290
    283291  /*
    284292   * Initialize the return parameter.
    285293   */
    286294  *ppvObject = 0;
    287  
     295
    288296  /*
    289297   * Compare the riid with the interface IDs implemented by this object.
    290298   */
    291   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
     299  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
    292300  {
    293301    *ppvObject = (IPicture*)This;
    294302  }
    295   else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0) 
     303  else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0)
    296304  {
    297305    *ppvObject = (IPicture*)This;
    298306  }
    299   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
     307  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
    300308  {
    301309    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    302310  }
    303   else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0) 
     311  else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0)
    304312  {
    305313    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    306314  }
    307   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
     315  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
    308316  {
    309317  *ppvObject = (IPersistStream*)&(This->lpvtbl3);
    310318  }
    311   else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0) 
     319  else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0)
    312320  {
    313321  *ppvObject = (IConnectionPointContainer*)&(This->lpvtbl4);
     
    321329    return E_NOINTERFACE;
    322330  }
    323  
     331
    324332  /*
    325333   * Query Interface always increases the reference count by one when it is
     
    328336  OLEPictureImpl_AddRef((IPicture*)This);
    329337
    330   return S_OK;;
     338  return S_OK;
    331339}
    332340/***********************************************************************
     
    360368 * See Windows documentation for more details on IUnknown methods.
    361369 */
    362 static ULONG WINAPI OLEPictureImpl_AddRef( 
     370static ULONG WINAPI OLEPictureImpl_AddRef(
    363371  IPicture* iface)
    364372{
     
    369377  return This->ref;
    370378}
    371        
     379
    372380/************************************************************************
    373381 * OLEPictureImpl_Release (IUnknown)
     
    375383 * See Windows documentation for more details on IUnknown methods.
    376384 */
    377 static ULONG WINAPI OLEPictureImpl_Release( 
     385static ULONG WINAPI OLEPictureImpl_Release(
    378386      IPicture* iface)
    379387{
     
    395403    return 0;
    396404  }
    397  
     405
    398406  return This->ref;
    399407}
     
    402410/************************************************************************
    403411 * OLEPictureImpl_get_Handle
    404  */ 
     412 */
    405413static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface,
    406414                                                OLE_HANDLE *phandle)
     
    410418  switch(This->desc.picType) {
    411419  case PICTYPE_BITMAP:
    412     *phandle = This->desc.u.bmp.hbitmap;
     420    *phandle = (OLE_HANDLE)This->desc.u.bmp.hbitmap;
    413421    break;
    414422  case PICTYPE_METAFILE:
    415     *phandle = This->desc.u.wmf.hmeta;
     423    *phandle = (OLE_HANDLE)This->desc.u.wmf.hmeta;
    416424    break;
    417425  case PICTYPE_ICON:
    418     *phandle = This->desc.u.icon.hicon;
     426    *phandle = (OLE_HANDLE)This->desc.u.icon.hicon;
    419427    break;
    420428  case PICTYPE_ENHMETAFILE:
    421     *phandle = This->desc.u.emf.hemf;
     429    *phandle = (OLE_HANDLE)This->desc.u.emf.hemf;
    422430    break;
    423431  default:
     
    431439/************************************************************************
    432440 * OLEPictureImpl_get_hPal
    433  */ 
     441 */
    434442static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface,
    435443                                              OLE_HANDLE *phandle)
     
    442450/************************************************************************
    443451 * OLEPictureImpl_get_Type
    444  */ 
     452 */
    445453static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface,
    446454                                              short *ptype)
     
    454462/************************************************************************
    455463 * OLEPictureImpl_get_Width
    456  */ 
     464 */
    457465static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface,
    458466                                               OLE_XSIZE_HIMETRIC *pwidth)
     
    466474/************************************************************************
    467475 * OLEPictureImpl_get_Height
    468  */ 
     476 */
    469477static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface,
    470478                                                OLE_YSIZE_HIMETRIC *pheight)
     
    478486/************************************************************************
    479487 * OLEPictureImpl_Render
    480  */ 
     488 */
    481489static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc,
    482490                                            long x, long y, long cx, long cy,
     
    488496{
    489497  ICOM_THIS(OLEPictureImpl, iface);
    490   TRACE("(%p)->(%08x, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n",
     498  TRACE("(%p)->(%p, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n",
    491499        This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
    492500  if(prcWBounds)
     
    540548/************************************************************************
    541549 * OLEPictureImpl_set_hPal
    542  */ 
     550 */
    543551static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface,
    544552                                              OLE_HANDLE hpal)
     
    552560/************************************************************************
    553561 * OLEPictureImpl_get_CurDC
    554  */ 
     562 */
    555563static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface,
    556564                                               HDC *phdc)
    557565{
    558566  ICOM_THIS(OLEPictureImpl, iface);
    559   TRACE("(%p), returning %x\n", This, This->hDCCur);
     567  TRACE("(%p), returning %p\n", This, This->hDCCur);
    560568  if (phdc) *phdc = This->hDCCur;
    561569  return S_OK;
     
    564572/************************************************************************
    565573 * OLEPictureImpl_SelectPicture
    566  */ 
     574 */
    567575static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface,
    568576                                                   HDC hdcIn,
     
    571579{
    572580  ICOM_THIS(OLEPictureImpl, iface);
    573   TRACE("(%p)->(%08x, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
     581  TRACE("(%p)->(%p, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
    574582  if (This->desc.picType == PICTYPE_BITMAP) {
    575583      SelectObject(hdcIn,This->desc.u.bmp.hbitmap);
     
    579587      This->hDCCur = hdcIn;
    580588      if (phbmpOut)
    581           *phbmpOut = This->desc.u.bmp.hbitmap;
     589          *phbmpOut = (OLE_HANDLE)This->desc.u.bmp.hbitmap;
    582590      return S_OK;
    583591  } else {
     
    589597/************************************************************************
    590598 * OLEPictureImpl_get_KeepOriginalFormat
    591  */ 
     599 */
    592600static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface,
    593601                                                            BOOL *pfKeep)
     
    603611/************************************************************************
    604612 * OLEPictureImpl_put_KeepOriginalFormat
    605  */ 
     613 */
    606614static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface,
    607615                                                            BOOL keep)
     
    616624/************************************************************************
    617625 * OLEPictureImpl_PictureChanged
    618  */ 
     626 */
    619627static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
    620628{
     
    627635/************************************************************************
    628636 * OLEPictureImpl_SaveAsFile
    629  */ 
     637 */
    630638static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
    631639                                                IStream *pstream,
     
    634642{
    635643  ICOM_THIS(OLEPictureImpl, iface);
    636   FIXME("(%p)->(%p, %d, %p): stub\n", This, pstream, SaveMemCopy, pcbSize);
    637   return E_NOTIMPL;
     644  FIXME("(%p)->(%p, %d, %p), hacked stub.\n", This, pstream, SaveMemCopy, pcbSize);
     645  return IStream_Write(pstream,This->data,This->datalen,(ULONG*)pcbSize);
    638646}
    639647
    640648/************************************************************************
    641649 * OLEPictureImpl_get_Attributes
    642  */ 
     650 */
    643651static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface,
    644652                                                    DWORD *pdwAttr)
     
    704712  ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl, iface);
    705713  TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
    706   if (!ppCP) 
     714  if (!ppCP)
    707715      return E_POINTER;
    708716  *ppCP = NULL;
     
    824832  }
    825833  xread = 0;
    826   xbuf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
     834  xbuf = This->data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
     835  This->datalen = header[1];
    827836  while (xread < header[1]) {
    828     ULONG nread; 
     837    ULONG nread;
    829838    hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread);
    830839    xread+=nread;
     
    9981007    break;
    9991008  }
    1000   HeapFree(GetProcessHeap(),0,xbuf);
    10011009
    10021010  /* FIXME: this notify is not really documented */
     
    10721080 */
    10731081static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount(
    1074   IDispatch*    iface, 
     1082  IDispatch*    iface,
    10751083  unsigned int* pctinfo)
    10761084{
     
    10861094 */
    10871095static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(
    1088   IDispatch*  iface, 
     1096  IDispatch*  iface,
    10891097  UINT      iTInfo,
    1090   LCID        lcid, 
     1098  LCID        lcid,
    10911099  ITypeInfo** ppTInfo)
    10921100{
     
    11031111static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames(
    11041112  IDispatch*  iface,
    1105   REFIID      riid, 
    1106   LPOLESTR* rgszNames, 
    1107   UINT      cNames, 
     1113  REFIID      riid,
     1114  LPOLESTR* rgszNames,
     1115  UINT      cNames,
    11081116  LCID        lcid,
    11091117  DISPID*     rgDispId)
     
    11211129static HRESULT WINAPI OLEPictureImpl_Invoke(
    11221130  IDispatch*  iface,
    1123   DISPID      dispIdMember, 
    1124   REFIID      riid, 
    1125   LCID        lcid, 
     1131  DISPID      dispIdMember,
     1132  REFIID      riid,
     1133  LCID        lcid,
    11261134  WORD        wFlags,
    11271135  DISPPARAMS* pDispParams,
    1128   VARIANT*    pVarResult, 
     1136  VARIANT*    pVarResult,
    11291137  EXCEPINFO*  pExepInfo,
    11301138  UINT*     puArgErr)
     
    12711279
    12721280/***********************************************************************
    1273  * OleLoadPictureEx (OLEAUT32.425)
     1281 * OleLoadPictureEx (OLEAUT32.401)
    12741282 */
    12751283HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
    1276                             REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
    1277 {
    1278   FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n",
    1279         lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
    1280   return S_OK;
    1281 }
    1282  
     1284                            REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
     1285{
     1286  LPPERSISTSTREAM ps;
     1287  IPicture      *newpic;
     1288  HRESULT hr;
     1289
     1290  FIXME("(%p,%ld,%d,%s,x=%ld,y=%ld,f=%lx,%p), partially implemented.\n",
     1291        lpstream, lSize, fRunmode, debugstr_guid(riid), xsiz, ysiz, flags, ppvObj);
     1292
     1293  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
     1294  if (hr)
     1295    return hr;
     1296  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
     1297  if (hr) {
     1298      FIXME("Could not get IPersistStream iface from Ole Picture?\n");
     1299      IPicture_Release(newpic);
     1300      *ppvObj = NULL;
     1301      return hr;
     1302  }
     1303  IPersistStream_Load(ps,lpstream);
     1304  IPersistStream_Release(ps);
     1305  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
     1306  if (hr)
     1307      FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
     1308  IPicture_Release(newpic);
     1309  return hr;
     1310}
  • trunk/src/oleaut32/parsedt.c

    r8450 r9400  
    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; 
     71int     DateStyle;
    7272bool    EuroDates;
    7373int     CTimeZone;
     
    8080#define UTIME_MAXDAY (18)
    8181
     82/* Assumes month in 1..12. Note tm_mon is 0..11 */
    8283#define IS_VALID_UTIME(y,m,d) (((y > UTIME_MINYEAR) \
    8384 || ((y == UTIME_MINYEAR) && ((m > UTIME_MINMONTH) \
     
    601602                                                printf("DecodeDateTime- month field %s value is %d\n", field[i], val);
    602603#endif
    603                                                 tm->tm_mon = val;
     604                        /* tm_mon is 0->11, so need to subtract one from value in table */
     605                                                tm->tm_mon = val-1;
    604606                                                break;
    605607
     
    681683                tm->tm_hour += 12;
    682684
     685    /* If parsing a time string into a date, all date parts are unset.
     686       Win2k defaults these to 30 dec, 1899 so:                        */
     687    if (tm->tm_year == 0 && tm->tm_mon == 0 && tm->tm_mday == 0 && fmask == DTK_TIME_M) {
     688        tm->tm_year  = 1899;
     689        tm->tm_mon   = 11; /* December, as tm_mon is 0..11 */
     690        tm->tm_mday  = 30;
     691    }
     692
     693
    683694#ifdef DATEDEBUG
    684695        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);
     696        printf(" set y%04d m%02d d%02d", tm->tm_year, (tm->tm_mon+1), tm->tm_mday);
    686697        printf(" %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
    687698#endif
     
    702713                        return -1;
    703714
    704                 if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
     715                if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon+1, tm->tm_mday))
    705716                {
    706717                        /* FIXME: The code below is not correct */
     
    910921                                        printf("DecodeDate- month field %s value is %d\n", field[i], val);
    911922#endif
    912                                         tm->tm_mon = val;
     923                    /* tm_mon is 0->11, so need to subtract one from value in table */
     924                                        tm->tm_mon = val-1;
    913925                                        break;
    914926
     
    10761088#endif
    10771089                *tmask = DTK_M(MONTH);
    1078                 tm->tm_mon = val;
     1090        /* tm_mon is 0..11 */
     1091                tm->tm_mon = val-1;
    10791092
    10801093                /* no year and EuroDates enabled? then could be day */
     
    10981111#endif
    10991112                *tmask = DTK_M(MONTH);
    1100                 tm->tm_mon = val;
     1113        /* tm_mon is 0..11 */
     1114                tm->tm_mon = val-1;
    11011115
    11021116        }
     
    11501164                tm->tm_mday = atoi(str + 6);
    11511165                *(str + 6) = '\0';
    1152                 tm->tm_mon = atoi(str + 4);
     1166                tm->tm_mon = atoi(str + 4) - 1;  /* tm_mon is 0..11 */
    11531167                *(str + 4) = '\0';
    11541168                tm->tm_year = atoi(str + 0);
     
    11821196                        tm->tm_mday = atoi(str + 4);
    11831197                        *(str + 4) = '\0';
    1184                         tm->tm_mon = atoi(str + 2);
     1198                        tm->tm_mon = atoi(str + 2) - 1; /* tm_mon is 0..11 */
    11851199                        *(str + 2) = '\0';
    11861200                        tm->tm_year = atoi(str + 0);
     
    13311345        return NULL;
    13321346}
    1333 
    1334 
    1335 
  • trunk/src/oleaut32/safearray.c

    r8450 r9400  
    2525#define WINE_LARGE_INTEGER
    2626#include "oleaut32.h"
    27 
    2827#endif
    2928
     
    4241
    4342/* Locally used methods */
    44 static INT 
     43static INT
    4544endOfDim(LONG *coor, SAFEARRAYBOUND *mat, LONG dim, LONG realDim);
    4645
    47 static ULONG   
     46static ULONG
    4847calcDisplacement(LONG *coor, SAFEARRAYBOUND *mat, LONG dim);
    4948
    50 static BOOL 
     49static BOOL
    5150isPointer(USHORT feature);
    5251
    53 static INT   
     52static INT
    5453getFeatures(VARTYPE vt);
    5554
    56 static BOOL 
     55static BOOL
    5756validCoordinate(LONG *coor, SAFEARRAY *psa);
    5857
    59 static BOOL 
     58static BOOL
    6059resizeSafeArray(SAFEARRAY *psa, LONG lDelta);
    6160
    62 static BOOL 
     61static BOOL
    6362validArg(SAFEARRAY *psa);
    6463
    65 static ULONG   
     64static ULONG
    6665getArraySize(SAFEARRAY *psa);
    6766
    68 static HRESULT 
     67static HRESULT
    6968duplicateData(SAFEARRAY *psa, SAFEARRAY **ppsaOut);
    7069
     
    129128 * Allocate the appropriate amount of memory for the SafeArray descriptor
    130129 */
    131 HRESULT WINAPI SafeArrayAllocDescriptor( 
    132   UINT    cDims, 
    133   SAFEARRAY **ppsaOut) 
     130HRESULT WINAPI SafeArrayAllocDescriptor(
     131  UINT    cDims,
     132  SAFEARRAY **ppsaOut)
    134133{
    135134  SAFEARRAYBOUND *sab;
     
    141140
    142141  /* Allocate memory for SAFEARRAY struc */
    143   if(( (*ppsaOut)=HeapAlloc( 
     142  if(( (*ppsaOut)=HeapAlloc(
    144143        GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize)) == NULL){
    145144    return(E_UNEXPECTED);
     
    151150
    152151/*************************************************************************
    153  *              SafeArrayAllocDescriptorEx (OLEAUT32.429)
     152 *              SafeArrayAllocDescriptorEx (OLEAUT32.41)
    154153 * Allocate the appropriate amount of memory for the SafeArray descriptor
    155154 *
     
    158157 * The MSDN documentation on this doesn't tell us much.
    159158 */
    160 HRESULT WINAPI SafeArrayAllocDescriptorEx( 
     159HRESULT WINAPI SafeArrayAllocDescriptorEx(
    161160  VARTYPE vt,
    162   UINT    cDims, 
    163   SAFEARRAY **ppsaOut) 
     161  UINT    cDims,
     162  SAFEARRAY **ppsaOut)
    164163{
    165164  if ( (vt >= LAST_VARTYPE) ||
     
    175174 */
    176175HRESULT WINAPI SafeArrayAllocData(
    177   SAFEARRAY *psa) 
     176  SAFEARRAY *psa)
    178177{
    179178  ULONG  ulWholeArraySize;   /* to store the size of the whole thing */
    180179
    181   if(! validArg(psa)) 
     180  if(! validArg(psa))
    182181    return E_INVALIDARG;
    183182
     
    185184
    186185  /* Allocate memory for the data itself */
    187   if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 
     186  if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
    188187        psa->cbElements*ulWholeArraySize)) == NULL)
    189188    return(E_UNEXPECTED);
    190189
    191   TRACE("SafeArray: %lu bytes allocated for data at %p (%lu objects).\n", 
     190  TRACE("SafeArray: %lu bytes allocated for data at %p (%lu objects).\n",
    192191    psa->cbElements*ulWholeArraySize, psa->pvData, ulWholeArraySize);
    193192
     
    197196/*************************************************************************
    198197 *              SafeArrayCreate (OLEAUT32.15)
    199  * Create a SafeArray object by encapsulating AllocDescriptor and AllocData 
     198 * Create a SafeArray object by encapsulating AllocDescriptor and AllocData
    200199 */
    201200SAFEARRAY* WINAPI SafeArrayCreate(
    202   VARTYPE        vt, 
    203   UINT         cDims, 
     201  VARTYPE        vt,
     202  UINT         cDims,
    204203  SAFEARRAYBOUND *rgsabound)
    205204{
     
    217216    return NULL;
    218217
    219   /* setup data members... */ 
     218  /* setup data members... */
    220219  psa->cDims     = cDims;
    221220  psa->fFeatures = getFeatures(vt);
     
    230229  }
    231230
    232   /* allocate memory for the data... */ 
     231  /* allocate memory for the data... */
    233232  if( FAILED( hRes = SafeArrayAllocData(psa))) {
    234     SafeArrayDestroyDescriptor(psa); 
     233    SafeArrayDestroyDescriptor(psa);
    235234    ERR("() : Failed to allocate the Safe Array data\n");
    236235    return NULL;
    237236  }
    238237
    239   return(psa); 
     238  return(psa);
    240239}
    241240
     
    248247{
    249248  /* Check for lockness before to free... */
    250   if(psa->cLocks > 0) 
     249  if(psa->cLocks > 0)
    251250    return DISP_E_ARRAYISLOCKED;
    252251
    253252  /* The array is unlocked, then, deallocate memory */
    254   if(HeapFree( GetProcessHeap(), 0, psa) == FALSE) 
     253  if(HeapFree( GetProcessHeap(), 0, psa) == FALSE)
    255254    return E_UNEXPECTED;
    256  
     255
    257256  return(S_OK);
    258257}
     
    264263 *
    265264 * Doc says (MSDN Library ) that psa->pvData should be made available (!= NULL)
    266  * only when psa->cLocks is > 0... I don't get it since pvData is allocated 
    267  * before the array is locked, therefore 
     265 * only when psa->cLocks is > 0... I don't get it since pvData is allocated
     266 * before the array is locked, therefore
    268267 */
    269268HRESULT WINAPI SafeArrayLock(
    270269  SAFEARRAY *psa)
    271270{
    272   if(! validArg(psa))     
     271  if(! validArg(psa))
    273272    return E_INVALIDARG;
    274273
     
    285284  SAFEARRAY *psa)
    286285{
    287   if(! validArg(psa)) 
    288     return E_INVALIDARG;
    289 
    290   if (psa->cLocks > 0) 
     286  if(! validArg(psa))
     287    return E_INVALIDARG;
     288
     289  if (psa->cLocks > 0)
    291290    psa->cLocks--;
    292291
     
    300299 */
    301300HRESULT WINAPI SafeArrayPutElement(
    302   SAFEARRAY *psa, 
    303   LONG      *rgIndices, 
     301  SAFEARRAY *psa,
     302  LONG      *rgIndices,
    304303  void      *pv)
    305304{
    306   ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to 
     305  ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to
    307306                                         the desired one... */
    308307  PVOID elementStorageAddress = NULL; /* Adress to store the data */
    309308
    310309  /* Validate the index given */
    311   if(! validCoordinate(rgIndices, psa)) 
     310  if(! validCoordinate(rgIndices, psa))
    312311    return DISP_E_BADINDEX;
    313312  if(! validArg(psa))
     
    318317    /* Figure out the number of items to skip */
    319318    stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    320  
     319
    321320    /* Figure out the number of byte to skip ... */
    322321    elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    323  
     322
    324323    if(isPointer(psa->fFeatures)) { /* increment ref count for this pointer */
    325324
    326       *((PVOID*)elementStorageAddress) = *(PVOID*)pv; 
     325      *((PVOID*)elementStorageAddress) = *(PVOID*)pv;
    327326      IUnknown_AddRef( *(IUnknown**)pv);
    328327
    329     } else { 
     328    } else {
    330329
    331330      if(psa->fFeatures == FADF_BSTR) { /* Create a new object */
     
    333332        if(pv &&
    334333           ((pbstrReAllocStr = SYSDUPSTRING( (OLECHAR*)pv )) == NULL)) {
    335           SafeArrayUnlock(psa); 
     334          SafeArrayUnlock(psa);
    336335          return E_OUTOFMEMORY;
    337         } else 
     336        } else
    338337          *((BSTR*)elementStorageAddress) = pbstrReAllocStr;
    339338      }
     
    355354
    356355  TRACE("SafeArray: item put at adress %p.\n",elementStorageAddress);
    357   return SafeArrayUnlock(psa); 
     356  return SafeArrayUnlock(psa);
    358357}
    359358
     
    364363 */
    365364HRESULT WINAPI SafeArrayGetElement(
    366   SAFEARRAY *psa, 
    367   LONG      *rgIndices, 
     365  SAFEARRAY *psa,
     366  LONG      *rgIndices,
    368367  void      *pv)
    369368{
    370   ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to 
     369  ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to
    371370                                         the desired one... */
    372371  PVOID elementStorageAddress = NULL; /* Adress to store the data */
    373372
    374   if(! validArg(psa)) 
    375     return E_INVALIDARG;
    376  
     373  if(! validArg(psa))
     374    return E_INVALIDARG;
     375
    377376  if(! validCoordinate(rgIndices, psa)) /* Validate the index given */
    378377    return(DISP_E_BADINDEX);
     
    382381    /* Figure out the number of items to skip */
    383382    stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    384  
     383
    385384    /* Figure out the number of byte to skip ... */
    386385    elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    387  
     386
    388387    if( psa->fFeatures == FADF_BSTR) {           /* reallocate the obj */
    389388      BSTR pbstrStoredStr = *(OLECHAR**)elementStorageAddress;
     
    393392        SafeArrayUnlock(psa);
    394393        return E_OUTOFMEMORY;
    395       } else 
    396         *((BSTR*)pv) = pbstrReturnedStr; 
     394      } else
     395        *((BSTR*)pv) = pbstrReturnedStr;
    397396    }
    398397    else if( psa->fFeatures == FADF_VARIANT) {
     
    406405    }
    407406    else if( isPointer(psa->fFeatures) )         /* simply copy the pointer */
    408       *(PVOID*)pv = *((PVOID*)elementStorageAddress); 
     407      *(PVOID*)pv = *((PVOID*)elementStorageAddress);
    409408    else                                         /* copy the bytes */
    410409      memcpy(pv, elementStorageAddress, psa->cbElements );
     
    415414  }
    416415
    417   return( SafeArrayUnlock(psa) ); 
     416  return( SafeArrayUnlock(psa) );
    418417}
    419418
     
    423422 */
    424423HRESULT WINAPI SafeArrayGetUBound(
    425   SAFEARRAY *psa, 
     424  SAFEARRAY *psa,
    426425  UINT    nDim,
    427426  LONG      *plUbound)
    428427{
    429   if(! validArg(psa))   
    430     return E_INVALIDARG;
    431 
    432   if(nDim > psa->cDims) 
     428  if(! validArg(psa))
     429    return E_INVALIDARG;
     430
     431  if(nDim > psa->cDims)
    433432    return DISP_E_BADINDEX;
    434433
     
    436435    return DISP_E_BADINDEX;
    437436
    438   *plUbound = psa->rgsabound[nDim-1].lLbound + 
     437  *plUbound = psa->rgsabound[nDim-1].lLbound +
    439438              psa->rgsabound[nDim-1].cElements - 1;
    440439
     
    444443/*************************************************************************
    445444 *              SafeArrayGetLBound (OLEAUT32.20)
    446  * Return the LO bound for a given array dimension 
     445 * Return the LO bound for a given array dimension
    447446 */
    448447HRESULT WINAPI SafeArrayGetLBound(
    449448  SAFEARRAY *psa,
    450   UINT    nDim, 
     449  UINT    nDim,
    451450  LONG      *plLbound)
    452451{
    453   if(! validArg(psa))   
    454     return E_INVALIDARG;
    455 
    456   if(nDim > psa->cDims) 
     452  if(! validArg(psa))
     453    return E_INVALIDARG;
     454
     455  if(nDim > psa->cDims)
    457456    return DISP_E_BADINDEX;
    458457
    459458  if(0 == nDim)
    460459    return DISP_E_BADINDEX;
    461  
     460
    462461  *plLbound = psa->rgsabound[nDim-1].lLbound;
    463462  return S_OK;
     
    470469UINT WINAPI SafeArrayGetDim(
    471470  SAFEARRAY * psa)
    472 { 
     471{
    473472  /*
    474473   * A quick test in Windows shows that the behavior here for an invalid
    475474   * pointer is to return 0.
    476475   */
    477   if(! validArg(psa)) 
     476  if(! validArg(psa))
    478477    return 0;
    479478
     
    487486UINT WINAPI SafeArrayGetElemsize(
    488487  SAFEARRAY * psa)
    489 { 
     488{
    490489  /*
    491490   * A quick test in Windows shows that the behavior here for an invalid
    492491   * pointer is to return 0.
    493492   */
    494   if(! validArg(psa)) 
     493  if(! validArg(psa))
    495494    return 0;
    496495
     
    500499/*************************************************************************
    501500 *              SafeArrayAccessData (OLEAUT32.23)
    502  * increment the access count and return the data 
     501 * increment the access count and return the data
    503502 */
    504503HRESULT WINAPI SafeArrayAccessData(
    505   SAFEARRAY *psa, 
     504  SAFEARRAY *psa,
    506505  void      **ppvData)
    507 { 
     506{
    508507  HRESULT hRes;
    509508
    510   if(! validArg(psa)) 
     509  if(! validArg(psa))
    511510    return E_INVALIDARG;
    512511
     
    514513
    515514  switch (hRes) {
    516     case S_OK: 
     515    case S_OK:
    517516      (*ppvData) = psa->pvData;
    518517      break;
     
    521520      return E_INVALIDARG;
    522521  }
    523  
     522
    524523  return S_OK;
    525524}
     
    532531HRESULT WINAPI SafeArrayUnaccessData(
    533532  SAFEARRAY * psa)
    534 { 
    535   if(! validArg(psa)) 
     533{
     534  if(! validArg(psa))
    536535    return E_INVALIDARG;
    537536
     
    539538}
    540539
    541 /************************************************************************ 
     540/************************************************************************
    542541 *              SafeArrayPtrOfIndex (OLEAUT32.148)
    543542 * Return a pointer to the element at rgIndices
    544543 */
    545544HRESULT WINAPI SafeArrayPtrOfIndex(
    546   SAFEARRAY *psa, 
    547   LONG      *rgIndices, 
     545  SAFEARRAY *psa,
     546  LONG      *rgIndices,
    548547  void      **ppvData)
    549 { 
    550   ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to 
     548{
     549  ULONG stepCountInSAData     = 0;    /* Number of array item to skip to get to
    551550                                         the desired one... */
    552551
    553   if(! validArg(psa))                   
    554     return E_INVALIDARG;
    555 
    556   if(! validCoordinate(rgIndices, psa)) 
     552  if(! validArg(psa))
     553    return E_INVALIDARG;
     554
     555  if(! validCoordinate(rgIndices, psa))
    557556    return DISP_E_BADINDEX;
    558557
     
    563562  /* Figure out the number of items to skip */
    564563  stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    565  
     564
    566565  *ppvData = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    567566
     
    569568}
    570569
    571 /************************************************************************ 
     570/************************************************************************
    572571 *              SafeArrayDestroyData (OLEAUT32.39)
    573572 * Frees the memory data bloc
     
    575574HRESULT WINAPI SafeArrayDestroyData(
    576575  SAFEARRAY *psa)
    577 { 
     576{
    578577  HRESULT  hRes;
    579578  ULONG    ulWholeArraySize; /* count spot in array  */
    580579  ULONG    ulDataIter;       /* to iterate the data space */
    581580
    582   if(! validArg(psa)) 
    583     return E_INVALIDARG;
    584 
    585   if(psa->cLocks > 0) 
     581  if(! validArg(psa))
     582    return E_INVALIDARG;
     583
     584  if(psa->cLocks > 0)
    586585    return DISP_E_ARRAYISLOCKED;
    587586
     
    592591
    593592    for(ulDataIter=0; ulDataIter < ulWholeArraySize; ulDataIter++) {
    594       punk = *(IUnknown**)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));       
    595 
    596       if( punk != NULL) 
     593      punk = *(IUnknown**)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));
     594
     595      if( punk != NULL)
    597596        IUnknown_Release(punk);
    598597    }
     
    605604      bstr = *(BSTR*)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));
    606605
    607       if( bstr != NULL) 
     606      if( bstr != NULL)
    608607        SysFreeString( bstr );
    609608    }
     
    615614    }
    616615  }
    617      
    618   /* check if this array is a Vector, in which case do not free the data 
     616
     617  /* check if this array is a Vector, in which case do not free the data
    619618     block since it has been allocated by AllocDescriptor and therefore
    620619     deserve to be freed by DestroyDescriptor */
     
    627626    psa->pvData = NULL;
    628627  }
    629  
     628
    630629  return S_OK;
    631630}
    632631
    633 /************************************************************************ 
     632/************************************************************************
    634633 *              SafeArrayCopyData (OLEAUT32.412)
    635634 * Copy the psaSource's data block into psaTarget if dimension and size
     
    639638  SAFEARRAY *psaSource,
    640639  SAFEARRAY **psaTarget)
    641 { 
     640{
    642641  USHORT   cDimCount;        /* looper */
    643642  LONG     lDelta;           /* looper */
    644   IUnknown *punk;   
     643  IUnknown *punk;
    645644  ULONG    ulWholeArraySize; /* Number of item in SA */
    646645  BSTR   bstr;
    647646
    648   if(! (validArg(psaSource) && validArg(*psaTarget)) ) 
     647  if(! (validArg(psaSource) && validArg(*psaTarget)) )
    649648    return E_INVALIDARG;
    650649
     
    652651    return E_INVALIDARG;
    653652
    654   ulWholeArraySize = getArraySize(psaSource); 
     653  ulWholeArraySize = getArraySize(psaSource);
    655654
    656655  /* The two arrays boundaries must be of same lenght */
    657656  for(cDimCount=0;cDimCount < psaSource->cDims; cDimCount++)
    658     if( psaSource->rgsabound[cDimCount].cElements != 
     657    if( psaSource->rgsabound[cDimCount].cElements !=
    659658      (*psaTarget)->rgsabound[cDimCount].cElements)
    660659      return E_INVALIDARG;
    661660
    662   if( isPointer((*psaTarget)->fFeatures) ) {         /* the target contains ptr 
     661  if( isPointer((*psaTarget)->fFeatures) ) {         /* the target contains ptr
    663662                                                        that must be released */
    664663    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
     
    666665        ((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements));
    667666
    668       if( punk != NULL) 
     667      if( punk != NULL)
    669668        IUnknown_Release(punk);
    670669    }
     
    672671  }
    673672  else if( (*psaTarget)->fFeatures & FADF_BSTR) {    /* the target contain BSTR
    674                                                         that must be freed */ 
     673                                                        that must be freed */
    675674    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
    676       bstr = 
     675      bstr =
    677676        *(BSTR*)((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements));
    678677
    679       if( bstr != NULL) 
     678      if( bstr != NULL)
    680679        SysFreeString( bstr );
    681680    }
     
    691690}
    692691
    693 /************************************************************************ 
     692/************************************************************************
    694693 *              SafeArrayDestroy (OLEAUT32.16)
    695694 * Deallocates all memory reserved for the SafeArray
     
    697696HRESULT WINAPI SafeArrayDestroy(
    698697  SAFEARRAY * psa)
    699 { 
     698{
    700699  HRESULT hRes;
    701700
    702   if(! validArg(psa)) 
    703     return E_INVALIDARG;
    704 
    705   if(psa->cLocks > 0) 
     701  if(! validArg(psa))
     702    return E_INVALIDARG;
     703
     704  if(psa->cLocks > 0)
    706705    return DISP_E_ARRAYISLOCKED;
    707706
     
    713712}
    714713
    715 /************************************************************************ 
     714/************************************************************************
    716715 *              SafeArrayCopy (OLEAUT32.27)
    717716 * Make a dupplicate of a SafeArray
    718717 */
    719718HRESULT WINAPI SafeArrayCopy(
    720   SAFEARRAY *psa, 
     719  SAFEARRAY *psa,
    721720  SAFEARRAY **ppsaOut)
    722 { 
     721{
    723722  HRESULT hRes;
    724723  DWORD   dAllocSize;
    725724  ULONG   ulWholeArraySize; /* size of the thing */
    726725
    727   if(! validArg(psa)) 
     726  if(! validArg(psa))
    728727    return E_INVALIDARG;
    729728
     
    731730
    732731    /* Duplicate the SAFEARRAY struc */
    733     memcpy(*ppsaOut, psa, 
     732    memcpy(*ppsaOut, psa,
    734733            sizeof(*psa)+(sizeof(*(psa->rgsabound))*(psa->cDims-1)));
    735734
     
    738737    /* make sure the new safe array doesn't have the FADF_CREATEVECTOR flag,
    739738       because the data has not been allocated with the descriptor. */
    740     (*ppsaOut)->fFeatures &= ~FADF_CREATEVECTOR; 
    741  
    742     /* Get the allocated memory size for source and allocate it for target */ 
     739    (*ppsaOut)->fFeatures &= ~FADF_CREATEVECTOR;
     740
     741    /* Get the allocated memory size for source and allocate it for target */
    743742    ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
    744743    dAllocSize = ulWholeArraySize*psa->cbElements;
    745744
    746     (*ppsaOut)->pvData = 
     745    (*ppsaOut)->pvData =
    747746      HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dAllocSize);
    748747    if( (*ppsaOut)->pvData != NULL) {   /* HeapAlloc succeed */
     
    754753        return hRes;
    755754      }
    756        
     755
    757756    } else { /* failed to allocate or dupplicate... */
    758757      SafeArrayDestroyDescriptor(*ppsaOut);
     
    766765}
    767766
    768 /************************************************************************ 
     767/************************************************************************
    769768 *              SafeArrayCreateVector (OLEAUT32.411)
    770  * Creates a one dimension safearray where the data is next to the 
     769 * Creates a one dimension safearray where the data is next to the
    771770 * SAFEARRAY structure.
    772771 */
    773772SAFEARRAY* WINAPI SafeArrayCreateVector(
    774   VARTYPE vt, 
    775   LONG    lLbound, 
    776   ULONG   cElements) 
    777 { 
     773  VARTYPE vt,
     774  LONG    lLbound,
     775  ULONG   cElements)
     776{
    778777  SAFEARRAY *psa;
    779778
     
    784783
    785784  /* Allocate memory for the array descriptor and data contiguously  */
    786   if( FAILED( psa = HeapAlloc( GetProcessHeap(), 
    787                       HEAP_ZERO_MEMORY, 
     785  if( FAILED( psa = HeapAlloc( GetProcessHeap(),
     786                      HEAP_ZERO_MEMORY,
    788787                      (sizeof(*psa) + (VARTYPE_SIZE[vt] * cElements))))) {
    789788    return NULL;
    790789  }
    791                                                                                
    792   /* setup data members... */ 
     790
     791  /* setup data members... */
    793792  psa->cDims      = 1; /* always and forever */
    794793  psa->fFeatures  = getFeatures(vt) | FADF_CREATEVECTOR;  /* undocumented flag used by Microsoft */
     
    800799  psa->rgsabound[0].lLbound   = lLbound;
    801800
    802   return(psa);                           
    803 } 
    804 
    805 /************************************************************************ 
     801  return(psa);
     802}
     803
     804/************************************************************************
    806805 *              SafeArrayRedim (OLEAUT32.40)
    807806 * Changes the caracteristics of the last dimension of the SafeArray
    808807 */
    809808HRESULT WINAPI SafeArrayRedim(
    810   SAFEARRAY      *psa, 
     809  SAFEARRAY      *psa,
    811810  SAFEARRAYBOUND *psaboundNew)
    812 { 
     811{
    813812  LONG   lDelta;  /* hold difference in size */
    814813  USHORT cDims=1; /* dims counter */
    815814
    816   if( !validArg(psa) )                   
    817     return E_INVALIDARG;
    818 
    819   if( psa->cLocks > 0 )                   
     815  if( !validArg(psa) )
     816    return E_INVALIDARG;
     817
     818  if( psa->cLocks > 0 )
    820819    return DISP_E_ARRAYISLOCKED;
    821820
    822   if( psa->fFeatures & FADF_FIXEDSIZE )   
    823     return E_INVALIDARG;
    824 
    825   if( SafeArrayLock(psa)==E_UNEXPECTED ) 
     821  if( psa->fFeatures & FADF_FIXEDSIZE )
     822    return E_INVALIDARG;
     823
     824  if( SafeArrayLock(psa)==E_UNEXPECTED )
    826825    return E_UNEXPECTED;/* UNDOC error condition */
    827826
     
    837836
    838837  } else /* need to enlarge (lDelta +) reduce (lDelta -) */
    839     if(! resizeSafeArray(psa, lDelta)) 
     838    if(! resizeSafeArray(psa, lDelta))
    840839      return E_UNEXPECTED; /* UNDOC error condition */
    841840
    842   /* the only modifyable dimension sits in [0] as the dimensions were reversed 
     841  /* the only modifyable dimension sits in [0] as the dimensions were reversed
    843842     at array creation time... */
    844843  psa->rgsabound[0].cElements = psaboundNew->cElements;
     
    852851 ************************************************************************/
    853852
    854 /************************************************************************ 
     853/************************************************************************
    855854 * Used to validate the SAFEARRAY type of arg
    856855 */
    857856static BOOL validArg(
    858   SAFEARRAY *psa) 
     857  SAFEARRAY *psa)
    859858{
    860859  SAFEARRAYBOUND *sab;
     
    886885}
    887886
    888 /************************************************************************ 
     887/************************************************************************
    889888 * Used to reallocate memory
    890889 */
    891890static BOOL resizeSafeArray(
    892   SAFEARRAY *psa, 
     891  SAFEARRAY *psa,
    893892  LONG lDelta)
    894893{
    895894  ULONG    ulWholeArraySize;  /* use as multiplicator */
    896   PVOID    pvNewBlock = NULL; 
     895  PVOID    pvNewBlock = NULL;
    897896  IUnknown *punk;
    898897  BSTR   bstr;
     
    905904              punk = *(IUnknown**)
    906905          ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements));
    907        
     906
    908907        if( punk != NULL )
    909908          IUnknown_Release(punk);
     
    926925  if (!(psa->fFeatures & FADF_CREATEVECTOR))
    927926  {
    928     /* Ok now, if we are enlarging the array, we *MUST* move the whole block 
     927    /* Ok now, if we are enlarging the array, we *MUST* move the whole block
    929928       pointed to by pvData.   If we are shorthening the array, this move is
    930        optional but we do it anyway becuase the benefit is that we are 
     929       optional but we do it anyway becuase the benefit is that we are
    931930       releasing to the system the unused memory */
    932931
    933     if((pvNewBlock = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, psa->pvData, 
    934        (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL) 
     932    if((pvNewBlock = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, psa->pvData,
     933       (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL)
    935934        return FALSE; /* TODO If we get here it means:
    936935                         SHRINK situation :  we've deleted the undesired
     
    941940  else
    942941  {
    943     /* Allocate a new block, because the previous data has been allocated with 
     942    /* Allocate a new block, because the previous data has been allocated with
    944943       the descriptor in SafeArrayCreateVector function. */
    945944
    946945    if((pvNewBlock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    947        ulWholeArraySize * psa->cbElements)) == NULL) 
     946       ulWholeArraySize * psa->cbElements)) == NULL)
    948947        return FALSE;
    949948
     
    955954}
    956955
    957 /************************************************************************ 
    958  * Used to set the fFeatures data member of the SAFEARRAY structure. 
     956/************************************************************************
     957 * Used to set the fFeatures data member of the SAFEARRAY structure.
    959958 */
    960959static INT getFeatures(
    961   VARTYPE vt) 
     960  VARTYPE vt)
    962961{
    963962  switch(vt) {
     
    970969}
    971970
    972 /************************************************************************ 
    973  * Used to figure out if the fFeatures data member of the SAFEARRAY 
    974  * structure contain any information about the type of data stored... 
     971/************************************************************************
     972 * Used to figure out if the fFeatures data member of the SAFEARRAY
     973 * structure contain any information about the type of data stored...
    975974 */
    976975static BOOL isPointer(
    977   USHORT feature) 
     976  USHORT feature)
    978977{
    979978  switch(feature) {
     
    984983}
    985984
    986 /************************************************************************ 
    987  * Used to calculate the displacement when accessing or modifying 
     985/************************************************************************
     986 * Used to calculate the displacement when accessing or modifying
    988987 * safearray data set.
    989988 *
     
    995994 */
    996995static ULONG calcDisplacement(
    997   LONG           *coor, 
    998   SAFEARRAYBOUND *mat, 
    999   LONG           dim) 
     996  LONG           *coor,
     997  SAFEARRAYBOUND *mat,
     998  LONG           dim)
    1000999{
    10011000  ULONG res = 0;
    10021001  LONG  iterDim;
    10031002
    1004   for(iterDim=0; iterDim<dim; iterDim++) 
     1003  for(iterDim=0; iterDim<dim; iterDim++)
    10051004    /* the -mat[dim] bring coor[dim] relative to 0 for calculation */
    1006     res += ((coor[iterDim]-mat[iterDim].lLbound) * 
     1005    res += ((coor[iterDim]-mat[iterDim].lLbound) *
    10071006            endOfDim(coor, mat, iterDim+1, dim));
    10081007
     
    10111010}
    10121011
    1013 /************************************************************************ 
    1014  * Recursivity agent for calcDisplacement method.  Used within Put and 
     1012/************************************************************************
     1013 * Recursivity agent for calcDisplacement method.  Used within Put and
    10151014 * Get methods.
    10161015 */
    10171016static INT endOfDim(
    1018   LONG           *coor, 
    1019   SAFEARRAYBOUND *mat, 
    1020   LONG           dim, 
    1021   LONG           realDim) 
    1022 {
    1023   if(dim==realDim) 
     1017  LONG           *coor,
     1018  SAFEARRAYBOUND *mat,
     1019  LONG           dim,
     1020  LONG           realDim)
     1021{
     1022  if(dim==realDim)
    10241023    return 1;
    1025   else 
     1024  else
    10261025    return (endOfDim(coor, mat, dim+1, realDim) * mat[dim].cElements);
    10271026}
    10281027
    10291028
    1030 /************************************************************************ 
    1031  * Method used to validate the coordinate received in Put and Get 
     1029/************************************************************************
     1030 * Method used to validate the coordinate received in Put and Get
    10321031 * methods.
    10331032 */
    10341033static BOOL validCoordinate(
    1035   LONG      *coor, 
    1036   SAFEARRAY *psa) 
     1034  LONG      *coor,
     1035  SAFEARRAY *psa)
    10371036{
    10381037  INT   iter=0;
     
    10481047    if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
    10491048      return FALSE;
    1050  
    1051     if(lLBound > lUBound) 
    1052       return FALSE; 
     1049
     1050    if(lLBound > lUBound)
     1051      return FALSE;
    10531052
    10541053    if((coor[iter] < lLBound) || (coor[iter] > lUBound))
     
    10561055  }
    10571056  return TRUE;
    1058 } 
    1059 
    1060 /************************************************************************ 
     1057}
     1058
     1059/************************************************************************
    10611060 * Method used to calculate the number of cells of the SA
    10621061 */
    10631062static ULONG getArraySize(
    1064   SAFEARRAY *psa) 
    1065 {
    1066   USHORT cCount; 
     1063  SAFEARRAY *psa)
     1064{
     1065  USHORT cCount;
    10671066  ULONG  ulWholeArraySize = 1;
    10681067
     
    10701069    ulWholeArraySize *= psa->rgsabound[cCount].cElements;
    10711070
    1072   return ulWholeArraySize; 
    1073 }
    1074 
    1075 
    1076 /************************************************************************ 
     1071  return ulWholeArraySize;
     1072}
     1073
     1074
     1075/************************************************************************
    10771076 * Method used to handle data space dupplication for Copy32 and CopyData32
    10781077 */
    10791078static HRESULT duplicateData(
    1080   SAFEARRAY *psa, 
    1081   SAFEARRAY **ppsaOut) 
     1079  SAFEARRAY *psa,
     1080  SAFEARRAY **ppsaOut)
    10821081{
    10831082  ULONG    ulWholeArraySize; /* size of the thing */
     
    10851084
    10861085  ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
    1087  
     1086
    10881087  SafeArrayLock(*ppsaOut);
    10891088
    1090   if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment 
     1089  if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment
    10911090                                        object's reference count */
    10921091    IUnknown *punk;
     
    11001099
    11011100    /* Copy the source array data into target array */
    1102     memcpy((*ppsaOut)->pvData, psa->pvData, 
     1101    memcpy((*ppsaOut)->pvData, psa->pvData,
    11031102      ulWholeArraySize*psa->cbElements);
    11041103
    11051104  }
    1106   else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate 
     1105  else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate
    11071106                                             the BSTR in the new array */
    11081107    BSTR   pbstrReAllocStr = NULL;
     
    11161115      }
    11171116
    1118       *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) = 
     1117      *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) =
    11191118        pbstrReAllocStr;
    11201119    }
     
    11311130  else { /* Simply copy the source array data into target array */
    11321131
    1133     memcpy((*ppsaOut)->pvData, psa->pvData, 
     1132    memcpy((*ppsaOut)->pvData, psa->pvData,
    11341133      ulWholeArraySize*psa->cbElements);
    11351134  }
     
    11411140
    11421141
    1143 /************************************************************************ 
    1144  *              SafeArrayGetVarType (OLEAUT32.77)
     1142/************************************************************************
     1143 *              SafeArrayGetVartype (OLEAUT32.77)
    11451144 * Returns the VARTYPE stored in the given safearray
    11461145 */
    1147 HRESULT WINAPI SafeArrayGetVarType(
     1146HRESULT WINAPI SafeArrayGetVartype(
    11481147  SAFEARRAY* psa,
    11491148  VARTYPE*   pvt)
  • trunk/src/oleaut32/stubs.cpp

    r8450 r9400  
    1 /* $Id: stubs.cpp,v 1.15 2002-05-17 10:17:00 sandervl Exp $ */
     1/* $Id: stubs.cpp,v 1.16 2002-11-12 17:07:47 sandervl Exp $ */
    22/*
    33 * Win32 COM/OLE stubs for OS/2
     
    9696}
    9797
    98 //*****************************************************************************
    99 //*****************************************************************************
    100 HRESULT WINAPI DispCallFunc(void* pvInstance, ULONG oVft, CALLCONV cc,
    101             VARTYPE vtReturn, UINT  cActuals, VARTYPE* prgvt,
    102             VARIANTARG** prgpvarg, VARIANT* pvargResult)
    103 {
    104     dprintf(("OLEAUT32: DispCallFunc - stub"));
    105     return S_OK;
    106 }
    10798
    10899//*****************************************************************************
  • trunk/src/oleaut32/tmarshal.c

    r8663 r9400  
    4141#include "typelib.h"
    4242#include "wine/debug.h"
    43 #include "ntddk.h"
     43#include "winternl.h"
    4444
    4545static const WCHAR riidW[5] = {'r','i','i','d',0};
     
    367367
    368368/* how much space do we use on stack in DWORD steps. */
    369 static int const
     369int const
    370370_argsize(DWORD vt) {
    371371    switch (vt) {
  • trunk/src/oleaut32/typelib.c

    r8640 r9400  
    2020 * License along with this library; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *                   
     22 *
    2323 * --------------------------------------------------------------------------------------
    2424 * Known problems (2000, Francois Jacques)
    2525 *
    2626 * - Tested using OLEVIEW (Platform SDK tool) only.
    27  *   
    28  * - dual interface dispinterfaces. vtable-interface ITypeInfo instances are 
    29  *   creating by doing a straight copy of the dispinterface instance and just changing 
     27 *
     28 * - dual interface dispinterfaces. vtable-interface ITypeInfo instances are
     29 *   creating by doing a straight copy of the dispinterface instance and just changing
    3030 *   its typekind. Pointed structures aren't copied - only the address of the pointers.
    3131 *   So when you release the dispinterface, you delete the vtable-interface structures
    3232 *   as well... fortunately, clean up of structures is not implemented.
    33  * 
     33 *
    3434 * - locale stuff is partially implemented but hasn't been tested.
    3535 *
     
    5050 * -. some methods just return pointers to internal data structures, this is
    5151 *      partly laziness, partly I want to check how windows does it.
    52  * 
     52 *
    5353 */
    5454
    5555#include "config.h"
     56#include "wine/port.h"
    5657
    5758#include <stdlib.h>
     
    7172#include "typelib.h"
    7273#include "wine/debug.h"
    73 #include "ntddk.h"
     74#include "parsedt.h"
    7475
    7576WINE_DEFAULT_DEBUG_CHANNEL(ole);
    7677WINE_DECLARE_DEBUG_CHANNEL(typelib);
     78
     79/****************************************************************************
     80 *              FromLExxx
     81 *
     82 * Takes p_iVal (which is in little endian) and returns it
     83 *   in the host machine's byte order.
     84 */
     85#ifdef WORDS_BIGENDIAN
     86static WORD FromLEWord(WORD p_iVal)
     87{
     88  return (((p_iVal & 0x00FF) << 8) |
     89          ((p_iVal & 0xFF00) >> 8));
     90}
     91
     92
     93static DWORD FromLEDWord(DWORD p_iVal)
     94{
     95  return (((p_iVal & 0x000000FF) << 24) |
     96          ((p_iVal & 0x0000FF00) <<  8) |
     97          ((p_iVal & 0x00FF0000) >>  8) |
     98          ((p_iVal & 0xFF000000) >> 24));
     99}
     100#else
     101#define FromLEWord(X)  (X)
     102#define FromLEDWord(X) (X)
     103#endif
     104
     105
     106/****************************************************************************
     107 *              FromLExxx
     108 *
     109 * Fix byte order in any structure if necessary
     110 */
     111#ifdef WORDS_BIGENDIAN
     112static void FromLEWords(void *p_Val, int p_iSize)
     113{
     114  WORD *Val = p_Val;
     115
     116  p_iSize /= sizeof(WORD);
     117
     118  while (p_iSize) {
     119    *Val = FromLEWord(*Val);
     120    Val++;
     121    p_iSize--;
     122  }
     123}
     124
     125
     126static void FromLEDWords(void *p_Val, int p_iSize)
     127{
     128  DWORD *Val = p_Val;
     129
     130  p_iSize /= sizeof(DWORD);
     131
     132  while (p_iSize) {
     133    *Val = FromLEDWord(*Val);
     134    Val++;
     135    p_iSize--;
     136  }
     137}
     138#else
     139#define FromLEWords(X,Y) /*nothing*/
     140#define FromLEDWords(X,Y) /*nothing*/
     141#endif
     142
    77143
    78144/****************************************************************************
     
    84150 */
    85151HRESULT WINAPI
    86 QueryPathOfRegTypeLib16(       
     152QueryPathOfRegTypeLib16(
    87153        REFGUID guid,   /* [in] referenced guid */
    88154        WORD wMaj,      /* [in] major version */
     
    119185        return S_OK;
    120186}
    121  
     187
    122188/****************************************************************************
    123189 *              QueryPathOfRegTypeLib   [OLEAUT32.164]
     
    126192 */
    127193HRESULT WINAPI
    128 QueryPathOfRegTypeLib( 
     194QueryPathOfRegTypeLib(
    129195        REFGUID guid,   /* [in] referenced guid */
    130196        WORD wMaj,      /* [in] major version */
     
    160226            "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win32",
    161227            guid->Data1,    guid->Data2,    guid->Data3,
    162             guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], 
     228            guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
    163229            guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
    164230            wMaj,
     
    200266        }
    201267    }
    202        
     268
    203269    if (hr != S_OK)
    204270                TRACE_(typelib)("%s not found\n", szTypeLibKey);
    205        
     271
    206272    return hr;
    207273}
     
    281347    INT index = 1;
    282348    TRACE("(%s,%d,%p)\n",debugstr_w(szFile), regkind, pptLib);
    283    
     349
    284350    if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath,
    285351                    NULL)) {
     
    288354        pIndexStr = strrchrW(szFile, '\\');
    289355        if(pIndexStr && pIndexStr != szFile && *++pIndexStr != '\0') {
    290             index = wcstol(pIndexStr, NULL, 10);
     356            index = atoiW(pIndexStr);
    291357            memcpy(szFileCopy, szFile,
    292358                   (pIndexStr - szFile - 1) * sizeof(WCHAR));
     
    333399 *              LoadRegTypeLib  [OLEAUT32.162]
    334400 */
    335 HRESULT WINAPI LoadRegTypeLib( 
     401HRESULT WINAPI LoadRegTypeLib(
    336402        REFGUID rguid,          /* [in] referenced guid */
    337403        WORD wVerMajor,         /* [in] major version */
     
    352418
    353419    return res;
    354 }       
     420}
    355421
    356422
    357423/******************************************************************************
    358424 *              RegisterTypeLib [OLEAUT32.163]
    359  * Adds information about a type library to the System Registry           
     425 * Adds information about a type library to the System Registry
    360426 * NOTES
    361427 *    Docs: ITypeLib FAR * ptlib
     
    556622/******************************************************************************
    557623 *      UnRegisterTypeLib       [OLEAUT32.186]
    558  * Removes information about a type library from the System Registry           
     624 * Removes information about a type library from the System Registry
    559625 * NOTES
    560626 *
     
    569635        LCID lcid,      /* [in] locale id */
    570636        SYSKIND syskind)
    571 {   
     637{
    572638    TRACE("(IID: %s): stub\n",debugstr_guid(libid));
    573639    return S_OK;        /* FIXME: pretend everything is OK */
     
    594660     * to retrieve the "versionForced" info from misc/version.c :(
    595661     * (this would be useful in other places, too) */
    596     FIXME("Please report to a.mohr@mailto.de if you get version error messages !\n");
     662    FIXME("If you get version error messages, please report them\n");
    597663    switch(GetVersion() & 0x8000ffff)  /* mask off build number */
    598664    {
     
    616682/*======================= ITypeLib implementation =======================*/
    617683
    618 typedef struct tagTLBCustData 
     684typedef struct tagTLBCustData
    619685{
    620686    GUID guid;
     
    649715    UINT ref;
    650716    TLIBATTR LibAttr;            /* guid,lcid,syskind,version,flags */
    651    
     717
    652718    /* strings can be stored in tlb as multibyte strings BUT they are *always*
    653719     * exported to the application as a UNICODE string.
     
    690756                               TLB_REF_INTERNAL for internal refs
    691757                               TLB_REF_NOT_FOUND for broken refs */
    692  
     758
    693759    struct tagTLBRefType * next;
    694760} TLBRefType;
     
    719785    int ctCustData;
    720786    TLBCustData * pCustData;        /* linked list to cust data; */
    721     struct tagTLBFuncDesc * next; 
     787    struct tagTLBFuncDesc * next;
    722788} TLBFuncDesc;
    723789
     
    732798    int ctCustData;
    733799    TLBCustData * pCustData;/* linked list to cust data; */
    734     struct tagTLBVarDesc * next; 
     800    struct tagTLBVarDesc * next;
    735801} TLBVarDesc;
    736802
     
    753819    ITypeLibImpl * pTypeLib;        /* back pointer to typelib */
    754820    int index;                  /* index in this typelib; */
    755     /* type libs seem to store the doc strings in ascii 
     821    /* type libs seem to store the doc strings in ascii
    756822     * so why should we do it in unicode?
    757823     */
     
    880946}
    881947
    882 static void dump_ELEMDESC(ELEMDESC *edesc) {
     948void dump_ELEMDESC(ELEMDESC *edesc) {
    883949  char buf[200];
    884950  dump_TypeDesc(&edesc->tdesc,buf);
     
    887953  MESSAGE("\t\tu.parmadesc.lpex %p\n",edesc->u.paramdesc.pparamdescex);
    888954}
    889 static void dump_FUNCDESC(FUNCDESC *funcdesc) {
     955void dump_FUNCDESC(FUNCDESC *funcdesc) {
    890956  int i;
    891957  MESSAGE("memid is %08lx\n",funcdesc->memid);
     
    922988  MESSAGE("\twFlags: %x\n", funcdesc->wFuncFlags);
    923989}
    924 static void dump_TLBFuncDescOne(TLBFuncDesc * pfd)
    925 {
    926   int i;
    927   if (!TRACE_ON(typelib))
    928       return;
    929   MESSAGE("%s(%u)\n", debugstr_w(pfd->Name), pfd->funcdesc.cParams);
    930   for (i=0;i<pfd->funcdesc.cParams;i++)
    931       MESSAGE("\tparm%d: %s\n",i,debugstr_w(pfd->pParamDesc[i].Name));
    932 
    933 
    934   dump_FUNCDESC(&(pfd->funcdesc));
    935 
    936   MESSAGE("\thelpstring: %s\n", debugstr_w(pfd->HelpString));
    937   MESSAGE("\tentry: %s\n", debugstr_w(pfd->Entry));
    938 }
    939 static void dump_TLBFuncDesc(TLBFuncDesc * pfd)
    940 {
    941         while (pfd)
    942         {
    943           dump_TLBFuncDescOne(pfd);
    944           pfd = pfd->next;
    945         };
    946 }
    947 static void dump_TLBVarDesc(TLBVarDesc * pvd)
    948 {
    949         while (pvd)
    950         {
    951           TRACE_(typelib)("%s\n", debugstr_w(pvd->Name));
    952           pvd = pvd->next;
    953         };
    954 }
    955 
    956 static void dump_TLBImpLib(TLBImpLib *import)
    957 {
    958     TRACE_(typelib)("%s %s\n", debugstr_guid(&(import->guid)),
    959                     debugstr_w(import->name));
    960     TRACE_(typelib)("v%d.%d lcid=%lx offset=%x\n", import->wVersionMajor,
    961                     import->wVersionMinor, import->lcid, import->offset);
    962 }
    963 
    964 static void dump_TLBRefType(TLBRefType * prt)
    965 {
    966         while (prt)
    967         {
    968           TRACE_(typelib)("href:0x%08lx\n", prt->reference);
    969           if(prt->index == -1)
    970             TRACE_(typelib)("%s\n", debugstr_guid(&(prt->guid)));
    971           else
    972             TRACE_(typelib)("type no: %d\n", prt->index);
    973 
    974           if(prt->pImpTLInfo != TLB_REF_INTERNAL &&
    975              prt->pImpTLInfo != TLB_REF_NOT_FOUND) {
    976               TRACE_(typelib)("in lib\n");
    977               dump_TLBImpLib(prt->pImpTLInfo);
    978           }
    979           prt = prt->next;
    980         };
    981 }
    982 
    983 static void dump_TLBImplType(TLBImplType * impl)
    984 {
    985     while (impl) {
    986         TRACE_(typelib)(
    987                 "implementing/inheriting interface hRef = %lx implflags %x\n",
    988                 impl->hRef, impl->implflags);
    989         impl = impl->next;
    990     }
    991 }
    992      
    993 static void dump_Variant(VARIANT * pvar)
    994 {
    995     char szVarType[32];
    996     LPVOID ref;
    997    
    998     TRACE("(%p)\n", pvar);
    999  
    1000     if (!pvar)  return;
    1001  
    1002     ZeroMemory(szVarType, sizeof(szVarType));
    1003                
    1004     /* FIXME : we could have better trace here, depending on the VARTYPE
    1005      * of the variant
    1006      */
    1007     dump_VarType(V_VT(pvar),szVarType);
    1008 
    1009     TRACE("VARTYPE: %s\n", szVarType);
    1010 
    1011     if (V_VT(pvar) & VT_BYREF) {
    1012       ref = V_UNION(pvar, byref);
    1013       TRACE("%p\n", ref);
    1014     }
    1015     else ref = &V_UNION(pvar, cVal);
    1016 
    1017     if (V_VT(pvar) & VT_ARRAY) {
    1018       /* FIXME */
    1019       return;
    1020     }
    1021     if (V_VT(pvar) & VT_VECTOR) {
    1022       /* FIXME */
    1023       return;
    1024     }
    1025 
    1026     switch (V_VT(pvar))
    1027     {
    1028         case VT_I2:
    1029             TRACE("%d\n", *(short*)ref);
    1030             break;
    1031 
    1032         case VT_I4:
    1033             TRACE("%d\n", *(INT*)ref);
    1034             break;
    1035 
    1036         case VT_R4:
    1037             TRACE("%3.3e\n", *(float*)ref);
    1038             break;
    1039 
    1040         case VT_R8:
    1041             TRACE("%3.3e\n", *(double*)ref);
    1042             break;
    1043 
    1044         case VT_BOOL:
    1045             TRACE("%s\n", *(VARIANT_BOOL*)ref ? "TRUE" : "FALSE");
    1046             break;
    1047 
    1048         case VT_BSTR:
    1049             TRACE("%s\n", debugstr_w(*(BSTR*)ref));
    1050             break;
    1051 
    1052         case VT_UNKNOWN:
    1053         case VT_DISPATCH:
    1054             TRACE("%p\n", *(LPVOID*)ref);
    1055             break;
    1056 
    1057         case VT_VARIANT:
    1058             if (V_VT(pvar) & VT_BYREF) dump_Variant(ref);
    1059             break;
    1060 
    1061         default:
    1062             TRACE("(?)%ld\n", *(long*)ref);
    1063             break;
    1064     }       
    1065 }
    1066 
    1067 static void dump_DispParms(DISPPARAMS * pdp)
    1068 {
    1069     int index = 0;
    1070    
    1071     TRACE("args=%u named args=%u\n", pdp->cArgs, pdp->cNamedArgs);
    1072 
    1073     while (index < pdp->cArgs)
    1074     {
    1075         dump_Variant( &pdp->rgvarg[index] );
    1076         ++index;
    1077     }
     990
     991void dump_IDLDESC(IDLDESC *idl) {
     992  MESSAGE("\t\twIdlflags: %d\n",idl->wIDLFlags);
    1078993}
    1079994
     
    10911006};
    10921007
     1008void dump_TYPEATTR(TYPEATTR *tattr) {
     1009  char buf[200];
     1010  MESSAGE("\tguid: %s\n",debugstr_guid(&tattr->guid));
     1011  MESSAGE("\tlcid: %ld\n",tattr->lcid);
     1012  MESSAGE("\tmemidConstructor: %ld\n",tattr->memidConstructor);
     1013  MESSAGE("\tmemidDestructor: %ld\n",tattr->memidDestructor);
     1014  MESSAGE("\tschema: %s\n",debugstr_w(tattr->lpstrSchema));
     1015  MESSAGE("\tsizeInstance: %ld\n",tattr->cbSizeInstance);
     1016  MESSAGE("\tkind:%s\n", typekind_desc[tattr->typekind]);
     1017  MESSAGE("\tcFuncs: %d\n", tattr->cFuncs);
     1018  MESSAGE("\tcVars: %d\n", tattr->cVars);
     1019  MESSAGE("\tcImplTypes: %d\n", tattr->cImplTypes);
     1020  MESSAGE("\tcbSizeVft: %d\n", tattr->cbSizeVft);
     1021  MESSAGE("\tcbAlignment: %d\n", tattr->cbAlignment);
     1022  MESSAGE("\twTypeFlags: %d\n", tattr->wTypeFlags);
     1023  MESSAGE("\tVernum: %d.%d\n", tattr->wMajorVerNum,tattr->wMinorVerNum);
     1024  dump_TypeDesc(&tattr->tdescAlias,buf);
     1025  MESSAGE("\ttypedesc: %s\n", buf);
     1026  dump_IDLDESC(&tattr->idldescType);
     1027}
     1028
     1029static void dump_TLBFuncDescOne(TLBFuncDesc * pfd)
     1030{
     1031  int i;
     1032  if (!TRACE_ON(typelib))
     1033      return;
     1034  MESSAGE("%s(%u)\n", debugstr_w(pfd->Name), pfd->funcdesc.cParams);
     1035  for (i=0;i<pfd->funcdesc.cParams;i++)
     1036      MESSAGE("\tparm%d: %s\n",i,debugstr_w(pfd->pParamDesc[i].Name));
     1037
     1038
     1039  dump_FUNCDESC(&(pfd->funcdesc));
     1040
     1041  MESSAGE("\thelpstring: %s\n", debugstr_w(pfd->HelpString));
     1042  MESSAGE("\tentry: %s\n", debugstr_w(pfd->Entry));
     1043}
     1044static void dump_TLBFuncDesc(TLBFuncDesc * pfd)
     1045{
     1046        while (pfd)
     1047        {
     1048          dump_TLBFuncDescOne(pfd);
     1049          pfd = pfd->next;
     1050        };
     1051}
     1052static void dump_TLBVarDesc(TLBVarDesc * pvd)
     1053{
     1054        while (pvd)
     1055        {
     1056          TRACE_(typelib)("%s\n", debugstr_w(pvd->Name));
     1057          pvd = pvd->next;
     1058        };
     1059}
     1060
     1061static void dump_TLBImpLib(TLBImpLib *import)
     1062{
     1063    TRACE_(typelib)("%s %s\n", debugstr_guid(&(import->guid)),
     1064                    debugstr_w(import->name));
     1065    TRACE_(typelib)("v%d.%d lcid=%lx offset=%x\n", import->wVersionMajor,
     1066                    import->wVersionMinor, import->lcid, import->offset);
     1067}
     1068
     1069static void dump_TLBRefType(TLBRefType * prt)
     1070{
     1071        while (prt)
     1072        {
     1073          TRACE_(typelib)("href:0x%08lx\n", prt->reference);
     1074          if(prt->index == -1)
     1075            TRACE_(typelib)("%s\n", debugstr_guid(&(prt->guid)));
     1076          else
     1077            TRACE_(typelib)("type no: %d\n", prt->index);
     1078
     1079          if(prt->pImpTLInfo != TLB_REF_INTERNAL &&
     1080             prt->pImpTLInfo != TLB_REF_NOT_FOUND) {
     1081              TRACE_(typelib)("in lib\n");
     1082              dump_TLBImpLib(prt->pImpTLInfo);
     1083          }
     1084          prt = prt->next;
     1085        };
     1086}
     1087
     1088static void dump_TLBImplType(TLBImplType * impl)
     1089{
     1090    while (impl) {
     1091        TRACE_(typelib)(
     1092                "implementing/inheriting interface hRef = %lx implflags %x\n",
     1093                impl->hRef, impl->implflags);
     1094        impl = impl->next;
     1095    }
     1096}
     1097
     1098void dump_Variant(VARIANT * pvar)
     1099{
     1100    char szVarType[32];
     1101    LPVOID ref;
     1102
     1103    TRACE("(%p)\n", pvar);
     1104
     1105    if (!pvar)  return;
     1106
     1107    ZeroMemory(szVarType, sizeof(szVarType));
     1108
     1109    /* FIXME : we could have better trace here, depending on the VARTYPE
     1110     * of the variant
     1111     */
     1112    dump_VarType(V_VT(pvar),szVarType);
     1113
     1114    TRACE("VARTYPE: %s\n", szVarType);
     1115
     1116    if (V_VT(pvar) & VT_BYREF) {
     1117      ref = V_UNION(pvar, byref);
     1118      TRACE("%p\n", ref);
     1119    }
     1120    else ref = &V_UNION(pvar, cVal);
     1121
     1122    if (V_VT(pvar) & VT_ARRAY) {
     1123      /* FIXME */
     1124      return;
     1125    }
     1126    if (V_VT(pvar) & VT_VECTOR) {
     1127      /* FIXME */
     1128      return;
     1129    }
     1130
     1131    switch (V_VT(pvar) & VT_TYPEMASK)
     1132    {
     1133        case VT_I2:
     1134            TRACE("%d\n", *(short*)ref);
     1135            break;
     1136
     1137        case VT_I4:
     1138            TRACE("%d\n", *(INT*)ref);
     1139            break;
     1140
     1141        case VT_R4:
     1142            TRACE("%3.3e\n", *(float*)ref);
     1143            break;
     1144
     1145        case VT_R8:
     1146            TRACE("%3.3e\n", *(double*)ref);
     1147            break;
     1148
     1149        case VT_BOOL:
     1150            TRACE("%s\n", *(VARIANT_BOOL*)ref ? "TRUE" : "FALSE");
     1151            break;
     1152
     1153        case VT_BSTR:
     1154            TRACE("%s\n", debugstr_w(*(BSTR*)ref));
     1155            break;
     1156
     1157        case VT_UNKNOWN:
     1158        case VT_DISPATCH:
     1159            TRACE("%p\n", *(LPVOID*)ref);
     1160            break;
     1161
     1162        case VT_VARIANT:
     1163            if (V_VT(pvar) & VT_BYREF) dump_Variant(ref);
     1164            break;
     1165
     1166        case VT_DATE:
     1167        {
     1168            struct tm TM;
     1169            memset( &TM, 0, sizeof(TM) );
     1170
     1171            if( DateToTm( *(DATE*)ref, 0, &TM ) == FALSE ) {
     1172                TRACE("invalid date? (?)%ld %f\n", *(long*)ref, *(double *)ref);
     1173            } else {
     1174                TRACE("(yyyymmdd) %4.4d-%2.2d-%2.2d (time) %2.2d:%2.2d:%2.2d [%f]\n",
     1175                       TM.tm_year, TM.tm_mon+1, TM.tm_mday,
     1176                      TM.tm_hour, TM.tm_min, TM.tm_sec, *(double *)ref);
     1177            }
     1178            break;
     1179        }
     1180
     1181        case VT_CY:
     1182            TRACE("%ld (hi), %lu (lo)\n", ((CY *)ref)->s.Hi, ((CY *)ref)->s.Lo);
     1183            break;
     1184
     1185
     1186        default:
     1187            TRACE("(?)%ld\n", *(long*)ref);
     1188            break;
     1189    }
     1190}
     1191
     1192static void dump_DispParms(DISPPARAMS * pdp)
     1193{
     1194    int index = 0;
     1195
     1196    TRACE("args=%u named args=%u\n", pdp->cArgs, pdp->cNamedArgs);
     1197
     1198    while (index < pdp->cArgs)
     1199    {
     1200        dump_Variant( &pdp->rgvarg[index] );
     1201        ++index;
     1202    }
     1203}
     1204
    10931205static void dump_TypeInfo(ITypeInfoImpl * pty)
    10941206{
     
    11031215    dump_TLBVarDesc(pty->varlist);
    11041216    dump_TLBImplType(pty->impltypelist);
     1217}
     1218
     1219void dump_VARDESC(VARDESC *v)
     1220{
     1221    MESSAGE("memid %ld\n",v->memid);
     1222    MESSAGE("lpstrSchema %s\n",debugstr_w(v->lpstrSchema));
     1223    MESSAGE("oInst %ld\n",v->u.oInst);
     1224    dump_ELEMDESC(&(v->elemdescVar));
     1225    MESSAGE("wVarFlags %x\n",v->wVarFlags);
     1226    MESSAGE("varkind %d\n",v->varkind);
    11051227}
    11061228#else
     
    11241246#define  dump_TLBFuncDesc(a)
    11251247#define  dump_TypeDesc(a,b)
    1126 #define  dump_Variant(a)
     1248#define  dump_VARDESC(a)
    11271249#define  debugstr_an(a,b) NULL
    11281250#endif
     
    11881310}
    11891311
     1312static DWORD MSFT_ReadLEDWords(void *buffer,  DWORD count, TLBContext *pcx,
     1313                               long where )
     1314{
     1315  DWORD ret;
     1316
     1317  ret = MSFT_Read(buffer, count, pcx, where);
     1318  FromLEDWords(buffer, ret);
     1319
     1320  return ret;
     1321}
     1322
     1323static DWORD MSFT_ReadLEWords(void *buffer,  DWORD count, TLBContext *pcx,
     1324                              long where )
     1325{
     1326  DWORD ret;
     1327
     1328  ret = MSFT_Read(buffer, count, pcx, where);
     1329  FromLEWords(buffer, ret);
     1330
     1331  return ret;
     1332}
     1333
    11901334static void MSFT_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx)
    11911335{
    1192     TRACE_(typelib)("%s\n", debugstr_guid(pGuid));
    1193 
    11941336    if(offset<0 || pcx->pTblDir->pGuidTab.offset <0){
    11951337        memset(pGuid,0, sizeof(GUID));
     
    11971339    }
    11981340    MSFT_Read(pGuid, sizeof(GUID), pcx, pcx->pTblDir->pGuidTab.offset+offset );
     1341    pGuid->Data1 = FromLEDWord(pGuid->Data1);
     1342    pGuid->Data2 = FromLEWord(pGuid->Data2);
     1343    pGuid->Data3 = FromLEWord(pGuid->Data3);
     1344    TRACE_(typelib)("%s\n", debugstr_guid(pGuid));
    11991345}
    12001346
     
    12071353    BSTR bstrName = NULL;
    12081354
    1209     MSFT_Read(&niName, sizeof(niName), pcx,
    1210                                 pcx->pTblDir->pNametab.offset+offset);
     1355    MSFT_ReadLEDWords(&niName, sizeof(niName), pcx,
     1356                      pcx->pTblDir->pNametab.offset+offset);
    12111357    niName.namelen &= 0xFF; /* FIXME: correct ? */
    12121358    name=TLB_Alloc((niName.namelen & 0xff) +1);
     
    12421388
    12431389    if(offset<0) return NULL;
    1244     MSFT_Read(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset);
     1390    MSFT_ReadLEWords(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset);
    12451391    if(length <= 0) return 0;
    12461392    string=TLB_Alloc(length +1);
     
    12681414}
    12691415/*
    1270  * read a value and fill a VARIANT structure 
     1416 * read a value and fill a VARIANT structure
    12711417 */
    12721418static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
     
    12811427        return;
    12821428    }
    1283     MSFT_Read(&(V_VT(pVar)), sizeof(VARTYPE), pcx,
    1284         pcx->pTblDir->pCustData.offset + offset );
     1429    MSFT_ReadLEWords(&(V_VT(pVar)), sizeof(VARTYPE), pcx,
     1430                     pcx->pTblDir->pCustData.offset + offset );
    12851431    TRACE_(typelib)("Vartype = %x\n", V_VT(pVar));
    12861432    switch (V_VT(pVar)){
     
    12901436        case VT_I4  :
    12911437        case VT_R4  :
    1292         case VT_ERROR   : 
    1293         case VT_BOOL    : 
    1294         case VT_I1  : 
    1295         case VT_UI1 : 
    1296         case VT_UI2 : 
    1297         case VT_UI4 : 
    1298         case VT_INT : 
    1299         case VT_UINT    : 
     1438        case VT_ERROR   :
     1439        case VT_BOOL    :
     1440        case VT_I1  :
     1441        case VT_UI1 :
     1442        case VT_UI2 :
     1443        case VT_UI4 :
     1444        case VT_INT :
     1445        case VT_UINT    :
    13001446        case VT_VOID    : /* FIXME: is this right? */
    1301         case VT_HRESULT : 
     1447        case VT_HRESULT :
    13021448            size=4; break;
    13031449        case VT_R8  :
    13041450        case VT_CY  :
    1305         case VT_DATE    : 
    1306         case VT_I8  : 
    1307         case VT_UI8 : 
     1451        case VT_DATE    :
     1452        case VT_I8  :
     1453        case VT_UI8 :
    13081454        case VT_DECIMAL :  /* FIXME: is this right? */
    13091455        case VT_FILETIME :
     
    13121458        case VT_BSTR    :{
    13131459            char * ptr;
    1314             MSFT_Read(&size, sizeof(INT), pcx, DO_NOT_SEEK );
     1460            MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK );
    13151461            if(size <= 0) {
    13161462                FIXME("BSTR length = %d?\n", size);
     
    13281474    /* FIXME: this will not work AT ALL when the variant contains a pointer */
    13291475        case VT_DISPATCH :
    1330         case VT_VARIANT : 
    1331         case VT_UNKNOWN : 
    1332         case VT_PTR : 
     1476        case VT_VARIANT :
     1477        case VT_UNKNOWN :
     1478        case VT_PTR :
    13331479        case VT_SAFEARRAY :
    1334         case VT_CARRAY  : 
    1335         case VT_USERDEFINED : 
    1336         case VT_LPSTR   : 
    1337         case VT_LPWSTR  : 
    1338         case VT_BLOB    : 
    1339         case VT_STREAM  : 
    1340         case VT_STORAGE : 
    1341         case VT_STREAMED_OBJECT : 
    1342         case VT_STORED_OBJECT   : 
    1343         case VT_BLOB_OBJECT : 
    1344         case VT_CF  : 
    1345         case VT_CLSID   : 
    1346         default: 
    1347             size=0; 
     1480        case VT_CARRAY  :
     1481        case VT_USERDEFINED :
     1482        case VT_LPSTR   :
     1483        case VT_LPWSTR  :
     1484        case VT_BLOB    :
     1485        case VT_STREAM  :
     1486        case VT_STORAGE :
     1487        case VT_STREAMED_OBJECT :
     1488        case VT_STORED_OBJECT   :
     1489        case VT_BLOB_OBJECT :
     1490        case VT_CF  :
     1491        case VT_CLSID   :
     1492        default:
     1493            size=0;
    13481494            FIXME("VARTYPE %d is not supported, setting pointer to NULL\n",
    13491495                V_VT(pVar));
     
    13681514        count++;
    13691515        pNew=TLB_Alloc(sizeof(TLBCustData));
    1370         MSFT_Read(&entry, sizeof(entry), pcx,
    1371             pcx->pTblDir->pCDGuids.offset+offset);
     1516        MSFT_ReadLEDWords(&entry, sizeof(entry), pcx, pcx->pTblDir->pCDGuids.offset+offset);
    13721517        MSFT_ReadGuid(&(pNew->guid), entry.GuidOffset , pcx);
    13731518        MSFT_ReadValue(&(pNew->data), entry.DataOffset, pcx);
     
    13941539}
    13951540
    1396 static void 
     1541static void
    13971542MSFT_DoFuncs(TLBContext*     pcx,
    13981543            ITypeInfoImpl*  pTI,
    1399             int             cFuncs, 
     1544            int             cFuncs,
    14001545            int             cVars,
    1401             int             offset, 
     1546            int             offset,
    14021547            TLBFuncDesc**   pptfd)
    14031548{
    1404     /* 
     1549    /*
    14051550     * member information is stored in a data structure at offset
    14061551     * indicated by the memoffset field of the typeinfo structure
    14071552     * There are several distinctive parts.
    1408      * the first part starts with a field that holds the total length 
     1553     * the first part starts with a field that holds the total length
    14091554     * of this (first) part excluding this field. Then follow the records,
    14101555     * for each member there is one record.
    14111556     *
    14121557     * First entry is always the length of the record (excluding this
    1413      * length word). 
    1414      * Rest of the record depends on the type of the member. If there is 
     1558     * length word).
     1559     * Rest of the record depends on the type of the member. If there is
    14151560     * a field indicating the member type (function variable intereface etc)
    14161561     * I have not found it yet. At this time we depend on the information
     
    14191564     * Second follows an array sized nrMEM*sizeof(INT) with a memeber id
    14201565     * for each member;
    1421      * 
    1422      * Third is a equal sized array with file offsets to the name entry 
     1566     *
     1567     * Third is a equal sized array with file offsets to the name entry
    14231568     * of each member.
    1424      * 
     1569     *
    14251570     * Forth and last (?) part is an array with offsets to the records in the
    14261571     * first part of this file segment.
     
    14351580    TRACE_(typelib)("\n");
    14361581
    1437     MSFT_Read(&infolen, sizeof(INT), pcx, offset);
     1582    MSFT_ReadLEDWords(&infolen, sizeof(INT), pcx, offset);
    14381583
    14391584    for ( i = 0; i < cFuncs ; i++ )
     
    14421587
    14431588        /* name, eventually add to a hash table */
    1444         MSFT_Read(&nameoffset,
    1445                  sizeof(INT),
    1446                  pcx,
    1447                  offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT));
     1589        MSFT_ReadLEDWords(&nameoffset, sizeof(INT), pcx,
     1590                          offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT));
    14481591
    14491592        (*pptfd)->Name = MSFT_ReadName(pcx, nameoffset);
    14501593
    14511594        /* read the function information record */
    1452         MSFT_Read(&reclength, sizeof(INT), pcx, recoffset);
    1453        
     1595        MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset);
     1596
    14541597        reclength &= 0x1ff;
    14551598
    1456         MSFT_Read(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;
     1599        MSFT_ReadLEDWords(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK);
    14571600
    14581601        /* do the attributes */
     
    14631606        {
    14641607            (*pptfd)->helpcontext = pFuncRec->OptAttr[0] ;
    1465            
     1608
    14661609            if ( nrattributes > 1 )
    14671610            {
     
    14861629                        if ( nrattributes > 6 && pFuncRec->FKCCIC & 0x80 )
    14871630                        {
    1488                             MSFT_CustData(pcx, 
     1631                            MSFT_CustData(pcx,
    14891632                                          pFuncRec->OptAttr[6],
    14901633                                          &(*pptfd)->pCustData);
     
    14961639
    14971640        /* fill the FuncDesc Structure */
    1498         MSFT_Read( & (*pptfd)->funcdesc.memid,
    1499                   sizeof(INT), pcx,
    1500                   offset + infolen + ( i + 1) * sizeof(INT));
     1641        MSFT_ReadLEDWords( & (*pptfd)->funcdesc.memid, sizeof(INT), pcx,
     1642                           offset + infolen + ( i + 1) * sizeof(INT));
    15011643
    15021644        (*pptfd)->funcdesc.funckind   =  (pFuncRec->FKCCIC)      & 0x7;
     
    15081650        (*pptfd)->funcdesc.wFuncFlags =   LOWORD(pFuncRec->Flags) ;
    15091651
    1510         MSFT_GetTdesc(pcx, 
    1511                       pFuncRec->DataType,   
     1652        MSFT_GetTdesc(pcx,
     1653                      pFuncRec->DataType,
    15121654                      &(*pptfd)->funcdesc.elemdescFunc.tdesc,
    15131655                      pTI);
     
    15191661            MSFT_ParameterInfo paraminfo;
    15201662
    1521             (*pptfd)->funcdesc.lprgelemdescParam = 
     1663            (*pptfd)->funcdesc.lprgelemdescParam =
    15221664                TLB_Alloc(pFuncRec->nrargs * sizeof(ELEMDESC));
    15231665
    1524             (*pptfd)->pParamDesc = 
     1666            (*pptfd)->pParamDesc =
    15251667                TLB_Alloc(pFuncRec->nrargs * sizeof(TLBParDesc));
    15261668
    1527             MSFT_Read(&paraminfo,
    1528                       sizeof(paraminfo),
    1529                       pcx,
    1530                       recoffset + reclength -
    1531                       pFuncRec->nrargs * sizeof(MSFT_ParameterInfo));
     1669            MSFT_ReadLEDWords(&paraminfo, sizeof(paraminfo), pcx,
     1670                              recoffset + reclength - pFuncRec->nrargs * sizeof(MSFT_ParameterInfo));
    15321671
    15331672            for ( j = 0 ; j < pFuncRec->nrargs ; j++ )
     
    15351674                TYPEDESC* lpArgTypeDesc = 0;
    15361675
    1537                 MSFT_GetTdesc(pcx, 
    1538                               paraminfo.DataType,   
     1676                MSFT_GetTdesc(pcx,
     1677                              paraminfo.DataType,
    15391678                              &(*pptfd)->funcdesc.lprgelemdescParam[j].tdesc,
    15401679                              pTI);
     
    15441683                (*pptfd)->pParamDesc[j].Name = (void *) paraminfo.oName;
    15451684
    1546                 /* SEEK value = jump to offset, 
     1685                /* SEEK value = jump to offset,
    15471686                 * from there jump to the end of record,
    15481687                 * go back by (j-1) arguments
    15491688                 */
    1550                 MSFT_Read( &paraminfo ,
     1689                MSFT_ReadLEDWords( &paraminfo ,
    15511690                           sizeof(MSFT_ParameterInfo), pcx,
    1552                            recoffset + reclength - ((pFuncRec->nrargs - j - 1) 
     1691                           recoffset + reclength - ((pFuncRec->nrargs - j - 1)
    15531692                                               * sizeof(MSFT_ParameterInfo)));
    1554                 lpArgTypeDesc = 
     1693                lpArgTypeDesc =
    15551694                    & ((*pptfd)->funcdesc.lprgelemdescParam[j].tdesc);
    15561695
     
    15681707
    15691708                    case VT_USERDEFINED:
    1570                         MSFT_DoRefType(pcx, pTI, 
     1709                        MSFT_DoRefType(pcx, pTI,
    15711710                                       lpArgTypeDesc->u.hreftype);
    15721711
     
    15861725                TYPEDESC* lpArgTypeDesc;
    15871726
    1588                 (*pptfd)->funcdesc.elemdescFunc = 
     1727                (*pptfd)->funcdesc.elemdescFunc =
    15891728                (*pptfd)->funcdesc.lprgelemdescParam[j];
    15901729
     
    15991738                        break;
    16001739                    case VT_CARRAY:
    1601                         lpArgTypeDesc = 
     1740                        lpArgTypeDesc =
    16021741                        & (lpArgTypeDesc->u.lpadesc->tdescElem);
    16031742
     
    16051744
    16061745                    case VT_USERDEFINED:
    1607                         MSFT_DoRefType(pcx, 
     1746                        MSFT_DoRefType(pcx,
    16081747                                       pTI,
    16091748                                       lpArgTypeDesc->u.hreftype);
     
    16261765
    16271766                /* default value */
    1628                 if ( (PARAMFLAG_FHASDEFAULT & 
     1767                if ( (PARAMFLAG_FHASDEFAULT &
    16291768                      (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) &&
    16301769                     ((pFuncRec->FKCCIC) & 0x1000) )
    16311770                {
    1632                     INT* pInt = (INT *)((char *)pFuncRec + 
    1633                                    reclength - 
     1771                    INT* pInt = (INT *)((char *)pFuncRec +
     1772                                   reclength -
    16341773                                   (pFuncRec->nrargs * 4 + 1) * sizeof(INT) );
    16351774
     
    16391778                    pParamDesc->pparamdescex->cBytes = sizeof(PARAMDESCEX);
    16401779
    1641                     MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), 
     1780                    MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue),
    16421781                        pInt[j], pcx);
    16431782                }
     
    16451784                if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 )
    16461785                {
    1647                     MSFT_CustData(pcx, 
     1786                    MSFT_CustData(pcx,
    16481787                                  pFuncRec->OptAttr[7+j],
    16491788                                  &(*pptfd)->pParamDesc[j].pCustData);
     
    16711810    TRACE_(typelib)("\n");
    16721811
    1673     MSFT_Read(&infolen,sizeof(INT), pcx, offset);
    1674     MSFT_Read(&recoffset,sizeof(INT), pcx, offset + infolen +
    1675         ((cFuncs+cVars)*2+cFuncs + 1)*sizeof(INT));
     1812    MSFT_ReadLEDWords(&infolen,sizeof(INT), pcx, offset);
     1813    MSFT_ReadLEDWords(&recoffset,sizeof(INT), pcx, offset + infolen +
     1814                      ((cFuncs+cVars)*2+cFuncs + 1)*sizeof(INT));
    16761815    recoffset += offset+sizeof(INT);
    16771816    for(i=0;i<cVars;i++){
    16781817        *pptvd=TLB_Alloc(sizeof(TLBVarDesc));
    16791818    /* name, eventually add to a hash table */
    1680         MSFT_Read(&nameoffset, sizeof(INT), pcx,
    1681             offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT));
     1819        MSFT_ReadLEDWords(&nameoffset, sizeof(INT), pcx,
     1820                          offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT));
    16821821        (*pptvd)->Name=MSFT_ReadName(pcx, nameoffset);
    16831822    /* read the variable information record */
    1684         MSFT_Read(&reclength, sizeof(INT), pcx, recoffset);
     1823        MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset);
    16851824        reclength &=0xff;
    1686         MSFT_Read(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;
     1825        MSFT_ReadLEDWords(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK);
    16871826    /* Optional data */
    16881827        if(reclength >(6*sizeof(INT)) )
     
    16941833            (*pptvd)->HelpStringContext=pVarRec->HelpStringContext;
    16951834    /* fill the VarDesc Structure */
    1696         MSFT_Read(&(*pptvd)->vardesc.memid, sizeof(INT), pcx,
    1697             offset + infolen + ( i + 1) * sizeof(INT));
     1835        MSFT_ReadLEDWords(&(*pptvd)->vardesc.memid, sizeof(INT), pcx,
     1836                          offset + infolen + ( i + 1) * sizeof(INT));
    16981837        (*pptvd)->vardesc.varkind = pVarRec->VarKind;
    16991838        (*pptvd)->vardesc.wVarFlags = pVarRec->Flags;
    1700         MSFT_GetTdesc(pcx, pVarRec->DataType,   
     1839        MSFT_GetTdesc(pcx, pVarRec->DataType,
    17011840            &(*pptvd)->vardesc.elemdescVar.tdesc, pTI);
    17021841/*   (*pptvd)->vardesc.lpstrSchema; is reserved (SDK) FIXME?? */
     
    17391878        TRACE_(typelib)("offset %x, masked offset %x\n", offset, offset + (offset & 0xfffffffc));
    17401879
    1741         MSFT_Read(&impinfo, sizeof(impinfo), pcx,
    1742             pcx->pTblDir->pImpInfo.offset + (offset & 0xfffffffc));
     1880        MSFT_ReadLEDWords(&impinfo, sizeof(impinfo), pcx,
     1881                          pcx->pTblDir->pImpInfo.offset + (offset & 0xfffffffc));
    17431882        for(j=0;pImpLib;j++){   /* search the known offsets of all import libraries */
    17441883            if(pImpLib->offset==impinfo.oImpFile) break;
     
    17761915        if(offset<0) break; /* paranoia */
    17771916        *ppImpl=TLB_Alloc(sizeof(**ppImpl));
    1778         MSFT_Read(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset);
    1779         MSFT_DoRefType(pcx, pTI, refrec.reftype); 
     1917        MSFT_ReadLEDWords(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset);
     1918        MSFT_DoRefType(pcx, pTI, refrec.reftype);
    17801919        (*ppImpl)->hRef = refrec.reftype;
    17811920        (*ppImpl)->implflags=refrec.flags;
     
    18001939
    18011940    ptiRet = (ITypeInfoImpl*) ITypeInfo_Constructor();
    1802     MSFT_Read(&tiBase, sizeof(tiBase) ,pcx ,
    1803         pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase));
     1941    MSFT_ReadLEDWords(&tiBase, sizeof(tiBase) ,pcx ,
     1942                      pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase));
    18041943/* this is where we are coming from */
    18051944    ptiRet->pTypeLib = pLibInfo;
     
    18251964    ptiRet->TypeAttr.cbSizeVft=tiBase.cbSizeVft; /* FIXME: this is only the non inherited part */
    18261965    if(ptiRet->TypeAttr.typekind == TKIND_ALIAS)
    1827         MSFT_GetTdesc(pcx, tiBase.datatype1, 
     1966        MSFT_GetTdesc(pcx, tiBase.datatype1,
    18281967            &ptiRet->TypeAttr.tdescAlias, ptiRet);
    18291968
     
    18441983    if(ptiRet->TypeAttr.cFuncs >0 )
    18451984        MSFT_DoFuncs(pcx, ptiRet, ptiRet->TypeAttr.cFuncs,
    1846                     ptiRet->TypeAttr.cVars, 
     1985                    ptiRet->TypeAttr.cVars,
    18471986                    tiBase.memoffset, & ptiRet->funclist);
    18481987    /* variables */
    18491988    if(ptiRet->TypeAttr.cVars >0 )
    18501989        MSFT_DoVars(pcx, ptiRet, ptiRet->TypeAttr.cFuncs,
    1851                    ptiRet->TypeAttr.cVars, 
     1990                   ptiRet->TypeAttr.cVars,
    18521991                   tiBase.memoffset, & ptiRet->varlist);
    18531992    if(ptiRet->TypeAttr.cImplTypes >0 ) {
     
    18551994        {
    18561995        case TKIND_COCLASS:
    1857             MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes , 
     1996            MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes ,
    18581997                tiBase.datatype1);
    18591998            break;
    18601999        case TKIND_DISPATCH:
    18612000            ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType));
    1862            
     2001
    18632002            if (tiBase.datatype1 != -1)
    18642003            {
     
    18832022                (*ppRef)->index            = TLB_REF_USE_GUID;
    18842023                (*ppRef)->pImpTLInfo       = TLB_Alloc(sizeof(TLBImpLib));
    1885                 (*ppRef)->pImpTLInfo->guid = IID_StdOle;             
     2024                (*ppRef)->pImpTLInfo->guid = IID_StdOle;
    18862025                (*ppRef)->pImpTLInfo->name = SysAllocStringLen(NULL,
    18872026                                                              nStdOleLen  + 1);
    1888              
     2027
    18892028                MultiByteToWideChar(CP_ACP,
    18902029                                    MB_PRECOMPOSED,
     
    18932032                                    (*ppRef)->pImpTLInfo->name,
    18942033                                    SysStringLen((*ppRef)->pImpTLInfo->name));
    1895                                  
     2034
    18962035                (*ppRef)->pImpTLInfo->lcid          = 0;
    18972036                (*ppRef)->pImpTLInfo->wVersionMajor = 2;
     
    19302069    int ret = TYPE_E_CANTLOADLIBRARY;
    19312070    DWORD dwSignature = 0;
    1932     HFILE hFile;
     2071    HANDLE hFile;
    19332072
    19342073    TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index);
     
    19502089
    19512090          /* first try to load as *.tlb */
    1952           dwSignature = *((DWORD*) pBase);
     2091          dwSignature = FromLEDWord(*((DWORD*) pBase));
    19532092          if ( dwSignature == MSFT_SIGNATURE)
    19542093          {
     
    19822121            LPVOID pBase = LockResource(hGlobal);
    19832122            DWORD  dwTLBLength = SizeofResource(hinstDLL, hrsrc);
    1984            
     2123
    19852124            if (pBase)
    19862125            {
    19872126              /* try to load as incore resource */
    1988               dwSignature = *((DWORD*) pBase);
     2127              dwSignature = FromLEDWord(*((DWORD*) pBase));
    19892128              if ( dwSignature == MSFT_SIGNATURE)
    19902129              {
     
    20452184    cx.pLibInfo = pTypeLibImpl;
    20462185    cx.length = dwTLBLength;
    2047    
     2186
    20482187    /* read header */
    2049     MSFT_Read((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);
     2188    MSFT_ReadLEDWords((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);
    20502189    TRACE("header:\n");
    20512190    TRACE("\tmagic1=0x%08x ,magic2=0x%08x\n",tlbHeader.magic1,tlbHeader.magic2 );
    2052     if (memcmp(&tlbHeader.magic1,TLBMAGIC2,4)) {
     2191    if (tlbHeader.magic1 != MSFT_SIGNATURE) {
    20532192        FIXME("Header type magic 0x%08x not supported.\n",tlbHeader.magic1);
    20542193        return NULL;
     
    20612200    /* now read the segment directory */
    20622201    TRACE("read segment directory (at %ld)\n",lPSegDir);
    2063     MSFT_Read((void*)&tlbSegDir, sizeof(tlbSegDir), &cx, lPSegDir); 
     2202    MSFT_ReadLEDWords(&tlbSegDir, sizeof(tlbSegDir), &cx, lPSegDir);
    20642203    cx.pTblDir = &tlbSegDir;
    20652204
     
    20982237    {
    20992238            int offset;
    2100             MSFT_Read(&offset, sizeof(offset), &cx, sizeof(tlbHeader));
     2239            MSFT_ReadLEDWords(&offset, sizeof(offset), &cx, sizeof(tlbHeader));
    21012240            pTypeLibImpl->HelpStringDll = MSFT_ReadString(&cx, offset);
    21022241    }
     
    21162255        INT16 td[4];
    21172256        pTypeLibImpl->pTypeDesc = TLB_Alloc( cTD * sizeof(TYPEDESC));
    2118         MSFT_Read(td, sizeof(td), &cx, tlbSegDir.pTypdescTab.offset);
     2257        MSFT_ReadLEWords(td, sizeof(td), &cx, tlbSegDir.pTypdescTab.offset);
    21192258        for(i=0; i<cTD; )
    21202259        {
     
    21382277                pTypeLibImpl->pTypeDesc[i].u.hreftype = MAKELONG(td[2],td[3]);
    21392278            }
    2140             if(++i<cTD) MSFT_Read(td, sizeof(td), &cx, DO_NOT_SEEK);
     2279            if(++i<cTD) MSFT_ReadLEWords(td, sizeof(td), &cx, DO_NOT_SEEK);
    21412280        }
    21422281
     
    21472286            if(tlbSegDir.pArrayDescriptions.offset>0)
    21482287            {
    2149                 MSFT_Read(td, sizeof(td), &cx, tlbSegDir.pArrayDescriptions.offset + (int) pTypeLibImpl->pTypeDesc[i].u.lpadesc);
     2288                MSFT_ReadLEWords(td, sizeof(td), &cx, tlbSegDir.pArrayDescriptions.offset + (int) pTypeLibImpl->pTypeDesc[i].u.lpadesc);
    21502289                pTypeLibImpl->pTypeDesc[i].u.lpadesc = TLB_Alloc(sizeof(ARRAYDESC)+sizeof(SAFEARRAYBOUND)*(td[3]-1));
    21512290
     
    21592298                for(j = 0; j<td[2]; j++)
    21602299                {
    2161                     MSFT_Read(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].cElements,
    2162                         sizeof(INT), &cx, DO_NOT_SEEK);
    2163                     MSFT_Read(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].lLbound,
    2164                         sizeof(INT), &cx, DO_NOT_SEEK);
     2300                    MSFT_ReadLEDWords(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].cElements,
     2301                                      sizeof(INT), &cx, DO_NOT_SEEK);
     2302                    MSFT_ReadLEDWords(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].lLbound,
     2303                                      sizeof(INT), &cx, DO_NOT_SEEK);
    21652304                }
    21662305            }
     
    21842323            *ppImpLib = TLB_Alloc(sizeof(TLBImpLib));
    21852324            (*ppImpLib)->offset = offset - tlbSegDir.pImpFiles.offset;
    2186             MSFT_Read(&oGuid, sizeof(INT), &cx, offset);
    2187 
    2188             MSFT_Read(&(*ppImpLib)->lcid,          sizeof(LCID),   &cx, DO_NOT_SEEK);
    2189             MSFT_Read(&(*ppImpLib)->wVersionMajor, sizeof(WORD),   &cx, DO_NOT_SEEK);
    2190             MSFT_Read(&(*ppImpLib)->wVersionMinor, sizeof(WORD),   &cx, DO_NOT_SEEK);
    2191             MSFT_Read(& size,                      sizeof(UINT16), &cx, DO_NOT_SEEK);
     2325            MSFT_ReadLEDWords(&oGuid, sizeof(INT), &cx, offset);
     2326
     2327            MSFT_ReadLEDWords(&(*ppImpLib)->lcid,         sizeof(LCID),   &cx, DO_NOT_SEEK);
     2328            MSFT_ReadLEWords(&(*ppImpLib)->wVersionMajor, sizeof(WORD),   &cx, DO_NOT_SEEK);
     2329            MSFT_ReadLEWords(&(*ppImpLib)->wVersionMinor, sizeof(WORD),   &cx, DO_NOT_SEEK);
     2330            MSFT_ReadLEWords(& size,                      sizeof(UINT16), &cx, DO_NOT_SEEK);
    21922331
    21932332            size >>= 2;
     
    26562795            }
    26572796        }
    2658        
     2797
    26592798        ppFuncDesc = &((*ppFuncDesc)->next);
    26602799        if(pFunc->next == 0xffff) break;
     
    28022941
    28032942    pHeader = pLib;
    2804    
     2943
    28052944    TRACE("header:\n");
    28062945    TRACE("\tmagic=0x%08lx, file blocks = %d\n", pHeader->SLTG_magic,
    28072946          pHeader->nrOfFileBlks );
    2808     if (memcmp(&pHeader->SLTG_magic, TLBMAGIC1, 4)) {
     2947    if (pHeader->SLTG_magic != SLTG_SIGNATURE) {
    28092948        FIXME("Header type magic 0x%08lx not supported.\n",
    28102949              pHeader->SLTG_magic);
    28112950        return NULL;
    28122951    }
    2813    
     2952
    28142953    /* There are pHeader->nrOfFileBlks - 2 TypeInfo records in this typelib */
    28152954    pTypeLibImpl->TypeInfoCount = pHeader->nrOfFileBlks - 2;
     
    28442983          pBlkEntry[order].next != 0;
    28452984          order = pBlkEntry[order].next - 1, i++) {
    2846 #ifdef __WIN32OS2__
    2847         pBlk = (LPBYTE)pBlk + pBlkEntry[order].len;
    2848 #else
    2849         pBlk += pBlkEntry[order].len;
    2850 #endif
     2985       pBlk = (char*)pBlk + pBlkEntry[order].len;
    28512986    }
    28522987    pLibBlk = pBlk;
     
    28673002
    28683003    ptr = (char*)pLibBlk + len;
    2869    
     3004
    28703005    for(i = 0; i < pTypeLibImpl->TypeInfoCount; i++) {
    28713006        WORD w, extra;
     
    29173052       dust and we should be pointing at the beginning of the name
    29183053       table */
    2919  
     3054
    29203055    pNameTable = (char*)pLibBlk + len;
    29213056
     
    29303065       break;
    29313066   }
    2932    
     3067
    29333068    pNameTable += 0x216;
    29343069
     
    29803115      (*ppTypeInfoImpl)->TypeAttr.wTypeFlags =
    29813116        (pTIHeader->typeflags1 >> 3) | (pTIHeader->typeflags2 << 5);
    2982      
     3117
    29833118      if((pTIHeader->typeflags1 & 7) != 2)
    29843119        FIXME("typeflags1 = %02x\n", pTIHeader->typeflags1);
     
    29943129      switch(pTIHeader->typekind) {
    29953130      case TKIND_ENUM:
    2996         pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable); 
     3131        pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable);
    29973132        break;
    29983133
    29993134      case TKIND_RECORD:
    3000         pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable); 
     3135        pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable);
    30013136        break;
    30023137
     
    30233158      }
    30243159      ppTypeInfoImpl = &((*ppTypeInfoImpl)->next);
    3025 #ifdef __WIN32OS2__
    3026       pBlk = (LPBYTE)pBlk + pBlkEntry[order].len;
    3027 #else
    3028       pBlk += pBlkEntry[order].len;
    3029 #endif
     3160      pBlk = (char*)pBlk + pBlkEntry[order].len;
    30303161    }
    30313162
     
    30513182
    30523183    *ppvObject=NULL;
    3053     if(IsEqualIID(riid, &IID_IUnknown) || 
     3184    if(IsEqualIID(riid, &IID_IUnknown) ||
    30543185       IsEqualIID(riid,&IID_ITypeLib)||
    30553186       IsEqualIID(riid,&IID_ITypeLib2))
     
    30863217
    30873218    --(This->ref);
    3088    
     3219
    30893220    TRACE("(%p)->(%u)\n",This, This->ref);
    30903221
     
    31183249          This->HelpStringDll = NULL;
    31193250      }
    3120    
     3251
    31213252      ITypeInfo_Release((ITypeInfo*) This->pTypeInfo);
    31223253      HeapFree(GetProcessHeap(),0,This);
     
    31283259
    31293260/* ITypeLib::GetTypeInfoCount
    3130  * 
     3261 *
    31313262 * Returns the number of type descriptions in the type library
    31323263 */
     
    31443275static HRESULT WINAPI ITypeLib2_fnGetTypeInfo(
    31453276    ITypeLib2 *iface,
    3146     UINT index, 
     3277    UINT index,
    31473278    ITypeInfo **ppTInfo)
    31483279{
    31493280    int i;
    3150    
     3281
    31513282    ICOM_THIS( ITypeLibImpl, iface);
    31523283    ITypeInfoImpl *pTypeInfo = This->pTypeInfo;
     
    31553286
    31563287    if (!ppTInfo) return E_INVALIDARG;
    3157    
     3288
    31583289    /* search element n in list */
    31593290    for(i=0; i < index; i++)
     
    31653296        return TYPE_E_ELEMENTNOTFOUND;
    31663297      }
    3167     }   
     3298    }
    31683299
    31693300    *ppTInfo = (ITypeInfo *) pTypeInfo;
    3170    
     3301
    31713302    ITypeInfo_AddRef(*ppTInfo);
    31723303    TRACE("-- found (%p)\n",*ppTInfo);
     
    31913322
    31923323    if(!pTKind) return E_INVALIDARG;
    3193    
     3324
    31943325    /* search element n in list */
    31953326    for(i=0; i < index; i++)
     
    32383369    }
    32393370
    3240     TRACE("-- found (%p, %s)\n", 
    3241           pTypeInfo, 
     3371    TRACE("-- found (%p, %s)\n",
     3372          pTypeInfo,
    32423373          debugstr_w(pTypeInfo->Name));
    32433374
     
    32533384 */
    32543385static HRESULT WINAPI ITypeLib2_fnGetLibAttr(
    3255         ITypeLib2 *iface, 
     3386        ITypeLib2 *iface,
    32563387        LPTLIBATTR *ppTLibAttr)
    32573388{
     
    32923423    BSTR *pBstrName,
    32933424    BSTR *pBstrDocString,
    3294     DWORD *pdwHelpContext, 
     3425    DWORD *pdwHelpContext,
    32953426    BSTR *pBstrHelpFile)
    32963427{
    32973428    ICOM_THIS( ITypeLibImpl, iface);
    3298    
     3429
    32993430    HRESULT result = E_INVALIDARG;
    3300    
     3431
    33013432    ITypeInfo *pTInfo;
    33023433
    3303    
     3434
    33043435    TRACE("(%p) index %d Name(%p) DocString(%p) HelpContext(%p) HelpFile(%p)\n",
    33053436        This, index,
    3306         pBstrName, pBstrDocString, 
     3437        pBstrName, pBstrDocString,
    33073438        pdwHelpContext, pBstrHelpFile);
    3308    
     3439
    33093440    if(index<0)
    3310     { 
     3441    {
    33113442        /* documentation for the typelib */
    33123443        if(pBstrName)
     
    33403471        result = S_OK;
    33413472    }
    3342     else 
     3473    else
    33433474    {
    33443475        /* for a typeinfo */
     
    33473478        if(SUCCEEDED(result))
    33483479        {
    3349             result = ITypeInfo_GetDocumentation(pTInfo, 
    3350                                           MEMBERID_NIL, 
     3480            result = ITypeInfo_GetDocumentation(pTInfo,
     3481                                          MEMBERID_NIL,
    33513482                                          pBstrName,
    3352                                           pBstrDocString, 
     3483                                          pBstrDocString,
    33533484                                          pdwHelpContext, pBstrHelpFile);
    3354            
     3485
    33553486            ITypeInfo_Release(pTInfo);
    33563487        }
     
    33983529        for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next)
    33993530            if(!memcmp(szNameBuf,pVInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit;
    3400        
     3531
    34013532    }
    34023533    *pfName=FALSE;
     
    34053536    TRACE("(%p)slow! search for %s: %s found!\n", This,
    34063537          debugstr_w(szNameBuf), *pfName?"NOT":"");
    3407    
     3538
    34083539    return S_OK;
    34093540}
     
    34283559    TLBVarDesc *pVInfo;
    34293560    int i,j = 0;
    3430    
     3561
    34313562    UINT nNameBufLen = SysStringLen(szNameBuf);
    34323563
     
    34513582
    34523583    *pcFound=j;
    3453    
     3584
    34543585    return S_OK;
    34553586}
     
    34763607static HRESULT WINAPI ITypeLib2_fnGetCustData(
    34773608        ITypeLib2 * iface,
    3478         REFGUID guid, 
     3609        REFGUID guid,
    34793610        VARIANT *pVarVal)
    34803611{
     
    34863617      if( IsEqualIID(guid, &pCData->guid)) break;
    34873618    }
    3488    
     3619
    34893620    TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT");
    34903621
     
    35053636 */
    35063637static HRESULT WINAPI ITypeLib2_fnGetLibStatistics(
    3507         ITypeLib2 * iface, 
     3638        ITypeLib2 * iface,
    35083639        ULONG *pcUniqueNames,
    35093640        ULONG *pcchUniqueNames)
     
    35263657 */
    35273658static HRESULT WINAPI ITypeLib2_fnGetDocumentation2(
    3528         ITypeLib2 * iface, 
     3659        ITypeLib2 * iface,
    35293660        INT index,
    35303661        LCID lcid,
     
    35593690      /* for a typeinfo */
    35603691      result=ITypeLib2_GetTypeInfo(iface, index, &pTInfo);
    3561      
     3692
    35623693      if(SUCCEEDED(result))
    3563       { 
     3694      {
    35643695        ITypeInfo2 * pTInfo2;
    3565         result = ITypeInfo_QueryInterface(pTInfo, 
    3566                                           &IID_ITypeInfo2, 
     3696        result = ITypeInfo_QueryInterface(pTInfo,
     3697                                          &IID_ITypeInfo2,
    35673698                                          (LPVOID*) &pTInfo2);
    35683699
    35693700        if(SUCCEEDED(result))
    35703701        {
    3571           result = ITypeInfo2_GetDocumentation2(pTInfo2, 
    3572                                            MEMBERID_NIL, 
     3702          result = ITypeInfo2_GetDocumentation2(pTInfo2,
     3703                                           MEMBERID_NIL,
    35733704                                           lcid,
    3574                                            pbstrHelpString, 
    3575                                            pdwHelpStringContext, 
     3705                                           pbstrHelpString,
     3706                                           pdwHelpStringContext,
    35763707                                           pbstrHelpStringDll);
    3577  
     3708
    35783709          ITypeInfo2_Release(pTInfo2);
    35793710        }
    3580            
     3711
    35813712        ITypeInfo_Release(pTInfo);
    35823713      }
     
    35873718/* ITypeLib2::GetAllCustData
    35883719 *
    3589  * Gets all custom data items for the library. 
     3720 * Gets all custom data items for the library.
    35903721 *
    35913722 */
     
    35973728    TLBCustData *pCData;
    35983729    int i;
    3599     TRACE("(%p) returning %d items\n", This, This->ctCustData); 
     3730    TRACE("(%p) returning %d items\n", This, This->ctCustData);
    36003731    pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM));
    36013732    if(pCustData->prgCustData ){
     
    36613792
    36623793    *ppvObject=NULL;
    3663     if(IsEqualIID(riid, &IID_IUnknown) || 
     3794    if(IsEqualIID(riid, &IID_IUnknown) ||
    36643795            IsEqualIID(riid,&IID_ITypeInfo)||
    36653796            IsEqualIID(riid,&IID_ITypeInfo2))
     
    36943825
    36953826    --(This->ref);
    3696    
     3827
    36973828    TRACE("(%p)->(%u)\n",This, This->ref);
    36983829
     
    37013832      FIXME("destroy child objects\n");
    37023833
    3703       TRACE("destroying ITypeInfo(%p)\n",This); 
     3834      TRACE("destroying ITypeInfo(%p)\n",This);
    37043835      if (This->Name)
    37053836      {
     
    37073838          This->Name = 0;
    37083839      }
    3709      
     3840
    37103841      if (This->DocString)
    37113842      {
     
    37663897    ICOM_THIS( ITypeInfoImpl, iface);
    37673898    int i;
    3768     TLBFuncDesc * pFDesc; 
     3899    TLBFuncDesc * pFDesc;
    37693900    TRACE("(%p) index %d\n", This, index);
    37703901    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next)
     
    37803911/* ITypeInfo::GetVarDesc
    37813912 *
    3782  * Retrieves a VARDESC structure that describes the specified variable. 
     3913 * Retrieves a VARDESC structure that describes the specified variable.
    37833914 *
    37843915 */
     
    37883919    ICOM_THIS( ITypeInfoImpl, iface);
    37893920    int i;
    3790     TLBVarDesc * pVDesc; 
     3921    TLBVarDesc * pVDesc;
    37913922    TRACE("(%p) index %d\n", This, index);
    37923923    for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, pVDesc=pVDesc->next)
     
    38103941{
    38113942    ICOM_THIS( ITypeInfoImpl, iface);
    3812     TLBFuncDesc * pFDesc; 
    3813     TLBVarDesc * pVDesc; 
     3943    TLBFuncDesc * pFDesc;
     3944    TLBVarDesc * pVDesc;
    38143945    int i;
    38153946    TRACE("(%p) memid=0x%08lx Maxname=%d\n", This, memid, cMaxNames);
     
    38904021      */
    38914022      if( This->TypeAttr.typekind != TKIND_DISPATCH) return E_INVALIDARG;
    3892      
     4023
    38934024      if (This->TypeAttr.wTypeFlags & TYPEFLAG_FDISPATCHABLE &&
    38944025          This->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL )
     
    39094040        pImpl = pImpl->next;
    39104041      }
    3911      
     4042
    39124043      if (!pImpl) return TYPE_E_ELEMENTNOTFOUND;
    3913      
     4044
    39144045      *pRefType = pImpl->hRef;
    3915      
     4046
    39164047      TRACE("-- 0x%08lx\n", pImpl->hRef );
    39174048    }
    3918    
     4049
    39194050    return S_OK;
    3920    
     4051
    39214052}
    39224053
    39234054/* ITypeInfo::GetImplTypeFlags
    3924  * 
    3925  * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface 
     4055 *
     4056 * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface
    39264057 * or base interface in a type description.
    39274058 */
     
    39534084{
    39544085    ICOM_THIS( ITypeInfoImpl, iface);
    3955     TLBFuncDesc * pFDesc; 
    3956     TLBVarDesc * pVDesc; 
     4086    TLBFuncDesc * pFDesc;
     4087    TLBVarDesc * pVDesc;
    39574088    HRESULT ret=S_OK;
    39584089
     
    39744105            return ret;
    39754106        }
    3976     }   
     4107    }
    39774108    for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) {
    39784109        if(!lstrcmpiW(*rgszNames, pVDesc->Name)) {
     
    39814112        }
    39824113    }
    3983     /* not found, see if this is and interface with an inheritance */       
    3984     if(This->TypeAttr.typekind==TKIND_INTERFACE && 
     4114    /* not found, see if this is and interface with an inheritance */
     4115    if(This->TypeAttr.typekind==TKIND_INTERFACE &&
    39854116            This->TypeAttr.cImplTypes ){
    39864117        /* recursive search */
    39874118        ITypeInfo *pTInfo;
    3988         ret=ITypeInfo_GetRefTypeInfo(iface, 
     4119        ret=ITypeInfo_GetRefTypeInfo(iface,
    39894120                This->impltypelist->hRef, &pTInfo);
    39904121        if(SUCCEEDED(ret)){
     
    40004131
    40014132/* ITypeInfo::Invoke
    4002  * 
     4133 *
    40034134 * Invokes a method, or accesses a property of an object, that implements the
    40044135 * interface described by the type description.
     
    40184149    case CC_STDCALL:
    40194150
     4151#ifdef __WIN32OS2__
    40204152        switch (nrargs) {
    4021 #ifdef __WIN32OS2__
    40224153        case 0: {
    40234154                DWORD (* WINAPI xfunc)() = func;
     
    40714202        }
    40724203#else
     4204        switch (nrargs) {
    40734205        case 0: {
    40744206                DWORD (WINAPI *xfunc)() = func;
     
    41104242                res = xfunc(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
    41114243                break;
    4112         }
     4244        }
    41134245        case 8: {
    41144246                DWORD (WINAPI *xfunc)(DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD) = func;
     
    41374269}
    41384270
     4271extern int const _argsize(DWORD vt);
     4272
     4273/***********************************************************************
     4274 *              DispCallFunc (OLEAUT32.@)
     4275 */
     4276HRESULT WINAPI
     4277DispCallFunc(
     4278    void* pvInstance, ULONG oVft, CALLCONV cc, VARTYPE vtReturn, UINT cActuals,
     4279    VARTYPE* prgvt, VARIANTARG** prgpvarg, VARIANT* pvargResult
     4280) {
     4281    int i, argsize, argspos;
     4282    DWORD *args;
     4283    HRESULT hres;
     4284
     4285    FIXME("(%p, %ld, %d, %d, %d, %p, %p, %p)\n",
     4286        pvInstance, oVft, cc, vtReturn, cActuals, prgvt, prgpvarg, pvargResult
     4287    );
     4288    argsize = 0;
     4289    for (i=0;i<cActuals;i++) {
     4290        FIXME("arg %d: type %d\n",i,prgvt[i]);
     4291        dump_Variant(prgpvarg[i]);
     4292        argsize += _argsize(prgvt[i]);
     4293    }
     4294    args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*argsize);
     4295    argspos = 0;
     4296    for (i=0;i<cActuals;i++) {
     4297        int arglen;
     4298        VARIANT *arg = prgpvarg[i];
     4299
     4300        arglen = _argsize(prgvt[i]);
     4301        if (V_VT(arg) == prgvt[i]) {
     4302            memcpy(&args[argspos],&V_UNION(arg,lVal), arglen*sizeof(DWORD));
     4303        } else {
     4304            if (prgvt[i] == VT_VARIANT) {
     4305                memcpy(&args[argspos],arg, arglen*sizeof(DWORD));
     4306            } else {
     4307                ERR("Set arg %d to disparg type %d vs %d\n",i,
     4308                        V_VT(arg),prgvt[i]
     4309                );
     4310            }
     4311        }
     4312        argspos += arglen;
     4313    }
     4314
     4315    FIXME("Do not know how to handle pvargResult %p. Expect crash ...\n",pvargResult);
     4316
     4317    hres = _invoke((*(DWORD***)pvInstance)[oVft/4],cc,argsize/4,args);
     4318    HeapFree(GetProcessHeap(),0,args);
     4319    return hres;
     4320}
     4321
    41394322static HRESULT WINAPI ITypeInfo_fnInvoke(
    41404323    ITypeInfo2 *iface,
     
    41484331{
    41494332    ICOM_THIS( ITypeInfoImpl, iface);
    4150     TLBFuncDesc * pFDesc; 
    4151     TLBVarDesc * pVDesc; 
     4333    TLBFuncDesc * pFDesc;
     4334    TLBVarDesc * pVDesc;
    41524335    int i;
    41534336
     
    41644347    if (pFDesc) {
    41654348        dump_TLBFuncDescOne(pFDesc);
     4349        /* dump_FUNCDESC(&pFDesc->funcdesc);*/
    41664350        switch (pFDesc->funcdesc.funckind) {
    41674351        case FUNC_PUREVIRTUAL:
    41684352        case FUNC_VIRTUAL: {
    41694353            DWORD res;
    4170             DWORD *args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*(pFDesc->funcdesc.cParams+1));
    4171             DWORD *args2 = (DWORD*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DWORD)*(pFDesc->funcdesc.cParams));
     4354            int   numargs, numargs2, argspos, args2pos;
     4355            DWORD *args , *args2;
     4356
     4357
     4358            numargs = 1; numargs2 = 0;
     4359            for (i=0;i<pFDesc->funcdesc.cParams;i++) {
     4360                if (i<pDispParams->cArgs)
     4361                    numargs += _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt);
     4362                else {
     4363                    numargs     += 1; /* sizeof(lpvoid) */
     4364                    numargs2    += _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt);
     4365                }
     4366            }
     4367
     4368            args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*numargs);
     4369            args2 = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*numargs2);
     4370
    41724371            args[0] = (DWORD)pIUnk;
    4173 
     4372            argspos = 1; args2pos = 0;
    41744373            for (i=0;i<pFDesc->funcdesc.cParams;i++) {
     4374                int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt);
    41754375                if (i<pDispParams->cArgs) {
    4176                     TRACE("set %d to disparg type %d vs %d\n",i,
    4177                             V_VT(&pDispParams->rgvarg[pDispParams->cArgs-i-1]),
    4178                             pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt
    4179                     );
    4180                     args[i+1] = V_UNION(&pDispParams->rgvarg[pDispParams->cArgs-i-1],lVal);
     4376                    VARIANT *arg = &pDispParams->rgvarg[pDispParams->cArgs-i-1];
     4377                    TYPEDESC *tdesc = &pFDesc->funcdesc.lprgelemdescParam[i].tdesc;
     4378
     4379                    if (V_VT(arg) == tdesc->vt) {
     4380                        memcpy(&args[argspos],&V_UNION(arg,lVal), arglen*sizeof(DWORD));
     4381                    } else {
     4382                        if (tdesc->vt == VT_VARIANT) {
     4383                            memcpy(&args[argspos],arg, arglen*sizeof(DWORD));
     4384                        } else {
     4385                            ERR("Set arg %d to disparg type %d vs %d\n",i,
     4386                                    V_VT(arg),tdesc->vt
     4387                            );
     4388                        }
     4389                    }
     4390                    argspos += arglen;
    41814391                } else {
    41824392                    TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i].tdesc);
    4183                     TRACE("set %d to pointer for get (type is %d)\n",i,tdesc->vt);
     4393                    if (tdesc->vt != VT_PTR)
     4394                        FIXME("set %d to pointer for get (type is %d)\n",i,tdesc->vt);
    41844395                    /*FIXME: give pointers for the rest, so propertyget works*/
    4185                     args[i+1] = (DWORD)&args2[i];
    4186 
    4187                     /* If pointer to variant, pass reference to variant
    4188                      * in result variant array.
    4189                      */
     4396                    args[argspos] = (DWORD)&args2[args2pos];
     4397
     4398                    /* If pointer to variant, pass reference it. */
    41904399                    if ((tdesc->vt == VT_PTR) &&
    41914400                        (tdesc->u.lptdesc->vt == VT_VARIANT) &&
    41924401                        pVarResult
    41934402                    )
    4194                         args[i+1] = (DWORD)(pVarResult+(i-pDispParams->cArgs));
     4403                        args[argspos]= (DWORD)pVarResult;
     4404                    argspos     += 1;
     4405                    args2pos    += arglen;
    41954406                }
    41964407            }
     
    42024413            res = _invoke((*(DWORD***)pIUnk)[pFDesc->funcdesc.oVft/4],
    42034414                    pFDesc->funcdesc.callconv,
    4204                     pFDesc->funcdesc.cParams+1,
     4415                    numargs,
    42054416                    args
    42064417            );
    42074418            if (pVarResult && (dwFlags & (DISPATCH_PROPERTYGET))) {
     4419                args2pos = 0;
    42084420                for (i=0;i<pFDesc->funcdesc.cParams-pDispParams->cArgs;i++) {
     4421                    int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt);
    42094422                    TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i+pDispParams->cArgs].tdesc);
    42104423                    /* If we are a pointer to a variant, we are done already */
     
    42124425                        continue;
    42134426
    4214                     VariantInit(&pVarResult[i]);
    4215                     V_UNION(pVarResult+i,intVal) = args2[i+pDispParams->cArgs];
     4427                    VariantInit(pVarResult);
     4428                    memcpy(&V_UNION(pVarResult,intVal),&args2[args2pos],arglen*sizeof(DWORD));
    42164429
    42174430                    if (tdesc->vt == VT_PTR)
    42184431                        tdesc = tdesc->u.lptdesc;
    4219                     V_VT(pVarResult+i) = tdesc->vt;
     4432                    V_VT(pVarResult) = tdesc->vt;
    42204433
    42214434                    /* HACK: VB5 likes this.
     
    42254438                     */
    42264439                    if ((tdesc->vt == VT_PTR) && (dwFlags & DISPATCH_METHOD))
    4227                         V_VT(pVarResult+i) = VT_DISPATCH;
    4228                     TRACE("storing into variant: [%d]\n", i);
    4229                     dump_Variant(pVarResult+i);
     4440                        V_VT(pVarResult) = VT_DISPATCH;
     4441                    TRACE("storing into variant:\n");
     4442                    dump_Variant(pVarResult);
     4443                    args2pos += arglen;
    42304444                }
    42314445            }
     
    42844498
    42854499/* ITypeInfo::GetDocumentation
    4286  * 
     4500 *
    42874501 * Retrieves the documentation string, the complete Help file name and path,
    42884502 * and the context ID for the Help topic for a specified type description.
     4503 *
     4504 * (Can be tested by the Visual Basic Editor in Word for instance.)
    42894505 */
    42904506static HRESULT WINAPI ITypeInfo_fnGetDocumentation( ITypeInfo2 *iface,
     
    42934509{
    42944510    ICOM_THIS( ITypeInfoImpl, iface);
    4295     TLBFuncDesc * pFDesc; 
    4296     TLBVarDesc * pVDesc; 
     4511    TLBFuncDesc * pFDesc;
     4512    TLBVarDesc * pVDesc;
    42974513    TRACE("(%p) memid %ld Name(%p) DocString(%p)"
    42984514          " HelpContext(%p) HelpFile(%p)\n",
     
    43214537    for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next)
    43224538        if(pVDesc->vardesc.memid==memid){
    4323             FIXME("Not implemented\n");
    4324             return S_OK;
     4539            if(pBstrName)
     4540              *pBstrName = SysAllocString(pVDesc->Name);
     4541            if(pBstrDocString)
     4542              *pBstrDocString=SysAllocString(pVDesc->HelpString);
     4543            if(pdwHelpContext)
     4544              *pdwHelpContext=pVDesc->HelpContext;
     4545            return S_OK;
    43254546        }
    43264547    }
     
    43294550
    43304551/*  ITypeInfo::GetDllEntry
    4331  * 
     4552 *
    43324553 * Retrieves a description or specification of an entry point for a function
    43334554 * in a DLL.
     
    43384559{
    43394560    ICOM_THIS( ITypeInfoImpl, iface);
    4340     FIXME("(%p) stub!\n", This);
     4561    TLBFuncDesc *pFDesc;
     4562
     4563    FIXME("(%p, memid %lx, %d, %p, %p, %p), partial stub!\n", This, memid, invKind, pBstrDllName, pBstrName, pwOrdinal);
     4564
     4565    for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next)
     4566        if(pFDesc->funcdesc.memid==memid){
     4567            dump_TypeInfo(This);
     4568            dump_TLBFuncDescOne(pFDesc);
     4569
     4570            /* FIXME: This is wrong, but how do you find that out? */
     4571            if (pBstrDllName) {
     4572                const WCHAR oleaut32W[] = {'O','L','E','A','U','T','3','2','.','D','L','L',0};
     4573                *pBstrDllName = SysAllocString(oleaut32W);
     4574            }
     4575
     4576            if (HIWORD(pFDesc->Entry) && (pFDesc->Entry != (void*)-1)) {
     4577                if (pBstrName)
     4578                    *pBstrName = SysAllocString(pFDesc->Entry);
     4579                if (pwOrdinal)
     4580                    *pwOrdinal = -1;
     4581                return S_OK;
     4582            }
     4583            if (pBstrName)
     4584                *pBstrName = NULL;
     4585            if (pwOrdinal)
     4586                *pwOrdinal = (DWORD)pFDesc->Entry;
     4587            return S_OK;
     4588        }
    43414589    return E_FAIL;
    43424590}
    43434591
    43444592/* ITypeInfo::GetRefTypeInfo
    4345  * 
     4593 *
    43464594 * If a type description references other type descriptions, it retrieves
    43474595 * the referenced type descriptions.
     
    43564604
    43574605
    4358     if (hRefType == -1 && 
     4606    if (hRefType == -1 &&
    43594607        (((ITypeInfoImpl*) This)->TypeAttr.typekind   == TKIND_DISPATCH) &&
    43604608        (((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags &  TYPEFLAG_FDUAL))
    43614609    {
    4362           /* when we meet a DUAL dispinterface, we must create the interface 
     4610          /* when we meet a DUAL dispinterface, we must create the interface
    43634611          * version of it.
    43644612          */
    43654613          ITypeInfoImpl* pTypeInfoImpl = (ITypeInfoImpl*) ITypeInfo_Constructor();
    43664614
    4367                
     4615
    43684616          /* the interface version contains the same information as the dispinterface
    43694617           * copy the contents of the structs.
     
    43714619          *pTypeInfoImpl = *This;
    43724620          pTypeInfoImpl->ref = 1;
    4373                
     4621
    43744622          /* change the type to interface */
    43754623          pTypeInfoImpl->TypeAttr.typekind = TKIND_INTERFACE;
    4376          
     4624
    43774625          *ppTInfo = (ITypeInfo*) pTypeInfoImpl;
    43784626
     
    44224670            if(SUCCEEDED(result)) {
    44234671                if(pRefType->index == TLB_REF_USE_GUID)
    4424                     result = ITypeLib2_GetTypeInfoOfGuid(pTLib, 
    4425                                                          &pRefType->guid, 
     4672                    result = ITypeLib2_GetTypeInfoOfGuid(pTLib,
     4673                                                         &pRefType->guid,
    44264674                                                         ppTInfo);
    44274675                else
     
    44404688
    44414689/* ITypeInfo::AddressOfMember
    4442  * 
     4690 *
    44434691 * Retrieves the addresses of static functions or variables, such as those
    44444692 * defined in a DLL.
     
    44534701
    44544702/* ITypeInfo::CreateInstance
    4455  * 
    4456  * Creates a new instance of a type that describes a component object class 
     4703 *
     4704 * Creates a new instance of a type that describes a component object class
    44574705 * (coclass).
    44584706 */
    4459 static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, 
    4460         IUnknown *pUnk, REFIID riid, VOID  **ppvObj) 
     4707static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface,
     4708        IUnknown *pUnk, REFIID riid, VOID  **ppvObj)
    44614709{
    44624710    ICOM_THIS( ITypeInfoImpl, iface);
     
    44784726
    44794727/* ITypeInfo::GetContainingTypeLib
    4480  * 
     4728 *
    44814729 * Retrieves the containing type library and the index of the type description
    44824730 * within that type library.
     
    45514799 * Returns the type flags without any allocations. This returns a DWORD type
    45524800 * flag, which expands the type flags without growing the TYPEATTR (type
    4553  * attribute). 
     4801 * attribute).
    45544802 *
    45554803 */
     
    45764824    HRESULT result;
    45774825    /* FIXME: should check for invKind??? */
    4578     for(i=0, pFuncInfo=This->funclist;pFuncInfo && 
     4826    for(i=0, pFuncInfo=This->funclist;pFuncInfo &&
    45794827            memid != pFuncInfo->funcdesc.memid; i++, pFuncInfo=pFuncInfo->next);
    45804828    if(pFuncInfo){
     
    45934841 *
    45944842 * Binds to a specific member based on a known DISPID, where the member name
    4595  * is not known (for example, when binding to a default member). 
     4843 * is not known (for example, when binding to a default member).
    45964844 *
    45974845 */
     
    46034851    int i;
    46044852    HRESULT result;
    4605     for(i=0, pVarInfo=This->varlist; pVarInfo && 
     4853    for(i=0, pVarInfo=This->varlist; pVarInfo &&
    46064854            memid != pVarInfo->vardesc.memid; i++, pVarInfo=pVarInfo->next)
    46074855        ;
     
    46564904    ICOM_THIS( ITypeInfoImpl, iface);
    46574905    TLBCustData *pCData=NULL;
    4658     TLBFuncDesc * pFDesc; 
     4906    TLBFuncDesc * pFDesc;
    46594907    int i;
    46604908    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++,
     
    46854933        REFGUID guid,
    46864934        VARIANT *pVarVal)
    4687 {   
     4935{
    46884936    ICOM_THIS( ITypeInfoImpl, iface);
    46894937    TLBCustData *pCData=NULL;
    4690     TLBFuncDesc * pFDesc; 
     4938    TLBFuncDesc * pFDesc;
    46914939    int i;
    46924940
     
    46944942
    46954943    if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams)
    4696         for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; 
     4944        for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData;
    46974945                pCData = pCData->next)
    46984946            if( IsEqualIID(guid, &pCData->guid)) break;
     
    47184966        REFGUID guid,
    47194967        VARIANT *pVarVal)
    4720 {   
     4968{
    47214969    ICOM_THIS( ITypeInfoImpl, iface);
    47224970    TLBCustData *pCData=NULL;
    4723     TLBVarDesc * pVDesc; 
     4971    TLBVarDesc * pVDesc;
    47244972    int i;
    47254973
     
    47545002        REFGUID guid,
    47555003        VARIANT *pVarVal)
    4756 {   
     5004{
    47575005    ICOM_THIS( ITypeInfoImpl, iface);
    47585006    TLBCustData *pCData=NULL;
    4759     TLBImplType * pRDesc; 
     5007    TLBImplType * pRDesc;
    47605008    int i;
    47615009
     
    47695017      }
    47705018    }
    4771    
     5019
    47725020    TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT");
    47735021
     
    47825030
    47835031/* ITypeInfo2::GetDocumentation2
    4784  * 
     5032 *
    47855033 * Retrieves the documentation string, the complete Help file name and path,
    47865034 * the localization context to use, and the context ID for the library Help
     
    47975045{
    47985046    ICOM_THIS( ITypeInfoImpl, iface);
    4799     TLBFuncDesc * pFDesc; 
    4800     TLBVarDesc * pVDesc; 
     5047    TLBFuncDesc * pFDesc;
     5048    TLBVarDesc * pVDesc;
    48015049    TRACE("(%p) memid %ld lcid(0x%lx)  HelpString(%p) "
    48025050          "HelpStringContext(%p) HelpStringDll(%p)\n",
     
    48455093/* ITypeInfo2::GetAllCustData
    48465094 *
    4847  * Gets all custom data items for the Type info. 
     5095 * Gets all custom data items for the Type info.
    48485096 *
    48495097 */
     
    48565104    int i;
    48575105
    4858     TRACE("(%p) returning %d items\n", This, This->ctCustData); 
     5106    TRACE("(%p) returning %d items\n", This, This->ctCustData);
    48595107
    48605108    pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM));
     
    48845132    ICOM_THIS( ITypeInfoImpl, iface);
    48855133    TLBCustData *pCData;
    4886     TLBFuncDesc * pFDesc; 
     5134    TLBFuncDesc * pFDesc;
    48875135    int i;
    4888     TRACE("(%p) index %d\n", This, index); 
     5136    TRACE("(%p) index %d\n", This, index);
    48895137    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++,
    48905138            pFDesc=pFDesc->next)
     
    49205168    ICOM_THIS( ITypeInfoImpl, iface);
    49215169    TLBCustData *pCData=NULL;
    4922     TLBFuncDesc * pFDesc; 
     5170    TLBFuncDesc * pFDesc;
    49235171    int i;
    4924     TRACE("(%p) index %d\n", This, indexFunc); 
     5172    TRACE("(%p) index %d\n", This, indexFunc);
    49255173    for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++,
    49265174            pFDesc=pFDesc->next)
    49275175        ;
    49285176    if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams){
    4929         pCustData->prgCustData = 
     5177        pCustData->prgCustData =
    49305178            TLB_Alloc(pFDesc->pParamDesc[indexParam].ctCustData *
    49315179                    sizeof(CUSTDATAITEM));
     
    49575205    ICOM_THIS( ITypeInfoImpl, iface);
    49585206    TLBCustData *pCData;
    4959     TLBVarDesc * pVDesc; 
     5207    TLBVarDesc * pVDesc;
    49605208    int i;
    4961     TRACE("(%p) index %d\n", This, index); 
     5209    TRACE("(%p) index %d\n", This, index);
    49625210    for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++,
    49635211            pVDesc=pVDesc->next)
     
    49955243    ICOM_THIS( ITypeInfoImpl, iface);
    49965244    TLBCustData *pCData;
    4997     TLBImplType * pRDesc; 
     5245    TLBImplType * pRDesc;
    49985246    int i;
    4999     TRACE("(%p) index %d\n", This, index); 
     5247    TRACE("(%p) index %d\n", This, index);
    50005248    for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++,
    50015249            pRDesc=pRDesc->next)
     
    50215269}
    50225270
    5023 static ICOM_VTABLE(ITypeInfo2) tinfvt = 
     5271static ICOM_VTABLE(ITypeInfo2) tinfvt =
    50245272{
    50255273    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/oleaut32/typelib.h

    r8640 r9400  
    2525#include "wine/windef16.h"
    2626
    27 #define TLBMAGIC2 "MSFT"
    28 #define TLBMAGIC1 "SLTG"
    2927#define HELPDLLFLAG (0x0100)
    3028#define DO_NOT_SEEK (-1)
     
    138136        INT     helpcontext;    /* */
    139137        INT     oCustData;          /* offset in customer data table */
     138#ifdef WORDS_BIGENDIAN
     139        INT16   cbSizeVft;      /* virtual table size, not including inherits */
     140        INT16   cImplTypes;     /* nr of implemented interfaces */
     141#else
    140142        INT16   cImplTypes;     /* nr of implemented interfaces */
    141143        INT16   cbSizeVft;      /* virtual table size, not including inherits */
     144#endif
    142145/*050*/ INT     size;           /* size in bytes, at least for structures */
    143146        /* FIXME: name of this field */
     
    165168    INT   DataType;     /* data type of the memeber, eg return of function */
    166169    INT   Flags;        /* something to do with attribute flags (LOWORD) */
     170#ifdef WORDS_BIGENDIAN
     171    INT16 res3;         /* some offset into dunno what */
     172    INT16 VtableOffset; /* offset in vtable */
     173#else
    167174    INT16 VtableOffset; /* offset in vtable */
    168175    INT16 res3;         /* some offset into dunno what */
     176#endif
    169177    INT   FKCCIC;       /* bit string with the following  */
    170178                        /* meaning (bit 0 is the msb): */
     
    175183                        /* Invokation kind (bits 9-12 ) */
    176184                        /* function kind (eg virtual), bits 13-15  */
     185#ifdef WORDS_BIGENDIAN
     186    INT16 nroargs;      /* nr of optional arguments */
     187    INT16 nrargs;       /* number of arguments (including optional ????) */
     188#else
    177189    INT16 nrargs;       /* number of arguments (including optional ????) */
    178190    INT16 nroargs;      /* nr of optional arguments */
     191#endif
    179192    /* optional attribute fields, the number of them is variable */
    180193    INT   OptAttr[1];
     
    209222    INT   DataType;     /* data type of the variable */
    210223    INT   Flags;        /* VarFlags (LOWORD) */
     224#ifdef WORDS_BIGENDIAN
     225    INT16 res3;         /* some offset into dunno what */
     226    INT16 VarKind;      /* VarKind */
     227#else
    211228    INT16 VarKind;      /* VarKind */
    212229    INT16 res3;         /* some offset into dunno what */
     230#endif
    213231    INT   OffsValue;    /* value of the variable or the offset  */
    214232                        /* in the data structure */
     
    558576extern DWORD _invoke(LPVOID func,CALLCONV callconv, int nrargs, DWORD *args);
    559577
     578#ifdef __WIN32OS2__
     579#ifdef DEBUG
     580extern void dump_Variant(VARIANT * pvar);
     581#else
     582#define  dump_Variant(a)
     583#endif
     584#else
     585extern void dump_Variant(VARIANT * pvar);
     586#endif
     587
    560588#include "poppack.h"
    561589
    562590/*---------------------------END--------------------------------------------*/
    563591#endif
    564 
    565 
  • trunk/src/oleaut32/variant.c

    r8450 r9400  
    3636
    3737#include "config.h"
    38  
     38
    3939#include <string.h>
    4040#include <stdlib.h>
     
    5353#include "winerror.h"
    5454#include "parsedt.h"
     55#include "typelib.h"
    5556
    5657WINE_DEFAULT_DEBUG_CHANNEL(ole);
     
    100101 * 400 then it is a leap year.
    101102 */
    102 /* According to postgreSQL date parsing functions there is
    103  * a leap year when this expression is true.
    104  * (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
    105  * So according to this there is 365.2515 days in one year.
    106  * One + every four years: 1/4 -> 365.25
    107  * One - every 100 years: 1/100 -> 365.01
    108  * One + every 400 years: 1/400 -> 365.0025
    109  */
    110 /* static const double DAYS_IN_ONE_YEAR = 365.2515;
     103
     104/*
     105 * Use 365 days/year and a manual calculation for leap year days
     106 * to keep arithmetic simple
     107 */
     108static const double DAYS_IN_ONE_YEAR = 365.0;
     109
     110/*
     111 * Token definitions for Varient Formatting
     112 * Worked out by experimentation on a w2k machine. Doesnt appear to be
     113 *   documented anywhere obviously so keeping definitions internally
    111114 *
    112  *  ^^  Might this be the key to an easy way to factor large prime numbers?
    113  *  Let's try using arithmetic.  <lawson_whitney@juno.com> 7 Mar 2000
    114  */
    115 static const double DAYS_IN_ONE_YEAR = 365.2425;
    116 
     115 */
     116/* Pre defined tokens */
     117#define TOK_COPY 0x00
     118#define TOK_END  0x02
     119#define LARGEST_TOKENID 6
     120
     121/* Mapping of token name to id put into the tokenized form
     122   Note testing on W2K shows aaaa and oooo are not parsed??!! */
     123#define TOK_COLON  0x03
     124#define TOK_SLASH  0x04
     125#define TOK_c      0x05
     126#define TOK_d      0x08
     127#define TOK_dd     0x09
     128#define TOK_ddd    0x0a
     129#define TOK_dddd   0x0b
     130#define TOK_ddddd  0x0c
     131#define TOK_dddddd 0x0d
     132#define TOK_w      0x0f
     133#define TOK_ww     0x10
     134#define TOK_m      0x11
     135#define TOK_mm     0x12
     136#define TOK_mmm    0x13
     137#define TOK_mmmm   0x14
     138#define TOK_q      0x06
     139#define TOK_y      0x15
     140#define TOK_yy     0x16
     141#define TOK_yyyy   0x18
     142#define TOK_h      0x1e
     143#define TOK_Hh     0x1f
     144#define TOK_N      0x1a
     145#define TOK_Nn     0x1b
     146#define TOK_S      0x1c
     147#define TOK_Ss     0x1d
     148#define TOK_ttttt  0x07
     149#define TOK_AMsPM  0x2f
     150#define TOK_amspm  0x32
     151#define TOK_AsP    0x30
     152#define TOK_asp    0x33
     153#define TOK_AMPM   0x2e
     154
     155typedef struct tagFORMATTOKEN {
     156    char  *str;
     157    BYTE   tokenSize;
     158    BYTE   tokenId;
     159    int    varTypeRequired;
     160} FORMATTOKEN;
     161
     162typedef struct tagFORMATHDR {
     163    BYTE   len;
     164    BYTE   hex3;
     165    BYTE   hex6;
     166    BYTE   reserved[8];
     167} FORMATHDR;
     168
     169FORMATTOKEN formatTokens[] = {           /* FIXME: Only date formats so far */
     170    {":"     ,   1,  TOK_COLON  , 0},
     171    {"/"     ,   1,  TOK_SLASH  , 0},
     172    {"c"     ,   1,  TOK_c      , VT_DATE},
     173    {"dddddd",   6,  TOK_dddddd , VT_DATE},
     174    {"ddddd" ,   5,  TOK_ddddd  , VT_DATE},
     175    {"dddd"  ,   4,  TOK_dddd   , VT_DATE},
     176    {"ddd"   ,   3,  TOK_ddd    , VT_DATE},
     177    {"dd"    ,   2,  TOK_dd     , VT_DATE},
     178    {"d"     ,   1,  TOK_d      , VT_DATE},
     179    {"ww"    ,   2,  TOK_ww     , VT_DATE},
     180    {"w"     ,   1,  TOK_w      , VT_DATE},
     181    {"mmmm"  ,   4,  TOK_mmmm   , VT_DATE},
     182    {"mmm"   ,   3,  TOK_mmm    , VT_DATE},
     183    {"mm"    ,   2,  TOK_mm     , VT_DATE},
     184    {"m"     ,   1,  TOK_m      , VT_DATE},
     185    {"q"     ,   1,  TOK_q      , VT_DATE},
     186    {"yyyy"  ,   4,  TOK_yyyy   , VT_DATE},
     187    {"yy"    ,   2,  TOK_yy     , VT_DATE},
     188    {"y"     ,   1,  TOK_y      , VT_DATE},
     189    {"h"     ,   1,  TOK_h      , VT_DATE},
     190    {"Hh"    ,   2,  TOK_Hh     , VT_DATE},
     191    {"Nn"    ,   2,  TOK_Nn     , VT_DATE},
     192    {"N"     ,   1,  TOK_N      , VT_DATE},
     193    {"S"     ,   1,  TOK_S      , VT_DATE},
     194    {"Ss"    ,   2,  TOK_Ss     , VT_DATE},
     195    {"ttttt" ,   5,  TOK_ttttt  , VT_DATE},
     196    {"AM/PM" ,   5,  TOK_AMsPM  , VT_DATE},
     197    {"am/pm" ,   5,  TOK_amspm  , VT_DATE},
     198    {"A/P"   ,   3,  TOK_AsP    , VT_DATE},
     199    {"a/p"   ,   3,  TOK_asp    , VT_DATE},
     200    {"AMPM"  ,   4,  TOK_AMPM   , VT_DATE},
     201    {0x00    ,   0,  0          , VT_NULL}
     202};
    117203
    118204/******************************************************************************
     
    248334    int leapYear = 0;
    249335
    250     if( (pTm->tm_year - 1900) < 0 ) return FALSE;
     336    /* Hmmm... An uninitialized Date in VB is December 30 1899 so
     337       Start at 0. This is the way DATE is defined. */
    251338
    252339    /* Start at 1. This is the way DATE is defined.
     
    257344    *pDateOut = 1;
    258345
    259     /* Add the number of days corresponding to
    260      * tm_year.
    261      */
    262     *pDateOut += (pTm->tm_year - 1900) * 365;
    263 
    264     /* Add the leap days in the previous years between now and 1900.
    265      * Note a leap year is one that is a multiple of 4
    266      * but not of a 100.  Except if it is a multiple of
    267      * 400 then it is a leap year.
    268      */
    269     *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
    270     *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
    271     *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
    272 
    273     /* Set the leap year flag if the
    274      * current year specified by tm_year is a
    275      * leap year. This will be used to add a day
    276      * to the day count.
    277      */
    278     if( isleap( pTm->tm_year ) )
    279         leapYear = 1;
    280 
    281     /* Add the number of days corresponding to
    282      * the month.
    283      */
    284     switch( pTm->tm_mon )
    285     {
    286     case 2:
    287         *pDateOut += 31;
    288         break;
    289     case 3:
    290         *pDateOut += ( 59 + leapYear );
    291         break;
    292     case 4:
    293         *pDateOut += ( 90 + leapYear );
    294         break;
    295     case 5:
    296         *pDateOut += ( 120 + leapYear );
    297         break;
    298     case 6:
    299         *pDateOut += ( 151 + leapYear );
    300         break;
    301     case 7:
    302         *pDateOut += ( 181 + leapYear );
    303         break;
    304     case 8:
    305         *pDateOut += ( 212 + leapYear );
    306         break;
    307     case 9:
    308         *pDateOut += ( 243 + leapYear );
    309         break;
    310     case 10:
    311         *pDateOut += ( 273 + leapYear );
    312         break;
    313     case 11:
    314         *pDateOut += ( 304 + leapYear );
    315         break;
    316     case 12:
    317         *pDateOut += ( 334 + leapYear );
    318         break;
     346    if( (pTm->tm_year - 1900) >= 0 ) {
     347
     348        /* Add the number of days corresponding to
     349         * tm_year.
     350         */
     351        *pDateOut += (pTm->tm_year - 1900) * 365;
     352
     353        /* Add the leap days in the previous years between now and 1900.
     354         * Note a leap year is one that is a multiple of 4
     355         * but not of a 100.  Except if it is a multiple of
     356         * 400 then it is a leap year.
     357         * Copied + reversed functionality into TmToDate
     358         */
     359        *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
     360        *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
     361        *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
     362
     363        /* Set the leap year flag if the
     364         * current year specified by tm_year is a
     365         * leap year. This will be used to add a day
     366         * to the day count.
     367         */
     368        if( isleap( pTm->tm_year ) )
     369            leapYear = 1;
     370
     371        /* Add the number of days corresponding to
     372         * the month. (remember tm_mon is 0..11)
     373         */
     374        switch( pTm->tm_mon )
     375        {
     376        case 1:
     377            *pDateOut += 31;
     378            break;
     379        case 2:
     380            *pDateOut += ( 59 + leapYear );
     381            break;
     382        case 3:
     383            *pDateOut += ( 90 + leapYear );
     384            break;
     385        case 4:
     386            *pDateOut += ( 120 + leapYear );
     387            break;
     388        case 5:
     389            *pDateOut += ( 151 + leapYear );
     390            break;
     391        case 6:
     392            *pDateOut += ( 181 + leapYear );
     393            break;
     394        case 7:
     395            *pDateOut += ( 212 + leapYear );
     396            break;
     397        case 8:
     398            *pDateOut += ( 243 + leapYear );
     399            break;
     400        case 9:
     401            *pDateOut += ( 273 + leapYear );
     402            break;
     403        case 10:
     404            *pDateOut += ( 304 + leapYear );
     405            break;
     406        case 11:
     407            *pDateOut += ( 334 + leapYear );
     408            break;
     409        }
     410        /* Add the number of days in this month.
     411         */
     412        *pDateOut += pTm->tm_mday;
     413
     414        /* Add the number of seconds, minutes, and hours
     415         * to the DATE. Note these are the fracionnal part
     416         * of the DATE so seconds / number of seconds in a day.
     417         */
     418    } else {
     419        *pDateOut = 0;
    319420    }
    320     /* Add the number of days in this month.
    321      */
    322     *pDateOut += pTm->tm_mday;
    323 
    324     /* Add the number of seconds, minutes, and hours
    325      * to the DATE. Note these are the fracionnal part
    326      * of the DATE so seconds / number of seconds in a day.
    327      */
     421
    328422    *pDateOut += pTm->tm_hour / 24.0;
    329423    *pDateOut += pTm->tm_min / 1440.0;
     
    346440 * Returns TRUE if successful.
    347441 */
    348 static BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
     442BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
    349443{
    350444    double decimalPart = 0.0;
    351445    double wholePart = 0.0;
    352 
    353     /* Do not process dates smaller than January 1, 1900.
    354      * Which corresponds to 2.0 in the windows DATE format.
    355      */
    356     if( dateIn < 2.0 ) return FALSE;
    357446
    358447    memset(pTm,0,sizeof(*pTm));
     
    365454     * This simplifies the processing of the DATE value.
    366455     */
     456    decimalPart = fmod( dateIn, 1.0 ); /* Do this before the -1, otherwise 0.xx goes negative */
    367457    dateIn -= 1.0;
    368 
    369458    wholePart = (double) floor( dateIn );
    370     decimalPart = fmod( dateIn, wholePart );
    371459
    372460    if( !(dwFlags & VAR_TIMEVALUEONLY) )
    373461    {
    374         int nDay = 0;
     462        unsigned int nDay = 0;
    375463        int leapYear = 0;
    376464        double yearsSince1900 = 0;
    377         /* Start at 1900, this is where the DATE time 0.0 starts.
    378          */
    379         pTm->tm_year = 1900;
    380         /* find in what year the day in the "wholePart" falls into.
    381          * add the value to the year field.
    382          */
    383         yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
    384         pTm->tm_year += yearsSince1900;
    385         /* determine if this is a leap year.
    386          */
    387         if( isleap( pTm->tm_year ) )
    388         {
    389             leapYear = 1;
    390             wholePart++;
    391         }
    392 
    393         /* find what day of that year the "wholePart" corresponds to.
    394          * Note: nDay is in [1-366] format
    395          */
    396         nDay = (int) ( wholePart - floor( yearsSince1900 * DAYS_IN_ONE_YEAR ) );
    397         /* Set the tm_yday value.
    398          * Note: The day must be converted from [1-366] to [0-365]
    399          */
    400         /*pTm->tm_yday = nDay - 1;*/
    401         /* find which month this day corresponds to.
    402          */
    403         if( nDay <= 31 )
    404         {
    405             pTm->tm_mday = nDay;
    406             pTm->tm_mon = 0;
    407         }
    408         else if( nDay <= ( 59 + leapYear ) )
    409         {
    410             pTm->tm_mday = nDay - 31;
    411             pTm->tm_mon = 1;
    412         }
    413         else if( nDay <= ( 90 + leapYear ) )
    414         {
    415             pTm->tm_mday = nDay - ( 59 + leapYear );
    416             pTm->tm_mon = 2;
    417         }
    418         else if( nDay <= ( 120 + leapYear ) )
    419         {
    420             pTm->tm_mday = nDay - ( 90 + leapYear );
    421             pTm->tm_mon = 3;
    422         }
    423         else if( nDay <= ( 151 + leapYear ) )
    424         {
    425             pTm->tm_mday = nDay - ( 120 + leapYear );
    426             pTm->tm_mon = 4;
    427         }
    428         else if( nDay <= ( 181 + leapYear ) )
    429         {
    430             pTm->tm_mday = nDay - ( 151 + leapYear );
    431             pTm->tm_mon = 5;
    432         }
    433         else if( nDay <= ( 212 + leapYear ) )
    434         {
    435             pTm->tm_mday = nDay - ( 181 + leapYear );
    436             pTm->tm_mon = 6;
    437         }
    438         else if( nDay <= ( 243 + leapYear ) )
    439         {
    440             pTm->tm_mday = nDay - ( 212 + leapYear );
    441             pTm->tm_mon = 7;
    442         }
    443         else if( nDay <= ( 273 + leapYear ) )
    444         {
    445             pTm->tm_mday = nDay - ( 243 + leapYear );
    446             pTm->tm_mon = 8;
    447         }
    448         else if( nDay <= ( 304 + leapYear ) )
    449         {
    450             pTm->tm_mday = nDay - ( 273 + leapYear );
    451             pTm->tm_mon = 9;
    452         }
    453         else if( nDay <= ( 334 + leapYear ) )
    454         {
    455             pTm->tm_mday = nDay - ( 304 + leapYear );
    456             pTm->tm_mon = 10;
    457         }
    458         else if( nDay <= ( 365 + leapYear ) )
    459         {
    460             pTm->tm_mday = nDay - ( 334 + leapYear );
    461             pTm->tm_mon = 11;
     465
     466        /* Hard code dates smaller than January 1, 1900. */
     467        if( dateIn < 2.0 ) {
     468            pTm->tm_year = 1899;
     469            pTm->tm_mon  = 11; /* December as tm_mon is 0..11 */
     470            if( dateIn < 1.0 ) {
     471                pTm->tm_mday  = 30;
     472                dateIn = dateIn * -1.0; /* Ensure +ve for time calculation */
     473                decimalPart = decimalPart * -1.0; /* Ensure +ve for time calculation */
     474            } else {
     475                pTm->tm_mday  = 31;
     476            }
     477
     478        } else {
     479
     480            /* Start at 1900, this is where the DATE time 0.0 starts.
     481             */
     482            pTm->tm_year = 1900;
     483            /* find in what year the day in the "wholePart" falls into.
     484             * add the value to the year field.
     485             */
     486            yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
     487            pTm->tm_year += yearsSince1900;
     488            /* determine if this is a leap year.
     489             */
     490            if( isleap( pTm->tm_year ) )
     491            {
     492                leapYear = 1;
     493                wholePart++;
     494            }
     495
     496            /* find what day of that year the "wholePart" corresponds to.
     497             * Note: nDay is in [1-366] format
     498             */
     499            nDay = (((unsigned int) wholePart) - ((pTm->tm_year-1900) * DAYS_IN_ONE_YEAR ));
     500
     501            /* Remove the leap days in the previous years between now and 1900.
     502             * Note a leap year is one that is a multiple of 4
     503             * but not of a 100.  Except if it is a multiple of
     504             * 400 then it is a leap year.
     505             * Copied + reversed functionality from TmToDate
     506             */
     507            nDay -= ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
     508            nDay += ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
     509            nDay -= ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
     510
     511            /* Set the tm_yday value.
     512             * Note: The day must be converted from [1-366] to [0-365]
     513             */
     514            /*pTm->tm_yday = nDay - 1;*/
     515            /* find which month this day corresponds to.
     516             */
     517            if( nDay <= 31 )
     518            {
     519                pTm->tm_mday = nDay;
     520                pTm->tm_mon = 0;
     521            }
     522            else if( nDay <= ( 59 + leapYear ) )
     523            {
     524                pTm->tm_mday = nDay - 31;
     525                pTm->tm_mon = 1;
     526            }
     527            else if( nDay <= ( 90 + leapYear ) )
     528            {
     529                pTm->tm_mday = nDay - ( 59 + leapYear );
     530                pTm->tm_mon = 2;
     531            }
     532            else if( nDay <= ( 120 + leapYear ) )
     533            {
     534                pTm->tm_mday = nDay - ( 90 + leapYear );
     535                pTm->tm_mon = 3;
     536            }
     537            else if( nDay <= ( 151 + leapYear ) )
     538            {
     539                pTm->tm_mday = nDay - ( 120 + leapYear );
     540                pTm->tm_mon = 4;
     541            }
     542            else if( nDay <= ( 181 + leapYear ) )
     543            {
     544                pTm->tm_mday = nDay - ( 151 + leapYear );
     545                pTm->tm_mon = 5;
     546            }
     547            else if( nDay <= ( 212 + leapYear ) )
     548            {
     549                pTm->tm_mday = nDay - ( 181 + leapYear );
     550                pTm->tm_mon = 6;
     551            }
     552            else if( nDay <= ( 243 + leapYear ) )
     553            {
     554                pTm->tm_mday = nDay - ( 212 + leapYear );
     555                pTm->tm_mon = 7;
     556            }
     557            else if( nDay <= ( 273 + leapYear ) )
     558            {
     559                pTm->tm_mday = nDay - ( 243 + leapYear );
     560                pTm->tm_mon = 8;
     561            }
     562            else if( nDay <= ( 304 + leapYear ) )
     563            {
     564                pTm->tm_mday = nDay - ( 273 + leapYear );
     565                pTm->tm_mon = 9;
     566            }
     567            else if( nDay <= ( 334 + leapYear ) )
     568            {
     569                pTm->tm_mday = nDay - ( 304 + leapYear );
     570                pTm->tm_mon = 10;
     571            }
     572            else if( nDay <= ( 365 + leapYear ) )
     573            {
     574                pTm->tm_mday = nDay - ( 334 + leapYear );
     575                pTm->tm_mon = 11;
     576            }
    462577        }
    463578    }
     
    466581        /* find the number of seconds in this day.
    467582         * fractional part times, hours, minutes, seconds.
     583         * Note: 0.1 is hack to ensure figures come out in whole numbers
     584         *   due to floating point inaccuracies
    468585         */
    469586        pTm->tm_hour = (int) ( decimalPart * 24 );
    470587        pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 );
    471         pTm->tm_sec = (int) ( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 );
     588        /* Note: 0.1 is hack to ensure seconds come out in whole numbers
     589             due to floating point inaccuracies */
     590        pTm->tm_sec = (int) (( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 ) + 0.1);
    472591    }
    473592    return TRUE;
     
    521640        break;
    522641    case( VT_BSTR ):
     642    case( VT_DISPATCH ):
     643    case( VT_UNKNOWN ):
    523644        size = sizeof(void*);
    524645        break;
    525646    case( VT_CY ):
    526     case( VT_DISPATCH ):
    527     case( VT_UNKNOWN ):
    528     case( VT_DECIMAL ):
     647        size = sizeof(CY);
     648        break;
     649    case( VT_DECIMAL ):         /* hmm, tricky, DECIMAL is only VT_BYREF */
    529650    default:
    530651        FIXME("Add size information for type vt=%d\n", V_VT(parg) & VT_TYPEMASK );
     
    536657/******************************************************************************
    537658 *         StringDupAtoBstr             [INTERNAL]
    538  * 
     659 *
    539660 */
    540661static BSTR StringDupAtoBstr( char* strIn )
     
    563684   nSign = (d >= 0.0) ? 1 : -1;
    564685    d = fabs( d );
    565    
     686
    566687        /* Remove the decimals.
    567688         */
     
    630751                str[0] = '\0';
    631752                strToken = strtok( pNewString, strOfCharToRemove );
    632                 while( strToken != NULL ) { 
     753                while( strToken != NULL ) {
    633754                        strcat( str, strToken );
    634755                        strToken = strtok( NULL, strOfCharToRemove );
     
    671792        int nTokens = 0;
    672793        LPSTR pChar = NULL;
    673        
     794
    674795        /* Check if we have a valid argument
    675796         */
     
    684805                 */
    685806                strToken = strtok( strRealString, " " );
    686                 while( strToken != NULL ) { 
    687                         nTokens++;             
    688                         strToken = strtok( NULL, " " ); 
     807                while( strToken != NULL ) {
     808                        nTokens++;
     809                        strToken = strtok( NULL, " " );
    689810                }
    690811
     
    778899                case '7':
    779900                case '8':
    780                 case '9': 
     901                case '9':
    781902                        if( bFirstDigitsProcessed == FALSE )
    782903                        {
     
    824945                /* If DecimalPoint...
    825946                 */
    826                 case '.': 
     947                case '.':
    827948                        if( bDecimalPointProcessed ||
    828949                                bSecondDigitsProcessed ||
     
    8941015        vtFrom = V_VT(ps) & VT_TYPEMASK;
    8951016
    896        
     1017
    8971018        /* Note: Since "long" and "int" values both have 4 bytes and are
    8981019         * both signed integers "int" will be treated as "long" in the
     
    9011022         */
    9021023
    903         /* Trivial Case: If the coercion is from two types that are 
     1024        /* Trivial Case: If the coercion is from two types that are
    9041025         * identical then we can blindly copy from one argument to another.*/
    9051026        if ((vt==vtFrom))
     
    12471368                }
    12481369                break;
    1249                
     1370
    12501371        case( VT_R4 ):
    12511372                switch( vtFrom )
     
    16101731                break;
    16111732        }
    1612        
     1733
    16131734        return res;
    16141735}
     
    16561777                        res = DISP_E_BADVARTYPE;
    16571778                }
    1658                        
     1779
    16591780    }
    16601781    else
     
    16621783        res = ValidateVtRange( vt );
    16631784    }
    1664                
     1785
    16651786        return res;
    16661787}
     
    16891810                        res = DISP_E_BADVARTYPE;
    16901811                }
    1691                        
     1812
    16921813    }
    16931814    else
     
    16951816        res = ValidateVtRange( vt );
    16961817    }
    1697                
     1818
    16981819        return res;
    16991820}
     
    17701891      }
    17711892    }
    1772        
     1893
    17731894    /*
    17741895     * Empty all the fields and mark the type as empty.
     
    18001921  {
    18011922    res = VariantClear( pvargDest );
    1802                
     1923
    18031924    if( res == S_OK )
    18041925    {
     
    18541975          }
    18551976        }
    1856        
     1977
    18571978        V_VT(pvargDest) = V_VT(pvargSrc);
    1858       }     
     1979      }
    18591980    }
    18601981  }
     
    18802001  if( res != S_OK )
    18812002    return res;
    1882  
     2003
    18832004  if( V_VT(pvargSrc) & VT_BYREF )
    18842005  {
     
    19312052                 * If the inner Variant itself contains an
    19322053                 * other inner variant the E_INVALIDARG error is
    1933                  * returned. 
     2054                 * returned.
    19342055                 */
    19352056                if( pvargSrc->n1.n2.wReserved1 & PROCESSING_INNER_VARIANT )
     
    19482069                   */
    19492070                  (V_UNION(pvargSrc,pvarVal))->n1.n2.wReserved1 |= PROCESSING_INNER_VARIANT;
    1950                  
     2071
    19512072                  /* Dereference the inner variant.
    19522073                   */
     
    20112132        VARIANTARG varg;
    20122133        VariantInit( &varg );
    2013        
     2134
    20142135        TRACE("(%p, %p, %ld, %u, %u) vt=%d\n", pvargDest, pvargSrc, lcid, wFlags, vt, V_VT(pvargSrc));
     2136    TRACE("Src Var:\n");
     2137    dump_Variant(pvargSrc);
    20152138
    20162139        /* validate our source argument.
     
    20562179                                VariantClear( &Variant );
    20572180                        }
    2058        
     2181
    20592182                }
    20602183                else
     
    20682191         */
    20692192        VariantClear( &varg );
    2070        
     2193
    20712194        /* set the type of the destination
    20722195         */
     
    20742197                V_VT(pvargDest) = vt;
    20752198
     2199    TRACE("Dest Var:\n");
     2200    dump_Variant(pvargDest);
     2201
    20762202        return res;
    20772203}
     
    20952221
    20962222        *pbOut = (BYTE) sIn;
    2097        
     2223
    20982224        return S_OK;
    20992225}
     
    21142240
    21152241        *pbOut = (BYTE) lIn;
    2116        
     2242
    21172243        return S_OK;
    21182244}
     
    21352261
    21362262        *pbOut = (BYTE) fltIn;
    2137        
     2263
    21382264        return S_OK;
    21392265}
     
    22642390         */
    22652391        dValue = atof( pNewString );
    2266        
     2392
    22672393        /* We don't need the string anymore so free it.
    22682394         */
     
    22882414HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) {
    22892415   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2290    
     2416
    22912417   if (t > UI1_MAX || t < UI1_MIN) return DISP_E_OVERFLOW;
    2292    
     2418
    22932419   *pbOut = (BYTE)t;
    22942420   return S_OK;
     
    23032429
    23042430        *psOut = (short) bIn;
    2305        
     2431
    23062432        return S_OK;
    23072433}
     
    23222448
    23232449        *psOut = (short) lIn;
    2324        
     2450
    23252451        return S_OK;
    23262452}
     
    24702596         */
    24712597        dValue = atof( pNewString );
    2472        
     2598
    24732599        /* We don't need the string anymore so free it.
    24742600         */
     
    24942620HRESULT WINAPI VarI2FromCy(CY cyIn, short* psOut) {
    24952621   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2496    
     2622
    24972623   if (t > I2_MAX || t < I2_MIN) return DISP_E_OVERFLOW;
    2498    
     2624
    24992625   *psOut = (SHORT)t;
    25002626   return S_OK;
     
    26632789         */
    26642790        dValue = atof( pNewString );
    2665        
     2791
    26662792        /* We don't need the string anymore so free it.
    26672793         */
     
    26872813HRESULT WINAPI VarI4FromCy(CY cyIn, LONG* plOut) {
    26882814   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2689    
     2815
    26902816   if (t > I4_MAX || t < I4_MIN) return DISP_E_OVERFLOW;
    2691    
     2817
    26922818   *plOut = (LONG)t;
    26932819   return S_OK;
     
    28382964         */
    28392965        dValue = atof( pNewString );
    2840        
     2966
    28412967        /* We don't need the string anymore so free it.
    28422968         */
     
    28612987HRESULT WINAPI VarR4FromCy(CY cyIn, FLOAT* pfltOut) {
    28622988   *pfltOut = (FLOAT)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2863    
     2989
    28642990   return S_OK;
    28652991}
     
    29813107        LPSTR pNewString = NULL;
    29823108
    2983         TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pdblOut );
     3109        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     3110        TRACE("( %s, %ld, %ld, %p ), stub\n", pNewString, lcid, dwFlags, pdblOut );
    29843111
    29853112        /* Check if we have a valid argument
    29863113         */
    2987         pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    29883114        RemoveCharacterFromString( pNewString, "," );
    29893115        if( IsValidRealString( pNewString ) == FALSE )
     
    29953121         */
    29963122        dValue = atof( pNewString );
    2997        
     3123
    29983124        /* We don't need the string anymore so free it.
    29993125         */
     
    30113137HRESULT WINAPI VarR8FromCy(CY cyIn, double* pdblOut) {
    30123138   *pdblOut = (double)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    3013    
     3139   TRACE("%lu %ld -> %f\n", cyIn.s.Hi, cyIn.s.Lo, *pdblOut);
    30143140   return S_OK;
    30153141}
     
    31003226 *
    31013227 * The formats for the date part are has follows:
    3102  * mm/[dd/][yy]yy 
     3228 * mm/[dd/][yy]yy
    31033229 * [dd/]mm/[yy]yy
    3104  * [yy]yy/mm/dd 
     3230 * [yy]yy/mm/dd
    31053231 * January dd[,] [yy]yy
    31063232 * dd January [yy]yy
     
    31093235 *
    31103236 * The formats for the date and time string are has follows.
    3111  * date[whitespace][time] 
     3237 * date[whitespace][time]
    31123238 * [time][whitespace]date
    31133239 *
     
    31353261        ret = DISP_E_TYPEMISMATCH;
    31363262    }
    3137 
    3138 
     3263    TRACE("Return value %f\n", *pdateOut);
    31393264        return ret;
    31403265}
     
    32183343
    32193344        *pbstrOut =  StringDupAtoBstr( pBuffer );
    3220        
     3345
    32213346        return S_OK;
    32223347}
     
    32773402 */
    32783403HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut) {
    3279         FIXME("([cyIn], %08lx, %08lx, %p), stub.\n", lcid, dwFlags, pbstrOut);
    3280         return E_NOTIMPL;
    3281 }
    3282 
    3283  
     3404    HRESULT rc = S_OK;
     3405    double curVal = 0.0;
     3406
     3407        TRACE("([cyIn], %08lx, %08lx, %p), partial stub (no flags handled).\n", lcid, dwFlags, pbstrOut);
     3408
     3409    /* Firstly get the currency in a double, then put it in a buffer */
     3410    rc = VarR8FromCy(cyIn, &curVal);
     3411    if (rc == S_OK) {
     3412        sprintf(pBuffer, "%g", curVal);
     3413        *pbstrOut = StringDupAtoBstr( pBuffer );
     3414    }
     3415        return rc;
     3416}
     3417
     3418
    32843419/******************************************************************************
    32853420 *              VarBstrFromDate         [OLEAUT32.114]
     
    33163451    memset( &TM, 0, sizeof(TM) );
    33173452
    3318     TRACE("( %f, %ld, %ld, %p ), stub\n", dateIn, lcid, dwFlags, pbstrOut );
     3453    TRACE("( %20.20f, %ld, %ld, %p ), stub\n", dateIn, lcid, dwFlags, pbstrOut );
    33193454
    33203455    if( DateToTm( dateIn, dwFlags, &TM ) == FALSE )
     
    33303465        strftime( pBuffer, BUFFER_MAX, "%x %X", &TM );
    33313466
     3467        TRACE("result: %s\n", pBuffer);
    33323468                *pbstrOut = StringDupAtoBstr( pBuffer );
    3333 
    33343469        return S_OK;
    33353470}
     
    35083643
    35093644        HeapFree( GetProcessHeap(), 0, pNewString );
    3510        
     3645
    35113646        return ret;
    35123647}
     
    35553690      if (cyIn.s.Hi || cyIn.s.Lo) *pboolOut = -1;
    35563691      else *pboolOut = 0;
    3557      
     3692
    35583693      return S_OK;
    35593694}
     
    36883823         */
    36893824        dValue = atof( pNewString );
    3690  
     3825
    36913826        /* We don't need the string anymore so free it.
    36923827         */
     
    37583893HRESULT WINAPI VarI1FromCy(CY cyIn, CHAR* pcOut) {
    37593894   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    3760    
     3895
    37613896   if (t > CHAR_MAX || t < CHAR_MIN) return DISP_E_OVERFLOW;
    3762    
     3897
    37633898   *pcOut = (CHAR)t;
    37643899   return S_OK;
     
    38874022         */
    38884023        dValue = atof( pNewString );
    3889  
     4024
    38904025        /* We don't need the string anymore so free it.
    38914026         */
     
    39364071        TRACE("( %ld, %p ), stub\n", ulIn, puiOut );
    39374072
    3938         if( ulIn < UI2_MIN || ulIn > UI2_MAX )
     4073        if( ulIn > UI2_MAX )
    39394074        {
    39404075                return DISP_E_OVERFLOW;
     
    39684103         */
    39694104        dValue = atof( pNewString );
    3970  
     4105
    39714106        /* We don't need the string anymore so free it.
    39724107         */
     
    39924127HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) {
    39934128   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    3994    
     4129
    39954130   if (t > UI2_MAX || t < UI2_MIN) return DISP_E_OVERFLOW;
    3996      
     4131
    39974132   *pusOut = (USHORT)t;
    3998    
     4133
    39994134   return S_OK;
    40004135}
     
    40364171        TRACE("( %ld, %p ), stub\n", lIn, pulOut );
    40374172
    4038         if( lIn < UI4_MIN )
     4173        if( lIn < 0 )
    40394174        {
    40404175                return DISP_E_OVERFLOW;
     
    41404275HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG* pulOut) {
    41414276   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    4142    
     4277
    41434278   if (t > UI4_MAX || t < UI4_MIN) return DISP_E_OVERFLOW;
    41444279
     
    41804315      pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    41814316      if (lIn < 0) pcyOut->s.Hi--;
    4182    
     4317
    41834318      return S_OK;
    41844319}
     
    41934328   pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    41944329   if (fltIn < 0) pcyOut->s.Hi--;
    4195    
     4330
    41964331   return S_OK;
    41974332}
     
    42254360/**********************************************************************
    42264361 *              VarCyFromStr [OLEAUT32.104]
     4362 * FIXME: Never tested with decimal seperator other than '.'
    42274363 */
    42284364HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pcyOut) {
    4229         FIXME("(%p, %08lx, %08lx, %p), stub.\n", strIn, lcid, dwFlags, pcyOut);
    4230         return E_NOTIMPL;
    4231 }
    4232 
    4233  
     4365
     4366        LPSTR   pNewString      = NULL;
     4367    char   *decSep          = NULL;
     4368    char   *strPtr,*curPtr  = NULL;
     4369    int size, rc;
     4370    double currencyVal = 0.0;
     4371
     4372
     4373        pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
     4374        TRACE("( '%s', 0x%08lx, 0x%08lx, %p )\n", pNewString, lcid, dwFlags, pcyOut );
     4375
     4376    /* Get locale information - Decimal Seperator (size includes 0x00) */
     4377    size = GetLocaleInfoA(lcid, LOCALE_SDECIMAL, NULL, 0);
     4378    decSep = (char *) malloc(size);
     4379    rc = GetLocaleInfoA(lcid, LOCALE_SDECIMAL, decSep, size);
     4380    TRACE("Decimal Seperator is '%s'\n", decSep);
     4381
     4382    /* Now copy to temporary buffer, skipping any character except 0-9 and
     4383       the decimal seperator */
     4384    curPtr = pBuffer;      /* Current position in string being built       */
     4385    strPtr = pNewString;   /* Current position in supplied currenct string */
     4386
     4387    while (*strPtr) {
     4388        /* If decimal seperator, skip it and put '.' in string */
     4389        if (strncmp(strPtr, decSep, (size-1)) == 0) {
     4390            strPtr = strPtr + (size-1);
     4391            *curPtr = '.';
     4392            curPtr++;
     4393        } else if ((*strPtr == '+' || *strPtr == '-') ||
     4394                   (*strPtr >= '0' && *strPtr <= '9')) {
     4395            *curPtr = *strPtr;
     4396            strPtr++;
     4397            curPtr++;
     4398        } else strPtr++;
     4399    }
     4400    *curPtr = 0x00;
     4401
     4402    /* Try to get currency into a double */
     4403    currencyVal = atof(pBuffer);
     4404    TRACE("Converted string '%s' to %f\n", pBuffer, currencyVal);
     4405
     4406    /* Free allocated storage */
     4407    HeapFree( GetProcessHeap(), 0, pNewString );
     4408    free(decSep);
     4409
     4410    /* Convert double -> currency using internal routine */
     4411        return VarCyFromR8(currencyVal, pcyOut);
     4412}
     4413
     4414
    42344415/**********************************************************************
    42354416 *              VarCyFromBool [OLEAUT32.106]
     
    42404421   else pcyOut->s.Hi = 0;
    42414422   pcyOut->s.Lo = (ULONG)boolIn * (ULONG)10000;
    4242    
     4423
    42434424   return S_OK;
    42444425}
     
    42524433   else pcyOut->s.Hi = 0;
    42534434   pcyOut->s.Lo = (ULONG)cIn * (ULONG)10000;
    4254    
     4435
    42554436   return S_OK;
    42564437}
     
    42634444   pcyOut->s.Hi = 0;
    42644445   pcyOut->s.Lo = (ULONG)usIn * (ULONG)10000;
    4265    
     4446
    42664447   return S_OK;
    42674448}
     
    42754456   pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
    42764457   pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    4277      
     4458
    42784459   return S_OK;
    42794460}
     
    42914472
    42924473    TRACE("( 0x%x, 0x%x, %p ), stub\n", wDosDate, wDosTime, pvtime );
    4293    
     4474
    42944475    t.tm_sec = (wDosTime & 0x001f) * 2;
    42954476    t.tm_min = (wDosTime & 0x07e0) >> 5;
    42964477    t.tm_hour = (wDosTime & 0xf800) >> 11;
    4297    
     4478
    42984479    t.tm_mday = (wDosDate & 0x001f);
    42994480    t.tm_mon = (wDosDate & 0x01e0) >> 5;
     
    43124493    int i,lastent=0;
    43134494    int cDig;
     4495    BOOL foundNum=FALSE;
     4496
    43144497    FIXME("(%s,flags=%lx,....), partial stub!\n",debugstr_w(strIn),dwFlags);
    43154498    FIXME("numparse: cDig=%d, InFlags=%lx\n",pnumprs->cDig,pnumprs->dwInFlags);
    43164499
    43174500    /* The other struct components are to be set by us */
    4318 
    43194501    memset(rgbDig,0,pnumprs->cDig);
     4502
     4503    /* FIXME: Just patching some values in */
     4504    pnumprs->nPwr10     = 0;
     4505    pnumprs->nBaseShift = 0;
     4506    pnumprs->cchUsed    = lastent;
     4507    pnumprs->dwOutFlags = NUMPRS_DECIMAL;
    43204508
    43214509    cDig = 0;
    43224510    for (i=0; strIn[i] ;i++) {
    43234511        if ((strIn[i]>='0') && (strIn[i]<='9')) {
     4512            foundNum = TRUE;
    43244513            if (pnumprs->cDig > cDig) {
    43254514                *(rgbDig++)=strIn[i]-'0';
     
    43274516                lastent = i;
    43284517            }
    4329         }
     4518        } else if ((strIn[i]=='-') && (foundNum==FALSE)) {
     4519            pnumprs->dwOutFlags |= NUMPRS_NEG;
     4520        }
    43304521    }
    43314522    pnumprs->cDig       = cDig;
    4332 
    4333     /* FIXME: Just patching some values in */
    4334     pnumprs->nPwr10     = 0;
    4335     pnumprs->nBaseShift = 0;
    4336     pnumprs->cchUsed    = lastent;
    4337     pnumprs->dwOutFlags = NUMPRS_DECIMAL;
     4523    TRACE("numparse out: cDig=%d, OutFlags=%lx\n",pnumprs->cDig,pnumprs->dwOutFlags);
    43384524    return S_OK;
    43394525}
     
    43484534    DWORD xint;
    43494535    int i;
    4350     FIXME("(,dwVtBits=%lx,....), partial stub!\n",dwVtBits);
     4536    FIXME("(..,dwVtBits=%lx,....), partial stub!\n",dwVtBits);
    43514537
    43524538    xint = 0;
    43534539    for (i=0;i<pnumprs->cDig;i++)
    43544540        xint = xint*10 + rgbDig[i];
     4541
     4542    if (pnumprs->dwOutFlags & NUMPRS_NEG) {
     4543        xint = xint * -1;
     4544    }
    43554545
    43564546    VariantInit(pvar);
     
    43644554        V_UNION(pvar,dblVal) = xint;
    43654555        return S_OK;
    4366     } else {
    4367         FIXME("vtbitmask is unsupported %lx\n",dwVtBits);
     4556    }
     4557    if (dwVtBits & VTBIT_R4) {
     4558        V_VT(pvar) = VT_R4;
     4559        V_UNION(pvar,fltVal) = xint;
     4560        return S_OK;
     4561    }
     4562    if (dwVtBits & VTBIT_I2) {
     4563        V_VT(pvar) = VT_I2;
     4564        V_UNION(pvar,iVal) = xint;
     4565        return S_OK;
     4566    }
     4567    /* FIXME: Currency should be from a double */
     4568    if (dwVtBits & VTBIT_CY) {
     4569        V_VT(pvar) = VT_CY;
     4570        TRACE("Calculated currency is xint=%ld\n", xint);
     4571        VarCyFromInt( (int) xint, &V_UNION(pvar,cyVal) );
     4572        TRACE("Calculated cy is %ld,%lu\n", V_UNION(pvar,cyVal).s.Hi, V_UNION(pvar,cyVal).s.Lo);
     4573        return VarCyFromInt( (int) xint, &V_UNION(pvar,cyVal) );
     4574    }
     4575
     4576        FIXME("vtbitmask is unsupported %lx, int=%d\n",dwVtBits, (int) xint);
    43684577        return E_FAIL;
    4369     }
    4370 }
    4371 
     4578}
     4579
     4580
     4581/**********************************************************************
     4582 *              VarFormatDateTime [OLEAUT32.97]
     4583 */
     4584HRESULT WINAPI VarFormatDateTime(LPVARIANT var, INT format, ULONG dwFlags, BSTR *out)
     4585{
     4586    FIXME("%p %d %lx %p\n", var, format, dwFlags, out);
     4587    return E_NOTIMPL;
     4588}
     4589
     4590/**********************************************************************
     4591 *              VarFormatCurrency [OLEAUT32.127]
     4592 */
     4593HRESULT WINAPI VarFormatCurrency(LPVARIANT var, INT digits, INT lead, INT paren, INT group, ULONG dwFlags, BSTR *out)
     4594{
     4595    FIXME("%p %d %d %d %d %lx %p\n", var, digits, lead, paren, group, dwFlags, out);
     4596    return E_NOTIMPL;
     4597}
    43724598
    43734599/**********************************************************************
     
    44034629HRESULT WINAPI SystemTimeToVariantTime( LPSYSTEMTIME  lpSystemTime, double *pvtime )
    44044630{
    4405     static const BYTE Days_Per_Month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    4406     static const BYTE Days_Per_Month_LY[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    4407 
    44084631    struct tm t;
    44094632
     
    44204643
    44214644        t.tm_mday = lpSystemTime->wDay;
    4422         t.tm_mon = lpSystemTime->wMonth;
     4645        t.tm_mon = lpSystemTime->wMonth - 1; /* tm_mon is 0..11, wMonth is 1..12 */
    44234646        t.tm_year = lpSystemTime->wYear;
    44244647
     
    44274650    else
    44284651    {
     4652        double tmpDate;
     4653        long firstDayOfNextYear;
     4654        long thisDay;
     4655        long leftInYear;
     4656        long result;
     4657
     4658        double decimalPart = 0.0;
     4659
    44294660        t.tm_sec = lpSystemTime->wSecond;
    44304661        t.tm_min = lpSystemTime->wMinute;
    44314662        t.tm_hour = lpSystemTime->wHour;
    44324663
    4433         if (isleap(lpSystemTime->wYear) )
    4434             t.tm_mday = Days_Per_Month_LY[13 - lpSystemTime->wMonth] - lpSystemTime->wDay;
    4435         else
    4436             t.tm_mday = Days_Per_Month[13 - lpSystemTime->wMonth] - lpSystemTime->wDay;
    4437 
    4438         t.tm_mon = 13 - lpSystemTime->wMonth;
     4664        /* Step year forward the same number of years before 1900 */
    44394665        t.tm_year = 1900 + 1899 - lpSystemTime->wYear;
    4440 
     4666        t.tm_mon = lpSystemTime->wMonth - 1;
     4667        t.tm_mday = lpSystemTime->wDay;
     4668
     4669        /* Calculate date */
    44414670        TmToDATE( &t, pvtime );
    44424671
    4443         *pvtime *= -1;
     4672        thisDay = (double) floor( *pvtime );
     4673        decimalPart = fmod( *pvtime, thisDay );
     4674
     4675        /* Now, calculate the same time for the first of Jan that year */
     4676        t.tm_mon = 0;
     4677        t.tm_mday = 1;
     4678        t.tm_sec = 0;
     4679        t.tm_min = 0;
     4680        t.tm_hour = 0;
     4681        t.tm_year = t.tm_year+1;
     4682        TmToDATE( &t, &tmpDate );
     4683        firstDayOfNextYear = (long) floor(tmpDate);
     4684
     4685        /* Finally since we know the size of the year, subtract the two to get
     4686           remaining time in the year                                          */
     4687        leftInYear = firstDayOfNextYear - thisDay;
     4688
     4689        /* Now we want full years up to the year in question, and remainder of year
     4690           of the year in question */
     4691        if (isleap(lpSystemTime->wYear) ) {
     4692           TRACE("Extra day due to leap year\n");
     4693           result = 2.0 - ((firstDayOfNextYear - 366) + leftInYear - 2.0);
     4694        } else {
     4695           result = 2.0 - ((firstDayOfNextYear - 365) + leftInYear - 2.0);
     4696        }
     4697        *pvtime = (double) result + decimalPart;
     4698        TRACE("<1899 support: returned %f, 1st day %ld, thisday %ld, left %ld\n", *pvtime, firstDayOfNextYear, thisDay, leftInYear);
    44444699
    44454700        return 1;
     
    44684723    struct tm r;
    44694724
    4470     TRACE(" Variant = %f SYSTEMTIME ptr %p", vtime, lpSystemTime);
     4725    TRACE(" Variant = %f SYSTEMTIME ptr %p\n", vtime, lpSystemTime);
    44714726
    44724727    if (vtime >= 0)
     
    46194874    *datein = t;
    46204875
    4621     if (i) dwFlags = 0; /*VAR_VALIDDATE*/
    4622     else dwFlags = 0;
    4623 
    4624     return i;
     4876    if (i) return S_OK;
     4877    else return E_INVALIDARG;
    46254878}
    46264879
    46274880
    46284881/**********************************************************************
    4629  *              VarBstrCmp [OLEAUT32.440]
     4882 *              VarBstrCmp [OLEAUT32.314]
    46304883 *
    4631  * flags can be: 
     4884 * flags can be:
    46324885 *   NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS
    46334886 *   NORM_IGNORESTRINGWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA
     
    46364889HRESULT WINAPI VarBstrCmp(BSTR left, BSTR right, LCID lcid, DWORD flags)
    46374890{
    4638     DWORD r;
    4639 
    4640     FIXME("( %s %s %ld %lx ) partial stub\n", debugstr_w(left), debugstr_w(right), lcid, flags);
    4641 
    4642     if((!left) || (!right))
    4643         return VARCMP_NULL;
     4891    INT r;
     4892
     4893    TRACE("( %s %s %ld %lx ) partial stub\n", debugstr_w(left), debugstr_w(right), lcid, flags);
     4894
     4895    /* Contrary to the MSDN, this returns eq for null vs null, null vs L"" and L"" vs NULL */
     4896    if((!left) || (!right)) {
     4897
     4898        if (!left && (!right || *right==0)) return VARCMP_EQ;
     4899        else if (!right && (!left || *left==0)) return VARCMP_EQ;
     4900        else return VARCMP_NULL;
     4901    }
    46444902
    46454903    if(flags&NORM_IGNORECASE)
     
    46574915
    46584916/**********************************************************************
    4659  *              VarBstrCat [OLEAUT32.439]
     4917 *              VarBstrCat [OLEAUT32.313]
    46604918 */
    46614919HRESULT WINAPI VarBstrCat(BSTR left, BSTR right, BSTR *out)
    46624920{
    46634921    BSTR result;
     4922    int size = 0;
    46644923
    46654924    TRACE("( %s %s %p )\n", debugstr_w(left), debugstr_w(right), out);
    46664925
    4667     if( (!left) || (!right) || (!out) )
    4668         return 0;
    4669 
    4670     result = SysAllocStringLen(left, lstrlenW(left)+lstrlenW(right));
    4671     lstrcatW(result,right);
    4672 
    4673     *out = result;
    4674 
    4675     return 1;
     4926    /* On Windows, NULL parms are still handled (as empty strings) */
     4927    if (left)  size=size + lstrlenW(left);
     4928    if (right) size=size + lstrlenW(right);
     4929
     4930    if (out) {
     4931        result = SysAllocStringLen(NULL, size);
     4932        *out = result;
     4933        if (left) lstrcatW(result,left);
     4934        if (right) lstrcatW(result,right);
     4935        TRACE("result = %s, [%p]\n", debugstr_w(result), result);
     4936    }
     4937    return S_OK;
    46764938}
    46774939
    46784940/**********************************************************************
    4679  *              VarCat [OLEAUT32.441]
     4941 *              VarCat [OLEAUT32.318]
    46804942 */
    46814943HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out)
     
    46994961    return S_OK;
    47004962}
     4963
     4964/**********************************************************************
     4965 *              VarCmp [OLEAUT32.176]
     4966 *
     4967 * flags can be:
     4968 *   NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS
     4969 *   NORM_IGNOREWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA
     4970 *
     4971 */
     4972HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
     4973{
     4974
     4975
     4976    BOOL         lOk        = TRUE;
     4977    BOOL         rOk        = TRUE;
     4978    LONGLONG     lVal = -1;
     4979    LONGLONG     rVal = -1;
     4980
     4981    TRACE("Left Var:\n");
     4982    dump_Variant(left);
     4983    TRACE("Right Var:\n");
     4984    dump_Variant(right);
     4985
     4986    /* If either are null, then return VARCMP_NULL */
     4987    if ((V_VT(left)&VT_TYPEMASK) == VT_NULL ||
     4988        (V_VT(right)&VT_TYPEMASK) == VT_NULL)
     4989        return VARCMP_NULL;
     4990
     4991    /* Strings - use VarBstrCmp */
     4992    if ((V_VT(left)&VT_TYPEMASK) == VT_BSTR &&
     4993        (V_VT(right)&VT_TYPEMASK) == VT_BSTR) {
     4994        return VarBstrCmp(V_BSTR(left), V_BSTR(right), lcid, flags);
     4995    }
     4996
     4997    /* Integers - Ideally like to use VarDecCmp, but no Dec support yet
     4998           Use LONGLONG to maximize ranges                              */
     4999    lOk = TRUE;
     5000    switch (V_VT(left)&VT_TYPEMASK) {
     5001    case VT_I1   : lVal = V_UNION(left,cVal); break;
     5002    case VT_I2   : lVal = V_UNION(left,iVal); break;
     5003    case VT_I4   : lVal = V_UNION(left,lVal); break;
     5004    case VT_INT  : lVal = V_UNION(left,lVal); break;
     5005    case VT_UI1  : lVal = V_UNION(left,bVal); break;
     5006    case VT_UI2  : lVal = V_UNION(left,uiVal); break;
     5007    case VT_UI4  : lVal = V_UNION(left,ulVal); break;
     5008    case VT_UINT : lVal = V_UNION(left,ulVal); break;
     5009    default: lOk = FALSE;
     5010    }
     5011
     5012    rOk = TRUE;
     5013    switch (V_VT(right)&VT_TYPEMASK) {
     5014    case VT_I1   : rVal = V_UNION(right,cVal); break;
     5015    case VT_I2   : rVal = V_UNION(right,iVal); break;
     5016    case VT_I4   : rVal = V_UNION(right,lVal); break;
     5017    case VT_INT  : rVal = V_UNION(right,lVal); break;
     5018    case VT_UI1  : rVal = V_UNION(right,bVal); break;
     5019    case VT_UI2  : rVal = V_UNION(right,uiVal); break;
     5020    case VT_UI4  : rVal = V_UNION(right,ulVal); break;
     5021    case VT_UINT : rVal = V_UNION(right,ulVal); break;
     5022    default: rOk = FALSE;
     5023    }
     5024
     5025    if (lOk && rOk) {
     5026        if (lVal < rVal) {
     5027            return VARCMP_LT;
     5028        } else if (lVal > rVal) {
     5029            return VARCMP_GT;
     5030        } else {
     5031            return VARCMP_EQ;
     5032        }
     5033    }
     5034
     5035    /* Strings - use VarBstrCmp */
     5036    if ((V_VT(left)&VT_TYPEMASK) == VT_DATE &&
     5037        (V_VT(right)&VT_TYPEMASK) == VT_DATE) {
     5038
     5039        if (floor(V_UNION(left,date)) == floor(V_UNION(right,date))) {
     5040            /* Due to floating point rounding errors, calculate varDate in whole numbers) */
     5041            double wholePart = 0.0;
     5042            double leftR;
     5043            double rightR;
     5044
     5045            /* Get the fraction * 24*60*60 to make it into whole seconds */
     5046            wholePart = (double) floor( V_UNION(left,date) );
     5047            if (wholePart == 0) wholePart = 1;
     5048            leftR = floor(fmod( V_UNION(left,date), wholePart ) * (24*60*60));
     5049
     5050            wholePart = (double) floor( V_UNION(right,date) );
     5051            if (wholePart == 0) wholePart = 1;
     5052            rightR = floor(fmod( V_UNION(right,date), wholePart ) * (24*60*60));
     5053
     5054            if (leftR < rightR) {
     5055                return VARCMP_LT;
     5056            } else if (leftR > rightR) {
     5057                return VARCMP_GT;
     5058            } else {
     5059                return VARCMP_EQ;
     5060            }
     5061
     5062        } else if (V_UNION(left,date) < V_UNION(right,date)) {
     5063            return VARCMP_LT;
     5064        } else if (V_UNION(left,date) > V_UNION(right,date)) {
     5065            return VARCMP_GT;
     5066        }
     5067    }
     5068
     5069
     5070    FIXME("VarCmp partial implementation, doesnt support these pair of variant types");
     5071    return E_FAIL;
     5072}
     5073
     5074/**********************************************************************
     5075 *              VarAnd [OLEAUT32.142]
     5076 *
     5077 */
     5078HRESULT WINAPI VarAnd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
     5079{
     5080    HRESULT rc = E_FAIL;
     5081
     5082
     5083    TRACE("Left Var:\n");
     5084    dump_Variant(left);
     5085    TRACE("Right Var:\n");
     5086    dump_Variant(right);
     5087
     5088    if ((V_VT(left)&VT_TYPEMASK) == VT_BOOL &&
     5089        (V_VT(right)&VT_TYPEMASK) == VT_BOOL) {
     5090
     5091        V_VT(result) = VT_BOOL;
     5092        if (V_BOOL(left) && V_BOOL(right)) {
     5093            V_BOOL(result) = VARIANT_TRUE;
     5094        } else {
     5095            V_BOOL(result) = VARIANT_FALSE;
     5096        }
     5097        rc = S_OK;
     5098
     5099    } else {
     5100        FIXME("VarAnd stub\n");
     5101    }
     5102
     5103    TRACE("rc=%d, Result:\n", (int) rc);
     5104    dump_Variant(result);
     5105    return rc;
     5106}
     5107
     5108/**********************************************************************
     5109 *              VarNot [OLEAUT32.174]
     5110 *
     5111 */
     5112HRESULT WINAPI VarNot(LPVARIANT in, LPVARIANT result)
     5113{
     5114    HRESULT rc = E_FAIL;
     5115
     5116    TRACE("Var In:\n");
     5117    dump_Variant(in);
     5118
     5119    if ((V_VT(in)&VT_TYPEMASK) == VT_BOOL) {
     5120
     5121        V_VT(result) = VT_BOOL;
     5122        if (V_BOOL(in)) {
     5123            V_BOOL(result) = VARIANT_FALSE;
     5124        } else {
     5125            V_BOOL(result) = VARIANT_TRUE;
     5126        }
     5127        rc = S_OK;
     5128
     5129    } else {
     5130        FIXME("VarNot stub\n");
     5131    }
     5132
     5133    TRACE("rc=%d, Result:\n", (int) rc);
     5134    dump_Variant(result);
     5135    return rc;
     5136}
     5137
     5138/**********************************************************************
     5139 *              VarTokenizeFormatString [OLEAUT32.140]
     5140 *
     5141 * From investigation on W2K, a list is built up which is:
     5142 *
     5143 * <0x00> AA BB - Copy from AA for BB chars (Note 1 byte with wrap!)
     5144 * <token> - Insert appropriate token
     5145 *
     5146 */
     5147HRESULT WINAPI VarTokenizeFormatString(LPOLESTR  format, LPBYTE rgbTok,
     5148                     int   cbTok, int iFirstDay, int iFirstWeek,
     5149                     LCID  lcid, int *pcbActual) {
     5150
     5151    FORMATHDR *hdr;
     5152    int        realLen, formatLeft;
     5153    BYTE      *pData;
     5154    LPSTR      pFormatA, pStart;
     5155    int        checkStr;
     5156    BOOL       insertCopy = FALSE;
     5157    LPSTR      copyFrom = NULL;
     5158
     5159    TRACE("'%s', %p %d %d %d only date support\n", debugstr_w(format), rgbTok, cbTok,
     5160                   iFirstDay, iFirstWeek);
     5161
     5162    /* Big enough for header? */
     5163    if (cbTok < sizeof(FORMATHDR)) {
     5164        return TYPE_E_BUFFERTOOSMALL;
     5165    }
     5166
     5167    /* Insert header */
     5168    hdr = (FORMATHDR *) rgbTok;
     5169    memset(hdr, 0x00, sizeof(FORMATHDR));
     5170    hdr->hex3 = 0x03; /* No idea what these are */
     5171    hdr->hex6 = 0x06;
     5172
     5173    /* Start parsing string */
     5174    realLen    = sizeof(FORMATHDR);
     5175    pData      = rgbTok + realLen;
     5176    pFormatA   = HEAP_strdupWtoA( GetProcessHeap(), 0, format );
     5177    pStart     = pFormatA;
     5178    formatLeft = strlen(pFormatA);
     5179
     5180    /* Work through the format */
     5181    while (*pFormatA != 0x00) {
     5182
     5183        checkStr = 0;
     5184        while (checkStr>=0 && (formatTokens[checkStr].tokenSize != 0x00)) {
     5185            if (formatLeft >= formatTokens[checkStr].tokenSize &&
     5186                strncmp(formatTokens[checkStr].str, pFormatA,
     5187                        formatTokens[checkStr].tokenSize) == 0) {
     5188                TRACE("match on '%s'\n", formatTokens[checkStr].str);
     5189
     5190                /* Found Match! */
     5191
     5192                /* If we have skipped chars, insert the copy */
     5193                if (insertCopy == TRUE) {
     5194
     5195                    if ((realLen + 3) > cbTok) {
     5196                        HeapFree( GetProcessHeap(), 0, pFormatA );
     5197                        return TYPE_E_BUFFERTOOSMALL;
     5198                    }
     5199                    insertCopy = FALSE;
     5200                    *pData = TOK_COPY;
     5201                    pData++;
     5202                    *pData = (BYTE)(copyFrom - pStart);
     5203                    pData++;
     5204                    *pData = (BYTE)(pFormatA - copyFrom);
     5205                    pData++;
     5206                    realLen = realLen + 3;
     5207                }
     5208
     5209
     5210                /* Now insert the token itself */
     5211                if ((realLen + 1) > cbTok) {
     5212                    HeapFree( GetProcessHeap(), 0, pFormatA );
     5213                    return TYPE_E_BUFFERTOOSMALL;
     5214                }
     5215                *pData = formatTokens[checkStr].tokenId;
     5216                pData = pData + 1;
     5217                realLen = realLen + 1;
     5218
     5219                pFormatA = pFormatA + formatTokens[checkStr].tokenSize;
     5220                formatLeft = formatLeft - formatTokens[checkStr].tokenSize;
     5221                checkStr = -1; /* Flag as found and break out of while loop */
     5222            } else {
     5223                checkStr++;
     5224            }
     5225        }
     5226
     5227        /* Did we ever match a token? */
     5228        if (checkStr != -1 && insertCopy == FALSE) {
     5229            TRACE("No match - need to insert copy from %p [%p]\n", pFormatA, pStart);
     5230            insertCopy = TRUE;
     5231            copyFrom   = pFormatA;
     5232        } else if (checkStr != -1) {
     5233            pFormatA = pFormatA + 1;
     5234        }
     5235
     5236    }
     5237
     5238    /* Finally, if we have skipped chars, insert the copy */
     5239    if (insertCopy == TRUE) {
     5240
     5241        TRACE("Chars left over, so still copy %p,%p,%p\n", copyFrom, pStart, pFormatA);
     5242        if ((realLen + 3) > cbTok) {
     5243            HeapFree( GetProcessHeap(), 0, pFormatA );
     5244            return TYPE_E_BUFFERTOOSMALL;
     5245        }
     5246        insertCopy = FALSE;
     5247        *pData = TOK_COPY;
     5248        pData++;
     5249        *pData = (BYTE)(copyFrom - pStart);
     5250        pData++;
     5251        *pData = (BYTE)(pFormatA - copyFrom);
     5252        pData++;
     5253        realLen = realLen + 3;
     5254    }
     5255
     5256    /* Finally insert the terminator */
     5257    if ((realLen + 1) > cbTok) {
     5258        HeapFree( GetProcessHeap(), 0, pFormatA );
     5259        return TYPE_E_BUFFERTOOSMALL;
     5260    }
     5261    *pData++ = TOK_END;
     5262    realLen = realLen + 1;
     5263
     5264    /* Finally fill in the length */
     5265    hdr->len = realLen;
     5266    *pcbActual = realLen;
     5267
     5268#if 0
     5269    { int i,j;
     5270      for (i=0; i<realLen; i=i+0x10) {
     5271          printf(" %4.4x : ", i);
     5272          for (j=0; j<0x10 && (i+j < realLen); j++) {
     5273              printf("%2.2x ", rgbTok[i+j]);
     5274          }
     5275          printf("\n");
     5276      }
     5277    }
     5278#endif
     5279    HeapFree( GetProcessHeap(), 0, pFormatA );
     5280
     5281    return S_OK;
     5282}
     5283
     5284/**********************************************************************
     5285 *              VarFormatFromTokens [OLEAUT32.139]
     5286 * FIXME: No account of flags or iFirstDay etc
     5287 */
     5288HRESULT WINAPI VarFormatFromTokens(LPVARIANT varIn, LPOLESTR format,
     5289                            LPBYTE pbTokCur, ULONG dwFlags, BSTR *pbstrOut,
     5290                            LCID  lcid) {
     5291
     5292    FORMATHDR   *hdr = (FORMATHDR *)pbTokCur;
     5293    BYTE        *pData    = pbTokCur + sizeof (FORMATHDR);
     5294    LPSTR        pFormatA = HEAP_strdupWtoA( GetProcessHeap(), 0, format );
     5295    char         output[BUFFER_MAX];
     5296    char        *pNextPos;
     5297    int          size, whichToken;
     5298    VARIANTARG   Variant;
     5299    struct tm    TM;
     5300
     5301
     5302
     5303    TRACE("'%s', %p %lx %p only date support\n", pFormatA, pbTokCur, dwFlags, pbstrOut);
     5304    TRACE("varIn:\n");
     5305    dump_Variant(varIn);
     5306
     5307    memset(output, 0x00, BUFFER_MAX);
     5308    pNextPos = output;
     5309
     5310    while (*pData != TOK_END && ((pData - pbTokCur) <= (hdr->len))) {
     5311
     5312        TRACE("Output looks like : '%s'\n", output);
     5313
     5314        /* Convert varient to appropriate data type */
     5315        whichToken = 0;
     5316        while ((formatTokens[whichToken].tokenSize != 0x00) &&
     5317               (formatTokens[whichToken].tokenId   != *pData)) {
     5318            whichToken++;
     5319        }
     5320
     5321        /* Use Variant local from here downwards as always correct type */
     5322        if (formatTokens[whichToken].tokenSize > 0 &&
     5323            formatTokens[whichToken].varTypeRequired != 0) {
     5324                        VariantInit( &Variant );
     5325            if (Coerce( &Variant, lcid, dwFlags, varIn,
     5326                        formatTokens[whichToken].varTypeRequired ) != S_OK) {
     5327                HeapFree( GetProcessHeap(), 0, pFormatA );
     5328                return DISP_E_TYPEMISMATCH;
     5329            } else if (formatTokens[whichToken].varTypeRequired == VT_DATE) {
     5330                if( DateToTm( V_UNION(&Variant,date), dwFlags, &TM ) == FALSE ) {
     5331                    HeapFree( GetProcessHeap(), 0, pFormatA );
     5332                    return E_INVALIDARG;
     5333                }
     5334            }
     5335        }
     5336
     5337        TRACE("Looking for match on token '%x'\n", *pData);
     5338        switch (*pData) {
     5339        case TOK_COPY:
     5340            TRACE("Copy from %d for %d bytes\n", *(pData+1), *(pData+2));
     5341            memcpy(pNextPos, &pFormatA[*(pData+1)], *(pData+2));
     5342            pNextPos = pNextPos + *(pData+2);
     5343            pData = pData + 3;
     5344            break;
     5345
     5346        case TOK_COLON   :
     5347            /* Get locale information - Time Seperator */
     5348            size = GetLocaleInfoA(lcid, LOCALE_STIME, NULL, 0);
     5349            GetLocaleInfoA(lcid, LOCALE_STIME, pNextPos, size);
     5350            TRACE("TOK_COLON Time seperator is '%s'\n", pNextPos);
     5351            pNextPos = pNextPos + size;
     5352            pData = pData + 1;
     5353            break;
     5354
     5355        case TOK_SLASH   :
     5356            /* Get locale information - Date Seperator */
     5357            size = GetLocaleInfoA(lcid, LOCALE_SDATE, NULL, 0);
     5358            GetLocaleInfoA(lcid, LOCALE_SDATE, pNextPos, size);
     5359            TRACE("TOK_COLON Time seperator is '%s'\n", pNextPos);
     5360            pNextPos = pNextPos + size;
     5361            pData = pData + 1;
     5362            break;
     5363
     5364        case TOK_d       :
     5365            sprintf(pNextPos, "%d", TM.tm_mday);
     5366            pNextPos = pNextPos + strlen(pNextPos);
     5367            pData = pData + 1;
     5368            break;
     5369
     5370        case TOK_dd      :
     5371            sprintf(pNextPos, "%2.2d", TM.tm_mday);
     5372            pNextPos = pNextPos + strlen(pNextPos);
     5373            pData = pData + 1;
     5374            break;
     5375
     5376        case TOK_w       :
     5377            sprintf(pNextPos, "%d", TM.tm_wday+1);
     5378            pNextPos = pNextPos + strlen(pNextPos);
     5379            pData = pData + 1;
     5380            break;
     5381
     5382        case TOK_m       :
     5383            sprintf(pNextPos, "%d", TM.tm_mon+1);
     5384            pNextPos = pNextPos + strlen(pNextPos);
     5385            pData = pData + 1;
     5386            break;
     5387
     5388        case TOK_mm      :
     5389            sprintf(pNextPos, "%2.2d", TM.tm_mon+1);
     5390            pNextPos = pNextPos + strlen(pNextPos);
     5391            pData = pData + 1;
     5392            break;
     5393
     5394        case TOK_q       :
     5395            sprintf(pNextPos, "%d", ((TM.tm_mon+1)/4)+1);
     5396            pNextPos = pNextPos + strlen(pNextPos);
     5397            pData = pData + 1;
     5398            break;
     5399
     5400        case TOK_y       :
     5401            sprintf(pNextPos, "%2.2d", TM.tm_yday+1);
     5402            pNextPos = pNextPos + strlen(pNextPos);
     5403            pData = pData + 1;
     5404            break;
     5405
     5406        case TOK_yy      :
     5407            sprintf(pNextPos, "%2.2d", TM.tm_year);
     5408            pNextPos = pNextPos + strlen(pNextPos);
     5409            pData = pData + 1;
     5410            break;
     5411
     5412        case TOK_yyyy    :
     5413            sprintf(pNextPos, "%4.4d", TM.tm_year);
     5414            pNextPos = pNextPos + strlen(pNextPos);
     5415            pData = pData + 1;
     5416            break;
     5417
     5418        case TOK_h       :
     5419            sprintf(pNextPos, "%d", TM.tm_hour);
     5420            pNextPos = pNextPos + strlen(pNextPos);
     5421            pData = pData + 1;
     5422            break;
     5423
     5424        case TOK_Hh      :
     5425            sprintf(pNextPos, "%2.2d", TM.tm_hour);
     5426            pNextPos = pNextPos + strlen(pNextPos);
     5427            pData = pData + 1;
     5428            break;
     5429
     5430        case TOK_N       :
     5431            sprintf(pNextPos, "%d", TM.tm_min);
     5432            pNextPos = pNextPos + strlen(pNextPos);
     5433            pData = pData + 1;
     5434            break;
     5435
     5436        case TOK_Nn      :
     5437            sprintf(pNextPos, "%2.2d", TM.tm_min);
     5438            pNextPos = pNextPos + strlen(pNextPos);
     5439            pData = pData + 1;
     5440            break;
     5441
     5442        case TOK_S       :
     5443            sprintf(pNextPos, "%d", TM.tm_sec);
     5444            pNextPos = pNextPos + strlen(pNextPos);
     5445            pData = pData + 1;
     5446            break;
     5447
     5448        case TOK_Ss      :
     5449            sprintf(pNextPos, "%2.2d", TM.tm_sec);
     5450            pNextPos = pNextPos + strlen(pNextPos);
     5451            pData = pData + 1;
     5452            break;
     5453
     5454        /* FIXME: To Do! */
     5455        case TOK_ttttt   :
     5456        case TOK_AMsPM   :
     5457        case TOK_amspm   :
     5458        case TOK_AsP     :
     5459        case TOK_asp     :
     5460        case TOK_AMPM    :
     5461        case TOK_c       :
     5462        case TOK_ddd     :
     5463        case TOK_dddd    :
     5464        case TOK_ddddd   :
     5465        case TOK_dddddd  :
     5466        case TOK_ww      :
     5467        case TOK_mmm     :
     5468        case TOK_mmmm    :
     5469        default:
     5470            FIXME("Unhandled token for VarFormat %d\n", *pData);
     5471            HeapFree( GetProcessHeap(), 0, pFormatA );
     5472            return E_INVALIDARG;
     5473        }
     5474
     5475    }
     5476
     5477    *pbstrOut = StringDupAtoBstr( output );
     5478    HeapFree( GetProcessHeap(), 0, pFormatA );
     5479    return S_OK;
     5480}
     5481
     5482/**********************************************************************
     5483 *              VarFormat [OLEAUT32.87]
     5484 *
     5485 */
     5486HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format,
     5487                         int firstDay, int firstWeek, ULONG dwFlags,
     5488                         BSTR *pbstrOut) {
     5489
     5490    LPSTR   pNewString = NULL;
     5491    HRESULT rc = S_OK;
     5492
     5493    TRACE("mostly stub! format='%s' day=%d, wk=%d, flags=%ld\n",
     5494          debugstr_w(format), firstDay, firstWeek, dwFlags);
     5495    TRACE("varIn:\n");
     5496    dump_Variant(varIn);
     5497
     5498    /* Note: Must Handle references type Variants (contain ptrs
     5499          to values rather than values */
     5500
     5501    /* Get format string */
     5502    pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, format );
     5503
     5504    /* FIXME: Handle some simple pre-definted format strings : */
     5505    if (((V_VT(varIn)&VT_TYPEMASK) == VT_CY) && (lstrcmpiA(pNewString, "Currency") == 0)) {
     5506
     5507        /* Can't use VarBstrFromCy as it does not put currency sign on nor decimal places */
     5508        double curVal;
     5509
     5510
     5511        /* Handle references type Variants (contain ptrs to values rather than values */
     5512        if (V_VT(varIn)&VT_BYREF) {
     5513            rc = VarR8FromCy(*(CY *)V_UNION(varIn,byref), &curVal);
     5514        } else {
     5515            rc = VarR8FromCy(V_UNION(varIn,cyVal), &curVal);
     5516        }
     5517
     5518        if (rc == S_OK) {
     5519            char tmpStr[BUFFER_MAX];
     5520            sprintf(tmpStr, "%f", curVal);
     5521            if (GetCurrencyFormatA(GetUserDefaultLCID(), dwFlags, tmpStr, NULL, pBuffer, BUFFER_MAX) == 0) {
     5522                return E_FAIL;
     5523            } else {
     5524                *pbstrOut = StringDupAtoBstr( pBuffer );
     5525            }
     5526        }
     5527
     5528    } else if ((V_VT(varIn)&VT_TYPEMASK) == VT_DATE) {
     5529
     5530        /* Attempt to do proper formatting! */
     5531        int firstToken = -1;
     5532
     5533        rc = VarTokenizeFormatString(format, pBuffer, sizeof(pBuffer), firstDay,
     5534                                  firstWeek, GetUserDefaultLCID(), &firstToken);
     5535        if (rc==S_OK) {
     5536            rc = VarFormatFromTokens(varIn, format, pBuffer, dwFlags, pbstrOut, GetUserDefaultLCID());
     5537        }
     5538
     5539    } else if ((V_VT(varIn)&VT_TYPEMASK) == VT_R8) {
     5540        if (V_VT(varIn)&VT_BYREF) {
     5541            sprintf(pBuffer, "%f", *(double *)V_UNION(varIn,byref));
     5542        } else {
     5543            sprintf(pBuffer, "%f", V_UNION(varIn,dblVal));
     5544        }
     5545
     5546        *pbstrOut = StringDupAtoBstr( pBuffer );
     5547
     5548    } else {
     5549        FIXME("VarFormat: Unsupported format %d!\n", V_VT(varIn)&VT_TYPEMASK);
     5550        *pbstrOut = StringDupAtoBstr( "??" );
     5551    }
     5552
     5553    /* Free allocated storage */
     5554    HeapFree( GetProcessHeap(), 0, pNewString );
     5555    TRACE("result: '%s'\n", debugstr_w(*pbstrOut));
     5556    return rc;
     5557}
     5558
     5559/**********************************************************************
     5560 *              VarCyMulI4 [OLEAUT32.304]
     5561 * Multiply currency value by integer
     5562 */
     5563HRESULT WINAPI VarCyMulI4(CY cyIn, LONG mulBy, CY *pcyOut) {
     5564
     5565    double cyVal = 0;
     5566    HRESULT rc = S_OK;
     5567
     5568    rc = VarR8FromCy(cyIn, &cyVal);
     5569    if (rc == S_OK) {
     5570        rc = VarCyFromR8((cyVal * (double) mulBy), pcyOut);
     5571        TRACE("Multiply %f by %ld = %f [%ld,%lu]\n", cyVal, mulBy, (cyVal * (double) mulBy),
     5572                    pcyOut->s.Hi, pcyOut->s.Lo);
     5573    }
     5574    return rc;
     5575}
Note: See TracChangeset for help on using the changeset viewer.