syncfiles/convert_line_endings.c
Dietrich Epp 2768a0c856 Add plain text and XML files to filter list
GitOrigin-RevId: 2c5ded355b43463d20e6e9e65c32a6c566df82a7
2021-03-26 03:47:55 -04:00

27 lines
583 B
C

#include "convert.h"
int convert_line_endings(short srcRef, short destRef, void *buf,
unsigned char srcEnding, unsigned char destEnding) {
unsigned char *ptr, *end;
long count;
int r, r2;
do {
count = kBufferBaseSize;
r = convert_read(srcRef, &count, buf);
if (r == kConvertError) {
return 1;
}
for (ptr = buf, end = ptr + count; ptr != end; ptr++) {
if (*ptr == srcEnding) {
*ptr = destEnding;
}
}
r2 = convert_write(destRef, count, buf);
if (r2 != kConvertOK) {
return 1;
}
} while (r != kConvertEOF);
return 0;
}