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

Function PROFILE_CopyEntry

storage/connect/inihandl.cpp:124–175  ·  view source on GitHub ↗

* PROFILE_CopyEntry * * Copy the content of an entry into a buffer, removing quotes, * and possibly translating environment variables. ***********************************************************************/

Source from the content-addressed store, hash-verified

122 * and possibly translating environment variables.
123 ***********************************************************************/
124static void PROFILE_CopyEntry( char *buffer, const char *value, uint len,
125 int handle_env )
126{
127 const char *p;
128 char quote = '\0';
129
130 if (!buffer)
131 return;
132
133 if ((*value == '\'') || (*value == '\"'))
134 if (value[1] && (value[strlen(value)-1] == *value))
135 quote = *value++;
136
137 if (!handle_env) {
138 strncpy(buffer, value, len);
139
140 if (quote && (len >= strlen(value)))
141 buffer[strlen(buffer)-1] = '\0';
142
143 return;
144 } // endif handle
145
146 for (p = value; (*p && (len > 1)); *buffer++ = *p++, len--) {
147 if ((*p == '$') && (p[1] == '{')) {
148 char env_val[1024];
149 const char *env_p;
150 const char *p2 = strchr(p, '}');
151
152 if (!p2)
153 continue; /* ignore it */
154
155 strncpy(env_val, p + 2, MY_MIN((int) sizeof(env_val), (int)(p2-p)-1));
156
157 if ((env_p = getenv(env_val)) != NULL) {
158 int buffer_len;
159
160 strncpy( buffer, env_p, len );
161 buffer_len = strlen( buffer );
162 buffer += buffer_len;
163 len -= buffer_len;
164 } // endif env_p
165
166 p = p2 + 1;
167 } // endif p
168
169 } // endfor p
170
171 if (quote && (len > 1))
172 buffer--;
173
174 *buffer = '\0';
175} // end of PROFILE_CopyEntry
176
177
178/***********************************************************************

Callers 2

PROFILE_GetSectionFunction · 0.85
PROFILE_GetStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected