home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / dos / loadseg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.1 KB  |  96 lines

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