Browse Source

* added defines use_amia_smartlink and use_auto_openlib

* implemented autoopening of library
nils 22 years ago
parent
commit
4bdf5c77b4

+ 63 - 2
packages/extra/amunits/units/amigaguide.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -21,9 +21,19 @@
     For use with fpc 1.0.7. They are in systemvartags.
     10 Nov 2002.
 
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented opening of
+    the library.
+    13 Jan 2003.
+
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit amigaguide;
 
 INTERFACE
@@ -223,6 +233,9 @@ Type
 
 VAR AmigaGuideBase : pLibrary;
 
+const
+    AMIGAGUIDENAME : Pchar = 'amigaguide.library';
+
 FUNCTION AddAmigaGuideHostA(h : pHook; name : pCHAR; attrs : pTagItem) : POINTER;
 FUNCTION AmigaGuideSignal(cl : POINTER) : ULONG;
 PROCEDURE CloseAmigaGuide(cl : POINTER);
@@ -244,6 +257,8 @@ PROCEDURE UnlockAmigaGuideBase(key : LONGINT);
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION AddAmigaGuideHostA(h : pHook; name : pCHAR; attrs : pTagItem) : POINTER;
 BEGIN
   ASM
@@ -469,12 +484,58 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of amigaguide.library}
+
+var
+    amigaguide_exit : Pointer;
+
+procedure CloseamigaguideLibrary;
+begin
+    ExitProc := amigaguide_exit;
+    if AmigaGuideBase <> nil then begin
+        CloseLibrary(AmigaGuideBase);
+        AmigaGuideBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    AmigaGuideBase := nil;
+    AmigaGuideBase := OpenLibrary(AMIGAGUIDENAME,LIBVERSION);
+    if AmigaGuideBase <> nil then begin
+        amigaguide_exit := ExitProc;
+        ExitProc := @CloseamigaguideLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open amigaguide.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of amigaguide.library compiled}
+   {$Info Make sure you open amigaguide.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT AMIGAGUIDE *)
 
 
 {
    $Log$
-   Revision 1.2  2002-11-17 20:28:53  nils
+   Revision 1.3  2003-01-14 18:46:04  nils
+   * added defines use_amia_smartlink and use_auto_openlib
+   
+   * implemented autoopening of library
+   
+   Revision 1.2  2002/11/17 20:28:53  nils
    * added functions with array of const
    
 }

+ 64 - 1
packages/extra/amunits/units/bullet.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -14,6 +14,22 @@
 
  **********************************************************************}
 
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented openingcode
+    for the library
+    13 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit bullet;
 
 INTERFACE
@@ -351,6 +367,10 @@ const
 
 VAR BulletBase : pLibrary;
 
+const
+    BULLETNAME : PChar = 'bullet.library';
+
+
 PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
 FUNCTION ObtainInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
 FUNCTION OpenEngine : pGlyphEngine;
@@ -359,6 +379,8 @@ FUNCTION SetInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
 
 IMPLEMENTATION
 
+uses msgbox;
+
 PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
 BEGIN
   ASM
@@ -420,6 +442,47 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of bullet.library}
+
+var
+    bullet_exit : Pointer;
+
+procedure ClosebulletLibrary;
+begin
+    ExitProc := bullet_exit;
+    if BulletBase <> nil then begin
+        CloseLibrary(BulletBase);
+        BulletBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    BulletBase := nil;
+    BulletBase := OpenLibrary(BULLETNAME,LIBVERSION);
+    if BulletBase <> nil then begin
+        bullet_exit := ExitProc;
+        ExitProc := @ClosebulletLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open bullet.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of bullet.library compiled}
+   {$Info Make sure you open bullet.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT BULLET *)
 
 

+ 67 - 2
packages/extra/amunits/units/colorwheel.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -13,7 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    13 Jan 2003.
+
+    [email protected] Nils Sjoholm
+}
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT colorwheel;
 
@@ -64,11 +78,16 @@ const
 
 VAR ColorWheelBase : pLibrary;
 
+const
+    COLORWHEELNAME : Pchar = 'colorwheel.library';
+
 PROCEDURE ConvertHSBToRGB(hsb : pColorWheelHSB; rgb : pColorWheelRGB);
 PROCEDURE ConvertRGBToHSB(rgb : pColorWheelRGB; hsb : pColorWheelHSB);
 
 IMPLEMENTATION
 
