Sweden-Number/ole/ole2disp.c

155 lines
3.7 KiB
C

/*
* OLE2DISP library
*
* Copyright 1995 Martin von Loewis
*/
#include "windows.h"
#include "ole.h"
#include "ole2.h"
#include "oleauto.h"
#include "interfaces.h"
#include "heap.h"
#include "ldt.h"
#include "debug.h"
/* 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 = SEGPTR_ALLOC(n);
return (BSTR16)SEGPTR_GET(ptr);
}
/******************************************************************************
* BSTR_Free [INTERNAL]
*/
static void BSTR_Free(BSTR16 in)
{
SEGPTR_FREE( PTR_SEG_TO_LIN(in) );
}
/******************************************************************************
* BSTR_GetAddr [INTERNAL]
*/
static void* BSTR_GetAddr(BSTR16 in)
{
return in ? PTR_SEG_TO_LIN(in) : 0;
}
/******************************************************************************
* SysAllocString16 [OLE2DISP.2]
*/
BSTR16 WINAPI SysAllocString16(LPOLESTR16 in)
{
BSTR16 out=BSTR_AllocBytes(strlen(in)+1);
if(!out)return 0;
strcpy(BSTR_GetAddr(out),in);
return out;
}
/******************************************************************************
* SysAllocString32 [OLEAUT32.2]
*/
BSTR32 WINAPI SysAllocString32(LPOLESTR32 in)
{
return HEAP_strdupW(GetProcessHeap(),0,in);
}
/******************************************************************************
* SysReAllocString16 [OLE2DISP.3]
*/
INT16 WINAPI SysReAllocString16(LPBSTR16 old,LPOLESTR16 in)
{
BSTR16 new=SysAllocString16(in);
BSTR_Free(*old);
*old=new;
return 1;
}
/******************************************************************************
* SysReAllocString32 [OLEAUT32.3]
*/
INT32 WINAPI SysReAllocString32(LPBSTR32 old,LPOLESTR32 in)
{
BSTR32 new=SysAllocString32(in);
HeapFree(GetProcessHeap(),0,*old);
*old=new;
return 1;
}
/******************************************************************************
* SysAllocStringLen16 [OLE2DISP.4]
*/
BSTR16 WINAPI SysAllocStringLen16(char *in, int len)
{
BSTR16 out=BSTR_AllocBytes(len+1);
if(!out)return 0;
strcpy(BSTR_GetAddr(out),in);
return out;
}
/******************************************************************************
* SysReAllocStringLen16 [OLE2DISP.5]
*/
int WINAPI SysReAllocStringLen16(BSTR16 *old,char *in,int len)
{
BSTR16 new=SysAllocStringLen16(in,len);
BSTR_Free(*old);
*old=new;
return 1;
}
/******************************************************************************
* SysFreeString16 [OLE2DISP.6]
*/
void WINAPI SysFreeString16(BSTR16 in)
{
BSTR_Free(in);
}
/******************************************************************************
* SysFreeString32 [OLEAUT32.6]
*/
void WINAPI SysFreeString32(BSTR32 in)
{
HeapFree(GetProcessHeap(),0,in);
}
/******************************************************************************
* SysStringLen16 [OLE2DISP.7]
*/
int WINAPI SysStringLen16(BSTR16 str)
{
return strlen(BSTR_GetAddr(str));
}
/******************************************************************************
* CreateDispTypeInfo [OLE2DISP.31]
*/
OLESTATUS WINAPI CreateDispTypeInfo(
INTERFACEDATA *pidata,
LCID lcid,
LPVOID **pptinfo /*ITypeInfo*/
) {
FIXME(ole,"(%p,%ld,%p),stub\n",pidata,lcid,pptinfo);
return 0;
}
/******************************************************************************
* RegisterActiveObject [OLE2DISP.35]
*/
OLESTATUS WINAPI RegisterActiveObject(
IUnknown * punk,REFCLSID rclsid,DWORD dwFlags, DWORD * pdwRegister
) {
char buf[80];
WINE_StringFromCLSID(rclsid,buf);
FIXME(ole,"(%p,%s,0x%08lx,%p):stub\n",punk,buf,dwFlags,pdwRegister);
return 0;
}