diff options
author | Karel Zak | 2009-09-15 22:22:16 +0200 |
---|---|---|
committer | Karel Zak | 2009-09-16 10:57:23 +0200 |
commit | 81f737929449e31b641d176638e030140e03911e (patch) | |
tree | 89fbd95c6239772435ab59c7a8ed2bc352db3f7b /shlibs/blkid/src/probe.c | |
parent | libblkid: remove superblock functions from probe.c (diff) | |
download | kernel-qcow2-util-linux-81f737929449e31b641d176638e030140e03911e.tar.gz kernel-qcow2-util-linux-81f737929449e31b641d176638e030140e03911e.tar.xz kernel-qcow2-util-linux-81f737929449e31b641d176638e030140e03911e.zip |
libblkid: use private {lookup,get}_value functions
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r-- | shlibs/blkid/src/probe.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index 23ebf9a90..b12ec1fe5 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -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) |