+uses msgbox;
+
 PROCEDURE ConvertHSBToRGB(hsb : pColorWheelHSB; rgb : pColorWheelRGB);
 BEGIN
   ASM
@@ -93,12 +112,58 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of colorwheel.library}
+
+var
+    colorwheel_exit : Pointer;
+
+procedure ClosecolorwheelLibrary;
+begin
+    ExitProc := colorwheel_exit;
+    if ColorWheelBase <> nil then begin
+        CloseLibrary(ColorWheelBase);
+        ColorWheelBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    ColorWheelBase := nil;
+    ColorWheelBase := OpenLibrary(COLORWHEELNAME,LIBVERSION);
+    if ColorWheelBase <> nil then begin
+        colorwheel_exit := ExitProc;
+        ExitProc := @ClosecolorwheelLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open colorwheel.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of colorwheel.library compiled}
+   {$Info Make sure you open colorwheel.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT COLORWHEEL *)
 
 
 {
   $Log$
-  Revision 1.2  2002-11-18 20:51:44  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/18 20:51:44  nils
     * wrong name on unit
 
 }

+ 61 - 3
packages/extra/amunits/units/commodities.pas

@@ -17,11 +17,21 @@
     History:
     Added overlay functions for Pchar->Strings, functions
     and procedures.
-
     14 Jul 2000.
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    13 Jan 2003.
+    
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit commodities;
 
 INTERFACE
@@ -217,6 +227,9 @@ CONST
 
 VAR CxBase : pLibrary;
 
+const
+    COMMODITIESNAME : PChar = 'commodities.library';
+
 FUNCTION ActivateCxObj(co : pCxObj; tru : LONGINT) : LONGINT;
 PROCEDURE AddIEvents(events : pInputEvent);
 PROCEDURE AttachCxObj(headObj : pCxObj; co : pCxObj);
@@ -252,7 +265,7 @@ PROCEDURE SetFilter(filter : pCxObj; text : string);
 
 IMPLEMENTATION
 
-uses pastoc;
+uses pastoc,msgbox;
 
 FUNCTION ActivateCxObj(co : pCxObj; tru : LONGINT) : LONGINT;
 BEGIN
@@ -588,13 +601,58 @@ begin
       SetFilter(filter,pas2c(text));
 end;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of commodities.library}
+
+var
+    commodities_exit : Pointer;
+
+procedure ClosecommoditiesLibrary;
+begin
+    ExitProc := commodities_exit;
+    if CxBase <> nil then begin
+        CloseLibrary(CxBase);
+        CxBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    CxBase := nil;
+    CxBase := OpenLibrary(COMMODITIESNAME,LIBVERSION);
+    if CxBase <> nil then begin
+        commodities_exit := ExitProc;
+        ExitProc := @ClosecommoditiesLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open commodities.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of commodities.library compiled}
+   {$Info Make sure you open commodities.library yourself}
+{$endif use_auto_openlib}
 
 END. (* UNIT COMMODITIES *)
 
 
 {
   $Log$
-  Revision 1.2  2002-11-18 20:52:02  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/18 20:52:02  nils
     * update check internal log
 
 }

+ 57 - 1
packages/extra/amunits/units/datatypes.pas

@@ -24,6 +24,11 @@
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit datatypes;
 
 INTERFACE
@@ -1061,6 +1066,9 @@ Type
 
 VAR DataTypesBase : pLibrary;
 
+const
+    DATATYPESNAME : PChar = 'datatypes.library';
+
 FUNCTION AddDTObject(win : pWindow; req : pRequester; o : pObject_; pos : LONGINT) : LONGINT;
 PROCEDURE DisposeDTObject(o : pObject_);
 FUNCTION DoAsyncLayout(o : pObject_; gpl : pgpLayout) : ULONG;
