static int history_option(t_shell *sh, char **cmd, int fd) { t_hist *hist; int nbr; char *line; int i; i = 0; hist = sh->hist; if (numeric_error(cmd) == 1) return (1); nbr = ft_atoi(cmd[1]); while (hist->prev) { hist = hist->prev; i++; } nbr = i - 1 - nbr; while (get_next_line(fd, &line) > 0) { if (nbr < 0) ft_putendl(line); free(line); nbr--; } free(line); return (0); }
caddr_t numeric_bin_op (numeric_bop_t num_op, numeric_t x, numeric_t y, caddr_t * qst, state_slot_t * target) { int rc; caddr_t res_box = NULL; if (target) { res_box = QST_GET (qst, target); if (DV_NUMERIC == DV_TYPE_OF (res_box)) { rc = num_op ((numeric_t) res_box, x, y); } else { res_box = (caddr_t) numeric_allocate (); rc = num_op ((numeric_t) res_box, x, y); qst_set (qst, target, res_box); } } else { res_box = (caddr_t) numeric_allocate (); rc = num_op ((numeric_t) res_box, x, y); } if (rc != NUMERIC_STS_SUCCESS) { char state[10]; char msg[200]; numeric_error (rc, state, sizeof (state), msg, sizeof (msg)); sqlr_new_error (state, "SR083", "%s", msg); } return res_box; }