/***************************************************************************
**    $Header:   D:/ECB2S/SRC/LOG/DA.CPP   1.2.1.5   17 Apr 1997 15:47:18   ZJRD  $
**
**    $Log:   D:/ECB2S/SRC/LOG/DA.CPP  $
** 
**    Rev 1.2.1.5   17 Apr 1997 15:47:18   ZJRD
** No change.
** 
**    Rev 1.2.1.4   16 Apr 1997 10:18:46   ZJRD
** No change.
** 
**    Rev 1.2.1.3   10 Apr 1997 15:30:06   ZJRD
** 2.09F
** 
**    Rev 1.2.1.1   03 Apr 1997 15:11:10   ZJRD
** No change.
** 
**    Rev 1.2.1.0   28 Mar 1997 10:16:10   ZJRD
** easy pack sld 2.09d
** 
**    Rev 1.1   19 Mar 1997 11:27:20   ZJRD
** Easy Pack SLD 2.09c
**
**    $Header:   D:/ECB2S/SRC/LOG/DA.CPP   1.2.1.5   17 Apr 1997 15:47:18   ZJRD  $
**
**    $Log$
** 
**    Rev 1.4.1.0.1.2   09 Dec 1996 10:14:22   ZJRD
** EasyPack/SLD Version 2.0P
** 
**    Rev 1.4.1.0.1.0   11 Nov 1996 12:57:38   ZJRD
** EasyPack/SLD Version 2.01
** 
**    Rev 1.4.1.4   09 Sep 1996 13:13:58   ZJRD
** No change.
** 
**    Rev 1.4.1.3   05 Sep 1996 11:25:30   ZJRD
** No change.
** 
**    Rev 1.4.1.2   02 Sep 1996 09:52:38   ZJRD
** No change.
** 
**    Rev 1.4.1.1   28 Aug 1996 15:45:04   ZJRD
** EasyPack/SLD Version 1.9b
** 
**    Rev 1.4.1.0   12 Aug 1996 10:50:14   ZJRD
** EasyPack/SLD Version 1.98
** 
**    Rev 1.1   29 May 1996 09:35:40   ZJRD
** EasyPack/SLD Version 1.95
** 
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
// da.cpp
//
// Michael Long
//                                                                           
// 5/14/96
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"

#include "toolopt.h"
#include "da.h"

/////////////////////////////////////////////////////////////////////////////
// diagnostic
#ifdef _DEBUG
void DATool::Dump(CDumpContext &dc) const
{         
    CToolOption::Dump(dc);
    dc << "m_fDebug = " << m_fDebug << "\n";
    dc << "m_fList = " << m_fList << "\n";
    dc << "m_strMore = " << m_strMore << "\n";
    dc << "m_strPath = " << m_strPath << "\n"; 
     dc << "m_incPath = " << m_incPath << "\n";
 
}
#endif

/////////////////////////////////////////////////////////////////////////////
// operations
void DATool::SetDefault(void)
{
    m_fDebug = TRUE;
    m_fList =  TRUE;
    m_strMore = "SYMBOLS XREF ";
    m_strPath = "c:\\omf51\\bin";  
     m_incPath = "c:\\omf51\\inc";
}

BOOL DATool::LoadOption(FILE * fp)
{
    ASSERT(fp);
    
    const int nCnt = 2;
    
    char dch[nCnt];
    
    if(fread(dch, 1, nCnt, fp) != nCnt)
        return FALSE;
        
    m_fDebug = dch[0];
    m_fList = dch[1];
        
    WORD wLen;
    if(fread(&wLen, 2, 1, fp) != 1)
        return FALSE;
    if(wLen > (WORD)32000)
        return FALSE;
        
    if(fread(m_strMore.GetBuffer(wLen), 1, wLen, fp) != wLen)
        return FALSE;

    m_strMore.ReleaseBuffer(wLen);  
    if(fread(&wLen, 2, 1, fp) != 1)
        return FALSE;
    if(wLen > (WORD)32000)
        return FALSE;
        
    if(fread(m_strPath.GetBuffer(wLen), 1, wLen, fp) != wLen)
        return FALSE;

    m_strPath.ReleaseBuffer(wLen);  
    
     if(fread(&wLen, 2, 1, fp) != 1)
        return FALSE;
    if(wLen > (WORD)32000)
        return FALSE;
        
    if(fread(m_incPath.GetBuffer(wLen), 1, wLen, fp) != wLen)
        return FALSE;

    m_incPath.ReleaseBuffer(wLen);  

    return TRUE;
}                 

BOOL DATool::SaveOption(FILE * fp)
{
    ASSERT(fp);
    
    const int nCnt = 2;

    char dch[nCnt];
    
    dch[0] = (char)m_fDebug;
    dch[1] = (char)m_fList;
  
    if(fwrite(dch, 1, nCnt, fp) != nCnt)
        return FALSE;
             
    WORD wLen = WORD(m_strMore.GetLength());           
    if(fwrite(&wLen, 2, 1, fp) != 1)
        return FALSE;
        
    if(fwrite(m_strMore.GetBuffer(wLen), 1, wLen, fp) != wLen)
        return FALSE;

    m_strMore.ReleaseBuffer(wLen);  
    
    wLen = WORD(m_strPath.GetLength());           
    if(fwrite(&wLen, 2, 1, fp) != 1)
        return FALSE;
        
    if(fwrite(m_strPath.GetBuffer(wLen), 1, wLen, fp) != wLen)
        return FALSE;

    m_strPath.ReleaseBuffer(wLen);  
    
    wLen = WORD(m_incPath.GetLength());           
    if(fwrite(&wLen, 2, 1, fp) != 1)
        return FALSE;
        
    if(fwrite(m_incPath.GetBuffer(wLen), 1, wLen, fp) != wLen)
        return FALSE;

    m_incPath.ReleaseBuffer(wLen);  

    return TRUE;
}

CString DATool::GetOption(void) const
{
    CString str = " ";
    
            
    if(m_fDebug)
        str += "DB ";
        
    if(m_fList)
        str += "COND ";
    else
        str += "NOCOND ";
           
    str += m_strMore;
    str += " ";
    
    return str;
}

         
         