Exemple #1
0
void		recursive_if(char **path, char *folder, char *flags)
{
	int				i;
	char			*rl;
	struct stat		*file_stat;

	i = 0;
	rl = ft_strnew(DEFAULT_BUFFER);
	while (path[i])
	{
		ft_bzero(rl, DEFAULT_BUFFER);
		rl = realpath(folder, rl);
		rl = ft_strcat(rl, "/");
		rl = ft_strcat(rl, path[i]);
		rl = ft_strcat(rl, "/");
		if (!(file_stat = get_file_stat(path[i], file_stat, folder)))
			return ;
		ft_putstr(rl);
		ft_putstr(":\n");
		print_recursive(get_specified_dir(rl, flags), flags, rl, 0);
		free(file_stat);
		i++;
	}
	free(rl);
	free_files(path);
}
void			print_directories(t_list *dir, int c, int options)
{
	t_list		*i;
	t_list		*content;

	i = dir;
	while (i)
	{
		content = NULL;
		get_directory_content(i, &content, options);
		sort(content, options);
		if (c > 1 || options & RECURSIVE_OPTION_MASK)
			print_directory_name(i, &c);
		if (options & LONG_OPTION_MASK)
			print_total(content);
		print(content, options);
		if (options & RECURSIVE_OPTION_MASK)
			print_recursive(content, i, c, options);
		ft_lstdel(&content, &free_file);
		i = i->next;
	}
}
Exemple #3
0
 void DisassemblerContext::print_term_definition(const ValuePtr<>& term, bool global) {
   *m_output << name(term) << " = ";
   
   switch (term->term_type()) {
   case term_functional: {
     if (global)
       *m_output << "define ";
     print_functional_term(value_cast<FunctionalValue>(term), false);
     *m_output << ";\n";
     break;
   }
   
   case term_function_type: {
     if (global)
       *m_output << "define ";
     print_function_type_term(value_cast<FunctionType>(term), false);
     *m_output << ";\n";
     break;
   }
   
   case term_instruction: {
     print_instruction_term(value_cast<Instruction>(term));
     break;
   }
   
   case term_phi: {
     print_phi_term(value_cast<Phi>(term));
     break;
   }
   
   case term_global_variable: {
     ValuePtr<GlobalVariable> gvar = value_cast<GlobalVariable>(term);
     *m_output << "global ";
     if (gvar->constant())
       *m_output << "const ";
     print_term(gvar->value_type(), true);
     if (gvar->value()) {
       *m_output << ' ';
       print_term(gvar->value(), true);
     }
     *m_output << ";\n";
     return;
   }
   
   case term_function: {
     print_function(value_cast<Function>(term));
     return;
   }
   
   case term_function_parameter: {
     ValuePtr<FunctionParameter> parameter = value_cast<FunctionParameter>(term);
     ValuePtr<Function> function = parameter->function();
     unsigned n = 0;
     for (Function::ParameterList::const_iterator ii = function->parameters().begin(), ie = function->parameters().end(); ii != ie; ++ii, ++n) {
       if (parameter == *ii) {
         *m_output << "[function parameter " << n << "]\n";
         return;
       }
     }
     *m_output << "[invalid function parameter]\n";
     return;
   }
   
   case term_apply: {
     if (global)
       *m_output << "define ";
     print_apply_term(value_cast<ApplyType>(term), false);
     *m_output << ";\n";
     return;
   }
   
   case term_exists: {
     if (global)
       *m_output << "define ";
     print_exists(value_cast<Exists>(term), false);
     *m_output << ";\n";
     return;
   }
   
   case term_recursive: {
     print_recursive(value_cast<RecursiveType>(term));
     return;
   }
   
   case term_recursive_parameter: *m_output << "[recursive parameter]\n"; return;
   case term_parameter_placeholder: *m_output << "[parameter placeholder]\n"; return;
   case term_upref_null: *m_output << "upref_null\n"; return;
     
   default:
     PSI_FAIL("unexpected term type - cannot print a definition");
   }
 }