some useful c code