redbutton-devel Mailing List for RedButton MHEG Engine (Page 10)
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-09-22 16:55:39
|
Revision: 411
http://redbutton.svn.sourceforge.net/redbutton/?rev=411&view=rev
Author: skilvington
Date: 2007-09-22 09:55:38 -0700 (Sat, 22 Sep 2007)
Log Message:
-----------
the skeleton needed to start generating complete DER objects
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/der_encode.h
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-22 16:49:21 UTC (rev 410)
+++ redbutton-author/trunk/der_encode.c 2007-09-22 16:55:38 UTC (rev 411)
@@ -210,5 +210,20 @@
void
convert_BASE64(unsigned char **out, unsigned int *len, const unsigned char *str)
{
+/* TODO */
+printf("TODO: convert_BASE64\n");
}
+/*
+ * recursively generate the DER tag/length header for the tree of nodes
+ */
+
+unsigned int
+gen_der_header(struct node *n)
+{
+/* TODO */
+printf("TODO: gen_der_header\n");
+
+ return n->hdr_length + n->length;
+}
+
Modified: redbutton-author/trunk/der_encode.h
===================================================================
--- redbutton-author/trunk/der_encode.h 2007-09-22 16:49:21 UTC (rev 410)
+++ redbutton-author/trunk/der_encode.h 2007-09-22 16:55:38 UTC (rev 411)
@@ -5,6 +5,8 @@
#ifndef __DER_ENCODE_H__
#define __DER_ENCODE_H__
+#include "parser.h"
+
#include <stdbool.h>
void der_encode_BOOLEAN(unsigned char **, unsigned int *, bool);
@@ -15,5 +17,7 @@
void convert_QPRINTABLE(unsigned char **, unsigned int *, const unsigned char *);
void convert_BASE64(unsigned char **, unsigned int *, const unsigned char *);
+unsigned int gen_der_header(struct node *);
+
#endif /* __DER_ENCODE_H__ */
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-22 16:49:21 UTC (rev 410)
+++ redbutton-author/trunk/mhegc.c 2007-09-22 16:55:38 UTC (rev 411)
@@ -27,6 +27,7 @@
#include <strings.h>
#include "parser.h"
+#include "der_encode.h"
#include "asn1tag.h"
#include "utils.h"
@@ -44,6 +45,7 @@
int arg;
struct node asn1obj;
unsigned int nerrs;
+ unsigned int filesize;
while((arg = getopt(argc, argv, "v")) != EOF)
{
@@ -94,6 +96,10 @@
print_node(&asn1obj, 0);
}
+ /* create the DER tag/length header for each node */
+ filesize = gen_der_header(&asn1obj);
+ verbose("\nDER Object size: %u bytes\n", filesize);
+
return EXIT_SUCCESS;
}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-22 16:49:21 UTC (rev 410)
+++ redbutton-author/trunk/parser.c.header 2007-09-22 16:55:38 UTC (rev 411)
@@ -46,8 +46,13 @@
/* class is in the top 8 bits, tag is the bottom 24 bits */
child->asn1tag = asn1tagclass & 0xffffff;
child->asn1class = (asn1tagclass >> 24) & 0xff;
+ /* DER tag/length header */
+ child->hdr_length = 0;
+ child->hdr_value = NULL;
+ /* DER value */
child->length = 0;
child->value = NULL;
+ /* the tree of nodes */
child->parent = parent;
child->children = NULL;
child->siblings = NULL;
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-22 16:49:21 UTC (rev 410)
+++ redbutton-author/trunk/parser.h.header 2007-09-22 16:55:38 UTC (rev 411)
@@ -13,6 +13,9 @@
/* DER type */
unsigned int asn1tag; /* ASN1 tag number */
unsigned int asn1class; /* only UNIVERSAL or CONTEXT */
+ /* DER tag/length header */
+ unsigned int hdr_length;
+ unsigned char *hdr_value;
/* DER value */
unsigned int length; /* length of the value data */
unsigned char *value; /* DER encoded value */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-22 16:49:26
|
Revision: 410
http://redbutton.svn.sourceforge.net/redbutton/?rev=410&view=rev
Author: skilvington
Date: 2007-09-22 09:49:21 -0700 (Sat, 22 Sep 2007)
Log Message:
-----------
show the extra text after the definition
Modified Paths:
--------------
redbutton-author/trunk/mhegc.c
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-21 16:26:48 UTC (rev 409)
+++ redbutton-author/trunk/mhegc.c 2007-09-22 16:49:21 UTC (rev 410)
@@ -78,7 +78,7 @@
parse_InterchangedObject(&asn1obj);
if(next_token())
- parse_error("Unexpected text after InterchangedObject");
+ parse_error("Unexpected text '%s' after InterchangedObject", token_text());
/* don't generate an object if there were any errors */
if((nerrs = nparse_errors()) > 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-21 16:26:50
|
Revision: 409
http://redbutton.svn.sourceforge.net/redbutton/?rev=409&view=rev
Author: skilvington
Date: 2007-09-21 09:26:48 -0700 (Fri, 21 Sep 2007)
Log Message:
-----------
make the auto-generated code look beautiful!
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-21 16:17:21 UTC (rev 408)
+++ redbutton-author/trunk/ccc.y 2007-09-21 16:26:48 UTC (rev 409)
@@ -436,8 +436,8 @@
while(item)
{
char *tok_name = unquote(item->name);
- buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
- buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ buf_append(&state.parse_fns, "\n\t/* %s */\n", item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
free(tok_name);
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-09-21 16:17:24
|
Revision: 408
http://redbutton.svn.sourceforge.net/redbutton/?rev=408&view=rev
Author: skilvington
Date: 2007-09-21 09:17:21 -0700 (Fri, 21 Sep 2007)
Log Message:
-----------
use as few bytes as possible to store -ve ints
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-21 15:52:33 UTC (rev 407)
+++ redbutton-author/trunk/der_encode.c 2007-09-21 16:17:21 UTC (rev 408)
@@ -56,15 +56,21 @@
}
else
{
+ /* work with an unsigned value */
+ uval = (unsigned int) val;
/*
- * TODO
- * should really use as few bytes as possible
+ * use as few bytes as possible
* ie chop off leading 0xff's while the next byte has its top bit set
*/
*len = sizeof(unsigned int);
+ while((*len) > 1
+ && ((uval >> (((*len) - 1) * 8)) & 0xff) == 0xff
+ && ((uval >> (((*len) - 2) * 8)) & 0x80) == 0x80)
+ {
+ (*len) --;
+ }
*out = safe_malloc(*len);
/* big endian */
- uval = (unsigned int) val;
for(i=1; i<=(*len); i++)
(*out)[i - 1] = (uval >> (((*len) - i) * 8)) & 0xff;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-21 15:52:37
|
Revision: 407
http://redbutton.svn.sourceforge.net/redbutton/?rev=407&view=rev
Author: skilvington
Date: 2007-09-21 08:52:33 -0700 (Fri, 21 Sep 2007)
Log Message:
-----------
ContentReference has different tags in different places
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/grammar
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-21 12:55:18 UTC (rev 406)
+++ redbutton-author/trunk/asn1tag.h 2007-09-21 15:52:33 UTC (rev 407)
@@ -123,7 +123,7 @@
#define ASN1TAG_ProgramConnectionTag 66
#define ASN1TAG_OriginalValue 67
#define ASN1TAG_ObjectReferenceValue 68
-#define ASN1TAG_ContentReferenceValue 69
+#define ASN1TAG_ContentReference69 69
#define ASN1TAG_MovementTable 70
#define ASN1TAG_TokenGroupItems 71
#define ASN1TAG_NoTokenActionSlots 72
@@ -374,7 +374,7 @@
#define ASN1TAGCLASS_ProgramConnectionTag ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ProgramConnectionTag)
#define ASN1TAGCLASS_OriginalValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalValue)
#define ASN1TAGCLASS_ObjectReferenceValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObjectReferenceValue)
-#define ASN1TAGCLASS_ContentReferenceValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentReferenceValue)
+#define ASN1TAGCLASS_ContentReference69 ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentReference69)
#define ASN1TAGCLASS_MovementTable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MovementTable)
#define ASN1TAGCLASS_TokenGroupItems ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TokenGroupItems)
#define ASN1TAGCLASS_NoTokenActionSlots ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NoTokenActionSlots)
@@ -588,7 +588,7 @@
#define ASN1TAGCLASS_EventType ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_EventData ASN1TAG_CHOICE
#define ASN1TAGCLASS_ObjectReference ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_ContentReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TargetElement ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_AVisible ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Position ASN1TAGCLASS_SEQUENCE
@@ -730,6 +730,8 @@
#define ASN1TAGCLASS_PointList ASN1TAGCLASS_SEQUENCE
/* added by me to get an explicit SEQUENCE under NoTokenActionSlot */
#define ASN1TAGCLASS_ActionClassSeq ASN1TAGCLASS_SEQUENCE
+/* ContentReference is [69] except in ReferencedContent */
+#define ASN1TAGCLASS_ContentReference ASN1TAG_SYNTHETIC
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-09-21 12:55:18 UTC (rev 406)
+++ redbutton-author/trunk/grammar 2007-09-21 15:52:33 UTC (rev 407)
@@ -199,7 +199,7 @@
| ObjectReferenceValue
| ContentReferenceValue .
ObjectReferenceValue ::= ":ObjectRef" ObjectReference .
-ContentReferenceValue ::= ":ContentRef" ContentReference .
+ContentReferenceValue ::= ":ContentRef" ContentReference69 .
// B.4.15 BooleanVariable Class
@@ -905,12 +905,14 @@
ObjectNumber ::= INTEGER .
ContentReference ::= OctetString .
+// srk - ContentReference is [69] except in ReferencedContent
+ContentReference69 ::= OctetString .
GenericObjectReference ::= DirectReference | IndirectReference .
DirectReference ::= ObjectReference .
IndirectReference ::= ":IndirectRef" ObjectReference .
-GenericContentReference ::= ContentReference | IndirectReference .
+GenericContentReference ::= ContentReference69 | IndirectReference .
GenericInteger ::= INTEGER | IndirectReference .
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-21 12:55:22
|
Revision: 406
http://redbutton.svn.sourceforge.net/redbutton/?rev=406&view=rev
Author: skilvington
Date: 2007-09-21 05:55:18 -0700 (Fri, 21 Sep 2007)
Log Message:
-----------
don't generate an object if there were any parsing errors
Modified Paths:
--------------
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/mhegc.c 2007-09-21 12:55:18 UTC (rev 406)
@@ -43,6 +43,7 @@
char *prog_name = argv[0];
int arg;
struct node asn1obj;
+ unsigned int nerrs;
while((arg = getopt(argc, argv, "v")) != EOF)
{
@@ -79,6 +80,10 @@
if(next_token())
parse_error("Unexpected text after InterchangedObject");
+ /* don't generate an object if there were any errors */
+ if((nerrs = nparse_errors()) > 0)
+ fatal("%u parsing error%s", nerrs, (nerrs == 1) ? "" : "s");
+
/* assert */
if(asn1obj.siblings != NULL)
fatal("Top level object has siblings");
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.c.header 2007-09-21 12:55:18 UTC (rev 406)
@@ -10,12 +10,17 @@
* lexer functions we need to provide
*/
-int yylineno = 1;
+unsigned int yylineno = 1;
+unsigned int yynerrs = 0;
void
yyerror(const char *str)
{
fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+
+ yynerrs ++;
+
+ return;
}
int
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.h.header 2007-09-21 12:55:18 UTC (rev 406)
@@ -40,6 +40,7 @@
char *token_text(void);
void parse_error(const char *, ...);
+unsigned int nparse_errors(void);
void verbose(const char *, ...);
void vverbose(const char *, ...);
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.l.footer 2007-09-21 12:55:18 UTC (rev 406)
@@ -87,3 +87,9 @@
return;
}
+unsigned int
+nparse_errors(void)
+{
+ return yynerrs;
+}
+
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.l.header 2007-09-21 12:55:18 UTC (rev 406)
@@ -5,7 +5,8 @@
#include <errno.h>
#include "parser.h"
#include "tokens.h"
-extern int yylineno;
+extern unsigned int yylineno;
+extern unsigned int yynerrs;
%}
%%
\/\/[^\n\r\f]* return COMMENT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-20 16:10:43
|
Revision: 405
http://redbutton.svn.sourceforge.net/redbutton/?rev=405&view=rev
Author: skilvington
Date: 2007-09-20 09:10:41 -0700 (Thu, 20 Sep 2007)
Log Message:
-----------
add a token to the grammar to make ActionClass sequences get tagged correctly
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/asn1type.c
redbutton-author/trunk/grammar
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-20 13:05:06 UTC (rev 404)
+++ redbutton-author/trunk/asn1tag.h 2007-09-20 16:10:41 UTC (rev 405)
@@ -725,9 +725,11 @@
#define ASN1TAGCLASS_ActionSlots ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_InVariables ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_OutVariables ASN1TAGCLASS_SEQUENCE
-#define ASN1TAGCLASS_ActionClass ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_ActionClass ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Parameters ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_PointList ASN1TAGCLASS_SEQUENCE
+/* added by me to get an explicit SEQUENCE under NoTokenActionSlot */
+#define ASN1TAGCLASS_ActionClassSeq ASN1TAGCLASS_SEQUENCE
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/asn1type.c
===================================================================
--- redbutton-author/trunk/asn1type.c 2007-09-20 13:05:06 UTC (rev 404)
+++ redbutton-author/trunk/asn1type.c 2007-09-20 16:10:41 UTC (rev 405)
@@ -212,6 +212,7 @@
MATCH(GetFocusPosition, SEQUENCE)
MATCH(SetFocusPosition, SEQUENCE)
MATCH(OctetString, CHOICE);
+ MATCH(ActionSlotSeq, CHOICE);
fprintf(stderr, "Unknown ASN1 type: %s\n", name);
exit(EXIT_FAILURE);
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-09-20 13:05:06 UTC (rev 404)
+++ redbutton-author/trunk/grammar 2007-09-20 16:10:41 UTC (rev 405)
@@ -250,9 +250,11 @@
AVisible ::= ObjectReference .
ActionSlots ::= ":ActionSlots" "(" ActionSlot+ ")" .
ActionSlot ::= ActionClass | Null .
-NoTokenActionSlots ::= ":NoTokenActionSlots" "(" ActionSlot+ ")" .
+NoTokenActionSlots ::= ":NoTokenActionSlots" "(" ActionSlotSeq+ ")" .
+// srk - to get an explicit SEQUENCE tag under NoTokenActionSlots
+ActionSlotSeq ::= ActionClassSeq | Null .
+ActionClassSeq ::= ActionClass .
-
// B.4.23 ListGroup Class
ListGroupClass ::= "{:ListGroup" TokenGroupBody
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-20 13:05:10
|
Revision: 404
http://redbutton.svn.sourceforge.net/redbutton/?rev=404&view=rev
Author: skilvington
Date: 2007-09-20 06:05:06 -0700 (Thu, 20 Sep 2007)
Log Message:
-----------
clean up comments about synthetic types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-09-20 12:49:08 UTC (rev 403)
+++ redbutton-author/trunk/asn1tag.c 2007-09-20 13:05:06 UTC (rev 404)
@@ -18,8 +18,7 @@
bool
is_synthetic(unsigned int asn1tag)
{
-/* TODO: only need one value for synthetic types (ie no need for separate ASN1TAG_CHOICE etc) */
- return (asn1tag >= ASN1TAG_SYNTHETIC);
+ return (asn1tag == ASN1TAG_SYNTHETIC || asn1tag == ASN1TAG_CHOICE);
}
/*
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-20 12:49:08 UTC (rev 403)
+++ redbutton-author/trunk/asn1tag.h 2007-09-20 13:05:06 UTC (rev 404)
@@ -572,7 +572,7 @@
#define ASN1TAGCLASS_SEQUENCE ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_SEQUENCE)
#define ASN1TAGCLASS_SET ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_SET)
-/* UNIVERSAL ASN1 types in the grammar */
+/* the ASN1 types in the grammar that are not CONTEXT class types */
#define ASN1TAGCLASS_JointIsoItuIdentifier ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_MHEGStandardIdentifier ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_DirectFont ASN1TAGCLASS_OctetString
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-20 12:49:11
|
Revision: 403
http://redbutton.svn.sourceforge.net/redbutton/?rev=403&view=rev
Author: skilvington
Date: 2007-09-20 05:49:08 -0700 (Thu, 20 Sep 2007)
Log Message:
-----------
Don't bother creating synthetic nodes. This means we can easily work out where we need to explicitly tag universal types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/parser.c.header
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-09-20 11:33:30 UTC (rev 402)
+++ redbutton-author/trunk/asn1tag.c 2007-09-20 12:49:08 UTC (rev 403)
@@ -21,3 +21,16 @@
/* TODO: only need one value for synthetic types (ie no need for separate ASN1TAG_CHOICE etc) */
return (asn1tag >= ASN1TAG_SYNTHETIC);
}
+
+/*
+ * returns true if we need an explicit tag for this primitive type
+ */
+
+bool
+needs_tagging(unsigned int asn1tag, unsigned int asn1class)
+{
+ /* only need an explicit tag if we are a choice or a constructed type */
+ return (asn1tag == ASN1TAG_CHOICE)
+ || (asn1class == ASN1CLASS_UNIVERSAL && asn1tag == ASN1TAG_SEQUENCE)
+ || (asn1class == ASN1CLASS_UNIVERSAL && asn1tag == ASN1TAG_SET);
+}
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-20 11:33:30 UTC (rev 402)
+++ redbutton-author/trunk/asn1tag.h 2007-09-20 12:49:08 UTC (rev 403)
@@ -15,6 +15,7 @@
char *asn1class_name(unsigned int);
bool is_synthetic(unsigned int);
+bool needs_tagging(unsigned int, unsigned int);
/*
* a synthetic object created as a result of the grammar definition
@@ -43,9 +44,15 @@
#define ASN1TAGCLASS_LineArtBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TextBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_PushButtonBody ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_OctetString ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_BoxSize ASN1TAG_SYNTHETIC
+/*
+ * this is not the same as an ASN1 OCTET STRING type
+ * rather it a choice about how you define the data in your source file
+ * ie as a STRING, QPRINTABLE or BASE64
+ */
+#define ASN1TAGCLASS_OctetString ASN1TAG_CHOICE
+
/* ASN1 CONTEXT tag values */
#define ASN1TAG_ApplicationClass 0
#define ASN1TAG_SceneClass 1
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-20 11:33:30 UTC (rev 402)
+++ redbutton-author/trunk/parser.c.header 2007-09-20 12:49:08 UTC (rev 403)
@@ -31,8 +31,13 @@
struct node *
add_child(struct node *parent, uint32_t asn1tagclass)
{
- struct node *child = safe_malloc(sizeof(struct node));
+ struct node *child;
+ if(asn1tagclass == ASN1TAG_SYNTHETIC)
+ return parent;
+
+ child = safe_malloc(sizeof(struct node));
+
/* class is in the top 8 bits, tag is the bottom 24 bits */
child->asn1tag = asn1tagclass & 0xffffff;
child->asn1class = (asn1tagclass >> 24) & 0xff;
@@ -88,12 +93,9 @@
verbose("<BOOLEAN value=%s/>\n", token_text());
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_BOOLEAN;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ /* create an explicit UNIVERSAL type if necessary */
+ if(needs_tagging(parent->asn1tag, parent->asn1class))
+ parent = add_child(parent, ASN1TAGCLASS_BOOLEAN);
der_encode_BOOLEAN(&parent->value, &parent->length, strcmp(token_text(), "false"));
@@ -108,12 +110,9 @@
verbose("<INTEGER value=%s/>\n", token_text());
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_INTEGER;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ /* create an explicit UNIVERSAL type if necessary */
+ if(needs_tagging(parent->asn1tag, parent->asn1class))
+ parent = add_child(parent, ASN1TAGCLASS_INTEGER);
der_encode_INTEGER(&parent->value, &parent->length, strtol(token_text(), NULL, 0));
@@ -123,17 +122,14 @@
void parse_OCTETSTRING(struct node *parent)
{
/*
- * give our parent's parent a UNIVERSAL type if it is synthetic
+ * create an explicit UNIVERSAL type if necessary
* need to look at our parent's parent because an OctetString in the grammar
* is a choice between a STRING, a QPRINTABLE or a BASE64
* so our parent will always be a choice node
- * the OCTETSTRING ASN1 type does not have this extra choice parent node
+ * the OCTET STRING ASN1 type does not have this extra choice parent node
*/
- if(is_synthetic(parent->parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_OCTETSTRING;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ if(needs_tagging(parent->parent->asn1tag, parent->parent->asn1class))
+ parent = add_child(parent, ASN1TAGCLASS_OCTETSTRING);
der_encode_OctetString(&parent->value, &parent->length, token_text());
@@ -187,12 +183,9 @@
if(parent->length != 0)
fatal("Null: length=%u", parent->length);
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_NULL;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ /* create an explicit UNIVERSAL type if necessary */
+ if(needs_tagging(parent->asn1tag, parent->asn1class))
+ parent = add_child(parent, ASN1TAGCLASS_NULL);
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-20 11:33:33
|
Revision: 402
http://redbutton.svn.sourceforge.net/redbutton/?rev=402&view=rev
Author: skilvington
Date: 2007-09-20 04:33:30 -0700 (Thu, 20 Sep 2007)
Log Message:
-----------
make sure CONTEXT 68 and 69 are only used in one place
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-19 12:00:20 UTC (rev 401)
+++ redbutton-author/trunk/asn1tag.h 2007-09-20 11:33:30 UTC (rev 402)
@@ -115,8 +115,8 @@
#define ASN1TAG_InitiallyAvailable 65
#define ASN1TAG_ProgramConnectionTag 66
#define ASN1TAG_OriginalValue 67
-#define ASN1TAG_ObjectReference 68
-#define ASN1TAG_ContentReference 69
+#define ASN1TAG_ObjectReferenceValue 68
+#define ASN1TAG_ContentReferenceValue 69
#define ASN1TAG_MovementTable 70
#define ASN1TAG_TokenGroupItems 71
#define ASN1TAG_NoTokenActionSlots 72
@@ -366,8 +366,8 @@
#define ASN1TAGCLASS_InitiallyAvailable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InitiallyAvailable)
#define ASN1TAGCLASS_ProgramConnectionTag ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ProgramConnectionTag)
#define ASN1TAGCLASS_OriginalValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalValue)
-#define ASN1TAGCLASS_ObjectReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObjectReference)
-#define ASN1TAGCLASS_ContentReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentReference)
+#define ASN1TAGCLASS_ObjectReferenceValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObjectReferenceValue)
+#define ASN1TAGCLASS_ContentReferenceValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentReferenceValue)
#define ASN1TAGCLASS_MovementTable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MovementTable)
#define ASN1TAGCLASS_TokenGroupItems ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TokenGroupItems)
#define ASN1TAGCLASS_NoTokenActionSlots ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NoTokenActionSlots)
@@ -580,8 +580,8 @@
#define ASN1TAGCLASS_EventSource ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_EventType ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_EventData ASN1TAG_CHOICE
-#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ObjectReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ContentReference ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TargetElement ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_AVisible ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Position ASN1TAGCLASS_SEQUENCE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-19 12:00:21
|
Revision: 401
http://redbutton.svn.sourceforge.net/redbutton/?rev=401&view=rev
Author: skilvington
Date: 2007-09-19 05:00:20 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
remove some of the extraneous SEQUENCEs - need to look at the rest
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-19 11:47:16 UTC (rev 400)
+++ redbutton-author/trunk/asn1tag.h 2007-09-19 12:00:20 UTC (rev 401)
@@ -44,6 +44,7 @@
#define ASN1TAGCLASS_TextBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_PushButtonBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_OctetString ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_BoxSize ASN1TAG_SYNTHETIC
/* ASN1 CONTEXT tag values */
#define ASN1TAG_ApplicationClass 0
@@ -584,7 +585,6 @@
#define ASN1TAGCLASS_TargetElement ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_AVisible ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Position ASN1TAGCLASS_SEQUENCE
-#define ASN1TAGCLASS_BoxSize ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_XLength ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_YLength ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_SYNTHETIC
@@ -707,7 +707,7 @@
#define ASN1TAGCLASS_XPosition ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_YPosition ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_ReferencedContent ASN1TAGCLASS_SEQUENCE
-#define ASN1TAGCLASS_XYPosition ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_XYPosition ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Point ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_Rational ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_ExternalReference ASN1TAGCLASS_SEQUENCE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-19 11:47:19
|
Revision: 400
http://redbutton.svn.sourceforge.net/redbutton/?rev=400&view=rev
Author: skilvington
Date: 2007-09-19 04:47:16 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
OctetString nodes need to look at their parent's parent to decide whether to set the tag or not
Modified Paths:
--------------
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-18 19:52:00 UTC (rev 399)
+++ redbutton-author/trunk/parser.c.header 2007-09-19 11:47:16 UTC (rev 400)
@@ -38,6 +38,7 @@
child->asn1class = (asn1tagclass >> 24) & 0xff;
child->length = 0;
child->value = NULL;
+ child->parent = parent;
child->children = NULL;
child->siblings = NULL;
@@ -119,15 +120,16 @@
return;
}
-void parse_STRING(struct node *parent)
+void parse_OCTETSTRING(struct node *parent)
{
- if(next_token() != STRING)
- parse_error("Unexpected token '%s'; expecting \"STRING\"", token_text());
-
- verbose("<STRING value=%s/>\n", token_text());
-
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
+ /*
+ * give our parent's parent a UNIVERSAL type if it is synthetic
+ * need to look at our parent's parent because an OctetString in the grammar
+ * is a choice between a STRING, a QPRINTABLE or a BASE64
+ * so our parent will always be a choice node
+ * the OCTETSTRING ASN1 type does not have this extra choice parent node
+ */
+ if(is_synthetic(parent->parent->asn1tag))
{
parent->asn1tag = ASN1TAG_OCTETSTRING;
parent->asn1class = ASN1CLASS_UNIVERSAL;
@@ -138,7 +140,18 @@
return;
}
+void parse_STRING(struct node *parent)
+{
+ if(next_token() != STRING)
+ parse_error("Unexpected token '%s'; expecting \"STRING\"", token_text());
+ verbose("<STRING value=%s/>\n", token_text());
+
+ parse_OCTETSTRING(parent);
+
+ return;
+}
+
void parse_QPRINTABLE(struct node *parent)
{
if(next_token() != QPRINTABLE)
@@ -146,19 +159,11 @@
verbose("<QPRINTABLE value=%s/>\n", token_text());
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_OCTETSTRING;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ parse_OCTETSTRING(parent);
- der_encode_OctetString(&parent->value, &parent->length, token_text());
-
return;
}
-
void parse_BASE64(struct node *parent)
{
if(next_token() != BASE64)
@@ -166,19 +171,11 @@
verbose("<BASE64 value=%s/>\n", token_text());
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_OCTETSTRING;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ parse_OCTETSTRING(parent);
- der_encode_OctetString(&parent->value, &parent->length, token_text());
-
return;
}
-
void parse_Null(struct node *parent)
{
if(next_token() != Null)
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-18 19:52:00 UTC (rev 399)
+++ redbutton-author/trunk/parser.h.header 2007-09-19 11:47:16 UTC (rev 400)
@@ -17,6 +17,7 @@
unsigned int length; /* length of the value data */
unsigned char *value; /* DER encoded value */
/* a tree of nodes */
+ struct node *parent; /* NULL if we are the top */
struct node *children; /* NULL if not a constructed type */
struct node *siblings; /* linked list of children */
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 19:52:01
|
Revision: 399
http://redbutton.svn.sourceforge.net/redbutton/?rev=399&view=rev
Author: skilvington
Date: 2007-09-18 12:52:00 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
an OctetString in the grammar is different than an ASN1 OCTETSTRING type
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/parser.c.header
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-18 16:42:05 UTC (rev 398)
+++ redbutton-author/trunk/asn1tag.h 2007-09-18 19:52:00 UTC (rev 399)
@@ -43,6 +43,7 @@
#define ASN1TAGCLASS_LineArtBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TextBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_PushButtonBody ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OctetString ASN1TAG_SYNTHETIC
/* ASN1 CONTEXT tag values */
#define ASN1TAG_ApplicationClass 0
@@ -549,16 +550,16 @@
/* ASN1 UNIVERSAL tag values */
#define ASN1TAG_BOOLEAN 1
#define ASN1TAG_INTEGER 2
-#define ASN1TAG_OctetString 4
-#define ASN1TAG_Null 5
+#define ASN1TAG_OCTETSTRING 4
+#define ASN1TAG_NULL 5
#define ASN1TAG_ENUMERATED 10
#define ASN1TAG_SEQUENCE 16
#define ASN1TAG_SET 17
/* and with the class included */
#define ASN1TAGCLASS_BOOLEAN ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_BOOLEAN)
#define ASN1TAGCLASS_INTEGER ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_INTEGER)
-#define ASN1TAGCLASS_OctetString ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_OctetString)
-#define ASN1TAGCLASS_Null ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_Null)
+#define ASN1TAGCLASS_OCTETSTRING ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_OCTETSTRING)
+#define ASN1TAGCLASS_NULL ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_NULL)
#define ASN1TAGCLASS_ENUMERATED ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_ENUMERATED)
#define ASN1TAGCLASS_SEQUENCE ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_SEQUENCE)
#define ASN1TAGCLASS_SET ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_SET)
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-18 16:42:05 UTC (rev 398)
+++ redbutton-author/trunk/parser.c.header 2007-09-18 19:52:00 UTC (rev 399)
@@ -129,7 +129,7 @@
/* give our parent a UNIVERSAL type if it is synthetic */
if(is_synthetic(parent->asn1tag))
{
- parent->asn1tag = ASN1TAG_OctetString;
+ parent->asn1tag = ASN1TAG_OCTETSTRING;
parent->asn1class = ASN1CLASS_UNIVERSAL;
}
@@ -149,7 +149,7 @@
/* give our parent a UNIVERSAL type if it is synthetic */
if(is_synthetic(parent->asn1tag))
{
- parent->asn1tag = ASN1TAG_OctetString;
+ parent->asn1tag = ASN1TAG_OCTETSTRING;
parent->asn1class = ASN1CLASS_UNIVERSAL;
}
@@ -169,7 +169,7 @@
/* give our parent a UNIVERSAL type if it is synthetic */
if(is_synthetic(parent->asn1tag))
{
- parent->asn1tag = ASN1TAG_OctetString;
+ parent->asn1tag = ASN1TAG_OCTETSTRING;
parent->asn1class = ASN1CLASS_UNIVERSAL;
}
@@ -193,7 +193,7 @@
/* give our parent a UNIVERSAL type if it is synthetic */
if(is_synthetic(parent->asn1tag))
{
- parent->asn1tag = ASN1TAG_Null;
+ parent->asn1tag = ASN1TAG_NULL;
parent->asn1class = ASN1CLASS_UNIVERSAL;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 16:42:53
|
Revision: 398
http://redbutton.svn.sourceforge.net/redbutton/?rev=398&view=rev
Author: skilvington
Date: 2007-09-18 09:42:05 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
DER encode -ve INTEGERs the lazy way
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 16:29:48 UTC (rev 397)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 16:42:05 UTC (rev 398)
@@ -28,20 +28,22 @@
{
unsigned int shifted;
unsigned int i;
+ unsigned int uval;
/* assert */
if(*out != NULL || *len != 0)
fatal("der_encode_INTEGER: length already %u", *len);
- /*
- * work out how many bytes we need to store 'val'
- * ints in DER are signed, so first byte we store must be <= 127
- * we add a leading 0 if first byte is > 127
- */
+ /* is it +ve or -ve */
if(val >= 0)
{
+ /*
+ * work out how many bytes we need to store 'val'
+ * ints in DER are signed, so first byte we store must be <= 127
+ * we add a leading 0 if first byte is > 127
+ */
shifted = val;
- (*len) = 1;
+ *len = 1;
while(shifted > 127)
{
(*len) ++;
@@ -54,7 +56,17 @@
}
else
{
-fatal("TODO: negative INTEGER: %d", val);
+ /*
+ * TODO
+ * should really use as few bytes as possible
+ * ie chop off leading 0xff's while the next byte has its top bit set
+ */
+ *len = sizeof(unsigned int);
+ *out = safe_malloc(*len);
+ /* big endian */
+ uval = (unsigned int) val;
+ for(i=1; i<=(*len); i++)
+ (*out)[i - 1] = (uval >> (((*len) - i) * 8)) & 0xff;
}
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 16:29:53
|
Revision: 397
http://redbutton.svn.sourceforge.net/redbutton/?rev=397&view=rev
Author: skilvington
Date: 2007-09-18 09:29:48 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
DER encode BOOLEAN
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 16:23:06 UTC (rev 396)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 16:29:48 UTC (rev 397)
@@ -16,6 +16,10 @@
if(*out != NULL || *len != 0)
fatal("der_encode_BOOLEAN: length already %u", *len);
+ *len = 1;
+ *out = safe_malloc(1);
+ (*out)[0] = val ? 1 : 0;
+
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 16:23:12
|
Revision: 396
http://redbutton.svn.sourceforge.net/redbutton/?rev=396&view=rev
Author: skilvington
Date: 2007-09-18 09:23:06 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
ENUMERATED, SEQUENCE and SET are not synthetic 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-09-18 13:02:58 UTC (rev 395)
+++ redbutton-author/trunk/asn1tag.h 2007-09-18 16:23:06 UTC (rev 396)
@@ -24,11 +24,6 @@
#define ASN1TAG_SYNTHETIC 10000
/* the tag for CHOICE types is determined by which choice we choose */
#define ASN1TAG_CHOICE 10001
-/* ENUMERATED types are encoded as INTEGERs */
-#define ASN1TAG_ENUMERATED 10002
-/* SEQUENCEs and SETs are just used to group their children together */
-#define ASN1TAG_SEQUENCE 10003
-#define ASN1TAG_SET 10004
/* abstract types */
#define ASN1TAGCLASS_Root ASN1TAG_SYNTHETIC
@@ -556,11 +551,17 @@
#define ASN1TAG_INTEGER 2
#define ASN1TAG_OctetString 4
#define ASN1TAG_Null 5
+#define ASN1TAG_ENUMERATED 10
+#define ASN1TAG_SEQUENCE 16
+#define ASN1TAG_SET 17
/* and with the class included */
#define ASN1TAGCLASS_BOOLEAN ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_BOOLEAN)
#define ASN1TAGCLASS_INTEGER ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_INTEGER)
#define ASN1TAGCLASS_OctetString ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_OctetString)
#define ASN1TAGCLASS_Null ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_Null)
+#define ASN1TAGCLASS_ENUMERATED ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_ENUMERATED)
+#define ASN1TAGCLASS_SEQUENCE ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_SEQUENCE)
+#define ASN1TAGCLASS_SET ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_SET)
/* UNIVERSAL ASN1 types in the grammar */
#define ASN1TAGCLASS_JointIsoItuIdentifier ASN1TAGCLASS_INTEGER
@@ -575,14 +576,14 @@
#define ASN1TAGCLASS_SceneWeight ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_IncludedContent ASN1TAGCLASS_OctetString
#define ASN1TAGCLASS_EventSource ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_EventType ASN1TAG_ENUMERATED
+#define ASN1TAGCLASS_EventType ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_EventData ASN1TAG_CHOICE
#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TargetElement ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_AVisible ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_Position ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_BoxSize ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Position ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_BoxSize ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_XLength ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_YLength ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_SYNTHETIC
@@ -599,7 +600,7 @@
#define ASN1TAGCLASS_EllipseHeight ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_EllipseWidth ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_EmulatedEventSource ASN1TAG_SYNTHETIC
-#define ASN1TAGCLASS_EmulatedEventType ASN1TAG_ENUMERATED
+#define ASN1TAGCLASS_EmulatedEventType ASN1TAGCLASS_ENUMERATED
#define ASN1TAGCLASS_EntryPointVar ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_ForkSucceeded ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Feature ASN1TAG_SYNTHETIC
@@ -704,21 +705,21 @@
#define ASN1TAGCLASS_AbsoluteColour ASN1TAGCLASS_OctetString
#define ASN1TAGCLASS_XPosition ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_YPosition ASN1TAGCLASS_INTEGER
-#define ASN1TAGCLASS_ReferencedContent ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_XYPosition ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_Point ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_Rational ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_ExternalReference ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_NextScene ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_ReferencedContent ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_XYPosition ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_Point ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_Rational ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_ExternalReference ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_NewReferencedContent ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_NextScene ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_TokenGroupItem ASN1TAGCLASS_SEQUENCE
#define ASN1TAGCLASS_Movement ASN1TAGCLASS_INTEGER
-#define ASN1TAGCLASS_ActionSlots ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_InVariables ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_OutVariables ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_ActionClass ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_Parameters ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_PointList ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_ActionSlots ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_InVariables ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_OutVariables ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_ActionClass ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_Parameters ASN1TAGCLASS_SEQUENCE
+#define ASN1TAGCLASS_PointList ASN1TAGCLASS_SEQUENCE
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-18 13:02:58 UTC (rev 395)
+++ redbutton-author/trunk/ccc.y 2007-09-18 16:23:06 UTC (rev 396)
@@ -459,12 +459,11 @@
/* assert */
if(state.and_items)
fatal("CHOICE or ENUMERATED type, but and_items set");
-/* TODO: these can probably both be ASN1TAGCLASS_SYNTHETIC */
/* add a child ASN1 object */
if(asn1type(name) == ASN1TYPE_CHOICE)
buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_CHOICE);\n\n");
- else
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_ENUMERATED);\n\n");
+// else
+// buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_ENUMERATED);\n\n");
/* peek at the next token */
buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
buf_append(&state.parse_fns, "\t/* CHOICE or ENUMERATED */\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 13:02:59
|
Revision: 395
http://redbutton.svn.sourceforge.net/redbutton/?rev=395&view=rev
Author: skilvington
Date: 2007-09-18 06:02:58 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
resolve synthetic types where needed
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/parser.c.header
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-18 12:55:32 UTC (rev 394)
+++ redbutton-author/trunk/asn1tag.h 2007-09-18 13:02:58 UTC (rev 395)
@@ -555,10 +555,12 @@
#define ASN1TAG_BOOLEAN 1
#define ASN1TAG_INTEGER 2
#define ASN1TAG_OctetString 4
+#define ASN1TAG_Null 5
/* and with the class included */
#define ASN1TAGCLASS_BOOLEAN ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_BOOLEAN)
#define ASN1TAGCLASS_INTEGER ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_INTEGER)
#define ASN1TAGCLASS_OctetString ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_OctetString)
+#define ASN1TAGCLASS_Null ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_Null)
/* UNIVERSAL ASN1 types in the grammar */
#define ASN1TAGCLASS_JointIsoItuIdentifier ASN1TAGCLASS_INTEGER
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-18 12:55:32 UTC (rev 394)
+++ redbutton-author/trunk/parser.c.header 2007-09-18 13:02:58 UTC (rev 395)
@@ -87,6 +87,13 @@
verbose("<BOOLEAN value=%s/>\n", token_text());
+ /* give our parent a UNIVERSAL type if it is synthetic */
+ if(is_synthetic(parent->asn1tag))
+ {
+ parent->asn1tag = ASN1TAG_BOOLEAN;
+ parent->asn1class = ASN1CLASS_UNIVERSAL;
+ }
+
der_encode_BOOLEAN(&parent->value, &parent->length, strcmp(token_text(), "false"));
return;
@@ -100,6 +107,13 @@
verbose("<INTEGER value=%s/>\n", token_text());
+ /* give our parent a UNIVERSAL type if it is synthetic */
+ if(is_synthetic(parent->asn1tag))
+ {
+ parent->asn1tag = ASN1TAG_INTEGER;
+ parent->asn1class = ASN1CLASS_UNIVERSAL;
+ }
+
der_encode_INTEGER(&parent->value, &parent->length, strtol(token_text(), NULL, 0));
return;
@@ -112,6 +126,13 @@
verbose("<STRING value=%s/>\n", token_text());
+ /* give our parent a UNIVERSAL type if it is synthetic */
+ if(is_synthetic(parent->asn1tag))
+ {
+ parent->asn1tag = ASN1TAG_OctetString;
+ parent->asn1class = ASN1CLASS_UNIVERSAL;
+ }
+
der_encode_OctetString(&parent->value, &parent->length, token_text());
return;
@@ -125,6 +146,13 @@
verbose("<QPRINTABLE value=%s/>\n", token_text());
+ /* give our parent a UNIVERSAL type if it is synthetic */
+ if(is_synthetic(parent->asn1tag))
+ {
+ parent->asn1tag = ASN1TAG_OctetString;
+ parent->asn1class = ASN1CLASS_UNIVERSAL;
+ }
+
der_encode_OctetString(&parent->value, &parent->length, token_text());
return;
@@ -138,6 +166,13 @@
verbose("<BASE64 value=%s/>\n", token_text());
+ /* give our parent a UNIVERSAL type if it is synthetic */
+ if(is_synthetic(parent->asn1tag))
+ {
+ parent->asn1tag = ASN1TAG_OctetString;
+ parent->asn1class = ASN1CLASS_UNIVERSAL;
+ }
+
der_encode_OctetString(&parent->value, &parent->length, token_text());
return;
@@ -155,6 +190,13 @@
if(parent->length != 0)
fatal("Null: length=%u", parent->length);
+ /* give our parent a UNIVERSAL type if it is synthetic */
+ if(is_synthetic(parent->asn1tag))
+ {
+ parent->asn1tag = ASN1TAG_Null;
+ parent->asn1class = ASN1CLASS_UNIVERSAL;
+ }
+
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 12:55:38
|
Revision: 394
http://redbutton.svn.sourceforge.net/redbutton/?rev=394&view=rev
Author: skilvington
Date: 2007-09-18 05:55:32 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
DER encode +ve INTEGERs
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 12:36:39 UTC (rev 393)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 12:55:32 UTC (rev 394)
@@ -22,10 +22,37 @@
void
der_encode_INTEGER(unsigned char **out, unsigned int *len, int val)
{
+ unsigned int shifted;
+ unsigned int i;
+
/* assert */
if(*out != NULL || *len != 0)
fatal("der_encode_INTEGER: length already %u", *len);
+ /*
+ * work out how many bytes we need to store 'val'
+ * ints in DER are signed, so first byte we store must be <= 127
+ * we add a leading 0 if first byte is > 127
+ */
+ if(val >= 0)
+ {
+ shifted = val;
+ (*len) = 1;
+ while(shifted > 127)
+ {
+ (*len) ++;
+ shifted >>= 8;
+ }
+ *out = safe_malloc(*len);
+ /* big endian */
+ for(i=1; i<=(*len); i++)
+ (*out)[i - 1] = (val >> (((*len) - i) * 8)) & 0xff;
+ }
+ else
+ {
+fatal("TODO: negative INTEGER: %d", val);
+ }
+
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 12:36:41
|
Revision: 393
http://redbutton.svn.sourceforge.net/redbutton/?rev=393&view=rev
Author: skilvington
Date: 2007-09-18 05:36:39 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
convert QPRINTABLEs to OctetStrings
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/der_encode.h
redbutton-author/trunk/utils.c
redbutton-author/trunk/utils.h
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 12:36:39 UTC (rev 393)
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <string.h>
+#include <ctype.h>
#include "der_encode.h"
#include "utils.h"
@@ -29,7 +30,7 @@
}
void
-der_encode_OctetString(unsigned char **out, unsigned int *len, const char *str)
+der_encode_OctetString(unsigned char **out, unsigned int *len, const unsigned char *str)
{
/* assert */
if(*out != NULL || *len != 0)
@@ -55,9 +56,9 @@
*/
void
-convert_STRING(unsigned char **out, unsigned int *len, const char *str)
+convert_STRING(unsigned char **out, unsigned int *len, const unsigned char *str)
{
- unsigned char *whole_str = str;
+ const unsigned char *whole_str = str;
unsigned char *p;
/* max size it could be */
@@ -92,6 +93,7 @@
}
else
{
+ /* TODO: show the line number */
fatal("Invalid escape sequence in STRING: %s", whole_str);
}
}
@@ -106,13 +108,58 @@
return;
}
+/*
+ * string is enclosed in '
+ * encoded as specified in RFC 1521 (MIME)
+ * in addition, ' is encoded as =27
+ * and line breaks do not need to be converted to CRLF
+ */
+
void
-convert_QPRINTABLE(unsigned char **out, unsigned int *len, const char *str)
+convert_QPRINTABLE(unsigned char **out, unsigned int *len, const unsigned char *str)
{
+ const unsigned char *whole_str = str;
+ unsigned char *p;
+
+ /* max size it could be */
+ *out = safe_malloc(strlen(str));
+
+ /* skip the initial ' */
+ str ++;
+ p = *out;
+ while(*str != '\'')
+ {
+ if(*str != '=')
+ {
+ *p = *str;
+ p ++;
+ str ++;
+ }
+ else if(isxdigit(*(str + 1)) && isxdigit(*(str + 2)))
+ {
+ *p = char2hex(*(str + 1)) << 4 | char2hex(*(str + 2));
+ p ++;
+ str += 3;
+ }
+ else
+ {
+ /* TODO: show the line number */
+ fatal("Invalid escape sequence in QPRINTABLE: %s", whole_str);
+ }
+ }
+
+ /* check we got to the closing quote */
+ if(*(str + 1) != '\0')
+ fatal("Unquoted ' in QPRINTABLE: %s", whole_str);
+
+ /* return the length (note: no \0 terminator) */
+ *len = (p - *out);
+
+ return;
}
void
-convert_BASE64(unsigned char **out, unsigned int *len, const char *str)
+convert_BASE64(unsigned char **out, unsigned int *len, const unsigned char *str)
{
}
Modified: redbutton-author/trunk/der_encode.h
===================================================================
--- redbutton-author/trunk/der_encode.h 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/der_encode.h 2007-09-18 12:36:39 UTC (rev 393)
@@ -9,11 +9,11 @@
void der_encode_BOOLEAN(unsigned char **, unsigned int *, bool);
void der_encode_INTEGER(unsigned char **, unsigned int *, int);
-void der_encode_OctetString(unsigned char **, unsigned int *, const char *);
+void der_encode_OctetString(unsigned char **, unsigned int *, const unsigned char *);
-void convert_STRING(unsigned char **, unsigned int *, const char *);
-void convert_QPRINTABLE(unsigned char **, unsigned int *, const char *);
-void convert_BASE64(unsigned char **, unsigned int *, const char *);
+void convert_STRING(unsigned char **, unsigned int *, const unsigned char *);
+void convert_QPRINTABLE(unsigned char **, unsigned int *, const unsigned char *);
+void convert_BASE64(unsigned char **, unsigned int *, const unsigned char *);
#endif /* __DER_ENCODE_H__ */
Modified: redbutton-author/trunk/utils.c
===================================================================
--- redbutton-author/trunk/utils.c 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/utils.c 2007-09-18 12:36:39 UTC (rev 393)
@@ -28,6 +28,21 @@
#include "utils.h"
/*
+ * returns 15 for 'f' etc
+ */
+
+unsigned int
+char2hex(unsigned char c)
+{
+ if(!isxdigit(c))
+ return 0;
+ else if(c >= '0' && c <= '9')
+ return c - '0';
+ else
+ return 10 + (tolower(c) - 'a');
+}
+
+/*
* I don't want to double the size of my code just to deal with malloc failures
* if you've run out of memory you're fscked anyway, me trying to recover is not gonna help...
*/
Modified: redbutton-author/trunk/utils.h
===================================================================
--- redbutton-author/trunk/utils.h 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/utils.h 2007-09-18 12:36:39 UTC (rev 393)
@@ -27,6 +27,8 @@
#include <stdarg.h>
#include <stdio.h>
+unsigned int char2hex(unsigned char);
+
void *safe_malloc(size_t);
void *safe_realloc(void *, size_t);
void safe_free(void *);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 12:18:15
|
Revision: 392
http://redbutton.svn.sourceforge.net/redbutton/?rev=392&view=rev
Author: skilvington
Date: 2007-09-18 05:18:13 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
STRING is only allowed to contain chars 0x20 to 0x7e
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 12:12:11 UTC (rev 391)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 12:18:13 UTC (rev 392)
@@ -50,12 +50,14 @@
/*
* string is enclosed in "
+ * contains chars 0x20 to 0x7e
* " and \ within the string are encoded as \" and \\
*/
void
convert_STRING(unsigned char **out, unsigned int *len, const char *str)
{
+ unsigned char *whole_str = str;
unsigned char *p;
/* max size it could be */
@@ -66,8 +68,12 @@
p = *out;
while(*str != '"')
{
- if(*str != '\\')
+ if(*str < 0x20 || *str > 0x7e)
{
+ fatal("Invalid character (0x%02x) in STRING: %s", *str, whole_str);
+ }
+ else if(*str != '\\')
+ {
*p = *str;
p ++;
str ++;
@@ -86,13 +92,13 @@
}
else
{
- fatal("Invalid escape sequence in STRING: %s", str - 1);
+ fatal("Invalid escape sequence in STRING: %s", whole_str);
}
}
/* check we got to the closing quote */
if(*(str + 1) != '\0')
- fatal("Unquoted \" in STRING: %s", str - 1);
+ fatal("Unquoted \" in STRING: %s", whole_str);
/* return the length (note: no \0 terminator) */
*len = (p - *out);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 12:12:12
|
Revision: 391
http://redbutton.svn.sourceforge.net/redbutton/?rev=391&view=rev
Author: skilvington
Date: 2007-09-18 05:12:11 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
convert STRINGs to OctetStrings
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/der_encode.h
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 11:57:45 UTC (rev 390)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 12:12:11 UTC (rev 391)
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <string.h>
+#include "der_encode.h"
#include "utils.h"
void
@@ -35,11 +36,77 @@
fatal("der_encode_OctetString: length already %u", *len);
/* convert the STRING, QPRINTABLE or BASE64 data to an OctetString */
-/* TODO: fixme */
-*len = strlen(str) + 1;
-*out=safe_malloc(*len);
-strcpy(*out,str);
+ if(*str == '"')
+ convert_STRING(out, len, str);
+ else if(*str == '\'')
+ convert_QPRINTABLE(out, len, str);
+ else if(*str == '`')
+ convert_BASE64(out, len, str);
+ else
+ fatal("der_encode_OctetString: str[0]=0x%02x", *str);
return;
}
+/*
+ * string is enclosed in "
+ * " and \ within the string are encoded as \" and \\
+ */
+
+void
+convert_STRING(unsigned char **out, unsigned int *len, const char *str)
+{
+ unsigned char *p;
+
+ /* max size it could be */
+ *out = safe_malloc(strlen(str));
+
+ /* skip the initial " */
+ str ++;
+ p = *out;
+ while(*str != '"')
+ {
+ if(*str != '\\')
+ {
+ *p = *str;
+ p ++;
+ str ++;
+ }
+ else if(*(str + 1) == '"')
+ {
+ *p = '"';
+ p ++;
+ str += 2;
+ }
+ else if(*(str + 1) == '\\')
+ {
+ *p = '\\';
+ p ++;
+ str += 2;
+ }
+ else
+ {
+ fatal("Invalid escape sequence in STRING: %s", str - 1);
+ }
+ }
+
+ /* check we got to the closing quote */
+ if(*(str + 1) != '\0')
+ fatal("Unquoted \" in STRING: %s", str - 1);
+
+ /* return the length (note: no \0 terminator) */
+ *len = (p - *out);
+
+ return;
+}
+
+void
+convert_QPRINTABLE(unsigned char **out, unsigned int *len, const char *str)
+{
+}
+
+void
+convert_BASE64(unsigned char **out, unsigned int *len, const char *str)
+{
+}
+
Modified: redbutton-author/trunk/der_encode.h
===================================================================
--- redbutton-author/trunk/der_encode.h 2007-09-18 11:57:45 UTC (rev 390)
+++ redbutton-author/trunk/der_encode.h 2007-09-18 12:12:11 UTC (rev 391)
@@ -11,5 +11,9 @@
void der_encode_INTEGER(unsigned char **, unsigned int *, int);
void der_encode_OctetString(unsigned char **, unsigned int *, const char *);
+void convert_STRING(unsigned char **, unsigned int *, const char *);
+void convert_QPRINTABLE(unsigned char **, unsigned int *, const char *);
+void convert_BASE64(unsigned char **, unsigned int *, const char *);
+
#endif /* __DER_ENCODE_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 11:57:46
|
Revision: 390
http://redbutton.svn.sourceforge.net/redbutton/?rev=390&view=rev
Author: skilvington
Date: 2007-09-18 04:57:45 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
dump the value of ASN1 objects in -v/-vv mode
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/utils.c
redbutton-author/trunk/utils.h
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 11:57:45 UTC (rev 390)
@@ -3,6 +3,7 @@
*/
#include <stdbool.h>
+#include <string.h>
#include "utils.h"
@@ -33,6 +34,12 @@
if(*out != NULL || *len != 0)
fatal("der_encode_OctetString: length already %u", *len);
+ /* convert the STRING, QPRINTABLE or BASE64 data to an OctetString */
+/* TODO: fixme */
+*len = strlen(str) + 1;
+*out=safe_malloc(*len);
+strcpy(*out,str);
+
return;
}
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/mhegc.c 2007-09-18 11:57:45 UTC (rev 390)
@@ -121,12 +121,12 @@
}
}
- if(show_kids)
- {
- for(kid=n->children; kid; kid=kid->siblings)
- print_node(kid, indent);
- }
+ if(n->length > 0)
+ hexdump(stderr, n->value, n->length);
+ for(kid=n->children; kid; kid=kid->siblings)
+ print_node(kid, indent);
+
if(show_node && show_kids)
{
indent --;
Modified: redbutton-author/trunk/utils.c
===================================================================
--- redbutton-author/trunk/utils.c 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/utils.c 2007-09-18 11:57:45 UTC (rev 390)
@@ -104,7 +104,7 @@
#define HEXDUMP_WIDTH 16
void
-hexdump(unsigned char *data, size_t nbytes)
+hexdump(FILE *out, unsigned char *data, size_t nbytes)
{
size_t nout;
int i;
@@ -114,16 +114,16 @@
{
/* byte offset at start of line */
if((nout % HEXDUMP_WIDTH) == 0)
- printf("0x%.8x ", nout);
+ fprintf(out, "0x%.8x ", nout);
/* the byte value in hex */
- printf("%.2x ", data[nout]);
+ fprintf(out, "%.2x ", data[nout]);
/* the ascii equivalent at the end of the line */
if((nout % HEXDUMP_WIDTH) == (HEXDUMP_WIDTH - 1))
{
- printf(" ");
+ fprintf(out, " ");
for(i=HEXDUMP_WIDTH-1; i>=0; i--)
- printf("%c", isprint(data[nout - i]) ? data[nout - i] : '.');
- printf("\n");
+ fprintf(out, "%c", isprint(data[nout - i]) ? data[nout - i] : '.');
+ fprintf(out, "\n");
}
nout ++;
}
@@ -133,13 +133,13 @@
{
/* pad to the start of the ascii equivalent */
for(i=(nout % HEXDUMP_WIDTH); i<HEXDUMP_WIDTH; i++)
- printf(" ");
- printf(" ");
+ fprintf(out, " ");
+ fprintf(out, " ");
/* print the ascii equivalent */
nout --;
for(i=(nout % HEXDUMP_WIDTH); i>=0; i--)
- printf("%c", isprint(data[nout - i]) ? data[nout - i] : '.');
- printf("\n");
+ fprintf(out, "%c", isprint(data[nout - i]) ? data[nout - i] : '.');
+ fprintf(out, "\n");
}
return;
Modified: redbutton-author/trunk/utils.h
===================================================================
--- redbutton-author/trunk/utils.h 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/utils.h 2007-09-18 11:57:45 UTC (rev 390)
@@ -25,12 +25,13 @@
#include <stdlib.h>
#include <stdarg.h>
+#include <stdio.h>
void *safe_malloc(size_t);
void *safe_realloc(void *, size_t);
void safe_free(void *);
-void hexdump(unsigned char *, size_t);
+void hexdump(FILE *, unsigned char *, size_t);
void error(char *, ...);
void fatal(char *, ...);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 11:22:10
|
Revision: 389
http://redbutton.svn.sourceforge.net/redbutton/?rev=389&view=rev
Author: skilvington
Date: 2007-09-18 04:22:00 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
only show synthetic nodes in -vv mode
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/asn1tag.c 2007-09-18 11:22:00 UTC (rev 389)
@@ -15,3 +15,9 @@
return "ILLEGAL-ASN1-CLASS-NUMBER";
}
+bool
+is_synthetic(unsigned int asn1tag)
+{
+/* TODO: only need one value for synthetic types (ie no need for separate ASN1TAG_CHOICE etc) */
+ return (asn1tag >= ASN1TAG_SYNTHETIC);
+}
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/asn1tag.h 2007-09-18 11:22:00 UTC (rev 389)
@@ -5,6 +5,8 @@
#ifndef __ASN1TAG_H__
#define __ASN1TAG_H__
+#include <stdbool.h>
+
/* tag classes */
#define ASN1CLASS_UNIVERSAL 0x00
#define ASN1CLASS_APPLICATION 0x40
@@ -12,6 +14,7 @@
#define ASN1CLASS_PRIVATE 0xc0
char *asn1class_name(unsigned int);
+bool is_synthetic(unsigned int);
/*
* a synthetic object created as a result of the grammar definition
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/mhegc.c 2007-09-18 11:22:00 UTC (rev 389)
@@ -67,6 +67,11 @@
else if(optind != argc)
usage(prog_name);
+ if(optind == argc - 1)
+ verbose("Parsing '%s':\n", argv[optind]);
+ else
+ verbose("Parsing stdin:\n");
+
bzero(&asn1obj, sizeof(struct node));
asn1obj.asn1tag = ASN1TAG_SYNTHETIC;
parse_InterchangedObject(&asn1obj);
@@ -94,17 +99,37 @@
void
print_node(struct node *n, unsigned int indent)
{
+ bool show_node;
+ bool show_kids;
struct node *kid;
- print_indent(indent);
- fprintf(stderr, "[%s %d]\n", asn1class_name(n->asn1class), n->asn1tag);
+ /* only show synthetic nodes if -vv was given on the cmd line */
+ show_node = (!is_synthetic(n->asn1tag) || _verbose > 1);
- if(n->children)
+ /* only show non-synthetic children, unless -vv was given */
+ show_kids = (has_real_children(n) || _verbose > 1);
+
+ if(show_node)
{
print_indent(indent);
- fprintf(stderr, "{\n");
+ fprintf(stderr, "[%s %d]\n", asn1class_name(n->asn1class), n->asn1tag);
+ if(show_kids)
+ {
+ print_indent(indent);
+ fprintf(stderr, "{\n");
+ indent ++;
+ }
+ }
+
+ if(show_kids)
+ {
for(kid=n->children; kid; kid=kid->siblings)
- print_node(kid, indent + 1);
+ print_node(kid, indent);
+ }
+
+ if(show_node && show_kids)
+ {
+ indent --;
print_indent(indent);
fprintf(stderr, "}\n");
}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/parser.c.header 2007-09-18 11:22:00 UTC (rev 389)
@@ -59,6 +59,24 @@
}
/*
+ * return true if any of the node's descendants are not synthetic
+ */
+
+bool
+has_real_children(struct node *n)
+{
+ struct node *kid;
+
+ for(kid=n->children; kid; kid=kid->siblings)
+ {
+ if(has_real_children(kid) || !is_synthetic(kid->asn1tag))
+ return true;
+ }
+
+ return false;
+}
+
+/*
* parser functions for the predefined types
*/
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/parser.h.header 2007-09-18 11:22:00 UTC (rev 389)
@@ -24,6 +24,9 @@
/* add a child to a node */
struct node *add_child(struct node *, uint32_t);
+/* return true if any of the node's descendants are not synthetic */
+bool has_real_children(struct node *);
+
/* lexer token type */
typedef int token_t;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-17 16:23:20
|
Revision: 388
http://redbutton.svn.sourceforge.net/redbutton/?rev=388&view=rev
Author: skilvington
Date: 2007-09-17 09:23:18 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
generate all the ASN1 tag and class values
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-09-17 09:14:00 UTC (rev 387)
+++ redbutton-author/trunk/Makefile 2007-09-17 16:23:18 UTC (rev 388)
@@ -28,7 +28,7 @@
${YACC} -b ccc -d ccc.y
${CC} ${CFLAGS} ${DEFS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
-lex.parser.c parser.c parser.h: parser.l.* parser.c.* parser.h.* tokens.h.* grammar ccc
+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
${LEX} -i -t parser.l > lex.parser.c
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-17 09:14:00 UTC (rev 387)
+++ redbutton-author/trunk/asn1tag.h 2007-09-17 16:23:18 UTC (rev 388)
@@ -30,6 +30,7 @@
/* abstract types */
#define ASN1TAGCLASS_Root ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Group ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Presentable ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Ingredient ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Program ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Variable ASN1TAG_SYNTHETIC
@@ -122,13 +123,14 @@
#define ASN1TAG_Positions 73
#define ASN1TAG_WrapAround 74
#define ASN1TAG_MultipleSelection 75
-#define ASN1TAG_BoxSize 76
+#define ASN1TAG_OriginalBoxSize 76
#define ASN1TAG_OriginalPosition 77
#define ASN1TAG_OriginalPaletteRef 78
#define ASN1TAG_Tiling 79
#define ASN1TAG_OriginalTransparency 80
#define ASN1TAG_BorderedBoundingBox 81
#define ASN1TAG_OriginalLineWidth 82
+#define ASN1TAG_OriginalLineStyle 83
#define ASN1TAG_OriginalRefLineColour 84
#define ASN1TAG_OriginalRefFillColour 85
#define ASN1TAG_OriginalFont 86
@@ -372,13 +374,14 @@
#define ASN1TAGCLASS_Positions ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Positions)
#define ASN1TAGCLASS_WrapAround ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_WrapAround)
#define ASN1TAGCLASS_MultipleSelection ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MultipleSelection)
-#define ASN1TAGCLASS_BoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BoxSize)
+#define ASN1TAGCLASS_OriginalBoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalBoxSize)
#define ASN1TAGCLASS_OriginalPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalPosition)
#define ASN1TAGCLASS_OriginalPaletteRef ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalPaletteRef)
#define ASN1TAGCLASS_Tiling ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Tiling)
#define ASN1TAGCLASS_OriginalTransparency ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalTransparency)
#define ASN1TAGCLASS_BorderedBoundingBox ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BorderedBoundingBox)
#define ASN1TAGCLASS_OriginalLineWidth ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalLineWidth)
+#define ASN1TAGCLASS_OriginalLineStyle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalLineStyle)
#define ASN1TAGCLASS_OriginalRefLineColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalRefLineColour)
#define ASN1TAGCLASS_OriginalRefFillColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalRefFillColour)
#define ASN1TAGCLASS_OriginalFont ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalFont)
@@ -559,166 +562,158 @@
#define ASN1TAGCLASS_MHEGStandardIdentifier ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_DirectFont ASN1TAGCLASS_OctetString
#define ASN1TAGCLASS_IndirectFont ASN1TAG_SYNTHETIC
-
-/* start TODO */
-#define ASN1TAG_FIXME 99999
-#define ASN1TAGCLASS_XScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_YScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_Width ASN1TAG_FIXME
-#define ASN1TAGCLASS_Height ASN1TAG_FIXME
-#define ASN1TAGCLASS_SceneRef ASN1TAG_FIXME
-#define ASN1TAGCLASS_SceneWeight ASN1TAG_FIXME
-#define ASN1TAGCLASS_IncludedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_EventSource ASN1TAG_FIXME
-#define ASN1TAGCLASS_EventType ASN1TAG_FIXME
-#define ASN1TAGCLASS_EventData ASN1TAG_FIXME
-#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_Presentable ASN1TAG_FIXME
-#define ASN1TAGCLASS_TargetElement ASN1TAG_FIXME
-#define ASN1TAGCLASS_AVisible ASN1TAG_FIXME
-#define ASN1TAGCLASS_Position ASN1TAG_FIXME
-#define ASN1TAGCLASS_OriginalBoxSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_XLength ASN1TAG_FIXME
-#define ASN1TAGCLASS_YLength ASN1TAG_FIXME
-#define ASN1TAGCLASS_OriginalLineStyle ASN1TAG_FIXME
-#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_FIXME
-#define ASN1TAGCLASS_Address ASN1TAG_FIXME
-#define ASN1TAGCLASS_Answer ASN1TAG_FIXME
-#define ASN1TAGCLASS_AppendValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_ArcAngle ASN1TAG_FIXME
-#define ASN1TAGCLASS_AvailabilityStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_CallSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_CellIndex ASN1TAG_FIXME
-#define ASN1TAGCLASS_CloneRefVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ConnectionTag ASN1TAG_FIXME
-#define ASN1TAGCLASS_Denominator ASN1TAG_FIXME
-#define ASN1TAGCLASS_EllipseHeight ASN1TAG_FIXME
-#define ASN1TAGCLASS_EllipseWidth ASN1TAG_FIXME
-#define ASN1TAGCLASS_EmulatedEventSource ASN1TAG_FIXME
-#define ASN1TAGCLASS_EmulatedEventType ASN1TAG_FIXME
-#define ASN1TAGCLASS_EntryPointVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ForkSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_Feature ASN1TAG_FIXME
-#define ASN1TAGCLASS_FillColourVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_FirstItemVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_HighlightStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_Index ASN1TAG_FIXME
-#define ASN1TAGCLASS_InFileName ASN1TAG_FIXME
-#define ASN1TAGCLASS_InteractionStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemIndex ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemRefVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemsToScroll ASN1TAG_FIXME
-#define ASN1TAGCLASS_LabelVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LastAnchorFiredVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LineColourVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LineStyleVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LineWidthVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_MovementIdentifier ASN1TAG_FIXME
-#define ASN1TAGCLASS_NbOfSteps ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCachePriority ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCounterEndPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCounterPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCounterValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCursorShape ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewEntryPoint ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewFirstItem ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewGenericOctetString ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewHighlightStatus ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewIncludedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewInteractionStatus ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewLabel ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewLineStyle ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewLineWidth ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewOverwriteMode ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewPaletteRef ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewPortion ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewSliderValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewSpeed ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewTransparency ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewVolume ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewXPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewYPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_Numerator ASN1TAG_FIXME
-#define ASN1TAGCLASS_OpenSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_Operator ASN1TAG_FIXME
-#define ASN1TAGCLASS_OutFileName ASN1TAG_FIXME
-#define ASN1TAGCLASS_OverwriteModeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_PortionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_Protocol ASN1TAG_FIXME
-#define ASN1TAGCLASS_ReadSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_ReferenceVisible ASN1TAG_FIXME
-#define ASN1TAGCLASS_RunningStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_SelectionStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_SizeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_SliderValueVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_StartAngle ASN1TAG_FIXME
-#define ASN1TAGCLASS_StoreSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_Target ASN1TAG_FIXME
-#define ASN1TAGCLASS_TextContentVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_TextDataVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_TimerID ASN1TAG_FIXME
-#define ASN1TAGCLASS_TimerValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_TokenPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_TransitionEffect ASN1TAG_FIXME
-#define ASN1TAGCLASS_TriggerIdentifier ASN1TAG_FIXME
-#define ASN1TAGCLASS_Value ASN1TAG_FIXME
-#define ASN1TAGCLASS_VisibleReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_VolumeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_X ASN1TAG_FIXME
-#define ASN1TAGCLASS_X1 ASN1TAG_FIXME
-#define ASN1TAGCLASS_X2 ASN1TAG_FIXME
-#define ASN1TAGCLASS_XBoxSizeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_XCursor ASN1TAG_FIXME
-#define ASN1TAGCLASS_XNewBoxSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_XOut ASN1TAG_FIXME
-#define ASN1TAGCLASS_XPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_XScale ASN1TAG_FIXME
-#define ASN1TAGCLASS_Y ASN1TAG_FIXME
-#define ASN1TAGCLASS_Y1 ASN1TAG_FIXME
-#define ASN1TAGCLASS_Y2 ASN1TAG_FIXME
-#define ASN1TAGCLASS_YBoxSizeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_YCursor ASN1TAG_FIXME
-#define ASN1TAGCLASS_YNewBoxSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_YOut ASN1TAG_FIXME
-#define ASN1TAGCLASS_YPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_YScale ASN1TAG_FIXME
-#define ASN1TAGCLASS_XOffsetVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_YOffsetVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewXOffset ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewYOffset ASN1TAG_FIXME
-#define ASN1TAGCLASS_FocusPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewFocusPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewMinValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewMaxValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewStepSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_InternalReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_GroupIdentifier ASN1TAG_FIXME
-#define ASN1TAGCLASS_ObjectNumber ASN1TAG_FIXME
-#define ASN1TAGCLASS_DirectReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_ColourIndex ASN1TAG_FIXME
-#define ASN1TAGCLASS_AbsoluteColour ASN1TAG_FIXME
-#define ASN1TAGCLASS_XPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_YPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_ReferencedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_XScene ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_YScene ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_Width ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_Height ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_SceneRef ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_SceneWeight ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_IncludedContent ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_EventSource ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EventType ASN1TAG_ENUMERATED
+#define ASN1TAGCLASS_EventData ASN1TAG_CHOICE
+#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TargetElement ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_AVisible ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Position ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_BoxSize ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_XLength ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_YLength ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Address ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Answer ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_AppendValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ArcAngle ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_AvailabilityStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_CallSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_CellIndex ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_CloneRefVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ConnectionTag ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Denominator ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EllipseHeight ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EllipseWidth ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EmulatedEventSource ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EmulatedEventType ASN1TAG_ENUMERATED
+#define ASN1TAGCLASS_EntryPointVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ForkSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Feature ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_FillColourVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_FirstItemVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_HighlightStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Index ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_InFileName ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_InteractionStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemIndex ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemRefVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemsToScroll ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LabelVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LastAnchorFiredVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineColourVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineStyleVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineWidthVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_MovementIdentifier ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NbOfSteps ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCachePriority ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCounterEndPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCounterPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCounterValue ASN1TAG_SYNTHETIC
+#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
+#define ASN1TAGCLASS_NewLabel ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewLineStyle ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewLineWidth ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewOverwriteMode ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewPaletteRef ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewPortion ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewSliderValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewSpeed ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewTransparency ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewVolume ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewXPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewYPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Numerator ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OpenSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Operator ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OutFileName ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OverwriteModeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_PortionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Protocol ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ReadSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ReferenceVisible ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_RunningStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_SelectionStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_SizeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_SliderValueVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_StartAngle ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_StoreSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Target ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TextContentVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TextDataVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TimerID ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TimerValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TokenPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TransitionEffect ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TriggerIdentifier ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Value ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_VisibleReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_VolumeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_X ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_X1 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_X2 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XBoxSizeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XCursor ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XNewBoxSize ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XOut ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XScale ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Y ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Y1 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Y2 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YBoxSizeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YCursor ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YNewBoxSize ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YOut ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YScale ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XOffsetVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YOffsetVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewXOffset ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewYOffset ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_FocusPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewFocusPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewMinValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewMaxValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewStepSize ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_InternalReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_GroupIdentifier ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_ObjectNumber ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_DirectReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ColourIndex ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_AbsoluteColour ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_XPosition ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_YPosition ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_ReferencedContent ASN1TAG_SEQUENCE
#define ASN1TAGCLASS_XYPosition ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_Point ASN1TAG_FIXME
-#define ASN1TAGCLASS_Rational ASN1TAG_FIXME
-#define ASN1TAGCLASS_ExternalReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_NextScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_FIXME
-/* TODO: an INTEGER ie class=UNIVERSAL, tag=2 */
-#define ASN1TAGCLASS_Movement ASN1TAG_FIXME
-/* TODO: sequences */
-#define ASN1TAGCLASS_ActionSlots ASN1TAG_FIXME
-#define ASN1TAGCLASS_InVariables ASN1TAG_FIXME
-#define ASN1TAGCLASS_OutVariables ASN1TAG_FIXME
-#define ASN1TAGCLASS_ActionClass ASN1TAG_FIXME
-#define ASN1TAGCLASS_Parameters ASN1TAG_FIXME
-#define ASN1TAGCLASS_PointList ASN1TAG_FIXME
-/* end TODO */
+#define ASN1TAGCLASS_Point ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Rational ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_ExternalReference ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_NextScene ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Movement ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_ActionSlots ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_InVariables ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_OutVariables ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_ActionClass ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Parameters ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_PointList ASN1TAG_SEQUENCE
#endif /* __ASN1TAG_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-17 09:14:03
|
Revision: 387
http://redbutton.svn.sourceforge.net/redbutton/?rev=387&view=rev
Author: skilvington
Date: 2007-09-17 02:14:00 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
import hello world example from http://www.digvid.info/mheg5/hello_world.php
Added Paths:
-----------
redbutton-author/trunk/helloworld/
redbutton-author/trunk/helloworld/hello.mhg.txt
redbutton-author/trunk/helloworld/startup.txt
Added: redbutton-author/trunk/helloworld/hello.mhg.txt
===================================================================
--- redbutton-author/trunk/helloworld/hello.mhg.txt (rev 0)
+++ redbutton-author/trunk/helloworld/hello.mhg.txt 2007-09-17 09:14:00 UTC (rev 387)
@@ -0,0 +1,44 @@
+// MHEG5 Hello World scene
+//
+// http://www.digvid.info/mheg5/hello_world.php
+//
+
+{:Scene
+ ( "~/hello.mhg" 0 )
+ :Items
+ (
+ // Declare a background Rectangle that covers the screen.
+ {:Rectangle
+ 1
+ :OrigBoxSize 720 576 // Size of rectangle
+ :OrigPosition 0 0 // Position at top left
+ :OrigRefLineColour '=ff=ff=ff=00' // White
+ :OrigRefFillColour '=ff=ff=ff=00' // White
+ }
+
+ // Place a Text box on the screen
+ {:Text
+ 2
+ :OrigContent "Hello World!" // Text to display
+ :OrigBoxSize 300 50 // Size of text box
+ :OrigPosition 200 100 // X,Y position
+ :FontAttributes "plain.36.42.0" // Use large characters
+ :TextColour '=ff=00=00=00' // Red
+ }
+
+ // Define a Link that triggers when the user presses the Blue key to
+ // Quit the application.
+ {:Link
+ 3
+ :EventSource 0 // Source is this scene
+ :EventType UserInput // Event type that we are looking for
+ :EventData 103 // 103 for the blue key
+ :LinkEffect (
+ :Quit ( ( '~/startup' 0 ) )
+ )
+ }
+ )
+
+ :InputEventReg 3
+ :SceneCS 720 576
+}
Added: redbutton-author/trunk/helloworld/startup.txt
===================================================================
--- redbutton-author/trunk/helloworld/startup.txt (rev 0)
+++ redbutton-author/trunk/helloworld/startup.txt 2007-09-17 09:14:00 UTC (rev 387)
@@ -0,0 +1,25 @@
+// MHEG5 Hello World app
+//
+// http://www.digvid.info/mheg5/hello_world.php
+//
+
+{:Application
+ ( '/startup' 0 ) // Application content reference
+ :Items (
+ {:Link
+ 1
+ :EventSource 0 // Check this application...
+ :EventType IsRunning // ... for the IsRunning event
+ :LinkEffect (
+ // Load the scene
+ :TransitionTo (( '~/hello.mhg' 0 ) )
+ )
+ }
+ )
+ :BackgroundColour '=FF=FF=FF=00' // White
+ :TextCHook 10 // Default text content hook
+ :TextColour '=00=00=00=00' // Black
+ :Font "rec://font/uk1" // Font to use for text rendering
+ :FontAttributes "plain.26.32.0" // Default font attributes
+ :BitmapCHook 4 // Default bitmap content hook
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|