[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: carriage returns and linefeeds



 > We're trying to generate an LDIF files out of a database on our mainframe,
 > and just looking at the file, it seem to be correct, but whenever we try to
 > run it through ldapadd/modify it never seemed to work. Looking closer at the
 > file I'm trying to import (comparing it to a hand-generated file) in hex
 > mode, I notice that the generated file has a carriagereturn/linefeed to end
 > each line, while my hand generated one only has linefeeds. Could this be the
 > problem, or am I looking in the wrong direction? If so, does anyone know of
 > a program that will strip carriagereturns out of a file?
 > 

Here's one. Just redirect stdin to the original file, and stdout to a
new filename, and you're set.


#include <stdio.h>

int main(int argc, char* argv[]) {
  int tmp;
  while ((tmp = getchar()) != EOF) {
    if (tmp != '\r') {
      putchar(tmp);
    }
  }
  return 0;
}

-Chris