static char *my_cat_str(t_str *str) { t_str *tmp_str; char *new_line; t_uint i; int j; if (str == NULL) return (NULL); if ((new_line = my_str_new_line(str)) == NULL) return (NULL); str = my_first_str(str); i = 0; while (str != NULL) { j = 0; while (str->str[j] != '\0') new_line[i++] = str->str[j++]; tmp_str = str; str = str->next; my_free_str(tmp_str); } new_line[i] = '\0'; return (new_line); }
char *get_next_line(const int fd) { static char buffer[READ_SIZE]; char *str; static int i; static int j; if (!(i = 0) && ((str = malloc(BF * sizeof(char))) == NULL || BF == 0)) return (NULL); while (j < READ_SIZE && buffer[++j] == '\n' && buffer[j] != '\0'); while (buffer[j] != '\0' && buffer[j] != '\n' && i != BUFFER_SIZE) str[i++] = buffer[j++]; while ((i != BUFFER_SIZE && buffer[j] != '\n') || (j== 0 && i == 0)) { if ((j = read(fd, buffer, READ_SIZE)) == -1 || (j == 0 && i == 0)) return (my_free_str(str)); (j < READ_SIZE) ? (j = j - 1) : (j); buffer[j + 1] = '\0'; str[i] = '\0'; if (j <= 0 && i != 0) return (str); j = 0; while (buffer[j] != '\0' && buffer[j] != '\n' && i != BUFFER_SIZE) str[i++] = buffer[j++]; } str[i] = '\0'; return (str); }