home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / tools / libs / regexp / src / startup.c < prev   
Encoding:
C/C++ Source or Header  |  1998-02-19  |  4.5 KB  |  198 lines

  1. /*
  2. **      $VER: StartUp.c 37.10 (1.4.97)
  3. **
  4. **      Library startup-code and function table definition
  5. **
  6. **      (C) Copyright 1996-97 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #define __USE_SYSBASE        // perhaps only recognized by SAS/C
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <exec/libraries.h>
  15. #include <exec/execbase.h>
  16. #include <exec/resident.h>
  17. #include <exec/initializers.h>
  18.  
  19.  
  20. #ifdef __MAXON__
  21. #include <pragma/exec_lib.h>
  22. #include <linkerfunc.h>
  23. #else
  24. #include <proto/exec.h>    // all other compilers
  25. #endif
  26. #include "compiler.h"
  27.  
  28. #ifndef __GNUC__            // changed from #ifdef - seems screwed up somehow...
  29. #include "regexpbase.h"  // GNUC can not handle relativ pathnames.
  30.                           // The full path must be given in the makefile
  31. #else
  32. #include "/include/regexp/regexpbase.h"
  33. #endif
  34.  
  35. #include <libraries/regexp.h>
  36. #include "regexp.h"
  37.  
  38. extern ULONG __saveds __stdargs L_OpenLibs(void);
  39. extern void  __saveds __stdargs L_CloseLibs(void);
  40.  
  41. struct RegexpBase * __saveds ASM InitLib( register __a6 struct ExecBase *sysbase GNUCREG("a6"),
  42.                     register __a0 APTR           *seglist GNUCREG("a0"),
  43.                     register __d0 struct RegexpBase *exb GNUCREG("d0"));
  44. struct RegexpBase * __saveds ASM OpenLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"));
  45. APTR __saveds ASM CloseLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"));
  46. APTR __saveds ASM ExpungeLib( register __a6 struct RegexpBase *exb GNUCREG("a6"));
  47. ULONG ASM ExtFuncLib(void);
  48.  
  49. LONG ASM LibStart(void)
  50. {
  51.  return(-1);
  52. }
  53.  
  54. extern APTR FuncTab [];
  55. extern struct MyDataInit DataTab;
  56.  
  57. struct InitTable                       /* do not change */
  58. {
  59.  ULONG              LibBaseSize;
  60.  APTR              *FunctionTable;
  61.  struct MyDataInit *DataTable;
  62.  APTR               InitLibTable;
  63. } InitTab =
  64. {
  65.  sizeof(struct RegexpBase),
  66.  &FuncTab[0],
  67.  &DataTab,
  68.  InitLib
  69. };
  70.  
  71. APTR FuncTab [] =                      
  72. {
  73.  OpenLib,
  74.  CloseLib,
  75.  ExpungeLib,
  76.  ExtFuncLib,
  77.  
  78.  RegComp,RegFree,RegExec,
  79.  
  80.  (APTR) ((LONG)-1)
  81. };
  82.  
  83.  
  84. extern struct RegexpBase *RegexpBase;
  85.  
  86. struct RegexpBase * __saveds ASM InitLib( register __a6 struct ExecBase      *sysbase GNUCREG("a6"),
  87.                     register __a0 APTR           *seglist GNUCREG("a0"),
  88.                     register __d0 struct RegexpBase *exb GNUCREG("d0"))
  89. {
  90.  RegexpBase = exb;
  91.  
  92.  RegexpBase->reb_SysBase = sysbase;
  93.  RegexpBase->reb_SegList = seglist;
  94.  
  95.  if(L_OpenLibs()) return(RegexpBase);
  96.  
  97.  L_CloseLibs();
  98.  
  99.  return(NULL);
  100. }
  101.  
  102. struct RegexpBase * __saveds ASM OpenLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"))
  103. {
  104.  #ifdef __MAXON__
  105.  GetBaseReg();
  106.  InitModules();
  107.  #endif
  108.  
  109.  RegexpBase->reb_LibNode.lib_OpenCnt++;
  110.  
  111.  RegexpBase->reb_LibNode.lib_Flags &= ~LIBF_DELEXP;
  112.  
  113.  return(RegexpBase);
  114. }
  115.  
  116. APTR __saveds ASM CloseLib( register __a6 struct RegexpBase *RegexpBase GNUCREG("a6"))
  117. {
  118.  RegexpBase->reb_LibNode.lib_OpenCnt--;
  119.  
  120.  if(!RegexpBase->reb_LibNode.lib_OpenCnt)
  121.   {
  122.    if(RegexpBase->reb_LibNode.lib_Flags & LIBF_DELEXP)
  123.     {
  124.      return( ExpungeLib(RegexpBase) );
  125.     }
  126.   }
  127.  
  128.  return(NULL);
  129. }
  130.  
  131. APTR __saveds ASM ExpungeLib( register __a6 struct RegexpBase *exb GNUCREG("a6"))
  132. {
  133.  struct RegexpBase *RegexpBase = exb;
  134.  APTR seglist;
  135.  
  136.  if(!RegexpBase->reb_LibNode.lib_OpenCnt)
  137.   {
  138.    ULONG negsize, possize, fullsize;
  139.    UBYTE *negptr = (UBYTE *) RegexpBase;
  140.  
  141.    seglist = RegexpBase->reb_SegList;
  142.  
  143.    Remove((struct Node *)RegexpBase);
  144.  
  145.    L_CloseLibs();
  146.  
  147.    negsize  = RegexpBase->reb_LibNode.lib_NegSize;
  148.    possize  = RegexpBase->reb_LibNode.lib_PosSize;
  149.    fullsize = negsize + possize;
  150.    negptr  -= negsize;
  151.  
  152.    FreeMem(negptr, fullsize);
  153.  
  154.    #ifdef __MAXON__
  155.    CleanupModules();
  156.    #endif
  157.  
  158.    return(seglist);
  159.   }
  160.   
  161.  RegexpBase->reb_LibNode.lib_Flags |= LIBF_DELEXP;
  162.  
  163.  return(NULL);
  164. }
  165.  
  166. ULONG ASM ExtFuncLib(void)
  167. {
  168.  return(NULL);
  169. }
  170.  
  171. struct RegexpBase *RegexpBase = NULL;
  172.  
  173. #ifdef __SASC
  174.  
  175. #ifdef ARK_OLD_STDIO_FIX
  176.  
  177. ULONG XCEXIT       = NULL; /* these symbols may be referenced by    */
  178. ULONG _XCEXIT      = NULL; /* some functions of sc.lib, but should  */
  179. ULONG ONBREAK      = NULL; /* never be used inside a shared library */
  180. ULONG _ONBREAK     = NULL;
  181. ULONG base         = NULL;
  182. ULONG _base        = NULL;
  183. ULONG ProgramName  = NULL;
  184. ULONG _ProgramName = NULL;
  185. ULONG StackPtr     = NULL;
  186. ULONG _StackPtr    = NULL;
  187. ULONG oserr        = NULL;
  188. ULONG _oserr       = NULL;
  189. ULONG OSERR        = NULL;
  190. ULONG _OSERR       = NULL;
  191.  
  192. #endif /* ARK_OLD_STDIO_FIX */
  193.  
  194. void __regargs __chkabort(void) { }  /* a shared library cannot be    */
  195. void __regargs _CXBRK(void)     { }  /* CTRL-C aborted when doing I/O */
  196.  
  197. #endif /* __SASC */
  198.