home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / amiga / jchlib / startup / exit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-24  |  1.1 KB  |  53 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. #ifdef __GNUC__
  9.   #include <inline/exec.h>
  10.   #include <inline/dos.h>
  11. #else
  12.   #include <clib/exec.h>
  13.   #include <clib/dos.h>
  14. #endif
  15.  
  16. volatile void _exit(LONG);
  17.  
  18. BOOL _Close_Input = FALSE;
  19. BOOL _Close_Output = FALSE;
  20. BPTR _WBOrigDir = NULL;
  21.  
  22. volatile void exit(int code)
  23. {
  24.   /* we could zero all handles we free, _WBCurrentDir, In/Output_handle ... */
  25.   if (NULL != DOSBase)
  26.     {
  27.       D(ebug("In exit()\n"));
  28.       if (WBenchMsg != NULL)
  29.     { /* _WBOrigDir may have been NULL, so don't test this */
  30.       D(ebug("Unlocking WBDir\n"));
  31.       UnLock(CurrentDir(_WBOrigDir));
  32.     }
  33.       if (_Close_Input && NULL != Input_handle)
  34.     {
  35.       D(ebug("Closing Input\n"));
  36.       Close(Input_handle);
  37.     }
  38.       if (_Close_Output && NULL != Output_handle)
  39.     {
  40.       D(ebug("Closing Output\n"));
  41.       Close(Output_handle);
  42.     }
  43.       CloseLibrary(DOSBase);
  44.       DOSBase = NULL;
  45.     }
  46.   if (WBenchMsg != NULL) /* WB startup */
  47.     {
  48.       Forbid();
  49.       ReplyMsg((struct Message *)WBenchMsg);
  50.     }
  51.   _exit(code);
  52. }
  53.