/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: l_whex.c,v 1.2 1997/09/25 17:40:54 ae59 Exp $ */
/*
$Log: l_whex.c,v $
 * Revision 1.2  1997/09/25  17:40:54  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:35  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : l_whex.c                              */
/*                                                              */
/*      Entry           : void l_whex(desc,r,mode)              */
/*                        f_text *desc;                         */
/*                        multiprecision r;                     */
/*                        a_char mode;                          */
/*                                                              */
/*      Arguments       : desc   - device descriptor            */
/*                        r      - multiprecision value         */
/*                        mode   - mode                         */
/*                                 'x' = hexadecimal (small)    */
/*                                 'X' = hexadecimal (capital)  */
/*                                                              */
/*      Description     : write multiprecision value in special */
/*                        format                                */
/*                                                              */
/*      Date            : 1992-01-22                            */
/*      1992-01-22 : consider INTEL flag                        */
/*      1991-02-14 : new routine                                */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif

#ifdef LINT_ARGS
local void l_whex(f_text *desc,multiprecision r,a_char mode)
#else
local void l_whex(desc,r,mode)

f_text *desc;
multiprecision r;
a_char mode;
#endif
        {
        int i,k;
        a_char *p;

        E_TPUSH("l_whex")

        if (b_text(desc,FALSE))
           {
           if (mode!='x' && mode!='X')
              e_trap(I_O_ERROR,4,E_TMSG,51,E_TCHR,&mode);
           else
              {
              f_putc((a_char)'|',desc);
              p = (a_char *)&r;
#if INTEL
              for (i=(int)sizeof(r)-1;i>=0;i--)
#else
              for (i=0;i<(int)sizeof(r);i++)
#endif
                 f_bhex(desc,p[i],mode);
              f_putc((a_char)'-',desc);
              f_putc((a_char)'>',desc);
              f_putc((a_char)'z',desc);
              f_putc((a_char)'=',desc);
              f_putc((r->z) ? (a_char)'1' : (a_char)'0',desc);
              f_putc((a_char)' ',desc);
              f_putc((a_char)'s',desc);
              f_putc((a_char)'=',desc);
              f_putc((r->s) ? (a_char)'1' : (a_char)'0',desc);
              f_putc((a_char)' ',desc);
              f_putc((a_char)'r',desc);
              f_putc((a_char)'=',desc);
              f_putc((r->r) ? (a_char)'1' : (a_char)'0',desc);
              f_putc((a_char)' ',desc);
              f_putc((a_char)'f',desc);
              f_putc((a_char)'=',desc);
              f_putc((r->f) ? (a_char)'1' : (a_char)'0',desc);
              f_putc((a_char)' ',desc);
              p = (a_char *)&(r->e);
              f_putc((a_char)'e',desc);
              f_putc((a_char)'=',desc);
#if INTEL
              for (i=(int)sizeof(r->e)-1;i>=0;i--)
#else
              for (i=0;i<(int)sizeof(r->e);i++)
#endif
                 {
                 f_bhex(desc,p[i],mode);
                 }
              f_putc((a_char)' ',desc);
              p = (a_char *)&(r->l);
              f_putc((a_char)'l',desc);
              f_putc((a_char)'=',desc);
#if INTEL
              for (i=(int)sizeof(r->l)-1;i>=0;i--)
#else
              for (i=0;i<(int)sizeof(r->l);i++)
#endif
                 {
                 f_bhex(desc,p[i],mode);
                 }
              f_putc((a_char)' ',desc);
              p = (a_char *)&(r->m);
              f_putc((a_char)'m',desc);
              f_putc((a_char)'=',desc);
#if INTEL
              for (i=(int)sizeof(r->m)-1;i>=0;i--)
#else
              for (i=0;i<(int)sizeof(r->m);i++)
#endif
                 {
                 f_bhex(desc,p[i],mode);
                 }
              f_putc((a_char)'-',desc);
              f_putc((a_char)'>',desc);
              p = (a_char *)(r->m);
              for (i=0;i<r->l;i++)
                 {
#if INTEL
                 for (k=(int)sizeof(a_btyp)-1;k>=0;k--)
#else
                 for (k=0;k<(int)sizeof(a_btyp);k++)
#endif
                    f_bhex(desc,p[i*sizeof(a_btyp)+k],mode);
                 if (i!=r->l-1) f_putc((a_char)' ',desc);
                 }
              f_putc((a_char)'|',desc);
              }
           }

        if (r->f) l_free(&r);

        E_TPOPP("l_whex")
        return;
        }

