/* This is the last stream in the pipeline, so pw is irrelevant. */ static int s_fileno_write_process(stream_state * st, stream_cursor_read * pr, stream_cursor_write * ignore_pw, bool last) { int nwrite, status; uint count; again: count = pr->limit - pr->ptr; /* Some versions of the DEC C library on AXP architectures */ /* give an error on write if the count is zero! */ if (count == 0) { process_interrupts((stream*)st->memory); return 0; } /* See above regarding the Mac MetroWorks compiler. */ nwrite = write(sfileno((stream *)st), (const void *)(pr->ptr + 1), count); if (nwrite >= 0) { pr->ptr += nwrite; status = 0; } else if (errno_is_retry(errno)) /* Handle System V interrupts */ goto again; else status = ERRC; process_interrupts((stream *)st->memory); return status; }
/* This is the first stream in the pipeline, so pr is irrelevant. */ static int s_fileno_read_process(stream_state * st, stream_cursor_read * ignore_pr, stream_cursor_write * pw, bool last) { stream *s = (stream *)st; /* no separate state */ int fd = sfileno(s); uint max_count; int nread, status; again: max_count = pw->limit - pw->ptr; status = 1; if (s->file_limit < max_long) { long limit_count = s->file_offset + s->file_limit - ltell(fd); if (max_count > limit_count) max_count = limit_count, status = EOFC; } /* * In the Mac MetroWerks compiler, the prototype for read incorrectly * declares the second argument of read as char * rather than void *. * Work around this here. */ nread = read(fd, (void *)(pw->ptr + 1), max_count); if (nread > 0) pw->ptr += nread; else if (nread == 0) status = EOFC; else if (errno_is_retry(errno)) /* Handle System V interrupts */ goto again; else status = ERRC; process_interrupts(s->memory); return status; }
BOOL CALLBACK AbortProc2(HDC hdcPrn, int code) { process_interrupts(NULL); if (code == SP_OUTOFDISK) return (FALSE); /* cancel job */ return (TRUE); }
size_t input_enqueue(String keys) { char *ptr = keys.data; char *end = ptr + keys.size; while (rbuffer_space(input_buffer) >= 6 && ptr < end) { uint8_t buf[6] = { 0 }; unsigned int new_size = trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, true, true); if (new_size) { new_size = handle_mouse_event(&ptr, buf, new_size); rbuffer_write(input_buffer, (char *)buf, new_size); continue; } if (*ptr == '<') { char *old_ptr = ptr; // Invalid or incomplete key sequence, skip until the next '>' or *end. do { ptr++; } while (ptr < end && *ptr != '>'); if (*ptr != '>') { // Incomplete key sequence, return without consuming. ptr = old_ptr; break; } ptr++; continue; } // copy the character, escaping CSI and K_SPECIAL if ((uint8_t)*ptr == CSI) { rbuffer_write(input_buffer, (char *)&(uint8_t){K_SPECIAL}, 1); rbuffer_write(input_buffer, (char *)&(uint8_t){KS_EXTRA}, 1); rbuffer_write(input_buffer, (char *)&(uint8_t){KE_CSI}, 1); } else if ((uint8_t)*ptr == K_SPECIAL) { rbuffer_write(input_buffer, (char *)&(uint8_t){K_SPECIAL}, 1); rbuffer_write(input_buffer, (char *)&(uint8_t){KS_SPECIAL}, 1); rbuffer_write(input_buffer, (char *)&(uint8_t){KE_FILLER}, 1); } else { rbuffer_write(input_buffer, ptr, 1); } ptr++; } size_t rv = (size_t)(ptr - keys.data); process_interrupts(); return rv; }