#include
#include
#define DECODE_OUTPUT_SIZE(len) \
((len/4)*3 + 3)
#define IN_SIZE 32
int main(int argc,char** argv){
FILE* fp = NULL;
FILE* output_file = NULL;
guint i = 0;
guchar in_buffer[IN_SIZE];
guchar out_buffer[DECODE_OUTPUT_SIZE(IN_SIZE)];
gint state = 0,save = 0;
gsize out_len = 0,len = 0;
output_file = fopen("./008.encode.app","wb");
if(output_file == NULL){
g_print("open 008.encode.app error!\n");
return -1;
}
fp = fopen("./008_encode.txt","rb");
if(fp == NULL) return -1;
while((len = fread(in_buffer,1,IN_SIZE,fp)) == IN_SIZE){
out_len = g_base64_decode_step(in_buffer,
IN_SIZE,
out_buffer,
&state,
&save);
fwrite(out_buffer,1,out_len,output_file);
}
if(len > 0){
out_len = g_base64_decode_step(in_buffer,
len,
out_buffer,
&state,
&save);
fwrite(out_buffer,1,out_len,output_file);
}
fclose(output_file);
fclose(fp);
return 0;
}