Remove globals/make jq_init/next/teardown() an API

Hi, this commit makes jq_{init, next, teardown}() into an thread-safe, re-entrant API.

Now C programs can use jq_compile(), jq_init(), and friends (as well as jv_*()) safely.

Note that I don't yet have Makefile changes to build a shared object.  That's next.

I've been using jq a lot to understand some complex JSON data and test transformations, which I then code up in Python.  Well, that seems silly: jq ought to be usable directly in a C program without having to spawn a process for it.

make test passes, of course.

I've tried to stick to your C style.  If there's anything you need me to change, just let me know.

There's only one problem left as far as jq being usable as an API: memory allocation failures should not cause abort() to be called.  Instead jq functions should return an error.  Calling abort() on memory allocation failure is not a problem for me today, but it likely will be for others (or me) eventually.  If you'd like me to I can write a patch to return ENOMEM up the stack; I haven't done it yet because the changes for that would clearly be invasive, and if you're not interested in them, then I probably won't bother writing that patch.

Nico
--