static void end_dump(struct object_request *r, void *p) { struct cache_entry *ce; int oh; if (!r->state || (r->state == 1 && dmp != D_SOURCE)) return; if ((oh = get_output_handle()) == -1) return; ce = r->ce; if (dmp == D_SOURCE) { if (ce) { struct fragment *frag; nextfrag: foreach(frag, ce->frag) if (frag->offset <= dump_pos && frag->offset + frag->length > dump_pos) { off_t l; int w; l = frag->length - (dump_pos - frag->offset); if (l >= MAXINT) l = MAXINT; w = hard_write(oh, frag->data + dump_pos - frag->offset, (int)l); if (w != l) { detach_object_connection(r, dump_pos); if (w < 0) fprintf(stderr, "Error writing to stdout: %s.\n", strerror(errno)); else fprintf(stderr, "Can't write to stdout.\n"); retval = RET_ERROR; goto terminate; } dump_pos += w; detach_object_connection(r, dump_pos); goto nextfrag; } } if (r->state >= 0) return; } else if (ce) {
void erase_screen(struct terminal *term) { if (!term->master || !is_blocked()) { if (term->master) want_draw(); hard_write(term->fdout, "\033[2J\033[1;1H", 10); if (term->master) done_draw(); } }
void redraw_screen(struct terminal *term) { int x, y, p = 0; int cx = term->lcx, cy = term->lcy; unsigned char *a; int attrib = -1; int mode = -1; int l = 0; struct term_spec *s; if (!term->dirty || (term->master && is_blocked())) return; a = init_str(); s = term->spec; for (y = 0; y < term->y; y++) for (x = 0; x < term->x; x++, p++) { if (y == term->y - 1 && x == term->x - 1) break; if (term->screen[p] == term->last_screen[p]) continue; if ((term->screen[p] & 0x3800) == (term->last_screen[p] & 0x3800) && ((term->screen[p] & 0xff) == 0 || (term->screen[p] & 0xff) == 1 || (term->screen[p] & 0xff) == ' ') && ((term->last_screen[p] & 0xff) == 0 || (term->last_screen[p] & 0xff) == 1 || (term->last_screen[p] & 0xff) == ' ') && (x != term->cx || y != term->cy)) continue; term->last_screen[p] = term->screen[p]; if (cx == x && cy == y) goto pc;/*PRINT_CHAR(p)*/ else if (cy == y && x - cx < 10 && x - cx > 0) { int i; for (i = x - cx; i >= 0; i--) PRINT_CHAR(p - i); } else { add_to_str(&a, &l, "\033["); add_num_to_str(&a, &l, y + 1); add_to_str(&a, &l, ";"); add_num_to_str(&a, &l, x + 1); add_to_str(&a, &l, "H"); cx = x; cy = y; pc: PRINT_CHAR(p); } } if (l) { if (s->col) add_to_str(&a, &l, "\033[37;40m"); add_to_str(&a, &l, "\033[0m"); if (s->mode == TERM_LINUX && s->m11_hack) add_to_str(&a, &l, "\033[10m"); if (s->mode == TERM_VT100) add_to_str(&a, &l, "\x0f"); } term->lcx = cx; term->lcy = cy; if (term->cx != term->lcx || term->cy != term->lcy) { term->lcx = term->cx; term->lcy = term->cy; add_to_str(&a, &l, "\033["); add_num_to_str(&a, &l, term->cy + 1); add_to_str(&a, &l, ";"); add_num_to_str(&a, &l, term->cx + 1); add_to_str(&a, &l, "H"); } if (l && term->master) want_draw(); hard_write(term->fdout, a, l); if (l && term->master) done_draw(); mem_free(a); term->dirty = 0; }
static void inline safe_hard_write(int fd, unsigned char *buf, int len) { if (is_blocked()) return; want_draw(); hard_write(fd, buf, len); done_draw(); }
void end_dump(struct status *stat, void *p) { struct cache_entry *ce = stat->ce; int oh = get_output_handle(); if (oh == -1) return; if (ce && ce->redirect && dump_red_count++ < MAX_REDIRECTS) { unsigned char *u, *p; if (stat->state >= 0) change_connection(stat, NULL, PRI_CANCEL); u = join_urls(ce->url, ce->redirect); if (!http_bugs.bug_302_redirect) if (!ce->redirect_get && (p = strchr(ce->url, POST_CHAR))) add_to_strn(&u, p); load_url(u, stat, PRI_MAIN, 0); mem_free(u); return; } if (stat->state >= 0 && stat->state < S_TRANS) return; if (stat->state >= S_TRANS && dmp != D_SOURCE) return; if (dmp == D_SOURCE) { if (ce) { struct fragment *frag; nextfrag: foreach(frag, ce->frag) if (frag->offset <= dump_pos && frag->offset + frag->length > dump_pos) { int l = frag->length - (dump_pos - frag->offset); int w = hard_write(oh, frag->data + dump_pos - frag->offset, l); if (w != l) { detach_connection(stat, dump_pos); if (w < 0) fprintf(stderr, "Error writing to stdout: %s.\n", strerror(errno)); else fprintf(stderr, "Can't write to stdout.\n"); retval = RET_ERROR; goto terminate; } dump_pos += w; detach_connection(stat, dump_pos); goto nextfrag; } } if (stat->state >= 0) return; } else if (ce) {