#endif
#ifndef _di_fl_fss_decrement_buffer_
- f_return_status fl_fss_decrement_buffer(const f_string_dynamic buffer, f_string_location *input, const f_string_length step) {
+ f_return_status fl_fss_decrement_buffer(const f_string_dynamic buffer, f_string_location *location, const f_string_length step) {
#ifndef _di_level_1_parameter_checking_
if (buffer.used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
if (step < 1) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- if (input->start < 1) return f_none_on_eos;
+ if (location->start < 1) return f_none_on_eos;
f_string_length i = 0;
unsigned short width = 0;
do {
- width = f_macro_utf_byte_width(buffer.string[input->start - 1]);
+ width = f_macro_utf_byte_width(buffer.string[location->start - 1]);
- if (width > input->start) {
+ if (width > location->start) {
if (width > 1) {
return f_status_set_error(f_incomplete_utf_on_eos);
}
}
i++;
- input->start -= width;
+ location->start -= width;
} while (i < step);
return f_none;
if (f_is_hexidecimal(buffer.string[i]) == f_true) {
i++;
- f_string_location location = f_string_location_initialize;
+ f_string_location length = f_string_location_initialize;
- location.start = i - 4;
- location.stop = i;
+ length.start = i - 4;
+ length.stop = i;
// 1: A possibly valid header type was found, now convert it into its proper format and save the header type
- f_string_to_hexidecimal(buffer.string, &header->type, location);
+ f_string_to_hexidecimal(buffer.string, &header->type, length);
// 2: At this point, we can still know the proper format for the file and still have a invalid header, handle accordingly
if (buffer.string[i] == f_fss_type_header_close) {
if (f_is_hexidecimal(buffer.string[i]) == f_true) {
i++;
- f_string_location location = f_string_location_initialize;
+ f_string_location length = f_string_location_initialize;
- location.start = i - 4;
- location.stop = i;
+ length.start = i - 4;
+ length.stop = i;
- f_string_to_hexidecimal(buffer.string, &header->type, location);
+ f_string_to_hexidecimal(buffer.string, &header->type, length);
header->length = i + 1;
f_status status = f_none;
f_string_dynamic buffer = f_string_dynamic_initialize;
- f_file_position location = f_file_position_initialize;
+ f_file_position length = f_file_position_initialize;
- // make sure we are in the proper location in the file
+ // make sure we are in the proper length in the file
{
int seek_result = f_macro_file_seek_begin(file->address, 0);
}
// 1: Prepare the buffer to handle a size of f_fss_max_header_length
- location.total_elements = f_fss_max_header_length;
+ length.total_elements = f_fss_max_header_length;
- f_macro_string_dynamic_adjust(status, buffer, location.total_elements + 1);
+ f_macro_string_dynamic_adjust(status, buffer, length.total_elements + 1);
if (f_status_is_error(status)) {
return status;
}
// 2: buffer the file
- status = f_file_read_at(file, &buffer, location);
+ status = f_file_read_at(file, &buffer, length);
if (f_status_is_error(status)) {
return status;
#endif // _di_fl_fss_identify_file_
#ifndef _di_fl_fss_increment_buffer_
- f_return_status fl_fss_increment_buffer(const f_string_dynamic buffer, f_string_location *input, const f_string_length step) {
+ f_return_status fl_fss_increment_buffer(const f_string_dynamic buffer, f_string_location *location, const f_string_length step) {
#ifndef _di_level_1_parameter_checking_
if (buffer.used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
if (step < 1) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
unsigned short width = 0;
do {
- width = f_macro_utf_byte_width(buffer.string[input->start]);
+ width = f_macro_utf_byte_width(buffer.string[location->start]);
- if (input->start + width > input->stop) {
+ if (location->start + width > location->stop) {
if (width > 1) {
return f_status_set_error(f_incomplete_utf_on_stop);
}
- input->start += width;
+ location->start += width;
return f_none_on_stop;
}
- else if (input->start + width >= buffer.used) {
+ else if (location->start + width >= buffer.used) {
if (width > 1) {
return f_status_set_error(f_incomplete_utf_on_eos);
}
- input->start += width;
+ location->start += width;
return f_none_on_eos;
}
i++;
- input->start += width;
+ location->start += width;
} while (i < step);
return f_none;
#endif // _di_fl_fss_increment_buffer_
#ifndef _di_fl_fss_is_graph_
- f_return_status fl_fss_is_graph(const f_string_dynamic buffer, const f_string_location input) {
+ f_return_status fl_fss_is_graph(const f_string_dynamic buffer, const f_string_location location) {
#ifndef _di_level_1_parameter_checking_
if (buffer.used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input.start < 0) return f_status_set_error(f_invalid_parameter);
- if (input.stop < input.start) return f_status_set_error(f_invalid_parameter);
- if (input.start >= buffer.used) return f_status_set_error(f_invalid_parameter);
+ if (location.start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location.stop < location.start) return f_status_set_error(f_invalid_parameter);
+ if (location.start >= buffer.used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- f_string_length max_width = (input.stop - input.start) + 1;
+ f_string_length max_width = (location.stop - location.start) + 1;
- if (max_width > buffer.used - input.start) {
- max_width = buffer.used - input.start;
+ if (max_width > buffer.used - location.start) {
+ max_width = buffer.used - location.start;
}
- return f_utf_is_graph(buffer.string + input.start, max_width);
+ return f_utf_is_graph(buffer.string + location.start, max_width);
}
#endif // _di_fl_fss_is_graph_
#ifndef _di_fl_fss_is_space_
- f_return_status fl_fss_is_space(const f_string_dynamic buffer, const f_string_location input) {
+ f_return_status fl_fss_is_space(const f_string_dynamic buffer, const f_string_location location) {
#ifndef _di_level_1_parameter_checking_
if (buffer.used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input.start < 0) return f_status_set_error(f_invalid_parameter);
- if (input.stop < input.start) return f_status_set_error(f_invalid_parameter);
- if (input.start >= buffer.used) return f_status_set_error(f_invalid_parameter);
+ if (location.start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location.stop < location.start) return f_status_set_error(f_invalid_parameter);
+ if (location.start >= buffer.used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
- f_string_length max_width = (input.stop - input.start) + 1;
+ f_string_length max_width = (location.stop - location.start) + 1;
- if (max_width > buffer.used - input.start) {
- max_width = buffer.used - input.start;
+ if (max_width > buffer.used - location.start) {
+ max_width = buffer.used - location.start;
}
- return f_utf_is_whitespace(buffer.string + input.start, max_width);
+ return f_utf_is_whitespace(buffer.string + location.start, max_width);
}
#endif // _di_fl_fss_is_space_
#ifndef _di_fl_fss_skip_past_whitespace_
- f_return_status fl_fss_skip_past_whitespace(const f_string_dynamic buffer, f_string_location *input) {
+ f_return_status fl_fss_skip_past_whitespace(const f_string_dynamic buffer, f_string_location *location) {
#ifndef _di_level_1_parameter_checking_
if (buffer.used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
unsigned short width = 0;
- f_string_length max_width = (input->stop - input->start) + 1;
+ f_string_length max_width = (location->stop - location->start) + 1;
- if (max_width > buffer.used - input->start) {
- max_width = buffer.used - input->start;
+ if (max_width > buffer.used - location->start) {
+ max_width = buffer.used - location->start;
}
- while (buffer.string[input->start] == f_string_eos || (status = f_utf_is_graph(buffer.string + input->start, max_width)) == f_false) {
+ while (buffer.string[location->start] == f_string_eos || (status = f_utf_is_graph(buffer.string + location->start, max_width)) == f_false) {
if (f_status_is_error(status)) {
return status;
}
- if (buffer.string[input->start] == f_string_eol) return f_none_on_eol;
+ if (buffer.string[location->start] == f_string_eol) return f_none_on_eol;
- width = f_macro_utf_byte_width_is(buffer.string[input->start]);
+ width = f_macro_utf_byte_width_is(buffer.string[location->start]);
if (width == 0) {
width = 1;
return f_status_set_error(f_incomplete_utf);
}
else {
- if (input->start + width >= buffer.used) return f_status_set_error(f_incomplete_utf_on_eos);
- if (input->start + width > input->stop) return f_status_set_error(f_incomplete_utf_on_stop);
+ if (location->start + width >= buffer.used) return f_status_set_error(f_incomplete_utf_on_eos);
+ if (location->start + width > location->stop) return f_status_set_error(f_incomplete_utf_on_stop);
}
- input->start += width;
+ location->start += width;
- if (input->start >= buffer.used) return f_none_on_eos;
- if (input->start > input->stop) return f_none_on_stop;
+ if (location->start >= buffer.used) return f_none_on_eos;
+ if (location->start > location->stop) return f_none_on_stop;
- max_width = (input->stop - input->start) + 1;
+ max_width = (location->stop - location->start) + 1;
- if (max_width > buffer.used - input->start) {
- max_width = buffer.used - input->start;
+ if (max_width > buffer.used - location->start) {
+ max_width = buffer.used - location->start;
}
} // while
#endif // _di_fl_fss_skip_past_whitespace_
#ifndef _di_fl_fss_skip_past_all_whitespace_
- f_return_status fl_fss_skip_past_all_whitespace(const f_string_dynamic buffer, f_string_location *input) {
+ f_return_status fl_fss_skip_past_all_whitespace(const f_string_dynamic buffer, f_string_location *location) {
#ifndef _di_level_1_parameter_checking_
if (buffer.used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer.used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
unsigned short width = 0;
- f_string_length max_width = (input->stop - input->start) + 1;
+ f_string_length max_width = (location->stop - location->start) + 1;
- if (max_width > buffer.used - input->start) {
- max_width = buffer.used - input->start;
+ if (max_width > buffer.used - location->start) {
+ max_width = buffer.used - location->start;
}
- while (buffer.string[input->start] == f_string_eos || (status = f_utf_is_graph(buffer.string + input->start, max_width)) == f_false) {
+ while (buffer.string[location->start] == f_string_eos || (status = f_utf_is_graph(buffer.string + location->start, max_width)) == f_false) {
if (f_status_is_error(status)) {
return status;
}
- width = f_macro_utf_byte_width_is(buffer.string[input->start]);
+ width = f_macro_utf_byte_width_is(buffer.string[location->start]);
if (width == 0) {
width = 1;
return f_status_set_error(f_incomplete_utf);
}
else {
- if (input->start + width >= buffer.used) return f_status_set_error(f_incomplete_utf_on_eos);
- if (input->start + width > input->stop) return f_status_set_error(f_incomplete_utf_on_stop);
+ if (location->start + width >= buffer.used) return f_status_set_error(f_incomplete_utf_on_eos);
+ if (location->start + width > location->stop) return f_status_set_error(f_incomplete_utf_on_stop);
}
- input->start += width;
+ location->start += width;
- if (input->start >= buffer.used) return f_none_on_eos;
- if (input->start > input->stop) return f_none_on_stop;
+ if (location->start >= buffer.used) return f_none_on_eos;
+ if (location->start > location->stop) return f_none_on_stop;
- max_width = (input->stop - input->start) + 1;
+ max_width = (location->stop - location->start) + 1;
- if (max_width > buffer.used - input->start) {
- max_width = buffer.used - input->start;
+ if (max_width > buffer.used - location->start) {
+ max_width = buffer.used - location->start;
}
} // while
#endif // _di_fl_fss_skip_past_all_whitespace_
#ifndef _di_fl_fss_shift_delimiters_
- f_return_status fl_fss_shift_delimiters(f_string_dynamic *buffer, const f_string_location input) {
+ f_return_status fl_fss_shift_delimiters(f_string_dynamic *buffer, const f_string_location location) {
#ifndef _di_level_1_parameter_checking_
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input.start < 0) return f_status_set_error(f_invalid_parameter);
- if (input.stop < input.start) return f_status_set_error(f_invalid_parameter);
- if (input.start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location.start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location.stop < location.start) return f_status_set_error(f_invalid_parameter);
+ if (location.start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length position = 0;
unsigned short utf_width = 0;
unsigned short i = 0;
- position = input.start;
+ position = location.start;
- while (position < buffer->used && position <= input.stop) {
+ while (position < buffer->used && position <= location.stop) {
if (buffer->string[position] == f_fss_delimit_placeholder) {
distance++;
}
// do not waste time trying to process what is only going to be replaced with a delimit placeholder
- if (position + distance >= buffer->used || position + distance > input.stop) {
+ if (position + distance >= buffer->used || position + distance > location.stop) {
break;
}
utf_width = f_macro_utf_byte_width_is(buffer->string[position]);
if (utf_width > 1) {
- // not enough space in buffer or in input range to process UTF-8 character.
- if (position + utf_width >= buffer->used || position + utf_width > input.stop) {
+ // not enough space in buffer or in location range to process UTF-8 character.
+ if (position + utf_width >= buffer->used || position + utf_width > location.stop) {
return f_status_set_error(f_invalid_utf);
}
}
if (distance > 0) {
- while (position < buffer->used + distance && position <= input.stop) {
+ while (position < buffer->used + distance && position <= location.stop) {
buffer->string[position] = f_fss_delimit_placeholder;
++position;
}
*
* @param buffer
* The string to process.
- * @param input
+ * @param location
* The start and stop positions to be incremented.
* The start position will be incremented by step.
* @param step
* f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
*/
#ifndef _di_fl_fss_decrement_buffer_
- extern f_return_status fl_fss_decrement_buffer(const f_string_dynamic buffer, f_string_location *input, const f_string_length step);
+ extern f_return_status fl_fss_decrement_buffer(const f_string_dynamic buffer, f_string_location *location, const f_string_length step);
#endif // _di_fl_fss_decrement_buffer_
/**
*
* @param buffer
* The string to process.
- * @param input
+ * @param location
* The start and stop positions to be incremented.
* The start position will be incremented by step.
* @param step
* f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
*/
#ifndef _di_fl_fss_increment_buffer_
- extern f_return_status fl_fss_increment_buffer(const f_string_dynamic buffer, f_string_location *input, const f_string_length step);
+ extern f_return_status fl_fss_increment_buffer(const f_string_dynamic buffer, f_string_location *location, const f_string_length step);
#endif // _di_fl_fss_increment_buffer_
/**
*
* @param buffer
* The string to process.
- * @param input
+ * @param location
* The character at the start position will be checked against the graph.
* @param header
* The header data to populate with results of this function.
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_fss_is_graph_
- extern f_return_status fl_fss_is_graph(const f_string_dynamic buffer, const f_string_location input);
+ extern f_return_status fl_fss_is_graph(const f_string_dynamic buffer, const f_string_location location);
#endif // _di_fl_fss_is_graph_
/**
*
* @param buffer
* The string to process.
- * @param input
+ * @param location
* The character at the start position will be checked against the graph.
* @param header
* The header data to populate with results of this function.
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_fss_is_space_
- extern f_return_status fl_fss_is_space(const f_string_dynamic buffer, const f_string_location input);
+ extern f_return_status fl_fss_is_space(const f_string_dynamic buffer, const f_string_location location);
#endif // _di_fl_fss_is_space_
/**
* @param buffer
* The string to process.
* This gets updated.
- * @param input
+ * @param location
* A restriction on where within the buffer the shifting happens.
*
* @return
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_fss_shift_delimiters_
- extern f_return_status fl_fss_shift_delimiters(f_string_dynamic *buffer, const f_string_location input);
+ extern f_return_status fl_fss_shift_delimiters(f_string_dynamic *buffer, const f_string_location location);
#endif // _di_fl_fss_shift_delimiters_
/**
*
* @param buffer
* The string to process.
- * @param input
+ * @param location
* The start and stop positions in the buffer being processed.
* This increments location->start.
*
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_fss_skip_past_whitespace_
- extern f_return_status fl_fss_skip_past_whitespace(const f_string_dynamic buffer, f_string_location *input);
+ extern f_return_status fl_fss_skip_past_whitespace(const f_string_dynamic buffer, f_string_location *location);
#endif // _di_fl_fss_skip_past_whitespace_
/**
*
* @param buffer
* The string to process.
- * @param input
+ * @param location
* The start and stop positions in the buffer being processed.
- * This increments input->start.
+ * This increments location->start.
*
* @return
* f_none on success.
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_fss_skip_past_all_whitespace_
- extern f_return_status fl_fss_skip_past_all_whitespace(const f_string_dynamic buffer, f_string_location *input);
+ extern f_return_status fl_fss_skip_past_all_whitespace(const f_string_dynamic buffer, f_string_location *location);
#endif // _di_fl_fss_skip_past_all_whitespace_
#ifdef __cplusplus
#endif
#ifndef _di_fl_fss_basic_object_read_
- f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_location *input, f_fss_object *found) {
+ f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
if (found == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
// delimits must only be applied once a valid object is found
f_string_lengths delimits = f_string_lengths_initialize;
- fl_fss_skip_past_whitespace(*buffer, input);
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_fss_skip_past_whitespace(*buffer, location);
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_fss_basic_close) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_fss_basic_close) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
f_bool has_delimit = f_false;
// begin the search
- found->start = input->start;
+ found->start = location->start;
// ignore all comment lines
- if (buffer->string[input->start] == f_fss_comment) {
- fl_macro_fss_object_seek_till_newline((*buffer), (*input), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ if (buffer->string[location->start] == f_fss_comment) {
+ fl_macro_fss_object_seek_till_newline((*buffer), (*location), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
int8_t quoted = f_string_eos;
// identify where the object begins
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length last_slash = input->start;
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length last_slash = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_placeholder) {
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
else {
- status = fl_fss_is_graph(*buffer, *input);
+ status = fl_fss_is_graph(*buffer, *location);
if (status == f_false) {
- found->stop = input->start - 1;
+ found->stop = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
else if (f_status_is_error(status)) {
return status;
}
- else if (buffer->string[input->start] != f_fss_delimit_slash) {
+ else if (buffer->string[location->start] != f_fss_delimit_slash) {
break;
}
}
- last_slash = input->start;
+ last_slash = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
+ if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) {
if (delimits.used >= delimits.size) {
f_status allocation_status = f_none;
delimits.array[delimits.used] = last_slash;
delimits.used++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
}
- else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
- quoted = buffer->string[input->start];
+ else if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) {
+ quoted = buffer->string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- found->start = input->start;
+ found->start = location->start;
}
// identify where the object ends
if (quoted == f_string_eos) {
status = f_none;
- while (buffer->string[input->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (buffer->string[location->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
} // while
if (f_status_is_error(status)) return status;
- status = fl_fss_is_space(*buffer, *input);
+ status = fl_fss_is_space(*buffer, *location);
if (status == f_true) {
- found->stop = input->start - 1;
+ found->stop = location->start - 1;
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- if (buffer->string[input->start] == f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object_no_content;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
}
}
else {
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length first_slash = input->start;
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
f_string_length slash_count = 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_placeholder) {
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (buffer->string[input->start] != f_fss_delimit_slash) {
+ else if (buffer->string[location->start] != f_fss_delimit_slash) {
break;
}
slash_count++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
- if (buffer->string[input->start] == quoted) {
- f_string_length location = input->start;
+ if (buffer->string[location->start] == quoted) {
+ f_string_length length = location->start;
- input->start = first_slash;
+ location->start = first_slash;
if (slash_count % 2 == 0) {
if (delimits.used + (slash_count / 2) >= delimits.size) {
}
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- input->start = location + 1;
+ location->start = length + 1;
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*location))
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if ((status = fl_fss_is_graph(*buffer, *input)) == f_true) {
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if ((status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
{
f_status allocation_status = f_none;
f_macro_string_lengths_delete(allocation_status, delimits);
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
return status;
}
- else if (buffer->string[input->start] == f_string_eol) {
+ else if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- found->stop = location - 1;
+ found->stop = length - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- found->stop = location - 1;
+ found->stop = length - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
}
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- input->start = location;
+ location->start = length;
}
}
}
- else if (buffer->string[input->start] == quoted) {
- found->stop = input->start - 1;
+ else if (buffer->string[location->start] == quoted) {
+ found->stop = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_string_eol) {
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object_no_content;
}
- else if ((status = fl_fss_is_space(*buffer, *input)) == f_true) {
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
else if (f_status_is_error(status)) {
return status;
}
- else if (buffer->string[input->start] != f_fss_delimit_placeholder) {
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
+ else if (buffer->string[location->start] != f_fss_delimit_placeholder) {
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
{
f_status allocation_status = f_none;
f_macro_string_lengths_delete(allocation_status, delimits);
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
}
- else if (buffer->string[input->start] == f_string_eol) {
+ else if (buffer->string[location->start] == f_string_eol) {
{
f_status allocation_status = f_none;
f_macro_string_lengths_delete(allocation_status, delimits);
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
}
// seek to the end of the line when no valid object is found
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
{
f_status allocation_status = f_none;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
#endif // _di_fl_fss_basic_object_read_
#ifndef _di_fl_fss_basic_content_read_
- f_return_status fl_fss_basic_content_read(f_string_dynamic *buffer, f_string_location *input, f_fss_content *found) {
+ f_return_status fl_fss_basic_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
if (found == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
// delimits must only be applied once a valid object is found
f_string_lengths delimits = f_string_lengths_initialize;
- fl_fss_skip_past_whitespace(*buffer, input);
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_fss_skip_past_whitespace(*buffer, location);
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_content;
}
fl_macro_fss_allocate_content_if_necessary((*found), delimits);
- found->array[found->used].start = input->start;
+ found->array[found->used].start = location->start;
// search for valid content
do {
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*location))
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_basic_close) break;
+ if (buffer->string[location->start] == f_fss_basic_close) break;
- ++input->start;
+ ++location->start;
} while (f_true);
- // Save the stop location
- found->array[found->used].stop = input->start - 1;
+ // Save the stop length
+ found->array[found->used].stop = location->start - 1;
found->used++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_content;
#endif // _di_fl_fss_basic_content_read_
#ifndef _di_fl_fss_basic_object_write_
- f_return_status fl_fss_basic_object_write(f_string_dynamic *buffer, const f_string_dynamic object, f_string_location *input) {
+ f_return_status fl_fss_basic_object_write(f_string_dynamic *buffer, const f_string_dynamic object, f_string_location *location) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length start_position = f_string_initialize;
f_string_length pre_allocate_size = 0;
- fl_macro_fss_skip_past_delimit_placeholders(object, (*input))
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*location))
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_no_data_on_stop;
}
- else if (input->start >= object.used) {
+ else if (location->start >= object.used) {
return f_no_data_on_eos;
}
- start_position = input->start;
+ start_position = location->start;
// add an additional 3 to ensure that there is room for the start and stop quotes or a slash delimit and the object open character.
- pre_allocate_size = buffer->used + (input->stop - input->start) + 3 + f_fss_default_allocation_step_string;
+ pre_allocate_size = buffer->used + (location->stop - location->start) + 3 + f_fss_default_allocation_step_string;
if (pre_allocate_size > buffer->size) {
f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
buffer_position.start = buffer->used;
buffer_position.stop = buffer->used;
- if (object.string[input->start] == f_fss_delimit_slash) {
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (object.string[location->start] == f_fss_delimit_slash) {
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (object.string[input->start] != f_fss_delimit_slash) {
+ else if (object.string[location->start] != f_fss_delimit_slash) {
break;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (object.string[input->start] == f_fss_delimit_single_quote || object.string[input->start] == f_fss_delimit_double_quote) {
+ if (object.string[location->start] == f_fss_delimit_single_quote || object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[input->start];
+ buffer->string[buffer_position.stop + 1] = object.string[location->start];
buffer_position.stop += 2;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
}
- else if (object.string[input->start] == f_fss_delimit_single_quote || object.string[input->start] == f_fss_delimit_double_quote) {
+ else if (object.string[location->start] == f_fss_delimit_single_quote || object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[input->start];
+ buffer->string[buffer_position.stop + 1] = object.string[location->start];
buffer_position.stop += 2;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
- else if (object.string[input->start] == f_fss_comment) {
+ else if (object.string[location->start] == f_fss_comment) {
quoted = f_true;
}
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (object.string[input->start] == f_string_eol) {
+ else if (object.string[location->start] == f_string_eol) {
if (quoted) {
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
return f_none_on_eol;
}
- else if ((status = fl_fss_is_space(*buffer, *input)) == f_true || quoted) {
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true || quoted) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
// restart the loop searching for f_fss_delimit_double_quote.
- input->start = start_position;
+ location->start = start_position;
buffer_position.stop = buffer_position.start;
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (object.string[input->start] == f_fss_delimit_double_quote) {
+ else if (object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
}
- else if (object.string[input->start] == f_fss_delimit_slash) {
+ else if (object.string[location->start] == f_fss_delimit_slash) {
f_string_length slash_count = 0;
do {
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
slash_count++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- fl_macro_fss_skip_past_delimit_placeholders(object, (*input));
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*location));
- if (input->start > input->stop || input->start >= object.used) {
+ if (location->start > location->stop || location->start >= object.used) {
break;
}
- if (object.string[input->start] == f_fss_delimit_double_quote) {
+ if (object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size += slash_count;
if (pre_allocate_size > buffer->size) {
break;
}
- else if (object.string[input->start] != f_fss_delimit_slash) {
+ else if (object.string[location->start] != f_fss_delimit_slash) {
slash_count = 0;
break;
}
continue;
}
- else if (object.string[input->start] == f_string_eol) {
+ else if (object.string[location->start] == f_string_eol) {
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
return f_none_on_eol;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
buffer_position.stop++;
return status;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
buffer_position.stop++;
buffer->used = buffer_position.stop + 1;
}
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_none_on_stop;
}
- else if (input->start >= object.used) {
+ else if (location->start >= object.used) {
return f_none_on_eos;
}
#endif // _di_fl_fss_basic_object_write_
#ifndef _di_fl_fss_basic_content_write_
- f_return_status fl_fss_basic_content_write(f_string_dynamic *buffer, const f_string_dynamic content, f_string_location *input) {
+ f_return_status fl_fss_basic_content_write(f_string_dynamic *buffer, const f_string_dynamic content, f_string_location *location) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
if (f_status_is_error(status)) return status;
}
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_string_eol){
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_string_eol){
buffer->string[buffer_position.stop] = f_string_eol;
buffer->used = buffer_position.stop + 1;
return f_none_on_eos;
}
- if (content.string[input->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[input->start];
+ if (content.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
}
- fl_fss_increment_buffer(*buffer, input, 1);
+ fl_fss_increment_buffer(*buffer, location, 1);
} // while
buffer->string[buffer_position.stop] = f_string_eol;
buffer->used = buffer_position.stop + 1;
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_none_on_stop;
}
- else if (input->start >= content.used) {
+ else if (location->start >= content.used) {
return f_none_on_eos;
}
extern "C" {
#endif
+/**
+ * Read an fss-0000 object.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid object was found.
+ *
+ * @return
+ * fl_fss_found_object on success and object was found (start location is at end of object).
+ * fl_fss_found_no_object on success and no object was found (start location is after character designating this is not an object).
+ * f_none_on_stop on success after reaching stopping point (a valid object is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid object is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no objects found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_object_read_
- /**
- * read an fss-0000 object.
- */
- extern f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_location *input, f_fss_object *found);
+ extern f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found);
#endif // _di_fl_fss_basic_object_read_
+/**
+ * Read an fss-0000 content.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid content was found.
+ *
+ * @return
+ * fl_fss_found_content on success and content was found (start location is at end of content).
+ * fl_fss_found_no_content on success and no content was found (start location is after character designating this is not a content).
+ * f_none_on_stop on success after reaching stopping point (a valid content is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid content is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no content found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_content_read_
- /**
- * read an fss-0000 content.
- */
- extern f_return_status fl_fss_basic_content_read(f_string_dynamic *buffer, f_string_location *input, f_fss_content *found);
+ extern f_return_status fl_fss_basic_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found);
#endif // _di_fl_fss_basic_content_read_
+/**
+ * Write an fss-0000 object.
+ *
+ * This will write the given string range as a valid object.
+ * Anything within this range will be escaped as necessary.
+ * This will stop if EOL is reached.
+ *
+ * @param object
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the object string to write as an object.
+ * @param buffer
+ * The buffer where the object is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_object_write_
- /**
- * write an fss-0000 object.
- */
- extern f_return_status fl_fss_basic_object_write(f_string_dynamic *buffer, const f_string_dynamic object, f_string_location *input);
+ extern f_return_status fl_fss_basic_object_write(f_string_dynamic *buffer, const f_string_dynamic object, f_string_location *location);
#endif // _di_fl_fss_basic_object_write_
+/**
+ * Write an fss-0000 content.
+ *
+ * This will write the given string range as a valid content.
+ * Anything within this range will be escaped as necessary.
+ *
+ * @param content
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the content string to write as an content.
+ * @param buffer
+ * The buffer where the content is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_content_write_
- /**
- * write an fss-0000 content.
- */
- extern f_return_status fl_fss_basic_content_write(f_string_dynamic *buffer, const f_string_dynamic content, f_string_location *input);
+ extern f_return_status fl_fss_basic_content_write(f_string_dynamic *buffer, const f_string_dynamic content, f_string_location *location);
#endif // _di_fl_fss_basic_content_write_
#ifdef __cplusplus
#endif
#ifndef _di_fl_fss_basic_list_object_read_
- f_return_status fl_fss_basic_list_object_read(f_string_dynamic *buffer, f_string_location *input, f_fss_object *found) {
+ f_return_status fl_fss_basic_list_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
if (found == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
// delimits must only be applied once a valid object is found
f_string_lengths delimits = f_string_lengths_initialize;
- fl_fss_skip_past_whitespace(*buffer, input);
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_fss_skip_past_whitespace(*buffer, location);
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
// begin the search
- found->start = input->start;
+ found->start = location->start;
// ignore all comment lines
- if (buffer->string[input->start] == f_fss_comment) {
- fl_macro_fss_object_seek_till_newline((*buffer), (*input), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ if (buffer->string[location->start] == f_fss_comment) {
+ fl_macro_fss_object_seek_till_newline((*buffer), (*location), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
// identify where the object ends
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length first_slash = input->start;
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
f_string_length slash_count = 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < buffer->used && input->start <= input->stop && (buffer->string[input->start] == f_fss_delimit_placeholder || buffer->string[input->start] == f_fss_delimit_slash)) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ while (location->start < buffer->used && location->start <= location->stop && (buffer->string[location->start] == f_fss_delimit_placeholder || buffer->string[location->start] == f_fss_delimit_slash)) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
slash_count++;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
- if (buffer->string[input->start] == f_fss_basic_list_open) {
- f_string_length stop_point = input->start - 1;
+ if (buffer->string[location->start] == f_fss_basic_list_open) {
+ f_string_length stop_point = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < buffer->used && input->start <= input->stop) {
- if (buffer->string[input->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
break;
}
if (f_status_is_error(status)) return status;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
- if (buffer->string[input->start] == f_string_eol) {
- f_string_length location = input->start;
+ if (buffer->string[location->start] == f_string_eol) {
+ f_string_length length = location->start;
- input->start = first_slash;
+ location->start = first_slash;
if (delimits.used + (slash_count / 2) >= delimits.size) {
f_status allocation_status = f_none;
if (slash_count % 2 == 0) {
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
found->stop = stop_point;
- input->start = location + 1;
+ location->start = length + 1;
return fl_fss_found_object;
}
- input->start = location + 1;
+ location->start = length + 1;
return fl_fss_found_no_object;
}
}
continue;
}
- else if (buffer->string[input->start] == f_fss_basic_list_open) {
- f_string_length stop_point = input->start - 1;
+ else if (buffer->string[location->start] == f_fss_basic_list_open) {
+ f_string_length stop_point = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < buffer->used && input->start <= input->stop) {
- if (buffer->string[input->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
break;
}
if (f_status_is_error(status)) return status;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_string_eol) {
+ if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
found->stop = stop_point;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
continue;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
// seek to the end of the line when no valid object is found
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
#endif // _di_fl_fss_basic_list_object_read_
#ifndef _di_fl_fss_basic_list_content_read_
- f_return_status fl_fss_basic_list_content_read(f_string_dynamic *buffer, f_string_location *input, f_fss_content *found) {
+ f_return_status fl_fss_basic_list_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
if (found == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
// delimits must only be applied once a valid object is found
f_string_lengths delimits = f_string_lengths_initialize;
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*location))
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
fl_macro_fss_allocate_content_if_necessary((*found), delimits);
- found->array[found->used].start = input->start;
+ found->array[found->used].start = location->start;
- f_string_length last_newline = input->start;
+ f_string_length last_newline = location->start;
f_bool found_newline = f_false;
// identify where the content ends
- while (input->start < buffer->used && input->start <= input->stop) {
- if (buffer->string[input->start] == f_string_eol) {
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol) {
found_newline = f_true;
- last_newline = input->start;
+ last_newline = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
continue;
}
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length first_slash = input->start;
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
f_string_length slash_count = 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < buffer->used && input->start <= input->stop && (buffer->string[input->start] == f_fss_delimit_placeholder || buffer->string[input->start] == f_fss_delimit_slash)) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ while (location->start < buffer->used && location->start <= location->stop && (buffer->string[location->start] == f_fss_delimit_placeholder || buffer->string[location->start] == f_fss_delimit_slash)) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
slash_count++;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
if (found_newline) {
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
}
else {
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
}
- if (buffer->string[input->start] == f_fss_basic_list_open) {
- f_string_length stop_point = input->start - 1;
+ if (buffer->string[location->start] == f_fss_basic_list_open) {
+ f_string_length stop_point = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < buffer->used && input->start <= input->stop) {
- if (buffer->string[input->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
break;
}
if (f_status_is_error(status)) return status;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
if (found_newline) {
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
}
else {
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
}
- if (buffer->string[input->start] == f_string_eol) {
- f_string_length location = input->start;
+ if (buffer->string[location->start] == f_string_eol) {
+ f_string_length length = location->start;
- input->start = first_slash;
+ location->start = first_slash;
if (slash_count % 2 == 0) {
// FIXME: apply delimits??
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
found->array[found->used].stop = last_newline;
- input->start = last_newline + 1;
+ location->start = last_newline + 1;
found->used++;
return fl_fss_found_content;
}
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
found_newline = f_true;
- input->start = location + 1;
+ location->start = length + 1;
}
}
continue;
}
- else if (buffer->string[input->start] == f_fss_basic_list_open) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ else if (buffer->string[location->start] == f_fss_basic_list_open) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < buffer->used && input->start <= input->stop) {
- if (buffer->string[input->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
break;
}
if (f_status_is_error(status)) return status;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
if (found_newline) {
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
}
else {
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
}
- if (buffer->string[input->start] == f_string_eol) {
+ if (buffer->string[location->start] == f_string_eol) {
if (found_newline) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
found->array[found->used].stop = last_newline;
- input->start = last_newline + 1;
+ location->start = last_newline + 1;
found->used++;
return fl_fss_found_content;
}
if (!found_newline) {
- input->start = last_newline;
+ location->start = last_newline;
}
return fl_fss_found_no_content;
continue;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
found->array[found->used].stop = last_newline - 1;
- input->start = last_newline + 1;
+ location->start = last_newline + 1;
found->used++;
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
return fl_fss_found_content;
}
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
return fl_fss_found_no_content;
}
#endif // _di_fl_fss_basic_list_content_read_
#ifndef _di_fl_fss_basic_list_object_write_
- f_return_status fl_fss_basic_list_object_write(const f_string_dynamic object, f_string_location *input, f_string_dynamic *buffer) {
+ f_return_status fl_fss_basic_list_object_write(const f_string_dynamic object, f_string_location *location, f_string_dynamic *buffer) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length pre_allocate_size = 0;
f_string_length start_buffer = 0;
- fl_macro_fss_skip_past_delimit_placeholders(object, (*input))
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*location))
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_no_data_on_stop;
}
- else if (input->start >= object.used) {
+ else if (location->start >= object.used) {
return f_no_data_on_eos;
}
- start_position = input->start;
+ start_position = location->start;
// add an additional 2 to ensure that there is room for the slash delimit and the object open character.
- pre_allocate_size = buffer->used + (input->stop - input->start) + 2 + f_fss_default_allocation_step_string;
+ pre_allocate_size = buffer->used + (location->stop - location->start) + 2 + f_fss_default_allocation_step_string;
if (pre_allocate_size > buffer->size) {
f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
buffer_position.start = buffer->used;
buffer_position.stop = buffer->used;
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_comment) {
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_comment) {
// comments are not allowed and this format has no way of "wrapping" a comment.
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
- else if ((status = fl_fss_is_graph(object, *input)) == f_true) {
+ else if ((status = fl_fss_is_graph(object, *location)) == f_true) {
break;
}
else if (f_status_is_error(status)) {
return status;
}
- if (object.string[input->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = object.string[input->start];
+ if (object.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
}
- status = fl_fss_increment_buffer(object, input, 1);
+ status = fl_fss_increment_buffer(object, location, 1);
if (f_status_is_error(status)) return status;
} // while
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_slash) {
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_slash) {
f_string_length slash_count = 1;
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
- status = fl_fss_increment_buffer(object, input, 1);
+ status = fl_fss_increment_buffer(object, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(object, input, 1);
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(object, location, 1);
if (f_status_is_error(status)) return status;
continue;
- } else if (object.string[input->start] != f_fss_delimit_slash) {
+ } else if (object.string[location->start] != f_fss_delimit_slash) {
break;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
- status = fl_fss_increment_buffer(object, input, 1);
+ status = fl_fss_increment_buffer(object, location, 1);
if (f_status_is_error(status)) return status;
slash_count++;
} // while
- if (input->start > input->stop || input->start >= object.used) {
+ if (location->start > location->stop || location->start >= object.used) {
pre_allocate_size += slash_count;
if (pre_allocate_size > buffer->size) {
break;
}
}
- else if (object.string[input->start] == f_string_eol) {
+ else if (object.string[location->start] == f_string_eol) {
if (buffer_position.stop == buffer_position.start) {
return f_no_data_on_eol;
}
break;
}
- if (object.string[input->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = object.string[input->start];
+ if (object.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
}
- status = fl_fss_increment_buffer(object, input, 1);
+ status = fl_fss_increment_buffer(object, location, 1);
if (f_status_is_error(status)) return status;
} // while
buffer->string[buffer_position.stop + 1] = f_string_eol;
buffer->used = buffer_position.stop + 2;
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_none_on_stop;
}
- else if (input->start >= object.used) {
+ else if (location->start >= object.used) {
return f_none_on_eos;
}
#endif // _di_fl_fss_basic_list_object_write_
#ifndef _di_fl_fss_basic_list_content_write_
- f_return_status fl_fss_basic_list_content_write(const f_string_dynamic content, f_string_location *input, f_string_dynamic *buffer) {
+ f_return_status fl_fss_basic_list_content_write(const f_string_dynamic content, f_string_location *location, f_string_dynamic *buffer) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length start_position = f_string_initialize;
f_string_length pre_allocate_size = 0;
- fl_macro_fss_skip_past_delimit_placeholders(content, (*input))
+ fl_macro_fss_skip_past_delimit_placeholders(content, (*location))
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_no_data_on_stop;
}
- else if (input->start >= content.used) {
+ else if (location->start >= content.used) {
return f_no_data_on_eos;
}
- start_position = input->start;
+ start_position = location->start;
// add an additional 2 to ensure that there is room for the slash delimit and the content open character.
- pre_allocate_size = buffer->used + (input->stop - input->start) + 2 + f_fss_default_allocation_step_string;
+ pre_allocate_size = buffer->used + (location->stop - location->start) + 2 + f_fss_default_allocation_step_string;
if (pre_allocate_size > buffer->size) {
f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
buffer_position.start = buffer->used;
buffer_position.stop = buffer->used;
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_fss_delimit_slash && !is_comment) {
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_slash && !is_comment) {
f_string_length slash_count = 1;
- buffer->string[buffer_position.stop] = content.string[input->start];
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
has_graph = f_true;
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(content, input, 1);
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (content.string[input->start] != f_fss_delimit_slash) {
+ else if (content.string[location->start] != f_fss_delimit_slash) {
break;
}
- buffer->string[buffer_position.stop] = content.string[input->start];
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
slash_count++;
} // while
- if (content.string[input->start] == f_fss_basic_list_open) {
- f_string_length location = input->start;
+ if (content.string[location->start] == f_fss_basic_list_open) {
+ f_string_length length = location->start;
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < content.used && input->start <= input->stop) {
- if (content.string[input->start] == f_string_eol || (status = fl_fss_is_graph(content, *input)) == f_true) {
+ while (location->start < content.used && location->start <= location->stop) {
+ if (content.string[location->start] == f_string_eol || (status = fl_fss_is_graph(content, *location)) == f_true) {
break;
}
if (f_status_is_error(status)) return status;
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (content.string[input->start] == f_string_eol || input->start >= content.used || input->start > input->stop) {
+ if (content.string[location->start] == f_string_eol || location->start >= content.used || location->start > location->stop) {
pre_allocate_size += slash_count + 1;
if (pre_allocate_size > buffer->size) {
buffer->string[buffer_position.stop] = f_fss_basic_list_open;
buffer_position.stop++;
- input->start = location + 1;
+ location->start = length + 1;
continue;
}
}
- else if (content.string[input->start] == f_fss_basic_list_open && !is_comment) {
- f_string_length location = input->start;
+ else if (content.string[location->start] == f_fss_basic_list_open && !is_comment) {
+ f_string_length length = location->start;
has_graph = f_true;
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start < content.used && input->start <= input->stop) {
- if (content.string[input->start] == f_string_eol || (status = fl_fss_is_graph(content, *input)) == f_true) {
+ while (location->start < content.used && location->start <= location->stop) {
+ if (content.string[location->start] == f_string_eol || (status = fl_fss_is_graph(content, *location)) == f_true) {
break;
}
if (f_status_is_error(status)) return status;
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (content.string[input->start] == f_string_eol || input->start >= content.used || input->start > input->stop) {
+ if (content.string[location->start] == f_string_eol || location->start >= content.used || location->start > location->stop) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
buffer->string[buffer_position.stop] = f_fss_basic_list_open;
buffer_position.stop++;
- input->start = location + 1;
+ location->start = length + 1;
continue;
}
- else if (content.string[input->start] == f_fss_comment && !has_graph) {
+ else if (content.string[location->start] == f_fss_comment && !has_graph) {
is_comment = f_true;
}
- else if (content.string[input->start] == f_string_eol) {
+ else if (content.string[location->start] == f_string_eol) {
has_graph = f_false;
is_comment = f_false;
}
- else if ((status = fl_fss_is_graph(content, *input)) == f_true) {
+ else if ((status = fl_fss_is_graph(content, *location)) == f_true) {
has_graph = f_true;
}
else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
return status;
}
- if (content.string[input->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[input->start];
+ if (content.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
}
- status = fl_fss_increment_buffer(content, input, 1);
+ status = fl_fss_increment_buffer(content, location, 1);
if (f_status_is_error(status)) return status;
} // while
buffer->string[buffer_position.stop] = f_string_eol;
buffer->used = buffer_position.stop + 1;
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_none_on_stop;
}
- else if (input->start >= content.used) {
+ else if (location->start >= content.used) {
return f_none_on_eos;
}
extern "C" {
#endif
+/**
+ * Read an fss-0002 object.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid object was found.
+ *
+ * @return
+ * fl_fss_found_object on success and object was found (start location is at end of object).
+ * fl_fss_found_no_object on success and no object was found (start location is after character designating this is not an object).
+ * f_none_on_stop on success after reaching stopping point (a valid object is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid object is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no objects found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_list_object_read_
- /**
- * read an fss-0002 object.
- */
- extern f_return_status fl_fss_basic_list_object_read(f_string_dynamic *buffer, f_string_location *input, f_fss_object *found);
+ extern f_return_status fl_fss_basic_list_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found);
#endif // _di_fl_fss_basic_list_object_read_
+/**
+ * Read an fss-0002 content.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid content was found.
+ *
+ * @return
+ * fl_fss_found_content on success and content was found (start location is at end of content).
+ * fl_fss_found_no_content on success and no content was found (start location is after character designating this is not a content).
+ * f_none_on_stop on success after reaching stopping point (a valid content is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid content is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no content found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_list_content_read_
- /**
- * read an fss-0002 content.
- */
- extern f_return_status fl_fss_basic_list_content_read(f_string_dynamic *buffer, f_string_location *input, f_fss_content *found);
+ extern f_return_status fl_fss_basic_list_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found);
#endif // _di_fl_fss_basic_list_content_read_
+/**
+ * Write an fss-0002 object.
+ *
+ * This will write the given string range as a valid object.
+ * Anything within this range will be escaped as necessary.
+ * This will stop if EOL is reached.
+ *
+ * @param object
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the object string to write as an object.
+ * @param buffer
+ * The buffer where the object is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_no_data_on_eol if there is no data to write and EOL was reached (@todo: review related code and detemine what this is doing).
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_list_object_write_
- /**
- * write an fss-0002 object.
- */
- extern f_return_status fl_fss_basic_list_object_write(const f_string_dynamic object, f_string_location *input, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_basic_list_object_write(const f_string_dynamic object, f_string_location *location, f_string_dynamic *buffer);
#endif // _di_fl_fss_basic_list_object_write_
+/**
+ * Write an fss-0002 content.
+ *
+ * This will write the given string range as a valid content.
+ * Anything within this range will be escaped as necessary.
+ *
+ * @param content
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the content string to write as an content.
+ * @param buffer
+ * The buffer where the content is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_basic_list_content_write_
- /**
- * write an fss-0002 content.
- */
- extern f_return_status fl_fss_basic_list_content_write(const f_string_dynamic content, f_string_location *input, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_basic_list_content_write(const f_string_dynamic content, f_string_location *location, f_string_dynamic *buffer);
#endif // _di_fl_fss_basic_list_content_write_
#ifdef __cplusplus
#endif
#ifndef _di_fl_fss_extended_object_read_
- f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_location *input, f_fss_object *found) {
+ f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
if (found == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
// delimits must only be applied once a valid object is found
f_string_lengths delimits = f_string_lengths_initialize;
- fl_fss_skip_past_whitespace(*buffer, input);
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_fss_skip_past_whitespace(*buffer, location);
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_fss_extended_close) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_fss_extended_close) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
f_bool has_delimit = f_false;
// begin the search
- found->start = input->start;
+ found->start = location->start;
// ignore all comment lines
- if (buffer->string[input->start] == f_fss_comment) {
- fl_macro_fss_object_seek_till_newline((*buffer), (*input), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ if (buffer->string[location->start] == f_fss_comment) {
+ fl_macro_fss_object_seek_till_newline((*buffer), (*location), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
int8_t quoted = f_string_eos;
// identify where the object begins
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length last_slash = input->start;
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length last_slash = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if ((status = fl_fss_is_graph(*buffer, *input)) == f_false) {
- found->stop = input->start - 1;
+ else if ((status = fl_fss_is_graph(*buffer, *location)) == f_false) {
+ found->stop = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
}
else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
return status;
}
- else if (buffer->string[input->start] != f_fss_delimit_slash) {
+ else if (buffer->string[location->start] != f_fss_delimit_slash) {
break;
}
- last_slash = input->start;
+ last_slash = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
+ if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) {
if (delimits.used >= delimits.size) {
f_status allocation_status = f_none;
delimits.array[delimits.used] = last_slash;
delimits.used++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
}
- else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
- quoted = buffer->string[input->start];
+ else if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) {
+ quoted = buffer->string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- found->start = input->start;
+ found->start = location->start;
}
// identify where the object ends
if (quoted == f_string_eos) {
status = f_none;
- while (buffer->string[input->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (buffer->string[location->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
} // while
if (f_status_is_error(status)) return status;
- if ((status = fl_fss_is_space(*buffer, *input)) == f_true) {
- found->stop = input->start - 1;
+ if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
+ found->stop = location->start - 1;
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- if (buffer->string[input->start] == f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object_no_content;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
}
}
else {
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length first_slash = input->start;
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
f_string_length slash_count = 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (buffer->string[input->start] != f_fss_delimit_slash) {
+ else if (buffer->string[location->start] != f_fss_delimit_slash) {
break;
}
slash_count++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
- if (buffer->string[input->start] == quoted) {
- f_string_length location = input->start;
+ if (buffer->string[location->start] == quoted) {
+ f_string_length length = location->start;
- input->start = first_slash;
+ location->start = first_slash;
if (delimits.used + (slash_count / 2) >= delimits.size) {
f_status allocation_status = f_none;
if (slash_count % 2 == 0) {
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- input->start = location + 1;
+ location->start = length + 1;
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*location))
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
- if ((status = fl_fss_is_graph(*buffer, *input)) == f_true) {
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if ((status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
return status;
}
- else if (buffer->string[input->start] == f_string_eol) {
+ else if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- found->stop = location - 1;
+ found->stop = length - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object_no_content;
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- found->stop = location - 1;
+ found->stop = length - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
}
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- input->start = location;
+ location->start = length;
}
}
}
- else if (buffer->string[input->start] == quoted) {
- found->stop = input->start - 1;
+ else if (buffer->string[location->start] == quoted) {
+ found->stop = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_string_eol) {
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object_no_content;
}
- else if ((status = fl_fss_is_space(*buffer, *input)) == f_true) {
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_object;
else if (f_status_is_error(status)) {
return status;
}
- else if (buffer->string[input->start] != f_fss_delimit_placeholder) {
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ else if (buffer->string[location->start] != f_fss_delimit_placeholder) {
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
}
- else if (buffer->string[input->start] == f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ else if (buffer->string[location->start] == f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
}
// seek to the end of the line when no valid object is found
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*input), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_object;
#endif // _di_fl_fss_extended_object_read_
#ifndef _di_fl_fss_extended_content_read_
- f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_location *input, f_fss_content *found) {
+ f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
- if (input == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
if (found == 0) return f_status_set_error(f_invalid_parameter);
- if (input->start < 0) return f_status_set_error(f_invalid_parameter);
- if (input->stop < input->start) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
- if (input->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = f_none;
// delimits must only be applied once a valid object is found
f_string_lengths delimits = f_string_lengths_initialize;
- fl_fss_skip_past_whitespace(*buffer, input);
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_fss_skip_past_whitespace(*buffer, location);
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
// return found nothing if this line only contains whitespace and delimit placeholders
- if (buffer->string[input->start] == f_fss_extended_close) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (buffer->string[location->start] == f_fss_extended_close) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_content;
f_bool continue_main_loop = f_false;
- f_string_length location = 0;
+ f_string_length length = 0;
f_array_length already_used = found->used;
- while (input->start <= input->stop && input->start < buffer->used) {
+ while (location->start <= location->stop && location->start < buffer->used) {
quoted = f_string_eos;
if (found->used >= found->size) {
}
// begin the search
- found->array[found->used].start = input->start;
+ found->array[found->used].start = location->start;
found->array[found->used].stop = 0;
// identify where the content begins
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length last_slash = input->start;
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length last_slash = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if ((status = fl_fss_is_graph(*buffer, *input)) == f_false) {
- found->array[found->used].stop = input->start - 1;
+ else if ((status = fl_fss_is_graph(*buffer, *location)) == f_false) {
+ found->array[found->used].stop = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
found->used++;
- if (buffer->string[input->start] == f_string_eol) {
+ if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
return fl_fss_found_content;
break;
}
else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
return status;
}
- else if (buffer->string[input->start] != f_fss_delimit_slash) {
+ else if (buffer->string[location->start] != f_fss_delimit_slash) {
break;
}
- last_slash = input->start;
+ last_slash = location->start;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
continue;
}
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
+ if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) {
if (delimits.used >= delimits.size) {
f_status allocation_status = f_none;
delimits.array[delimits.used] = last_slash;
delimits.used++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
}
- else if (buffer->string[input->start] == f_fss_delimit_single_quote || buffer->string[input->start] == f_fss_delimit_double_quote) {
- quoted = buffer->string[input->start];
+ else if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) {
+ quoted = buffer->string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- found->array[found->used].start = input->start;
+ found->array[found->used].start = location->start;
}
// identify where the content ends
if (quoted == f_string_eos) {
status = f_none;
- while (buffer->string[input->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *input)) == f_true) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (buffer->string[location->start] == f_fss_delimit_placeholder || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
} // while
if (f_status_is_error(status)) return status;
- if ((status = fl_fss_is_space(*buffer, *input)) == f_true) {
- found->array[found->used].stop = input->start - 1;
+ if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
+ found->array[found->used].stop = location->start - 1;
found->used++;
- if (buffer->string[input->start] == f_string_eol) {
+ if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_content;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
}
else {
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
- f_string_length first_slash = input->start;
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
f_string_length slash_count = 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (buffer->string[input->start] != f_fss_delimit_slash) {
+ else if (buffer->string[location->start] != f_fss_delimit_slash) {
break;
}
slash_count++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
- if (buffer->string[input->start] == quoted) {
- location = input->start;
- input->start = first_slash;
+ if (buffer->string[location->start] == quoted) {
+ length = location->start;
+ location->start = first_slash;
if (slash_count % 2 == 0) {
if (delimits.used + (slash_count / 2) >= delimits.size) {
}
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- input->start = location + 1;
+ location->start = length + 1;
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*input))
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*location))
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
- if ((status = fl_fss_is_graph(*buffer, *input)) == f_true) {
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if ((status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return f_status_is_warning(f_unterminated_group);
}
else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
return status;
}
- else if (buffer->string[input->start] == f_string_eol) {
+ else if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- found->array[found->used].stop = location - 1;
+ found->array[found->used].stop = length - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
found->used++;
return fl_fss_found_content;
}
- found->array[found->used].stop = location - 1;
+ found->array[found->used].stop = length - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
found->used++;
}
while (slash_count > 0) {
- if (buffer->string[input->start] == f_fss_delimit_slash) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
if (slash_count % 2 != 0) {
- delimits.array[delimits.used] = input->start;
+ delimits.array[delimits.used] = location->start;
delimits.used++;
}
slash_count--;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- input->start = location;
+ location->start = length;
}
}
}
- else if (buffer->string[input->start] == quoted) {
- found->array[found->used].stop = input->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ else if (buffer->string[location->start] == quoted) {
+ found->array[found->used].stop = location->start - 1;
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < buffer->used) {
- if (buffer->string[input->start] == f_string_eol) {
+ while (location->start <= location->stop && location->start < buffer->used) {
+ if (buffer->string[location->start] == f_string_eol) {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
found->used++;
return fl_fss_found_content;
}
- else if ((status = fl_fss_is_space(*buffer, *input)) == f_true) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
found->used++;
else if (f_status_is_error(status)) {
return status;
}
- else if (buffer->string[input->start] != f_fss_delimit_placeholder) {
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ else if (buffer->string[location->start] != f_fss_delimit_placeholder) {
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return f_status_is_warning(f_unterminated_group);
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
break;
}
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
}
- else if (buffer->string[input->start] == f_string_eol) {
+ else if (buffer->string[location->start] == f_string_eol) {
if (found->used == already_used) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_content;
else {
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- found->array[found->used].stop = input->start - 1;
+ found->array[found->used].stop = location->start - 1;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
found->used++;
}
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_content_return_on_overflow((*buffer), (*input), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_status_is_warning(f_unterminated_group_on_eos), f_status_is_warning(f_unterminated_group_on_stop))
}
if (continue_main_loop) {
break;
} // while
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
// seek to the end of the line when no valid content is found
- while (input->start < buffer->used && input->start <= input->stop && buffer->string[input->start] != f_string_eol) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*input), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
if (found->used == already_used) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_no_content;
fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
return fl_fss_found_content;
#endif // _di_fl_fss_extended_content_read_
#ifndef _di_fl_fss_extended_object_write_
- f_return_status fl_fss_extended_object_write(const f_string_dynamic object, f_string_location *input, f_string_dynamic *buffer) {
+ f_return_status fl_fss_extended_object_write(const f_string_dynamic object, f_string_location *location, f_string_dynamic *buffer) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
f_string_length start_position = f_string_initialize;
f_string_length pre_allocate_size = 0;
- fl_macro_fss_skip_past_delimit_placeholders(object, (*input))
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*location))
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_no_data_on_stop;
}
- else if (input->start >= object.used) {
+ else if (location->start >= object.used) {
return f_no_data_on_eos;
}
- start_position = input->start;
+ start_position = location->start;
// add an additional 3 to ensure that there is room for the start and stop quotes or a slash delimit and the object open character.
- pre_allocate_size = buffer->used + (input->stop - input->start) + 3 + f_fss_default_allocation_step_string;
+ pre_allocate_size = buffer->used + (location->stop - location->start) + 3 + f_fss_default_allocation_step_string;
if (pre_allocate_size > buffer->size) {
f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
buffer_position.start = buffer->used;
buffer_position.stop = buffer->used;
- if (object.string[input->start] == f_fss_delimit_slash) {
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ if (object.string[location->start] == f_fss_delimit_slash) {
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
- } else if (object.string[input->start] != f_fss_delimit_slash) {
+ } else if (object.string[location->start] != f_fss_delimit_slash) {
break;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (object.string[input->start] == f_fss_delimit_single_quote || object.string[input->start] == f_fss_delimit_double_quote) {
+ if (object.string[location->start] == f_fss_delimit_single_quote || object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[input->start];
+ buffer->string[buffer_position.stop + 1] = object.string[location->start];
buffer_position.stop += 2;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
}
- else if (object.string[input->start] == f_fss_delimit_single_quote || object.string[input->start] == f_fss_delimit_double_quote) {
+ else if (object.string[location->start] == f_fss_delimit_single_quote || object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[input->start];
+ buffer->string[buffer_position.stop + 1] = object.string[location->start];
buffer_position.stop += 2;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
- else if (object.string[input->start] == f_fss_comment) {
+ else if (object.string[location->start] == f_fss_comment) {
quoted = f_true;
}
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (object.string[input->start] == f_string_eol) {
+ else if (object.string[location->start] == f_string_eol) {
if (quoted) {
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
return f_none_on_eol;
}
- else if ((status = fl_fss_is_space(*buffer, *input)) == f_true || quoted) {
- f_string_length first_space = input->start;
+ else if ((status = fl_fss_is_space(*buffer, *location)) == f_true || quoted) {
+ f_string_length first_space = location->start;
if (!quoted) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < object.used && isspace(object.string[input->start])) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < object.used && isspace(object.string[location->start])) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (input->start > input->stop || input->start >= object.used) {
+ if (location->start > location->stop || location->start >= object.used) {
buffer->string[first_space] = f_fss_extended_open;
buffer->used = buffer_position.stop + 1;
break;
}
// restart the loop searching for f_fss_delimit_double_quote.
- input->start = start_position;
+ location->start = start_position;
buffer_position.stop = buffer_position.start;
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
- while (input->start <= input->stop && input->start < object.used) {
- if (object.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- else if (object.string[input->start] == f_fss_delimit_double_quote) {
+ else if (object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
}
- else if (object.string[input->start] == f_fss_delimit_slash) {
+ else if (object.string[location->start] == f_fss_delimit_slash) {
f_string_length slash_count = 0;
do {
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
buffer_position.stop++;
slash_count++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- fl_macro_fss_skip_past_delimit_placeholders(object, (*input));
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*location));
- if (input->start > input->stop || input->start >= object.used) {
+ if (location->start > location->stop || location->start >= object.used) {
break;
}
- if (object.string[input->start] == f_fss_delimit_double_quote) {
+ if (object.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size += slash_count;
if (pre_allocate_size > buffer->size) {
break;
}
- else if (object.string[input->start] != f_fss_delimit_slash) {
+ else if (object.string[location->start] != f_fss_delimit_slash) {
slash_count = 0;
break;
}
continue;
}
- else if (object.string[input->start] == f_string_eol) {
+ else if (object.string[location->start] == f_string_eol) {
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
return f_none_on_eol;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
buffer_position.stop++;
return status;
}
- buffer->string[buffer_position.stop] = object.string[input->start];
+ buffer->string[buffer_position.stop] = object.string[location->start];
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
buffer_position.stop++;
buffer->used = buffer_position.stop + 1;
}
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_none_on_stop;
}
- else if (input->start >= object.used) {
+ else if (location->start >= object.used) {
return f_none_on_eos;
}
#endif // _di_fl_fss_extended_object_write_
#ifndef _di_fl_fss_extended_content_write_
- f_return_status fl_fss_extended_content_write(const f_string_dynamic content, f_string_location *input, f_string_dynamic *buffer) {
+ f_return_status fl_fss_extended_content_write(const f_string_dynamic content, f_string_location *location, f_string_dynamic *buffer) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return f_status_set_error(f_invalid_parameter);
#endif // _di_level_1_parameter_checking_
if (f_status_is_error(status)) return status;
}
- fl_macro_fss_skip_past_delimit_placeholders(content, (*input))
+ fl_macro_fss_skip_past_delimit_placeholders(content, (*location))
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_no_data_on_stop;
}
- else if (input->start >= content.used) {
+ else if (location->start >= content.used) {
return f_no_data_on_eos;
}
- start_position = input->start;
+ start_position = location->start;
// if this first slash is followed by a quote, then that quote must be delimited.
- if (content.string[input->start] == f_fss_delimit_slash) {
+ if (content.string[location->start] == f_fss_delimit_slash) {
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- if (content.string[input->start] != f_fss_delimit_slash) {
+ if (content.string[location->start] != f_fss_delimit_slash) {
break;
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
buffer->string[buffer_position.stop] = ' ';
buffer->used = buffer_position.stop + 1;
return f_none_on_stop;
}
- else if (input->start >= content.used) {
+ else if (location->start >= content.used) {
buffer->string[buffer_position.stop] = ' ';
buffer->used = buffer_position.stop + 1;
return f_none_on_eos;
}
- if (content.string[input->start] == f_fss_delimit_single_quote || content.string[input->start] == f_fss_delimit_double_quote) {
+ if (content.string[location->start] == f_fss_delimit_single_quote || content.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = content.string[input->start];
+ buffer->string[buffer_position.stop + 1] = content.string[location->start];
buffer_position.stop += 2;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
}
- else if (content.string[input->start] == f_fss_delimit_single_quote || content.string[input->start] == f_fss_delimit_double_quote) {
+ else if (content.string[location->start] == f_fss_delimit_single_quote || content.string[location->start] == f_fss_delimit_double_quote) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
}
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = content.string[input->start];
+ buffer->string[buffer_position.stop + 1] = content.string[location->start];
buffer_position.stop += 2;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
}
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_string_eol) {
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_string_eol) {
buffer->string[buffer_position.stop] = ' ';
buffer->used = buffer_position.stop + 1;
return f_none_on_eol;
}
- if (content.string[input->start] != f_fss_delimit_placeholder && (status = fl_fss_is_graph(*buffer, *input)) == f_false) {
+ if (content.string[location->start] != f_fss_delimit_placeholder && (status = fl_fss_is_graph(*buffer, *location)) == f_false) {
quoted = f_fss_delimit_double_quote;
pre_allocate_size += 2;
if (f_status_is_error(status)) return status;
}
- input->start = start_position;
+ location->start = start_position;
buffer_position.stop = buffer_position.start;
buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
buffer_position.stop++;
return status;
}
- buffer->string[buffer_position.stop] = content.string[input->start];
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
if (quoted != f_string_eos) {
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_fss_delimit_slash) {
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_slash) {
f_string_length slash_count = 1;
buffer->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
- while (input->start <= input->stop && input->start < content.used) {
- if (content.string[input->start] == f_fss_delimit_placeholder) {
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
continue;
}
- if (content.string[input->start] != f_fss_delimit_slash) {
+ if (content.string[location->start] != f_fss_delimit_slash) {
break;
}
buffer_position.stop++;
slash_count++;
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
- if (content.string[input->start] == quoted || input->start > input->stop || input->start >= content.used) {
+ if (content.string[location->start] == quoted || location->start > location->stop || location->start >= content.used) {
pre_allocate_size += slash_count + 1;
if (pre_allocate_size > buffer->size) {
slash_count--;
} // while
- if (input->start > input->stop || input->start >= content.used) {
+ if (location->start > location->stop || location->start >= content.used) {
break;
}
buffer_position.stop += 2;
}
else {
- buffer->string[buffer_position.stop] = content.string[input->start];
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
}
}
- else if (content.string[input->start] == quoted) {
+ else if (content.string[location->start] == quoted) {
pre_allocate_size++;
if (pre_allocate_size > buffer->size) {
buffer->string[buffer_position.stop + 1] = quoted;
buffer_position.stop += 2;
}
- else if (content.string[input->start] == f_string_eol) {
+ else if (content.string[location->start] == f_string_eol) {
buffer->string[buffer_position.stop] = quoted;
buffer->string[buffer_position.stop + 1] = ' ';
buffer->used = buffer_position.stop + 2;
return f_none_on_eol;
}
- else if (content.string[input->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[input->start];
+ else if (content.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = content.string[location->start];
buffer_position.stop++;
}
- status = fl_fss_increment_buffer(*buffer, input, 1);
+ status = fl_fss_increment_buffer(*buffer, location, 1);
if (f_status_is_error(status)) return status;
} // while
buffer->string[buffer_position.stop] = ' ';
buffer->used = buffer_position.stop + 1;
- if (input->start > input->stop) {
+ if (location->start > location->stop) {
return f_none_on_stop;
}
- else if (input->start >= content.used) {
+ else if (location->start >= content.used) {
return f_none_on_eos;
}
extern "C" {
#endif
+/**
+ * Read an fss-0001 object.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid object was found.
+ *
+ * @return
+ * fl_fss_found_object on success and object was found (start location is at end of object).
+ * fl_fss_found_no_object on success and no object was found (start location is after character designating this is not an object).
+ * f_none_on_stop on success after reaching stopping point (a valid object is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid object is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no objects found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_extended_object_read_
- /**
- * read an fss-0001 object.
- */
- extern f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_location *input, f_fss_object *found);
+ extern f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found);
#endif // _di_fl_fss_extended_object_read_
+/**
+ * Read an fss-0001 content.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid content was found.
+ *
+ * @return
+ * fl_fss_found_content on success and content was found (start location is at end of content).
+ * fl_fss_found_no_content on success and no content was found (start location is after character designating this is not a content).
+ * f_none_on_stop on success after reaching stopping point (a valid content is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid content is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no content found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_extended_content_read_
- /**
- * read an fss-0001 content.
- */
- extern f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_location *input, f_fss_content *found);
+ extern f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found);
#endif // _di_fl_fss_extended_content_read_
+/**
+ * Write an fss-0001 object.
+ *
+ * This will write the given string range as a valid object.
+ * Anything within this range will be escaped as necessary.
+ * This will stop if EOL is reached.
+ *
+ * @param object
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the object string to write as an object.
+ * @param buffer
+ * The buffer where the object is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_extended_object_write_
- /**
- * write an fss-0001 object.
- */
- extern f_return_status fl_fss_extended_object_write(const f_string_dynamic object, f_string_location *input, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_extended_object_write(const f_string_dynamic object, f_string_location *location, f_string_dynamic *buffer);
#endif // _di_fl_fss_extended_object_write_
+/**
+ * Write an fss-0001 content.
+ *
+ * This will write the given string range as a valid content.
+ * Anything within this range will be escaped as necessary.
+ *
+ * @param content
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the content string to write as an content.
+ * @param buffer
+ * The buffer where the content is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
#ifndef _di_fl_fss_extended_content_write_
- /**
- * write an fss-0001 content.
- */
- extern f_return_status fl_fss_extended_content_write(const f_string_dynamic content, f_string_location *input, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_extended_content_write(const f_string_dynamic content, f_string_location *location, f_string_dynamic *buffer);
#endif // _di_fl_fss_extended_content_write_
#ifdef __cplusplus
--- /dev/null
+#include <level_1/fss_basic.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_fl_fss_extended_list_object_read_
+ f_return_status fl_fss_extended_list_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found) {
+ #ifndef _di_level_1_parameter_checking_
+ if (buffer == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
+ if (found == 0) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ f_status status = f_none;
+
+ // delimits must only be applied once a valid object is found
+ f_string_lengths delimits = f_string_lengths_initialize;
+
+ fl_fss_skip_past_whitespace(*buffer, location);
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+
+ // return found nothing if this line only contains whitespace and delimit placeholders
+ if (buffer->string[location->start] == f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ return fl_fss_found_no_object;
+ }
+
+ // begin the search
+ found->start = location->start;
+
+ // ignore all comment lines
+ if (buffer->string[location->start] == f_fss_comment) {
+ fl_macro_fss_object_seek_till_newline((*buffer), (*location), delimits, f_no_data_on_eos, f_no_data_on_stop)
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ return fl_fss_found_no_object;
+ }
+
+ // identify where the object ends
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
+ f_string_length slash_count = 1;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < buffer->used && location->start <= location->stop && (buffer->string[location->start] == f_fss_delimit_placeholder || buffer->string[location->start] == f_fss_delimit_slash)) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ slash_count++;
+ }
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+
+ if (buffer->string[location->start] == f_fss_extended_list_open) {
+ f_string_length stop_point = location->start - 1;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ break;
+ }
+
+ if (f_status_is_error(status)) return status;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+
+ if (buffer->string[location->start] == f_string_eol) {
+ f_string_length length = location->start;
+
+ location->start = first_slash;
+
+ if (delimits.used + (slash_count / 2) >= delimits.size) {
+ f_status allocation_status = f_none;
+
+ f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
+
+ if (f_status_is_error(allocation_status)) {
+ f_macro_string_lengths_delete(allocation_status, delimits);
+ return allocation_status;
+ }
+ }
+
+ if (slash_count % 2 == 0) {
+ while (slash_count > 0) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ if (slash_count % 2 != 0) {
+ delimits.array[delimits.used] = location->start;
+ delimits.used++;
+ }
+
+ slash_count--;
+ }
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ found->stop = stop_point;
+ location->start = length + 1;
+
+ return fl_fss_found_object;
+ }
+
+ location->start = length + 1;
+ return fl_fss_found_no_object;
+ }
+ }
+
+ continue;
+ }
+ else if (buffer->string[location->start] == f_fss_extended_list_open) {
+ f_string_length stop_point = location->start - 1;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ break;
+ }
+
+ if (f_status_is_error(status)) return status;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+
+ if (buffer->string[location->start] == f_string_eol) {
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ found->stop = stop_point;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ return fl_fss_found_object;
+ }
+
+ continue;
+ }
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ // seek to the end of the line when no valid object is found
+ while (location->start < buffer->used && location->start <= location->stop && buffer->string[location->start] != f_string_eol) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ return fl_fss_found_no_object;
+ }
+#endif // _di_fl_fss_extended_list_object_read_
+
+#ifndef _di_fl_fss_extended_list_content_read_
+ f_return_status fl_fss_extended_list_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found) {
+ #ifndef _di_level_1_parameter_checking_
+ if (buffer == 0) return f_status_set_error(f_invalid_parameter);
+ if (location == 0) return f_status_set_error(f_invalid_parameter);
+ if (found == 0) return f_status_set_error(f_invalid_parameter);
+ if (location->start < 0) return f_status_set_error(f_invalid_parameter);
+ if (location->stop < location->start) return f_status_set_error(f_invalid_parameter);
+ if (buffer->used <= 0) return f_status_set_error(f_invalid_parameter);
+ if (location->start >= buffer->used) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ f_status status = f_none;
+
+ // delimits must only be applied once a valid object is found
+ f_string_lengths delimits = f_string_lengths_initialize;
+
+ fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*location))
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+
+ fl_macro_fss_allocate_content_if_necessary((*found), delimits);
+ found->array[found->used].start = location->start;
+
+ f_string_length last_newline = location->start;
+ f_bool found_newline = f_false;
+
+ // identify where the content ends
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol) {
+ found_newline = f_true;
+ last_newline = location->start;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+
+ continue;
+ }
+
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ f_string_length first_slash = location->start;
+ f_string_length slash_count = 1;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < buffer->used && location->start <= location->stop && (buffer->string[location->start] == f_fss_delimit_placeholder || buffer->string[location->start] == f_fss_delimit_slash)) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ slash_count++;
+ }
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ if (found_newline) {
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ }
+ else {
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ }
+
+ if (buffer->string[location->start] == f_fss_extended_list_open) {
+ f_string_length stop_point = location->start - 1;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ break;
+ }
+
+ if (f_status_is_error(status)) return status;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ if (found_newline) {
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ }
+ else {
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ }
+
+ if (buffer->string[location->start] == f_string_eol) {
+ f_string_length length = location->start;
+
+ location->start = first_slash;
+
+ if (slash_count % 2 == 0) {
+ // FIXME: apply delimits??
+ if (found_newline) {
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ found->array[found->used].stop = last_newline;
+ location->start = last_newline + 1;
+ found->used++;
+
+ return fl_fss_found_content;
+ }
+
+ return fl_fss_found_no_content;
+ }
+
+ if (delimits.used + (slash_count / 2) >= delimits.size) {
+ f_status allocation_status = f_none;
+
+ f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
+
+ if (f_status_is_error(allocation_status)) {
+ f_macro_string_lengths_delete(allocation_status, delimits);
+ return allocation_status;
+ }
+ }
+
+ while (slash_count > 0) {
+ if (buffer->string[location->start] == f_fss_delimit_slash) {
+ if (slash_count % 2 != 0) {
+ delimits.array[delimits.used] = location->start;
+ delimits.used++;
+ }
+
+ slash_count--;
+ }
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ found_newline = f_true;
+ location->start = length + 1;
+ }
+ }
+
+ continue;
+ }
+ else if (buffer->string[location->start] == f_fss_extended_list_open) {
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < buffer->used && location->start <= location->stop) {
+ if (buffer->string[location->start] == f_string_eol || (status = fl_fss_is_graph(*buffer, *location)) == f_true) {
+ break;
+ }
+
+ if (f_status_is_error(status)) return status;
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ if (found_newline) {
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+ }
+ else {
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+ }
+
+ if (buffer->string[location->start] == f_string_eol) {
+ if (found_newline) {
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ found->array[found->used].stop = last_newline;
+ location->start = last_newline + 1;
+ found->used++;
+
+ return fl_fss_found_content;
+ }
+
+ if (!found_newline) {
+ location->start = last_newline;
+ }
+
+ return fl_fss_found_no_content;
+ }
+
+ continue;
+ }
+
+ status = fl_fss_increment_buffer(*buffer, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ if (found_newline) {
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ found->array[found->used].stop = last_newline - 1;
+ location->start = last_newline + 1;
+ found->used++;
+
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop)
+
+ return fl_fss_found_content;
+ }
+
+ fl_macro_fss_content_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop)
+
+ return fl_fss_found_no_content;
+ }
+#endif // _di_fl_fss_extended_list_content_read_
+
+#ifndef _di_fl_fss_extended_list_object_write_
+ f_return_status fl_fss_extended_list_object_write(const f_string_dynamic object, f_string_location *location, f_string_dynamic *buffer) {
+ #ifndef _di_level_1_parameter_checking_
+ if (buffer == 0) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ f_status status = f_none;
+
+ f_string_location buffer_position = f_string_location_initialize;
+ f_string_length start_position = f_string_initialize;
+ f_string_length pre_allocate_size = 0;
+ f_string_length start_buffer = 0;
+
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*location))
+
+ if (location->start > location->stop) {
+ return f_no_data_on_stop;
+ }
+ else if (location->start >= object.used) {
+ return f_no_data_on_eos;
+ }
+
+ start_position = location->start;
+
+ // add an additional 2 to ensure that there is room for the slash delimit and the object open character.
+ pre_allocate_size = buffer->used + (location->stop - location->start) + 2 + f_fss_default_allocation_step_string;
+
+ if (pre_allocate_size > buffer->size) {
+ f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+
+ if (f_status_is_error(status)) return status;
+ }
+
+ buffer_position.start = buffer->used;
+ buffer_position.stop = buffer->used;
+
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_comment) {
+ // comments are not allowed and this format has no way of "wrapping" a comment.
+ return f_status_set_error(f_invalid_data);
+ }
+ else if ((status = fl_fss_is_graph(object, *location)) == f_true) {
+ break;
+ }
+ else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
+ return status;
+ }
+
+ if (object.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = object.string[location->start];
+ buffer_position.stop++;
+ }
+
+ status = fl_fss_increment_buffer(object, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_slash) {
+ f_string_length slash_count = 1;
+
+ buffer->string[buffer_position.stop] = object.string[location->start];
+ buffer_position.stop++;
+
+ status = fl_fss_increment_buffer(object, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start <= location->stop && location->start < object.used) {
+ if (object.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(object, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ continue;
+ } else if (object.string[location->start] != f_fss_delimit_slash) {
+ break;
+ }
+
+ buffer->string[buffer_position.stop] = object.string[location->start];
+ buffer_position.stop++;
+
+ status = fl_fss_increment_buffer(object, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ slash_count++;
+ } // while
+
+ if (location->start > location->stop || location->start >= object.used) {
+ pre_allocate_size += slash_count;
+
+ if (pre_allocate_size > buffer->size) {
+ f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+
+ if (f_status_is_error(status)) return status;
+ }
+
+ while (slash_count > 0) {
+ buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ buffer_position.stop++;
+ slash_count--;
+ } // while
+
+ break;
+ }
+ }
+ else if (object.string[location->start] == f_string_eol) {
+ // @todo: review what this is doing.
+ if (buffer_position.stop == buffer_position.start) {
+ return f_no_data_on_eol;
+ }
+
+ break;
+ }
+
+ if (object.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = object.string[location->start];
+ buffer_position.stop++;
+ }
+
+ status = fl_fss_increment_buffer(object, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ buffer->string[buffer_position.stop] = f_fss_extended_list_open;
+ buffer->string[buffer_position.stop + 1] = f_string_eol;
+ buffer->used = buffer_position.stop + 2;
+
+ if (location->start > location->stop) {
+ return f_none_on_stop;
+ }
+ else if (location->start >= object.used) {
+ return f_none_on_eos;
+ }
+
+ return f_none;
+ }
+#endif // _di_fl_fss_extended_list_object_write_
+
+#ifndef _di_fl_fss_extended_list_content_write_
+ f_return_status fl_fss_extended_list_content_write(const f_string_dynamic content, f_string_location *location, f_string_dynamic *buffer) {
+ #ifndef _di_level_1_parameter_checking_
+ if (buffer == 0) return f_status_set_error(f_invalid_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ f_status status = f_none;
+ f_bool is_comment = f_false;
+ f_bool has_graph = f_false;
+
+ f_string_location buffer_position = f_string_location_initialize;
+ f_string_length start_position = f_string_initialize;
+ f_string_length pre_allocate_size = 0;
+
+ fl_macro_fss_skip_past_delimit_placeholders(content, (*location))
+
+ if (location->start > location->stop) {
+ return f_no_data_on_stop;
+ }
+ else if (location->start >= content.used) {
+ return f_no_data_on_eos;
+ }
+
+ start_position = location->start;
+
+ // add an additional 2 to ensure that there is room for the slash delimit and the content open character.
+ pre_allocate_size = buffer->used + (location->stop - location->start) + 2 + f_fss_default_allocation_step_string;
+
+ if (pre_allocate_size > buffer->size) {
+ f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+
+ if (f_status_is_error(status)) return status;
+ }
+
+ buffer_position.start = buffer->used;
+ buffer_position.stop = buffer->used;
+
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_slash && !is_comment) {
+ f_string_length slash_count = 1;
+
+ buffer->string[buffer_position.stop] = content.string[location->start];
+ buffer_position.stop++;
+
+ has_graph = f_true;
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start <= location->stop && location->start < content.used) {
+ if (content.string[location->start] == f_fss_delimit_placeholder) {
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ continue;
+ }
+ else if (content.string[location->start] != f_fss_delimit_slash) {
+ break;
+ }
+
+ buffer->string[buffer_position.stop] = content.string[location->start];
+ buffer_position.stop++;
+
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ slash_count++;
+ } // while
+
+ if (content.string[location->start] == f_fss_extended_list_open) {
+ f_string_length length = location->start;
+
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < content.used && location->start <= location->stop) {
+ if (content.string[location->start] == f_string_eol || (status = fl_fss_is_graph(content, *location)) == f_true) {
+ break;
+ }
+
+ if (f_status_is_error(status)) return status;
+
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ if (content.string[location->start] == f_string_eol || location->start >= content.used || location->start > location->stop) {
+ pre_allocate_size += slash_count + 1;
+
+ if (pre_allocate_size > buffer->size) {
+ f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+
+ if (f_status_is_error(status)) return status;
+ }
+
+ while (slash_count > 0) {
+ buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ buffer_position.stop++;
+ slash_count--;
+ } // while
+
+ buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ buffer_position.stop++;
+ has_graph = f_false;
+ is_comment = f_false;
+ }
+
+ buffer->string[buffer_position.stop] = f_fss_extended_list_open;
+ buffer_position.stop++;
+ location->start = length + 1;
+ continue;
+ }
+ }
+ else if (content.string[location->start] == f_fss_extended_list_open && !is_comment) {
+ f_string_length length = location->start;
+
+ has_graph = f_true;
+
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+
+ while (location->start < content.used && location->start <= location->stop) {
+ if (content.string[location->start] == f_string_eol || (status = fl_fss_is_graph(content, *location)) == f_true) {
+ break;
+ }
+
+ if (f_status_is_error(status)) return status;
+
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ if (content.string[location->start] == f_string_eol || location->start >= content.used || location->start > location->stop) {
+ pre_allocate_size++;
+
+ if (pre_allocate_size > buffer->size) {
+ f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+
+ if (f_status_is_error(status)) return status;
+ }
+
+ buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ buffer_position.stop++;
+ has_graph = f_false;
+ is_comment = f_false;
+ }
+
+ buffer->string[buffer_position.stop] = f_fss_extended_list_open;
+ buffer_position.stop++;
+ location->start = length + 1;
+ continue;
+ }
+ else if (content.string[location->start] == f_fss_comment && !has_graph) {
+ is_comment = f_true;
+ }
+ else if (content.string[location->start] == f_string_eol) {
+ has_graph = f_false;
+ is_comment = f_false;
+ }
+ else if ((status = fl_fss_is_graph(content, *location)) == f_true) {
+ has_graph = f_true;
+ }
+ else if (f_status_is_error(status)) {
+ f_status status2 = f_status_set_fine(status);
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_invalid_utf);
+ }
+
+ if (status2 == f_failure) {
+ return f_status_set_error(f_incomplete_utf);
+ }
+
+ return status;
+ }
+
+ if (content.string[location->start] != f_fss_delimit_placeholder) {
+ buffer->string[buffer_position.stop] = content.string[location->start];
+ buffer_position.stop++;
+ }
+
+ status = fl_fss_increment_buffer(content, location, 1);
+ if (f_status_is_error(status)) return status;
+ } // while
+
+ buffer->string[buffer_position.stop] = f_string_eol;
+ buffer->used = buffer_position.stop + 1;
+
+ if (location->start > location->stop) {
+ return f_none_on_stop;
+ }
+ else if (location->start >= content.used) {
+ return f_none_on_eos;
+ }
+
+ return f_none;
+ }
+#endif // _di_fl_fss_extended_list_content_write_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 1
+ *
+ * Project: FSS
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * This is the fss-0003 implementation.
+ */
+#ifndef _FL_fss_extended_list_h
+#define _FL_fss_extended_list_h
+
+// libc includes
+#include <ctype.h>
+#include <string.h>
+
+// fll-0 includes
+#include <level_0/status.h>
+#include <level_0/fss.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/type.h>
+#include <level_0/utf.h>
+
+// fll-1 includes
+#include <level_1/fss.h>
+#include <level_1/fss_basic.h>
+#include <level_1/fss_status.h>
+#include <level_1/fss_macro.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Read an fss-0003 object.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid object was found.
+ *
+ * @return
+ * fl_fss_found_object on success and object was found (start location is at end of object).
+ * fl_fss_found_no_object on success and no object was found (start location is after character designating this is not an object).
+ * f_none_on_stop on success after reaching stopping point (a valid object is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid object is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no objects found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_fss_extended_list_object_read_
+ extern f_return_status fl_fss_extended_list_object_read(f_string_dynamic *buffer, f_string_location *location, f_fss_object *found);
+#endif // _di_fl_fss_extended_list_object_read_
+
+/**
+ * Read an fss-0003 content.
+ *
+ * This will update the buffer at the given range with any placeholders to unescape any escaped data.
+ * Calling this more than once on the same buffer range could result in multiple unescaping.
+ *
+ * @param buffer
+ * The buffer to read from.
+ * This will be updated with delimit placeholders as it is being processed.
+ * @param location
+ * The start/stop location within the buffer to be processed.
+ * The start location will be updated as the buffer is being processed.
+ * The start location will represent where the read stopped on return.
+ * A start location past the stop location or buffer used means that the entire range was processed.
+ * @param found
+ * A set of all locations where a valid content was found.
+ *
+ * @return
+ * fl_fss_found_content on success and content was found (start location is at end of content).
+ * fl_fss_found_no_content on success and no content was found (start location is after character designating this is not a content).
+ * f_none_on_stop on success after reaching stopping point (a valid content is not yet confirmed).
+ * f_none_on_eos on success after reaching the end of the buffer (a valid content is not yet confirmed).
+ * f_no_data_on_stop no data found after reaching stopping point (essentially only comments are found).
+ * f_no_data_on_eos no content found after reaching the end of the buffer (essentially only comments are found).
+ * f_incomplete_utf_on_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf_on_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_fss_extended_list_content_read_
+ extern f_return_status fl_fss_extended_list_content_read(f_string_dynamic *buffer, f_string_location *location, f_fss_content *found);
+#endif // _di_fl_fss_extended_list_content_read_
+
+/**
+ * Write an fss-0003 object.
+ *
+ * This will write the given string range as a valid object.
+ * Anything within this range will be escaped as necessary.
+ * This will stop if EOL is reached.
+ *
+ * @param object
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the object string to write as an object.
+ * @param buffer
+ * The buffer where the object is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_no_data_on_eol if there is no data to write and EOL was reached (@todo: review related code and detemine what this is doing).
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_fss_extended_list_object_write_
+ extern f_return_status fl_fss_extended_list_object_write(const f_string_dynamic object, f_string_location *location, f_string_dynamic *buffer);
+#endif // _di_fl_fss_extended_list_object_write_
+
+/**
+ * Write an fss-0003 content.
+ *
+ * This will write the given string range as a valid content.
+ * Anything within this range will be escaped as necessary.
+ *
+ * @param content
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param location
+ * The start/stop location within the content string to write as an content.
+ * @param buffer
+ * The buffer where the content is written to.
+ * This will be auto-incremented and must not be a static string.
+ *
+ * @return
+ * f_none on success.
+ * f_none_on_stop on success after reaching stopping point .
+ * f_none_on_eos on success after reaching the end of the buffer.
+ * f_no_data_on_stop no data to write due start location being greater than stop location.
+ * f_no_data_on_eos no data to write due start location being greater than or equal to buffer size.
+ * f_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * f_invalid_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ * f_reallocation_error (with error bit) on reallocation error.
+ * f_invalid_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_fl_fss_extended_list_content_write_
+ extern f_return_status fl_fss_extended_list_content_write(const f_string_dynamic content, f_string_location *location, f_string_dynamic *buffer);
+#endif // _di_fl_fss_extended_list_content_write_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _FL_fss_extended_list_h
#endif // _di_fl_macro_fss_apply_delimit_placeholders_
#ifndef _di_fl_macro_fss_skip_past_delimit_placeholders_
- #define fl_macro_fss_skip_past_delimit_placeholders(buffer, input) \
- while (buffer.string[input.start] == f_fss_delimit_placeholder) { \
- ++input.start;\
+ #define fl_macro_fss_skip_past_delimit_placeholders(buffer, location) \
+ while (buffer.string[location.start] == f_fss_delimit_placeholder) { \
+ ++location.start;\
\
- if (input.start >= buffer.used) break; \
- if (input.start > input.stop) break; \
+ if (location.start >= buffer.used) break; \
+ if (location.start > location.stop) break; \
} // while
#endif // _di_fl_macro_fss_skip_past_delimit_placeholders_
#ifndef _di_fl_macro_fss_object_return_on_overflow_
- #define fl_macro_fss_object_return_on_overflow(buffer, input, found, delimits, eos_status, stop_status) \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_object_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
found.stop = buffer.used - 1; \
return eos_status; \
} \
- else if (input.start > input.stop) { \
+ else if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.stop = input.stop; \
+ found.stop = location.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_object_return_on_overflow_
#ifndef _di_fl_macro_fss_object_delimited_return_on_overflow_
- #define fl_macro_fss_object_delimited_return_on_overflow(buffer, input, found, delimits, eos_status, stop_status) \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_object_delimited_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
found.stop = buffer.used - 1; \
return eos_status; \
} \
- else if (input.start > input.stop) { \
+ else if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
} \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.stop = input.stop; \
+ found.stop = location.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_object_delimited_return_on_overflow_
#ifndef _di_fl_macro_fss_content_return_on_overflow_
- #define fl_macro_fss_content_return_on_overflow(buffer, input, found, delimits, eos_status, stop_status) \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_content_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
found.array[found.used].stop = buffer.used - 1; \
return eos_status; \
} \
- else if (input.start > input.stop) { \
+ else if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.array[found.used].stop = input.stop; \
+ found.array[found.used].stop = location.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_content_return_on_overflow_
#ifndef _di_fl_macro_fss_content_delimited_return_on_overflow_
- #define fl_macro_fss_content_delimited_return_on_overflow(buffer, input, found, delimits, eos_status, stop_status) \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_content_delimited_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
found.array[found.used].stop = buffer.used - 1; \
return eos_status; \
} \
- else if (input.start > input.stop) { \
+ else if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
} \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.array[found.used].stop = input.stop; \
+ found.array[found.used].stop = location.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_content_delimited_return_on_overflow_
#ifndef _di_fl_macro_fss_content_return_on_overflow_reset_
- #define fl_macro_fss_content_return_on_overflow_reset(buffer, input, found, delimits, eos_status, stop_status, set_stop) \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_content_return_on_overflow_reset(buffer, location, found, delimits, eos_status, stop_status, set_stop) \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- input.start = set_stop; \
+ location.start = set_stop; \
found.array[found.used].stop = set_stop; \
return eos_status; \
} \
- else if (input.start > input.stop) { \
+ else if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- input.start = set_stop; \
+ location.start = set_stop; \
found.array[found.used].stop = set_stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_content_return_on_overflow_reset_
#ifndef _di_fl_macro_fss_content_delimited_return_on_overflow_reset_
- #define fl_macro_fss_content_delimited_return_on_overflow_reset(buffer, input, found, delimits, eos_status, stop_status, set_stop) \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_content_delimited_return_on_overflow_reset(buffer, location, found, delimits, eos_status, stop_status, set_stop) \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
} \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- input.start = set_stop; \
+ location.start = set_stop; \
found.array[found.used].stop = set_stop; \
return eos_status; \
} \
- else if (input.start > input.stop) { \
+ else if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
} \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- input.start = set_stop; \
+ location.start = set_stop; \
found.array[found.used].stop = set_stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_allocate_content_if_necessary_
#ifndef _di_fl_macro_fss_object_seek_till_newline_
- #define fl_macro_fss_object_seek_till_newline(buffer, input, delimits, eos_status, stop_status) \
- while (buffer.string[input.start] != f_string_eol) { \
- ++input.start; \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_object_seek_till_newline(buffer, location, delimits, eos_status, stop_status) \
+ while (buffer.string[location.start] != f_string_eol) { \
+ ++location.start; \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
return eos_status; \
} \
- if (input.start > input.stop) { \
+ if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
#endif // _di_fl_macro_fss_object_seek_till_newline_
#ifndef _di_fl_macro_fss_object_delimited_seek_till_newline_
- #define fl_macro_fss_object_delimited_seek_till_newline(buffer, input, delimits, eos_status, stop_status) \
- while (buffer.string[input.start] != f_string_eol) { \
- ++input.start; \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_object_delimited_seek_till_newline(buffer, location, delimits, eos_status, stop_status) \
+ while (buffer.string[location.start] != f_string_eol) { \
+ ++location.start; \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
\
return eos_status; \
} \
- if (input.start > input.stop) { \
+ if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
#endif // _di_fl_macro_fss_object_delimited_seek_till_newline_
#ifndef _di_fl_macro_fss_content_seek_till_newline_
- #define fl_macro_fss_content_seek_till_newline(buffer, input, found, delimits, eos_status, stop_status) \
- while (buffer.string[input.start] != f_string_eol) { \
- ++input.start; \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_content_seek_till_newline(buffer, location, found, delimits, eos_status, stop_status) \
+ while (buffer.string[location.start] != f_string_eol) { \
+ ++location.start; \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.array[found.used].stop = input.stop; \
+ found.array[found.used].stop = location.stop; \
return eos_status; \
} \
- if (input.start > input.stop) { \
+ if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.array[found.used].stop = input.stop; \
+ found.array[found.used].stop = location.stop; \
return stop_status; \
} \
} // while
#endif // _di_fl_macro_fss_content_seek_till_newline_
#ifndef _di_fl_macro_fss_content_delimited_seek_till_newline_
- #define fl_macro_fss_content_delimited_seek_till_newline(buffer, input, found, delimits, eos_status, stop_status) \
- while (buffer.string[input.start] != f_string_eol) { \
- ++input.start; \
- if (input.start >= buffer.used) { \
+ #define fl_macro_fss_content_delimited_seek_till_newline(buffer, location, found, delimits, eos_status, stop_status) \
+ while (buffer.string[location.start] != f_string_eol) { \
+ ++location.start; \
+ if (location.start >= buffer.used) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
} \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.array[found.used].stop = input.stop; \
+ found.array[found.used].stop = location.stop; \
return eos_status; \
} \
- if (input.start > input.stop) { \
+ if (location.start > location.stop) { \
f_status allocation_status = f_none; \
f_string_length i = 0; \
\
} \
f_macro_string_lengths_delete(allocation_status, delimits); \
\
- found.array[found.used].stop = input.stop; \
+ found.array[found.used].stop = location.stop; \
return stop_status; \
} \
} // while
default:
*string = 0;
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
return f_none;
*
* @return
* f_none on success.
- * f_invalid_data if there status is unknown.
+ * f_invalid_data (with error bit) if there status is unknown.
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_status_to_string_
// numbers are not valid status code strings.
if ((status = f_is_decimal(string[0])) == f_true) {
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
if (f_status_is_error(status)) {
return f_none;
}
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
#endif // _di_fll_fss_status_from_string_
// numbers are not valid status code strings.
if ((status = f_is_decimal(string[0])) == f_true) {
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
if (f_status_is_error(status)) {
return f_none;
}
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
#endif // _di_fll_status_from_string_
* @return
* f_none on success.
* f_no_data if string is empty.
- * f_invalid_data if not found.
+ * f_invalid_data (with error bit) if not found.
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fll_status_from_string_
firewall_delete_local_data(&local);
firewall_delete_data(data);
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
}
firewall_delete_local_data(&local);
firewall_delete_data(data);
- return f_invalid_data;
+ return f_status_set_error(f_invalid_data);
}
}
"Object 1" "This is a single quoted Content." \"Additional unquoted Content\"
Object_2 This is multiple\" Contents and the trailing quote does not need to be delimited.
-All specifications are expected to support or be of the character encoding utf-8; however, there is no imposed restriction on supporting or using any other encoding.
+All specifications are expected to support or be of the character encoding UTF-8; however, there is no imposed restriction on supporting or using any other encoding.
Those encodings must only support the appropriate characters required by a given standard for differentiating Objects, Contents, and delimits.
Unless explicitly defined, comments are designated by the pound symbol '#' but only if only whitespace is to the left of the pound.
There is no support for inline comments.
+Unless explicitly defined, all designation characters must be in ASCII.
+With designation characters being any character code used to designate how to read a file (such as a colon ':' at the end of a basic list).
+This keeps the processing and logic simple, for UTF-8.
+Whitespace used for designation characters must include support UTF-8 whitespace characters, unless explicitly designate not to.
+Control characters used for designation characters must include support UTF-8 control character support, unless explicitly designate not to.
+
+The UTF-8 BOM is not allowed as a "BOM", instead it must always be treated as the character represented by its code (unless explicitly allowed).
+
The follow specifications are defined in this project.
Each of these specifications has a common name associated with the specification number.
- fss-0000: Basic