@@ -1080,6 +1088,8 @@ FUNCTION SetDTAttrsA(o : pObject_; win : pWindow; req : pRequester; attrs : pTag
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION AddDTObject(win : pWindow; req : pRequester; o : pObject_; pos : LONGINT) : LONGINT;
 BEGIN
   ASM
@@ -1278,12 +1288,58 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of datatypes.library}
+
+var
+    datatypes_exit : Pointer;
+
+procedure ClosedatatypesLibrary;
+begin
+    ExitProc := datatypes_exit;
+    if DataTypesBase <> nil then begin
+        CloseLibrary(DataTypesBase);
+        DataTypesBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    DataTypesBase := nil;
+    DataTypesBase := OpenLibrary(DATATYPESNAME,LIBVERSION);
+    if DataTypesBase <> nil then begin
+        datatypes_exit := ExitProc;
+        ExitProc := @ClosedatatypesLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open datatypes.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of datatypes.library compiled}
+   {$Info Make sure you open datatypes.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT DATATYPES *)
 
 
 {
   $Log$
-  Revision 1.2  2002-11-18 20:52:28  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/18 20:52:28  nils
     * update check internal log
 
 }

+ 65 - 2
packages/extra/amunits/units/diskfont.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -13,6 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    13 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 unit diskfont;
 
@@ -125,6 +140,8 @@ FUNCTION OpenDiskFont(textAttr : pTextAttr) : pTextFont;
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION AvailFonts(buffer : pCHAR; bufBytes : LONGINT; flags : LONGINT) : LONGINT;
 BEGIN
   ASM
@@ -188,11 +205,57 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of diskfont.library}
+
+var
+    diskfont_exit : Pointer;
+
+procedure ClosediskfontLibrary;
+begin
+    ExitProc := diskfont_exit;
+    if DiskfontBase <> nil then begin
+        CloseLibrary(DiskfontBase);
+        DiskfontBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    DiskfontBase := nil;
+    DiskfontBase := OpenLibrary(DISKFONTNAME,LIBVERSION);
+    if DiskfontBase <> nil then begin
+        diskfont_exit := ExitProc;
+        ExitProc := @ClosediskfontLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open diskfont.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of diskfont.library compiled}
+   {$Info Make sure you open diskfont.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT DISKFONT *)
 
 {
   $Log$
-  Revision 1.2  2002-11-18 20:52:58  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/18 20:52:58  nils
     * added diskfontname
 
 }

+ 60 - 1
packages/extra/amunits/units/expansion.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -13,6 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening of
+    the library.
+    14 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT expansion;
 
@@ -53,6 +68,8 @@ PROCEDURE WriteExpansionByte(board : POINTER; offset : ULONG; byte : ULONG);
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION AddBootNode(bootPri : LONGINT; flags : ULONG; deviceNode : pDeviceNode; configDev : pConfigDev) : BOOLEAN;
 BEGIN
   ASM
@@ -312,6 +329,48 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of expansion.library}
+
+var
+    expansion_exit : Pointer;
+
+procedure CloseexpansionLibrary;
+begin
+    ExitProc := expansion_exit;
+    if ExpansionBase <> nil then begin
+        CloseLibrary(ExpansionBase);
+        ExpansionBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    ExpansionBase := nil;
+    ExpansionBase := OpenLibrary(EXPANSIONNAME,LIBVERSION);
+    if ExpansionBase <> nil then begin
+        expansion_exit := ExitProc;
+        ExitProc := @CloseexpansionLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open expansion.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of expansion.library compiled}
+   {$Info Make sure you open expansion.library yourself}
+{$endif use_auto_openlib}
+
+
 END. (* UNIT EXPANSION *)
 
 

+ 60 - 3
packages/extra/amunits/units/icon.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -22,8 +22,19 @@
     Removed amigaoverlays, use smartlink instead.
     05 Nov 2002.
 
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening of
+    the library.
+    14 Jan 2003.
+
     [email protected]
 }
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit icon;
 
 INTERFACE
@@ -68,7 +79,7 @@ FUNCTION PutDiskObject(name : string; diskobj : pDiskObject) : BOOLEAN;
 IMPLEMENTATION
 
 
-uses pastoc;
+uses pastoc,msgbox;
 
 FUNCTION AddFreeList(freelist : pFreeList; mem : POINTER; size : ULONG) : BOOLEAN;
 BEGIN
@@ -289,12 +300,58 @@ begin
        PutDiskObject := PutDiskObject(pas2c(name),diskobj);
 end;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of icon.library}
