-/*\r
- * OLE2DISP library\r
- *\r
- * Copyright 1995 Martin von Loewis\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- */\r
-\r
-#include "config.h"\r
-\r
-#include <stdarg.h>\r
-#include <string.h>\r
-\r
-#include "wine/windef16.h"\r
-#include "windef.h"\r
-#include "winbase.h"\r
-#include "wingdi.h"\r
-#include "winuser.h"\r
-#include "ole2.h"\r
-#include "oleauto.h"\r
-#include "winerror.h"\r
-\r
-#include "ole2disp.h"\r
-\r
-#include "wine/debug.h"\r
-\r
-WINE_DEFAULT_DEBUG_CHANNEL(ole);\r
-\r
-/* This implementation of the BSTR API is 16-bit only. It\r
- represents BSTR as a 16:16 far pointer, and the strings\r
- as ISO-8859 */\r
-\r
-/******************************************************************************\r
- * BSTR_AllocBytes [Internal]\r
- */\r
-static BSTR16 BSTR_AllocBytes(int n)\r
-{\r
- void *ptr = HeapAlloc( GetProcessHeap(), 0, n );\r
- return (BSTR16)MapLS(ptr);\r
-}\r
-\r
-/******************************************************************************\r
- * BSTR_Free [INTERNAL]\r
- */\r
-static void BSTR_Free(BSTR16 in)\r
-{\r
- void *ptr = MapSL( (SEGPTR)in );\r
- UnMapLS( (SEGPTR)in );\r
- HeapFree( GetProcessHeap(), 0, ptr );\r
-}\r
-\r
-/******************************************************************************\r
- * BSTR_GetAddr [INTERNAL]\r
- */\r
-static void* BSTR_GetAddr(BSTR16 in)\r
-{\r
- return in ? MapSL((SEGPTR)in) : 0;\r
-}\r
-\r
-/******************************************************************************\r
- * SysAllocString [OLE2DISP.2]\r
- *\r
- * Create a BSTR16 from an OLESTR16 (16 Bit).\r
- *\r
- * PARAMS\r
- * oleStr [I] Source to create BSTR16 from\r
- *\r
- * RETURNS\r
- * Success: A BSTR16 allocated with SysAllocStringLen16().\r
- * Failure: NULL, if oleStr is NULL.\r
- */\r
-BSTR16 WINAPI SysAllocString16(LPCOLESTR16 oleStr)\r
-{\r
- BSTR16 out;\r
-\r
- if (!oleStr) return 0;\r
-\r
- out = BSTR_AllocBytes(strlen(oleStr)+1);\r
- if (!out) return 0;\r
- strcpy(BSTR_GetAddr(out),oleStr);\r
- return out;\r
-}\r
-\r
-/******************************************************************************\r
- * SysReallocString [OLE2DISP.3]\r
- *\r
- * Change the length of a previously created BSTR16 (16 Bit).\r
- *\r
- * PARAMS\r
- * pbstr [I] BSTR16 to change the length of\r
- * oleStr [I] New source for pbstr\r
- *\r
- * RETURNS\r
- * Success: 1\r
- * Failure: 0.\r
- *\r
- * NOTES\r
- * SysAllocStringStringLen16().\r
- */\r
-INT16 WINAPI SysReAllocString16(LPBSTR16 pbstr,LPCOLESTR16 oleStr)\r
-{\r
- BSTR16 new=SysAllocString16(oleStr);\r
- BSTR_Free(*pbstr);\r
- *pbstr=new;\r
- return 1;\r
-}\r
-\r
-/******************************************************************************\r
- * SysAllocStringLen [OLE2DISP.4]\r
- *\r
- * Create a BSTR16 from an OLESTR16 of a given character length (16 Bit).\r
- *\r
- * PARAMS\r
- * oleStr [I] Source to create BSTR16 from\r
- * len [I] Length of oleStr in wide characters\r
- *\r
- * RETURNS\r
- * Success: A newly allocated BSTR16 from SysAllocStringByteLen16()\r
- * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.\r
- *\r
- * NOTES\r
- * See SysAllocStringByteLen16().\r
- */\r
-BSTR16 WINAPI SysAllocStringLen16(const char *oleStr, int len)\r
-{\r
- BSTR16 out=BSTR_AllocBytes(len+1);\r
-\r
- if (!out)\r
- return 0;\r
-\r
- /*\r
- * Copy the information in the buffer.\r
- * Since it is valid to pass a NULL pointer here, we'll initialize the\r
- * buffer to nul if it is the case.\r
- */\r
- if (oleStr != 0)\r
- strcpy(BSTR_GetAddr(out),oleStr);\r
- else\r
- memset(BSTR_GetAddr(out), 0, len+1);\r
-\r
- return out;\r
-}\r
-\r
-/******************************************************************************\r
- * SysReAllocStringLen [OLE2DISP.5]\r
- *\r
- * Change the length of a previously created BSTR16 (16 Bit).\r
- *\r
- * PARAMS\r
- * pbstr [I] BSTR16 to change the length of\r
- * oleStr [I] New source for pbstr\r
- * len [I] Length of oleStr in characters\r
- *\r
- * RETURNS\r
- * Success: 1. The size of pbstr is updated.\r
- * Failure: 0, if len >= 0x8000 or memory allocation fails.\r
- *\r
- * NOTES\r
- * See SysAllocStringByteLen16().\r
- * *pbstr may be changed by this function.\r
- */\r
-int WINAPI SysReAllocStringLen16(BSTR16 *old,const char *in,int len)\r
-{\r
- /* FIXME: Check input length */\r
- BSTR16 new=SysAllocStringLen16(in,len);\r
- BSTR_Free(*old);\r
- *old=new;\r
- return 1;\r
-}\r
-\r
-/******************************************************************************\r
- * SysFreeString [OLE2DISP.6]\r
- *\r
- * Free a BSTR16 (16 Bit).\r
- *\r
- * PARAMS\r
- * str [I] String to free.\r
- *\r
- * RETURNS\r
- * Nothing.\r
- */\r
-void WINAPI SysFreeString16(BSTR16 str)\r
-{\r
- BSTR_Free(str);\r
-}\r
-\r
-/******************************************************************************\r
- * SysStringLen [OLE2DISP.7]\r
- *\r
- * Get the allocated length of a BSTR16 in characters (16 Bit).\r
- *\r
- * PARAMS\r
- * str [I] BSTR16 to find the length of\r
- *\r
- * RETURNS\r
- * The allocated length of str, or 0 if str is NULL.\r
- */\r
-int WINAPI SysStringLen16(BSTR16 str)\r
-{\r
- return strlen(BSTR_GetAddr(str));\r
-}\r
-\r
-/******************************************************************************\r
- * CreateDispTypeInfo [OLE2DISP.31]\r
- */\r
-HRESULT WINAPI CreateDispTypeInfo16(\r
- INTERFACEDATA *pidata,\r
- LCID lcid,\r
- ITypeInfo **pptinfo)\r
-{\r
- FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);\r
- return E_NOTIMPL;\r
-}\r
-\r
-/******************************************************************************\r
- * CreateStdDispatch [OLE2DISP.32]\r
- */\r
-HRESULT WINAPI CreateStdDispatch16(\r
- IUnknown* punkOuter,\r
- void* pvThis,\r
- ITypeInfo* ptinfo,\r
- IUnknown** ppunkStdDisp)\r
-{\r
- FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,\r
- ppunkStdDisp);\r
- return 0;\r
-}\r
-\r
-/******************************************************************************\r
- * RegisterActiveObject [OLE2DISP.35]\r
- */\r
-HRESULT WINAPI RegisterActiveObject16(\r
- IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister\r
-) {\r
- FIXME("(%p,%s,0x%08lx,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister);\r
- return E_NOTIMPL;\r
-}\r
+/*
+ * OLE2DISP library
+ *
+ * Copyright 1995 Martin von Loewis
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#include <stdarg.h>
+#include <string.h>
+
+#include "wine/windef16.h"
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "ole2.h"
+#include "oleauto.h"
+#include "winerror.h"
+
+#include "ole2disp.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ole);
+
+/* This implementation of the BSTR API is 16-bit only. It
+ represents BSTR as a 16:16 far pointer, and the strings
+ as ISO-8859 */
+
+/******************************************************************************
+ * BSTR_AllocBytes [Internal]
+ */
+static BSTR16 BSTR_AllocBytes(int n)
+{
+ void *ptr = HeapAlloc( GetProcessHeap(), 0, n );
+ return (BSTR16)MapLS(ptr);
+}
+
+/******************************************************************************
+ * BSTR_Free [INTERNAL]
+ */
+static void BSTR_Free(BSTR16 in)
+{
+ void *ptr = MapSL( (SEGPTR)in );
+ UnMapLS( (SEGPTR)in );
+ HeapFree( GetProcessHeap(), 0, ptr );
+}
+
+/******************************************************************************
+ * BSTR_GetAddr [INTERNAL]
+ */
+static void* BSTR_GetAddr(BSTR16 in)
+{
+ return in ? MapSL((SEGPTR)in) : 0;
+}
+
+/******************************************************************************
+ * SysAllocString [OLE2DISP.2]
+ *
+ * Create a BSTR16 from an OLESTR16 (16 Bit).
+ *
+ * PARAMS
+ * oleStr [I] Source to create BSTR16 from
+ *
+ * RETURNS
+ * Success: A BSTR16 allocated with SysAllocStringLen16().
+ * Failure: NULL, if oleStr is NULL.
+ */
+BSTR16 WINAPI SysAllocString16(LPCOLESTR16 oleStr)
+{
+ BSTR16 out;
+
+ if (!oleStr) return 0;
+
+ out = BSTR_AllocBytes(strlen(oleStr)+1);
+ if (!out) return 0;
+ strcpy(BSTR_GetAddr(out),oleStr);
+ return out;
+}
+
+/******************************************************************************
+ * SysReallocString [OLE2DISP.3]
+ *
+ * Change the length of a previously created BSTR16 (16 Bit).
+ *
+ * PARAMS
+ * pbstr [I] BSTR16 to change the length of
+ * oleStr [I] New source for pbstr
+ *
+ * RETURNS
+ * Success: 1
+ * Failure: 0.
+ *
+ * NOTES
+ * SysAllocStringStringLen16().
+ */
+INT16 WINAPI SysReAllocString16(LPBSTR16 pbstr,LPCOLESTR16 oleStr)
+{
+ BSTR16 new=SysAllocString16(oleStr);
+ BSTR_Free(*pbstr);
+ *pbstr=new;
+ return 1;
+}
+
+/******************************************************************************
+ * SysAllocStringLen [OLE2DISP.4]
+ *
+ * Create a BSTR16 from an OLESTR16 of a given character length (16 Bit).
+ *
+ * PARAMS
+ * oleStr [I] Source to create BSTR16 from
+ * len [I] Length of oleStr in wide characters
+ *
+ * RETURNS
+ * Success: A newly allocated BSTR16 from SysAllocStringByteLen16()
+ * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
+ *
+ * NOTES
+ * See SysAllocStringByteLen16().
+ */
+BSTR16 WINAPI SysAllocStringLen16(const char *oleStr, int len)
+{
+ BSTR16 out=BSTR_AllocBytes(len+1);
+
+ if (!out)
+ return 0;
+
+ /*
+ * Copy the information in the buffer.
+ * Since it is valid to pass a NULL pointer here, we'll initialize the
+ * buffer to nul if it is the case.
+ */
+ if (oleStr != 0)
+ strcpy(BSTR_GetAddr(out),oleStr);
+ else
+ memset(BSTR_GetAddr(out), 0, len+1);
+
+ return out;
+}
+
+/******************************************************************************
+ * SysReAllocStringLen [OLE2DISP.5]
+ *
+ * Change the length of a previously created BSTR16 (16 Bit).
+ *
+ * PARAMS
+ * pbstr [I] BSTR16 to change the length of
+ * oleStr [I] New source for pbstr
+ * len [I] Length of oleStr in characters
+ *
+ * RETURNS
+ * Success: 1. The size of pbstr is updated.
+ * Failure: 0, if len >= 0x8000 or memory allocation fails.
+ *
+ * NOTES
+ * See SysAllocStringByteLen16().
+ * *pbstr may be changed by this function.
+ */
+int WINAPI SysReAllocStringLen16(BSTR16 *old,const char *in,int len)
+{
+ /* FIXME: Check input length */
+ BSTR16 new=SysAllocStringLen16(in,len);
+ BSTR_Free(*old);
+ *old=new;
+ return 1;
+}
+
+/******************************************************************************
+ * SysFreeString [OLE2DISP.6]
+ *
+ * Free a BSTR16 (16 Bit).
+ *
+ * PARAMS
+ * str [I] String to free.
+ *
+ * RETURNS
+ * Nothing.
+ */
+void WINAPI SysFreeString16(BSTR16 str)
+{
+ BSTR_Free(str);
+}
+
+/******************************************************************************
+ * SysStringLen [OLE2DISP.7]
+ *
+ * Get the allocated length of a BSTR16 in characters (16 Bit).
+ *
+ * PARAMS
+ * str [I] BSTR16 to find the length of
+ *
+ * RETURNS
+ * The allocated length of str, or 0 if str is NULL.
+ */
+int WINAPI SysStringLen16(BSTR16 str)
+{
+ return strlen(BSTR_GetAddr(str));
+}
+
+/******************************************************************************
+ * CreateDispTypeInfo [OLE2DISP.31]
+ */
+HRESULT WINAPI CreateDispTypeInfo16(
+ INTERFACEDATA *pidata,
+ LCID lcid,
+ ITypeInfo **pptinfo)
+{
+ FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
+ return E_NOTIMPL;
+}
+
+/******************************************************************************
+ * CreateStdDispatch [OLE2DISP.32]
+ */
+HRESULT WINAPI CreateStdDispatch16(
+ IUnknown* punkOuter,
+ void* pvThis,
+ ITypeInfo* ptinfo,
+ IUnknown** ppunkStdDisp)
+{
+ FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
+ ppunkStdDisp);
+ return 0;
+}
+
+/******************************************************************************
+ * RegisterActiveObject [OLE2DISP.35]
+ */
+HRESULT WINAPI RegisterActiveObject16(
+ IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister
+) {
+ FIXME("(%p,%s,0x%08lx,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister);
+ return E_NOTIMPL;
+}