// birthday.cc    main program for Birthday_C class
// P. Conrad, for CISC220, 06J

#include <iostream>
#include <fstream>
using std::cout;
using std::cerr;
using std::endl;
using std::ifstream;
using std::ios;

#include "Birthday.h"

#include <cstring>

#define INPUT_LINE_LEN 1024   // no semicolon on a #define

int main(int argc, char *argv[])
{

  if ( argc != 4)
    {
      cerr << "Usage: " << argv[0] << " filename month day  " << endl;
      cerr << "  This will print all people in the file whose "
	   << "birthday is on that date" << endl;
      exit(1);  // error condition available at unix cmd line -- echo $?
    }

  ifstream inf(argv[1],ios::in);
  
  if (!inf)
    {
      cerr << "Error: could not open " << argv[1] << endl;
      exit(2);
    }

  // now we know that we have an open file on inf
  // so read all lines from the file

  
  char inputLine[INPUT_LINE_LEN];

  
  const int MAX_NUM_BIRTHDAYS = 10;

  Birthday_C *birthdays[MAX_NUM_BIRTHDAYS]={0};

  inf.getline(inputLine, INPUT_LINE_LEN);
  while (!inf.eof())
    {
      // process the inputLine
      // specifically, use strtok to get the stuff

      char *userNamePtr = strtok(inputLine,",");
      char *firstNamePtr = strtok(NULL,",");
      char *monthPtr = strtok(NULL,",");
      char *dayPtr = strtok(NULL,",");


      // On Tuesday, add code to 
      // instantiate the class, and add 
      // birthday into the array

#ifdef DEBUG
      cout << inputLine << endl; // temporary to make sure we are reading ok
#endif // DEBUG


      inf.getline(inputLine, INPUT_LINE_LEN);
    }

}
