Пример #1
0
int main()
{
	char *line;
	char **cmd;
	uneditedLine = (char*)malloc(256 * sizeof(char));

	while (1)
	{
		my_setup();
		my_prompt();
		line = my_read();
		strcpy(uneditedLine, line);		

		if (line == 0) return 0;
		if (line[0] == '\0') 
		{
			free(line);
			continue;
		}

		cmd = my_parse(line);
		my_execute(cmd);
		my_clean(line, cmd);
	}

	free(uneditedLine);

	return 0;
}
Пример #2
0
int		main(int ac, char **av)
{
  t_ptr		*ptr;
  t_col		*color;
  t_sc		*scene;

  if (ac > 1)
    my_parse(av[1]);
  (void)av;
  if (ac != 1)
    my_putstr_error(ARG_ERROR);
  if ((ptr = my_init()) == NULL)
    {
      my_putstr_error(INIT_ERROR);
      return (EXIT_ERROR);
    }
  if ((color = my_init_color(0, 0, 0)) == NULL)
    {
      my_putstr_error(INIT_ERROR);
      return (EXIT_ERROR);
    }
  if ((scene = my_init_scene()) == NULL)
    return (EXIT_ERROR);
  my_fill_image(ptr->pic, color, scene);
  mlx_expose_hook(ptr->win->ptr, &my_expose, ptr);
  mlx_key_hook(ptr->win->ptr, &my_key, ptr);
  mlx_loop(ptr->mlx);
  return (SUCCESS);
}
Пример #3
0
int main() { 
  char *line;
  char **cmd; 
  
  while (1) {
    my_setup();
    my_prompt();
    my_read(line);
    cmd = my_parse(line);
    //my_execute(cmd);
    //my_clean();
  } 
  
  return 0; 
}
Пример #4
0
void	parse_arg(t_env *e)
{
  int	i;
  int	nb;

  i = 0;
  nb = 0;
  e->a = malloc((nb_ac(e->arg) + 3) * sizeof(t_pipe));
  if (nb_ac(e->arg) == 0)
    {
      e->a->pos1 = e->arg;
      e->a->op = NULL;
    }
  else
    my_parse(e);
}
Пример #5
0
// main function
int main()
{
    char *line;
    char **cmd;

    while (1)
    {
	/*
	my_setup();
	my_prompt();
	*/
	line = my_read();
	cmd = my_parse(line);
	/*
	my_exectue(cmd);
	my_clean();
	*/
    }
    
    return 0;
}
Пример #6
0
int	main(int ac, char **av)
{
	t_fdf	e;

	fdf_ini(&e);
	if (ac < 2 || !my_parse(&e, ac, av))
		return (0);
	e.wia = FT_MAX(e.maa - e.mia, 1);
	if (!(e.mlx = mlx_init()))
		return (fdf_quit(&e));
	if (!(e.win = mlx_new_window(e.mlx, e.wid, e.hig, "FdF")))
		return (fdf_quit(&e));
	if (!(e.img = mlx_new_image(e.mlx, e.wid, e.hig)))
		return (fdf_quit(&e));
	e.buf = mlx_get_data_addr(e.img, &e.bit, &e.lin, &e.end);
	e.bit /= 8;
	prepare_image(&e);
	mlx_key_hook(e.win, &my_key_func, &e);
	mlx_expose_hook(e.win, &my_expose_func, &e);
	mlx_loop(e.mlx);
	return (0);
}
Пример #7
0
static int write_vcf_file(char* response,char* name_vcf)
{
	FILE *output_file;
	
	int i = 0;
	int j = 0;
	int size = 0;
	int size_info,size_alt;
	Variant *v = (Variant*)malloc(1*sizeof(Variant));

	my_parse(response);
	my_set_variants();
	size = my_variants_size();
	
	output_file = fopen(name_vcf,"a");
	for(i=0; i<size; i++)
	{
		size_info =  get_info_size(i);
		size_alt = get_alt_size(i);
		
		my_get_variant(i,v);
		
		fprintf(output_file,"%s\t",v->referenceName);
		fprintf(output_file,"%ld\t",v->start);
		fprintf(output_file,"%s\t",v->id);
		fprintf(output_file,"%s\t",v->referenceBases);
		fprintf(output_file,"%s",v->alternateBases[0]);
		for(j=1; j<size_alt; j++)
		{
			fprintf(output_file,",%s",v->alternateBases[j]);
		}
		fprintf(output_file,"\t");
		fprintf(output_file,".\t");
		fprintf(output_file,"PASS\t");
		//consider case size_info = 0 ?

		if(size_info!=0&&size_info!=-1)
		{
			fprintf(output_file,"%s",v->info_key[0]);
			fprintf(output_file,"=%s",v->info_value[0]);
			for(j = 1; j< size_info; j++)
			{
				fprintf(output_file,";%s",v->info_key[j]);
				fprintf(output_file,"=%s",v->info_value[j]);
			}
		}else{
		
			fprintf(output_file,".");
		}
		fprintf(output_file,"\t");
		fprintf(output_file,"\n");
		
		if(v->info_key!=NULL)
		{
		free(v->info_key);
		}
		
		if(v->info_value!=NULL)
		{
		free(v->info_value);
		}
		
		if(v->alternateBases!=NULL)
		{
		free(v->alternateBases);
		}
	}
	fclose(output_file);		
	return 0;
}
Пример #8
0
/* For input redirection */
void input_red(char** cmd){
	if( is_iored(cmd))
	{
		int k = 0;
		while( cmd[k] != NULL ) k++; 						// k->cmd.end()
		char filename[strlen(cmd[k-1])];
		if( strcpy( filename, cmd[k-1]) == NULL){
			printf("strcpy filename failed!\n");
			exit(1);
		}
		
		char path[256];
		strcpy( path, getenv("PWD") );
		strcat( path, "/" );
		strcat( path, filename );							//making path/filename
		
		char command[20];
		if( strcpy(command, cmd[0]) )
		{
															//making command(echo, ls,,,)
			int fd = open( path, O_RDONLY);
			if(fd == 0) { printf("open file failed!\n"); return;} 
																// check availability of file
			pid_t fpid = fork();
			if (fpid < 0){
				perror("io fork failed!\n");
				exit(1);
			}

			if( fpid == 0 ){ 									// child
				close(STDIN_FILENO);
				dup(fd);
				close(fd);
				
				free(cmd);
				char *line;
				char *newcmd[32], **argu; //newcmd could hold 31 argus + 1 cmd
				line = my_read();
				argu = my_parse(line); //redo parsing from file! to get argus.
				newcmd[0] = command;
				int z;
				for(z=0; argu[z]!=NULL ;z++)
					newcmd[z+1] = argu[z];
				newcmd[z+1] = argu[z]; //copy argu provided from file to newcmd
				
				check_command(newcmd);
				
				_exit(0);
			}

			else{	 							
				waitpid(fpid, NULL, 0);
			}				
		}
		else
		{	printf("strcpy command copy failed!\n");
			exit(1);}
			
	}
	else
		printf("Undefined input_red cmd format!\n");
}