Move safewrite and saferead to a separate file.
We currently use safewrite from inside libvirt and don't want to publish
any such function name. However, we do want to use it in applications
like virsh, libvirtd and libvirt_proxy that link with libvirt. To that
end, this change moves that function definition (along with the nearly
identical saferead) into a new file, util-lib.c. To avoid maintaining
separate copies of even such small functions, we simply include that new
file from util.c. Then, the separate applications that need to use
safewrite simply compile and link with util-lib.c.
Of course, this does mean that each of those applications will
containing two copies of these functions. However, the functions
are so small that it's not worth worrying about that.
* src/util.c (saferead, safewrite): Move function definitions to
util-lib.c and include that .c file.
* src/util-lib.c (saferead, safewrite): New file. Functions from src/util.c
with slight change (s/int r =/ssize_t r =/) to reflect read/write return type.
* src/util-lib.h: Declare the two moved functions.
* src/util.h: Remove declarations. Include src/util-lib.h.
* proxy/Makefile.am (libvirt_proxy_SOURCES): Add src/util-lib.c.
* qemud/Makefile.am (libvirtd_SOURCES): Likewise.
* src/Makefile.am (virsh_SOURCES): Add util-lib.c. Remove some SP-before-TAB.
2008-02-22 15:53:13 +00:00
|
|
|
/*
|
|
|
|
* private utility functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Red Hat, Inc.
|
|
|
|
* See COPYING.LIB for the License of this software
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_LIB_H__
|
|
|
|
#define __UTIL_LIB_H__
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2008-02-25 13:55:56 +00:00
|
|
|
/*
|
|
|
|
* To avoid a double definition of the function when compiling
|
|
|
|
* programs using both util-lib and libvirt, like virsh
|
|
|
|
*/
|
|
|
|
#ifdef IN_LIBVIRT
|
|
|
|
#define saferead libvirt_saferead
|
|
|
|
#define safewrite libvirt_safewrite
|
|
|
|
#endif
|
|
|
|
|
Move safewrite and saferead to a separate file.
We currently use safewrite from inside libvirt and don't want to publish
any such function name. However, we do want to use it in applications
like virsh, libvirtd and libvirt_proxy that link with libvirt. To that
end, this change moves that function definition (along with the nearly
identical saferead) into a new file, util-lib.c. To avoid maintaining
separate copies of even such small functions, we simply include that new
file from util.c. Then, the separate applications that need to use
safewrite simply compile and link with util-lib.c.
Of course, this does mean that each of those applications will
containing two copies of these functions. However, the functions
are so small that it's not worth worrying about that.
* src/util.c (saferead, safewrite): Move function definitions to
util-lib.c and include that .c file.
* src/util-lib.c (saferead, safewrite): New file. Functions from src/util.c
with slight change (s/int r =/ssize_t r =/) to reflect read/write return type.
* src/util-lib.h: Declare the two moved functions.
* src/util.h: Remove declarations. Include src/util-lib.h.
* proxy/Makefile.am (libvirt_proxy_SOURCES): Add src/util-lib.c.
* qemud/Makefile.am (libvirtd_SOURCES): Likewise.
* src/Makefile.am (virsh_SOURCES): Add util-lib.c. Remove some SP-before-TAB.
2008-02-22 15:53:13 +00:00
|
|
|
int saferead(int fd, void *buf, size_t count);
|
|
|
|
ssize_t safewrite(int fd, const void *buf, size_t count);
|
|
|
|
|
|
|
|
#endif
|