2012-12-12 16:35:35 +00:00
|
|
|
/*
|
|
|
|
* virconf.h: parser for a subset of the Python encoded Xen configuration files
|
2006-08-29 22:27:07 +00:00
|
|
|
*
|
Detect heap allocation failure; factor out some duplication.
* qemud/qemud.c (tls_port, tcp_port, mdns_name, tls_allowed_ip_list):
(tls_allowed_dn_list): Remove "const", now that we free these.
(unix_sock_rw_mask): Rename from unix_sock_rw_perms, so that
the latter name can be used as a local string variable, so that the
variable name matches the config attribute name.
(unix_sock_ro_mask): Rename from unix_sock_ro_perms, likewise.
(remoteCheckDN, remoteCheckAccess): Adapt to const removal.
(qemudDispatchServer): Check for heap allocation failure.
(remoteConfigGetStringList): New function, based on code from Dan Berrangé.
(CHECK_TYPE): Remove macro.
(checkType): New function.
(GET_CONF_INT, GET_CONF_STR): New macros.
(remoteReadConfigFile): Use new macros to avoid duplication and to
check for allocation failure.
* src/conf.h (virConfTypeName): New static inline function.
2007-11-30 15:43:42 +00:00
|
|
|
* Copyright (C) 2006, 2007 Red Hat, Inc.
|
2006-08-29 22:27:07 +00:00
|
|
|
*
|
2012-07-27 09:39:53 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-27 09:39:53 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2006-08-29 22:27:07 +00:00
|
|
|
*
|
|
|
|
* Daniel Veillard <veillard@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_CONF_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_CONF_H__
|
2006-08-29 22:27:07 +00:00
|
|
|
|
2014-12-09 13:53:28 +00:00
|
|
|
# include "virutil.h"
|
|
|
|
|
2006-08-29 22:27:07 +00:00
|
|
|
/**
|
|
|
|
* virConfType:
|
|
|
|
* one of the possible type for a value from the configuration file
|
|
|
|
*
|
|
|
|
* TODO: we probably need a float too.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2014-12-09 13:53:28 +00:00
|
|
|
VIR_CONF_NONE = 0, /* undefined */
|
|
|
|
VIR_CONF_LONG, /* a long int */
|
2014-12-09 15:22:09 +00:00
|
|
|
VIR_CONF_ULONG, /* an unsigned long int */
|
2014-12-09 13:53:28 +00:00
|
|
|
VIR_CONF_STRING, /* a string */
|
|
|
|
VIR_CONF_LIST, /* a list */
|
|
|
|
VIR_CONF_LAST, /* sentinel */
|
2006-08-29 22:27:07 +00:00
|
|
|
} virConfType;
|
|
|
|
|
2014-12-09 13:53:28 +00:00
|
|
|
VIR_ENUM_DECL(virConf)
|
|
|
|
|
2009-06-19 12:34:30 +00:00
|
|
|
typedef enum {
|
2010-09-22 20:41:38 +00:00
|
|
|
VIR_CONF_FLAG_VMX_FORMAT = 1, /* allow ':', '.' and '-' in names for compatibility
|
|
|
|
with VMware VMX configuration file, but restrict
|
2009-06-22 11:54:49 +00:00
|
|
|
allowed value types to string only */
|
2014-02-05 14:09:59 +00:00
|
|
|
VIR_CONF_FLAG_LXC_FORMAT = 2, /* allow '.' in names for compatibility with LXC
|
|
|
|
configuration file, restricts allowed value types
|
|
|
|
to string only and don't expect quotes for values */
|
2009-06-19 12:34:30 +00:00
|
|
|
} virConfFlags;
|
|
|
|
|
2006-08-29 22:27:07 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2014-02-05 14:09:59 +00:00
|
|
|
typedef int (*virConfWalkCallback)(const char* name,
|
|
|
|
virConfValuePtr value,
|
|
|
|
void *opaque);
|
|
|
|
|
2008-11-17 11:03:25 +00:00
|
|
|
virConfPtr virConfNew (void);
|
2009-06-19 12:34:30 +00:00
|
|
|
virConfPtr virConfReadFile (const char *filename, unsigned int flags);
|
2008-11-17 11:03:25 +00:00
|
|
|
virConfPtr virConfReadMem (const char *memory,
|
2009-06-19 12:34:30 +00:00
|
|
|
int len, unsigned int flags);
|
2008-11-17 11:03:25 +00:00
|
|
|
int virConfFree (virConfPtr conf);
|
|
|
|
void virConfFreeValue (virConfValuePtr val);
|
2006-08-29 22:27:07 +00:00
|
|
|
|
2008-11-17 11:03:25 +00:00
|
|
|
virConfValuePtr virConfGetValue (virConfPtr conf,
|
2008-04-10 16:54:54 +00:00
|
|
|
const char *setting);
|
2008-11-17 11:03:25 +00:00
|
|
|
int virConfSetValue (virConfPtr conf,
|
2008-04-10 16:54:54 +00:00
|
|
|
const char *setting,
|
|
|
|
virConfValuePtr value);
|
2014-02-05 14:09:59 +00:00
|
|
|
int virConfWalk(virConfPtr conf,
|
|
|
|
virConfWalkCallback callback,
|
|
|
|
void *opaque);
|
2008-11-17 11:03:25 +00:00
|
|
|
int virConfWriteFile (const char *filename,
|
2008-04-10 16:54:54 +00:00
|
|
|
virConfPtr conf);
|
2008-11-17 11:03:25 +00:00
|
|
|
int virConfWriteMem (char *memory,
|
2008-04-10 16:54:54 +00:00
|
|
|
int *len,
|
|
|
|
virConfPtr conf);
|
2006-08-29 22:27:07 +00:00
|
|
|
|
|
|
|
#endif /* __VIR_CONF_H__ */
|