// winbodoc.cpp : implementation of the CWinbootDoc class
//

#include "stdafx.h"
#include "winboot.h"

#include "winbodoc.h"

#include "reboot.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWinbootDoc

IMPLEMENT_DYNCREATE(CWinbootDoc, CDocument)

BEGIN_MESSAGE_MAP(CWinbootDoc, CDocument)
	//{{AFX_MSG_MAP(CWinbootDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWinbootDoc construction/destruction

CWinbootDoc::CWinbootDoc()
{
	// TODO: add one-time construction code here
	m_bootflags = 0;
}

CWinbootDoc::~CWinbootDoc()
{
}

BOOL CWinbootDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	UpdateAllViews(NULL);
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CWinbootDoc serialization

void CWinbootDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CWinbootDoc diagnostics

#ifdef _DEBUG
void CWinbootDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CWinbootDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CWinbootDoc commands

void CWinbootDoc::BootFreeBSD(void)
{
	CString params="";

	if (m_bootflags & RB_ASKNAME)  params += "a";
	if (m_bootflags & RB_CDROM)    params += "C";
	if (m_bootflags & RB_KDB)      params += "d";
	if (m_bootflags & RB_DFLTROOT) params += "r";
	if (m_bootflags & RB_SINGLE)   params += "s";
	if (m_bootflags & RB_CONFIG)   params += "c";
	if (m_bootflags & RB_VERBOSE)  params += "v";
	if (m_bootdos) params += "D";

	params += " " + m_kernelname;

	if (!params.IsEmpty()) params = "-" + params;
	ExitWindowsExec(((CWinbootApp *) AfxGetApp())->m_fbsdboot_path, params);
}