1 /* VDMP: version 4.1 updated 02/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 BUFSIZE 16384 13 14 extern char *ctime(); 15 extern long time(); 16 17 char *Sid = "@(#)vdmp.c 4.1\t02/12/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 /* write header */ 60 { 61 char str[512]; 62 long clock; 63 clock = time(0); 64 sprintf(str,"%s:%s%s\n\0",name,ctime(&clock),banner); 65 ioctl(3, VSETSTATE,prtmd); 66 write(3,str,strlen(str) & 0xfffffffe); /*makes strlen even*/ 67 } 68 while (argc>b) { 69 in = open(argv[b++], 0); 70 if(in == NULL) { 71 char str[128]; 72 sprintf(str,"%s: No such file\n\n\n",argv[b-1]); 73 ioctl(3, VSETSTATE,prtmd); 74 write(3,str, strlen(str)); 75 } 76 else putplot(); 77 } 78 } 79 80 81 putplot() 82 { 83 int i; 84 85 /* vpd has already opened the Versatec as device 3 */ 86 ioctl(3, VSETSTATE, plotmd); 87 while( (i=read(in,vpbuf, BUFSIZE)) > 0) 88 write(3,vpbuf,i); 89 } 90