String stuff that should be in stdlib but isn't.
Dependents: X10Svr SSDP_Server
SW_String.h
- Committer:
- WiredHome
- Date:
- 2016-04-11
- Revision:
- 0:6d899ce93ea0
- Child:
- 1:65bc379d8cd0
File content as of revision 0:6d899ce93ea0:
/// @file SW_String.h This is a small collection of string utilities that /// are not consistent across compilers. /// /// @note Copyright © 2016 by Smartware Computing, all rights reserved. /// This software may be used to derive new software, as long as /// this copyright statement remains in the source file. /// @author David Smart /// #include "string.h" /// sw_tolower exists because not all compiler libraries have this function /// /// This takes a character and if it is upper-case, it converts it to /// lower-case and returns it. /// /// @note an alternate means would be a 256-entry lookup table. Very fast... /// /// @param a is the character to convert /// @returns the lower case equivalent to a /// char sw_tolower(char a); /// sw_strnicmp exists because not all compiler libraries have this function. /// /// In a case-insensitive compare, evaluate 'n' characters of the left and /// right referenced strings. /// /// @note Some compilers have strnicmp, others _strnicmp, and others have C++ /// methods, which is outside the scope of this C-portable set of functions. /// /// @param l is a pointer to the string on the left /// @param r is a pointer to the string on the right /// @param n is the number of characters to compare /// @returns -1 if l < r /// @returns 0 if l == r /// @returns +1 if l > r /// int sw_strnicmp(const char *l, const char *r, size_t n); /// sw_stristr exists because not all compiler libraries have this function. /// /// In a case-insenstive search, try to find the needle in the haystack. /// /// @param haystack is a pointer to string being searched /// @param needle is a pointer to a string to find /// @returns a pointer to the found needle in the haystack, or NULL /// const char * sw_stristr(const char * haystack, const char * needle); /// sw_stristr exists because not all compiler libraries have this function. /// /// In a case-insenstive search, try to find the needle in the haystack. /// /// @param haystack is a pointer to string being searched /// @param needle is a pointer to a string to find /// @returns a pointer to the found needle in the haystack, or NULL /// char * sw_stristr(char * haystack, const char * needle);