]>
git.saurik.com Git - wxWidgets.git/blob - src/expat/amiga/expat_lib.c
   2 ** Copyright (c) 2001-2009 Expat maintainers. 
   4 ** Permission is hereby granted, free of charge, to any person obtaining 
   5 ** a copy of this software and associated documentation files (the 
   6 ** "Software"), to deal in the Software without restriction, including 
   7 ** without limitation the rights to use, copy, modify, merge, publish, 
   8 ** distribute, sublicense, and/or sell copies of the Software, and to 
   9 ** permit persons to whom the Software is furnished to do so, subject to 
  10 ** the following conditions: 
  12 ** The above copyright notice and this permission notice shall be included 
  13 ** in all copies or substantial portions of the Software. 
  15 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  16 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  17 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
  18 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
  19 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
  20 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
  21 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
  29 #define __NOGLOBALIFACE__ 
  32 #include <proto/exec.h> 
  34 #include "expat_base.h" 
  37 #define LIBNAME         "expat.library" 
  41 #define VSTRING         "expat.library 53.1 (7.8.2009)"  /* dd.mm.yyyy */ 
  44 static const char* __attribute__((used
)) verstag 
= "\0$VER: " VSTRING
; 
  47 struct Interface 
*INewlib 
= 0; 
  50 struct ExpatBase 
* libInit(struct ExpatBase 
*libBase
, BPTR seglist
, struct ExecIFace 
*ISys
); 
  51 uint32 
libObtain (struct LibraryManagerInterface 
*Self
); 
  52 uint32 
libRelease (struct LibraryManagerInterface 
*Self
); 
  53 struct ExpatBase 
*libOpen (struct LibraryManagerInterface 
*Self
, uint32 version
); 
  54 BPTR 
libClose (struct LibraryManagerInterface 
*Self
); 
  55 BPTR 
libExpunge (struct LibraryManagerInterface 
*Self
); 
  56 struct Interface 
*openInterface(struct ExecIFace 
*IExec
, CONST_STRPTR libName
, uint32 libVer
); 
  57 void closeInterface(struct ExecIFace 
*IExec
, struct Interface 
*iface
); 
  60 static APTR lib_manager_vectors
[] = { 
  73 static struct TagItem lib_managerTags
[] = { 
  74         { MIT_Name
, (uint32
)"__library" }, 
  75         { MIT_VectorTable
, (uint32
)lib_manager_vectors 
}, 
  81 extern void *main_vectors
[]; 
  83 static struct TagItem lib_mainTags
[] = { 
  84         { MIT_Name
, (uint32
)"main" }, 
  85         { MIT_VectorTable
, (uint32
)main_vectors 
}, 
  91 static APTR libInterfaces
[] = { 
  98 extern void *VecTable68K
[]; 
 100 static struct TagItem libCreateTags
[] = { 
 101         { CLT_DataSize
, sizeof(struct ExpatBase
) }, 
 102         { CLT_InitFunc
, (uint32
)libInit 
}, 
 103         { CLT_Interfaces
, (uint32
)libInterfaces 
}, 
 104         { CLT_Vector68K
, (uint32
)VecTable68K 
}, 
 109 static struct Resident 
__attribute__((used
)) lib_res 
= { 
 110         RTC_MATCHWORD
,  // rt_MatchWord 
 111         &lib_res
,               // rt_MatchTag 
 112         &lib_res
+1,             // rt_EndSkip 
 113         RTF_NATIVE 
| RTF_AUTOINIT
,      // rt_Flags 
 114         VERSION
,                // rt_Version 
 115         NT_LIBRARY
,             // rt_Type 
 118         VSTRING
,                // rt_IdString 
 119         libCreateTags   
// rt_Init 
 129 struct ExpatBase 
*libInit(struct ExpatBase 
*libBase
, BPTR seglist
, struct ExecIFace 
*iexec
) 
 131         libBase
->libNode
.lib_Node
.ln_Type 
= NT_LIBRARY
; 
 132         libBase
->libNode
.lib_Node
.ln_Pri 
= LIBPRI
; 
 133         libBase
->libNode
.lib_Node
.ln_Name 
= LIBNAME
; 
 134         libBase
->libNode
.lib_Flags 
= LIBF_SUMUSED
|LIBF_CHANGED
; 
 135         libBase
->libNode
.lib_Version 
= VERSION
; 
 136         libBase
->libNode
.lib_Revision 
= REVISION
; 
 137         libBase
->libNode
.lib_IdString 
= VSTRING
; 
 139         libBase
->SegList 
= seglist
; 
 141         libBase
->IExec 
= iexec
; 
 142         INewlib        
= openInterface(iexec
, "newlib.library", 0); 
 144         if ( INewlib 
!= 0 )  { 
 148         closeInterface(iexec
, INewlib
); 
 151         iexec
->DeleteLibrary(&libBase
->libNode
); 
 157 uint32 
libObtain( struct LibraryManagerInterface 
*Self 
) 
 159         ++Self
->Data
.RefCount
; 
 160         return Self
->Data
.RefCount
; 
 164 uint32 
libRelease( struct LibraryManagerInterface 
*Self 
) 
 166         --Self
->Data
.RefCount
; 
 167         return Self
->Data
.RefCount
; 
 171 struct ExpatBase 
*libOpen( struct LibraryManagerInterface 
*Self
, uint32 version 
) 
 173         struct ExpatBase 
*libBase
; 
 175         libBase 
= (struct ExpatBase 
*)Self
->Data
.LibBase
; 
 177         ++libBase
->libNode
.lib_OpenCnt
; 
 178         libBase
->libNode
.lib_Flags 
&= ~LIBF_DELEXP
; 
 184 BPTR 
libClose( struct LibraryManagerInterface 
*Self 
) 
 186         struct ExpatBase 
*libBase
; 
 188         libBase 
= (struct ExpatBase 
*)Self
->Data
.LibBase
; 
 190         --libBase
->libNode
.lib_OpenCnt
; 
 191         if ( libBase
->libNode
.lib_OpenCnt 
) { 
 195         if ( libBase
->libNode
.lib_Flags 
& LIBF_DELEXP 
) { 
 196                 return (BPTR
)Self
->LibExpunge(); 
 204 BPTR 
libExpunge( struct LibraryManagerInterface 
*Self 
) 
 206         struct ExpatBase 
*libBase 
= (struct ExpatBase 
*)Self
->Data
.LibBase
; 
 209         if (libBase
->libNode
.lib_OpenCnt 
== 0) { 
 210                 libBase
->IExec
->Remove(&libBase
->libNode
.lib_Node
); 
 212                 result 
= libBase
->SegList
; 
 214                 closeInterface(libBase
->IExec
, INewlib
); 
 217                 libBase
->IExec
->DeleteLibrary(&libBase
->libNode
); 
 220                 libBase
->libNode
.lib_Flags 
|= LIBF_DELEXP
; 
 227 struct Interface 
*openInterface(struct ExecIFace 
*IExec
, CONST_STRPTR libName
, uint32 libVer
) 
 229         struct Library 
*base 
= IExec
->OpenLibrary(libName
, libVer
); 
 230         struct Interface 
*iface 
= IExec
->GetInterface(base
, "main", 1, 0); 
 232                 IExec
->CloseLibrary(base
); 
 239 void closeInterface(struct ExecIFace 
*IExec
, struct Interface 
*iface
) 
 243                 struct Library 
*base 
= iface
->Data
.LibBase
; 
 244                 IExec
->DropInterface(iface
); 
 245                 IExec
->CloseLibrary(base
);