![]() |
FrostWing
A lightweight raw-control operating system.
|
The header file for strings.c. More...


Go to the source code of this file.
Macros | |
| #define | MAX_WORDS 30 |
| #define | MAX_WORD_LEN 40 |
| #define | CONCAT(...) |
Functions | |
| int | strlen (char s[]) |
| Calculate the length of a null-terminated string. | |
| string | strcpy (string dest, cstring src) |
| Copies a string from src to dest. | |
| string | strncpy (string dest, cstring src, size_t n) |
| Copies n characters from src to dest. | |
| int | strcmp (cstring s1, cstring s2) |
| Compares two strings lexicographically. | |
| int | strncmp (cstring s1, cstring s2, size_t n) |
| Compares two strings, up to a specified number of characters. | |
| bool | contains (cstring str, cstring substr) |
| Check if a substring is found within a string. | |
| void | string_transport_front (char *str, int x) |
| Move the last x characters of a string to the front and delete the rest. | |
| string | trim (cstring str) |
| Creates a new string without spaces from a C-style string. | |
| string | strcat (string dest, cstring src) |
| Concatenate two strings. | |
| void | remove_last_char (string str) |
| Removes the last char. | |
| long | strtol (const char *str, char **endptr, int base) |
| Converts a string to a long integer. | |
| char * | uint_to_string (unsigned int num) |
| Converts an uint to string. | |
| char * | hex_to_string (signed int num, bool caps) |
| Prints Hexadecimal number. | |
| char * | leading_trailing_trim (const char *str) |
| Removes the leading and trailing spaces. | |
| char ** | splitf (const char *str, char delim, int *num_tokens) |
| Splits a string into tokens based on a delimiter. | |
| int | isspace (char c) |
| Implemented for sh.c. | |
| char * | trim_inplace (char *s) |
| char * | strrchr (const char *s, int c) |
The header file for strings.c.
Definition in file strings.h.
| #define CONCAT | ( | ... | ) |
| bool contains | ( | cstring | str, |
| cstring | substr ) |
Check if a substring is found within a string.
This function searches for the presence of a substring within a given string.
| str | The string to search within. |
| substr | The substring to search for. |
| char * hex_to_string | ( | signed int | num, |
| bool | caps ) |
Prints Hexadecimal number.
| hex | the hexadecimal number to be printed. |
| int isspace | ( | char | c | ) |
Implemented for sh.c.
| c |
| char * leading_trailing_trim | ( | const char * | str | ) |
Removes the leading and trailing spaces.
| str |
| void remove_last_char | ( | string | str | ) |
Removes the last char.
| str |
| char ** splitf | ( | const char * | str, |
| char | delim, | ||
| int * | num_tokens ) |
Splits a string into tokens based on a delimiter.
| str | The input string to be split. |
| delim | The delimiter character. |
| num_tokens | The number of tokens found. |
| string strcat | ( | string | dest, |
| cstring | src ) |
Concatenate two strings.
This function concatenates the source string src to the end of the destination string dest. It assumes that dest has enough space to accommodate the concatenated result.
| dest | The destination string. |
| src | The source string to be concatenated. |
| int strcmp | ( | cstring | s1, |
| cstring | s2 ) |
Compares two strings lexicographically.
This function compares two strings s1 and s2 lexicographically. It returns a negative value if s1 is less than s2, a positive value if s1 is greater than s2, and zero if they are equal.
| s1 | The first string to be compared. |
| s2 | The second string to be compared. |
| string strcpy | ( | string | dest, |
| cstring | src ) |
Copies a string from src to dest.
| dest | Pointer to the destination |
| src | Source string |
| void string_transport_front | ( | char * | str, |
| int | x ) |
Move the last x characters of a string to the front and delete the rest.
This function takes a null-terminated C string and moves the last x characters to the beginning of the string while deleting the remaining characters. If x is greater than or equal to the length of the string, the function does nothing.
| str | The input string. |
| x | The number of characters to move to the front. |
| int strlen | ( | char | s[] | ) |
Calculate the length of a null-terminated string.
This function calculates the length of the input null-terminated string by iterating through the characters until it reaches the null terminator.
| s | The input string. |
| int strncmp | ( | cstring | s1, |
| cstring | s2, | ||
| size_t | n ) |
Compares two strings, up to a specified number of characters.
This function compares the first n characters of two strings s1 and s2. It returns a negative value if s1 is less than s2, a positive value if s1 is greater than s2, and zero if they are equal.
| s1 | The first string to be compared. |
| s2 | The second string to be compared. |
| n | The maximum number of characters to compare. |
| string strncpy | ( | string | dest, |
| cstring | src, | ||
| size_t | n ) |
Copies n characters from src to dest.
| dest | Pointer to the destination |
| src | Source string |
| n | Number of characters that will be copies |
| long strtol | ( | const char * | str, |
| char ** | endptr, | ||
| int | base ) |
Converts a string to a long integer.
/**
| str | The input string to be converted. |
| endptr | Reference to a pointer that will be updated to point to the character after the last valid character. |
| base | The base of the number. |
| string trim | ( | cstring | str | ) |
Creates a new string without spaces from a C-style string.
This function allocates memory for a new string without spaces and returns the result. It is the caller's responsibility to free the allocated memory.
| str | The input string to be trimmed. |
| char * uint_to_string | ( | unsigned int | num | ) |
Converts an uint to string.
| num |