generated html version of bbssendrecv.cHOME

#include "stdio.h"
#include "stdlib.h"

unsigned char *int2u8(unsigned U){
static unsigned char out[7];
int i=0;
if(U<=0x80)out[i++]=U;
else if(U<0x800){
out[i++]=(U>>6|0xC0);
out[i++]=(U&0x3f|0x80);
}else if(U<=0x10000){
out[i++]=(U>>12|0xE0);
out[i++]=(U>>6&0x3f|0x80);
out[i++]=(U&0x3f|0x80);
}else if(U<=0x200000){
out[i++]=(U>>18|0xF0);
out[i++]=(U>>12&0x3f|0x80);
out[i++]=(U>>6&0x3f|0x80);
out[i++]=(U&0x3f|0x80);
}else if(U<=0x4000000){
out[i++]=(U>>24|0xF8);
out[i++]=(U>>18&0x3f|0x80);
out[i++]=(U>>12&0x3f|0x80);
out[i++]=(U>>6&0x3f|0x80);
out[i++]=(U&0x3f|0x80);
}else if(U<=0x80000000){
out[i++]=(U>>30|0xFC);
out[i++]=(U>>24&0x3f|0x80);
out[i++]=(U>>18&0x3f|0x80);
out[i++]=(U>>12&0x3f|0x80);
out[i++]=(U>>6&0x3f|0x80);
out[i++]=(U&0x3f|0x80);
}
out[i]=0;
return out;
}

int main(int argc, char **argv){
	int i;
	FILE *f=fopen("/var/www/bbsraws","r+");
	for(i=0;i < 2112;i++) {
		int c;
		int o;
		int k=scanf(" %d %d ",&o,&c);
		if(k < 2)break;
		if(o>2112)continue;
		fseek(f,o*4,SEEK_SET);
		fwrite(&c,4,1,f);
	}
	rewind(f);
	int ch[2112];
	fread(ch,4,2112,f);
	fclose(f);
	puts("Content-type: text/plain\r\n\r");
	for(i=0;i<2112;i++){
		fputs(int2u8(ch[i]),stdout);
	}
	return 0;
}