enhanced reading
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!
Now I added the netstring_add function. It supports adding many strings to a netstring list (it concatenates them).
char *netstring=0; /* we must initialize it to zero */
netstring_add(&netstring, "first");
netstring_add(&netstring, "second");
netstring_add(&netstring, "third");
I guess it is better than using netstring_encode_new because with this one we have to concatenate the result by ourselves.