void C_Scenario::set_size (size_t P_size) {
  GEN_DEBUG(1, "C_Scenario::set_size() start");
  m_sequence_size = P_size ;
  ALLOC_TABLE(m_cmd_sequence, T_pCmd_scenario, 
	      sizeof(T_cmd_scenario), m_sequence_size);
  GEN_DEBUG(1, "C_Scenario::set_size() end");
}
int C_ProtocolBinaryBodyNotInterpreted::get_header_body_values_from_xml (C_XmlData *P_def) {

  int                       L_ret = 0                                      ;
  C_XmlData                *L_data                                         ;
  char                     *L_value, *L_name, *L_type, *L_endstr           ;
  char                     *L_value_unit, *L_value_size, *L_value_position ;
  T_XmlData_List::iterator  L_listIt                                       ;
  T_pXmlData_List           L_subListDefine                                ;
  int                       L_id                                           ;
  T_IdMap::iterator         L_IdMapIt                                      ;
  int                       L_typeId                                       ;
  int                       L_fieldDefCpt                                  ;

  unsigned long             L_size                                         ;
  unsigned long             L_position                                     ;

  T_HeaderBodyPositionSize  L_position_size                                ;



  GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::get_header_body_values_from_xml() start");


  m_nb_header_body_values++ ;
  
  ALLOC_TABLE(m_header_body_value_table,
              T_pHeaderBodyValue,
              sizeof(T_HeaderBodyValue),
              m_nb_header_body_values);
  
  L_id = 0 ;
  L_position = 0 ;
  L_typeId = 0 ;
  L_size = 0 ;
  
  L_fieldDefCpt = 0;
  L_subListDefine = P_def->get_sub_data() ;
  
  
  m_header_body_value_id_map
    ->insert(T_IdMap::value_type((char*)"body", L_id));
  
  m_header_body_value_table[L_id].m_id = L_id ;
  m_header_body_value_table[L_id].m_name = (char*)"body" ;
  m_header_body_value_table[L_id].m_type_id = L_typeId ;
  m_header_body_value_table[L_id].m_nb_set=0;
  
  L_position_size.m_position = L_position ;
  L_position_size.m_size = L_size ;
  
  m_header_body_decode_map
    ->insert(T_DecodeMap::value_type(L_position, L_id));

  
  m_header_body_position_size_map
    ->insert(T_HeaderBodyPositionSizeMap::value_type(L_id, L_position_size));
  
  
  L_id ++ ;
  
  if (m_use_open_id) {
    m_session_id_id += L_id ;
  }

  for(L_listIt  = L_subListDefine->begin() ;
      L_listIt != L_subListDefine->end() ;
      L_listIt++,  L_fieldDefCpt ++) {

    L_position = 0 ;
    L_typeId = 0 ;
    L_size = 0 ;

    L_data = *L_listIt ;
    L_value = L_data->get_name() ;

    if (strcmp(L_value, (char*)"define") == 0) {

      L_name = L_data->find_value((char*)"name") ;
      if (L_name == NULL) {
	GEN_ERROR(E_GEN_FATAL_ERROR, "define name value is mandatory");
	L_ret = -1 ;
	break ;
      } 

      L_type = L_data->find_value((char*)"type") ;
      if (L_type == NULL) {
	GEN_ERROR(E_GEN_FATAL_ERROR, "define type value is mandatory");
	L_ret = -1 ;
	break ;
      }
      L_IdMapIt = 
	m_type_id_map->find(T_IdMap::key_type(L_type));
      
      if (L_IdMapIt != m_type_id_map->end()) {
	L_typeId = L_IdMapIt->second ;
      } else {
	GEN_ERROR(E_GEN_FATAL_ERROR, 
	      "Type ["
	      << L_type << "] not defined");
	L_ret = -1 ;
	break;
      }


      L_value_position = L_data->find_value((char*)"position") ;
      if (L_value_position == NULL) {
	GEN_ERROR(E_GEN_FATAL_ERROR, "define position value is mandatory");
	L_ret = -1 ;
	break ;
      } 


      L_position = (int)strtoul_f (L_value_position, &L_endstr, 10);
      if (L_endstr[0] != '\0') {
        GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
                  << L_value_position << "] not a number");
        L_ret = -1 ;
        break;
      }
      
      
      L_value_unit = L_data->find_value((char*)"unit") ;
      if (L_value_unit != NULL) {
        if (strcmp(L_value_unit, (char*)"octet") != 0) {
	  GEN_ERROR(E_GEN_FATAL_ERROR, "Unsupported unit ["
	        << L_value_unit << "] value on fielddef [" << L_fieldDefCpt << "] defintion");
	  L_ret = -1 ;
	  break;
        }
      }

      L_value_size = L_data->find_value((char*)"size") ;
      if (L_value_size == NULL) {
        GEN_ERROR(E_GEN_FATAL_ERROR, 
                  "fielddef [" << L_fieldDefCpt << "] size value is mandatory ["
                  << L_name << "]");
        L_ret = -1 ;
        break ;
      }

      L_size = strtoul_f (L_value_size, &L_endstr,10) ;
      GEN_DEBUG(1, "C_ProtocolBinary::get_header_from_xml() field length ["
                << L_fieldDefCpt <<"] is " << L_size );
      
      if (L_endstr[0] != '\0') {
        L_size = strtoul_f (L_value_size, &L_endstr,16) ;
        if (L_endstr[0] != '\0') {
          GEN_ERROR(E_GEN_FATAL_ERROR, "typedef size value ["
                    << L_value_size 
                    << "] bad format  on fielddef [" 
                    << L_fieldDefCpt << "] defintion");
          L_ret = -1 ;
          break ;
        }
      }

      if (!((strcmp(L_type,(char*)"String") == 0 ) ||
            (strcmp(L_type,(char*)"string") == 0 ))) {
        if ( L_size > sizeof(unsigned long)) {
          GEN_ERROR(E_GEN_FATAL_ERROR, "fielddef [" 
                    << L_fieldDefCpt << "] max size value ["  
                    << sizeof(unsigned long) << "]");
          L_ret = -1 ;
          break ;
        }
      }
      
      m_header_body_value_table[L_id].m_id = L_id ;
      m_header_body_value_table[L_id].m_name = L_name ;
      m_header_body_value_table[L_id].m_type_id = L_typeId ;
      m_header_body_value_table[L_id].m_nb_set=0;

      L_position_size.m_position = L_position ;
      L_position_size.m_size = L_size ;
      if (L_ret != -1) {
 	m_header_body_value_id_map
 	  ->insert(T_IdMap::value_type(L_name, L_id));
 	m_header_body_decode_map
 	  ->insert(T_DecodeMap::value_type(L_position, L_id));

        m_header_body_position_size_map
          ->insert(T_HeaderBodyPositionSizeMap::value_type(L_id, L_position_size));

	L_id ++ ;
      }
    }
    if (L_ret == -1) break ;
  }

