Vadim647 converted some old c&c code to lite-c which does what you are looking for. Can be found here