home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / mac / Software / finanzen / win95 / quotenow.exe / data.z / tradepbs.cpp < prev    next >
C/C++ Source or Header  |  1997-04-06  |  19KB  |  779 lines

  1. // tradepbs.cpp : Defines the initialization routines for the DLL.
  2. //
  3.  
  4. /*
  5. QuotesNow! is trademark and (C)opyright 1996
  6. by Federated Telecommunications Corp. and
  7. Windows Xpert Systems 
  8.  
  9. You or any entity using this code must purchase a copy of QuotesNow!
  10. (tm) for each person that will use this source code.  The purchaser/
  11. registered user may freely distribute compiled derivative
  12. (machine readable code only) versions of this code.
  13.  
  14. Registered Users (Users who have purchased the QuotesNow! (tm) program
  15. from Federated Telecommunications Corp. or Windows Xpert Systems)
  16. Once you have purchased the application, you may use one copy
  17. of the program.  The program is licensed to YOU (the purchaser/user
  18. by name), no other user may legally use the software.
  19. It is understood that you use the software at your own risk.
  20.  Registered Users may produce compiled derivative works of the
  21.  source code provided with this program as long as it's intended use
  22.  is only for use with the QuotesNow! (tm) program by Windows Xpert Systems
  23.  and Federated Telecommunications Corp.  The derivative source code
  24.  may be distributed as long as all notices in all code, including
  25.  copyright and trademark notices remain intact and the author makes it
  26.  clear that the source code may only be used to work with the
  27.  QuotesNow! (tm) program by Windows Xpert Systems and 
  28.  Federated Telecommunications, and that any user of the source code must
  29.  purchase the QuotesNow! (tm) program to use it.  The header files
  30.  (files ending in .h, such as server.h) may not be distributed
  31.  seperately from the QuotesNow! (tm) program.
  32.  The add-in .SRV/.DLL source code itself may only be distributed
  33.  as a derivative work as mentioned above 
  34.  (with all notices intact and the author notifying any potential
  35.  user of the required uses of the source code - only a Registered
  36.  QuotesNow! (tm) user may distribute/use the Source code derivative
  37.  work.)
  38.  
  39.   */
  40.  
  41.  
  42.  
  43. #include "stdafx.h"
  44. #include <afxdllx.h>
  45. #include "resource.h"
  46. #include "../../server.h"
  47.  
  48. #ifdef _DEBUG
  49. #define new DEBUG_NEW
  50. #undef THIS_FILE
  51. static char THIS_FILE[] = __FILE__;
  52. #endif
  53.  
  54.  
  55. //stock parsing callback declare
  56. __declspec(dllexport) ParseTradePBSSServer(char *buffer,
  57.                                            DWORD len,
  58.                                            CPUBSTOCKOBJ &pobjArray,
  59.                                            int iIgnore,CServerObject *srvo);
  60.  
  61. //option parsing callback declare
  62. __declspec(dllexport) ParseTradePBSOServer(char *buffer,
  63.                                            DWORD len,
  64.                                            CPUBSTOCKOBJ &pobjArray,
  65.                                            int iIgnore,CServerObject *srvo);
  66.  
  67. __declspec(dllexport) int QuickenFileFormat(CPUBSTOCKOBJ &aStocks,
  68.                                             HANDLE fp,DWORD dwSettings);
  69.  
  70.  
  71. //defines to simplify calling helper functions
  72. #define GetTagS    (*wxsinfo.lpfnGetTagS)
  73. #define GetTableItems (*wxsinfo.lpfnGetTableItems)
  74. #define SplitStringDash (*wxsinfo.lpfnSplitStringDash)
  75. #define FixupNumber    (*wxsinfo.lpfnFixupNumber)
  76. #define FindDataField (*wxsinfo.lpfnFindDataField)
  77. #define GetNumberAndFraction (*wxsinfo.lpfnGetNumberAndFraction)
  78. #define RegisterFileFormat (*wxsinfo.lpfnRegisterFileFormat)
  79. #define RegisterImportFileFormat (*wxsinfo.lpfnRegisterImportFileFormat)
  80.  
  81.  
  82. HINSTANCE g_hInstance;
  83. //globally defined structure so that our helper function
  84. //macros will work
  85. WXSINFO wxsinfo;
  86.  
  87. static AFX_EXTENSION_MODULE TradepbsDLL = { NULL, NULL };
  88.  
  89. extern "C" int APIENTRY
  90. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  91. {
  92.     if (dwReason == DLL_PROCESS_ATTACH)
  93.     {
  94.         TRACE0("TRADEPBS.DLL Initializing!\n");
  95.         g_hInstance=hInstance;
  96.         // Extension DLL one-time initialization
  97.         AfxInitExtensionModule(TradepbsDLL, hInstance);
  98.  
  99.         // Insert this DLL into the resource chain
  100.         new CDynLinkLibrary(TradepbsDLL);
  101.     }
  102.     else if (dwReason == DLL_PROCESS_DETACH)
  103.     {
  104.         TRACE0("TRADEPBS.DLL Terminating!\n");
  105.     }
  106.     return 1;   // ok
  107. }
  108.  
  109.  
  110. //WxsGetApiVersion required function
  111. extern "C" __declspec(dllexport) float WxsGetApiVersion()
  112. {
  113.     return (float)WXSSERVER_APIVERSION;
  114. }
  115.                                                     
  116.  
  117. //WxsServerInit required function
  118. extern "C" __declspec(dllexport) BOOL WxsServerInit(CServerObject *srv,float fApiVersion,int iCServerObject,
  119.                                                     WXSINFO *pwxs)
  120. {
  121.  
  122.     HINSTANCE hInst=AfxGetResourceHandle();
  123.  
  124.     
  125.     //This is true only if the client exactly matches how the .DLL
  126.     //was compiled.  (This can be different when the .DLL
  127.     //version doesn't match the client version) Though it could be
  128.     //the same.  Depends on whether or not we have made changes to
  129.     //the CServerObject data strcuture for a prticular version
  130.     //this test is only for our sanity test purposes.
  131.     //If possible you should handle older versions of the client
  132.     //so this ASSERT(sizeof(CServerObject)==iCServerObject);
  133.     //should not be included at runtime and you may need to remove
  134.     //it for testing purposes to test with different versions of
  135.     //the client
  136.     if (sizeof(CServerObject)!=iCServerObject)
  137.     {
  138.         //ASSERT(sizeof(CServerObject)==iCServerObject);
  139.         return FALSE;
  140.     }
  141.  
  142.     //set the resourceHandle to point to this .DLL
  143.     AfxSetResourceHandle(g_hInstance);
  144.  
  145.     //save the helper function pointers in the
  146.     //global structure.  Need to save these here as the
  147.     // pointer to the WXSINFO structure (pwxs) will be invalid
  148.     //after this function completes.
  149.     wxsinfo.lpfnGetTagS=pwxs->lpfnGetTagS;
  150.     wxsinfo.lpfnGetTableItems=pwxs->lpfnGetTableItems;
  151.     wxsinfo.lpfnSplitStringDash=pwxs->lpfnSplitStringDash;
  152.     wxsinfo.lpfnFixupNumber=pwxs->lpfnFixupNumber;
  153.     wxsinfo.lpfnFindDataField=pwxs->lpfnFindDataField;
  154.     wxsinfo.lpfnGetNumberAndFraction=pwxs->lpfnGetNumberAndFraction;
  155.     wxsinfo.lpfnRegisterFileFormat=pwxs->lpfnRegisterFileFormat;
  156.  
  157.     //store the strings and data into the server object
  158.     //so it can be returned to the client
  159.     srv->m_dwSize=sizeof(CServerObject);
  160.     
  161.     //Server name :Trade PBS
  162.     srv->m_sServerName.LoadString(IDS_NNAME_TRADEPBS);    
  163.  
  164.     //Server www address : www.tradepbs.com
  165.     srv->m_httpAddress.LoadString(IDS_SSERVER_TRADEPBS);
  166.  
  167.     //stock quote format string
  168.     srv->m_httpSQuoteFormat.LoadString(IDS_SSERVER_TRADEPBS_REQ);
  169.     
  170.     //option quot format string
  171.     srv->m_httpOQuoteFormat.LoadString(IDS_OSERVER_TRADEPBS_REQ);
  172.  
  173.     srv->m_httpGraphFormat="";
  174.     srv->m_httpNewsFormat="";
  175.     srv->m_httpHistoricalDataFormat="";
  176.     srv->m_httpSTickerLookupFormat="";
  177.     
  178.     //option lookup http address
  179.     srv->m_httpOSymbolLookup.LoadString(IDS_OSRV_TRADEPBS_OLOOKUP);
  180.     srv->m_httpStockHomePageFormat="";
  181.  
  182.     //stock parse callback
  183.     srv->m_lpParseCallback=(SERVERPARSE_CALLBACK)ParseTradePBSSServer;
  184.  
  185.     //option parse callback
  186.     srv->m_lpOParseCallback=(SERVERPARSE_CALLBACK)ParseTradePBSOServer;
  187.     srv->m_lpStockUpdate=NULL;
  188.     
  189.  
  190.     //server can handle options and stock quotes
  191.     srv->m_srvCaps=CServerObject::SRV_CAP_SQUOTE|
  192.                     CServerObject::SRV_CAP_OQUOTE|
  193.                     CServerObject::SRV_CAP_OSYMBOLLOOKUP;
  194.     srv->m_dwBufferSize=0;    //use default buffer
  195.  
  196.     //if we know we can handle older versions of API with this
  197.     //.DLL we can assign m_fApiVersion=fApiVersion passed in
  198.     //so that the client won't complain about an inproper version
  199.     srv->m_fApiVersion=(float)WXSSERVER_APIVERSION;
  200.  
  201.     CString sQuicken;
  202.     CString sQFmt;
  203.  
  204.     sQFmt.LoadString(IDS_SQUICKENFILEEXT);
  205.  
  206.     sQuicken.LoadString(IDS_SQUICKENFORMAT);
  207.     RegisterFileFormat((LPCTSTR)sQuicken,
  208.         (FILEEXPORT_CALLBACK)QuickenFileFormat,
  209.         (LPCTSTR)sQFmt,(LPCTSTR)srv->m_sServerName);
  210.  
  211.     //restore the resource handle back to the client .DLL
  212.     AfxSetResourceHandle(hInst);
  213.  
  214.     return TRUE;
  215. }
  216.  
  217.  
  218. #define TABLE_ROW    6
  219. #define TABLE_ITEMS 11
  220.  
  221. #define DTABLE_NAME            0
  222. #define    DTABLE_PRICE        1
  223. #define DTABLE_DCHANGE        2
  224. #define    DTABLE_HIGH            3
  225. #define    DTABLE_LOW            4
  226. #define    DTABLE_VOLUME        5
  227. #define    DTABLE_BID            6
  228. #define    DTABLE_ASK            7
  229. #define    DTABLE_52HIGH        8
  230. #define    DTABLE_52LOW        9
  231. #define    DTABLE_LASTUPDATED    10
  232.  
  233.  
  234.  
  235.  
  236. const UINT aTradeItems[TABLE_ITEMS][TABLE_ROW]= {
  237.  
  238.     //object,table,level,subtable,row,column
  239.  
  240.     {DTABLE_NAME,1,0,0,0,1},
  241.     {DTABLE_LASTUPDATED,1,0,0,0,3},
  242.     {DTABLE_PRICE,2,0,0,2,2},
  243.     {DTABLE_DCHANGE,2,0,0,2,3},
  244.     {DTABLE_BID,10,0,0,0,0},        //no bid invalid server doesn't support
  245.     {DTABLE_ASK,10,0,0,0,0},        //no ask invalid server doesn't support
  246.     {DTABLE_VOLUME,2,0,0,2,8},
  247.     {DTABLE_HIGH,2,0,0,2,6}, 
  248.     {DTABLE_LOW,2,0,0,2,7},
  249.     {DTABLE_52HIGH,3,0,0,2,7}, 
  250.     {DTABLE_52LOW,3,0,0,2,8}
  251.     
  252. };
  253.  
  254.  
  255. #define TITEM    0
  256. #define TMTABLE    1
  257. #define TLEVEL    2
  258. #define TTABLE    3
  259. #define TROW    4
  260. #define TCOLUMN    5
  261.  
  262.  
  263. struct TRADETABLEDATA {
  264.     CPubSrvStockObj *sobj;
  265.     int iIgnore;
  266.  
  267. };
  268.  
  269.  
  270. BOOL GetTradeTableCallback(UINT uMTable,UINT uLevel,UINT uSubTable,
  271.                             UINT uRow,UINT uColumn,
  272.                             char *pStart,char *pEnd,LONG lData)
  273. {
  274.  
  275.     int x;
  276.     BOOL bFound=FALSE;
  277.     int bRet=TRUE;
  278.     int iRet=0;
  279.  
  280.     
  281. #ifdef _DEBUG
  282.     TRACE("Table: %d, Level:%d, SubTable:%d, Row:%d, Column:%d\n",uMTable,uLevel,uSubTable,uRow,uColumn);
  283. #endif
  284.  
  285.     
  286.         
  287.     for (x=0; x<TABLE_ITEMS; x++)
  288.         if (aTradeItems[x][TMTABLE]==uMTable &&    //table
  289.             aTradeItems[x][TLEVEL]==uLevel &&    //level
  290.             aTradeItems[x][TTABLE]==uSubTable &&    //subtable
  291.             aTradeItems[x][TROW]==uRow &&        //row
  292.             aTradeItems[x][TCOLUMN]==uColumn)    //column
  293.         {
  294.  
  295.             bFound=TRUE;
  296.             break;
  297.         }
  298.         
  299.     if (!bFound)
  300.         return TRUE;
  301.     
  302.  
  303.     
  304.  
  305.     
  306.     char szTemp[256];
  307.     char szData[256];
  308.     CString sData;
  309.     char *end;
  310.     char *p=pStart;
  311.     float fValue=(float)0.0;
  312.     TRADETABLEDATA *tdp=(TRADETABLEDATA *)lData;
  313.     CPubSrvStockObj *sobj=(CPubSrvStockObj *)tdp->sobj;
  314.     int iIgnore=tdp->iIgnore;
  315.  
  316.     sData="";
  317.  
  318.     
  319.  
  320.         
  321.     
  322.     while (NULL!=*p && p<pEnd)
  323.         if (NULL==(p=FindDataField(p,&end)))
  324.         {
  325.         //error getting the number and fraction
  326.         TRACE("Error FindDataField file: %s. FindAndGetNumber Line:%d\n",__FILE__,__LINE__);
  327.         //exit out of switch, no data in field
  328.         } else {
  329.             UINT len=end-p;
  330.             if (end<=pEnd)
  331.             {
  332.                 lstrcpyn(szTemp,p,((len+1) > sizeof(szTemp)) ? sizeof(szTemp) : (len+1));
  333.             sData=sData+szTemp;
  334.             sData=sData+" ";
  335.             }
  336.             p=end;
  337.         }
  338.  
  339.     sData.TrimLeft();
  340.     sData.TrimRight();
  341.  
  342.     lstrcpy(szData,(LPCTSTR)sData);
  343.  
  344.     
  345.     switch (aTradeItems[x][TITEM])
  346.     {
  347.         case    DTABLE_NAME:
  348.             sobj->m_sName.Format("%s",szData);
  349.             break;
  350.  
  351.         case     DTABLE_PRICE:
  352.             fValue=(float)0.0;
  353.             FixupNumber(sData);
  354.             lstrcpy(szData,(LPCTSTR)sData);
  355.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  356.             sobj->m_fPrice=(-1==iRet) ? (float)0.0 : fValue;
  357.             break;
  358.  
  359.         case    DTABLE_DCHANGE:
  360.             {
  361.             CString s;
  362.             s=szData;
  363.  
  364.             fValue=(float)0.0;
  365.             FixupNumber(s);
  366.             lstrcpy(szData,(LPCTSTR)s);
  367.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  368.             sobj->m_fChange=(-1==iRet) ? (float)0.0 : fValue;
  369.             }
  370.             break;
  371.  
  372.         case     DTABLE_HIGH:
  373.             {
  374.             
  375.                 
  376.             fValue=(float)0.0;
  377.             FixupNumber(sData);
  378.  
  379.             lstrcpy(szData,(LPCTSTR)sData);
  380.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  381.             sobj->m_fHigh=(-1==iRet) ? (float)0.0 : fValue;
  382.  
  383.             }
  384.             break;
  385.  
  386.         case     DTABLE_LOW:
  387.             fValue=(float)0.0;
  388.             FixupNumber(sData);
  389.             lstrcpy(szData,(LPCTSTR)sData);
  390.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  391.             sobj->m_fLow=(-1==iRet) ? 0 : fValue;
  392.             break;
  393.  
  394.         case     DTABLE_VOLUME:
  395.             fValue=(float)0.0;
  396.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  397.             sobj->m_nVolume=(-1==iRet) ? 0 : (UINT)fValue;
  398.             break;
  399.  
  400.         case     DTABLE_BID:
  401.             fValue=(float)0.0;
  402.             FixupNumber(sData);
  403.             lstrcpy(szData,(LPCTSTR)sData);
  404.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  405.             sobj->m_fBid=(-1==iRet) ? (float)0.0 : fValue;
  406.             break;
  407.  
  408.         case     DTABLE_ASK:
  409.             fValue=(float)0.0;
  410.             FixupNumber(sData);
  411.             lstrcpy(szData,(LPCTSTR)sData);
  412.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  413.             sobj->m_fAsk=(-1==iRet) ? (float)0.0 : fValue;
  414.             break;
  415.  
  416.         case     DTABLE_52HIGH:
  417.             {
  418.             
  419.                 
  420.             fValue=(float)0.0;
  421.             FixupNumber(sData);
  422.  
  423.             lstrcpy(szData,(LPCTSTR)sData);
  424.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  425.             sobj->m_fYearHigh=(-1==iRet) ? (float)0.0 : fValue;
  426.  
  427.             
  428.             }
  429.             break;
  430.  
  431.         case     DTABLE_52LOW:
  432.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  433.             sobj->m_fYearLow=(-1==iRet) ? (float)0.0 : fValue;
  434.             break;
  435.  
  436.         case     DTABLE_LASTUPDATED:
  437.             //hande time here
  438.             break;
  439.  
  440.     }
  441.     
  442.  
  443.  
  444.     if (-1==iRet)
  445.     {
  446. #ifdef _DEBUG
  447.         TRACE("iRet=-1: item:%d, File: %s, Line:%d\n",aTradeItems[x][TITEM],
  448.             __FILE__,__LINE__);
  449. #endif
  450.         return FALSE; //stop callback and return error
  451.     }
  452.  
  453.     return TRUE;
  454.  
  455. }
  456.  
  457.  
  458.  
  459. //handles stock quote parsing
  460. __declspec(dllexport) ParseTradePBSSServer(char *buffer,
  461.                                            DWORD len,
  462.                                            CPUBSTOCKOBJ &pobjArray,
  463.                                            int iIgnore,CServerObject *srvo)
  464. {
  465.  
  466.  
  467.     CString sTest,sTest2;
  468.     TRADETABLEDATA td;
  469.  
  470.     
  471.     CPubSrvStockObj *sobj=(CPubSrvStockObj *)&pobjArray[0];
  472.     sTest2=sTest=sobj->m_sSymbol;
  473.     sTest.MakeUpper();
  474.     sTest2.MakeLower();
  475.     if (!strstr(buffer,(LPCTSTR)sTest) &&
  476.         !strstr(buffer,(LPCTSTR)sTest2))
  477.     {
  478.         //Probably an error -- could not find the symbol anywhere
  479.         // in the HTML page as upper or lowercase
  480.         TRACE("Initial symbol check. TRADEPBS: File: %s, Line:%d\n",__FILE__,__LINE__);
  481.         return PARSERET_ERROR;
  482.     }
  483.     
  484.     td.sobj=sobj;
  485.     td.iIgnore=iIgnore;
  486.     if (FALSE==GetTableItems(buffer,(GTI_CALLBACK)GetTradeTableCallback,(LONG)&td))
  487.         return PARSERET_ERROR;
  488.  
  489.  
  490.     return PARSERET_OK;
  491.  
  492. }
  493.  
  494.  
  495. //option table format
  496. const UINT aOTradeItems[TABLE_ITEMS][TABLE_ROW]= {
  497.  
  498.     //object,table,level,subtable,row,column
  499.  
  500.     {DTABLE_NAME,2,0,0,0,1},
  501.     {DTABLE_LASTUPDATED,1,0,0,1,2},
  502.     {DTABLE_PRICE,3,0,0,2,2},
  503.     {DTABLE_DCHANGE,3,0,0,2,3},
  504.     {DTABLE_BID,10,0,0,0,0},        //no bid invalid
  505.     {DTABLE_ASK,10,0,0,0,0},        //no ask invalid
  506.     {DTABLE_VOLUME,3,0,0,2,8},
  507.     {DTABLE_HIGH,3,0,0,2,6}, 
  508.     {DTABLE_LOW,3,0,0,2,7},
  509.     {DTABLE_52HIGH,10,0,0,2,7}, // NO 52high invalid
  510.     {DTABLE_52LOW,10,0,0,2,8}    //NO 52 week low invalid
  511.     
  512. };
  513.  
  514.  
  515.  
  516. //Option table callback
  517.  
  518. BOOL GetTradeOTableCallback(UINT uMTable,UINT uLevel,UINT uSubTable,
  519.                             UINT uRow,UINT uColumn,
  520.                             char *pStart,char *pEnd,LONG lData)
  521. {
  522.  
  523.  
  524.         int x;
  525.     BOOL bFound=FALSE;
  526.     int bRet=TRUE;
  527.     int iRet=0;
  528.  
  529.     
  530. #ifdef _DEBUG
  531.     TRACE("Table: %d, Level:%d, SubTable:%d, Row:%d, Column:%d\n",uMTable,uLevel,uSubTable,uRow,uColumn);
  532. #endif
  533.  
  534.     
  535.         
  536.     for (x=0; x<TABLE_ITEMS; x++)
  537.         if (aOTradeItems[x][TMTABLE]==uMTable &&    //table
  538.             aOTradeItems[x][TLEVEL]==uLevel &&    //level
  539.             aOTradeItems[x][TTABLE]==uSubTable &&    //subtable
  540.             aOTradeItems[x][TROW]==uRow &&        //row
  541.             aOTradeItems[x][TCOLUMN]==uColumn)    //column
  542.         {
  543.  
  544.             bFound=TRUE;
  545.             break;
  546.         }
  547.         
  548.     if (!bFound)
  549.         return TRUE;
  550.     
  551.  
  552.     
  553.  
  554.     
  555.     char szTemp[256];
  556.     char szData[256];
  557.     CString sData;
  558.     char *end;
  559.     char *p=pStart;
  560.     float fValue=(float)0.0;
  561.     TRADETABLEDATA *tdp=(TRADETABLEDATA *)lData;
  562.     CPubSrvStockObj *sobj=(CPubSrvStockObj *)tdp->sobj;
  563.     int iIgnore=tdp->iIgnore;
  564.  
  565.     sData="";
  566.  
  567.     
  568.  
  569.         
  570.     
  571.     while (NULL!=*p && p<pEnd)
  572.         if (NULL==(p=FindDataField(p,&end)))
  573.         {
  574.         //error getting the number and fraction
  575.         TRACE("Error FindDataField file: %s. FindAndGetNumber Line:%d\n",__FILE__,__LINE__);
  576.         //exit out of switch, no data in field
  577.         } else {
  578.             UINT len=end-p;
  579.             if (end<=pEnd)
  580.             {
  581.                 lstrcpyn(szTemp,p,((len+1) > sizeof(szTemp)) ? sizeof(szTemp) : (len+1));
  582.             sData=sData+szTemp;
  583.             sData=sData+" ";
  584.             }
  585.             p=end;
  586.         }
  587.  
  588.     sData.TrimLeft();
  589.     sData.TrimRight();
  590.  
  591.     lstrcpy(szData,(LPCTSTR)sData);
  592.  
  593.     
  594.     switch (aTradeItems[x][TITEM])
  595.     {
  596.         case    DTABLE_NAME:
  597.             sobj->m_sName.Format("%s",szData);
  598.             break;
  599.  
  600.         case     DTABLE_PRICE:
  601.             fValue=(float)0.0;
  602.             FixupNumber(sData);
  603.             lstrcpy(szData,(LPCTSTR)sData);
  604.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  605.             sobj->m_fPrice=(-1==iRet) ? (float)0.0 : fValue;
  606.             break;
  607.  
  608.         case    DTABLE_DCHANGE:
  609.             {
  610.             CString s;
  611.             s=szData;
  612.  
  613.             fValue=(float)0.0;
  614.             FixupNumber(s);
  615.             lstrcpy(szData,(LPCTSTR)s);
  616.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  617.             sobj->m_fChange=(-1==iRet) ? (float)0.0 : fValue;
  618.             }
  619.             break;
  620.  
  621.         case     DTABLE_HIGH:
  622.             {
  623.             
  624.                 
  625.             fValue=(float)0.0;
  626.             FixupNumber(sData);
  627.  
  628.             lstrcpy(szData,(LPCTSTR)sData);
  629.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  630.             sobj->m_fHigh=(-1==iRet) ? (float)0.0 : fValue;
  631.  
  632.             }
  633.             break;
  634.  
  635.         case     DTABLE_LOW:
  636.             fValue=(float)0.0;
  637.             FixupNumber(sData);
  638.             lstrcpy(szData,(LPCTSTR)sData);
  639.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  640.             sobj->m_fLow=(-1==iRet) ? 0 : fValue;
  641.             break;
  642.  
  643.         case     DTABLE_VOLUME:
  644.             fValue=(float)0.0;
  645.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  646.             sobj->m_nVolume=(-1==iRet) ? 0 : (UINT)fValue;
  647.             break;
  648.  
  649.         case     DTABLE_BID:
  650.             fValue=(float)0.0;
  651.             FixupNumber(sData);
  652.             lstrcpy(szData,(LPCTSTR)sData);
  653.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  654.             sobj->m_fBid=(-1==iRet) ? (float)0.0 : fValue;
  655.             break;
  656.  
  657.         case     DTABLE_ASK:
  658.             fValue=(float)0.0;
  659.             FixupNumber(sData);
  660.             lstrcpy(szData,(LPCTSTR)sData);
  661.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  662.             sobj->m_fAsk=(-1==iRet) ? (float)0.0 : fValue;
  663.             break;
  664.  
  665.         case     DTABLE_52HIGH:
  666.             {
  667.             
  668.                 
  669.             fValue=(float)0.0;
  670.             FixupNumber(sData);
  671.  
  672.             lstrcpy(szData,(LPCTSTR)sData);
  673.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  674.             sobj->m_fYearHigh=(-1==iRet) ? (float)0.0 : fValue;
  675.  
  676.             
  677.             }
  678.             break;
  679.  
  680.         case     DTABLE_52LOW:
  681.             iRet=GetNumberAndFraction(szData,NULL,fValue);
  682.             sobj->m_fYearLow=(-1==iRet) ? (float)0.0 : fValue;
  683.             break;
  684.  
  685.         case     DTABLE_LASTUPDATED:
  686.             sobj->m_sTime=sData;
  687.             iRet=1;
  688.             //hande time here
  689.             break;
  690.  
  691.     }
  692.     
  693.  
  694.  
  695.     if (-1==iRet)
  696.     {
  697. #ifdef _DEBUG
  698.         TRACE("iRet=-1: item:%d, File: %s, Line:%d\n",aTradeItems[x][TITEM],
  699.             __FILE__,__LINE__);
  700. #endif
  701.         return FALSE; //stop callback and return error
  702.     }
  703.  
  704.     return TRUE;
  705.  
  706.  
  707.  
  708.  
  709. }
  710.  
  711.  
  712. //Handles Option Parsing
  713. __declspec(dllexport) ParseTradePBSOServer(char *buffer,
  714.                                            DWORD len,
  715.                                            CPUBSTOCKOBJ &pobjArray,
  716.                                            int iIgnore,CServerObject *srvo)
  717. {
  718.  
  719.         CString sTest,sTest2;
  720.     TRADETABLEDATA td;
  721.  
  722.     
  723.     CPubSrvStockObj *sobj=(CPubSrvStockObj *)&pobjArray[0];
  724.     sTest2=sTest=sobj->m_sSymbol;
  725.     sTest.MakeUpper();
  726.     sTest2.MakeLower();
  727.     if (!strstr(buffer,(LPCTSTR)sTest) &&
  728.         !strstr(buffer,(LPCTSTR)sTest2))
  729.     {
  730.         //Probably an error -- could not find the symbol anywhere
  731.         // in the HTML page as upper or lowercase
  732.         TRACE("Initial symbol check. TRADEPBS: File: %s, Line:%d\n",__FILE__,__LINE__);
  733.         return PARSERET_ERROR;
  734.     }
  735.     
  736.     td.sobj=sobj;
  737.     td.iIgnore=iIgnore;
  738.     if (FALSE==GetTableItems(buffer,(GTI_CALLBACK)GetTradeOTableCallback,(LONG)&td))
  739.         return PARSERET_ERROR;
  740.  
  741.  
  742.     return PARSERET_OK;
  743.  
  744.  
  745.  
  746. }
  747.  
  748. #define BUFFER_SIZE    128
  749.  
  750.  
  751. __declspec(dllexport) int QuickenFileFormat(CPUBSTOCKOBJ &aStocks,
  752.                                             HANDLE fp,DWORD dwSettings)
  753. {
  754.  
  755.     int iSize=aStocks.GetSize();
  756.     int i;
  757.     char szBuffer[BUFFER_SIZE];
  758.     DWORD dwBytes;
  759.  
  760.     for (i=0; i<iSize; i++)
  761.     {
  762.         BOOL bRet;
  763.  
  764.         //can't use a CTime in a .DLL so we'll use the
  765.         //integer items m_iDay,m_iMonth,m_iYear
  766.         sprintf(szBuffer,"%s,%.04f,%d/%d/%d\n",aStocks[i].m_sSymbol,
  767.             aStocks[i].m_fPrice,
  768.             aStocks[i].m_iDay,
  769.             aStocks[i].m_iMonth,
  770.             aStocks[i].m_iYear);
  771.  
  772.         bRet=WriteFile(fp,szBuffer,lstrlen(szBuffer),&dwBytes,NULL);
  773.         if (!bRet)
  774.             return 0;
  775.     }
  776.  
  777.     return 1;
  778.  
  779. }