summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--configure.in2
-rw-r--r--lib/int.h2
-rw-r--r--lib/libtasn1.h4
-rw-r--r--lib/structure.c38
-rw-r--r--tests/Test_tree.c13
6 files changed, 59 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index f895828..9a06d24 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Version 0.2.8
+- Add asn1_delete_element function
+
Version 0.2.7
- Added versioned symbols.
diff --git a/configure.in b/configure.in
index 040bf68..93c0931 100644
--- a/configure.in
+++ b/configure.in
@@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os", [OS name])
dnl libtasn1 Version
ASN1_MAJOR_VERSION=0
ASN1_MINOR_VERSION=2
-ASN1_MICRO_VERSION=7
+ASN1_MICRO_VERSION=8
ASN1_VERSION=$ASN1_MAJOR_VERSION.$ASN1_MINOR_VERSION.$ASN1_MICRO_VERSION
AC_DEFINE_UNQUOTED(ASN1_VERSION, "$ASN1_VERSION", [version of libtasn1])
diff --git a/lib/int.h b/lib/int.h
index 088cc98..4af32d3 100644
--- a/lib/int.h
+++ b/lib/int.h
@@ -32,7 +32,7 @@
#include <mem.h>
-#define LIBTASN1_VERSION "0.2.7"
+#define LIBTASN1_VERSION "0.2.8"
#define MAX32 4294967295
#define MAX24 16777215
diff --git a/lib/libtasn1.h b/lib/libtasn1.h
index 65faa47..02c1cfc 100644
--- a/lib/libtasn1.h
+++ b/lib/libtasn1.h
@@ -28,7 +28,7 @@
extern "C" {
#endif
-#define LIBTASN1_VERSION "0.2.7"
+#define LIBTASN1_VERSION "0.2.8"
#include <sys/types.h>
#include <time.h>
@@ -145,6 +145,8 @@ asn1_retCode asn1_create_element(ASN1_TYPE definitions,const char *source_name,
asn1_retCode asn1_delete_structure(ASN1_TYPE *structure);
+asn1_retCode asn1_delete_element(ASN1_TYPE structure,const char *element_name);
+
asn1_retCode asn1_write_value(ASN1_TYPE element,const char *name,
const void *value,int len);
diff --git a/lib/structure.c b/lib/structure.c
index 97834e9..f336654 100644
--- a/lib/structure.c
+++ b/lib/structure.c
@@ -299,6 +299,44 @@ asn1_delete_structure(ASN1_TYPE *structure)
}
+/**
+ * asn1_delete_element - Deletes the element of a structure.
+ * @structure: pointer to the structure that contains the element you want to delete.
+ * @element_name: element's name you want to delete.
+ * Description:
+ *
+ * Deletes the element named *element_name inside *structure.
+ *
+ * Returns:
+ *
+ * ASN1_SUCCESS\: everything OK
+ *
+ * ASN1_ELEMENT_NOT_FOUND
+ *
+ **/
+asn1_retCode
+asn1_delete_element(ASN1_TYPE structure,const char *element_name)
+{
+ node_asn *p2,*p3,*source_node;
+
+ source_node=_asn1_find_node(structure,element_name);
+
+ if(source_node==ASN1_TYPE_EMPTY) return ASN1_ELEMENT_NOT_FOUND;
+
+ p2=source_node->right;
+ p3=_asn1_find_left(source_node);
+ if(!p3){
+ p3=_asn1_find_up(source_node);
+ if(p3)
+ _asn1_set_down(p3,p2);
+ else
+ if(source_node->right) source_node->right->left=NULL;
+ }
+ else _asn1_set_right(p3,p2);
+
+ return asn1_delete_structure(&source_node);
+}
+
node_asn *
_asn1_copy_structure3(node_asn *source_node)
diff --git a/tests/Test_tree.c b/tests/Test_tree.c
index d25c28f..d6c5af2 100644
--- a/tests/Test_tree.c
+++ b/tests/Test_tree.c
@@ -57,6 +57,7 @@
#define ACT_ENCODING_LENGTH 18
#define ACT_READ_BIT 19
#define ACT_SET_DER 20
+#define ACT_DELETE_ELEMENT 21
typedef struct{
@@ -82,6 +83,8 @@ test_type test_array[]={
{ACT_CREATE,"TEST_TREE.KrbError",0,0,ASN1_SUCCESS},
{ACT_DECODING,0,0,0,ASN1_SUCCESS},
{ACT_VISIT,"","",ASN1_PRINT_ALL,ASN1_SUCCESS},
+ {ACT_DELETE_ELEMENT,"pvno","",0,ASN1_SUCCESS},
+ {ACT_DELETE_ELEMENT,"pvno","",0,ASN1_ELEMENT_NOT_FOUND},
{ACT_DELETE,"","",0,ASN1_SUCCESS},
/* Test: CHOICE */
@@ -119,6 +122,12 @@ test_type test_array[]={
{ACT_CREATE,"TEST_TREE.CertTemplate",0,0,ASN1_SUCCESS},
{ACT_DECODING,0,0,0,ASN1_SUCCESS},
{ACT_VISIT,"","",ASN1_PRINT_ALL,ASN1_SUCCESS},
+ {ACT_DELETE_ELEMENT,"issuer.rdnSequence.?1","",0,ASN1_SUCCESS},
+ {ACT_DELETE_ELEMENT,"issuer.rdnSequence.?1","",0,ASN1_ELEMENT_NOT_FOUND},
+ {ACT_DELETE_ELEMENT,"issuer.rdnSequence.?3","",0,ASN1_SUCCESS},
+ {ACT_DELETE_ELEMENT,"issuer.rdnSequence.?5","",0,ASN1_SUCCESS},
+ {ACT_DELETE_ELEMENT,"issuer.rdnSequence.?7","",0,ASN1_SUCCESS},
+ {ACT_VISIT,"","",ASN1_PRINT_ALL,ASN1_SUCCESS},
{ACT_DELETE,"","",0,ASN1_SUCCESS},
/* Test: Empty sequnces */
@@ -452,6 +461,9 @@ main(int argc,char *argv[])
case ACT_DELETE:
result=asn1_delete_structure(&asn1_element);
break;
+ case ACT_DELETE_ELEMENT:
+ result=asn1_delete_element(asn1_element,test->par1);
+ break;
case ACT_WRITE:
if((test->par2) && (!strcmp("DER",test->par2)))
result=asn1_write_value(asn1_element,test->par1,der,der_len);
@@ -535,6 +547,7 @@ main(int argc,char *argv[])
switch(test->action){
case ACT_CREATE:
case ACT_DELETE:
+ case ACT_DELETE_ELEMENT:
case ACT_WRITE:
case ACT_VISIT:
case ACT_ENCODING: