netstring-c icon indicating copy to clipboard operation
netstring-c copied to clipboard

enhanced reading

Open kroggen opened this issue 7 years ago • 1 comments

Hi!

Thank you for sharing your code!

I understand that netstrings are used mainly as lists, so I thought that we could enhance the sequential reading of strings in a netstring list.

In the current code we don't know how much remaining bytes are there to call netstring_read again. Off course we can calculate it but I guess that less code is better.

I forked the repo and made some changes. With it we can iterate a list with code like this:

while(netstring_read(&base, &size, &str, &len) == 0) {
  do_something(str, len);
}

If you think it is useful I can make a pull request.

It will break the current ABI, so it can have a new version.

Thank you again!

kroggen avatar Jan 24 '17 04:01 kroggen