+
+var
+    icon_exit : Pointer;
+
+procedure CloseiconLibrary;
+begin
+    ExitProc := icon_exit;
+    if IconBase <> nil then begin
+        CloseLibrary(IconBase);
+        IconBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    IconBase := nil;
+    IconBase := OpenLibrary(ICONNAME,LIBVERSION);
+    if IconBase <> nil then begin
+        icon_exit := ExitProc;
+        ExitProc := @CloseiconLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open icon.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of icon.library compiled}
+   {$Info Make sure you open icon.library yourself}
+{$endif use_auto_openlib}
+
 
 END. (* UNIT ICON *)
 
 {
   $Log$
-  Revision 1.2  2002-11-18 20:54:32  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/18 20:54:32  nils
     * update check internal log
 
 }

+ 65 - 1
packages/extra/amunits/units/iffparse.pas

@@ -13,6 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening of
+    the library.
+    14 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 unit iffparse;
 
@@ -257,6 +272,8 @@ FUNCTION WriteChunkRecords(iff : pIFFHandle; buf : POINTER; bytesPerRecord : LON
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION AllocIFF : pIFFHandle;
 BEGIN
   ASM
@@ -784,12 +801,59 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of iffparse.library}
+
+var
+    iffparse_exit : Pointer;
+
+procedure CloseiffparseLibrary;
+begin
+    ExitProc := iffparse_exit;
+    if IFFParseBase <> nil then begin
+        CloseLibrary(IFFParseBase);
+        IFFParseBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    IFFParseBase := nil;
+    IFFParseBase := OpenLibrary(IFFPARSENAME,LIBVERSION);
+    if IFFParseBase <> nil then begin
+        iffparse_exit := ExitProc;
+        ExitProc := @CloseiffparseLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open iffparse.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of iffparse.library compiled}
+   {$Info Make sure you open iffparse.library yourself}
+{$endif use_auto_openlib}
+
+
 END. (* UNIT IFFPARSE *)
 
 
 {
   $Log$
-  Revision 1.2  2002-11-18 20:54:56  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/18 20:54:56  nils
     * missing semicolon
 
 }

+ 64 - 1
packages/extra/amunits/units/keymap.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -18,6 +18,22 @@
         keymap.resource definitions and console.device key map definitions
 }
 
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    14 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit keymap;
 
 INTERFACE
@@ -91,6 +107,9 @@ Const
 
 VAR KeymapBase : pLibrary;
 
+const
+    KEYMAPNAME : PChar = 'keymap.library';
+
 FUNCTION AskKeyMapDefault : pKeyMap;
 FUNCTION MapANSI(thestring : pCHAR; count : LONGINT; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
 FUNCTION MapRawKey(event : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : INTEGER;
@@ -98,6 +117,8 @@ PROCEDURE SetKeyMapDefault(keyMap : pKeyMap);
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION AskKeyMapDefault : pKeyMap;
 BEGIN
   ASM
@@ -151,6 +172,48 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of keymap.library}
+
+var
+    keymap_exit : Pointer;
+
+procedure ClosekeymapLibrary;
+begin
+    ExitProc := keymap_exit;
+    if KeymapBase <> nil then begin
+        CloseLibrary(KeymapBase);
+        KeymapBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    KeymapBase := nil;
+    KeymapBase := OpenLibrary(KEYMAPNAME,LIBVERSION);
+    if KeymapBase <> nil then begin
+        keymap_exit := ExitProc;
+        ExitProc := @ClosekeymapLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open keymap.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of keymap.library compiled}
+   {$Info Make sure you open keymap.library yourself}
+{$endif use_auto_openlib}
+
+
 END. (* UNIT KEYMAP *)
 
 

+ 66 - 3
packages/extra/amunits/units/layers.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -13,6 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    14 Jan 2003.
+    
+    [email protected]
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT layers;
 
@@ -102,6 +117,8 @@ FUNCTION WhichLayer(li : pLayer_Info; x : LONGINT; y : LONGINT) : pLayer;
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION BeginUpdate(l : pLayer) : LONGINT;
 BEGIN
   ASM
