4 * Copyright 1995 Martin von Loewis
7 /* At the moment, these are only empty stubs.
19 DWORD currentMalloc
=0;
21 /***********************************************************************
22 * CoBuildVersion [COMPOBJ.1]
24 DWORD WINAPI
CoBuildVersion()
26 dprintf_ole(stddeb
,"CoBuildVersion()\n");
30 /***********************************************************************
31 * CoInitialize [COMPOBJ.2]
32 * lpReserved is an IMalloc pointer in 16bit OLE. We just stored it as-is.
34 HRESULT WINAPI
CoInitialize(DWORD lpReserved
)
36 dprintf_ole(stdnimp
,"CoInitialize\n");
37 /* remember the LPMALLOC, maybe somebody wants to read it later on */
38 currentMalloc
= lpReserved
;
42 /***********************************************************************
43 * CoUnitialize [COMPOBJ.3]
45 void WINAPI
CoUnitialize()
47 dprintf_ole(stdnimp
,"CoUnitialize()\n");
50 /***********************************************************************
51 * CoGetMalloc [COMPOBJ.4]
53 HRESULT WINAPI
CoGetMalloc(DWORD dwMemContext
, DWORD
* lpMalloc
)
57 *lpMalloc
= currentMalloc
;
61 /* 16-bit E_NOTIMPL */
65 /***********************************************************************
68 OLESTATUS WINAPI
CoDisconnectObject( LPUNKNOWN lpUnk
, DWORD reserved
)
70 dprintf_ole(stdnimp
,"CoDisconnectObject:%p %lx\n",lpUnk
,reserved
);
74 /***********************************************************************
75 * IsEqualGUID [COMPOBJ.18]
77 BOOL16 WINAPI
IsEqualGUID(GUID
* g1
, GUID
* g2
)
79 return !memcmp( g1
, g2
, sizeof(GUID
) );
82 /***********************************************************************
83 * CLSIDFromString [COMPOBJ.20]
86 /* Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] */
88 OLESTATUS WINAPI
CLSIDFromString(const LPCSTR idstr
, CLSID
*id
)
90 BYTE
*s
= (BYTE
*) idstr
;
95 dprintf_ole(stddeb
,"ClsIDFromString() %s -> %p\n", idstr
, id
);
97 /* quick lookup table */
98 memset(table
, 0, 256);
100 for (i
= 0; i
< 10; i
++) {
103 for (i
= 0; i
< 6; i
++) {
104 table
['A' + i
] = i
+10;
105 table
['a' + i
] = i
+10;
108 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
110 if (strlen(idstr
) != 38)
111 return OLE_ERROR_OBJECT
;
115 s
++; /* skip leading brace */
116 for (i
= 0; i
< 4; i
++) {
117 p
[3 - i
] = table
[*s
]<<4 | table
[*(s
+1)];
123 for (i
= 0; i
< 2; i
++) {
124 p
[1-i
] = table
[*s
]<<4 | table
[*(s
+1)];
130 for (i
= 0; i
< 2; i
++) {
131 p
[1-i
] = table
[*s
]<<4 | table
[*(s
+1)];
137 /* these are just sequential bytes */
138 for (i
= 0; i
< 2; i
++) {
139 *p
++ = table
[*s
]<<4 | table
[*(s
+1)];
144 for (i
= 0; i
< 6; i
++) {
145 *p
++ = table
[*s
]<<4 | table
[*(s
+1)];
152 /***********************************************************************
153 * CLSIDFromString [COMPOBJ.19]
156 OLESTATUS WINAPI
StringFromCLSID(const CLSID
*id
, LPSTR idstr
)
158 static const char *hex
= "0123456789ABCDEF";
162 sprintf(idstr
, "{%08lx-%04x-%04x-%2x%2x-",
163 id
->Data1
, id
->Data2
, id
->Data3
,
164 id
->Data4
[0], id
->Data4
[1]);
168 for (i
= 2; i
< 8; i
++) {
169 *s
++ = hex
[id
->Data4
[i
]>>4];
170 *s
++ = hex
[id
->Data4
[i
] & 0xf];
176 for (i
= strlen(idstr
)-1; i
>= 0; i
--) {
177 idstr
[i
] = toupper(idstr
[i
]);
180 dprintf_ole(stddeb
,"StringFromClsID: %p->%s\n", id
, idstr
);