Commits (6)
......@@ -39,7 +39,7 @@ void sbbs_t::showfileinfo(file_t* f, bool show_extdesc)
bprintf(P_TRUNCATE, text[FiFilename],f->name);
if(getfilesize(&cfg, f) >= 0)
bprintf(P_TRUNCATE, text[FiFileSize], ultoac((ulong)f->size,tmp)
bprintf(P_TRUNCATE, text[FiFileSize], i64toac(f->size,tmp)
, byte_estimate_to_str(f->size, tmp2, sizeof(tmp2), /* units: */1024, /* precision: */1));
bprintf(P_TRUNCATE, text[FiCredits]
......
......@@ -1030,12 +1030,14 @@ int sbbs_t::listfileinfo(uint dirnum, const char *filespec, long mode)
}
}
}
getnodedat(cfg.node_num,&thisnode,1);
action=NODE_DLNG;
t=now + gettimetodl(&cfg, f, cur_cps);
localtime_r(&t,&tm);
thisnode.aux=(tm.tm_hour*60)+tm.tm_min;
putnodedat(cfg.node_num,&thisnode); /* calculate ETA */
action = NODE_DLNG;
if(getnodedat(cfg.node_num,&thisnode,true) == 0) {
thisnode.action = action;
t=now + gettimetodl(&cfg, f, cur_cps);
localtime_r(&t,&tm);
thisnode.aux=(tm.tm_hour*60)+tm.tm_min;
putnodedat(cfg.node_num,&thisnode); /* calculate ETA */
}
start=time(NULL);
error=protocol(cfg.prot[i],XFER_DOWNLOAD,path,nulstr,false);
end=time(NULL);
......
......@@ -495,6 +495,23 @@ char* ultoac(ulong l, char *string)
return(string);
}
char* i64toac(int64_t l, char *string)
{
char str[256];
int i,j,k;
_i64toa(l,str,10);
i=strlen(str)-1;
j=i/3+1+i;
string[j--]=0;
for(k=1;i>-1;k++) {
string[j--]=str[i--];
if(j>0 && !(k%3))
string[j--]=',';
}
return string;
}
/****************************************************************************/
/* Truncate string at first occurrence of char in specified character set */
/* Returns a pointer to the terminating NUL if the string was truncated, */
......
......@@ -64,6 +64,7 @@ DLLEXPORT BOOL valid_ctrl_a_attr(char a);
DLLEXPORT BOOL valid_ctrl_a_code(char a);
DLLEXPORT size_t strip_invalid_attr(char *str);
DLLEXPORT char * ultoac(ulong l,char *str);
DLLEXPORT char * i64toac(int64_t, char *str);
DLLEXPORT char * rot13(char* str);
DLLEXPORT uint32_t str_to_bits(uint32_t currval, const char *str);
DLLEXPORT BOOL str_has_ctrl(const char*);
......
......@@ -871,6 +871,8 @@ enum {
,FidoNetMailReceived
,WithAttachment
,FidoEchoMailReceived
,HashingFile
,HashedFile
,TOTAL_TEXT
};
......
......@@ -1411,4 +1411,7 @@ const char * const text_defaults[TOTAL_TEXT]={
,"\x20\x77\x69\x74\x68\x20\x61\x74\x74\x61\x63\x68\x6d\x65\x6e\x74" // 859 WithAttachment
,"\x25\x2e\x30\x73\x01\x6e\x01\x68\x01\x6d\x25\x73\x20\x01\x6e\x01\x6d\x73\x65\x6e\x74\x20\x79\x6f\x75\x20\x45\x63\x68\x6f\x4d\x61"
"\x69\x6c\x20\x6f\x6e\x20\x01\x68\x25\x73\x20\x01\x6e\x01\x6d\x25\x73\x01\x6e\x0d\x0a" // 860 FidoEchoMailReceived
,"\x01\x5f\x01\x77\x01\x68\x43\x61\x6c\x63\x75\x6c\x61\x74\x69\x6e\x67\x20\x66\x69\x6c\x65\x27\x73\x20\x68\x61\x73\x68\x20\x76\x61"
"\x6c\x75\x65\x73\x20\x40\x45\x4c\x4c\x49\x50\x53\x49\x53\x40\x01\x6e" // 861 HashingFile
,"\x01\x5b\x01\x3e" // 862 HashedFile
};
......@@ -32,7 +32,7 @@ bool sbbs_t::uploadfile(file_t* f)
char ext[LEN_EXTDESC + 1] = "";
char tmp[MAX_PATH+1];
uint i;
long length;
off_t length;
FILE* stream;
curdirnum=f->dir;
......@@ -106,7 +106,7 @@ bool sbbs_t::uploadfile(file_t* f)
}
}
if((length=(long)flength(path))==0L) {
if((length = flength(path))==0L) {
bprintf(text[FileZeroLength],f->name);
remove(path);
safe_snprintf(str,sizeof(str),"attempted to upload %s to %s %s (Zero length)"
......@@ -116,10 +116,11 @@ bool sbbs_t::uploadfile(file_t* f)
return false;
}
bputs(text[SearchingForDupes]);
bputs(text[HashingFile]);
/* Note: Hashes file *after* running upload-testers (which could modify file) */
if(hashfile(&cfg, f)) {
bputs(text[SearchedForDupes]);
bool hashed = hashfile(&cfg, f);
bputs(text[HashedFile]);
if(hashed) {
for(uint i=0, k=0; i < usrlibs; i++) {
progress(text[Scanning], i, usrlibs);
for(uint j=0; j < usrdirs[i]; j++,k++) {
......@@ -138,8 +139,7 @@ bool sbbs_t::uploadfile(file_t* f)
}
}
progress(text[Done], usrlibs, usrlibs);
} else
bputs(text[SearchedForDupes]);
}
if(cfg.dir[f->dir]->misc&DIR_DIZ) {
lprintf(LOG_DEBUG, "Extracting DIZ from: %s", path);
......@@ -170,10 +170,10 @@ bool sbbs_t::uploadfile(file_t* f)
}
if(cfg.dir[f->dir]->misc&DIR_AONLY) /* Forced anonymous */
f->hdr.attr |= MSG_ANONYMOUS;
uint32_t cdt = (uint32_t)length;
uint32_t cdt = (uint32_t)min(length, UINT32_MAX);
smb_hfield_bin(f, SMB_COST, cdt);
smb_hfield_str(f, SENDER, useron.alias);
bprintf(text[FileNBytesReceived],f->name,ultoac(length,tmp));
bprintf(text[FileNBytesReceived],f->name, i64toac(length,tmp));
if(!addfile(&cfg, f->dir, f, ext, /* metadata: */NULL, &client))
return false;
......@@ -527,8 +527,8 @@ bool sbbs_t::bulkupload(uint dirnum)
if(strListFind(list, fname, /* case-sensitive: */FALSE) < 0) {
smb_freemsgmem(&f);
smb_hfield_str(&f, SMB_FILENAME, dirent->d_name);
uint32_t cdt = (uint32_t)flength(str);
bprintf(text[BulkUploadDescPrompt], format_filename(f.name, fname, 12, /* pad: */FALSE), cdt/1024);
off_t flen = flength(str);
bprintf(text[BulkUploadDescPrompt], format_filename(f.name, fname, 12, /* pad: */FALSE), flen/1024);
if(strcmp(f.name, fname) != 0)
SAFECOPY(desc, f.name);
else
......
......@@ -601,6 +601,25 @@ char* ultoa(ulong val, char* str, int radix)
}
return(str);
}
char* _i64toa(int64_t val, char* str, int radix)
{
switch(radix) {
case 8:
sprintf(str,"%"PRIo64,val);
break;
case 10:
sprintf(str,"%"PRId64,val);
break;
case 16:
sprintf(str,"%"PRIx64,val);
break;
default:
sprintf(str,"bad radix: %d",radix);
break;
}
return str;
}
#endif
/****************************************************************************/
......
......@@ -228,6 +228,7 @@ extern "C" {
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
DLLEXPORT char* ultoa(ulong, char*, int radix);
DLLEXPORT char* _i64toa(int64_t, char*, int radix);
#endif
#if defined(__unix__)
......