From a5fe605aaea2710fa4dadc03933a8bfc9b108f52 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 20 Sep 2016 23:27:21 -0700 Subject: [PATCH] HTTPSink: Add basic property setting support. --- src/HTTPSinkImpl.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/HTTPSinkImpl.cpp b/src/HTTPSinkImpl.cpp index 6c1e89454a..125db57cf9 100644 --- a/src/HTTPSinkImpl.cpp +++ b/src/HTTPSinkImpl.cpp @@ -166,6 +166,33 @@ bool HTTPSinkImpl::ProcessCommand(llvm::raw_ostream& os, SourceImpl& source, } // try to assign parameter + auto prop = source.GetPropertyIndex(param); + if (!prop) { + WARNING("ignoring HTTP parameter \"" << param << "\""); + continue; + } + + CS_Status status = 0; + auto type = source.GetPropertyType(prop); + switch (type) { + case CS_PROP_BOOLEAN: + case CS_PROP_INTEGER: + case CS_PROP_ENUM: { + int val; + if (value.str().getAsInteger(10, val)) { + WARNING("HTTP parameter \"" << param << "\" value \"" << value + << "\" is not an integer"); + } else + source.SetProperty(prop, val, &status); + break; + } + case CS_PROP_STRING: { + source.SetStringProperty(prop, value, &status); + break; + } + default: + break; + } } if (respond) {