Too big a chunk of refactoring and portability fix.
Added gcc and clang build support for Ubuntu (tested with 17.04). Added gcc/c4droid build support (tested with Marshmallow). Added clang/termux build support (tested with marshmallow). Added command line rewrite driver for testing. Hopefully, Mac build is fine. I don't have the environment to verify. Fixed a few potential buffer overrun (I vaguely remember a command could be up to 4k (?) (I could very well be wrong) and strncpy doesn't always NULL-end the string, ref manpage).
I was actually planning/researching on a similar tool, but for native environment. Thanks to this great template, a working prototype took only a few hours. It would most likely end up as a magisk module. Though it wasn't my plan to contribute to termux when I started, but I am a grateful user, so why not.
If ppl like what I did to it, there is more to come. If not, that fine, too. The code and updates will be on github, I just won't be actively sending pull requests.
Cheers,
- kenneth