mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 03:50:57 +01:00
added inline stdnstr() implementation for systems where it doesnt exists (e.g. linux)
This commit is contained in:
4
TODO
4
TODO
@@ -25,6 +25,10 @@ Symmetric decrypt mode tries to open vault
|
||||
|
||||
pcp_find_primary_secret() makes a copy ???
|
||||
|
||||
sym encrypt mac => mac, mac => freebsd and freebsd => mac doesnt work
|
||||
|
||||
c++ destructor double free mess
|
||||
|
||||
Python binding, e.g.:
|
||||
py % cdll.LoadLibrary("libsodium.so.8")
|
||||
<CDLL 'libsodium.so.8', handle 800776c00 at 80192a3d0>
|
||||
|
||||
@@ -76,6 +76,7 @@ AC_CHECK_FUNCS( \
|
||||
memcpy \
|
||||
perror \
|
||||
strnlen \
|
||||
strnstr \
|
||||
strlen \
|
||||
strtol \
|
||||
sizeof \
|
||||
|
||||
@@ -118,6 +118,9 @@
|
||||
/* Define to 1 if you have the `strnlen' function. */
|
||||
#undef HAVE_STRNLEN
|
||||
|
||||
/* Define to 1 if you have the `strnstr' function. */
|
||||
#undef HAVE_STRNSTR
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
|
||||
@@ -157,5 +157,33 @@ strnlen(const char *msg, size_t maxlen)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_STRNSTR
|
||||
/* via FreeBSD libc */
|
||||
#include <string.h>
|
||||
static inline char *
|
||||
strnstr(const char *s, const char *find, size_t slen)
|
||||
{
|
||||
char c, sc;
|
||||
size_t len;
|
||||
|
||||
if ((c = *find++) != '\0') {
|
||||
len = strlen(find);
|
||||
do {
|
||||
do {
|
||||
if (slen-- < 1 || (sc = *s++) == '\0')
|
||||
return (NULL);
|
||||
} while (sc != c);
|
||||
if (len > slen)
|
||||
return (NULL);
|
||||
} while (strncmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return ((char *)s);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* !_HAVE_PCP_PLATFORM_H */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user