Documentation updates.
[wine] / ole / ole2disp.c
1 /*
2  *      OLE2DISP library
3  *
4  *      Copyright 1995  Martin von Loewis
5  */
6
7 #include "windows.h"
8 #include "ole.h"
9 #include "ole2.h"
10 #include "oleauto.h"
11 #include "interfaces.h"
12 #include "heap.h"
13 #include "ldt.h"
14 #include "debug.h"
15
16 /* This implementation of the BSTR API is 16-bit only. It
17    represents BSTR as a 16:16 far pointer, and the strings
18    as ISO-8859 */
19
20 /******************************************************************************
21  *              BSTR_AllocBytes [Internal]
22  */
23 static BSTR16 BSTR_AllocBytes(int n)
24 {
25     void *ptr = SEGPTR_ALLOC(n);
26     return (BSTR16)SEGPTR_GET(ptr);
27 }
28
29 /******************************************************************************
30  * BSTR_Free [INTERNAL]
31  */
32 static void BSTR_Free(BSTR16 in)
33 {
34     SEGPTR_FREE( PTR_SEG_TO_LIN(in) );
35 }
36
37 /******************************************************************************
38  * BSTR_GetAddr [INTERNAL]
39  */
40 static void* BSTR_GetAddr(BSTR16 in)
41 {
42     return in ? PTR_SEG_TO_LIN(in) : 0;
43 }
44
45 /******************************************************************************
46  *              SysAllocString16        [OLE2DISP.2]
47  */
48 BSTR16 WINAPI SysAllocString16(LPOLESTR16 in)
49 {
50         BSTR16 out=BSTR_AllocBytes(strlen(in)+1);
51         if(!out)return 0;
52         strcpy(BSTR_GetAddr(out),in);
53         return out;
54 }
55
56 /******************************************************************************
57  *              SysAllocString32        [OLEAUT32.2]
58  */
59 BSTR32 WINAPI SysAllocString32(LPOLESTR32 in)
60 {
61         return HEAP_strdupW(GetProcessHeap(),0,in);
62 }
63
64 /******************************************************************************
65  *              SysReAllocString16      [OLE2DISP.3]
66  */
67 INT16 WINAPI SysReAllocString16(LPBSTR16 old,LPOLESTR16 in)
68 {
69         BSTR16 new=SysAllocString16(in);
70         BSTR_Free(*old);
71         *old=new;
72         return 1;
73 }
74
75 /******************************************************************************
76  *              SysReAllocString32      [OLEAUT32.3]
77  */
78 INT32 WINAPI SysReAllocString32(LPBSTR32 old,LPOLESTR32 in)
79 {
80         BSTR32 new=SysAllocString32(in);
81         HeapFree(GetProcessHeap(),0,*old);
82         *old=new;
83         return 1;
84 }
85
86 /******************************************************************************
87  *              SysAllocStringLen16     [OLE2DISP.4]
88  */
89 BSTR16 WINAPI SysAllocStringLen16(char *in, int len)
90 {
91         BSTR16 out=BSTR_AllocBytes(len+1);
92         if(!out)return 0;
93         strcpy(BSTR_GetAddr(out),in);
94         return out;
95 }
96
97 /******************************************************************************
98  *              SysReAllocStringLen16   [OLE2DISP.5]
99  */
100 int WINAPI SysReAllocStringLen16(BSTR16 *old,char *in,int len)
101 {
102         BSTR16 new=SysAllocStringLen16(in,len);
103         BSTR_Free(*old);
104         *old=new;
105         return 1;
106 }
107
108 /******************************************************************************
109  *              SysFreeString16 [OLE2DISP.6]
110  */
111 void WINAPI SysFreeString16(BSTR16 in)
112 {
113         BSTR_Free(in);
114 }
115
116 /******************************************************************************
117  *              SysFreeString32 [OLEAUT32.6]
118  */
119 void WINAPI SysFreeString32(BSTR32 in)
120 {
121         HeapFree(GetProcessHeap(),0,in);
122 }
123
124 /******************************************************************************
125  *              SysStringLen16  [OLE2DISP.7]
126  */
127 int WINAPI SysStringLen16(BSTR16 str)
128 {
129         return strlen(BSTR_GetAddr(str));
130 }
131
132 /******************************************************************************
133  * CreateDispTypeInfo [OLE2DISP.31]
134  */
135 OLESTATUS WINAPI CreateDispTypeInfo(
136         INTERFACEDATA *pidata,
137         LCID lcid,
138         LPVOID **pptinfo /*ITypeInfo*/ 
139 ) {
140         FIXME(ole,"(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
141         return 0;
142 }
143
144 /******************************************************************************
145  * RegisterActiveObject [OLE2DISP.35]
146  */
147 OLESTATUS WINAPI RegisterActiveObject(
148         IUnknown * punk,REFCLSID rclsid,DWORD dwFlags, DWORD * pdwRegister
149 ) {
150         char    buf[80];
151         WINE_StringFromCLSID(rclsid,buf);
152         FIXME(ole,"(%p,%s,0x%08lx,%p):stub\n",punk,buf,dwFlags,pdwRegister);
153         return 0;
154 }