/* pe2ssdu.c - write a PE to a SSDU */

#ifndef	lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/psap/pe2ssdu.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif

/* 
 * $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/psap/pe2ssdu.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
 *
 *
 * $Log: pe2ssdu.c,v $
 * Revision 1.1.1.1  2018/04/24 16:12:56  root
 * BSD 4.3reno
 *
 * Revision 7.0  89/11/23  22:12:57  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.
 *
 */


/* LINTLIBRARY */

#include <stdio.h>
#include "psap.h"
#include "tailor.h"

/*  */

int	pe2ssdu (pe, base, len)
register PE pe;
char  **base;
int    *len;
{
    register PS ps;

    *base = NULL, *len = 0;

    if ((ps = ps_alloc (str_open)) == NULLPS)
	return NOTOK;
    if (str_setup (ps, NULLCP, ps_get_abs (pe), 0) == NOTOK
	    || pe2ps_aux (ps, pe, 0) == NOTOK) {
	ps_free (ps);
	return NOTOK;
    }

    *len = ps -> ps_ptr - (*base = ps -> ps_base);

    ps -> ps_base = ps -> ps_ptr = NULL;
    ps_free (ps);

#ifdef	DEBUG
    if (psap_log -> ll_events & LLOG_PDUS)
	pe2text (psap_log, pe, 0, *len);
#endif

    return OK;
}
