Work in progress

Creating function for validateing element ID strings
This commit is contained in:
Michael Tryby
2019-04-16 14:44:06 -04:00
parent 8989be193a
commit ac56971ef2
5 changed files with 74 additions and 9 deletions

View File

@@ -17,7 +17,7 @@
#include "cstr_helper.h"
int copy_cstr(const char *source, char **dest)
int cstr_copy(const char *source, char **dest)
// Determines length, allocates memory, and returns a null terminated copy
// Be Aware: caller is responsible for freeing memory
{
@@ -39,7 +39,20 @@ int copy_cstr(const char *source, char **dest)
}
bool isnullterm_cstr(const char *source)
bool cstr_validate_id(const char *element_id)
// Determines if invalid characters are present in an element id string
{
const char *invalid_chars = " \";";
if (strpbrk(element_id, invalid_chars))
return false;
else
return true;
}
bool cstr_isnullterm(const char *source)
// Determines if the string passed is null terminated or not
{
if (strchr(source, '\0'))
return true;