This article is from the GNU Chess and XBoard FAQ, by Tim Mann email@example.com with numerous contributions by others.
This is a non-trivial task. XBoard and WinBoard were not designed with a
clean interface for talking to chess programs; they were written to work
with an existing version of GNU Chess that expects to be talking to a
person. Your program has to emulate GNU Chess's rather idiosyncratic
command structure to work with XBoard and WinBoard. We are gradually
cleaning up, improving, and documenting the interface as newer versions
of XBoard and WinBoard come out, however.
For documentation, see the file engine-intf.html, included in both
distributions or available from my chess Web page,
http://www.research.digital.com/SRC/personal/Tim_Mann/chess.html . The
version of engine-intf.html on my Web page is often more up-to-date than
those in the XBoard/WinBoard distributions.