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 ...@@ -60,12 +60,12 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
smbmsg_t remsg; smbmsg_t remsg;
if(msg->subj == NULL) { 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; return SMB_ERR_HDR_FIELD;
} }
if(!SMB_IS_OPEN(smb)) { 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; return SMB_ERR_NOT_OPEN;
} }
...@@ -93,7 +93,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -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) { if(smb_findhash(smb, hashes, &found, dupechk_hashes, /* mark? */FALSE)==SMB_SUCCESS) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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_hashsourcetype(found.source)
,smb_hashsource(msg,found.source) ,smb_hashsource(msg,found.source)
,found.number); ,found.number);
...@@ -145,7 +146,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -145,7 +146,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(length) { if(length) {
if(length >= 0x80000000 || length < 0) { 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; retval=SMB_ERR_DAT_LEN;
break; break;
} }
...@@ -181,7 +182,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -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(xlat!=XLAT_NONE) { /* e.g. XLAT_LZH */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) { if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
break; break;
...@@ -191,7 +193,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -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 */ xlat=XLAT_NONE; /* xlat string terminator */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) { if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
break; break;
...@@ -200,7 +203,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -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) { if(smb_fwrite(smb,body,bodylen,smb->sdt_fp)!=bodylen) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,bodylen); ,bodylen);
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
...@@ -215,7 +219,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -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 */ xlat=XLAT_NONE; /* xlat string terminator */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) { if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
break; break;
...@@ -223,7 +228,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -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)) { if(smb_fwrite(smb,tail,taillen-sizeof(xlat),smb->sdt_fp)!=taillen-sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,taillen-sizeof(xlat)); ,taillen-sizeof(xlat));
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
...@@ -237,7 +243,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash ...@@ -237,7 +243,8 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
} }
if(l%SDT_BLOCK_LEN) { if(l%SDT_BLOCK_LEN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
break; break;
...@@ -328,22 +335,22 @@ int SMBCALL smb_addvote(smb_t* smb, smbmsg_t* msg, int storage) ...@@ -328,22 +335,22 @@ int SMBCALL smb_addvote(smb_t* smb, smbmsg_t* msg, int storage)
int retval; int retval;
if(!SMB_IS_OPEN(smb)) { 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; return SMB_ERR_NOT_OPEN;
} }
if(filelength(fileno(smb->shd_fp)) < 1) { 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; return SMB_ERR_NOT_FOUND;
} }
if(!(msg->hdr.attr&MSG_VOTE) || msg->hdr.attr&MSG_POLL) { 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; return SMB_ERR_HDR_ATTR;
} }
if(msg->hdr.thread_back == 0) { 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; return SMB_ERR_HDR_FIELD;
} }
...@@ -366,17 +373,17 @@ int SMBCALL smb_addpoll(smb_t* smb, smbmsg_t* msg, int storage) ...@@ -366,17 +373,17 @@ int SMBCALL smb_addpoll(smb_t* smb, smbmsg_t* msg, int storage)
int retval; int retval;
if(!SMB_IS_OPEN(smb)) { 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; return SMB_ERR_NOT_OPEN;
} }
if(msg->subj == NULL) { 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; return SMB_ERR_HDR_FIELD;
} }
if(smb_get_hfield(msg, SMB_POLL_ANSWER, NULL) == NULL) { 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; return SMB_ERR_HDR_FIELD;
} }
...@@ -407,17 +414,17 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage) ...@@ -407,17 +414,17 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage)
int retval; int retval;
if(!SMB_IS_OPEN(smb)) { 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; return SMB_ERR_NOT_OPEN;
} }
if(filelength(fileno(smb->shd_fp)) < 1) { 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; return SMB_ERR_NOT_FOUND;
} }
if(msg->hdr.thread_back == 0) { 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; return SMB_ERR_HDR_FIELD;
} }
...@@ -433,14 +440,14 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage) ...@@ -433,14 +440,14 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage)
} }
if(remsg.hdr.auxattr&POLL_CLOSED) { 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_freemsgmem(&remsg);
smb_unlockmsghdr(smb, &remsg); smb_unlockmsghdr(smb, &remsg);
return SMB_CLOSED; return SMB_CLOSED;
} }
if(!smb_msg_is_from(&remsg, msg->from, msg->from_net.type, msg->from_net.addr)) { 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_freemsgmem(&remsg);
smb_unlockmsghdr(smb, &remsg); smb_unlockmsghdr(smb, &remsg);
return SMB_UNAUTHORIZED; return SMB_UNAUTHORIZED;
......
...@@ -51,7 +51,7 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs) ...@@ -51,7 +51,7 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
ulong j,l,blocks,offset=0L; ulong j,l,blocks,offset=0L;
if(smb->sda_fp==NULL) { 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); return(SMB_ERR_NOT_OPEN);
} }
blocks=smb_datblocks(length); blocks=smb_datblocks(length);
...@@ -70,19 +70,19 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs) ...@@ -70,19 +70,19 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
} }
} }
if((long)offset<0) { 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); return(SMB_ERR_DAT_OFFSET);
} }
clearerr(smb->sda_fp); clearerr(smb->sda_fp);
if(fseek(smb->sda_fp,(offset/SDT_BLOCK_LEN)*sizeof(refs),SEEK_SET)) { 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)); ,(offset/SDT_BLOCK_LEN)*sizeof(refs));
return(SMB_ERR_SEEK); return(SMB_ERR_SEEK);
} }
for(l=0;l<blocks;l++) for(l=0;l<blocks;l++)
if(!fwrite(&refs,sizeof(refs),1,smb->sda_fp)) { if(!fwrite(&refs,sizeof(refs),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(refs)); ,((offset/SDT_BLOCK_LEN)+l)*sizeof(refs));
return(SMB_ERR_WRITE); return(SMB_ERR_WRITE);
...@@ -100,20 +100,20 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs) ...@@ -100,20 +100,20 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
ulong l,blocks,offset; ulong l,blocks,offset;
if(smb->sda_fp==NULL) { 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); return(SMB_ERR_NOT_OPEN);
} }
fflush(smb->sda_fp); fflush(smb->sda_fp);
clearerr(smb->sda_fp); clearerr(smb->sda_fp);
blocks=smb_datblocks(length); blocks=smb_datblocks(length);
if(fseek(smb->sda_fp,0L,SEEK_END)) { 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); return(SMB_ERR_SEEK);
} }
offset=(ftell(smb->sda_fp)/sizeof(refs))*SDT_BLOCK_LEN; offset=(ftell(smb->sda_fp)/sizeof(refs))*SDT_BLOCK_LEN;
if((long)offset<0) { if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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); return(SMB_ERR_DAT_OFFSET);
} }
for(l=0;l<blocks;l++) for(l=0;l<blocks;l++)
...@@ -122,7 +122,7 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs) ...@@ -122,7 +122,7 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
fflush(smb->sda_fp); fflush(smb->sda_fp);
if(l<blocks) { if(l<blocks) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE); return(SMB_ERR_WRITE);
} }
...@@ -157,7 +157,7 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs ...@@ -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); sda_offset=((offset/SDT_BLOCK_LEN)+l)*sizeof(i);
if(fseek(smb->sda_fp,sda_offset,SEEK_SET)) { if(fseek(smb->sda_fp,sda_offset,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,sda_offset,sda_offset); ,sda_offset,sda_offset);
retval=SMB_ERR_SEEK; retval=SMB_ERR_SEEK;
...@@ -165,7 +165,7 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs ...@@ -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)) { if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,sda_offset); ,sda_offset);
retval=SMB_ERR_READ; retval=SMB_ERR_READ;
...@@ -177,14 +177,14 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs ...@@ -177,14 +177,14 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
i-=refs; i-=refs;
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) { if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_SEEK; retval=SMB_ERR_SEEK;
break; break;
} }
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) { if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,sda_offset); ,sda_offset);
retval=SMB_ERR_WRITE; retval=SMB_ERR_WRITE;
...@@ -207,32 +207,32 @@ int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, uint16_t refs) ...@@ -207,32 +207,32 @@ int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, uint16_t refs)
ulong l,blocks; ulong l,blocks;
if(smb->sda_fp==NULL) { 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); return(SMB_ERR_NOT_OPEN);
} }
clearerr(smb->sda_fp); clearerr(smb->sda_fp);
blocks=smb_datblocks(length); blocks=smb_datblocks(length);
for(l=0;l<blocks;l++) { for(l=0;l<blocks;l++) {
if(fseek(smb->sda_fp,((offset/SDT_BLOCK_LEN)+l)*sizeof(i),SEEK_SET)) { 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)); ,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_SEEK); return(SMB_ERR_SEEK);
} }
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) { if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i)); ,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_READ); return(SMB_ERR_READ);
} }
i+=refs; i+=refs;
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) { 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); return(SMB_ERR_SEEK);
} }
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) { if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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()) ,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i)); ,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_WRITE); return(SMB_ERR_WRITE);
...@@ -282,19 +282,19 @@ int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length) ...@@ -282,19 +282,19 @@ int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length)
ulong l,blocks; ulong l,blocks;
if(smb->sha_fp==NULL) { 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); return(SMB_ERR_NOT_OPEN);
} }
clearerr(smb->sha_fp); clearerr(smb->sha_fp);
blocks=smb_hdrblocks(length); blocks=smb_hdrblocks(length);
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET)) { 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); return(SMB_ERR_SEEK);
} }
for(l=0;l<blocks;l++) for(l=0;l<blocks;l++)
if(!fwrite(&c,1,1,smb->sha_fp)) { if(!fwrite(&c,1,1,smb->sha_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE); return(SMB_ERR_WRITE);
} }
...@@ -351,7 +351,7 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length) ...@@ -351,7 +351,7 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length)
ulong i,l,blocks,offset=0; ulong i,l,blocks,offset=0;
if(smb->sha_fp==NULL) { 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); return(SMB_ERR_NOT_OPEN);
} }
blocks=smb_hdrblocks(length); blocks=smb_hdrblocks(length);
...@@ -371,13 +371,13 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length) ...@@ -371,13 +371,13 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length)
} }
clearerr(smb->sha_fp); clearerr(smb->sha_fp);
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET)) { 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); return(SMB_ERR_SEEK);
} }
for(l=0;l<blocks;l++) for(l=0;l<blocks;l++)
if(fputc(1,smb->sha_fp)!=1) { if(fputc(1,smb->sha_fp)!=1) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE); return(SMB_ERR_WRITE);
} }
...@@ -395,21 +395,21 @@ long SMBCALL smb_fallochdr(smb_t* smb, ulong length) ...@@ -395,21 +395,21 @@ long SMBCALL smb_fallochdr(smb_t* smb, ulong length)
ulong l,blocks,offset; ulong l,blocks,offset;
if(smb->sha_fp==NULL) { 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); return(SMB_ERR_NOT_OPEN);
} }
blocks=smb_hdrblocks(length); blocks=smb_hdrblocks(length);
fflush(smb->sha_fp); fflush(smb->sha_fp);
clearerr(smb->sha_fp); clearerr(smb->sha_fp);
if(fseek(smb->sha_fp,0L,SEEK_END)) { 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); return(SMB_ERR_SEEK);
} }
offset=ftell(smb->sha_fp)*SHD_BLOCK_LEN; offset=ftell(smb->sha_fp)*SHD_BLOCK_LEN;
for(l=0;l<blocks;l++) for(l=0;l<blocks;l++)
if(!fwrite(&c,1,1,smb->sha_fp)) { if(!fwrite(&c,1,1,smb->sha_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error) 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())); ,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE); return(SMB_ERR_WRITE);
} }
...@@ -427,12 +427,12 @@ long SMBCALL smb_hallochdr(smb_t* smb) ...@@ -427,12 +427,12 @@ long SMBCALL smb_hallochdr(smb_t* smb)
ulong offset; ulong offset;
if(smb->shd_fp==NULL) { if(smb->shd_fp==NULL) {