/*
   b_ptr_utsname.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 11:32 PM EDT

TITLE
   b_ptr_utsname.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_utsname.h"

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


static struct utsname utsname_temp ;
//--------------------------------------------------------------------

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

  //generated

   strcpy(_b_ptr_utsnameTYPENAME,CLASS_STRING);
strcpy(_b_ptr_utsnameS_NULL,"b_ptr_utsname_S_NULL");
strcpy(_b_ptr_utsnameS_SIZE1,"b_ptr_utsname_S_SIZE1");
strcpy(_b_ptr_utsnameS_SYS_NMLN,"b_ptr_utsname_S_SYS_NMLN");
strcpy(_b_ptr_utsnameS_SELF,"b_ptr_utsname_S_SELF");
strcpy(_b_ptr_utsnameN_NULL,"b_ptr_utsname_N_NULL");
strcpy(_b_ptr_utsnameN_SIZE1,"b_ptr_utsname_N_SIZE1");
strcpy(_b_ptr_utsnameN_SYS_NMLN,"b_ptr_utsname_N_SYS_NMLN");
strcpy(_b_ptr_utsnameN_SELF,"b_ptr_utsname_N_SELF");
strcpy(_b_ptr_utsnameR_NULL,"b_ptr_utsname_R_NULL");
strcpy(_b_ptr_utsnameR_SIZE1,"b_ptr_utsname_R_SIZE1");
strcpy(_b_ptr_utsnameR_SYS_NMLN,"b_ptr_utsname_R_SYS_NMLN");
strcpy(_b_ptr_utsnameR_SELF,"b_ptr_utsname_R_SELF");
strcpy(_b_ptr_utsnameV_NULL,"b_ptr_utsname_V_NULL");
strcpy(_b_ptr_utsnameV_SIZE1,"b_ptr_utsname_V_SIZE1");
strcpy(_b_ptr_utsnameV_SYS_NMLN,"b_ptr_utsname_V_SYS_NMLN");
strcpy(_b_ptr_utsnameV_SELF,"b_ptr_utsname_V_SELF");
strcpy(_b_ptr_utsnameM_NULL,"b_ptr_utsname_M_NULL");
strcpy(_b_ptr_utsnameM_SIZE1,"b_ptr_utsname_M_SIZE1");
strcpy(_b_ptr_utsnameM_SYS_NMLN,"b_ptr_utsname_M_SYS_NMLN");
strcpy(_b_ptr_utsnameM_SELF,"b_ptr_utsname_M_SELF");
}

//--------------------------------------------------------------------
b_param *b_ptr_utsname::b_ptr_utsnameS_NULL()
{
   return &_b_ptr_utsnameS_NULL;
}

b_param *b_ptr_utsname::b_ptr_utsnameS_SIZE1()
{
   return &_b_ptr_utsnameS_SIZE1;
}

b_param *b_ptr_utsname::b_ptr_utsnameS_SYS_NMLN()
{
   return &_b_ptr_utsnameS_SYS_NMLN;
}

b_param *b_ptr_utsname::b_ptr_utsnameS_SELF()
{
   return &_b_ptr_utsnameS_SELF;
}

b_param *b_ptr_utsname::b_ptr_utsnameN_NULL()
{
   return &_b_ptr_utsnameN_NULL;
}

b_param *b_ptr_utsname::b_ptr_utsnameN_SIZE1()
{
   return &_b_ptr_utsnameN_SIZE1;
}

b_param *b_ptr_utsname::b_ptr_utsnameN_SYS_NMLN()
{
   return &_b_ptr_utsnameN_SYS_NMLN;
}

b_param *b_ptr_utsname::b_ptr_utsnameN_SELF()
{
   return &_b_ptr_utsnameN_SELF;
}

b_param *b_ptr_utsname::b_ptr_utsnameR_NULL()
{
   return &_b_ptr_utsnameR_NULL;
}

b_param *b_ptr_utsname::b_ptr_utsnameR_SIZE1()
{
   return &_b_ptr_utsnameR_SIZE1;
}

b_param *b_ptr_utsname::b_ptr_utsnameR_SYS_NMLN()
{
   return &_b_ptr_utsnameR_SYS_NMLN;
}

b_param *b_ptr_utsname::b_ptr_utsnameR_SELF()
{
   return &_b_ptr_utsnameR_SELF;
}

b_param *b_ptr_utsname::b_ptr_utsnameV_NULL()
{
   return &_b_ptr_utsnameV_NULL;
}

b_param *b_ptr_utsname::b_ptr_utsnameV_SIZE1()
{
   return &_b_ptr_utsnameV_SIZE1;
}

b_param *b_ptr_utsname::b_ptr_utsnameV_SYS_NMLN()
{
   return &_b_ptr_utsnameV_SYS_NMLN;
}

b_param *b_ptr_utsname::b_ptr_utsnameV_SELF()
{
   return &_b_ptr_utsnameV_SELF;
}

b_param *b_ptr_utsname::b_ptr_utsnameM_NULL()
{
   return &_b_ptr_utsnameM_NULL;
}

b_param *b_ptr_utsname::b_ptr_utsnameM_SIZE1()
{
   return &_b_ptr_utsnameM_SIZE1;
}

b_param *b_ptr_utsname::b_ptr_utsnameM_SYS_NMLN()
{
   return &_b_ptr_utsnameM_SYS_NMLN;
}

b_param *b_ptr_utsname::b_ptr_utsnameM_SELF()
{
   return &_b_ptr_utsnameM_SELF;
}

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

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

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
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_utsname_s_null = 0;
b_ptr_utsname_s_size1 = 0;
b_ptr_utsname_s_sys_nmln = 0;
b_ptr_utsname_s_self = 0;
b_ptr_utsname_n_null = 0;
b_ptr_utsname_n_size1 = 0;
b_ptr_utsname_n_sys_nmln = 0;
b_ptr_utsname_n_self = 0;
b_ptr_utsname_r_null = 0;
b_ptr_utsname_r_size1 = 0;
b_ptr_utsname_r_sys_nmln = 0;
b_ptr_utsname_r_self = 0;
b_ptr_utsname_v_null = 0;
b_ptr_utsname_v_size1 = 0;
b_ptr_utsname_v_sys_nmln = 0;
b_ptr_utsname_v_self = 0;
b_ptr_utsname_m_null = 0;
b_ptr_utsname_m_size1 = 0;
b_ptr_utsname_m_sys_nmln = 0;
b_ptr_utsname_m_self = 0;
   int dataPTR =0;


   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utsnameS_NULL)==0)
      b_ptr_utsname_s_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameS_SIZE1)==0)
      b_ptr_utsname_s_size1 = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameS_SYS_NMLN)==0)
      b_ptr_utsname_s_sys_nmln = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameS_SELF)==0)
      b_ptr_utsname_s_self = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"SYSNAME"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utsnameN_NULL)==0)
      b_ptr_utsname_n_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameN_SIZE1)==0)
      b_ptr_utsname_n_size1 = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameN_SYS_NMLN)==0)
      b_ptr_utsname_n_sys_nmln = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameN_SELF)==0)
      b_ptr_utsname_n_self = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"NODENAME"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utsnameR_NULL)==0)
      b_ptr_utsname_r_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameR_SIZE1)==0)
      b_ptr_utsname_r_size1 = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameR_SYS_NMLN)==0)
      b_ptr_utsname_r_sys_nmln = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameR_SELF)==0)
      b_ptr_utsname_r_self = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"RELEASE"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utsnameV_NULL)==0)
      b_ptr_utsname_v_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameV_SIZE1)==0)
      b_ptr_utsname_v_size1 = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameV_SYS_NMLN)==0)
      b_ptr_utsname_v_sys_nmln = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameV_SELF)==0)
      b_ptr_utsname_v_self = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"VERSION"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_utsnameM_NULL)==0)
      b_ptr_utsname_m_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameM_SIZE1)==0)
      b_ptr_utsname_m_size1 = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameM_SYS_NMLN)==0)
      b_ptr_utsname_m_sys_nmln = 1;
   else if (strcmp(data[dataPTR],_b_ptr_utsnameM_SELF)==0)
      b_ptr_utsname_m_self = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"MACHINE"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

 
 FILE* logFile = NULL;
 if ((logFile = fopen ("/tmp/templateLog.txt","a+")) == NULL)
 {
 exit(99);
 }

if (b_ptr_utsname_s_self==1)
{

 struct utsname utsname_self;
 if(!(uname(&utsname_self) ==0))
 {
 fprintf(logFile, "b_ptr_utsname - S_SELF error occurred in uname function not tested.\n");
 fclose(logFile);
 exit(99);
 }
 strcpy (utsname_temp.sysname, utsname_self.sysname);
 
}

if (b_ptr_utsname_s_null==1)
{

 utsname_temp.sysname[0] = '\0';
 
}

if (b_ptr_utsname_s_size1==1)
{

 utsname_temp.sysname[0] = 'a';
 utsname_temp.sysname[1] = '\0';
 
}

if (b_ptr_utsname_s_sys_nmln==1)
{
 
 int i;
 for (i=0; i<SYS_NMLN; i++)
 {
 utsname_temp.sysname[i] = 'a'; 
 }
 
}

if (b_ptr_utsname_n_self==1)
{

 struct utsname utsname_self;
 if(!(uname(&utsname_self) ==0)) 
 {
 fprintf(logFile, "b_ptr_utsname - N_SELF error occurred in uname function not tested.\n");
 fclose(logFile);
 exit(99);
 }
 strcpy (utsname_temp.nodename, utsname_self.nodename);
 
}

if (b_ptr_utsname_n_null==1)
{

 utsname_temp.nodename[0] = '\0';
 
}

if (b_ptr_utsname_n_size1==1)
{

 utsname_temp.nodename[0] = 'a';
 utsname_temp.nodename[1] = '\0';
 
}

if (b_ptr_utsname_n_sys_nmln==1)
{

 int i;
 for (i=0; i<SYS_NMLN; i++)
 {
 utsname_temp.nodename[i] = 'a';
 }
 
}

if (b_ptr_utsname_r_self==1)
{

 struct utsname utsname_self;
 if(!(uname(&utsname_self) ==0)) 
 {
 fprintf(logFile, "b_ptr_utsname - R_SELF error occurred in uname function not tested.\n");
 fclose(logFile);
 exit(99);
 }
 strcpy (utsname_temp.release, utsname_self.release);
 
}

if (b_ptr_utsname_r_null==1)
{

 utsname_temp.release[0] ='\0';
 
}

if (b_ptr_utsname_r_size1==1)
{

 utsname_temp.release[0] ='a';
 utsname_temp.release[1] ='\0';
 
}

if (b_ptr_utsname_r_sys_nmln==1)
{

 int i;
 for (i=0; i<SYS_NMLN; i++)
 {
 utsname_temp.release[i] = 'a'; 
 }
 
}

if (b_ptr_utsname_v_self==1)
{

 struct utsname utsname_self;
 if(!(uname(&utsname_self) ==0)) 
 {
 fprintf(logFile, "b_ptr_utsname - V_SELF error occurred in uname function not tested.\n");
 fclose(logFile);
 exit(99);
 }
 strcpy (utsname_temp.version, utsname_self.version);
 
}

if (b_ptr_utsname_v_null==1)
{

 utsname_temp.version[0] = '\0';
 
}

if (b_ptr_utsname_v_size1==1)
{

 utsname_temp.version[0] = 'a';
 utsname_temp.version[1] = '\0';
 
}

if (b_ptr_utsname_v_sys_nmln==1)
{

 int i;
 for (i=0; i<SYS_NMLN; i++)
 {
 utsname_temp.version[i] = 'a'; 
 }
 
}

if (b_ptr_utsname_m_self==1)
{

 struct utsname utsname_self;
 if(!(uname(&utsname_self) ==0)) 
 {
 fprintf(logFile, "b_ptr_utsname - M_SELF error occurred in uname function not tested.\n");
 fclose(logFile);
 exit(99);
 }
 strcpy (utsname_temp.machine, utsname_self.machine);
 
}

if (b_ptr_utsname_m_null==1)
{

 utsname_temp.machine[0] = '\0';
 
}

if (b_ptr_utsname_m_size1==1)
{

 utsname_temp.machine[0] = 'a';
 utsname_temp.machine[1] = '\0';
 
}

if (b_ptr_utsname_m_sys_nmln==1)
{

 int i;
 for (i=0; i<SYS_NMLN; i++)
 {
 utsname_temp.machine[i] = 'a'; 
 }
 
}

 _theVariable = &utsname_temp;
 fclose(logFile);
   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 4;
      break;

   case 2:
      return 4;
      break;

   case 3:
      return 4;
      break;

   case 4:
      return 4;
      break;

   case 5:
      return 4;
      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_utsnameS_NULL();
         break;
      case 2:
         return b_ptr_utsnameS_SIZE1();
         break;
      case 3:
         return b_ptr_utsnameS_SYS_NMLN();
         break;
      case 4:
         return b_ptr_utsnameS_SELF();
         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_utsnameN_NULL();
         break;
      case 2:
         return b_ptr_utsnameN_SIZE1();
         break;
      case 3:
         return b_ptr_utsnameN_SYS_NMLN();
         break;
      case 4:
         return b_ptr_utsnameN_SELF();
         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 3:
 switch (position)
   {
      case 1:
         return b_ptr_utsnameR_NULL();
         break;
      case 2:
         return b_ptr_utsnameR_SIZE1();
         break;
      case 3:
         return b_ptr_utsnameR_SYS_NMLN();
         break;
      case 4:
         return b_ptr_utsnameR_SELF();
         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 4:
 switch (position)
   {
      case 1:
         return b_ptr_utsnameV_NULL();
         break;
      case 2:
         return b_ptr_utsnameV_SIZE1();
         break;
      case 3:
         return b_ptr_utsnameV_SYS_NMLN();
         break;
      case 4:
         return b_ptr_utsnameV_SELF();
         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 5:
 switch (position)
   {
      case 1:
         return b_ptr_utsnameM_NULL();
         break;
      case 2:
         return b_ptr_utsnameM_SIZE1();
         break;
      case 3:
         return b_ptr_utsnameM_SYS_NMLN();
         break;
      case 4:
         return b_ptr_utsnameM_SELF();
         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;
}

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