/** Close terminal device **/ int ttclose() { short value; short error; /* Cancel transparent editing mode */ value = 0; FDEVICECONTROL(mpetermin, &value, 1, 192, 15, 2, &error); #ifdef DEBUG if (ccode() != CCE) { printf("FDEVICECONTROL(15) failed; error %d\n", error); } #endif /* DEBUG */ /* Restore echoing */ FDEVICECONTROL(mpetermin, &mpeoecho, 1, 192, 4, 2, &error); #ifdef DEBUG if (ccode() != CCE) { printf("FDEVICECONTROL(4) failed; error %d\n", error); } #endif /* DEBUG */ /* Restore type ahead */ FDEVICECONTROL(mpetermin, &mpeotahd, 1, 192, 51, 2, &error); #ifdef DEBUG if (ccode() != CCE) { printf("FDEVICECONTROL(51) failed; error %d\n", error); } #endif /* DEBUG */ /* Close terminal */ FCLOSE(mpetermin, 0, 0); FCLOSE(mpetermout, 0, 0); /* Success */ return(0); }
int __bind_mpe_fsync(int file) { int ccode_return,dummy=0; /* Complete I/O */ FCONTROL(_mpe_fileno(file),2,__bind_mpe_longaddr(&dummy)); if ((ccode_return=ccode()) != CCE) { fprintf(stderr,"MPE fsync complete failed, ccode=%d\n",ccode_return); PRINTFILEINFO(_mpe_fileno(file)); errno = ESYSERR; return -1; } return 0; }
/** Flush output buffer to display **/ int ttflush() { int len; /* Compute length of write */ len = outbuft - outbuf; if (len == 0) return(0); /* Reset buffer position */ outbuft = outbuf; /* Perform write to screen */ FWRITE(mpetermout, outbuf, -len, 0320); #ifdef DEBUG if (ccode() != CCE) { printf("FWRITE fails\n"); } #endif return 0; }
/** Open terminal device **/ int ttopen() { short value; short error; /* Open terminal for input */ mpetermin = FOPEN(0, 0444, 0, -80); if (ccode() != CCE) { #ifdef DEBUG printf("Cannot open $STDIN\n"); #endif /* DEBUG */ goto error_stdin; } /* Open terminal for output */ mpetermout = FOPEN(0, 0414, 1, -80); if (ccode() != CCE) { #ifdef DEBUG printf("Cannot open $STDLIST\n"); #endif /* DEBUG */ goto error_stdlist; } /* Get terminal type */ FCONTROL(mpetermin, 39, &mpetype); if (ccode() != CCE) { #ifdef DEBUG printf("FCONTROL(39) failed\n"); #endif /* DEBUG */ goto error_other; } /* Set transparent editing mode */ #ifdef DEBUG value = '*'; #else value = '\377'; #endif FDEVICECONTROL(mpetermin, &value, 1, 192, 15, 2, &error); if (ccode() != CCE) { #ifdef DEBUG printf("FDEVICECONTROL(15) failed; error %d\n", error); #endif /* DEBUG */ goto error_other; } /* Turn off echo */ mpeoecho = 0; FDEVICECONTROL(mpetermin, &mpeoecho, 1, 192, 4, 3, &error); if (ccode() != CCE) { #ifdef DEBUG printf("FDEVICECONTROL(4) failed; error %d\n", error); #endif /* DEBUG */ goto error_other; } /* Set type ahead */ mpeotahd = 1; FDEVICECONTROL(mpetermin, &mpeotahd, 1, 192, 51, 3, &error); if (ccode() != CCE) { #ifdef DEBUG printf("FDEVICECONTROL(51) failed; error %d\n", error); #endif /* DEBUG */ goto error_other; } /* Success */ return(0); error_other: FCLOSE(mpetermout, 0, 0); error_stdlist: FCLOSE(mpetermin, 0, 0); error_stdin: return -1; }