#include "state_tools.h"
#include <unistd.h>
#include <sys/stat.h>

using namespace std;

int System(const string & str)
{
   return system(str.c_str());
}

int _main()
{
   int value1 = 123;
   int value2 = 456;
   int value3 = 100;

   cout << "value1a=" << value1 << endl;
   cout << "value2a=" << value2 << endl;
   cout << "value3a=" << value3 << endl;

   cout << "value1: ";
   cin >> value1;

   cout << "value2: ";
   cin >> value2;

   cout << "value3: ";
   cin >> value3;

   state_save();

   cout << "value1b=" << value1 << endl;
   cout << "value2b=" << value2 << endl;
   cout << "value3b=" << value3 << endl;

   return 0;
}

bool do_load()
{
   bool ret = false;
   ifstream fin("state.dat");
   if(fin) 
      ret = true;
   else
      ret = false;
   return ret;
}

int main(int argc, char ** argv, char ** envp)
{
   program_name = argv[0];

   state_init();

   if(do_load()) {
      state_load();
   }

   _main();

   return 0;
}
