summaryrefslogtreecommitdiffstats
path: root/polycom_xmit/util.c
blob: d6371743d25f68face283f224839a0b7d485258c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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;
    }
}