]> git.sur5r.net Git - openldap/commitdiff
Add ATDESC config arg type for AttributeDescriptions
authorHoward Chu <hyc@openldap.org>
Mon, 20 Apr 2009 00:31:33 +0000 (00:31 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 20 Apr 2009 00:31:33 +0000 (00:31 +0000)
servers/slapd/config.c
servers/slapd/config.h

index a343eae17401e5f9f1b399f0b9c3817916460434..c9763bf8be0a853e261675708f1cc6cbce97457e 100644 (file)
@@ -216,6 +216,16 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
                        ch_free( c->value_ndn.bv_val );
                        ch_free( c->value_dn.bv_val );
                }
+       } else if(arg_type == ARG_ATDESC) {
+               const char *text = NULL;
+               c->value_ad = NULL;
+               rc = slap_str2ad( c->argv[1], &c->value_ad, &text );
+               if ( rc != LDAP_SUCCESS ) {
+                       snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid AttributeDescription %d (%s)",
+                               c->argv[0], rc, text );
+                       Debug(LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s\n" , c->log, c->cr_msg, 0);
+                       return(ARG_BAD_CONF);
+               }
        } else {        /* all numeric */
                int j;
                iarg = 0; larg = 0; barg = 0;
@@ -366,6 +376,9 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
                        case ARG_BERVAL:
                                *(struct berval *)ptr = c->value_bv;
                                break;
+                       case ARG_ATDESC:
+                               *(AttributeDescription **)ptr = c->value_ad;
+                               break;
                }
        return(0);
 }
@@ -443,6 +456,8 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
                        break;
                case ARG_BERVAL:
                        ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
+               case ARG_ATDESC:
+                       c->value_ad = *(AttributeDescription **)ptr; break;
                }
        }
        if ( cf->arg_type & ARGS_TYPES) {
@@ -469,6 +484,13 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
                                return 1;
                        }
                        break;
+               case ARG_ATDESC:
+                       if ( c->value_ad ) {
+                               bv = c->value_ad->ad_cname;
+                       } else {
+                               return 1;
+                       }
+                       break;
                default:
                        bv.bv_val = NULL;
                        break;
index 4dc902dac9336f07795f5997169dedd05efd52e9..b076a42e6cf82764724d67dc621aec2b809faf1d 100644 (file)
@@ -58,6 +58,7 @@ typedef enum {
 #define ARG_BERVAL     0x00006000
 #define ARG_DN         0x00007000
 #define ARG_UINT       0x00008000
+#define ARG_ATDESC     0x00009000
 
 #define ARGS_SYNTAX    0xffff0000
 #define ARG_IGNORED    0x00080000
@@ -140,6 +141,7 @@ typedef struct config_args_s {
                        struct berval vdn_dn;
                        struct berval vdn_ndn;
                } v_dn;
+               AttributeDescription *v_ad;
        } values;
        /* return values for emit mode */
        BerVarray rvalue_vals;
@@ -170,6 +172,7 @@ typedef struct config_args_s {
 #define value_bv values.v_bv
 #define value_dn values.v_dn.vdn_dn
 #define value_ndn values.v_dn.vdn_ndn
+#define value_ad values.v_ad
 
 int config_fp_parse_line(ConfigArgs *c);