当前位置: 首页>>代码示例>>C++>>正文


C++ VALIDATE_HANDLE函数代码示例

本文整理汇总了C++中VALIDATE_HANDLE函数的典型用法代码示例。如果您正苦于以下问题:C++ VALIDATE_HANDLE函数的具体用法?C++ VALIDATE_HANDLE怎么用?C++ VALIDATE_HANDLE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VALIDATE_HANDLE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ti92_send_RTS

TIEXPORT3 int TICALL ti92_send_RTS(CalcHandle* handle, uint32_t varsize, uint8_t vartype, const char *varname)
{
	uint8_t buffer[32];
	uint16_t len;

	VALIDATE_HANDLE(handle);
	VALIDATE_NONNULL(varname);
	len = (uint16_t)strlen(varname);
	if (len > 17)
	{
		ticalcs_critical("Oversized variable name has length %i, clamping to 17", len);
		len = 17;
	}

	buffer[0] = LSB(LSW(varsize));
	buffer[1] = MSB(LSW(varsize));
	buffer[2] = LSB(MSW(varsize));
	buffer[3] = MSB(MSW(varsize));
	buffer[4] = vartype;
	buffer[5] = len;
	memcpy(buffer + 6, varname, len);

	ticalcs_info(" PC->TI: RTS (size=0x%08X=%i, id=%02X, name=%s)", varsize, varsize, vartype, varname);
	return dbus_send(handle, DBUS_MID_PC_TI92, DBUS_CMD_RTS, 6 + len, buffer);
}
开发者ID:TC01,项目名称:tilibs,代码行数:25,代码来源:cmd68k.c

示例2: ti89_send_DEL

TIEXPORT3 int TICALL ti89_send_DEL(CalcHandle* handle, uint32_t varsize, uint8_t vartype, const char *varname)
{
	uint8_t buffer[32];
	uint16_t len;

	VALIDATE_HANDLE(handle);
	VALIDATE_NONNULL(varname);
	len = (uint16_t)strlen(varname);
	if (len > 17)
	{
		ticalcs_critical("Oversized variable name has length %i, clamping to 17", len);
		len = 17;
	}

	buffer[0] = 0;
	buffer[1] = 0;
	buffer[2] = 0;
	buffer[3] = 0;
	buffer[4] = 0;
	buffer[5] = len;
	memcpy(buffer + 6, varname, len);

	ticalcs_info(" PC->TI: DEL (size=0x%08X=%i, id=%02X, name=%s)", varsize, varsize, vartype, varname);
	return dbus_send(handle, ti68k_handle_to_dbus_mid(handle), DBUS_CMD_DEL, 6 + len, buffer);
}
开发者ID:TC01,项目名称:tilibs,代码行数:25,代码来源:cmd68k.c

示例3: ti89_send_RTS

TIEXPORT3 int TICALL ti89_send_RTS(CalcHandle* handle, uint32_t varsize, uint8_t vartype, const char *varname)
{
	uint8_t buffer[32];
	uint16_t len;

	VALIDATE_HANDLE(handle);
	VALIDATE_NONNULL(varname);
	len = (uint16_t)strlen(varname);
	if (len > 17)
	{
		ticalcs_critical("Oversized variable name has length %i, clamping to 17", len);
		len = 17;
	}

	buffer[0] = LSB(LSW(varsize));
	buffer[1] = MSB(LSW(varsize));
	buffer[2] = LSB(MSW(varsize));
	buffer[3] = MSB(MSW(varsize));
	buffer[4] = vartype;
	buffer[5] = len;
	memcpy(buffer + 6, varname, len);
	buffer[6 + len] = 0x00;

	len += 6 + 1;
	// used by AMS <= 2.09 ?
	//if ((vartype == TI89_AMS) || (vartype == TI89_APPL)) len--;

	ticalcs_info(" PC->TI: RTS (size=0x%08X=%i, id=%02X, name=%s)", varsize, varsize, vartype, varname);
	return dbus_send(handle, ti68k_handle_to_dbus_mid(handle), DBUS_CMD_RTS, len, buffer);
}
开发者ID:TC01,项目名称:tilibs,代码行数:30,代码来源:cmd68k.c

示例4: cman_is_active

int cman_is_active(cman_handle_t handle)
{
	struct cman_handle *h = (struct cman_handle *)handle;
	VALIDATE_HANDLE(h);

	return info_call(h, CMAN_CMD_ISACTIVE, NULL, 0, NULL, 0);
}
开发者ID:smintz,项目名称:cluster,代码行数:7,代码来源:libcman.c

示例5: ti68k_send_XDP

TIEXPORT3 int TICALL ti68k_send_XDP(CalcHandle* handle, uint32_t length, const uint8_t * data, uint8_t target)
{
	VALIDATE_HANDLE(handle);

	ticalcs_info(" PC->TI: XDP (0x%04X = %i bytes)", length, length);
	return dbus_send(handle, target, DBUS_CMD_XDP, length, data);
}
开发者ID:TC01,项目名称:tilibs,代码行数:7,代码来源:cmd68k.c

