[Redbutton-devel] SF.net SVN: redbutton: [442] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-10-16 16:12:52
|
Revision: 442
http://redbutton.svn.sourceforge.net/redbutton/?rev=442&view=rev
Author: skilvington
Date: 2007-10-16 09:12:48 -0700 (Tue, 16 Oct 2007)
Log Message:
-----------
decode SEQUENCE types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-16 13:01:37 UTC (rev 441)
+++ redbutton-author/trunk/asn1tag.h 2007-10-16 16:12:48 UTC (rev 442)
@@ -782,5 +782,11 @@
#define ASN1TAGCLASS_StorageEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_StreamComponent FIXME
#define ASN1TAGCLASS_TerminationEnum ASN1TAGCLASS_ENUMERATED
+#define ASN1TAGCLASS_ComparisonValue FIXME
+#define ASN1TAGCLASS_EmulatedEventData FIXME
+#define ASN1TAGCLASS_NewColour FIXME
+#define ASN1TAGCLASS_NewContent FIXME
+#define ASN1TAGCLASS_NewFont FIXME
+#define ASN1TAGCLASS_NewVariableValue FIXME
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-16 13:01:37 UTC (rev 441)
+++ redbutton-author/trunk/ccc.y 2007-10-16 16:12:48 UTC (rev 442)
@@ -854,6 +854,10 @@
/* is it a SEQUENCE or SET */
else if(state.and_items)
{
+ if(asn1type(name) == ASN1TYPE_SEQUENCE)
+ buf_append(&state.decode_fns, "\t/* SEQUENCE */\n");
+ else
+ buf_append(&state.decode_fns, "\t/* SET */\n");
/* output any literals at the start */
for(item=state.items; item && item->type==IT_LITERAL; item=item->next)
buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
@@ -867,9 +871,33 @@
/* is_Xxx() - just match the first item */
buf_append(&state.decode_is_fns, "\treturn is_%s(class, number);\n", item->name);
/* decode_Xxx() - examine each non-literal item in turn */
+ buf_append(&state.decode_fns, "\tlong pretag;\n\n");
while(item && item->type != IT_LITERAL)
{
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* decode the next tag */
+ buf_append(&state.decode_fns, "\tpretag = ftell(der);\n");
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
+ /* is it what we expect */
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
+ /* if it is a synthetic or ENUMERATED type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
+ buf_append(&state.decode_fns, "\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\n", item->name);
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, pretag, SEEK_SET);\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
+ buf_append(&state.decode_fns, "\t}\n\n");
+ /* if it is not optional, raise an error if it is not present */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* if it is optional and not present, seek back to the start of the tag */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
item = item->next;
}
break;
@@ -935,7 +963,7 @@
/* assert */
if(item->type != IT_LITERAL)
fatal("Trailing non-literal");
- buf_append(&state.decode_fns, "\tfprintf(out, %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
item = item->next;
}
}
@@ -990,6 +1018,7 @@
buf_append(&state.decode_fns, "\t");
else
buf_append(&state.decode_fns, "\telse ");
+/* TODO: does GenericObjectReference_direct_reference need a fseek(pretag) */
buf_append(&state.decode_fns, "if(MATCH_TAGCLASS(tag.class, tag.number, ASN1TAGCLASS_%s))\n\t{\n", item->name);
buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, tag.length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|