1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Add 'get' functions.

This commit is contained in:
Alasdair Kergon 2002-01-10 16:47:58 +00:00
parent cf633b70c2
commit 2801ddcacc
2 changed files with 38 additions and 10 deletions

View File

@ -632,8 +632,32 @@ int find_config_bool(struct config_node *cn, const char *path,
return fail;
}
/*
* Local variables:
* c-file-style: "linux"
* End:
*/
int get_config_uint32(struct config_node *cn, const char *path,
char sep, uint32_t *result)
{
struct config_node *n;
n = find_config_node(cn, path, sep);
if (!n || !n->v || n->v->type != CFG_INT)
return 0;
*result = n->v->v.i;
return 1;
}
int get_config_uint64(struct config_node *cn, const char *path,
char sep, uint64_t *result)
{
struct config_node *n;
n = find_config_node(cn, path, sep);
if (!n || !n->v || n->v->type != CFG_INT)
return 0;
/* FIXME Support 64-bit value! */
*result = (uint64_t) n->v->v.i;
return 1;
}

View File

@ -7,6 +7,7 @@
#ifndef _LVM_CONFIG_H
#define _LVM_CONFIG_H
#include <inttypes.h>
enum {
CFG_STRING,
@ -59,10 +60,13 @@ float find_config_float(struct config_node *cn, const char *path,
int find_config_bool(struct config_node *cn, const char *path,
char sep, int fail);
int get_config_uint32(struct config_node *cn, const char *path,
char sep, uint32_t *result);
int get_config_uint64(struct config_node *cn, const char *path,
char sep, uint64_t *result);
#endif
/*
* Local variables:
* c-file-style: "linux"
* End:
*/