@@ -63,6 +63,8 @@ str_to_datatype(const char *str)
6363 type = TS_RECORDDATATYPE_INT;
6464 } else if (!strcmp (str, " STRING" )) {
6565 type = TS_RECORDDATATYPE_STRING;
66+ } else if (!strcmp (str, " FLOAT" )) {
67+ type = TS_RECORDDATATYPE_FLOAT;
6668 }
6769
6870 return type;
@@ -106,6 +108,9 @@ RemapConfigs::parse_inline(const char *arg)
106108 _items[_current]._data_len = value.size ();
107109 }
108110 break ;
111+ case TS_RECORDDATATYPE_FLOAT:
112+ _items[_current]._data .rec_float = strtof (value.c_str (), nullptr );
113+ break ;
109114 default :
110115 TSError (" [%s] Configuration variable '%s' is of an unsupported type" , PLUGIN_NAME, key.c_str ());
111116 return false ;
@@ -181,7 +186,7 @@ RemapConfigs::parse_file(const char *filename)
181186 // Find the type (INT or STRING only)
182187 tok = strtok_r (nullptr , " \t " , &ln);
183188 if (TS_RECORDDATATYPE_NULL == (type = str_to_datatype (tok))) {
184- TSError (" [%s] file %s, line %d: only INT and STRING types supported" , PLUGIN_NAME, path.c_str (), line_num);
189+ TSError (" [%s] file %s, line %d: only INT, STRING, and FLOAT types supported" , PLUGIN_NAME, path.c_str (), line_num);
185190 continue ;
186191 }
187192
@@ -231,6 +236,9 @@ RemapConfigs::parse_file(const char *filename)
231236 _items[_current]._data_len = strlen (tok);
232237 }
233238 break ;
239+ case TS_RECORDDATATYPE_FLOAT:
240+ _items[_current]._data .rec_float = strtof (tok, nullptr );
241+ break ;
234242 default :
235243 TSError (" [%s] file %s, line %d: type not support (unheard of)" , PLUGIN_NAME, path.c_str (), line_num);
236244 continue ;
@@ -330,6 +338,10 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * /* rri ATS_UNUSED */
330338 TSHttpTxnConfigStringSet (txnp, conf->_items [ix]._name , conf->_items [ix]._data .rec_string , conf->_items [ix]._data_len );
331339 TSDebug (PLUGIN_NAME, " Setting config id %d to %s" , conf->_items [ix]._name , conf->_items [ix]._data .rec_string );
332340 break ;
341+ case TS_RECORDDATATYPE_FLOAT:
342+ TSHttpTxnConfigFloatSet (txnp, conf->_items [ix]._name , conf->_items [ix]._data .rec_int );
343+ TSDebug (PLUGIN_NAME, " Setting config id %d to %f" , conf->_items [ix]._name , conf->_items [ix]._data .rec_float );
344+ break ;
333345 default :
334346 break ; // Error ?
335347 }
0 commit comments