summaryrefslogtreecommitdiffstats
path: root/polycom_xmit/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'polycom_xmit/util.c')
-rw-r--r--polycom_xmit/util.c47
1 files changed, 47 insertions, 0 deletions
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;
+ }
+}