ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Macros | Functions
stringsup.h File Reference

Various string and character functions. More...

Go to the source code of this file.

Macros

#define MEMSPACE
 
#define WEAK_ATR   __attribute__((weak))
 

Functions

MEMSPACE void sep (void)
 undo any existing macros More...
 
MEMSPACE int WEAK_ATR isdigit (int c)
 test if a character is a digit More...
 
MEMSPACE int WEAK_ATR isupper (int c)
 Is a character upper case. More...
 
MEMSPACE int WEAK_ATR islower (int c)
 
MEMSPACE int WEAK_ATR tolower (int c)
 Convert character to lower case, only if it is upper case. More...
 
MEMSPACE int WEAK_ATR toupper (int c)
 Convert character to upper case, only if it is lower case. More...
 
MEMSPACE void * memchr (const void *str, int c, size_t size)
 find a character in a string of maximum size More...
 
MEMSPACE size_t WEAK_ATR strlen (const char *str)
 String Length. More...
 
MEMSPACE WEAK_ATR char * strcpy (char *dest, const char *src)
 copy a string More...
 
MEMSPACE WEAK_ATR char * strncpy (char *dest, const char *src, size_t size)
 copy a string of at most N characters More...
 
MEMSPACE WEAK_ATR char * strcat (char *dest, const char *src)
 Append string. More...
 
MEMSPACE WEAK_ATR char * strncat (char *dest, const char *src, size_t max)
 Append string of at most N bytes from src. More...
 
MEMSPACE void WEAK_ATR reverse (char *str)
 Reverse a string in place Example: abcdef -> fedcba. More...
 
MEMSPACE void WEAK_ATR strupper (char *str)
 UPPERCASE a string. More...
 
MEMSPACE void trim_tail (char *str)
 Trim White space and control characters from end of string. More...
 
MEMSPACE char * skipspaces (char *ptr)
 Skip white space in a string - tabs and spaces. More...
 
MEMSPACE char * nextspace (char *ptr)
 Skip to first white space in a string - tabs and spaces. More...
 
MEMSPACE char * skipchars (char *str, char *pat)
 Skip characters defined in user string. More...
 
MEMSPACE int WEAK_ATR strcmp (const char *str, const char *pat)
 Compare two strings. More...
 
MEMSPACE int WEAK_ATR strncmp (const char *str, const char *pat, size_t len)
 Compare two strings maximum len bytes in size. More...
 
MEMSPACE int WEAK_ATR strcasecmp (const char *str, const char *pat)
 Compare two strings without case. More...
 
MEMSPACE int WEAK_ATR strncasecmp (const char *str, const char *pat, size_t len)
 Compare two strings without case maximum len bytes in size. More...
 
MEMSPACE int MATCH (char *str, char *pat)
 Compare two strings. More...
 
MEMSPACE int MATCHARGS (char *str, char *pat, int min, int argc)
 Match two strings and compare argument index Display message if the number of arguments is too few. More...
 
MEMSPACE int MATCHI (char *str, char *pat)
 Compare two strings without case. More...
 
MEMSPACE int MATCH_LEN (char *str, char *pat)
 Compare two strings limted to length of pattern. More...
 
MEMSPACE int MATCHI_LEN (char *str, char *pat)
 Compare two strings without case limted to length of pattern. More...
 
MEMSPACE int split_args (char *str, char *argv[], int max)
 Split string into arguments stored in argv[] We split source string into arguments Warning: source string is modified! To save memory each gap in the source string is terminated with an EOS This becomes the end of string for each argument returned Warning: Do NOT modify the source string or argument contents while using them You can reassign new pointers to the arguments if you like. More...
 
MEMSPACE char * get_token (char *str, char *token, int max)
 return next token More...
 
MEMSPACE int token (char *str, char *pat)
 Search for token in a string matching user pattern. More...
 
MEMSPACE int32_t get_value (char *str)
 get a number More...
 
MEMSPACE char * strnalloc (char *str, int len)
 Allocate space for string with maximum size. More...
 
MEMSPACE char * stralloc (char *str)
 Allocate space for string. More...
 

Detailed Description

Various string and character functions.

Copyright © 2016 Mike Gore, GPL License
You are free to use this code under the terms of GPL
please retain a copy of this notice in any code you use it in.

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file stringsup.h.

Macro Definition Documentation

#define MEMSPACE

Definition at line 28 of file stringsup.h.

#define WEAK_ATR   __attribute__((weak))

Function Documentation

MEMSPACE char* get_token ( char *  str,
char *  token,
int  max 
)

return next token

  • Skips all non printable ASCII characters before token
  • Token returns only printable ASCII
Parameters
[in]strstring to search.
[out]tokentoken to return
[in]maxmaximum token size
Returns
pointer past token on success .
NULL if no token found

return next token

Parameters
[in]*strstring
[out]*tokentoken characters greter then space less then 0x7f
[in]maxmaximum length of token
Returns
: string pointer to character after token

