MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / str_strstr

Function str_strstr

ut.h:1179–1216  ·  view source on GitHub ↗

* search @strb in @stra, return pointer to 1st occurrence */

Source from the content-addressed store, hash-verified

1177 * search @strb in @stra, return pointer to 1st occurrence
1178 */
1179static inline char* str_strstr(const str *stra, const str *strb)
1180{
1181 int i;
1182 int len;
1183
1184 if (stra==NULL || strb==NULL || stra->s==NULL || strb->s==NULL
1185 || stra->len<=0 || strb->len<=0) {
1186#ifdef EXTRA_DEBUG
1187 LM_DBG("bad parameters\n");
1188#endif
1189 return NULL;
1190 }
1191
1192 if (strb->len > stra->len)
1193 return NULL;
1194
1195 len=0;
1196 while (stra->len-len >= strb->len){
1197 if (stra->s[len] != strb->s[0]) {
1198 len++;
1199 continue;
1200 }
1201
1202 for (i=1; i<strb->len; i++)
1203 if (stra->s[len+i]!=strb->s[i]) {
1204 len++;
1205 break;
1206 }
1207
1208 if (i != strb->len)
1209 continue;
1210
1211 return stra->s+len;
1212 }
1213
1214
1215 return NULL;
1216}
1217
1218/*
1219 * search @strb in @stra ignoring case of both, return pointer to 1st occurrence

Callers 9

mod_initFunction · 0.85
b2b_sdp_demux_bodyFunction · 0.85
set_node_contentFunction · 0.85
w_handle_callFunction · 0.85
parse_extra_tokenFunction · 0.85
test_utFunction · 0.85
parse_net_proxy_protocolFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_utFunction · 0.68