예제 #1
0
int vt_execute(VT_CONN *conn, const char *stmt_str, unsigned long length, int stream) {
  mysql_thread_init();
  clear_result(conn);

  if(mysql_real_query(conn->mysql, stmt_str, length) != 0) {
    return 1;
  }

  if(stream) {
    conn->result = mysql_use_result(conn->mysql);
  } else {
    conn->result = mysql_store_result(conn->mysql);
    conn->affected_rows = mysql_affected_rows(conn->mysql);
  }
  if(conn->result == 0) {
    if(mysql_errno(conn->mysql) != 0) {
      return 1;
    }
    conn->insert_id = mysql_insert_id(conn->mysql);
  } else {
    conn->num_fields = mysql_num_fields(conn->result);
    conn->fields =  mysql_fetch_fields(conn->result);
  }
  return 0;
}
예제 #2
0
void LogCompStr::clear() {
  FOOTMARK();
  clear_read();
  clear_comp();
  clear_result();
  clear_extra();
  fix();
}
예제 #3
0
void CCalcEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	//TRACE("xxxx0 OnKeyD: sel = %x\r\n", GetSel());
	in_edit_ = true;
	ASSERT(pp_ != NULL && pp_->IsVisible());

	// Clear any result (unless arrows etc pressed)
	clear_result((nFlags & 0x100) == 0 && isprint(nChar));

	// If editing an integer then make allowances for separator char
	if (pp_->state_ == CALCINTLIT)
	{
		CString ss;                         // Text from the window (edit control)
		int start, end;                     // Current selection in the edit control

		// Set selection so that arrows/Del work OK in presence of separator chars
		GetWindowText(ss);
		GetSel(start, end);

		char sep_char = ' ';
		if (pp_->radix_ == 10) sep_char = theApp.dec_sep_char_;

		// If no selection and character to delete is separator ...
		if (nChar == VK_DELETE && start == end && start < ss.GetLength() - 1 && ss[start+1] == sep_char)
		{
			// Set selection so that the separator and following digit is deleted
			SetSel(start, start+2);
		}
		else if (nChar == VK_LEFT && start == end && start > 0 && ss[start-1] == sep_char)
		{
			// Move cursor back one so we skip over the separator (else add_sep below makes the caret stuck)
			SetSel(start-1, start-1);
		}
		else if (nChar == VK_RIGHT && start == end && start < ss.GetLength() - 1 && ss[start+1] == sep_char)
		{
			// Move cursor back one so we skip over the separator (else add_sep below makes the caret stuck)
			SetSel(start+1, start+1);
		}
	}

	CEdit::OnKeyDown(nChar, nRepCnt, nFlags);

	if (nChar == VK_DELETE)
	{
		// This is handled similarly to OnChar since Del key changes the text
		get();
		pp_->state_ = update_value(false);
		pp_->check_for_error();
		add_sep();
		get();
		pp_->set_right();
		pp_->inedit(km_user_str);
		pp_->ctl_calc_bits_.RedrawWindow();
	}
	in_edit_ = false;
	//TRACE("xxxx1 OnKeyD: sel = %x\r\n", GetSel());
}
예제 #4
0
파일: mysql.c 프로젝트: EQ4/samplecat
static Sample*
mysql__search_iter_next_(unsigned long** lengths)
{
	if(!search_result) return NULL;

	clear_result();

	MYSQL_ROW row = mysql_fetch_row(search_result);
	if(!row) return NULL;

	*lengths = mysql_fetch_lengths(search_result); //free? 

	GdkPixbuf* pixbuf = NULL;
	if(row[MYSQL_PIXBUF]){
		pixbuf = blob_to_pixbuf((guint8*)row[MYSQL_PIXBUF], (*lengths)[MYSQL_PIXBUF]);
	}

	int get_int(MYSQL_ROW row, int i)
	{
		return row[i] ? atoi(row[i]) : 0;
	}

	float get_float(MYSQL_ROW row, int i)
	{
		return row[i] ? atof(row[i]) : 0.0;
	}

	static char full_path[PATH_MAX];
	if (row[MYSQL_FULL_PATH] && *(row[MYSQL_FULL_PATH])) {
		strcpy(full_path, row[MYSQL_FULL_PATH]);
	} else {
		snprintf(full_path, PATH_MAX, "%s/%s", row[MYSQL_DIR], row[MYSQL_NAME]);
		full_path[PATH_MAX-1]='\0';
	}

	result.id          = atoi(row[MYSQL_ID]);
	result.full_path   = full_path;
	result.name        = row[MYSQL_NAME];
	result.sample_dir  = row[MYSQL_DIR];
	result.keywords    = row[MYSQL_KEYWORDS];
	result.length      = get_int(row, MYSQL_LENGTH);
	result.sample_rate = get_int(row, MYSQL_SAMPLERATE);
	result.channels    = get_int(row, MYSQL_CHANNELS);
	result.peaklevel   = get_float(row, MYSQL_PEAKLEVEL);
	result.overview    = pixbuf;
	result.notes       = row[MYSQL_NOTES];
	result.ebur        = row[MYSQL_EBUR];
	result.colour_index= get_int(row, MYSQL_COLOUR);
	result.mimetype    = row[MYSQL_MIMETYPE];
	result.online      = get_int(row, MYSQL_ONLINE);
	result.mtime       = get_int(row, MYSQL_MTIME);
	result.bit_depth   = get_int(row, MYSQL_BITDEPTH);
	result.bit_rate    = get_int(row, MYSQL_BITRATE);
	result.frames      = get_int(row, MYSQL_FRAMES); 
	sample_set_metadata(&result, row[MYSQL_METADATA]);
	return &result;
}
예제 #5
0
void CCalcEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	//TRACE("xxxx0 OnChar: sel = %x\r\n", GetSel());
	in_edit_ = true;
	ASSERT(pp_ != NULL && pp_->IsVisible());
	clear_result();					// Clear text if previous result is displayed

	// If editing an integer then make allowances for separator char
	if (pp_->state_ == CALCINTLIT)
	{
		CString ss;                         // Text from the window (edit control)
		int start, end;                     // Current selection in the edit control

		// Set selection so that arrows/Del work OK in presence of separator chars
		GetWindowText(ss);
		GetSel(start, end);

		char sep_char = ' ';
		if (pp_->radix_ == 10) sep_char = theApp.dec_sep_char_;

		if (nChar == '\b' && start > 1 && start == end && ss[start-1] == sep_char)
		{
			// If deleting 1st char of group then also delete preceding sep_char
			SetSel(start-2, end);
		}
	}
	
	CEdit::OnChar(nChar, nRepCnt, nFlags);

	// Update internals (state_, current_ etc) from the current edit box text
	get();
	pp_->state_ = update_value(false);
	pp_->check_for_error();
	add_sep();        // fix display of integers in edit box

	// Update the expression to be displayed
	get();
	pp_->set_right();

	pp_->inedit(km_user_str);
	pp_->ctl_calc_bits_.RedrawWindow();
	in_edit_ = false;
	//TRACE("xxxx1 OnChar: sel = %x\r\n", GetSel());
}
예제 #6
0
void vt_close_result(VT_CONN *conn) {
  MYSQL_RES *result;

  if(conn->result) {
    mysql_thread_init();
    mysql_free_result(conn->result);
    clear_result(conn);
  }
  // Ignore subsequent results if any. We only
  // return the first set of results for now.
  while(mysql_next_result(conn->mysql) == 0) {
    result = mysql_store_result(conn->mysql);
    if (result) {
      while(mysql_fetch_row(result)) {
      }
      mysql_free_result(result);
    }
  }
}