/* ------------------------------------------------------------------------- */ #include <stdio.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/parport.h> #include <linux/ppdev.h> main() { int fd, rc, i; int mode; char buf[32768]; int fd1; fd1= open ("dumpFile", O_RDONLY); fd = open ("/dev/parport0", O_RDWR); if (fd == -1) { perror("open."); exit(1); } rc = ioctl (fd, PPCLAIM); if (rc == -1) { perror("PPCLAIM."); exit(1); } mode = IEEE1284_MODE_ECP; rc = ioctl(fd,PPNEGOT, &mode); if (rc == -1) { perror("PPNEGOT."); exit(1); } rc = ioctl (fd, PPSETMODE, &mode); if (rc == -1) { perror("PPSETMODE."); exit(1); } for (;;) { rc = read(fd1, buf, 32768); if (rc==0) break; rc = write (fd, buf, rc); if (rc < 0) { perror("write"); break; } usleep(1); } mode = IEEE1284_MODE_COMPAT; rc = ioctl(fd,PPNEGOT, &mode); if (rc == -1) { perror("PPNEGOT."); exit(1); } rc = ioctl (fd, PPSETMODE, &mode); if (rc == -1) { perror("PPSETMODE."); exit(1); } rc = ioctl (fd, PPRELEASE); if (rc == -1) { perror("PPRELEASE."); exit(1); } close(fd); }