/* RCS $Id: o_tprt.txt,v 1.1 1994/01/27 13:23:40 ae59 Exp ae59 $ */
/*
$Log: o_tprt.txt,v $
# Revision 1.1  1994/01/27  13:23:40  ae59
# Put under RCS control
#
 */
/****************************************************************/
/*                                                              */
/*      Filename        : e_tprt.c                              */
/*                                                              */
/*      Entry           : void e_tprt(e_argc,e_argv)            */
/*                        int e_argc;                           */
/*                        va_list e_argv;                       */
/*                                                              */
/*      Arguments       : e_argc - number of arguments          */
/*                        e_argv - reference to arguments       */
/*                                                              */
/*      Description     : Print variable argument list.         */
/*                                                              */
/*      Note            : e_argc must be even.                  */
/*                        e_argv is a list of pairs representing*/
/*                        integer values for the data type      */
/*                        specification and pointers to the     */
/*                        objects.                              */
/*                        Displaying stops if one result        */
/*                        argument is detected or the list ends.*/
/*                        Real data is diplayed in decimal, too.*/
/*                                                              */
/*      Date            : 1991-09-12                            */
/*      1991-09-12 : new routine                                */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
extern char *e_head;
extern f_text f_errr;
extern int e_rtyp;
extern a_VOID e_rptr;
#endif

