clean the code. add stdlib dependency for NULL
move function defined in defs.h from main to defs.c
clean codes. change automated test to console interface test