redbutton-devel Mailing List for RedButton MHEG Engine (Page 7)
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...> - 2008-01-25 16:17:32
|
Revision: 481
http://redbutton.svn.sourceforge.net/redbutton/?rev=481&view=rev
Author: skilvington
Date: 2008-01-25 08:17:03 -0800 (Fri, 25 Jan 2008)
Log Message:
-----------
tagged release 20080125 of author package
Added Paths:
-----------
redbutton-author/tags/redbutton-author-20080125/
Copied: redbutton-author/tags/redbutton-author-20080125 (from rev 480, redbutton-author/trunk)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-25 16:12:28
|
Revision: 480
http://redbutton.svn.sourceforge.net/redbutton/?rev=480&view=rev
Author: skilvington
Date: 2008-01-25 08:12:24 -0800 (Fri, 25 Jan 2008)
Log Message:
-----------
describe mhegd on the web page
Modified Paths:
--------------
www/index.html
Modified: www/index.html
===================================================================
--- www/index.html 2008-01-25 15:32:11 UTC (rev 479)
+++ www/index.html 2008-01-25 16:12:24 UTC (rev 480)
@@ -13,7 +13,9 @@
Both rb-download and rb-browser can be run on the same host,
or rb-download can be run on a host with a DVB card and rb-browser can be run on a remote frontend without a DVB card.
<P>
+The rb-author package contains tools for working with MHEG applications.
If you want to write your own MHEG applications, you can use the mhegc compiler to generate the ASN1 format files rb-browser expects.
+If you want to see how other peoples applications work, you can use the mhegd tool to convert ASN1 format files into the text form.
<P>
The source is released under the GPL and can be
<A HREF="http://sourceforge.net/project/showfiles.php?group_id=158629">downloaded here.</A>
@@ -241,6 +243,15 @@
<PRE>
rb-browser helloworld/
</PRE>
+<H2>mhegd</H2>
+Usage:
+<PRE>
+mhegd [-vv] [-o <output_file>] <input_file>
+</PRE>
+Will convert the <input_file> from the ASN1 form to the MHEG text format.
+The text will be written to the given output file (or to stdout if no -o option is given).
+<P>
+The -v flag enables debug mode and will print details about the ASN1 object as it is decoded. Use -vv for even more info.
<H2>Contact Details</H2>
I can be contacted here: s.kilvington at eris dot qinetiq com.
</BODY>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-25 15:32:14
|
Revision: 479
http://redbutton.svn.sourceforge.net/redbutton/?rev=479&view=rev
Author: skilvington
Date: 2008-01-25 07:32:11 -0800 (Fri, 25 Jan 2008)
Log Message:
-----------
encode true booleans as 255 rather than 1 (same as BBC) - should probably be a cmd line option
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2008-01-25 15:29:40 UTC (rev 478)
+++ redbutton-author/trunk/der_encode.c 2008-01-25 15:32:11 UTC (rev 479)
@@ -36,7 +36,7 @@
*len = 1;
*out = safe_malloc(1);
- (*out)[0] = val ? 1 : 0;
+ (*out)[0] = val ? 0xff : 0;
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-25 15:29:44
|
Revision: 478
http://redbutton.svn.sourceforge.net/redbutton/?rev=478&view=rev
Author: skilvington
Date: 2008-01-25 07:29:40 -0800 (Fri, 25 Jan 2008)
Log Message:
-----------
something TODO
Modified Paths:
--------------
redbutton-download/trunk/TODO
Modified: redbutton-download/trunk/TODO
===================================================================
--- redbutton-download/trunk/TODO 2008-01-15 09:37:05 UTC (rev 477)
+++ redbutton-download/trunk/TODO 2008-01-25 15:29:40 UTC (rev 478)
@@ -19,3 +19,6 @@
create carousels/PID/CID dir in add_dsmcc_pid()
(may need to use carousels/<assoc_tag> as stream2pid may return 0)
+if you run rb-download without a service ID (ie want to list channels), but we
+can't get a lock, then list the channels in the channels.conf file
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-15 09:37:07
|
Revision: 477
http://redbutton.svn.sourceforge.net/redbutton/?rev=477&view=rev
Author: skilvington
Date: 2008-01-15 01:37:05 -0800 (Tue, 15 Jan 2008)
Log Message:
-----------
whitespace
Modified Paths:
--------------
redbutton-author/trunk/output.c
Modified: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c 2008-01-14 18:42:46 UTC (rev 476)
+++ redbutton-author/trunk/output.c 2008-01-15 09:37:05 UTC (rev 477)
@@ -68,7 +68,7 @@
else if(tok[0] == ')' && tok[1] == '\0')
{
/* assert */
- if(paren_level <=0)
+ if(paren_level <= 0)
fatal("output_token: unexpected ')'");
if(indent_paren[paren_level])
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-14 18:42:50
|
Revision: 476
http://redbutton.svn.sourceforge.net/redbutton/?rev=476&view=rev
Author: skilvington
Date: 2008-01-14 10:42:46 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
remove duplicate if condition
Modified Paths:
--------------
redbutton-author/trunk/output.c
Modified: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c 2008-01-14 17:19:14 UTC (rev 475)
+++ redbutton-author/trunk/output.c 2008-01-14 18:42:46 UTC (rev 476)
@@ -100,7 +100,6 @@
|| strcmp(tok, ":MovementTable") == 0
|| strcmp(tok, ":Multiplex") == 0
|| strcmp(tok, ":NextScenes") == 0
- || strcmp(tok, ":NextScenes") == 0
|| strcmp(tok, ":NoTokenActionSlots") == 0
|| strcmp(tok, ":Positions") == 0
|| strcmp(tok, ":TokenGroupItems") == 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-14 17:19:18
|
Revision: 475
http://redbutton.svn.sourceforge.net/redbutton/?rev=475&view=rev
Author: skilvington
Date: 2008-01-14 09:19:14 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
make mhegd output even nicer
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/mhegd.c
redbutton-author/trunk/output.c
redbutton-author/trunk/output.h
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/TODO 2008-01-14 17:19:14 UTC (rev 475)
@@ -31,3 +31,32 @@
allow INTEGERs to be arthimetic expressions
#include "uk.inc"
+---
+
+mhegd
+make this look nicer (4165/a)...
+{:TokenGroup 1000
+ :Shared true
+ :TokenGroupItems (
+ ( 102
+ :ActionSlots (
+ (
+ :Call ( ... )
+ :Activate ( 1001 )
+ ) )
+ )
+}
+
+this is even worse (4165/enh_gateway.mhg)...
+ {:TokenGroup 82
+ :TokenGroupItems (
+ ( ( '/a' 1 )
+ :ActionSlots (
+ (
+ :Run ( ( '/a' 119 ) ) ) (
+ :Run ( ( '/a' 119 ) ) ) (
+ :Run ( ( '/a' 122 ) )
+ :Run ( ( '/a' 120 ) ) )
+ ) )
+ )
+
Modified: redbutton-author/trunk/mhegd.c
===================================================================
--- redbutton-author/trunk/mhegd.c 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/mhegd.c 2008-01-14 17:19:14 UTC (rev 475)
@@ -29,6 +29,7 @@
#include "asn1decode.h"
#include "der_decode.h"
+#include "output.h"
#include "utils.h"
void verbose(const char *, ...);
@@ -82,6 +83,7 @@
rewind(in_file);
/* write text form of DER encoded in_file to out_file */
+ output_init();
used = asn1decode_InterchangedObject(in_file, out_file, filesize);
fprintf(out_file, "\n");
if(used < 0)
Modified: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/output.c 2008-01-14 17:19:14 UTC (rev 475)
@@ -32,15 +32,55 @@
int indent = 0;
bool newline = true;
+/* keep track of () blocks that should be indented */
+#define PAREN_LEVEL_MAX 8192
+int paren_level = 0;
+bool indent_paren[PAREN_LEVEL_MAX];
+
void
+output_init(void)
+{
+ bzero(indent_paren, sizeof(indent_paren));
+
+ return;
+}
+
+void
output_token(FILE *out, char *tok)
{
/* assert */
if(tok[0] == '\0')
fatal("output_token: 0 length token");
- if(tok[0] == '{' && tok[1] == ':')
+ if(tok[0] == '(' && tok[1] == '\0')
{
+ /* assert */
+ if(paren_level >= (PAREN_LEVEL_MAX - 1))
+ fatal("output_token: max nested parenthesis reached");
+ print_token(out, tok);
+ paren_level ++;
+ if(indent_paren[paren_level])
+ {
+ print_newline(out);
+ indent ++;
+ }
+ }
+ else if(tok[0] == ')' && tok[1] == '\0')
+ {
+ /* assert */
+ if(paren_level <=0)
+ fatal("output_token: unexpected ')'");
+ if(indent_paren[paren_level])
+ {
+ indent --;
+ print_newline(out);
+ }
+ indent_paren[paren_level] = false;
+ paren_level --;
+ print_token(out, tok);
+ }
+ else if(tok[0] == '{' && tok[1] == ':')
+ {
print_newline(out);
print_token(out, tok);
indent ++;
@@ -54,14 +94,33 @@
print_newline(out);
print_token(out, tok);
}
+ else if(strcmp(tok, ":ActionSlots") == 0
+ || strcmp(tok, ":Items") == 0
+ || strcmp(tok, ":LinkEffect") == 0
+ || strcmp(tok, ":MovementTable") == 0
+ || strcmp(tok, ":Multiplex") == 0
+ || strcmp(tok, ":NextScenes") == 0
+ || strcmp(tok, ":NextScenes") == 0
+ || strcmp(tok, ":NoTokenActionSlots") == 0
+ || strcmp(tok, ":Positions") == 0
+ || strcmp(tok, ":TokenGroupItems") == 0)
+ {
+ print_newline(out);
+ print_token(out, tok);
+ /* next () block should be indented */
+ indent_paren[paren_level + 1] = true;
+ }
else if(tok[0] == ':'
+ && strcmp(tok, ":CCPriority") != 0
+ && strcmp(tok, ":ContentRef") != 0
+ && strcmp(tok, ":IndirectRef") != 0
&& strcmp(tok, ":GBoolean") != 0
+ && strcmp(tok, ":GContentRef") != 0
&& strcmp(tok, ":GInteger") != 0
+ && strcmp(tok, ":GObjectRef") != 0
&& strcmp(tok, ":GOctetString") != 0
- && strcmp(tok, ":GObjectRef") != 0
- && strcmp(tok, ":GContentRef") != 0
- && strcmp(tok, ":IndirectRef") != 0
- && strcmp(tok, ":ContentRef") != 0)
+ && strcmp(tok, ":NewCCPriority") != 0
+ && strcmp(tok, ":NewRefContent") != 0)
{
print_newline(out);
print_token(out, tok);
Modified: redbutton-author/trunk/output.h
===================================================================
--- redbutton-author/trunk/output.h 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/output.h 2008-01-14 17:19:14 UTC (rev 475)
@@ -25,6 +25,8 @@
#include <stdio.h>
+void output_init(void);
+
void output_token(FILE *, char *);
#endif /* __OUTPUT_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-09 17:06:58
|
Revision: 474
http://redbutton.svn.sourceforge.net/redbutton/?rev=474&view=rev
Author: skilvington
Date: 2008-01-09 09:06:53 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
make mhegd output prettier
Modified Paths:
--------------
redbutton-author/trunk/output.c
Modified: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c 2008-01-09 16:48:01 UTC (rev 473)
+++ redbutton-author/trunk/output.c 2008-01-09 17:06:53 UTC (rev 474)
@@ -54,7 +54,14 @@
print_newline(out);
print_token(out, tok);
}
- else if(tok[0] == ':' && strcmp(tok, ":ContentRef") != 0)
+ else if(tok[0] == ':'
+ && strcmp(tok, ":GBoolean") != 0
+ && strcmp(tok, ":GInteger") != 0
+ && strcmp(tok, ":GOctetString") != 0
+ && strcmp(tok, ":GObjectRef") != 0
+ && strcmp(tok, ":GContentRef") != 0
+ && strcmp(tok, ":IndirectRef") != 0
+ && strcmp(tok, ":ContentRef") != 0)
{
print_newline(out);
print_token(out, tok);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2008-01-09 16:58:53
|
Revision: 473
http://redbutton.svn.sourceforge.net/redbutton/?rev=473&view=rev
Author: skilvington
Date: 2008-01-09 08:48:01 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
something TODO
Modified Paths:
--------------
redbutton-author/trunk/TODO
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-12-07 17:20:22 UTC (rev 472)
+++ redbutton-author/trunk/TODO 2008-01-09 16:48:01 UTC (rev 473)
@@ -25,3 +25,9 @@
clean up ccc.y
+---
+
+ideas from mhegenc (http://www.spongelava.com/mhegenc.html):
+allow INTEGERs to be arthimetic expressions
+#include "uk.inc"
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-12-07 17:20:25
|
Revision: 472
http://redbutton.svn.sourceforge.net/redbutton/?rev=472&view=rev
Author: skilvington
Date: 2007-12-07 09:20:22 -0800 (Fri, 07 Dec 2007)
Log Message:
-----------
first stab at making mhegd output prettier
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/asn1decode.c.header
redbutton-author/trunk/ccc.y
redbutton-author/trunk/der_decode.c
Added Paths:
-----------
redbutton-author/trunk/output.c
redbutton-author/trunk/output.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/Makefile 2007-12-07 17:20:22 UTC (rev 472)
@@ -24,6 +24,7 @@
asn1decode.o \
der_decode.o \
asn1tag.o \
+ output.o \
utils.o
TARDIR=`basename ${PWD}`
Modified: redbutton-author/trunk/asn1decode.c.header
===================================================================
--- redbutton-author/trunk/asn1decode.c.header 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/asn1decode.c.header 2007-12-07 17:20:22 UTC (rev 472)
@@ -4,6 +4,7 @@
#include "asn1decode.h"
#include "der_decode.h"
#include "asn1tag.h"
+#include "output.h"
void verbose(char *, ...);
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/ccc.y 2007-12-07 17:20:22 UTC (rev 472)
@@ -822,7 +822,7 @@
{
/* output any literals at the start */
for(item=state.items; item && item->type==IT_LITERAL; item=item->next)
- buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
/* assert */
if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
@@ -951,7 +951,7 @@
/* assert */
if(item->type != IT_LITERAL)
fatal("Trailing non-literal");
- buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
item = item->next;
}
}
@@ -964,7 +964,7 @@
buf_append(&state.decode_fns, "\t/* SET */\n");
/* output any literals at the start */
for(item=state.items; item && item->type==IT_LITERAL; item=item->next)
- buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
/* items must be in the order they are defined for SEQUENCE types */
switch(asn1type(name))
{
@@ -1112,7 +1112,7 @@
/* assert */
if(item->type != IT_LITERAL)
fatal("Trailing non-literal");
- buf_append(&state.decode_fns, "\tfprintf(out, \"%%s \", %s);\n\n", item->name);
+ buf_append(&state.decode_fns, "\toutput_token(out, %s);\n\n", item->name);
item = item->next;
}
}
@@ -1140,8 +1140,6 @@
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
/* end decode_Xxx() function */
- if(!is_synthetic(asn1tagclass(name)))
- buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
@@ -1215,8 +1213,6 @@
}
/* end decode_Xxx() function */
- if(!is_synthetic(asn1tagclass(name)))
- buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
Modified: redbutton-author/trunk/der_decode.c
===================================================================
--- redbutton-author/trunk/der_decode.c 2007-11-30 16:31:33 UTC (rev 471)
+++ redbutton-author/trunk/der_decode.c 2007-12-07 17:20:22 UTC (rev 472)
@@ -95,7 +95,7 @@
verbose("<Boolean value=\"%s\"/>\n", val ? "true" : "false");
- fprintf(out, "%s ", val ? "true" : "false");
+ fprintf(out, " %s", val ? "true" : "false");
return length;
}
@@ -107,7 +107,7 @@
verbose("<Integer value=\"%d\"/>\n", val);
- fprintf(out, "%d ", val);
+ fprintf(out, " %d", val);
return length;
}
@@ -123,7 +123,7 @@
verbose("<OctetString size=\"%d\">\n", length);
/* output a QPRINTABLE string */
- fprintf(out, "'");
+ fprintf(out, " '");
while(left > 0)
{
if(der_read_file(der, 1, &byte) < 0)
@@ -134,7 +134,7 @@
fprintf(out, "=%02x", byte);
left --;
}
- fprintf(out, "' ");
+ fprintf(out, "'");
verbose("</OctetString>\n");
@@ -162,7 +162,7 @@
verbose("<Enumerated value=\"%d\"/>\n", val);
- fprintf(out, "%s ", names[val - 1]);
+ fprintf(out, " %s", names[val - 1]);
return length;
}
Added: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c (rev 0)
+++ redbutton-author/trunk/output.c 2007-12-07 17:20:22 UTC (rev 472)
@@ -0,0 +1,103 @@
+/*
+ * output.c
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "utils.h"
+
+void print_newline(FILE *);
+void print_token(FILE *, char *);
+
+int indent = 0;
+bool newline = true;
+
+void
+output_token(FILE *out, char *tok)
+{
+ /* assert */
+ if(tok[0] == '\0')
+ fatal("output_token: 0 length token");
+
+ if(tok[0] == '{' && tok[1] == ':')
+ {
+ print_newline(out);
+ print_token(out, tok);
+ indent ++;
+ }
+ else if(tok[0] == '}')
+ {
+ /* assert */
+ if(indent == 0)
+ fatal("output_token: unexpected '}'");
+ indent --;
+ print_newline(out);
+ print_token(out, tok);
+ }
+ else if(tok[0] == ':' && strcmp(tok, ":ContentRef") != 0)
+ {
+ print_newline(out);
+ print_token(out, tok);
+ }
+ else
+ {
+ print_token(out, tok);
+ }
+
+ return;
+}
+
+void
+print_newline(FILE *out)
+{
+ if(!newline)
+ fprintf(out, "\n");
+
+ newline = true;
+
+ return;
+}
+
+void
+print_token(FILE *out, char *tok)
+{
+ int i = indent;
+
+ if(newline)
+ {
+ while(i > 0)
+ {
+ fprintf(out, "\t");
+ i --;
+ }
+ newline = false;
+ }
+ else
+ {
+ fprintf(out, " ");
+ }
+
+ fprintf(out, "%s", tok);
+
+ return;
+}
Added: redbutton-author/trunk/output.h
===================================================================
--- redbutton-author/trunk/output.h (rev 0)
+++ redbutton-author/trunk/output.h 2007-12-07 17:20:22 UTC (rev 472)
@@ -0,0 +1,31 @@
+/*
+ * output.h
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __OUTPUT_H__
+#define __OUTPUT_H__
+
+#include <stdio.h>
+
+void output_token(FILE *, char *);
+
+#endif /* __OUTPUT_H__ */
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-30 16:31:34
|
Revision: 471
http://redbutton.svn.sourceforge.net/redbutton/?rev=471&view=rev
Author: skilvington
Date: 2007-11-30 08:31:33 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
something TODO
Modified Paths:
--------------
redbutton-author/trunk/TODO
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-30 16:25:35 UTC (rev 470)
+++ redbutton-author/trunk/TODO 2007-11-30 16:31:33 UTC (rev 471)
@@ -9,6 +9,13 @@
---
+mhegc
+be able to choose what value is used for 'true' BOOLEANs (1-255)
+curently we always use 1
+BBC use 0xff
+
+---
+
mhegd
check NoTokenActionSlots (empty and not empty)
check ActionSlots empty (ie Null) works
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-30 16:25:38
|
Revision: 470
http://redbutton.svn.sourceforge.net/redbutton/?rev=470&view=rev
Author: skilvington
Date: 2007-11-30 08:25:35 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
move is_synthetic() checks out of asn1decode.c
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-29 17:15:30 UTC (rev 469)
+++ redbutton-author/trunk/ccc.y 2007-11-30 16:25:35 UTC (rev 470)
@@ -792,9 +792,8 @@
/* 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");
+ if(!is_synthetic(asn1tagclass(name)))
+ buf_append(&state.decode_is_fns, "\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_%s);\n", name);
/* count how many non-literal items there are */
nitems = 0;
@@ -815,7 +814,8 @@
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, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_OCTETSTRING);\n");
+ if(is_synthetic(asn1tagclass(name)))
+ 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)
@@ -942,7 +942,8 @@
}
buf_append(&state.decode_fns, "\n");
/* is_Xxx() function */
- buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
+ if(is_synthetic(asn1tagclass(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)
@@ -972,7 +973,8 @@
if(item->type != IT_IDENTIFIER)
fatal("not Identifier");
/* is_Xxx() - just match the first item */
- buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
+ if(is_synthetic(asn1tagclass(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 */
while(item && item->type != IT_LITERAL)
{
@@ -1059,15 +1061,18 @@
while(item && item->type != IT_LITERAL)
{
/* is_Xxx() */
- if(first)
- buf_append(&state.decode_is_fns, "\t\treturn ");
- else
- 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)
- buf_append(&state.decode_is_fns, ";");
- buf_append(&state.decode_is_fns, "\n");
+ if(is_synthetic(asn1tagclass(name)))
+ {
+ if(first)
+ buf_append(&state.decode_is_fns, "\treturn ");
+ else
+ buf_append(&state.decode_is_fns, "\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)
+ buf_append(&state.decode_is_fns, ";");
+ buf_append(&state.decode_is_fns, "\n");
+ }
/* decode_Xxx() */
if(first)
buf_append(&state.decode_fns, "\t\t");
@@ -1158,7 +1163,8 @@
/* prototype */
buf_append(&state.decode_hdr, "int der_decode_%s(FILE *, FILE *, int);\n", name);
/* is_Xxx() function */
- buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_ENUMERATED);\n");
+ if(is_synthetic(asn1tagclass(name)))
+ buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_ENUMERATED);\n");
}
/* must be a CHOICE */
else
@@ -1172,15 +1178,18 @@
for(item=state.items; item; item=item->next)
{
/* is_Xxx() function */
- if(item == state.items)
- buf_append(&state.decode_is_fns, "\t\treturn ");
- else
- 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)
- buf_append(&state.decode_is_fns, ";");
- buf_append(&state.decode_is_fns, "\n");
+ if(is_synthetic(asn1tagclass(name)))
+ {
+ if(item == state.items)
+ buf_append(&state.decode_is_fns, "\t\treturn ");
+ else
+ 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)
+ buf_append(&state.decode_is_fns, ";");
+ buf_append(&state.decode_is_fns, "\n");
+ }
/* decode_Xxx() function */
if(item == state.items)
buf_append(&state.decode_fns, "\t");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-29 17:15:32
|
Revision: 469
http://redbutton.svn.sourceforge.net/redbutton/?rev=469&view=rev
Author: skilvington
Date: 2007-11-29 09:15:30 -0800 (Thu, 29 Nov 2007)
Log Message:
-----------
don't need to explicitly deal with this case
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-28 17:31:34 UTC (rev 468)
+++ redbutton-author/trunk/ccc.y 2007-11-29 17:15:30 UTC (rev 469)
@@ -826,8 +826,14 @@
/* assert */
if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
-/* TODO */
-/* is it OPTIONAL - check if length == 0, if so bomb out now */
+#if 0
+ /* is it OPTIONAL - check if length == 0, if so bomb out now */
+ /*
+ * only thing this effects is TokenManager ::= [MovementTable]
+ * which works without this check (because TokenGroupBody is a SET)
+ */
+ if(item->type == IT_OPTIONAL) printf("TODO: OPTIONAL %s->%s\n", name, item->name);
+#endif
/* is it a primitive type */
if(strcmp(item->name, "BOOLEAN") == 0
|| strcmp(item->name, "INTEGER") == 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-28 17:31:37
|
Revision: 468
http://redbutton.svn.sourceforge.net/redbutton/?rev=468&view=rev
Author: skilvington
Date: 2007-11-28 09:31:34 -0800 (Wed, 28 Nov 2007)
Log Message:
-----------
now Movement is a SEQUENCE, it should be okay
Modified Paths:
--------------
redbutton-author/trunk/TODO
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-21 16:46:51 UTC (rev 467)
+++ redbutton-author/trunk/TODO 2007-11-28 17:31:34 UTC (rev 468)
@@ -5,8 +5,7 @@
---
mhegc
-not entirely convinced MovementTable/Movement/TargetElement will be encoded correctly
-should Movement be SYNTHETIC?
+check MovementTable/Movement/TargetElement are encoded correctly
---
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-21 16:46:57
|
Revision: 467
http://redbutton.svn.sourceforge.net/redbutton/?rev=467&view=rev
Author: skilvington
Date: 2007-11-21 08:46:51 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
make the asn1decode.c code more compact
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-21 16:27:56 UTC (rev 466)
+++ redbutton-author/trunk/ccc.y 2007-11-21 16:46:51 UTC (rev 467)
@@ -889,14 +889,13 @@
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, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\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 = asn1decode_%s(der, out, tag.length)) < 0)\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");
buf_append(&state.decode_fns, "\t\t}\n");
@@ -920,14 +919,13 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
}
else
{
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, tag.length)) < 0)\n", item->name);
}
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
@@ -982,8 +980,7 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
}
@@ -1002,16 +999,14 @@
buf_append(&state.decode_fns, "\t\telse\n");
buf_append(&state.decode_fns, "\t\t{\n");
buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\tif((sublen = asn1decode_%s(der, out, tag.length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n");
}
else
{
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\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 -= tag.length;\n");
}
@@ -1078,13 +1073,12 @@
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, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
}
else
{
- 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 = asn1decode_%s(der, out, tag.length)) < 0)\n", item->name);
}
- buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n");
@@ -1191,13 +1185,12 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, tag.length)) < 0)\n", item->name);
}
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-21 16:28:05
|
Revision: 466
http://redbutton.svn.sourceforge.net/redbutton/?rev=466&view=rev
Author: skilvington
Date: 2007-11-21 08:27:56 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
fix NewContentSize NULL parsing
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-11-19 16:44:26 UTC (rev 465)
+++ redbutton-author/trunk/asn1tag.h 2007-11-21 16:27:56 UTC (rev 466)
@@ -744,7 +744,7 @@
#define ASN1TAGCLASS_NewReferencedContent ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_NextScene ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_TokenGroupItem ASN1TAGCLASS_SEQUENCE
-#define ASN1TAGCLASS_Movement ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_Movement ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_ActionSlots ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_InVariables ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_OutVariables ASN1TAGCLASS_SEQUENCE
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-19 16:44:26 UTC (rev 465)
+++ redbutton-author/trunk/ccc.y 2007-11-21 16:27:56 UTC (rev 466)
@@ -983,17 +983,42 @@
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
}
else
{
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ /* is it a type that is encoded as a NULL if it is not present */
+ if(item->type == IT_IDENTORNULL)
+ {
+ buf_append(&state.decode_fns, "\t\tstruct der_tag null_tag;\n");
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &null_tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tif(is_Null(null_tag.class, null_tag.number))\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
+ buf_append(&state.decode_fns, "\t\t}\n");
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
+ }
}
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
/* is it a type that is encoded as a NULL if it is not present */
- if(item->type == IT_IDENTORNULL)
+ if(item->type == IT_IDENTORNULL && keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\telse if(!is_Null(tag.class, tag.number))\n");
buf_append(&state.decode_fns, "\t{\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-19 16:45:03
|
Revision: 465
http://redbutton.svn.sourceforge.net/redbutton/?rev=465&view=rev
Author: skilvington
Date: 2007-11-19 08:44:26 -0800 (Mon, 19 Nov 2007)
Log Message:
-----------
stop parsing if we find an error
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegd.c
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-16 17:20:21 UTC (rev 464)
+++ redbutton-author/trunk/ccc.y 2007-11-19 16:44:26 UTC (rev 465)
@@ -982,12 +982,14 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
/* is it a type that is encoded as a NULL if it is not present */
@@ -1051,12 +1053,14 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t\t}\n");
item = item->next;
@@ -1100,7 +1104,8 @@
buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
/* the ENUMERATED value is encoded as an INTEGER */
buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t{\n", name);
- buf_append(&state.decode_fns, "\t\tder_decode_ENUMERATED(der, out, tag.length, %u, enum_names);\n", enum_val);
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_ENUMERATED(der, out, tag.length, %u, enum_names)) < 0)\n", enum_val);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
@@ -1161,12 +1166,14 @@
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n");
}
Modified: redbutton-author/trunk/mhegd.c
===================================================================
--- redbutton-author/trunk/mhegd.c 2007-11-16 17:20:21 UTC (rev 464)
+++ redbutton-author/trunk/mhegd.c 2007-11-19 16:44:26 UTC (rev 465)
@@ -46,6 +46,7 @@
FILE *in_file;
FILE *out_file = stdout;
int filesize;
+ int used;
while((arg = getopt(argc, argv, "o:v")) != EOF)
{
@@ -81,7 +82,11 @@
rewind(in_file);
/* write text form of DER encoded in_file to out_file */
- if(asn1decode_InterchangedObject(in_file, out_file, filesize) != filesize)
+ used = asn1decode_InterchangedObject(in_file, out_file, filesize);
+ fprintf(out_file, "\n");
+ if(used < 0)
+ fatal("Parsing error");
+ else if(used != filesize)
fatal("Unexpected data after InterchangedObject");
return EXIT_SUCCESS;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-16 17:20:22
|
Revision: 464
http://redbutton.svn.sourceforge.net/redbutton/?rev=464&view=rev
Author: skilvington
Date: 2007-11-16 09:20:21 -0800 (Fri, 16 Nov 2007)
Log Message:
-----------
keep the compiler happy
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-16 17:16:23 UTC (rev 463)
+++ redbutton-author/trunk/ccc.y 2007-11-16 17:20:21 UTC (rev 464)
@@ -787,6 +787,7 @@
buf_append(&state.decode_fns, "\tint left = length;\n");
buf_append(&state.decode_fns, "\tint sublen;\n");
buf_append(&state.decode_fns, "\tstruct der_tag tag;\n\n");
+ buf_append(&state.decode_fns, "\t/* keep the compiler happy */\n\ttag = tag;\n\n");
buf_append(&state.decode_fns, "\tverbose(\"<%s>\\n\");\n\n", name);
/* ASN1 is_Xxx() functions */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-16 17:16:28
|
Revision: 463
http://redbutton.svn.sourceforge.net/redbutton/?rev=463&view=rev
Author: skilvington
Date: 2007-11-16 09:16:23 -0800 (Fri, 16 Nov 2007)
Log Message:
-----------
give NewTimer an explicit SEQUENCE tag
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/grammar
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-11-16 17:07:16 UTC (rev 462)
+++ redbutton-author/trunk/asn1tag.c 2007-11-16 17:16:23 UTC (rev 463)
@@ -547,6 +547,7 @@
MATCH(NewContent)
MATCH(NewFont)
MATCH(NewVariableValue)
+ MATCH(NewTimer)
fprintf(stderr, "Unknown ASN1TAGCLASS type: %s\n", name);
exit(EXIT_FAILURE);
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-11-16 17:07:16 UTC (rev 462)
+++ redbutton-author/trunk/asn1tag.h 2007-11-16 17:16:23 UTC (rev 463)
@@ -792,5 +792,6 @@
#define ASN1TAGCLASS_NewContent ASN1TAG_CHOICE
#define ASN1TAGCLASS_NewFont ASN1TAG_CHOICE
#define ASN1TAGCLASS_NewVariableValue ASN1TAG_CHOICE
+#define ASN1TAGCLASS_NewTimer ASN1TAGCLASS_SEQUENCE
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-11-16 17:07:16 UTC (rev 462)
+++ redbutton-author/trunk/grammar 2007-11-16 17:16:23 UTC (rev 463)
@@ -711,8 +711,8 @@
SetSliderValue ::= ":SetSliderValue" "(" Target
NewSliderValue ")" .
SetSpeed ::= ":SetSpeed" "(" Target NewSpeed ")" .
-SetTimer ::= ":SetTimer" "(" Target TimerID
- [TimerValue] [AbsoluteTime] ")" .
+SetTimer ::= ":SetTimer" "(" Target TimerID [NewTimer] ")" .
+NewTimer ::= TimerValue [AbsoluteTime] .
SetTransparency ::= ":SetTransparency" "(" Target
NewTransparency ")" .
SetVariable ::= ":SetVariable" "(" Target
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-16 17:07:21
|
Revision: 462
http://redbutton.svn.sourceforge.net/redbutton/?rev=462&view=rev
Author: skilvington
Date: 2007-11-16 09:07:16 -0800 (Fri, 16 Nov 2007)
Log Message:
-----------
get an explicit SEQUENCE tag for ActionSlot under ActionSlots
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/grammar
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-09 17:03:45 UTC (rev 461)
+++ redbutton-author/trunk/TODO 2007-11-16 17:07:16 UTC (rev 462)
@@ -12,6 +12,7 @@
mhegd
check NoTokenActionSlots (empty and not empty)
+check ActionSlots empty (ie Null) works
check MovementTable (empty and not empty)
---
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-11-09 17:03:45 UTC (rev 461)
+++ redbutton-author/trunk/grammar 2007-11-16 17:07:16 UTC (rev 462)
@@ -249,7 +249,7 @@
TokenGroupItem ::= "(" AVisible [ActionSlots] ")" .
AVisible ::= ObjectReference .
ActionSlots ::= ":ActionSlots" "(" ActionSlot+ ")" .
-ActionSlot ::= ActionClass | Null .
+ActionSlot ::= ActionClassSeq | Null .
NoTokenActionSlots ::= ":NoTokenActionSlots" "(" ActionSlotSeq+ ")" .
// srk - to get an explicit SEQUENCE tag under NoTokenActionSlots
ActionSlotSeq ::= ActionClassSeq | Null .
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-09 17:03:46
|
Revision: 461
http://redbutton.svn.sourceforge.net/redbutton/?rev=461&view=rev
Author: skilvington
Date: 2007-11-09 09:03:45 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
don't know how that got in there
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-11-09 16:48:47 UTC (rev 460)
+++ redbutton-author/trunk/asn1tag.c 2007-11-09 17:03:45 UTC (rev 461)
@@ -327,7 +327,7 @@
MATCH(UnlockScreen)
MATCH(NewGenericBoolean)
MATCH(NewGenericInteger)
- MATCH(NewGenericOctetstring)
+ MATCH(NewGenericOctetString)
MATCH(NewGenericObjectReference)
MATCH(NewGenericContentReference)
MATCH(NewColourIndex)
@@ -420,7 +420,6 @@
MATCH(NewCursorShape)
MATCH(NewEntryPoint)
MATCH(NewFirstItem)
- MATCH(NewGenericOctetString)
MATCH(NewHighlightStatus)
MATCH(NewIncludedContent)
MATCH(NewInteractionStatus)
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-11-09 16:48:47 UTC (rev 460)
+++ redbutton-author/trunk/asn1tag.h 2007-11-09 17:03:45 UTC (rev 461)
@@ -303,7 +303,7 @@
#define ASN1TAG_UnlockScreen 224
#define ASN1TAG_NewGenericBoolean 225
#define ASN1TAG_NewGenericInteger 226
-#define ASN1TAG_NewGenericOctetstring 227
+#define ASN1TAG_NewGenericOctetString 227
#define ASN1TAG_NewGenericObjectReference 228
#define ASN1TAG_NewGenericContentReference 229
#define ASN1TAG_NewColourIndex 230
@@ -554,7 +554,7 @@
#define ASN1TAGCLASS_UnlockScreen ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_UnlockScreen)
#define ASN1TAGCLASS_NewGenericBoolean ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericBoolean)
#define ASN1TAGCLASS_NewGenericInteger ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericInteger)
-#define ASN1TAGCLASS_NewGenericOctetstring ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericOctetstring)
+#define ASN1TAGCLASS_NewGenericOctetString ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericOctetString)
#define ASN1TAGCLASS_NewGenericObjectReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericObjectReference)
#define ASN1TAGCLASS_NewGenericContentReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericContentReference)
#define ASN1TAGCLASS_NewColourIndex ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewColourIndex)
@@ -660,7 +660,6 @@
#define ASN1TAGCLASS_NewCursorShape ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewEntryPoint ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewFirstItem ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_NewGenericOctetString ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewHighlightStatus ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewIncludedContent ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_NewInteractionStatus ASN1TAG_SYNTHETIC
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-09 16:48:51
|
Revision: 460
http://redbutton.svn.sourceforge.net/redbutton/?rev=460&view=rev
Author: skilvington
Date: 2007-11-09 08:48:47 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
stop :ContentRef including the OCTET-STRING tag as part of its value
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-09 16:38:42 UTC (rev 459)
+++ redbutton-author/trunk/TODO 2007-11-09 16:48:47 UTC (rev 460)
@@ -16,11 +16,5 @@
---
-mhegd
-:ContentRef ContentReference keeps the tag as part of the OctetString
-(eg enh_gateway.mhg)
-
----
-
clean up ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-09 16:38:42 UTC (rev 459)
+++ redbutton-author/trunk/ccc.y 2007-11-09 16:48:47 UTC (rev 460)
@@ -836,7 +836,8 @@
if(item->type != IT_IDENTIFIER)
fatal("Primitive but not Identifier");
/* does it need an extra explicit tag for the primitive type? */
- if(asn1tagclass(name) != asn1tagclass(item->name))
+ if(!is_synthetic(asn1tagclass(name))
+ && asn1tagclass(name) != asn1tagclass(item->name))
{
/* no explicit primitive tag */
buf_append(&state.decode_fns, "\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-09 16:38:44
|
Revision: 459
http://redbutton.svn.sourceforge.net/redbutton/?rev=459&view=rev
Author: skilvington
Date: 2007-11-09 08:38:42 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
cope with ENUMERATED types with no explicit ENUMERATED tag
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-08 17:31:58 UTC (rev 458)
+++ redbutton-author/trunk/TODO 2007-11-09 16:38:42 UTC (rev 459)
@@ -11,12 +11,6 @@
---
mhegd
-HorizontalJustification needs writing
-ie ENUMERATED types without an explicit ENUMERATED tag
-
----
-
-mhegd
check NoTokenActionSlots (empty and not empty)
check MovementTable (empty and not empty)
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-08 17:31:58 UTC (rev 458)
+++ redbutton-author/trunk/ccc.y 2007-11-09 16:38:42 UTC (rev 459)
@@ -868,8 +868,9 @@
/* assert */
if(item->type != IT_IDENTIFIER)
fatal("ENUMERATED but not Identifier");
-/* TODO */
-buf_append(&state.decode_fns, "printf(\"TODO: %s->%s\\n\");\nexit(1);\n",name,item->name);
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n");
}
/* is the whole length one or more sub types */
else if(item->type == IT_ONEORMORE)
@@ -1101,6 +1102,29 @@
buf_append(&state.decode_fns, "\t\tleft -= tag.length;\n");
buf_append(&state.decode_fns, "\t}\n\telse\n");
buf_append(&state.decode_fns, "\t{\n\t\treturn der_error(\"%s\");\n\t}\n\n", name);
+ /* end decode_Xxx() function */
+ if(!is_synthetic(asn1tagclass(name)))
+ buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
+ buf_append(&state.decode_fns, "\tif(left != 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
+ buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
+ buf_append(&state.decode_fns, "\treturn length;\n}\n\n");
+ /* create a der_decode_Xxx() function */
+ buf_append(&state.decode_fns, "int der_decode_%s(FILE *der, FILE *out, int length)\n", name);
+ buf_append(&state.decode_fns, "{\n");
+ buf_append(&state.decode_fns, "\tint left = length;\n");
+ buf_append(&state.decode_fns, "\tint sublen;\n\n");
+ buf_append(&state.decode_fns, "\tverbose(\"<%s>\\n\");\n\n", name);
+ buf_append(&state.decode_fns, "\t/* ENUMERATED */\n");
+ buf_append(&state.decode_fns, "\tchar *enum_names[] = {\n");
+ for(item=state.items; item; item=item->next)
+ buf_append(&state.decode_fns, "\t\t%s,\n", item->name);
+ buf_append(&state.decode_fns, "\t};\n\n");
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_ENUMERATED(der, out, length, %u, enum_names)) < 0)\n", enum_val);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n\n");
+ /* prototype */
+ buf_append(&state.decode_hdr, "int der_decode_%s(FILE *, FILE *, int);\n", name);
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn MATCH_TAGCLASS(class, number, ASN1TAGCLASS_ENUMERATED);\n");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-08 17:32:04
|
Revision: 458
http://redbutton.svn.sourceforge.net/redbutton/?rev=458&view=rev
Author: skilvington
Date: 2007-11-08 09:31:58 -0800 (Thu, 08 Nov 2007)
Log Message:
-----------
back to where we were before, but with a prettier asn1decode.c
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-11-02 17:24:31 UTC (rev 457)
+++ redbutton-author/trunk/TODO 2007-11-08 17:31:58 UTC (rev 458)
@@ -11,9 +11,8 @@
---
mhegd
-HorizontalJustification doesn't work
-EventTypeEnum does
-ie ENUMERATED types without an explicit ENUMERATED tag don't work
+HorizontalJustification needs writing
+ie ENUMERATED types without an explicit ENUMERATED tag
---
@@ -25,6 +24,7 @@
mhegd
:ContentRef ContentReference keeps the tag as part of the OctetString
+(eg enh_gateway.mhg)
---
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-11-02 17:24:31 UTC (rev 457)
+++ redbutton-author/trunk/ccc.y 2007-11-08 17:31:58 UTC (rev 458)
@@ -825,19 +825,16 @@
/* assert */
if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE && item->type != IT_OPTIONAL)
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
+/* TODO */
/* is it OPTIONAL - check if length == 0, if so bomb out now */
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
- /* if it is ONEORMORE we need a while loop */
- if(item->type == IT_ONEORMORE)
- buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* is it a primitive type */
if(strcmp(item->name, "BOOLEAN") == 0
|| strcmp(item->name, "INTEGER") == 0
|| strcmp(item->name, "OctetString") == 0)
{
/* assert */
- if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
- fatal("Primitive but not Identifier or Identifier+");
+ if(item->type != IT_IDENTIFIER)
+ fatal("Primitive but not Identifier");
/* does it need an extra explicit tag for the primitive type? */
if(asn1tagclass(name) != asn1tagclass(item->name))
{
@@ -850,11 +847,11 @@
{
/* do need an explicit primitive tag */
buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
- buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n\n", name);
buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n", item->name);
buf_append(&state.decode_fns, "\t{\n");
buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
@@ -864,123 +861,79 @@
buf_append(&state.decode_fns, "\t}\n");
}
}
-#if 0
- /* is it an ENUMERATED type */
- else if(asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
+ /* is it an ENUMERATED type which does not need an explicit ENUMERATED tag */
+ else if(asn1tagclass(name) != ASN1TAGCLASS_ENUMERATED
+ && asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
{
/* assert */
if(item->type != IT_IDENTIFIER)
fatal("ENUMERATED but not Identifier");
+/* TODO */
buf_append(&state.decode_fns, "printf(\"TODO: %s->%s\\n\");\nexit(1);\n",name,item->name);
}
-#endif
- /* else the whole length is the sub types value */
- else
+ /* is the whole length one or more sub types */
+ else if(item->type == IT_ONEORMORE)
{
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* decode the item */
- buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
- buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
- /* if it is a synthetic or primitive type, we still need the current tag */
- if(keep_tag(asn1tagclass(item->name)))
- {
- buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
- }
- else
- {
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
- }
- buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\telse\n");
- buf_append(&state.decode_fns, "\t{\n");
- buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
- buf_append(&state.decode_fns, "\t}");
- }
- /* if it is ONEORMORE we need a while loop */
- if(item->type == IT_ONEORMORE)
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\n");
-#if 0
-/* is it OPTIONAL - check if length == 0, if so bomb out now */
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
- /* is it a primitive type */
- if(strcmp(item->name, "OctetString") == 0
- || asn1tagclass(item->name) == ASN1TAGCLASS_BOOLEAN
- || asn1tagclass(item->name) == ASN1TAGCLASS_INTEGER
- || asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
- {
- /* assert */
- if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
- fatal("Primitive but not Identifier");
- /* does it need an extra explicit tag for the primitive type? */
- buf_append(&state.decode_fns, "\tif(ASN1TAGCLASS_%s != ASN1TAGCLASS_%s)\n", name, item->name);
- buf_append(&state.decode_fns, "\t{\n");
- if(asn1tagclass(item->name) != ASN1TAGCLASS_ENUMERATED)
- buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
- else
- buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t}\n");
- buf_append(&state.decode_fns, "\telse\n");
- }
- /* is it ONEORMORE - need a while(left > 0) loop */
- if(item->type == IT_ONEORMORE)
- {
- buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
- /* decode the item */
buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
- buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n\n", name);
+ buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n", item->name);
+ buf_append(&state.decode_fns, "\t\t{\n");
/* if it is a synthetic or primitive type, we still need the current tag */
if(keep_tag(asn1tagclass(item->name)))
{
buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\t\tasn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
- buf_append(&state.decode_fns, "\t\t\tleft -= tag.length;\n");
- buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
- buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
- buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\t}\n");
+ buf_append(&state.decode_fns, "\t\telse\n");
+ buf_append(&state.decode_fns, "\t\t{\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t\t}\n");
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\t}\n");
}
+ /* else the whole length is the sub types value */
else
{
- /* the whole length is the sub types value */
- buf_append(&state.decode_fns, "\t{\n");
/* decode the item */
- buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
- buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n\n", name);
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n", item->name);
+ buf_append(&state.decode_fns, "\t{\n");
/* if it is a synthetic or primitive type, we still need the current tag */
if(keep_tag(asn1tagclass(item->name)))
{
- buf_append(&state.decode_fns, "\t\t\tfseek(der, -sublen, SEEK_CUR);\n");
- buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, length);\n", item->name);
}
else
{
- buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n");
- buf_append(&state.decode_fns, "\t\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
}
- buf_append(&state.decode_fns, "\t\t\tif(sublen < 0)\n");
- buf_append(&state.decode_fns, "\t\t\t\treturn der_error(\"%s\");\n", name);
- buf_append(&state.decode_fns, "\t\t\tleft -= sublen;\n\n");
- buf_append(&state.decode_fns, "\t\t}\n\t\telse\n");
- buf_append(&state.decode_fns, "\t\t{\n\t\t\treturn der_error(\"%s\");\n\t\t}\n", name);
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t}\n");
}
buf_append(&state.decode_fns, "\n");
-#endif
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-11-02 17:24:35
|
Revision: 457
http://redbutton.svn.sourceforge.net/redbutton/?rev=457&view=rev
Author: skilvington
Date: 2007-11-02 10:24:31 -0700 (Fri, 02 Nov 2007)
Log Message:
-----------
try to tidy up asn1decode.c - less working than before
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2007-10-29 17:11:26 UTC (rev 456)
+++ redbutton-author/trunk/TODO 2007-11-02 17:24:31 UTC (rev 457)
@@ -4,6 +4,12 @@
---
+mhegc
+not entirely convinced MovementTable/Movement/TargetElement will be encoded correctly
+should Movement be SYNTHETIC?
+
+---
+
mhegd
HorizontalJustification doesn't work
EventTypeEnum does
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-10-29 17:11:26 UTC (rev 456)
+++ redbutton-author/trunk/ccc.y 2007-11-02 17:24:31 UTC (rev 457)
@@ -827,18 +827,103 @@
fatal("not IDENTIFIER, ONEORMORE or OPTIONAL");
/* is it OPTIONAL - check if length == 0, if so bomb out now */
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\twhile(left > 0)\n\t{\n");
/* is it a primitive type */
if(strcmp(item->name, "BOOLEAN") == 0
|| strcmp(item->name, "INTEGER") == 0
|| strcmp(item->name, "OctetString") == 0)
{
/* assert */
+ if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
+ fatal("Primitive but not Identifier or Identifier+");
+ /* does it need an extra explicit tag for the primitive type? */
+ if(asn1tagclass(name) != asn1tagclass(item->name))
+ {
+ /* no explicit primitive tag */
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tleft -= sublen;\n");
+ }
+ else
+ {
+ /* do need an explicit primitive tag */
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n", item->name);
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, sublen + tag.length)) < 0)\n", item->name);
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t}\n");
+ }
+ }
+#if 0
+ /* is it an ENUMERATED type */
+ else if(asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
+ {
+ /* assert */
if(item->type != IT_IDENTIFIER)
+ fatal("ENUMERATED but not Identifier");
+buf_append(&state.decode_fns, "printf(\"TODO: %s->%s\\n\");\nexit(1);\n",name,item->name);
+ }
+#endif
+ /* else the whole length is the sub types value */
+ else
+ {
+ /* decode the item */
+ buf_append(&state.decode_fns, "\tif((sublen = der_decode_Tag(der, &tag)) < 0)\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\tif(is_%s(tag.class, tag.number))\n\t\t{\n", item->name);
+ /* if it is a synthetic or primitive type, we still need the current tag */
+ if(keep_tag(asn1tagclass(item->name)))
+ {
+ buf_append(&state.decode_fns, "\t\tfseek(der, -sublen, SEEK_CUR);\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, sublen + tag.length);\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
+ buf_append(&state.decode_fns, "\t\tsublen = asn1decode_%s(der, out, tag.length);\n", item->name);
+ }
+ buf_append(&state.decode_fns, "\t\tif(sublen < 0)\n");
+ buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
+ buf_append(&state.decode_fns, "\t\tleft -= sublen;\n\n");
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\telse\n");
+ buf_append(&state.decode_fns, "\t{\n");
+ buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: unexpected tag [%%s %%u]\", asn1class_name(tag.class), tag.number);\n", name);
+ buf_append(&state.decode_fns, "\t}");
+ }
+ /* if it is ONEORMORE we need a while loop */
+ if(item->type == IT_ONEORMORE)
+ buf_append(&state.decode_fns, "\t}\n");
+ buf_append(&state.decode_fns, "\n");
+#if 0
+/* is it OPTIONAL - check if length == 0, if so bomb out now */
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+ /* is it a primitive type */
+ if(strcmp(item->name, "OctetString") == 0
+ || asn1tagclass(item->name) == ASN1TAGCLASS_BOOLEAN
+ || asn1tagclass(item->name) == ASN1TAGCLASS_INTEGER
+ || asn1tagclass(item->name) == ASN1TAGCLASS_ENUMERATED)
+ {
+ /* assert */
+ if(item->type != IT_IDENTIFIER && item->type != IT_ONEORMORE)
fatal("Primitive but not Identifier");
/* does it need an extra explicit tag for the primitive type? */
buf_append(&state.decode_fns, "\tif(ASN1TAGCLASS_%s != ASN1TAGCLASS_%s)\n", name, item->name);
buf_append(&state.decode_fns, "\t{\n");
- buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ if(asn1tagclass(item->name) != ASN1TAGCLASS_ENUMERATED)
+ buf_append(&state.decode_fns, "\t\tif((sublen = der_decode_%s(der, out, length)) < 0)\n", item->name);
+ else
+ buf_append(&state.decode_fns, "\t\tif((sublen = asn1decode_%s(der, out, length)) < 0)\n", item->name);
buf_append(&state.decode_fns, "\t\t\treturn der_error(\"%s\");\n", name);
buf_append(&state.decode_fns, "\t\tleft -= sublen;\n");
buf_append(&state.decode_fns, "\t}\n");
@@ -895,6 +980,7 @@
buf_append(&state.decode_fns, "\t}\n");
}
buf_append(&state.decode_fns, "\n");
+#endif
/* is_Xxx() function */
buf_append(&state.decode_is_fns, "\t\treturn is_%s(class, number);\n", item->name);
/* output any literals at the end */
@@ -1110,8 +1196,8 @@
}
/* end decode_Xxx() function */
- buf_append(&state.decode_fns, "\tif(!is_synthetic(ASN1TAGCLASS_%s))\n", name);
- buf_append(&state.decode_fns, "\t\tfprintf(out, \"\\n\");\n\n");
+ if(!is_synthetic(asn1tagclass(name)))
+ buf_append(&state.decode_fns, "\tfprintf(out, \"\\n\");\n\n");
buf_append(&state.decode_fns, "\tif(left != 0)\n");
buf_append(&state.decode_fns, "\t\treturn der_error(\"%s: %%d bytes left\", left);\n\n", name);
buf_append(&state.decode_fns, "\tverbose(\"</%s>\\n\");\n\n", name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|