MCPcopy Create free account
hub / github.com/apache/trafficserver / plugin_expand

Function plugin_expand

src/proxy/Plugin.cc:209–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209static char *
210plugin_expand(char *arg)
211{
212 RecDataT data_type;
213 char *str = nullptr;
214
215 if (*arg != '$') {
216 return (char *)nullptr;
217 }
218 // skip the $ character
219 arg += 1;
220
221 if (RecGetRecordDataType(arg, &data_type) != REC_ERR_OKAY) {
222 goto not_found;
223 }
224
225 switch (data_type) {
226 case RECD_STRING: {
227 RecString str_val;
228 if (RecGetRecordString_Xmalloc(arg, &str_val) != REC_ERR_OKAY) {
229 goto not_found;
230 }
231 return static_cast<char *>(str_val);
232 break;
233 }
234 case RECD_FLOAT: {
235 RecFloat float_val;
236 if (RecGetRecordFloat(arg, &float_val) != REC_ERR_OKAY) {
237 goto not_found;
238 }
239 str = static_cast<char *>(ats_malloc(128));
240 snprintf(str, 128, "%f", static_cast<float>(float_val));
241 return str;
242 break;
243 }
244 case RECD_INT: {
245 RecInt int_val;
246 if (RecGetRecordInt(arg, &int_val) != REC_ERR_OKAY) {
247 goto not_found;
248 }
249 str = static_cast<char *>(ats_malloc(128));
250 snprintf(str, 128, "%ld", static_cast<long int>(int_val));
251 return str;
252 break;
253 }
254 case RECD_COUNTER: {
255 RecCounter count_val;
256 if (RecGetRecordCounter(arg, &count_val) != REC_ERR_OKAY) {
257 goto not_found;
258 }
259 str = static_cast<char *>(ats_malloc(128));
260 snprintf(str, 128, "%ld", static_cast<long int>(count_val));
261 return str;
262 break;
263 }
264 default:
265 goto not_found;
266 break;

Callers 1

plugin_initFunction · 0.85

Calls 6

RecGetRecordDataTypeFunction · 0.85
RecGetRecordFloatFunction · 0.85
ats_mallocFunction · 0.85
RecGetRecordIntFunction · 0.85
RecGetRecordCounterFunction · 0.85

Tested by

no test coverage detected