[3/7] libnsdb: Generalize nsdb_parse_annotations()

Submitted by Chuck Lever on Nov. 20, 2012, 8:26 p.m.

Details

Message ID 20121120202652.47389.76893.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever Nov. 20, 2012, 8:26 p.m.
At one point, nsdb_parse_annotations() used to parse fedfsAnnotations
by breaking them into key-value pairs.  But now it just stores each
pair into an array of strings.  This was changed before the initial
0.6.0 commit, but the documenting comment was never updated.

This looks like something that can be used for any FedFS-related
LDAP object that has a fedfsAnnotations attribute.  Instead of
having a version of this function that is specific to fedfsFsl
records, let's make it more general by having it output a string
array rather than filling in a struct fedfs_fsl.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 src/libnsdb/fileserver.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index 9ec0f37..fe09604 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -585,14 +585,11 @@  nsdb_resolve_fsn_parse_objectclass(char *attr, struct berval **values,
  * Parse fedfsAnnotation attribute of a fedfsFsl
  *
  * @param values array of values for this attribute
- * @param fsl OUT: fedfs_fsl structure to fill in
+ * @param annotations OUT: pointer to array of NUL-terminated C strings
  * @return a FedFsStatus code
- *
- * Place the keywords in fsl->fl_anno_keys and the values in
- * fsl->fl_anno_vals.
  */
 static FedFsStatus
-nsdb_parse_annotations(struct berval **values, struct fedfs_fsl *fsl)
+nsdb_parse_annotations(struct berval **values, char ***annotations)
 {
 	char **tmp_annos;
 	int i, count;
@@ -619,7 +616,7 @@  nsdb_parse_annotations(struct berval **values, struct fedfs_fsl *fsl)
 	}
 	tmp_annos[i] = NULL;
 
-	fsl->fl_annotations = tmp_annos;
+	*annotations = tmp_annos;
 	return FEDFS_OK;
 }
 
@@ -662,7 +659,7 @@  nsdb_resolve_fsn_parse_attribute(LDAP *ld, LDAPMessage *entry, char *attr,
 		retval = nsdb_parse_singlevalue_int(attr, values,
 				&fsl->fl_fslport);
 	else if (strcasecmp(attr, "fedfsAnnotation") == 0)
-		retval = nsdb_parse_annotations(values, fsl);
+		retval = nsdb_parse_annotations(values, &fsl->fl_annotations);
 	else if (strcasecmp(attr, "fedfsDescr") == 0)
 		retval = nsdb_parse_multivalue_str(attr, values,
 				&fsl->fl_description);