Allow reason strings to be used as workitem result string
This commit is contained in:
@@ -34,6 +34,11 @@ struct private_imv_reason_string_t {
|
||||
*/
|
||||
char *lang;
|
||||
|
||||
/**
|
||||
* Separator concatenating multiple reasons
|
||||
*/
|
||||
char *separator;
|
||||
|
||||
/**
|
||||
* Contains the concatenated reasons
|
||||
*/
|
||||
@@ -51,7 +56,8 @@ METHOD(imv_reason_string_t, add_reason, void,
|
||||
if (this->reasons.len)
|
||||
{
|
||||
/* append any further reasons */
|
||||
this->reasons = chunk_cat("mcc", this->reasons, chunk_from_chars('\n'),
|
||||
this->reasons = chunk_cat("mcc", this->reasons,
|
||||
chunk_from_str(this->separator),
|
||||
chunk_create(s_reason, strlen(s_reason)));
|
||||
}
|
||||
else
|
||||
@@ -77,7 +83,7 @@ METHOD(imv_reason_string_t, destroy, void,
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
imv_reason_string_t *imv_reason_string_create(char *lang)
|
||||
imv_reason_string_t *imv_reason_string_create(char *lang, char *separator)
|
||||
{
|
||||
private_imv_reason_string_t *this;
|
||||
|
||||
@@ -88,6 +94,7 @@ imv_reason_string_t *imv_reason_string_create(char *lang)
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.lang = lang,
|
||||
.separator = separator,
|
||||
);
|
||||
|
||||
return &this->public;
|
||||
|
||||
@@ -58,7 +58,8 @@ struct imv_reason_string_t {
|
||||
* Creates an Reason String object
|
||||
*
|
||||
* @param lang Preferred language
|
||||
* @param separator String separating multiple reasons
|
||||
*/
|
||||
imv_reason_string_t* imv_reason_string_create(char *lang);
|
||||
imv_reason_string_t* imv_reason_string_create(char *lang, char *separator);
|
||||
|
||||
#endif /** IMV_REASON_STRING_H_ @}*/
|
||||
|
||||
@@ -421,7 +421,7 @@ METHOD(imv_state_t, get_reason_string, bool,
|
||||
|
||||
/* Instantiate a TNC Reason String object */
|
||||
DESTROY_IF(this->reason_string);
|
||||
this->reason_string = imv_reason_string_create(*reason_language);
|
||||
this->reason_string = imv_reason_string_create(*reason_language, "\n");
|
||||
|
||||
if (this->count_update || this->count_blacklist)
|
||||
{
|
||||
|
||||
@@ -281,7 +281,7 @@ METHOD(imv_state_t, get_reason_string, bool,
|
||||
|
||||
/* Instantiate a TNC Reason String object */
|
||||
DESTROY_IF(this->reason_string);
|
||||
this->reason_string = imv_reason_string_create(*reason_language);
|
||||
this->reason_string = imv_reason_string_create(*reason_language, "\n");
|
||||
if (this->rec != TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION)
|
||||
{
|
||||
this->reason_string->add_reason(this->reason_string, reasons);
|
||||
|
||||
@@ -228,7 +228,7 @@ METHOD(imv_state_t, get_reason_string, bool,
|
||||
|
||||
/* Instantiate a TNC Reason String object */
|
||||
DESTROY_IF(this->reason_string);
|
||||
this->reason_string = imv_reason_string_create(*reason_language);
|
||||
this->reason_string = imv_reason_string_create(*reason_language, "\n");
|
||||
this->reason_string->add_reason(this->reason_string, reasons);
|
||||
*reason_string = this->reason_string->get_encoding(this->reason_string);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user