home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XSUSER.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-09  |  5.7 KB  |  150 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31. /*======================================================================*/
  32. /* Miscellaneous user editting routines                                 */
  33. /*======================================================================*/
  34.  
  35. #include "msg.h"
  36. #include "xext.h"
  37.  
  38.  
  39.  
  40. word pascal finduser (char type, char *users_name) {
  41.  
  42.     /* Finds user named users_name in users.bbs unless user isn't there
  43.        or user is locked out.  Returns user # and alters structure other
  44.        to contain user's info.  Info is undefined if 0 is returned. */
  45.  
  46.     int handle;
  47.     struct ffblk f;
  48.     struct _user *uuser;
  49.     word temp;
  50.  
  51.     if(type) uuser=&user;
  52.     else uuser=&other;
  53.     if(findfirst(searchpath("users.bbs"),&f,0)) {
  54.         return 0;
  55.     }
  56.     if (!f.ff_fsize) {
  57.         return 0;
  58.     }
  59.     if ((handle=oopen(searchpath("USERS.BBS"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  60.         return 0;
  61.     }
  62.     lseek(handle,0L,SEEK_SET);
  63.     while (!eof(handle)) {
  64.          if(_read(handle,uuser,sizeof(struct _user))<1) break;
  65.          if (!(stricmp(uuser->name,users_name)) && (!uuser->deleted)) break;
  66.          if (!(stricmp(uuser->handle,users_name)) && (!uuser->deleted)) break;
  67.     }
  68.     if (((stricmp(uuser->name,users_name)) && (stricmp(uuser->handle,users_name))) || (uuser->deleted)) goto notfound;
  69.     temp=(word)(tell(handle)/(long)sizeof(struct _user));
  70.     cclose(handle);
  71.  
  72.     if (!temp) {
  73. notfound:
  74.         cclose(handle);
  75.         return 0;
  76.     }
  77.     if(type)userno=temp;
  78.     else tempuserno=temp;
  79.     return temp;
  80. }
  81.  
  82.  
  83.  
  84. word pascal load_user (word num) {
  85.  
  86.     int handle,x;
  87.     struct ffblk f;
  88.  
  89.     if(findfirst(searchpath("users.bbs"),&f,0)) {
  90.         return 0;
  91.     }
  92.     if (!f.ff_fsize) {
  93.         return 0;
  94.     }
  95.     if((word)(f.ff_fsize/(long)sizeof(struct _user))<num) return 0;
  96.     if ((handle=oopen(searchpath("USERS.BBS"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  97.         return 0;
  98.     }
  99.     if(conf.share) {
  100.         x=0;
  101.         while (lock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user))){
  102.             x++;
  103.             if(x>2) {
  104.                 say_prompt(50);
  105.                 return 0;
  106.             }
  107.             say_prompt(57);
  108.             sleep(1);
  109.         }
  110.     }
  111.     lseek(handle,(long)sizeof(struct _user)*(num-1),SEEK_SET);
  112.     _read(handle,&other,sizeof(struct _user));
  113.     if(conf.share)unlock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user));
  114.     cclose(handle);
  115.     return num;
  116. }
  117.  
  118.  
  119. word pascal save_user (word num) {
  120.  
  121.     int handle,x;
  122.     struct ffblk f;
  123.  
  124.     if(findfirst(searchpath("users.bbs"),&f,0)) {
  125.         return 0;
  126.     }
  127.     if((word)(f.ff_fsize/(long)sizeof(struct _user))<num) return 0;
  128.     if ((handle=oopen(searchpath("USERS.BBS"),O_RDWR | O_BINARY | O_DENYNONE))==-1) {
  129.         return 0;
  130.     }
  131.     if(conf.share) {
  132.         x=0;
  133.         while (lock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user))){
  134.             x++;
  135.             if(x>2) {
  136.                 say_prompt(50);
  137.                 return 0;
  138.             }
  139.             say_prompt(57);
  140.             sleep(1);
  141.         }
  142.     }
  143.     lseek(handle,(long)sizeof(struct _user)*(num-1),SEEK_SET);
  144.     _write(handle,&other,sizeof(struct _user));
  145.     if(conf.share)unlock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user));
  146.     cclose(handle);
  147.     return num;
  148. }
  149.  
  150.