add extern 'C' to support C++
rearrange source code directory
正确处理异常