#if !defined(__alffnlog_h) // Sentry, use file only if it's not already included.
#define __alffnlog_h
/*  Project Biblio-Tec

	 SUBSYSTEM:    TEC30r.dll Library (TecLib)
	 FILE:         alfflogf.h
	 AUTHOR:       Alcindo Ferreira Filho

	 OVERVIEW:
	 ALFFLogFile Class definition, an Log file for sessions.

    COPYRIGHT:    © 1997,2005
                  Alcindo Ferreira Filho
                  <alcindo@inttec.com.br>

    LICENSE:      Biblio-Tec license (BiblTec.txt)
*/
#include "alffobj.h"
#include "alffutil.h"
#include "alfffile.h"

#include <owl\window.h>
#include <owl\opensave.h>
#include <classlib\file.h>

//{{ALFFLogFile}}
/* Open Log Return Codes */
#define NOFILENAME     -10
#define INVALIDOPEN    -11
#define CANCELOPEN     -12
#define SUCCESSFULOPEN -13

/* Carriage Return (CR) and Line Feed (LF) ASCII Codes */
#define LF        0x0A
#define CR        0x0D

/* Maximum Log File Record Length */
#define MAXTEXTSIZE    256

class _TECLIBCLASS ALFFLogFile : private TFile, public ALFFObject
{
	public:
    ALFFLogFile();
	 ALFFLogFile(TWindow* pParent);

	 virtual ~ALFFLogFile();
    char far* GetClassName() {return "ALFFLogFile";}

	 /* Get Log File Name  ......  */
	 const char* GetFileName();

	 /* Open Trace Data File and Initialize it */
	 int OpenTrace();
    int OpenTrace(const char* fileName);

    /* Open Text Log File and Initialize it */
	 int OpenLog(const char* fileName);

    /* Get the status of the Log or Trace File */
    bool isOpen() {return isOpened;}

	 void SetLogTitle(const char* title, ALFFDate::DateFormat fmt);

	 /* Log Line Text as it is passed */
	 void LogText(int resourceId, HINSTANCE instance, char* errText=NULL);
	 void LogText(const char* buffer, int buflen);

	 /* Log Line Recv & Line Send Data Routine */
	 void LogData(char direction, const char* buffer,
					  int bufLength, bool urgent=false, bool convertToAsc=false,
					  char* tabEbcAsc=0);
	 /* Log Terminal Options Routine */
	 void LogOption(char direction, char* format, int option);


	 /* Log Terminal SubOptions Routine */
	 void LogSubOption(char direction, char* subbuffer, int bufLength);


    /* Close the File */

	 bool Close();


  protected:
	 TWindow*  logParent;

	 TOpenSaveDialog::TData* fileData;

  	 string	  fileFullPath;

    bool      isOpened;

	 void TidyFileName();
	 void DumpData (const char *buffer, int length,
						 bool convertToAsc, char* tabEbcAsc);
};
//{{ALFFLogFile}}
#endif
