From 92368833faf51fd56e95a2d646eaae1d697f8e81 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 31 Mar 2001 19:06:45 +0000 Subject: configure configure.in include/config.h.in lib/replace.c: Added test and replacement for setlinebuf which apparantly doesn't exist on HPUX 11. include/byteorder.h: rpc_parse/parse_prs.c: Ding Dong the witch is dead ! :-). Ok, I'm happy 'cos I've finally deleted all the *HORRIBLE* DBG_RW_XXX and RW_XXX macros from include/byteorder.h. They were macros that included macros that had conditional macros included. No one understood them (they were the cause of most of the bigendian issue bugs). Finally, I went into parse_prs.c and inlined all of that stuff with regular function calls. They're understandable, they're easy to edit and they don't include macros ! JF - please look at the one comment I added (JF PLEASE CHECK). I have tested this partly with IRIX (a bigendian system) running with AS/U on a Solaris box in SGI's lab, and I've also confirmed these new changes work with W2K (vmware) but there may be the odd bug lurking. Herb, if you could re-checkout and test again with this code that would help. Extra. Fixed bug spotted by the sharp eyes of JF - big endian unicode packet would cause a early truncate of string parsing as we were checking for a char * 0, not a uint16 * 0. Jeremy. (This used to be commit 13765eca71e54aa5d048ce36cd8066b8406777c8) --- source3/include/byteorder.h | 92 --------------------------------------------- 1 file changed, 92 deletions(-) (limited to 'source3/include/byteorder.h') diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h index 5c66d684f6..e6cce73ceb 100644 --- a/source3/include/byteorder.h +++ b/source3/include/byteorder.h @@ -94,32 +94,6 @@ it also defines lots of intermediate macros, just ignore those :-) */ -/* some switch macros that do both store and read to and from SMB buffers */ - -#define RW_PCVAL(read,inbuf,outbuf,len) \ - { if (read) { PCVAL (inbuf,0,outbuf,len); } \ - else { PSCVAL(inbuf,0,outbuf,len); } } - -#define RW_PIVAL(read,big_endian,inbuf,outbuf,len) \ - { if (read) { if (big_endian) { RPIVAL(inbuf,0,outbuf,len); } else { PIVAL(inbuf,0,outbuf,len); } } \ - else { if (big_endian) { RPSIVAL(inbuf,0,outbuf,len); } else { PSIVAL(inbuf,0,outbuf,len); } } } - -#define RW_PSVAL(read,big_endian,inbuf,outbuf,len) \ - { if (read) { if (big_endian) { RPSVAL(inbuf,0,outbuf,len); } else { PSVAL(inbuf,0,outbuf,len); } } \ - else { if (big_endian) { RPSSVAL(inbuf,0,outbuf,len); } else { PSSVAL(inbuf,0,outbuf,len); } } } - -#define RW_CVAL(read, inbuf, outbuf, offset) \ - { if (read) { (outbuf) = CVAL (inbuf,offset); } \ - else { SCVAL(inbuf,offset,outbuf); } } - -#define RW_IVAL(read, big_endian, inbuf, outbuf, offset) \ - { if (read) { (outbuf) = ((big_endian) ? RIVAL(inbuf,offset) : IVAL (inbuf,offset)); } \ - else { if (big_endian) { RSIVAL(inbuf,offset,outbuf); } else { SIVAL(inbuf,offset,outbuf); } } } - -#define RW_SVAL(read, big_endian, inbuf, outbuf, offset) \ - { if (read) { (outbuf) = ((big_endian) ? RSVAL(inbuf,offset) : SVAL (inbuf,offset)); } \ - else { if (big_endian) { RSSVAL(inbuf,offset,outbuf); } else { SSVAL(inbuf,offset,outbuf); } } } - #undef CAREFUL_ALIGNMENT /* we know that the 386 can handle misalignment and has the "right" @@ -173,25 +147,6 @@ it also defines lots of intermediate macros, just ignore those :-) #endif /* CAREFUL_ALIGNMENT */ -/* macros for reading / writing arrays */ - -#define SMBMACRO(macro1,macro2,buf,pos,val,len,size) \ -{ int l; for (l = 0; l < (len); l++) macro1((val),(size)*l,macro2((buf), (pos) + (size)*l)); } - -#define SSMBMACRO(macro,buf,pos,val,len,size) \ -{ int l; for (l = 0; l < (len); l++) macro((buf), (pos) + (size)*l, (val)[l]); } - -/* reads multiple data from an SMB buffer */ -#define PCVAL(buf,pos,val,len) SMBMACRO(SCVAL,CVAL,buf,pos,val,len,1) -#define PSVAL(buf,pos,val,len) SMBMACRO(SSVAL,SVAL,buf,pos,val,len,2) -#define PIVAL(buf,pos,val,len) SMBMACRO(SIVAL,IVAL,buf,pos,val,len,4) - -/* stores multiple data in an SMB buffer */ -#define PSCVAL(buf,pos,val,len) SSMBMACRO(SCVAL,buf,pos,val,len,1) -#define PSSVAL(buf,pos,val,len) SSMBMACRO(SSVAL,buf,pos,val,len,2) -#define PSIVAL(buf,pos,val,len) SSMBMACRO(SIVAL,buf,pos,val,len,4) - - /* now the reverse routines - these are used in nmb packets (mostly) */ #define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16))) @@ -205,53 +160,6 @@ it also defines lots of intermediate macros, just ignore those :-) #define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val)) #define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val)) -/* reads multiple data from an SMB buffer (big-endian) */ -#define RPSVAL(buf,pos,val,len) SMBMACRO(SSVAL,RSVAL,buf,pos,val,len,2) -#define RPIVAL(buf,pos,val,len) SMBMACRO(SIVAL,RIVAL,buf,pos,val,len,4) - -/* stores multiple data in an SMB buffer (big-endian) */ -#define RPSSVAL(buf,pos,val,len) SSMBMACRO(RSSVAL,buf,pos,val,len,2) -#define RPSIVAL(buf,pos,val,len) SSMBMACRO(RSIVAL,buf,pos,val,len,4) - -#define DBG_RW_PCVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \ - { RW_PCVAL(read,inbuf,outbuf,len) \ - DEBUG(5,("%s%04x %s: ", \ - tab_depth(depth), base,string)); \ - if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \ - { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \ - DEBUG(5,("\n")); } - -#define DBG_RW_PSVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \ - { RW_PSVAL(read,big_endian,inbuf,outbuf,len) \ - DEBUG(5,("%s%04x %s: ", \ - tab_depth(depth), base,string)); \ - if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \ - { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \ - DEBUG(5,("\n")); } - -#define DBG_RW_PIVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \ - { RW_PIVAL(read,big_endian,inbuf,outbuf,len) \ - DEBUG(5,("%s%04x %s: ", \ - tab_depth(depth), base,string)); \ - if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \ - { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \ - DEBUG(5,("\n")); } - -#define DBG_RW_CVAL(string,depth,base,read,inbuf,outbuf) \ - { RW_CVAL(read,inbuf,outbuf,0) \ - DEBUG(5,("%s%04x %s: %02x\n", \ - tab_depth(depth), base, string, outbuf)); } - -#define DBG_RW_SVAL(string,depth,base,read,big_endian,inbuf,outbuf) \ - { RW_SVAL(read,big_endian,inbuf,outbuf,0) \ - DEBUG(5,("%s%04x %s: %04x\n", \ - tab_depth(depth), base, string, outbuf)); } - -#define DBG_RW_IVAL(string,depth,base,read,big_endian,inbuf,outbuf) \ - { RW_IVAL(read,big_endian,inbuf,outbuf,0) \ - DEBUG(5,("%s%04x %s: %08x\n", \ - tab_depth(depth), base, string, outbuf)); } - /* Alignment macros. */ #define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3)) #define ALIGN2(p,base) ((p) + ((2 - (PTR_DIFF((p), (base)) & 1)) & 1)) -- cgit