static void to64(FILE * infile, FILE * outfile, int PortableNewlines) { int c1, c2, c3, ct = 0; InNewline = 0; /* always reset it */ while ((c1 = nextcharin(infile, PortableNewlines)) != EOF) { c2 = nextcharin(infile, PortableNewlines); if (c2 == EOF) { output64chunk(c1, 0, 0, 2, outfile); } else { c3 = nextcharin(infile, PortableNewlines); if (c3 == EOF) { output64chunk(c1, c2, 0, 1, outfile); } else { output64chunk(c1, c2, c3, 0, outfile); } } ct += 4; if (ct > 71) { putc('\n', outfile); ct = 0; } } if (ct) putc('\n', outfile); fflush(outfile); }
int to64(FILE *infile, FILE *outfile, long int limit) { int c1, c2, c3, ct=0, written=0; if (limit && limit < 73) return 1; while ((c1 = getc(infile)) != EOF) { c2 = getc(infile); if (c2 == EOF) { output64chunk(c1, 0, 0, 2, outfile); } else { c3 = getc(infile); if (c3 == EOF) { output64chunk(c1, c2, 0, 1, outfile); } else { output64chunk(c1, c2, c3, 0, outfile); } } ct += 4; if (ct > 71) { putc('\n', outfile); if (limit) { limit -= ct + 1; if (limit < 73) return 1; } written += 73; ct = 0; } } if (ct) { putc('\n', outfile); ct++; } return written + ct; }