home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-1.LHA / CLISP960530-sr.lha / amiga / jchlib / startup / exit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-09  |  1009 b   |  48 lines

  1. /* GCC Library
  2.  * Jörg Höhle, 15-Jul-94
  3.  */
  4.  
  5. #include "defs.h"
  6. #include <exec/ports.h>
  7. #include <libraries/dos.h>
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10.  
  11. volatile void _exit(LONG);
  12.  
  13. BOOL _Close_Input = FALSE;
  14. BOOL _Close_Output = FALSE;
  15. BPTR _WBOrigDir = NULL;
  16.  
  17. volatile void exit(int code)
  18. {
  19.   /* we could zero all handles we free, _WBCurrentDir, In/Output_handle ... */
  20.   if (NULL != DOSBase)
  21.     {
  22.       D(ebug("In exit()\n"));
  23.       if (WBenchMsg != NULL)
  24.     { /* _WBOrigDir may have been NULL, so don't test this */
  25.       D(ebug("Unlocking WBDir\n"));
  26.       UnLock(CurrentDir(_WBOrigDir));
  27.     }
  28.       if (_Close_Input && NULL != Input_handle)
  29.     {
  30.       D(ebug("Closing Input\n"));
  31.       Close(Input_handle);
  32.     }
  33.       if (_Close_Output && NULL != Output_handle)
  34.     {
  35.       D(ebug("Closing Output\n"));
  36.       Close(Output_handle);
  37.     }
  38.       CloseLibrary(DOSBase);
  39.       DOSBase = NULL;
  40.     }
  41.   if (WBenchMsg != NULL) /* WB startup */
  42.     {
  43.       Forbid();
  44.       ReplyMsg((struct Message *)WBenchMsg);
  45.     }
  46.   _exit(code);
  47. }
  48.