/* RCS $Id: o_trap.txt,v 1.1 1994/01/27 13:23:40 ae59 Exp ae59 $ */
/*
$Log: o_trap.txt,v $
# Revision 1.1  1994/01/27  13:23:40  ae59
# Put under RCS control
#
 */
/****************************************************************/
/*                                                              */
/*      Filename        : o_trap.c                              */
/*                                                              */
/*      Entry           : void e_trap(code,e_argc,e_args)       */
/*                        a_btyp code;                          */
/*                        int e_argc;                           */
/*                        e_list                                */
/*                                                              */
/*      Arguments       : code - error code                     */
/*                        e_argc - number of arguments in list  */
/*                        e_args - variable argument list       */
/*                                                              */
/*      Description     : Short trap handler.                   */
/*                        Warning messages are suppressed.      */
/*                        Replaces e_trap() in runtime system   */
/*                        library.                              */
/*                                                              */
/*      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 aentry *e_astk;
extern aentry e_anor;
extern char *e_head;
extern f_text f_errr;
#endif

#ifdef LINT_ARGS
#if C_P_7
local void e_trap(a_btyp code,int e_argc,...)
#else
local void e_trap(code,e_argc,e_args)
a_btyp code;
int e_argc;
e_list
#endif
#else
local void e_trap(code,e_argc,e_args)
a_btyp code;
int e_argc;
e_list
#endif

        {
        a_btyp op;
        char *t;

        /* split code value     */
        op = code & E_MASK;

        /* define message text   */
        switch ((int)op)
           {
           case NO_ERROR:
              t = "";
              break;
           case INV_OP:
              t = "Invalid arithmetic operation\n";
              break;
           case DIV_BY_ZERO:
              t = "Division by zero\n";
              break;
           case OVERFLOW:
              t = "Arithmetic overflow\n";
              break;
           case UNDERFLOW:
              t = "Division by zero\n";
              break;
           case INEXACT:
              t = "Division by zero\n";
              break;
           case ALLOCATION:
              t = "Allocation error\n";
              break;
           case I_O_ERROR:
              t = "I/O error\n";
              break;
           case I_O_BUFFER:
              t = "Insufficient buffer size\n";
              break;
           case INV_ARG:
              t = "Invalid argument\n";
              break;
           case INDEX_RANGE:
              t = "Range error\n";
              break;
           otherwise:
              t = "Unknown error condition code\n";
           }

        /* display error message */
        if (op!=NO_ERROR && *t!='\0' && (code & E_EXIT)==0)
           {
           fprintf(f_errr.fp,"%sERROR occurred : code = %08.8lx\n",code);
           if (*t!='\0') fprintf(f_errr.fp,"%s%s\n",e_head,t);
           }

        /* abort processing */
        if (code & E_EXIT)
           {
           fprintf(f_errr.fp,"%s%s\n",
                   e_head,"------ Processing aborted ------\n");
           exit(EXIT_VALUE);
           }

        return;
        }
