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

  1. /*
  2.  * chgpwd.c - a program that will change a users password from the CLI
  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: chgpwd B5 (10.2.91)";
  16.  
  17.  
  18. int main(argc, argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.         int error, hlh;
  23.         
  24.         /* check for valid number of arguments */
  25.         if((argc!=0)&&(argc!=1)&&(argc!=4))
  26.         {
  27.                 printf("USAGE: chgpwd [user name] [old password] [new password]\n");
  28.                 exit(0);
  29.         }
  30.         
  31.         /* try to open the hotlink.library.
  32.          * The hotlink.library will not open unless the hotlink resident code
  33.          * is running.
  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 no arguments are given use the standard requester */
  45.         if(argc<2)
  46.         {
  47.                 error = NewPassword(hlh);
  48.         }
  49.         /* otherwise use the arguments themselves */
  50.         else
  51.         {
  52.                 /* make the call to change the users password */
  53.                 error = ChgPassword(hlh, argv[1], argv[2], argv[3]);
  54.         }
  55.         
  56.         /* check for errors */
  57.         switch(error)
  58.         {
  59.                 case INVPARAM: printf("ERROR - user not found\n");
  60.                                break;
  61.                               
  62.                 case NOPRIV: printf("ERROR - you do not have clearance to use this function\n");
  63.                              break;
  64.                              
  65.                 case NOMEMORY: printf("ERROR - out of memory\n");
  66.                                break;
  67.         }
  68.         
  69.         /* Unregister this program from the hotlinks system */
  70.         UnRegister(hlh);
  71.         
  72.         /* close the library */
  73.         CloseLibrary((struct Library *)HotLinksBase);
  74. }
  75.