Example #1
0
int main()
{

  gtm_char_t err[maxmsg];
  gtm_char_t msg[maxmsg];
  gtm_char_t value[maxstr];

  gtm_status_t status;
  gtm_string_t p_value;

  int failed=0;

  // Initialization
  p_value.address = (xc_char_t *) &value;
  p_value.length = 0;



  // Initialize GT.M runtime
  CALLGTM( gtm_init() );


  // Initialize the GT.M access routines
  p_value.address = ( xc_char_t *) &value ; p_value.length = maxstr ;
  CALLGTM( gtm_ci( "gtminit", &err ));
  if (0 != strlen( err )) fprintf( stdout, "%s\n", err);


  // Set a node - note that value can be an arbitrary blob, not just a null terminated string
  gtm_char_t washington[] = "Washington, DC";
  p_value.address = (xc_char_t *) &washington;
  p_value.length = strlen( "Washington, DC" );
  CALLGTM( gtm_ci( "gtmset", "^Capital(\"United States\")", &p_value, &err ));
  if (0 != strlen( err )) fprintf( stdout, "%s\n", err);



  // Cleanup GT.M runtime
  CALLGTM( gtm_exit() );

  if( failed == 0 )
    {
    printf("Test PASSED !\n");
    }
  else
    {
    printf("Test FAILED !\n");
    }

  return failed;
}
Example #2
0
File: zappyd.c Project: fosm/xapi
int main()
{
 	gtm_char_t	port[] = "6520";
	gtm_char_t	logLevel[] = "0";
	gtm_char_t	msgbuf[BUF_LEN];
        gtm_status_t    status;
        status = gtm_init();
        if (status != 0)
        {
            gtm_zstatus(msgbuf, BUF_LEN);
            return status;
        }
        status = gtm_ci("zappyd", port, logLevel);
        if (status != 0)
        {
            gtm_zstatus(msgbuf, BUF_LEN);
            fprintf(stderr, "%s\n", msgbuf);
            return status;
        }
        return 0;
}
Example #3
0
//
// Constructor
//
GTM::GTM()
{

  //
  // Since GT.M changes the terminal attributes, save the attributes of stderr, stdin and stdout
  // in order to restore them before exit
  //
  tcgetattr( 0, &stdin_sav );
  tcgetattr( 1, &stdout_sav );
  tcgetattr( 2, &stderr_sav );

  //
  // Clear error message buffer by putting null terminator in first byte
  //
  errorMessage[0] = '\0';

  //
  // Initialize GTM
  //
  CALLGTM( gtm_init() );

  //
  // Initialization - function descriptors for calling in to GT.M
  //
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmget);
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmkill);
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmlock);
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmorder);
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmquery);
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmset);
  INITIALIZE_FUNCTION_DESCRIPTOR(gtmxecute);

  //
  // Initialization - structure for return values
  //
  this->p_value.address = NULL;
  this->p_value.length = 0;
}