#ifdef LINT_ARGS
local void e_tprt(int e_argc,va_list e_argv)
#else
local void e_tprt(e_argc,e_argv)
int e_argc;
va_list e_argv;
#endif
        {
        int i,k,res,type,msg;    /* !!! must be int !!! */

        e_rtyp = 0;
        e_rptr = NULL;

        for (i=0;i<e_argc;)
           {
           /* possible pointer allignment problems              */
           type = e_ref(int);

           /* Process message */
           if (type==E_TMSG)
              {
              /* possible pointer allignment problems           */
              type = e_ref(int);
              e_tmsg(type);
              e_argc -= 2;
              continue;
              }

           /* display header if not result argument */
           if ((res = type & E_TRES)==0)
              fprintf(f_errr.fp,"%s",e_head);

           /* display argument number */
           if ((msg=(type & E_TMSG))+res==0)
              fprintf(f_errr.fp,"%1d. ",i/2+1);

           /* display object according to specified type */
           switch (type & ~(E_TMSG+E_TRES))
              {

              case E_TCHR:
                 /* possible pointer allignment problems        */
                 e_rptr = e_ref(char *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       char   : ");
                 fprintf(f_errr.fp,"0x%02.2x   '%c'\n",
                         *(char *)e_rptr,*(char *)e_rptr);
                 break;

              case E_TDBL:
                 /* possible pointer allignment problems        */
                 e_rptr = (char *)e_ref(a_real *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       real   : 0x");
                 for (k=0;k<D_U_RATIO;k++)
fprintf(f_errr.fp,"%08.8lx",
       ((a_btyp *)e_rptr)[B_HPART+((B_LPART-B_HPART)/
                          (D_U_RATIO-1))*k]);
/* #ifdef TRAP_REAL */
                 fprintf(f_errr.fp,"   ");
                 r_writ(f_errr.fp,*(a_real *)e_rptr,16,0,0);
/* #endif */
                 fprintf(f_errr.fp,"\n");
                 break;

              case E_TDTP:
                 /* possible pointer allignment problems        */
                 e_rptr = (char *)e_ref(dotprecision *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       dot    : ");
                 if ((*(dotprecision *)e_rptr)[A_STATUS] &
                     A_QUIETNAN)
                    fprintf(f_errr.fp,"qNaN = %08.8lx\n",
                            (*(dotprecision *)e_rptr)[A_LOWNAN]);
                 else if ((*(dotprecision *)e_rptr)[A_STATUS] &
                          A_PINFINITY)
                    fprintf(f_errr.fp,"+infinity\n");
                 else if ((*(dotprecision *)e_rptr)[A_STATUS] &
                          A_MINFINITY)
                    fprintf(f_errr.fp,"-infinity\n");
                 else if ((*(dotprecision *)e_rptr)[A_BEGIN]==ZERO)
                      fprintf(f_errr.fp,"0\n");
                 else
                    {
                    fprintf(f_errr.fp,"sign='%c' ",
                       ((*(dotprecision *)e_rptr)[A_SIGN])
                        ? '-' : '+');
                    fprintf(f_errr.fp,"begin=%-2d ",
                       (*(dotprecision *)e_rptr)[A_BEGIN]);
                    fprintf(f_errr.fp,"end=%-2d ",
                       (*(dotprecision *)e_rptr)[A_END]);
                    for (k=0;k<=(*(dotprecision *)e_rptr)[A_END]-
                         (*(dotprecision *)e_rptr)[A_BEGIN];k++)
                       {
                       if ((k & 7)==0) fprintf(f_errr.fp,"\n%s   ",e_head);
                       fprintf(f_errr.fp,"%08.8lx ",
                          (*(dotprecision *)e_rptr)
                          [(*(dotprecision *)e_rptr)[A_BEGIN]+k]);
                       }
                    fprintf(f_errr.fp,"\n");
                    }
                 break;

              case E_TINT:
                 /* possible pointer allignment problems        */
                 e_rptr = (char *)e_ref(a_intg *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       int    : ");
                 fprintf(f_errr.fp,"0x%08.8lx   ",*(a_intg *)e_rptr);
                 fprintf(f_errr.fp,"%10ld\n",*(a_intg *)e_rptr);
                 break;

              case E_TMLT:
                 /* possible pointer allignment problems        */
                 e_rptr = (char *)e_ref(multiprecision *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       multi  : ");
                 if ((*(multiprecision *)e_rptr)->z)
                    fprintf(f_errr.fp,"0\n");
                 else
                    {
                    fprintf(f_errr.fp,"sign='%c' ",
                            ((*(multiprecision *)e_rptr)->s) ? '-' : '+');
                    fprintf(f_errr.fp,"exp=%-10d ",
                            (*(multiprecision *)e_rptr)->e);
                    fprintf(f_errr.fp,"len=%-10d ",
                            (*(multiprecision *)e_rptr)->l);
                    for (k=0;k<(*(multiprecision *)e_rptr)->l;k++)
                       {
                       if ((k & 7)==0) fprintf(f_errr.fp,"\n%s   ",e_head);
                       fprintf(f_errr.fp,"%08.8lx ",
                               (*(multiprecision *)e_rptr)->m[k]);
                       }
                    fprintf(f_errr.fp,"\n");
                    }
                 break;

              case E_TSTR:
                 /* possible pointer allignment problems        */
                 e_rptr = e_ref(char *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       string : ");
                 fprintf(f_errr.fp,"'%s'\n",(char *)e_rptr);
                 break;
/*
              case E_TULT:
                 e_rptr = (char *)e_ref(ultraprecision *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       ultra  : ");
                 if ((*(ultraprecision *)e_rptr)->z)
                    fprintf(f_errr.fp,"0\n");
                 else
                    {
                    fprintf(f_errr.fp,"sign='%c' ",
                    ((*(ultraprecision *)e_rptr)->s) ? '-' : '+');
                    fprintf(f_errr.fp,"exp=%-10d ",
                    (*(ultraprecision *)e_rptr)->e);
                    fprintf(f_errr.fp,"len=%-10d ",
                    (*(ultraprecision *)e_rptr)->l);
                    for (k=0;k<(*(ultraprecision *)e_rptr)->l;k++)
                       {
                       if ((k & 7)==0)
                          fprintf(f_errr.fp,"\n%s   ",e_head);
                       fprintf(f_errr.fp,"%08.8lx ",
                       (*(ultraprecision *)e_rptr)->m[k]);
                       }
                    fprintf(f_errr.fp,"\n");
                    }
                 break;
*/
              case E_TSTG:
                 /* possible pointer allignment problems        */
                 e_rptr = (char *)e_ref(s_trng *);
                 if (res) break;
                 if (msg) e_tmsg(msg);
                 else fprintf(f_errr.fp,"       string : ");
                 fprintf(f_errr.fp,"'");
                 for (k=0;k<((s_trng *)e_rptr)->clen;k++)
                    fprintf(f_errr.fp,"'%c'\n",
                    ((s_trng *)e_rptr)->ptr[k]);
                 fprintf(f_errr.fp,"'\n");
                 break;
              }
           i += 2;

           /* Display stops if result */
           if (res)
              {
              e_rtyp = type ^ E_TRES;
              return;
              }
           }

        return;
        }
