#include "color.h"
+#include "private-color.h"
#ifdef __cplusplus
extern "C" {
}
}
- f_status_t status = f_color_save_1(context->format, context->list.reset, &context->reset);
+ f_status_t status = private_f_color_save_1(context->format, context->list.reset, &context->reset);
if (F_status_is_error_not(status)) {
- status = f_color_save_1(context->format, context->list.yellow, &context->warning);
+ status = private_f_color_save_1(context->format, context->list.yellow, &context->warning);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_2(context->format, context->list.bold, context->list.red, &context->error);
+ status = private_f_color_save_2(context->format, context->list.bold, context->list.red, &context->error);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_2(context->format, context->list.bold, context->list.green, &context->success);
+ status = private_f_color_save_2(context->format, context->list.bold, context->list.green, &context->success);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_1(context->format, context->list.bold, &context->notable);
+ status = private_f_color_save_1(context->format, context->list.bold, &context->notable);
}
if (use_light_colors) {
if (F_status_is_error_not(status)) {
- status = f_color_save_2(context->format, context->list.bold, context->list.blue, &context->title);
+ status = private_f_color_save_2(context->format, context->list.bold, context->list.blue, &context->title);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_1(context->format, context->list.blue, &context->important);
+ status = private_f_color_save_1(context->format, context->list.blue, &context->important);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_1(context->format, context->list.purple, &context->standout);
+ status = private_f_color_save_1(context->format, context->list.purple, &context->standout);
}
if (F_status_is_error_not(status)) {
}
else {
if (F_status_is_error_not(status)) {
- status = f_color_save_2(context->format, context->list.bold, context->list.yellow, &context->title);
+ status = private_f_color_save_2(context->format, context->list.bold, context->list.yellow, &context->title);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_2(context->format, context->list.bold, context->list.green, &context->important);
+ status = private_f_color_save_2(context->format, context->list.bold, context->list.green, &context->important);
}
if (F_status_is_error_not(status)) {
- status = f_color_save_1(context->format, context->list.green, &context->standout);
+ status = private_f_color_save_1(context->format, context->list.green, &context->standout);
}
if (F_status_is_error_not(status)) {
context->set.warning.before = &context->warning;
context->set.warning.after = &context->reset;
+
+ status = F_none;
}
return status;
if (!buffer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- f_status_t status = F_none;
-
- status = f_string_dynamic_increase_by(format.begin.used + format.end.used + color1.used + 1, buffer);
- if (F_status_is_error(status)) return status;
-
- if (format.begin.used) {
- memcpy(buffer->string + buffer->used, format.begin.string, sizeof(f_char_t) * format.begin.used);
-
- buffer->used += format.begin.used;
- }
-
- if (color1.used) {
- memcpy(buffer->string + buffer->used, color1.string, sizeof(f_char_t) * color1.used);
-
- buffer->used += color1.used;
- }
-
- if (format.end.used) {
- memcpy(buffer->string + buffer->used, format.end.string, sizeof(f_char_t) * format.end.used);
-
- buffer->used += format.end.used;
- }
-
- buffer->string[buffer->used] = 0;
-
- return F_none;
+ return private_f_color_save_1(format, color1, buffer);
}
#endif // _di_f_color_save_1_
if (!buffer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- f_status_t status = F_none;
-
- status = f_string_dynamic_increase_by(format.begin.used + format.medium.used + format.end.used + color1.used + color2.used + 1, buffer);
- if (F_status_is_error(status)) return status;
-
- if (format.begin.used) {
- memcpy(buffer->string + buffer->used, format.begin.string, sizeof(f_char_t) * format.begin.used);
-
- buffer->used += format.begin.used;
- }
-
- if (color1.used) {
- memcpy(buffer->string + buffer->used, color1.string, sizeof(f_char_t) * color1.used);
-
- buffer->used += color1.used;
- }
-
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
-
- buffer->used += format.medium.used;
- }
-
- if (color2.used) {
- memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
-
- buffer->used += color2.used;
- }
-
- if (format.end.used) {
- memcpy(buffer->string + buffer->used, format.end.string, sizeof(f_char_t) * format.end.used);
-
- buffer->used += format.end.used;
- }
-
- buffer->string[buffer->used] = 0;
-
- return F_none;
+ return private_f_color_save_2(format, color1, color2, buffer);
}
#endif // _di_f_color_save_2_
if (!buffer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- f_status_t status = F_none;
-
- status = f_string_dynamic_increase_by(format.begin.used + (format.medium.used * 2) + format.end.used + color1.used + color2.used + color3.used + 1, buffer);
+ f_status_t status = f_string_dynamic_increase_by(format.begin.used + (format.medium.used * 2) + format.end.used + color1.used + color2.used + color3.used + 1, buffer);
if (F_status_is_error(status)) return status;
- if (format.begin.used) {
- memcpy(buffer->string + buffer->used, format.begin.string, sizeof(f_char_t) * format.begin.used);
-
- buffer->used += format.begin.used;
- }
-
if (color1.used) {
memcpy(buffer->string + buffer->used, color1.string, sizeof(f_char_t) * color1.used);
buffer->used += color1.used;
- }
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color2.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color2.used) {
- memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
+ memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
- buffer->used += color2.used;
- }
+ buffer->used += color2.used;
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color3.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color3.used) {
- memcpy(buffer->string + buffer->used, color3.string, sizeof(f_char_t) * color3.used);
+ memcpy(buffer->string + buffer->used, color3.string, sizeof(f_char_t) * color3.used);
- buffer->used += color3.used;
+ buffer->used += color3.used;
+ }
+ }
}
if (format.end.used) {
if (!buffer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- f_status_t status = F_none;
-
- status = f_string_dynamic_increase_by(format.begin.used + (format.medium.used * 3) + format.end.used + color1.used + color2.used + color3.used + color4.used + 1, buffer);
+ f_status_t status = f_string_dynamic_increase_by(format.begin.used + (format.medium.used * 3) + format.end.used + color1.used + color2.used + color3.used + color4.used + 1, buffer);
if (F_status_is_error(status)) return status;
- if (format.begin.used) {
- memcpy(buffer->string + buffer->used, format.begin.string, sizeof(f_char_t) * format.begin.used);
-
- buffer->used += format.begin.used;
- }
-
if (color1.used) {
memcpy(buffer->string + buffer->used, color1.string, sizeof(f_char_t) * color1.used);
buffer->used += color1.used;
- }
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color2.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color2.used) {
- memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
+ memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
- buffer->used += color2.used;
- }
+ buffer->used += color2.used;
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color3.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color3.used) {
- memcpy(buffer->string + buffer->used, color3.string, sizeof(f_char_t) * color3.used);
+ memcpy(buffer->string + buffer->used, color3.string, sizeof(f_char_t) * color3.used);
- buffer->used += color3.used;
- }
+ buffer->used += color3.used;
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color4.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color4.used) {
- memcpy(buffer->string + buffer->used, color4.string, sizeof(f_char_t) * color4.used);
+ memcpy(buffer->string + buffer->used, color4.string, sizeof(f_char_t) * color4.used);
- buffer->used += color4.used;
+ buffer->used += color4.used;
+ }
+ }
+ }
}
if (format.end.used) {
if (!buffer) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- f_status_t status = F_none;
-
- status = f_string_dynamic_increase_by(format.begin.used + (format.medium.used * 4) + format.end.used + color1.used + color2.used + color3.used + color4.used + color5.used + 1, buffer);
+ f_status_t status = f_string_dynamic_increase_by(format.begin.used + (format.medium.used * 4) + format.end.used + color1.used + color2.used + color3.used + color4.used + color5.used + 1, buffer);
if (F_status_is_error(status)) return status;
if (format.begin.used) {
memcpy(buffer->string + buffer->used, color1.string, sizeof(f_char_t) * color1.used);
buffer->used += color1.used;
- }
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color2.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color2.used) {
- memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
+ memcpy(buffer->string + buffer->used, color2.string, sizeof(f_char_t) * color2.used);
- buffer->used += color2.used;
- }
+ buffer->used += color2.used;
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color3.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color3.used) {
- memcpy(buffer->string + buffer->used, color3.string, sizeof(f_char_t) * color3.used);
+ memcpy(buffer->string + buffer->used, color3.string, sizeof(f_char_t) * color3.used);
- buffer->used += color3.used;
- }
+ buffer->used += color3.used;
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color4.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color4.used) {
- memcpy(buffer->string + buffer->used, color4.string, sizeof(f_char_t) * color4.used);
+ memcpy(buffer->string + buffer->used, color4.string, sizeof(f_char_t) * color4.used);
- buffer->used += color4.used;
- }
+ buffer->used += color4.used;
- if (format.medium.used) {
- memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
+ if (color5.used) {
+ if (format.medium.used) {
+ memcpy(buffer->string + buffer->used, format.medium.string, sizeof(f_char_t) * format.medium.used);
- buffer->used += format.medium.used;
- }
+ buffer->used += format.medium.used;
+ }
- if (color5.used) {
- memcpy(buffer->string + buffer->used, color5.string, sizeof(f_char_t) * color5.used);
+ memcpy(buffer->string + buffer->used, color5.string, sizeof(f_char_t) * color5.used);
- buffer->used += color5.used;
+ buffer->used += color5.used;
+ }
+ }
+ }
+ }
}
if (format.end.used) {
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_color_save_1()
- * Errors (with error bit) from: f_color_save_2()
+ * Errors (with error bit) from: f_string_dynamic_increase_by()
+ *
+ * @see memcpy()
*
- * @see f_color_save_1()
- * @see f_color_save_2()
+ * @see f_string_dynamic_increase_by()
*/
#ifndef _di_f_color_load_context_
extern f_status_t f_color_load_context(const bool use_light_colors, f_color_context_t * const context);
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_string_dynamic_append()
* Errors (with error bit) from: f_string_dynamic_increase_by()
*
- * @see f_string_dynamic_append()
+ * @see memcpy()
+ *
* @see f_string_dynamic_increase_by()
*/
#ifndef _di_f_color_save_1_
* A color to assign.
* @param color2
* A second color to assign.
+ * Ignored if color1.used is 0.
* @param buffer
* The string to save the colors to.
* The buffer will become NULL terminated after the appended string length.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_string_dynamic_append()
* Errors (with error bit) from: f_string_dynamic_increase_by()
*
- * @see f_string_dynamic_append()
+ * @see memcpy()
+ *
* @see f_string_dynamic_increase_by()
*/
#ifndef _di_f_color_save_2_
* A color to assign.
* @param color2
* A second color to assign.
+ * Ignored if color1.used is 0.
* @param color3
* A third color to assign.
+ * Ignored if color1.used or color2.used is 0.
* @param buffer
* The string to save the colors to.
* The buffer will become NULL terminated after the appended string length.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_string_dynamic_append()
* Errors (with error bit) from: f_string_dynamic_increase_by()
*
- * @see f_string_dynamic_append()
+ * @see memcpy()
+ *
* @see f_string_dynamic_increase_by()
*/
#ifndef _di_f_color_save_3_
* A color to assign.
* @param color2
* A second color to assign.
+ * Ignored if color1.used is 0.
* @param color3
* A third color to assign.
+ * Ignored if color1.used or color2.used is 0.
* @param color4
* A fourth color to assign.
+ * Ignored if color1.used, color2.used, or color3.used is 0.
* @param buffer
* The string to save the colors to.
* The buffer will become NULL terminated after the appended string length.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_string_dynamic_append()
* Errors (with error bit) from: f_string_dynamic_increase_by()
*
- * @see f_string_dynamic_append()
+ * @see memcpy()
+ *
* @see f_string_dynamic_increase_by()
*/
#ifndef _di_f_color_save_4_
* A color to assign.
* @param color2
* A second color to assign.
+ * Ignored if color1.used is 0.
* @param color3
* A third color to assign.
+ * Ignored if color1.used or color2.used is 0.
* @param color4
* A fourth color to assign.
+ * Ignored if color1.used, color2.used, or color3.used is 0.
* @param color5
* A fifth color to assign.
+ * Ignored if color1.used, color2.used, color3.used, or color4.used is 0.
* @param buffer
* The string to save the colors to.
* The buffer will become NULL terminated after the appended string length.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_string_dynamic_append()
* Errors (with error bit) from: f_string_dynamic_increase_by()
*
- * @see f_string_dynamic_append()
+ * @see memcpy()
+ *
* @see f_string_dynamic_increase_by()
*/
#ifndef _di_f_color_save_5_