/*
   b_ptr_utimbuf.cpp   Generated by the Ballista(tm) Project data object compiler
   Copyright (C) 1998-2001  Carnegie Mellon University

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

   File generated Tuesday, May 22 at 08:02 PM EDT

TITLE
   b_ptr_utimbuf.cpp
*/

//--------------------------------------------------------------------

#include <errno.h>
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <stream.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "b_ptr_utimbuf.h"

//--------------------------------------------------------------------


#define MIDNIGHT_2000 (2000-1970)*365*24*60*60 
#define YEAR 365*24*60*60
#define DAY 24*60*60
#define HOUR 60*60
#define MINUTE 60
static struct utimbuf tmp_utimbuf;
//--------------------------------------------------------------------

CLASSNAME::CLASSNAME()
{
  //DIAL DECLARATIONS HERE

  //generated

   strcpy(_b_ptr_utimbufTYPENAME,CLASS_STRING);
strcpy(_b_ptr_utimbufA_NOW,"b_ptr_utimbuf_A_NOW");
strcpy(_b_ptr_utimbufA_TOMORROW,"b_ptr_utimbuf_A_TOMORROW");
strcpy(_b_ptr_utimbufA_NEXTWEEK,"b_ptr_utimbuf_A_NEXTWEEK");
strcpy(_b_ptr_utimbufA_NEXTMONTH,"b_ptr_utimbuf_A_NEXTMONTH");
strcpy(_b_ptr_utimbufA_NEXTYEAR,"b_ptr_utimbuf_A_NEXTYEAR");
strcpy(_b_ptr_utimbufA_NEXTDECADE,"b_ptr_utimbuf_A_NEXTDECADE");
strcpy(_b_ptr_utimbufA_NEXTCENTURY,"b_ptr_utimbuf_A_NEXTCENTURY");
strcpy(_b_ptr_utimbufA_NEXTMILLENIUM,"b_ptr_utimbuf_A_NEXTMILLENIUM");
strcpy(_b_ptr_utimbufA_Y2K,"b_ptr_utimbuf_A_Y2K");
strcpy(_b_ptr_utimbufA_Y2K_MINUS_ONE,"b_ptr_utimbuf_A_Y2K_MINUS_ONE");
strcpy(_b_ptr_utimbufA_Y2K_PLUS_ONE,"b_ptr_utimbuf_A_Y2K_PLUS_ONE");
strcpy(_b_ptr_utimbufA_MAX,"b_ptr_utimbuf_A_MAX");
strcpy(_b_ptr_utimbufA_MIN,"b_ptr_utimbuf_A_MIN");
strcpy(_b_ptr_utimbufM_NOW,"b_ptr_utimbuf_M_NOW");
strcpy(_b_ptr_utimbufM_TOMORROW,"b_ptr_utimbuf_M_TOMORROW");
strcpy(_b_ptr_utimbufM_NEXTWEEK,"b_ptr_utimbuf_M_NEXTWEEK");
strcpy(_b_ptr_utimbufM_NEXTMONTH,"b_ptr_utimbuf_M_NEXTMONTH");
strcpy(_b_ptr_utimbufM_NEXTYEAR,"b_ptr_utimbuf_M_NEXTYEAR");
strcpy(_b_ptr_utimbufM_NEXTDECADE,"b_ptr_utimbuf_M_NEXTDECADE");
strcpy(_b_ptr_utimbufM_NEXTCENTURY,"b_ptr_utimbuf_M_NEXTCENTURY");
strcpy(_b_ptr_utimbufM_NEXTMILLENIUM,"b_ptr_utimbuf_M_NEXTMILLENIUM");
strcpy(_b_ptr_utimbufM_Y2K,"b_ptr_utimbuf_M_Y2K");
strcpy(_b_ptr_utimbufM_Y2K_MINUS_ONE,"b_ptr_utimbuf_M_Y2K_MINUS_ONE");
strcpy(_b_ptr_utimbufM_Y2K_PLUS_ONE,"b_ptr_utimbuf_M_Y2K_PLUS_ONE");
strcpy(_b_ptr_utimbufM_MAX,"b_ptr_utimbuf_M_MAX");
strcpy(_b_ptr_utimbufM_MIN,"b_ptr_utimbuf_M_MIN");
}

