home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / woohoo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  34.0 KB  |  1,214 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20.  
  21. #include "cmdparse.h"
  22. #ifdef MOZ_MAIL_NEWS
  23. #include "wfemsg.h"
  24. #include "msgcom.h"
  25. #include "addrfrm.h"
  26. #endif /* MOZ_MAIL_NEWS */
  27. #include "template.h"
  28. #include "mainfrm.h"
  29. #include "woohoo.h"
  30. #ifdef JAVA
  31. #include "java.h"
  32. #endif
  33.  
  34.  
  35. //
  36. // Parse the command line for component launch arguments
  37. // Set bRemove to TRUE if you want to remove the switch from pszCommandLine
  38. BOOL CNetscapeApp::ParseComponentArguments(char * pszCommandLine,BOOL bRemove)
  39. {    //simply look for the switch and set to true if it exists.  We use it later on.
  40.  
  41.  
  42.     if (IsRuntimeSwitch("-BROWSER",  pszCommandLine, bRemove)){
  43.         m_bCreateBrowser = TRUE;
  44.  
  45. #ifdef MOZ_MAIL_NEWS
  46.     }else    if (IsRuntimeSwitch("-FOLDERS", pszCommandLine, bRemove)){
  47.                 m_bCreateFolders = TRUE;
  48.  
  49.     }else    if (IsRuntimeSwitch("-NEWS", pszCommandLine,  bRemove)){
  50.                 m_bCreateNews = TRUE;
  51.             
  52.     }else    if (IsRuntimeSwitch("-NETPROFILE", pszCommandLine,  bRemove)){
  53.                 m_bNetworkProfile = TRUE;
  54.             
  55.     }else    if (IsRuntimeSwitch("-COMPOSE", pszCommandLine,  bRemove)){
  56.                 m_bCreateCompose = TRUE;
  57. #endif /* MOZ_MAIL_NEWS */
  58.  
  59. #ifdef EDITOR
  60.     }else    if (IsRuntimeSwitch("-EDIT", pszCommandLine,  bRemove)){
  61.                 m_bCreateEdit = TRUE;
  62. #endif // EDITOR
  63.  
  64. #ifdef MOZ_MAIL_NEWS
  65.     }else    if (IsRuntimeSwitch("-INBOX", pszCommandLine,  bRemove)){
  66.                 m_bCreateInbox = TRUE;
  67.  
  68.   // rhp - for MAPI startup
  69.     }else    if (IsRuntimeSwitch("-MAPICLIENT", pszCommandLine,  bRemove)){  
  70.                 m_bCreateInboxMAPI = TRUE;
  71.   // rhp - for MAPI startup
  72.  
  73.     }else    if (IsRuntimeSwitch("-ADDRESS", pszCommandLine,  bRemove)){
  74.                 m_bCreateAddress = TRUE;
  75. #endif /* MOZ_MAIL_NEWS */
  76.     }else    if (IsRuntimeSwitch("-IMPORT", pszCommandLine,  bRemove)){
  77.                 m_bCreateLDIF_IMPORT = TRUE;
  78.  
  79.        }else    if (IsRuntimeSwitch("-EXPORT", pszCommandLine,  bRemove)){
  80.                 m_bCreateLDIF_EXPORT = TRUE;
  81.  
  82.     }else    return FALSE; //nothing to do here!!
  83.  
  84.     if (strlen(pszCommandLine) > 1) 
  85.     { 
  86.         m_bHasArguments = TRUE;
  87.     }
  88.  
  89.     return TRUE;
  90.     
  91. }
  92.  
  93.  
  94. ///////////////////////////////////////////////////////////////////////////////
  95. //  METHOD: ImportExportLDIF  - Imports or exports the specified ldif or html
  96. //                              address book file.
  97. //  PARAMETERS: pBook         - A pointer to the the address book.
  98. //              pszFileName   - A fully qualified path including file name.
  99. //              action        - STARTUP_IMPORT or STARTUP_EXPORT defined in 
  100. //                              netscape.h
  101. //  CALLERS:    Initinstance(), LaunchComponentWindow()
  102. ///////////////////////////////////////////////////////////////////////////////
  103. BOOL CNetscapeApp::ImportExportLDIF(ABook *pBook, char *pszFileName, int action)
  104. {
  105. #ifdef MOZ_MAIL_NEWS
  106.     if (action == STARTUP_IMPORT)
  107.     {
  108.         AB_ImportFromFileNamed(pBook, pszFileName);
  109.     }
  110.     else if (action == STARTUP_EXPORT)
  111.     { 
  112.         AB_ExportToFileNamed(pBook, pszFileName);
  113.     }
  114. #endif /* MOZ_MAIL_NEWS */
  115.     return FALSE;
  116. }
  117.  
  118.  
  119. //Used in OnDDECommand to check the DDE string.
  120. //Takes a command line string and searches for the specified arguements
  121. //Similar to ParseComponentArguments except it doesn't have option to remove argument
  122. BOOL CNetscapeApp::ExistComponentArguments(char * pszCommandLine)
  123. {    //simply look for the switch and set to true if it exists.  We use it later on.
  124.  
  125.   // This is not an #ifdef, just here to make the braces match for all combinations
  126.   // of ifdefs below.
  127.   if (0) {  
  128.  
  129. #ifdef MOZ_MAIL_NEWS
  130.   } else if (strcasestr(pszCommandLine, "-INBOX" )){
  131.     m_bCreateInbox = TRUE;
  132.  
  133.   // rhp - for MAPI startup
  134.   } else if (strcasestr(pszCommandLine, "-MAPICLIENT" )){
  135.     m_bCreateInboxMAPI = TRUE;
  136.   // rhp - for MAPI startup
  137.  
  138.   } else if (strcasestr(pszCommandLine, "-FOLDERS" )){
  139.     m_bCreateFolders = TRUE;
  140.  
  141.   } else if (strcasestr(pszCommandLine, "-FOLDER" )){
  142.     m_bCreateFolder = TRUE;
  143.  
  144.   } else if (strcasestr(pszCommandLine, "-NEWS" )){
  145.     m_bCreateNews = TRUE;
  146.  
  147.   } else if (strcasestr(pszCommandLine, "-MAIL" )){
  148.     m_bCreateMail = TRUE;
  149.  
  150. #endif /* MOZ_MAIL_NEWS */
  151.   } else if (strcasestr(pszCommandLine, "-NETCASTER" )){
  152.     m_bCreateNetcaster = TRUE;
  153.  
  154. #ifdef MOZ_MAIL_NEWS
  155.   } else if (strcasestr(pszCommandLine, "-COMPOSE" )){
  156.     m_bCreateCompose = TRUE;
  157. #endif // MOZ_MAIL_NEWS
  158.  
  159. #ifdef EDITOR
  160.   } else if (strcasestr(pszCommandLine,"-EDIT" )){
  161.     m_bCreateEdit = TRUE;
  162. #endif // EDITOR
  163.  
  164. #ifdef MOZ_MAIL_NEWS
  165.   } else if (strcasestr(pszCommandLine,"-ADDRESS" )){
  166.     m_bCreateAddress = TRUE;
  167. #endif // MOZ_MAIL_NEWS
  168.  
  169.   } else if (strcasestr(pszCommandLine,"-IMPORT" )){
  170.     m_bCreateLDIF_IMPORT = TRUE;
  171.  
  172.   } else if (strcasestr(pszCommandLine,"-EXPORT" )){
  173.     m_bCreateLDIF_EXPORT = TRUE;
  174.  
  175.   // This *&#! stupid !@#$% has to go here! (above -browser)
  176.   } else if (strcasestr(pszCommandLine,"-NEW_ACCOUNT" )){
  177.     // Any second instance trying to go to Account Setup
  178.     // is likely to have problems.  Setting m_bAccountSetup
  179.     // will cause an error below.
  180.     m_bAccountSetup = TRUE;
  181.     m_bAlwaysDockTaskBar= TRUE;
  182.     m_bAccountSetupStartupJava = TRUE;
  183.  
  184.   } else if (strcasestr(pszCommandLine,"-START_JAVA" )) {
  185.     m_bAccountSetupStartupJava = TRUE;
  186.  
  187.  
  188.   } else if (strcasestr(pszCommandLine,"-BROWSER" )){
  189.     m_bCreateBrowser = TRUE;
  190.  
  191.   } else if (strcasestr(pszCommandLine,"-NEW_PROFILE" )){
  192.     m_bCreateNewProfile = TRUE;
  193.       
  194.   } else if (strcasestr(pszCommandLine,"-PROFILE_MANAGER" )){
  195.     m_bProfileManager = TRUE;
  196.  
  197. #ifdef JAVA
  198.   } else if (strcasestr(pszCommandLine,"-javadebug" )){
  199.     m_bCreateJavaDebugAgent = TRUE;
  200. #endif
  201.  
  202.   } else    {
  203.     return FALSE; //nothing to do here!!
  204.   }
  205.  
  206.   if (strlen(pszCommandLine) > 1) {
  207.     m_bHasArguments = TRUE;
  208.   }
  209.  
  210.   return TRUE;  
  211. }
  212.  
  213. /**************************************************************************************
  214.  CNetscapeApp::BuildCmdLineList                                  Introduce by AJ 1/9/97
  215.  
  216.  Purpose:   Build a token list from a given token string after first removing a 
  217.             specified flag which is not to be included in the token list.
  218.  
  219.  Parameters: 
  220.             const char* pszRemoveString:  Flag to be stripped from the string
  221.             CStringList &rlstrList:       List to hold tokens pulled from the string
  222.             char* pszCmdLine:             Command line to pull tokens from.
  223.  
  224.  Called by: Called from OnDDECommand to parse out command line arguments.
  225.  
  226.  Returns:   Fills rlstrList with any tokens found on the command line with the exception
  227.             of the pszRemoveString parameter.  If pszRemoveString is NULL, then the
  228.             string will be trunkated to the first starting '"' in the string.
  229.  
  230.  Expecting: pszCmdLine is expected to be passed a string in the form of 
  231.             [cmdline("-FLAG message.txt @attach.txt")] for example.
  232. ***************************************************************************************/
  233.  
  234. BOOL CNetscapeApp::BuildCmdLineList(const char* pszRemoveString, CCmdParse &cmdParse, CStringList &rlstrList, char* pszCmdLine)
  235. {
  236.     char *pszTemp = NULL;
  237.     char *pFirst = NULL;
  238.     char *pEnd   = NULL;
  239.     char *pszRemove = NULL;
  240.     char *pFind   = NULL;
  241.        BOOL bError = FALSE; 
  242.  
  243.  
  244.     StrAllocCopy(pszRemove,pszRemoveString);
  245.     //make sure we are playing the same game
  246.     pszCmdLine = _strupr(pszCmdLine);
  247.     pszRemove = _strupr(pszRemove);
  248.  
  249.     pFind =  strstr(pszCmdLine, "CMDLINE");
  250.  
  251.     pFirst = strstr(pszCmdLine, pszRemove);
  252.       
  253.     if (!pFirst)
  254.     {   //just in case no switch was given
  255.         pFirst = strchr(pszCmdLine,'"');  
  256.     }
  257.     else
  258.     {   //jump over the flag since we don't want it on the list
  259.          pFirst += XP_STRLEN(pszRemove);
  260.     }
  261.         
  262.     if (pFirst && (pEnd = strrchr(pFirst,'"')) && pFind)
  263.     {   //parse out the arguments and put them on the list
  264.         *pEnd = NULL;
  265.         cmdParse.Init(pFirst,rlstrList);
  266.         if(!(bError = cmdParse.ProcessCmdLine()))
  267.         {
  268.             AfxMessageBox(IDS_CMDLINE_ERROR3);    
  269.         }
  270.     }
  271.     else if (pFirst && !pFind)
  272.     {//The DDE command stuff was already parsed out
  273.         cmdParse.Init(pFirst,rlstrList);
  274.         if(!(bError = cmdParse.ProcessCmdLine()))
  275.         {
  276.             AfxMessageBox(IDS_CMDLINE_ERROR3);    
  277.         }
  278.     }
  279.  
  280.     //free the string we allocated to play the same game
  281.     XP_FREE(pszRemove);
  282.     return bError;
  283. }
  284.  
  285. /***************************************************************************
  286. *    CNetscapeApp::LaunchComponentWindow
  287. *
  288. *    PARAMETERS:    iStartupMode.  Tells us which component is to be launch.
  289. *                It is initialized by SetStartupMode(..).
  290. *    
  291. *    RETURNS:
  292. *        void
  293. *
  294. *    DESCRIPTION:
  295. *        This function launches the specified component window.  Called from
  296. *        only from OnDDECommand(..).  Assumption is that we are the first 
  297. *        instance of navigator and a second instance has requested us to do 
  298. *        something.
  299. *        
  300. ****************************************************************************/
  301.  
  302. void CNetscapeApp::LaunchComponentWindow(int iStartupMode, char *pszCmdLine)
  303. {
  304.     void    WFE_AddNewFrameToFrameList(CGenericFrame * pFrame);
  305.     void    OpenDraftExit (URL_Struct *url_struct, int/*status*/,MWContext *pContext);
  306.  
  307.     CStringList lstrArgumentList;
  308.     CCmdParse cmdParse;
  309.     switch(iStartupMode)
  310.     {
  311. #ifdef MOZ_MAIL_NEWS
  312.         case STARTUP_INBOX:
  313.             WFE_MSGOpenInbox();
  314.             break;
  315.  
  316.     // rhp - for MAPI startup
  317.     case STARTUP_CLIENT_MAPI:
  318.       {
  319.         CGenericDoc *pDoc = (CGenericDoc *)theApp.m_ViewTmplate->OpenDocumentFile(NULL, FALSE);
  320.         if (pDoc)
  321.         {
  322.           CFrameGlue *pFrame = (pDoc->GetContext())->GetFrame();
  323.               if(pFrame)
  324.           {
  325.               CFrameWnd *pFrameWnd = pFrame->GetFrameWnd();
  326.             if (pFrameWnd)
  327.             {
  328.             extern void StoreMAPIFrameWnd(CFrameWnd *pFrameWnd);
  329.  
  330.               pFrameWnd->ShowWindow(SW_SHOWMINIMIZED);
  331.               StoreMAPIFrameWnd(pFrameWnd);
  332.             }
  333.           } 
  334.         }
  335.       }
  336.             break;
  337.     // rhp - for MAPI startup
  338.  
  339.         case STARTUP_FOLDER:
  340.             WFE_MSGOpenInbox();            // Will eventually open a specific folder
  341.             break;
  342.  
  343.         case STARTUP_MAIL:
  344.         //    CFolderFrame::Open();        //opens the collections window
  345.         //  Per John's request we are opening the inbox for a -mail flag.
  346.             WFE_MSGOpenInbox();
  347.  
  348.             break;
  349.          
  350.         case STARTUP_FOLDERS:
  351.             WFE_MSGOpenFolders();        //opens the collections window
  352.             break;                    
  353.  
  354.  
  355.         case STARTUP_COMPOSE:
  356.  
  357.              if (!BuildCmdLineList("-COMPOSE",cmdParse, lstrArgumentList,pszCmdLine) )
  358.                 return; //error occured!!
  359.  
  360.             if(!lstrArgumentList.GetCount())
  361.                 MSG_Mail(m_pBmContext);    // starts the mail composition window.  
  362.             else
  363.             {    //handle any extra arguments for this flag here.
  364.                 char *pTemp;
  365.                 URL_Struct* pURL;
  366.                 CString strUrl;
  367.                 
  368.                 int nArgCount = lstrArgumentList.GetCount();
  369.                 if (nArgCount == 1)
  370.                 {//either a message or an attachment.  If it's an attachment it will be prefixed with an "@" symbol
  371.                     pTemp  = (char*) (const char*)lstrArgumentList.GetHead();
  372.                     if(*pTemp != '@' && *pTemp!='-') //decide whether it's a message or an attachment
  373.                     {//it's a message
  374.                         CFileStatus rStatus;
  375.                         if(CFile::GetStatus(pTemp,rStatus))
  376.                         {
  377.                             WFE_ConvertFile2Url(strUrl, pTemp);
  378.                             pURL = NET_CreateURLStruct(strUrl, NET_DONT_RELOAD);
  379.                             StrAllocCopy(pURL->content_type,"message/rfc822"); 
  380.                             NET_GetURL (pURL, FO_OPEN_DRAFT, m_pBmContext,
  381.                                        OpenDraftExit);
  382.                             //Load it into the compose window
  383.                         }
  384.                         else
  385.                         {
  386.                             AfxMessageBox(IDS_CMDLINE_ERROR1);
  387.                             MSG_Mail(m_pBmContext);
  388.                             //were just going to act as if we couldn't read what they gave us and continue    
  389.                         }
  390.                     }
  391.                     else
  392.                     {//it's an attachment
  393.                         pTemp += 1;
  394.                         CFileStatus rStatus;
  395.                         if(CFile::GetStatus(pTemp,rStatus))
  396.                         {
  397.                             if (!LaunchComposeAndAttach(lstrArgumentList))
  398.                             {
  399.                                 AfxMessageBox(IDS_CMDLINE_ERROR3);
  400.                                 MSG_Mail(m_pBmContext);
  401.                             }
  402.                             //Load it into the compose window
  403.                         }
  404.                         else
  405.                         {
  406.                             AfxMessageBox(IDS_CMDLINE_ERROR1);
  407.                             MSG_Mail(m_pBmContext); 
  408.                         }                    
  409.                     }                    
  410.                 }
  411.                 else
  412.                 {
  413.                     if (nArgCount == 2)
  414.                     {
  415.                         //it's a message and has an attachment(s)
  416.                         if (!LaunchComposeAndAttach(lstrArgumentList))
  417.                         {
  418.                             AfxMessageBox(IDS_CMDLINE_ERROR3);
  419.                             MSG_Mail(m_pBmContext);
  420.                         }
  421.                     }
  422.                     else
  423.                     {//command line is not in a recognizable format for this flag
  424.                         AfxMessageBox(IDS_CMDLINE_ERROR3);
  425.                         MSG_Mail(m_pBmContext); 
  426.                         //ERROR!!!
  427.                     }
  428.                 }
  429.             }
  430.             break;                      
  431.  
  432.         case STARTUP_ADDRESS:
  433.             CAddrFrame::Open();
  434.             break;
  435.  
  436.        case STARTUP_IMPORT:
  437.             if (!BuildCmdLineList("-IMPORT",cmdParse, lstrArgumentList,pszCmdLine) )
  438.                 return; //error occured!!
  439.  
  440.             if(!lstrArgumentList.GetCount())
  441.                 return; //nothing on the list
  442.             else
  443.             {
  444.                 char *pTemp  = (char*) (const char*)lstrArgumentList.GetHead();
  445.                 ImportExportLDIF(m_pABook, pTemp, iStartupMode);   
  446.             }
  447.             return; //we don't want to fall through on this case
  448.  
  449.        case STARTUP_EXPORT:
  450.             if (!BuildCmdLineList("-EXPORT",cmdParse, lstrArgumentList,pszCmdLine) )
  451.                 return; //error occured!!
  452.  
  453.             if(!lstrArgumentList.GetCount())
  454.                 return; //nothing on the list
  455.             else
  456.             {
  457.                 char *pTemp  = (char*) (const char*)lstrArgumentList.GetHead();
  458.                 ImportExportLDIF(m_pABook, pTemp, iStartupMode);
  459.             }
  460.             return;//we don't want to fall through on this case
  461.  
  462.         case STARTUP_NEWS:
  463.             //starts the news and opens the default news server and group in split pain.
  464.             WFE_MSGOpenNews();
  465.             break; 
  466. #endif // MOZ_MAIL_NEWS
  467.  
  468. #ifdef EDITOR            
  469.         case STARTUP_EDITOR:
  470.             RemoveDDESyntaxAndSwitch("-edit",pszCmdLine);
  471.             //we do this outside the switch
  472.             break;
  473. #endif /* EDITOR */         
  474.         
  475.         // Outside MOZ_MAIL_NEWS and EDITOR flags in case lite and retail ever happen together...
  476.         case STARTUP_ACCOUNT_SETUP:
  477.             // Account Setup can't DDE
  478.             AfxMessageBox(IDS_CMDLINE_ERROR7); 
  479.             return;
  480.  
  481.         case STARTUP_BROWSER:
  482.             RemoveDDESyntaxAndSwitch("-browser",pszCmdLine);
  483.  
  484.             //we do this outside the switch
  485.             break; 
  486.  
  487. #ifdef JAVA
  488.         case STARTUP_NETCASTER:
  489.             FEU_OpenNetcaster() ;
  490.             break;
  491.  
  492.         case STARTUP_JAVA_DEBUG_AGENT:
  493.             LJ_StartDebugger(LJDebugPort_SharedMemory);
  494.             break;
  495.  
  496.         case STARTUP_JAVA:
  497.             //we decided to ignore the -start_java flag on second instance
  498.             //and just simply continue to start navigator
  499.             break;
  500. #endif
  501.  
  502.         case 0:
  503.             {
  504.             AfxMessageBox(IDS_CMDLINE_ERROR4);
  505.             }
  506.              return;
  507.             
  508.              
  509.         default:
  510.             break;
  511.     }
  512.                 
  513.  
  514.   // rhp - added STARTUP_CLIENT_MAPI for starting MAPI
  515.     if ((iStartupMode & STARTUP_BROWSER || iStartupMode & STARTUP_EDITOR || // if startup browser or editor
  516.         !(iStartupMode & (STARTUP_JAVA_DEBUG_AGENT|STARTUP_BROWSER|STARTUP_NEWS|STARTUP_MAIL|STARTUP_ADDRESS
  517.         |STARTUP_INBOX|STARTUP_CLIENT_MAPI|STARTUP_COMPOSE|STARTUP_FOLDER|STARTUP_FOLDERS)) ||    // or invalid data
  518.         m_bKioskMode ))  {                                                  // or kiosk mode - start browser
  519.  
  520.  #ifdef EDITOR
  521.         //  The Editor is started INSTEAD of the Browser,
  522.         if ( bIsGold && (iStartupMode & STARTUP_EDITOR) ) 
  523.         {
  524.             FE_LoadUrl(pszCmdLine, LOAD_URL_COMPOSER);
  525.             return;
  526.         } 
  527.         else 
  528. #endif /* EDITOR */
  529.         {
  530.             CFrameWnd *pFrameWnd = FEU_GetLastActiveFrame(MWContextBrowser); 
  531.                if (!theApp.m_ViewTmplate)
  532.                {
  533.                    AfxMessageBox(IDS_NO_RUN_WHILE_PROFILING);
  534.                    return;
  535.                }
  536.             else if ( pszCmdLine != NULL && strlen(pszCmdLine) > 0)
  537.             {
  538.                 CString strUrl;
  539.                 WFE_ConvertFile2Url(strUrl, pszCmdLine);
  540.  
  541.                 //  Open it in a new window.
  542.                 //  Use the first window as the provider of the context.
  543.                 URL_Struct *pUrl = NET_CreateURLStruct(strUrl, NET_DONT_RELOAD);
  544.                 if(m_pFrameList && m_pFrameList->GetMainContext())
  545.                 {
  546.                     MWContext *pContext = m_pFrameList->GetMainContext()->GetContext();
  547.                     CFE_CreateNewDocWindow(pContext, pUrl);
  548.                 }
  549.                 else
  550.                 {
  551.                     CFE_CreateNewDocWindow(NULL, pUrl);
  552.                 }
  553.                 return;
  554.             }
  555.             else
  556.                 theApp.m_ViewTmplate->OpenDocumentFile(NULL);
  557.         }
  558.  
  559.  
  560.         CMainFrame *pFrame;
  561.         CGenericFrame *pGenFrame;
  562.         if (!theApp.m_pFrameList) 
  563.             return;
  564.         for(pGenFrame = theApp.m_pFrameList; pGenFrame->m_pNext; pGenFrame = pGenFrame->m_pNext) {
  565.             /* No Body */;
  566.         }
  567.  
  568.         pFrame = (CMainFrame *) pGenFrame;
  569.  
  570.         //    The new frame will be the last one in the application's frame list.
  571.  
  572.         pFrame->OnLoadHomePage();
  573.         
  574.         // possibly clear URL bar focus here. - JRE            
  575.     }
  576.  
  577. }
  578.  
  579. CString CNetscapeApp::BuildDDEFile()
  580. {
  581.     char szbuffer[256];
  582.     char szName[256];
  583.     CString strPrefix;
  584.  
  585.     strPrefix.LoadString(IDS_STUB_PREFIX);
  586.  
  587.  
  588. #ifdef XP_WIN32
  589.     int nSize = GetTempPath(511, szbuffer);
  590.     if (nSize == 0)
  591.     {
  592.         AfxMessageBox(IDS_NO_TEMP_DIRECTORY);
  593.         return (CString)" ";
  594.     }
  595.     szbuffer[nSize+1] = '\0'; //terminate the string
  596.     GetTempFileName(szbuffer,strPrefix, 0,szName);
  597. #else
  598.     GetTempFileName(0,strPrefix, 0,szName);
  599. #endif
  600.     return (CString)szName;
  601.  
  602. }
  603.  
  604.  
  605. void CNetscapeApp::BuildStubFile()
  606. {
  607.     char szbuffer[256];
  608.     char szName[256];
  609.     CString strPrefix;
  610.  
  611.     strPrefix.LoadString(IDS_STUB_PREFIX);
  612.  
  613.     if (!m_strStubFile.IsEmpty()) 
  614.         return;
  615.  
  616. #ifdef XP_WIN32
  617.     int nSize = GetTempPath(511, szbuffer);
  618.     if (nSize == 0)
  619.     {
  620.         AfxMessageBox(IDS_NO_TEMP_DIRECTORY);
  621.         return;
  622.     }
  623.     szbuffer[nSize+1] = '\0'; //terminate the string
  624.     GetTempFileName(szbuffer,strPrefix, 0,szName);
  625. #else
  626.     GetTempFileName(0,strPrefix, 0,szName);
  627. #endif
  628.     m_strStubFile = szName;
  629.  
  630. }
  631.  
  632. #ifdef MOZ_MAIL_NEWS
  633. BOOL CNetscapeApp::LaunchComposeAndAttach(CStringList &rlstrArgumentList)
  634. {
  635.  
  636.     void OpenDraftExit (URL_Struct *url_struct, int/*status*/,MWContext *pContext);
  637.  
  638.     CFileStatus rStatus;
  639.     MSG_AttachmentData *pAttachList = NULL;
  640.     POSITION rPos = rlstrArgumentList.GetHeadPosition();
  641.     char *pszMessage = NULL;     
  642.     char *pszAttachments = NULL;
  643.     
  644.     BuildStubFile();
  645.  
  646.     if (rlstrArgumentList.GetCount() > 1)
  647.     {
  648.  
  649.         pszMessage     =  (char*)(const char*)rlstrArgumentList.GetNext(rPos);
  650.         pszAttachments =  (char*)(const char*)rlstrArgumentList.GetNext(rPos);
  651.         
  652.         if ( (*pszMessage == '@') || (*pszMessage == '-') )
  653.             return FALSE;
  654.  
  655.         //Make sure the files exist.
  656.         if(!CFile::GetStatus(pszMessage,rStatus))
  657.             return FALSE;
  658.  
  659.         if(!CFile::GetStatus(pszAttachments+1,rStatus))
  660.             return FALSE;
  661.     }
  662.     else
  663.     {   //there was no message file given so we have to fake one to get compose to start
  664.         CStdioFile file;
  665.         if(!CFile::GetStatus(m_strStubFile,rStatus))
  666.         {
  667.             if (!file.Open(m_strStubFile, CFile::modeCreate | CFile::modeWrite))
  668.             {
  669.                 return 0;
  670.             }
  671.         }
  672.         else
  673.         {
  674.             if (!file.Open(m_strStubFile, CFile::modeWrite))
  675.             {
  676.                 return 0;
  677.             }
  678.         }
  679.         pszAttachments =  (char*)(const char*)rlstrArgumentList.GetNext(rPos);
  680.     }
  681.     
  682.     pAttachList = BuildAttachmentListFromFile(pszAttachments);
  683.  
  684.  
  685.     if (pAttachList)
  686.     {
  687.         CString strUrl;
  688.         if (pszMessage)
  689.             WFE_ConvertFile2Url(strUrl, pszMessage);
  690.         else 
  691.             WFE_ConvertFile2Url(strUrl, m_strStubFile);
  692.  
  693.         URL_Struct *pURL = NET_CreateURLStruct(strUrl, NET_DONT_RELOAD);
  694.         StrAllocCopy(pURL->content_type,"message/rfc822"); 
  695.         pURL->fe_data = (void*)pAttachList;
  696.         NET_GetURL (pURL, FO_CMDLINE_ATTACHMENTS, m_pBmContext,
  697.                    OpenDraftExit);
  698.         
  699.         return TRUE;
  700.     }
  701.     else
  702.         return FALSE;
  703. }
  704.  
  705.  
  706. MSG_AttachmentData * CNetscapeApp::BuildAttachmentListFromFile(char *pszAttachFile)
  707. {
  708.     //handle a single attachment here
  709.     if (*pszAttachFile == '-') 
  710.     {
  711.         pszAttachFile += 1;
  712.         CFileStatus rStatus;
  713.         if (CFile::GetStatus(pszAttachFile, rStatus))
  714.         {
  715.             MSG_AttachmentData * pAttach = 
  716.                 (MSG_AttachmentData *)XP_CALLOC(2,sizeof(MSG_AttachmentData));
  717.             XP_MEMSET (pAttach, 0, (2) * sizeof (MSG_AttachmentData));
  718.             CString cs;
  719.             WFE_ConvertFile2Url(cs,(const char *)pszAttachFile);
  720.             pAttach->url = XP_STRDUP(cs);
  721.             ASSERT(pAttach->url);
  722.             return pAttach;
  723.         }
  724.     }//handle multiple attachments contained in a list file
  725.     else if(*pszAttachFile == '@')
  726.     {
  727.         //we have to read from the file of attachments
  728.         CStdioFile file;
  729.         MSG_AttachmentData * pAttachList = NULL;
  730.         MSG_AttachmentData *pAttach = NULL;
  731.         pszAttachFile += 1;
  732.  
  733.         if (!file.Open(pszAttachFile,CFile::modeRead | CFile::typeText))
  734.             return NULL;  //The list file did not exist!!!!
  735.         
  736.         CString strAttach;
  737.         CFileStatus rStatus;
  738.         CStringList rlstrFileList;
  739.         
  740. #ifdef XP_WIN16
  741.         char buf[256];
  742.         while(file.ReadString(buf,255))
  743.         {
  744.             if(CFile::GetStatus(buf,rStatus))
  745.                 rlstrFileList.AddTail((CString)buf);
  746.             else
  747.                 if ( IDNO == AfxMessageBox(IDS_CMDLINE_ERROR6, MB_YESNO |MB_ICONEXCLAMATION))
  748.                     return NULL;
  749.             memset(buf,'\0',256);
  750.         }//build an intermediate list which will be used to create a MSG_AttachmentData list 
  751. #else        
  752.         while(file.ReadString(strAttach))
  753.         {
  754.             if(CFile::GetStatus(strAttach,rStatus))
  755.                 rlstrFileList.AddTail(strAttach);
  756.             else
  757.                 if ( IDNO == AfxMessageBox(IDS_CMDLINE_ERROR6, MB_YESNO |MB_ICONEXCLAMATION))
  758.                     return NULL;
  759.         }//build an intermediate list which will be used to create a MSG_AttachmentData list 
  760. #endif
  761.         int nNumFiles = rlstrFileList.GetCount();
  762.         
  763.         if (nNumFiles > 0)
  764.         {
  765.             //make sure the attachment is a real file.
  766.             CString cs;
  767.             int count = 0;
  768.             pAttachList = (MSG_AttachmentData *)XP_CALLOC(nNumFiles +1,sizeof(MSG_AttachmentData));
  769.             XP_MEMSET (pAttachList, 0, (nNumFiles +1) * sizeof (MSG_AttachmentData));
  770.  
  771.             if (!pAttachList)
  772.                 return NULL;
  773.     
  774.             POSITION pos1, pos2;
  775.             for( pos1 = rlstrFileList.GetHeadPosition(); ( pos2 = pos1 ) != NULL; )
  776.             {
  777.                 strAttach = rlstrFileList.GetNext( pos1 );
  778.  
  779.                 WFE_ConvertFile2Url(cs,(const char *)strAttach);
  780.                 pAttachList[count++].url = XP_STRDUP(cs);
  781.             }
  782.             return pAttachList;
  783.         }
  784.     }
  785.     return NULL;
  786.  
  787. }
  788. #endif /* MOZ_MAIL_NEWS */
  789.  
  790. ////////////////////////////////////////////////////////////////////////////
  791. //Function:        CNetscapeApp::SetStartupMode
  792. //
  793. //Parameters:    iStartupMode. 
  794. //
  795. //Purpose:        Initialize iStartupMode with the appropriate component launch
  796. //                value.
  797. /////////////////////////////////////////////////////////////////////////////                
  798. void CNetscapeApp::SetStartupMode(int *iStartupMode)
  799. {
  800.     // set launch type and clear global flag.
  801.     if (m_bAccountSetup)        {                  // MUST be first to ensure only in browser
  802.         *iStartupMode=    STARTUP_ACCOUNT_SETUP;
  803.         m_bAccountSetup= FALSE;
  804.  
  805. #ifdef EDITOR
  806.     }else if ( m_bCmdEdit || m_bCreateEdit)    {
  807.         *iStartupMode    =    STARTUP_EDITOR;
  808.         m_bCmdEdit=m_bCreateEdit = 0;
  809. #endif /* EDITOR */    
  810.  
  811. #ifdef MOZ_MAIL_NEWS
  812.     }else     if (m_bCreateInbox)            {
  813.                 *iStartupMode=    STARTUP_INBOX;
  814.                 m_bCreateInbox= 0;
  815.  
  816.   // rhp - for MAPI startup
  817.   }else     if (m_bCreateInboxMAPI)            {
  818.                 *iStartupMode=    STARTUP_CLIENT_MAPI;
  819.                 m_bCreateInboxMAPI= 0;
  820.   // rhp - for MAPI startup
  821.  
  822.     }else     if (m_bCreateFolder)        {
  823.                 *iStartupMode=    STARTUP_FOLDER;
  824.                 m_bCreateFolder= 0;
  825.  
  826.     }else     if (m_bCreateFolders)        {
  827.                 *iStartupMode=    STARTUP_FOLDERS;
  828.                 m_bCreateFolders= 0;
  829.  
  830.     }else    if (m_bCreateCompose)        {
  831.                 *iStartupMode=    STARTUP_COMPOSE;
  832.                 m_bCreateCompose= 0;
  833.  
  834.     }else    if (m_bCreateAddress)        {
  835.                 *iStartupMode=    STARTUP_ADDRESS;
  836.                 m_bCreateAddress= 0;
  837.  
  838. #endif /* MOZ_MAIL_NEWS */
  839.     }else    if (m_bCreateLDIF_IMPORT)    {
  840.                 *iStartupMode=    STARTUP_IMPORT;
  841.                 m_bCreateLDIF_IMPORT= 0;
  842.  
  843.     }else    if (m_bCreateLDIF_EXPORT)    {
  844.                 *iStartupMode=    STARTUP_EXPORT;
  845.                 m_bCreateLDIF_EXPORT= 0;
  846.  
  847. #ifdef MOZ_MAIL_NEWS
  848.     } else    if (m_bCreateMail)            { //same as folder
  849.                 *iStartupMode=    STARTUP_MAIL;
  850.                 m_bCreateMail= 0;
  851.  
  852. #endif /* MOZ_MAIL_NEWS */
  853.     } else    if (m_bCreateNetcaster)            {
  854.                 *iStartupMode=    STARTUP_NETCASTER;
  855.                 m_bCreateNetcaster= 0;
  856.  
  857. #ifdef MOZ_MAIL_NEWS
  858.     } else    if (m_bCreateNews)            { 
  859.                 *iStartupMode=    STARTUP_NEWS;
  860.                 m_bCreateNews= 0;
  861.  
  862.     //over ride prefference settings for this mode
  863. #endif /* MOZ_MAIL_NEWS */
  864.     } else    if (m_bCreateBrowser)        { 
  865.                 *iStartupMode=    STARTUP_BROWSER;
  866.                 m_bCreateBrowser= 0;
  867.     
  868.     //we don't want to handle preferences in the first instance 
  869.     //if requested to do so by a second instance
  870.     }else    if (m_bCreateNewProfile)        { 
  871.                 *iStartupMode=    (*iStartupMode == 0 ? 0: *iStartupMode);
  872.                 m_bCreateNewProfile= 0;
  873.  
  874.     }else    if (m_bProfileManager)        { 
  875.                 *iStartupMode=    (*iStartupMode == 0 ? 0: *iStartupMode);
  876.                 m_bProfileManager= 0;
  877.  
  878.     }else    if (m_bCreateJavaDebugAgent)        { 
  879.                 *iStartupMode=    STARTUP_JAVA_DEBUG_AGENT;
  880.                 m_bCreateJavaDebugAgent = 0;
  881.     
  882.     }else    if (m_bAccountSetupStartupJava) {
  883.                 m_bAccountSetupStartupJava = FALSE;
  884.                 *iStartupMode=    STARTUP_JAVA;
  885.     }
  886.     else {
  887.         //  Implied component checking here.
  888.         if(m_CmdLineLoadURL) {
  889.             switch(NET_URL_Type(m_CmdLineLoadURL)) {
  890.                 case NETHELP_TYPE_URL: {
  891.                     *iStartupMode = STARTUP_NETHELP;
  892.                     break;
  893.                 }
  894.             }
  895.         }
  896.     }
  897.  
  898. }
  899.  
  900.  
  901. BOOL CNetscapeApp::ProcessCommandLineDDE(char *pszDDECommand)
  902. {
  903.     //DDE says we have something to chew on.
  904.             //so let's see what we have!
  905.     char *pszCommand = pszDDECommand;
  906.     char *pszFreeMe = NULL;
  907.     BOOL bDdeException = FALSE;
  908.  
  909.     if (strcasestr(pszDDECommand,"-DDEEXCEPTION"))
  910.     {
  911.          char *pDelete = XP_STRDUP(pszDDECommand);
  912.         char *pOpen = pDelete;
  913.  
  914.         if (strnicmp(pOpen, "[cmdline(\"-DDEEXCEPTION", 25) != 0)   
  915.         {
  916.             pOpen += 23;
  917.         }
  918.         else
  919.         {
  920.             XP_FREE(pDelete);   //Added by CLM - memory leak       
  921.             return FALSE; //bad DDE command syntax
  922.         }
  923.         char *pEnd = strchr(pOpen, '"');
  924.  
  925.         if (pEnd == NULL)
  926.         {
  927.             XP_FREE(pDelete);   //Added by CLM - memory leak       
  928.             return FALSE;
  929.         }
  930.         // trim the string, and open the file
  931.         *pEnd = '\0';
  932.         
  933.         CFile fin;
  934.         if( !fin.Open( pOpen, CFile::modeRead ) )
  935.         {
  936.             XP_FREE(pDelete);
  937.             remove(pOpen);
  938.             return FALSE;
  939.         }
  940.  
  941.         char *pszDDEstring = new char[fin.GetLength()+1];
  942.         memset(pszDDEstring,'\0', fin.GetLength()+1);
  943.         bDdeException = TRUE;
  944.         int nBytesRead = 0;
  945.  
  946.         if (pszDDEstring)
  947.         {
  948.             int nLength = fin.GetLength();
  949.             nBytesRead = fin.Read(pszDDEstring,nLength);
  950.             pszDDEstring[nBytesRead] = NULL;
  951.         }
  952.         fin.Close();
  953.         remove(pOpen);
  954.         XP_FREEIF(pDelete);
  955.         pszFreeMe = pszDDEstring;
  956.         pszCommand = pszDDEstring;
  957.     }
  958.  
  959.  
  960.  
  961.     if (ExistComponentArguments(pszCommand))
  962.     {
  963.         int iStartupMode = 0;
  964.         SetStartupMode(&iStartupMode);
  965.         LaunchComponentWindow(iStartupMode,pszCommand);
  966.     }
  967.     else
  968.     {   //We've got something other than an expected switch.
  969.         //It's probably a URL.  Let's check it out and do the right thing.
  970.          CString strUrl;
  971.         BOOL bTranslate = TRUE;
  972.         char *pDelete = NULL;
  973.        if (!bDdeException)
  974.        {
  975.             //  Copy the string to mess with.
  976.             char *pDelete = XP_STRDUP(pszCommand);
  977.             char *pOpen = pDelete;
  978.  
  979.             // cmdline format is "[cmdline("%s")]" - no whitespace allowed, one per line
  980.             if (strnicmp(pOpen, "[cmdline(\"", 11) != 0)   
  981.             {
  982.                 pOpen += 10;
  983.             }
  984.             else
  985.             {
  986.                 XP_FREE(pDelete);   //Added by CLM - memory leak       
  987.                 return FALSE; //bad DDE command syntax
  988.             }
  989.  
  990.             BOOL bJumpQuote = FALSE;
  991.             if (*pOpen == '"') {
  992.                 pOpen += 1; //jump over additional quote if it is there.
  993.                 bJumpQuote = TRUE;
  994.             }
  995.  
  996.             //  Search backwards for the end, with some smarts.
  997.             char *pEnd = strrchr(pOpen, ']');
  998.             if(pEnd) {
  999.                 *pEnd = '\0';
  1000.                 pEnd = strrchr(pOpen, ')');
  1001.                 if(pEnd) {
  1002.                     *pEnd = '\0';
  1003.                     pEnd = strrchr(pOpen, '\"');
  1004.                     if(pEnd && bJumpQuote) {
  1005.                         *pEnd = '\0';
  1006.                         pEnd = strrchr(pOpen, '\"');
  1007.                     }
  1008.                 }
  1009.             }
  1010.  
  1011.             if (pEnd == NULL)
  1012.             {
  1013.                 XP_FREE(pDelete);   //Added by CLM - memory leak       
  1014.                 return FALSE;
  1015.             }
  1016.  
  1017.             // trim the string, and open the file
  1018.             *pEnd = '\0';
  1019.             strUrl = pOpen;
  1020.         }
  1021.         else
  1022.         {
  1023.             WFE_ConvertFile2Url(strUrl, pszCommand);
  1024.         }
  1025.  
  1026.         //  Handle other weird cases, like print here.
  1027.         //  Other code is not smart enough.
  1028.         if(0 == strnicmp(strUrl, "/print", 6)) {
  1029.             theApp.OnDDECommand((char *)(const char *)strUrl);
  1030.         }
  1031.         else {
  1032.             //  some URLs get handled differently.
  1033.             switch(NET_URL_Type(strUrl)) {
  1034.                 case NETHELP_TYPE_URL: {
  1035.                     if(theApp.m_pSlaveCX) {
  1036.                         theApp.m_pSlaveCX->NormalGetUrl(strUrl);
  1037.                     }
  1038.                     break;
  1039.                 }
  1040.                 default: {
  1041.                     //  Open it in a new window.
  1042.                     //  Use the first window as the provider of the context.
  1043.                     URL_Struct *pUrl = NET_CreateURLStruct(strUrl, NET_DONT_RELOAD);
  1044.                     if(m_pFrameList && m_pFrameList->GetMainContext())
  1045.                     {
  1046.                         if (bTranslate)
  1047.                         {
  1048.                         MWContext *pContext = m_pFrameList->GetMainContext()->GetContext();
  1049.                         CFE_CreateNewDocWindow(pContext, pUrl);
  1050.                         }
  1051.                         else
  1052.                         {
  1053.                             CFrameGlue * pFrame =
  1054.                             CFrameGlue::GetLastActiveFrame(MWContextBrowser);
  1055.                             if (pFrame != NULL && pFrame->GetMainContext() && 
  1056.                                 pFrame->GetMainContext()->GetContext() &&
  1057.                                 !pFrame->GetMainContext()->GetContext()->restricted_target)
  1058.                             {
  1059.                                 CAbstractCX * pCX = pFrame->GetMainContext();
  1060.                                 if (pCX != NULL)
  1061.                                 {
  1062.                                     pCX->NormalGetUrl(strUrl);
  1063.                                 }  /* end if */
  1064.                             }  /* end if */
  1065.                             else
  1066.                             {
  1067.                                 CFE_CreateNewDocWindow(NULL, pUrl);
  1068.                             }  /* end else */
  1069.                         }  /* end else */
  1070.                     }
  1071.                     else
  1072.                     {
  1073.                         CFE_CreateNewDocWindow(NULL, pUrl);
  1074.                     }
  1075.                     break;
  1076.                 }
  1077.             }
  1078.         }
  1079.  
  1080.         if (!bDdeException)
  1081.             XP_FREEIF(pDelete);
  1082.     }
  1083.     //handled!!
  1084.     if (bDdeException)
  1085.         delete pszFreeMe;
  1086.  
  1087.     return TRUE;
  1088. }
  1089.  
  1090. // CLM:
  1091. //   System to find previous instance of program by ourselves
  1092. //    or from other applications.
  1093. //   Return value from OnNetscapeGoldIsActive() in previous instance 
  1094. //      is hwnd of CGenericFrame-derived frame
  1095. //
  1096. BOOL CALLBACK FindNavigator( HWND hwnd, LPARAM lParam )
  1097. {
  1098.     if ( hwnd == (HWND)(::SendMessage( hwnd, WM_NG_IS_ACTIVE, 0, 0 )) )
  1099.     {
  1100.         // Return window found and quit enumerating
  1101.         *((HWND*)lParam) = hwnd;
  1102.         return FALSE;
  1103.     }
  1104.     return TRUE;
  1105. }
  1106.  
  1107. BOOL CMapStringToObNoCase::Lookup(LPCTSTR key, CObject*& rValue) const
  1108. {
  1109.     CString csKey = key;
  1110.     csKey.MakeLower();
  1111.  
  1112.     return CMapStringToOb::Lookup(csKey, rValue);
  1113. }
  1114.  
  1115. BOOL CMapStringToObNoCase::LookupKey(LPCTSTR key, LPCTSTR& rKey) const
  1116. {
  1117.     ASSERT(0);
  1118.     return FALSE;
  1119. }
  1120.  
  1121.  
  1122. CObject*& CMapStringToObNoCase::operator[](LPCTSTR key)
  1123. {
  1124.     CString csKey = key;
  1125.     csKey.MakeLower();
  1126.  
  1127.     return CMapStringToOb::operator[](csKey);
  1128. }
  1129.  
  1130. void CMapStringToObNoCase::SetAt(LPCTSTR key, CObject* newValue)
  1131. {
  1132.     CString csKey = key;
  1133.     csKey.MakeLower();
  1134.  
  1135.     CMapStringToOb::SetAt(csKey, newValue);
  1136. }
  1137.  
  1138. BOOL CMapStringToObNoCase::RemoveKey(LPCTSTR key)
  1139. {
  1140.     CString csKey = key;
  1141.     csKey.MakeLower();
  1142.  
  1143.     return CMapStringToOb::RemoveKey(csKey);
  1144. }
  1145.  
  1146. inline UINT CMapStringToObNoCase::HashKey(LPCTSTR key) const
  1147. {
  1148.     CString csKey = key;
  1149.     csKey.MakeLower();
  1150.     return CMapStringToOb::HashKey(csKey);
  1151. }
  1152.  
  1153. void WFE_LJ_StartupJava(void)
  1154. {
  1155. #ifdef JAVA
  1156.     LJ_StartupJava();
  1157. #endif
  1158. }
  1159.  
  1160. void WFE_LJ_StartDebugger(void)
  1161. {
  1162. #ifdef JAVA
  1163.     LJ_StartDebugger(LJDebugPort_SharedMemory);
  1164. #endif
  1165. }
  1166.  
  1167.  
  1168. void CNetscapeApp::RemoveDDESyntaxAndSwitch(CString strSwitch, char *pszCmdLine)
  1169. {
  1170.     char *pSavPosition = pszCmdLine;
  1171.  
  1172.     if (strstr(pszCmdLine, "cmdline") )
  1173.     {
  1174.         char *pszFirst = strchr(pszCmdLine, '"');
  1175.         if (pszFirst && *pszFirst == '"')
  1176.             ++pszFirst;
  1177.         else
  1178.         {   //we might have already ripped off the "cmdline" stuff
  1179.             pszFirst = strcasestr(pszCmdLine,strSwitch);
  1180.         }
  1181.     
  1182.         char *pszNext = NULL;
  1183.         if (pszFirst)
  1184.         {
  1185.             pszNext = strrchr(pszFirst,'"');
  1186.             if (pszNext)
  1187.             {    
  1188.                 *pszNext = NULL;
  1189.                 pszCmdLine = pszFirst;
  1190.             }
  1191.             if (IsRuntimeSwitch(strSwitch,pszCmdLine,TRUE))
  1192.             {
  1193.                 while (isspace(*pszCmdLine))
  1194.                     ++pszCmdLine;
  1195.                 if (*pszCmdLine == '"') 
  1196.                     pszCmdLine++;
  1197.                 if (pszCmdLine[strlen(pszCmdLine)-1] == '"') 
  1198.                     pszCmdLine[strlen(pszCmdLine) -1] = '\0';
  1199.  
  1200.                 strcpy(pSavPosition,pszCmdLine);
  1201.             }
  1202.         }
  1203.     }
  1204.     else
  1205.     {
  1206.         if (IsRuntimeSwitch(strSwitch,pszCmdLine,TRUE))
  1207.         {
  1208.             while (isspace(*pszCmdLine))
  1209.                 ++pszCmdLine;
  1210.         }
  1211.     }
  1212.  
  1213. }
  1214.