#include "mathlink.h"
/* handle three common MathLink urgent messages */
void f(MLINK lp, int msg, int arg)
{
if(msg
MLInterruptMessage)
{ /* generate an interrupt menu */ }
else if(msg
MLAbortMessage)
{ /* abort the current operation */ }
else if(msg
MLTerminateMessage)
{ /* shutdown the program */ }
/* ... */
}
int main(int argc, char **argv)
{
MLENV env;
MLINK link;
int error;
env = MLInitialize((char *)0);
if(env
(MLENV)0)
{ /* unable to initialize MathLink environment */ }
link = MLOpenArgcArgv(env, argc, argv, &error);
if(link
(MLINK)0 || error
MLEOK)
{ /* unable to create link */ }
if(! MLSetMessageHandler(link, (MLMessageHandlerObject)f)
{ /* unable to install message handler for link */ }
/* ... */
MLClose(link);
MLDeinitialize(env);
return 0;
}