home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / packery / xpk_source / xpkmaster / sublibs.c < prev    next >
C/C++ Source or Header  |  1996-10-19  |  1KB  |  61 lines

  1. #ifndef XPKMASTER_SUBLIBS_C
  2. #define XPKMASTER_SUBLIBS_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        sublibs.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: sublibs.c 1.0 (09.10.96)
  9.     Author:        SDI
  10.     Distribution:    PD
  11.     Description:    Handling of xpksublibraries
  12.  
  13.  1.0   09.10.96 : first real version
  14. */
  15.  
  16. #include <pragma/exec_lib.h>
  17. #include <exec/types.h>
  18. #include <dos/dos.h>
  19. #include "xpkmaster.h"
  20. #include "xpk_strings.h"
  21.  
  22. /************************* open sublib from ID ***************************/
  23. struct Library *opensub(struct XpkBuffer *xbuf, ULONG ID)
  24. {
  25.   UBYTE libname[] = "compressors/xpk____.library";
  26.   struct Library *XpkSubBase;
  27.  
  28.   /* Do nothing if we already have what we want */
  29.   if((xbuf->xb_SubBase) && (xbuf->xb_SubID == ID))
  30.     return xbuf->xb_SubBase;
  31.  
  32.   closesub(xbuf);
  33.  
  34.   xbuf->xb_SubID = ID;
  35.   CopyMem((STRPTR) &ID, libname+15, 4);
  36.  
  37.   if(!(XpkSubBase = OpenLibrary(libname, 0)))
  38.   {
  39.     xbuf->xb_Result = XPKERR_MISSINGLIB;
  40.     sprintf(xbuf->xb_ErrMsg, strings[FMT_CANNOT_OPEN_SUBLIB], libname);
  41.   }
  42.   else if((xbuf->xb_SubInfo = XpksPackerInfo())->xi_MasterVersion > MainVersion)
  43.   {
  44.     xbuf->xb_Result = XPKERR_OLDMASTLIB;
  45.     closesub(xbuf);
  46.   }
  47.   return(xbuf->xb_SubBase = XpkSubBase);
  48. }
  49.  
  50. /*********************** close any open sub-library *********************/
  51. void closesub(struct XpkBuffer *xbuf)
  52. {
  53.   if(xbuf->xb_SubBase)
  54.   {
  55.     CloseLibrary(xbuf->xb_SubBase);
  56.     xbuf->xb_SubBase = NULL;
  57.   }
  58. }
  59.  
  60. #endif /* XPKMASTER_SUBLIBS_C */
  61.