home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: StartUp.c 1.0 (14.8.96)
- **
- ** Library startup-code and function table definition
- **
- ** (C) Copyright 1996 Andreas R. Kleinert
- ** All Rights Reserved.
- **
- ** Modified by Dirk Holtwick for DITO, 1996
- */
-
- /// HEADER
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/libraries.h>
- #include <exec/execbase.h>
- #include <exec/resident.h>
- #include <exec/initializers.h>
-
- #include <proto/exec.h>
-
- #include "Base.h"
- #include <clib/ditoext_protos.h>
- ///
- /// PROTOTYPES
- extern ULONG __saveds __stdargs L_OpenLibs(void);
- extern void __saveds __stdargs L_CloseLibs(void);
-
-
- struct DitoExtBase * __saveds __asm InitLib( register __a6 struct ExecBase *sysbase,
- register __a0 struct SegList *seglist,
- register __d0 struct DitoExtBase *exb);
-
- struct DitoExtBase * __saveds __asm OpenLib( register __a6 struct DitoExtBase *DitoExtBase);
- struct SegList * __saveds __asm CloseLib( register __a6 struct DitoExtBase *DitoExtBase);
- struct SegList * __saveds __asm ExpungeLib( register __a6 struct DitoExtBase *exb);
- ULONG __saveds __asm ExtFuncLib(void);
- ///
-
- /// LibStart()
- ULONG __saveds __asm LibStart(void)
- {
- return(0);
- }
- ///
-
- /// struct InitTable
- extern APTR FuncTab [];
- extern struct MyDataInit DataTab;
-
- struct InitTable
- {
- ULONG LibBaseSize;
- APTR *FunctionTable;
- struct MyDataInit *DataTable;
- APTR InitLibTable;
- } InitTab =
- {
- sizeof(struct DitoExtBase),
- &FuncTab[0],
- &DataTab,
- InitLib
- };
- ///
- /// struct FuncTable
- APTR FuncTab [] =
- {
- OpenLib,
- CloseLib,
- ExpungeLib,
- ExtFuncLib,
-
- DITO_GetExtInfo,
- DITO_CreateInput,
- DITO_DisposeInput,
- DITO_WriteInput,
- DITO_ClearInput,
- DITO_ReadInput,
- DITO_ActivateFirstInput,
- DITO_FontsInput,
- DITO_UpdateInput,
- DITO_CreateOutput,
- DITO_DisposeOutput,
- DITO_WriteOutput,
- DITO_FontsOutput,
- DITO_UpdateOutput,
- DITO_ParseInput,
- DITO_GrammarString,
-
- (APTR) ((LONG)-1)
- };
-
-
- extern struct DitoExtBase *DitoExtBase;
- ///
-
- /// InitLib()
- struct DitoExtBase * __saveds __asm InitLib( register __a6 struct ExecBase *sysbase,
- register __a0 struct SegList *seglist,
- register __d0 struct DitoExtBase *exb)
- {
- DitoExtBase = exb;
-
- DitoExtBase->exb_SysBase = sysbase;
- DitoExtBase->exb_SegList = seglist;
-
- if(L_OpenLibs()) return(DitoExtBase);
-
- L_CloseLibs();
-
- return(NULL);
- }
- ///
- /// OpenLib()
- struct DitoExtBase * __saveds __asm OpenLib( register __a6 struct DitoExtBase *DitoExtBase)
- {
- DitoExtBase->exb_LibNode.lib_OpenCnt++;
-
- DitoExtBase->exb_LibNode.lib_Flags &= (0xFF ^ LIBF_DELEXP);
-
- return(DitoExtBase);
- }
- ///
- /// CloseLib()
- struct SegList * __saveds __asm CloseLib( register __a6 struct DitoExtBase *DitoExtBase)
- {
- DitoExtBase->exb_LibNode.lib_OpenCnt--;
-
- if(!DitoExtBase->exb_LibNode.lib_OpenCnt)
- {
- if(DitoExtBase->exb_LibNode.lib_Flags & LIBF_DELEXP)
- {
- return( ExpungeLib(DitoExtBase) );
- }
- }
-
- return(NULL);
- }
- ///
- /// ExpungeLib()
- struct SegList * __saveds __asm ExpungeLib( register __a6 struct DitoExtBase *exb)
- {
- struct DitoExtBase *DitoExtBase = exb;
- struct SegList *seglist;
-
- if(!DitoExtBase->exb_LibNode.lib_OpenCnt)
- {
- ULONG negsize, possize, fullsize;
- UBYTE *negptr = (UBYTE *) DitoExtBase;
-
- seglist = DitoExtBase->exb_SegList;
-
- Remove(DitoExtBase);
-
- L_CloseLibs();
-
- negsize = DitoExtBase->exb_LibNode.lib_NegSize;
- possize = DitoExtBase->exb_LibNode.lib_PosSize;
- fullsize = negsize + possize;
- negptr -= negsize;
-
- FreeMem(negptr, fullsize);
-
- return(seglist);
- }
-
- DitoExtBase->exb_LibNode.lib_Flags |= LIBF_DELEXP;
-
- return(NULL);
- }
- ///
- /// ExtFuncLib()
- ULONG __saveds __asm ExtFuncLib(void)
- {
- return(NULL);
- }
-
- struct DitoExtBase *DitoExtBase = NULL;
- ///
-
- /// SAS (private)
- /* for SAS/C's sc.lib only */
-
- ULONG XCEXIT = NULL;
- ULONG _XCEXIT = NULL;
- ULONG ONBREAK = NULL;
- 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;
- ///
-