Hi, In message <_A3475@delegate-en.ML_> on 08/31/06(00:37:08) I wrote: | |Delegate strips away all the spaces and sends then only 0E0D0A. | |The client wait for 0D0A0E0D0A as EOF-mark, | |so after 60 sec he has a timeout and disconnects the session. | |The problem is caused because DeleGate uses fgets() and fputs() to |get and put the message on POP. |A simple workaround to escape the problem is encoding '\0' into |0xC0 0x80 (or \300\200, UTF-8 string which represents zero) at |the input, and decoding it at the output. It can be done like the |enclosed patch (a patch to be applied to DeleGate/9.2.4-pre19). Sorry, I found that the patch is not enough for POP, and encoding a character into multi-bytes might cause another problem on the buffer boundary. So just ignoring '\0' might be the practical workaround as the enclosed patch. Cheers, Yutaka -- 9 9 Yutaka Sato <pfqcabdyi-mxhgu4y5ah3w.ml@delegate.org> http://delegate.org/y.sato/ ( ~ ) National Institute of Advanced Industrial Science and Technology _< >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan Do the more with the less -- B. Fuller diff -cr ../arc/delegate9.2.4-pre19/include/ystring.h ./include/ystring.h *** ../arc/delegate9.2.4-pre19/include/ystring.h Wed Aug 9 10:23:12 2006 --- ./include/ystring.h Thu Aug 31 00:43:24 2006 *************** *** 228,233 **** --- 228,242 ---- int Xfprintf(FILE *fp,PCStr(fmt),...); #define fprintf Xfprintf + #ifdef FGETPUTSZ + #undef fgets + #undef fputs + const char *fgetsZ(PVStr(str),int siz,FILE *fp); + int fputsZ(PCStr(str),FILE *fp); + #define fgets(s,z,f) fgetsZ(AVStr(s),z,f) + #define fputs(s,f) fputsZ(s,f) + #endif + /* #ifdef __cplusplus class CString { diff -cr ../arc/delegate9.2.4-pre19/mimekit/mime.c ./mimekit/mime.c *** ../arc/delegate9.2.4-pre19/mimekit/mime.c Wed Aug 23 17:46:50 2006 --- ./mimekit/mime.c Thu Aug 31 00:47:28 2006 *************** *** 19,24 **** --- 19,25 ---- 950312 encode/decode parts in a multipart message //////////////////////////////////////////////////////////////////////#*/ + #define FGETPUTSZ #include "mime.h" #ifdef MIMEKIT #define strid_alloc(s) stralloc(s) diff -cr ../arc/delegate9.2.4-pre19/mimekit/rfc822.c ./mimekit/rfc822.c *** ../arc/delegate9.2.4-pre19/mimekit/rfc822.c Thu May 4 03:11:12 2006 --- ./mimekit/rfc822.c Thu Aug 31 00:45:09 2006 *************** *** 19,24 **** --- 19,25 ---- 950312 encode/decode parts in a multipart message 951029 extracted from mime.c of DeleGate //////////////////////////////////////////////////////////////////////#*/ + #define FGETPUTSZ #include "mime.h" char *nextField(PCStr(field),int ignEOH); void RFC822_strip_lwsp(PCStr(src),PVStr(dst),int size); diff -cr ../arc/delegate9.2.4-pre19/rary/String.c ./rary/String.c *** ../arc/delegate9.2.4-pre19/rary/String.c Wed Aug 9 22:52:47 2006 --- ./rary/String.c Thu Aug 31 01:18:02 2006 *************** *** 2280,2282 **** --- 2280,2326 ---- ((char*)str)[len0-i] = ch; /**/ } } + + /* represent zero in UTF-8 {0xC0 0x80} without string terminator '\0' */ + int FGETSZ_IGN = 1; + const char *fgetsZ(PVStr(str),int siz,FILE *fp){ + int ch; + refQStr(sp,str); + const char *sx; + + sx = &str[siz-1]; + for( sp = str; sp < sx; ){ + ch = getc(fp); + if( ch == EOF ) + break; + if( ch == 0 ){ + if( FGETSZ_IGN ){ + }else{ + setVStrPtrInc(sp,0xC0); + setVStrPtrInc(sp,0x80); + } + }else{ + setVStrPtrInc(sp,ch); + if( ch == '\n' ) + break; + } + } + setVStrEnd(sp,0); + if( sp == str && feof(fp) ) + return NULL; + return str; + } + int fputsZ(PCStr(str),FILE *fp){ + const unsigned char *sp; + unsigned char ch; + + for( sp = (const unsigned char*)str; ch = *sp; sp++ ){ + if( ch == 0xC0 && sp[1] == 0x80 ){ + putc(0,fp); + sp++; + }else{ + putc(ch,fp); + } + } + return 0; + }