4 * Copyright 1995 Martin von Loewis
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/windef16.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
41 /* This implementation of the BSTR API is 16-bit only. It
42 represents BSTR as a 16:16 far pointer, and the strings
45 /******************************************************************************
46 * BSTR_AllocBytes [Internal]
48 static BSTR16
BSTR_AllocBytes(int n
)
50 void *ptr
= HeapAlloc( GetProcessHeap(), 0, n
);
51 return (BSTR16
)MapLS(ptr
);
54 /******************************************************************************
55 * BSTR_Free [INTERNAL]
57 static void BSTR_Free(BSTR16 in
)
59 void *ptr
= MapSL( (SEGPTR
)in
);
60 UnMapLS( (SEGPTR
)in
);
61 HeapFree( GetProcessHeap(), 0, ptr
);
64 /******************************************************************************
65 * BSTR_GetAddr [INTERNAL]
67 static void* BSTR_GetAddr(BSTR16 in
)
69 return in
? MapSL((SEGPTR
)in
) : 0;
72 /******************************************************************************
73 * SysAllocString [OLE2DISP.2]
75 * Create a BSTR16 from an OLESTR16 (16 Bit).
78 * oleStr [I] Source to create BSTR16 from
81 * Success: A BSTR16 allocated with SysAllocStringLen16().
82 * Failure: NULL, if oleStr is NULL.
84 BSTR16 WINAPI
SysAllocString16(LPCOLESTR16 oleStr
)
88 if (!oleStr
) return 0;
90 out
= BSTR_AllocBytes(strlen(oleStr
)+1);
92 strcpy(BSTR_GetAddr(out
),oleStr
);
96 /******************************************************************************
97 * SysReallocString [OLE2DISP.3]
99 * Change the length of a previously created BSTR16 (16 Bit).
102 * pbstr [I] BSTR16 to change the length of
103 * oleStr [I] New source for pbstr
110 * SysAllocStringStringLen16().
112 INT16 WINAPI
SysReAllocString16(LPBSTR16 pbstr
,LPCOLESTR16 oleStr
)
114 BSTR16
new=SysAllocString16(oleStr
);
120 /******************************************************************************
121 * SysAllocStringLen [OLE2DISP.4]
123 * Create a BSTR16 from an OLESTR16 of a given character length (16 Bit).
126 * oleStr [I] Source to create BSTR16 from
127 * len [I] Length of oleStr in wide characters
130 * Success: A newly allocated BSTR16 from SysAllocStringByteLen16()
131 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
134 * See SysAllocStringByteLen16().
136 BSTR16 WINAPI
SysAllocStringLen16(const char *oleStr
, int len
)
138 BSTR16 out
=BSTR_AllocBytes(len
+1);
144 * Copy the information in the buffer.
145 * Since it is valid to pass a NULL pointer here, we'll initialize the
146 * buffer to nul if it is the case.
149 strcpy(BSTR_GetAddr(out
),oleStr
);
151 memset(BSTR_GetAddr(out
), 0, len
+1);
156 /******************************************************************************
157 * SysReAllocStringLen [OLE2DISP.5]
159 * Change the length of a previously created BSTR16 (16 Bit).
162 * pbstr [I] BSTR16 to change the length of
163 * oleStr [I] New source for pbstr
164 * len [I] Length of oleStr in characters
167 * Success: 1. The size of pbstr is updated.
168 * Failure: 0, if len >= 0x8000 or memory allocation fails.
171 * See SysAllocStringByteLen16().
172 * *pbstr may be changed by this function.
174 int WINAPI
SysReAllocStringLen16(BSTR16
*old
,const char *in
,int len
)
176 /* FIXME: Check input length */
177 BSTR16
new=SysAllocStringLen16(in
,len
);
183 /******************************************************************************
184 * SysFreeString [OLE2DISP.6]
186 * Free a BSTR16 (16 Bit).
189 * str [I] String to free.
194 void WINAPI
SysFreeString16(BSTR16 str
)
199 /******************************************************************************
200 * SysStringLen [OLE2DISP.7]
202 * Get the allocated length of a BSTR16 in characters (16 Bit).
205 * str [I] BSTR16 to find the length of
208 * The allocated length of str, or 0 if str is NULL.
210 int WINAPI
SysStringLen16(BSTR16 str
)
212 return strlen(BSTR_GetAddr(str
));
215 /******************************************************************************
216 * CreateDispTypeInfo [OLE2DISP.31]
218 HRESULT WINAPI
CreateDispTypeInfo16(
219 INTERFACEDATA
*pidata
,
223 FIXME("(%p,%d,%p),stub\n",pidata
,lcid
,pptinfo
);
227 /******************************************************************************
228 * CreateStdDispatch [OLE2DISP.32]
230 HRESULT WINAPI
CreateStdDispatch16(
234 IUnknown
** ppunkStdDisp
)
236 FIXME("(%p,%p,%p,%p),stub\n",punkOuter
, pvThis
, ptinfo
,
241 /******************************************************************************
242 * RegisterActiveObject [OLE2DISP.35]
244 HRESULT WINAPI
RegisterActiveObject16(
245 IUnknown
*punk
, REFCLSID rclsid
, DWORD dwFlags
, unsigned long *pdwRegister
247 FIXME("(%p,%s,0x%08x,%p):stub\n",punk
,debugstr_guid(rclsid
),dwFlags
,pdwRegister
);