示例6: cman_shutdown

int cman_shutdown(cman_handle_t handle, int flags)
{
	struct cman_handle *h = (struct cman_handle *)handle;
	VALIDATE_HANDLE(h);

	return info_call(h, CMAN_CMD_TRY_SHUTDOWN, &flags, sizeof(int), NULL, 0);
}
开发者ID:smintz,项目名称:cluster,代码行数:7,代码来源:libcman.c

示例7: cman_set_dirty

int cman_set_dirty(cman_handle_t handle)
{
	struct cman_handle *h = (struct cman_handle *)handle;
	VALIDATE_HANDLE(h);

	return info_call(h, CMAN_CMD_SET_DIRTY, NULL, 0, NULL, 0);
}
开发者ID:smintz,项目名称:cluster,代码行数:7,代码来源:libcman.c

示例8: dusb_send_buf_size_alloc

TIEXPORT3 int TICALL dusb_send_buf_size_alloc(CalcHandle* handle, uint32_t size)
{
	DUSBRawPacket raw;
	int ret;

	VALIDATE_HANDLE(handle);

	if (size > sizeof(raw.data) + 1)
	{
		ticalcs_warning("Clamping dubious large DUSB buffer size request");
		size = sizeof(raw.data) + 1;
	}

	memset(&raw, 0, sizeof(raw));
	raw.size = 4;
	raw.type = DUSB_RPKT_BUF_SIZE_ALLOC;
	raw.data[0] = (size >> 24) & 0xFF;
	raw.data[1] = (size >> 16) & 0xFF;
	raw.data[2] = (size >>  8) & 0xFF;
	raw.data[3] = (size      ) & 0xFF;

	ret = dusb_send(handle, &raw);
	if (!ret)
	{
		ticalcs_info("  PC->TI: Buffer Size Allocation (%i bytes)", size);
	}

	handle->priv.dusb_rpkt_maxlen = size;

	return ret;
}
开发者ID:TC01,项目名称:tilibs,代码行数:31,代码来源:dusb_vpkt.c

示例9: ti68k_recv_CTS

static int ti68k_recv_CTS(CalcHandle* handle, uint8_t is_92)
{
	uint8_t host, cmd;
	uint16_t length;
	uint8_t *buffer;
	int ret;

	VALIDATE_HANDLE(handle);

	buffer = (uint8_t *)handle->buffer;
	ret = dbus_recv(handle, &host, &cmd, &length, buffer);
	if (ret)
	{
		return ret;
	}

	if (cmd == DBUS_CMD_SKP)
	{
		return is_92 ? ERR_VAR_REJECTED : ERR_CALC_ERROR1 + err_code(buffer);
	}
	else if (cmd != DBUS_CMD_CTS)
	{
		return ERR_INVALID_CMD;
	}
	if (length != 0x0000)
	{
		return ERR_CTS_ERROR;
	}

	ticalcs_info(" TI->PC: CTS");

	return 0;
}
开发者ID:TC01,项目名称:tilibs,代码行数:33,代码来源:cmd68k.c

示例10: dusb_cmd_r_eot

// 0xDD00: end of transmission (recv)
TIEXPORT3 int TICALL dusb_cmd_r_eot(CalcHandle *handle)
{
	DUSBVirtualPacket* pkt;
	int retval = 0;

	VALIDATE_HANDLE(handle);

	pkt = dusb_vtl_pkt_new_ex(handle, 0, 0, NULL);

	retval = dusb_recv_data(handle, pkt);

	if (!retval)
	{
		CATCH_DELAY();

		if (pkt->type == DUSB_VPKT_ERROR)
		{
			retval = ERR_CALC_ERROR2 + err_code_pkt(pkt);
			goto end;
		}
		else if (pkt->type != DUSB_VPKT_EOT)
		{
			retval = ERR_INVALID_PACKET;
			goto end;
		}
	}

end:
	dusb_vtl_pkt_del(handle, pkt);

	return retval;
}
开发者ID:TC01,项目名称:tilibs,代码行数:33,代码来源:dusb_cmd.c

示例11: dbus_recv_header

TIEXPORT3 int TICALL dbus_recv_header(CalcHandle *handle, uint8_t* host, uint8_t* cmd, uint16_t* length)
{
	int ret;
	uint8_t buf[4];

	VALIDATE_HANDLE(handle);
	VALIDATE_NONNULL(host);
	VALIDATE_NONNULL(cmd);
	VALIDATE_NONNULL(length);

	// Any packet has always at least 2 bytes (MID, CID)
	ret = ticables_cable_recv(handle->cable, buf, 2);
	if (!ret)
	{
		*host = buf[0];
		*cmd = buf[1];

		// Any non-TI-80 packet has a length; TI-80 data packets also have a length
		if (*host != DBUS_MID_TI80_PC || *cmd == DBUS_CMD_XDP)
		{
			ret = ticables_cable_recv(handle->cable, buf, 2);
			if (!ret)
			{
				*length = buf[0] | ((uint16_t)buf[1] << 8);
			}
		}
		else
		{
			*length = 0;
		}
	}

	return ret;
}
开发者ID:TC01,项目名称:tilibs,代码行数:34,代码来源:dbus_pkt.c

