2 * This file is part of INAV.
4 * INAV is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * INAV is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with INAV. If not, see <http://www.gnu.org/licenses/>.
21 #include "string_light.h"
22 #include "typeconversion.h"
26 return sl_isdigit(c
) || sl_isupper(c
) || sl_islower(c
);
31 return (c
>= '0' && c
<= '9');
36 return (c
>= 'A' && c
<= 'Z');
41 return (c
>= 'a' && c
<= 'z');
46 return sl_isupper(c
) ? (c
) - 'A' + 'a' : c
;
51 return sl_islower(c
) ? (c
) - 'a' + 'A' : c
;
54 void sl_toupperptr(char * c
)
56 for (unsigned int i
= 0; i
< strlen(c
); i
++) {
57 if (c
[i
] >= 'a' && c
[i
] <= 'z') {
58 c
[i
] = c
[i
] - 'a' + 'A';
63 int sl_strcasecmp(const char * s1
, const char * s2
)
65 return sl_strncasecmp(s1
, s2
, INT_MAX
);
68 int sl_strncasecmp(const char * s1
, const char * s2
, int n
)
70 const unsigned char * ucs1
= (const unsigned char *) s1
;
71 const unsigned char * ucs2
= (const unsigned char *) s2
;
75 for ( ; n
!= 0; n
--) {
76 const int c1
= sl_tolower(*ucs1
++);
77 const int c2
= sl_tolower(*ucs2
++);
78 if (((d
= c1
- c2
) != 0) || (c2
== '\0')) {