Example D-4 is an example of a typical algorithm of this callback.
Tt_message myAcmeSheetLoadCB( Tt_message msg, void *client_data, Tttk_op op, Tt_status diagnosis, unsigned char *contents, int len, char *file, char *docname ) { Tt_status status = TT_OK; if (diagnosis != TT_OK) { // toolkit detected an error if (tt_message_status( msg ) == TT_WRN_START_MESSAGE) { // // Error is in start message! We now have no // reason to live, so tell main() to exit(). // myAbortCode = 2; } // let toolkit handle the error return msg; } if ((op == TTME_COMPOSE) && (file == 0)) { // open empty new buffer } else if (len > 0) { // load contents into new buffer } else if (file != 0) { if (ttdt_Get_Modified( msg, file, TT_BOTH, myCntxt, 5000 )) { switch (myUserChoice( "Save, Revert, Ignore?" )) { case 0: ttdt_Save( msg, file, TT_BOTH, myCntxt, 5000 ); break; case 1: ttdt_Revert( msg, file, TT_BOTH, myCntxt, 5000); break; } } // load file into new buffer } else { tttk_message_fail( msg, TT_DESKTOP_ENODATA, 0, 1 ); tt_free( contents ); tt_free( file ); tt_free( docname ); return 0; } int w, h, x, y = INT_MAX; ttdt_sender_imprint_on( 0, msg, 0, &w, &h, &x, &y, myCntxt, 5000 ); positionMyWindowRelativeTo( w, h, x, y ); if (maxBuffersAreNowOpen) { // Un-volunteer to handle future requests until less busy tt_ptype_undeclare( "Acme_Calc" ); } if (tt_message_status( msg ) == TT_WRN_START_MESSAGE) { // // Join session before accepting start message, // to prevent unnecessary starts of our ptype // ttdt_session_join( 0, myContractCB, myShell, 0, 1 ); } ttdt_message_accept( msg, myContractCB, myShell, 0, 1, 1 ); tt_free( contents ); tt_free( file ); tt_free( docname ); return 0; }