faxmail/MsgFmt.c++
/*
 * Decode a string that is RFC2047-encoded
 */
Decode a string that is RFC2047-encoded
Decode a string that is RFC2047 - encoded
void
MsgFmt::decodeRFC2047(fxStr& s)
{
    fxStackBuffer buf;
    u_int bm = s.find(0, "=?");			
    if (bm < s.length()) {
	u_int mm = s.find(bm+2, "?Q?");		
	if (mm == s.length()) s.find(bm, "?q?");
	if (mm < s.length()) {
	    u_int em = s.find(mm+3, "?=");	
	    if (em < s.length()) {
		s.remove(em, 2);
		s.remove(bm, mm-bm+3);
		u_int i = 0;
		while (i < s.length()) {
		    if (s[i] == '_') s[i] = ' ';
		    i++;
		}
		copyQP(buf, s, s.length());
		buf.put('\0');
		s = buf;
	    }
	} else {
	    s.find(bm, "?B?");			
	    if (mm == s.length()) s.find(bm, "?b?");
	    if (mm < s.length()) {
		u_int em = s.find(mm+3, "?=");	
		if (em < s.length()) {
		    s.remove(em, 2);
		    s.remove(bm, mm-bm+3);
		    b64State state;
		    state.c1 = -1;
		    state.c2 = -1;
		    state.c3 = -1;
		    state.c4 = -1;
		    copyBase64(buf, s, s.length(), state);
		    buf.put('\0');
		    s = buf;
		}
	    }
	}
    }
}
void MsgFmt :: decodeRFC2047 ( fxStr & s ) { fxStackBuffer buf ; u_int bm = s . find ( 0 , " " ) ; if ( bm < s . length ( ) ) { u_int mm = s . find ( bm + 2 , " " ) ; if ( mm == s . length ( ) ) s . find ( bm , " " ) ; if ( mm < s . length ( ) ) { u_int em = s . find ( mm + 3 , " " ) ; if ( em < s . length ( ) ) { s . remove ( em , 2 ) ; s . remove ( bm , mm - bm + 3 ) ; u_int i = 0 ; while ( i < s . length ( ) ) { if ( s [ i ] == ' ' ) s [ i ] = ' ' ; i ++ ; } copyQP ( buf , s , s . length ( ) ) ; buf . put ( ' \0 ' ) ; s = buf ; } } else { s . find ( bm , " " ) ; if ( mm == s . length ( ) ) s . find ( bm , " " ) ; if ( mm < s . length ( ) ) { u_int em = s . find ( mm + 3 , " " ) ; if ( em < s . length ( ) ) { s . remove ( em , 2 ) ; s . remove ( bm , mm - bm + 3 ) ; b64State state ; state . c1 = -1 ; state . c2 = -1 ; state . c3 = -1 ; state . c4 = -1 ; copyBase64 ( buf , s , s . length ( ) , state ) ; buf . put ( ' \0 ' ) ; s = buf ; } } } } }
Decode a string that is RFC2047-encoded
Decode a string that is RFC2047 - encoded
// beginning marker // quoted printable // end marker // base64 // end marker