next up previous
Next: image_init Up: Sample Functions Previous: aisf.h

aiss_sys_init

 int aiss_sys_init(a_state *data)
{
  FILE *config;
  char tmp;
  char crap;
  char tempbreaks[3];
  int i,a;
  config=fopen("/etc/aiss.conf","r");
  if(config==NULL)
    {
      printf("Error 001 Config file not found.\n");
      return -1;
    }

  while(crap !='\n')
    crap=(char)fgetc(config);
  
    
  fscanf(config,"NAME= %s", (char *) &data->name);
  crap=(char)fgetc(config);

  fscanf(config,"OBS_NAME= %s",(char *) data->observatory);
  crap=(char)fgetc(config);

  fscanf(config,"CDS_ROWS= %d",&data->cds_rows);
  crap=(char)fgetc(config);

  fscanf(config,"CDS_COLUMN= %d",&data->cds_columns);
  crap=(char)fgetc(config);

  fscanf(config,"PHYSICAL_ROWS= %d",&data->p_rows);
  crap=(char)fgetc(config);
  
  fscanf(config,"PHYSICAL_COLUMNS= %d",&data->p_columns);
  crap=(char)fgetc(config);
  
  fscanf(config,"BITPIX= %d",&data->bitpix);
  crap=(char)fgetc(config);
  
  fscanf(config,"DEFAULT_SUB= %c",&tmp);
  crap=(char)fgetc(config);
  
  if(tmp=='T')
    data->sub=TRUE;
  else if (tmp=='F')
    data->sub=FALSE;
  else
    { 
      printf("Error parsing config, invalid subtraction def. ERR 002\n");
      return -1;
    }

  fscanf(config,"DATA= %d", (int *)&data->d_type_default);
  crap=(char)fgetc(config);
  
  fscanf(config,"NUM_FW= %d",&data->numfw);
  crap=(char)fgetc(config);
  
  data->breaks=calloc(data->numfw,sizeof(int));

  fscanf(config,"NUM_FILTERS= %d",&data->numbfilters);
  crap=(char)fgetc(config);

  for(i=1;i<=data->numfw;i++)
    {
      for (a=0;a<11;a++)
	tmp= (char)fgetc(config);
      tempbreaks[0]=fgetc(config);
      tmp=(char)fgetc(config);
      if (tmp=='\n')
	{
	  data->breaks[i-1]=atoi(&tempbreaks[0]);
	  continue;
	}
      else
	{
	  tempbreaks[1]=(char)fgetc(config);
	  data->breaks[i-1]=atoi(tempbreaks);
	}
    }
  fclose(config);
  return 0;
}


Aaron Smith 2004-03-04