FreeBSD/usr.sbin/ctm/ctm_rmail/ctm_rmail.c
/*
 * Decode a line of ASCII into binary.  Returns the number of bytes in
 * the output buffer, or < 0 on indigestable input.  Error output is
 * the negative of the index of the inedible character.
 */
Decode a line of ASCII into binary.  Returns the number of bytes in
the output buffer, or < 0 on indigestable input.  Error output is
the negative of the index of the inedible character.
Decode a line of ASCII into binary . Returns the number of bytes in the output buffer or < 0 on indigestable input . Error output is the negative of the index of the inedible character .
int
decode_line(char *line, char *out_buf)
    {
    unsigned char *ip = (unsigned char *)line;
    unsigned char *op = (unsigned char *)out_buf;
    unsigned long bits;
    unsigned x;
    for (;;)
	{
	if (*ip >= 0x80 || (x = from_b64[*ip]) >= 0x40)
	    break;
	bits = x << 18;
	ip++;
	if (*ip < 0x80 && (x = from_b64[*ip]) < 0x40)
	    {
	    bits |= x << 12;
	    *op++ = bits >> 16;
	    ip++;
	    if (*ip < 0x80 && (x = from_b64[*ip]) < 0x40)
		{
		bits |= x << 6;
		*op++ = bits >> 8;
		ip++;
		if (*ip < 0x80 && (x = from_b64[*ip]) < 0x40)
		    {
		    bits |= x;
		    *op++ = bits;
		    ip++;
		    }
		}
	    }
	}
    if (*ip == '\0' || *ip == '\n')
	return op - (unsigned char *)out_buf;
    else
	return -(ip - (unsigned char *)line);
    }
int decode_line ( char * line , char * out_buf ) { unsigned char * ip = ( unsigned char * ) line ; unsigned char * op = ( unsigned char * ) out_buf ; unsigned long bits ; unsigned x ; for ( ; ; ) { if ( * ip >= 0x80 || ( x = from_b64 [ * ip ] ) >= 0x40 ) break ; bits = x << 18 ; ip ++ ; if ( * ip < 0x80 && ( x = from_b64 [ * ip ] ) < 0x40 ) { bits |= x << 12 ; * op ++ = bits >> 16 ; ip ++ ; if ( * ip < 0x80 && ( x = from_b64 [ * ip ] ) < 0x40 ) { bits |= x << 6 ; * op ++ = bits >> 8 ; ip ++ ; if ( * ip < 0x80 && ( x = from_b64 [ * ip ] ) < 0x40 ) { bits |= x ; * op ++ = bits ; ip ++ ; } } } } if ( * ip == ' \0 ' || * ip == ' \n ' ) return op - ( unsigned char * ) out_buf ; else return - ( ip - ( unsigned char * ) line ) ; }
Decode a line of ASCII into binary.
Decode a line of ASCII into binary .