home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
c't freeware shareware 1997
/
CT_SW_97.ISO
/
mac
/
Software
/
finanzen
/
win95
/
quotenow.exe
/
data.z
/
lombard.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-03
|
24KB
|
974 lines
// lombard.cpp : Defines the initialization routines for the DLL.
//
/*
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.)
*/
#include "stdafx.h"
#include <afxdllx.h>
#include "resource.h"
#include "../../server.h"
#include "passdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//stock parsing callback declare
__declspec(dllexport) ParseLombardSServer(char *buffer,
DWORD len,
CPUBSTOCKOBJ &pobjArray,
int iIgnore,CServerObject *srvo);
//option parsing callback declare
__declspec(dllexport) ParseLombardOServer(char *buffer,
DWORD len,
CPUBSTOCKOBJ &pobjArray,
int iIgnore,CServerObject *srvo);
//required functions when SRV_CAP_SETTINGS
//names can be anything you like as the addresses
//are passed back to the CServerObject structure
//passed in by the client
__declspec(dllexport) DWORD CreateSettings(void *buffer,DWORD len);
__declspec(dllexport) BOOL DeleteSettings(DWORD dwSettings);
__declspec(dllexport) DWORD EditSettings(DWORD dwSettings,int iWhichSetting);
__declspec(dllexport) DWORD GetSettings(DWORD dwSettings,
void **lpBuf,LPDWORD lpdwSize);
//required function when SRV_CAP_REQUIRESLOGIN set
//name can be anything you like as the addresses
//are passed back to the CServerObject structure
//passed in by the client. These are not called
//directly
__declspec(dllexport) DWORD GetUserInfo(DWORD dwSettings,
CString &sUsername,
CString &sPassword);
__declspec(dllexport) BOOL TickerBar(DWORD dwSettings,DWORD dwFlag,
CPubDrawObject *dobj);
//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 RegisterImportFileFormat (*wxsinfo.lpfnRegisterImportFileFormat)
HINSTANCE g_hInstance;
//globally defined structure so that our helper function
//macros will work
WXSINFO wxsinfo;
static AFX_EXTENSION_MODULE LombardDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("Lombard.DLL Initializing!\n");
g_hInstance=hInstance;
// Extension DLL one-time initialization
AfxInitExtensionModule(LombardDLL, hInstance);
// Insert this DLL into the resource chain
new CDynLinkLibrary(LombardDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("Lombard.DLL Terminating!\n");
}
return 1; // ok
}
//WxsGetApiVersion required function
//MUST BE NAMED this way exactly
extern "C" __declspec(dllexport) float WxsGetApiVersion()
{
return (float)WXSSERVER_APIVERSION;
}
//WxsServerInit required function
//MUST BE NAMED this way exactly
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 particular 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.lpfnRegisterFileFormat=pwxs->lpfnRegisterFileFormat;
//store the strings and data into the server object
//so it can be returned to the client
srv->m_dwSize=sizeof(CServerObject);
//Server name :Trade PBS
srv->m_sServerName.LoadString(IDS_NNAME_LOMBARD);
//Server www address : www.Lombard.com
srv->m_httpAddress.LoadString(IDS_SSERVER_LOMBARD);
//stock quote format string
srv->m_httpSQuoteFormat.LoadString(IDS_SSERVER_LOMBARD_REQ);
//option quot format string
srv->m_httpOQuoteFormat.LoadString(IDS_OSERVER_LOMBARD_REQ);
srv->m_httpGraphFormat.LoadString(IDS_GSERVER_LOMBARD_REQ);
srv->m_httpNewsFormat="";
srv->m_httpHistoricalDataFormat="";
srv->m_httpSTickerLookupFormat.LoadString(IDS_SRV_LOMBARD_TLOOKUP);
//option lookup http address
srv->m_httpOSymbolLookup.LoadString(IDS_OSRV_LOMBARD_OLOOKUP);
srv->m_httpStockHomePageFormat="";
//stock parse callback
srv->m_lpParseCallback=(SERVERPARSE_CALLBACK)ParseLombardSServer;
//option parse callback
srv->m_lpOParseCallback=(SERVERPARSE_CALLBACK)ParseLombardOServer;
srv->m_lpStockUpdate=NULL;
//Add this line to enable the tickerbar sample code
//and add the line containing the SRV_CAP_TICKER and logical or |
//it with the rest of the capabilities to enable the sample
//it will display a message after every symbol and after
//all in a document have been displayed
//srv->m_lpTickerBar=(SERVERTICKERBAR_CALLBACK)TickerBar;
//server can handle options and stock quotes
srv->m_srvCaps=CServerObject::SRV_CAP_SQUOTE|
CServerObject::SRV_CAP_OQUOTE|
CServerObject::SRV_CAP_GRAPH|
CServerObject::SRV_CAP_STICKERLOOKUP|
CServerObject::SRV_CAP_SETTINGS|
CServerObject::SRV_CAP_REQUIRESLOGIN;
//Can add this capability in to enable
//the ticker bar sample code
//CServerObject::SRV_CAP_TICKERBAR;
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;
//DEBUGGING - REMOVE this and add code to handle settings
srv->m_sUserId="thedoctor";
srv->m_sPassword="knight";
//set the required callbacks
//these are required when SRV_CAP_SETTINGS flag is set
srv->m_lpCreateSettings=(SRV_SETTINGSCREATE_CALLBACK)CreateSettings; //CreateSettings
srv->m_lpDeleteSettings=(SRV_SETTINGSDELETE_CALLBACK)DeleteSettings; //DeleteSettings
srv->m_lpEditSettings=(SRV_SETTINGSEDIT_CALLBACK)EditSettings; //EditSettings
srv->m_lpGetSettings=(SRV_SETTINGSGET_CALLBACK)GetSettings; //GetSettings
//must be defined if SRV_CAP_REQUIRESLOGIN flag is
//set
srv->m_lpGetUserInfo=(SRV_GETUSERPWD_CALLBACK)GetUserInfo; //GetUserInfo
//restore the resource handle back to the client .DLL
AfxSetResourceHandle(hInst);
return TRUE;
}
#define TABLE_ROW 6
#define TABLE_ITEMS 11
#define DTABLE_NAME 0
#define DTABLE_PRICE 1
#define DTABLE_DCHANGE 2
#define DTABLE_HIGH 3
#define DTABLE_LOW 4
#define DTABLE_VOLUME 5
#define DTABLE_BID 6
#define DTABLE_ASK 7
#define DTABLE_52HIGH 8
#define DTABLE_52LOW 9
#define DTABLE_LASTUPDATED 10
const UINT aTradeItems[TABLE_ITEMS][TABLE_ROW]= {
//object,table,level,subtable,row,column
{DTABLE_NAME,3,0,0,1,1},
{DTABLE_LASTUPDATED,3,0,0,4,2},
{DTABLE_PRICE,3,0,0,2,1},
{DTABLE_DCHANGE,3,0,0,2,2},
{DTABLE_BID,3,0,0,3,1},
{DTABLE_ASK,3,0,0,3,2},
{DTABLE_VOLUME,3,0,0,4,1},
{DTABLE_HIGH,3,0,0,10,2},
{DTABLE_LOW,3,0,0,10,1},
{DTABLE_52HIGH,10,0,0,2,7}, //no 52high invalid server doesn't support
{DTABLE_52LOW,10,0,0,2,8} //no 52low invalid server doesn't support
};
#define TITEM 0
#define TMTABLE 1
#define TLEVEL 2
#define TTABLE 3
#define TROW 4
#define TCOLUMN 5
struct TRADETABLEDATA {
CPubSrvStockObj *sobj;
int iIgnore;
BOOL bNoBidAsk;
};
BOOL GetTradeTableCallback(UINT uMTable,UINT uLevel,UINT uSubTable,
UINT uRow,UINT uColumn,
char *pStart,char *pEnd,LONG lData)
{
int x;
BOOL bFound=FALSE;
int bRet=TRUE;
int iRet=0;
TRADETABLEDATA *tdp=(TRADETABLEDATA *)lData;
#ifdef _DEBUG
TRACE("Table: %d, Level:%d, SubTable:%d, Row:%d, Column:%d\n",uMTable,uLevel,uSubTable,uRow,uColumn);
#endif
for (x=0; x<TABLE_ITEMS; x++)
{
if (tdp->bNoBidAsk && (DTABLE_BID==aTradeItems[x][TITEM] ||
DTABLE_ASK==aTradeItems[x][TITEM]))
continue;
UINT row=aTradeItems[x][TROW];
if (tdp->bNoBidAsk && row>3)
row--;
if (tdp->bNoBidAsk && row>6)
row--;
if (aTradeItems[x][TMTABLE]==uMTable && //table
aTradeItems[x][TLEVEL]==uLevel && //level
aTradeItems[x][TTABLE]==uSubTable && //subtable
row==uRow && //row
aTradeItems[x][TCOLUMN]==uColumn) //column
{
bFound=TRUE;
break;
}
}
if (!bFound)
return TRUE;
char szTemp[256];
char szData[256];
CString sData;
char *end;
char *p=pStart;
float fValue=(float)0.0;
CPubSrvStockObj *sobj=(CPubSrvStockObj *)tdp->sobj;
int iIgnore=tdp->iIgnore;
sData="";
while (NULL!=*p && p<pEnd)
if (NULL==(p=FindDataField(p,&end)))
{
//error getting the number and fraction
TRACE("Error FindDataField file: %s. FindAndGetNumber Line:%d\n",__FILE__,__LINE__);
//exit out of switch, no data in field
} else {
UINT len=end-p;
if (end<=pEnd)
{
lstrcpyn(szTemp,p,((len+1) > sizeof(szTemp)) ? sizeof(szTemp) : (len+1));
sData=sData+szTemp;
sData=sData+" ";
}
p=end;
}
sData.TrimLeft();
sData.TrimRight();
lstrcpy(szData,(LPCTSTR)sData);
switch (aTradeItems[x][TITEM])
{
case DTABLE_NAME:
sobj->m_sName.Format("%s",szData);
break;
case DTABLE_PRICE:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fPrice=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_DCHANGE:
{
CString s;
s=szData;
fValue=(float)0.0;
FixupNumber(s);
lstrcpy(szData,(LPCTSTR)s);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fChange=(-1==iRet) ? (float)0.0 : fValue;
}
break;
case DTABLE_HIGH:
{
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fHigh=(-1==iRet) ? (float)0.0 : fValue;
}
break;
case DTABLE_LOW:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fLow=(-1==iRet) ? 0 : fValue;
break;
case DTABLE_VOLUME:
fValue=(float)0.0;
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_nVolume=(-1==iRet) ? 0 : (UINT)fValue;
break;
case DTABLE_BID:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fBid=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_ASK:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fAsk=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_52HIGH:
{
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fYearHigh=(-1==iRet) ? (float)0.0 : fValue;
}
break;
case DTABLE_52LOW:
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fYearLow=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_LASTUPDATED:
//hande time here
break;
}
if (-1==iRet)
{
#ifdef _DEBUG
TRACE("iRet=-1: item:%d, File: %s, Line:%d\n",aTradeItems[x][TITEM],
__FILE__,__LINE__);
#endif
return FALSE; //stop callback and return error
}
return TRUE;
}
#define CHECK_NASDAQ "NASDAQ"
//handles stock quote parsing
__declspec(dllexport) ParseLombardSServer(char *buffer,
DWORD len,
CPUBSTOCKOBJ &pobjArray,
int iIgnore,CServerObject *srvo)
{
CString sTest,sTest2;
TRADETABLEDATA td;
CPubSrvStockObj *sobj=(CPubSrvStockObj *)&pobjArray[0];
sTest2=sTest=sobj->m_sSymbol;
sTest.MakeUpper();
sTest2.MakeLower();
if (!strstr(buffer,(LPCTSTR)sTest) &&
!strstr(buffer,(LPCTSTR)sTest2))
{
//Probably an error -- could not find the symbol anywhere
// in the HTML page as upper or lowercase
TRACE("Initial symbol check. Lombard: File: %s, Line:%d\n",__FILE__,__LINE__);
return PARSERET_ERROR;
}
if (!strstr(buffer,CHECK_NASDAQ))
td.bNoBidAsk=TRUE;
else
td.bNoBidAsk=FALSE;
td.sobj=sobj;
td.iIgnore=iIgnore;
if (FALSE==GetTableItems(buffer,(GTI_CALLBACK)GetTradeTableCallback,(LONG)&td))
return PARSERET_ERROR;
return PARSERET_OK;
}
//option table format
const UINT aOTradeItems[TABLE_ITEMS][TABLE_ROW]= {
//object,table,level,subtable,row,column
{DTABLE_NAME,3,0,0,1,1},
{DTABLE_LASTUPDATED,3,0,0,4,2},
{DTABLE_PRICE,3,0,0,2,1},
{DTABLE_DCHANGE,3,0,0,2,2},
{DTABLE_BID,3,0,0,3,1},
{DTABLE_ASK,3,0,0,3,2},
{DTABLE_VOLUME,3,0,0,4,1},
{DTABLE_HIGH,3,0,0,10,2},
{DTABLE_LOW,3,0,0,10,1},
{DTABLE_52HIGH,10,0,0,2,7}, //no 52high invalid server doesn't support
{DTABLE_52LOW,10,0,0,2,8} //no 52low invalid server doesn't support
};
//Option table callback
BOOL GetTradeOTableCallback(UINT uMTable,UINT uLevel,UINT uSubTable,
UINT uRow,UINT uColumn,
char *pStart,char *pEnd,LONG lData)
{
int x;
BOOL bFound=FALSE;
int bRet=TRUE;
int iRet=0;
#ifdef _DEBUG
TRACE("Table: %d, Level:%d, SubTable:%d, Row:%d, Column:%d\n",uMTable,uLevel,uSubTable,uRow,uColumn);
#endif
for (x=0; x<TABLE_ITEMS; x++)
if (aOTradeItems[x][TMTABLE]==uMTable && //table
aOTradeItems[x][TLEVEL]==uLevel && //level
aOTradeItems[x][TTABLE]==uSubTable && //subtable
aOTradeItems[x][TROW]==uRow && //row
aOTradeItems[x][TCOLUMN]==uColumn) //column
{
bFound=TRUE;
break;
}
if (!bFound)
return TRUE;
char szTemp[256];
char szData[256];
CString sData;
char *end;
char *p=pStart;
float fValue=(float)0.0;
TRADETABLEDATA *tdp=(TRADETABLEDATA *)lData;
CPubSrvStockObj *sobj=(CPubSrvStockObj *)tdp->sobj;
int iIgnore=tdp->iIgnore;
sData="";
while (NULL!=*p && p<pEnd)
if (NULL==(p=FindDataField(p,&end)))
{
//error getting the number and fraction
TRACE("Error FindDataField file: %s. FindAndGetNumber Line:%d\n",__FILE__,__LINE__);
//exit out of switch, no data in field
} else {
UINT len=end-p;
if (end<=pEnd)
{
lstrcpyn(szTemp,p,((len+1) > sizeof(szTemp)) ? sizeof(szTemp) : (len+1));
sData=sData+szTemp;
sData=sData+" ";
}
p=end;
}
sData.TrimLeft();
sData.TrimRight();
lstrcpy(szData,(LPCTSTR)sData);
switch (aTradeItems[x][TITEM])
{
case DTABLE_NAME:
sobj->m_sName.Format("%s",szData);
break;
case DTABLE_PRICE:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fPrice=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_DCHANGE:
{
CString s;
s=szData;
fValue=(float)0.0;
FixupNumber(s);
lstrcpy(szData,(LPCTSTR)s);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fChange=(-1==iRet) ? (float)0.0 : fValue;
}
break;
case DTABLE_HIGH:
{
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fHigh=(-1==iRet) ? (float)0.0 : fValue;
}
break;
case DTABLE_LOW:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fLow=(-1==iRet) ? 0 : fValue;
break;
case DTABLE_VOLUME:
fValue=(float)0.0;
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_nVolume=(-1==iRet) ? 0 : (UINT)fValue;
break;
case DTABLE_BID:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fBid=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_ASK:
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fAsk=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_52HIGH:
{
fValue=(float)0.0;
FixupNumber(sData);
lstrcpy(szData,(LPCTSTR)sData);
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fYearHigh=(-1==iRet) ? (float)0.0 : fValue;
}
break;
case DTABLE_52LOW:
iRet=GetNumberAndFraction(szData,NULL,fValue);
sobj->m_fYearLow=(-1==iRet) ? (float)0.0 : fValue;
break;
case DTABLE_LASTUPDATED:
//hande time here
break;
}
if (-1==iRet)
{
#ifdef _DEBUG
TRACE("iRet=-1: item:%d, File: %s, Line:%d\n",aTradeItems[x][TITEM],
__FILE__,__LINE__);
#endif
return FALSE; //stop callback and return error
}
return TRUE;
}
//Handles Option Parsing
__declspec(dllexport) ParseLombardOServer(char *buffer,
DWORD len,
CPUBSTOCKOBJ &pobjArray,
int iIgnore,CServerObject *srvo)
{
CString sTest,sTest2;
TRADETABLEDATA td;
CPubSrvStockObj *sobj=(CPubSrvStockObj *)&pobjArray[0];
sTest2=sTest=sobj->m_sSymbol;
sTest.MakeUpper();
sTest2.MakeLower();
if (!strstr(buffer,(LPCTSTR)sTest) &&
!strstr(buffer,(LPCTSTR)sTest2))
{
//Probably an error -- could not find the symbol anywhere
// in the HTML page as upper or lowercase
TRACE("Initial symbol check. Lombard: File: %s, Line:%d\n",__FILE__,__LINE__);
return PARSERET_ERROR;
}
td.sobj=sobj;
td.iIgnore=iIgnore;
if (FALSE==GetTableItems(buffer,(GTI_CALLBACK)GetTradeOTableCallback,(LONG)&td))
return PARSERET_ERROR;
return PARSERET_OK;
}
#define SIZE_STRINGID 10
#define LOMBARDID_STRINGID "LOMBARD"
#define SIZE_CHARARRAYS 128
typedef struct {
char szID[SIZE_STRINGID];
char szUser[SIZE_CHARARRAYS];
char szPassword[SIZE_CHARARRAYS];
} LOMBARDSETTINGS;
//settings functions
__declspec(dllexport) DWORD CreateSettings(void *buffer,DWORD len)
{
LOMBARDSETTINGS *pls;
DWORD dwRet=0;
if (NULL==buffer)
{
pls=new LOMBARDSETTINGS;
lstrcpy(pls->szID,LOMBARDID_STRINGID);
pls->szUser[0]=NULL;
pls->szPassword[0]=NULL;
dwRet=(DWORD)pls;
} else {
if (sizeof(LOMBARDSETTINGS)!=len)
{
//probably an error, or wrong version
return 0;
}
//can compare szID here with LOMBARDID_STRINGID
pls=(LOMBARDSETTINGS *)buffer;
dwRet=(DWORD)pls;
}
return dwRet;
}
__declspec(dllexport) BOOL DeleteSettings(DWORD dwSettings)
{
LOMBARDSETTINGS *pls;
if (0==dwSettings)
return FALSE;
pls=(LOMBARDSETTINGS *)dwSettings;
delete pls;
return TRUE;
}
__declspec(dllexport) DWORD EditSettings(DWORD dwSettings,int iWhichSetting)
{
DWORD dwRet=0;
if (0==dwSettings)
{
dwRet=CreateSettings(NULL,0);
dwSettings=dwRet;
}
LOMBARDSETTINGS *pls=(LOMBARDSETTINGS *)dwSettings;
//NOTE: we are ignore iWhichSetting
//since the only setting supported is a password
CPasswordDlg dlg;
dlg.m_sUser=pls->szUser;
dlg.m_sPass=dlg.m_sPass2=pls->szPassword;
if (IDOK==dlg.DoModal())
{
lstrcpy(pls->szUser,(LPCTSTR)dlg.m_sUser);
lstrcpy(pls->szPassword,(LPCTSTR)dlg.m_sPass);
}
return dwSettings;
}
__declspec(dllexport) DWORD GetSettings(DWORD dwSettings,
void **lpBuf,LPDWORD lpdwSize)
{
if (0==dwSettings)
{
*lpBuf=NULL;
*lpdwSize=0;
return 0;
}
LOMBARDSETTINGS *pls=(LOMBARDSETTINGS *)dwSettings;
//point to the buffer containing the information
*lpBuf=pls;
*lpdwSize=sizeof(LOMBARDSETTINGS);
return dwSettings;
}
__declspec(dllexport) DWORD GetUserInfo(DWORD dwSettings,
CString &sUsername,
CString &sPassword)
{
if (0==dwSettings)
{
//no settings
//return
sUsername="";
sPassword="";
return dwSettings;
}
LOMBARDSETTINGS *pls=(LOMBARDSETTINGS *)dwSettings;
sUsername=pls->szUser;
sPassword=pls->szPassword;
return dwSettings;
}
//tickerbar callback. Return TRUE if we wanted to add an item
__declspec(dllexport) BOOL TickerBar(DWORD dwSettings,DWORD dwFlag,
CPubDrawObject *dobj)
{
if (TICKERBAR_FLAG_SYMBOL==dwFlag)
{
dobj->m_str="Found Symbol:"+dobj->m_sSymbol;
return TRUE;
} else
if (TICKERBAR_FLAG_ENDALL==dwFlag)
{
dobj->m_str="End of all items";
return TRUE;
}
return FALSE;
}