char *check_comment(char *str) { int fd; int quotes; char *comment; char *tmp; fd = xopen(str, O_RDONLY); comment = NULL; while ((tmp = get_next_line(fd))) { if (my_strncmp(tmp, COMMENT_CMD_STRING, 8) == 0) { quotes = count_dot(tmp, 0, '"'); if (quotes < 2) print_bad_comment(); else return (recup_comment(tmp)); } } close(fd); if (comment == NULL) print_header_error(); return (NULL); }
char *recup_comment(char *str) { char *save; int i; int j; i = 0; j = 0; while (str[i] != '\"') i++; save = xmalloc(sizeof(char) * COMMENT_LENGTH + 1); while (str[++i] != '"' && count_dot(str, i, '"') >= 1) { save[j] = str[i]; j++; } save[j] = 0; return (save); }
char *recup_name(char *str) { int i; int j; char *save; save = xmalloc(PROG_NAME_LENGTH * sizeof(char)); i = 0; j = 0; while (str[i] != '"') i++; while (str[++i] != '"' && count_dot(str, i, '"') >= 1) { save[j] = str[i]; j++; } save[j] = '\0'; return (save); }
int count_dot_pair(char *x, int xlen, char *y, int ylen) { int xdot = count_dot(x, xlen); int ydot = count_dot(y, ylen); return (xdot > ydot ? xdot : ydot); }