]> git.sur5r.net Git - openldap/commitdiff
union of operation-specific data in LDIFRecord (ITS#6194, by Rich Megginson)
authorPierangelo Masarati <ando@openldap.org>
Tue, 13 Apr 2010 07:37:59 +0000 (07:37 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 13 Apr 2010 07:37:59 +0000 (07:37 +0000)
clients/tools/ldapmodify.c
include/ldap.h
libraries/libldap/ldifutil.c

index afbff968bcbfec823256a76f010865b486433205..b0dc2f930c9636c2a08932a65d2ef15e8ea015ad 100644 (file)
@@ -444,9 +444,9 @@ process_ldif_rec( char *rbuf, int linenum )
                if ( LDAP_REQ_DELETE == lr.lr_op ) {
                        rc = dodelete( &lr.lr_dn, lr.lr_ctrls );
                } else if ( LDAP_REQ_RENAME == lr.lr_op ) {
-                       rc = dorename( &lr.lr_dn, &lr.lr_newrdn, &lr.lr_newsuperior, lr.lr_deleteoldrdn, lr.lr_ctrls );
+                       rc = dorename( &lr.lr_dn, &lr.lrop_newrdn, &lr.lrop_newsup, lr.lrop_delold, lr.lr_ctrls );
                } else if ( ( LDAP_REQ_ADD == lr.lr_op ) || ( LDAP_REQ_MODIFY == lr.lr_op ) ) {
-                       rc = domodify( &lr.lr_dn, lr.lr_mods, lr.lr_ctrls, LDAP_REQ_ADD == lr.lr_op );
+                       rc = domodify( &lr.lr_dn, lr.lrop_mods, lr.lr_ctrls, LDAP_REQ_ADD == lr.lr_op );
                } else {
                        /* record skipped e.g. version: or comment or something we don't handle yet */
                }
index f51d2b4c9fd6724d59a7d9e0379714b98e2afda1..aec07379f14e0abd458526f3519432c4e13fbccd 100644 (file)
@@ -2498,15 +2498,33 @@ typedef struct ldifrecord {
        struct berval lr_dn; /* DN of operation */
        LDAPControl **lr_ctrls; /* controls specified for operation */
        /* some ops such as LDAP_REQ_DELETE require only a DN */
-       LDAPMod **lr_mods; /* list of mods for LDAP_REQ_MODIFY, LDAP_REQ_ADD */
-       struct berval lr_newrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
-       struct berval lr_newsuperior; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
-       int lr_deleteoldrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
-       /* the following are for future support */
-       struct berval lr_extop_oid; /* LDAP_REQ_EXTENDED */
-       struct berval lr_extop_data; /* LDAP_REQ_EXTENDED */
-       struct berval lr_cmp_attr; /* LDAP_REQ_COMPARE */
-       struct berval lr_cmp_bvalue; /* LDAP_REQ_COMPARE */
+       /* other ops require different data - the ldif_ops union
+          is used to specify the data for each type of operation */
+       union ldif_ops_u {
+               LDAPMod **lr_mods; /* list of mods for LDAP_REQ_MODIFY, LDAP_REQ_ADD */
+#define lrop_mods ldif_ops.lr_mods
+               struct ldif_op_rename_s {
+                       struct berval lr_newrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
+#define lrop_newrdn ldif_ops.ldif_op_rename.lr_newrdn
+                       struct berval lr_newsuperior; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
+#define lrop_newsup ldif_ops.ldif_op_rename.lr_newsuperior
+                       int lr_deleteoldrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
+#define lrop_delold ldif_ops.ldif_op_rename.lr_deleteoldrdn
+               } ldif_op_rename; /* rename/moddn/modrdn */
+               /* the following are for future support */
+               struct ldif_op_ext_s {
+                       struct berval lr_extop_oid; /* LDAP_REQ_EXTENDED */
+#define lrop_extop_oid ldif_ops.ldif_op_ext.lr_extop_oid
+                       struct berval lr_extop_data; /* LDAP_REQ_EXTENDED */
+#define lrop_extop_data ldif_ops.ldif_op_ext.lr_extop_data
+               } ldif_op_ext; /* extended operation */
+               struct ldif_op_cmp_s {
+                       struct berval lr_cmp_attr; /* LDAP_REQ_COMPARE */
+#define lrop_cmp_attr ldif_ops.ldif_op_cmp.lr_cmp_attr
+                       struct berval lr_cmp_bvalue; /* LDAP_REQ_COMPARE */
+#define lrop_cmp_bval ldif_ops.ldif_op_cmp.lr_cmp_bvalue
+               } ldif_op_cmp; /* compare operation */
+       } ldif_ops;
        /* PRIVATE STUFF - DO NOT TOUCH */
        /* for efficiency, the implementation allocates memory */
        /* in large blobs, and makes the above fields point to */
index 8788d78f78d8d9e83bd17401a4db9227a481ef7d..407c276d4e37a991b00c805d9d9c4c1ad43391d4 100644 (file)
@@ -276,7 +276,7 @@ short_input:
                                rc = LDAP_PARAM_ERROR;
                                goto leave;
                        }
-                       lr->lr_newrdn = lr->lr_vals[i];
+                       lr->lrop_newrdn = lr->lr_vals[i];
                        i++;
                        if ( i >= lr->lr_lines )
                                goto short_input;
@@ -287,7 +287,7 @@ short_input:
                                rc = LDAP_PARAM_ERROR;
                                goto leave;
                        }
-                       lr->lr_deleteoldrdn = ( lr->lr_vals[i].bv_val[0] == '0' ) ? 0 : 1;
+                       lr->lrop_delold = ( lr->lr_vals[i].bv_val[0] == '0' ) ? 0 : 1;
                        i++;
                        if ( i < lr->lr_lines ) {
                                if ( !BV_CASEMATCH( lr->lr_btype+i, &BV_NEWSUP )) {
@@ -297,7 +297,7 @@ short_input:
                                        rc = LDAP_PARAM_ERROR;
                                        goto leave;
                                }
-                               lr->lr_newsuperior = lr->lr_vals[i];
+                               lr->lrop_newsup = lr->lr_vals[i];
                                i++;
                        }
                        got_all = 1;
@@ -523,11 +523,11 @@ doit:
        /* next, set the op */
        if ( delete_entry ) {
                lr->lr_op = LDAP_REQ_DELETE;
-       } else if ( lr->lr_newrdn.bv_val != NULL ) {
+       } else if ( lr->lrop_newrdn.bv_val != NULL ) {
                lr->lr_op = LDAP_REQ_MODDN;
        } else {
                /* for now, either add or modify */
-               lr->lr_mods = pmods;
+               lr->lrop_mods = pmods;
                if ( new_entry ) {
                        lr->lr_op = LDAP_REQ_ADD;
                } else {