Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
523389a7
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
523389a7
编写于
11月 15, 2006
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added virConfNew() and virConfSetValue() apis to virConf object
上级
a3cf19e6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
93 addition
and
11 deletion
+93
-11
ChangeLog
ChangeLog
+6
-0
src/conf.c
src/conf.c
+83
-11
src/conf.h
src/conf.h
+4
-0
未找到文件。
ChangeLog
浏览文件 @
523389a7
Wed Nov 15 15:52:01 EST 2006 Daniel Berrange <berrange@redhat.com>
* src/conf.c, src/conf.h: Add two new APIs virConfNew() and
virConfSetValue() for creating & populating new config objects
in memory instead of from a file
Wed Nov 15 15:42:01 EST 2006 Daniel Berrange <berrange@redhat.com>
Wed Nov 15 15:42:01 EST 2006 Daniel Berrange <berrange@redhat.com>
* python/libvir.c, python/libvirt_wrap.h, python/types.h: Ensure
* python/libvir.c, python/libvirt_wrap.h, python/types.h: Ensure
...
...
src/conf.c
浏览文件 @
523389a7
...
@@ -144,16 +144,7 @@ virConfFreeValue(virConfValuePtr val)
...
@@ -144,16 +144,7 @@ virConfFreeValue(virConfValuePtr val)
free
(
val
);
free
(
val
);
}
}
/**
virConfPtr
virConfNew
(
void
)
* virConfCreate:
* @filename: the name to report errors
*
* Create a configuration internal structure
*
* Returns a pointer or NULL in case of error.
*/
static
virConfPtr
virConfCreate
(
const
char
*
filename
)
{
{
virConfPtr
ret
;
virConfPtr
ret
;
...
@@ -164,8 +155,25 @@ virConfCreate(const char *filename)
...
@@ -164,8 +155,25 @@ virConfCreate(const char *filename)
}
}
memset
(
ret
,
0
,
sizeof
(
virConf
));
memset
(
ret
,
0
,
sizeof
(
virConf
));
ret
->
filename
=
filename
;
ret
->
filename
=
NULL
;
return
(
ret
);
}
/**
* virConfCreate:
* @filename: the name to report errors
*
* Create a configuration internal structure
*
* Returns a pointer or NULL in case of error.
*/
static
virConfPtr
virConfCreate
(
const
char
*
filename
)
{
virConfPtr
ret
=
virConfNew
();
if
(
ret
)
ret
->
filename
=
filename
;
return
(
ret
);
return
(
ret
);
}
}
...
@@ -784,6 +792,60 @@ virConfGetValue(virConfPtr conf, const char *setting)
...
@@ -784,6 +792,60 @@ virConfGetValue(virConfPtr conf, const char *setting)
return
(
NULL
);
return
(
NULL
);
}
}
/**
* virConfGetValue:
* @conf: a configuration file handle
* @entry: the name of the entry
* @value: the new configuration value
*
* Set (or replace) the value associated to this entry in the configuration
* file. The passed in 'value' will be owned by the conf object upon return
* of this method, even in case of error. It should not be referenced again
* by the caller.
*
* Returns 0 on success, or -1 on failure.
*/
int
virConfSetValue
(
virConfPtr
conf
,
const
char
*
setting
,
virConfValuePtr
value
)
{
virConfEntryPtr
cur
,
prev
=
NULL
;
cur
=
conf
->
entries
;
while
(
cur
!=
NULL
)
{
if
((
cur
->
name
!=
NULL
)
&&
(
!
strcmp
(
cur
->
name
,
setting
)))
{
break
;
}
prev
=
cur
;
cur
=
cur
->
next
;
}
if
(
!
cur
)
{
if
(
!
(
cur
=
malloc
(
sizeof
(
virConfEntry
))))
{
virConfFreeValue
(
value
);
return
(
-
1
);
}
cur
->
next
=
NULL
;
cur
->
comment
=
NULL
;
if
(
!
(
cur
->
name
=
strdup
(
setting
)))
{
virConfFreeValue
(
value
);
free
(
cur
);
return
(
-
1
);
}
cur
->
value
=
value
;
if
(
prev
)
{
prev
->
next
=
cur
;
}
else
{
conf
->
entries
=
cur
;
}
}
else
{
if
(
cur
->
value
)
{
virConfFreeValue
(
cur
->
value
);
}
cur
->
value
=
value
;
}
return
(
0
);
}
/**
/**
* virConfWriteFile:
* virConfWriteFile:
* @filename: the path to the configuration file.
* @filename: the path to the configuration file.
...
@@ -878,3 +940,13 @@ error:
...
@@ -878,3 +940,13 @@ error:
virBufferFree
(
buf
);
virBufferFree
(
buf
);
return
(
ret
);
return
(
ret
);
}
}
/*
* Local variables:
* indent-tabs-mode: nil
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/
src/conf.h
浏览文件 @
523389a7
...
@@ -50,6 +50,7 @@ struct _virConfValue {
...
@@ -50,6 +50,7 @@ struct _virConfValue {
typedef
struct
_virConf
virConf
;
typedef
struct
_virConf
virConf
;
typedef
virConf
*
virConfPtr
;
typedef
virConf
*
virConfPtr
;
virConfPtr
virConfNew
(
void
);
virConfPtr
virConfReadFile
(
const
char
*
filename
);
virConfPtr
virConfReadFile
(
const
char
*
filename
);
virConfPtr
virConfReadMem
(
const
char
*
memory
,
virConfPtr
virConfReadMem
(
const
char
*
memory
,
int
len
);
int
len
);
...
@@ -57,6 +58,9 @@ int virConfFree (virConfPtr conf);
...
@@ -57,6 +58,9 @@ int virConfFree (virConfPtr conf);
virConfValuePtr
virConfGetValue
(
virConfPtr
conf
,
virConfValuePtr
virConfGetValue
(
virConfPtr
conf
,
const
char
*
setting
);
const
char
*
setting
);
int
virConfSetValue
(
virConfPtr
conf
,
const
char
*
setting
,
virConfValuePtr
value
);
int
virConfWriteFile
(
const
char
*
filename
,
int
virConfWriteFile
(
const
char
*
filename
,
virConfPtr
conf
);
virConfPtr
conf
);
int
virConfWriteMem
(
char
*
memory
,
int
virConfWriteMem
(
char
*
memory
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录