Finish libcwap API.

Also modify the files that use it.