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

Function cmp_cachedb_id

cachedb/cachedb_id.c:435–486  ·  view source on GitHub ↗

* Compare two connection identifiers * \param id1 first identifier * \param id2 second identifier * \return one if both are equal, zero otherwise */

Source from the content-addressed store, hash-verified

433 * \return one if both are equal, zero otherwise
434 */
435int cmp_cachedb_id(struct cachedb_id* id1, struct cachedb_id* id2)
436{
437 if (!id1 || !id2) return 0;
438
439 /* connections with different flags never match */
440 if (id1->flags != id2->flags) return 0;
441 /* different scehemes - never match */
442 if (strcmp(id1->scheme,id2->scheme)) return 0;
443
444 if (id1->flags == CACHEDB_ID_NO_URL) {
445 /* no url - always match, based just on scheme */
446 return 1;
447 }
448
449 /* different group names - never match */
450 if ((id1->group_name == NULL && id2->group_name != NULL) ||
451 (id1->group_name != NULL && id2->group_name == NULL))
452 return 0;
453 if (id1->group_name && strcmp(id1->group_name,id2->group_name)) return 0;
454
455 /* different usernames - never match */
456 if ((id1->username == NULL && id2->username != NULL) ||
457 (id1->username != NULL && id2->username == NULL))
458 return 0;
459 if (id1->username && strcmp(id1->username,id2->username)) return 0;
460
461 /* different passwords - never match */
462 if ((id1->password == NULL && id2->password != NULL) ||
463 (id1->password != NULL && id2->password == NULL))
464 return 0;
465 if (id1->password && strcmp(id1->password,id2->password)) return 0;
466
467 if (strcmp(id1->host,id2->host)) return 0;
468
469 if ((id1->database == NULL && id2->database != NULL) ||
470 (id1->database != NULL && id2->database == NULL))
471 return 0;
472 if (id1->database && strcmp(id1->database,id2->database)) return 0;
473
474 if ((!id1->extra_options && id2->extra_options) ||
475 (id1->extra_options && !id2->extra_options))
476 return 0;
477 if (id1->extra_options &&
478 strcmp(id1->extra_options, id2->extra_options)) return 0;
479
480 if (id1->flags != CACHEDB_ID_MULTIPLE_HOSTS) {
481 /* also check port as it is not included in host member */
482 if (id1->port != id2->port) return 0;
483 }
484
485 return 1;
486}
487
488
489/**

Callers 1

cachedb_pool_getFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected