summaryrefslogtreecommitdiff
path: root/pjlib/src/pj/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib/src/pj/string.c')
-rw-r--r--pjlib/src/pj/string.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/pjlib/src/pj/string.c b/pjlib/src/pj/string.c
index 9a2ca0f2..fb520c7b 100644
--- a/pjlib/src/pj/string.c
+++ b/pjlib/src/pj/string.c
@@ -28,6 +28,44 @@
#endif
+PJ_DEF(char*) pj_strstr(const pj_str_t *str, const pj_str_t *substr)
+{
+ const char *s, *ends;
+
+ /* Special case when substr is zero */
+ if (substr->slen == 0) {
+ return (char*)str->ptr;
+ }
+
+ s = str->ptr;
+ ends = str->ptr + str->slen - substr->slen;
+ for (; s<=ends; ++s) {
+ if (pj_ansi_strncmp(s, substr->ptr, substr->slen)==0)
+ return (char*)s;
+ }
+ return NULL;
+}
+
+
+PJ_DEF(char*) pj_stristr(const pj_str_t *str, const pj_str_t *substr)
+{
+ const char *s, *ends;
+
+ /* Special case when substr is zero */
+ if (substr->slen == 0) {
+ return (char*)str->ptr;
+ }
+
+ s = str->ptr;
+ ends = str->ptr + str->slen - substr->slen;
+ for (; s<=ends; ++s) {
+ if (pj_ansi_strnicmp(s, substr->ptr, substr->slen)==0)
+ return (char*)s;
+ }
+ return NULL;
+}
+
+
PJ_DEF(pj_str_t*) pj_strltrim( pj_str_t *str )
{
register char *p = str->ptr;