* case-insensitive compare n chars of two str's */
| 1261 | * case-insensitive compare n chars of two str's |
| 1262 | */ |
| 1263 | static inline int str_strncasecmp(const str *stra, const str *strb, int n) |
| 1264 | { |
| 1265 | int i; |
| 1266 | |
| 1267 | if(stra==NULL || strb==NULL || stra->s ==NULL || strb->s==NULL |
| 1268 | || stra->len<0 || strb->len<0) |
| 1269 | { |
| 1270 | #ifdef EXTRA_DEBUG |
| 1271 | LM_DBG("bad parameters\n"); |
| 1272 | #endif |
| 1273 | return -2; |
| 1274 | } |
| 1275 | |
| 1276 | if (stra->len<n || strb->len<n) { |
| 1277 | LM_ERR("input strings don't have at least [n=%d] characters\n", n); |
| 1278 | return -2; |
| 1279 | } |
| 1280 | |
| 1281 | for (i = 0; i < n; i++) { |
| 1282 | const char a = tolower(stra->s[i]); |
| 1283 | const char b = tolower(strb->s[i]); |
| 1284 | if (a < b) |
| 1285 | return -1; |
| 1286 | if (a > b) |
| 1287 | return 1; |
| 1288 | } |
| 1289 | |
| 1290 | return 0; |
| 1291 | |
| 1292 | } |
| 1293 | |
| 1294 | /* |
| 1295 | * case-insensitive compare two str's |
no outgoing calls
no test coverage detected