home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / error.c < prev    next >
C/C++ Source or Header  |  1993-01-19  |  3KB  |  168 lines

  1. /* ---------------------------------------------------------------------- */
  2. /*                   Copyright (C) 1991 by Natürlich!                     */
  3. /*                      This file is copyrighted!                         */
  4. /*                Refer to the documentation for details.                 */
  5. /* ---------------------------------------------------------------------- */
  6. #include "defines.h"
  7. #include OSBIND
  8. #include <stdio.h>
  9. #include <setjmp.h>
  10. #include "nasm.h"
  11. #if OS != TOS
  12. #include <errno.h>
  13. #endif
  14.  
  15. static char nil[] = "***NIL***";
  16. char  outofmem[] = "<grunt> Not enough space <wheeze> in here",
  17.       bufoverflow[] = "An internal buffer <gasp> overflowed <gurgle>";
  18.  
  19. int         errors;
  20. jmp_buf     panic;
  21.  
  22. extern int  maxerrors;
  23.  
  24.  
  25.  
  26. void nexit( no)
  27. int   no;
  28. {
  29.    extern int  tossable;
  30.  
  31. #if OS == TOS
  32.    if( tossable)
  33.    {
  34.       while( Bconstat( 2))
  35.          Bconin( 2);
  36.       Bconin( 2);
  37.    }
  38. #endif
  39.    exit( no);
  40. }
  41.  
  42. void pluserrors()
  43. {
  44.    if( ++errors == maxerrors)
  45.    {
  46.       fprintf( ESTREAM, "Aborting after %d errors, 'nuff'z'nuff\n",
  47.             maxerrors);
  48.       finalshit();
  49. #if STATISTICS
  50.       stats();
  51. #endif
  52.       nexit(1);
  53.    }
  54. }
  55.  
  56. void nerror( err)
  57. char   *err;
  58. {
  59.    h_print();
  60.    fprintf( ESTREAM, "Error \"%s\"\n", err);
  61.    pluserrors();
  62. }
  63.  
  64.  
  65. void nserror( err, s)
  66. char   *err, *s;
  67. {
  68.    if( ! s)
  69.       s = nil;
  70.    h_print();
  71.    fprintf( ESTREAM, "Error \"%s\" ( %s )\n", err, s);
  72.    pluserrors();
  73. }
  74.  
  75.  
  76. void nswarning( err, s)
  77. char   *err, *s;
  78. {
  79.    if( ! s)
  80.       s = nil;
  81.    h_print();
  82.    fprintf( ESTREAM, "Warning \"%s\" ( %s )\n", err, s);
  83. }
  84.  
  85.  
  86. void npanic( err)
  87. char  *err;
  88. {
  89.    nerror(err);
  90.    longjmp( panic, 1);
  91. }
  92.  
  93. /* -------------------------------------------------------------- */
  94. void nwarning( warning)
  95. char   *warning;
  96. {
  97.    h_print();
  98.    fprintf( ESTREAM, "Warning \"%s\"\n", warning);
  99. }
  100.  
  101. void nmessage( message)
  102. char   *message;
  103. {
  104.    h_print();
  105.    fprintf( ESTREAM, "Har Har \"%s\"\n", message); /* used to be "Info ..*/
  106. }
  107.  
  108. void finalstats( what)
  109. {
  110.    printf("%s with %d error%c\n",
  111.           what ? "Finished" : "Aborted", errors, errors == 1 ? ' ' : 's');
  112. }
  113.  
  114. /* Fatal error */
  115. void nferror( err)
  116. char  *err;
  117. {
  118.    nerror( err);
  119.    finalstats(0);
  120.    finalshit();
  121. #if STATISTICS
  122.    stats();
  123. #endif
  124.    nexit(1);
  125. }
  126.  
  127. /* GEMDOS error */
  128. void ngferror( no, s)
  129. long  no;
  130. char  *s;
  131. {
  132. #if OS == TOS   /* (MSDOS too ??) */
  133.    switch( (int) no)
  134.    {
  135.       default:
  136. #endif
  137.          nferror( s);
  138. #if OS == TOS
  139.       case -12  :
  140.       case -1   :
  141.          nferror("General error");
  142.  
  143.       case -2   :
  144.          nferror("Drive not ready");
  145.  
  146.       case -11  :
  147.          nferror("Read error");
  148.  
  149.       case -37  :
  150.          nferror("Invalid handle");
  151.    }
  152. #else
  153.    h_print();
  154.    perror("I/O error");
  155. #endif
  156. }
  157.  
  158. /* Katastrophaler error */
  159. void nierror( err)
  160. char  *err;
  161. {
  162.    putc('\n', ESTREAM);
  163.    h_print();
  164.    fprintf( ESTREAM, "Catastrophical error \"%s\"\n", err);
  165.    nexit(0xDEAD);
  166. }
  167.  
  168.