diff options
| author | David M. Syzdek <david@syzdek.net> | 2019-11-26 16:22:08 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2019-11-26 16:22:08 -0900 |
| commit | 0de8c61ec5c48d8e39f537869236e31dcba94c43 (patch) | |
| tree | d4da2270797a3fbb1d83ea3d148f7680b89d3d40 | |
| parent | 96d37633238442133afaaf54bd0c7eb72b2990e0 (diff) | |
| download | ldap-utils-0de8c61ec5c48d8e39f537869236e31dcba94c43.tar.gz ldap-utils-0de8c61ec5c48d8e39f537869236e31dcba94c43.tar.bz2 ldap-utils-0de8c61ec5c48d8e39f537869236e31dcba94c43.tar.xz ldap-utils-0de8c61ec5c48d8e39f537869236e31dcba94c43.zip | |
libldapschema: replacing ldapschema_attributetype_initialize()
Replacing ldapschema_attributetype_initialize() with commo function
ldapschema_model_initialize().
| -rw-r--r-- | lib/libldapschema/libldapschema.h | 4 | ||||
| -rw-r--r-- | lib/libldapschema/llexer.c | 31 | ||||
| -rw-r--r-- | lib/libldapschema/lmemory.c | 19 |
3 files changed, 4 insertions, 50 deletions
diff --git a/lib/libldapschema/libldapschema.h b/lib/libldapschema/libldapschema.h index 3d0eeaa..60ff776 100644 --- a/lib/libldapschema/libldapschema.h +++ b/lib/libldapschema/libldapschema.h | |||
| @@ -215,10 +215,6 @@ void | |||
| 215 | ldapschema_attributetype_free( | 215 | ldapschema_attributetype_free( |
| 216 | LDAPSchemaAttributeType * attr ); | 216 | LDAPSchemaAttributeType * attr ); |
| 217 | 217 | ||
| 218 | LDAPSchemaAttributeType * | ||
| 219 | ldapschema_attributetype_initialize( | ||
| 220 | LDAPSchema * lsd ); | ||
| 221 | |||
| 222 | void | 218 | void |
| 223 | ldapschema_ext_free( | 219 | ldapschema_ext_free( |
| 224 | LDAPSchemaExtension * ext ); | 220 | LDAPSchemaExtension * ext ); |
diff --git a/lib/libldapschema/llexer.c b/lib/libldapschema/llexer.c index 9c64991..b009e6a 100644 --- a/lib/libldapschema/llexer.c +++ b/lib/libldapschema/llexer.c | |||
| @@ -479,37 +479,17 @@ LDAPSchemaAttributeType * ldapschema_parse_attributetype(LDAPSchema * lsd, const | |||
| 479 | LDAPSchemaAttributeType * attr; | 479 | LDAPSchemaAttributeType * attr; |
| 480 | LDAPSchemaAlias * alias; | 480 | LDAPSchemaAlias * alias; |
| 481 | 481 | ||
| 482 | attr = NULL; | ||
| 483 | argv = NULL; | ||
| 484 | |||
| 485 | // initialize attributeType | ||
| 486 | if ((attr = ldapschema_attributetype_initialize(lsd)) == NULL) | ||
| 487 | return(NULL); | ||
| 488 | |||
| 489 | // parses definition | 482 | // parses definition |
| 490 | if ((argc = ldapschema_definition_split_len(lsd, &attr->model, def, &argv)) == -1) | 483 | argv = NULL; |
| 491 | { | 484 | if ((argc = ldapschema_definition_split_len(lsd, NULL, def, &argv)) == -1) |
| 492 | ldapschema_attributetype_free(attr); | ||
| 493 | return(NULL); | 485 | return(NULL); |
| 494 | }; | ||
| 495 | 486 | ||
| 496 | // copy definition and oid into syntax | 487 | // initialize syntax |
| 497 | if ((attr->model.oid = strdup(argv[0])) == NULL) | 488 | if ((attr = (LDAPSchemaAttributeType *)ldapschema_model_initialize(lsd, argv[0], LDAPSCHEMA_ATTRIBUTETYPE, def)) == NULL) |
| 498 | { | ||
| 499 | lsd->errcode = LDAPSCHEMA_NO_MEMORY; | ||
| 500 | ldapschema_value_free(argv); | ||
| 501 | ldapschema_attributetype_free(attr); | ||
| 502 | return(NULL); | ||
| 503 | }; | ||
| 504 | if ((attr->model.definition = malloc(def->bv_len+1)) == NULL) | ||
| 505 | { | 489 | { |
| 506 | lsd->errcode = LDAPSCHEMA_NO_MEMORY; | ||
| 507 | ldapschema_value_free(argv); | 490 | ldapschema_value_free(argv); |
| 508 | ldapschema_attributetype_free(attr); | ||
| 509 | return(NULL); | 491 | return(NULL); |
| 510 | }; | 492 | }; |
| 511 | memcpy(attr->model.definition, def->bv_val, def->bv_len); | ||
| 512 | attr->model.definition[def->bv_len] = '\0'; | ||
| 513 | 493 | ||
| 514 | // processes attribute definition | 494 | // processes attribute definition |
| 515 | for(pos = 1; pos < argc; pos++) | 495 | for(pos = 1; pos < argc; pos++) |
| @@ -685,9 +665,6 @@ LDAPSchemaAttributeType * ldapschema_parse_attributetype(LDAPSchema * lsd, const | |||
| 685 | }; | 665 | }; |
| 686 | ldapschema_value_free(argv); | 666 | ldapschema_value_free(argv); |
| 687 | 667 | ||
| 688 | // adds specification to syntax | ||
| 689 | attr->model.spec = ldapschema_spec_search(attr->model.oid); | ||
| 690 | |||
| 691 | // register attributeType | 668 | // register attributeType |
| 692 | if ((err = ldapschema_model_register(lsd, &attr->model)) != LDAP_SUCCESS) | 669 | if ((err = ldapschema_model_register(lsd, &attr->model)) != LDAP_SUCCESS) |
| 693 | { | 670 | { |
diff --git a/lib/libldapschema/lmemory.c b/lib/libldapschema/lmemory.c index 372841b..5f2880c 100644 --- a/lib/libldapschema/lmemory.c +++ b/lib/libldapschema/lmemory.c | |||
| @@ -94,25 +94,6 @@ void ldapschema_attributetype_free( LDAPSchemaAttributeType * attr ) | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | LDAPSchemaAttributeType * ldapschema_attributetype_initialize(LDAPSchema * lsd) | ||
| 98 | { | ||
| 99 | LDAPSchemaAttributeType * attr; | ||
| 100 | |||
| 101 | assert(lsd != NULL); | ||
| 102 | |||
| 103 | if ((attr = malloc(sizeof(LDAPSchemaAttributeType))) == NULL) | ||
| 104 | { | ||
| 105 | lsd->errcode = LDAPSCHEMA_NO_MEMORY; | ||
| 106 | return(NULL); | ||
| 107 | }; | ||
| 108 | bzero(attr, sizeof(LDAPSchemaAttributeType)); | ||
| 109 | attr->model.size = sizeof(LDAPSchemaAttributeType); | ||
| 110 | attr->model.type = LDAPSCHEMA_ATTRIBUTETYPE; | ||
| 111 | |||
| 112 | return(attr); | ||
| 113 | } | ||
| 114 | |||
| 115 | |||
| 116 | /// counts number of values in list | 97 | /// counts number of values in list |
| 117 | /// @param[in] vals Reference to allocated ldap_schema struct | 98 | /// @param[in] vals Reference to allocated ldap_schema struct |
| 118 | /// | 99 | /// |
