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

Function PROFILE_SetString

storage/connect/inihandl.cpp:1007–1060  ·  view source on GitHub ↗

* PROFILE_SetString * * Set a profile string. ***********************************************************************/

Source from the content-addressed store, hash-verified

1005 * Set a profile string.
1006 ***********************************************************************/
1007static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name,
1008 LPCSTR value, BOOL create_always)
1009{
1010 if (!key_name) { /* Delete a whole section */
1011 if (trace(2))
1012 htrc("Deleting('%s')\n", section_name);
1013
1014 CurProfile->changed |= PROFILE_DeleteSection(&CurProfile->section,
1015 section_name);
1016 return TRUE; /* Even if PROFILE_DeleteSection() has failed,
1017 this is not an error on application's level.*/
1018 } else if (!value) { /* Delete a key */
1019 if (trace(2))
1020 htrc("Deleting('%s','%s')\n", section_name, key_name);
1021
1022 CurProfile->changed |= PROFILE_DeleteKey(&CurProfile->section,
1023 section_name, key_name);
1024 return TRUE; /* same error handling as above */
1025 } else { /* Set the key value */
1026 PROFILEKEY *key = PROFILE_Find(&CurProfile->section, section_name,
1027 key_name, TRUE, create_always);
1028 if (trace(2))
1029 htrc("Setting('%s','%s','%s')\n", section_name, key_name, value);
1030
1031 if (!key)
1032 return FALSE;
1033
1034 if (key->value) {
1035 /* strip the leading spaces. We can safely strip \n\r and
1036 * friends too, they should not happen here anyway. */
1037 while (PROFILE_isspace(*value))
1038 value++;
1039
1040 if (!strcmp(key->value, value)) {
1041 if (trace(2))
1042 htrc(" no change needed\n" );
1043
1044 return TRUE; /* No change needed */
1045 } // endif value
1046
1047 if (trace(2))
1048 htrc(" replacing '%s'\n", key->value);
1049
1050 free(key->value);
1051 } else if (trace(2))
1052 htrc(" creating key\n" );
1053
1054 key->value = (char*)malloc(strlen(value) + 1);
1055 strcpy(key->value, value);
1056 CurProfile->changed = TRUE;
1057 } // endelse
1058
1059 return TRUE;
1060} // end of PROFILE_SetString
1061
1062
1063/***********************************************************************

Callers 2

Calls 6

PROFILE_DeleteSectionFunction · 0.85
PROFILE_DeleteKeyFunction · 0.85
PROFILE_FindFunction · 0.85
PROFILE_isspaceFunction · 0.85
freeFunction · 0.85
htrcFunction · 0.70

Tested by

no test coverage detected