mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
added str_str() to help parse http POST requests for rhizome direct. #9
This commit is contained in:
parent
389ae8e989
commit
fb82043246
10
str.c
10
str.c
@ -17,6 +17,8 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "str.h"
|
||||
|
||||
@ -42,3 +44,11 @@ int strcase_startswith(char *str, const char *substring, char **afterp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Like strstr() but doesn't depend on null termination */
|
||||
const char *str_str(const char *s1,const char *s2,int s1len)
|
||||
{
|
||||
int s2len=strlen(s2);
|
||||
for(;*s1&&(s1len--);s1++)
|
||||
if (!strncmp(s2,s1,s2len)) return s1;
|
||||
return NULL;
|
||||
}
|
||||
|
5
str.h
5
str.h
@ -37,5 +37,8 @@ int str_startswith(char *str, const char *substring, char **afterp);
|
||||
*/
|
||||
int strcase_startswith(char *str, const char *substring, char **afterp);
|
||||
|
||||
/* like strstr(), but doesn't depend on null termination.
|
||||
@author Paul Gardner-Stephen <paul@servalproject.org> */
|
||||
const char *str_str(const char *s1,const char *s2,int s1len);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user