redbutton-devel Mailing List for RedButton MHEG Engine (Page 8)
Brought to you by:
skilvington
You can subscribe to this list here.
| 2006 |
Jan
(1) |
Feb
(4) |
Mar
(27) |
Apr
(6) |
May
(46) |
Jun
(45) |
Jul
(7) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(10) |
Dec
(11) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(49) |
Feb
(29) |
Mar
(35) |
Apr
(43) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(58) |
Sep
(66) |
Oct
(27) |
Nov
(15) |
Dec
(1) |
| 2008 |
Jan
(11) |
Feb
|
Mar
(8) |
Apr
|
May
|
Jun
(30) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(3) |
Dec
(6) |
| 2009 |
Jan
(6) |
Feb
(1) |
Mar
(2) |
Apr
(5) |
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(6) |
| 2010 |
Jan
(6) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
(4) |
Oct
|
Nov
(11) |
Dec
(4) |
| 2011 |
Jan
|
Feb
(11) |
Mar
(8) |
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
(2) |
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
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-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 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-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-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-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-18 16:20:55
|
Revision: 450
http://redbutton.svn.sourceforge.net/redbutton/?rev=450&view=rev
Author: skilvington
Date: 2007-10-18 09:20:22 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
use is_Xxx() functions when decoding CHOICE types
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-18 16:09:40 UTC (rev 449)
+++ redbutton-author/trunk/ccc.y 2007-10-18 16:20:22 UTC (rev 450)
@@ -1008,7 +1008,7 @@
buf_append(&state.decode_is_fns, "\t\treturn ");
else
buf_append(&state.decode_is_fns, "\t\t || ");
- buf_append(&state.decode_is_fns, "MATCH_TAGCLASS(class, number, ASN1TAGCLASS_%s)", item->name);
+ buf_append(&state.decode_is_fns, "is_%s(class, number)", item->name);
/* is it the last */
if(item->next == NULL)
buf_append(&state.decode_is_fns, ";");
@@ -1019,7 +1019,7 @@
else
buf_append(&state.decode_fns, "\telse ");
/* TODO: does GenericObjectReference_direct_reference need a fseek(pretag) */
- buf_append(&state.decode_fns, "if(MATCH_TAGCLASS(tag.class, tag.number, ASN1TAGCLASS_%s))\n\t{\n", item->name);
+ buf_append(&state.decode_fns, "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");
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:09:41
|
Revision: 449
http://redbutton.svn.sourceforge.net/redbutton/?rev=449&view=rev
Author: skilvington
Date: 2007-10-18 09:09:40 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
make is_Xxx() functions look prettier
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-18 16:06:13 UTC (rev 448)
+++ redbutton-author/trunk/ccc.y 2007-10-18 16:09:40 UTC (rev 449)
@@ -813,7 +813,7 @@
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);
/* is_Xxx() function */
- buf_append(&state.decode_is_fns, "\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_OCTETSTRING);\n");
+ buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_OCTETSTRING);\n");
}
/* has it got only 1 non-literal item */
else if(nitems == 1)
@@ -827,7 +827,7 @@
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 ENUMERATED type, we still need the current tag */
+ /* 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");
@@ -841,7 +841,7 @@
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);
/* is_Xxx() function */
- buf_append(&state.decode_is_fns, "\treturn is_%s(class, number);\n", item->name);
+ buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
item = item->next;
while(item)
@@ -871,7 +871,7 @@
if(item->type != IT_IDENTIFIER)
fatal("not Identifier");
/* is_Xxx() - just match the first item */
- buf_append(&state.decode_is_fns, "\treturn is_%s(class, number);\n", item->name);
+ 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)
@@ -883,7 +883,7 @@
buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
/* is it what we expect */
buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
- /* if it is a synthetic or ENUMERATED type, we still need the current tag */
+ /* 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");
@@ -917,9 +917,9 @@
{
/* is_Xxx() */
if(first)
- buf_append(&state.decode_is_fns, "\treturn ");
+ buf_append(&state.decode_is_fns, "\t\treturn ");
else
- buf_append(&state.decode_is_fns, "\t || ");
+ buf_append(&state.decode_is_fns, "\t\t || ");
buf_append(&state.decode_is_fns, "is_%s(class, number)", item->name);
/* is it the last */
if(item->next == NULL || item->next->type == IT_LITERAL)
@@ -932,7 +932,7 @@
buf_append(&state.decode_fns, "\t\telse ");
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 ENUMERATED type, we still need the current tag */
+ /* 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");
@@ -990,7 +990,7 @@
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);
/* is_Xxx() function */
- buf_append(&state.decode_is_fns, "\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_ENUMERATED);\n");
+ buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_ENUMERATED);\n");
}
/* must be a CHOICE */
else
@@ -1005,9 +1005,9 @@
{
/* is_Xxx() function */
if(item == state.items)
- buf_append(&state.decode_is_fns, "\treturn ");
+ buf_append(&state.decode_is_fns, "\t\treturn ");
else
- buf_append(&state.decode_is_fns, "\t || ");
+ buf_append(&state.decode_is_fns, "\t\t || ");
buf_append(&state.decode_is_fns, "MATCH_TAGCLASS(class, number, ASN1TAGCLASS_%s)", item->name);
/* is it the last */
if(item->next == NULL)
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: Simon K. <s.k...@er...> - 2007-10-18 13:08:24
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mario Rossi wrote: > Simon Kilvington wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi, >> >> I upgraded my copy of flex to 2.5.33 and got the same error as >> you - so I've commit another patch that just removes the yy prefix from >> the variables I created - that makes sure the line number is increased >> on \r \n or \f, rather than just what flex thinks it should be increased >> on. > > Now it works. > I will try to understand what it does now... :-) > it allows you to write your own applications! the files that are broadcast over the air are encoded in a binary format, but you can write MHEG aplications in a text form too. The mhegc command converts this text form into the binary form. So to build the helloworld example, do this: mhegc -o helloworld/startup helloworld/startup.txt mhegc -o helloworld/hello.mhg helloworld/hello.mhg.txt then you can run it with rb-browser like this: rb-browser helloworld/ unless you've got a copy of the MHEG spec, its probably going to be a bit of trial and error to write apps! you can look at the "grammar" file and see what format the text should be in, and the purpose of some of the objects (Text, Rectangle, etc) should be fairly obvious, but other bits may be more difficult the svn version has a tool called "mhegd" that will convert the binary form back to text - except it's not finished yet! - when that is finished you can use it to look at how "real" apps work, and modify those and recompile them with mhegc libdsmcc has something similar to mhegd in it (called asn2txt) except it doesn't work properly so the text form it produces is not always valid. See http://libdsmcc.sourceforge.net/ - -- Simon Kilvington -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHF1q4mt9ZifioJSwRAp6aAJ4qBlBnXMCdtluX+7vN+8loVKUz7QCfT++x z/Pw08deOaR8wft0jUgYp/Q= =ogVG -----END PGP SIGNATURE----- |
|
From: Mario R. <mar...@go...> - 2007-10-18 10:28:10
|
Simon Kilvington wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, > > I upgraded my copy of flex to 2.5.33 and got the same error as > you - so I've commit another patch that just removes the yy prefix from > the variables I created - that makes sure the line number is increased > on \r \n or \f, rather than just what flex thinks it should be increased > on. Now it works. I will try to understand what it does now... :-) |
|
From: Simon K. <s.k...@er...> - 2007-10-18 10:11:43
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mario Rossi wrote: > Simon Kilvington wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi, >> >> you obviously have a more pedantic version of gcc than me! I've >> commited a patch, but basically all you need to do is change these 2 >> lines: >> > > I've tried the patch you sent (from scratch) and I get the same error: > Hi, I upgraded my copy of flex to 2.5.33 and got the same error as you - so I've commit another patch that just removes the yy prefix from the variables I created - that makes sure the line number is increased on \r \n or \f, rather than just what flex thinks it should be increased on. - -- Simon Kilvington -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHFzFSmt9ZifioJSwRAppcAJ0cU5DZC8Z1jaG4M+bJtP8sJemg6QCggM4C fHqFejbh3hEt00/m1BQcwEY= =uiqn -----END PGP SIGNATURE----- |
|
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 08:41:16
|
Revision: 446
http://redbutton.svn.sourceforge.net/redbutton/?rev=446&view=rev
Author: skilvington
Date: 2007-10-18 01:41:14 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
these should be unsigned too
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/parser.c.header
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-18 08:34:54 UTC (rev 445)
+++ redbutton-author/trunk/ccc.y 2007-10-18 08:41:14 UTC (rev 446)
@@ -92,7 +92,7 @@
void
yyerror(const char *str)
{
- fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+ fprintf(stderr, "Error: %s at line %u\n", str, yylineno);
return;
}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-10-18 08:34:54 UTC (rev 445)
+++ redbutton-author/trunk/parser.c.header 2007-10-18 08:41:14 UTC (rev 446)
@@ -34,7 +34,7 @@
void
yyerror(const char *str)
{
- fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+ fprintf(stderr, "Error: %s at line %u\n", str, yylineno);
yynerrs ++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Simon K. <s.k...@er...> - 2007-10-18 08:37:16
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, you obviously have a more pedantic version of gcc than me! I've commited a patch, but basically all you need to do is change these 2 lines: in ccc.l old: extern int yylineno; new: extern unsigned int yylineno; in ccc.y old: int yylineno = 1; new: unsigned int yylineno = 1; Mario Rossi wrote: > Hi, > > If I try to compile the authoring tool I get > > gcc -Wall -O2 -D_GNU_SOURCE -c asn1type.c > flex -i -t ccc.l > lex.ccc.c > bison -b ccc -d ccc.y > gcc -Wall -O2 -D_GNU_SOURCE -o ccc lex.ccc.c ccc.tab.c asn1type.o > <stdout>:1104: warning: ‘yyunput’ defined but not used > cat grammar | ./ccc -l parser.l -p parser.c -h parser.h -t tokens.h > flex -i -t parser.l > lex.parser.c > gcc -Wall -O2 -D_GNU_SOURCE -c mhegc.c > gcc -Wall -O2 -D_GNU_SOURCE -c lex.parser.c > parser.l:12: error: conflicting types for ‘yylineno’ > <stdout>:346: error: previous definition of ‘yylineno’ was here > make: *** [lex.parser.o] Error 1 > > The problem is that in lex.parser.c there is > > ==================================================== > typedef unsigned char YY_CHAR; > > FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; > > typedef int yy_state_type; > > extern int yylineno; > > int yylineno = 1; > ==================================================== > > which conflict with the content of parser.l.header which is included in > lex.parser.c > > extern unsigned int yylineno; > extern unsigned int yynerrs; > > > So, I change parser.l.header to "int yylineno" and get this linker error > > gcc -Wall -O2 -D_GNU_SOURCE -o mhegc mhegc.o lex.parser.o parser.o > der_encode.o asn1tag.o utils.o > parser.o:(.data+0x0): multiple definition of `yylineno' > lex.parser.o:(.data+0x0): first defined here > collect2: ld returned 1 exit status > make: *** [mhegc] Error 1 > > What am I doing wrong? > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Redbutton-devel mailing list > Red...@li... > https://lists.sourceforge.net/lists/listinfo/redbutton-devel > > - -- Simon Kilvington -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHFxsnmt9ZifioJSwRArSHAJ4imoVD5EgEXk7F4tsLva5QNqI+9ACfexrH dNsWvbub63i5zFdCFa+DZ0Q= =whng -----END PGP SIGNATURE----- |
|
From: <ski...@us...> - 2007-10-18 08:34:57
|
Revision: 445
http://redbutton.svn.sourceforge.net/redbutton/?rev=445&view=rev
Author: skilvington
Date: 2007-10-18 01:34:54 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
fix error spotted by Mario Rossi
Modified Paths:
--------------
redbutton-author/trunk/ccc.l
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.l
===================================================================
--- redbutton-author/trunk/ccc.l 2007-10-18 07:24:42 UTC (rev 444)
+++ redbutton-author/trunk/ccc.l 2007-10-18 08:34:54 UTC (rev 445)
@@ -2,7 +2,7 @@
#include <string.h>
#define YYSTYPE char *
#include "ccc.tab.h"
-extern int yylineno;
+extern unsigned int yylineno;
%}
%%
\/\/[^\n\r\f]* return COMMENT;
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-18 07:24:42 UTC (rev 444)
+++ redbutton-author/trunk/ccc.y 2007-10-18 08:34:54 UTC (rev 445)
@@ -86,7 +86,7 @@
void file_append(FILE *, char *);
/* input line we are currently parsing */
-int yylineno = 1;
+unsigned int yylineno = 1;
/* yacc functions we need to provide */
void
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-18 07:24:49
|
Revision: 444
http://redbutton.svn.sourceforge.net/redbutton/?rev=444&view=rev
Author: skilvington
Date: 2007-10-18 00:24:42 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
check for synthetic types in the is_Xxx() functions
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-17 16:07:23 UTC (rev 443)
+++ redbutton-author/trunk/asn1tag.h 2007-10-18 07:24:42 UTC (rev 444)
@@ -755,6 +755,7 @@
/* needed by mhegd */
#define FIXME 9999
+#define ASN1TAGCLASS_InterchangedObject ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_ActionSlot FIXME
#define ASN1TAGCLASS_ActionSlotSeq FIXME
#define ASN1TAGCLASS_ButtonStyleEnum ASN1TAGCLASS_ENUMERATED
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-17 16:07:23 UTC (rev 443)
+++ redbutton-author/trunk/ccc.y 2007-10-18 07:24:42 UTC (rev 444)
@@ -790,6 +790,9 @@
/* ASN1 is_Xxx() functions */
buf_append(&state.decode_is_fns, "bool is_%s(unsigned char class, unsigned int number)\n{\n", name);
+ buf_append(&state.decode_is_fns, "\tif(!is_synthetic(ASN1TAGCLASS_%s))\n", name);
+ buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_%s);\n", name);
+ buf_append(&state.decode_is_fns, "\telse\n");
/* count how many non-literal items there are */
nitems = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Mario R. <mar...@go...> - 2007-10-17 20:35:13
|
Hi, If I try to compile the authoring tool I get gcc -Wall -O2 -D_GNU_SOURCE -c asn1type.c flex -i -t ccc.l > lex.ccc.c bison -b ccc -d ccc.y gcc -Wall -O2 -D_GNU_SOURCE -o ccc lex.ccc.c ccc.tab.c asn1type.o <stdout>:1104: warning: ‘yyunput’ defined but not used cat grammar | ./ccc -l parser.l -p parser.c -h parser.h -t tokens.h flex -i -t parser.l > lex.parser.c gcc -Wall -O2 -D_GNU_SOURCE -c mhegc.c gcc -Wall -O2 -D_GNU_SOURCE -c lex.parser.c parser.l:12: error: conflicting types for ‘yylineno’ <stdout>:346: error: previous definition of ‘yylineno’ was here make: *** [lex.parser.o] Error 1 The problem is that in lex.parser.c there is ==================================================== typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern int yylineno; int yylineno = 1; ==================================================== which conflict with the content of parser.l.header which is included in lex.parser.c extern unsigned int yylineno; extern unsigned int yynerrs; So, I change parser.l.header to "int yylineno" and get this linker error gcc -Wall -O2 -D_GNU_SOURCE -o mhegc mhegc.o lex.parser.o parser.o der_encode.o asn1tag.o utils.o parser.o:(.data+0x0): multiple definition of `yylineno' lex.parser.o:(.data+0x0): first defined here collect2: ld returned 1 exit status make: *** [mhegc] Error 1 What am I doing wrong? |
|
From: <ski...@us...> - 2007-10-17 16:07:34
|
Revision: 443
http://redbutton.svn.sourceforge.net/redbutton/?rev=443&view=rev
Author: skilvington
Date: 2007-10-17 09:07:23 -0700 (Wed, 17 Oct 2007)
Log Message:
-----------
don't think we are going to need this
Modified Paths:
--------------
redbutton-author/trunk/asn1decode.c.header
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1decode.c.header
===================================================================
--- redbutton-author/trunk/asn1decode.c.header 2007-10-16 16:12:48 UTC (rev 442)
+++ redbutton-author/trunk/asn1decode.c.header 2007-10-17 16:07:23 UTC (rev 443)
@@ -1,3 +1,6 @@
+#include <stdio.h>
+#include <stdbool.h>
+
#include "asn1decode.h"
#include "der_decode.h"
#include "asn1tag.h"
@@ -4,6 +7,17 @@
void verbose(char *, ...);
+bool keep_tag(unsigned int tagclass)
+{
+/* TODO: is this function needed? */
+return true;
+ if(ASN1TAGCLASS_GroupIdentifier == ASN1TAG_SYNTHETIC
+ || ASN1TAGCLASS_GroupIdentifier == ASN1TAGCLASS_ENUMERATED)
+ return true;
+ else
+ return false;
+}
+
int asn1decode_BOOLEAN(FILE *der, FILE *out, int length)
{
int left = length;
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-16 16:12:48 UTC (rev 442)
+++ redbutton-author/trunk/ccc.y 2007-10-17 16:07:23 UTC (rev 443)
@@ -825,8 +825,7 @@
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 ENUMERATED type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
- buf_append(&state.decode_fns, "\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\n", item->name);
+ buf_append(&state.decode_fns, "\t\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);
@@ -882,8 +881,7 @@
/* is it what we expect */
buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
/* if it is a synthetic or ENUMERATED type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
- buf_append(&state.decode_fns, "\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\n", item->name);
+ buf_append(&state.decode_fns, "\t\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);
@@ -932,8 +930,7 @@
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 ENUMERATED type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
- buf_append(&state.decode_fns, "\t\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\n", item->name);
+ 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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-16 16:12:52
|
Revision: 442
http://redbutton.svn.sourceforge.net/redbutton/?rev=442&view=rev
Author: skilvington
Date: 2007-10-16 09:12:48 -0700 (Tue, 16 Oct 2007)
Log Message:
-----------
decode SEQUENCE types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-16 13:01:37 UTC (rev 441)
+++ redbutton-author/trunk/asn1tag.h 2007-10-16 16:12:48 UTC (rev 442)
@@ -782,5 +782,11 @@
#define ASN1TAGCLASS_StorageEnum ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_StreamComponent FIXME
#define ASN1TAGCLASS_TerminationEnum ASN1TAGCLASS_ENUMERATED
+#define ASN1TAGCLASS_ComparisonValue FIXME
+#define ASN1TAGCLASS_EmulatedEventData FIXME
+#define ASN1TAGCLASS_NewColour FIXME
+#define ASN1TAGCLASS_NewContent FIXME
+#define ASN1TAGCLASS_NewFont FIXME
+#define ASN1TAGCLASS_NewVariableValue FIXME
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-16 13:01:37 UTC (rev 441)
+++ redbutton-author/trunk/ccc.y 2007-10-16 16:12:48 UTC (rev 442)
@@ -854,6 +854,10 @@
/* is it a SEQUENCE or SET */
else if(state.and_items)
{
+ if(asn1type(name) == ASN1TYPE_SEQUENCE)
+ buf_append(&state.decode_fns, "\t/* SEQUENCE */\n");
+ else
+ buf_append(&state.decode_fns, "\t/* SET */\n");
/* output any literals at the start */
for(item=state.items; item && item->type==IT_LITERAL; item=item->next)
buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
@@ -867,9 +871,33 @@
/* is_Xxx() - just match the first item */
buf_append(&state.decode_is_fns, "\treturn is_%s(class, number);\n", item->name);
/* decode_Xxx() - examine each non-literal item in turn */
+ buf_append(&state.decode_fns, "\tlong pretag;\n\n");
while(item && item->type != IT_LITERAL)
{
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* decode the next tag */
+ buf_append(&state.decode_fns, "\tpretag = ftell(der);\n");
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
+ /* is it what we expect */
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", item->name);
+ /* if it is a synthetic or ENUMERATED type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
+ buf_append(&state.decode_fns, "\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\n", item->name);
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, pretag, SEEK_SET);\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
+ buf_append(&state.decode_fns, "\t}\n\n");
+ /* if it is not optional, raise an error if it is not present */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* if it is optional and not present, seek back to the start of the tag */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
item = item->next;
}
break;
@@ -935,7 +963,7 @@
/* assert */
if(item->type != IT_LITERAL)
fatal("Trailing non-literal");
- buf_append(&state.decode_fns, "\tfprintf(out, %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
item = item->next;
}
}
@@ -990,6 +1018,7 @@
buf_append(&state.decode_fns, "\t");
else
buf_append(&state.decode_fns, "\telse ");
+/* TODO: does GenericObjectReference_direct_reference need a fseek(pretag) */
buf_append(&state.decode_fns, "if(MATCH_TAGCLASS(tag.class, tag.number, ASN1TAGCLASS_%s))\n\t{\n", item->name);
buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, tag.length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-16 13:01:42
|
Revision: 441
http://redbutton.svn.sourceforge.net/redbutton/?rev=441&view=rev
Author: skilvington
Date: 2007-10-16 06:01:37 -0700 (Tue, 16 Oct 2007)
Log Message:
-----------
propogate the current tag to ENUMERATED types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-10-16 11:27:20 UTC (rev 440)
+++ redbutton-author/trunk/asn1tag.h 2007-10-16 13:01:37 UTC (rev 441)
@@ -753,5 +753,34 @@
/* ContentReference is [69] except in ReferencedContent */
#define ASN1TAGCLASS_ContentReference ASN1TAG_SYNTHETIC
+/* needed by mhegd */
+#define FIXME 9999
+#define ASN1TAGCLASS_ActionSlot FIXME
+#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_EventDataBody FIXME
+#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_GroupItem FIXME
+#define ASN1TAGCLASS_InputTypeEnum ASN1TAGCLASS_ENUMERATED
+#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_SliderStyleEnum ASN1TAGCLASS_ENUMERATED
+#define ASN1TAGCLASS_StartCornerEnum ASN1TAGCLASS_ENUMERATED
+#define ASN1TAGCLASS_StorageEnum ASN1TAGCLASS_ENUMERATED
+#define ASN1TAGCLASS_StreamComponent FIXME
+#define ASN1TAGCLASS_TerminationEnum ASN1TAGCLASS_ENUMERATED
+
#endif /* __ASN1TAG_H__ */
-
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-16 11:27:20 UTC (rev 440)
+++ redbutton-author/trunk/ccc.y 2007-10-16 13:01:37 UTC (rev 441)
@@ -819,11 +819,22 @@
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);
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ /* if it is a synthetic or ENUMERATED type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
+ buf_append(&state.decode_fns, "\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\n", item->name);
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, pretag, SEEK_SET);\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t}\n");
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
@@ -892,8 +903,9 @@
buf_append(&state.decode_fns, "\t\telse ");
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 type, we still need the current tag */
- buf_append(&state.decode_fns, "\t\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC)\n", item->name);
+ /* if it is a synthetic or ENUMERATED type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\t|| ASN1TAGCLASS_%s == ASN1TAGCLASS_ENUMERATED)\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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-16 11:27:22
|
Revision: 440
http://redbutton.svn.sourceforge.net/redbutton/?rev=440&view=rev
Author: skilvington
Date: 2007-10-16 04:27:20 -0700 (Tue, 16 Oct 2007)
Log Message:
-----------
propogate the current tag to synthetic types
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-16 11:02:58 UTC (rev 439)
+++ redbutton-author/trunk/ccc.y 2007-10-16 11:27:20 UTC (rev 440)
@@ -867,6 +867,7 @@
/* 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");
@@ -891,7 +892,16 @@
buf_append(&state.decode_fns, "\t\telse ");
first = false;
buf_append(&state.decode_fns, "if(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ /* if it is a synthetic type, we still need the current tag */
+ buf_append(&state.decode_fns, "\t\t\tif(ASN1TAGCLASS_%s == ASN1TAG_SYNTHETIC)\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");
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n");
item = item->next;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-16 11:03:03
|
Revision: 439
http://redbutton.svn.sourceforge.net/redbutton/?rev=439&view=rev
Author: skilvington
Date: 2007-10-16 04:02:58 -0700 (Tue, 16 Oct 2007)
Log Message:
-----------
mhegd -vv shows the DER tags as we read them
Modified Paths:
--------------
redbutton-author/trunk/der_decode.c
Modified: redbutton-author/trunk/der_decode.c
===================================================================
--- redbutton-author/trunk/der_decode.c 2007-10-15 15:14:48 UTC (rev 438)
+++ redbutton-author/trunk/der_decode.c 2007-10-16 11:02:58 UTC (rev 439)
@@ -8,8 +8,10 @@
#include <ctype.h>
#include "der_decode.h"
+#include "asn1tag.h"
void verbose(char *, ...);
+void vverbose(char *, ...);
/* DER does not allow indefinite lengths */
@@ -75,6 +77,8 @@
}
tag->length = len;
+ vverbose("<TAG class=%s number=%d length=%d/>\n", asn1class_name(tag->class), tag->number, tag->length);
+
return nbytes;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-15 15:14:51
|
Revision: 438
http://redbutton.svn.sourceforge.net/redbutton/?rev=438&view=rev
Author: skilvington
Date: 2007-10-15 08:14:48 -0700 (Mon, 15 Oct 2007)
Log Message:
-----------
I wondered why I'd never written that hexdigit function before
Modified Paths:
--------------
redbutton-author/trunk/der_decode.c
Modified: redbutton-author/trunk/der_decode.c
===================================================================
--- redbutton-author/trunk/der_decode.c 2007-10-15 08:52:29 UTC (rev 437)
+++ redbutton-author/trunk/der_decode.c 2007-10-15 15:14:48 UTC (rev 438)
@@ -10,7 +10,6 @@
#include "der_decode.h"
void verbose(char *, ...);
-char hexdigit(unsigned char);
/* DER does not allow indefinite lengths */
@@ -119,15 +118,16 @@
verbose("<OctetString size=\"%d\">\n", length);
+ /* output a QPRINTABLE string */
fprintf(out, "'");
while(left > 0)
{
if(der_read_file(der, 1, &byte) < 0)
return der_error("OctetString");
if(byte != '\'' && byte >= 0x20 && byte < 0x7f)
- fprintf(out, "%c", byte);
+ fprintf(out, "%c", byte);
else
- fprintf(out, "=%c%c", hexdigit((byte >> 4) & 0xf), hexdigit(byte & 0xf));
+ fprintf(out, "=%02x", byte);
left --;
}
fprintf(out, "'");
@@ -163,17 +163,6 @@
return length;
}
-char
-hexdigit(unsigned char nibble)
-{
- if(nibble < 10)
- return '0' + nibble;
- else if(nibble < 16)
- return 'a' + nibble;
- else
- return '?';
-}
-
int
get_der_int(FILE *der, int length)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-10-15 08:52:30
|
Revision: 437
http://redbutton.svn.sourceforge.net/redbutton/?rev=437&view=rev
Author: skilvington
Date: 2007-10-15 01:52:29 -0700 (Mon, 15 Oct 2007)
Log Message:
-----------
forgot these files
Added Paths:
-----------
redbutton-author/trunk/asn1decode.c.header
redbutton-author/trunk/asn1decode.h.footer
redbutton-author/trunk/asn1decode.h.header
Added: redbutton-author/trunk/asn1decode.c.header
===================================================================
--- redbutton-author/trunk/asn1decode.c.header (rev 0)
+++ redbutton-author/trunk/asn1decode.c.header 2007-10-15 08:52:29 UTC (rev 437)
@@ -0,0 +1,111 @@
+#include "asn1decode.h"
+#include "der_decode.h"
+#include "asn1tag.h"
+
+void verbose(char *, ...);
+
+int asn1decode_BOOLEAN(FILE *der, FILE *out, int length)
+{
+ int left = length;
+ int sublen;
+ struct der_tag tag;
+
+ verbose("<BOOLEAN>\n");
+
+ if((sublen = der_decode_Tag(der, &tag)) < 0)
+ return der_error("BOOLEAN");
+ left -= sublen;
+
+ if(is_BOOLEAN(tag.class, tag.number))
+ {
+ der_decode_BOOLEAN(der, out, tag.length);
+ left -= tag.length;
+ }
+ else
+ {
+ return der_error("BOOLEAN");
+ }
+
+ if(left != 0)
+ return der_error("BOOLEAN: %d bytes left", left);
+
+ verbose("</BOOLEAN>\n");
+
+ return length;
+}
+
+bool is_BOOLEAN(unsigned char class, unsigned int number)
+{
+ return MATCH_TAGCLASS(class, number, ASN1TAGCLASS_BOOLEAN);
+}
+
+int asn1decode_INTEGER(FILE *der, FILE *out, int length)
+{
+ int left = length;
+ int sublen;
+ struct der_tag tag;
+
+ verbose("<INTEGER>\n");
+
+ if((sublen = der_decode_Tag(der, &tag)) < 0)
+ return der_error("INTEGER");
+ left -= sublen;
+
+ if(is_INTEGER(tag.class, tag.number))
+ {
+ der_decode_INTEGER(der, out, tag.length);
+ left -= tag.length;
+ }
+ else
+ {
+ return der_error("INTEGER");
+ }
+
+ if(left != 0)
+ return der_error("INTEGER: %d bytes left", left);
+
+ verbose("</INTEGER>\n");
+
+ return length;
+}
+
+bool is_INTEGER(unsigned char class, unsigned int number)
+{
+ return MATCH_TAGCLASS(class, number, ASN1TAGCLASS_INTEGER);
+}
+
+int asn1decode_Null(FILE *der, FILE *out, int length)
+{
+ int left = length;
+ int sublen;
+ struct der_tag tag;
+
+ verbose("<Null>\n");
+
+ if((sublen = der_decode_Tag(der, &tag)) < 0)
+ return der_error("Null");
+ left -= sublen;
+
+ if(is_Null(tag.class, tag.number))
+ {
+ der_decode_Null(der, out, tag.length);
+ left -= tag.length;
+ }
+ else
+ {
+ return der_error("Null");
+ }
+
+ if(left != 0)
+ return der_error("Null: %d bytes left", left);
+
+ verbose("</Null>\n");
+
+ return length;
+}
+
+bool is_Null(unsigned char class, unsigned int number)
+{
+ return MATCH_TAGCLASS(class, number, ASN1TAGCLASS_NULL);
+}
+
Added: redbutton-author/trunk/asn1decode.h.footer
===================================================================
--- redbutton-author/trunk/asn1decode.h.footer (rev 0)
+++ redbutton-author/trunk/asn1decode.h.footer 2007-10-15 08:52:29 UTC (rev 437)
@@ -0,0 +1,2 @@
+#endif /* __ASN1DECODE_H__ */
+
Added: redbutton-author/trunk/asn1decode.h.header
===================================================================
--- redbutton-author/trunk/asn1decode.h.header (rev 0)
+++ redbutton-author/trunk/asn1decode.h.header 2007-10-15 08:52:29 UTC (rev 437)
@@ -0,0 +1,15 @@
+#ifndef __ASN1DECODE_H__
+#define __ASN1DECODE_H__
+
+#include <stdio.h>
+#include <stdbool.h>
+
+int asn1decode_BOOLEAN(FILE *, FILE *, int);
+bool is_BOOLEAN(unsigned char, unsigned int);
+
+int asn1decode_INTEGER(FILE *, FILE *, int);
+bool is_INTEGER(unsigned char, unsigned int);
+
+int asn1decode_Null(FILE *, FILE *, int);
+bool is_Null(unsigned char, unsigned int);
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|