/***************************************************************************
 *            sti_internal.h
 *
 *  Sat May 21 19:00:53 2005
 *  Copyright  2005  User
 *  Email
 ****************************************************************************/

#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winerror.h"
#include "winnls.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "msvcrt/stdio.h"

#include "objbase.h"
#include "unknwn.h"
#include "devguid.h"
#include "sti.h"
#include "stiusd.h"

#define rpcTranport "ncalrpc"
#define pipeName "STI_LRPC"

/* COM hacks */
#ifndef offsetof
#define offsetof(class, member) (size_t)&(((class*)0)->member)
#endif
/* The following macro took me 6 hours to fix (it was changing globals :-) */
#define IMPL(class, member, pointer) ((class*) (((char*) pointer) - offsetof(class, member)))


extern WCHAR *regStillImageDevices;
extern FILE *logFile;

/* Internal device list implementation */
typedef struct {
	int m_refCount;
	WCHAR m_internalName[STI_MAX_INTERNAL_NAME_LENGTH];
	HANDLE m_mutex;
	/* Something to stack apps we notify would go here too */
} InternalDevice;

/* IStillImage implementation. ASCII/UNICODE interfaces differ only in VTBL. */
typedef struct {
	/* Interfaces exported */
    IUnknown iUnknown;
    IStillImage iStillImage;

	/* COM punishment */
    int m_refCount;
    IUnknown *m_punkOuter;
	
	/* Fields */
    HINSTANCE m_hinst;
} StillImage;


/* IStiDevice implementation */
typedef struct {
	/* Interfaces exported */
	IUnknown iUnknown;
    IStiDevice iStiDevice;
	
	/* COM punishment */
	int m_refCount;
	IUnknown *m_punkOuter;
	
	/* Contained fields */
	HKEY m_driverKey;
	HINSTANCE m_hinst;
	WCHAR m_portName[STI_MAX_INTERNAL_NAME_LENGTH];
	DWORD m_openMode;
	InternalDevice *m_internalDev;
	IStiUSD *m_iStiUSD;
} StiDevice;
extern HRESULT CreateStiDevice(IUnknown *punkOuter, void **ppv);

/* IStiDeviceControl implementation */
typedef struct {
	/* Interfaces exported */
	IUnknown iUnknown;
	IStiDeviceControl iStiDeviceControl;
	
	/* COM punishment */
	int m_refCount;
	IUnknown *m_punkOuter;
	
	/* Fields */
	HANDLE m_fileHandle;
	DWORD m_lastError;
	WCHAR m_portName[STI_MAX_INTERNAL_NAME_LENGTH];
	DWORD m_openMode;
} StiDeviceControl;
extern HRESULT CreateStiDeviceControl(IUnknown *punkOuter, void **ppv);
