conf.h 1.7 KB
Newer Older
D
Daniel Veillard 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
/**
 * conf.h: parser for a subset of the Python encoded Xen configuration files
 *
 * Copyright (C) 2006 Red Hat, Inc.
 *
 * See COPYING.LIB for the License of this software
 *
 * Daniel Veillard <veillard@redhat.com>
 */

#ifndef __VIR_CONF_H__
#define __VIR_CONF_H__

#ifdef __cplusplus
extern "C" {
#endif

/**
 * virConfType:
 * one of the possible type for a value from the configuration file
 *
 * TODO: we probably need a float too.
 */
typedef enum {
    VIR_CONF_NONE = 0,		/* undefined */
    VIR_CONF_LONG = 1,		/* a long int */
    VIR_CONF_STRING = 2,	/* a string */
    VIR_CONF_LIST = 3		/* a list */
} virConfType;

/**
 * virConfValue:
 * a value from the configuration file
 */
typedef struct _virConfValue virConfValue;
typedef virConfValue *virConfValuePtr;

struct _virConfValue {
    virConfType type;		/* the virConfType */
    virConfValuePtr next;	/* next element if in a list */
    long  l;			/* long integer */
    char *str;			/* pointer to 0 terminated string */
    virConfValuePtr list;	/* list of a list */
};

/**
 * virConfPtr:
 * a pointer to a parsed configuration file
 */
typedef struct _virConf virConf;
typedef virConf *virConfPtr;

53
virConfPtr      virConfNew              (void);
D
Daniel Veillard 已提交
54 55 56 57 58 59 60
virConfPtr	virConfReadFile		(const char *filename);
virConfPtr	virConfReadMem		(const char *memory,
					 int len);
int		virConfFree		(virConfPtr conf);

virConfValuePtr	virConfGetValue		(virConfPtr conf,
					 const char *setting);
61 62 63
int             virConfSetValue         (virConfPtr conf,
					 const char *setting,
					 virConfValuePtr value);
D
Daniel Veillard 已提交
64 65 66 67 68 69 70 71 72 73
int		virConfWriteFile	(const char *filename,
					 virConfPtr conf);
int		virConfWriteMem		(char *memory,
					 int *len,
					 virConfPtr conf);

#ifdef __cplusplus
}
#endif
#endif /* __VIR_CONF_H__ */