--- sbbs/src/sbbs3/allusers.c 2018/04/24 16:41:23 1.1 +++ sbbs/src/sbbs3/allusers.c 2018/04/24 16:42:49 1.1.1.2 @@ -1,11 +1,35 @@ -/* ALLUSERS.C */ +/* $Id: allusers.c,v 1.1.1.2 2018/04/24 16:42:49 root Exp $ */ -/* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */ - -/****************************************************************************/ -/* Makes global changes to Synchronet user database (USER.DAT) */ -/* Compatible with Version 2.1 of Synchronet BBS Software */ -/****************************************************************************/ +/**************************************************************************** + * @format.tab-size 4 (Plain Text/Source Code File Header) * + * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * + * * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * See the GNU General Public License for more details: gpl.txt or * + * http://www.fsf.org/copyleft/gpl.html * + * * + * Anonymous FTP access to the most recent released source is available at * + * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * + * * + * Anonymous CVS access to the development source and modification history * + * is available at cvs.synchro.net:/cvsroot/sbbs, example: * + * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login * + * (just hit return, no password is necessary) * + * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src * + * * + * For Synchronet coding style and modification guidelines, see * + * http://www.synchro.net/source.html * + * * + * You are encouraged to submit any modifications (preferably in Unix diff * + * format) via e-mail to mods@synchro.net * + * * + * Note: If this box doesn't appear square, then you need to fix your tabs. * + ****************************************************************************/ #include #include @@ -13,9 +37,7 @@ #include #include -#include "dirwrap.h" - -#include "sbbsdefs.h" +#include "sbbs.h" int min=0,max=99; long reqflags[4]={0},reqrest=0,reqexempt=0; @@ -49,15 +71,16 @@ int lockuser(FILE *stream, ulong offset) { time_t start; -if(lock(fileno(stream),offset,U_LEN)==0) - return(0); -start=time(NULL); -while(1) { if(lock(fileno(stream),offset,U_LEN)==0) return(0); - if(time(NULL)-start>=10L) - break; } -return(-1); + start=time(NULL); + while(1) { + if(lock(fileno(stream),offset,U_LEN)==0) + return(0); + if(time(NULL)-start>=10L) + break; + } + return(-1); } /****************************************************************************/ @@ -65,15 +88,16 @@ return(-1); /****************************************************************************/ long getflagoff(int set) { -switch(set) { - default: - return(U_FLAGS1); - case 2: - return(U_FLAGS2); - case 3: - return(U_FLAGS3); - case 4: - return(U_FLAGS4); } + switch(set) { + default: + return(U_FLAGS1); + case 2: + return(U_FLAGS2); + case 3: + return(U_FLAGS3); + case 4: + return(U_FLAGS4); + } } /****************************************************************************/ @@ -86,256 +110,286 @@ int chkuser(FILE *stream, long offset) char str[128]; int i; -if(min || max!=99) { /* Check security level */ - fseek(stream,offset+U_LEVEL,SEEK_SET); - if(!fread(str,2,1,stream)) - return(0); - str[2]=0; - i=atoi(str); - if(imax) /* not within range */ - return(0); } /* so skip this user */ - -for(i=0;i<4;i++) - if(reqflags[i]) { - fseek(stream,offset+getflagoff(i+1),SEEK_SET); + if(min || max!=99) { /* Check security level */ + fseek(stream,offset+U_LEVEL,SEEK_SET); + if(!fread(str,2,1,stream)) + return(0); + str[2]=0; + i=atoi(str); + if(imax) /* not within range */ + return(0); /* so skip this user */ + } + + for(i=0;i<4;i++) + if(reqflags[i]) { + fseek(stream,offset+getflagoff(i+1),SEEK_SET); + if(!fread(str,8,1,stream)) + return(0); + str[8]=0; + truncsp(str); + if((ahtoul(str)&reqflags[i])!=reqflags[i]) + return(0); /* doesn't have 'em all */ + + } + + if(reqrest) { + fseek(stream,offset+U_REST,SEEK_SET); if(!fread(str,8,1,stream)) return(0); str[8]=0; truncsp(str); - if((ahtoul(str)&reqflags[i])!=reqflags[i]) - return(0); } /* doesn't have 'em all */ + if((ahtoul(str)&reqrest)!=reqrest) + return(0); + } -if(reqrest) { - fseek(stream,offset+U_REST,SEEK_SET); - if(!fread(str,8,1,stream)) - return(0); - str[8]=0; - truncsp(str); - if((ahtoul(str)&reqrest)!=reqrest) - return(0); } - -if(reqexempt) { - fseek(stream,offset+U_REST,SEEK_SET); - if(!fread(str,8,1,stream)) - return(0); - str[8]=0; - truncsp(str); - if((ahtoul(str)&reqexempt)!=reqexempt) - return(0); } + if(reqexempt) { + fseek(stream,offset+U_REST,SEEK_SET); + if(!fread(str,8,1,stream)) + return(0); + str[8]=0; + truncsp(str); + if((ahtoul(str)&reqexempt)!=reqexempt) + return(0); + } -return(1); + return(1); } int main(int argc, char **argv) { char dir[128],str[128]; - int i,j,k,file,set,sub,mod; + int i,j,file,set,sub,mod; long l,f,flags,flagoff,length,offset; FILE *stream; -printf("\nALLUSERS v2.10 - Bulk User Editor for Synchronet User Database\n"); + printf("\nALLUSERS v2.10 - Bulk User Editor for Synchronet User Database\n"); -if(argc<2) { - printf(usage); - exit(1); } -dir[0]=0; -for(i=1;i99) - j=99; - if(j<0) - j=0; - sprintf(str,"%suser.dat",dir); - if(!fexistcase(str) || (file=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) { - printf("Error opening %s\n",str); - exit(1); } - if((stream=fdopen(file,"w+b"))==NULL) { - printf("Error opening %s\n",str); - exit(1); } - setvbuf(stream,NULL,_IOFBF,2048); - length=filelength(file); - printf("\nChanging Levels\n"); - for(offset=0;offset99) + j=99; + if(j<0) + j=0; + sprintf(str,"%suser.dat",dir); + if(!fexistcase(str) || (file=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) { + printf("Error opening %s\n",str); + exit(1); + } + if((stream=fdopen(file,"w+b"))==NULL) { + printf("Error opening %s\n",str); + exit(1); + } + setvbuf(stream,NULL,_IOFBF,2048); + length=filelength(file); + printf("\nChanging Levels\n"); + for(offset=0;offset