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

  1. /*
  2.  * login.c - a program that will log in a user to the hotlinks system
  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. /* the hotlink library base pointer */
  12. struct HotLinksBase *HotLinksBase;
  13.  
  14. /* version string */
  15. char     VERSTAG[]="\0$VER: Login B2 (10.2.91)";
  16.  
  17. int main(argc, argv)
  18. int argc;
  19. char *argv[];
  20. {
  21.         struct PubBlock *pb;
  22.         int hlh,error;
  23.         
  24.         /* check for help sign */
  25.         if((argv[1][0]=='?')||(argc>3))
  26.         {
  27.                 printf("USAGE: login <name> <password>\n");
  28.                 exit(0);
  29.         }
  30.         
  31.         /* try to open the hotlink library.
  32.          * If the hotlink resident code is not running the library will
  33.          * not be able to be opened.
  34.          */
  35.         if((HotLinksBase=(struct HotLinksBase *)OpenLibrary("hotlinks.library", 0))==0)
  36.         {
  37.                 printf("ERROR - could not open the hotlinks.library\n");
  38.                 exit(20);
  39.         }
  40.         
  41.         /* register this program with the hotlink system */
  42.         hlh = HLRegister(1,0,0);
  43.         
  44.         /* if only one argument use the login box */
  45.         if(argc==1)
  46.         {
  47.                 /* cause hotlinks to request a login - if no one is logged in */
  48.                 pb = AllocPBlock(hlh);
  49.                 if(((int)pb!=INVPARAM)&&((int)pb!=NOPRIV)&&((int)pb!=NOMEMORY))
  50.                 {
  51.                         FreePBlock(pb);
  52.                 }
  53.         }
  54.         else
  55.         {
  56.                 // name with no password
  57.                 if(argc==2)
  58.                 {       
  59.                         error = SetUser(hlh, argv[1], 0);
  60.                 }
  61.                 else //name and password
  62.                 {
  63.                         error = SetUser(hlh, argv[1], argv[2]);
  64.                 }
  65.                 
  66.                 if(error!=NOERROR)
  67.                 {
  68.                         printf("ERROR: %d\n", error);
  69.                 }
  70.         }
  71.         
  72.         /* Unregister this program from the hotlink system */
  73.         UnRegister(hlh);
  74.         
  75.         /* close the library */
  76.         CloseLibrary((struct Library *)HotLinksBase);
  77. }
  78.