Loading src/common/util.c +16 −0 Changes for src/common/util.c: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -484,6 +484,22 @@ strcasecmpend(const char *s1, const char *s2) return strncasecmp(s1+(n1-n2), s2, n2); } /** Compare the value of the string <b>prefix</b> with the start of the * <b>memlen</b>-byte memory chunk at <b>mem</b>. Return as for strcmp. * * [As memcmp(mem, prefix, strlen(prefix)) but returns -1 if memlen is less * than strlen(prefix).] */ int memcmpstart(const void *mem, size_t memlen, const char *prefix) { size_t plen = strlen(prefix); if (memlen < plen) return -1; return memcmp(mem, prefix, plen); } /** Return a pointer to the first char of s that is not whitespace and * not a comment, or to the terminating NUL if no such character exists. */ Loading src/common/util.h +3 −0 Changes for src/common/util.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -181,6 +181,9 @@ int strcasecmpstart(const char *s1, const char *s2) int strcmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2)); int strcasecmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2)); int memcmpstart(const void *mem, size_t memlen, const char *prefix) ATTR_PURE; void tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2)); long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next); Loading Loading
src/common/util.c +16 −0 Changes for src/common/util.c: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -484,6 +484,22 @@ strcasecmpend(const char *s1, const char *s2) return strncasecmp(s1+(n1-n2), s2, n2); } /** Compare the value of the string <b>prefix</b> with the start of the * <b>memlen</b>-byte memory chunk at <b>mem</b>. Return as for strcmp. * * [As memcmp(mem, prefix, strlen(prefix)) but returns -1 if memlen is less * than strlen(prefix).] */ int memcmpstart(const void *mem, size_t memlen, const char *prefix) { size_t plen = strlen(prefix); if (memlen < plen) return -1; return memcmp(mem, prefix, plen); } /** Return a pointer to the first char of s that is not whitespace and * not a comment, or to the terminating NUL if no such character exists. */ Loading
src/common/util.h +3 −0 Changes for src/common/util.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -181,6 +181,9 @@ int strcasecmpstart(const char *s1, const char *s2) int strcmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2)); int strcasecmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2)); int memcmpstart(const void *mem, size_t memlen, const char *prefix) ATTR_PURE; void tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2)); long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next); Loading