示例#1
0
/*---------------------------------------------------------------------------*/
ADAPT_CLASS ReadAdaptedClass(FILE *File) { 
/*
 **	Parameters:
 **		File	open file to read adapted class from
 **	Globals: none
 **	Operation: Read an adapted class description from File and return
 **		a ptr to the adapted class.
 **	Return: Ptr to new adapted class.
 **	Exceptions: none
 **	History: Tue Mar 19 14:11:01 1991, DSJ, Created.
 */
  int NumTempProtos;
  int NumConfigs;
  int i;
  ADAPT_CLASS Class;
  TEMP_PROTO TempProto;

  /* first read high level adapted class structure */
  Class = (ADAPT_CLASS) Emalloc (sizeof (ADAPT_CLASS_STRUCT));
  fread ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);

  /* then read in the definitions of the permanent protos and configs */
  Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
  Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
  fread ((char *) Class->PermProtos, sizeof (UINT32),
    WordsInVectorOfSize (MAX_NUM_PROTOS), File);
  fread ((char *) Class->PermConfigs, sizeof (UINT32),
    WordsInVectorOfSize (MAX_NUM_CONFIGS), File);

  /* then read in the list of temporary protos */
  fread ((char *) &NumTempProtos, sizeof (int), 1, File);
  Class->TempProtos = NIL;
  for (i = 0; i < NumTempProtos; i++) {
    TempProto =
      (TEMP_PROTO) c_alloc_struct (sizeof (TEMP_PROTO_STRUCT),
      "TEMP_PROTO_STRUCT");
    fread ((char *) TempProto, sizeof (TEMP_PROTO_STRUCT), 1, File);
    Class->TempProtos = push_last (Class->TempProtos, TempProto);
  }

  /* then read in the adapted configs */
  fread ((char *) &NumConfigs, sizeof (int), 1, File);
  for (i = 0; i < NumConfigs; i++)
    if (test_bit (Class->PermConfigs, i))
      Class->Config[i].Perm = ReadPermConfig (File);
  else
    Class->Config[i].Temp = ReadTempConfig (File);

  return (Class);

}                                /* ReadAdaptedClass */
示例#2
0
/**
 * Read an adapted class description from File and return
 * a ptr to the adapted class.
 *
 * @param File  open file to read adapted class from
 * @return Ptr to new adapted class.
 *
 * @note Globals: none
 * @note Exceptions: none
 * @note History: Tue Mar 19 14:11:01 1991, DSJ, Created.
 */
ADAPT_CLASS ReadAdaptedClass(FILE *File) {
  int NumTempProtos;
  int NumConfigs;
  int i;
  ADAPT_CLASS Class;
  TEMP_PROTO TempProto;

  /* first read high level adapted class structure */
  Class = (ADAPT_CLASS) Emalloc (sizeof (ADAPT_CLASS_STRUCT));
  fread ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);

  /* then read in the definitions of the permanent protos and configs */
  Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
  Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
  fread ((char *) Class->PermProtos, sizeof (uinT32),
    WordsInVectorOfSize (MAX_NUM_PROTOS), File);
  fread ((char *) Class->PermConfigs, sizeof (uinT32),
    WordsInVectorOfSize (MAX_NUM_CONFIGS), File);

  /* then read in the list of temporary protos */
  fread ((char *) &NumTempProtos, sizeof (int), 1, File);
  Class->TempProtos = NIL_LIST;
  for (i = 0; i < NumTempProtos; i++) {
    TempProto =
      (TEMP_PROTO) alloc_struct (sizeof (TEMP_PROTO_STRUCT),
      "TEMP_PROTO_STRUCT");
    fread ((char *) TempProto, sizeof (TEMP_PROTO_STRUCT), 1, File);
    Class->TempProtos = push_last (Class->TempProtos, TempProto);
  }

  /* then read in the adapted configs */
  fread ((char *) &NumConfigs, sizeof (int), 1, File);
  for (i = 0; i < NumConfigs; i++)
    if (test_bit (Class->PermConfigs, i))
      Class->Config[i].Perm = ReadPermConfig (File);
    else
      Class->Config[i].Temp = ReadTempConfig (File);

  return (Class);

}                                /* ReadAdaptedClass */