static int send_var (CalcHandle* handle, CalcMode mode, FileContent* content) { uint8_t status; gchar *path; int ret; VarEntry * entry; update_->cnt2 = 0; update_->max2 = 1; update_->pbar(); entry = content->entries[0]; if (!ticalcs_validate_varentry(entry)) { ticalcs_critical("%s: skipping invalid content entry #0", __FUNCTION__); return ERR_INVALID_PARAMETER; } if (entry->action == ACT_SKIP) { return 0; } //if (!strlen(entry->folder)) //{ // return ERR_ABORT; //} ret = nsp_session_open(handle, NSP_SID_FILE_MGMT); if (ret) { return ret; } path = build_path(handle->model, entry); ticonv_varname_to_utf8_sn(handle->model, path, update_->text, sizeof(update_->text), entry->type); update_label(); ret = nsp_cmd_s_put_file(handle, path, entry->size); g_free(path); if (!ret) { ret = nsp_cmd_r_put_file(handle); if (!ret) { ret = nsp_cmd_s_file_contents(handle, entry->size, entry->data); if (!ret) { ret = nsp_cmd_r_status(handle, &status); } } } DO_CLOSE_SESSION(handle); return ret; }
static int send_var (CalcHandle* handle, CalcMode mode, FileContent* content) { char *utf8; uint8_t status; const char * dot_if_any = "."; update_->cnt2 = 0; update_->max2 = 1; update_->pbar(); { VarEntry *ve = content->entries[0]; gchar *path; int err; if(ve->action == ACT_SKIP) return 0; if(!strlen(ve->folder)) return ERR_ABORT; TRYF(nsp_session_open(handle, SID_FILE_MGMT)); // Don't add a dot if this file type is unknown. if (ve->type >= NSP_MAXTYPES) dot_if_any = ""; path = g_strconcat("/", ve->folder, "/", ve->name, dot_if_any, tifiles_vartype2fext(handle->model, ve->type), NULL); utf8 = ticonv_varname_to_utf8(handle->model, path, ve->type); g_snprintf(update_->text, sizeof(update_->text), "%s", utf8); g_free(utf8); update_label(); err = nsp_cmd_s_put_file(handle, path, ve->size); g_free(path); if (err) { return err; } TRYF(nsp_cmd_r_put_file(handle)); TRYF(nsp_cmd_s_file_contents(handle, ve->size, ve->data)); TRYF(nsp_cmd_r_status(handle, &status)); TRYF(nsp_session_close(handle)); } return 0; }