kernel/inc/utils/string.h

63 lines
2.5 KiB
C
Raw Permalink Normal View History

// This file is part of noxos and licensed under the MIT open source license
2023-01-25 00:42:04 +00:00
2023-01-25 11:22:27 +00:00
#ifndef NOX_STRING_H
#define NOX_STRING_H
2023-01-25 00:42:04 +00:00
#include "stdtypes.h"
#include <stdarg.h>
2023-01-25 00:42:04 +00:00
#define STRING_EXT_SIZE(n) ((n) + 5)
2023-01-25 00:42:04 +00:00
typedef const char* string_t;
typedef enum {
STRING_EXT_CMD_CLEAR,
STRING_EXT_CMD_CURSOR_MOVE,
STRING_EXT_CMD_CURSOR_SET,
STRING_EXT_CMD_COLOR_SET,
STRING_EXT_CMD_COLOR_RESET,
STRING_EXT_CMD_RENDER_DISABLE,
STRING_EXT_CMD_RENDER_ENABLE,
STRING_EXT_CMD_KEYBOARD_ECHO
} string_ext_command_E;
typedef struct {
uint8_t shift_in;
uint16_t length;
uint8_t command;
uint8_t data;
// DATA BLOCKS
// SHIFT OUT
}__attribute__((packed)) string_ext_header_T;
uint32_t string_length (string_t string);
bool string_compare (string_t a, string_t b);
uint32_t string_find_next (string_t string, char chr);
uint32_t string_find_last (string_t string, char chr);
void string_add_ext_command (string_t string, string_ext_command_E command, int num_data, uint8_t data[]);
uint64_t variadic_format_size (string_t string, va_list args);
uint64_t format_size (string_t string, ...);
void variadic_format (string_t output, string_t string, va_list args);
void format (string_t output, string_t string, ...);
void string_unsigned_dec_to_alpha (string_t string, uint64_t value);
void string_dec_to_alpha (string_t string, int64_t value);
void string_hex_8bit_to_alpha (string_t string, uint8_t value);
void string_hex_16bit_to_alpha (string_t string, uint16_t value);
void string_hex_32bit_to_alpha (string_t string, uint32_t value);
void string_hex_64bit_to_alpha (string_t string, uint64_t value);
void string_bin_to_alpha (string_t string, uint8_t num_bits, uint64_t value);
void string_bool_to_alpha (string_t string, bool value);
2023-01-25 00:42:04 +00:00
bool string_is_char_text (char chr);
bool string_is_char_number (char chr);
bool string_is_char_special (char chr);
bool string_is_char_alpha (char chr);
bool string_is_char_uppercase (char chr);
bool string_is_char_lowercase (char chr);
uint32_t string_hash_djb (string_t str);
2023-01-25 11:22:27 +00:00
#endif //NOX_STRING_H