home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
c't freeware shareware 1997
/
CT_SW_97.ISO
/
mac
/
Software
/
finanzen
/
win95
/
quotenow.exe
/
data.z
/
wxssrvr.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-10
|
7KB
|
205 lines
// wxssrvr.cpp : Defines the initialization routines for the DLL.
// (C)opyright 1996 by Federated Telecommunications Corp.
/*
QuotesNow! is trademark and (C)opyright 1996
by Federated Telecommunications Corp. and
Windows Xpert Systems
You or any entity using this code must purchase a copy of QuotesNow!
(tm) for each person that will use this source code. The purchaser/
registered user may freely distribute compiled derivative
(machine readable code only) versions of this code.
Registered Users (Users who have purchased the QuotesNow! (tm) program
from Federated Telecommunications Corp. or Windows Xpert Systems)
Once you have purchased the application, you may use one copy
of the program. The program is licensed to YOU (the purchaser/user
by name), no other user may legally use the software.
It is understood that you use the software at your own risk.
Registered Users may produce compiled derivative works of the
source code provided with this program as long as it's intended use
is only for use with the QuotesNow! (tm) program by Windows Xpert Systems
and Federated Telecommunications Corp. The derivative source code
may be distributed as long as all notices in all code, including
copyright and trademark notices remain intact and the author makes it
clear that the source code may only be used to work with the
QuotesNow! (tm) program by Windows Xpert Systems and
Federated Telecommunications, and that any user of the source code must
purchase the QuotesNow! (tm) program to use it. The header files
(files ending in .h, such as server.h) may not be distributed
seperately from the QuotesNow! (tm) program.
The add-in .SRV/.DLL source code itself may only be distributed
as a derivative work as mentioned above
(with all notices intact and the author notifying any potential
user of the required uses of the source code - only a Registered
QuotesNow! (tm) user may distribute/use the Source code derivative
work.)
*/
// This code shows a sample server .dll (.srv) for use
// with the WXSStock client
#include "stdafx.h"
#include <afxdllx.h>
#include "resource.h"
#define _SERVER_DLL
#include "..\..\wxsstock\server.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
HINSTANCE g_hInstance;
static AFX_EXTENSION_MODULE WxssrvrDLL = { NULL, NULL };
//defines to simplify calling helper functions
#define GetTagS (*wxsinfo.lpfnGetTagS)
#define GetTableItems (*wxsinfo.lpfnGetTableItems)
#define SplitStringDash (*wxsinfo.lpfnSplitStringDash)
#define FixupNumber (*wxsinfo.lpfnFixupNumber)
#define FindDataField (*wxsinfo.lpfnFindDataField)
#define GetNumberAndFraction (*wxsinfo.lpfnGetNumberAndFraction)
#define RegisterFileFormat (*wxsinfo.lpfnRegisterFileFormat)
#define RegisterWebLink (*wxsinfo.lpfnRegisterWebLink)
extern "C" __declspec(dllexport) BOOL WeblinkCallback(DWORD dwSettings,const char *lpszRSymbol,
const char *lpszTitle,
DWORD dwUserValue);
//globally defined structure so that our helper function
//macros will work
WXSINFO wxsinfo;
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("WXSSRVR.DLL Initializing!\n");
g_hInstance=hInstance;
// Extension DLL one-time initialization
AfxInitExtensionModule(WxssrvrDLL, hInstance);
// Insert this DLL into the resource chain
new CDynLinkLibrary(WxssrvrDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("WXSSRVR.DLL Terminating!\n");
}
return 1; // ok
}
//WxsGetApiVersion required function
extern "C" __declspec(dllexport) float WxsGetApiVersion()
{
return (float)WXSSERVER_APIVERSION;
}
//WxsServerInit required function
extern "C" __declspec(dllexport) BOOL WxsServerInit(CServerObject *srv,float fApiVersion,int iCServerObject,
WXSINFO *pwxs)
{
HINSTANCE hInst=AfxGetResourceHandle();
//This is true only if the client exactly matches how the .DLL
//was compiled. (This can be different when the .DLL
//version doesn't match the client version) Though it could be
//the same. Depends on whether or not we have made changes to
//the CServerObject data strcuture for a prticular version
//this test is only for our sanity test purposes.
//If possible you should handle older versions of the client
//so this ASSERT(sizeof(CServerObject)==iCServerObject);
//should not be included at runtime and you may need to remove
//it for testing purposes to test with different versions of
//the client
if (sizeof(CServerObject)!=iCServerObject)
{
//ASSERT(sizeof(CServerObject)==iCServerObject);
return FALSE;
}
//set the resourceHandle to point to this .DLL
AfxSetResourceHandle(g_hInstance);
//save the helper function pointers in the
//global structure. Need to save these here as the
// pointer to the WXSINFO structure (pwxs) will be invalid
//after this function completes.
wxsinfo.lpfnGetTagS=pwxs->lpfnGetTagS;
wxsinfo.lpfnGetTableItems=pwxs->lpfnGetTableItems;
wxsinfo.lpfnSplitStringDash=pwxs->lpfnSplitStringDash;
wxsinfo.lpfnFixupNumber=pwxs->lpfnFixupNumber;
wxsinfo.lpfnFindDataField=pwxs->lpfnFindDataField;
wxsinfo.lpfnGetNumberAndFraction=pwxs->lpfnGetNumberAndFraction;
wxsinfo.lpfnRegisterWebLink=pwxs->lpfnRegisterWebLink;
//store the strings and data into the server object
//so it can be returned to the client
srv->m_dwSize=sizeof(CServerObject);
srv->m_sServerName.LoadString(IDS_NNAME_SCHWAB);
srv->m_httpAddress.LoadString(IDS_SSERVER_SCHWAB);
srv->m_httpSQuoteFormat.LoadString(IDS_SSERVER_SCHWAB_REQ);
srv->m_httpGraphFormat.LoadString(IDS_GSERVER_SCHWAB);
srv->m_httpNewsFormat="";
srv->m_httpHistoricalDataFormat="";
srv->m_httpSTickerLookupFormat="";
srv->m_httpStockHomePageFormat="";
srv->m_lpParseCallback=NULL;
//(SERVERPARSE_CALLBACK)ParsePrNewsWireNewsServer;
srv->m_httpOQuoteFormat="";
srv->m_srvCaps=CServerObject::SRV_CAP_GRAPH;
srv->m_dwBufferSize=0; //use default buffer
//if we know we can handle older versions of API with this
//.DLL we can assign m_fApiVersion=fApiVersion passed in
//so that the client won't complain about an inproper version
srv->m_fApiVersion=(float)WXSSERVER_APIVERSION;
//Test code to show how web links work
//This can be uncommented out to show how web links
//can be added via an add-in .srv/.dll file
/*RegisterWebLink(RWL_WXSALLSYMBOLS,
"Test Title from WXSSRVR",
(LPCTSTR)srv->m_sServerName,
"",
(WEBLINK_CALLBACK)WeblinkCallback,
0);*/
//restore the resource handle back to the client .DLL
AfxSetResourceHandle(hInst);
return TRUE;
}
//This code is for showing how web link callbacks
//can be handled
extern "C" __declspec(dllexport) BOOL WeblinkCallback(DWORD dwSettings,const char *lpszRSymbol,
const char *lpszTitle,
DWORD dwUserValue)
{
AfxMessageBox("Got callback!",MB_OK);
return TRUE;
}