Date: Sun, 21 Apr 1996 18:27:40 +0200 (IST) From: Eli Zaretskii To: kagel AT dg1 DOT bloomberg DOT com Cc: djgpp AT delorie DOT com Subject: Re: Help writing to the printer In-Reply-To: <9604191241.AA04010@quasar.bloomberg.com > Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 19 Apr 1996 kagel AT quasar DOT bloomberg DOT com wrote: > had with piped output, but, it did not. I am trying to write to the default > DOS printer (PRN, LPT1) and cannot. The app's output goes to the DJGPP temp > directory and never prints. Anyone have a solution? Anyone try this? I'll There is a bug in the DJGPP v2 library: it defines `stdprn' as using file handle 3 and `stdaux' as using handle 4, whereas it should be the other way around. So when you fprintf to stdprn, it actually tries to write to the COM1 port, with the obvious results. To correct this, compile the files `stdprn.c' and `stdaux.c' below and put them into your C library, like this: gcc -Wall -O3 -c stdprn.c gcc -Wall -O3 -c stdaux.c ar rvs c:/djgpp/lib/libc.a stdprn.o stdaux.o ranlib c:/djgpp/lib/libc.a and print happily ever after by writing to stdprn. > In my Borland and other 16bit versions I just wrote to stdprn or opened > a file named "PRN" and voila! Neither solution seems to work. Opening "PRN" or "LPT1" works for me. For instance the following program really prints: #include void main (void) { FILE *fprn = fopen ("PRN", "a"); fprintf (fprn, "Hello, world!\n\f"); } (I add '\f' because some laser printers won't actually eject the paper until they see a form-feed--maybe that's your problem?) -------------- stdprn.c ----------------------------------- /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include FILE __dj_stdprn = { 0, 0, 0, 0, _IOWRT | _IOLBF, 4 }; ------------------------ stdaux.c -------------------------------- /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include FILE __dj_stdaux = { 0, 0, 0, 0, _IORW | _IONBF, 3 };