// $Source: /usr/local/SimSoft/Sfx3D/src/gts/gtsio.cpp,v $
// $Revision: 1.2 $
// $Author: baum $
// $Date: 2001/11/29 15:18:10 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-14 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: gtsio.cpp,v $
// Revision 1.2  2001/11/29 15:18:10  baum
// -Realzeitsteuerung eingebaut
// -Handsteuerung eingebaut
//

/*** Windows headers ***/
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
//#include <winnt.h>
#endif /*WIN32*/

#include <stdarg.h>
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>

#include "gtsio.h"

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Write (ostream& ostrm, char *format, ...)
{
  static char buf [1024];
  va_list args;
  va_start (args, format);
  vsprintf (buf, format, args);
  va_end (args);
  ostrm << buf << flush;
}  // ENDE Write

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Writeln (ostream& ostrm)
{
  ostrm << endl << flush;
}  // ENDE Writeln

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Write (char *format, ...)
{
  static char buf [1024];
  va_list args;
  va_start (args, format);
  vsprintf (buf, format, args);
  va_end (args);
  cout << buf << flush;
}  // ENDE Write

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Writeln ()
{
  cout << endl << flush;
}  // ENDE Writeln


//==================================================================
//		Implementation
//		for class SFXToken
//==================================================================

SFXToken::SFXToken() : Token ()
{
  ObjComment             = '§';      // Dummy-CommentChar
  ObjLeadingBlockDelimit = '§';      // Dummy-LeadingStringDelimiter
  ObjEndingBlockDelimit  = '§';      // Dummy-EndingStringDelimiter
  ObjSequenz             = '§';      // just jump to next Token
}

// destructor
/*virtual*/ SFXToken::~SFXToken ()
 { }

bool SFXToken::findSentence (int sNumber, InputFile& file)
{
  int sentence;

  do {
    nextToken (file);
  } while (!isInt());
  sentence = atoi (ObjData);

  if (sentence == sNumber) return true;
  if (sentence > sNumber)  file.seekg (0);

  while ((file) && (sentence != -999) && (sentence != -3)) {
    file.jump (200);   // EOL
    nextToken (file);
    sentence = atoi (ObjData);
    if (sentence == sNumber) return true;
  }

  return false;
}  //  ENDE  findSentence

void SFXToken::Reset (InputFile& file)
{
  file.seekg (0);
}  //  ENDE  Reset

void SFXToken::EndOfLine (InputFile& file)
{
  file.jump (999);
}  //  ENDE EndOfLine


