/* py_pp.c - generic pretty-printer */
static char *rcsid
= "$Header: /f/osi/pepy/RCS/py_pp.c,v 7.1 91/02/22 09:35:20 mrose Interim $";
* $Header: /f/osi/pepy/RCS/py_pp.c,v 7.1 91/02/22 09:35:20 mrose Interim $
* Revision 7.1 91/02/22 09:35:20 mrose
* Revision 7.0 89/11/23 22:12:06 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
#define ps_advise(ps, f) \
advise (NULLCP, "%s: %s", (f), ps_error ((ps) -> ps_errno))
static char *myname
= "pp";
static enum { ps2pp
, pl2pp
} mode
= ps2pp
;
void adios (), advise ();
int PY_pp (argc
, argv
, envp
, pfx
)
if (myname
= rindex (argv
[0], '/'))
if (myname
== NULL
|| *myname
== NULL
)
for (argc
--, argv
++; cp
= *argv
; argc
--, argv
++)
if (strcmp (cp
+ 1, "ps") == 0) {
if (strcmp (cp
+ 1, "pl") == 0) {
adios (NULLCP
, "usage: %s [ -ps | -pl ] [ files... ]", myname
);
status
= process ("(stdin)", stdin
, pfx
);
if ((fp
= fopen (cp
, "r")) == NULL
) {
advise (cp
, "unable to read");
status
+= process (cp
, fp
, pfx
);
static int process (file
, fp
, pfx
)
if ((ps
= ps_alloc (std_open
)) == NULLPS
) {
ps_advise (ps
, "ps_alloc");
if (std_setup (ps
, fp
) == NOTOK
) {
advise (NULLCP
, "%s: std_setup loses", file
);
if ((pe
= ps2pe (ps
)) == NULLPE
)
if ((pe
= pl2pe (ps
)) == NULLPE
)
(void) (*pfx
) (pe
, 1, NULLIP
, NULLVP
, NULLCP
);
static void adios (va_alist
)
static void adios (what
, fmt
)
static void advise (va_alist
)
fprintf (stderr
, "%s: ", myname
);
(void) fputs (buffer
, stderr
);
(void) fputc ('\n', stderr
);
static void advise (what
, fmt
)