Example #1
0
tlibc_error_code_t tlibc_csv_reader_store(tlibc_csv_reader_t *self, const char *line, size_t line_size)
{
	tlibc_error_code_t ret = E_TLIBC_NOERROR;
	self->col = 0;

	line_open(self, line, line_size);
	if(self->cur_line == NULL)
	{
		line_close(self);
		goto error_ret;
	}
	return E_TLIBC_NOERROR;
error_ret:
	return ret;
}
Example #2
0
static void ssl_close(struct tty_struct *tty, struct file * filp)
{
	line_close(serial_lines, tty);
}
Example #3
0
void tlibc_csv_reader_close(tlibc_csv_reader_t *self)
{
	line_close(self);
}
Example #4
0
tlibc_error_code_t tlibc_csv_reader_init(tlibc_csv_reader_t *self, const char *top_line, size_t top_line_size)
{
	tlibc_error_code_t ret = E_TLIBC_NOERROR;
	size_t i;
	tlibc_abstract_reader_init(&self->super);

	self->super.enable_name = true;
	self->pre_read_uint32 = false;
	self->field = NULL;
	self->field_end = NULL;
	self->read_enum_name_once = false;
	self->pre_u32 = 0;

	self->super.read_vector_begin = tlibc_csv_read_vector_begin;
	self->super.read_vector_end = tlibc_csv_read_vector_end;
	self->super.read_vector_element_begin = tlibc_csv_read_vector_element_begin;
	self->super.read_vector_element_end = tlibc_csv_read_vector_element_end;
	self->super.read_field_begin = tlibc_csv_read_field_begin;	
	self->super.read_field_end = tlibc_csv_read_field_end;	
	self->super.read_enum_begin = tlibc_csv_read_enum_begin;

	self->super.read_int8 = tlibc_csv_read_int8;
	self->super.read_int16 = tlibc_csv_read_int16;
	self->super.read_int32 = tlibc_csv_read_int32;
	self->super.read_int64 = tlibc_csv_read_int64;

	self->super.read_uint8 = tlibc_csv_read_uint8;
	self->super.read_uint16 = tlibc_csv_read_uint16;
	self->super.read_uint32 = tlibc_csv_read_uint32;
	self->super.read_uint64 = tlibc_csv_read_uint64;

	self->super.read_double = tlibc_csv_read_double;
	self->super.read_char = tlibc_csv_read_char;
	self->super.read_bool = tlibc_csv_read_bool;
	self->super.read_string = tlibc_csv_read_string;



	self->top_line = NULL;
	self->top_line_size = 0;
	self->top_line_fields_num = 0;

	self->cur_line = NULL;
	self->cur_line_size = 0;
	self->cur_line_fields_num = 0;
	line_open(self, top_line, top_line_size);
	if(self->cur_line == NULL)
	{
		line_close(self);
		ret = E_TLIBC_NO_MEMORY;
		goto done;
	}
	self->top_line_size = self->cur_line_size;
	self->top_line = malloc(self->top_line_size);
	memcpy(self->top_line, self->cur_line, self->top_line_size);

	self->top_line_fields_num = self->cur_line_fields_num;
	for(i = 0; i < self->top_line_fields_num; ++i)
	{
		self->top_line_fields[i] = self->top_line + (self->cur_line_fields[i] - self->cur_line);
		self->field_index[i] = -1;
	}
	line_close(self);

done:
	return ret;
}