forked from HISONA/https_client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesp_utils.c
More file actions
46 lines (36 loc) · 954 Bytes
/
Copy pathesp_utils.c
File metadata and controls
46 lines (36 loc) · 954 Bytes
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
#include "esp_utils.h"
#include <stdio.h>
static uint32_t esp_debug_level = 0;
const char *esp_find_substr(const char *hay, size_t hay_len, const char *needle, size_t needle_len)
{
int i,j;
int found;
if (hay_len == 0 || needle_len == 0 || hay_len < needle_len)
return NULL;
for (i = 0; i < hay_len - needle_len + 1; i++) {
if (hay[i] == needle[0]) {
found = 1;
for (j = 1; j < needle_len; j++) {
if (hay[i+j] != needle[j]) {
found = 0;
break;
}
}
if (found)
return &hay[i];
}
}
return NULL;
}
int esp_debug(uint32_t priority, const char *format, ...)
{
va_list args;
va_start(args, format);
if(priority <= esp_debug_level)
vprintf(format, args);
va_end(args);
}
void esp_debug_set_level(uint32_t lvl)
{
esp_debug_level = lvl;
}