OpenTTCN/Developer corner/Implementing external functions/Skeletons/C/main.cxx
From OpenTTCN
Home | Developer's corner | Knowledge base | Working documents | Documentation | OpenTTCN IDE | Tutorials | Training | How do I | Frequently asked questions | Technical support |
main.cxx
/* for sleep() call */
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <tci/tci.h>
#include <tri/tri.h>
#include <isl/TTCN3.h>
#include <isl/Version.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
extern void initializePA();
int main (int argc, char *argv[])
{
int status = otInitAdapter(0);
if (status)
{
printf("main(): otInitAdapter() failed.\n");
exit(status);
}
printf("\nOpenTTCN SDK for C " OT_OPENTTCN_SDK_VERSION_NUMBER "\n");
printf("Adapter for 'ext_func_example' example\n\n");
{
TriPACallbackFunctionPointers triPaCbFptrsContainer;
otInitTriPACallbackFunctionPointers(&triPaCbFptrsContainer);
triPaCbFptrsContainer.triExternalFunctionPtr = &triExternalFunction;
otSetTriPACallbackFunctionPointers(&triPaCbFptrsContainer);
initializePA(); // custom function to set up certain mappings
}
otSetEncoder(0, &tciEncode);
otSetDecoder(0, &tciDecode);
// Register the adapter to OpenTTCN server as platform adapter
// in the ext_func_example session:
status = otRegisterAdapter("ext_func_example", "TRI_PA");
if (status)
{
printf("main(): otRegisterAdapter() failed.\n");
exit(status);
}
/* Enable printout of library diagnostic information */
otSetSAFlags(OT_SA_FLAG_VERBOSE);
printf("Adapter initialisation complete.\n");
/* Enter the infinite loop */
while (1)
{
#ifndef _WIN32
sleep(100); // seconds
#else
Sleep(100000); // milliseconds
#endif
}
/* Avoid compiler complaints */
return 0;
}
