home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / i-os2lib.ads < prev    next >
Text File  |  2000-07-19  |  6KB  |  146 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                     I N T E R F A C E S . O S 2 L I B                    --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.14 $                            --
  10. --                                                                          --
  11. --          Copyright (C) 1993-1997 Free Software Foundation, Inc.          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. --  This package (and children) provide interface definitions to the standard
  37. --  OS/2 Library. They are merely a translation of the various <bse*.h> files.
  38.  
  39. --  It is intended that higher level interfaces (with better names, and
  40. --  stronger typing!) be built on top of this one for Ada (i.e. clean)
  41. --  programming.
  42.  
  43. --  We have chosen to keep names, types, etc.  as close as possible to the
  44. --  C definition to provide easier reference to the documentation. The main
  45. --  exception is when a formal and its type (in C) differed only by the case
  46. --  of letters (like in HMUX hmux). In this case, we have prepended "F_" to
  47. --  the formal (i.e. F_hmux : HMUX).
  48.  
  49. with Interfaces.C;
  50. with Interfaces.C.Strings;
  51. with System;
  52.  
  53. package Interfaces.OS2Lib is
  54. pragma Preelaborate (OS2Lib);
  55.  
  56.    package IC  renames Interfaces.C;
  57.    package ICS renames Interfaces.C.Strings;
  58.  
  59.    -------------------
  60.    -- General Types --
  61.    -------------------
  62.  
  63.    type    APIRET   is new IC.unsigned_long;
  64.    type    APIRET16 is new IC.unsigned_short;
  65.    subtype APIRET32 is     APIRET;
  66.  
  67.    subtype PSZ    is ICS.chars_ptr;
  68.    subtype PCHAR  is ICS.chars_ptr;
  69.    subtype PVOID  is System.Address;
  70.    type    PPVOID is access all PVOID;
  71.  
  72.    type BOOL32 is new IC.unsigned_long;
  73.    False32 : constant BOOL32 := 0;
  74.    True32  : constant BOOL32 := 1;
  75.  
  76.    type UCHAR   is new IC.unsigned_char;
  77.    type USHORT  is new IC.unsigned_short;
  78.    type ULONG   is new IC.unsigned_long;
  79.    type PULONG  is access all ULONG;
  80.  
  81.    --  Coprocessor stack register element.
  82.  
  83.    type FPREG is record
  84.       losig             : ULONG;        --  Low 32-bits of the mantissa
  85.       hisig             : ULONG;        --  High 32-bits of the mantissa
  86.       signexp           : USHORT;       --  Sign and exponent
  87.    end record;
  88.    pragma Convention (C, FPREG);
  89.  
  90.    type AULONG is array (IC.size_t range <>) of ULONG;
  91.    type AFPREG is array (IC.size_t range <>) of FPREG;
  92.  
  93.    type LHANDLE is new IC.unsigned_long;
  94.  
  95.    NULLHANDLE : constant := 0;
  96.  
  97.    ---------------------
  98.    -- Time Management --
  99.    ---------------------
  100.  
  101.    function DosSleep (How_long : ULONG) return APIRET;
  102.    pragma Import (C, DosSleep, "DosSleep");
  103.  
  104.    type DATETIME is record
  105.       hours      : UCHAR;
  106.       minutes    : UCHAR;
  107.       seconds    : UCHAR;
  108.       hundredths : UCHAR;
  109.       day        : UCHAR;
  110.       month      : UCHAR;
  111.       year       : USHORT;
  112.       timezone   : IC.short;
  113.       weekday    : UCHAR;
  114.    end record;
  115.  
  116.    type PDATETIME is access all DATETIME;
  117.  
  118.    function DosGetDateTime (pdt : PDATETIME) return APIRET;
  119.    pragma Import (C, DosGetDateTime, "DosGetDateTime");
  120.  
  121.    function DosSetDateTime (pdt : PDATETIME) return APIRET;
  122.    pragma Import (C, DosSetDateTime, "DosSetDateTime");
  123.  
  124.    ----------------------------
  125.    -- Miscelleneous Features --
  126.    ----------------------------
  127.  
  128.    --  Features which do not fit any child
  129.  
  130.    function DosBeep (Freq : ULONG; Dur : ULONG) return APIRET;
  131.    pragma Import (C, DosBeep, "DosBeep");
  132.  
  133.    procedure Must_Not_Fail (Return_Code : OS2Lib.APIRET);
  134.    pragma Inline (Must_Not_Fail);
  135.    --  Many OS/2 functions return APIRET and are not supposed to fail. In C
  136.    --  style, these would be called as procedures, disregarding the returned
  137.    --  value. This procedure can be used to achieve the same effect with a
  138.    --  call of the form: Must_Not_Fail (Some_OS2_Function (...));
  139.  
  140.    procedure Sem_Must_Not_Fail (Return_Code : OS2Lib.APIRET);
  141.    pragma Inline (Sem_Must_Not_Fail);
  142.    --  Similar to Must_Not_Fail, but used in the case of DosPostEventSem,
  143.    --  where the "error" code ERROR_ALREADY_POSTED is not really an error.
  144.  
  145. end Interfaces.OS2Lib;
  146.