/*
*********************************************************************
*
*	The Essence of OLE
*
*	Source code sample
*
*	Copyright (c) 1996, Rolling Thunder Computing, Ipswich MA
*
*	e-mail: essence@rollthunder.com
*	CompuServe: 73540,3430
*	Web: http://www.rollthunder.com
*
*	File Name:CELIZA.CPP
*
*	Purpose: Implementation of IEliza custom interface
*
*********************************************************************
*/

#include <windows.h>

#include "celiza.h"

extern "C" void Eliza (TCHAR *InStr, TCHAR *OutStr) ;

CEliza::CEliza (void)
{
    m_RefCount = 1 ;
    return;
}


CEliza::~CEliza(void)
{
    return;
}



STDMETHODIMP CEliza::QueryInterface(REFIID riid, LPVOID *ppv)
{
    if (IsEqualIID(riid, IID_IUnknown)
        || IsEqualIID(riid, IID_IEliza))
	{
        *ppv = (LPVOID)this;
		AddRef( ) ;
		return NOERROR;
	}
	else
	{
    	*ppv = NULL ;
    	return ResultFromScode(E_NOINTERFACE);
	}
        
}


STDMETHODIMP_(ULONG) CEliza::AddRef(void)
{
    return ++m_RefCount;
}


STDMETHODIMP_(ULONG) CEliza::Release(void)
{
	m_RefCount -- ;

    if (m_RefCount == 0)
	{
        delete this;
		return 0 ;
	}

    return m_RefCount ;
}







/*
 * CEliza::Complain
 *
 * Purpose:
 *    Receive complaint from client.  Prepare Eliza pseudo-shrink reply
 *    based on its content.
 *
 * Parameters:
 *    LPSTR pIn -- pointer to input string
 *    LPSTR pOut -- pointer to buffer for output string
 *
 * Return Value:
 *  HRESULT         NOERROR always.
 */

STDMETHODIMP CEliza::Complain (LPOLESTR pIn, LPOLESTR pOut)
{
	Eliza (pIn, pOut) ;
	return NOERROR ;
}
