cutil/listio.h File Reference

#include <stdio.h>
#include "oldlist.h"

Go to the source code of this file.

Functions


Function Documentation

LIST read_list ( const char *  filename  ) 

Read a list of strings from a file.

Return the string list to the caller.

Definition at line 35 of file listio.cpp.

References CHARS_PER_LINE, NIL, NULL, open_file(), push(), reverse_d(), and strsave.

Referenced by read_variables().

00035                                      {
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:21 2007 for Tesseract by  doxygen 1.5.1