Whitespace cleanups in tnc code

This commit is contained in:
Martin Willi
2011-02-08 11:03:10 +01:00
parent c6c7c7001c
commit 6ccb23e80b
14 changed files with 124 additions and 125 deletions
@@ -38,7 +38,7 @@ struct private_tnccs_batch_t {
* Batch ID
*/
int batch_id;
/**
* TNCC if TRUE, TNCS if FALSE
*/
@@ -75,7 +75,7 @@ METHOD(tnccs_batch_t, add_msg, void,
private_tnccs_batch_t *this, tnccs_msg_t* msg)
{
xmlNodePtr root;
DBG2(DBG_TNC, "adding %N message", tnccs_msg_type_names,
msg->get_type(msg));
this->messages->insert_last(this->messages, msg);
@@ -86,13 +86,13 @@ METHOD(tnccs_batch_t, add_msg, void,
METHOD(tnccs_batch_t, build, void,
private_tnccs_batch_t *this)
{
xmlChar *xmlbuf;
int buf_size;
xmlChar *xmlbuf;
int buf_size;
xmlDocDumpFormatMemory(this->doc, &xmlbuf, &buf_size, 1);
this->encoding = chunk_create((u_char*)xmlbuf, buf_size);
this->encoding = chunk_clone(this->encoding);
xmlFree(xmlbuf);
this->encoding = chunk_clone(this->encoding);
xmlFree(xmlbuf);
}
METHOD(tnccs_batch_t, process, status_t,
@@ -101,9 +101,9 @@ METHOD(tnccs_batch_t, process, status_t,
tnccs_msg_t *tnccs_msg, *msg;
tnccs_error_type_t error_type = TNCCS_ERROR_OTHER;
char *error_msg, buf[BUF_LEN];
xmlNodePtr cur;
xmlNsPtr ns;
xmlChar *batchid, *recipient;
xmlNodePtr cur;
xmlNsPtr ns;
xmlChar *batchid, *recipient;
int batch_id;
this->doc = xmlParseMemory(this->encoding.ptr, this->encoding.len);
@@ -116,7 +116,7 @@ METHOD(tnccs_batch_t, process, status_t,
/* check out the XML document */
cur = xmlDocGetRootElement(this->doc);
if (!cur)
if (!cur)
{
error_type = TNCCS_ERROR_MALFORMED_BATCH;
error_msg = "empty XML document";
@@ -141,12 +141,12 @@ METHOD(tnccs_batch_t, process, status_t,
snprintf(buf, BUF_LEN, "wrong XML document type '%s', expected TNCCS-Batch",
cur->name);
goto fatal;
}
}
/* check presence of BatchID property */
batchid = xmlGetProp(cur, (const xmlChar*)"BatchId");
if (!batchid)
{
{
error_type = TNCCS_ERROR_INVALID_BATCH_ID;
error_msg = "BatchId is missing";
goto fatal;
@@ -180,7 +180,7 @@ METHOD(tnccs_batch_t, process, status_t,
error_msg = buf;
snprintf(buf, BUF_LEN, "message recipient expected '%s', got '%s'",
this->is_server ? "TNCS" : "TNCC", (char*)recipient);
xmlFree(recipient);
xmlFree(recipient);
goto fatal;
}
xmlFree(recipient);
@@ -247,7 +247,7 @@ METHOD(tnccs_batch_t, destroy, void,
offsetof(tnccs_msg_t, destroy));
this->errors->destroy_offset(this->errors,
offsetof(tnccs_msg_t, destroy));
xmlFreeDoc(this->doc);
xmlFreeDoc(this->doc);
free(this->encoding.ptr);
free(this);
}
@@ -56,7 +56,7 @@ struct private_imc_imv_msg_t {
};
/**
* Encodes message data into multiple base64-encoded lines
* Encodes message data into multiple base64-encoded lines
*/
static chunk_t encode_base64(chunk_t data)
{
@@ -98,7 +98,7 @@ static chunk_t encode_base64(chunk_t data)
}
/**
* Decodes message data from multiple base64-encoded lines
* Decodes message data from multiple base64-encoded lines
*/
static chunk_t decode_base64(chunk_t data)
{
@@ -183,15 +183,15 @@ tnccs_msg_t *imc_imv_msg_create_from_node(xmlNodePtr node, linked_list_t *errors
if (streq((char*)cur->name, "Type") && cur->ns == ns)
{
content = xmlNodeGetContent(cur);
this->msg_type = strtoul((char*)content, NULL, 16);
xmlFree(content);
this->msg_type = strtoul((char*)content, NULL, 16);
xmlFree(content);
}
else if (streq((char*)cur->name, "Base64") && cur->ns == ns)
{
content = xmlNodeGetContent(cur);
b64_body = chunk_create((char*)content, strlen((char*)content));
this->msg_body = decode_base64(b64_body);
xmlFree(content);
xmlFree(content);
}
cur = cur->next;
}
@@ -220,7 +220,7 @@ tnccs_msg_t *imc_imv_msg_create(TNC_MessageType msg_type, chunk_t msg_body)
.get_msg_body = _get_msg_body,
},
.type = IMC_IMV_MSG,
.node = xmlNewNode(NULL, BAD_CAST "IMC-IMV-Message"),
.node = xmlNewNode(NULL, BAD_CAST "IMC-IMV-Message"),
.msg_type = msg_type,
.msg_body = chunk_clone(msg_body),
);
@@ -59,10 +59,10 @@ tnccs_msg_t* tnccs_msg_create_from_node(xmlNodePtr node, linked_list_t *errors)
{
if (streq((char*)cur->name, "Type") && cur->ns == ns)
{
xmlChar *content = xmlNodeGetContent(cur);
xmlChar *content = xmlNodeGetContent(cur);
type = strtol((char*)content, NULL, 16);
xmlFree(content);
type = strtol((char*)content, NULL, 16);
xmlFree(content);
found = TRUE;
}
else if (streq((char*)cur->name, "XML") && cur->ns == ns)
@@ -83,18 +83,18 @@ tnccs_msg_t* tnccs_msg_create_from_node(xmlNodePtr node, linked_list_t *errors)
}
cur = xml_msg_node;
/* skip empty and blank nodes */
while (cur && xmlIsBlankNode(cur))
/* skip empty and blank nodes */
while (cur && xmlIsBlankNode(cur))
{
cur = cur->next;
}
if (!cur)
if (!cur)
{
error_msg = "XML node is empty";
goto fatal;
}
/* check if TNCCS message type and node name agree */
/* check if TNCCS message type and node name agree */
if (type >= TNCCS_MSG_RECOMMENDATION && type <= TNCCS_MSG_ROOF)
{
DBG2(DBG_TNC, "processing %N message", tnccs_msg_type_names, type);
@@ -139,11 +139,11 @@ tnccs_msg_t *tnccs_reason_strings_msg_create(chunk_t reason, chunk_t language)
n2 = xmlNewNode(NULL, BAD_CAST enum_to_name(tnccs_msg_type_names, this->type));
/* could add multiple reasons here, if we had them */
n3 = xmlNewNode(NULL, BAD_CAST "ReasonString");
xmlNewProp(n3, BAD_CAST "xml:lang", BAD_CAST this->language.ptr);
xmlNodeSetContent(n3, BAD_CAST this->reason.ptr);
xmlAddChild(n2, n3);
/* could add multiple reasons here, if we had them */
n3 = xmlNewNode(NULL, BAD_CAST "ReasonString");
xmlNewProp(n3, BAD_CAST "xml:lang", BAD_CAST this->language.ptr);
xmlNodeSetContent(n3, BAD_CAST this->reason.ptr);
xmlAddChild(n2, n3);
return &this->public.tnccs_msg_interface;
}
@@ -100,7 +100,7 @@ tnccs_msg_t *tnccs_recommendation_msg_create_from_node(xmlNodePtr node,
{
error_msg = "type property in TNCCS-Recommendation is missing";
goto fatal;
}
}
else if (streq((char*)rec_string, "allow"))
{
this->rec = TNC_IMV_ACTION_RECOMMENDATION_ALLOW;
@@ -122,7 +122,7 @@ tnccs_msg_t *tnccs_recommendation_msg_create_from_node(xmlNodePtr node,
goto fatal;
}
xmlFree(rec_string);
return &this->public.tnccs_msg_interface;
fatal:
@@ -178,7 +178,7 @@ tnccs_msg_t *tnccs_recommendation_msg_create(TNC_IMV_Action_Recommendation rec)
}
n2 = xmlNewNode(NULL, BAD_CAST enum_to_name(tnccs_msg_type_names, this->type));
xmlNewProp(n2, BAD_CAST "type", BAD_CAST rec_string);
xmlNewProp(n2, BAD_CAST "type", BAD_CAST rec_string);
xmlNodeSetContent(n2, "");
xmlAddChild(n, n2);
+3 -3
View File
@@ -371,7 +371,7 @@ METHOD(tls_t, build, status_t,
this->connection_id, TNC_CONNECTION_STATE_HANDSHAKE);
charon->imcs->begin_handshake(charon->imcs, this->connection_id);
}
/* Do not allow any asynchronous IMCs or IMVs to add additional messages */
this->mutex->lock(this->mutex);
@@ -399,7 +399,7 @@ METHOD(tls_t, build, status_t,
else
{
*buflen = data.len;
}
}
memcpy(buf, data.ptr, *buflen);
this->batch->destroy(this->batch);
this->batch = NULL;
@@ -412,7 +412,7 @@ METHOD(tls_t, build, status_t,
}
this->mutex->unlock(this->mutex);
return status;
return status;
}
METHOD(tls_t, is_server, bool,