Commit 5324f9be authored by rswindell's avatar rswindell
Browse files

Well that sucks. __FUNCTION__ can't be used as a macro string constant in

GCC (worked fine in MSVC) :-(
parent 6d491e54
......@@ -60,12 +60,12 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
smbmsg_t remsg;
if(msg->subj == NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" subject field missing");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s subject field missing", __FUNCTION__);
return SMB_ERR_HDR_FIELD;
}
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__);
return SMB_ERR_NOT_OPEN;
}
......@@ -93,7 +93,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(smb_findhash(smb, hashes, &found, dupechk_hashes, /* mark? */FALSE)==SMB_SUCCESS) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" duplicate %s: %s found in message #%lu"
,"%s duplicate %s: %s found in message #%lu"
,__FUNCTION__
,smb_hashsourcetype(found.source)
,smb_hashsource(msg,found.source)
,found.number);
......@@ -145,7 +146,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(length) {
if(length >= 0x80000000 || length < 0) {
sprintf(smb->last_error,__FUNCTION__" message length: 0x%"PRIXMAX,(intmax_t)length);
sprintf(smb->last_error,"%s message length: 0x%"PRIXMAX, __FUNCTION__, (intmax_t)length);
retval=SMB_ERR_DAT_LEN;
break;
}
......@@ -181,7 +182,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(xlat!=XLAT_NONE) { /* e.g. XLAT_LZH */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing body xlat string"
,"%s %d '%s' writing body xlat string"
,__FUNCTION__
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -191,7 +193,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
xlat=XLAT_NONE; /* xlat string terminator */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing body xlat terminator"
,"%s %d '%s' writing body xlat terminator"
,__FUNCTION__
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -200,7 +203,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(smb_fwrite(smb,body,bodylen,smb->sdt_fp)!=bodylen) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing body (%ld bytes)"
,"%s %d '%s' writing body (%ld bytes)"
,__FUNCTION__
,get_errno(),STRERROR(get_errno())
,bodylen);
retval=SMB_ERR_WRITE;
......@@ -215,7 +219,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
xlat=XLAT_NONE; /* xlat string terminator */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing tail xlat terminator"
,"%s %d '%s' writing tail xlat terminator"
,__FUNCTION__
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -223,7 +228,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(smb_fwrite(smb,tail,taillen-sizeof(xlat),smb->sdt_fp)!=taillen-sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing tail (%ld bytes)"
,"%s %d '%s' writing tail (%ld bytes)"
,__FUNCTION__
,get_errno(),STRERROR(get_errno())
,taillen-sizeof(xlat));
retval=SMB_ERR_WRITE;
......@@ -237,7 +243,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
}
if(l%SDT_BLOCK_LEN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing data padding"
,"%s %d '%s' writing data padding"
,__FUNCTION__
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -328,22 +335,22 @@ int SMBCALL smb_addvote(smb_t* smb, smbmsg_t* msg, int storage)
int retval;
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return SMB_ERR_NOT_OPEN;
}
if(filelength(fileno(smb->shd_fp)) < 1) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" header file empty");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s header file empty", __FUNCTION__);
return SMB_ERR_NOT_FOUND;
}
if(!(msg->hdr.attr&MSG_VOTE) || msg->hdr.attr&MSG_POLL) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" incorrect attr: %04hX", msg->hdr.attr);
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s incorrect attr: %04hX", __FUNCTION__, msg->hdr.attr);
return SMB_ERR_HDR_ATTR;
}
if(msg->hdr.thread_back == 0) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" thread_back field missing");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s thread_back field missing", __FUNCTION__);
return SMB_ERR_HDR_FIELD;
}
......@@ -366,17 +373,17 @@ int SMBCALL smb_addpoll(smb_t* smb, smbmsg_t* msg, int storage)
int retval;
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return SMB_ERR_NOT_OPEN;
}
if(msg->subj == NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error), __FUNCTION__" subject field missing");
safe_snprintf(smb->last_error,sizeof(smb->last_error), "%s subject field missing", __FUNCTION__);
return SMB_ERR_HDR_FIELD;
}
if(smb_get_hfield(msg, SMB_POLL_ANSWER, NULL) == NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error), __FUNCTION__" poll answers missing");
safe_snprintf(smb->last_error,sizeof(smb->last_error), "%s poll answers missing", __FUNCTION__);
return SMB_ERR_HDR_FIELD;
}
......@@ -407,17 +414,17 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage)
int retval;
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return SMB_ERR_NOT_OPEN;
}
if(filelength(fileno(smb->shd_fp)) < 1) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" header file empty");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s header file empty", __FUNCTION__);
return SMB_ERR_NOT_FOUND;
}
if(msg->hdr.thread_back == 0) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" thread_back field missing");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s thread_back field missing", __FUNCTION__);
return SMB_ERR_HDR_FIELD;
}
......@@ -433,14 +440,14 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage)
}
if(remsg.hdr.auxattr&POLL_CLOSED) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" closed poll");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s closed poll", __FUNCTION__);
smb_freemsgmem(&remsg);
smb_unlockmsghdr(smb, &remsg);
return SMB_CLOSED;
}
if(!smb_msg_is_from(&remsg, msg->from, msg->from_net.type, msg->from_net.addr)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" wrong pollster");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s wrong pollster", __FUNCTION__);
smb_freemsgmem(&remsg);
smb_unlockmsghdr(smb, &remsg);
return SMB_UNAUTHORIZED;
......
......@@ -51,7 +51,7 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
ulong j,l,blocks,offset=0L;
if(smb->sda_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
blocks=smb_datblocks(length);
......@@ -70,19 +70,19 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
}
}
if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" invalid data offset: %lu",offset);
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s invalid data offset: %lu", __FUNCTION__, offset);
return(SMB_ERR_DAT_OFFSET);
}
clearerr(smb->sda_fp);
if(fseek(smb->sda_fp,(offset/SDT_BLOCK_LEN)*sizeof(refs),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to: %ld"
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to: %ld", __FUNCTION__
,(offset/SDT_BLOCK_LEN)*sizeof(refs));
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(!fwrite(&refs,sizeof(refs),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation bytes at offset %ld"
,"%s %d '%s' writing allocation bytes at offset %ld", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(refs));
return(SMB_ERR_WRITE);
......@@ -100,20 +100,20 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
ulong l,blocks,offset;
if(smb->sda_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->sda_fp);
clearerr(smb->sda_fp);
blocks=smb_datblocks(length);
if(fseek(smb->sda_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding", __FUNCTION__);
return(SMB_ERR_SEEK);
}
offset=(ftell(smb->sda_fp)/sizeof(refs))*SDT_BLOCK_LEN;
if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" invalid data offset: %lu",offset);
,"%s invalid data offset: %lu", __FUNCTION__, offset);
return(SMB_ERR_DAT_OFFSET);
}
for(l=0;l<blocks;l++)
......@@ -122,7 +122,7 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
fflush(smb->sda_fp);
if(l<blocks) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation bytes"
,"%s %d '%s' writing allocation bytes", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -157,7 +157,7 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
sda_offset=((offset/SDT_BLOCK_LEN)+l)*sizeof(i);
if(fseek(smb->sda_fp,sda_offset,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' seeking to %lu (0x%lX) of allocation file"
,"%s %d '%s' seeking to %lu (0x%lX) of allocation file", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,sda_offset,sda_offset);
retval=SMB_ERR_SEEK;
......@@ -165,7 +165,7 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
}
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' reading allocation bytes at offset %ld"
,"%s %d '%s' reading allocation bytes at offset %ld", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,sda_offset);
retval=SMB_ERR_READ;
......@@ -177,14 +177,14 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
i-=refs;
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' seeking backwards 2 bytes in allocation file"
,"%s %d '%s' seeking backwards 2 bytes in allocation file", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_SEEK;
break;
}
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation bytes at offset %ld"
,"%s %d '%s' writing allocation bytes at offset %ld", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,sda_offset);
retval=SMB_ERR_WRITE;
......@@ -207,32 +207,32 @@ int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, uint16_t refs)
ulong l,blocks;
if(smb->sda_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
clearerr(smb->sda_fp);
blocks=smb_datblocks(length);
for(l=0;l<blocks;l++) {
if(fseek(smb->sda_fp,((offset/SDT_BLOCK_LEN)+l)*sizeof(i),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to %ld"
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %ld", __FUNCTION__
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_SEEK);
}
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' reading allocation record at offset %ld"
,"%s %d '%s' reading allocation record at offset %ld", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_READ);
}
i+=refs;
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding %ld", -(int)sizeof(i));
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding %ld", __FUNCTION__, -(int)sizeof(i));
return(SMB_ERR_SEEK);
}
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation record at offset %ld"
,"%s %d '%s' writing allocation record at offset %ld", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_WRITE);
......@@ -282,19 +282,19 @@ int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length)
ulong l,blocks;
if(smb->sha_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
clearerr(smb->sha_fp);
blocks=smb_hdrblocks(length);
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to %ld", offset/SHD_BLOCK_LEN);
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %ld", __FUNCTION__, offset/SHD_BLOCK_LEN);
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(!fwrite(&c,1,1,smb->sha_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation record"
,"%s %d '%s' writing allocation record", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -351,7 +351,7 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length)
ulong i,l,blocks,offset=0;
if(smb->sha_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
blocks=smb_hdrblocks(length);
......@@ -371,13 +371,13 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length)
}
clearerr(smb->sha_fp);
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to %ld", offset/SHD_BLOCK_LEN);
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %ld", __FUNCTION__, offset/SHD_BLOCK_LEN);
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(fputc(1,smb->sha_fp)!=1) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation record"
,"%s %d '%s' writing allocation record", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -395,21 +395,21 @@ long SMBCALL smb_fallochdr(smb_t* smb, ulong length)
ulong l,blocks,offset;
if(smb->sha_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
blocks=smb_hdrblocks(length);
fflush(smb->sha_fp);
clearerr(smb->sha_fp);
if(fseek(smb->sha_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding", __FUNCTION__);
return(SMB_ERR_SEEK);
}
offset=ftell(smb->sha_fp)*SHD_BLOCK_LEN;
for(l=0;l<blocks;l++)
if(!fwrite(&c,1,1,smb->sha_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' writing allocation record"
,"%s %d '%s' writing allocation record", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -427,12 +427,12 @@ long SMBCALL smb_hallochdr(smb_t* smb)
ulong offset;
if(smb->shd_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), "%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->shd_fp);
if(fseek(smb->shd_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding", __FUNCTION__);
return(SMB_ERR_SEEK);
}
offset=ftell(smb->shd_fp);
......@@ -459,24 +459,24 @@ long SMBCALL smb_hallocdat(smb_t* smb)
if(smb->sdt_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" msgbase not open");
,"%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->sdt_fp);
offset=filelength(fileno(smb->sdt_fp));
if(offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" invalid file length: %lu",(ulong)offset);
,"%s invalid file length: %lu", __FUNCTION__,(ulong)offset);
return(SMB_ERR_FILE_LEN);
}
if(fseek(smb->sdt_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s rewinding", __FUNCTION__);
return(SMB_ERR_SEEK);
}
offset=ftell(smb->sdt_fp);
if(offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" invalid file offset: %ld",offset);
,"%s invalid file offset: %ld", __FUNCTION__,offset);
return(SMB_ERR_DAT_OFFSET);
}
......
......@@ -145,7 +145,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
ext="hash";
else {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" opening %s: Illegal FILE* pointer argument: %p"
,"%s opening %s: Illegal FILE* pointer argument: %p", __FUNCTION__
,smb->file, fp);
return(SMB_ERR_OPEN);
}
......@@ -160,7 +160,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
break;
if(get_errno()!=EACCES && get_errno()!=EAGAIN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' opening %s"
,"%s %d '%s' opening %s", __FUNCTION__
,get_errno(),STRERROR(get_errno()),path);
return(SMB_ERR_OPEN);
}
......@@ -169,7 +169,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
else
if(time(NULL)-start>=(time_t)smb->retry_time) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" timeout opening %s (retry_time=%ld)"
,"%s timeout opening %s (retry_time=%ld)", __FUNCTION__
,path,smb->retry_time);
return(SMB_ERR_TIMEOUT);
}
......@@ -177,7 +177,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
}
if((*fp=fdopen(file,"r+b"))==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' fdopening %s (%d)"
,"%s %d '%s' fdopening %s (%d)", __FUNCTION__
,get_errno(),STRERROR(get_errno()),path,file);
close(file);
return(SMB_ERR_OPEN);
......
......@@ -312,7 +312,7 @@ int SMBCALL smb_hashmsg(smb_t* smb, smbmsg_t* msg, const uchar* text, BOOL updat
if(smb_findhash(smb, hashes, &found, SMB_HASH_SOURCE_DUPE, update)==SMB_SUCCESS && !update) {
retval=SMB_DUPE_MSG;
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" duplicate %s: %s found in message #%lu"
,"%s duplicate %s: %s found in message #%lu", __FUNCTION__
,smb_hashsourcetype(found.source)
,smb_hashsource(msg,found.source)
,found.number);
......
......@@ -111,28 +111,28 @@ int SMBCALL smb_open(smb_t* smb)
memset(&hdr,0,sizeof(smbhdr_t));
if(smb_fread(smb,&hdr,sizeof(smbhdr_t),smb->shd_fp)!=sizeof(smbhdr_t)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' reading header"
,"%s %d '%s' reading header", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
smb_close(smb);
return(SMB_ERR_READ);
}
if(memcmp(hdr.id,SMB_HEADER_ID,LEN_HEADER_ID)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" corrupt SMB header ID: %.*s"
,"%s corrupt SMB header ID: %.*s", __FUNCTION__
,LEN_HEADER_ID,hdr.id);
smb_close(smb);
return(SMB_ERR_HDR_ID);
}
if(hdr.version<0x110) { /* Compatibility check */
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" insufficient header version: %X"
,"%s insufficient header version: %X", __FUNCTION__
,hdr.version);
smb_close(smb);
return(SMB_ERR_HDR_VER);
}
if(smb_fread(smb,&(smb->status),sizeof(smbstatus_t),smb->shd_fp)!=sizeof(smbstatus_t)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' reading status"
,"%s %d '%s' reading status", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
smb_close(smb);
return(SMB_ERR_READ);
......@@ -198,7 +198,7 @@ int SMBCALL smb_lock(smb_t* smb)
else
if(time(NULL)-start>=(time_t)smb->retry_time) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' creating %s"
,"%s %d '%s' creating %s", __FUNCTION__
,get_errno(),STRERROR(get_errno()),path);
return(SMB_ERR_LOCK);
}
......@@ -215,7 +215,7 @@ int SMBCALL smb_unlock(smb_t* smb)
smb_lockfname(smb,path,sizeof(path)-1);
if(remove(path)!=0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' removing %s"
,"%s %d '%s' removing %s", __FUNCTION__
,get_errno(),STRERROR(get_errno()),path);
return(SMB_ERR_DELETE);
}
......@@ -228,7 +228,7 @@ BOOL SMBCALL smb_islocked(smb_t* smb)
if(access(smb_lockfname(smb,path,sizeof(path)-1),0)!=0)
return(FALSE);
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" %s exists",path);
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s %s exists", __FUNCTION__,path);
return(TRUE);
}
......@@ -256,7 +256,7 @@ int SMBCALL smb_stack(smb_t* smb, int op)
if(op==SMB_STACK_PUSH) {
if(stack_idx>=SMB_STACK_LEN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" SMB stack overflow");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s SMB stack overflow", __FUNCTION__);
return(SMB_FAILURE);
}
if(smb->shd_fp==NULL || smb->sdt_fp==NULL || smb->sid_fp==NULL)
......@@ -293,7 +293,7 @@ int SMBCALL smb_trunchdr(smb_t* smb)
time_t start=0;
if(smb->shd_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
rewind(smb->shd_fp);
......@@ -302,7 +302,7 @@ int SMBCALL smb_trunchdr(smb_t* smb)
break;
if(get_errno()!=EACCES && get_errno()!=EAGAIN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' changing header file size"
,"%s %d '%s' changing header file size", __FUNCTION__
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -311,7 +311,7 @@ int SMBCALL smb_trunchdr(smb_t* smb)
else
if(time(NULL)-start>=(time_t)smb->retry_time) { /* Time-out */
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" timeout changing header file size (retry_time=%ld)"
,"%s timeout changing header file size (retry_time=%ld)", __FUNCTION__
,smb->retry_time);
return(SMB_ERR_TIMEOUT);
}
......@@ -332,7 +332,7 @@ int SMBCALL smb_locksmbhdr(smb_t* smb)
time_t start=0;
if(smb->shd_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
while(1) {
......@@ -352,7 +352,7 @@ int SMBCALL smb_locksmbhdr(smb_t* smb)
SLEEP(smb->retry_delay);
}
}
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" timeout locking message base");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s timeout locking message base", __FUNCTION__);
return(SMB_ERR_TIMEOUT);
}
......@@ -364,14 +364,14 @@ int SMBCALL smb_getstatus(smb_t* smb)
int i;
if(smb->shd_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__);
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->shd_fp);
clearerr(smb->shd_fp);
if(fseek(smb->shd_fp,sizeof(smbhdr_t),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,__FUNCTION__" %d '%s' seeking to %u in header file"
,"%s %d '%s' seeking to %u in header file", __FUNCTION__
,get_errno(),STRERROR(get_errno()),sizeof(smbhdr_t));
return(SMB_ERR_SEEK);
}
......@@ -379,7 +379,7 @@ int SMBCALL smb_getstatus(smb_t* smb)
if(i==sizeof(smbstatus_t))
return(SMB_SUCCESS);
safe_snprintf(smb->last_error,sizeof(smb->last_error)