HP-UX SNAplus2 RJE User's Guide

Program Output with PDIRs
Output Program Example
Appendix A 161
Output Program Example
This example consists of two parts: a script that is configured as the
output program, and a C program that must be compiled and installed as
/opt/sna/bin/catrje.
The script uses this program to produce sections of the offset that are
indexed by byte offsets from the PDIR file. The script is used to separate
the header and trailer from an output file and then to append the header
and trailer to each other section of output. Copies of these assembled
sections of output then print, according to the number of copies specified
in the PDIR.
Example:
/*Compile this program and install it as/opt/sna/bin/catrje*
#include <stdio.h>
void main(argc,argv)
int argc;
char *argv[];
{
int ch;
int count = 1;
int offset1,offset2;
offset1 = atoi(argv[1];
offset2 = atoi(argv[2];
ch = getc(stdin);
while ((ch != EOF) && (count <= offset2))
{
if (count >= offset1)
putc(ch,stdout);
ch = getc(stdin);
count++;
}
}
#!/bin/ksh
#This script is only an example. It is not supported code and
#Hewlett-Packard does not provide assistance if it does not work
#or needs modification.