Line 110:
Line 110:
:unsigned long length; // the length of the line, ie. the number of characters that were read in from the file
:unsigned long length; // the length of the line, ie. the number of characters that were read in from the file
+
+
:char *buffer_ptr; // points to start of next line in a buffer -- initialized by SetBuffer
+
+
:unsigned long buffer_size; // the total number of characters in the buffer -- initialized by SetBuffer
Line 147:
Line 151:
<blockquote>
<blockquote>
A utility routine to increment through the entire file just to count how many lines of text are in the file (i.e. how many lines are terminated by <tt>\r</tt> or <tt>\n</tt>. This routine DOES call <tt>rewind(fp) </tt> before returning, so <tt>fp</tt> points to the start of the file upon returning.
A utility routine to increment through the entire file just to count how many lines of text are in the file (i.e. how many lines are terminated by <tt>\r</tt> or <tt>\n</tt>. This routine DOES call <tt>rewind(fp) </tt> before returning, so <tt>fp</tt> points to the start of the file upon returning.
+
</blockquote>
+
+
===<tt> void SetBuffer(LineBuffer *line,char *buffer, unsigned long size); </tt>===
+
<blockquote>
+
Sets the internal variables line->buffer_ptr and buffer_size
+
will start looking for complete lines starting at buffer_ptr
+
buffer_ptr will be incremented to keep track of our position in the buffer
+
</blockquote>
+
+
===<tt> void RewindBuffer(LineBuffer *line,char *buffer); </tt>===
+
<blockquote>
+
resets the internal variable line->buffer_ptr, so we start searching for lines at the beginning of the buffer
+
</blockquote>
+
+
===<tt> Boolean GetNextLineInBuffer(LineBuffer *line,char *buffer); </tt>===
+
<blockquote>
+
get the next array of characters that are terminated by /r or /n or end-of-file and store them as a null-terminared string in line->text
+
</blockquote>
+
+
===<tt> unsigned long CountLinesInBuffer(LineBuffer *line,char *buffer,unsigned long size); </tt>===
+
<blockquote>
+
given a buffer of size characters, return the number of lines that are terminated by /r or /n. Calls SetBuffer and RewindBuffer on exit, so you are back at the beginning of the buffer
</blockquote>
</blockquote>