home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / h / hldevkit.zip / DELED.C < prev    next >
C/C++ Source or Header  |  1992-04-28  |  2KB  |  83 lines

  1. /*
  2.  * deled.c - a program to delete a hotlink publication
  3.  *
  4.  */
  5.  
  6. #include <proto/exec.h>
  7. #include <proto/hotlinks.h>
  8. #include <lattice/stdio.h>
  9. #include <hotlinks/hotlinks.h>
  10.  
  11. /* hotlink library base pointer */
  12. struct HotLinksBase *HotLinksBase;
  13.  
  14. /* version string */
  15. char     VERSTAG[]="\0$VER: deled B5 (1.3.92)";
  16.  
  17.  
  18.  
  19. int main()
  20. {
  21.         struct PubBlock *pb;
  22.         int error, hlh;
  23.         
  24.         /* try to open the hotlink.library.
  25.          * The library will not open unless hotlinks is running.
  26.          */
  27.         if((HotLinksBase=(struct HotLinksBase *)OpenLibrary("hotlinks.library", 0))==0)
  28.         {
  29.                 printf("ERROR - could not open the hotlinks.library\n");
  30.                 exit(20);
  31.         }
  32.  
  33.         /* register this program with the hotlinks system */
  34.         hlh = HLRegister(1,0,0);
  35.         
  36.         /* get a PubBlock pointer */
  37.         pb=AllocPBlock(hlh);
  38.         
  39.         /* check for errors */
  40.         if((pb==(struct PubBlock *)NOMEMORY)||(pb==(struct PubBlock *)NOPRIV))
  41.         {
  42.                 printf("ERROR - AllocPBlock call failed: error=%d\n", pb);
  43.                 UnRegister(hlh);
  44.                 CloseLibrary((struct Library *)HotLinksBase);
  45.                 exit(0);
  46.         }
  47.                 
  48.         /* get a publication using the publication requester provided by the
  49.          * hotlink.library.
  50.          */
  51.          
  52.         error = GetPub(pb, 0);
  53.         
  54.         /* if the user selected a file and pressed ok then delete the file*/
  55.         if(error==NOERROR)
  56.         {
  57.                 /* delete the edition */
  58.                 error=RemovePub(pb);
  59.                 
  60.                 /* check for errors */
  61.                 switch(error)
  62.                 {
  63.                         case NOPRIV: printf("ERROR: privalge violation\n");
  64.                                      break;
  65.                                      
  66.                         case INVPARAM: printf("ERROR: invaild parameters\n");
  67.                                        break;
  68.                                        
  69.                         case IOERROR: printf("ERROR: I/O error, publication not removed\n");
  70.                                       break;
  71.                 }
  72.         }
  73.         
  74.         /* free the PubBlock pointer obtained by AllocPBlock */
  75.         (void)FreePBlock(pb);
  76.         
  77.         /* Unregister this program form the hotlink system */
  78.         UnRegister(hlh);
  79.         
  80.         /* close the libray and exit */
  81.         CloseLibrary((struct Library *)HotLinksBase);
  82. }
  83.