]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Sync with libtasn1 v1.7.
authorSimon Josefsson <simon@josefsson.org>
Tue, 18 Nov 2008 00:06:04 +0000 (01:06 +0100)
committerSimon Josefsson <simon@josefsson.org>
Tue, 18 Nov 2008 00:06:04 +0000 (01:06 +0100)
12 files changed:
NEWS
lib/minitasn1/coding.c
lib/minitasn1/decoding.c
lib/minitasn1/element.c
lib/minitasn1/element.h
lib/minitasn1/errors.c
lib/minitasn1/gstr.h
lib/minitasn1/libtasn1.h
lib/minitasn1/parser_aux.c
lib/minitasn1/parser_aux.h
lib/minitasn1/structure.c
lib/minitasn1/structure.h

diff --git a/NEWS b/NEWS
index 7286c8dd4f52b92fcd7e40860c39ea29fa0b7470..ac1eea5dd44b3d69c3165ef35dc482c49b3e29b3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -54,6 +54,8 @@ Modules include memchr and memcmp.
 
 ** Fix warnings and build GnuTLS with more warnings enabled.
 
+** minitasn1: Internal copy updated to libtasn1 v1.7.
+
 ** API and ABI modifications:
 gnutls_certificate_set_x509_simple_pkcs12_mem: ADDED
 GNUTLS_VERSION: ADDED, replaces LIBGNUTLS_VERSION.
