home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / loadseg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  1.7 KB  |  85 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: loadseg.c,v 1.9 1997/01/27 00:36:24 ldp Exp $
  4.  
  5.     Desc: DOS function LoadSeg()
  6.     Lang: english
  7. */
  8. #include <dos/dos.h>
  9. #include <proto/dos.h>
  10. #include <dos/dosextens.h>
  11. #define DEBUG 1
  12. #include <aros/debug.h>
  13. #include "dos_intern.h"
  14.  
  15. BPTR LoadSeg_AOS(BPTR file);
  16. BPTR LoadSeg_ELF(BPTR file);
  17. BPTR LoadSeg_AOUT(BPTR file);
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22. #include <proto/dos.h>
  23.  
  24.     AROS_LH1(BPTR, LoadSeg,
  25.  
  26. /*  SYNOPSIS */
  27.     AROS_LHA(STRPTR, name, D1),
  28.  
  29. /*  LOCATION */
  30.     struct DosLibrary *, DOSBase, 25, Dos)
  31.  
  32. /*  FUNCTION
  33.     Loads an executable file into memory. Each hunk of the loadfile
  34.     is loaded into his own memory section and a handle on all of them
  35.     is returned. The segments can be freed with UnLoadSeg().
  36.  
  37.     INPUTS
  38.     name - NUL terminated name of the file.
  39.  
  40.     RESULT
  41.     Handle to the loaded executable or 0 if the load failed.
  42.     IoErr() gives additional information in that case.
  43.  
  44.     NOTES
  45.  
  46.     EXAMPLE
  47.  
  48.     BUGS
  49.  
  50.     SEE ALSO
  51.     UnLoadSeg()
  52.  
  53.     INTERNALS
  54.  
  55.     HISTORY
  56.     29-10-95    digulla automatically created from
  57.                 dos_lib.fd and clib/dos_protos.h
  58.  
  59. *****************************************************************************/
  60. {
  61.     AROS_LIBFUNC_INIT
  62.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  63.  
  64.     BPTR file, segs=0;
  65.  
  66.     /* Open the file */
  67.     file=Open(name,MODE_OLDFILE);
  68.     if(file)
  69.     {
  70. D(bug("Loading \"%s\"...\n", name));
  71.     /* Then try to load the different file formats */
  72. /*      segs=LoadSeg_AOS(file); Not yet */
  73.     if(!segs)
  74.         segs=LoadSeg_ELF(file);
  75.     if(!segs)
  76.         segs=LoadSeg_AOUT(file);
  77.  
  78.     /* Clean up */
  79.     Close(file);
  80.     }
  81.     /* And return */
  82.     return segs;
  83.     AROS_LIBFUNC_EXIT
  84. } /* LoadSeg */
  85.