@@ -530,13 +547,59 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of layers.library}
+
+var
+    layers_exit : Pointer;
+
+procedure CloselayersLibrary;
+begin
+    ExitProc := layers_exit;
+    if LayersBase <> nil then begin
+        CloseLibrary(LayersBase);
+        LayersBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    LayersBase := nil;
+    LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
+    if LayersBase <> nil then begin
+        layers_exit := ExitProc;
+        ExitProc := @CloselayersLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open layers.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of layers.library compiled}
+   {$Info Make sure you open layers.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT LAYERS *)
 
 {
   $Log$
-  Revision 1.2  2002-11-19 18:47:46  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/19 18:47:46  nils
     * update check internal log
 
 }
 
-  
+  

+ 64 - 3
packages/extra/amunits/units/locale.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -21,9 +21,18 @@
     For use with fpc 1.0.7. They are in systemvartags.
     11 Nov 2002.
     
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    14 Jan 2003.
+
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT locale;
 
@@ -253,6 +262,9 @@ Type
 
 VAR LocaleBase : pLocaleBase;
 
+const
+    LOCALENAME : PChar = 'locale.library';
+
 PROCEDURE CloseCatalog(catalog : pCatalog);
 PROCEDURE CloseLocale(locale : pLocale);
 FUNCTION ConvToLower(locale : pLocale; character : ULONG) : ULONG;
@@ -281,6 +293,8 @@ FUNCTION StrnCmp(locale : pLocale; string1 : pCHAR; string2 : pCHAR; length : LO
 
 IMPLEMENTATION
 
+uses msgbox;
+
 PROCEDURE CloseCatalog(catalog : pCatalog);
 BEGIN
   ASM
@@ -637,13 +651,60 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of locale.library}
+
+var
+    locale_exit : Pointer;
+
+procedure CloselocaleLibrary;
+begin
+    ExitProc := locale_exit;
+    if LocaleBase <> nil then begin
+        CloseLibrary(plibrary(LocaleBase));
+        LocaleBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    LocaleBase := nil;
+    LocaleBase := pLocaleBase(OpenLibrary(LOCALENAME,LIBVERSION));
+    if LocaleBase <> nil then begin
+        locale_exit := ExitProc;
+        ExitProc := @CloselocaleLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open locale.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of locale.library compiled}
+   {$Info Make sure you open locale.library yourself}
+{$endif use_auto_openlib}
+
+
 END. (* UNIT LOCALE *)
 
 {
   $Log$
-  Revision 1.2  2002-11-19 18:47:46  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/19 18:47:46  nils
     * update check internal log
 
 }
 
-  
+  

+ 63 - 1
packages/extra/amunits/units/nonvolatile.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -13,6 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    14 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT nonvolatile;
 
@@ -64,6 +79,9 @@ const
 
 VAR NVBase : pLibrary;
 
+const
+    NONVOLATILENAME : PChar = 'nonvolatile.library';
+
 FUNCTION DeleteNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : BOOLEAN;
 PROCEDURE FreeNVData(data : POINTER);
 FUNCTION GetCopyNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : POINTER;
@@ -74,6 +92,8 @@ FUNCTION StoreNV(appName : pCHAR; itemName : pCHAR; data : POINTER; length : ULO
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION DeleteNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : BOOLEAN;
 BEGIN
   ASM
@@ -175,4 +195,46 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of nonvolatile.library}
+
+var
+    nonvolatile_exit : Pointer;
+
+procedure ClosenonvolatileLibrary;
+begin
+    ExitProc := nonvolatile_exit;
+    if NVBase <> nil then begin
+        CloseLibrary(NVBase);
+        NVBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    NVBase := nil;
+    NVBase := OpenLibrary(NONVOLATILENAME,LIBVERSION);
+    if NVBase <> nil then begin
+        nonvolatile_exit := ExitProc;
+        ExitProc := @ClosenonvolatileLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open nonvolatile.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of nonvolatile.library compiled}
+   {$Info Make sure you open nonvolatile.library yourself}
+{$endif use_auto_openlib}
+
+
 END. (* UNIT NONVOLATILE *)

+ 64 - 3
packages/extra/amunits/units/realtime.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -21,9 +21,18 @@
     For use with fpc 1.0.7. They are in systemvartags.
     11 Nov 2002.
     
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening of the
+    library.
+    14 Jan 2003.
+
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT realtime;
 
@@ -224,6 +233,9 @@ const
 
 VAR RealTimeBase : pRealTimeBase;
 
