From: Kevin Day Date: Thu, 12 Sep 2019 22:17:19 +0000 (-0500) Subject: Update: use int8_t instead of char X-Git-Tag: 0.5.0~420 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=2d7e36addb92ede10653f2d764a53039bc15285d;p=fll Update: use int8_t instead of char Guarantee that we are always dealing with 1-byte values by using int8_t instead of char. They should be identical, but this prevents a given system from doing something different. char by default is signed. --- diff --git a/level_0/f_color/c/color.h b/level_0/f_color/c/color.h index 88e08d8..cff1510 100644 --- a/level_0/f_color/c/color.h +++ b/level_0/f_color/c/color.h @@ -37,11 +37,11 @@ extern "C" { */ #ifndef _di_f_color_control_ typedef struct f_color_control { - const char *blink; - const char *bold; - const char *conceal; - const char *reverse; - const char *underline; + const int8_t *blink; + const int8_t *bold; + const int8_t *conceal; + const int8_t *reverse; + const int8_t *underline; } f_color_control; #define f_color_control_names_initialize { "blink", "bold", "conceal", "reverse", "underline" } @@ -52,12 +52,12 @@ extern "C" { */ #ifndef _di_f_color_standard_io_ typedef struct { - const char *error; - const char *message; - const char *warning; - const char *strong_error; - const char *strong_message; - const char *strong_warning; + const int8_t *error; + const int8_t *message; + const int8_t *warning; + const int8_t *strong_error; + const int8_t *strong_message; + const int8_t *strong_warning; } f_color_standard_io; #define f_color_standard_io_names_initialize { "error", "message", "warning", "strong_error", "strong_message", "strong_warning" } @@ -76,15 +76,15 @@ extern "C" { */ #ifndef _di_f_color_help_ typedef struct { - const char *alert; - const char *command; - const char *comment; - const char *emphasize; - const char *standard; - const char *syntax; - const char *title; - const char *topic; - const char *version; + const int8_t *alert; + const int8_t *command; + const int8_t *comment; + const int8_t *emphasize; + const int8_t *standard; + const int8_t *syntax; + const int8_t *title; + const int8_t *topic; + const int8_t *version; } f_color_help; #define f_color_help_names_initialize { "alert", "command", "comment", "emphasize", "standard", "syntax", "title", "topic", "version" } @@ -92,9 +92,9 @@ extern "C" { #ifndef _di_f_color_format_ typedef struct { - const char *begin; - const char *end; - const char *medium; + const int8_t *begin; + const int8_t *end; + const int8_t *medium; } f_color_format; #define f_color_format_initialize_linux { "\033[", "m", ";" } @@ -112,44 +112,44 @@ extern "C" { */ #ifndef _di_f_color_ typedef struct { - const char *reset; - const char *bold; - const char *underline; - const char *blink; - const char *reverse; - const char *conceal; - const char *black; - const char *red; - const char *green; - const char *yellow; - const char *blue; - const char *purple; - const char *teal; - const char *white; - const char *black_bg; - const char *red_bg; - const char *green_bg; - const char *yellow_bg; - const char *blue_bg; - const char *purple_bg; - const char *teal_bg; - const char *white_bg; - const char *bright_black; - const char *bright_red; - const char *bright_green; - const char *bright_yellow; - const char *bright_blue; - const char *bright_purple; - const char *bright_teal; - const char *bright_white; - const char *bright_black_bg; - const char *bright_red_bg; - const char *bright_green_bg; - const char *bright_yellow_bg; - const char *bright_blue_bg; - const char *bright_purple_bg; - const char *bright_teal_bg; - const char *bright_white_bg; + const int8_t *reset; + const int8_t *bold; + const int8_t *underline; + const int8_t *blink; + const int8_t *reverse; + const int8_t *conceal; + const int8_t *black; + const int8_t *red; + const int8_t *green; + const int8_t *yellow; + const int8_t *blue; + const int8_t *purple; + const int8_t *teal; + const int8_t *white; + const int8_t *black_bg; + const int8_t *red_bg; + const int8_t *green_bg; + const int8_t *yellow_bg; + const int8_t *blue_bg; + const int8_t *purple_bg; + const int8_t *teal_bg; + const int8_t *white_bg; + const int8_t *bright_black; + const int8_t *bright_red; + const int8_t *bright_green; + const int8_t *bright_yellow; + const int8_t *bright_blue; + const int8_t *bright_purple; + const int8_t *bright_teal; + const int8_t *bright_white; + const int8_t *bright_black_bg; + const int8_t *bright_red_bg; + const int8_t *bright_green_bg; + const int8_t *bright_yellow_bg; + const int8_t *bright_blue_bg; + const int8_t *bright_purple_bg; + const int8_t *bright_teal_bg; + const int8_t *bright_white_bg; } f_color; #define f_color_initialize_linux { "0", "1", "4", "5", "7", "8", "30", "31", "32", "33", "34", "35", "36", "37", "40", "41", "42", "43", "44", "45", "46", "47", "30", "31", "32", "33", "34", "35", "36", "37", "40", "41", "42", "43", "44", "45", "46", "47" } diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index 43ff9ec..cbaf57c 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -140,9 +140,9 @@ extern "C" { */ #ifndef _di_f_console_parameter_ typedef struct { - const char *symbol_short; - const char *symbol_long; - const char *symbol_other; + const int8_t *symbol_short; + const int8_t *symbol_long; + const int8_t *symbol_other; const uint8_t has_additional; const uint8_t type; diff --git a/level_0/f_conversion/c/conversion.c b/level_0/f_conversion/c/conversion.c index bc88d70..4f57bd8 100644 --- a/level_0/f_conversion/c/conversion.c +++ b/level_0/f_conversion/c/conversion.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_f_is_decimal_ - f_return_status f_is_decimal(const char character) { + f_return_status f_is_decimal(const int8_t character) { if (character > 0x29 && character < 0x40) { return f_true; @@ -16,7 +16,7 @@ extern "C" { #endif // _di_f_is_decimal_ #ifndef _di_f_is_hexidecimal_ - f_return_status f_is_hexidecimal(const char character) { + f_return_status f_is_hexidecimal(const int8_t character) { if (character > 0x29 && character < 0x40) { return f_true; @@ -33,7 +33,7 @@ extern "C" { #endif // _di_f_is_hexidecimal_ #ifndef _di_f_character_to_decimal_ - f_return_status f_character_to_decimal(const char character, unsigned long *decimal) { + f_return_status f_character_to_decimal(const int8_t character, unsigned long *decimal) { #ifndef _di_level_0_parameter_checking_ if (decimal == 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ @@ -58,7 +58,7 @@ extern "C" { #endif // _di_f_character_to_decimal_ #ifndef _di_f_character_to_hexidecimal_ - f_return_status f_character_to_hexidecimal(const char character, unsigned long *decimal) { + f_return_status f_character_to_hexidecimal(const int8_t character, unsigned long *decimal) { #ifndef _di_level_0_parameter_checking_ if (decimal == 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_conversion/c/conversion.h b/level_0/f_conversion/c/conversion.h index f05bc6d..9e47bc4 100644 --- a/level_0/f_conversion/c/conversion.h +++ b/level_0/f_conversion/c/conversion.h @@ -33,7 +33,7 @@ extern "C" { * f_false if character is not a decimal. */ #ifndef _di_f_is_decimal_ - extern f_return_status f_is_decimal(const char character); + extern f_return_status f_is_decimal(const int8_t character); #endif // _di_f_is_decimal_ /** @@ -47,7 +47,7 @@ extern "C" { * f_false if character is not a hexidecimal. */ #ifndef _di_f_is_hexidecimal_ - extern f_return_status f_is_hexidecimal(const char character); + extern f_return_status f_is_hexidecimal(const int8_t character); #endif // _di_f_is_hexidecimal_ /** @@ -65,7 +65,7 @@ extern "C" { * f_invalid_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_character_to_decimal_ - extern f_return_status f_character_to_decimal(const char character, unsigned long *decimal); + extern f_return_status f_character_to_decimal(const int8_t character, unsigned long *decimal); #endif // _di_f_character_to_decimal_ /** @@ -83,7 +83,7 @@ extern "C" { * f_invalid_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_character_to_hexidecimal_ - extern f_return_status f_character_to_hexidecimal(const char character, unsigned long *decimal); + extern f_return_status f_character_to_hexidecimal(const int8_t character, unsigned long *decimal); #endif // _di_f_character_to_hexidecimal_ /** diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 35947a2..66b86e2 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -85,7 +85,7 @@ extern "C" { f_file_mode mode; } f_file; - #define f_file_initialize { 0, sizeof(char), 0, (f_file_mode) f_file_read_only } + #define f_file_initialize { 0, sizeof(int8_t), 0, (f_file_mode) f_file_read_only } #endif // _di_f_file_ /** diff --git a/level_0/f_memory/c/memory.c b/level_0/f_memory/c/memory.c index 5dce5c9..8cf5dd4 100644 --- a/level_0/f_memory/c/memory.c +++ b/level_0/f_memory/c/memory.c @@ -99,9 +99,9 @@ extern "C" { if (new_pointer) { if (new_pointer != *pointer) { if (new_length > old_length) { - // char * is of a data type size of 1, casting it to char should result in a single-length increment. + // uint8_t * is of a data type size of 1, casting it to uint8_t should result in a single-length increment. // this is done to avoid problems with (void *) having arithmetic issues. - memset(((char *) new_pointer) + (type * old_length), 0, type * (new_length - old_length)); + memset(((uint8_t *) new_pointer) + (type * old_length), 0, type * (new_length - old_length)); } *pointer = new_pointer; @@ -142,9 +142,9 @@ extern "C" { if (old_length > 0) { if (new_length < old_length) { - // char * is of a data type size of 1, casting it to char should result in a single-length increment. + // uint8_t * is of a data type size of 1, casting it to uint8_t should result in a single-length increment. // this is done to avoid problems with (void *) having arithmetic issues. - memset(((char *)*pointer) + new_length, 0, type * (old_length - new_length)); + memset(((uint8_t *)*pointer) + new_length, 0, type * (old_length - new_length)); } } @@ -164,9 +164,9 @@ extern "C" { if (new_pointer) { if (new_pointer != *pointer) { if (new_length > old_length) { - // char * is of a data type size of 1, casting it to bool should result in a single-length increment. + // uint8_t * is of a data type size of 1, casting it to bool should result in a single-length increment. // this is done to avoid problems with (void *) having arithmetic issues. - memset(((char *)new_pointer) + (type * old_length), 0, type * (new_length - old_length)); + memset(((uint8_t *)new_pointer) + (type * old_length), 0, type * (new_length - old_length)); } *pointer = new_pointer; diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 6576c74..2bea0b0 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -63,14 +63,14 @@ extern "C" { * The max size is to be the (max supported size - 1) such that that last number can be used for overflow operations. */ #ifndef _di_f_type_sizes_ - #define f_unsigned_char_size (((unsigned char) -1) - 1) + #define f_unsigned_char_size (((uint8_t) -1) - 1) #define f_unsigned_short_size (((unsigned short) -1) - 1) #define f_unsigned_int_size (((unsigned int) -1) - 1) #define f_unsigned_long_size (((unsigned long) -1) - 1) #define f_unsigned_long_long_size (((unsigned long long) -1) - 1) #define f_unsigned_double_size (((unsigned double) -1) - 1) #define f_unsigned_long_double_size (((unsigned double) -1) - 1) - #define f_signed_char_size ((((unsigned char) -1) / 2) - 1) + #define f_signed_char_size ((((uint8_t) -1) / 2) - 1) #define f_signed_short_size ((((unsigned short) -1) / 2) - 1) #define f_signed_int_size ((((unsigned int) -1) / 2) - 1) #define f_signed_long_size ((((unsigned long) -1) / 2) - 1) diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index ff26f87..5d4e425 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -7,7 +7,7 @@ extern "C" { #ifndef _di_f_utf_is_big_endian_ f_return_status f_utf_is_big_endian() { uint16_t test_int = (0x01 << 8) | 0x02; - char test_char[2] = {0x01, 0x02}; + int8_t test_char[2] = {0x01, 0x02}; if (!memcmp(&test_int, test_char, 2)) { return f_true; @@ -457,7 +457,7 @@ extern "C" { unsigned short width = f_macro_utf_character_width_is(character); if (width == 0) { - char ascii = character >> 24; + int8_t ascii = character >> 24; if (isspace(ascii)) { return f_true; @@ -670,7 +670,7 @@ extern "C" { unsigned short width = f_macro_utf_character_width_is(character); if (width == 0) { - char ascii = character >> 24; + int8_t ascii = character >> 24; if (isspace(ascii)) { return f_true; @@ -873,7 +873,7 @@ extern "C" { *max_width = width; if (f_utf_is_big_endian()) { - memcpy(*character, &utf_character, sizeof(char) * width); + memcpy(*character, &utf_character, sizeof(int8_t) * width); } else { uint32_t utf = 0; @@ -891,7 +891,7 @@ extern "C" { utf = (f_macro_utf_character_to_char_4(utf_character) << 24) | (f_macro_utf_character_to_char_3(utf_character) << 16) | (f_macro_utf_character_to_char_2(utf_character) << 8) | f_macro_utf_character_to_char_1(utf_character); } - memcpy(*character, &utf, sizeof(char) * width); + memcpy(*character, &utf, sizeof(int8_t) * width); } return f_none; diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index d1e6939..93c25a5 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -58,7 +58,7 @@ extern "C" { #ifndef _di_f_utf_bom_ #define f_utf_bom_length 3 - const static char f_utf_bom[f_utf_bom_length] = { 0xef, 0xbb, 0xbf }; // 1110 1111, 1011 1011, 1011 1111 + const static int8_t f_utf_bom[f_utf_bom_length] = { 0xef, 0xbb, 0xbf }; // 1110 1111, 1011 1011, 1011 1111 #endif // _di_f_utf_bom_ /** @@ -106,7 +106,7 @@ extern "C" { * This is intended to be used when a single variable is desired to represent a 1-byte, 2-byte, 3-byte, or even 4-byte character. * * This "character" type is stored as a big-endian 4-byte integer (32-bits). - * A helper function, f_utf_is_big_endian(), is provided to detect system endianness so that character arrays (char []) can be correctly processed. + * A helper function, f_utf_is_big_endian(), is provided to detect system endianness so that character arrays (int8_t []) can be correctly processed. * * The byte structure is intended to be read left to right. * @@ -114,9 +114,9 @@ extern "C" { * * The f_macro_utf_character_mask_char_* are used to get a specific UTF-8 block as a single character range. * - * The f_macro_utf_character_to_char_* are used to convert a f_utf_character into a char, for a given 8-bit block. + * The f_macro_utf_character_to_char_* are used to convert a f_utf_character into a int8_t, for a given 8-bit block. * - * The f_macro_utf_character_from_char_* are used to convert a char into part of a f_utf_character, for a given 8-bit block. + * The f_macro_utf_character_from_char_* are used to convert a int8_t into part of a f_utf_character, for a given 8-bit block. * * The f_macro_utf_character_width is used to determine the width of the UTF-8 character based on f_macro_utf_byte_width. * The f_macro_utf_character_width_is is used to determine the width of the UTF-8 character based on f_macro_utf_byte_width_is. @@ -456,32 +456,32 @@ extern "C" { #define f_utf_space_separator_line_length 3 #define f_utf_space_separator_paragraph_length 3 - const static char f_utf_space_em[f_utf_space_em_length] = { 0xe2, 0x80, 0x83 }; - const static char f_utf_space_em_quad[f_utf_space_em_quad_length] = { 0xe2, 0x80, 0x81 }; - const static char f_utf_space_em_per_three[f_utf_space_em_per_three_length] = { 0xe2, 0x80, 0x84 }; - const static char f_utf_space_em_per_four[f_utf_space_em_per_four_length] = { 0xe2, 0x80, 0x85 }; - const static char f_utf_space_em_per_six[f_utf_space_em_per_six_length] = { 0xe2, 0x80, 0x86 }; + const static int8_t f_utf_space_em[f_utf_space_em_length] = { 0xe2, 0x80, 0x83 }; + const static int8_t f_utf_space_em_quad[f_utf_space_em_quad_length] = { 0xe2, 0x80, 0x81 }; + const static int8_t f_utf_space_em_per_three[f_utf_space_em_per_three_length] = { 0xe2, 0x80, 0x84 }; + const static int8_t f_utf_space_em_per_four[f_utf_space_em_per_four_length] = { 0xe2, 0x80, 0x85 }; + const static int8_t f_utf_space_em_per_six[f_utf_space_em_per_six_length] = { 0xe2, 0x80, 0x86 }; - const static char f_utf_space_en[f_utf_space_en_length] = { 0xe2, 0x80, 0x82 }; - const static char f_utf_space_en_quad[f_utf_space_en_quad_length] = { 0xe2, 0x80, 0x80 }; + const static int8_t f_utf_space_en[f_utf_space_en_length] = { 0xe2, 0x80, 0x82 }; + const static int8_t f_utf_space_en_quad[f_utf_space_en_quad_length] = { 0xe2, 0x80, 0x80 }; - const static char f_utf_space_line_feed_reverse[f_utf_space_line_feed_reverse_length] = { 0xc2, 0x8d }; - const static char f_utf_space_line_next[f_utf_space_line_next_length] = { 0xc2, 0x85 }; + const static int8_t f_utf_space_line_feed_reverse[f_utf_space_line_feed_reverse_length] = { 0xc2, 0x8d }; + const static int8_t f_utf_space_line_next[f_utf_space_line_next_length] = { 0xc2, 0x85 }; - const static char f_utf_space_medium_mathematical[f_utf_space_medium_mathematical_length] = { 0xe2, 0x81, 0x9f }; + const static int8_t f_utf_space_medium_mathematical[f_utf_space_medium_mathematical_length] = { 0xe2, 0x81, 0x9f }; - const static char f_utf_space_no_break[f_utf_space_no_break_length] = { 0xc2, 0xa0 }; - const static char f_utf_space_no_break_narrow[f_utf_space_no_break_narrow_length] = { 0xe2, 0x80, 0xaf }; + const static int8_t f_utf_space_no_break[f_utf_space_no_break_length] = { 0xc2, 0xa0 }; + const static int8_t f_utf_space_no_break_narrow[f_utf_space_no_break_narrow_length] = { 0xe2, 0x80, 0xaf }; - const static char f_utf_space_ogham[f_utf_space_ogham_length] = { 0xe1, 0x9a, 0x80 }; - const static char f_utf_space_figure[f_utf_space_figure_length] = { 0xe2, 0x80, 0x87 }; - const static char f_utf_space_punctuation[f_utf_space_punctuation_length] = { 0xe2, 0x80, 0x88 }; - const static char f_utf_space_thin[f_utf_space_thin_length] = { 0xe2, 0x80, 0x89 }; - const static char f_utf_space_hair[f_utf_space_hair_length] = { 0xe2, 0x80, 0x8a }; - const static char f_utf_space_ideographic[f_utf_space_ideographic_length] = { 0xe3, 0x80, 0x80 }; + const static int8_t f_utf_space_ogham[f_utf_space_ogham_length] = { 0xe1, 0x9a, 0x80 }; + const static int8_t f_utf_space_figure[f_utf_space_figure_length] = { 0xe2, 0x80, 0x87 }; + const static int8_t f_utf_space_punctuation[f_utf_space_punctuation_length] = { 0xe2, 0x80, 0x88 }; + const static int8_t f_utf_space_thin[f_utf_space_thin_length] = { 0xe2, 0x80, 0x89 }; + const static int8_t f_utf_space_hair[f_utf_space_hair_length] = { 0xe2, 0x80, 0x8a }; + const static int8_t f_utf_space_ideographic[f_utf_space_ideographic_length] = { 0xe3, 0x80, 0x80 }; - const static char f_utf_space_separator_line[f_utf_space_separator_line_length] = { 0xe2, 0x80, 0xa8 }; - const static char f_utf_space_separator_paragraph[f_utf_space_separator_paragraph_length] = { 0xe2, 0x80, 0xa8 }; + const static int8_t f_utf_space_separator_line[f_utf_space_separator_line_length] = { 0xe2, 0x80, 0xa8 }; + const static int8_t f_utf_space_separator_paragraph[f_utf_space_separator_paragraph_length] = { 0xe2, 0x80, 0xa8 }; #endif // _di_f_utf_space_ /** @@ -500,13 +500,13 @@ extern "C" { #define f_utf_substitute_open_box_length 3 #define f_utf_substitute_open_box_shouldered_length 3 - const static char f_utf_substitute_symbol_blank[f_utf_substitute_symbol_blank_length] = { 0xe2, 0x90, 0xa2 }; - const static char f_utf_substitute_symbol_space[f_utf_substitute_symbol_space_length] = { 0xe2, 0x90, 0xa0 }; + const static int8_t f_utf_substitute_symbol_blank[f_utf_substitute_symbol_blank_length] = { 0xe2, 0x90, 0xa2 }; + const static int8_t f_utf_substitute_symbol_space[f_utf_substitute_symbol_space_length] = { 0xe2, 0x90, 0xa0 }; - const static char f_utf_substitute_middle_dot[f_utf_substitute_middle_dot_length] = { 0xc2, 0xb7 }; + const static int8_t f_utf_substitute_middle_dot[f_utf_substitute_middle_dot_length] = { 0xc2, 0xb7 }; - const static char f_utf_substitute_open_box[f_utf_substitute_open_box_length] = { 0xe2, 0x90, 0xa3 }; - const static char f_utf_substitute_open_box_shouldered[f_utf_substitute_open_box_shouldered_length] = { 0xe2, 0x8d, 0xbd }; + const static int8_t f_utf_substitute_open_box[f_utf_substitute_open_box_length] = { 0xe2, 0x90, 0xa3 }; + const static int8_t f_utf_substitute_open_box_shouldered[f_utf_substitute_open_box_shouldered_length] = { 0xe2, 0x8d, 0xbd }; #endif // _di_f_utf_substitute_ /** @@ -785,14 +785,14 @@ extern "C" { #endif // _di_f_utf_char_to_character_ /** - * Convert a specialized f_utf_character type to a char, stored as a string (character buffer). + * Convert a specialized f_utf_character type to a int8_t, stored as a string (character buffer). * * This will also convert ASCII characters stored in the utf_character array. * * @param utf_character * The UTF-8 characterr to convert from. * @param character - * A char representation of the UTF-8 character, stored as a string of width bytes. + * A int8_t representation of the UTF-8 character, stored as a string of width bytes. * If max_width is 0, then this should not be allocated (set the pointer address to 0). * @param max_width * The number of bytes the generated character represents. diff --git a/level_1/fl_color/c/color.c b/level_1/fl_color/c/color.c index 13ccc40..c77910b 100644 --- a/level_1/fl_color/c/color.c +++ b/level_1/fl_color/c/color.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fl_color_set_ - f_return_status fl_color_set(FILE *file, const f_color_format format, const char *color1, const char *color2, const char *color3, const char *color4, const char *color5) { + f_return_status fl_color_set(FILE *file, const f_color_format format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5) { #ifndef _di_level_1_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); if (color1 == 0) return f_status_set_error(f_invalid_parameter); @@ -27,7 +27,7 @@ extern "C" { #endif // _di_fl_color_set_ #ifndef _di_fl_color_save_ - f_return_status fl_color_save(f_string_dynamic *buffer, const f_color_format format, const char *color1, const char *color2, const char *color3, const char *color4, const char *color5) { + f_return_status fl_color_save(f_string_dynamic *buffer, const f_color_format format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5) { #ifndef _di_level_1_parameter_checking_ if (buffer == 0) return f_status_set_error(f_invalid_parameter); if (color1 == 0) return f_status_set_error(f_invalid_parameter); @@ -114,7 +114,7 @@ extern "C" { #endif // _di_fl_color_save_ #ifndef _di_fl_color_print_ - f_return_status fl_color_print(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const char *string, ...) { + f_return_status fl_color_print(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const int8_t *string, ...) { #ifndef _di_level_1_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); if (string == 0) return f_status_set_error(f_invalid_parameter); @@ -145,7 +145,7 @@ extern "C" { #endif // _di_fl_color_print_ #ifndef _di_fl_color_print_line_ - f_return_status fl_color_print_line(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const char *string, ...) { + f_return_status fl_color_print_line(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const int8_t *string, ...) { #ifndef _di_level_1_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); if (string == 0) return f_status_set_error(f_invalid_parameter); @@ -200,7 +200,7 @@ extern "C" { // switch to the appropriate terminal color mode { - char *environment = getenv("TERM"); + int8_t *environment = getenv("TERM"); if (!environment || strncmp(environment, "linux", 6) == 0) { context->color_list = f_color_linux; diff --git a/level_1/fl_color/c/color.h b/level_1/fl_color/c/color.h index 9f61be3..36152e5 100644 --- a/level_1/fl_color/c/color.h +++ b/level_1/fl_color/c/color.h @@ -125,7 +125,7 @@ extern "C" { * f_invalid_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_fl_color_set_ - extern f_return_status fl_color_set(FILE *file, const f_color_format format, const char *color1, const char *color2, const char *color3, const char *color4, const char *color5); + extern f_return_status fl_color_set(FILE *file, const f_color_format format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5); #define fl_macro_color_set_1(file, format, color1) fl_color_set(file, format, color1, 0, 0, 0, 0) #define fl_macro_color_set_2(file, format, color1, color2) fl_color_set(file, format, color1, color2, 0, 0, 0) @@ -160,7 +160,7 @@ extern "C" { * f_reallocation_error (with error bit) on memory reallocation error. */ #ifndef _di_fl_color_save_ - extern f_return_status fl_color_save(f_string_dynamic *buffer, const f_color_format format, const char *color1, const char *color2, const char *color3, const char *color4, const char *color5); + extern f_return_status fl_color_save(f_string_dynamic *buffer, const f_color_format format, const int8_t *color1, const int8_t *color2, const int8_t *color3, const int8_t *color4, const int8_t *color5); #define fl_macro_color_save_1(buffer, format, color1) fl_color_save(buffer, format, color1, 0, 0, 0, 0) #define fl_macro_color_save_2(buffer, format, color1, color2) fl_color_save(buffer, format, color1, color2, 0, 0, 0) @@ -193,7 +193,7 @@ extern "C" { * f_output_error (with error bit) on output error. */ #ifndef _di_fl_color_print_ - extern f_return_status fl_color_print(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const char *string, ...); + extern f_return_status fl_color_print(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const int8_t *string, ...); #endif // _di_fl_color_print_ /** @@ -220,7 +220,7 @@ extern "C" { * f_output_error (with error bit) on output error. */ #ifndef _di_fl_color_print_line_ - extern f_return_status fl_color_print_line(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const char *string, ...); + extern f_return_status fl_color_print_line(FILE *file, const f_string_dynamic start_color, const f_string_dynamic end_color, const int8_t *string, ...); #endif // _di_fl_color_print_line_ /** diff --git a/level_1/fl_directory/c/directory.c b/level_1/fl_directory/c/directory.c index 0ffb29d..3e7d760 100644 --- a/level_1/fl_directory/c/directory.c +++ b/level_1/fl_directory/c/directory.c @@ -37,7 +37,7 @@ extern "C" { return status; } - memcpy(names->array[names->used].string, listing[counter]->d_name, sizeof(char) * size); + memcpy(names->array[names->used].string, listing[counter]->d_name, sizeof(int8_t) * size); names->array[names->used].used = size; names->used++; } diff --git a/level_1/fl_fss/c/fss.h b/level_1/fl_fss/c/fss.h index 9787c48..4dede3c 100644 --- a/level_1/fl_fss/c/fss.h +++ b/level_1/fl_fss/c/fss.h @@ -42,8 +42,8 @@ extern "C" { * The number of steps to decrement the start position. * The steps refer to characters and not integers. * Essentially this number is considered against the width of every character found. - * (For ASCII each step would be (sizeof(char)). - * (For UTF-8 character of width 3, each step would be (3 * sizeof(char)). + * (For ASCII each step would be (sizeof(int8_t)). + * (For UTF-8 character of width 3, each step would be (3 * sizeof(int8_t)). * * @return * f_none on success. @@ -113,8 +113,8 @@ extern "C" { * The number of steps to increment the start position. * The steps refer to characters and not integers. * Essentially this number is considered against the width of every character found. - * (For ASCII each step would be (sizeof(char)). - * (For UTF-8 character of width 3, each step would be (3 * sizeof(char)). + * (For ASCII each step would be (sizeof(int8_t)). + * (For UTF-8 character of width 3, each step would be (3 * sizeof(int8_t)). * * @return * f_none on success. diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index 9e3c36a..84dba29 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -50,7 +50,7 @@ extern "C" { } // handle quote support - char quoted = f_string_eos; + int8_t quoted = f_string_eos; // identify where the object begins if (buffer->string[input->start] == f_fss_delimit_slash) { diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index b7c777c..25ccedc 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -50,7 +50,7 @@ extern "C" { } // handle quote support - char quoted = f_string_eos; + int8_t quoted = f_string_eos; // identify where the object begins if (buffer->string[input->start] == f_fss_delimit_slash) { @@ -384,7 +384,7 @@ extern "C" { } f_bool has_delimit = f_false; - char quoted = f_string_eos; + int8_t quoted = f_string_eos; f_bool continue_main_loop = f_false; @@ -1031,7 +1031,7 @@ extern "C" { #endif // _di_level_1_parameter_checking_ f_status status = f_none; - char quoted = f_string_eos; + int8_t quoted = f_string_eos; f_string_location buffer_position = f_string_location_initialize; f_string_length start_position = 0; diff --git a/level_1/fl_serialized/c/serialized.c b/level_1/fl_serialized/c/serialized.c index f02e5ad..dabd7be 100644 --- a/level_1/fl_serialized/c/serialized.c +++ b/level_1/fl_serialized/c/serialized.c @@ -19,12 +19,12 @@ extern "C" { } if (serialized->used == 0) { - memcpy(serialized->string + serialized->used, value.string, sizeof(char) * value.used); + memcpy(serialized->string + serialized->used, value.string, sizeof(int8_t) * value.used); serialized->used += value.used; } else { - memcpy(serialized->string + serialized->used, f_serialized_simple_splitter_string, sizeof(char)); - memcpy(serialized->string + serialized->used + 1, value.string, sizeof(char) * value.used); + memcpy(serialized->string + serialized->used, f_serialized_simple_splitter_string, sizeof(int8_t)); + memcpy(serialized->string + serialized->used + 1, value.string, sizeof(int8_t) * value.used); serialized->used += value.used + 1; } diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index cc97b2b..8b74f4f 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -30,7 +30,7 @@ extern "C" { return status; } - memcpy(result->string, buffer.string + location.start, sizeof(char) * size); + memcpy(result->string, buffer.string + location.start, sizeof(int8_t) * size); result->used = size; return f_none; @@ -41,7 +41,7 @@ extern "C" { #endif // _di_fl_string_rip_ #ifndef _di_fl_string_seek_line_until_graph_ - f_return_status fl_string_seek_line_until_graph(const f_string_dynamic buffer, f_string_location *location, const char placeholder) { + f_return_status fl_string_seek_line_until_graph(const f_string_dynamic buffer, f_string_location *location, const int8_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (location == 0) return f_status_set_error(f_invalid_parameter); if (location->start < 0) return f_status_set_error(f_invalid_parameter); @@ -101,7 +101,7 @@ extern "C" { #endif // _di_fl_string_seek_line_until_graph_ #ifndef _di_fl_string_seek_line_until_non_graph_ - f_return_status fl_string_seek_line_until_non_graph(const f_string_dynamic buffer, f_string_location *location, const char placeholder) { + f_return_status fl_string_seek_line_until_non_graph(const f_string_dynamic buffer, f_string_location *location, const int8_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (location == 0) return f_status_set_error(f_invalid_parameter); if (location->start < 0) return f_status_set_error(f_invalid_parameter); @@ -161,7 +161,7 @@ extern "C" { #endif // _di_fl_string_seek_line_until_non_graph_ #ifndef _di_fl_string_seek_line_to_ - f_return_status fl_string_seek_line_to(const f_string_dynamic buffer, f_string_location *location, const char seek_to_this) { + f_return_status fl_string_seek_line_to(const f_string_dynamic buffer, f_string_location *location, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (location == 0) return f_status_set_error(f_invalid_parameter); if (location->start < 0) return f_status_set_error(f_invalid_parameter); @@ -251,7 +251,7 @@ extern "C" { #endif // _di_fl_string_seek_line_to_utf_character_ #ifndef _di_fl_string_seek_to_ - f_return_status fl_string_seek_to(const f_string_dynamic buffer, f_string_location *location, const char seek_to_this) { + f_return_status fl_string_seek_to(const f_string_dynamic buffer, f_string_location *location, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (location == 0) return f_status_set_error(f_invalid_parameter); if (location->start < 0) return f_status_set_error(f_invalid_parameter); diff --git a/level_1/fl_string/c/string.h b/level_1/fl_string/c/string.h index 2af3112..b62862c 100644 --- a/level_1/fl_string/c/string.h +++ b/level_1/fl_string/c/string.h @@ -70,7 +70,7 @@ extern "C" { * f_reallocation_error (with error bit) on memory reallocation error. */ #ifndef _di_fl_string_seek_line_until_graph_ - extern f_return_status fl_string_seek_line_until_graph(const f_string_dynamic buffer, f_string_location *location, const char placeholder); + extern f_return_status fl_string_seek_line_until_graph(const f_string_dynamic buffer, f_string_location *location, const int8_t placeholder); #endif // _di_fl_string_seek_line_until_graph_ /** @@ -98,7 +98,7 @@ extern "C" { * f_reallocation_error (with error bit) on memory reallocation error. */ #ifndef _di_fl_string_seek_line_until_non_graph_ - extern f_return_status fl_string_seek_line_until_non_graph(const f_string_dynamic buffer, f_string_location *location, const char placeholder); + extern f_return_status fl_string_seek_line_until_non_graph(const f_string_dynamic buffer, f_string_location *location, const int8_t placeholder); #endif // _di_fl_string_seek_line_until_non_graph_ /** @@ -122,7 +122,7 @@ extern "C" { * @see fl_string_seek_line_to_utf_character() */ #ifndef _di_fl_string_seek_line_to_ - extern f_return_status fl_string_seek_line_to(const f_string_dynamic buffer, f_string_location *location, const char seek_to_this); + extern f_return_status fl_string_seek_line_to(const f_string_dynamic buffer, f_string_location *location, const int8_t seek_to_this); #endif // _di_fl_string_seek_line_to_ /** @@ -175,7 +175,7 @@ extern "C" { * @see fl_string_seek_to_utf_character() */ #ifndef _di_fl_string_seek_to_ - extern f_return_status fl_string_seek_to(const f_string_dynamic buffer, f_string_location *location, const char seek_to_this); + extern f_return_status fl_string_seek_to(const f_string_dynamic buffer, f_string_location *location, const int8_t seek_to_this); #endif // _di_fl_string_seek_to_ /** diff --git a/level_1/fl_utf/c/utf.c b/level_1/fl_utf/c/utf.c index df11da6..34bce80 100644 --- a/level_1/fl_utf/c/utf.c +++ b/level_1/fl_utf/c/utf.c @@ -106,7 +106,7 @@ extern "C" { #endif // _di_fl_utf_seek_line_to_ #ifndef _di_fl_utf_seek_line_to_char_ - f_return_status fl_utf_seek_line_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const char seek_to_this) { + f_return_status fl_utf_seek_line_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (location == 0) return f_status_set_error(f_invalid_parameter); if (location->start < 0) return f_status_set_error(f_invalid_parameter); @@ -196,7 +196,7 @@ extern "C" { #endif // _di_fl_utf_string_seek_to_ #ifndef _di_fl_utf_string_seek_to_char_ - f_return_status fl_utf_string_seek_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const char seek_to_this) { + f_return_status fl_utf_string_seek_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (location == 0) return f_status_set_error(f_invalid_parameter); if (location->start < 0) return f_status_set_error(f_invalid_parameter); diff --git a/level_1/fl_utf/c/utf.h b/level_1/fl_utf/c/utf.h index 309e777..854a3df 100644 --- a/level_1/fl_utf/c/utf.h +++ b/level_1/fl_utf/c/utf.h @@ -139,7 +139,7 @@ extern "C" { * @see fl_utf_seek_line_to() */ #ifndef _di_fl_utf_string_seek_line_to_char_ - extern f_return_status fl_utf_seek_line_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const char seek_to_this); + extern f_return_status fl_utf_seek_line_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const int8_t seek_to_this); #endif // _di_fl_utf_string_seek_line_to_char_ /** @@ -187,7 +187,7 @@ extern "C" { * @see fl_utf_string_seek_to() */ #ifndef _di_fl_utf_string_seek_to_character_ - extern f_return_status fl_utf_string_seek_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const char seek_to_this); + extern f_return_status fl_utf_string_seek_to_char(const f_utf_string_dynamic buffer, f_utf_string_location *location, const int8_t seek_to_this); #endif // _di_fl_utf_string_seek_to_character_ /** diff --git a/level_2/fll_execute/c/execute.c b/level_2/fll_execute/c/execute.c index b86ef3c..01f0c2f 100644 --- a/level_2/fll_execute/c/execute.c +++ b/level_2/fll_execute/c/execute.c @@ -65,7 +65,7 @@ extern "C" { return status; } - memcpy(fixed_arguments[i + 1], arguments.array[i].string, sizeof(char) * arguments.array[i].used); + memcpy(fixed_arguments[i + 1], arguments.array[i].string, sizeof(int8_t) * arguments.array[i].used); fixed_arguments[i + 1][arguments.array[i].used] = f_string_eos; } // for @@ -145,7 +145,7 @@ extern "C" { return status; } - memcpy(fixed_arguments[i + 1], arguments.array[i].string, sizeof(char) * arguments.array[i].used); + memcpy(fixed_arguments[i + 1], arguments.array[i].string, sizeof(int8_t) * arguments.array[i].used); fixed_arguments[i + 1][arguments.array[i].used] = f_string_eos; } // for diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 3140f74..be730e5 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -334,7 +334,7 @@ } } else if (data.mode == byte_dump_mode_binary) { - char binary_string[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int8_t binary_string[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; binary_string[0] = ((byte >> 7) & 0x01) ? '1' : '0'; binary_string[1] = ((byte >> 6) & 0x01) ? '1' : '0'; diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 5ce8473..089ec06 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -534,9 +534,9 @@ extern "C" { return status; } - memcpy((void *)file_path.string, network_path, sizeof(char) * network_path_length); - memcpy((void *)(file_path.string + network_path_length), data->devices.array[i].string, sizeof(char) * data->devices.array[i].used); - memcpy((void *)(file_path.string + network_path_length + data->devices.array[i].used), firewall_file_suffix, sizeof(char) * firewall_file_suffix_length); + memcpy((void *)file_path.string, network_path, sizeof(int8_t) * network_path_length); + memcpy((void *)(file_path.string + network_path_length), data->devices.array[i].string, sizeof(int8_t) * data->devices.array[i].used); + memcpy((void *)(file_path.string + network_path_length + data->devices.array[i].used), firewall_file_suffix, sizeof(int8_t) * firewall_file_suffix_length); file_path.used = network_path_length + data->devices.array[i].used + firewall_file_suffix_length; file_path.string[file_path.used] = 0; diff --git a/level_3/firewall/c/private-firewall.h b/level_3/firewall/c/private-firewall.h index 4fce43d..4114896 100644 --- a/level_3/firewall/c/private-firewall.h +++ b/level_3/firewall/c/private-firewall.h @@ -74,7 +74,7 @@ typedef struct { f_macro_fss_contents_delete(status, contents); #define firewall_macro_concat_string(destination, source, length) \ - memcpy((void *)(destination), source, sizeof(char) * length); + memcpy((void *)(destination), source, sizeof(int8_t) * length); #define firewall_macro_rule_contents_has_incorrect_items(index, total_items) \ local.rule_contents.array[index].used <= 0 || local.rule_contents.array[index].used > total_items