//--------------------------------------------------------------------
b_param *b_ptr_utimbuf::b_ptr_utimbufA_NOW()
{
   return &_b_ptr_utimbufA_NOW;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_TOMORROW()
{
   return &_b_ptr_utimbufA_TOMORROW;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_NEXTWEEK()
{
   return &_b_ptr_utimbufA_NEXTWEEK;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_NEXTMONTH()
{
   return &_b_ptr_utimbufA_NEXTMONTH;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_NEXTYEAR()
{
   return &_b_ptr_utimbufA_NEXTYEAR;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_NEXTDECADE()
{
   return &_b_ptr_utimbufA_NEXTDECADE;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_NEXTCENTURY()
{
   return &_b_ptr_utimbufA_NEXTCENTURY;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_NEXTMILLENIUM()
{
   return &_b_ptr_utimbufA_NEXTMILLENIUM;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_Y2K()
{
   return &_b_ptr_utimbufA_Y2K;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_Y2K_MINUS_ONE()
{
   return &_b_ptr_utimbufA_Y2K_MINUS_ONE;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_Y2K_PLUS_ONE()
{
   return &_b_ptr_utimbufA_Y2K_PLUS_ONE;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_MAX()
{
   return &_b_ptr_utimbufA_MAX;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufA_MIN()
{
   return &_b_ptr_utimbufA_MIN;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NOW()
{
   return &_b_ptr_utimbufM_NOW;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_TOMORROW()
{
   return &_b_ptr_utimbufM_TOMORROW;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NEXTWEEK()
{
   return &_b_ptr_utimbufM_NEXTWEEK;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NEXTMONTH()
{
   return &_b_ptr_utimbufM_NEXTMONTH;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NEXTYEAR()
{
   return &_b_ptr_utimbufM_NEXTYEAR;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NEXTDECADE()
{
   return &_b_ptr_utimbufM_NEXTDECADE;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NEXTCENTURY()
{
   return &_b_ptr_utimbufM_NEXTCENTURY;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_NEXTMILLENIUM()
{
   return &_b_ptr_utimbufM_NEXTMILLENIUM;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_Y2K()
{
   return &_b_ptr_utimbufM_Y2K;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_Y2K_MINUS_ONE()
{
   return &_b_ptr_utimbufM_Y2K_MINUS_ONE;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_Y2K_PLUS_ONE()
{
   return &_b_ptr_utimbufM_Y2K_PLUS_ONE;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_MAX()
{
   return &_b_ptr_utimbufM_MAX;
}

b_param *b_ptr_utimbuf::b_ptr_utimbufM_MIN()
{
   return &_b_ptr_utimbufM_MIN;
}

//--------------------------------------------------------------------
//---------------------------------------------------------------------------
//type name return method

b_param *CLASSNAME::typeName()
{
  return &_b_ptr_utimbufTYPENAME;
}

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int CLASSNAME::distanceFromBase()
{
  return CLASSPARENT::distanceFromBase() +1;
}


//---------------------------------------------------------------------------
void CLASSNAME::typeList(b_param list[], int num)
{
  strcpy(list[num],(char *) typeName());
  CLASSPARENT::typeList(list,num+1);
}
//--------------------------------------------------------------------
  void *CLASSNAME::access(b_param data[])
{
  if (strcmp(data[0],(char *)typeName())!=0)
    return CLASSPARENT::access(data);

  //ACCESS CODE
b_ptr_utimbuf_a_now = 0;
b_ptr_utimbuf_a_tomorrow = 0;
b_ptr_utimbuf_a_nextweek = 0;
b_ptr_utimbuf_a_nextmonth = 0;
b_ptr_utimbuf_a_nextyear = 0;
b_ptr_utimbuf_a_nextdecade = 0;
b_ptr_utimbuf_a_nextcentury = 0;
b_ptr_utimbuf_a_nextmillenium = 0;
b_ptr_utimbuf_a_y2k = 0;
b_ptr_utimbuf_a_y2k_minus_one = 0;
b_ptr_utimbuf_a_y2k_plus_one = 0;
b_ptr_utimbuf_a_max = 0;
b_ptr_utimbuf_a_min = 0;
b_ptr_utimbuf_m_now = 0;
b_ptr_utimbuf_m_tomorrow = 0;
b_ptr_utimbuf_m_nextweek = 0;
b_ptr_utimbuf_m_nextmonth = 0;
b_ptr_utimbuf_m_nextyear = 0;
b_ptr_utimbuf_m_nextdecade = 0;
b_ptr_utimbuf_m_nextcentury = 0;
b_ptr_utimbuf_m_nextmillenium = 0;
b_ptr_utimbuf_m_y2k = 0;
b_ptr_utimbuf_m_y2k_minus_one = 0;
b_ptr_utimbuf_m_y2k_plus_one = 0;
b_ptr_utimbuf_m_max = 0;
b_ptr_utimbuf_m_min = 0;
   int dataPTR =0;


   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utimbufA_NOW)==0)
      b_ptr_utimbuf_a_now = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_TOMORROW)==0)
      b_ptr_utimbuf_a_tomorrow = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_NEXTWEEK)==0)
      b_ptr_utimbuf_a_nextweek = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_NEXTMONTH)==0)
      b_ptr_utimbuf_a_nextmonth = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_NEXTYEAR)==0)
      b_ptr_utimbuf_a_nextyear = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_NEXTDECADE)==0)
      b_ptr_utimbuf_a_nextdecade = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_NEXTCENTURY)==0)
      b_ptr_utimbuf_a_nextcentury = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_NEXTMILLENIUM)==0)
      b_ptr_utimbuf_a_nextmillenium = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_Y2K)==0)
      b_ptr_utimbuf_a_y2k = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_Y2K_MINUS_ONE)==0)
      b_ptr_utimbuf_a_y2k_minus_one = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_Y2K_PLUS_ONE)==0)
      b_ptr_utimbuf_a_y2k_plus_one = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_MAX)==0)
      b_ptr_utimbuf_a_max = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufA_MIN)==0)
      b_ptr_utimbuf_a_min = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"ACTIME"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utimbufM_NOW)==0)
      b_ptr_utimbuf_m_now = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_TOMORROW)==0)
      b_ptr_utimbuf_m_tomorrow = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_NEXTWEEK)==0)
      b_ptr_utimbuf_m_nextweek = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_NEXTMONTH)==0)
      b_ptr_utimbuf_m_nextmonth = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_NEXTYEAR)==0)
      b_ptr_utimbuf_m_nextyear = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_NEXTDECADE)==0)
      b_ptr_utimbuf_m_nextdecade = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_NEXTCENTURY)==0)
      b_ptr_utimbuf_m_nextcentury = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_NEXTMILLENIUM)==0)
      b_ptr_utimbuf_m_nextmillenium = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_Y2K)==0)
      b_ptr_utimbuf_m_y2k = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_Y2K_MINUS_ONE)==0)
      b_ptr_utimbuf_m_y2k_minus_one = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_Y2K_PLUS_ONE)==0)
      b_ptr_utimbuf_m_y2k_plus_one = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_MAX)==0)
      b_ptr_utimbuf_m_max = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utimbufM_MIN)==0)
      b_ptr_utimbuf_m_min = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"MODTIME"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

