Exemple #1
0
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	char varname[9] = { 0 };

	g_snprintf(update_->text, sizeof(update_->text), _("Waiting for backup..."));
    update_label();

	content->model = CALC_TI86;
	strcpy(content->comment, tifiles_comment_set_backup());

    TRYF(ti85_recv_VAR(&(content->data_length1), &content->type, varname));
    content->data_length2 = (uint8_t)varname[0] | ((uint8_t)varname[1] << 8);
    content->data_length3 = (uint8_t)varname[2] | ((uint8_t)varname[3] << 8);
    content->data_length4 = (uint8_t)varname[4] | ((uint8_t)varname[5] << 8);
    TRYF(ti85_send_ACK());

    TRYF(ti85_send_CTS());
    TRYF(ti85_recv_ACK(NULL));

    strcpy(update_->text, "");
	update_label();

	update_->cnt2 = 0;
	update_->max2 = 4;
	update_->pbar();

    content->data_part1 = tifiles_ve_alloc_data(65536);
    TRYF(ti85_recv_XDP(&content->data_length1, content->data_part1));
    TRYF(ti85_send_ACK());
    update_->cnt2++;
	update_->pbar();

    content->data_part2 = tifiles_ve_alloc_data(65536);
    TRYF(ti85_recv_XDP(&content->data_length2, content->data_part2));
    TRYF(ti85_send_ACK());
    update_->cnt2++;
	update_->pbar();

    if (content->data_length3) 
	{
      content->data_part3 = tifiles_ve_alloc_data(65536);
      TRYF(ti85_recv_XDP(&content->data_length3, content->data_part3));
      TRYF(ti85_send_ACK());
    } else
      content->data_part3 = NULL;
    update_->cnt2++;
	update_->pbar();

    content->data_part4 = tifiles_ve_alloc_data(65536);
    TRYF(ti85_recv_XDP(&content->data_length4, content->data_part4));
    TRYF(ti85_send_ACK());
    update_->cnt2++;
	update_->pbar();

	return 0;
}
Exemple #2
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
	char *path;
	uint8_t *data = NULL;
	VarEntry *ve;
	char *utf8;
	int err;
	const char * dot_if_any = ".";

	TRYF(nsp_session_open(handle, SID_FILE_MGMT));

	// Don't add a dot if this file type is unknown.
	if (vr->type >= NSP_MAXTYPES)
		dot_if_any = "";

	path = g_strconcat("/", vr->folder, "/", vr->name, dot_if_any, 
		tifiles_vartype2fext(handle->model, vr->type), NULL);
	utf8 = ticonv_varname_to_utf8(handle->model, path, vr->type);
	g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
	update_label();

	err = nsp_cmd_s_get_file(handle, path);
	g_free(path);
	if (err)
	{
		return err;
	}
	TRYF(nsp_cmd_r_get_file(handle, &(vr->size)));

	TRYF(nsp_cmd_s_file_ok(handle));
	if (vr->size)
		TRYF(nsp_cmd_r_file_contents(handle, &(vr->size), &data));
	TRYF(nsp_cmd_s_status(handle, ERR_OK));

	content->model = handle->model;
	strcpy(content->comment, tifiles_comment_set_single());
	content->num_entries = 1;

	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	ve->data = tifiles_ve_alloc_data(ve->size);
	if (data && ve->data)
	{
		memcpy(ve->data, data, ve->size);
	}
	g_free(data);

	// XXX don't check the result of this call, to enable reception of variables from Nspires running OS >= 1.7.
	// Those versions send a martian packet:
	// * a src port never seen before in the conversation;
	// * an improper dest port;
	// * a 1-byte payload containing 02 (i.e. an invalid address for the next packet).
	// * .ack = 0x00 (instead of 0x0A).
	nsp_session_close(handle);

	return 0;
}
Exemple #3
0
static int		recv_cert	(CalcHandle* handle, FlashContent* content)
{
	int ret;
	int i;
	uint8_t buf[256];

	ticalcs_strlcpy(handle->updat->text, _("Receiving certificate"), sizeof(handle->updat->text));
	ticalcs_update_label(handle);

	content->model = handle->model;
	content->name[0] = 0;
	content->data_type = TI83p_CERT;
	content->device_type = 0x73;
	content->num_pages = 0;
	content->data_part = (uint8_t *)tifiles_ve_alloc_data(2 * 1024 * 1024);	// 2MB max

	ret = SEND_REQ2(handle, 0x00, TI83p_GETCERT, "\0\0\0\0\0\0\0", 0x00);
	if (!ret)
	{
		ret = RECV_ACK(handle, NULL);
		if (!ret)
		{
			ret = ticables_cable_recv(handle->cable, buf, 4);	//VAR w/ no header
			if (!ret)
			{
				ticalcs_info(" TI->PC: VAR");
				ret = SEND_ACK(handle);

				for (i = 0, content->data_length = 0; !ret; i++)
				{
					uint16_t block_size;

					ret = SEND_CTS(handle);
					if (!ret)
					{
						ret = RECV_ACK(handle, NULL);
						if (!ret)
						{
							ret = RECV_XDP(handle, &block_size, content->data_part);
							if (!ret)
							{
								ret = SEND_ACK(handle);
								if (!ret)
								{
									content->data_length += block_size;

									handle->updat->cnt2 += block_size;
									ticalcs_update_pbar(handle);
								}
							}
						}
					}
				}
			}
		}
	}

	return ret;
}
Exemple #4
0
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	char varname[9] = { 0 };
	uint16_t unused;

	content->model = CALC_TI83;
	strcpy(content->comment, tifiles_comment_set_backup());

	TRYF(ti82_send_REQ(handle, 0x0000, TI83_BKUP, ""));
	TRYF(ti82_recv_ACK(handle, &unused));

	TRYF(ti82_recv_VAR(handle, &(content->data_length1), &content->type, varname));
	content->data_length2 = (uint16_t)varname[0] | (((uint16_t)(varname[1])) << 8);
	content->data_length3 = (uint16_t)varname[2] | (((uint16_t)(varname[3])) << 8);
	content->mem_address  = (uint16_t)varname[4] | (((uint16_t)(varname[5])) << 8);
	TRYF(ti82_send_ACK(handle));

	TRYF(ti82_send_CTS(handle));
	TRYF(ti82_recv_ACK(handle, NULL));

	update_->cnt2 = 0;
	update_->max2 = 3;

	content->data_part1 = tifiles_ve_alloc_data(65536);
	TRYF(ti82_recv_XDP(handle, &content->data_length1, content->data_part1));
	TRYF(ti82_send_ACK(handle));
	update_->cnt2++;
	update_->pbar();

	content->data_part2 = tifiles_ve_alloc_data(65536);
	TRYF(ti82_recv_XDP(handle, &content->data_length2, content->data_part2));
	TRYF(ti82_send_ACK(handle));
	update_->cnt2++;
	update_->pbar();

	content->data_part3 = tifiles_ve_alloc_data(65536);
	TRYF(ti82_recv_XDP(handle, &content->data_length3, content->data_part3));
	TRYF(ti82_send_ACK(handle));
	update_->cnt2++;
	update_->pbar();

	content->data_part4 = NULL;

	return 0;
}
Exemple #5
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
	uint16_t status;
	VarEntry *ve;
	uint32_t unused;
	char varname[18];
	char *utf8;

	content->model = CALC_TI92;
	strcpy(content->comment, tifiles_comment_set_single());
	content->num_entries = 1;
	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	tifiles_build_fullname(handle->model, varname, vr->folder, vr->name);

	utf8 = ticonv_varname_to_utf8(handle->model, varname, vr->type);
	g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
	update_label();

	TRYF(ti92_send_REQ(0, vr->type, varname));
	TRYF(ti92_recv_ACK(&status));
	if (status != 0)
		return ERR_MISSING_VAR;

	TRYF(ti92_recv_VAR(&ve->size, &ve->type, ve->name));
	TRYF(ti92_send_ACK());

	TRYF(ti92_send_CTS());
	TRYF(ti92_recv_ACK(NULL));

	ve->data = tifiles_ve_alloc_data(ve->size + 4);
	TRYF(ti92_recv_XDP(&unused, ve->data));
	memmove(ve->data, ve->data + 4, ve->size);
	TRYF(ti92_send_ACK());

	TRYF(ti92_recv_EOT());
	TRYF(ti92_send_ACK());

	return 0;
}
Exemple #6
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
	uint16_t aids[] = { AID_ARCHIVED, AID_VAR_VERSION, AID_VAR_SIZE };
	const int naids = sizeof(aids) / sizeof(uint16_t);
	CalcAttr **attrs;
	const int nattrs = 1;
	char fldname[40], varname[40];
	uint8_t *data;
	VarEntry *ve;
	char *utf8;

	utf8 = ticonv_varname_to_utf8(handle->model, vr->name, vr->type);
	g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
	update_label();

	attrs = ca_new_array(nattrs);
	attrs[0] = ca_new(AID_VAR_TYPE2, 4);
	attrs[0]->data[0] = 0xF0; attrs[0]->data[1] = 0x07;
	attrs[0]->data[2] = 0x00; attrs[0]->data[3] = vr->type;

	TRYF(cmd_s_var_request(handle,"",vr->name,naids,aids,nattrs,CA(attrs)));
	ca_del_array(nattrs, attrs);
	attrs = ca_new_array(naids);
	TRYF(cmd_r_var_header(handle, fldname, varname, attrs));
	TRYF(cmd_r_var_content(handle, NULL, &data));

	content->model = handle->model;
	strcpy(content->comment, tifiles_comment_set_single());
	content->num_entries = 1;

	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	ve->size = GINT32_FROM_BE(*((uint32_t *)(attrs[2]->data)));
	ve->data = tifiles_ve_alloc_data(ve->size);
	memcpy(ve->data, data, ve->size);

	g_free(data);
	ca_del_array(naids, attrs);
	return 0;
}
Exemple #7
0
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	uint32_t block_size;
	int block, err;
	uint32_t unused;
	uint16_t unused2;
	uint8_t *ptr;

	TRYF(ti92_send_REQ(0, TI92_BKUP, "main\\backup"));
	TRYF(ti92_recv_ACK(&unused2));

	content->model = CALC_TI92;
	strcpy(content->comment, tifiles_comment_set_backup());
	content->data_part = tifiles_ve_alloc_data(128 * 1024);
	content->type = TI92_BKUP;
	content->data_length = 0;

	for (block = 0;; block++) 
	{
		g_snprintf(update_->text, sizeof(update_->text), _("Block #%2i"), block);
		update_label();
    
		err = ti92_recv_VAR(&block_size, &content->type, content->rom_version);
		TRYF(ti92_send_ACK());

		if (err == ERR_EOT)
			break;
		TRYF(err);

		TRYF(ti92_send_CTS());
		TRYF(ti92_recv_ACK(NULL));

		ptr = content->data_part + content->data_length;
		TRYF(ti92_recv_XDP(&unused, ptr));
		memmove(ptr, ptr + 4, block_size);
		TRYF(ti92_send_ACK());
		content->data_length += block_size;
	}

	return 0;
}
Exemple #8
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
  uint16_t unused;
  VarEntry *ve;
  char *utf8;
  uint16_t ve_size;

	content->model = CALC_TI83;
	strcpy(content->comment, tifiles_comment_set_single());
	content->num_entries = 1;
	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
	g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
	update_label();

	// silent request
	TRYF(ti82_send_REQ(handle, (uint16_t)vr->size, vr->type, vr->name));
	TRYF(ti82_recv_ACK(handle, &unused));

	TRYF(ti82_recv_VAR(handle, &ve_size, &ve->type, ve->name));
	ve->size = ve_size;
	TRYF(ti82_send_ACK(handle));

	TRYF(ti82_send_CTS(handle));
	TRYF(ti82_recv_ACK(handle, NULL));

	ve->data = tifiles_ve_alloc_data(ve->size);
	TRYF(ti82_recv_XDP(handle, &ve_size, ve->data));
	ve->size = ve_size;
	TRYF(ti82_send_ACK(handle));

	return 0;
}
Exemple #9
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
	char *path;
	int ret;

	ret = nsp_session_open(handle, NSP_SID_FILE_MGMT);
	if (ret)
	{
		return ret;
	}

	path = build_path(handle->model, vr);
	ticonv_varname_to_utf8_sn(handle->model, path, update_->text, sizeof(update_->text), vr->type);
	update_label();

	ret = nsp_cmd_s_get_file(handle, path);
	g_free(path);
	if (!ret)
	{
		ret = nsp_cmd_r_get_file(handle, &(vr->size));
		if (!ret)
		{
			ret = nsp_cmd_s_file_ok(handle);
			if (!ret)
			{
				uint8_t *data = NULL;

				if (vr->size)
				{
					ret = nsp_cmd_r_file_contents(handle, &(vr->size), &data);
				}
				if (!ret)
				{
					ret = nsp_cmd_s_status(handle, NSP_ERR_OK);
					if (!ret)
					{
						VarEntry *ve;

						content->model = handle->model;
						ticalcs_strlcpy(content->comment, tifiles_comment_set_single(), sizeof(content->comment));
						content->num_entries = 1;

						content->entries = tifiles_ve_create_array(1);
						ve = content->entries[0] = tifiles_ve_create();
						memcpy(ve, vr, sizeof(VarEntry));

						ve->data = tifiles_ve_alloc_data(ve->size);
						if (data && ve->data)
						{
							memcpy(ve->data, data, ve->size);
						}
					}
					g_free(data);
				}
			}
		}
	}

	// Close session at the end.
	// XXX don't check the result of this call, to enable reception of variables from Nspires running OS >= 1.7.
	// Those versions send a martian packet:
	// * a src port never seen before in the conversation;
	// * an improper dest port;
	// * a 1-byte payload containing 02 (i.e. an invalid address for the next packet).
	// * .ack = 0x00 (instead of 0x0A).
	nsp_session_close(handle);

	return ret;
}
Exemple #10
0
int main(int argc, char **argv)
{
    void * ptr;

    tifiles_library_init();

    PRINTF(tifiles_error_get, INT, -1, NULL);
    PRINTF(tifiles_error_free, INT, NULL);
    PRINTF(tifiles_model_to_string, STR, -1);
    PRINTF(tifiles_string_to_model, INT, NULL);
    PRINTF(tifiles_attribute_to_string, STR, -1);
    PRINTF(tifiles_string_to_attribute, INT, NULL);
    PRINTF(tifiles_class_to_string, STR, -1);
    PRINTF(tifiles_string_to_class, INT, NULL);
    PRINTF(tifiles_fext_of_group, STR, -1);
    PRINTF(tifiles_fext_of_backup, STR, -1);

    PRINTF(tifiles_fext_of_flash_app, STR, -1);
    PRINTF(tifiles_fext_of_flash_os, STR, -1);
    PRINTF(tifiles_fext_of_certif, STR, -1);
    PRINTF(tifiles_fext_get, STR, NULL);
    ptr = tifiles_fext_dup(NULL);
    PRINTF(, PTR, ptr);
    tifiles_fext_free(ptr);
    PRINTFVOID(tifiles_fext_free, NULL);
    PRINTF(tifiles_file_is_ti, INT, NULL);
    PRINTF(tifiles_file_is_single, INT, NULL);
    PRINTF(tifiles_file_is_group, INT, NULL);
    PRINTF(tifiles_file_is_regular, INT, NULL);

    PRINTF(tifiles_file_is_backup, INT, NULL);
    PRINTF(tifiles_file_is_os, INT, NULL);
    PRINTF(tifiles_file_is_app, INT, NULL);
    PRINTF(tifiles_file_is_tib, INT, NULL);
    PRINTF(tifiles_file_is_flash, INT, NULL);
    PRINTF(tifiles_file_is_tigroup, INT, NULL);
    PRINTF(tifiles_file_is_tno, INT, NULL);
    PRINTF(tifiles_file_has_ti_header, INT, NULL);
    PRINTF(tifiles_file_has_tib_header, INT, NULL);
    PRINTF(tifiles_file_has_tig_header, INT, NULL);

    PRINTF(tifiles_file_has_tifl_header, INT, NULL, (void *)0x12345678, (void *)0x12345678);
    PRINTF(tifiles_file_has_tno_header, INT, NULL);
    PRINTF(tifiles_model_to_dev_type, INT, -1);
    PRINTF(tifiles_file_test, INT, NULL, -1, -1);
    PRINTF(tifiles_file_get_model, INT, NULL);
    PRINTF(tifiles_file_get_class, INT, NULL);
    PRINTF(tifiles_file_get_type, STR, NULL);
    PRINTF(tifiles_file_get_icon, STR, NULL);
    PRINTF(tifiles_vartype2string, STR, -1, -1);
    PRINTF(tifiles_string2vartype, INT, -1, NULL);

    PRINTF(tifiles_vartype2fext, STR, -1, -1);
    PRINTF(tifiles_fext2vartype, INT, -1, NULL);
    PRINTF(tifiles_vartype2type, STR, -1, -1);
    PRINTF(tifiles_vartype2icon, STR, -1, -1);
    PRINTF(tifiles_calctype2signature, STR, -1);
    PRINTF(tifiles_signature2calctype, INT, NULL);
    PRINTF(tifiles_folder_type, INT, -1);
    PRINTF(tifiles_flash_type, INT, -1);
    PRINTF(tifiles_idlist_type, INT, -1);
    PRINTF(tifiles_calc_is_ti8x, INT, -1);

    PRINTF(tifiles_calc_is_ti9x, INT, -1);
    PRINTF(tifiles_calc_are_compat, INT, -1, -1);
    PRINTF(tifiles_has_folder, INT, -1);
    PRINTF(tifiles_is_flash, INT, -1);
    PRINTF(tifiles_has_backup, INT, -1);
    PRINTF(tifiles_checksum, INT, NULL, 1234567891);
    PRINTF(tifiles_hexdump, INT, NULL, 1);
    PRINTF(tifiles_get_varname, STR, NULL);
    PRINTF(tifiles_get_fldname, STR, NULL);
    PRINTF(tifiles_build_fullname, STR, -1, NULL, NULL, (void *)0x12345678);

    PRINTF(tifiles_build_fullname, STR, -1, (void *)0x12345678, NULL, NULL);
    PRINTF(tifiles_build_fullname, STR, -1, NULL, (void *)0x12345678, NULL);
    PRINTF(tifiles_build_filename, STR, -1, NULL);
    PRINTFVOID(tifiles_filename_free, NULL);
    ptr = tifiles_content_create_regular(-1);
    PRINTF(, PTR, ptr);
    tifiles_content_delete_regular(ptr);
    PRINTF(tifiles_content_delete_regular, INT, NULL);
    PRINTF(tifiles_file_read_regular, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_read_regular, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_write_regular, INT, NULL, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_write_regular, INT, NULL, (void *)0x12345678, NULL);

    PRINTF(tifiles_file_write_regular, INT, (void *)0x12345678, NULL, NULL);
    PRINTF(tifiles_file_display_regular, INT, NULL);
    ptr = tifiles_content_create_backup(-1);
    PRINTF(, PTR, ptr);
    tifiles_content_delete_backup(ptr);
    PRINTF(tifiles_content_delete_backup, INT, NULL);
    PRINTF(tifiles_file_read_backup, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_read_backup, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_write_backup, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_write_backup, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_display_backup, INT, NULL);
    ptr = tifiles_content_create_flash(-1);
    PRINTF(, PTR, ptr);
    tifiles_content_delete_flash(ptr);

    PRINTF(tifiles_file_read_flash, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_content_delete_flash, INT, NULL);
    PRINTF(tifiles_file_read_flash, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_write_flash, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_write_flash, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_write_flash2, INT, NULL, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_write_flash2, INT, (void *)0x12345678, NULL, NULL);
    PRINTF(tifiles_file_display_flash, INT, NULL);
    PRINTF(tifiles_content_dup_regular, PTR, NULL);
    PRINTF(tifiles_content_dup_flash, PTR, NULL);

    PRINTF(tifiles_file_display, INT, NULL);
    ptr = tifiles_content_create_group(0);
    PRINTF(, PTR, ptr);
    tifiles_content_delete_group(ptr);
    PRINTF(tifiles_content_delete_group, INT, NULL);
    PRINTF(tifiles_group_contents, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_group_contents, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_ungroup_content, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_ungroup_content, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_group_files, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_group_files, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_ungroup_file, INT, NULL, (void *)0x12345678);

    PRINTF(tifiles_content_add_entry, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_content_del_entry, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_group_add_file, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_group_add_file, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_group_del_file, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_group_del_file, INT, (void *)0x12345678, NULL);
    ptr = tifiles_content_create_tigroup(-1, -1);
    PRINTF(, PTR, ptr);
    tifiles_content_delete_tigroup(ptr);
    PRINTF(tifiles_content_delete_tigroup, INT, NULL);
    PRINTF(tifiles_file_read_tigroup, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_read_tigroup, INT, (void *)0x12345678, NULL);

    PRINTF(tifiles_file_write_tigroup, INT, NULL, (void *)0x12345678);
    PRINTF(tifiles_file_write_tigroup, INT, (void *)0x12345678, NULL);
    PRINTF(tifiles_file_display_tigroup, INT, NULL);
    PRINTF(tifiles_tigroup_contents, INT, NULL, (void *)0x12345678, NULL);
    PRINTF(tifiles_tigroup_contents, INT, (void *)0x12345678, NULL, NULL);
    PRINTF(tifiles_tigroup_contents, INT, NULL, NULL, NULL);
    PRINTF(tifiles_untigroup_content, INT, NULL, NULL, NULL);
    PRINTF(tifiles_untigroup_content, INT, NULL, NULL, NULL);
    PRINTF(tifiles_untigroup_content, INT, NULL, NULL, NULL);
    PRINTF(tifiles_tigroup_files, INT, NULL, NULL);

    PRINTF(tifiles_tigroup_files, INT, NULL, NULL);
    PRINTF(tifiles_untigroup_file, INT, NULL, NULL);
    PRINTF(tifiles_untigroup_file, INT, NULL, NULL);
    PRINTF(tifiles_content_add_te, INT, NULL, NULL);
    PRINTF(tifiles_content_add_te, INT, NULL, NULL);
    PRINTF(tifiles_content_del_te, INT, NULL, NULL);
    PRINTF(tifiles_content_del_te, INT, NULL, NULL);
    PRINTF(tifiles_tigroup_add_file, INT, NULL, NULL);
    PRINTF(tifiles_tigroup_add_file, INT, NULL, NULL);
    PRINTF(tifiles_tigroup_del_file, INT, NULL, NULL);

    PRINTF(tifiles_tigroup_del_file, INT, NULL, NULL);
    PRINTF(tifiles_te_create, PTR, NULL, -1, -1);
    PRINTF(tifiles_te_delete, INT, NULL);
    ptr = tifiles_te_create_array(0);
    PRINTF(, PTR, ptr);
    tifiles_te_delete_array(ptr);
    ptr = tifiles_te_resize_array(NULL, 0);
    PRINTF(, PTR, ptr);
    tifiles_te_delete_array(ptr);
    PRINTFVOID(tifiles_te_delete_array, NULL);
    PRINTF(tifiles_te_sizeof_array, INT, NULL);
    PRINTF(tifiles_comment_set_single, STR);
    PRINTF(tifiles_comment_set_group, STR);
    PRINTF(tifiles_comment_set_backup, STR);

    PRINTF(tifiles_comment_set_tigroup, STR);
    ptr = tifiles_ve_create();
    PRINTF(, PTR, ptr);
    tifiles_ve_delete(ptr);
    ptr = tifiles_ve_create_alloc_data(0);
    PRINTF(, PTR, ptr);
    tifiles_ve_delete(ptr);
    ptr = tifiles_ve_create_with_data(0);
    PRINTF(, PTR, ptr);
    tifiles_ve_delete(ptr);
    ptr = tifiles_ve_create_with_data2(0, NULL);
    PRINTF(, PTR, ptr);
    tifiles_ve_delete(ptr);
    PRINTFVOID(tifiles_ve_delete, NULL);
    ptr = tifiles_ve_alloc_data(0);
    PRINTF(, PTR, ptr);
    tifiles_ve_free_data(ptr);
    ptr = tifiles_ve_realloc_data(NULL, 1);
    PRINTF(, PTR, ptr);
    tifiles_ve_free_data(ptr);
    PRINTFVOID(tifiles_ve_free_data, NULL);
    PRINTF(tifiles_ve_copy, PTR, NULL, NULL);

    PRINTF(tifiles_ve_dup, PTR, NULL);
    ptr = tifiles_ve_create_array(0);
    PRINTF(, PTR, ptr);
    tifiles_ve_delete_array(ptr);
    ptr = tifiles_ve_resize_array(NULL, 0);
    PRINTF(, PTR, ptr);
    tifiles_ve_delete_array(ptr);
    PRINTFVOID(tifiles_ve_delete_array, NULL);
    ptr = tifiles_fp_create();
    PRINTF(, PTR, ptr);
    tifiles_fp_delete(ptr);
    ptr = tifiles_fp_create_alloc_data(0);
    PRINTF(, PTR, ptr);
    tifiles_fp_delete(ptr);
    ptr = tifiles_fp_create_with_data(0);
    PRINTF(, PTR, ptr);
    tifiles_fp_delete(ptr);
    ptr = tifiles_fp_create_with_data2(0, NULL);
    PRINTF(, PTR, ptr);
    tifiles_fp_delete(ptr);
    PRINTFVOID(tifiles_fp_delete, NULL);
    ptr = tifiles_fp_alloc_data(0);
    PRINTF(, PTR, ptr);
    tifiles_fp_free_data(ptr);

    ptr = tifiles_fp_realloc_data(NULL, 1);
    PRINTF(, PTR, ptr);
    tifiles_fp_free_data(ptr);
    PRINTFVOID(tifiles_fp_free_data, NULL);
    ptr = tifiles_fp_create_array(0);
    PRINTF(, PTR, ptr);
    tifiles_fp_delete_array(ptr);
    ptr = tifiles_fp_resize_array(NULL, 0);
    PRINTF(, PTR, ptr);
    tifiles_fp_delete_array(ptr);
    PRINTFVOID(tifiles_fp_delete_array, NULL);
    ptr = tifiles_create_table_of_entries(NULL, NULL);
    PRINTF(, PTR, ptr);
    tifiles_free_table_of_entries(ptr);
    PRINTFVOID(tifiles_free_table_of_entries, NULL);

    cert_functions_unit_test();

    tifiles_library_exit();

    return 0;
}
Exemple #11
0
static int		recv_var_ns	(CalcHandle* handle, CalcMode mode, FileContent* content, VarEntry** vr)
{
  int nvar = 0;
  int err = 0;
  char *utf8;
  uint16_t ve_size;

  g_snprintf(update_->text, sizeof(update_->text), _("Waiting for var(s)..."));
  update_label();

  content->model = CALC_TI82;

  for (nvar = 0;; nvar++) 
  {
    VarEntry *ve;

	content->entries = tifiles_ve_resize_array(content->entries, nvar+1);
    ve = content->entries[nvar] = tifiles_ve_create();

    do 
	{
      update_refresh();
      if (update_->cancel)
		return ERR_ABORT;

      err = ti82_recv_VAR(&ve_size, &(ve->type), ve->name);
      ve->size = ve_size;
    }
    while (err == ERROR_READ_TIMEOUT);

    TRYF(ti82_send_ACK());
    if (err == ERR_EOT) 
	  goto exit;
    TRYF(err);

    TRYF(ti82_send_CTS());
    TRYF(ti82_recv_ACK(NULL));

    utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
    g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
	g_free(utf8);
    update_label();

	ve->data = tifiles_ve_alloc_data(ve->size);
    TRYF(ti82_recv_XDP(&ve_size, ve->data));
    ve->size = ve_size;
    TRYF(ti82_send_ACK());
  }

exit:
  content->num_entries = nvar;
  if(nvar == 1)
  {
	strcpy(content->comment, tifiles_comment_set_single());
	*vr = tifiles_ve_dup(content->entries[0]);
  }
  else
  {
	strcpy(content->comment, tifiles_comment_set_group());
	*vr = NULL;
  }

  return 0;
}
Exemple #12
0
static int		recv_var_ns	(CalcHandle* handle, CalcMode mode, FileContent* content, VarEntry** vr)
{
	uint32_t unused;
	int nvar, err;
    char tipath[18];
    char *tiname;
	char *utf8;

	content->model = handle->model;

	// receive packets
	for(nvar = 1;; nvar++)
	{
		VarEntry *ve;

		content->entries = tifiles_ve_resize_array(content->entries, nvar+1);
		ve = content->entries[nvar-1] = tifiles_ve_create();;
		strcpy(ve->folder, "main");	

		err = ti92_recv_VAR(&ve->size, &ve->type, tipath);
		TRYF(ti92_send_ACK());

		if(err == ERR_EOT)	// end of transmission
			goto exit;
		else
			content->num_entries = nvar;

		// from Christian (TI can send varname or fldname/varname)
        if ((tiname = strchr(tipath, '\\')) != NULL) 
		{
			*tiname = '\0';
            strcpy(ve->folder, tipath);
            strcpy(ve->name, tiname + 1);
        }
        else 
		{
            strcpy(ve->folder, "main");
            strcpy(ve->name, tipath);
        }

		utf8 = ticonv_varname_to_utf8(handle->model, ve->name, ve->type);
		g_snprintf(update_->text, sizeof(update_->text), "%s", utf8);
		g_free(utf8);
		update_label();

		TRYF(ti92_send_CTS());
		TRYF(ti92_recv_ACK(NULL));

		ve->data = tifiles_ve_alloc_data(ve->size + 4);
		TRYF(ti92_recv_XDP(&unused, ve->data));
		memmove(ve->data, ve->data + 4, ve->size);
		TRYF(ti92_send_ACK());
	}

exit:
	nvar--;
	if(nvar > 1) 
		*vr = NULL;
	else
		*vr = tifiles_ve_dup(content->entries[0]);

	return 0;
}
Exemple #13
0
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	int ret;
	char varname[9];

	content->model = handle->model;
	ticalcs_strlcpy(content->comment, tifiles_comment_set_backup(), sizeof(content->comment));

	if (handle->model == CALC_TI83)
	{
		ret = SEND_REQ(handle, 0x0000, TI83_BKUP, "\0\0\0\0\0\0\0");
		if (!ret)
		{
			ret = RECV_ACK(handle, NULL);
		}
		if (ret)
		{
			return ret;
		}
	}
	else
	{
		ticalcs_strlcpy(update_->text, _("Waiting for backup..."), sizeof(update_->text));
		update_label();
	}

	varname[0] = 0;
	do
	{
		ret = RECV_VAR(handle, &(content->data_length1), &content->type, varname);
		if (ret)
		{
			break;
		}
		content->data_length2 = (uint8_t)varname[0] | (((uint16_t)(uint8_t)varname[1]) << 8);
		content->data_length3 = (uint8_t)varname[2] | (((uint16_t)(uint8_t)varname[3]) << 8);
		if (handle->model != CALC_TI86)
		{
			content->mem_address  = (uint8_t)varname[4] | (((uint16_t)(uint8_t)varname[5]) << 8);
		}
		else
		{
			content->data_length4 = (uint8_t)varname[4] | (((uint16_t)(uint8_t)varname[5]) << 8);
		}
		ret = SEND_ACK(handle);
		if (!ret)
		{
			ret = SEND_CTS(handle);
			if (!ret)
			{
				ret = RECV_ACK(handle, NULL);
			}
		}
		if (ret)
		{
			break;
		}

		update_->text[0] = 0;
		update_label();

		update_->cnt2 = 0;
		update_->max2 = (handle->model != CALC_TI86) ? 3 : 4;
		update_->pbar();

		content->data_part1 = tifiles_ve_alloc_data(65536);
		ret = RECV_XDP(handle, &content->data_length1, content->data_part1);
		if (!ret)
		{
			ret = SEND_ACK(handle);
		}
		if (ret)
		{
			break;
		}
		update_->cnt2++;
		update_->pbar();

		content->data_part2 = tifiles_ve_alloc_data(65536);
		ret = RECV_XDP(handle, &content->data_length2, content->data_part2);
		if (!ret)
		{
			ret = SEND_ACK(handle);
		}
		if (ret)
		{
			break;
		}
		update_->cnt2++;
		update_->pbar();

		if (content->data_length3)
		{
			content->data_part3 = tifiles_ve_alloc_data(65536);
			ret = RECV_XDP(handle, &content->data_length3, content->data_part3);
			if (!ret)
			{
				ret = SEND_ACK(handle);
			}
			if (ret)
			{
				break;
			}
		}
		else
		{
			content->data_part3 = NULL;
		}
		update_->cnt2++;
		update_->pbar();

		if (handle->model != CALC_TI86)
		{
			content->data_part4 = NULL;
		}
		else
		{
			content->data_part4 = tifiles_ve_alloc_data(65536);
			ret = RECV_XDP(handle, &content->data_length4, content->data_part4);
			if (!ret)
			{
				ret = SEND_ACK(handle);
			}
			if (ret)
			{
				break;
			}
			update_->cnt2++;
			update_->pbar();
		}
	} while(0);

	return ret;
}
Exemple #14
0
static int		recv_var_ns	(CalcHandle* handle, CalcMode mode, FileContent* content, VarEntry** vr)
{
	int nvar = 0;
	int ret = 0;
	uint16_t ve_size;

	ticalcs_strlcpy(update_->text, _("Waiting for var(s)..."), sizeof(update_->text));
	update_label();

	content->model = handle->model;
	content->num_entries = 0;

	for (nvar = 0;; nvar++)
	{
		VarEntry *ve = tifiles_ve_create();
		int ret2;

		do
		{
			update_refresh();
			if (update_->cancel)
			{
				ret = ERR_ABORT;
				goto error;
			}

			ret = RECV_VAR(handle, &ve_size, &(ve->type), ve->name);
			ve->size = ve_size;
		}
		while (ret == ERROR_READ_TIMEOUT);

		ret2 = SEND_ACK(handle);

		if (ret)
		{
			if (ret == ERR_EOT)	// end of transmission
			{
				ret = 0;
			}
			goto error;
		}
		if (ret2)
		{
			ret = ret2;
			goto error;
		}

		ret = SEND_CTS(handle);
		if (!ret)
		{
			ret = RECV_ACK(handle, NULL);
			if (!ret)
			{
				ticonv_varname_to_utf8_sn(handle->model, ve->name, update_->text, sizeof(update_->text), ve->type);
				update_label();

				ve->data = tifiles_ve_alloc_data(ve->size);
				ret = RECV_XDP(handle, &ve_size, ve->data);
				if (!ret)
				{
					ve->size = ve_size;
					ret = SEND_ACK(handle);
				}
			}
		}

		if (!ret)
		{
			tifiles_content_add_entry(content, ve);
		}
		else
		{
error:
			tifiles_ve_delete(ve);
			break;
		}
	}

	if (nvar == 1)
	{
		ticalcs_strlcpy(content->comment, tifiles_comment_set_single(), sizeof(content->comment));
		*vr = tifiles_ve_dup(content->entries[0]);
	}
	else
	{
		ticalcs_strlcpy(content->comment, tifiles_comment_set_group(), sizeof(content->comment));
		*vr = NULL;
	}

	return ret;
}
Exemple #15
0
static int		recv_var	(CalcHandle* handle, CalcMode mode, FileContent* content, VarRequest* vr)
{
	int ret;
	uint16_t unused;
	VarEntry *ve;
	uint16_t ve_size;

	content->model = handle->model;
	ticalcs_strlcpy(content->comment, tifiles_comment_set_single(), sizeof(content->comment));
	content->num_entries = 1;
	content->entries = tifiles_ve_create_array(1);
	ve = content->entries[0] = tifiles_ve_create();
	memcpy(ve, vr, sizeof(VarEntry));

	ticonv_varname_to_utf8_sn(handle->model, vr->name, update_->text, sizeof(update_->text), vr->type);
	update_label();

	do
	{
		// silent request
		ret = SEND_REQ(handle, (uint16_t)vr->size, vr->type, vr->name);
		if (!ret)
		{
			ret = RECV_ACK(handle, &unused);
			if (!ret)
			{
				ret = RECV_VAR(handle, &ve_size, &ve->type, ve->name);
			}
		}
		if (ret)
		{
			break;
		}

		ve->size = ve_size;

		ret = SEND_ACK(handle);
		if (!ret)
		{
			ret = SEND_CTS(handle);
			if (!ret)
			{
				ret = RECV_ACK(handle, NULL);
			}
		}
		if (ret)
		{
			break;
		}

		ve->data = tifiles_ve_alloc_data(ve->size);
		ret = RECV_XDP(handle, &ve_size, ve->data);
		if (!ret)
		{
			ve->size = ve_size;
			ret = SEND_ACK(handle);
		}
	} while(0);

	return ret;
}
Exemple #16
0
static int		recv_backup	(CalcHandle* handle, BackupContent* content)
{
	int ret;
	char varname[9];
	uint8_t attr, ver;

	content->model = handle->model;
	ticalcs_strlcpy(content->comment, tifiles_comment_set_backup(), sizeof(content->comment));

	varname[0] = 0;
	ret = SEND_REQ(handle, 0x0000, TI73_BKUP, "\0\0\0\0\0\0\0", 0x00, 0x00);
	if (!ret)
	{
		ret = RECV_ACK(handle, NULL);
	}
	if (ret)
	{
		return ret;
	}

	do
	{
		ret = RECV_VAR(handle, &content->data_length1, &content->type, varname, &attr, &ver);
		if (ret)
		{
			break;
		}

		content->data_length2 = (uint8_t)varname[0] | (((uint16_t)(uint8_t)varname[1]) << 8);
		content->data_length3 = (uint8_t)varname[2] | (((uint16_t)(uint8_t)varname[3]) << 8);
		content->mem_address  = (uint8_t)varname[4] | (((uint16_t)(uint8_t)varname[5]) << 8);
		content->version = ver;
		ret = SEND_ACK(handle);
		if (!ret)
		{
			ret = SEND_CTS(handle);
			if (!ret)
			{
				ret = RECV_ACK(handle, NULL);
			}
		}
		if (ret)
		{
			break;
		}

		handle->updat->cnt2 = 0;
		handle->updat->max2 = 3;
		ticalcs_update_pbar(handle);

		content->data_part1 = tifiles_ve_alloc_data(65536);
		ret = RECV_XDP(handle, &content->data_length1, content->data_part1);
		if (!ret)
		{
			ret = SEND_ACK(handle);
		}
		if (ret)
		{
			break;
		}
		handle->updat->cnt2++;
		ticalcs_update_pbar(handle);

		content->data_part2 = tifiles_ve_alloc_data(65536);
		ret = RECV_XDP(handle, &content->data_length2, content->data_part2);
		if (!ret)
		{
			ret = SEND_ACK(handle);
		}
		if (ret)
		{
			break;
		}
		handle->updat->cnt2++;
		ticalcs_update_pbar(handle);

		content->data_part3 = tifiles_ve_alloc_data(65536);
		ret = RECV_XDP(handle, &content->data_length3, content->data_part3);
		if (!ret)
		{
			ret = SEND_ACK(handle);
		}
		if (ret)
		{
			break;
		}
		handle->updat->cnt2++;
		ticalcs_update_pbar(handle);

		content->data_part4 = NULL;
	} while(0);

	return ret;
}