home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adapm_15.zip / dos.adb < prev    next >
Text File  |  1994-12-07  |  5KB  |  94 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                               PM Bindings                                --
  4. --                                                                          --
  5. --                                DOS Body                                  --
  6. --                                                                          --
  7. --                    Binding to the OS/2 DOS API routines                  -- 
  8. --                                                                          --
  9. --                            $Revision: .1 $                               --
  10. --                                                                          --
  11. --     Copyright (c) 1994 Dimensional Media Systems, All Rights Reserved    --
  12. --                                                                          --
  13. --   The PM bindings are free software; you can redistribute them and/or    --
  14. --   modify them under terms of the GNU General Public License as published --
  15. --   by the Free Software Foundation; either version 2, or (at your         --
  16. --   option) any later version.  The PM bindings are distributed in the     --
  17. --   hope that they will be useful, but WITH OUT ANY WARRANTY; without even --
  18. --   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR    --
  19. --   PURPOSE.  See the GNU General Public License for more details.  You    --
  20. --   should have received a copy of the GNU General Public License          --
  21. --   distributed with The PM bindings; see file COPYING.  If not, write to  --
  22. --   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25. --                                                                          --
  26. --   For more information about these PM bindings and their usage with GNAT --
  27. --   you can contact Bill Yow at                                            --
  28. --                                                                          --  
  29. --      Dimensional Media Systems (DMS)                                     --
  30. --      1522 Festival Dr.                                                   --
  31. --      Houston TX, 77062                                                   --
  32. --      Phone - (713) 488-7050                                              --
  33. --      Email - Byow@mci.com                                                --
  34. --                                                                          --
  35. ------------------------------------------------------------------------------
  36.  
  37. with Pm_Types;
  38. with System;
  39.  
  40. package body Dos is
  41.  
  42.    Exec_Flag_Values : constant array (Exec_Flag_Type) of Pm_Types.U_Long := (
  43.       Exec_Sync             => 0,
  44.       Exec_Async            => 1,
  45.       Exec_Async_Result     => 2,
  46.       Exec_Trace            => 3,
  47.       Exec_Background       => 4,
  48.       Exec_Load             => 5,
  49.       Exec_Async_Result_DB  => 6);
  50.  
  51.  
  52.   function Exec_Program (
  53.              Object_Buffer : Object_Buffer_Type;
  54.              Exec_Flag     : Exec_Flag_Type;
  55.              Arguments     : String;
  56.              Enviorment    : String;
  57.              Return_Codes  : Result_Codes_Type;
  58.              Program       : String) return Api_Return_Code is
  59.  
  60.      function DosExecPgm (
  61.          Object_Buffer   : System.Address;
  62.          Buffer_Size     : Pm_Types.Long;
  63.          Exec_Flag       : Pm_Types.U_Long;
  64.          Arguments       : System.Address;
  65.          Enviorment      : System.Address;
  66.          Return_Codes    : System.Address;
  67.          Program         : System.Address) return Api_Return_Code;
  68.  
  69.          pragma Import (Convention => C,
  70.                         Entity     => DosExecPgm,
  71.                         Link_Name  => "DosExecPgm");
  72.  
  73.     Args : String (Arguments'first .. Arguments'last + 1);
  74.     Env  : String (Enviorment'first .. Enviorment'last + 1);
  75.     Pgm  : String (Program'first .. Program'last + 1);
  76.  
  77.   begin
  78.  
  79.     Args := Arguments & ASCII.Nul;
  80.     Env  := Enviorment & ASCII.Nul;
  81.     Pgm  := Program & ASCII.Nul;
  82.  
  83.     return DosExecPgm (
  84.             Object_Buffer   => Object_Buffer (Object_Buffer'first)'address,
  85.             Buffer_Size     => Pm_Types.Long (Object_Buffer'length),
  86.             Exec_Flag       => Exec_Flag_Values (Exec_Flag),
  87.             Arguments       => Args (Args'first)'address,
  88.             Enviorment      => Env (Env'first)'address,
  89.             Return_Codes    => Return_Codes'address,
  90.             Program         => Pgm (Pgm'first)'address);
  91.  
  92.    end Exec_Program;
  93.  
  94.  end Dos;