tmp_utimbuf.actime = time(NULL);
tmp_utimbuf.modtime = time(NULL);

if (b_ptr_utimbuf_a_now==1)
{

 
}

if (b_ptr_utimbuf_a_tomorrow==1)
{

 tmp_utimbuf.actime += DAY;
 
}

if (b_ptr_utimbuf_a_nextweek==1)
{

 tmp_utimbuf.actime += (DAY*7);
 
}

if (b_ptr_utimbuf_a_nextmonth==1)
{

 tmp_utimbuf.actime += (DAY*30);
 
}

if (b_ptr_utimbuf_a_nextyear==1)
{

 tmp_utimbuf.actime += YEAR;
 
}

if (b_ptr_utimbuf_a_nextdecade==1)
{

 tmp_utimbuf.actime += (YEAR*10);
 
}

if (b_ptr_utimbuf_a_nextcentury==1)
{

 tmp_utimbuf.actime += (YEAR*100);
 
}

if (b_ptr_utimbuf_a_nextmillenium==1)
{

 tmp_utimbuf.actime += (YEAR*1000);
 
}

if (b_ptr_utimbuf_a_y2k==1)
{

 tmp_utimbuf.actime = MIDNIGHT_2000;
 
}

if (b_ptr_utimbuf_a_y2k_minus_one==1)
{

 tmp_utimbuf.actime = MIDNIGHT_2000-1;
 
}

