// Change History:

// DART Data Parameter File

#include <stdarg.h>

#include "ddp/ddp_printfile.h"
#include "base/AT_StringFunctions.h"

//#include <map>

bool DDP_PrintFile::Print(const byte * fmt, ... )
{
    char buf[LINE_SIZE];
    uint sz = 0;
    if(fmt)
        {
        va_list arg;
        va_start(arg, fmt);
        sz = vsnprintf((char *)buf, sizeof(buf), (const char *)fmt, arg);
        va_end(arg);
        }
    if(File)
      return File->write(buf, sz);
      
return false;
}
//----------------------------------------------------------------------------

bool DDP_PrintFile::NPrint(uint sz, const byte * fmt, ... )
{
    char * buf = new char [sz + LINE_SIZE];
    uint size = 0;
    if(fmt)
        {
        va_list arg;
        va_start(arg, fmt);
        size = vsnprintf((char *)buf, sz + LINE_SIZE, (const char *)fmt, arg);
        va_end(arg);
        }
        
    bool bFile = !!File;
    if(File)
      bFile = File->write(buf, size);
    delete [] buf;

return bFile;
}
//----------------------------------------------------------------------------

bool DDP_PrintFile::Open(const byte * name)
{
    File = ARL_CreateWriteSeqFile(name, ATFT_Raw);
return !!File;
}
//----------------------------------------------------------------------------

bool DDP_PrintFile::Close()
{
    if(!File)
        return true;

    ARL_DeleteFile(File);
    File = NULL;
    
return true;
}
//----------------------------------------------------------------------------

/****************************************************************************
 NOTES
 ****************************************************************************/

