From 0a8e1c08e10d53f58d9e67d5bca09b8ae6a16c39 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jul 2015 08:33:53 +0100 Subject: fish --- polycom_xmit/util.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 polycom_xmit/util.c (limited to 'polycom_xmit/util.c') diff --git a/polycom_xmit/util.c b/polycom_xmit/util.c new file mode 100644 index 0000000..d637174 --- /dev/null +++ b/polycom_xmit/util.c @@ -0,0 +1,47 @@ +#include "project.h" + + +char *ICACHE_FLASH_ATTR +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; + } +} -- cgit v1.2.3