home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / commands / arp.lzh / ARP / TOOLS / REMLIB.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-16  |  1.1 KB  |  52 lines

  1. /* Remove a specified version of arplibrary */
  2. /* This will ALWAYS remove the library, no matter what - USE WITH CARE */
  3. /* SDB */
  4.  
  5. #include <exec/types.h>
  6. #include <exec/libraries.h>
  7. #include <exec/execbase.h>
  8. #include <libraries/arpbase.h>
  9.  
  10. struct ArpBase *ArpBase, *OpenLibrary();
  11. struct EnvironmentBase *EB;
  12. extern struct ExecBase *SysBase;
  13.  
  14. main(argc, argv)
  15. char **argv;
  16. {
  17.     register int i;
  18.     register ULONG v;
  19.     struct ArpBase *FindName();
  20.  
  21.     if (argc <= 1)
  22.         printf("Usage remlib <version#>\n"), exit(100);
  23.     argv++;
  24.  
  25.     v = atoi(*argv);
  26.     
  27.     Forbid();
  28.     ArpBase = (struct ArpBase *)(&SysBase->LibList);
  29.     while( ArpBase = FindName(ArpBase, "arp.library"))
  30.     {
  31.         if (ArpBase->LibNode.lib_Version == v)
  32.             break;
  33.     }
  34.     if (!ArpBase)
  35.         printf("Version %ld of arplib not found!\n", v), Permit(),exit(100);
  36.  
  37.     /* Make sure you want to do this! */
  38.     if (v >= 12)
  39.     {
  40.         EB = (struct EnvironmentBase *)ArpBase->EnvBase;
  41.         *EB->EnvSpace = 0;
  42.     }
  43.     while (ArpBase->LibNode.lib_OpenCnt > 1)
  44.         CloseLibrary(ArpBase);
  45.     if (ArpBase->LibNode.lib_OpenCnt)
  46.         RemLibrary(ArpBase), CloseLibrary(ArpBase);
  47.     else
  48.         RemLibrary(ArpBase);
  49.     Permit();
  50. }
  51.  
  52.