Ejemplo n.º 1
0
char		*my_read(int fd, int ret)
{
  static int	i = 0;
  static char	buff[4097];

  if (i == 0 || buff[i] == '\0')
    {
      i = 0;
      if ((ret = read(fd, buff, 4096)) > 0 && !my_str_isprintable(buff))
	ret = my_fread(buff, fd);
      if (ret <= 0)
        {
	  if (ret)
	    my_warn(NULL, fd);
          return (NULL);
        }
      buff[ret] = '\0';
    }
  ret = i;
  while (buff[i] && buff[i] != '\n' && buff[i] != ';')
    jump_inhibitors(buff, &i);
  if (buff[i])
    i = i + 1;
  return (read_one_line(buff + ret));
}
Ejemplo n.º 2
0
int		my_fread(char buff[4097], int fd)
{
  int		ret;

  if (signal(SIGINT, &disable_sigint) == SIG_ERR)
    return (0);
  while ((ret = read(fd, buff, 4096)) > 0 && !my_str_isprintable(buff))
    {
      my_putstr("\033[32m$ \033[33m~ \033[31m> \033[0mcommand not found\n");
      buff[ret] = '\0';
    }
  if (signal(SIGINT, &my_sigint) == SIG_ERR || launch_exiting(0))
    return (0);
  return (ret);
}
Ejemplo n.º 3
0
/*
**		If string received from my_read contains delimitor ('\n'):
**		=> return line (without '\n').
**		Else while there isn't a '\n' it appends string with next string.
**		Display line before to return it.
*/
char		*get_next_line(int fd)
{
  char		*str;
  char		*tmp;

  str = my_read(fd);
  if (str == NULL)
    return (NULL);
  while (str[end_of_line(str)] != '\n' && my_strlen(str) < BUFF_SIZE * 10)
    {
      tmp = my_read(fd);
      if (tmp == NULL)
        return (NULL);
      str = my_strcatdup(str, tmp);
      if (str == NULL)
        return (NULL);
    }
  str[end_of_line(str)] = '\0';
  if (my_str_isprintable(str))
    return (str);
  my_putstr(str);
  my_putchar('\n');
  return (str);
}
Ejemplo n.º 4
0
int main()
{
    printf("%i",my_str_isprintable("isprintable"));
    return(0);
}