How does one write XA programs?

The XA API is supported from both Pro*C and Oracle OCI (Oracle Call Interfaces). Look at the sample precompiler applications that ships with the Oracle database server.

Client:

tx_begin();                 /* Begin transaction boundary */
tpm_service("Service1");    /* Call Service 1 */
tpm_service("Service2");    /* Call Service 2 */
tx_commit();                /* Commit the transaction */

Server:

Service1() {
  // Get service specific data...
  EXEC SQL UPDATE ....;
  // Return service status back to the client...
}
Service2() {
  // Get service specific data...
  EXEC SQL UPDATE ....;
  ...
  // Return service status back to client...
}