1 /* VDMP: version 4.3 updated 05/13/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 BUFSIZE 16384 13 14 extern char *ctime(); 15 extern long time(); 16 17 char *Sid = "@(#)vdmp.c 4.3\t05/13/81"; 18 int plotmd[] = { VPLOT, 0, 0}; 19 int prtmd[] = { VPRINT, 0, 0}; 20 char *name = ""; 21 char *banner = ""; 22 23 char vpbuf[BUFSIZE]; 24 25 int in; 26 27 #define VARIAN 1 28 #define VERSATEC 2 29 30 int device = VARIAN; /* Indicate which device */ 31 int BytesPerLine = 264; /* Number of bytes per raster line of the output device */ 32 33 main(argc, argv) 34 char **argv; 35 { 36 extern int onintr(); 37 int b; 38 39 for(b=1; argv[b][0] == '-';b++) { 40 switch(argv[b][1]) { 41 case 'W': 42 device = VERSATEC; 43 BytesPerLine = 880; 44 break; 45 case 'V': 46 device = VARIAN; 47 BytesPerLine = 264; 48 break; 49 case 'n': 50 if(argv[++b] != 0) 51 name = argv[b]; 52 break; 53 case 'b': 54 if(argv[++b] != 0) 55 banner = argv[b]; 56 break; 57 } 58 } 59 /* page feed */ 60 if(device == VARIAN) { 61 ioctl(3, VSETSTATE,prtmd); 62 write(3,"\f",2); 63 } 64 if(device == VERSATEC) { 65 ioctl(3, VSETSTATE,prtmd); 66 write(3,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",16); 67 } 68 /* write header */ 69 { 70 char str[512]; 71 long clock; 72 clock = time(0); 73 sprintf(str,"%s:%s%s\n \0",name,ctime(&clock),banner); 74 ioctl(3, VSETSTATE,prtmd); 75 write(3,str,strlen(str) & 0xfffffffe); /*makes strlen even*/ 76 } 77 while (argc>b) { 78 in = open(argv[b++], 0); 79 if(in == NULL) { 80 char str[128]; 81 sprintf(str,"%s: No such file\n\n\n",argv[b-1]); 82 ioctl(3, VSETSTATE,prtmd); 83 write(3,str, strlen(str)); 84 exit(-1); 85 } 86 else putplot(); 87 } 88 if(device == VERSATEC) { 89 ioctl(3, VSETSTATE,prtmd); 90 write(3,"\n\n\n\n\n\n\n",8); 91 } 92 exit(0); 93 } 94 95 96 putplot() 97 { 98 register int i; 99 register char *buf; 100 101 buf = &(vpbuf[0]); 102 /* vpd has already opened the Versatec as device 3 */ 103 ioctl(3, VSETSTATE, plotmd); 104 while( (i=read(in,buf, BUFSIZE)) > 0) 105 if(write(3,buf,i)!=i) exit(1); 106 } 107