stringutil.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * StringUtil.h
8  *
9  * Contains utility functions for working with char strings.
10  *
11  * Created on: 26.01.2017
12  * Author: (github.com/)ADiea
13  *
14  ****/
15 
16 #pragma once
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "stddef.h"
23 
29 const char* strstri(const char* pString, const char* pToken);
30 
31 #ifndef _GNU_SOURCE
35 int strcasecmp(const char* s1, const char* s2);
36 
45 void* memmem(const void* haystack, size_t haystacklen, const void* needle, size_t needlelen);
46 
47 void *memrchr(const void *s, int c, size_t n);
48 
49 #endif
50 
51 int memicmp(const void* buf1, const void* buf2, size_t len);
52 
53 static inline char hexchar(unsigned char c)
54 {
55  if(c < 10)
56  return '0' + c;
57  else if(c <= 15)
58  return 'a' + c - 10;
59  else
60  return '\0';
61 }
62 
63 static inline signed char unhex(char c)
64 {
65  if(c >= '0' && c <= '9')
66  return c - '0';
67  else if(c >= 'a' && c <= 'f')
68  return 10 + c - 'a';
69  else if(c >= 'A' && c <= 'F')
70  return 10 + c - 'A';
71  else
72  return -1;
73 }
74 
75 #ifndef ARRAY_SIZE
76 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
77 #endif
78 
79 #ifdef __cplusplus
80 }
81 #endif
static char hexchar(unsigned char c)
Definition: stringutil.h:53
void * memrchr(const void *s, int c, size_t n)
static signed char unhex(char c)
Definition: stringutil.h:63
void * memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
int strcasecmp(const char *s1, const char *s2)
A case-insensitive strcmp().
const char * strstri(const char *pString, const char *pToken)
Return pointer to occurrence of substring in string. Case insensitive.
int memicmp(const void *buf1, const void *buf2, size_t len)