#ifdef MSDOS
#include "vmsmgr.hpp"

vmsmgr::vmsmgr(unsigned long the_size, unsigned long num_elements)
	: dmsmgr (the_size, num_elements)          // numelements defaults to 1
{
	int inK;
	
	installed = TRUE;
	memory = FALSE;
	inK = ((the_size * num_elements) / 1024) + 1;
	if (xmsmgr::is_installed())	{	// got extended memory!
		XMSindex = alloc_emb (inK);
		if (xmsmgr::is_installed())	{	// alloc okay?
			memory = TRUE;
			return;
			}
	}
	alloc_dmb ();
	installed = (dmsmgr::is_installed()) ? TRUE : FALSE;
	return;
}

char* vmsmgr::vmserr()
{
	return ((memory == TRUE) ? xmserr() : dmserr());
}

Boolean vmsmgr::stow (char far* send, size_t listnum)
{
Boolean retval;

	if (!is_installed())
		return FALSE;
	if (memory)
		retval = xmsmgr::stow (send, XMSindex, thesize, (unsigned long) (thesize * listnum));
	else
		retval = dmsmgr::stow (send, listnum);
	return retval;
}

Boolean vmsmgr::fetch (char far* receive, size_t listnum)
{
Boolean retval;

	if (!is_installed())
		return FALSE;
	if (memory)
		retval = xmsmgr::fetch (receive, XMSindex, thesize, (unsigned long) (thesize * listnum));
	else
		retval = dmsmgr::fetch (receive, listnum);
	return retval;
}
#endif /* MSDOS */
