|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 3037 (0xbdd)
Types: TextFile
Names: »psaptest.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/psap/psaptest.c«
/* psaptest.c - test out -lpsap */
#ifndef lint
static char *rcsid = "$Header: /f/osi/psap/RCS/psaptest.c,v 6.0 89/03/18 23:39:07 mrose Rel $";
#endif
/*
* $Header: /f/osi/psap/RCS/psaptest.c,v 6.0 89/03/18 23:39:07 mrose Rel $
*
*
* $Log: psaptest.c,v $
* Revision 6.0 89/03/18 23:39:07 mrose
* Release 5.0
*
*/
/*
* NOTICE
*
* 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
* this agreement.
*
*/
#include <stdio.h>
#include "psap.h"
#include "tailor.h"
/* \f
*/
static enum {
ps2pl, ps2ps, pl2pl, pl2ps
} mode;
/* \f
*/
/* ARGSUSED */
main (argc, argv, envp)
int argc;
char **argv,
**envp;
{
char *cp;
register PE pe;
register PS ps;
argc--, argv++;
if (argc != 1) {
usage: ;
fprintf (stderr, "usage: psaptest [ps2pl | ps2ps | pl2pl | pl2ps]\n");
exit (1);
}
if (strcmp (*argv, "version") == 0) {
printf ("%s\n", psapversion);
exit (0);
}
if ((cp = getenv ("PSAPTEST")) && *cp) {
psap_log -> ll_events = atoi (cp);
psap_log -> ll_stat |= LLOGTTY;
}
if (strcmp (*argv, "binary") == 0) {
int i;
char buffer[BUFSIZ],
packet[BUFSIZ];
while (fgets (buffer, sizeof buffer, stdin)) {
if (*buffer == ' ')
(void) strncpy (packet, buffer + 1, i = strlen (buffer) - 2);
else
i = implode ((u_char *) packet, buffer, strlen (buffer) - 1);
(void) fwrite (packet, sizeof *packet, i, stdout);
}
exit (0);
}
if (strcmp (*argv, "ps2pl") == 0)
mode = ps2pl;
else
if (strcmp (*argv, "ps2ps") == 0)
mode = ps2ps;
else
if (strcmp (*argv, "pl2pl") == 0)
mode = pl2pl;
else
if (strcmp (*argv, "pl2ps") == 0)
mode = pl2ps;
else
goto usage;
for (;;) {
if ((ps = ps_alloc (std_open)) == NULLPS) {
fprintf (stderr, "ps_alloc(stdin): you lose\n");
exit (1);
}
if (std_setup (ps, stdin) == NOTOK)
ps_die (ps, "std_setup(stdin)");
switch (mode) {
case ps2pl:
case ps2ps:
if ((pe = ps2pe (ps)) == NULLPE)
if (ps -> ps_errno)
ps_die (ps, "ps2pe");
else
exit (0);
break;
case pl2ps:
case pl2pl:
if ((pe = pl2pe (ps)) == NULLPE)
if (ps -> ps_errno)
ps_die (ps, "pl2pe");
else
exit (0);
break;
}
ps_free (ps);
if ((ps = ps_alloc (std_open)) == NULLPS) {
fprintf (stderr, "ps_alloc(stdout): you lose\n");
exit (1);
}
if (std_setup (ps, stdout) == NOTOK)
ps_die (ps, "std_setup(stdout)");
switch (mode) {
case ps2ps:
case pl2ps:
if (pe2ps (ps, pe) == NOTOK)
ps_die (ps, "pe2ps");
break;
case pl2pl:
case ps2pl:
if (pe2pl (ps, pe) == NOTOK)
ps_die (ps, "pe2pl");
break;
}
ps_free (ps);
}
}
/* \f
ERRORS */
static ps_die (ps, s)
register PS ps;
register char *s;
{
fprintf (stderr, "%s: %s\n", s, ps_error (ps -> ps_errno));
exit (1);
}