/*
   b_ptr_sigaction.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 Wednesday, May 23 at 12:22 AM EDT

TITLE
   b_ptr_sigaction.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_sigaction.h"

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


struct sigaction sigaction_temp;
void foo_handler1(int a){
}
void foo_action1(int sig, siginfo_t * b, void * c){
}
//--------------------------------------------------------------------

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

  //generated

   strcpy(_b_ptr_sigactionTYPENAME,CLASS_STRING);
strcpy(_b_ptr_sigactionNULL,"b_ptr_sigaction_NULL");
strcpy(_b_ptr_sigactionSIG_DFL,"b_ptr_sigaction_SIG_DFL");
strcpy(_b_ptr_sigactionSIG_IGN,"b_ptr_sigaction_SIG_IGN");
strcpy(_b_ptr_sigactionUSR_FUNC,"b_ptr_sigaction_USR_FUNC");
strcpy(_b_ptr_sigactionSIG_HOLD,"b_ptr_sigaction_SIG_HOLD");
strcpy(_b_ptr_sigactionSIG_ERR,"b_ptr_sigaction_SIG_ERR");
strcpy(_b_ptr_sigactionEMPTY,"b_ptr_sigaction_EMPTY");
strcpy(_b_ptr_sigactionFULL,"b_ptr_sigaction_FULL");
strcpy(_b_ptr_sigactionSIGABRT,"b_ptr_sigaction_SIGABRT");
strcpy(_b_ptr_sigactionSIGSEGV,"b_ptr_sigaction_SIGSEGV");
strcpy(_b_ptr_sigactionSIGINT,"b_ptr_sigaction_SIGINT");
strcpy(_b_ptr_sigactionSIGILL,"b_ptr_sigaction_SIGILL");
strcpy(_b_ptr_sigactionZERO,"b_ptr_sigaction_ZERO");
strcpy(_b_ptr_sigactionMAXINT,"b_ptr_sigaction_MAXINT");
strcpy(_b_ptr_sigactionSA_NOCLDSTOP_SET,"b_ptr_sigaction_SA_NOCLDSTOP_SET");
strcpy(_b_ptr_sigactionSA_SIGINFO_SET,"b_ptr_sigaction_SA_SIGINFO_SET");
strcpy(_b_ptr_sigactionSA_ONSTACK,"b_ptr_sigaction_SA_ONSTACK");
strcpy(_b_ptr_sigactionSA_RESTART,"b_ptr_sigaction_SA_RESTART");
strcpy(_b_ptr_sigactionSA_ALL,"b_ptr_sigaction_SA_ALL");
strcpy(_b_ptr_sigactionNO_EXTRA,"b_ptr_sigaction_NO_EXTRA");
strcpy(_b_ptr_sigactionSA_ZERO,"b_ptr_sigaction_SA_ZERO");
strcpy(_b_ptr_sigactionSA_MAXINT,"b_ptr_sigaction_SA_MAXINT");
strcpy(_b_ptr_sigactionACTION_NULL,"b_ptr_sigaction_ACTION_NULL");
strcpy(_b_ptr_sigactionACTION_USR_FUNC,"b_ptr_sigaction_ACTION_USR_FUNC");
}

//--------------------------------------------------------------------
b_param *b_ptr_sigaction::b_ptr_sigactionNULL()
{
   return &_b_ptr_sigactionNULL;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIG_DFL()
{
   return &_b_ptr_sigactionSIG_DFL;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIG_IGN()
{
   return &_b_ptr_sigactionSIG_IGN;
}

b_param *b_ptr_sigaction::b_ptr_sigactionUSR_FUNC()
{
   return &_b_ptr_sigactionUSR_FUNC;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIG_HOLD()
{
   return &_b_ptr_sigactionSIG_HOLD;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIG_ERR()
{
   return &_b_ptr_sigactionSIG_ERR;
}

b_param *b_ptr_sigaction::b_ptr_sigactionEMPTY()
{
   return &_b_ptr_sigactionEMPTY;
}

b_param *b_ptr_sigaction::b_ptr_sigactionFULL()
{
   return &_b_ptr_sigactionFULL;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIGABRT()
{
   return &_b_ptr_sigactionSIGABRT;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIGSEGV()
{
   return &_b_ptr_sigactionSIGSEGV;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIGINT()
{
   return &_b_ptr_sigactionSIGINT;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSIGILL()
{
   return &_b_ptr_sigactionSIGILL;
}

b_param *b_ptr_sigaction::b_ptr_sigactionZERO()
{
   return &_b_ptr_sigactionZERO;
}

b_param *b_ptr_sigaction::b_ptr_sigactionMAXINT()
{
   return &_b_ptr_sigactionMAXINT;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_NOCLDSTOP_SET()
{
   return &_b_ptr_sigactionSA_NOCLDSTOP_SET;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_SIGINFO_SET()
{
   return &_b_ptr_sigactionSA_SIGINFO_SET;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_ONSTACK()
{
   return &_b_ptr_sigactionSA_ONSTACK;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_RESTART()
{
   return &_b_ptr_sigactionSA_RESTART;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_ALL()
{
   return &_b_ptr_sigactionSA_ALL;
}

b_param *b_ptr_sigaction::b_ptr_sigactionNO_EXTRA()
{
   return &_b_ptr_sigactionNO_EXTRA;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_ZERO()
{
   return &_b_ptr_sigactionSA_ZERO;
}

b_param *b_ptr_sigaction::b_ptr_sigactionSA_MAXINT()
{
   return &_b_ptr_sigactionSA_MAXINT;
}

b_param *b_ptr_sigaction::b_ptr_sigactionACTION_NULL()
{
   return &_b_ptr_sigactionACTION_NULL;
}

b_param *b_ptr_sigaction::b_ptr_sigactionACTION_USR_FUNC()
{
   return &_b_ptr_sigactionACTION_USR_FUNC;
}

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

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

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
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_sigaction_null = 0;
b_ptr_sigaction_sig_dfl = 0;
b_ptr_sigaction_sig_ign = 0;
b_ptr_sigaction_usr_func = 0;
b_ptr_sigaction_sig_hold = 0;
b_ptr_sigaction_sig_err = 0;
b_ptr_sigaction_empty = 0;
b_ptr_sigaction_full = 0;
b_ptr_sigaction_sigabrt = 0;
b_ptr_sigaction_sigsegv = 0;
b_ptr_sigaction_sigint = 0;
b_ptr_sigaction_sigill = 0;
b_ptr_sigaction_zero = 0;
b_ptr_sigaction_maxint = 0;
b_ptr_sigaction_sa_nocldstop_set = 0;
b_ptr_sigaction_sa_siginfo_set = 0;
b_ptr_sigaction_sa_onstack = 0;
b_ptr_sigaction_sa_restart = 0;
b_ptr_sigaction_sa_all = 0;
b_ptr_sigaction_no_extra = 0;
b_ptr_sigaction_sa_zero = 0;
b_ptr_sigaction_sa_maxint = 0;
b_ptr_sigaction_action_null = 0;
b_ptr_sigaction_action_usr_func = 0;
   int dataPTR =0;


   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_sigactionNULL)==0)
      b_ptr_sigaction_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIG_DFL)==0)
      b_ptr_sigaction_sig_dfl = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIG_IGN)==0)
      b_ptr_sigaction_sig_ign = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionUSR_FUNC)==0)
      b_ptr_sigaction_usr_func = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIG_HOLD)==0)
      b_ptr_sigaction_sig_hold = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIG_ERR)==0)
      b_ptr_sigaction_sig_err = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"SA_HANDLER"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_sigactionEMPTY)==0)
      b_ptr_sigaction_empty = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionFULL)==0)
      b_ptr_sigaction_full = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIGABRT)==0)
      b_ptr_sigaction_sigabrt = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIGSEGV)==0)
      b_ptr_sigaction_sigsegv = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIGINT)==0)
      b_ptr_sigaction_sigint = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSIGILL)==0)
      b_ptr_sigaction_sigill = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionZERO)==0)
      b_ptr_sigaction_zero = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionMAXINT)==0)
      b_ptr_sigaction_maxint = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"SA_MASK"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_sigactionSA_NOCLDSTOP_SET)==0)
      b_ptr_sigaction_sa_nocldstop_set = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSA_SIGINFO_SET)==0)
      b_ptr_sigaction_sa_siginfo_set = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSA_ONSTACK)==0)
      b_ptr_sigaction_sa_onstack = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSA_RESTART)==0)
      b_ptr_sigaction_sa_restart = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSA_ALL)==0)
      b_ptr_sigaction_sa_all = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionNO_EXTRA)==0)
      b_ptr_sigaction_no_extra = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSA_ZERO)==0)
      b_ptr_sigaction_sa_zero = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionSA_MAXINT)==0)
      b_ptr_sigaction_sa_maxint = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"SA_FLAGS"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

   dataPTR++;
if (strcmp(data[dataPTR],_b_ptr_sigactionACTION_NULL)==0)
      b_ptr_sigaction_action_null = 1;
   else if (strcmp(data[dataPTR],_b_ptr_sigactionACTION_USR_FUNC)==0)
      b_ptr_sigaction_action_usr_func = 1;
  else
    {
      cerr<<"Error: Unknown setting for the "
          <<"SA_SIGACTION"
          <<" dial of the data object "
          <<CLASS_STRING
          <<". "<<endl
          <<"The offending string is : "
          <<data[dataPTR]
          <<endl;
      exit(1);
    }

 sigaction_temp.sa_flags = 0;
 sigaction_temp.sa_mask.__sigbits[0] = 0;
 sigaction_temp.sa_mask.__sigbits[1] = 0;
 sigaction_temp.sa_mask.__sigbits[2] = 0;
 sigaction_temp.sa_mask.__sigbits[3] = 0;

if (b_ptr_sigaction_null==1)
{

 sigaction_temp.sa_handler = NULL;
 
}

if (b_ptr_sigaction_sig_dfl==1)
{

 sigaction_temp.sa_handler = SIG_DFL;
 
}

if (b_ptr_sigaction_sig_ign==1)
{

 sigaction_temp.sa_handler = SIG_IGN;
 
}

if (b_ptr_sigaction_usr_func==1)
{

 sigaction_temp.sa_handler = foo_handler1;
 
}

if (b_ptr_sigaction_sig_hold==1)
{

 sigaction_temp.sa_handler = SIG_HOLD;
 
}

if (b_ptr_sigaction_sig_err==1)
{

 sigaction_temp.sa_handler = SIG_ERR;
 
}

if (b_ptr_sigaction_empty==1)
{

 if((sigemptyset (&sigaction_temp.sa_mask))!=0)
 {
 FILE* logFile = NULL;
 
 if ((logFile = fopen ("/tmp/templateLog.txt","a+")) == NULL)
 {
 exit(99);
 }
 fprintf (logFile, "b_ptr_sigaction - sigemptyset at EMPTY failed. Function not tested\n");
 fclose(logFile);
 exit(99);
 }
 
}

if (b_ptr_sigaction_full==1)
{

 if((sigfillset (&sigaction_temp.sa_mask))!=0)
 {
 FILE* logFile = NULL;
 
 if ((logFile = fopen ("/tmp/templateLog.txt","a+")) == NULL)
 {
 exit(99);
 }
 fprintf (logFile, "b_ptr_sigaction - sigfullset at FULL failed. Function not tested\n");
 fclose(logFile);
 exit(99);
 }
 
}

if (b_ptr_sigaction_sigabrt==1)
{

 sigaction_temp.sa_mask.__sigbits[0] = SIGABRT;
 
}

if (b_ptr_sigaction_sigsegv==1)
{

 sigaction_temp.sa_mask.__sigbits[0] = SIGSEGV;
 
}

if (b_ptr_sigaction_sigint==1)
{

 sigaction_temp.sa_mask.__sigbits[0] = SIGINT;
 
}

if (b_ptr_sigaction_sigill==1)
{

 sigaction_temp.sa_mask.__sigbits[0] = SIGILL;
 
}

if (b_ptr_sigaction_zero==1)
{

 sigaction_temp.sa_mask.__sigbits[0] = 0;
 
}

if (b_ptr_sigaction_maxint==1)
{

 sigaction_temp.sa_mask.__sigbits[0] = MAXINT;
 
}

if (b_ptr_sigaction_sa_nocldstop_set==1 || b_ptr_sigaction_sa_all==1)
{

 sigaction_temp.sa_flags |= SA_NOCLDSTOP;
 
}

if (b_ptr_sigaction_sa_siginfo_set==1 || b_ptr_sigaction_sa_all==1)
{

 sigaction_temp.sa_flags |= SA_SIGINFO;
 
}

if (b_ptr_sigaction_sa_onstack==1 || b_ptr_sigaction_sa_all==1)
{

 sigaction_temp.sa_flags |= SA_ONSTACK;
 
}

if (b_ptr_sigaction_sa_restart==1 || b_ptr_sigaction_sa_all==1)
{

 sigaction_temp.sa_flags |= SA_RESTART;
 
}

if (b_ptr_sigaction_sa_zero==1)
{

 sigaction_temp.sa_flags |= 0;
 
}

if (b_ptr_sigaction_sa_maxint==1)
{

 sigaction_temp.sa_flags |= MAXINT;
 
}

if (b_ptr_sigaction_sa_all==1)
{

 sigaction_temp.sa_flags |= SA_RESTART | SA_NODEFER | SA_RESETHAND | SA_NOCLDWAIT;
 
}

if (b_ptr_sigaction_action_null==1)
{

 sigaction_temp.sa_sigaction = NULL;
 
}

if (b_ptr_sigaction_action_usr_func==1)
{

 sigaction_temp.sa_sigaction = foo_action1;
 
}

 _theVariable = &sigaction_temp;
   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 6;
      break;

   case 2:
      return 8;
      break;

   case 3:
      return 8;
      break;

   case 4:
      return 2;
      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_sigactionNULL();
         break;
      case 2:
         return b_ptr_sigactionSIG_DFL();
         break;
      case 3:
         return b_ptr_sigactionSIG_IGN();
         break;
      case 4:
         return b_ptr_sigactionUSR_FUNC();
         break;
      case 5:
         return b_ptr_sigactionSIG_HOLD();
         break;
      case 6:
         return b_ptr_sigactionSIG_ERR();
         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_sigactionEMPTY();
         break;
      case 2:
         return b_ptr_sigactionFULL();
         break;
      case 3:
         return b_ptr_sigactionSIGABRT();
         break;
      case 4:
         return b_ptr_sigactionSIGSEGV();
         break;
      case 5:
         return b_ptr_sigactionSIGINT();
         break;
      case 6:
         return b_ptr_sigactionSIGILL();
         break;
      case 7:
         return b_ptr_sigactionZERO();
         break;
      case 8:
         return b_ptr_sigactionMAXINT();
         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_sigactionSA_NOCLDSTOP_SET();
         break;
      case 2:
         return b_ptr_sigactionSA_SIGINFO_SET();
         break;
      case 3:
         return b_ptr_sigactionSA_ONSTACK();
         break;
      case 4:
         return b_ptr_sigactionSA_RESTART();
         break;
      case 5:
         return b_ptr_sigactionSA_ALL();
         break;
      case 6:
         return b_ptr_sigactionNO_EXTRA();
         break;
      case 7:
         return b_ptr_sigactionSA_ZERO();
         break;
      case 8:
         return b_ptr_sigactionSA_MAXINT();
         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_sigactionACTION_NULL();
         break;
      case 2:
         return b_ptr_sigactionACTION_USR_FUNC();
         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;
}

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