When generating PDML, insert a fake protocol wrapper around top-level field items. This is to help preserve the PDML schema, and is discussed in bug 2226.
svn path=/trunk/; revision=24281
This commit is contained in:
parent
609bb57097
commit
542913de9d
36
print.c
36
print.c
@ -262,10 +262,29 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
|
|||||||
int chop_len;
|
int chop_len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Will wrap up top-level field items inside a fake protocol wrapper to
|
||||||
|
preserve the PDML schema */
|
||||||
|
gboolean wrap_in_fake_protocol =
|
||||||
|
(((fi->hfinfo->type != FT_PROTOCOL) ||
|
||||||
|
(fi->hfinfo->id == proto_data)) &&
|
||||||
|
(pdata->level == 0));
|
||||||
|
|
||||||
|
/* Indent to the correct level */
|
||||||
for (i = -1; i < pdata->level; i++) {
|
for (i = -1; i < pdata->level; i++) {
|
||||||
fputs(" ", pdata->fh);
|
fputs(" ", pdata->fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wrap_in_fake_protocol) {
|
||||||
|
/* Open fake protocol wrapper */
|
||||||
|
fputs("<proto name=\"fake-field-wrapper\">\n", pdata->fh);
|
||||||
|
|
||||||
|
/* Indent to increased level before writint out field */
|
||||||
|
pdata->level++;
|
||||||
|
for (i = -1; i < pdata->level; i++) {
|
||||||
|
fputs(" ", pdata->fh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Text label. It's printed as a field with no name. */
|
/* Text label. It's printed as a field with no name. */
|
||||||
if (fi->hfinfo->id == hf_text_only) {
|
if (fi->hfinfo->id == hf_text_only) {
|
||||||
/* Get the text */
|
/* Get the text */
|
||||||
@ -294,16 +313,15 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
|
|||||||
fputs("\"/>\n", pdata->fh);
|
fputs("\"/>\n", pdata->fh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Uninterpreted data, i.e., the "Data" protocol, is
|
/* Uninterpreted data, i.e., the "Data" protocol, is
|
||||||
* printed as a field instead of a protocol. */
|
* printed as a field instead of a protocol. */
|
||||||
else if (fi->hfinfo->id == proto_data) {
|
else if (fi->hfinfo->id == proto_data) {
|
||||||
|
|
||||||
|
/* Write out field with data */
|
||||||
fputs("<field name=\"data\" value=\"", pdata->fh);
|
fputs("<field name=\"data\" value=\"", pdata->fh);
|
||||||
|
|
||||||
write_pdml_field_hex_value(pdata, fi);
|
write_pdml_field_hex_value(pdata, fi);
|
||||||
|
|
||||||
fputs("\"/>\n", pdata->fh);
|
fputs("\"/>\n", pdata->fh);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Normal protocols and fields */
|
/* Normal protocols and fields */
|
||||||
else {
|
else {
|
||||||
@ -421,10 +439,17 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
|
|||||||
pdata->level--;
|
pdata->level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Take back the extra level we added for fake wrapper protocol */
|
||||||
|
if (wrap_in_fake_protocol) {
|
||||||
|
pdata->level--;
|
||||||
|
}
|
||||||
|
|
||||||
if (node->first_child != NULL) {
|
if (node->first_child != NULL) {
|
||||||
|
/* Indent to correct level */
|
||||||
for (i = -1; i < pdata->level; i++) {
|
for (i = -1; i < pdata->level; i++) {
|
||||||
fputs(" ", pdata->fh);
|
fputs(" ", pdata->fh);
|
||||||
}
|
}
|
||||||
|
/* Close off current element */
|
||||||
if (fi->hfinfo->id != proto_data) { /* Data protocol uses simple tags */
|
if (fi->hfinfo->id != proto_data) { /* Data protocol uses simple tags */
|
||||||
if (fi->hfinfo->type == FT_PROTOCOL) {
|
if (fi->hfinfo->type == FT_PROTOCOL) {
|
||||||
fputs("</proto>\n", pdata->fh);
|
fputs("</proto>\n", pdata->fh);
|
||||||
@ -434,6 +459,11 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Close off fake wrapper protocol */
|
||||||
|
if (wrap_in_fake_protocol) {
|
||||||
|
fputs("</proto>\n", pdata->fh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print info for a 'geninfo' pseudo-protocol. This is required by
|
/* Print info for a 'geninfo' pseudo-protocol. This is required by
|
||||||
|
Loading…
x
Reference in New Issue
Block a user