Each numbered step below (1-4) is highlighted in the source code for the sample application that follows:
When distributing an application, a NULL shared library must be
included in the installation package. This will ensure that the
application will load and execute correctly, even if no measurement
agent is installed.
/********************************************************************/
/* sample.c */
/********************************************************************/
#include <stdio.h>
(1) #include "arm.h"
int32 appl_id = -1; /* Unique id for the application */
int32 tran_id = -1; /* Unique id for the transaction */
void init()
{
(2) appl_id = arm_init("ARM sample program" /* application name */
"*", /* use default user */
0,0,0);
if (appl_id < 0)
printf("ARM sample program not registered.");
(3) tran_id = arm_getid(appl_id, /* application id from arm_init */
"Sample_transaction", /* transaction name */
"First Transaction in Sample program",
0,0,0);
if (tran_id < 0)
printf("Sample_transaction is not registered.");
} /* init */
void transaction()
{
int32 tran_handle;
(4) tran_handle = arm_start(tran_id, /* trans id from arm_getid */
0,0,0);
/*********************************************/
/* Perform actual transaction processing here*/
/*********************************************/
sleep(1);
(4) arm_stop(tran_handle, /* transaction handle from arm_start */
ARM_GOOD, /* successful completion define = 0 */
0,0,0);
return;
} /* transaction */
main()
{
int continue_processing = 1;
init();
while (continue_processing)
{
transaction();
}
(2) arm_end(appl_id, /* application id from arm_init */
0,0,0);
return(0);
}
Contents | Next section | Index |