Пример #1
0
static int parse_line(char *type, double *cur_time, unsigned int *timestamp, unsigned int *data_size, char **data)
{
	char *line = one_line(index_fp);
	if (!line) {
		printf("Warning: No more lines in [%s]\n", input_path);
		return -1;
	}
	int file_path_size = strlen(input_path) + strlen(line) + 50;
	char *file_path = malloc(file_path_size);
	snprintf(file_path, file_path_size, "%s/%s", input_path, line);
	// Open file
	FILE *cur_fp = fopen(file_path, "r");
	if (!cur_fp) {
		printf("Error: Cannot open file [%s]\n", file_path);
		exit(1);
	}
	// Parse data from file name
	*data_size = get_data_size(cur_fp);
	sscanf(line, "%c-%lf-%u-%*s", type, cur_time, timestamp);
	*data = malloc(*data_size);
	if (fread(*data, *data_size, 1, cur_fp) != 1) {
		printf("Error: Couldn't read entire file.\n");
		return -1;
	}
	fclose(cur_fp);
	free(line);
	free(file_path);
	return 0;
}
Пример #2
0
	void IPOFrame::HandleOneReq(const std::set<int> &interaction,
								CoveringArray &array,
								std::set<int> &dealed_factors,
								std::list<int> &undealed_factors)
	{
		LocalCombSet &local_state=m_uncover_table->getLocalState(interaction);

		for(int i=0;i<local_state.Size();i++)
		{
			while(local_state.getState(i)>0)
			{
				std::vector<int> combination;
				local_state.getCombination(combination,i);

				int j=0;
				std::vector<int> one_line(array.Column(),-1);
				for(std::set<int>::const_iterator it=interaction.begin();
					it!=interaction.end();++it)
					one_line[*it]=combination[j++];

				local_state.Remove(i);
				array.Push_Back(one_line);
			}
		}

		dealed_factors.insert(interaction.begin(),interaction.end());
		std::list<int>::iterator range_begin=undealed_factors.begin();
		for(std::set<int>::const_iterator it=dealed_factors.begin();
			it!=dealed_factors.end();++it)
		{
			std::list<int>::iterator del_it=find(range_begin,undealed_factors.end(),*it);
			range_begin=undealed_factors.erase(del_it);
		}
	}
Пример #3
0
Файл: ia.c Проект: plean/CPE
void	my_ia(t_prog_base *base)
{
  if (!one_line(base))
    return ;
  base->line = find_line(base);
  base->matches = 1;
  if (rand() % 100 <= base->difficulty)
    while (xor_all_pile(base) != 0)
	{
	  base->matches++;
	  if (base->matches > base->matches_per_lines[base->line - 1] -
	      base->nb_deleted[base->line - 1])
	    {
	      base->matches = 1;
	      while (base->is_empty[++base->line + 1]);
	      if (base->line > base->nb_lines)
		{
		  base->line = find_line(base);
		  return ;
		}
	    }
	}
}
Пример #4
0
void make_w3( help_data* help )
{
  char     tmp  [ FOUR_LINES ];
  char*  input;
  FILE*     fp;

  sprintf( tmp, "%shelp/%s/%s", W3_DIR,
    help_cat_table[ help->category ].name, help->name );
  smash_spaces( tmp );

  if( ( fp = fopen( tmp, "w" ) ) == NULL ) {
    bug( "Make_W3( help ): Fopen error" );
    return;
    }

  fprintf( fp, "<html>\n" );
  fprintf( fp, "<body>\n" );

  for( input = help->text; *input != '\0'; ) {
    input = one_line( input, tmp );
    smash_color( tmp );
    if( !strcasecmp( tmp, "Syntax" ) ) 
      fprintf( fp, "<h1> Syntax </h1>\n" );
    else if( !strcasecmp( tmp, "Description" ) ) 
      fprintf( fp, "<h1> Description </h1>\n" );
    else 
      fprintf( fp, "%s<br>\n", tmp );
    }

  fprintf( fp, "</html>\n" );
  fprintf( fp, "</body>\n" );
  
  fclose( fp );

  return;
}