//    {
//      T_IdMap::iterator L_IdMapIt ;
    
//      for (L_IdMapIt = m_header_body_value_id_map->begin();
//           L_IdMapIt != m_header_body_value_id_map->end() ;
//           L_IdMapIt++) {
//        std::cerr << "id ********* iss " 
//                  << L_IdMapIt->second 
//                  << " and name is "
//                  << L_IdMapIt->first
//                  << std::endl;
//      }
//    }
  
  
  GEN_DEBUG(1, "C_ProtocolBinary::get_header_body_values_from_xml() end");

  return (L_ret);
}
Esempio n. 3
0
/* Initialize currency tables 
*/
static int initcurr()
{
   register int dbt_lc;			/* loop control */
   register int rec, i;
   RECORD_ENTRY FAR *rec_ptr;
   SET_ENTRY FAR *set_ptr;
   DB_ADDR FAR *co_ptr;
   int old_size;
   int new_size;

   /* Initialize current record and type */
#ifndef	 ONE_DB
   for (dbt_lc = no_of_dbs, curr_db_table = &db_table[old_no_of_dbs],
				curr_rn_table = &rn_table[old_no_of_dbs];
	--dbt_lc >= 0; ++curr_db_table, ++curr_rn_table) {
      DB_REF(curr_dbt_rec) = NULL_DBA;
#endif
      RN_REF(rn_dba)   = NULL_DBA;
      RN_REF(rn_type)  = -1;
#ifndef ONE_DB
   }
#endif

   if ( size_st ) {
      new_size = size_st * sizeof(DB_ADDR);
      old_size = old_size_st * sizeof(DB_ADDR);
      if ( ALLOC_TABLE(&db_global.Curr_own, new_size, old_size, "curr_own")
								!= S_OKAY ) {
	 return( db_status );
      }
      if ( ALLOC_TABLE(&db_global.Curr_mem, new_size, old_size, "curr_mem")
								!= S_OKAY ) {
	 return( db_status );
      }
#ifndef	 NO_TIMESTAMP
      new_size = size_st * sizeof(ULONG);
      old_size = old_size_st * sizeof(ULONG);
      if ( db_tsrecs ) {
	 if ( ALLOC_TABLE(&db_global.Co_time, new_size, old_size, "co_time")
								!= S_OKAY ) {
	    return( db_status );
	 }
	 if ( ALLOC_TABLE(&db_global.Cm_time, new_size, old_size, "cm_time")
								!= S_OKAY ) {
	    return( db_status );
	 }
      }
      if ( db_tssets ) {
	 if ( ALLOC_TABLE(&db_global.Cs_time, new_size, old_size, "cs_time")
								!= S_OKAY ) {
	    return( db_status );
	 }
      }
#endif
      /* for each db make system record as curr_own of its sets */
#ifndef	 ONE_DB
      for (dbt_lc = no_of_dbs, curr_db_table = &db_table[old_no_of_dbs]; 
	   --dbt_lc >= 0; ++curr_db_table) {
#endif
	 for (rec = ORIGIN(rt_offset), 
		 rec_ptr = &record_table[ORIGIN(rt_offset)];
	      rec < ORIGIN(rt_offset) + DB_REF(Size_rt);
	      ++rec, ++rec_ptr) {
	    if (rec_ptr->rt_fdtot == -1) { 
	       /* found system record */
	       curr_rec = ((FILEMASK & NUM2EXT(rec_ptr->rt_file, ft_offset))
							    << FILESHIFT) | 1L;
	       /* make system record current of sets it owns */
	       for (i = ORIGIN(st_offset), 
		       set_ptr = &set_table[ORIGIN(st_offset)],
		       co_ptr = &curr_own[ORIGIN(st_offset)];
		    i < ORIGIN(st_offset) + DB_REF(Size_st);
		    ++i, ++set_ptr, ++co_ptr) {
 		  if (set_ptr->st_own_rt == rec) {
		     *co_ptr = curr_rec;
		  }
	       }
	       DB_REF(sysdba) = curr_rec;
#ifndef ONE_DB
 	       DB_REF(curr_dbt_rec) = curr_rec;
#endif
	       break;
	    }
	 }
#ifndef	 ONE_DB
      }
#endif
   }
   else {
      curr_own = NULL;
      curr_mem = NULL;
   }
#ifndef	 ONE_DB
   curr_db = 0;
   MEM_LOCK(&db_global.Db_table);
   curr_db_table = db_table;
   MEM_LOCK(&db_global.Rn_table);
   curr_rn_table = rn_table;
   setdb_on = FALSE;
   curr_rec = DB_REF(curr_dbt_rec);
#endif
   return( db_status = S_OKAY );
}
Esempio n. 4
0
/* Allocate space for dictionary
*/
static int alloc_dict()
{
   int old_size;
   int new_size;
   int extra_file = 0;
#ifndef ONE_DB
   DB_ENTRY FAR *db_ptr;
#endif

   /* allocate and initialize file_table */
#ifndef NO_TRANS
   if ( use_ovfl ) {
      extra_file = 1;
   }
#endif

#ifndef ONE_DB
   if ( old_no_of_dbs == 0 ) {
      old_size_ft = 0;
      old_size_fd = 0;
      old_size_st = 0;
      old_size_mt = 0;
      old_size_srt = 0;
      old_size_kt = 0;
      old_size_rt = 0;
   }
   else {
      db_ptr = &db_table[old_no_of_dbs];
      old_size_ft = db_ptr->Size_ft + db_ptr->ft_offset + extra_file;
      old_size_fd = db_ptr->Size_fd + db_ptr->fd_offset;
      old_size_st = db_ptr->Size_st + db_ptr->st_offset;
      old_size_mt = db_ptr->Size_mt + db_ptr->mt_offset;
      old_size_srt = db_ptr->Size_srt + db_ptr->srt_offset;
      old_size_kt = db_ptr->Size_kt + db_ptr->kt_offset;
      old_size_rt = db_ptr->Size_rt + db_ptr->rt_offset;
   }
#endif

   new_size = (size_ft + extra_file) * sizeof(FILE_ENTRY);
   old_size = old_size_ft * sizeof(FILE_ENTRY);
   if ( ALLOC_TABLE(&db_global.File_table, new_size, old_size, "file_table")
								!= S_OKAY ) {
      return( db_status );
   }

   /* allocate record_table */
   new_size = size_rt * sizeof(RECORD_ENTRY);
   old_size = old_size_rt * sizeof(RECORD_ENTRY);
   if ( ALLOC_TABLE(&db_global.Record_table, new_size, old_size, "record_table")
								!= S_OKAY ) {
      return( db_status );
   }

   /* allocate field_table */
   new_size = size_fd * sizeof(FIELD_ENTRY);
   old_size = old_size_fd * sizeof(FIELD_ENTRY);
   if ( ALLOC_TABLE(&db_global.Field_table, new_size, old_size, "field_table")
   								!= S_OKAY ) {
      return( db_status );
   }

   /* allocate set table */
   if ( size_st ) {
      new_size = size_st * sizeof(SET_ENTRY);
      old_size = old_size_st * sizeof(SET_ENTRY);
      if ( ALLOC_TABLE(&db_global.Set_table, new_size, old_size, "set_table")
								!= S_OKAY ) {
	 return( db_status );
      }
   } else set_table = NULL;

   /* allocate member_table */
   if ( size_mt ) {
      new_size = size_mt * sizeof(MEMBER_ENTRY);
      old_size = old_size_mt * sizeof(MEMBER_ENTRY);
      if ( ALLOC_TABLE(&db_global.Member_table, new_size, old_size, "member_table")
								!= S_OKAY ) {
	 return( db_status );
      }
   } else member_table = NULL;

   /* allocate sort_table */
   if ( size_srt ) {
      new_size = size_srt * sizeof(SORT_ENTRY);
      old_size = old_size_srt * sizeof(SORT_ENTRY);
      if ( ALLOC_TABLE(&db_global.Sort_table, new_size, old_size, "sort_table")
								!= S_OKAY ) {
	 return( db_status );
      }
   } else sort_table = NULL;

   /* allocate key_table */
   if ( size_kt ) {
      new_size = size_kt * sizeof(KEY_ENTRY);
      old_size = old_size_kt * sizeof(KEY_ENTRY);
      if ( ALLOC_TABLE(&db_global.Key_table, new_size, old_size, "key_table")
								!= S_OKAY ) {
	 return( db_status );
      }
   } else key_table = NULL;

   return( db_status = S_OKAY );
}