if (b_ptr_utimbuf_a_y2k_plus_one==1)
{

 tmp_utimbuf.actime = MIDNIGHT_2000+1;
 
}

if (b_ptr_utimbuf_a_max==1)
{

 tmp_utimbuf.actime = MAXINT;
 
}

if (b_ptr_utimbuf_a_min==1)
{

 tmp_utimbuf.actime = - MAXINT;
 
}

if (b_ptr_utimbuf_m_now==1)
{

 
}

if (b_ptr_utimbuf_m_tomorrow==1)
{

 tmp_utimbuf.modtime += DAY;
 
}

if (b_ptr_utimbuf_m_nextweek==1)
{

 tmp_utimbuf.modtime += (DAY*7);
 
}

if (b_ptr_utimbuf_m_nextmonth==1)
{

 tmp_utimbuf.modtime += (DAY*30);
 
}

if (b_ptr_utimbuf_m_nextyear==1)
{

 tmp_utimbuf.modtime += YEAR;
 
}

if (b_ptr_utimbuf_m_nextdecade==1)
{

 tmp_utimbuf.modtime += (YEAR*10);
 
}

if (b_ptr_utimbuf_m_nextcentury==1)
{

 tmp_utimbuf.modtime += (YEAR*100);
 
}

if (b_ptr_utimbuf_m_nextmillenium==1)
{

 tmp_utimbuf.modtime += (YEAR*1000);
 
}

if (b_ptr_utimbuf_m_y2k==1)
{

 tmp_utimbuf.modtime = MIDNIGHT_2000;
 
}

if (b_ptr_utimbuf_m_y2k_minus_one==1)
{

 tmp_utimbuf.modtime = MIDNIGHT_2000-1;
 
}

if (b_ptr_utimbuf_m_y2k_plus_one==1)
{

 tmp_utimbuf.modtime = MIDNIGHT_2000+1;
 
}

if (b_ptr_utimbuf_m_max==1)
{

 tmp_utimbuf.modtime = MAXINT;
 
}

if (b_ptr_utimbuf_m_min==1)
{

 tmp_utimbuf.modtime = - MAXINT;
 
}

 _theVariable = &tmp_utimbuf;
   return &_theVariable;
}

//--------------------------------------------------------------------
  int CLASSNAME::commit(b_param tname)
{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::commit(tname);
  //COMMIT CODE HERE
//generated

   return 0;
}

//--------------------------------------------------------------------
  int CLASSNAME::cleanup(b_param tname)
{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::cleanup(tname);
      
  //CLEANUP CODE
//generated

   return 0;
}

//--------------------------------------------------------------------
int CLASSNAME::numDials(b_param tname)
{
  if (!strcmp(tname,(char *)typeName()))
    return NUMBER_OF_DIALS;
  else return CLASSPARENT::numDials(tname);
      
}


