Added asn1_copy_node2()
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 30 May 2014 13:12:00 +0000 (15:12 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 30 May 2014 13:21:30 +0000 (15:21 +0200)
lib/libtasn1.h
lib/libtasn1.map
lib/structure.c
tests/copynode.c

index a457068..064c10f 100644 (file)
@@ -329,6 +329,8 @@ extern "C"
   extern ASN1_API int
     asn1_copy_node (asn1_node dst, const char *dst_name,
                    asn1_node src, const char *src_name);
+  extern ASN1_API asn1_node
+    asn1_copy_node2 (asn1_node src, const char *src_name);
 
   /* Internal and low-level DER utility functions. */
 
index fa91638..a2b535e 100644 (file)
@@ -54,6 +54,7 @@ LIBTASN1_0_3
     asn1_decode_simple_der;
     asn1_read_value_type;
     asn1_delete_structure2;
+    asn1_copy_node2;
   local:
     *;
 };
index 27fbfe3..2184aa8 100644 (file)
@@ -1128,12 +1128,13 @@ asn1_find_structure_from_oid (asn1_node definitions, const char *oidValue)
 
 /**
  * asn1_copy_node:
- * @dst: Destination asn1_node node.
+ * @dst: Destination asn1 node.
  * @dst_name: Field name in destination node.
- * @src: Source asn1_node node.
+ * @src: Source asn1 node.
  * @src_name: Field name in source node.
  *
- * Create a deep copy of a asn1_node variable.
+ * Create a deep copy of a asn1_node variable. That
+ * function requires @dst to be expanded using asn1_create_element().
  *
  * Returns: Return %ASN1_SUCCESS on success.
  **/
@@ -1141,9 +1142,6 @@ int
 asn1_copy_node (asn1_node dst, const char *dst_name,
                asn1_node src, const char *src_name)
 {
-/* FIXME: rewrite using copy_structure().
- * It seems quite hard to do.
- */
   int result;
   asn1_node dst_node;
   void *data = NULL;
@@ -1177,3 +1175,19 @@ asn1_copy_node (asn1_node dst, const char *dst_name,
 
   return result;
 }
+
+/**
+ * asn1_copy_node2:
+ * @src: Source asn1 node.
+ * @src_name: Field name in source node.
+ *
+ * Create a deep copy of a asn1_node variable. This function
+ * will return an exact copy of the provided structure.
+ *
+ * Returns: Return %NULL on failure.
+ **/
+asn1_node
+asn1_copy_node2 (asn1_node src, const char *src_name)
+{
+  return _asn1_copy_structure2(src, src_name);
+}
index 62e49ec..5e5821f 100644 (file)
@@ -150,7 +150,6 @@ main (int argc, char *argv[])
       exit(1);
     }
 
-#if 0
   asn1_delete_structure (&cpy_node);
 
   /* Test asn1_copy_node2 */
@@ -176,7 +175,6 @@ main (int argc, char *argv[])
       printf("DER encoded data differ!\n");
       exit(1);
     }
-#endif
 
   /* Clear the definition structures */
   asn1_delete_structure (&asn1_element);