home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / B_PASSWO.C < prev    next >
C/C++ Source or Header  |  1990-06-30  |  7KB  |  163 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-90, 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.240.    */
  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:132/491, 1:141/491  */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n132.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 <stdio.h>
  49. #include <signal.h>
  50. #include <ctype.h>
  51. #include <conio.h>
  52. #include <string.h>
  53.  
  54. #define WAZOO_SECTION
  55. #include "com.h"
  56. #include "xfer.h"
  57. #include "zmodem.h"
  58. #include "keybd.h"
  59. #include "sbuf.h"
  60. #include "sched.h"
  61. #include "externs.h"
  62. #include "prototyp.h"
  63.  
  64. static char *strnpbk (char *, int);
  65.  
  66. /*--------------------------------------------------------------------------*/
  67. /* N PASSWORD                                                               */
  68. /*--------------------------------------------------------------------------*/
  69. int n_password (theirs, ours)
  70. char *theirs;
  71. char *ours;
  72. {
  73.    int got_one;
  74.  
  75.    if ((ours != NULL) && (ours[0]))
  76.       {
  77.       got_one = 2;
  78.       if ((theirs != NULL) && (theirs[0]))
  79.          {
  80.          got_one = 1;
  81.          (void) strnpbk (theirs, 8);           /* Get rid of trailing blanks */
  82.          (void) strnpbk (ours, 8);
  83.  
  84.          if (!strnicmp (theirs, ours, 8))
  85.             {
  86.             status_line (msgtxt[M_PROTECTED_SESSION]);
  87.             return 0;
  88.             }
  89.          }
  90.                 
  91.       status_line (msgtxt[M_PWD_ERROR],
  92.                     Full_Addr_Str (&remote_addr),
  93.                     theirs,
  94.                     ours
  95.                   );
  96.  
  97. /*
  98.       SENDCHARS (snitty_message, strlen (snitty_message), 0);
  99.  
  100.       while (!OUT_EMPTY () && CARRIER)
  101.          time_release ();
  102. */
  103.  
  104.       return got_one;
  105.       }
  106.    return 0;
  107. }
  108.  
  109.  
  110. /*--------------------------------------------------------------------------*/
  111. /* N GET PASSWORD                                                           */
  112. /* Find the nodelist entry for this system and point remote_password at     */
  113. /* its password if any                                                      */
  114. /*--------------------------------------------------------------------------*/
  115. int n_getpassword (pw_addr)
  116. ADDR *pw_addr;
  117. {
  118.    extern char *remote_password;
  119.    extern struct _newnode newnodedes;            /* desc. of node            */
  120.    
  121.    remote_password = NULL;                       /* Default to no password   */
  122.    newnodedes.Password[0] = '\0';
  123.  
  124.    if (!nodefind (pw_addr, 0))                   /* find the node in the list */
  125.       {
  126.       remote_password = NULL;
  127.       return (0);                                /* return failure if can't  */
  128.       }
  129.  
  130.    if (newnodedes.Password[0] != '\0')           /* If anything there,       */
  131.       {
  132.       remote_password = (char *) (&newnodedes.Password[0]); /* Point at it              */
  133.       return (1);                                /* Successful attempt       */
  134.       }
  135.    else
  136.       {
  137.       /* No password involved */
  138.       return (0);
  139.       }
  140. }
  141.  
  142. /*
  143.  * Strip all trailing blanks from a record.
  144.  *
  145.  */
  146.  
  147. static char *strnpbk (string, n)
  148. register char *string;
  149. register int n;
  150. {
  151.    string += n;                                 /* point past end of string */
  152.    while (n--)                                  /* now keep count */
  153.       {
  154.       if (*--string)                            /* if there's a character   */
  155.          {
  156.          if (*string != ' ')                    /* if not a blank, we exit  */
  157.             break;
  158.          *string = '\0';                        /* if blank, terminate here */
  159.          }
  160.       }
  161.    return string;
  162. }
  163.