Updated something, dunno what...
This commit is contained in:
parent
4a68e16148
commit
e0198b52af
33
xtandard.c
33
xtandard.c
@ -47,6 +47,16 @@ void echo (char * data) {
|
|||||||
out (data, string_length (data));
|
out (data, string_length (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void echo_new_line (void) {
|
||||||
|
out ("\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void echo_byte (int byte) {
|
||||||
|
out ("0123456789ABCDEF" + (byte % 256) / 16, 1);
|
||||||
|
out ("0123456789ABCDEF" + (byte % 256) % 16, 1);
|
||||||
|
out (" ", 1);
|
||||||
|
}
|
||||||
|
|
||||||
void fatal_failure (int condition, char * message) {
|
void fatal_failure (int condition, char * message) {
|
||||||
if (condition != 0) {
|
if (condition != 0) {
|
||||||
echo ("\033[1;31m[!]\033[0m ");
|
echo ("\033[1;31m[!]\033[0m ");
|
||||||
@ -426,6 +436,12 @@ int character_is_underscore (char character) {
|
|||||||
return ((int) (character == '_'));
|
return ((int) (character == '_'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int character_is_hexadecimal (char character) {
|
||||||
|
char * hexadecimals = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
return (character_compare_array (character, hexadecimals, string_length (hexadecimals)));
|
||||||
|
}
|
||||||
|
|
||||||
int character_compare_array (char character, char * character_array, int count) {
|
int character_compare_array (char character, char * character_array, int count) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -664,4 +680,21 @@ void terminal_show_cursor (int show) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int encode_byte (char * byte) {
|
||||||
|
int encode = 0;
|
||||||
|
|
||||||
|
fatal_failure (character_is_hexadecimal (byte [0]) == 0, "encode_byte: Upper byte character is not hexadecimal digit.");
|
||||||
|
fatal_failure (character_is_hexadecimal (byte [1]) == 0, "encode_byte: Lower byte character is not hexadecimal digit.");
|
||||||
|
|
||||||
|
encode = ((byte [0] - (character_is_digit (byte [0]) ? ('0') : ('A' - 10))) << 4) | (byte [1] - (character_is_digit (byte [1]) ? ('0') : ('A' - 10)));
|
||||||
|
|
||||||
|
return (encode);
|
||||||
|
}
|
||||||
|
|
||||||
|
char * decode_byte (int byte) {
|
||||||
|
static char * decode = " ";
|
||||||
|
|
||||||
|
return (decode);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,6 +75,8 @@ extern void in (void *, int);
|
|||||||
extern void out (void *, int);
|
extern void out (void *, int);
|
||||||
|
|
||||||
extern void echo (char *);
|
extern void echo (char *);
|
||||||
|
extern void echo_new_line (void);
|
||||||
|
extern void echo_byte (int);
|
||||||
|
|
||||||
extern void fatal_failure (int, char *);
|
extern void fatal_failure (int, char *);
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ extern int character_is_visible (char);
|
|||||||
extern int character_is_invisible (char);
|
extern int character_is_invisible (char);
|
||||||
extern int character_is_escape (char);
|
extern int character_is_escape (char);
|
||||||
extern int character_is_underscore (char);
|
extern int character_is_underscore (char);
|
||||||
|
extern int character_is_hexadecimal (char);
|
||||||
|
|
||||||
extern int character_compare_array (char, char *, int);
|
extern int character_compare_array (char, char *, int);
|
||||||
|
|
||||||
@ -140,4 +143,7 @@ extern void terminal_clear (void);
|
|||||||
extern void terminal_style (int, int);
|
extern void terminal_style (int, int);
|
||||||
extern void terminal_show_cursor (int);
|
extern void terminal_show_cursor (int);
|
||||||
|
|
||||||
|
extern int encode_byte (char *);
|
||||||
|
extern char * decode_byte (int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user