Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commits (2)
  • Rob Swindell's avatar
    4415d99b
  • Rob Swindell's avatar
    Modernize finduser() a bit · 2106e629
    Rob Swindell authored
    Skip any prepended white-space in the passed name to find.
    Use better variable names (and length) for the character strings.
    Use matchusername() instead of strcmp(); matchusername() follows the liberal user-id/alias/name matching algorithm.
    Use strcasestr() instead of strstr(), so no copy/modification (upper-casing) of passed name is now required.
    When 'Q'uitting the search, set the SS_ABORT flag.
    2106e629
......@@ -31,26 +31,26 @@
/* Returns the number of the matched user or 0 if unsuccessful */
/* Called from functions main_sec, useredit and readmailw */
/****************************************************************************/
uint sbbs_t::finduser(const char* instr, bool silent_failure)
uint sbbs_t::finduser(const char* name, bool silent_failure)
{
int file,i;
char str[128],str2[256],str3[256],ynq[25],c,pass=1;
char buf[256],ynq[25],c,pass=1;
char path[MAX_PATH + 1];
long l,length;
FILE *stream;
i=atoi(instr);
SKIP_WHITESPACE(name);
i=atoi(name);
if(i>0) {
username(&cfg, i,str2);
if(str2[0] && strcmp(str2,"DELETED USER"))
username(&cfg, i, buf);
if(buf[0] && strcmp(buf,"DELETED USER"))
return(i);
}
SAFECOPY(str,instr);
strupr(str);
SAFEPRINTF(str3,"%suser/name.dat",cfg.data_dir);
if(flength(str3)<1L)
SAFEPRINTF(path,"%suser/name.dat",cfg.data_dir);
if(flength(path)<1L)
return(0);
if((stream=fnopen(&file,str3,O_RDONLY))==NULL) {
errormsg(WHERE,ERR_OPEN,str3,O_RDONLY);
if((stream=fnopen(&file,path,O_RDONLY))==NULL) {
errormsg(WHERE,ERR_OPEN,path,O_RDONLY);
return(0);
}
SAFEPRINTF(ynq,"%.3s",text[YNQP]);
......@@ -59,20 +59,18 @@ uint sbbs_t::finduser(const char* instr, bool silent_failure)
fseek(stream,0L,SEEK_SET); /* seek to beginning for each pass */
for(l=0;l<length;l+=LEN_ALIAS+2) {
if(!online) break;
fread(str2,LEN_ALIAS+2,1,stream);
fread(buf,LEN_ALIAS+2,1,stream);
for(c=0;c<LEN_ALIAS;c++)
if(str2[c]==ETX) break;
str2[c]=0;
if(buf[c]==ETX) break;
buf[c]=0;
if(!c) /* deleted user */
continue;
SAFECOPY(str3,str2);
strupr(str2);
if(pass==1 && !strcmp(str,str2)) {
if(pass==1 && matchusername(&cfg, name, buf)) {
fclose(stream);
return((l/(LEN_ALIAS+2))+1);
}
if(pass==2 && strstr(str2,str)) {
bprintf(text[DoYouMeanThisUserQ],str3
if(pass==2 && strcasestr(buf, name)) {
bprintf(text[DoYouMeanThisUserQ], buf
,(uint)(l/(LEN_ALIAS+2))+1);
c=(char)getkeys(ynq,0);
if(sys_status&SS_ABORT) {
......@@ -85,6 +83,7 @@ uint sbbs_t::finduser(const char* instr, bool silent_failure)
}
if(c==text[YNQP][2]) {
fclose(stream);
sys_status |= SS_ABORT;
return(0);
}
}
......
......@@ -120,7 +120,7 @@ void sbbs_t::showfileinfo(file_t* f, bool show_extdesc)
char* sbbs_t::getfilespec(char *str)
{
bputs(text[FileSpecStarDotStar]);
if(!getstr(str, MAX_FILENAME_LEN, K_NONE))
if(!getstr(str, MAX_FILENAME_LEN, K_TRIM))
strcpy(str, ALLFILES);
if(msgabort(true))
return NULL;
......@@ -271,7 +271,7 @@ bool sbbs_t::editfilename(file_t* f)
bputs(text[EditFilename]);
SAFECOPY(str, f->name);
if(!getstr(str, sizeof(str) - 1, K_EDIT|K_AUTODEL))
if(!getstr(str, sizeof(str) - 1, K_EDIT|K_AUTODEL|K_TRIM))
return false;
if(msgabort(true))
return false;
......@@ -336,7 +336,7 @@ bool sbbs_t::editfileinfo(file_t* f)
char uploader[LEN_ALIAS + 1];
SAFECOPY(uploader, f->from);
bputs(text[EditUploader]);
getstr(uploader, sizeof(uploader), K_EDIT|K_AUTODEL);
getstr(uploader, sizeof(uploader), K_EDIT|K_AUTODEL|K_TRIM);
if(msgabort(true))
return false;
if(*uploader != '\0' || *f->from != '\0')
......