home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
c't freeware shareware 1997
/
CT_SW_97.ISO
/
mac
/
Software
/
finanzen
/
win95
/
quotenow.exe
/
data.z
/
server.h
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-31
|
19KB
|
582 lines
//SERVER.H
//DO NOT DISTRIBUTE THIS FILE
/*
QuotesNow! is trademark and (C)opyright 1996
by Federated Telecommunications Corp. and
Windows Xpert Systems
THIS FILE CANNOT BE DISTRIBUTED
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.)
*/
#ifndef _SERVER_H
#define _SERVER_H
#include <afxtempl.h>
//Server,h
#define WXSSERVER_APIVERSION 1.0
#define WXSSERVER_INITFUNCTION "WxsServerInit"
#define WXSSERVER_APIVERSIONFUNC "WxsGetApiVersion"
//used by inline news servers
#define DONT_IGNORE 0
#define IGNORE_NEWS 1
#define IGNORE_QUOTE 2
//flags that are passed and used with the Ticker
//bar callback to determine if the callback
//is being called after a symbol or after
//the end of all symbols
#define TICKERBAR_FLAG_SYMBOL 0
#define TICKERBAR_FLAG_ENDALL 1
//these are defines for the return values
//to be used by the stock quote parsing routine
//or the option quote parsing routine
#define PARSERET_OK 1
#define PARSERET_ERROR -1
#define PARSERET_INVALIDSYMBOL -2
#define PARSERET_SERVERERROR -3
//types of settings - used by edit settings interface
//this value is just to let your add-in know which
//page of it's property sheet for it's settings it
//should display as the currently active page.
//All pages should be available to tab to if needed
#define WXSSETTINGS_GENERALALL 0 //general/all settings
#define WXSSETTINGS_STOCKQUOTES 1 //stock quote settings
#define WXSSETTINGS_OPTQUOTES 2 //option quote settings
#define WXSSETTINGS_GRAPHS 3 //graph settings
#define WXSSETTINGS_NEWS 4 //news settings
//Define used when calling RegisterWebLink
//to define the link for all stock symbols
#define RWL_WXSALLSYMBOLS "#AllSymbols"
class CServerObject;
class CPubDrawObject
{
public:
CString m_str;
int m_x;
int m_y;
int m_iImage;
CSize m_size;
enum {DRAWTYPE_STOCK=0,DRAWTYPE_NEWS=1,DRAWTYPE_OTHER=2};
int m_iDrawType; //object type
CString m_sSymbol;
int m_iData; //used for keeping track of object info
CString m_httpAddress;
};
class CNewsObj : public CObject
{
public:
void Serialize(CArchive &ar);
CNewsObj();
~CNewsObj();
CNewsObj & operator=(CNewsObj &news);
CString m_sSymbol; //related stock symbol for news
CString m_sHeadline; //headline of news item
CString m_sHttpLink; //full http for link to story
CTime m_time; //time of news item used internally
CString m_sTime; //string for time of news item
//use in .DLL since CTime doesn't
//work in .DLL
//Used internally and will be used by linked in server objects
//a unique server id is used because a user can change news
//servers and build up news from different sources. Only
//the server that had the item will know when the full story
//text may not be available any more,etc. So m_sServerID
//is used by the news server that added the item to check
//to see if a item exists already, is new or should be
//deleted because full text is no longer availble.
CString m_sServerID; //unqiue server id
//can be used by the server .dll that created the item specified
//by the unique m_sServerID for processing.
DWORD m_dwHint;
//Found flag is used to indicate if this news item was found on the
//the server during the last news retrieval. If it was found
//it is kept in the list. If it was not found because the server
//no longer has information on it, then the news item is removed
//when DeleteNotFoundReadNews is called on the stock object
BOOL m_bFound;
DECLARE_SERIAL(CNewsObj)
};
class CPubSrvStockObj : public CObject
{
public:
CString m_sSymbol; //ticker symbol (such as IBM)
CString m_sName; //full company name
float m_fPrice; //last price
float m_fChange; //change in price from the open
float m_fHigh; //high price for the day
float m_fLow; //low price for the day
UINT m_nVolume; //total volume for the day
float m_fBid; //current bid price
float m_fAsk; //current ask price
float m_fYearHigh; //52 week high
float m_fYearLow; //52 week low
float m_fPercentChange; //percent change
UINT m_nOpenInterest; //open interest
CTime m_cTime; //time of quote from server
CString m_sTime; //server time return string (display)
enum {OBJECT_STOCK,OBJECT_OPTION};
DWORD m_dwObjectType; //object type either stock or option
CString m_httpGraph; //http Graph string
CString m_httpNews; //http news string
CString m_httpHistoricalData; //http historical data string
CString m_httpWWW; //home page http address
float m_fAlertLow; //low alert value
float m_fAlertHigh; //high alert value
DWORD m_dwAlertVolume; //high volume alert
BOOL m_bNewsAlert; //news alert if TRUE
CObArray m_tnNewsArray; //array of New news CNewsObj
CObArray m_tnReadNewsArray; //array of Old news CNewsObj
DWORD m_dwLastNewsCount; //can be used by server
DWORD m_dwNewsCount; //can be used by server
BOOL m_bEndOfDay; //TRUE if quote is an end of day quote
//quote time from server in integer format rather than
//CTime since CTime is not supported in .DLL's
int m_iDay;
int m_iMonth;
int m_iYear;
int m_iHour;
int m_iMinute;
int m_iSecond;
//Special variables and defines for internal use
enum {F_SYMBOL=0,F_NAME=1,F_PRICE=2,F_CHANGE=3,F_HIGH=4,
F_LOW=5,F_VOLUME=6,F_BID=7,F_ASK=8,
F_52WEEKHIGH=9,F_52WEEKLOW=10,F_LASTUPDATE=11,F_SHARES=12,
F_TOTALVALUE=13,F_GAINLOSS=14};
BOOL m_bClearAlert;
CPubSrvStockObj & operator=(CPubSrvStockObj &pbsobj)
{
m_sSymbol=pbsobj.m_sSymbol;
m_sName=pbsobj.m_sName;
m_fPrice=pbsobj.m_fPrice;
m_fChange=pbsobj.m_fChange;
m_fHigh=pbsobj.m_fHigh;
m_fLow=pbsobj.m_fLow;
m_nVolume=pbsobj.m_nVolume;
m_fBid=pbsobj.m_fBid;
m_fAsk=pbsobj.m_fAsk;
m_fYearHigh=pbsobj.m_fYearHigh;
m_fYearLow=pbsobj.m_fYearLow;
m_fPercentChange=pbsobj.m_fPercentChange;
m_nOpenInterest=pbsobj.m_nOpenInterest;
m_cTime=pbsobj.m_cTime;
m_sTime=pbsobj.m_sTime;
m_iDay=pbsobj.m_iDay;
m_iMonth=pbsobj.m_iMonth;
m_iYear=pbsobj.m_iYear;
m_iHour=pbsobj.m_iHour;
m_iMinute=pbsobj.m_iMinute;
m_iSecond=pbsobj.m_iSecond;
m_bClearAlert=pbsobj.m_bClearAlert;
m_bEndOfDay=pbsobj.m_bEndOfDay;
//handle copying new news array
int nSize=m_tnNewsArray.GetSize();
for (int z=0; z<nSize; z++)
delete m_tnNewsArray[z];
m_tnNewsArray.RemoveAll();
nSize=pbsobj.m_tnNewsArray.GetSize();
for (z=0; z<nSize; z++)
{
CNewsObj *pnews=new CNewsObj;
CNewsObj *pnews1=(CNewsObj *)pbsobj.m_tnNewsArray[z];
*pnews=*pnews1;
//add newly created item to the array.
//we needed to create a new item because if the old sobj
//is deleted it would delete all of the news objects
//as well and then we would be left with invalid pointers
m_tnNewsArray.Add(pnews);
}
//Handle copying old news array
nSize=m_tnReadNewsArray.GetSize();
for (z=0; z<nSize; z++)
delete m_tnReadNewsArray[z];
m_tnReadNewsArray.RemoveAll();
nSize=pbsobj.m_tnReadNewsArray.GetSize();
for (z=0; z<nSize; z++)
{
CNewsObj *pnews=new CNewsObj;
CNewsObj *pnews1=(CNewsObj *)pbsobj.m_tnReadNewsArray[z];
*pnews=*pnews1;
//add newly created item to the array.
//we needed to create a new item because if the old sobj
//is deleted it would delete all of the news objects
//as well and then we would be left with invalid pointers
m_tnReadNewsArray.Add(pnews);
}
m_dwLastNewsCount=pbsobj.m_dwLastNewsCount;
m_dwNewsCount=pbsobj.m_dwNewsCount;
return *this;
}
//DeleteNotFoundReadNews
//Used to remove news items that do NOT have the
//m_bFound flag set to TRUE. The server .dll
//is responsible for setting the flag and calling this function
//or handling deletion on it's own.
//This is just a helper function
BOOL DeleteNotFoundReadNews(CString &sServerID)
{
int nSize=m_tnReadNewsArray.GetSize();
int z;
for (z=0; z<nSize; z++)
{
CNewsObj *pnews=(CNewsObj *)m_tnReadNewsArray[z];
if (sServerID==pnews->m_sServerID && !pnews->m_bFound)
{
//remove this news item since it has been read and
//the news page is not carrying it anymore
delete pnews;
m_tnReadNewsArray.RemoveAt(z);
//reset our for loop to handle the fact that
//and item has been removed
nSize--;
z--;
}
}
return TRUE;
}
//ClearReadNewsFoundFlag
//Is used to clear the m_bFound flag before a server checks
//it's news items, so that it can set the found flags for any
//news items it does find on the server
BOOL ClearReadNewsFoundFlag(CString &sServerID)
{
int nSize=m_tnReadNewsArray.GetSize();
int z;
for (z=0; z<nSize; z++)
{
CNewsObj *pnews=(CNewsObj *)m_tnReadNewsArray[z];
if (sServerID==pnews->m_sServerID)
pnews->m_bFound=FALSE;
}
return TRUE;
}
public:
~CPubSrvStockObj() {
//delete the memory associated with the news
//arrays
int nSize=m_tnNewsArray.GetSize();
for (int z=0; z<nSize; z++)
delete m_tnNewsArray[z];
m_tnNewsArray.RemoveAll();
nSize=m_tnReadNewsArray.GetSize();
for (z=0; z<nSize; z++)
delete m_tnReadNewsArray[z];
m_tnReadNewsArray.RemoveAll();
};
}; //end of public stock obj
typedef CArray<CPubSrvStockObj,CPubSrvStockObj&> CPUBSTOCKOBJ;
typedef int (* FILEEXPORT_CALLBACK)(CPUBSTOCKOBJ &,HANDLE fp,DWORD dwSettings);
typedef BOOL (* GTI_CALLBACK)(UINT uMTable,UINT uLevel,UINT uSubTable,
UINT uRow,UINT uColumn,
char *pStart,
char *pEnd,LONG lData);
typedef char * (* UTILITY_GETTAGS)(char *p,CString &sTag,char **lend);
typedef BOOL (* UTILITY_GETTABLEITEMS)(char *buffer,GTI_CALLBACK gtiCallBack,LONG lData);
typedef BOOL (* UTILITY_SPLITSTRINGDASH)(const char *pString,CString &s1,CString &s2);
typedef BOOL (* UTILITY_FIXUPNUMBER)(CString &s);
typedef char * (* UTILITY_FINDDATAFIELD)(char *p, char **end);
typedef int (* UTILITY_GETNUMBERANDFRACTION)(char *buffer,char *end, float& fValue);
typedef int (* UTILITY_REGISTERFILEFORMAT)(const char *lpszFormatName,FILEEXPORT_CALLBACK lpfnExport,
const char *lpszExt,const char *lpszServerName,BOOL bDisplayDialog=TRUE);
typedef BOOL (* WEBLINK_CALLBACK)(DWORD dwSettings,const char *lpszRSymbol,
const char *lpszTitle,
DWORD dwUserValue);
typedef BOOL (* UTILITY_REGISTERWEBLINK)(const char *lpszRSymbol,
const char *lpszTitle,
const char *lpszServerName,
const char *lpzHttp,
WEBLINK_CALLBACK lpfnCallback,
DWORD lpdwUser);
struct WXSINFO
{
DWORD dwSize;
UTILITY_GETTAGS lpfnGetTagS;
UTILITY_GETTABLEITEMS lpfnGetTableItems;
UTILITY_SPLITSTRINGDASH lpfnSplitStringDash;
UTILITY_FIXUPNUMBER lpfnFixupNumber;
UTILITY_FINDDATAFIELD lpfnFindDataField;
UTILITY_GETNUMBERANDFRACTION lpfnGetNumberAndFraction;
UTILITY_REGISTERFILEFORMAT lpfnRegisterFileFormat;
UTILITY_REGISTERFILEFORMAT lpfnRegisterImportFileFormat;
UTILITY_REGISTERWEBLINK lpfnRegisterWebLink;
HWND hFrameWnd;
};
#ifndef _SERVER_DLL
class CStockObj;
//internal client defines to call into .srv dll
//typedef int (CALLBACK* SERVERPARSE_CALLBACK)(char *,DWORD,CStockObj *,int,CServerObject *);
//OLD BAD DEFINES
//typedef BOOL (CALLBACK* SERVERINIT_CALLBACK)(CServerObject *,float fVersion,int iCServerObject,WXSINFO *pwxs);
//typedef float (CALLBACK* SERVERWXS_GETAPIVERSION)();
extern "C" typedef BOOL (* SERVERINIT_CALLBACK)(CServerObject *,float fVersion,int iCServerObject,WXSINFO *pwxs);
extern "C" typedef float (* SERVERWXS_GETAPIVERSION)();
#else
#endif
typedef int (* SERVERPARSE_CALLBACK)(char *,DWORD,CPUBSTOCKOBJ &,int,CServerObject *);
typedef DWORD (* SRV_HANDLEREQUEST_CALLBACK)(CPUBSTOCKOBJ &,DWORD);
typedef BOOL (* SERVERFORMAT_CALLBACK)(CString *,LPCSTR lpstrSymbol,DWORD dwSettings);
typedef DWORD (* SRV_SETTINGSCREATE_CALLBACK)(void *buffer,DWORD len);
typedef BOOL (* SRV_SETTINGSDELETE_CALLBACK)(DWORD dwSettings);
typedef DWORD (* SRV_SETTINGSEDIT_CALLBACK)(DWORD dwSettings,int iWhichSetting);
typedef DWORD (* SRV_SETTINGSGET_CALLBACK)(DWORD dwSettings,void **lpBuf,LPDWORD lpdwSize);
typedef int (* STOCKUPDATE_CALLBACK)(CPubSrvStockObj &pobj,DWORD dwSettings);
typedef DWORD (* SRV_GETUSERPWD_CALLBACK)(DWORD dwSettings,
CString &sUsername,
CString &sPassword);
typedef BOOL (* SERVERTICKERBAR_CALLBACK)(DWORD dwSettings,DWORD dwFlag,
CPubDrawObject *dobj);
class CServerObject : public CObject
{
public:
DWORD m_dwSize;
CServerObject & operator=(CServerObject &srv);
void Serialize(CArchive &ar);
CString m_sServerName; //Server Name "My Server"
CString m_httpAddress; //http address "www.myaddress.com"
CString m_httpSQuoteFormat; //http request format "/cgi-bin/quote?symbol=%s"
CString m_httpOQuoteFormat; //http request format "/cgi-bin/quote?symbol=%s"
CString m_httpGraphFormat; //http request format "/cgi-bin/quote?symbol=%s"
CString m_httpNewsFormat; //http request format "/cgi-bin/quote?symbol=%s"
CString m_httpHistoricalDataFormat; //http request format "/cgi-bin/quote?symbol=%s"
CString m_httpSTickerLookupFormat; //full http address of servers lookup symbol page
CString m_httpOSymbolLookup;
CString m_httpStockHomePageFormat; //http request format "/cgi-bin/quote?symbol=%s"
DWORD m_srvCaps; //server capabilities
DWORD m_srvCall; //callbacks enabled
float m_fApiVersion; //store Api version here
//intialize with 0 to use default buffer size or
//size to use a custom buffer size
DWORD m_dwBufferSize; //buffer size needed or 0 for default
//only used when SRV_CAP_SQBATCH capability is enabled
//not supported at this time
DWORD m_dwMaxSQBatch; //max # of quotes at one time
//currently not used. but will
//be in a future version
//Used internally by WXS to store user/password info
CString m_sUserId; //used with SRV_CAP_REQUIRESLOGIN
CString m_sPassword; // used with SRV_CAP_REQUIRESLOGIN
enum {SRV_CAP_SQUOTE=1, // can handle stock quotes
SRV_CAP_GRAPH=2, // can display graphs
SRV_CAP_NEWS=4, // can display news
SRV_CAP_HIST=8, // can display quote history
SRV_CAP_STICKERLOOKUP=16, //stock ticker lookup
SRV_CAP_GETSTOCKHTTP=32, //can get http homepage of stock
SRV_CAP_INLINENEWS=64, //gets news with quote
SRV_CAP_CANUPDATENEWS=128, //can check for news updates
SRV_CAP_REQUIRESLOGIN=256, //need a userid and password to access
SRV_CAP_OQUOTE=512, //supports option quotes
SRV_CAP_SQBATCH=1024, //batch quote support (NOT SUPPORTED YET)
SRV_CAP_FILEEXPORT=2048, //support file exports
SRV_CAP_OSYMBOLLOOKUP=4096, //supports option symbol lookups
SRV_CAP_SETTINGS=8192, //has settings dialog
SRV_CAP_TICKERBAR=16384, //server has a tickerbar callback
};
//parsing callbacks
SERVERPARSE_CALLBACK m_lpParseCallback; //stock quote parsing
SERVERPARSE_CALLBACK m_lpNParseCallback; //news parsing
SERVERPARSE_CALLBACK m_lpOParseCallback; //option quote parsing
//format request callbacks
SERVERFORMAT_CALLBACK m_lpFormatSQuote; //format stock quote req
SERVERFORMAT_CALLBACK m_lpFormatGraph; //format graph req
SERVERFORMAT_CALLBACK m_lpFormatNews; //format news req
SERVERFORMAT_CALLBACK m_lpFormatOQuote; //format option quote
//settings callbacks SRV_CAP_SETTINGS should be enabled
SRV_SETTINGSCREATE_CALLBACK m_lpCreateSettings; //CreateSettings
SRV_SETTINGSDELETE_CALLBACK m_lpDeleteSettings; //DeleteSettings
SRV_SETTINGSEDIT_CALLBACK m_lpEditSettings; //EditSettings
SRV_SETTINGSGET_CALLBACK m_lpGetSettings; //GetSettings
//must be defined if SRV_CAP_REQUIRESLOGIN flag is
//set
SRV_GETUSERPWD_CALLBACK m_lpGetUserInfo; //GetUserInfo
//handlerequest callback
SRV_HANDLEREQUEST_CALLBACK m_lpHandleRequest; //HandleRequest
STOCKUPDATE_CALLBACK m_lpStockUpdate; //StockUpdate
SERVERTICKERBAR_CALLBACK m_lpTickerBar; //TickerBar
//used internally by WXS
HMODULE hMod; //used to store .DLL module
//used internally by client to store Map to server data
DWORD m_dwDefaultServerSettings; //used internally by WXS
DWORD GetSrvCaps() { return m_srvCaps;}
//constructor
CServerObject() {
m_lpParseCallback=NULL;
m_lpNParseCallback=NULL;
m_lpOParseCallback=NULL;
m_lpFormatSQuote=NULL;
m_lpFormatGraph=NULL;
m_lpFormatNews=NULL;
m_lpFormatOQuote=NULL;
m_lpCreateSettings=NULL;
m_lpDeleteSettings=NULL;
m_lpGetSettings=NULL;
m_lpHandleRequest=NULL;
m_lpStockUpdate=NULL;
m_lpTickerBar=NULL;
m_dwDefaultServerSettings=0;
m_dwBufferSize=0;
hMod=0;
};
public:
DECLARE_SERIAL(CServerObject)
};
#endif