Tesseract  3.02
tesseract-ocr/cutil/listio.h File Reference
#include <stdio.h>
#include "oldlist.h"

Go to the source code of this file.

Functions

LIST read_list (const char *filename)

Function Documentation

LIST read_list ( const char *  filename)

Definition at line 45 of file listio.cpp.

                                     {
  FILE *infile;
  char s[CHARS_PER_LINE];
  LIST list;
  char *chopAt250();

  if ((infile = open_file (filename, "r")) == NULL)
    return (NIL_LIST);

  list = NIL_LIST;
  while (fgets (s, CHARS_PER_LINE, infile) != NULL) {
    s[CHARS_PER_LINE - 1] = '\0';
    if (strlen (s) > 0) {
      if (s[strlen (s) - 1] == '\n')
        s[strlen (s) - 1] = '\0';
      if (strlen (s) > 0) {
        list = push (list, (LIST) strsave (s));
      }
    }
  }

  fclose(infile);
  return (reverse_d (list));
}