|
|
@@ -1,7 +1,7 @@ |
|
|
|
/* |
|
|
|
* Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic |
|
|
|
* |
|
|
|
* Xtandard is deallocate software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation. |
|
|
|
* Xtandard is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation. |
|
|
|
* And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version. |
|
|
|
* It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3. |
|
|
|
*/ |
|
|
@@ -96,12 +96,13 @@ void * memorize (int size) { |
|
|
|
void * record (void) { |
|
|
|
char * buffer = NULL; |
|
|
|
int offset = 0; |
|
|
|
int loling = 1024; |
|
|
|
|
|
|
|
buffer = reallocate (buffer, 1024); |
|
|
|
buffer = reallocate (buffer, loling); |
|
|
|
|
|
|
|
do { |
|
|
|
if ((offset + 1) % 1024 == 0) { |
|
|
|
buffer = reallocate (buffer, ((offset + 1) / 1024 + 1) * 1024); |
|
|
|
if ((offset + 1) % loling == 0) { |
|
|
|
buffer = reallocate (buffer, ((offset + 1) / loling + 1) * loling); |
|
|
|
} |
|
|
|
|
|
|
|
buffer [offset] = '\0'; |
|
|
@@ -116,8 +117,25 @@ void * record (void) { |
|
|
|
return (buffer); |
|
|
|
} |
|
|
|
|
|
|
|
void curses_style (int effect, int colour) { |
|
|
|
char format [8] = "\033[ ;3 m"; |
|
|
|
|
|
|
|
if ((effect == -1) || (colour == -1)) { |
|
|
|
out ("\033[0m", 5); |
|
|
|
} else { |
|
|
|
format [2] = (char) effect + '0'; |
|
|
|
format [5] = (char) colour + '0'; |
|
|
|
|
|
|
|
out (format, 8); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void curses_clear (void) { |
|
|
|
out ("\033[2J", 5); |
|
|
|
} |
|
|
|
|
|
|
|
int string_length (char * string) { |
|
|
|
int length; |
|
|
|
int length = 0; |
|
|
|
|
|
|
|
fatal_failure (string == NULL, "string_length: String is null."); |
|
|
|
|
|
|
@@ -131,7 +149,8 @@ void string_delete (char * string) { |
|
|
|
} |
|
|
|
|
|
|
|
void string_reverse (char * string) { |
|
|
|
int i, length; |
|
|
|
int i = 0; |
|
|
|
int length = 0; |
|
|
|
|
|
|
|
fatal_failure (string == NULL, "string_reverse: String is null."); |
|
|
|
|
|
|
@@ -143,7 +162,7 @@ void string_reverse (char * string) { |
|
|
|
} |
|
|
|
|
|
|
|
int string_compare (char * string_0, char * string_1) { |
|
|
|
int i; |
|
|
|
int i = 0; |
|
|
|
|
|
|
|
fatal_failure (string_0 == NULL, "string_compare: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_compare: Source string is null."); |
|
|
@@ -157,23 +176,9 @@ int string_compare (char * string_0, char * string_1) { |
|
|
|
return (1); |
|
|
|
} |
|
|
|
|
|
|
|
int string_compare_limit (char * string_0, char * string_1, int limit) { |
|
|
|
int i; |
|
|
|
|
|
|
|
fatal_failure (string_0 == NULL, "string_compare: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_compare: Source string is null."); |
|
|
|
|
|
|
|
for (i = 0; (string_0 [i] != '\0') && (string_1 [i] != '\0') && (i != limit); ++i) { |
|
|
|
if (string_0 [i] != string_1 [i]) { |
|
|
|
return (0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return (1); |
|
|
|
} |
|
|
|
|
|
|
|
void string_copy (char * string_0, char * string_1) { |
|
|
|
int i, length; |
|
|
|
int i = 0; |
|
|
|
int length = 0; |
|
|
|
|
|
|
|
fatal_failure (string_0 == NULL, "string_copy: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_copy: Source string is null."); |
|
|
@@ -184,29 +189,74 @@ void string_copy (char * string_0, char * string_1) { |
|
|
|
string_0 [i] = string_1 [i]; |
|
|
|
} |
|
|
|
} |
|
|
|
/* |
|
|
|
|
|
|
|
void string_concatenate (char * string_0, char * string_1) { |
|
|
|
int i = 0; |
|
|
|
int length_0 = 0; |
|
|
|
int length_1 = 0; |
|
|
|
|
|
|
|
} |
|
|
|
fatal_failure (string_0 == NULL, "string_concatenate: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_concatenate: Source string is null."); |
|
|
|
|
|
|
|
void string_remove (char * string_0, char * string_1) { |
|
|
|
length_0 = string_length (string_0); |
|
|
|
length_1 = string_length (string_1); |
|
|
|
|
|
|
|
for (i = 0; i != length_1; ++i) { |
|
|
|
string_0 [length_0 + i] = string_1 [i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int string_string (char * string_0, char * string_1) { |
|
|
|
int string_compare_limit (char * string_0, char * string_1, int limit) { |
|
|
|
int i = 0; |
|
|
|
|
|
|
|
} |
|
|
|
fatal_failure (string_0 == NULL, "string_compare_limit: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_compare_limit: Source string is null."); |
|
|
|
|
|
|
|
int string_character (char * string_0, char * string_1) { |
|
|
|
for (i = 0; (string_0 [i] != '\0') && (string_1 [i] != '\0') && (i != limit); ++i) { |
|
|
|
if (string_0 [i] != string_1 [i]) { |
|
|
|
return (0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return (1); |
|
|
|
} |
|
|
|
|
|
|
|
void string_offset (char * string, char character, int count) { |
|
|
|
void string_copy_limit (char * string_0, char * string_1, int limit) { |
|
|
|
int i = 0; |
|
|
|
int length = 0; |
|
|
|
|
|
|
|
fatal_failure (string_0 == NULL, "string_copy_limit: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_copy_limit: Source string is null."); |
|
|
|
|
|
|
|
if (limit <= 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
length = string_length (string_1); |
|
|
|
|
|
|
|
for (i = 0; (i != length) && (i != limit); ++i) { |
|
|
|
string_0 [i] = string_1 [i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void string_replace (char * string, char character, int count) { |
|
|
|
void string_concatenate_limit (char * string_0, char * string_1, int limit) { |
|
|
|
int i = 0; |
|
|
|
int length_0 = 0; |
|
|
|
int length_1 = 0; |
|
|
|
|
|
|
|
fatal_failure (string_0 == NULL, "string_concatenate_limit: Destination string is null."); |
|
|
|
fatal_failure (string_1 == NULL, "string_concatenate_limit: Source string is null."); |
|
|
|
|
|
|
|
if (limit <= 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
length_0 = string_length (string_0); |
|
|
|
length_1 = string_length (string_1); |
|
|
|
|
|
|
|
for (i = 0; (i != length_1) && (i != limit); ++i) { |
|
|
|
string_0 [length_0 + i] = string_1 [i]; |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
#endif |