home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /*======================================================================*/
- /* Miscellaneous user editting routines */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
-
-
- word pascal finduser (char type, char *users_name) {
-
- /* Finds user named users_name in users.bbs unless user isn't there
- or user is locked out. Returns user # and alters structure other
- to contain user's info. Info is undefined if 0 is returned. */
-
- int handle;
- struct ffblk f;
- struct _user *uuser;
- word temp;
-
- if(type) uuser=&user;
- else uuser=&other;
- if(findfirst(searchpath("users.bbs"),&f,0)) {
- return 0;
- }
- if (!f.ff_fsize) {
- return 0;
- }
- if ((handle=oopen(searchpath("USERS.BBS"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- return 0;
- }
- lseek(handle,0L,SEEK_SET);
- while (!eof(handle)) {
- if(_read(handle,uuser,sizeof(struct _user))<1) break;
- if (!(stricmp(uuser->name,users_name)) && (!uuser->deleted)) break;
- if (!(stricmp(uuser->handle,users_name)) && (!uuser->deleted)) break;
- }
- if (((stricmp(uuser->name,users_name)) && (stricmp(uuser->handle,users_name))) || (uuser->deleted)) goto notfound;
- temp=(word)(tell(handle)/(long)sizeof(struct _user));
- cclose(handle);
-
- if (!temp) {
- notfound:
- cclose(handle);
- return 0;
- }
- if(type)userno=temp;
- else tempuserno=temp;
- return temp;
- }
-
-
-
- word pascal load_user (word num) {
-
- int handle,x;
- struct ffblk f;
-
- if(findfirst(searchpath("users.bbs"),&f,0)) {
- return 0;
- }
- if (!f.ff_fsize) {
- return 0;
- }
- if((word)(f.ff_fsize/(long)sizeof(struct _user))<num) return 0;
- if ((handle=oopen(searchpath("USERS.BBS"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- return 0;
- }
- if(conf.share) {
- x=0;
- while (lock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user))){
- x++;
- if(x>2) {
- say_prompt(50);
- return 0;
- }
- say_prompt(57);
- sleep(1);
- }
- }
- lseek(handle,(long)sizeof(struct _user)*(num-1),SEEK_SET);
- _read(handle,&other,sizeof(struct _user));
- if(conf.share)unlock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user));
- cclose(handle);
- return num;
- }
-
-
- word pascal save_user (word num) {
-
- int handle,x;
- struct ffblk f;
-
- if(findfirst(searchpath("users.bbs"),&f,0)) {
- return 0;
- }
- if((word)(f.ff_fsize/(long)sizeof(struct _user))<num) return 0;
- if ((handle=oopen(searchpath("USERS.BBS"),O_RDWR | O_BINARY | O_DENYNONE))==-1) {
- return 0;
- }
- if(conf.share) {
- x=0;
- while (lock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user))){
- x++;
- if(x>2) {
- say_prompt(50);
- return 0;
- }
- say_prompt(57);
- sleep(1);
- }
- }
- lseek(handle,(long)sizeof(struct _user)*(num-1),SEEK_SET);
- _write(handle,&other,sizeof(struct _user));
- if(conf.share)unlock(handle,(long)sizeof(struct _user)*(num-1),(long)sizeof(struct _user));
- cclose(handle);
- return num;
- }
-
-