home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: StartUp.c 37.10 (1.4.97)
- **
- ** Library startup-code and function table definition
- **
- ** (C) Copyright 1996-97 Andreas R. Kleinert
- ** All Rights Reserved.
- */
-
- #define __USE_SYSBASE // perhaps only recognized by SAS/C
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/libraries.h>
- #include <exec/execbase.h>
- #include <exec/resident.h>
- #include <exec/initializers.h>
-
-
- #ifdef __MAXON__
- #include <pragma/exec_lib.h>
- #include <linkerfunc.h>
- #else
- #include <proto/exec.h> // all other compilers
- #endif
- #include "compiler.h"
-
- #ifndef __GNUC__ // changed from #ifdef - seems screwed up somehow...
- #include "regexpbase.h" // GNUC can not handle relativ pathnames.
- // The full path must be given in the makefile
- #else
- #include "/include/regexp/regexpbase.h"
- #endif
-
- #include <libraries/regexp.h>
- #include "regexp.h"
-
- extern ULONG __saveds __stdargs L_OpenLibs(void);
- extern void __saveds __stdargs L_CloseLibs(void);
-
- struct RegexpBase * __saveds ASM InitLib( register __a6 struct ExecBase *sysbase GNUCREG("a6"),
- register __a0 APTR *seglist GNUCREG("a0"),
- register __d0 struct RegexpBase *exb GNUCREG("d0"));
- struct RegexpBase * __saveds ASM OpenLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"));
- APTR __saveds ASM CloseLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"));
- APTR __saveds ASM ExpungeLib( register __a6 struct RegexpBase *exb GNUCREG("a6"));
- ULONG ASM ExtFuncLib(void);
-
- LONG ASM LibStart(void)
- {
- return(-1);
- }
-
- extern APTR FuncTab [];
- extern struct MyDataInit DataTab;
-
- struct InitTable /* do not change */
- {
- ULONG LibBaseSize;
- APTR *FunctionTable;
- struct MyDataInit *DataTable;
- APTR InitLibTable;
- } InitTab =
- {
- sizeof(struct RegexpBase),
- &FuncTab[0],
- &DataTab,
- InitLib
- };
-
- APTR FuncTab [] =
- {
- OpenLib,
- CloseLib,
- ExpungeLib,
- ExtFuncLib,
-
- RegComp,RegFree,RegExec,
-
- (APTR) ((LONG)-1)
- };
-
-
- extern struct RegexpBase *RegexpBase;
-
- struct RegexpBase * __saveds ASM InitLib( register __a6 struct ExecBase *sysbase GNUCREG("a6"),
- register __a0 APTR *seglist GNUCREG("a0"),
- register __d0 struct RegexpBase *exb GNUCREG("d0"))
- {
- RegexpBase = exb;
-
- RegexpBase->reb_SysBase = sysbase;
- RegexpBase->reb_SegList = seglist;
-
- if(L_OpenLibs()) return(RegexpBase);
-
- L_CloseLibs();
-
- return(NULL);
- }
-
- struct RegexpBase * __saveds ASM OpenLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"))
- {
- #ifdef __MAXON__
- GetBaseReg();
- InitModules();
- #endif
-
- RegexpBase->reb_LibNode.lib_OpenCnt++;
-
- RegexpBase->reb_LibNode.lib_Flags &= ~LIBF_DELEXP;
-
- return(RegexpBase);
- }
-
- APTR __saveds ASM CloseLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"))
- {
- RegexpBase->reb_LibNode.lib_OpenCnt--;
-
- if(!RegexpBase->reb_LibNode.lib_OpenCnt)
- {
- if(RegexpBase->reb_LibNode.lib_Flags & LIBF_DELEXP)
- {
- return( ExpungeLib(RegexpBase) );
- }
- }
-
- return(NULL);
- }
-
- APTR __saveds ASM ExpungeLib( register __a6 struct RegexpBase *exb GNUCREG("a6"))
- {
- struct RegexpBase *RegexpBase = exb;
- APTR seglist;
-
- if(!RegexpBase->reb_LibNode.lib_OpenCnt)
- {
- ULONG negsize, possize, fullsize;
- UBYTE *negptr = (UBYTE *) RegexpBase;
-
- seglist = RegexpBase->reb_SegList;
-
- Remove((struct Node *)RegexpBase);
-
- L_CloseLibs();
-
- negsize = RegexpBase->reb_LibNode.lib_NegSize;
- possize = RegexpBase->reb_LibNode.lib_PosSize;
- fullsize = negsize + possize;
- negptr -= negsize;
-
- FreeMem(negptr, fullsize);
-
- #ifdef __MAXON__
- CleanupModules();
- #endif
-
- return(seglist);
- }
-
- RegexpBase->reb_LibNode.lib_Flags |= LIBF_DELEXP;
-
- return(NULL);
- }
-
- ULONG ASM ExtFuncLib(void)
- {
- return(NULL);
- }
-
- struct RegexpBase *RegexpBase = NULL;
-
- #ifdef __SASC
-
- #ifdef ARK_OLD_STDIO_FIX
-
- ULONG XCEXIT = NULL; /* these symbols may be referenced by */
- ULONG _XCEXIT = NULL; /* some functions of sc.lib, but should */
- ULONG ONBREAK = NULL; /* never be used inside a shared library */
- ULONG _ONBREAK = NULL;
- ULONG base = NULL;
- ULONG _base = NULL;
- ULONG ProgramName = NULL;
- ULONG _ProgramName = NULL;
- ULONG StackPtr = NULL;
- ULONG _StackPtr = NULL;
- ULONG oserr = NULL;
- ULONG _oserr = NULL;
- ULONG OSERR = NULL;
- ULONG _OSERR = NULL;
-
- #endif /* ARK_OLD_STDIO_FIX */
-
- void __regargs __chkabort(void) { } /* a shared library cannot be */
- void __regargs _CXBRK(void) { } /* CTRL-C aborted when doing I/O */
-
- #endif /* __SASC */
-