Release 981025.
[wine/gsoc-2012-control.git] / ole / ole2disp.c
blob58f7dfc22f3b403bb83cdb7f75a48eb0ffb0fbff
1 /*
2 * OLE2DISP library
4 * Copyright 1995 Martin von Loewis
5 */
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"
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 */
20 /******************************************************************************
21 * BSTR_AllocBytes [Internal]
23 static BSTR16 BSTR_AllocBytes(int n)
25 void *ptr = SEGPTR_ALLOC(n);
26 return (BSTR16)SEGPTR_GET(ptr);
29 /******************************************************************************
30 * BSTR_Free [INTERNAL]
32 static void BSTR_Free(BSTR16 in)
34 SEGPTR_FREE( PTR_SEG_TO_LIN(in) );
37 /******************************************************************************
38 * BSTR_GetAddr [INTERNAL]
40 static void* BSTR_GetAddr(BSTR16 in)
42 return in ? PTR_SEG_TO_LIN(in) : 0;
45 /******************************************************************************
46 * SysAllocString16 [OLE2DISP.2]
48 BSTR16 WINAPI SysAllocString16(LPOLESTR16 in)
50 BSTR16 out=BSTR_AllocBytes(strlen(in)+1);
51 if(!out)return 0;
52 strcpy(BSTR_GetAddr(out),in);
53 return out;
56 /******************************************************************************
57 * SysAllocString32 [OLEAUT32.2]
59 BSTR32 WINAPI SysAllocString32(LPOLESTR32 in)
61 return HEAP_strdupW(GetProcessHeap(),0,in);
64 /******************************************************************************
65 * SysReAllocString16 [OLE2DISP.3]
67 INT16 WINAPI SysReAllocString16(LPBSTR16 old,LPOLESTR16 in)
69 BSTR16 new=SysAllocString16(in);
70 BSTR_Free(*old);
71 *old=new;
72 return 1;
75 /******************************************************************************
76 * SysReAllocString32 [OLEAUT32.3]
78 INT32 WINAPI SysReAllocString32(LPBSTR32 old,LPOLESTR32 in)
80 BSTR32 new=SysAllocString32(in);
81 HeapFree(GetProcessHeap(),0,*old);
82 *old=new;
83 return 1;
86 /******************************************************************************
87 * SysAllocStringLen16 [OLE2DISP.4]
89 BSTR16 WINAPI SysAllocStringLen16(char *in, int len)
91 BSTR16 out=BSTR_AllocBytes(len+1);
92 if(!out)return 0;
93 strcpy(BSTR_GetAddr(out),in);
94 return out;
97 /******************************************************************************
98 * SysReAllocStringLen16 [OLE2DISP.5]
100 int WINAPI SysReAllocStringLen16(BSTR16 *old,char *in,int len)
102 BSTR16 new=SysAllocStringLen16(in,len);
103 BSTR_Free(*old);
104 *old=new;
105 return 1;
108 /******************************************************************************
109 * SysFreeString16 [OLE2DISP.6]
111 void WINAPI SysFreeString16(BSTR16 in)
113 BSTR_Free(in);
116 /******************************************************************************
117 * SysFreeString32 [OLEAUT32.6]
119 void WINAPI SysFreeString32(BSTR32 in)
121 HeapFree(GetProcessHeap(),0,in);
124 /******************************************************************************
125 * SysStringLen16 [OLE2DISP.7]
127 int WINAPI SysStringLen16(BSTR16 str)
129 return strlen(BSTR_GetAddr(str));
132 /******************************************************************************
133 * CreateDispTypeInfo [OLE2DISP.31]
135 OLESTATUS WINAPI CreateDispTypeInfo(
136 INTERFACEDATA *pidata,
137 LCID lcid,
138 LPVOID **pptinfo /*ITypeInfo*/
140 FIXME(ole,"(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
141 return 0;
144 /******************************************************************************
145 * RegisterActiveObject [OLE2DISP.35]
147 OLESTATUS WINAPI RegisterActiveObject(
148 IUnknown * punk,REFCLSID rclsid,DWORD dwFlags, DWORD * pdwRegister
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;