示例12: cman_poll_quorum_device

int cman_poll_quorum_device(cman_handle_t handle, int isavailable)
{
	struct cman_handle *h = (struct cman_handle *)handle;
	VALIDATE_HANDLE(h);

	return info_call(h, CMAN_CMD_POLL_QUORUMDEV, &isavailable, sizeof(int), NULL, 0);
}
开发者ID:smintz,项目名称:cluster,代码行数:7,代码来源:libcman.c

示例13: dusb_cmd_s_dirlist_request

// 0x0009: request directory listing
TIEXPORT3 int TICALL dusb_cmd_s_dirlist_request(CalcHandle *handle, unsigned int naids, const uint16_t *aids)
{
	DUSBVirtualPacket* pkt;
	unsigned int i;
	unsigned int j = 0;
	int retval = 0;

	VALIDATE_HANDLE(handle);
	VALIDATE_ATTRS(naids, aids);

	pkt = dusb_vtl_pkt_new_ex(handle, 4 + 2 * naids + 7, DUSB_VPKT_DIR_REQ, dusb_vtl_pkt_alloc_data(4 + 2 * naids + 7));

	pkt->data[j++] = MSB(MSW(naids));
	pkt->data[j++] = LSB(MSW(naids));
	pkt->data[j++] = MSB(LSW(naids));
	pkt->data[j++] = LSB(LSW(naids));

	for (i = 0; i < naids; i++)
	{
		pkt->data[j++] = MSB(aids[i]);
		pkt->data[j++] = LSB(aids[i]);
	}

	pkt->data[j++] = 0x00; pkt->data[j++] = 0x01;
	pkt->data[j++] = 0x00; pkt->data[j++] = 0x01;
	pkt->data[j++] = 0x00; pkt->data[j++] = 0x01;
	pkt->data[j++] = 0x01;

	retval = dusb_send_data(handle, pkt);

	dusb_vtl_pkt_del(handle, pkt);
	ticalcs_info("   naids=%i", naids);

	return retval;
}
开发者ID:TC01,项目名称:tilibs,代码行数:36,代码来源:dusb_cmd.c

示例14: dusb_recv

TIEXPORT3 int TICALL dusb_recv(CalcHandle* handle, DUSBRawPacket* pkt)
{
	uint8_t buf[5];
	int ret;

	VALIDATE_HANDLE(handle);
	VALIDATE_NONNULL(pkt);

	// Any packet has always an header of 5 bytes (size & type)
	ticables_progress_reset(handle->cable);
	ret = ticables_cable_recv(handle->cable, buf, 5);
	while (!ret)
	{

		pkt->size = buf[3] | (((uint32_t)buf[2]) << 8) | (((uint32_t)buf[1]) << 16) | (((uint32_t)buf[0]) << 24);
		pkt->type = buf[4];

		if (   (handle->model == CALC_TI84P_USB || handle->model == CALC_TI84PC_USB || handle->model == CALC_TI82A_USB || handle->model == CALC_TI84PT_USB)
		    && pkt->size > 250)
		{
			ticalcs_warning("Raw packet is unexpectedly large: %u bytes", pkt->size);
		}
		else if (   (handle->model == CALC_TI83PCE_USB || handle->model == CALC_TI84PCE_USB)
		         && pkt->size > 1018)
		{
			ticalcs_warning("Raw packet is unexpectedly large: %u bytes", pkt->size);
		}
		else if (handle->model == CALC_TI89T_USB)
		{
			// Fall through.
		}
		// else do nothing for now.

		if (pkt->size > sizeof(pkt->data))
		{
			ticalcs_critical("Raw packet is too large: %u bytes", pkt->size);
			ret = ERR_INVALID_PACKET;
			break;
		}

		//printf("dusb_send: pkt->size=%d\n", pkt->size);
		// Next, follows data
		ret = ticables_cable_recv(handle->cable, pkt->data, pkt->size);
		if (!ret)
		{
			if (pkt->size >= 128)
			{
				ticables_progress_get(handle->cable, NULL, NULL, &handle->updat->rate);
			}

			if (handle->updat->cancel)
			{
				ret = ERR_ABORT;
			}
		}
		break;
	}

	return ret;
}
开发者ID:TC01,项目名称:tilibs,代码行数:60,代码来源:dusb_rpkt.c

示例15: cman_unregister_quorum_device

int cman_unregister_quorum_device(cman_handle_t handle)
{
	struct cman_handle *h = (struct cman_handle *)handle;
	VALIDATE_HANDLE(h);

	return info_call(h, CMAN_CMD_UNREG_QUORUMDEV, NULL, 0, NULL, 0);
}
开发者ID:smintz,项目名称:cluster,代码行数:7,代码来源:libcman.c


注:本文中的VALIDATE_HANDLE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。