cutil/listio.cpp

Go to the documentation of this file.
00001 
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include <stdlib.h>
00025 #include "listio.h"
00026 
00027 /*---------------------------------------------------------------------------
00028         Public Function Code
00029 ---------------------------------------------------------------------------*/
00035 LIST read_list(const char *filename) {
00036   FILE *infile;
00037   char s[CHARS_PER_LINE];
00038   LIST list;
00039   char *chopAt250();
00040 
00041   if ((infile = open_file (filename, "r")) == NULL)
00042     return (NIL);
00043 
00044   list = NIL;
00045   while (fgets (s, CHARS_PER_LINE, infile) != NULL) {
00046     s[CHARS_PER_LINE - 1] = '\0';
00047     if (strlen (s) > 0) {
00048       if (s[strlen (s) - 1] == '\n')
00049         s[strlen (s) - 1] = '\0';
00050       if (strlen (s) > 0) {
00051         list = push (list, (LIST) strsave (s));
00052       }
00053     }
00054   }
00055 
00056   fclose(infile);
00057   return (reverse_d (list));
00058 }

Generated on Wed Feb 28 19:49:10 2007 for Tesseract by  doxygen 1.5.1