コード例 #1
0
ファイル: Switches.cpp プロジェクト: Alexpux/firebird
Switches::Switches(const in_sw_tab_t* table, FB_SIZE_T count, bool copy, bool minLength)
	: m_base(table), m_count(count), m_copy(copy), m_minLength(minLength),
	  m_table(0), m_opLengths(0)
{
	fb_assert(table && count > 1); // the last element is a terminator
	if (!table || count < 2)
		complain("Switches: invalid arguments for constructor");

	if (m_copy)
	{
		m_table = FB_NEW(*getDefaultMemoryPool()) in_sw_tab_t[m_count];
		for (FB_SIZE_T iter = 0; iter < m_count; ++iter)
			m_table[iter] = m_base[iter];
	}

	m_opLengths = FB_NEW(*getDefaultMemoryPool()) FB_SIZE_T[m_count];

	for (FB_SIZE_T iter = 0; iter < m_count; ++iter)
	{
		if (m_base[iter].in_sw_name)
		{
			m_opLengths[iter] = fb_strlen(m_base[iter].in_sw_name);
			fb_assert(m_opLengths[iter] > 0);
			fb_assert(!m_minLength || m_opLengths[iter] >= m_base[iter].in_sw_min_length);
		}
		else
			m_opLengths[iter] = 0;
	}
}
コード例 #2
0
ファイル: spit.cpp プロジェクト: mp-lee/core
static int write_header(const b_fil* fl_ptr,
						header_rec	hdr_rec,
						FILE_DESC	output_fl_desc,
						TEXT		header_str[])
{
/********************************************************************
**
**	w r i t e _ h e a d e r
**
*********************************************************************
**
**	Functional description:
**
**		writes out gsplit header record
**
**		assigns backup file name to header record file name array
**		calls conv_ntoc routine to convert numeric data to char data
**			and assigns to header record file number field
**		writes gsplit header record out to backup file
**
*********************************************************************
*/
	TEXT num_arr[5];

	SLONG ret_cd = conv_ntoc(fl_ptr->b_fil_number, num_arr);
	if (ret_cd == FB_FAILURE)
	{
		printf("gsplit could not convert numeric data to character data\n");
		return FB_FAILURE;
	}
	num_arr[sizeof(num_arr) - 1] = TERMINAL;
	SLONG pos = sizeof(hdr_rec.name) + sizeof(hdr_rec.date_time) + sizeof(hdr_rec.text1);
	ret_cd = set_hdr_str(header_str, num_arr, pos, sizeof(hdr_rec.num));

	const TEXT* file_name = fl_ptr->b_fil_name;
	pos = sizeof(hdr_rec.name) + sizeof(hdr_rec.date_time) +
		sizeof(hdr_rec.text1) + sizeof(hdr_rec.num) +
		sizeof(hdr_rec.text2) + sizeof(hdr_rec.total) + sizeof(hdr_rec.text3);
	ret_cd = set_hdr_str(header_str, file_name, pos, static_cast<SLONG>(strlen(file_name)));

	SLONG end, indx;
	SLONG write_cnt = write_platf(output_fl_desc, header_str, header_rec_len);
	switch (write_cnt)
	{
	case -1:					// write failed
		close_platf(output_fl_desc);
		return FB_FAILURE;

	default:
		end = pos + fb_strlen(file_name);
		for (indx = pos; indx < end; indx++)
			header_str[indx] = BLANK;
		return FB_SUCCESS;
	}
}