Ignore:
Timestamp:
Jan 26, 2008 10:45:52 AM (16 years ago)
Author:
bennylp
Message:

Added pj_strstr() and pj_stristr() in pjlib

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/string.c

    r1210 r1757  
    2727#  include <pj/string_i.h> 
    2828#endif 
     29 
     30 
     31PJ_DEF(char*) pj_strstr(const pj_str_t *str, const pj_str_t *substr) 
     32{ 
     33    const char *s, *ends; 
     34 
     35    /* Special case when substr is zero */ 
     36    if (substr->slen == 0) { 
     37        return (char*)str->ptr; 
     38    } 
     39 
     40    s = str->ptr; 
     41    ends = str->ptr + str->slen - substr->slen; 
     42    for (; s<=ends; ++s) { 
     43        if (pj_ansi_strncmp(s, substr->ptr, substr->slen)==0) 
     44            return (char*)s; 
     45    } 
     46    return NULL; 
     47} 
     48 
     49 
     50PJ_DEF(char*) pj_stristr(const pj_str_t *str, const pj_str_t *substr) 
     51{ 
     52    const char *s, *ends; 
     53 
     54    /* Special case when substr is zero */ 
     55    if (substr->slen == 0) { 
     56        return (char*)str->ptr; 
     57    } 
     58 
     59    s = str->ptr; 
     60    ends = str->ptr + str->slen - substr->slen; 
     61    for (; s<=ends; ++s) { 
     62        if (pj_ansi_strnicmp(s, substr->ptr, substr->slen)==0) 
     63            return (char*)s; 
     64    } 
     65    return NULL; 
     66} 
    2967 
    3068 
Note: See TracChangeset for help on using the changeset viewer.