Пример #1
0
t_tetrimino	*init_main(char **av, char **env, t_config *config,
			   t_tetrimino *tetri)
{
  if (env[0] == NULL)
    return (NULL);
  srand(time(NULL));
  tetri = NULL;
  config->error = 0;
  if (load_tetriminos(&tetri) == -1)
    config->error = 1;
  if (init_config(config) == -1)
    return (NULL);
  if  (user_config(av, config) == -1)
    {
      write(2, "Error: bad parameter\n", 21);
      return (NULL);
    }
  if (init_sequences(config, env) == -1 ||
      get_highscore(config) == -1)
    return (NULL);
  debug_part(config, &tetri);
  if (config->error == 1)
    return (NULL);
  prep_screen();
  clean_list(&tetri);
  config->form = choose_tetrimino(tetri);
  config->next = choose_tetrimino(tetri);
  config->pos[0] = (config->width / 2) - (config->form->width / 2);
  display_game(config, 1);
  return (tetri);
}
Пример #2
0
void	free_full_env(t_env *env)
{
  clean_list(&env->list);
  clean_wordtab(env->environ);
  free(env->username);
  free(env);
}
Пример #3
0
void CCusQueryDlg::show_result(void)
{
	MYSQL_ROW row;
	unsigned int num_fields;
	unsigned int i=0,j=0;

	clean_list();

	create_cols();//tao cac cols

	num_fields = mysql_num_fields(m_pKmySql->get_res());
	
// 	for (int i=0; i<num_fields; i++)
// 		m_resList.InsertColumn(i,_T(""),LVCFMT_LEFT,LVCF_MINWIDTH);

	while ((row = mysql_fetch_row(m_pKmySql->get_res())))
	{
		for(i = 0; i < num_fields; i++)
		{			
			add_item(j,i,CString(row[i]));
		}
		j++;
	}
	total_row=j;
}
Пример #4
0
void rtsp_cleanupMenu()
{
	if ( pstream_head != NULL && *ppstream_head != NULL )
	{
		clean_list(*ppstream_head);
		*ppstream_head = NULL;
	}

	mysem_destroy(rtsp_semaphore);
}
Пример #5
0
void	do_unsetenv(char **t, t_env *env)
{
  if (t[1] == NULL)
    return;
  if (my_strcmp_casse(t[1], "*") == 0)
    clean_list(&env->list);
  else
    delete_entry(&env->list, t[1]);
  clean_wordtab(env->environ);
  env->environ = convert_to_tab(env->list);
}
Пример #6
0
int main(void)
{
  struct elem *head = NULL;
  size_t len = 10;
  
  //
  head = init_list(len);
  traverse_list(head, 2);
  clean_list(head, len);
  //
  
  return 0;
}
Пример #7
0
void clean_list(streams_struct *stream_ptr)
{
	//recursively clears linked list

	//dprintf("%s: clean list\n", __FUNCTION__);

	if ( stream_ptr->next!=NULL )
	{
		clean_list((streams_struct *) stream_ptr->next);
	}

	dfree(stream_ptr->stream);
	FREE(stream_ptr->name);
	FREE(stream_ptr->description);
	FREE(stream_ptr->thumb);
	FREE(stream_ptr->poster);
	dfree(stream_ptr);
}
Пример #8
0
int main(int argc, char** argv){
	int cases, case_no;
	long a, b, c, r, k, n;
	node* k_list, *tail;
	long output;
	float start_time, end_time;
	char* filename = "sample.txt";
	if(argc>=2){
		filename = argv[1];
	}

	FILE* infile = fopen(filename,"r");
	FILE* outfile = fopen("out.txt","w");
	fscanf(infile,"%d",&cases);
	for(case_no=1;case_no<=cases;case_no++){
		//input
		fscanf(infile,"%ld %ld",&n,&k);
		fscanf(infile,"%ld %ld %ld %ld",&a,&b,&c,&r);
		printf("Case #%d: %ld/%ld: %ld %ld %ld %ld\n",case_no,k,n,a,b,c,r);
		start_time = (float) clock()/CLOCKS_PER_SEC;

		//generate first k-values
		k_list = generate_k(a,b,c,r,k);
		//print_arr(k_list,k);

		//execution
		k_list = solve(k_list, a, b, c, r, k, n);
		tail=get_tail(k_list,k);
		output = tail->val;
		//print_arr(k_list,k);

		//post-execution
		clean_list(k_list,k);
		end_time = (float) clock()/CLOCKS_PER_SEC;
		printf("Case #%d: Output: %ld\n",case_no,output);
		fprintf(outfile,"Case #%d: %ld\n",case_no,output);
		printf("Time %f sec\n",end_time-start_time);
	}
	fclose(infile);
	fclose(outfile);

	return 0;
}
Пример #9
0
static int get_rtsp_streams(streams_struct **ppstream_head)
{
	int ret;
	int i = 0;
	char buf[PATH_MAX];

	dprintf("%s: in\n", __FUNCTION__);

	if ( pstream_head != NULL && *ppstream_head != NULL )
	{
		interface_clearMenuEntries(_M &rtspStreamMenu); // don't leave thumb pointers to previous streams!
		clean_list(*ppstream_head);
		*ppstream_head = NULL;
	}

	dprintf("%s: call find_streams\n", __FUNCTION__);

	ret = find_streams(ppstream_head);

	if ( !((ret == 0)&&(pstream_head != NULL)) )
	{
		int file;

		dprintf("%s: open %s\n", __FUNCTION__, appControlInfo.rtspInfo.streamFile);

		file = open(appControlInfo.rtspInfo.streamFile, O_RDONLY);

		if ( file > 0 )
		{
			while ( helperReadLine(file, buf) == 0 )
			{
				if ( strlen(buf) > 0 )
				{
					add_stream(ppstream_head, buf, i);
				}
				i++;
			}
		}
		ret = file;
	}

	return ret;
}
Пример #10
0
// show result on list view
void CAllDlg::show_on_list(void)
{
	MYSQL_ROW row;
	unsigned int num_fields;
	unsigned int i=0,j=0;
	clean_list();

	num_fields = mysql_num_fields(ptr_cKmysql->get_res());
	while ((row = mysql_fetch_row(ptr_cKmysql->get_res())))
	{
// 		unsigned long *lengths;
// 		lengths = mysql_fetch_lengths(ptr_cKmysql->get_res());
		for(i = 0; i < num_fields; i++)
		{			
			add_item(j,i,CString(row[i]));
		}
		j++;
	}
	total_row=j;
}
int main()
{
    struct Node * list;

    add_number(&list,1);
    print(print_list, list);
    printf("\n");
    add_number(&list,45);
    print(print_list, list);
    printf("\n");
    add_number(&list,3);
    print(print_list, list);
    printf("\n");
    add_number(&list,46);
    print(print_list, list);
    printf("\n");
    add_number(&list,103);

    print(print_list, list);
    printf("\n");
    
    clean_list(&list);
}
Пример #12
0
char *query (char *query, char *bloom_filter, double tole_rate, double sampling_rate, char *list, char *target_path, char *report_fmt, char mode)
{
  gzFile zip = NULL;
  char type = '@';
  int normal = 0;
  int threads = 0;
  BIGCAST offset = 0;
  char *position = NULL;
  static char timestamp[40] = {0};

  // Get current timestamp, for benchmarking purposes (begin of run timestamp)
  isodate(timestamp);
  bloom *bl_2 = NEW (bloom);
  F_set *File_head = make_list (bloom_filter, list);
  /*initialization for python interface*/
  File_head->hits = 0;
  File_head->all_k = 0;
  File_head->reads_num = 0;
  File_head->reads_contam = 0;
  File_head->filename = bloom_filter;           //extra initialization for python interface
  if (load_bloom (File_head->filename, bl_2)<=0)	//load a bloom filter
	exit(-1);
  
  if (tole_rate == 0)
  {
  	tole_rate = mco_suggestion (bl_2->k_mer); // suggest an optimal match cut-off
  }
  if (mode == 'r')
  {
 	init_string(ONEG); // initialize strings for containing reads
  }
/*
  if ((get_size (query) < 2 * ONEG) && !strstr (query, ".gz") && !strstr (query, ".tar"))
        normal = 0;
  else
  {
      if ((zip = gzopen (query, "rb")) < 0)
	{
          perror ("query open error...\n");
          exit (-1);
	}
      normal = 0;
  }
*/
  if ((zip = gzopen (query, "rb")) <= 0)
  {
  	fprintf(stderr, "%s\n", strerror(errno));
  	exit(EXIT_FAILURE);
  }
  
  if (strstr (query, ".fastq") != NULL || strstr (query, ".fq") != NULL)
  	type = '@';
  else
  	type = '>';
  if (normal == 0)
  	position = (char *) calloc (1,(ONEG+1)*sizeof (char));
  while (offset != -1)
  {
      if (normal == 1)
      {
	  position = mmaping (query);
	  offset = -1;
      }
      else
      {
	  offset = CHUNKer (zip, offset, ONEG, position, type);
      }
      Queue *head = NEW (Queue);
      head->location = NULL;
      Queue *tail = NEW (Queue);
      head->next = tail;
      Queue *head2 = head;
      get_parainfo (position, head, type);
#pragma omp parallel
      {
// XXX: Awesome will be the day when OpenMP is in OSX
#ifndef __APPLE__ 
          threads = omp_get_num_threads();
#endif
#pragma omp single nowait
	{
	  while (head != tail)
	    {
#pragma omp task firstprivate(head)
	      {
		if (head->location != NULL)
		{
			read_process (bl_2, head, tail, File_head, sampling_rate, tole_rate, mode, type);
		}
	      }
	      head = head->next;
	    }			// End of firstprivate
	}			// End of single - no implied barrier (nowait)
      }				// End of parallel region - implied barrier
  if (position != NULL && normal == 0)
  {
  	memset (position, 0, strlen (position));
  } 
  else if (normal == 1)
  {
	munmap (position, strlen (position));
  } 
  else
  {
 	perror ("Cannot memset, wrong position on fastq file\n");
	exit (-1);
  }
  clean_list (head2, tail);
  if (mode == 'r')
  {
	if (target_path!=NULL)
	{
      		save_result (query, File_head->filename, type, target_path, re_clean(), re_contam()); //save results into file if facs remove is called
  	}
	else
	{
		write_default(re_clean(), re_contam(), offset);
	}
	reset_string();
  }
  }				//end while
  if (normal == 0)
  {
 	bloom_destroy(bl_2);
  	gzclose(zip);
  	free (position);        //dont like file mapping, strings need to be freed in a normal way
  }

  /*
  mode c and r refer to contamination checking and removal function respectively. 
  The following 9 lines make sure that json/tsv output is printed after the checking 
  process, but willnot be written in stdout when running removal process.
  */
  if (target_path!=NULL || mode == 'c')
  {
  	return report(File_head, query, report_fmt, target_path, timestamp, prob_suggestion(bl_2->k_mer), threads);
  }
  else
  {
	char *s = "";
	return s;
  }
}