/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : MissionPlan.cc                                                */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#include <string.h>
#include "malloc.h"
#include "MissionPlan.h"
#include "Behavior.h"
#include "Syslog.h"

MissionPlan::MissionPlan()
{
}


MissionPlan::~MissionPlan()
{
}


int MissionPlan::load(const char *fileName, BehaviorStack *behaviorStack)
{
  Boolean debug = False;
  Boolean error = False;
  char errorBuf[256];

  restartMissionPlanLexer();

  dprintf("MissionPlan::load() - file = %s\n", fileName);

  FILE *fp;
  if ((fp = fopen(fileName, "r")) == 0) {
    Syslog::write("Couldn't open mission plan file \"%s\"\n", fileName);
    return -1;
  }

  parse(fp, behaviorStack, &error, errorBuf);

  fclose(fp);

  if (error) {
    Syslog::write("MissionPlan::load() error:\n%s\n", errorBuf);
    return -1;
  }
  else {
    dprintf("Successfully loaded %s\n", fileName);
    return 0;
  }
}

