Allow reason strings to be used as workitem result string

This commit is contained in:
Andreas Steffen
2014-01-13 12:06:17 +01:00
parent 6009b6e0dd
commit 81d49c5cfd
9 changed files with 89 additions and 53 deletions
+9 -2
View File
@@ -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;
+2 -1
View File
@@ -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_ @}*/
+1 -1
View File
@@ -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);