index 74c83904ecc242d99a8748c3813c31f4b9c5fe84..63d38a730d38fa73646bb0e468facca8359857dd 100644 (file)
@@ -46,7 +46,7 @@
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_error_description_value_not_found (node_asn * node,
+_asn1_error_description_value_not_found (ASN1_TYPE  node,
                                         char *ErrorDescription)
 {
 
@@ -55,7 +55,7 @@ _asn1_error_description_value_not_found (node_asn * node,
 
   Estrcpy (ErrorDescription, ":: value of element '");
   _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
-                          MAX_ERROR_DESCRIPTION_SIZE - 40);
+                          ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
   Estrcat (ErrorDescription, "' not found");
 
 }
@@ -371,10 +371,10 @@ asn1_bit_der (const unsigned char *str, int bit_len,
 /*   otherwise ASN1_SUCCESS.                          */
 /******************************************************/
 asn1_retCode
-_asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
+_asn1_complete_explicit_tag (ASN1_TYPE  node, unsigned char *der,
                             int *counter, int *max_len)
 {
-  node_asn *p;
+  ASN1_TYPE p;
   int is_tag_implicit, len2, len3;
   unsigned char temp[SIZEOF_UNSIGNED_INT];
 
@@ -444,10 +444,10 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
 /*   otherwise ASN1_SUCCESS.                          */
 /******************************************************/
 asn1_retCode
-_asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
+_asn1_insert_tag_der (ASN1_TYPE  node, unsigned char *der, int *counter,
                      int *max_len)
 {
-  node_asn *p;
+  ASN1_TYPE p;
   int tag_len, is_tag_implicit;
   unsigned char class, class_implicit = 0, temp[SIZEOF_UNSIGNED_INT * 3 + 1];
   unsigned long tag_implicit = 0;
@@ -605,7 +605,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
+_asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE  node)
 {
   struct vet
   {
@@ -616,7 +616,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
 
   int counter, len, len2;
   struct vet *first, *last, *p_vet, *p2_vet;
-  node_asn *p;
+  ASN1_TYPE p;
   unsigned char class, *temp;
   unsigned long tag;
 
@@ -719,7 +719,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
+_asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE  node)
 {
   struct vet
   {
@@ -729,7 +729,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
 
   int counter, len, len2, change;
   struct vet *first, *last, *p_vet, *p2_vet;
-  node_asn *p;
+  ASN1_TYPE p;
   unsigned char *temp, class;
   unsigned long k, max;
 
@@ -874,7 +874,7 @@ asn1_retCode
 asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
                 char *ErrorDescription)
 {
-  node_asn *node, *p, *p2;
+  ASN1_TYPE node, p, p2;
   char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
   int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
   asn1_retCode err;
index 51ecc01cea91ad43a704b7ab48591f8ccccf3c9c..9e162e5811255e341743ff4b2a66ae5e985b621d 100644 (file)
@@ -37,12 +37,12 @@ static asn1_retCode
 _asn1_get_indefinite_length_string (const unsigned char *der, int *len);
 
 static void
-_asn1_error_description_tag_error (node_asn * node, char *ErrorDescription)
+_asn1_error_description_tag_error (ASN1_TYPE node, char *ErrorDescription)
 {
 
   Estrcpy (ErrorDescription, ":: tag error near element '");
   _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
-                          MAX_ERROR_DESCRIPTION_SIZE - 40);
+                          ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
   Estrcat (ErrorDescription, "'");
 
 }
@@ -166,28 +166,30 @@ asn1_get_tag_der (const unsigned char *der, int der_len,
  * @ber_len: Length of BER data to decode.
  * @len: Output variable containing the length of the BER length field.
  *
- * Extract a length field from BER data.
+ * Extract a length field from BER data.  The difference to
+ * asn1_get_length_der() is that this function will return a length
+ * even if the value has indefinite encoding.
  *
  * Return value: Return the decoded length value, or negative value
- * when the value was too big. The difference with asn1_get_length_der()
- * is that it will return length even if the value has indefinite encoding.
+ *   when the value was too big.
  *
+ * Since: 2.0
  **/
-long
+signed long
 asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len)
 {
   int ret;
   long err;
 
   ret = asn1_get_length_der( ber, ber_len, len);
-  if (ret == -1) 
+  if (ret == -1)
     {                  /* indefinite length method */
       ret = ber_len;
       err = _asn1_get_indefinite_length_string (ber+1, &ret);
       if (err != ASN1_SUCCESS)
-        return -3;
+       return -3;
     }
-    
+
   return ret;
 }
 
@@ -339,10 +341,10 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
 
 
 int
-_asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
+_asn1_extract_tag_der (ASN1_TYPE node, const unsigned char *der, int der_len,
                       int *ret_len)
 {
-  node_asn *p;
+  ASN1_TYPE p;
   int counter, len2, len3, is_tag_implicit;
   unsigned long tag, tag_implicit = 0;
   unsigned char class, class2, class_implicit = 0;
@@ -538,9 +540,9 @@ _asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
 
 
 int
-_asn1_delete_not_used (node_asn * node)
+_asn1_delete_not_used (ASN1_TYPE node)
 {
-  node_asn *p, *p2;
+  ASN1_TYPE p, p2;
 
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
@@ -596,7 +598,7 @@ _asn1_delete_not_used (node_asn * node)
   return ASN1_SUCCESS;
 }
 
-asn1_retCode _asn1_extract_der_octet(node_asn * node, const unsigned char *der, int der_len)
+asn1_retCode _asn1_extract_der_octet(ASN1_TYPE node, const unsigned char *der, int der_len)
 {
 int len2, len3;
 int counter2, counter_end;
@@ -639,7 +641,7 @@ int counter2, counter_end;
 
 
 asn1_retCode
-_asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
+_asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
 {
   int len2, len3, counter, tot_len, indefinite;
 
@@ -800,7 +802,7 @@ asn1_retCode
 asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
                   char *errorDescription)
 {
-  node_asn *node, *p, *p2, *p3;
+  ASN1_TYPE node, p, p2, p3;
   char temp[128];
   int counter, len2, len3, len4, move, ris, tlen;
   unsigned char class;
@@ -1354,9 +1356,9 @@ asn1_retCode
 asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
                           const void *ider, int len, char *errorDescription)
 {
-  node_asn *node, *p, *p2, *p3, *nodeFound = ASN1_TYPE_EMPTY;
-  char temp[128], currentName[MAX_NAME_SIZE * 10], *dot_p, *char_p;
-  int nameLen = MAX_NAME_SIZE * 10 - 1, state;
+  ASN1_TYPE node, p, p2, p3, nodeFound = ASN1_TYPE_EMPTY;
+  char temp[128], currentName[ASN1_MAX_NAME_SIZE * 10], *dot_p, *char_p;
+  int nameLen = ASN1_MAX_NAME_SIZE * 10 - 1, state;
   int counter, len2, len3, len4, move, ris, tlen;
   unsigned char class, *temp2;
   unsigned long tag;
@@ -2125,7 +2127,7 @@ asn1_retCode
 asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
                            const char *name_element, int *start, int *end)
 {
-  node_asn *node, *node_to_find, *p, *p2, *p3;
+  ASN1_TYPE node, node_to_find, p, p2, p3;
   int counter, len2, len3, len4, move, ris;
   unsigned char class;
   unsigned long tag;
@@ -2468,12 +2470,12 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
 asn1_retCode
 asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
 {
-  char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1],
-    value[MAX_NAME_SIZE];
+  char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1],
+    value[ASN1_MAX_NAME_SIZE];
   asn1_retCode retCode = ASN1_SUCCESS, result;
   int len, len2, len3;
   ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY;
-  char errorDescription[MAX_ERROR_DESCRIPTION_SIZE];
+  char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
 
   if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
     return ASN1_ELEMENT_NOT_FOUND;
@@ -2557,7 +2559,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
                      strcpy (name, definitionsName);
                      strcat (name, p2->name);
 
-                     len = MAX_NAME_SIZE;
+                     len = ASN1_MAX_NAME_SIZE;
                      result =
                        asn1_read_value (definitions, name, value, &len);
 
@@ -2707,12 +2709,12 @@ asn1_retCode
 asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
                          const char *octetName, const char *objectName)
 {
-  char name[2 * MAX_NAME_SIZE + 1], value[MAX_NAME_SIZE];
+  char name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE];
   asn1_retCode retCode = ASN1_SUCCESS, result;
   int len, len2, len3;
   ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY;
   ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY;
-  char errorDescription[MAX_ERROR_DESCRIPTION_SIZE];
+  char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
 
   if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
     return ASN1_ELEMENT_NOT_FOUND;
index 25ecd5af3f14680d17dfea574b61ac7433d32da6..f9cd3c7dcf804bcb374f11b4b34173c20156c0f1 100644 (file)
@@ -34,9 +34,9 @@
 #include "structure.h"
 
 void
-_asn1_hierarchical_name (node_asn * node, char *name, int name_size)
+_asn1_hierarchical_name (ASN1_TYPE  node, char *name, int name_size)
 {
-  node_asn *p;
+  ASN1_TYPE p;
   char tmp_name[64];
 
   p = node;
@@ -129,9 +129,9 @@ _asn1_convert_integer (const char *value, unsigned char *value_out,
 
 
 int
-_asn1_append_sequence_set (node_asn * node)
+_asn1_append_sequence_set (ASN1_TYPE  node)
 {
-  node_asn *p, *p2;
+  ASN1_TYPE p, p2;
   char temp[10];
   long n;
 
@@ -278,7 +278,7 @@ asn1_retCode
 asn1_write_value (ASN1_TYPE node_root, const char *name,
                  const void *ivalue, int len)
 {
-  node_asn *node, *p, *p2;
+  ASN1_TYPE node, p, p2;
   unsigned char *temp, *value_temp = NULL, *default_temp = NULL;
   int len2, k, k2, negative;
   const unsigned char *value = ivalue;
@@ -713,7 +713,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
 asn1_retCode
 asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
 {
-  node_asn *node, *p, *p2;
+  ASN1_TYPE node, p, p2;
   int len2, len3;
   int value_size = *len;
   unsigned char *value = ivalue;
@@ -893,10 +893,10 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
   *
   **/
 asn1_retCode
-asn1_read_tag (node_asn * root, const char *name, int *tagValue,
+asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue,
               int *classValue)
 {
-  node_asn *node, *p, *pTag;
+  ASN1_TYPE node, p, pTag;
 
   node = asn1_find_node (root, name);
   if (node == NULL)
index 3db95295f9e350265d916b4a37cbb31b19404d9c..f0314d27a690e44f33290926389154e6dea9f3ee 100644 (file)
@@ -3,11 +3,11 @@
 #define _ELEMENT_H
 
 
-asn1_retCode _asn1_append_sequence_set(node_asn *node);
+asn1_retCode _asn1_append_sequence_set(ASN1_TYPE node);
 
 asn1_retCode _asn1_convert_integer(const char *value,unsigned char *value_out,
                          int value_out_size, int *len);
 
-void _asn1_hierarchical_name(node_asn *node,char *name,int name_size);
+void _asn1_hierarchical_name(ASN1_TYPE node,char *name,int name_size);
 
 #endif
index 0d3e4a2b22389508ec1629a6bff0652b7ed28cfd..cbfb622a300178b148a62340b8d18d875d2efee2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *      Copyright (C) 2006 Free Software Foundation, Inc.
+ *      Copyright (C) 2006, 2008 Free Software Foundation, Inc.
  *      Copyright (C) 2002, 2005 Fabio Fiorina
  *
  * This file is part of LIBTASN1.
@@ -26,9 +26,7 @@
 # include <stdarg.h>
 #endif
 
-
-#define LIBTASN1_ERROR_ENTRY(name) \
-       { #name, name }
+#define LIBTASN1_ERROR_ENTRY(name) { #name, name }
 
 struct libtasn1_error_entry
 {
@@ -59,77 +57,81 @@ static const libtasn1_error_entry error_algorithms[] = {
   {0}
 };
 
-#define LIBTASN1_ERROR_LOOP(b) \
-        const libtasn1_error_entry *p; \
-                for(p = error_algorithms; p->name != NULL; p++) { b ; }
-
-#define LIBTASN1_ERROR_ALG_LOOP(a) \
-                        LIBTASN1_ERROR_LOOP( if(p->number == error) { a; break; } )
-
-
-
 /**
-  * libtasn1_perror - prints a string to stderr with a description of an error
-  * @error: is an error returned by a libtasn1 function.
-  *
-  * This function is like perror(). The only difference is that it
-  * accepts an error returned by a libtasn1 function.
-  **/
+ * asn1_perror - prints a string to stderr with a description of an error
+ * @error: is an error returned by a libtasn1 function.
+ *
+ * This function is like perror(). The only difference is that it
+ * accepts an error returned by a libtasn1 function.
+ *
+ * Since: 1.6
+ **/
 void
-libtasn1_perror (asn1_retCode error)
+asn1_perror (asn1_retCode error)
 {
-  const char *ret = NULL;
-
-  /* avoid prefix */
-  LIBTASN1_ERROR_ALG_LOOP (ret = p->name + sizeof ("ASN1_") - 1);
-
-  fprintf (stderr, "LIBTASN1 ERROR: %s\n", ret);
-
+  const char *str = asn1_strerror (error);
+  fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)");
 }
 
-
 /**
-  * libtasn1_strerror - Returns a string with a description of an error
-  * @error: is an error returned by a libtasn1 function.
-  *
-  * This function is similar to strerror(). The only difference is
-  * that it accepts an error (number) returned by a libtasn1 function.
-  *
-  * Returns: Pointer to static zero-terminated string describing error
-  *   code.
-  **/
+ * asn1_strerror - Returns a string with a description of an error
+ * @error: is an error returned by a libtasn1 function.
+ *
+ * This function is similar to strerror(). The only difference is
+ * that it accepts an error (number) returned by a libtasn1 function.
+ *
+ * Returns: Pointer to static zero-terminated string describing error
+ *   code.
+ *
+ * Since: 1.6
+ **/
 const char *
-libtasn1_strerror (asn1_retCode error)
+asn1_strerror (asn1_retCode error)
 {
-  const char *ret = NULL;
+  const libtasn1_error_entry *p;
 
-  /* avoid prefix */
-  LIBTASN1_ERROR_ALG_LOOP (ret = p->name + sizeof ("ASN1_") - 1);
+  for (p = error_algorithms; p->name != NULL; p++)
+    if (p->number == error)
+      return p->name + sizeof ("ASN1_") - 1;
 
-  return ret;
+  return NULL;
 }
 
-/* this function will output a message.
- */
-#ifdef LIBTASN1_DEBUG
-void
-_libtasn1_log (const char *fmt, ...)
-{
-  va_list args;
-  char str[MAX_LOG_SIZE];
-
-  va_start (args, fmt);
-  vsprintf (str, fmt, args);   /* Flawfinder: ignore */
-  va_end (args);
+#ifndef ASN1_DISABLE_DEPRECATED
 
-  fprintf (stderr, str);
+/* Compatibility mappings to preserve ABI. */
 
-  return;
-}
-#else /* not DEBUG */
+/**
+ * libtasn1_perror - prints a string to stderr with a description of an error
+ * @error: is an error returned by a libtasn1 function.
+ *
+ * This function is like perror(). The only difference is that it
+ * accepts an error returned by a libtasn1 function.
+ *
+ * Deprecated: Use asn1_perror() instead.
+ **/
 void
-_libtasn1_log (const char *fmt, ...)
+libtasn1_perror (asn1_retCode error)
+{
+  asn1_perror (error);
+}
+
+/**
+ * libtasn1_strerror - Returns a string with a description of an error
+ * @error: is an error returned by a libtasn1 function.
+ *
+ * This function is similar to strerror(). The only difference is
+ * that it accepts an error (number) returned by a libtasn1 function.
+ *
+ * Returns: Pointer to static zero-terminated string describing error
+ *   code.
+ *
+ * Deprecated: Use asn1_strerror() instead.
+ **/
+const char *
+libtasn1_strerror (asn1_retCode error)
 {
-  return;
+  return asn1_strerror (error);
 }
-#endif /* DEBUG */
+
+#endif
index 5508d26e0279997994fc6888d65acee6999c8d2a..992fd0ff3d9ba6c831266533ff638c7f1689eca4 100644 (file)
@@ -1,5 +1,5 @@
 void _asn1_str_cpy( char* dest, size_t dest_tot_size, const char* src);
 void _asn1_str_cat( char* dest, size_t dest_tot_size, const char* src);
 
-#define Estrcpy(x,y) _asn1_str_cpy(x,MAX_ERROR_DESCRIPTION_SIZE,y)
-#define Estrcat(x,y) _asn1_str_cat(x,MAX_ERROR_DESCRIPTION_SIZE,y)
+#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
+#define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
index efcee0e1bcd3cb40006518f437a97bb834960686..6834079bbd3d52af3dc02d3a570f2c917d992bbf 100644 (file)
 # define LIBTASN1_H
 
 #include <stdio.h>             /* for FILE* */
+#include <sys/types.h>
+#include <time.h>
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
-#define LIBTASN1_VERSION "1.5"
-
-#include <sys/types.h>
-#include <time.h>
+#define ASN1_VERSION "1.7"
 
-#define MAX_NAME_SIZE 128      /* maximum number of characters of a name */
-  /* inside a file with ASN1 definitons     */
-#define MAX_ERROR_DESCRIPTION_SIZE 128 /* maximum number of characters */
-  /* of a description message     */
-  /* (null character included)    */
+  typedef int asn1_retCode;    /* type returned by libtasn1 functions */
 
+  /*****************************************/
+  /* Errors returned by libtasn1 functions */
+  /*****************************************/
+#define ASN1_SUCCESS                   0
+#define ASN1_FILE_NOT_FOUND            1
+#define ASN1_ELEMENT_NOT_FOUND         2
+#define ASN1_IDENTIFIER_NOT_FOUND      3
+#define ASN1_DER_ERROR                 4
+#define ASN1_VALUE_NOT_FOUND           5
+#define ASN1_GENERIC_ERROR             6
+#define ASN1_VALUE_NOT_VALID           7
+#define ASN1_TAG_ERROR                 8
+#define ASN1_TAG_IMPLICIT              9
+#define ASN1_ERROR_TYPE_ANY            10
+#define ASN1_SYNTAX_ERROR              11
+#define ASN1_MEM_ERROR                 12
+#define ASN1_MEM_ALLOC_ERROR           13
+#define ASN1_DER_OVERFLOW              14
+#define ASN1_NAME_TOO_LONG             15
+#define ASN1_ARRAY_ERROR               16
+#define ASN1_ELEMENT_NOT_EMPTY         17
+
+  /*************************************/
+  /* Constants used in asn1_visit_tree */
+  /*************************************/
+#define ASN1_PRINT_NAME                        1
+#define ASN1_PRINT_NAME_TYPE           2
+#define ASN1_PRINT_NAME_TYPE_VALUE     3
+#define ASN1_PRINT_ALL                 4
 
-  typedef int asn1_retCode;    /* type returned by libtasn1 functions */
+  /*****************************************/
+  /* Constants returned by asn1_read_tag   */
+  /*****************************************/
+#define ASN1_CLASS_UNIVERSAL           0x00    /* old: 1 */
+#define ASN1_CLASS_APPLICATION         0x40    /* old: 2 */
+#define ASN1_CLASS_CONTEXT_SPECIFIC    0x80    /* old: 3 */
+#define ASN1_CLASS_PRIVATE             0xC0    /* old: 4 */
+#define ASN1_CLASS_STRUCTURED          0x20
 
   /*****************************************/
-  /*  Errors returned by libtasn1 functions */
+  /* Constants returned by asn1_read_tag   */
   /*****************************************/
-#define ASN1_SUCCESS               0
-#define ASN1_FILE_NOT_FOUND        1
-#define ASN1_ELEMENT_NOT_FOUND     2
-#define ASN1_IDENTIFIER_NOT_FOUND  3
-#define ASN1_DER_ERROR             4
-#define ASN1_VALUE_NOT_FOUND       5
-#define ASN1_GENERIC_ERROR         6
-#define ASN1_VALUE_NOT_VALID       7
-#define ASN1_TAG_ERROR             8
-#define ASN1_TAG_IMPLICIT          9
-#define ASN1_ERROR_TYPE_ANY        10
-#define ASN1_SYNTAX_ERROR          11
-#define ASN1_MEM_ERROR            12
-#define ASN1_MEM_ALLOC_ERROR      13
-#define ASN1_DER_OVERFLOW          14
-#define ASN1_NAME_TOO_LONG         15
-#define ASN1_ARRAY_ERROR           16
-#define ASN1_ELEMENT_NOT_EMPTY     17
-
-/*************************************/
-/* Constants used in asn1_visit_tree */
-/*************************************/
-#define ASN1_PRINT_NAME             1
-#define ASN1_PRINT_NAME_TYPE        2
-#define ASN1_PRINT_NAME_TYPE_VALUE  3
-#define ASN1_PRINT_ALL              4
-
-/*****************************************/
-/* Constants returned by asn1_read_tag   */
-/*****************************************/
-#define ASN1_CLASS_UNIVERSAL        0x00       /* old: 1 */
-#define ASN1_CLASS_APPLICATION      0x40       /* old: 2 */
-#define ASN1_CLASS_CONTEXT_SPECIFIC 0x80       /* old: 3 */
-#define ASN1_CLASS_PRIVATE          0xC0       /* old: 4 */
-#define ASN1_CLASS_STRUCTURED       0x20
-
-/*****************************************/
-/* Constants returned by asn1_read_tag   */
-/*****************************************/
-#define ASN1_TAG_BOOLEAN          0x01
-#define ASN1_TAG_INTEGER          0x02
-#define ASN1_TAG_SEQUENCE         0x10
-#define ASN1_TAG_SET              0x11
-#define ASN1_TAG_OCTET_STRING     0x04
-#define ASN1_TAG_BIT_STRING       0x03
-#define ASN1_TAG_UTCTime          0x17
-#define ASN1_TAG_GENERALIZEDTime  0x18
-#define ASN1_TAG_OBJECT_ID        0x06
-#define ASN1_TAG_ENUMERATED       0x0A
-#define ASN1_TAG_NULL             0x05
-#define ASN1_TAG_GENERALSTRING    0x1B
-
-/******************************************************/
-/* Structure definition used for the node of the tree */
-/* that represent an ASN.1 DEFINITION.                */
-/******************************************************/
-
-#define SMALL_VALUE_SIZE 16
+#define ASN1_TAG_BOOLEAN               0x01
+#define ASN1_TAG_INTEGER               0x02
+#define ASN1_TAG_SEQUENCE              0x10
+#define ASN1_TAG_SET                   0x11
+#define ASN1_TAG_OCTET_STRING          0x04
+#define ASN1_TAG_BIT_STRING            0x03
+#define ASN1_TAG_UTCTime               0x17
+#define ASN1_TAG_GENERALIZEDTime       0x18
+#define ASN1_TAG_OBJECT_ID             0x06
+#define ASN1_TAG_ENUMERATED            0x0A
+#define ASN1_TAG_NULL                  0x05
+#define ASN1_TAG_GENERALSTRING         0x1B
+
+  /******************************************************/
+  /* Structure definition used for the node of the tree */
+  /* that represent an ASN.1 DEFINITION.                */
+  /******************************************************/
 
   struct node_asn_struct
   {
     char *name;                        /* Node name */
     unsigned int type;         /* Node type */
     unsigned char *value;      /* Node value */
-    unsigned char small_value[SMALL_VALUE_SIZE]; /* if value is less than that store it here */
     int value_len;
     struct node_asn_struct *down;      /* Pointer to the son node */
     struct node_asn_struct *right;     /* Pointer to the brother node */
@@ -125,16 +113,29 @@ extern "C"
 
 #define ASN1_TYPE_EMPTY  NULL
 
+  /*****************************************/
+  /* For the on-disk format of ASN.1 trees */
+  /*****************************************/
   struct static_struct_asn
   {
-    const char *name;                  /* Node name */
-    unsigned int type;         /* Node type */
+    const char *name;  /* Node name */
+    unsigned int type; /* Node type */
     const void *value; /* Node value */
   };
-
   typedef struct static_struct_asn ASN1_ARRAY_TYPE;
 
+  /***********************************/
+  /*  Fixed constants                */
+  /***********************************/
 
+  /* maximum number of characters of a name */
+  /* inside a file with ASN1 definitons     */
+#define ASN1_MAX_NAME_SIZE 128
+
+  /* maximum number of characters */
+  /* of a description message     */
+  /* (null character included)    */
+#define ASN1_MAX_ERROR_DESCRIPTION_SIZE 128
 
   /***********************************/
   /*  Functions definitions          */
@@ -198,7 +199,7 @@ extern "C"
                                         const char *octetName,
                                         const char *objectName);
 
-  asn1_retCode asn1_read_tag (node_asn * root, const char *name,
+  asn1_retCode asn1_read_tag (ASN1_TYPE root, const char *name,
                              int *tagValue, int *classValue);
 
   const char *asn1_find_structure_from_oid (ASN1_TYPE definitions,
@@ -206,9 +207,8 @@ extern "C"
 
   const char *asn1_check_version (const char *req_version);
 
-  const char *libtasn1_strerror (asn1_retCode error);
-
-  void libtasn1_perror (asn1_retCode error);
+  const char *asn1_strerror (asn1_retCode error);
+  void asn1_perror (asn1_retCode error);
 
   /* DER utility functions. */
 
@@ -231,7 +231,7 @@ extern "C"
 
   signed long asn1_get_length_der (const unsigned char *der, int der_len,
                                   int *len);
-  long asn1_get_length_ber (const unsigned char *ber, int ber_len,
+  signed long asn1_get_length_ber (const unsigned char *ber, int ber_len,
                                   int *len);
 
   void asn1_length_der (unsigned long int len, unsigned char *ans,
@@ -244,6 +244,38 @@ extern "C"
   asn1_retCode asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
                               ASN1_TYPE src, const char *src_name);
 
+
+  /* Deprecated stuff. */
+
+#ifndef ASN1_DISABLE_DEPRECATED
+
+#define LIBTASN1_VERSION ASN1_VERSION
+
+#ifndef MAX_NAME_SIZE
+# define MAX_NAME_SIZE ASN1_MAX_NAME_SIZE
+#endif
+
+#ifndef MAX_ERROR_DESCRIPTION_SIZE
+# define MAX_ERROR_DESCRIPTION_SIZE ASN1_MAX_ERROR_DESCRIPTION_SIZE
+#endif
+
+#ifndef __attribute__
+  /* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+#  define __attribute__(Spec)  /* empty */
+# endif
+#endif
+
+  /* Use asn1_strerror instead. */
+  const char *libtasn1_strerror (asn1_retCode error)
+    __attribute__ ((deprecated));
+
+  /* Use asn1_perror instead. */
+  void libtasn1_perror (asn1_retCode error)
+    __attribute__ ((deprecated));
+
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 43522dace65bbc6ce61982bf0cfcb4aaeebf8d48..03d369736ec419ce57eda0d278ed4b06fcec913f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *      Copyright (C) 2004, 2006, 2007 Free Software Foundation
+ *      Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation
  *      Copyright (C) 2000,2001 Fabio Fiorina
  *
  * This file is part of LIBTASN1.
@@ -27,7 +27,7 @@
 #include "structure.h"
 #include "element.h"
 
-char _asn1_identifierMissing[MAX_NAME_SIZE + 1];       /* identifier name not found */
+char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1];  /* identifier name not found */
 
 /***********************************************/
 /* Type: list_type                             */
@@ -36,7 +36,7 @@ char _asn1_identifierMissing[MAX_NAME_SIZE + 1];      /* identifier name not found */
 /***********************************************/
 typedef struct list_struct
 {
-  node_asn *node;
+  ASN1_TYPE node;
   struct list_struct *next;
 } list_type;
 
@@ -53,13 +53,13 @@ list_type *firstElement = NULL;
 /*         and CONST_ constants).                     */
 /* Return: pointer to the new element.                */
 /******************************************************/
-node_asn *
+ASN1_TYPE
 _asn1_add_node (unsigned int type)
 {
   list_type *listElement;
-  node_asn *punt;
+  ASN1_TYPE punt;
 
-  punt = (node_asn *) _asn1_calloc (1, sizeof (node_asn));
+  punt = (ASN1_TYPE) _asn1_calloc (1, sizeof (struct node_asn_struct));
   if (punt == NULL)
     return NULL;
 
@@ -94,8 +94,8 @@ _asn1_add_node (unsigned int type)
 ASN1_TYPE
 asn1_find_node (ASN1_TYPE pointer, const char *name)
 {
-  node_asn *p;
-  char *n_end, n[MAX_NAME_SIZE + 1];
+  ASN1_TYPE p;
+  char *n_end, n[ASN1_MAX_NAME_SIZE + 1];
   const char *n_start;
 
   if (pointer == NULL)
@@ -198,14 +198,14 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
 /*   len: character number of value.                              */
 /* Return: pointer to the NODE_ASN element.                       */
 /******************************************************************/
-node_asn *
-_asn1_set_value (node_asn * node, const void *value, unsigned int len)
+ASN1_TYPE 
+_asn1_set_value (ASN1_TYPE  node, const void *value, unsigned int len)
 {
   if (node == NULL)
     return node;
   if (node->value)
     {
-      if (node->value != node->small_value) _asn1_free (node->value);
+      _asn1_free (node->value);
       node->value = NULL;
       node->value_len = 0;
     }
@@ -213,13 +213,9 @@ _asn1_set_value (node_asn * node, const void *value, unsigned int len)
   if (!len)
     return node;
 
-  if (len < sizeof(node->small_value)) {
-      node->value = node->small_value;
-  } else {
-      node->value = _asn1_malloc (len);
-      if (node->value == NULL)
-        return NULL;
-  }
+  node->value = (unsigned char *) _asn1_malloc (len);
+  if (node->value == NULL)
+    return NULL;
   node->value_len = len;
 
   memcpy (node->value, value, len);
@@ -237,8 +233,8 @@ _asn1_set_value (node_asn * node, const void *value, unsigned int len)
 /*   len: character number of value.                              */
 /* Return: pointer to the NODE_ASN element.                       */
 /******************************************************************/
-node_asn *
-_asn1_set_value_octet (node_asn * node, const void *value, unsigned int len)
+ASN1_TYPE 
+_asn1_set_value_octet (ASN1_TYPE  node, const void *value, unsigned int len)
 {
 int len2;
 void* temp;
@@ -258,15 +254,15 @@ void* temp;
 /* the same as _asn1_set_value except that it sets an already malloc'ed
  * value.
  */
-node_asn *
-_asn1_set_value_m (node_asn * node, void *value, unsigned int len)
+ASN1_TYPE 
+_asn1_set_value_m (ASN1_TYPE  node, void *value, unsigned int len)
 {
   if (node == NULL)
     return node;
 
   if (node->value)
     {
-      if (node->value != node->small_value) _asn1_free (node->value);
+      _asn1_free (node->value);
       node->value = NULL;
       node->value_len = 0;
     }
@@ -290,38 +286,24 @@ _asn1_set_value_m (node_asn * node, void *value, unsigned int len)
 /*   len: character number of value.                              */
 /* Return: pointer to the NODE_ASN element.                       */
 /******************************************************************/
-node_asn *
-_asn1_append_value (node_asn * node, const void *value, unsigned int len)
+ASN1_TYPE 
+_asn1_append_value (ASN1_TYPE  node, const void *value, unsigned int len)
 {
   if (node == NULL)
     return node;
-  if (node->value != NULL && node->value != node->small_value) /* value is allocated */
+  if (node->value != NULL) /* value is allocated */
     {
       int prev_len = node->value_len;
       node->value_len+=len;
       node->value = _asn1_realloc( node->value, node->value_len);
       if (node->value == NULL) {
-        node->value_len = 0;
-        return NULL;
+       node->value_len = 0;
+       return NULL;
       }
       memcpy( &node->value[prev_len], value, len);
-      
+
       return node;
     }
-  else if (node->value == node->small_value) /* value is in node */
-    {
-      int prev_len = node->value_len;
-      node->value_len+=len;
-      node->value = _asn1_malloc( node->value_len);
-      if (node->value == NULL) {
-        node->value_len = 0;
-        return NULL;
-      }
-      memcpy( node->value, node->small_value, prev_len);
-      memcpy( &node->value[prev_len], value, len);
-      
-      return node;
-    } 
   else /* node->value == NULL */
     return _asn1_set_value(node, value, len);
 }
@@ -336,8 +318,8 @@ _asn1_append_value (node_asn * node, const void *value, unsigned int len)
 /*         to set.                                                */
 /* Return: pointer to the NODE_ASN element.                       */
 /******************************************************************/
-node_asn *
-_asn1_set_name (node_asn * node, const char *name)
+ASN1_TYPE 
+_asn1_set_name (ASN1_TYPE  node, const char *name)
 {
   if (node == NULL)
     return node;
@@ -371,8 +353,8 @@ _asn1_set_name (node_asn * node, const char *name)
 /*          by NODE.                                              */
 /* Return: pointer to *NODE.                                      */
 /******************************************************************/
-node_asn *
-_asn1_set_right (node_asn * node, node_asn * right)
+ASN1_TYPE 
+_asn1_set_right (ASN1_TYPE  node, ASN1_TYPE  right)
 {
   if (node == NULL)
     return node;
@@ -390,8 +372,8 @@ _asn1_set_right (node_asn * node, node_asn * right)
 /*   node: NODE_ASN element pointer.                              */
 /* Return: field RIGHT of NODE.                                   */
 /******************************************************************/
-node_asn *
-_asn1_get_right (node_asn * node)
+ASN1_TYPE 
+_asn1_get_right (ASN1_TYPE  node)
 {
   if (node == NULL)
     return NULL;
@@ -405,10 +387,10 @@ _asn1_get_right (node_asn * node)
 /*   node: starting element pointer.                              */
 /* Return: pointer to the last element along the right chain.     */
 /******************************************************************/
-node_asn *
-_asn1_get_last_right (node_asn * node)
+ASN1_TYPE 
+_asn1_get_last_right (ASN1_TYPE  node)
 {
-  node_asn *p;
+  ASN1_TYPE p;
 
   if (node == NULL)
     return NULL;
@@ -427,8 +409,8 @@ _asn1_get_last_right (node_asn * node)
 /*          by NODE.                                              */
 /* Return: pointer to *NODE.                                      */
 /******************************************************************/
-node_asn *
-_asn1_set_down (node_asn * node, node_asn * down)
+ASN1_TYPE 
+_asn1_set_down (ASN1_TYPE  node, ASN1_TYPE  down)
 {
   if (node == NULL)
     return node;
@@ -446,8 +428,8 @@ _asn1_set_down (node_asn * node, node_asn * down)
 /*   node: NODE_ASN element pointer.                              */
 /* Return: field DOWN of NODE.                                    */
 /******************************************************************/
-node_asn *
-_asn1_get_down (node_asn * node)
+ASN1_TYPE 
+_asn1_get_down (ASN1_TYPE  node)
 {
   if (node == NULL)
     return NULL;
@@ -462,7 +444,7 @@ _asn1_get_down (node_asn * node)
 /* Return: a null terminated string.                              */
 /******************************************************************/
 char *
-_asn1_get_name (node_asn * node)
+_asn1_get_name (ASN1_TYPE  node)
 {
   if (node == NULL)
     return NULL;
@@ -480,8 +462,8 @@ _asn1_get_name (node_asn * node)
 /*          value of field TYPE.                                  */
 /* Return: NODE pointer.                                          */
 /******************************************************************/
-node_asn *
-_asn1_mod_type (node_asn * node, unsigned int value)
+ASN1_TYPE 
+_asn1_mod_type (ASN1_TYPE  node, unsigned int value)
 {
   if (node == NULL)
     return node;
@@ -498,14 +480,14 @@ _asn1_mod_type (node_asn * node, unsigned int value)
 /*   node: NODE_ASN element pointer.                              */
 /******************************************************************/
 void
-_asn1_remove_node (node_asn * node)
+_asn1_remove_node (ASN1_TYPE  node)
 {
   if (node == NULL)
     return;
 
   if (node->name != NULL)
     _asn1_free (node->name);
-  if (node->value != NULL && node->value != node->small_value)
+  if (node->value != NULL)
     _asn1_free (node->value);
   _asn1_free (node);
 }
@@ -517,10 +499,10 @@ _asn1_remove_node (node_asn * node)
 /*   node: NODE_ASN element pointer.                              */
 /* Return: Null if not found.                                     */
 /******************************************************************/
-node_asn *
-_asn1_find_up (node_asn * node)
+ASN1_TYPE 
+_asn1_find_up (ASN1_TYPE  node)
 {
-  node_asn *p;
+  ASN1_TYPE p;
 
   if (node == NULL)
     return NULL;
@@ -618,7 +600,7 @@ _asn1_ltostr (long v, char *str)
 asn1_retCode
 _asn1_change_integer_value (ASN1_TYPE node)
 {
-  node_asn *p;
+  ASN1_TYPE p;
   unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
   unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
   int len;
@@ -685,8 +667,8 @@ _asn1_change_integer_value (ASN1_TYPE node)
 asn1_retCode
 _asn1_expand_object_id (ASN1_TYPE node)
 {
-  node_asn *p, *p2, *p3, *p4, *p5;
-  char name_root[MAX_NAME_SIZE], name2[2 * MAX_NAME_SIZE + 1];
+  ASN1_TYPE p, p2, p3, p4, p5;
+  char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1];
   int move, tlen;
 
   if (node == NULL)
@@ -866,7 +848,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
 asn1_retCode
 _asn1_type_set_config (ASN1_TYPE node)
 {
-  node_asn *p, *p2;
+  ASN1_TYPE p, p2;
   int move;
 
   if (node == NULL)
@@ -939,8 +921,8 @@ _asn1_type_set_config (ASN1_TYPE node)
 asn1_retCode
 _asn1_check_identifier (ASN1_TYPE node)
 {
-  node_asn *p, *p2;
-  char name2[MAX_NAME_SIZE * 2 + 2];
+  ASN1_TYPE p, p2;
+  char name2[ASN1_MAX_NAME_SIZE * 2 + 2];
 
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
@@ -1043,7 +1025,7 @@ _asn1_check_identifier (ASN1_TYPE node)
 asn1_retCode
 _asn1_set_default_tag (ASN1_TYPE node)
 {
-  node_asn *p;
+  ASN1_TYPE p;
 
   if ((node == NULL) || (type_field (node->type) != TYPE_DEFINITIONS))
     return ASN1_ELEMENT_NOT_FOUND;
@@ -1139,7 +1121,7 @@ parse_version_string (const char *s, int *major, int *minor, int *micro)
  * condition is not satisfied.  If a %NULL is passed to this function,
  * no check is done, but the version string is simply returned.
  *
- * See %LIBTASN1_VERSION for a suitable @req_version string.
+ * See %ASN1_VERSION for a suitable @req_version string.
  *
  * Return value: Version string of run-time library, or %NULL if the
  *   run-time library does not meet the required version number.
@@ -1147,7 +1129,7 @@ parse_version_string (const char *s, int *major, int *minor, int *micro)
 const char *
 asn1_check_version (const char *req_version)
 {
-  const char *ver = LIBTASN1_VERSION;
+  const char *ver = ASN1_VERSION;
   int my_major, my_minor, my_micro;
   int rq_major, rq_minor, rq_micro;
   const char *my_plvl, *rq_plvl;
index 6e18bb69c2cecf82f8b93c57e88473c3071c347e..d30a34ca975567743164d0fe7a7fe342b6d935ab 100644 (file)
@@ -7,47 +7,47 @@
 /***************************************/
 /*  Functions used by ASN.1 parser     */
 /***************************************/
-node_asn *
+ASN1_TYPE
 _asn1_add_node(unsigned int type);
 
-node_asn *
-_asn1_set_value(node_asn *node,const void *value,unsigned int len);
+ASN1_TYPE
+_asn1_set_value(ASN1_TYPE node,const void *value,unsigned int len);
 
-node_asn *
-_asn1_set_value_m(node_asn *node,void *value,unsigned int len);
+ASN1_TYPE
+_asn1_set_value_m(ASN1_TYPE node,void *value,unsigned int len);
 
-node_asn *
-_asn1_set_value_octet(node_asn *node,const void *value,unsigned int len);
+ASN1_TYPE
+_asn1_set_value_octet(ASN1_TYPE node,const void *value,unsigned int len);
 
-node_asn *
-_asn1_append_value(node_asn *node,const void *value,unsigned int len);
+ASN1_TYPE
+_asn1_append_value(ASN1_TYPE node,const void *value,unsigned int len);
 
-node_asn *
-_asn1_set_name(node_asn *node,const char *name);
+ASN1_TYPE
+_asn1_set_name(ASN1_TYPE node,const char *name);
 
-node_asn *
-_asn1_set_right(node_asn *node,node_asn *right);
+ASN1_TYPE
+_asn1_set_right(ASN1_TYPE node, ASN1_TYPE right);
 
-node_asn *
-_asn1_get_right(node_asn *node);
+ASN1_TYPE
+_asn1_get_right(ASN1_TYPE node);
 
-node_asn *
-_asn1_get_last_right(node_asn *node);
+ASN1_TYPE
+_asn1_get_last_right(ASN1_TYPE node);
 
-node_asn *
-_asn1_set_down(node_asn *node,node_asn *down);
+ASN1_TYPE
+_asn1_set_down(ASN1_TYPE node, ASN1_TYPE down);
 
 char *
-_asn1_get_name(node_asn *node);
+_asn1_get_name(ASN1_TYPE node);
 
-node_asn *
-_asn1_get_down(node_asn *node);
+ASN1_TYPE
+_asn1_get_down(ASN1_TYPE node);
 
-node_asn *
-_asn1_mod_type(node_asn *node,unsigned int value);
+ASN1_TYPE
+_asn1_mod_type(ASN1_TYPE node,unsigned int value);
 
 void
-_asn1_remove_node(node_asn *node);
+_asn1_remove_node(ASN1_TYPE node);
 
 void _asn1_delete_list(void);
 
@@ -55,7 +55,7 @@ void _asn1_delete_list_and_nodes(void);
 
 char * _asn1_ltostr(long v,char *str);
 
-node_asn * _asn1_find_up(node_asn *node);
+ASN1_TYPE _asn1_find_up(ASN1_TYPE node);
 
 asn1_retCode _asn1_change_integer_value(ASN1_TYPE node);
 
index a7a4c623b9257d902e88340c4522f85785003b98..522704563370070ff3f34d51a4bd0d9481e679e2 100644 (file)
@@ -46,12 +46,12 @@ extern char _asn1_identifierMissing[];
 /*         and CONST_ constants).                     */
 /* Return: pointer to the new element.                */
 /******************************************************/
-node_asn *
+ASN1_TYPE
 _asn1_add_node_only (unsigned int type)
 {
-  node_asn *punt;
+  ASN1_TYPE punt;
 
-  punt = (node_asn *) _asn1_calloc (1, sizeof (node_asn));
+  punt = (ASN1_TYPE) _asn1_calloc (1, sizeof (struct node_asn_struct));
   if (punt == NULL)
     return NULL;
 
@@ -69,8 +69,8 @@ _asn1_add_node_only (unsigned int type)
 /*   node: NODE_ASN element pointer.                              */
 /* Return: NULL if not found.                                     */
 /******************************************************************/
-node_asn *
-_asn1_find_left (node_asn * node)
+ASN1_TYPE
+_asn1_find_left (ASN1_TYPE  node)
 {
   if ((node == NULL) || (node->left == NULL) || (node->left->down == node))
     return NULL;
@@ -84,7 +84,7 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
                               char *vector_name)
 {
   FILE *file;
-  node_asn *p;
+  ASN1_TYPE p;
   unsigned long t;
 
   file = fopen (output_file_name, "w");
@@ -184,7 +184,7 @@ asn1_retCode
 asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
                 char *errorDescription)
 {
-  node_asn *p, *p_last = NULL;
+  ASN1_TYPE p, p_last = NULL;
   unsigned long k;
   int move;
   asn1_retCode result;
@@ -295,7 +295,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
 asn1_retCode
 asn1_delete_structure (ASN1_TYPE * structure)
 {
-  node_asn *p, *p2, *p3;
+  ASN1_TYPE p, p2, p3;
 
   if (*structure == ASN1_TYPE_EMPTY)
     return ASN1_ELEMENT_NOT_FOUND;
@@ -363,7 +363,7 @@ asn1_delete_structure (ASN1_TYPE * structure)
 asn1_retCode
 asn1_delete_element (ASN1_TYPE structure, const char *element_name)
 {
-  node_asn *p2, *p3, *source_node;
+  ASN1_TYPE p2, p3, source_node;
 
   source_node = asn1_find_node (structure, element_name);
 
@@ -386,10 +386,10 @@ asn1_delete_element (ASN1_TYPE structure, const char *element_name)
   return asn1_delete_structure (&source_node);
 }
 
-node_asn *
-_asn1_copy_structure3 (node_asn * source_node)
+ASN1_TYPE
+_asn1_copy_structure3 (ASN1_TYPE  source_node)
 {
-  node_asn *dest_node, *p_s, *p_d, *p_d_prev;
+  ASN1_TYPE dest_node, p_s, p_d, p_d_prev;
   int move;
 
   if (source_node == NULL)
@@ -409,7 +409,7 @@ _asn1_copy_structure3 (node_asn * source_node)
          if (p_s->name)
            _asn1_set_name (p_d, p_s->name);
          if (p_s->value)
-           _asn1_set_value (p_d, p_s->value, p_s->value_len);
+             _asn1_set_value (p_d, p_s->value, p_s->value_len);
          move = DOWN;
        }
       else
@@ -455,10 +455,10 @@ _asn1_copy_structure3 (node_asn * source_node)
 }
 
 
-node_asn *
-_asn1_copy_structure2 (node_asn * root, const char *source_name)
+static ASN1_TYPE
+_asn1_copy_structure2 (ASN1_TYPE  root, const char *source_name)
 {
-  node_asn *source_node;
+  ASN1_TYPE source_node;
 
   source_node = asn1_find_node (root, source_name);
 
@@ -468,9 +468,9 @@ _asn1_copy_structure2 (node_asn * root, const char *source_name)
 
 
 asn1_retCode
-_asn1_type_choice_config (node_asn * node)
+_asn1_type_choice_config (ASN1_TYPE  node)
 {
-  node_asn *p, *p2, *p3, *p4;
+  ASN1_TYPE p, p2, p3, p4;
   int move, tlen;
 
   if (node == NULL)
@@ -553,10 +553,10 @@ _asn1_type_choice_config (node_asn * node)
 
 
 asn1_retCode
-_asn1_expand_identifier (node_asn ** node, node_asn * root)
+_asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE  root)
 {
-  node_asn *p, *p2, *p3;
-  char name2[MAX_NAME_SIZE + 2];
+  ASN1_TYPE p, p2, p3;
+  char name2[ASN1_MAX_NAME_SIZE + 2];
   int move;
 
   if (node == NULL)
@@ -684,7 +684,7 @@ asn1_retCode
 asn1_create_element (ASN1_TYPE definitions, const char *source_name,
                     ASN1_TYPE * element)
 {
-  node_asn *dest_node;
+  ASN1_TYPE dest_node;
   int res;
 
   dest_node = _asn1_copy_structure2 (definitions, source_name);
@@ -719,7 +719,7 @@ void
 asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
                      int mode)
 {
-  node_asn *p, *root;
+  ASN1_TYPE p, root;
   int k, indent = 0, len, len2, len3;
 
   if (out == NULL)
@@ -1088,7 +1088,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
 asn1_retCode
 asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
 {
-  node_asn *node, *p;
+  ASN1_TYPE node, p;
 
   if (num == NULL)
     return ASN1_GENERIC_ERROR;
@@ -1127,8 +1127,8 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
 const char *
 asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
 {
-  char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1];
-  char value[MAX_NAME_SIZE];
+  char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1];
+  char value[ASN1_MAX_NAME_SIZE];
   ASN1_TYPE p;
   int len;
   asn1_retCode result;
@@ -1150,7 +1150,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
          strcpy (name, definitionsName);
          strcat (name, p->name);
 
-         len = MAX_NAME_SIZE;
+         len = ASN1_MAX_NAME_SIZE;
          result = asn1_read_value (definitions, name, value, &len);
 
          if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value)))
index 4c78391e3fcbc462f2601582f58974a60fe69281..1803e7ab041bbb13783d7e897329533f60c73ce7 100644 (file)
@@ -8,16 +8,14 @@
 #ifndef _STRUCTURE_H
 #define _STRUCTURE_H
 
-asn1_retCode _asn1_create_static_structure(node_asn *pointer,
+asn1_retCode _asn1_create_static_structure(ASN1_TYPE pointer,
        char* output_file_name,char *vector_name);
 
-node_asn* _asn1_copy_structure3(node_asn *source_node);
+ASN1_TYPE _asn1_copy_structure3(ASN1_TYPE source_node);
 
-node_asn* _asn1_copy_structure2(node_asn *root,const char *source_name);
+ASN1_TYPE  _asn1_add_node_only(unsigned int type);
 
-node_asn * _asn1_add_node_only(unsigned int type);
-
-node_asn * _asn1_find_left(node_asn *node);
+ASN1_TYPE  _asn1_find_left(ASN1_TYPE node);
 
 #endif