Ejemplo n.º 1
0
static void	print_time(int fd)
{
	time_t		st;

	st = time(NULL);
	st = st % 86400;
	ft_putstr_fd(C_INFO, fd);
	ft_putstr_fd("[", fd);
	if (st / 3600 < 10)
		ft_putchar('0');
	ft_putnbr_fd(st / 3600, fd);
	ft_putstr_fd(":", fd);
	if ((st % 3600) / 60 < 10)
		ft_putchar('0');
	ft_putnbr_fd((st % 3600) / 60, fd);
	ft_putstr_fd(":", fd);
	if ((st % 3600) % 60 < 10)
		ft_putchar('0');
	ft_putnbr_fd((st % 3600) % 60, fd);
	ft_putstr_fd("]", fd);
	ft_putstr_fd(C_REGULAR, fd);
	ft_putstr_fd(" ", fd);
}
Ejemplo n.º 2
0
void			ft_perror(const char *prog, const char *s, int errnum, int type)
{
	const char	*error;

	(void)error;
	if (errnum >= TAB_ERR_SIZE)
		errnum = 0;
	if (prog)
	{
		ft_putstr_fd(prog, 2);
		ft_putstr_fd(" : ", 2);
	}
	ft_putstr_fd("error", 2);
	if (s)
	{
		ft_putstr_fd(" : ", 2);
		ft_putstr_fd(s, 2);
	}
	ft_putstr_fd("\n", 2);
	if (type % 2 == 0)
		exit(1);
}
Ejemplo n.º 3
0
void		ft_color(const char *s, int fd)
{
	int		fd2;

	fd2 = 0;
	if (ft_strcmp(s + ft_strlen(s) - 2, ".c") == 0)
		ft_putstr_fd("\033[31m", fd);
	else if (ft_strcmp(s + ft_strlen(s) - 2, ".o") == 0)
		ft_putstr_fd("\033[30m", fd);
	else if (ft_strcmp(s + ft_strlen(s) - 2, ".h") == 0)
		ft_putstr_fd("\033[33m", fd);
	else if (ft_strcmp(s + ft_strlen(s) - 4, ".pdf") == 0)
		ft_putstr_fd("\033[32m", fd);
	else if ((fd2 = open(s, O_RDONLY)) == -1)
	{
		ft_putstr_fd("\033[37m", fd);
		close(fd2);
	}
	else
	{
		ft_putstr_fd("\033[34m", fd);
		close(fd2);
	}
}
Ejemplo n.º 4
0
void	ft_putstr(const char *s)
{
	ft_putstr_fd(s, 1);
}
Ejemplo n.º 5
0
void	ft_fatal(char *str)
{
	ft_putstr_fd(str, 2);
	exit(0);
}
Ejemplo n.º 6
0
void	ft_putstr(char *str)
{
	ft_putstr_fd(str, 1);
}
Ejemplo n.º 7
0
void	ft_putstr(char const *str)
{
	ft_putstr_fd(str, 1);
}
Ejemplo n.º 8
0
void	sh_error_quit(char	*str)
{
	ft_putstr_fd("error :", 2);
	ft_putendl_fd(str, 2);
	sh_quit();
}
Ejemplo n.º 9
0
void			eb_putstr_term(char *str)
{
	ft_putstr_fd(str, isatty(FD_STD_OUT));
}
Ejemplo n.º 10
0
void	ft_putendl_fd(char const *s, int fd)
{
	ft_putstr_fd(s, fd);
	write(fd, "\n", 1);
}
Ejemplo n.º 11
0
void		ft_arg_error(void)
{
	(void) ft_putstr_fd("[USAGE] ./client [PID] [STR]\n\0", 0x01);
	(void) exit(0);
}
Ejemplo n.º 12
0
void	ft_putexit(char const *s, int fd)
{
	ft_putstr_fd(s, fd);
	ft_putchar_fd('\n', fd);
	exit(2);
}
Ejemplo n.º 13
0
Archivo: fail.c Proyecto: elhmn/mod1
void	*fail(char *s)
{
	ft_putstr_fd(s, 2);
	return (NULL);
}
Ejemplo n.º 14
0
int		ft_puterr(char *err)
{
	ft_putstr_fd(err, 2);
	return (-1);
}
Ejemplo n.º 15
0
int					ft_print_parse_error(char *error)
{
	ft_putstr_fd("42sh: Parse error: ", 2);
	ft_putendl_fd(error, 2);
	return (0);
}
Ejemplo n.º 16
0
void			small_size(void)
{
	tputs(tgoto(tgetstr("cm", NULL), 0, 0), FD, tputs_putchar);
	tputs(tgetstr("cd", NULL), FD, tputs_putchar);
	ft_putstr_fd("Size too small\n", FD);
}
Ejemplo n.º 17
0
void	ft_putendl_fd(char *str, size_t fd)
{
	ft_putstr_fd(str, fd);
	write(fd, "\n", 1);
}
Ejemplo n.º 18
0
void	ft_putstr(const char *s)
{
	if (s)
		ft_putstr_fd(s, 1);
}
Ejemplo n.º 19
0
void	ft_putendl_fd(char const *s, int fd)
{
	ft_putstr_fd(s, fd);
	ft_putstr_fd("\n" ,fd);
}
Ejemplo n.º 20
0
void	ft_putendl(char const *s)
{
	ft_putstr_fd(s, 1);
	ft_putstr_fd("\n", 1);
}
Ejemplo n.º 21
0
void	ft_putstr(char const *s)
{
	ft_putstr_fd(s, 1);
}
Ejemplo n.º 22
0
void	ft_putendl_fd(const char *s, int fd)
{
	ft_putstr_fd((char *)s, fd);
	ft_putchar_fd('\n', fd);
}
Ejemplo n.º 23
0
Archivo: error.c Proyecto: gjacot/42
void	error2(char *str, int fd)
{
	ft_putstr_fd(str, fd);
	exit(0);
}
Ejemplo n.º 24
0
int		aff_str(char *str)
{
	ft_putstr_fd(str, 0);
	return (0);
}
Ejemplo n.º 25
0
void ft_putendl_fd(char const *s, int fd)
{
	ft_putstr_fd(s, fd);
	ft_putchar_fd('\n', fd);
}
Ejemplo n.º 26
0
void	ls_invalid_opt(char ch)
{
	ft_putstr_fd("ls: illegal option -- ", 2);
	ft_putchar_fd(ch, 2);
	write(2, "\n", 1);
}
Ejemplo n.º 27
0
static void		display_eacces(char *file)
{
	ft_putstr_fd("ls: ", 2);
	ft_putstr_fd(file, 2);
	ft_putstr_fd(": Permission denied\n", 2);
}
Ejemplo n.º 28
0
void	color_error(char c)
{
	ft_putstr_fd("error: invalid character '", 2);
	write(2, &c, 1);
	ft_putstr_fd("' in LSCOLORS env var\n", 2);
}
Ejemplo n.º 29
0
void	ft_putnbr_fd(int n, int fd)
{
	ft_putstr_fd(ft_itoa(n), fd);
}
Ejemplo n.º 30
0
void		print_too_many_arguments(t_state *state, char *s)
{
	ft_putstr_fd(s, 2);
	ft_putendl_fd(": too many arguments", 2);
	set_env(&state->env, "?", "1");
}