//---------------------------------------------------------------------------
int CLASSNAME::numItems(b_param tname,int dialNumber)
{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::numItems(tname,dialNumber);
  switch (dialNumber)
    {
      //NUMITEMS SWITCH CASES HERE
      //generated

   case 1:
      return 13;
      break;

   case 2:
      return 13;
      break;
//---------------------------------------------------------------------------
      //end generated

    default:
      cerr<<"Error, invalid dial number passed to "
          <<CLASS_STRING<<"::numItems\n"
          <<"Please check declaration files.  Dial number passed was "
          <<dialNumber<<endl;
      exit(1);
    }
  return 0;
}

//---------------------------------------------------------------------------
b_param *CLASSNAME::paramName(b_param tname,
                                   int dialNumber,
                                   int position)

{
  if (strcmp(tname,(char *)typeName())!=0)
    return CLASSPARENT::paramName(tname,dialNumber,position);
  
  switch (dialNumber)
    {
      //PARAMNAME SWITCH CASES HERE
      //generated

case 1:
 switch (position)
   {
      case 1:
         return b_ptr_utimbufA_NOW();
         break;
      case 2:
         return b_ptr_utimbufA_TOMORROW();
         break;
      case 3:
         return b_ptr_utimbufA_NEXTWEEK();
         break;
      case 4:
         return b_ptr_utimbufA_NEXTMONTH();
         break;
      case 5:
         return b_ptr_utimbufA_NEXTYEAR();
         break;
      case 6:
         return b_ptr_utimbufA_NEXTDECADE();
         break;
      case 7:
         return b_ptr_utimbufA_NEXTCENTURY();
         break;
      case 8:
         return b_ptr_utimbufA_NEXTMILLENIUM();
         break;
      case 9:
         return b_ptr_utimbufA_Y2K();
         break;
      case 10:
         return b_ptr_utimbufA_Y2K_MINUS_ONE();
         break;
      case 11:
         return b_ptr_utimbufA_Y2K_PLUS_ONE();
         break;
      case 12:
         return b_ptr_utimbufA_MAX();
         break;
      case 13:
         return b_ptr_utimbufA_MIN();
         break;

      default:
          cerr<<"Error, invalid position number passed to "
              <<CLASS_STRING<<"::paramName\n"
              <<"Please check declaration files.  Dial number passed was"
              <<dialNumber<<" position "<<position<<".\n";
          exit(1);
   }
   break;

case 2:
 switch (position)
   {
      case 1:
         return b_ptr_utimbufM_NOW();
         break;
      case 2:
         return b_ptr_utimbufM_TOMORROW();
         break;
      case 3:
         return b_ptr_utimbufM_NEXTWEEK();
         break;
      case 4:
         return b_ptr_utimbufM_NEXTMONTH();
         break;
      case 5:
         return b_ptr_utimbufM_NEXTYEAR();
         break;
      case 6:
         return b_ptr_utimbufM_NEXTDECADE();
         break;
      case 7:
         return b_ptr_utimbufM_NEXTCENTURY();
         break;
      case 8:
         return b_ptr_utimbufM_NEXTMILLENIUM();
         break;
      case 9:
         return b_ptr_utimbufM_Y2K();
         break;
      case 10:
         return b_ptr_utimbufM_Y2K_MINUS_ONE();
         break;
      case 11:
         return b_ptr_utimbufM_Y2K_PLUS_ONE();
         break;
      case 12:
         return b_ptr_utimbufM_MAX();
         break;
      case 13:
         return b_ptr_utimbufM_MIN();
         break;

      default:
          cerr<<"Error, invalid position number passed to "
              <<CLASS_STRING<<"::paramName\n"
              <<"Please check declaration files.  Dial number passed was"
              <<dialNumber<<" position "<<position<<".\n";
          exit(1);
   }
   break;
    default:
      cerr<<"Error, invalid dial number passed to "
          <<CLASS_STRING<<"::paramName\n"
          <<"Please check declaration files.  Dial number passed was "
          <<dialNumber<<endl;
      exit(1);

    }
  return NULL;
}

//---------------------------------------------------------------------------
