/* pe2ps.c - presentation element to presentation stream */
static char *rcsid
= "$Header: /f/osi/psap/RCS/pe2ps.c,v 7.1 91/02/22 09:36:01 mrose Interim $";
* $Header: /f/osi/psap/RCS/pe2ps.c,v 7.1 91/02/22 09:36:01 mrose Interim $
* Revision 7.1 91/02/22 09:36:01 mrose
* Revision 7.0 89/11/23 22:12:56 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
static PElement pe_eoc
= { PE_CLASS_UNIV
, PE_FORM_PRIM
, PE_UNIV_EOC
, 0 };
int pe2ps_aux (ps
, pe
, eval
)
if ((result
= pe2ps_aux2 (ps
, pe
, eval
)) != NOTOK
)
static int pe2ps_aux2 (ps
, pe
, eval
)
if (pe
-> pe_form
== PE_FORM_ICONS
) {
if (ps_write_aux (ps
, pe
-> pe_prim
, pe
-> pe_len
, 1) == NOTOK
)
if (ps_write_id (ps
, pe
) == NOTOK
|| ps_write_len (ps
, pe
) == NOTOK
)
if (ps_write_aux (ps
, pe
-> pe_prim
, pe
-> pe_len
, 1) == NOTOK
)
for (p
= pe
-> pe_cons
; p
; p
= p
-> pe_next
)
if (pe2ps_aux2 (ps
, p
, 0) == NOTOK
)
if (pe
-> pe_len
== PE_LEN_INDF
&& pe2ps_aux2 (ps
, &pe_eoc
, 0) == NOTOK
)
static int ps_write_id (ps
, pe
)
byte buffer
[1 + sizeof (PElementID
)];
register byte
*bp
= buffer
;
if ((form
= pe
-> pe_form
) == PE_FORM_ICONS
)
*bp
= ((pe
-> pe_class
<< PE_CLASS_SHIFT
) & PE_CLASS_MASK
)
| ((form
<< PE_FORM_SHIFT
) & PE_FORM_MASK
);
if ((id
= pe
-> pe_id
) < PE_ID_XTND
)
for (jd
= id
; jd
!= 0; jd
>>= PE_ID_SHIFT
)
for (bp
= ep
; id
!= 0; id
>>= PE_ID_SHIFT
)
for (bp
= buffer
+ 1; bp
< ep
; bp
++)
if (ps_write (ps
, buffer
, bp
- buffer
) == NOTOK
)
/* probably should integrate the non-PE_LEN_SMAX case with the algorithm in
num2prim() for a single, unified routine */
static int ps_write_len (ps
, pe
)
byte buffer
[1 + sizeof (PElementLen
)];
register byte
*bp
= buffer
,
register PElementLen len
;
if ((len
= pe
-> pe_len
) == PE_LEN_INDF
)
ep
= buffer
+ sizeof buffer
- 1;
for (bp
= ep
; len
!= 0 && buffer
< bp
; len
>>= 8)
*bp
= PE_LEN_XTND
| ((ep
- bp
) & 0xff);
if (ps_write (ps
, bp
, ep
- bp
+ 1) == NOTOK
)
if (ps_write (ps
, buffer
, bp
- buffer
) == NOTOK
)