cut the main function into two function
add extern'C' for *.h