|
|
1.1 ! root 1: #include "ex.h" ! 2: #include <ssdef.h> ! 3: #include <iodef.h> ! 4: #include <ttdef.h> ! 5: #include <descrip.h> ! 6: ! 7: /* ! 8: * These are hack routines that will only work with ! 9: * ex/vi on vms. If you use it for anything else, ! 10: * that's your problem. ! 11: */ ! 12: ! 13: static $DESCRIPTOR(inpdev, "TT"); /* Terminal to use for input */ ! 14: static long termset[2] = { 0,0 }; /* No terminator */ ! 15: static short iosb[4]; ! 16: ! 17: static short ichan = -1; /* Gets channel for inpdev */ ! 18: static int cbreak = 0; /* Whether we are in cbreak mode */ ! 19: ! 20: /* ARGSUSED */ ! 21: gtty(chan, ttybuf) ! 22: int chan; ! 23: struct sgttyb *ttybuf; ! 24: { ! 25: int errcode; ! 26: long term_char[2]; ! 27: ! 28: if (ichan < 0) ! 29: set_ichan(); ! 30: errcode = sys$qiow(1, ichan, IO$_SENSEMODE, iosb, NULL, 0, ! 31: term_char, 0, 0, 0, 0, 0); ! 32: if (errcode != SS$_NORMAL) ! 33: return -1; ! 34: switch (iosb[1]) { ! 35: case TT$C_BAUD_300: ! 36: ttybuf->sg_ispeed = ttybuf->sg_ospeed = B300; ! 37: break; ! 38: case TT$C_BAUD_1200: ! 39: ttybuf->sg_ispeed = ttybuf->sg_ospeed = B1200; ! 40: break; ! 41: case TT$C_BAUD_9600: ! 42: /* ! 43: * Effectively the same as 2400 ! 44: */ ! 45: case TT$C_BAUD_2400: ! 46: ttybuf->sg_ispeed = ttybuf->sg_ospeed = B2400; ! 47: break; ! 48: default: ! 49: lprintf("Defaulting to 2400 baud terminal\n"); ! 50: flush(); ! 51: ttybuf->sg_ispeed = ttybuf->sg_ospeed = B2400; ! 52: break; ! 53: } ! 54: ttybuf->sg_erase = 0177; ! 55: ttybuf->sg_kill = CTRL(U); ! 56: ttybuf->sg_flags = ECHO | CRMOD; ! 57: if (cbreak) ! 58: ttybuf->sg_flags |= CBREAK; ! 59: return 0; ! 60: } ! 61: ! 62: stty(chan, ttybuf) ! 63: int chan; ! 64: struct sgttyb *ttybuf; ! 65: { ! 66: if (chan != 1) ! 67: return; ! 68: cbreak = (ttybuf->sg_flags & CBREAK); ! 69: return 0; ! 70: } ! 71: ! 72: set_ichan() ! 73: { ! 74: if (sys$assign(&inpdev, &ichan, 0, 0) != SS$_NORMAL) { ! 75: syserror("TT"); ! 76: ex_exit(1); ! 77: } ! 78: } ! 79: ! 80: vms_read(fd, buf, cnt) ! 81: int fd; ! 82: char *buf; ! 83: int cnt; ! 84: { ! 85: int errcode; ! 86: ! 87: if (fd != 0) ! 88: return read(fd, buf, cnt); ! 89: if (ichan < 0) ! 90: set_ichan(); ! 91: errcode = sys$qiow(1, ichan, ! 92: IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR, ! 93: NULL, NULL, 0, buf, 1, 0, &termset, NULL, 0); ! 94: if (errcode == SS$_NORMAL) ! 95: return 1; ! 96: else ! 97: return 0; ! 98: } ! 99: ! 100: vms_write(fd, buf, cnt) ! 101: int fd; ! 102: char *buf; ! 103: int cnt; ! 104: { ! 105: int errcode; ! 106: ! 107: if (fd != 1 || !cbreak) ! 108: return write(fd, buf, cnt); ! 109: if (ichan < 0) ! 110: set_ichan(); ! 111: errcode = sys$qiow(1, ichan, ! 112: IO$_WRITELBLK | IO$M_NOFORMAT, ! 113: NULL, NULL, 0, buf, cnt, 0, 0, 0, 0); ! 114: if (errcode == SS$_NORMAL) ! 115: return cnt; ! 116: else ! 117: return 0; ! 118: } ! 119: ! 120: /* ! 121: * getlog - getenv() look-alike routine for VMS logical names ! 122: * ! 123: * Chris Carlson 1nov84 ! 124: */ ! 125: char * ! 126: getlog(log) ! 127: char *log; ! 128: { ! 129: struct dsc$descriptor_s log_d = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; ! 130: static char trans[128]; ! 131: $DESCRIPTOR(trans_d, trans); ! 132: short int translen; ! 133: ! 134: log_d.dsc$a_pointer = log; ! 135: log_d.dsc$w_length = strlen(log); ! 136: if (lib$sys_trnlog(&log_d, &translen, &trans_d, 0, 0, 0) ! 137: == SS$_NORMAL) { ! 138: do { ! 139: log_d.dsc$a_pointer = trans; ! 140: log_d.dsc$w_length = translen; ! 141: } while (lib$sys_trnlog(&log_d, &translen, &trans_d, 0, 0, 0) ! 142: == SS$_NORMAL); ! 143: trans[translen] = '\0'; ! 144: return(trans); ! 145: } ! 146: return((char *)0); ! 147: } ! 148: ! 149: /* ! 150: * unlink: ! 151: * Removes a file. This is provided so there is a minimum ! 152: * of carnage in standard ex sources ! 153: */ ! 154: unlink(fname) ! 155: char *fname; ! 156: { ! 157: return delete(fname); ! 158: } ! 159: ! 160: vms_exit(n) ! 161: int n; ! 162: { ! 163: #undef _exit ! 164: if (n == 0) ! 165: _exit(SS$_NORMAL); ! 166: else ! 167: _exit(SS$_ABORT); ! 168: } ! 169: ! 170: bcopy(from, to, count) ! 171: char *from, *to; ! 172: int count; ! 173: { ! 174: lib$movc3(&count, from, to); ! 175: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.