Gary Kline wrote:
Your function may not work exactly as you think it will. Your basic idea
runs on the assumption that the tag will never be broken during the file
read. It's possible that you'll read "some data<Tag begin" and the next
read will have ">more data here<tag ends>", or some variation thereof.
If you know for a fact that the string you read in will always be
complete, then what's below should work fine:
maybe this can't be done reading in a file with fgets(buffer, fp),
then calling skiptags(), conditionally, to while () past ',' and '>'.
I know I need to calll skipTags with its address, skipTags(&buffer);, but then
how to i
handle the variable "s" in skipTags? Anybody?
// redo, skip TAGS
if (*s == '<')
while (*s != '>')
// where *s is the address of a string to be parsed
// maxlen represents the maximum number of chars potentially in the string and
is not zero based (ie: maxlen 256 = char positions 0-255)
// *curpos is the current position of the pointer (this prevents bounds errors)
skipTags(char *s, long maxlen, long *curpos)
if (*s == '<')
while (*s != '>' && && *s && *curpos < maxlen)
if (*curpos < maxlen)
When you read in the next line of the file, reset curpos to zero, set
maxlen to number of bytes read. As you process each char after the
function is called, you'll need to increment curpos as well.
Depending on the size of the files you are reading, you may be able to
read the entire file into memory at once and avoid any possible TAG
If you explain exactly what you're trying to accomplish, we may be able
to come up with an easier/cleaner solution.
(warning: none of the above code is tested, but in concept it should
email@example.com mailing list
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"