home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- $CRT 16 Mar 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>Lib.c<< 04 Nov 1996 07:59:17 - (C) ProDAD
- *******************************************************************/
-
- //##private
-
- // mcpp:cppc -gs -o pos:pos/libs/my.library p:pLib/LibCode.o p:pCom/_Example/Lib/Lib.c p:pLib/pLinkLib.o
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
-
- #include "p:pExec/Library.h"
- #include "p:pExec/Resident.h"
- #include "p:pUtil/TagItem.h"
- #include "p:pDOS/Segment.h"
- #include "p:pExec/Diagnos.h"
- #include "p:pExec/TstTags.h"
-
- #ifdef _____ME_____
- #include "grund/inc_string.h"
- #include "grund/inc_limits.h"
- #else
- extern "C" {
- #include <string.h>
- #include <limits.h>
- }
- #endif
-
-
- struct MY_Lib
- {
- pOS_Library my_Lib;
-
- };
-
-
- extern ULONG *FuncTable[];
- extern BOOL pLibMain(_R_LB pOS_ExecBase*,_R_A0 MY_Lib*);
-
- const CHAR LibraryName[] ="my.library";
- const CHAR LibraryIDName[]="my.library 1.0 ("__DATE2__")";
-
- const pOS_TagItem LibraryDescribe[]=
- {
- EXTSTTAG_MainOSID, pOS_MAINOSID,
- TAG_END
- };
-
-
-
-
- pOS_ResidentLibInit InitTable=
- {
- sizeof(MY_Lib),
- FuncTable,
- NULL,
- (BOOL(*)(_R_LB pOS_ExecBase*,_R_A0 pOS_Library*))pLibMain
- };
-
-
- /*----------------------------------
- -----------------------------------*/
- static BOOL Open_func(MY_Lib* lib)
- {
- //PRINT("MY_Lib: Open()\n");
- return(1);
- }
-
- static VOID Close_func(MY_Lib* lib)
- {
- //PRINT("MY_Lib: Close()\n");
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- static pOS_SegmentLst* Expunge_func(MY_Lib* lib)
- {
- lib->my_Lib.lib_Flags |= LIBF_DELEXP;
- if(lib->my_Lib.lib_OpenCnt==0) {
- pOS_SegmentLst* Seg=lib->my_Lib.lib_Segm;
-
- pOS_ListRemove(&lib->my_Lib.lib_Node);
- _pOS_FreeLibraryMem2(&lib->my_Lib);
- //PRINT("MY_Lib: Expunge+Remove()\n");
- return(Seg);
- }
- return(0);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- static ULONG Reserved_func(MY_Lib* lib)
- {
- //PRINT("MY_Lib: Reserved()\n");
- return(0);
- }
-
-
-
- ULONG *FuncTable[]=
- {
- (ULONG*)Open_func,
- (ULONG*)Close_func,
- (ULONG*)Expunge_func,
- // ------------
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- // ------------
-
- (ULONG*)ULONG_MAX
-
- };
-
-
-
-
- /*----------------------------------
- -----------------------------------*/
- BOOL pLibMain(_R_LB pOS_ExecBase* exec,_R_A0 MY_Lib* lib)
- {
- gb_ExecBase=(struct pOS_ExecBase*)exec;
- gb_ExecLib=*((struct pOS_ExecLibFunction**)lib->my_Lib.lib_Segm->sel_Seg.seg_Reserved2);
- // PRINT("MY_lib: pLibMain( ) exec=%lx lib=%lx seg=%lx %lx\n",gb_ExecBase,lib,lib->my_Lib.lib_Segm,gb_ExecLib);
- return(TRUE);
- }
-
-
-