+const
+    REALTIMENAME : PChar = 'realtime.library';
+
 FUNCTION CreatePlayerA(tagList : pTagItem) : pPlayer;
 PROCEDURE DeletePlayer(player : pPlayer);
 FUNCTION ExternalSync(player : pPlayer; minTime : LONGINT; maxTime : LONGINT) : BOOLEAN;
@@ -238,6 +250,8 @@ PROCEDURE UnlockRealTime(lock : POINTER);
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION CreatePlayerA(tagList : pTagItem) : pPlayer;
 BEGIN
   ASM
@@ -368,13 +382,60 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of realtime.library}
+
+var
+    realtime_exit : Pointer;
+
+procedure CloserealtimeLibrary;
+begin
+    ExitProc := realtime_exit;
+    if RealTimeBase <> nil then begin
+        CloseLibrary(pLibrary(RealTimeBase));
+        RealTimeBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    RealTimeBase := nil;
+    RealTimeBase := pRealTimeBase(OpenLibrary(REALTIMENAME,LIBVERSION));
+    if RealTimeBase <> nil then begin
+        realtime_exit := ExitProc;
+        ExitProc := @CloserealtimeLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open realtime.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of realtime.library compiled}
+   {$Info Make sure you open realtime.library yourself}
+{$endif use_auto_openlib}
+
+
 END. (* UNIT REALTIME *)
 
 {
   $Log$
-  Revision 1.2  2002-11-19 18:47:46  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/19 18:47:46  nils
     * update check internal log
 
 }
 
-  
+  

+ 63 - 4
packages/extra/amunits/units/rexx.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -22,9 +22,19 @@
     Removed amigaoverlays, use smartlink instead.
     05 Nov 2002.
 
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening of
+    the library.
+    14 Jan 2003.
+
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 UNIT rexx;
 
 INTERFACE
@@ -470,6 +480,9 @@ Const
 
 VAR RexxSysBase : pLibrary;
 
+const
+    REXXSYSLIBNAME : PChar = 'rexxsyslib.library';
+
 PROCEDURE ClearRexxMsg(msgptr : pRexxMsg; count : ULONG);
 FUNCTION CreateArgstring(argstring : pCHAR; length : ULONG) : pCHAR;
 FUNCTION CreateRexxMsg(port : pMsgPort; extension : pCHAR; host : pCHAR) : pRexxMsg;
@@ -490,7 +503,7 @@ FUNCTION LengthArgstring(argstring : string) : ULONG;
 
 IMPLEMENTATION
 
-uses pastoc;
+uses pastoc,msgbox;
 
 
 PROCEDURE ClearRexxMsg(msgptr : pRexxMsg; count : ULONG);
@@ -651,14 +664,60 @@ begin
        LengthArgstring := LengthArgstring(pas2c(argstring));
 end;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of rexxsyslib.library}
+
+var
+    rexxsyslib_exit : Pointer;
+
+procedure CloserexxsyslibLibrary;
+begin
+    ExitProc := rexxsyslib_exit;
+    if RexxSysBase <> nil then begin
+        CloseLibrary(RexxSysBase);
+        RexxSysBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    RexxSysBase := nil;
+    RexxSysBase := OpenLibrary(REXXSYSLIBNAME,LIBVERSION);
+    if RexxSysBase <> nil then begin
+        rexxsyslib_exit := ExitProc;
+        ExitProc := @CloserexxsyslibLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open rexxsyslib.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of rexxsyslib.library compiled}
+   {$Info Make sure you open rexxsyslib.library yourself}
+{$endif use_auto_openlib}
+
 
 END. (* UNIT REXXSYSLIB *)
 
 {
   $Log$
-  Revision 1.3  2002-11-19 18:47:47  nils
+  Revision 1.4  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.3  2002/11/19 18:47:47  nils
     * update check internal log
 
 }
 
-  
+  

+ 62 - 1
packages/extra/amunits/units/translator.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -13,6 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{
+    History:
+    
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening
+    of the library.
+    14 Jan 2003.
+    
+    [email protected] Nils Sjoholm
+}
+
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
 
 UNIT translator;
 
@@ -27,10 +42,15 @@ Const
 
 VAR TranslatorBase : pLibrary;
 
