[Redbutton-devel] SF.net SVN: redbutton: [377] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-09-13 11:45:57
|
Revision: 377
http://redbutton.svn.sourceforge.net/redbutton/?rev=377&view=rev
Author: skilvington
Date: 2007-09-13 04:45:48 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
we will need to store the ASN1 tag class after all
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-12 13:17:20 UTC (rev 376)
+++ redbutton-author/trunk/asn1tag.h 2007-09-13 11:45:48 UTC (rev 377)
@@ -5,6 +5,12 @@
#ifndef __ASN1TAG_H__
#define __ASN1TAG_H__
+/* tag classes */
+#define ASN1CLASS_UNIVERSAL 0x00
+#define ASN1CLASS_APPLICATION 0x40
+#define ASN1CLASS_CONTEXT 0x80
+#define ASN1CLASS_PRIVATE 0xc0
+
/*
* a synthetic object created as a result of the grammar definition
* eg TextBody etc
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-12 13:17:20 UTC (rev 376)
+++ redbutton-author/trunk/parser.c.header 2007-09-13 11:45:48 UTC (rev 377)
@@ -2,7 +2,12 @@
#include "parser.h"
#include "tokens.h"
+#include "utils.h"
+/*
+ * lexer functions we need to provide
+ */
+
int yylineno = 1;
void
@@ -18,6 +23,39 @@
}
/*
+ * parser helper functions
+ */
+
+struct node *
+add_child(struct node *parent, unsigned int asn1tag, unsigned int asn1class)
+{
+ struct node *child = safe_malloc(sizeof(struct node));
+
+ child->asn1tag = asn1tag;
+ child->asn1class = asn1class;
+ child->length = 0;
+ child->value = NULL;
+ child->children = NULL;
+ child->siblings = NULL;
+
+ /* is it the first */
+ if(parent->children == NULL)
+ {
+ parent->children = child;
+ }
+ else
+ {
+ /* add it to the end of the siblings list */
+ struct node *sib = parent->children;
+ while(sib->siblings != NULL)
+ sib = sib->siblings;
+ sib->siblings = child;
+ }
+
+ return child;
+}
+
+/*
* parser functions for the predefined types
*/
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-12 13:17:20 UTC (rev 376)
+++ redbutton-author/trunk/parser.h.header 2007-09-13 11:45:48 UTC (rev 377)
@@ -11,6 +11,7 @@
{
/* DER type */
unsigned int asn1tag; /* ASN1 tag number */
+ unsigned int asn1class; /* only UNIVERSAL or CONTEXT */
/* DER value */
unsigned int length; /* length of the value data */
unsigned char *value; /* DER encoded value */
@@ -19,9 +20,13 @@
struct node *siblings; /* linked list of children */
};
+/* add a child to a node */
+struct node *add_child(struct node *, unsigned int, unsigned int);
+
/* lexer token type */
typedef int token_t;
+/* lexer functions */
void set_input_file(char *);
token_t peek_token(void);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|