Definition at line 628 of file stringsup.c.

MEMSPACE int32_t get_value ( char *  str)

get a number

  • Used only for debugging
    Parameters
    [in]strstring to examine
    Returns
    value

Definition at line 706 of file stringsup.c.

MEMSPACE int WEAK_ATR isdigit ( int  c)

test if a character is a digit

Parameters
[in]ccharacter
Returns
true or false

Definition at line 48 of file stringsup.c.

MEMSPACE int WEAK_ATR islower ( int  c)
Parameters
[in]ccharacter.
Returns
1 of lower case, else 0

Definition at line 80 of file stringsup.c.

Referenced by toupper().

MEMSPACE int WEAK_ATR isupper ( int  c)

Is a character upper case.

Parameters
[in]ccharacter.
Returns
1 of upper case, else 0

Definition at line 64 of file stringsup.c.

Referenced by tolower().

MEMSPACE int MATCH ( char *  str,
char *  pat 
)

Compare two strings.

Parameters
[in]strstring to match.
[in]patpattern to compare.
Returns
string lenth on match.
0 on no match.

Definition at line 455 of file stringsup.c.

Referenced by MATCHARGS().

MEMSPACE int MATCH_LEN ( char *  str,
char *  pat 
)

Compare two strings limted to length of pattern.

Parameters
[in]strstring to match.
[in]patpattern to compare.
Returns
string lenth on match.
0 on no match.
Warning
Matches sub strings so be caeful.

Definition at line 511 of file stringsup.c.

MEMSPACE int MATCHARGS ( char *  str,
char *  pat,
int  min,
int  argc 
)

Match two strings and compare argument index Display message if the number of arguments is too few.

Parameters
strstring to test
patpattern to match
minminumum number or arguments
argcactual number of arguments
Returns
1 on match, 0 on no match or too few arguments

Definition at line 471 of file stringsup.c.

Referenced by fatfs_tests(), posix_tests(), and user_tests().

MEMSPACE int MATCHI ( char *  str,
char *  pat 
)

Compare two strings without case.

Parameters
[in]strstring to match.
[in]patpattern to compare.
Returns
string lenth on match.
0 on no match.

Definition at line 493 of file stringsup.c.

MEMSPACE int MATCHI_LEN ( char *  str,
char *  pat 
)

Compare two strings without case limted to length of pattern.

Parameters
[in]strstring to match.
[in]patpattern to compare.
Returns
string lenth on match.
0 on no match.
Warning
Matches sub strings so be caeful.

Definition at line 537 of file stringsup.c.

Referenced by get_value(), and match_headers().

MEMSPACE void* memchr ( const void *  str,
int  c,
size_t  size 
)

find a character in a string of maximum size

Parameters
[in]strstring
[in]ccharacter
[in]sizestring length to search
Returns
string length

Definition at line 125 of file stringsup.c.

MEMSPACE char* nextspace ( char *  ptr)

Skip to first white space in a string - tabs and spaces.

Parameters
[in]ptrinput string
Returns
pointer to first white space character

Definition at line 306 of file stringsup.c.

Referenced by process_args().

MEMSPACE void WEAK_ATR reverse ( char *  str)

Reverse a string in place Example: abcdef -> fedcba.

Parameters
[in]strstring
Returns
string length

Definition at line 231 of file stringsup.c.

MEMSPACE void sep ( void  )

undo any existing macros

undo any existing macros

Definition at line 32 of file stringsup.c.

Referenced by setup().

MEMSPACE char* skipchars ( char *  str,
char *  pat 
)

Skip characters defined in user string.

Parameters
[in]strstring
[in]patpattern string
Returns
pointer to string after skipped characters.

Definition at line 328 of file stringsup.c.

MEMSPACE char* skipspaces ( char *  ptr)

Skip white space in a string - tabs and spaces.

Parameters
[in]ptrinput string
Returns
pointer to first non white space character

Definition at line 289 of file stringsup.c.

Referenced by get_token(), get_value(), match_headers(), parse_http_request(), split_args(), timetests(), and token().

MEMSPACE int split_args ( char *  str,
char *  argv[],
int  max 
)

Split string into arguments stored in argv[] We split source string into arguments Warning: source string is modified! To save memory each gap in the source string is terminated with an EOS This becomes the end of string for each argument returned Warning: Do NOT modify the source string or argument contents while using them You can reassign new pointers to the arguments if you like.

Parameters

Definition at line 566 of file stringsup.c.

Referenced by user_tasks().

MEMSPACE char* stralloc ( char *  str)

Allocate space for string.

  • Copies tring into allocated space.
Parameters
[in]struser string.
Returns
pointer to alocated string.
NULL on out of memory.

Allocate space for string.

Parameters
[in]*strstring to allocate and copy memory for
Returns
: char * pointer to allocated string

Definition at line 774 of file stringsup.c.

