All pastes #26888 Raw Edit

Miscellany

public text v1 · immutable
#26888 ·published 2005-10-28 02:08 UTC
rendered paste body
	bits1 = 0;
	bits2 = 0;
	bits3 = 0;
	
	switch (encoded_len - i) {
		case 3:
			bits3 = getbits(base64_string[i+2]);
			decoded_string[pos+2] = ((bits3 << 6) & 0xc0);
		case 2:
			bits2 = getbits(base64_string[i+1]);
			decoded_string[pos+1] = ((bits2 << 4) & 0xf0) | ((bits3 >> 2) & 0x0f);
		case 1:
			decoded_string[pos] = ((getbits(base64_string[i]) << 2) & 0xfc) | ((bits2 >> 4) & 0x03);
		default:
			/* Nothing for 0 and 4 will never be */
			break;
	}
	
	decoded_string[pos+(encoded_len - i)] = '\0';