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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #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 BSTR16 WINAPI SysAllocString16(LPCOLESTR16 in)
81 out = BSTR_AllocBytes(strlen(in)+1);
83 strcpy(BSTR_GetAddr(out),in);
87 /******************************************************************************
88 * SysReallocString [OLE2DISP.3]
90 INT16 WINAPI SysReAllocString16(LPBSTR16 old,LPCOLESTR16 in)
92 BSTR16 new=SysAllocString16(in);
98 /******************************************************************************
99 * SysAllocStringLen [OLE2DISP.4]
101 BSTR16 WINAPI SysAllocStringLen16(const char *in, int len)
103 BSTR16 out=BSTR_AllocBytes(len+1);
109 * Copy the information in the buffer.
110 * Since it is valid to pass a NULL pointer here, we'll initialize the
111 * buffer to nul if it is the case.
114 strcpy(BSTR_GetAddr(out),in);
116 memset(BSTR_GetAddr(out), 0, len+1);
121 /******************************************************************************
122 * SysReAllocStringLen [OLE2DISP.5]
124 int WINAPI SysReAllocStringLen16(BSTR16 *old,const char *in,int len)
126 BSTR16 new=SysAllocStringLen16(in,len);
132 /******************************************************************************
133 * SysFreeString [OLE2DISP.6]
135 void WINAPI SysFreeString16(BSTR16 in)
140 /******************************************************************************
141 * SysStringLen [OLE2DISP.7]
143 int WINAPI SysStringLen16(BSTR16 str)
145 return strlen(BSTR_GetAddr(str));
148 /******************************************************************************
149 * CreateDispTypeInfo [OLE2DISP.31]
151 HRESULT WINAPI CreateDispTypeInfo16(
152 INTERFACEDATA *pidata,
156 FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
160 /******************************************************************************
161 * CreateStdDispatch [OLE2DISP.32]
163 HRESULT WINAPI CreateStdDispatch16(
167 IUnknown** ppunkStdDisp)
169 FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
174 /******************************************************************************
175 * RegisterActiveObject [OLE2DISP.35]
177 HRESULT WINAPI RegisterActiveObject16(
178 IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister
180 FIXME("(%p,%s,0x%08lx,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister);