MCPcopy Create free account
hub / github.com/MariaDB/server / PROFILE_Find

Function PROFILE_Find

storage/connect/inihandl.cpp:733–817  ·  view source on GitHub ↗

* PROFILE_Find * * Find a key in a profile tree, optionally creating it. ***********************************************************************/

Source from the content-addressed store, hash-verified

731 * Find a key in a profile tree, optionally creating it.
732 ***********************************************************************/
733static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section,
734 const char *section_name,
735 const char *key_name,
736 BOOL create, BOOL create_always)
737{
738 const char *p;
739 int seclen, keylen;
740
741 while (PROFILE_isspace(*section_name))
742 section_name++;
743
744 p = section_name + strlen(section_name) - 1;
745
746 while ((p > section_name) && PROFILE_isspace(*p))
747 p--;
748
749 seclen = p - section_name + 1;
750
751 while (PROFILE_isspace(*key_name))
752 key_name++;
753
754 p = key_name + strlen(key_name) - 1;
755
756 while ((p > key_name) && PROFILE_isspace(*p))
757 p--;
758
759 keylen = p - key_name + 1;
760
761 while (*section) {
762 if (((*section)->name[0])
763 && (!(_strnicmp((*section)->name, section_name, seclen )))
764 && (((*section)->name)[seclen] == '\0')) {
765 PROFILEKEY* *key = &(*section)->key;
766
767 while (*key) {
768 /* If create_always is FALSE then we check if the keyname already exists.
769 * Otherwise we add it regardless of its existence, to allow
770 * keys to be added more then once in some cases.
771 */
772 if (!create_always) {
773 if ((!(_strnicmp( (*key)->name, key_name, keylen )))
774 && (((*key)->name)[keylen] == '\0'))
775 return *key;
776
777 } // endif !create_always
778
779 key = &(*key)->next;
780 } // endwhile *key
781
782 if (!create)
783 return NULL;
784
785 if (!(*key = (PROFILEKEY*)malloc(sizeof(PROFILEKEY) + strlen(key_name))))
786 return NULL;
787
788 strcpy((*key)->name, key_name);
789 (*key)->value = NULL;
790 (*key)->next = NULL;

Callers 2

PROFILE_GetStringFunction · 0.85
PROFILE_SetStringFunction · 0.85

Calls 2

PROFILE_isspaceFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected