|
|
1.1 ! root 1: /* VDMP: version 4.4 updated 7/12/81 ! 2: * ! 3: * reads raster file created by cifplot and dumps it onto the ! 4: * Varian or Versatec plotter. ! 5: * Must be called with vcontrol or by vpd/vad daemon since ! 6: * it assumes plotter is already opened as device 3. ! 7: */ ! 8: #include <stdio.h> ! 9: #include <signal.h> ! 10: #include <sys/vcmd.h> ! 11: ! 12: #define MAGIC_WORD 0xA5CF4DFA ! 13: ! 14: #define BUFSIZE 1024*128 ! 15: #define BLOCK 1024 ! 16: ! 17: extern char *ctime(); ! 18: extern long time(); ! 19: ! 20: char *Sid = "@(#)vdmp.c 4.4\t7/12/81"; ! 21: int plotmd[] = { VPLOT, 0, 0}; ! 22: int prtmd[] = { VPRINT, 0, 0}; ! 23: char *name = ""; ! 24: char *banner = ""; ! 25: ! 26: int inbuf[BLOCK/sizeof(int)]; ! 27: char vpbuf[BUFSIZE]; ! 28: ! 29: int in; ! 30: ! 31: #define VARIAN 1 ! 32: #define VERSATEC 2 ! 33: ! 34: int device = VARIAN; /* Indicate which device */ ! 35: int BytesPerLine = 264; /* Number of bytes per raster line of the output device */ ! 36: ! 37: main(argc, argv) ! 38: char **argv; ! 39: { ! 40: extern int onintr(); ! 41: int b; ! 42: ! 43: for(b=0; argv[1][0] == '-';b++) { ! 44: switch(argv[1][1]) { ! 45: case 'W': ! 46: device = VERSATEC; ! 47: BytesPerLine = 880; ! 48: break; ! 49: case 'V': ! 50: device = VARIAN; ! 51: BytesPerLine = 264; ! 52: break; ! 53: case 'n': ! 54: argc--; argv++; ! 55: if(argv[1] != 0) ! 56: name = argv[1]; ! 57: break; ! 58: case 'b': ! 59: argc--; argv++; ! 60: if(argv[1] != 0) ! 61: banner = argv[b]; ! 62: break; ! 63: } ! 64: argc--; argv++; ! 65: } ! 66: if(argc < 2) exit(-1); ! 67: /* page feed */ ! 68: if(device == VARIAN) { ! 69: ioctl(3, VSETSTATE,prtmd); ! 70: write(3,"\f",2); ! 71: } ! 72: if(device == VERSATEC) { ! 73: ioctl(3, VSETSTATE,prtmd); ! 74: write(3,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",16); ! 75: } ! 76: /* open dump file */ ! 77: in = open(argv[1], 0); ! 78: if(in == NULL) { ! 79: char str[128]; ! 80: sprintf(str,"%s: No such file\n\n\n",argv[1]); ! 81: ioctl(3, VSETSTATE,prtmd); ! 82: write(3,str, strlen(str)); ! 83: exit(-1); ! 84: } ! 85: /* write header */ ! 86: { char str[512]; ! 87: long clock; ! 88: clock = time(0); ! 89: sprintf(str,"%s:%s%s",name,ctime(&clock),banner); ! 90: ioctl(3, VSETSTATE,prtmd); ! 91: write(3,str,(strlen(str)+1) & 0xfffffffe); /*makes strlen even*/ ! 92: } ! 93: /* open file for reading */ ! 94: b=read(in,inbuf,BLOCK); ! 95: if(inbuf[0] == MAGIC_WORD && b == BLOCK) { ! 96: /* we have a formatted dump file */ ! 97: inbuf[(BLOCK/sizeof(int))-1] = 0; /* make sure string terminates */ ! 98: write(3,&(inbuf[4]),(strlen(&(inbuf[4]))+1) & 0xfffe); ! 99: ioctl(3, VSETSTATE,prtmd); ! 100: write(3," \n",2); ! 101: putplot(); ! 102: close(in); ! 103: } ! 104: else { /* dump file not formatted */ ! 105: /* reset in's seek pointer and plot */ ! 106: close(in); ! 107: in = open(argv[1], 0); ! 108: putplot(); ! 109: close(in); ! 110: } ! 111: if(device == VERSATEC) { ! 112: ioctl(3, VSETSTATE,prtmd); ! 113: write(3,"\n\n\n\n\n\n\n",8); ! 114: } ! 115: exit(0); ! 116: } ! 117: ! 118: ! 119: putplot() ! 120: { ! 121: register int i; ! 122: register char *buf; ! 123: ! 124: buf = &(vpbuf[0]); ! 125: /* vpd has already opened the Versatec as device 3 */ ! 126: ioctl(3, VSETSTATE, plotmd); ! 127: while( (i=read(in,buf, BUFSIZE)) > 0) ! 128: if(write(3,buf,i)!=i) exit(1); ! 129: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.