Put the case defn and the system-status enumeration in a file and load it into the base package. Have system status be a enumeration macro that doesn't give numbers but instead calls to (named-c-constant "FOO") with the obvious translation. Need a normal enumerated definition for running with Scheme. Of course, if there is no overlap we can just use negative numbers for the error numbers visible in Pre-Scheme. PS_READ_CHAR(port_10X, Kchar_27X, eofP_15X, status_16X) #define PS_PEEK_CHAR(PORT,RESULT,EOFP,STATUS) { FILE * TTport = PORT; if (EOF == (RESULT = getc(TTport))) RESULT = ps_read_char(TTport, &EOFP, &STATUS); else { EOFP = 0; STATUS = 0; } } #define PS_GETC(PORT,RESULT) /* RESULT = getc(PORT); */ \ { \ FILE * TTport = PORT; \ int errorp; \ while (EOF == (RESULT = getc(TTport)) \ && (errorp = ferror(TTport), \ clearerr(TTport), \ (errorp && errno == EINTR))) \ ; \ } char ps_read_char( FILE *filep, int *eofp ) { int value; while (TRUE) { value = getc(filep); if (EOF != value) { *eofp = FALSE; return value; } if (ferror(filep)) { clearerr(filep); if (errno != EINTR) { ps_status_errno = errno; *eofp = FALSE; return 0; } } else { *eofp = TRUE; return 0; }} } /* Identical to ps_read_char except that we give the character back. */ char ps_peek_char( FILE *filep ) { int value; while (TRUE) { value = getc(filep); if (EOF != value) { ungetc(value); return value; } if (ferror(filep)) { clearerr(filep); if (errno != EINTR) { ps_status_errno = errno; return 0; } } else { ps_status_errno = EOF_ERRNO; return 0; } } } void ps_write_char( char c; FILE *filep ) { while (TRUE) { if (EOF != putc(c, filep); return; if (ferror(filep)) { clearerr(filep); if (errno != EINTR) { ps_status_errno = errno; return; } } else { ps_status_errno = EOF_ERRNO; return; } } } ; no status current-input-port current-output-port current-error-port ; -> port status open-input-file open-output-file ; -> status close-output-port close-input-port ; -> value eof? status read-char peek-char read-integer ; -> status write-char newline write-string write-integer force-output Error status: no-errors 0 parse-error EINVAL invalid argument pending-i/o EAGAIN? resource temporarily unavailable file-not-found ENOENT no such EISDIR is a directory out-of-memory ENOMEM not enough space out-of-channels EMFILE too many open files channel-closed EBADF bad file descriptor no-such-channel EBADF bad file descriptor