server_ptree_walk()

int server_ptree_walk(server_ptree_t **branch, int *temp, unsigned char *input, int input_len);

Walks a tree, branch changes as walking progresses. When you first initiate a walk you start with the root returned from server_ptree_new().

Make sure you keep the root pointer around so you can reuse it, the walk function overwrites the space you pass in branch when it steps to new branches.

The temp integer is used as scratch space that must persist across walk calls. You don't have to initialize the temp variable ever, it is fully managed by the walk function.

input and input_len are the input stream of bytes that you want the walk function to try use as directions through the tree.

The function returns -1, 0, or +N.

When 0 is returned a destination has been reached in the tree, whos associated object is available in branch-$>$hook. When -1 is returned a parse error was experienced. When +N is returned and N is less than or equal to input_len N bytes have been consumed from the input. If N is less than input_len a destination was reached and it should be handled as if 0 was returned.

If N is greater than input_len a target was reached and N-1 bytes (all input bytes) were consumed. This last case is done to avoid returning N equal to input_len and arrived at destination, a situation that technically shouldn't require another ptree_walk() call, which is different from pre-1.0.0 ServerKit releases which required another ptree_walk() call.

2007-12-06