Thread: [Redbutton-devel] SF.net SVN: redbutton: [447] redbutton-author/trunk (Page 3)
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-10-18 10:05:05
|
Revision: 447
http://redbutton.svn.sourceforge.net/redbutton/?rev=447&view=rev
Author: skilvington
Date: 2007-10-18 03:05:02 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
don't use yy prefix for our variables, avoids problems with newer versions of flex
Modified Paths:
--------------
redbutton-author/trunk/ccc.l
redbutton-author/trunk/ccc.y
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
Modified: redbutton-author/trunk/ccc.l
===================================================================
--- redbutton-author/trunk/ccc.l 2007-10-18 08:41:14 UTC (rev 446)
+++ redbutton-author/trunk/ccc.l 2007-10-18 10:05:02 UTC (rev 447)
@@ -2,7 +2,7 @@
#include <string.h>
#define YYSTYPE char *
#include "ccc.tab.h"
-extern unsigned int yylineno;
+extern unsigned int lineno;
%}
%%
\/\/[^\n\r\f]* return COMMENT;
@@ -15,7 +15,7 @@
"+" return ONEORMORE;
"?" return IDENTORNULL;
"." return ENDCLAUSE;
-[\n\r\f] yylineno ++;
+[\n\r\f] lineno ++;
[ \t]+ /* ignore whitespace */
. return INVALID;
%%
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-18 08:41:14 UTC (rev 446)
+++ redbutton-author/trunk/ccc.y 2007-10-18 10:05:02 UTC (rev 447)
@@ -86,13 +86,13 @@
void file_append(FILE *, char *);
/* input line we are currently parsing */
-unsigned int yylineno = 1;
+unsigned int lineno = 1;
/* yacc functions we need to provide */
void
yyerror(const char *str)
{
- fprintf(stderr, "Error: %s at line %u\n", str, yylineno);
+ fprintf(stderr, "Error: %s at line %u\n", str, lineno);
return;
}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-10-18 08:41:14 UTC (rev 446)
+++ redbutton-author/trunk/parser.c.header 2007-10-18 10:05:02 UTC (rev 447)
@@ -28,15 +28,15 @@
* lexer functions we need to provide
*/
-unsigned int yylineno = 1;
-unsigned int yynerrs = 0;
+unsigned int lineno = 1;
+unsigned int nerrs = 0;
void
yyerror(const char *str)
{
- fprintf(stderr, "Error: %s at line %u\n", str, yylineno);
+ fprintf(stderr, "Error: %s at line %u\n", str, lineno);
- yynerrs ++;
+ nerrs ++;
return;
}
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-10-18 08:41:14 UTC (rev 446)
+++ redbutton-author/trunk/parser.l.footer 2007-10-18 10:05:02 UTC (rev 447)
@@ -91,6 +91,6 @@
unsigned int
nparse_errors(void)
{
- return yynerrs;
+ return nerrs;
}
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-10-18 08:41:14 UTC (rev 446)
+++ redbutton-author/trunk/parser.l.header 2007-10-18 10:05:02 UTC (rev 447)
@@ -5,8 +5,8 @@
#include <errno.h>
#include "parser.h"
#include "tokens.h"
-extern unsigned int yylineno;
-extern unsigned int yynerrs;
+extern unsigned int lineno;
+extern unsigned int nerrs;
%}
%%
\/\/[^\n\r\f]* return COMMENT;
@@ -16,5 +16,5 @@
'[^']*' return QPRINTABLE;
`[^`]*` return BASE64;
null return Null;
-[\n\r\f] yylineno ++;
+[\n\r\f] lineno ++;
[ \t]+ /* ignore whitespace */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-18 16:06:16
|
Revision: 448
http://redbutton.svn.sourceforge.net/redbutton/?rev=448&view=rev
Author: skilvington
Date: 2007-10-18 09:06:13 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
keep_tag function is needed
Modified Paths:
--------------
redbutton-author/trunk/asn1decode.c.header
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1decode.c.header
===================================================================
--- redbutton-author/trunk/asn1decode.c.header 2007-10-18 10:05:02 UTC (rev 447)
+++ redbutton-author/trunk/asn1decode.c.header 2007-10-18 16:06:13 UTC (rev 448)
@@ -9,10 +9,12 @@
bool keep_tag(unsigned int tagclass)
{
-/* TODO: is this function needed? */
-return true;
- if(ASN1TAGCLASS_GroupIdentifier == ASN1TAG_SYNTHETIC
- || ASN1TAGCLASS_GroupIdentifier == ASN1TAGCLASS_ENUMERATED)
+ if(is_synthetic(tagclass)
+ || tagclass == ASN1TAGCLASS_BOOLEAN
+ || tagclass == ASN1TAGCLASS_INTEGER
+ || tagclass == ASN1TAGCLASS_OctetString
+ || tagclass == ASN1TAGCLASS_Null
+ || tagclass == ASN1TAGCLASS_ENUMERATED)
return true;
else
return false;
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-18 10:05:02 UTC (rev 447)
+++ redbutton-author/trunk/asn1tag.h 2007-10-18 16:06:13 UTC (rev 448)
@@ -771,7 +771,7 @@
#define ASN1TAGCLASS_GenericInteger FIXME
#define ASN1TAGCLASS_GenericObjectReference FIXME
#define ASN1TAGCLASS_GenericOctetString FIXME
-#define ASN1TAGCLASS_GroupItem FIXME
+#define ASN1TAGCLASS_GroupItem ASN1TAG_CHOICE
#define ASN1TAGCLASS_InputTypeEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_JustificationEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_LineOrientationEnum ASN1TAGCLASS_ENUMERATED
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-19 11:06:52
|
Revision: 451
http://redbutton.svn.sourceforge.net/redbutton/?rev=451&view=rev
Author: skilvington
Date: 2007-10-19 04:06:49 -0700 (Fri, 19 Oct 2007)
Log Message:
-----------
don't eat synthetic tags in CHOICE types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
redbutton-author/trunk/der_decode.c
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-18 16:20:22 UTC (rev 450)
+++ redbutton-author/trunk/asn1tag.h 2007-10-19 11:06:49 UTC (rev 451)
@@ -763,14 +763,14 @@
#define ASN1TAGCLASS_ContentBody FIXME
#define ASN1TAGCLASS_DefaultAttribute FIXME
#define ASN1TAGCLASS_ElementaryAction FIXME
-#define ASN1TAGCLASS_EventDataBody FIXME
+#define ASN1TAGCLASS_EventDataBody ASN1TAG_CHOICE
#define ASN1TAGCLASS_EventTypeEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_FontBody FIXME
-#define ASN1TAGCLASS_GenericBoolean FIXME
-#define ASN1TAGCLASS_GenericContentReference FIXME
-#define ASN1TAGCLASS_GenericInteger FIXME
-#define ASN1TAGCLASS_GenericObjectReference FIXME
-#define ASN1TAGCLASS_GenericOctetString FIXME
+#define ASN1TAGCLASS_GenericBoolean ASN1TAG_CHOICE
+#define ASN1TAGCLASS_GenericContentReference ASN1TAG_CHOICE
+#define ASN1TAGCLASS_GenericInteger ASN1TAG_CHOICE
+#define ASN1TAGCLASS_GenericObjectReference ASN1TAG_CHOICE
+#define ASN1TAGCLASS_GenericOctetString ASN1TAG_CHOICE
#define ASN1TAGCLASS_GroupItem ASN1TAG_CHOICE
#define ASN1TAGCLASS_InputTypeEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_JustificationEnum ASN1TAGCLASS_ENUMERATED
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-18 16:20:22 UTC (rev 450)
+++ redbutton-author/trunk/ccc.y 2007-10-19 11:06:49 UTC (rev 451)
@@ -849,7 +849,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;
}
}
@@ -997,6 +997,7 @@
{
/* a CHOICE type */
buf_append(&state.decode_fns, "\t/* CHOICE */\n");
+ buf_append(&state.decode_fns, "\tlong pretag = 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");
@@ -1018,11 +1019,18 @@
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(is_%s(tag.class, tag.number))\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);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ /* if it is a synthetic or primitive type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\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");
}
buf_append(&state.decode_fns, "\telse\n");
@@ -1030,7 +1038,8 @@
}
/* end decode_Xxx() function */
- buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
+ buf_append(&state.decode_fns, "\tif(!is_synthetic(ASN1TAGCLASS_%s))\n", name);
+ buf_append(&state.decode_fns, "\t\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
Modified: redbutton-author/trunk/der_decode.c
===================================================================
--- redbutton-author/trunk/der_decode.c 2007-10-18 16:20:22 UTC (rev 450)
+++ redbutton-author/trunk/der_decode.c 2007-10-19 11:06:49 UTC (rev 451)
@@ -95,7 +95,7 @@
verbose("<Boolean value=\"%s\"/>\n", val ? "true" : "false");
- fprintf(out, "%s", val ? "true" : "false");
+ fprintf(out, "%s ", val ? "true" : "false");
return length;
}
@@ -107,7 +107,7 @@
verbose("<Integer value=\"%d\"/>\n", val);
- fprintf(out, "%d", val);
+ fprintf(out, "%d ", val);
return length;
}
@@ -134,7 +134,7 @@
fprintf(out, "=%02x", byte);
left --;
}
- fprintf(out, "'");
+ fprintf(out, "' ");
verbose("</OctetString>\n");
@@ -162,7 +162,7 @@
verbose("<Enumerated value=\"%d\"/>\n", val);
- fprintf(out, "%s", names[val - 1]);
+ fprintf(out, "%s ", names[val - 1]);
return length;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-19 16:25:34
|
Revision: 452
http://redbutton.svn.sourceforge.net/redbutton/?rev=452&view=rev
Author: skilvington
Date: 2007-10-19 09:25:28 -0700 (Fri, 19 Oct 2007)
Log Message:
-----------
cope with optional types in sequences
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-19 11:06:49 UTC (rev 451)
+++ redbutton-author/trunk/asn1tag.h 2007-10-19 16:25:28 UTC (rev 452)
@@ -756,13 +756,13 @@
/* needed by mhegd */
#define FIXME 9999
#define ASN1TAGCLASS_InterchangedObject ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_ActionSlot FIXME
-#define ASN1TAGCLASS_ActionSlotSeq FIXME
+#define ASN1TAGCLASS_ActionSlot ASN1TAG_CHOICE
+#define ASN1TAGCLASS_ActionSlotSeq FIXME
#define ASN1TAGCLASS_ButtonStyleEnum ASN1TAGCLASS_ENUMERATED
-#define ASN1TAGCLASS_Colour FIXME
-#define ASN1TAGCLASS_ContentBody FIXME
-#define ASN1TAGCLASS_DefaultAttribute FIXME
-#define ASN1TAGCLASS_ElementaryAction FIXME
+#define ASN1TAGCLASS_Colour ASN1TAG_CHOICE
+#define ASN1TAGCLASS_ContentBody FIXME
+#define ASN1TAGCLASS_DefaultAttribute ASN1TAG_CHOICE
+#define ASN1TAGCLASS_ElementaryAction ASN1TAG_CHOICE
#define ASN1TAGCLASS_EventDataBody ASN1TAG_CHOICE
#define ASN1TAGCLASS_EventTypeEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_FontBody FIXME
@@ -776,18 +776,18 @@
#define ASN1TAGCLASS_JustificationEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_LineOrientationEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_OrientationEnum ASN1TAGCLASS_ENUMERATED
-#define ASN1TAGCLASS_OriginalValueBody FIXME
+#define ASN1TAGCLASS_OriginalValueBody FIXME
#define ASN1TAGCLASS_Parameter FIXME
#define ASN1TAGCLASS_SliderStyleEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_StartCornerEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_StorageEnum ASN1TAGCLASS_ENUMERATED
-#define ASN1TAGCLASS_StreamComponent FIXME
+#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_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-19 11:06:49 UTC (rev 451)
+++ redbutton-author/trunk/ccc.y 2007-10-19 16:25:28 UTC (rev 452)
@@ -821,25 +821,52 @@
/* 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);
- /* decode the item */
- buf_append(&state.decode_fns, "\tlong pretag = 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");
- buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
- /* if it is a synthetic or primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\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\telse\n");
- buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
+ /* assert */
+ if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
+ fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
+/* is it OPTIONAL - check if length == 0 */
+/* then do the decode as for IDENTIFIER - as below... */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+#if 0
+/* TextContentHook needs it to work this way... */
+ /* is it a primitive type => no extra tag to decode */
+ if(strcmp(item->name, "BOOLEAN") == 0 || strcmp(item->name, "INTEGER") == 0)
+ {
+ /* assert */
+ if(item->type != IT_IDENTIFIER)
+ fatal("Primitive but not Identifier");
+ buf_append(&state.decode_fns, "\tder_decode_%s(der, out, length);\n", item->name);
+ }
+ else
+/* ObjectNumber needs it to work this way... */
+#endif
+ {
+ /* is it ONEORMORE - need a while(left > 0) loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\t\twhile(left > 0)\n\t{\n");
+ /* decode the item */
+ 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");
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
+ /* if it is a synthetic or primitive type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\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\telse\n");
+ buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n", name);
+ /* is it ONEORMORE - need a while(left > 0) loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\n");
+ }
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
@@ -873,11 +900,9 @@
/* is_Xxx() - just match the first item */
buf_append(&state.decode_is_fns, "\t\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");
@@ -886,7 +911,7 @@
/* if it is a synthetic or primitive type, we still need the current tag */
buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\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\tfseek(der, -sublen, SEEK_CUR);\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");
@@ -894,11 +919,32 @@
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");
+ buf_append(&state.decode_fns, "\t}\n");
+ /* is it a type that is encoded as a NULL if it is not present */
+ if(item->type == IT_IDENTORNULL)
+ {
+ buf_append(&state.decode_fns, "\telse if(!is_Null(tag.class, tag.number))\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: missing Null\");\n", name);
+ buf_append(&state.decode_fns, "\t}\n\n");
+ }
+ /* if it is optional and not present, seek back to the start of the tag */
+ else if(item->type == IT_OPTIONAL)
+ {
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tleft += sublen;\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 */
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ else
+ {
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: missing %s\");\n", name, item->name);
+ buf_append(&state.decode_fns, "\t}\n\n");
+ }
item = item->next;
}
break;
@@ -948,8 +994,8 @@
}
/* decode_Xxx() */
buf_append(&state.decode_fns, "\t\telse\n");
- buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n\t}\n", name);
- buf_append(&state.decode_fns, "\t\t}\n\n");
+ buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n\t\t}\n", name);
+ buf_append(&state.decode_fns, "\t}\n\n");
break;
default:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-25 16:07:06
|
Revision: 453
http://redbutton.svn.sourceforge.net/redbutton/?rev=453&view=rev
Author: skilvington
Date: 2007-10-25 09:06:59 -0700 (Thu, 25 Oct 2007)
Log Message:
-----------
mhegd can now correctly decode the helloworld example
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-10-19 16:25:28 UTC (rev 452)
+++ redbutton-author/trunk/TODO 2007-10-25 16:06:59 UTC (rev 453)
@@ -1,3 +1,4 @@
+mhegc
output filename should default to App/Scene GroupIdentifier rather than "a"
(but warn if file exists - stops accidental overwrite of source!)
@@ -3,4 +4,22 @@
---
+mhegd
+HorizontalJustification doesn't work
+EventTypeEnum does
+ie ENUMERATED types without an explicit ENUMERATED tag don't work
+
+---
+
+mhegd
+check NoTokenActionSlots (empty and not empty)
+check MovementTable (empty and not empty)
+
+---
+
+mhegd
+:ContentRef ContentReference keeps the tag as part of the OctetString
+
+---
+
clean up ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-19 16:25:28 UTC (rev 452)
+++ redbutton-author/trunk/asn1tag.h 2007-10-25 16:06:59 UTC (rev 453)
@@ -754,18 +754,18 @@
#define ASN1TAGCLASS_ContentReference ASN1TAG_SYNTHETIC
/* needed by mhegd */
-#define FIXME 9999
#define ASN1TAGCLASS_InterchangedObject ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_ActionSlot ASN1TAG_CHOICE
-#define ASN1TAGCLASS_ActionSlotSeq FIXME
+/* TODO: check this, also make sure NoTokenActionSlots are decoded correctly */
+#define ASN1TAGCLASS_ActionSlotSeq ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_ButtonStyleEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_Colour ASN1TAG_CHOICE
-#define ASN1TAGCLASS_ContentBody FIXME
+#define ASN1TAGCLASS_ContentBody ASN1TAG_CHOICE
#define ASN1TAGCLASS_DefaultAttribute ASN1TAG_CHOICE
#define ASN1TAGCLASS_ElementaryAction ASN1TAG_CHOICE
#define ASN1TAGCLASS_EventDataBody ASN1TAG_CHOICE
#define ASN1TAGCLASS_EventTypeEnum ASN1TAGCLASS_ENUMERATED
-#define ASN1TAGCLASS_FontBody FIXME
+#define ASN1TAGCLASS_FontBody ASN1TAG_CHOICE
#define ASN1TAGCLASS_GenericBoolean ASN1TAG_CHOICE
#define ASN1TAGCLASS_GenericContentReference ASN1TAG_CHOICE
#define ASN1TAGCLASS_GenericInteger ASN1TAG_CHOICE
@@ -776,18 +776,18 @@
#define ASN1TAGCLASS_JustificationEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_LineOrientationEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_OrientationEnum ASN1TAGCLASS_ENUMERATED
-#define ASN1TAGCLASS_OriginalValueBody FIXME
-#define ASN1TAGCLASS_Parameter FIXME
+#define ASN1TAGCLASS_OriginalValueBody ASN1TAG_CHOICE
+#define ASN1TAGCLASS_Parameter ASN1TAG_CHOICE
#define ASN1TAGCLASS_SliderStyleEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_StartCornerEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_StorageEnum ASN1TAGCLASS_ENUMERATED
-#define ASN1TAGCLASS_StreamComponent FIXME
+#define ASN1TAGCLASS_StreamComponent ASN1TAG_CHOICE
#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
+#define ASN1TAGCLASS_ComparisonValue ASN1TAG_CHOICE
+#define ASN1TAGCLASS_EmulatedEventData ASN1TAG_CHOICE
+#define ASN1TAGCLASS_NewColour ASN1TAG_CHOICE
+#define ASN1TAGCLASS_NewContent ASN1TAG_CHOICE
+#define ASN1TAGCLASS_NewFont ASN1TAG_CHOICE
+#define ASN1TAGCLASS_NewVariableValue ASN1TAG_CHOICE
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-19 16:25:28 UTC (rev 452)
+++ redbutton-author/trunk/ccc.y 2007-10-25 16:06:59 UTC (rev 453)
@@ -824,49 +824,76 @@
/* assert */
if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
-/* is it OPTIONAL - check if length == 0 */
-/* then do the decode as for IDENTIFIER - as below... */
+/* is it OPTIONAL - check if length == 0, if so bomb out now */
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-#if 0
-/* TextContentHook needs it to work this way... */
- /* is it a primitive type => no extra tag to decode */
- if(strcmp(item->name, "BOOLEAN") == 0 || strcmp(item->name, "INTEGER") == 0)
+ /* is it a primitive type */
+ if(strcmp(item->name, "BOOLEAN") == 0
+ || strcmp(item->name, "INTEGER") == 0
+ || strcmp(item->name, "OctetString") == 0)
{
/* assert */
if(item->type != IT_IDENTIFIER)
fatal("Primitive but not Identifier");
- buf_append(&state.decode_fns, "\tder_decode_%s(der, out, length);\n", item->name);
+ /* does it need an extra explicit tag for the primitive type? */
+ buf_append(&state.decode_fns, "\tif(ASN1TAGCLASS_%s != ASN1TAGCLASS_%s)\n", name, item->name);
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
}
+ /* is it ONEORMORE - need a while(left > 0) loop */
+ if(item->type == IT_ONEORMORE)
+ {
+ buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
+ /* decode the item */
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
+ buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ /* if it is a synthetic or primitive type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t}\n");
+ buf_append(&state.decode_fns, "\t\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t}\n");
+ buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
+ buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
+ buf_append(&state.decode_fns, "\t}\n");
+ }
else
-/* ObjectNumber needs it to work this way... */
-#endif
{
- /* is it ONEORMORE - need a while(left > 0) loop */
- if(item->type == IT_ONEORMORE)
- buf_append(&state.decode_fns, "\t\twhile(left > 0)\n\t{\n");
+ /* the whole length is the sub types value */
+ buf_append(&state.decode_fns, "\t{\n");
/* decode the item */
- 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");
- buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
/* if it is a synthetic or primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
- buf_append(&state.decode_fns, "\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\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\telse\n");
- buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n", name);
- /* is it ONEORMORE - need a while(left > 0) loop */
- if(item->type == IT_ONEORMORE)
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\n");
+ buf_append(&state.decode_fns, "\t\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t}\n");
+ buf_append(&state.decode_fns, "\t\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t}\n");
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n\n");
+ buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
+ buf_append(&state.decode_fns, "\t}\n");
}
+ buf_append(&state.decode_fns, "\n");
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-29 16:42:38
|
Revision: 454
http://redbutton.svn.sourceforge.net/redbutton/?rev=454&view=rev
Author: skilvington
Date: 2007-10-29 09:42:31 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
give access to the ASN1TAGCLASS_XXX constants when XXX is not known until run time
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-10-25 16:06:59 UTC (rev 453)
+++ redbutton-author/trunk/asn1tag.c 2007-10-29 16:42:31 UTC (rev 454)
@@ -20,6 +20,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
#include "asn1tag.h"
char *
@@ -51,3 +55,485 @@
|| (asn1class == ASN1CLASS_UNIVERSAL && asn1tag == ASN1TAG_SEQUENCE)
|| (asn1class == ASN1CLASS_UNIVERSAL && asn1tag == ASN1TAG_SET);
}
+
+/*
+ * give access to ASN1TAGCLASS_XXX constants when XXX is not known until run time
+ */
+
+#define MATCH(TYPE) if(strcmp(name, #TYPE) == 0) return ASN1TAGCLASS_ ## TYPE;
+
+unsigned int
+asn1tagclass(const char *name)
+{
+ MATCH(Root)
+ MATCH(Group)
+ MATCH(Presentable)
+ MATCH(Ingredient)
+ MATCH(Program)
+ MATCH(Variable)
+ MATCH(Visible)
+ MATCH(Interactible)
+ MATCH(Button)
+ MATCH(TokenManager)
+ MATCH(ObjectIdentifier)
+ MATCH(TokenGroupBody)
+ MATCH(LineArtBody)
+ MATCH(TextBody)
+ MATCH(PushButtonBody)
+ MATCH(BoxSize)
+ MATCH(OctetString)
+ MATCH(ApplicationClass)
+ MATCH(SceneClass)
+ MATCH(StandardIdentifier)
+ MATCH(StandardVersion)
+ MATCH(ObjectInformation)
+ MATCH(OnStartUp)
+ MATCH(OnCloseDown)
+ MATCH(OriginalGroupCachePriority)
+ MATCH(Items)
+ MATCH(ResidentProgramClass)
+ MATCH(RemoteProgramClass)
+ MATCH(InterchangedProgramClass)
+ MATCH(PaletteClass)
+ MATCH(FontClass)
+ MATCH(CursorShapeClass)
+ MATCH(BooleanVariableClass)
+ MATCH(IntegerVariableClass)
+ MATCH(OctetStringVariableClass)
+ MATCH(ObjectRefVariableClass)
+ MATCH(ContentRefVariableClass)
+ MATCH(LinkClass)
+ MATCH(StreamClass)
+ MATCH(BitmapClass)
+ MATCH(LineArtClass)
+ MATCH(DynamicLineArtClass)
+ MATCH(RectangleClass)
+ MATCH(HotspotClass)
+ MATCH(SwitchButtonClass)
+ MATCH(PushButtonClass)
+ MATCH(TextClass)
+ MATCH(EntryFieldClass)
+ MATCH(HyperTextClass)
+ MATCH(SliderClass)
+ MATCH(TokenGroupClass)
+ MATCH(ListGroupClass)
+ MATCH(OnSpawnCloseDown)
+ MATCH(OnRestart)
+ MATCH(DefaultAttributes)
+ MATCH(CharacterSet)
+ MATCH(BackgroundColour)
+ MATCH(TextContentHook)
+ MATCH(TextColour)
+ MATCH(Font)
+ MATCH(FontAttributes)
+ MATCH(InterchangedProgramContentHook)
+ MATCH(StreamContentHook)
+ MATCH(BitmapContentHook)
+ MATCH(LineArtContentHook)
+ MATCH(ButtonRefColour)
+ MATCH(HighlightRefColour)
+ MATCH(SliderRefColour)
+ MATCH(InputEventRegister)
+ MATCH(SceneCoordinateSystem)
+ MATCH(AspectRatio)
+ MATCH(MovingCursor)
+ MATCH(NextScenes)
+ MATCH(InitiallyActive)
+ MATCH(ContentHook)
+ MATCH(OriginalContent)
+ MATCH(Shared)
+ MATCH(ContentSize)
+ MATCH(ContentCachePriority)
+ MATCH(LinkCondition)
+ MATCH(LinkEffect)
+ MATCH(Name)
+ MATCH(InitiallyAvailable)
+ MATCH(ProgramConnectionTag)
+ MATCH(OriginalValue)
+ MATCH(ObjectReferenceValue)
+ MATCH(ContentReference69)
+ MATCH(MovementTable)
+ MATCH(TokenGroupItems)
+ MATCH(NoTokenActionSlots)
+ MATCH(Positions)
+ MATCH(WrapAround)
+ MATCH(MultipleSelection)
+ MATCH(OriginalBoxSize)
+ MATCH(OriginalPosition)
+ MATCH(OriginalPaletteRef)
+ MATCH(Tiling)
+ MATCH(OriginalTransparency)
+ MATCH(BorderedBoundingBox)
+ MATCH(OriginalLineWidth)
+ MATCH(OriginalLineStyle)
+ MATCH(OriginalRefLineColour)
+ MATCH(OriginalRefFillColour)
+ MATCH(OriginalFont)
+ MATCH(HorizontalJustification)
+ MATCH(VerticalJustification)
+ MATCH(LineOrientation)
+ MATCH(StartCorner)
+ MATCH(TextWrapping)
+ MATCH(Multiplex)
+ MATCH(Storage)
+ MATCH(Looping)
+ MATCH(AudioClass)
+ MATCH(VideoClass)
+ MATCH(RTGraphicsClass)
+ MATCH(ComponentTag)
+ MATCH(OriginalVolume)
+ MATCH(Termination)
+ MATCH(EngineResp)
+ MATCH(Orientation)
+ MATCH(MaxValue)
+ MATCH(MinValue)
+ MATCH(InitialValue)
+ MATCH(InitialPortion)
+ MATCH(StepSize)
+ MATCH(SliderStyle)
+ MATCH(InputType)
+ MATCH(CharList)
+ MATCH(ObscuredInput)
+ MATCH(MaxLength)
+ MATCH(OriginalLabel)
+ MATCH(ButtonStyle)
+ MATCH(Activate)
+ MATCH(Add)
+ MATCH(AddItem)
+ MATCH(Append)
+ MATCH(BringToFront)
+ MATCH(Call)
+ MATCH(CallActionSlot)
+ MATCH(Clear)
+ MATCH(Clone)
+ MATCH(CloseConnection)
+ MATCH(Deactivate)
+ MATCH(DelItem)
+ MATCH(Deselect)
+ MATCH(DeselectItem)
+ MATCH(Divide)
+ MATCH(DrawArc)
+ MATCH(DrawLine)
+ MATCH(DrawOval)
+ MATCH(DrawPolygon)
+ MATCH(DrawPolyline)
+ MATCH(DrawRectangle)
+ MATCH(DrawSector)
+ MATCH(Fork)
+ MATCH(GetAvailabilityStatus)
+ MATCH(GetBoxSize)
+ MATCH(GetCellItem)
+ MATCH(GetCursorPosition)
+ MATCH(GetEngineSupport)
+ MATCH(GetEntryPoint)
+ MATCH(GetFillColour)
+ MATCH(GetFirstItem)
+ MATCH(GetHighlightStatus)
+ MATCH(GetInteractionStatus)
+ MATCH(GetItemStatus)
+ MATCH(GetLabel)
+ MATCH(GetLastAnchorFired)
+ MATCH(GetLineColour)
+ MATCH(GetLineStyle)
+ MATCH(GetLineWidth)
+ MATCH(GetListItem)
+ MATCH(GetListSize)
+ MATCH(GetOverwriteMode)
+ MATCH(GetPortion)
+ MATCH(GetPosition)
+ MATCH(GetRunningStatus)
+ MATCH(GetSelectionStatus)
+ MATCH(GetSliderValue)
+ MATCH(GetTextContent)
+ MATCH(GetTextData)
+ MATCH(GetTokenPosition)
+ MATCH(GetVolume)
+ MATCH(Launch)
+ MATCH(LockScreen)
+ MATCH(Modulo)
+ MATCH(Move)
+ MATCH(MoveTo)
+ MATCH(Multiply)
+ MATCH(OpenConnection)
+ MATCH(Preload)
+ MATCH(PutBefore)
+ MATCH(PutBehind)
+ MATCH(Quit)
+ MATCH(ReadPersistent)
+ MATCH(Run)
+ MATCH(ScaleBitmap)
+ MATCH(ScaleVideo)
+ MATCH(ScrollItems)
+ MATCH(Select)
+ MATCH(SelectItem)
+ MATCH(SendEvent)
+ MATCH(SendToBack)
+ MATCH(SetBoxSize)
+ MATCH(SetCachePriority)
+ MATCH(SetCounterEndPosition)
+ MATCH(SetCounterPosition)
+ MATCH(SetCounterTrigger)
+ MATCH(SetCursorPosition)
+ MATCH(SetCursorShape)
+ MATCH(SetData)
+ MATCH(SetEntryPoint)
+ MATCH(SetFillColour)
+ MATCH(SetFirstItem)
+ MATCH(SetFontRef)
+ MATCH(SetHighlightStatus)
+ MATCH(SetInteractionStatus)
+ MATCH(SetLabel)
+ MATCH(SetLineColour)
+ MATCH(SetLineStyle)
+ MATCH(SetLineWidth)
+ MATCH(SetOverwriteMode)
+ MATCH(SetPaletteRef)
+ MATCH(SetPortion)
+ MATCH(SetPosition)
+ MATCH(SetSliderValue)
+ MATCH(SetSpeed)
+ MATCH(SetTimer)
+ MATCH(SetTransparency)
+ MATCH(SetVariable)
+ MATCH(SetVolume)
+ MATCH(Spawn)
+ MATCH(Step)
+ MATCH(Stop)
+ MATCH(StorePersistent)
+ MATCH(Subtract)
+ MATCH(TestVariable)
+ MATCH(Toggle)
+ MATCH(ToggleItem)
+ MATCH(TransitionTo)
+ MATCH(Unload)
+ MATCH(UnlockScreen)
+ MATCH(NewGenericBoolean)
+ MATCH(NewGenericInteger)
+ MATCH(NewGenericOctetstring)
+ MATCH(NewGenericObjectReference)
+ MATCH(NewGenericContentReference)
+ MATCH(NewColourIndex)
+ MATCH(NewAbsoluteColour)
+ MATCH(NewFontName)
+ MATCH(NewFontReference)
+ MATCH(NewContentSize)
+ MATCH(NewContentCachePriority)
+ MATCH(IndirectReference)
+ MATCH(SetBackgroundColour)
+ MATCH(SetCellPosition)
+ MATCH(SetInputReg)
+ MATCH(SetTextColour)
+ MATCH(SetFontAttributes)
+ MATCH(SetVideoDecodeOffset)
+ MATCH(GetVideoDecodeOffset)
+ MATCH(GetFocusPosition)
+ MATCH(SetFocusPosition)
+ MATCH(SetBitmapDecodeOffset)
+ MATCH(GetBitmapDecodeOffset)
+ MATCH(SetSliderParameters)
+ MATCH(BOOLEAN)
+ MATCH(INTEGER)
+ MATCH(OCTETSTRING)
+ MATCH(NULL)
+ MATCH(ENUMERATED)
+ MATCH(SEQUENCE)
+ MATCH(SET)
+ MATCH(Null)
+ MATCH(JointIsoItuIdentifier)
+ MATCH(MHEGStandardIdentifier)
+ MATCH(DirectFont)
+ MATCH(IndirectFont)
+ MATCH(XScene)
+ MATCH(YScene)
+ MATCH(Width)
+ MATCH(Height)
+ MATCH(SceneRef)
+ MATCH(SceneWeight)
+ MATCH(IncludedContent)
+ MATCH(EventSource)
+ MATCH(EventType)
+ MATCH(EventData)
+ MATCH(ObjectReference)
+ MATCH(ContentReferenceValue)
+ MATCH(TargetElement)
+ MATCH(AVisible)
+ MATCH(Position)
+ MATCH(XLength)
+ MATCH(YLength)
+ MATCH(AbsoluteTime)
+ MATCH(Address)
+ MATCH(Answer)
+ MATCH(AppendValue)
+ MATCH(ArcAngle)
+ MATCH(AvailabilityStatusVar)
+ MATCH(CallSucceeded)
+ MATCH(CellIndex)
+ MATCH(CloneRefVar)
+ MATCH(ConnectionTag)
+ MATCH(Denominator)
+ MATCH(EllipseHeight)
+ MATCH(EllipseWidth)
+ MATCH(EmulatedEventSource)
+ MATCH(EmulatedEventType)
+ MATCH(EntryPointVar)
+ MATCH(ForkSucceeded)
+ MATCH(Feature)
+ MATCH(FillColourVar)
+ MATCH(FirstItemVar)
+ MATCH(HighlightStatusVar)
+ MATCH(Index)
+ MATCH(InFileName)
+ MATCH(InteractionStatusVar)
+ MATCH(ItemIndex)
+ MATCH(ItemRefVar)
+ MATCH(ItemStatusVar)
+ MATCH(ItemsToScroll)
+ MATCH(LabelVar)
+ MATCH(LastAnchorFiredVar)
+ MATCH(LineColourVar)
+ MATCH(LineStyleVar)
+ MATCH(LineWidthVar)
+ MATCH(MovementIdentifier)
+ MATCH(NbOfSteps)
+ MATCH(NewCachePriority)
+ MATCH(NewCounterEndPosition)
+ MATCH(NewCounterPosition)
+ MATCH(NewCounterValue)
+ MATCH(NewCursorShape)
+ MATCH(NewEntryPoint)
+ MATCH(NewFirstItem)
+ MATCH(NewGenericOctetString)
+ MATCH(NewHighlightStatus)
+ MATCH(NewIncludedContent)
+ MATCH(NewInteractionStatus)
+ MATCH(NewLabel)
+ MATCH(NewLineStyle)
+ MATCH(NewLineWidth)
+ MATCH(NewOverwriteMode)
+ MATCH(NewPaletteRef)
+ MATCH(NewPortion)
+ MATCH(NewSliderValue)
+ MATCH(NewSpeed)
+ MATCH(NewTransparency)
+ MATCH(NewVolume)
+ MATCH(NewXPosition)
+ MATCH(NewYPosition)
+ MATCH(Numerator)
+ MATCH(OpenSucceeded)
+ MATCH(Operator)
+ MATCH(OutFileName)
+ MATCH(OverwriteModeVar)
+ MATCH(PortionVar)
+ MATCH(Protocol)
+ MATCH(ReadSucceeded)
+ MATCH(ReferenceVisible)
+ MATCH(RunningStatusVar)
+ MATCH(SelectionStatusVar)
+ MATCH(SizeVar)
+ MATCH(SliderValueVar)
+ MATCH(StartAngle)
+ MATCH(StoreSucceeded)
+ MATCH(Target)
+ MATCH(TextContentVar)
+ MATCH(TextDataVar)
+ MATCH(TimerID)
+ MATCH(TimerValue)
+ MATCH(TokenPositionVar)
+ MATCH(TransitionEffect)
+ MATCH(TriggerIdentifier)
+ MATCH(Value)
+ MATCH(VisibleReference)
+ MATCH(VolumeVar)
+ MATCH(X)
+ MATCH(X1)
+ MATCH(X2)
+ MATCH(XBoxSizeVar)
+ MATCH(XCursor)
+ MATCH(XNewBoxSize)
+ MATCH(XOut)
+ MATCH(XPositionVar)
+ MATCH(XScale)
+ MATCH(Y)
+ MATCH(Y1)
+ MATCH(Y2)
+ MATCH(YBoxSizeVar)
+ MATCH(YCursor)
+ MATCH(YNewBoxSize)
+ MATCH(YOut)
+ MATCH(YPositionVar)
+ MATCH(YScale)
+ MATCH(XOffsetVar)
+ MATCH(YOffsetVar)
+ MATCH(NewXOffset)
+ MATCH(NewYOffset)
+ MATCH(FocusPositionVar)
+ MATCH(NewFocusPosition)
+ MATCH(NewMinValue)
+ MATCH(NewMaxValue)
+ MATCH(NewStepSize)
+ MATCH(InternalReference)
+ MATCH(GroupIdentifier)
+ MATCH(ObjectNumber)
+ MATCH(DirectReference)
+ MATCH(ColourIndex)
+ MATCH(AbsoluteColour)
+ MATCH(XPosition)
+ MATCH(YPosition)
+ MATCH(ReferencedContent)
+ MATCH(XYPosition)
+ MATCH(Point)
+ MATCH(Rational)
+ MATCH(ExternalReference)
+ MATCH(NewReferencedContent)
+ MATCH(NextScene)
+ MATCH(TokenGroupItem)
+ MATCH(Movement)
+ MATCH(ActionSlots)
+ MATCH(InVariables)
+ MATCH(OutVariables)
+ MATCH(ActionClass)
+ MATCH(Parameters)
+ MATCH(PointList)
+ MATCH(ActionClassSeq)
+ MATCH(ContentReference)
+ MATCH(InterchangedObject)
+ MATCH(ActionSlot)
+ MATCH(ActionSlotSeq)
+ MATCH(ButtonStyleEnum)
+ MATCH(Colour)
+ MATCH(ContentBody)
+ MATCH(DefaultAttribute)
+ MATCH(ElementaryAction)
+ MATCH(EventDataBody)
+ MATCH(EventTypeEnum)
+ MATCH(FontBody)
+ MATCH(GenericBoolean)
+ MATCH(GenericContentReference)
+ MATCH(GenericInteger)
+ MATCH(GenericObjectReference)
+ MATCH(GenericOctetString)
+ MATCH(GroupItem)
+ MATCH(InputTypeEnum)
+ MATCH(JustificationEnum)
+ MATCH(LineOrientationEnum)
+ MATCH(OrientationEnum)
+ MATCH(OriginalValueBody)
+ MATCH(Parameter)
+ MATCH(SliderStyleEnum)
+ MATCH(StartCornerEnum)
+ MATCH(StorageEnum)
+ MATCH(StreamComponent)
+ MATCH(TerminationEnum)
+ MATCH(ComparisonValue)
+ MATCH(EmulatedEventData)
+ MATCH(NewColour)
+ MATCH(NewContent)
+ MATCH(NewFont)
+ MATCH(NewVariableValue)
+
+ fprintf(stderr, "Unknown ASN1TAGCLASS type: %s\n", name);
+ exit(EXIT_FAILURE);
+
+ return ASN1TAG_BAD;
+}
+
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-25 16:06:59 UTC (rev 453)
+++ redbutton-author/trunk/asn1tag.h 2007-10-29 16:42:31 UTC (rev 454)
@@ -43,6 +43,8 @@
#define ASN1TAG_SYNTHETIC 10000
/* the tag for CHOICE types is determined by which choice we choose */
#define ASN1TAG_CHOICE 10001
+/* for signalling internal parser errors */
+#define ASN1TAG_BAD 10002
/* abstract types */
#define ASN1TAGCLASS_Root ASN1TAG_SYNTHETIC
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-29 16:44:53
|
Revision: 455
http://redbutton.svn.sourceforge.net/redbutton/?rev=455&view=rev
Author: skilvington
Date: 2007-10-29 09:44:42 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
add the prototype
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/asn1type.c
redbutton-author/trunk/asn1type.h
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-29 16:42:31 UTC (rev 454)
+++ redbutton-author/trunk/asn1tag.h 2007-10-29 16:44:42 UTC (rev 455)
@@ -34,6 +34,7 @@
char *asn1class_name(unsigned int);
bool is_synthetic(unsigned int);
bool needs_tagging(unsigned int, unsigned int);
+unsigned int asn1tagclass(const char *);
/*
* a synthetic object created as a result of the grammar definition
Modified: redbutton-author/trunk/asn1type.c
===================================================================
--- redbutton-author/trunk/asn1type.c 2007-10-29 16:42:31 UTC (rev 454)
+++ redbutton-author/trunk/asn1type.c 2007-10-29 16:44:42 UTC (rev 455)
@@ -29,7 +29,7 @@
#define MATCH(NAME, TYPE) if(strcmp(name, #NAME) == 0) return ASN1TYPE_ ## TYPE;
enum asn1type
-asn1type(char *name)
+asn1type(const char *name)
{
MATCH(InterchangedObject, CHOICE)
MATCH(Group, SET) // MATCH(GroupClass, SET)
Modified: redbutton-author/trunk/asn1type.h
===================================================================
--- redbutton-author/trunk/asn1type.h 2007-10-29 16:42:31 UTC (rev 454)
+++ redbutton-author/trunk/asn1type.h 2007-10-29 16:44:42 UTC (rev 455)
@@ -32,6 +32,6 @@
ASN1TYPE_SEQUENCE
};
-enum asn1type asn1type(char *);
+enum asn1type asn1type(const char *);
#endif /* __ASN1TYPE_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-29 17:11:42
|
Revision: 456
http://redbutton.svn.sourceforge.net/redbutton/?rev=456&view=rev
Author: skilvington
Date: 2007-10-29 10:11:26 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
simplify asn1decode.c now we can look up ASN1TAGCLASS values in ccc at run time
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/asn1decode.c.header
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-10-29 16:44:42 UTC (rev 455)
+++ redbutton-author/trunk/Makefile 2007-10-29 17:11:26 UTC (rev 456)
@@ -36,10 +36,10 @@
mhegd: asn1decode.h ${MHEGD_OBJS}
${CC} ${CFLAGS} ${DEFS} -o mhegd ${MHEGD_OBJS} ${LIBS}
-ccc: ccc.y ccc.l asn1type.o
+ccc: ccc.y ccc.l asn1type.o asn1tag.o
${LEX} -i -t ccc.l > lex.ccc.c
${YACC} -b ccc -d ccc.y
- ${CC} ${CFLAGS} ${DEFS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
+ ${CC} ${CFLAGS} ${DEFS} -o ccc lex.ccc.c ccc.tab.c asn1type.o asn1tag.o
lex.parser.c parser.c parser.h: parser.l.* parser.c.* parser.h.* tokens.h.* grammar asn1tag.h ccc
cat grammar | ./ccc -l parser.l -p parser.c -h parser.h -t tokens.h
Modified: redbutton-author/trunk/asn1decode.c.header
===================================================================
--- redbutton-author/trunk/asn1decode.c.header 2007-10-29 16:44:42 UTC (rev 455)
+++ redbutton-author/trunk/asn1decode.c.header 2007-10-29 17:11:26 UTC (rev 456)
@@ -7,19 +7,6 @@
void verbose(char *, ...);
-bool keep_tag(unsigned int tagclass)
-{
- if(is_synthetic(tagclass)
- || tagclass == ASN1TAGCLASS_BOOLEAN
- || tagclass == ASN1TAGCLASS_INTEGER
- || tagclass == ASN1TAGCLASS_OctetString
- || tagclass == ASN1TAGCLASS_Null
- || tagclass == ASN1TAGCLASS_ENUMERATED)
- return true;
- else
- return false;
-}
-
int asn1decode_BOOLEAN(FILE *der, FILE *out, int length)
{
int left = length;
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-10-29 16:44:42 UTC (rev 455)
+++ redbutton-author/trunk/asn1tag.c 2007-10-29 17:11:26 UTC (rev 456)
@@ -57,6 +57,24 @@
}
/*
+ * return true if we need to pass on the tag for this type in the asn1decode functions
+ */
+
+bool
+keep_tag(unsigned int tagclass)
+{
+ if(is_synthetic(tagclass)
+ || tagclass == ASN1TAGCLASS_BOOLEAN
+ || tagclass == ASN1TAGCLASS_INTEGER
+ || tagclass == ASN1TAGCLASS_OctetString
+ || tagclass == ASN1TAGCLASS_Null
+ || tagclass == ASN1TAGCLASS_ENUMERATED)
+ return true;
+ else
+ return false;
+}
+
+/*
* give access to ASN1TAGCLASS_XXX constants when XXX is not known until run time
*/
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-29 16:44:42 UTC (rev 455)
+++ redbutton-author/trunk/asn1tag.h 2007-10-29 17:11:26 UTC (rev 456)
@@ -34,6 +34,7 @@
char *asn1class_name(unsigned int);
bool is_synthetic(unsigned int);
bool needs_tagging(unsigned int, unsigned int);
+bool keep_tag(unsigned int);
unsigned int asn1tagclass(const char *);
/*
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-29 16:44:42 UTC (rev 455)
+++ redbutton-author/trunk/ccc.y 2007-10-29 17:11:26 UTC (rev 456)
@@ -10,6 +10,7 @@
#include <errno.h>
#include "asn1type.h"
+#include "asn1tag.h"
#define YYSTYPE char *
@@ -853,15 +854,15 @@
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
/* if it is a synthetic or primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t}\n");
- buf_append(&state.decode_fns, "\t\t\telse\n");
- buf_append(&state.decode_fns, "\t\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t}\n");
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ }
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
@@ -876,16 +877,16 @@
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
/* if it is a synthetic or primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t}\n");
- buf_append(&state.decode_fns, "\t\t\telse\n");
- buf_append(&state.decode_fns, "\t\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t}\n");
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ }
buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n\n");
@@ -936,15 +937,15 @@
/* 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 primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
- buf_append(&state.decode_fns, "\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\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");
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ }
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
/* is it a type that is encoded as a NULL if it is not present */
@@ -980,7 +981,6 @@
/* while there is data left in the current object */
buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* decode the next tag */
- buf_append(&state.decode_fns, "\t\tlong pretag = ftell(der);\n");
buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
@@ -1006,15 +1006,15 @@
first = false;
buf_append(&state.decode_fns, "if(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
/* if it is a synthetic or primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\t\tif(keep_tag(ASN1TAGCLASS_%s))\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\t\tfseek(der, pretag, SEEK_SET);\n");
- buf_append(&state.decode_fns, "\t\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t}\n");
- buf_append(&state.decode_fns, "\t\t\telse\n");
- buf_append(&state.decode_fns, "\t\t\t{\n");
- buf_append(&state.decode_fns, "\t\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t}\n");
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ }
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n");
item = item->next;
@@ -1070,7 +1070,6 @@
{
/* a CHOICE type */
buf_append(&state.decode_fns, "\t/* CHOICE */\n");
- buf_append(&state.decode_fns, "\tlong pretag = 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");
@@ -1094,15 +1093,15 @@
buf_append(&state.decode_fns, "\telse ");
buf_append(&state.decode_fns, "if(is_%s(tag.class, tag.number))\n\t{\n", item->name);
/* if it is a synthetic or primitive type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\tif(keep_tag(ASN1TAGCLASS_%s))\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");
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ }
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-02 17:24:35
|
Revision: 457
http://redbutton.svn.sourceforge.net/redbutton/?rev=457&view=rev
Author: skilvington
Date: 2007-11-02 10:24:31 -0700 (Fri, 02 Nov 2007)
Log Message:
-----------
try to tidy up asn1decode.c - less working than before
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-10-29 17:11:26 UTC (rev 456)
+++ redbutton-author/trunk/TODO 2007-11-02 17:24:31 UTC (rev 457)
@@ -4,6 +4,12 @@
---
+mhegc
+not entirely convinced MovementTable/Movement/TargetElement will be encoded correctly
+should Movement be SYNTHETIC?
+
+---
+
mhegd
HorizontalJustification doesn't work
EventTypeEnum does
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-29 17:11:26 UTC (rev 456)
+++ redbutton-author/trunk/ccc.y 2007-11-02 17:24:31 UTC (rev 457)
@@ -827,18 +827,103 @@
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
/* is it OPTIONAL - check if length == 0, if so bomb out now */
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* is it a primitive type */
if(strcmp(item->name, "BOOLEAN") == 0
|| strcmp(item->name, "INTEGER") == 0
|| strcmp(item->name, "OctetString") == 0)
{
/* assert */
+ if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
+ fatal("Primitive but not Identifier or Identifier+");
+ /* does it need an extra explicit tag for the primitive type? */
+ if(asn1tagclass(name) != asn1tagclass(item->name))
+ {
+ /* no explicit primitive tag */
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n");
+ }
+ else
+ {
+ /* do need an explicit primitive tag */
+ 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, "\tif(is_%s(tag.class, tag.number))\n", item->name);
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t}\n");
+ }
+ }
+#if 0
+ /* is it an ENUMERATED type */
+ else if(asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
+ {
+ /* assert */
if(item->type != IT_IDENTIFIER)
+ fatal("ENUMERATED but not Identifier");
+buf_append(&state.decode_fns, "printf(\"TODO: %s->%s\\n\");\nexit(1);\n",name,item->name);
+ }
+#endif
+ /* else the whole length is the sub types value */
+ else
+ {
+ /* decode the item */
+ 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, "\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ /* if it is a synthetic or primitive type, we still need the current tag */
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ }
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t}");
+ }
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\n");
+#if 0
+/* is it OPTIONAL - check if length == 0, if so bomb out now */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* is it a primitive type */
+ if(strcmp(item->name, "OctetString") == 0
+ || asn1tagclass(item->name) == ASN1TAGCLASS_BOOLEAN
+ || asn1tagclass(item->name) == ASN1TAGCLASS_INTEGER
+ || asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
+ {
+ /* assert */
+ if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
fatal("Primitive but not Identifier");
/* does it need an extra explicit tag for the primitive type? */
buf_append(&state.decode_fns, "\tif(ASN1TAGCLASS_%s != ASN1TAGCLASS_%s)\n", name, item->name);
buf_append(&state.decode_fns, "\t{\n");
- buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ if(asn1tagclass(item->name) != ASN1TAGCLASS_ENUMERATED)
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ else
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
@@ -895,6 +980,7 @@
buf_append(&state.decode_fns, "\t}\n");
}
buf_append(&state.decode_fns, "\n");
+#endif
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
@@ -1110,8 +1196,8 @@
}
/* end decode_Xxx() function */
- buf_append(&state.decode_fns, "\tif(!is_synthetic(ASN1TAGCLASS_%s))\n", name);
- buf_append(&state.decode_fns, "\t\tfprintf(out, \"\\n\");\n\n");
+ if(!is_synthetic(asn1tagclass(name)))
+ buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-08 17:32:04
|
Revision: 458
http://redbutton.svn.sourceforge.net/redbutton/?rev=458&view=rev
Author: skilvington
Date: 2007-11-08 09:31:58 -0800 (Thu, 08 Nov 2007)
Log Message:
-----------
back to where we were before, but with a prettier asn1decode.c
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-02 17:24:31 UTC (rev 457)
+++ redbutton-author/trunk/TODO 2007-11-08 17:31:58 UTC (rev 458)
@@ -11,9 +11,8 @@
---
mhegd
-HorizontalJustification doesn't work
-EventTypeEnum does
-ie ENUMERATED types without an explicit ENUMERATED tag don't work
+HorizontalJustification needs writing
+ie ENUMERATED types without an explicit ENUMERATED tag
---
@@ -25,6 +24,7 @@
mhegd
:ContentRef ContentReference keeps the tag as part of the OctetString
+(eg enh_gateway.mhg)
---
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-02 17:24:31 UTC (rev 457)
+++ redbutton-author/trunk/ccc.y 2007-11-08 17:31:58 UTC (rev 458)
@@ -825,19 +825,16 @@
/* assert */
if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
+/* TODO */
/* is it OPTIONAL - check if length == 0, if so bomb out now */
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
- /* if it is ONEORMORE we need a while loop */
- if(item->type == IT_ONEORMORE)
- buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* is it a primitive type */
if(strcmp(item->name, "BOOLEAN") == 0
|| strcmp(item->name, "INTEGER") == 0
|| strcmp(item->name, "OctetString") == 0)
{
/* assert */
- if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
- fatal("Primitive but not Identifier or Identifier+");
+ if(item->type != IT_IDENTIFIER)
+ fatal("Primitive but not Identifier");
/* does it need an extra explicit tag for the primitive type? */
if(asn1tagclass(name) != asn1tagclass(item->name))
{
@@ -850,11 +847,11 @@
{
/* do need an explicit primitive tag */
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, "\t\treturn der_error(\"%s\");\n\n", name);
buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n", item->name);
buf_append(&state.decode_fns, "\t{\n");
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
@@ -864,123 +861,79 @@
buf_append(&state.decode_fns, "\t}\n");
}
}
-#if 0
- /* is it an ENUMERATED type */
- else if(asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
+ /* is it an ENUMERATED type which does not need an explicit ENUMERATED tag */
+ else if(asn1tagclass(name) != ASN1TAGCLASS_ENUMERATED
+ && asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
{
/* assert */
if(item->type != IT_IDENTIFIER)
fatal("ENUMERATED but not Identifier");
+/* TODO */
buf_append(&state.decode_fns, "printf(\"TODO: %s->%s\\n\");\nexit(1);\n",name,item->name);
}
-#endif
- /* else the whole length is the sub types value */
- else
+ /* is the whole length one or more sub types */
+ else if(item->type == IT_ONEORMORE)
{
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* decode the item */
- 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, "\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
- /* if it is a synthetic or primitive type, we still need the current tag */
- if(keep_tag(asn1tagclass(item->name)))
- {
- buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
- }
- else
- {
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
- }
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\telse\n");
- buf_append(&state.decode_fns, "\t{\n");
- buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
- buf_append(&state.decode_fns, "\t}");
- }
- /* if it is ONEORMORE we need a while loop */
- if(item->type == IT_ONEORMORE)
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\n");
-#if 0
-/* is it OPTIONAL - check if length == 0, if so bomb out now */
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
- /* is it a primitive type */
- if(strcmp(item->name, "OctetString") == 0
- || asn1tagclass(item->name) == ASN1TAGCLASS_BOOLEAN
- || asn1tagclass(item->name) == ASN1TAGCLASS_INTEGER
- || asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
- {
- /* assert */
- if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
- fatal("Primitive but not Identifier");
- /* does it need an extra explicit tag for the primitive type? */
- buf_append(&state.decode_fns, "\tif(ASN1TAGCLASS_%s != ASN1TAGCLASS_%s)\n", name, item->name);
- buf_append(&state.decode_fns, "\t{\n");
- if(asn1tagclass(item->name) != ASN1TAGCLASS_ENUMERATED)
- buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
- else
- buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\telse\n");
- }
- /* is it ONEORMORE - need a while(left > 0) loop */
- if(item->type == IT_ONEORMORE)
- {
- buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
- /* decode the item */
buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
- buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n\n", name);
+ buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n", item->name);
+ buf_append(&state.decode_fns, "\t\t{\n");
/* if it is a synthetic or primitive type, we still need the current tag */
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\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\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
- buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
- buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
- buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
- buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ 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\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\t}\n");
}
+ /* else the whole length is the sub types value */
else
{
- /* the whole length is the sub types value */
- buf_append(&state.decode_fns, "\t{\n");
/* decode the item */
- buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ 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\n", name);
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n", item->name);
+ buf_append(&state.decode_fns, "\t{\n");
/* if it is a synthetic or primitive type, we still need the current tag */
if(keep_tag(asn1tagclass(item->name)))
{
- buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
- buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
- buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n\n");
- buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
- buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t}\n");
}
buf_append(&state.decode_fns, "\n");
-#endif
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-09 16:38:44
|
Revision: 459
http://redbutton.svn.sourceforge.net/redbutton/?rev=459&view=rev
Author: skilvington
Date: 2007-11-09 08:38:42 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
cope with ENUMERATED types with no explicit ENUMERATED tag
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-08 17:31:58 UTC (rev 458)
+++ redbutton-author/trunk/TODO 2007-11-09 16:38:42 UTC (rev 459)
@@ -11,12 +11,6 @@
---
mhegd
-HorizontalJustification needs writing
-ie ENUMERATED types without an explicit ENUMERATED tag
-
----
-
-mhegd
check NoTokenActionSlots (empty and not empty)
check MovementTable (empty and not empty)
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-08 17:31:58 UTC (rev 458)
+++ redbutton-author/trunk/ccc.y 2007-11-09 16:38:42 UTC (rev 459)
@@ -868,8 +868,9 @@
/* assert */
if(item->type != IT_IDENTIFIER)
fatal("ENUMERATED but not Identifier");
-/* TODO */
-buf_append(&state.decode_fns, "printf(\"TODO: %s->%s\\n\");\nexit(1);\n",name,item->name);
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n");
}
/* is the whole length one or more sub types */
else if(item->type == IT_ONEORMORE)
@@ -1101,6 +1102,29 @@
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
+ /* end decode_Xxx() function */
+ if(!is_synthetic(asn1tagclass(name)))
+ buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
+ buf_append(&state.decode_fns, "\tif(left != 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
+ buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
+ buf_append(&state.decode_fns, "\treturn length;\n}\n\n");
+ /* create a der_decode_Xxx() function */
+ buf_append(&state.decode_fns, "int der_decode_%s(FILE *der, FILE *out, int length)\n", name);
+ buf_append(&state.decode_fns, "{\n");
+ buf_append(&state.decode_fns, "\tint left = length;\n");
+ buf_append(&state.decode_fns, "\tint sublen;\n\n");
+ buf_append(&state.decode_fns, "\tverbose(\"<%s>\\n\");\n\n", name);
+ buf_append(&state.decode_fns, "\t/* ENUMERATED */\n");
+ buf_append(&state.decode_fns, "\tchar *enum_names[] = {\n");
+ for(item=state.items; item; item=item->next)
+ buf_append(&state.decode_fns, "\t\t%s,\n", item->name);
+ buf_append(&state.decode_fns, "\t};\n\n");
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_ENUMERATED(der, out, length, %u, enum_names)) < 0)\n", enum_val);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
+ /* prototype */
+ buf_append(&state.decode_hdr, "int der_decode_%s(FILE *, FILE *, int);\n", name);
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_ENUMERATED);\n");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-09 16:48:51
|
Revision: 460
http://redbutton.svn.sourceforge.net/redbutton/?rev=460&view=rev
Author: skilvington
Date: 2007-11-09 08:48:47 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
stop :ContentRef including the OCTET-STRING tag as part of its value
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-09 16:38:42 UTC (rev 459)
+++ redbutton-author/trunk/TODO 2007-11-09 16:48:47 UTC (rev 460)
@@ -16,11 +16,5 @@
---
-mhegd
-:ContentRef ContentReference keeps the tag as part of the OctetString
-(eg enh_gateway.mhg)
-
----
-
clean up ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-09 16:38:42 UTC (rev 459)
+++ redbutton-author/trunk/ccc.y 2007-11-09 16:48:47 UTC (rev 460)
@@ -836,7 +836,8 @@
if(item->type != IT_IDENTIFIER)
fatal("Primitive but not Identifier");
/* does it need an extra explicit tag for the primitive type? */
- if(asn1tagclass(name) != asn1tagclass(item->name))
+ if(!is_synthetic(asn1tagclass(name))
+ && asn1tagclass(name) != asn1tagclass(item->name))
{
/* no explicit primitive tag */
buf_append(&state.decode_fns, "\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-09 17:03:46
|
Revision: 461
http://redbutton.svn.sourceforge.net/redbutton/?rev=461&view=rev
Author: skilvington
Date: 2007-11-09 09:03:45 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
don't know how that got in there
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-11-09 16:48:47 UTC (rev 460)
+++ redbutton-author/trunk/asn1tag.c 2007-11-09 17:03:45 UTC (rev 461)
@@ -327,7 +327,7 @@
MATCH(UnlockScreen)
MATCH(NewGenericBoolean)
MATCH(NewGenericInteger)
- MATCH(NewGenericOctetstring)
+ MATCH(NewGenericOctetString)
MATCH(NewGenericObjectReference)
MATCH(NewGenericContentReference)
MATCH(NewColourIndex)
@@ -420,7 +420,6 @@
MATCH(NewCursorShape)
MATCH(NewEntryPoint)
MATCH(NewFirstItem)
- MATCH(NewGenericOctetString)
MATCH(NewHighlightStatus)
MATCH(NewIncludedContent)
MATCH(NewInteractionStatus)
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-11-09 16:48:47 UTC (rev 460)
+++ redbutton-author/trunk/asn1tag.h 2007-11-09 17:03:45 UTC (rev 461)
@@ -303,7 +303,7 @@
#define ASN1TAG_UnlockScreen 224
#define ASN1TAG_NewGenericBoolean 225
#define ASN1TAG_NewGenericInteger 226
-#define ASN1TAG_NewGenericOctetstring 227
+#define ASN1TAG_NewGenericOctetString 227
#define ASN1TAG_NewGenericObjectReference 228
#define ASN1TAG_NewGenericContentReference 229
#define ASN1TAG_NewColourIndex 230
@@ -554,7 +554,7 @@
#define ASN1TAGCLASS_UnlockScreen ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_UnlockScreen)
#define ASN1TAGCLASS_NewGenericBoolean ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericBoolean)
#define ASN1TAGCLASS_NewGenericInteger ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericInteger)
-#define ASN1TAGCLASS_NewGenericOctetstring ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericOctetstring)
+#define ASN1TAGCLASS_NewGenericOctetString ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericOctetString)
#define ASN1TAGCLASS_NewGenericObjectReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericObjectReference)
#define ASN1TAGCLASS_NewGenericContentReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericContentReference)
#define ASN1TAGCLASS_NewColourIndex ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewColourIndex)
@@ -660,7 +660,6 @@
#define ASN1TAGCLASS_NewCursorShape ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewEntryPoint ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewFirstItem ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_NewGenericOctetString ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewHighlightStatus ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewIncludedContent ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewInteractionStatus ASN1TAG_SYNTHETIC
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-16 17:07:21
|
Revision: 462
http://redbutton.svn.sourceforge.net/redbutton/?rev=462&view=rev
Author: skilvington
Date: 2007-11-16 09:07:16 -0800 (Fri, 16 Nov 2007)
Log Message:
-----------
get an explicit SEQUENCE tag for ActionSlot under ActionSlots
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/grammar
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-09 17:03:45 UTC (rev 461)
+++ redbutton-author/trunk/TODO 2007-11-16 17:07:16 UTC (rev 462)
@@ -12,6 +12,7 @@
mhegd
check NoTokenActionSlots (empty and not empty)
+check ActionSlots empty (ie Null) works
check MovementTable (empty and not empty)
---
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-11-09 17:03:45 UTC (rev 461)
+++ redbutton-author/trunk/grammar 2007-11-16 17:07:16 UTC (rev 462)
@@ -249,7 +249,7 @@
TokenGroupItem ::= "(" AVisible [ActionSlots] ")" .
AVisible ::= ObjectReference .
ActionSlots ::= ":ActionSlots" "(" ActionSlot+ ")" .
-ActionSlot ::= ActionClass | Null .
+ActionSlot ::= ActionClassSeq | Null .
NoTokenActionSlots ::= ":NoTokenActionSlots" "(" ActionSlotSeq+ ")" .
// srk - to get an explicit SEQUENCE tag under NoTokenActionSlots
ActionSlotSeq ::= ActionClassSeq | Null .
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-16 17:16:28
|
Revision: 463
http://redbutton.svn.sourceforge.net/redbutton/?rev=463&view=rev
Author: skilvington
Date: 2007-11-16 09:16:23 -0800 (Fri, 16 Nov 2007)
Log Message:
-----------
give NewTimer an explicit SEQUENCE tag
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/grammar
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-11-16 17:07:16 UTC (rev 462)
+++ redbutton-author/trunk/asn1tag.c 2007-11-16 17:16:23 UTC (rev 463)
@@ -547,6 +547,7 @@
MATCH(NewContent)
MATCH(NewFont)
MATCH(NewVariableValue)
+ MATCH(NewTimer)
fprintf(stderr, "Unknown ASN1TAGCLASS type: %s\n", name);
exit(EXIT_FAILURE);
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-11-16 17:07:16 UTC (rev 462)
+++ redbutton-author/trunk/asn1tag.h 2007-11-16 17:16:23 UTC (rev 463)
@@ -792,5 +792,6 @@
#define ASN1TAGCLASS_NewContent ASN1TAG_CHOICE
#define ASN1TAGCLASS_NewFont ASN1TAG_CHOICE
#define ASN1TAGCLASS_NewVariableValue ASN1TAG_CHOICE
+#define ASN1TAGCLASS_NewTimer ASN1TAGCLASS_SEQUENCE
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-11-16 17:07:16 UTC (rev 462)
+++ redbutton-author/trunk/grammar 2007-11-16 17:16:23 UTC (rev 463)
@@ -711,8 +711,8 @@
SetSliderValue ::= ":SetSliderValue" "(" Target
NewSliderValue ")" .
SetSpeed ::= ":SetSpeed" "(" Target NewSpeed ")" .
-SetTimer ::= ":SetTimer" "(" Target TimerID
- [TimerValue] [AbsoluteTime] ")" .
+SetTimer ::= ":SetTimer" "(" Target TimerID [NewTimer] ")" .
+NewTimer ::= TimerValue [AbsoluteTime] .
SetTransparency ::= ":SetTransparency" "(" Target
NewTransparency ")" .
SetVariable ::= ":SetVariable" "(" Target
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-19 16:45:03
|
Revision: 465
http://redbutton.svn.sourceforge.net/redbutton/?rev=465&view=rev
Author: skilvington
Date: 2007-11-19 08:44:26 -0800 (Mon, 19 Nov 2007)
Log Message:
-----------
stop parsing if we find an error
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegd.c
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-16 17:20:21 UTC (rev 464)
+++ redbutton-author/trunk/ccc.y 2007-11-19 16:44:26 UTC (rev 465)
@@ -982,12 +982,14 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
/* is it a type that is encoded as a NULL if it is not present */
@@ -1051,12 +1053,14 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\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\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n");
item = item->next;
@@ -1100,7 +1104,8 @@
buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
/* the ENUMERATED value is encoded as an INTEGER */
buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", name);
- buf_append(&state.decode_fns, "\t\tder_decode_ENUMERATED(der, out, tag.length, %u, enum_names);\n", enum_val);
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_ENUMERATED(der, out, tag.length, %u, enum_names)) < 0)\n", enum_val);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
@@ -1161,12 +1166,14 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
}
Modified: redbutton-author/trunk/mhegd.c
===================================================================
--- redbutton-author/trunk/mhegd.c 2007-11-16 17:20:21 UTC (rev 464)
+++ redbutton-author/trunk/mhegd.c 2007-11-19 16:44:26 UTC (rev 465)
@@ -46,6 +46,7 @@
FILE *in_file;
FILE *out_file = stdout;
int filesize;
+ int used;
while((arg = getopt(argc, argv, "o:v")) != EOF)
{
@@ -81,7 +82,11 @@
rewind(in_file);
/* write text form of DER encoded in_file to out_file */
- if(asn1decode_InterchangedObject(in_file, out_file, filesize) != filesize)
+ used = asn1decode_InterchangedObject(in_file, out_file, filesize);
+ fprintf(out_file, "\n");
+ if(used < 0)
+ fatal("Parsing error");
+ else if(used != filesize)
fatal("Unexpected data after InterchangedObject");
return EXIT_SUCCESS;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-21 16:28:05
|
Revision: 466
http://redbutton.svn.sourceforge.net/redbutton/?rev=466&view=rev
Author: skilvington
Date: 2007-11-21 08:27:56 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
fix NewContentSize NULL parsing
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-11-19 16:44:26 UTC (rev 465)
+++ redbutton-author/trunk/asn1tag.h 2007-11-21 16:27:56 UTC (rev 466)
@@ -744,7 +744,7 @@
#define ASN1TAGCLASS_NewReferencedContent ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_NextScene ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_TokenGroupItem ASN1TAGCLASS_SEQUENCE
-#define ASN1TAGCLASS_Movement ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_Movement ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_ActionSlots ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_InVariables ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_OutVariables ASN1TAGCLASS_SEQUENCE
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-19 16:44:26 UTC (rev 465)
+++ redbutton-author/trunk/ccc.y 2007-11-21 16:27:56 UTC (rev 466)
@@ -983,17 +983,42 @@
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
}
else
{
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ /* is it a type that is encoded as a NULL if it is not present */
+ if(item->type == IT_IDENTORNULL)
+ {
+ buf_append(&state.decode_fns, "\t\tstruct der_tag null_tag;\n");
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &null_tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tif(is_Null(null_tag.class, null_tag.number))\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ 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\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
+ buf_append(&state.decode_fns, "\t\t}\n");
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
+ }
}
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
/* is it a type that is encoded as a NULL if it is not present */
- if(item->type == IT_IDENTORNULL)
+ if(item->type == IT_IDENTORNULL && keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\telse if(!is_Null(tag.class, tag.number))\n");
buf_append(&state.decode_fns, "\t{\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-12-07 17:20:25
|
Revision: 472
http://redbutton.svn.sourceforge.net/redbutton/?rev=472&view=rev
Author: skilvington
Date: 2007-12-07 09:20:22 -0800 (Fri, 07 Dec 2007)
Log Message:
-----------
first stab at making mhegd output prettier
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/asn1decode.c.header
redbutton-author/trunk/ccc.y
redbutton-author/trunk/der_decode.c
Added Paths:
-----------
redbutton-author/trunk/output.c
redbutton-author/trunk/output.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/Makefile 2007-12-07 17:20:22 UTC (rev 472)
@@ -24,6 +24,7 @@
asn1decode.o \
der_decode.o \
asn1tag.o \
+ output.o \
utils.o
TARDIR=`basename ${PWD}`
Modified: redbutton-author/trunk/asn1decode.c.header
===================================================================
--- redbutton-author/trunk/asn1decode.c.header 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/asn1decode.c.header 2007-12-07 17:20:22 UTC (rev 472)
@@ -4,6 +4,7 @@
#include "asn1decode.h"
#include "der_decode.h"
#include "asn1tag.h"
+#include "output.h"
void verbose(char *, ...);
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/ccc.y 2007-12-07 17:20:22 UTC (rev 472)
@@ -822,7 +822,7 @@
{
/* 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);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
/* assert */
if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
@@ -951,7 +951,7 @@
/* assert */
if(item->type != IT_LITERAL)
fatal("Trailing non-literal");
- buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
item = item->next;
}
}
@@ -964,7 +964,7 @@
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);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
/* items must be in the order they are defined for SEQUENCE types */
switch(asn1type(name))
{
@@ -1112,7 +1112,7 @@
/* assert */
if(item->type != IT_LITERAL)
fatal("Trailing non-literal");
- buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
item = item->next;
}
}
@@ -1140,8 +1140,6 @@
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
/* end decode_Xxx() function */
- if(!is_synthetic(asn1tagclass(name)))
- buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
@@ -1215,8 +1213,6 @@
}
/* end decode_Xxx() function */
- if(!is_synthetic(asn1tagclass(name)))
- buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
Modified: redbutton-author/trunk/der_decode.c
===================================================================
--- redbutton-author/trunk/der_decode.c 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/der_decode.c 2007-12-07 17:20:22 UTC (rev 472)
@@ -95,7 +95,7 @@
verbose("<Boolean value=\"%s\"/>\n", val ? "true" : "false");
- fprintf(out, "%s ", val ? "true" : "false");
+ fprintf(out, " %s", val ? "true" : "false");
return length;
}
@@ -107,7 +107,7 @@
verbose("<Integer value=\"%d\"/>\n", val);
- fprintf(out, "%d ", val);
+ fprintf(out, " %d", val);
return length;
}
@@ -123,7 +123,7 @@
verbose("<OctetString size=\"%d\">\n", length);
/* output a QPRINTABLE string */
- fprintf(out, "'");
+ fprintf(out, " '");
while(left > 0)
{
if(der_read_file(der, 1, &byte) < 0)
@@ -134,7 +134,7 @@
fprintf(out, "=%02x", byte);
left --;
}
- fprintf(out, "' ");
+ fprintf(out, "'");
verbose("</OctetString>\n");
@@ -162,7 +162,7 @@
verbose("<Enumerated value=\"%d\"/>\n", val);
- fprintf(out, "%s ", names[val - 1]);
+ fprintf(out, " %s", names[val - 1]);
return length;
}
Added: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c (rev 0)
+++ redbutton-author/trunk/output.c 2007-12-07 17:20:22 UTC (rev 472)
@@ -0,0 +1,103 @@
+/*
+ * output.c
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "utils.h"
+
+void print_newline(FILE *);
+void print_token(FILE *, char *);
+
+int indent = 0;
+bool newline = true;
+
+void
+output_token(FILE *out, char *tok)
+{
+ /* assert */
+ if(tok[0] == '\0')
+ fatal("output_token: 0 length token");
+
+ if(tok[0] == '{' && tok[1] == ':')
+ {
+ print_newline(out);
+ print_token(out, tok);
+ indent ++;
+ }
+ else if(tok[0] == '}')
+ {
+ /* assert */
+ if(indent == 0)
+ fatal("output_token: unexpected '}'");
+ indent --;
+ print_newline(out);
+ print_token(out, tok);
+ }
+ else if(tok[0] == ':' && strcmp(tok, ":ContentRef") != 0)
+ {
+ print_newline(out);
+ print_token(out, tok);
+ }
+ else
+ {
+ print_token(out, tok);
+ }
+
+ return;
+}
+
+void
+print_newline(FILE *out)
+{
+ if(!newline)
+ fprintf(out, "\n");
+
+ newline = true;
+
+ return;
+}
+
+void
+print_token(FILE *out, char *tok)
+{
+ int i = indent;
+
+ if(newline)
+ {
+ while(i > 0)
+ {
+ fprintf(out, "\t");
+ i --;
+ }
+ newline = false;
+ }
+ else
+ {
+ fprintf(out, " ");
+ }
+
+ fprintf(out, "%s", tok);
+
+ return;
+}
Added: redbutton-author/trunk/output.h
===================================================================
--- redbutton-author/trunk/output.h (rev 0)
+++ redbutton-author/trunk/output.h 2007-12-07 17:20:22 UTC (rev 472)
@@ -0,0 +1,31 @@
+/*
+ * output.h
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __OUTPUT_H__
+#define __OUTPUT_H__
+
+#include <stdio.h>
+
+void output_token(FILE *, char *);
+
+#endif /* __OUTPUT_H__ */
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-14 17:19:18
|
Revision: 475
http://redbutton.svn.sourceforge.net/redbutton/?rev=475&view=rev
Author: skilvington
Date: 2008-01-14 09:19:14 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
make mhegd output even nicer
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/mhegd.c
redbutton-author/trunk/output.c
redbutton-author/trunk/output.h
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/TODO 2008-01-14 17:19:14 UTC (rev 475)
@@ -31,3 +31,32 @@
allow INTEGERs to be arthimetic expressions
#include "uk.inc"
+---
+
+mhegd
+make this look nicer (4165/a)...
+{:TokenGroup 1000
+ :Shared true
+ :TokenGroupItems (
+ ( 102
+ :ActionSlots (
+ (
+ :Call ( ... )
+ :Activate ( 1001 )
+ ) )
+ )
+}
+
+this is even worse (4165/enh_gateway.mhg)...
+ {:TokenGroup 82
+ :TokenGroupItems (
+ ( ( '/a' 1 )
+ :ActionSlots (
+ (
+ :Run ( ( '/a' 119 ) ) ) (
+ :Run ( ( '/a' 119 ) ) ) (
+ :Run ( ( '/a' 122 ) )
+ :Run ( ( '/a' 120 ) ) )
+ ) )
+ )
+
Modified: redbutton-author/trunk/mhegd.c
===================================================================
--- redbutton-author/trunk/mhegd.c 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/mhegd.c 2008-01-14 17:19:14 UTC (rev 475)
@@ -29,6 +29,7 @@
#include "asn1decode.h"
#include "der_decode.h"
+#include "output.h"
#include "utils.h"
void verbose(const char *, ...);
@@ -82,6 +83,7 @@
rewind(in_file);
/* write text form of DER encoded in_file to out_file */
+ output_init();
used = asn1decode_InterchangedObject(in_file, out_file, filesize);
fprintf(out_file, "\n");
if(used < 0)
Modified: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/output.c 2008-01-14 17:19:14 UTC (rev 475)
@@ -32,15 +32,55 @@
int indent = 0;
bool newline = true;
+/* keep track of () blocks that should be indented */
+#define PAREN_LEVEL_MAX 8192
+int paren_level = 0;
+bool indent_paren[PAREN_LEVEL_MAX];
+
void
+output_init(void)
+{
+ bzero(indent_paren, sizeof(indent_paren));
+
+ return;
+}
+
+void
output_token(FILE *out, char *tok)
{
/* assert */
if(tok[0] == '\0')
fatal("output_token: 0 length token");
- if(tok[0] == '{' && tok[1] == ':')
+ if(tok[0] == '(' && tok[1] == '\0')
{
+ /* assert */
+ if(paren_level >= (PAREN_LEVEL_MAX - 1))
+ fatal("output_token: max nested parenthesis reached");
+ print_token(out, tok);
+ paren_level ++;
+ if(indent_paren[paren_level])
+ {
+ print_newline(out);
+ indent ++;
+ }
+ }
+ else if(tok[0] == ')' && tok[1] == '\0')
+ {
+ /* assert */
+ if(paren_level <=0)
+ fatal("output_token: unexpected ')'");
+ if(indent_paren[paren_level])
+ {
+ indent --;
+ print_newline(out);
+ }
+ indent_paren[paren_level] = false;
+ paren_level --;
+ print_token(out, tok);
+ }
+ else if(tok[0] == '{' && tok[1] == ':')
+ {
print_newline(out);
print_token(out, tok);
indent ++;
@@ -54,14 +94,33 @@
print_newline(out);
print_token(out, tok);
}
+ else if(strcmp(tok, ":ActionSlots") == 0
+ || strcmp(tok, ":Items") == 0
+ || strcmp(tok, ":LinkEffect") == 0
+ || strcmp(tok, ":MovementTable") == 0
+ || strcmp(tok, ":Multiplex") == 0
+ || strcmp(tok, ":NextScenes") == 0
+ || strcmp(tok, ":NextScenes") == 0
+ || strcmp(tok, ":NoTokenActionSlots") == 0
+ || strcmp(tok, ":Positions") == 0
+ || strcmp(tok, ":TokenGroupItems") == 0)
+ {
+ print_newline(out);
+ print_token(out, tok);
+ /* next () block should be indented */
+ indent_paren[paren_level + 1] = true;
+ }
else if(tok[0] == ':'
+ && strcmp(tok, ":CCPriority") != 0
+ && strcmp(tok, ":ContentRef") != 0
+ && strcmp(tok, ":IndirectRef") != 0
&& strcmp(tok, ":GBoolean") != 0
+ && strcmp(tok, ":GContentRef") != 0
&& strcmp(tok, ":GInteger") != 0
+ && strcmp(tok, ":GObjectRef") != 0
&& strcmp(tok, ":GOctetString") != 0
- && strcmp(tok, ":GObjectRef") != 0
- && strcmp(tok, ":GContentRef") != 0
- && strcmp(tok, ":IndirectRef") != 0
- && strcmp(tok, ":ContentRef") != 0)
+ && strcmp(tok, ":NewCCPriority") != 0
+ && strcmp(tok, ":NewRefContent") != 0)
{
print_newline(out);
print_token(out, tok);
Modified: redbutton-author/trunk/output.h
===================================================================
--- redbutton-author/trunk/output.h 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/output.h 2008-01-14 17:19:14 UTC (rev 475)
@@ -25,6 +25,8 @@
#include <stdio.h>
+void output_init(void);
+
void output_token(FILE *, char *);
#endif /* __OUTPUT_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|