home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / B_PASSWO.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  7KB  |  145 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                      BinkleyTerm Password Processor                      */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  24. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  25. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  26. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  27. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /* You can contact Bit Bucket Software Co. at any one of the following      */
  31. /* addresses:                                                               */
  32. /*                                                                          */
  33. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n343.z1.fidonet.org         */
  37. /*                                                                          */
  38. /* Please feel free to contact us at any time to share your comments about  */
  39. /* our software and/or licensing policies.                                  */
  40. /*                                                                          */
  41. /*                                                                          */
  42. /*  This module is based largely on a similar module in OPUS-CBCS V1.03b.   */
  43. /*  The original work is (C) Copyright 1987, Wynn Wagner III. The original  */
  44. /*  author has graciously allowed us to use his code in this work.          */
  45. /*                                                                          */
  46. /*--------------------------------------------------------------------------*/
  47.  
  48. /* Include this file before any other includes or defines! */
  49.  
  50. #include "includes.h"
  51.  
  52. char *strnpbk (char *, int);
  53.  
  54. /*--------------------------------------------------------------------------*/
  55. /* N PASSWORD                                                               */
  56. /*--------------------------------------------------------------------------*/
  57. int n_password (char *theirs, char *ours)
  58. {
  59.    int got_one;
  60.    char s_ours[9], s_theirs[9];
  61.  
  62.    if ((ours != NULL) && (ours[0]))
  63.       {
  64.       got_one = 2;
  65.  
  66.       if ((theirs != NULL) && (theirs[0]))
  67.          {
  68.          got_one = 1;
  69.          (void) strnpbk (theirs, 8);           /* Get rid of trailing blanks */
  70.          (void) strnpbk (ours, 8);
  71.  
  72.          if (!strnicmp (theirs, ours, 8))
  73.             {
  74.             status_line (MSG_TXT(M_PROTECTED_SESSION));
  75.             return 0;
  76.             }
  77.          }
  78.                 
  79.       (void) strncpy (s_ours, ours, 8);
  80.       (void) strncpy (s_theirs, theirs, 8);
  81.       s_ours[8] = s_theirs[8] = '\0';
  82.  
  83.       status_line (MSG_TXT(M_PWD_ERROR),
  84.                     Full_Addr_Str (&remote_addr),
  85.                     theirs,
  86.                     ours
  87.                   );
  88.  
  89.       return got_one;
  90.       }
  91.    return 0;
  92. }
  93.  
  94.  
  95. /*--------------------------------------------------------------------------*/
  96. /* N GET PASSWORD                                                           */
  97. /* Find the nodelist entry for this system and point remote_password at     */
  98. /* its password if any                                                      */
  99. /*--------------------------------------------------------------------------*/
  100. int n_getpassword (ADDRP pw_addr)
  101. {
  102.    extern char *remote_password;
  103.    extern struct _newnode newnodedes;            /* desc. of node            */
  104.    
  105.    remote_password = NULL;                       /* Default to no password   */
  106.    newnodedes.Password[0] = '\0';
  107.  
  108.    if (!nodefind (pw_addr, 0))                   /* find the node in the list */
  109.       {
  110.       remote_password = NULL;
  111.       return (0);                                /* return failure if can't  */
  112.       }
  113.  
  114.    if (newnodedes.Password[0] != '\0')           /* If anything there,       */
  115.       {
  116.       remote_password = (char *) (&newnodedes.Password[0]); /* Point at it              */
  117.       return (1);                                /* Successful attempt       */
  118.       }
  119.    else
  120.       {
  121.       /* No password involved */
  122.       return (0);
  123.       }
  124. }
  125.  
  126. /*
  127.  * Strip all trailing blanks from a record.
  128.  *
  129.  */
  130.  
  131. char *strnpbk (register char *string, register int n)
  132. {
  133.    string += n;                                 /* point past end of string */
  134.    while (n--)                                  /* now keep count */
  135.       {
  136.       if (*--string)                            /* if there's a character   */
  137.          {
  138.          if (*string != ' ')                    /* if not a blank, we exit  */
  139.             break;
  140.          *string = '\0';                        /* if blank, terminate here */
  141.          }
  142.       }
  143.    return string;
  144. }
  145.