+const
+    TRANSLATORNAME : PChar = 'translator.library';
+
 FUNCTION Translate(inputString : pCHAR; inputLength : LONGINT; outputBuffer : pCHAR; bufferSize : LONGINT) : LONGINT;
 
 IMPLEMENTATION
 
+uses msgbox;
+
 FUNCTION Translate(inputString : pCHAR; inputLength : LONGINT; outputBuffer : pCHAR; bufferSize : LONGINT) : LONGINT;
 BEGIN
   ASM
@@ -46,4 +66,45 @@ BEGIN
   END;
 END;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of translator.library}
+
+var
+    translator_exit : Pointer;
+
+procedure ClosetranslatorLibrary;
+begin
+    ExitProc := translator_exit;
+    if TranslatorBase <> nil then begin
+        CloseLibrary(TranslatorBase);
+        TranslatorBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    TranslatorBase := nil;
+    TranslatorBase := OpenLibrary(TRANSLATORNAME,LIBVERSION);
+    if TranslatorBase <> nil then begin
+        translator_exit := ExitProc;
+        ExitProc := @ClosetranslatorLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open translator.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of translator.library compiled}
+   {$Info Make sure you open translator.library yourself}
+{$endif use_auto_openlib}
+
 END. (* UNIT TRANSLATOR *)

+ 58 - 3
packages/extra/amunits/units/workbench.pas

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
 
     A file in Amiga system run time library.
-    Copyright (c) 1998-2002 by Nils Sjoholm
+    Copyright (c) 1998-2003 by Nils Sjoholm
     member of the Amiga RTL development team.
 
     See the file COPYING.FPC, included in this distribution,
@@ -34,9 +34,19 @@
     Removed amigaoverlays, use smartlink instead.
     05 Nov 2002.
 
+    Added the defines use_amiga_smartlink and
+    use_auto_openlib. Implemented autoopening of
+    the library.
+    14 Jan 2003.
+
     [email protected]
 }
 
+{$I useamigasmartlink.inc}
+{$ifdef use_amiga_smartlink}
+   {$smartlink on}
+{$endif use_amiga_smartlink}
+
 unit workbench;
 
 INTERFACE
@@ -249,7 +259,7 @@ PROCEDURE WBInfo(lock : BPTR; name : string; screen : pScreen);
 
 IMPLEMENTATION
 
-uses pastoc;
+uses pastoc,msgbox;
 
 FUNCTION AddAppIconA(id : ULONG; userdata : ULONG; text_ : pCHAR; msgport : pMsgPort; lock : pFileLock; diskobj : pDiskObject; taglist : pTagItem) : pAppIcon;
 BEGIN
@@ -374,12 +384,57 @@ begin
        WBInfo(lock,pas2c(name),screen);
 end;
 
+{$I useautoopenlib.inc}
+{$ifdef use_auto_openlib}
+  {$Info Compiling autoopening of workbench.library}
+
+var
+    wb_exit : Pointer;
+
+procedure ClosewbLibrary;
+begin
+    ExitProc := wb_exit;
+    if WorkbenchBase <> nil then begin
+        CloseLibrary(WorkbenchBase);
+        WorkbenchBase := nil;
+    end;
+end;
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+begin
+    WorkbenchBase := nil;
+    WorkbenchBase := OpenLibrary(WORKBENCHNAME,LIBVERSION);
+    if WorkbenchBase <> nil then begin
+        wb_exit := ExitProc;
+        ExitProc := @ClosewbLibrary
+    end else begin
+        MessageBox('FPC Pascal Error',
+        'Can''t open wb.library version ' + VERSION + #10 +
+        'Deallocating resources and closing down',
+        'Oops');
+        halt(20);
+    end;
+
+{$else}
+   {$Warning No autoopening of workbench.library compiled}
+   {$Info Make sure you open workbench.library yourself}
+{$endif use_auto_openlib}
 
 END. (* UNIT WB *)
 
 {
   $Log$
-  Revision 1.2  2002-11-19 18:47:48  nils
+  Revision 1.3  2003-01-14 18:46:04  nils
+  * added defines use_amia_smartlink and use_auto_openlib
+
+  * implemented autoopening of library
+
+  Revision 1.2  2002/11/19 18:47:48  nils
     * update check internal log
 
 }