]> err.no Git - util-linux/commitdiff
libblkid: use private {lookup,get}_value functions
authorKarel Zak <kzak@redhat.com>
Tue, 15 Sep 2009 20:22:16 +0000 (22:22 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Sep 2009 08:57:23 +0000 (10:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/probe.c

index 23ebf9a90f0e835e227e4b07fbaed3950ed43684..b12ec1fe54ad62dd2903fc86e5e53a1838fe7639 100644 (file)
@@ -699,15 +699,23 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage)
        return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1);
 }
 
+/**
+ * blkid_probe_get_value:
+ * @pr: probe
+ * @num: wanted value in range 0..N, where N is blkid_probe_numof_values() - 1
+ * @name: pointer to return value name or NULL
+ * @data: pointer to return value data or NULL
+ * @len: pointer to return value length or NULL
+ *
+ * Returns: 0 on success, or -1 in case of error.
+ */
 int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
                        const char **data, size_t *len)
 {
-       struct blkid_prval *v;
+       struct blkid_prval *v = __blkid_probe_get_value(pr, num);
 
-       if (pr == NULL || num < 0 || num >= pr->nvals)
+       if (!v)
                return -1;
-
-       v = &pr->vals[num];
        if (name)
                *name = v->name;
        if (data)
@@ -719,29 +727,37 @@ int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
        return 0;
 }
 
+/**
+ * blkid_probe_lookup_value:
+ * @pr: probe
+ * @name: name of value
+ * @data: pointer to return value data or NULL
+ * @len: pointer to return value length or NULL
+ *
+ * Returns: 0 on success, or -1 in case of error.
+ */
 int blkid_probe_lookup_value(blkid_probe pr, const char *name,
                        const char **data, size_t *len)
 {
-       int i;
+       struct blkid_prval *v = __blkid_probe_lookup_value(pr, name);
 
-       if (pr == NULL || pr->nvals == 0 || name == NULL)
+       if (!v)
                return -1;
-
-       for (i = 0; i < pr->nvals; i++) {
-               struct blkid_prval *v = &pr->vals[i];
-
-               if (v->name && strcmp(name, v->name) == 0) {
-                       if (data)
-                               *data = (char *) v->data;
-                       if (len)
-                               *len = v->len;
-                       DBG(DEBUG_LOWPROBE, printf("returning %s value\n", v->name));
-                       return 0;
-               }
-       }
-       return -1;
+       if (data)
+               *data = (char *) v->data;
+       if (len)
+               *len = v->len;
+       DBG(DEBUG_LOWPROBE, printf("returning %s value\n", v->name));
+       return 0;
 }
 
+/**
+ * blkid_probe_has_value:
+ * @pr: probe
+ * @name: name of value
+ *
+ * Returns: 1 if value exist in probing result, otherwise 0.
+ */
 int blkid_probe_has_value(blkid_probe pr, const char *name)
 {
        if (blkid_probe_lookup_value(pr, name, NULL, NULL) == 0)