diff options
Diffstat (limited to 'polycom_recv/util.c')
-rw-r--r-- | polycom_recv/util.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/polycom_recv/util.c b/polycom_recv/util.c new file mode 100644 index 0000000..1d44f3d --- /dev/null +++ b/polycom_recv/util.c @@ -0,0 +1,55 @@ +#include "project.h" + + +ICACHE_FLASH_ATTR char * +bounded_strstr (char *haystack, uint32_t len, char *needle) +{ + char *end = haystack + len; + char *hptr, *nptr; + + if (!*needle) + return NULL; + + for (; (*haystack) && (haystack < end); ++haystack) + { + + hptr = haystack; + nptr = needle; + + while ((*hptr) == (*nptr)) + { + nptr++; + hptr++; + if (!*nptr) + return haystack; + if (hptr >= end) + return NULL; + } + } + + return NULL; +} + + +bool +util_isspace (char c) +{ + switch (c) + { + case ' ': + case '\r': + case '\t': + case '\n': + return true; + default: + return false; + } +} + +ICACHE_FLASH_ATTR void +crash (void) +{ + char *c = NULL; + + os_printf ("%d", *c); +} |