Browse Source

* changed startcode for library

nils 22 years ago
parent
commit
203ec998ac
2 changed files with 149 additions and 27 deletions
  1. 75 12
      packages/extra/amunits/units/bullet.pas
  2. 74 15
      packages/extra/amunits/units/locale.pas

+ 75 - 12
packages/extra/amunits/units/bullet.pas

@@ -22,6 +22,9 @@
     for the library
     13 Jan 2003.
     
+    Changed startcode for library.
+    1 Feb 2003.
+    
     [email protected] Nils Sjoholm
 }
 
@@ -377,9 +380,27 @@ FUNCTION OpenEngine : pGlyphEngine;
 FUNCTION ReleaseInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
 FUNCTION SetInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
 
+{Here we read how to compile this unit}
+{You can remove this include and use a define instead}
+{$I useautoopenlib.inc}
+{$ifdef use_init_openlib}
+procedure InitBULLETLibrary;
+{$endif use_init_openlib}
+
+{This is a variable that knows how the unit is compiled}
+var
+    BULLETIsCompiledHow : longint;
+
 IMPLEMENTATION
 
-uses msgbox;
+{
+ If you don't use array of const then just remove tagsarray
+}
+uses
+{$ifndef dont_use_openlib}
+msgbox,
+{$endif dont_use_openlib}
+tagsarray;
 
 PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
 BEGIN
@@ -442,9 +463,16 @@ BEGIN
   END;
 END;
 
-{$I useautoopenlib.inc}
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of bullet.library}
+
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+{$ifdef use_init_openlib}
+  {$Info Compiling initopening of bullet.library}
+  {$Info don't forget to use InitBULLETLibrary in the beginning of your program}
 
 var
     bullet_exit : Pointer;
@@ -458,18 +486,48 @@ begin
     end;
 end;
 
-const
-    { Change VERSION and LIBVERSION to proper values }
+procedure InitBULLETLibrary;
+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;
+end;
 
-    VERSION : string[2] = '0';
-    LIBVERSION : Cardinal = 0;
+begin
+    BULLETIsCompiledHow := 2;
+{$endif use_init_openlib}
+
+{$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;
 
 begin
     BulletBase := nil;
     BulletBase := OpenLibrary(BULLETNAME,LIBVERSION);
     if BulletBase <> nil then begin
         bullet_exit := ExitProc;
-        ExitProc := @ClosebulletLibrary
+        ExitProc := @ClosebulletLibrary;
+        BULLETIsCompiledHow := 1;
     end else begin
         MessageBox('FPC Pascal Error',
         'Can''t open bullet.library version ' + VERSION + #10 +
@@ -478,11 +536,16 @@ begin
         halt(20);
     end;
 
-{$else}
-   {$Warning No autoopening of bullet.library compiled}
-   {$Info Make sure you open bullet.library yourself}
 {$endif use_auto_openlib}
 
+{$ifdef dont_use_openlib}
+begin
+    BULLETIsCompiledHow := 3;
+   {$Warning No autoopening of bullet.library compiled}
+   {$Warning Make sure you open bullet.library yourself}
+{$endif dont_use_openlib}
+
+
 END. (* UNIT BULLET *)
 
 

+ 74 - 15
packages/extra/amunits/units/locale.pas

@@ -26,6 +26,9 @@
     of the library.
     14 Jan 2003.
 
+    Changed the start code for unit.
+    01 Feb 2003.
+
     [email protected]
 }
 
@@ -290,10 +293,23 @@ FUNCTION ParseDate(locale : pLocale; date : pDateStamp; fmtTemplate : pCHAR; get
 FUNCTION StrConvert(locale : pLocale; string1 : pCHAR; buffer : POINTER; bufferSize : ULONG; typ : ULONG) : ULONG;
 FUNCTION StrnCmp(locale : pLocale; string1 : pCHAR; string2 : pCHAR; length : LONGINT; typ : ULONG) : LONGINT;
 
+{Here we read how to compile this unit}
+{You can remove this include and use a define instead}
+{$I useautoopenlib.inc}
+{$ifdef use_init_openlib}
+procedure InitLOCALELibrary;
+{$endif use_init_openlib}
+
+{This is a variable that knows how the unit is compiled}
+var
+    LOCALEIsCompiledHow : longint;
 
 IMPLEMENTATION
 
-uses msgbox;
+uses
+{$ifndef dont_use_openlib}
+msgbox;
+{$endif dont_use_openlib}
 
 PROCEDURE CloseCatalog(catalog : pCatalog);
 BEGIN
@@ -651,9 +667,15 @@ BEGIN
   END;
 END;
 
-{$I useautoopenlib.inc}
-{$ifdef use_auto_openlib}
-  {$Info Compiling autoopening of locale.library}
+const
+    { Change VERSION and LIBVERSION to proper values }
+
+    VERSION : string[2] = '0';
+    LIBVERSION : Cardinal = 0;
+
+{$ifdef use_init_openlib}
+  {$Info Compiling initopening of locale.library}
+  {$Info don't forget to use InitLOCALELibrary in the beginning of your program}
 
 var
     locale_exit : Pointer;
@@ -662,23 +684,53 @@ procedure CloselocaleLibrary;
 begin
     ExitProc := locale_exit;
     if LocaleBase <> nil then begin
-        CloseLibrary(plibrary(LocaleBase));
+        CloseLibrary(pLibrary(LocaleBase));
         LocaleBase := nil;
     end;
 end;
 
-const
-    { Change VERSION and LIBVERSION to proper values }
+procedure InitLOCALELibrary;
+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;
+end;
 
-    VERSION : string[2] = '0';
-    LIBVERSION : Cardinal = 0;
+begin
+    LOCALEIsCompiledHow := 2;
+{$endif use_init_openlib}
+
+{$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;
 
 begin
     LocaleBase := nil;
     LocaleBase := pLocaleBase(OpenLibrary(LOCALENAME,LIBVERSION));
     if LocaleBase <> nil then begin
         locale_exit := ExitProc;
-        ExitProc := @CloselocaleLibrary
+        ExitProc := @CloselocaleLibrary;
+        LOCALEIsCompiledHow := 1;
     end else begin
         MessageBox('FPC Pascal Error',
         'Can''t open locale.library version ' + VERSION + #10 +
@@ -687,17 +739,24 @@ begin
         halt(20);
     end;
 
-{$else}
-   {$Warning No autoopening of locale.library compiled}
-   {$Info Make sure you open locale.library yourself}
 {$endif use_auto_openlib}
 
+{$ifdef dont_use_openlib}
+begin
+    LOCALEIsCompiledHow := 3;
+   {$Warning No autoopening of locale.library compiled}
+   {$Warning Make sure you open locale.library yourself}
+{$endif dont_use_openlib}
+
 
 END. (* UNIT LOCALE *)
 
 {
   $Log$
-  Revision 1.3  2003-01-14 18:46:04  nils
+  Revision 1.4  2003-02-07 20:49:54  nils
+  * changed startcode for library
+
+  Revision 1.3  2003/01/14 18:46:04  nils
   * added defines use_amia_smartlink and use_auto_openlib
 
   * implemented autoopening of library
@@ -707,4 +766,4 @@ END. (* UNIT LOCALE *)
 
 }
 
-  
+