ITEM: BA6529L
Filtering printer data
Question:
ENV:
AIX 3.2.5
7013-360
DESC:
We have an application which generates data and sends
it to an AIX print queue. However, the application
adds both carriage returns and linefeeds to the end
of each line of data. We need to selectively filter
out SOME of these \\n. If there is a \\r\\n in the file
(carriage return newline) we want to print just the
carriage return. If a \\n (newline) appears without
a carriage return in front of it we need to print it.
Response:
ACT:
Wrote this C program for you:
/*
Set the _f virtual printer attribute to c:
Name Description Value
_f Single-Character BSD-type Filter Name (e.g., "p" c
for "pr" filter)
Then, the fc to another C program we will write:
Name Description Value
fc Command String for the "c" Filter. /fc Command String for the "c" Filter. /bin/rmnl
where /bin/rmnl is the compiled version of this C program:
*/
\#include \
main (int argc, char **argv)
{ int ch1, ch2;
while (EOF != (ch1 = fgetc(stdin))) /* Read the 1st character */
if (ch1 == '\\r') /* If 1st character is \\r */
{
ch2 = fgetc(stdin); /* then read a 2nd char */
if(ch2 == '\\n') /* If 1st is \\r and 2nd \\n */
fputc(ch1, stdout); /* then print \\r but not \\n */
}
else
fputc(ch1, stdout); /* 1st character was not a \\r */
/* so print it - whether it */
/* is a \\n or not. */
} Placed this code on your system and ran several test print
jobs. It works as desired.
Support Line: Filtering printer data ITEM: BA6529L
Dated: October 1995 Category: N/A
This HTML file was generated 99/06/24~13:30:23
Comments or suggestions?
Contact us