MEMSPACE int WEAK_ATR strcasecmp ( const char *  str,
const char *  pat 
)

Compare two strings without case.

Parameters
[in]strstring to match.
[in]patpattern to compare.
Returns
0 on match, < 0 implies str sorts before pat, > 0 implies str sorts after pat

Definition at line 410 of file stringsup.c.

Referenced by file_type(), http_value(), and MATCHI().

MEMSPACE WEAK_ATR char* strcat ( char *  dest,
const char *  src 
)

Append string.

Parameters
[in]deststring
[in]srcstring
Returns
string length

Definition at line 199 of file stringsup.c.

Referenced by ls(), and upload().

MEMSPACE int WEAK_ATR strcmp ( const char *  str,
const char *  pat 
)

Compare two strings.

Parameters
[in]strstring to match.
[in]patpattern to compare.
Returns
0 on match, < 0 implies str sorts before pat, > 0 implies str sorts after pat

Definition at line 362 of file stringsup.c.

Referenced by FindFontName(), main(), MATCH(), and stat().

MEMSPACE WEAK_ATR char* strcpy ( char *  dest,
const char *  src 
)

copy a string

Parameters
[in]destdestination string
[in]srcsource string
Returns
destination string

Definition at line 161 of file stringsup.c.

Referenced by escape(), fatfs_ls(), fatfs_scan_files(), ls(), main(), setup_networking(), stralloc(), and strcat().

MEMSPACE size_t WEAK_ATR strlen ( const char *  str)

String Length.

Parameters
[in]strstring
Returns
string length

Definition at line 146 of file stringsup.c.

MEMSPACE char* strnalloc ( char *  str,
int  len 
)

Allocate space for string with maximum size.

  • Copies tring into allocated space limited to maximum size.
Parameters
[in]struser string.
[in]lenmaximum string length.
Returns
pointer to alocated string.

Definition at line 750 of file stringsup.c.

MEMSPACE int WEAK_ATR strncasecmp ( const char *  str,
const char *  pat,
size_t  len 
)

Compare two strings without case maximum len bytes in size.

Parameters
[in]strstring to match.
[in]patpattern to compare.
[in]lenmaximum string length for compare
Returns
0 on match, < 0 implies str sorts before pat, > 0 implies str sorts after pat

Definition at line 432 of file stringsup.c.

Referenced by MATCHI_LEN().

MEMSPACE WEAK_ATR char* strncat ( char *  dest,
const char *  src,
size_t  max 
)

Append string of at most N bytes from src.

Parameters
[in]deststring
[in]srcstring
Returns
string length

Definition at line 214 of file stringsup.c.

Referenced by html_msg().

MEMSPACE int WEAK_ATR strncmp ( const char *  str,
const char *  pat,
size_t  len 
)

Compare two strings maximum len bytes in size.

Parameters
[in]strstring to match.
[in]patpattern to compare.
[in]lenmaximum string length for compare
Returns
0 on match, < 0 implies str sorts before pat, > 0 implies str sorts after pat

Definition at line 386 of file stringsup.c.

Referenced by MATCH_LEN(), match_token(), and token().

MEMSPACE WEAK_ATR char* strncpy ( char *  dest,
const char *  src,
size_t  size 
)

copy a string of at most N characters

Parameters
[in]destdestination string
[in]srcsource string
[in]sizemaximum destination size
Returns
destination string

Definition at line 179 of file stringsup.c.

Referenced by main(), readdir(), strerror_r(), strnalloc(), strncat(), and user_loop().

MEMSPACE void WEAK_ATR strupper ( char *  str)

UPPERCASE a string.

Parameters
[in]strstring
Returns
void

Definition at line 253 of file stringsup.c.

MEMSPACE int token ( char *  str,
char *  pat 
)

Search for token in a string matching user pattern.

  • Skips all non printable ASCII characters before trying match.
Parameters
[in]strstring to search.
[in]patpattern to search for.
Returns
string lenth on match.
0 on no match.

Definition at line 671 of file stringsup.c.

Referenced by rcvr_datablock(), and ReadBdf().

MEMSPACE int WEAK_ATR tolower ( int  c)

Convert character to lower case, only if it is upper case.

Parameters
[in]ccharacter.
Returns
character or lowercase value or character

Definition at line 96 of file stringsup.c.

Referenced by mkfs().

MEMSPACE int WEAK_ATR toupper ( int  c)

Convert character to upper case, only if it is lower case.

Parameters
[in]ccharacter.
Returns
character or upper case value or character

Definition at line 112 of file stringsup.c.

Referenced by ReadBdf(), strcasecmp(), strncasecmp(), and strupper().

MEMSPACE void trim_tail ( char *  str)

Trim White space and control characters from end of string.

Parameters
[in]strstring
Returns
void
Warning
Overwrites White space and control characters with EOS.

Trim White space and control characters from end of string.

Parameters
[in]*strstring to remove quotes from
Returns
: void

Definition at line 271 of file stringsup.c.