Exemple #1
0
/*
 * server
 * client minor ver <= server minor ver
 */
int isisds_recv_open(SOCKET s, ISISDSAccessMode *access_type) {
  isisds_open_t op;
  if ((recv_all(s, (char *)&op, sizeof(op), 0)) != sizeof(op)) {
    return -1;
  }
  if (op.len != sizeof(op)) {
    return -1;
  }
  if ((op.ver_major != ISISDS_MAJOR_VER) || (op.ver_minor > ISISDS_MINOR_VER)) {
    return -1;
  }
  *access_type = (ISISDSAccessMode)op.access_type;
  return isisds_send_command(s, "OK", NULL, ISISDSUnknown, NULL, 0);
}
/*
 * server
 * client minor ver <= server minor ver
 */
int isisds_recv_open(SOCKET s, ISISDSAccessMode *access_type) {
  isisds_open_t op;
  if ((recv_all(s, reinterpret_cast<char *>(&op), sizeof(op), 0)) !=
      sizeof(op)) {
    return -1;
  }
  if (op.len != sizeof(op)) {
    return -1;
  }
  if ((op.ver_major != ISISDS_MAJOR_VER) || (op.ver_minor > ISISDS_MINOR_VER)) {
    return -1;
  }
  *access_type = static_cast<ISISDSAccessMode>(op.access_type);
  return isisds_send_command(s, "OK", nullptr, ISISDSUnknown, nullptr, 0);
}
Exemple #3
0
/** main worker routine for all data reading. Returns 0 on success, -1 on error */
static int getdat(idc_handle_t fh, int ifsn, int nos, int** value, int dims_array[], int* ndims, int do_alloc)
{
        (void) isisds_type_size; // Avoid compiler warning
        (void) isisds_type_name; // Avoid compiler warning

	int stat, comm_buff_size;
	ISISDSDataType ret_type;
	int spec_nos[2] = { ifsn, nos };
	int spec_nos_dims[1] = { 2 };
	char* command = NULL;
	char comm_buffer[256];
	if (isisds_send_command(fh->s, "GETDAT", spec_nos, ISISDSInt32, spec_nos_dims, 1) <= 0)
	{
		IDCreport(0, 0, "error sending command (getdat)");
		return -1;
	};
        ret_type = ISISDSInt32;
	if (do_alloc)
	{
		stat = isisds_recv_command_alloc(fh->s, &command, (void**)value, &ret_type, dims_array, ndims);
	}
	else
	{
		comm_buff_size = sizeof(comm_buffer);
		stat = isisds_recv_command(fh->s, comm_buffer, &comm_buff_size, *value, &ret_type, dims_array, ndims);
	}
	if (stat <= 0)
	{
		IDCreport(0, 0, "error reading command (getdat)");
		return -1;
	}
	if (ret_type != ISISDSInt32)
	{
		IDCreport(0, 0, "invalid return type command (getdat)");
		return -1;
	}
/*	IDCreport(0, 0, "type %s\n", isisds_type_name[ret_type]); */
	return 0;
}
Exemple #4
0
///Get a parameter
static int IDCgetpar(idc_handle_t fh, const char* name, void** value, ISISDSDataType type,
					 int dims_array[], int* ndims, int do_alloc)
{
	int n, stat, comm_buff_size;
	ISISDSDataType ret_type;
	char* command = NULL;
	char comm_buffer[256];
	sprintf(comm_buffer, "GETPAR%s", isisds_type_code[type]);
	n = static_cast<int>(strlen(name));
	if (isisds_send_command(fh->s, comm_buffer, name, ISISDSChar, &n, 1) <= 0)
	{
		IDCreport(0, 0, "error sending command %s (getpar)", name);
		return -1;
	};
	ret_type = type;
	if (do_alloc)
	{
		stat = isisds_recv_command_alloc(fh->s, &command, value, &ret_type, dims_array, ndims);
	}
	else
	{
		comm_buff_size = sizeof(comm_buffer);
		stat = isisds_recv_command(fh->s, comm_buffer, &comm_buff_size, *value, &ret_type, dims_array, ndims);
	}
	if (stat <= 0)
	{
		IDCreport(0, 0, "error receiving command %s (getpar)", name);
		return -1;
	}
/*	IDCreport(0, 0, "type %s\n", isisds_type_name[ret_type]); */
	if (ret_type != type)
	{
	    return -1;
	}
	return 0;
}