DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T p

⟦50b1b4e16⟧ TextFile

    Length: 3037 (0xbdd)
    Types: TextFile
    Names: »psaptest.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/psap/psaptest.c« 

TextFile

/* psaptest.c - test out -lpsap */

#ifndef	lint
static char *rcsid = "$Header: /f/osi/psap/RCS/psaptest.c,v 7.0 89/11/23 22:13:26 mrose Rel $";
#endif

/* 
 * $Header: /f/osi/psap/RCS/psaptest.c,v 7.0 89/11/23 22:13:26 mrose Rel $
 *
 *
 * $Log:	psaptest.c,v $
 * Revision 7.0  89/11/23  22:13:26  mrose
 * Release 6.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);
}