Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site sask.UUCP Path: utzoo!utcsri!ubc-vision!alberta!sask!hardie From: hardie@sask.UUCP (Peter Hardie ) Newsgroups: net.micro.amiga Subject: Print.c - prints files. Message-ID: <332@sask.UUCP> Date: Tue, 18-Feb-86 15:34:49 EST Article-I.D.: sask.332 Posted: Tue Feb 18 15:34:49 1986 Date-Received: Tue, 18-Feb-86 19:48:42 EST Distribution: net Organization: University of Saskatchewan, CANADA Lines: 114 Here's the C (Lattice 3.02) source for a program that prints files. It's better than using the copy command but it does not work under Workbench. It's not a spooler but at least you can start it up in a CLI and forget about it until it's done. Pete ihnp4!sask!hardie /************************** CUT HERE *********************************/ /* print .... print files to the printer.device. print [-r | -nN] file [file [ file .....] ] The -r option causes print to write the files using raw I/O which means that all characters go through exactly as in the file. (i.e. escape sequences are not translated etc.) If -r is not specified then the normal device is used and any escape sequences are assumed to be the standard ISO ones used by the driver (see include/devices/printer.h for a list of codes) The program adds a formfeed at the end of each file. If the -nN option is used then only one file should be specified and that file will be printed N times without the formfeed between each one. This is useful for printing an address label umpty times. BUGS: Yep. It does not look for a cancel signal so once started it goes until it's done or until a reboot, whichever occurs first. PUBLIC DOMAIN FREEBIE ..... just don't sell it turkey! Peter Hardie ihnp4!sask!hardie Saskatoon, Sask, Canada. */ #include #include #include #include #include struct IOStdReq *iorb,iob; struct InputEvent *event,ev; char buf[512]; char formfeed = '\014'; main(argc,argv) char *argv[]; int argc; { int ifd,rawwrite; int num; int repeat, count; event = &ev; iorb = &iob; OpenDevice("printer.device",1,iorb,0); if(iorb->io_Error) { printf("can't open printer.device\n"); exit(); } iorb->io_Message.mn_ReplyPort = CreatePort("printer_reply",0L); if(iorb->io_Message.mn_ReplyPort == NULL) { CloseDevice(iorb); printf("can't get a reply port\n"); exit(); } rawwrite = CMD_WRITE; repeat = 1; if(argc > 1) { while(argv[1][0] == '-') { argv++; argc--; switch(argv[0][1]) { case 'r': rawwrite = PRD_RAWWRITE; break; case 'n': repeat = atoi(&argv[0][2]); break; default: printf("unknown argument '%s'\n",argv[0]); usage(); goto finish; } } } if((repeat > 1) && (argc != 2)) { printf("arg count: only one file can be repeated\n"); goto finish; } while(argc > 1) { if((ifd = open(argv[1],O_RDONLY)) == 0) { printf("can't open %s\n",argv[1]); argc--; argv++; continue; } for(count = 0; count < repeat; count++) { while((num = read(ifd,&buf[0],512)) > 0) { iorb->io_Command = rawwrite; iorb->io_Length = num; iorb->io_Data = &buf[0]; DoIO(iorb); } if(repeat > 1)lseek(ifd,0L,0); } iorb->io_Command = rawwrite; iorb->io_Length = 1; iorb->io_Data = &formfeed; DoIO(iorb); close(ifd); argc--; argv++; } finish: CloseDevice(iorb); } usage() { printf("Usage: print [-r | -nN] file [file .....]\n"); printf("If -nN is specified then only one file should be given\n"); }