refactor command registration and dispatch

This is a step towards some enhancements I'm planning for the watchman
CLI process.

Switch the registration from a central list of commands (and a separate
list for the client mode command set) to declaring the registration
details alongside the command function with some flags to indicate
whether it is permitted in client or daemon mode.

This can later be extended to include a CLI-side command preprocessor
callback that can do things like `realpath`ing the root dir on the
client side before sending a watch command.

We could also extend this to include a usage summary to be displayed
when `watchman -h` is invoked.

As part of this refactor, I took out the function call that initialized
the query expression term hash, so I applied the same principle to that
subsystem.
Move command registration funcs out of listener.c

Just a straightforward move of this code to a home of its own.
preprocess commands in the CLI

Adds a per-command callback that is invoked by the CLI prior to sending
a command to the server.

For commands that accept the root dir as the second parameter, we wire
up a callback that executes `realpath` on the root prior to sending the
command.  This makes it more convenient to use the CLI, as you may now
specify relative paths for the root.

This does not apply or have meaning to clients that are directly
accessing the socket, because they are bypassing the CLI.

References https://github.com/facebook/watchman/issues/33