Per discussion on IRC, here are two changes to
convert all TABs-as-indentation to spaces.
The first one is the fully-automated conversion.
However, note that the command mentioned uses a file
(the .x-sc* one) that is added only in the following patch.
The second patch adds rules to help keep things that way:
Document and enforce the new spaces-only indentation policy.
* cfg.mk (disable_temporarily): Remove sc_TAB_in_indentation,
to enable the "make syntax-check" that enforces this.
* .x-sc_TAB_in_indentation: New file. Exceptions.
* HACKING: Document the policy, with tips on how to conform.
From 2f1a50d81671810256dce0852e6b1e0810ac44af Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 11:10:13 -0400
Subject: [PATCH 1/2] Convert all TABs-as-indentation to spaces.
Do it by running this command:
[exempted files are matched via .x-sc_TAB_in_indentation]
git ls-files \
| pcregrep -vf .x-sc_TAB_in_indentation \
| xargs pcregrep -l '^ *\t' \
| xargs perl -MText::Tabs -ni -le \
'$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
---
HACKING | 50 +-
appliance/libguestfs-supermin-helper.in | 4 +-
appliance/supermin-split.sh.in | 24 +-
bootstrap | 2 +-
cat/virt-cat.pl | 4 +-
configure.ac | 218 +-
contrib/README | 20 +-
daemon/configure.ac | 32 +-
daemon/daemon.h | 4 +-
daemon/debug.c | 10 +-
daemon/devsparts.c | 50 +-
daemon/dir.c | 4 +-
daemon/ext2.c | 32 +-
daemon/file.c | 18 +-
daemon/guestfsd.c | 64 +-
daemon/inotify.c | 26 +-
daemon/link.c | 14 +-
daemon/lvm.c | 28 +-
daemon/mount.c | 40 +-
daemon/proto.c | 48 +-
daemon/readdir.c | 2 +-
daemon/sfdisk.c | 8 +-
daemon/xattr.c | 22 +-
df/virt-df.pl | 146 +-
examples/to-xml.c | 16 +-
fish/destpaths.c | 116 +-
fish/fish.c | 460 ++--
fish/fish.h | 2 +-
fish/glob.c | 54 +-
fish/rc.c | 80 +-
fish/tilde.c | 6 +-
fish/time.c | 4 +-
inspector/virt-inspector.pl | 246 +-
.../redhat/et/libguestfs/LibGuestFSException.java | 2 +-
java/t/GuestFS005Load.java | 16 +-
java/t/GuestFS010Launch.java | 32 +-
java/t/GuestFS050LVCreate.java | 60 +-
m4/ocaml.m4 | 48 +-
make-recipes.sh | 18 +-
ocaml/t/guestfs_060_readdir.ml | 8 +-
perl/lib/Sys/Guestfs/Lib.pm | 710 ++--
perl/t/500-lib-load.t | 6 +-
perl/t/510-lib-file-arch.t | 6 +-
perl/typemap | 2 +-
recipes/squashfs.example | 14 +-
src/generator.ml | 3828 ++++++++++----------
src/gettext.h | 28 +-
src/guestfs.c | 226 +-
test-tool/test-tool.c | 104 +-
v2v/virt-v2v.pl | 8 +-
50 files changed, 3485 insertions(+), 3485 deletions(-)
diff --git a/HACKING b/HACKING
index 336fc7c..c6a3022 100644
--- a/HACKING
+++ b/HACKING
@@ -28,74 +28,74 @@ Directories
----------------------------------------------------------------------
appliance/
- The qemu appliance, build scripts and so on.
+ The qemu appliance, build scripts and so on.
cat/
- The virt-cat tool.
+ The virt-cat tool.
capitests/
- Automated tests of the C API.
+ Automated tests of the C API.
contrib/
- Outside contributions, experimental parts.
+ Outside contributions, experimental parts.
daemon/
- The daemon that runs inside the guest and carries out actions.
+ The daemon that runs inside the guest and carries out actions.
df/
- The virt-df tool.
+ The virt-df tool.
examples/
- The examples.
+ The examples.
fish/
- Guestfish (the command-line program / shell)
+ Guestfish (the command-line program / shell)
haskell/
- Haskell bindings.
+ Haskell bindings.
images/
- Some guest images to test against. These are gzipped to save
- space. You have to unzip them before use.
+ Some guest images to test against. These are gzipped to save
+ space. You have to unzip them before use.
- Also contains some files used by the test suite.
+ Also contains some files used by the test suite.
inspector/
- Virtual machine image inspector (virt-inspector).
+ Virtual machine image inspector (virt-inspector).
java/
- Java bindings.
+ Java bindings.
m4/
- M4 macros used by autoconf.
+ M4 macros used by autoconf.
ocaml/
- OCaml bindings.
+ OCaml bindings.
po/
- Translations.
+ Translations.
perl/
- Perl bindings.
+ Perl bindings.
python/
- Python bindings.
+ Python bindings.
regressions/
- Regression tests.
+ Regression tests.
ruby/
- Ruby bindings.
+ Ruby bindings.
src/
- Source code to the C library.
- Also contains the crucial generator program.
+ Source code to the C library.
+ Also contains the crucial generator program.
test-tool/
- Interactive qemu/kernel test tool.
+ Interactive qemu/kernel test tool.
v2v/
- Xen to KVM (V2V) conversion tool.
+ Xen to KVM (V2V) conversion tool.
Debugging
----------------------------------------------------------------------
diff --git a/appliance/libguestfs-supermin-helper.in
b/appliance/libguestfs-supermin-helper.in
index e521020..a096ea4 100755
--- a/appliance/libguestfs-supermin-helper.in
+++ b/appliance/libguestfs-supermin-helper.in
@@ -44,8 +44,8 @@ for f in $kernels; do
b=$(echo "$b" | sed 's,vmlinuz-,,')
modpath="/lib/modules/$b"
if [ -d "$modpath" ]; then
- ln -sf "$f" "$kernel"
- break
+ ln -sf "$f" "$kernel"
+ break
fi
modpath=
done
diff --git a/appliance/supermin-split.sh.in b/appliance/supermin-split.sh.in
index fe4ab6e..61df891 100755
--- a/appliance/supermin-split.sh.in
+++ b/appliance/supermin-split.sh.in
@@ -54,40 +54,40 @@ for path in $(find -not -name fakeroot.log); do
# All we're going to keep are the special files /init, the daemon,
# configuration files (/etc), devices and modifiable stuff (/var).
if [ "$path" = "./init" -o "$file" =
"guestfsd" ]; then
- echo "$path" >&5
+ echo "$path" >&5
elif [[ "$path" =~ '^\./etc' || "$path" =~
'^./dev' || "$path" =~ '^\./var' ]]; then
- echo "$path" >&5
+ echo "$path" >&5
# Kernel modules are always copied in from the host, including all
# the dependency files.
elif [[ "$path" =~ '^\./lib/modules/' ]]; then
- :
+ :
elif [ -d "$path" ]; then
- # Always write directory names to both output files.
- echo "$path" >&5
- echo "$path" >&6
+ # Always write directory names to both output files.
+ echo "$path" >&5
+ echo "$path" >&6
# Some libraries need fixed version numbers replaced by wildcards.
elif [[ "$file" =~ '^ld-[.0-9]+\.so$' ]]; then
- echo "$dir/ld-*.so" >&6
+ echo "$dir/ld-*.so" >&6
# libfoo-1.2.3.so
elif [[ "$file" =~ '^lib(.*)-[-.0-9]+\.so$' ]]; then
- echo "$dir/lib${BASH_REMATCH[1]}-*.so" >&6
+ echo "$dir/lib${BASH_REMATCH[1]}-*.so" >&6
# libfoo-1.2.3.so.1.2.3 (but NOT '*.so.N')
elif [[ "$file" =~ '^lib(.*)-[-.0-9]+\.so\.([0-9]+)\.' ]]; then
- echo "$dir/lib${BASH_REMATCH[1]}-*.so.${BASH_REMATCH[2]}.*" >&6
+ echo "$dir/lib${BASH_REMATCH[1]}-*.so.${BASH_REMATCH[2]}.*" >&6
# libfoo.so.1.2.3 (but NOT '*.so.N')
elif [[ "$file" =~ '^lib(.*)\.so\.([0-9]+)\.' ]]; then
- echo "$dir/lib${BASH_REMATCH[1]}.so.${BASH_REMATCH[2]}.*" >&6
+ echo "$dir/lib${BASH_REMATCH[1]}.so.${BASH_REMATCH[2]}.*" >&6
else
- # Anything else comes from the host directly.
- echo "$path" >&6
+ # Anything else comes from the host directly.
+ echo "$path" >&6
fi
done
diff --git a/bootstrap b/bootstrap
index 73a5e04..e4ddf85 100755
--- a/bootstrap
+++ b/bootstrap
@@ -46,7 +46,7 @@ case ${GNULIB_SRCDIR--} in
# Redirect the gnulib submodule to the directory on the command line
# if possible.
if test -d "$GNULIB_SRCDIR"/.git && \
- git config --file .gitmodules submodule.gnulib.url >/dev/null; then
+ git config --file .gitmodules submodule.gnulib.url >/dev/null; then
git submodule init
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
diff --git a/cat/virt-cat.pl b/cat/virt-cat.pl
index 1ac720c..1017876 100755
--- a/cat/virt-cat.pl
+++ b/cat/virt-cat.pl
@@ -116,8 +116,8 @@ at all.
=cut
GetOptions ("help|?" => \$help,
- "version" => \$version,
- "connect|c=s" => \$uri,
+ "version" => \$version,
+ "connect|c=s" => \$uri,
) or pod2usage (2);
pod2usage (1) if $help;
if ($version) {
diff --git a/configure.ac b/configure.ac
index df466fa..28514b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,8 +62,8 @@ dnl Check for rpcgen and XDR library. rpcgen is optional.
AC_CHECK_PROG([RPCGEN],[rpcgen],[rpcgen],[no])
AM_CONDITIONAL([HAVE_RPCGEN],[test "x$RPCGEN" != "xno"])
AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
- AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
- ])
+ AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
+ ])
dnl Check for pod2man and pod2text.
AC_CHECK_PROG([POD2MAN],[pod2man],[pod2man],[no])
@@ -75,19 +75,19 @@ test "x$POD2TEXT" = "xno" &&
dnl Check for mksquashfs.
AC_PATH_PROGS([MKSQUASHFS],[mksquashfs],[no],
- [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
+ [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
test "x$MKSQUASHFS" = "xno" && AC_MSG_ERROR([mksquashfs must
be installed])
dnl Check for QEMU for running binaries on this $host_cpu, fall
dnl back to basic 'qemu'. Allow the user to override it.
default_qemu="qemu-kvm qemu-system-$host_cpu qemu"
AC_ARG_WITH([qemu],
- [AS_HELP_STRING([--with-qemu],
- [set default QEMU binary @<:@default=[qemu-kvm] qemu-system-<host>
qemu@:>@])],
- [],
- [with_qemu="$default_qemu"])
+ [AS_HELP_STRING([--with-qemu],
+ [set default QEMU binary @<:@default=[qemu-kvm] qemu-system-<host>
qemu@:>@])],
+ [],
+ [with_qemu="$default_qemu"])
AC_PATH_PROGS([QEMU],[$with_qemu],[no],
- [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/libexec])
+ [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/libexec])
test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be
installed])
AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
@@ -100,13 +100,13 @@ if test "x$vmchannel_test" != "xno"; then
else
AC_MSG_RESULT([no])
AC_MSG_CHECKING([for "-net channel" support in $QEMU])
- vmchannelout=`$QEMU -net channel /dev/zero 2>&1 ||:`
- echo "vmchannel test command output: $vmchannelout"
>&AS_MESSAGE_LOG_FD
- if echo "$vmchannelout" | grep -sq "vmchannel wrong port number" ;
then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- AC_MSG_FAILURE(
+ vmchannelout=`$QEMU -net channel /dev/zero 2>&1 ||:`
+ echo "vmchannel test command output: $vmchannelout"
>&AS_MESSAGE_LOG_FD
+ if echo "$vmchannelout" | grep -sq "vmchannel wrong port
number" ; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE(
[I did not find vmchannel support in $QEMU.
vmchannel support is vital for libguestfs to operate. You need a version
@@ -122,7 +122,7 @@ If I am using the wrong qemu or you want to compile qemu from source
and install it in another location, then you should configure with
the --with-qemu option.
])
- fi
+ fi
fi
fi
@@ -132,37 +132,37 @@ dnl
dnl NB. We will change the default in future to virtio, but at the
dnl moment this causes a performance problem, RHBZ#509383.
AC_ARG_WITH([drive-if],
- [AS_HELP_STRING([--with-drive-if],
- [set default driver (ide|scsi|virtio) @<:@default=ide@:>@])],
- [],
- [with_drive_if=ide])
+ [AS_HELP_STRING([--with-drive-if],
+ [set default driver (ide|scsi|virtio) @<:@default=ide@:>@])],
+ [],
+ [with_drive_if=ide])
AC_DEFINE_UNQUOTED([DRIVE_IF],["$with_drive_if"],[Default drive interface.])
dnl Check for febootstrap etc.
AC_CHECK_PROG([FEBOOTSTRAP],
- [febootstrap],[febootstrap],[no])
+ [febootstrap],[febootstrap],[no])
if test "x$FEBOOTSTRAP" != "xno"; then
AC_CHECK_PROG([FEBOOTSTRAP_RUN],
- [febootstrap-run],[febootstrap-run],[no])
+ [febootstrap-run],[febootstrap-run],[no])
test "x$FEBOOTSTRAP_RUN" = "xno" && \
AC_MSG_ERROR([febootstrap-run must be installed])
AC_CHECK_PROG([FEBOOTSTRAP_INSTALL],
- [febootstrap-install],[febootstrap-install],[no])
+ [febootstrap-install],[febootstrap-install],[no])
test "x$FEBOOTSTRAP_INSTALL" = "xno" && \
AC_MSG_ERROR([febootstrap-install must be installed])
AC_CHECK_PROG([FEBOOTSTRAP_MINIMIZE],
- [febootstrap-minimize],[febootstrap-minimize],[no])
+ [febootstrap-minimize],[febootstrap-minimize],[no])
test "x$FEBOOTSTRAP_MINIMIZE" = "xno" && \
AC_MSG_ERROR([febootstrap-minimize must be installed])
AC_CHECK_PROG([FEBOOTSTRAP_TO_INITRAMFS],
- [febootstrap-to-initramfs],[febootstrap-to-initramfs],[no])
+ [febootstrap-to-initramfs],[febootstrap-to-initramfs],[no])
test "x$FEBOOTSTRAP_TO_INITRAMFS" = "xno" && \
AC_MSG_ERROR([febootstrap-to-initramfs must be installed])
dnl Check we have fakechroot >= 2.9 (it's an indirect requirement
dnl of febootstrap, but old versions will fail with yum).
AC_CHECK_PROG([FAKECHROOT],
- [fakechroot],[fakechroot],[no])
+ [fakechroot],[fakechroot],[no])
test "x$FAKECHROOT" = "xno" && \
AC_MSG_ERROR([fakechroot must be installed])
@@ -184,9 +184,9 @@ if test "x$FEBOOTSTRAP" != "xno"; then
else
# check for debootstrap and debirf
AC_CHECK_PROG([DEBOOTSTRAP],
- [debootstrap],[debootstrap],[no])
+ [debootstrap],[debootstrap],[no])
test "x$DEBOOTSTRAP" = "xno" && \
- AC_MSG_ERROR([Either febootstrap or debootstrap must be installed])
+ AC_MSG_ERROR([Either febootstrap or debootstrap must be installed])
AC_CHECK_PROG([DEBIRF],[debirf],[debirf],[no])
test "x$DEBIRF" = "xno" &&
AC_MSG_ERROR([debirf must be installed])
@@ -209,20 +209,20 @@ AC_SUBST(DIST)
dnl --with-repo to specify a Fedora repository.
AC_ARG_WITH([repo],
- [AS_HELP_STRING([--with-repo],
- [set name of Fedora repository @<:@default=fedora-11@:>@])],
- [],
- [with_repo=fedora-11])
+ [AS_HELP_STRING([--with-repo],
+ [set name of Fedora repository @<:@default=fedora-11@:>@])],
+ [],
+ [with_repo=fedora-11])
REPO="$with_repo"
AC_SUBST(REPO)
AC_DEFINE_UNQUOTED([REPO],["$REPO"],[Name of Fedora repository.])
dnl --with-updates to specify a Fedora updates repository.
AC_ARG_WITH([updates],
- [AS_HELP_STRING([--with-updates],
- [set name of Fedora updates repository @<:@default=updates-released-f11@:>@])],
- [],
- [with_updates=updates-released-f11])
+ [AS_HELP_STRING([--with-updates],
+ [set name of Fedora updates repository
@<:@default=updates-released-f11@:>@])],
+ [],
+ [with_updates=updates-released-f11])
UPDATES="$with_updates"
AC_SUBST(UPDATES)
@@ -231,20 +231,20 @@ AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host
architecture.])
dnl --with-mirror to specify a local Fedora mirror.
AC_ARG_WITH([mirror],
- [AS_HELP_STRING([--with-mirror],
- [set URI of a local Fedora mirror])],
- [],
- [with_mirror=])
+ [AS_HELP_STRING([--with-mirror],
+ [set URI of a local Fedora mirror])],
+ [],
+ [with_mirror=])
MIRROR="$with_mirror"
AC_SUBST(MIRROR)
dnl Build the supermin appliance? Please see README file before
dnl enabling this option.
AC_ARG_ENABLE([supermin],
- [AS_HELP_STRING([--enable-supermin],
- [enable supermin appliance (see README) @<:@default=no@:>@])],
- [],
- [enable_supermin=no])
+ [AS_HELP_STRING([--enable-supermin],
+ [enable supermin appliance (see README) @<:@default=no@:>@])],
+ [],
+ [enable_supermin=no])
AM_CONDITIONAL([SUPERMIN],[test "x$enable_supermin" = "xyes"])
if test "x$enable_supermin" = "xyes"; then
@@ -255,7 +255,7 @@ if test "x$enable_supermin" = "xyes"; then
echo "febootstrap_to_initramfs test command output: $out"
>&AS_MESSAGE_LOG_FD
if ! echo "$out" | grep -sq -e --files ; then
AC_MSG_RESULT([no])
- AC_MSG_FAILURE(
+ AC_MSG_FAILURE(
[febootstrap-to-initramfs does not support the --files option.
To build the supermin appliance, you need to upgrade to the latest
@@ -271,7 +271,7 @@ version of febootstrap.
echo "febootstrap_to_initramfs test command output: $out"
>&AS_MESSAGE_LOG_FD
if ! echo "$out" | grep -sq -e --nocompress ; then
AC_MSG_RESULT([no])
- AC_MSG_FAILURE(
+ AC_MSG_FAILURE(
[febootstrap-to-initramfs does not support the --nocompress option.
To build the supermin appliance, you need to upgrade to the latest
@@ -351,11 +351,11 @@ if test "x$PYTHON" != "xno"; then
do
AC_MSG_CHECKING([Python.h in $d])
if test -r "$d/Python.h"; then
- AC_MSG_RESULT([found])
- PYTHON_INCLUDEDIR=$d
- break
- fi
- AC_MSG_RESULT([not found])
+ AC_MSG_RESULT([found])
+ PYTHON_INCLUDEDIR=$d
+ break
+ fi
+ AC_MSG_RESULT([not found])
done
for d in \
$PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
@@ -366,11 +366,11 @@ if test "x$PYTHON" != "xno"; then
do
AC_MSG_CHECKING([for $d])
if test -d "$d"; then
- AC_MSG_RESULT([found])
- PYTHON_SITE_PACKAGES=$d
- break
- fi
- AC_MSG_RESULT([not found])
+ AC_MSG_RESULT([found])
+ PYTHON_SITE_PACKAGES=$d
+ break
+ fi
+ AC_MSG_RESULT([not found])
done
fi
@@ -399,46 +399,46 @@ AC_ARG_WITH(java_home,
if test "x$with_java_home" != "xno"; then
if test "x$with_java_home" != "xyes" -a
"x$with_java_home" != "xcheck"
then
- # Reject unsafe characters in $JAVA_HOME
- jh_lf='
+ # Reject unsafe characters in $JAVA_HOME
+ jh_lf='
'
- case $JAVA_HOME in
- *[\\\"\#\$\&\'\`$jh_lf\ \ ]*)
+ case $JAVA_HOME in
+ *[\\\"\#\$\&\'\`$jh_lf\ \ ]*)
AC_MSG_FAILURE([unsafe \$JAVA_HOME directory (use --with-java-home=no to
disable Java support)]);;
- esac
+ esac
if test -d "$with_java_home"; then
- JAVA_HOME="$with_java_home"
- else
+ JAVA_HOME="$with_java_home"
+ else
AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no
to disable Java support)])
- fi
+ fi
fi
if test "x$JAVA_HOME" = "x"; then
# Look for Java in some likely locations.
- for d in \
- /usr/lib/jvm/java \
- /usr/lib/jvm/java-6-openjdk
- do
- if test -d $d -a -f $d/bin/java; then
+ for d in \
+ /usr/lib/jvm/java \
+ /usr/lib/jvm/java-6-openjdk
+ do
+ if test -d $d -a -f $d/bin/java; then
JAVA_HOME=$d
- break
- fi
- done
+ break
+ fi
+ done
fi
if test "x$JAVA_HOME" != "x"; then
AC_MSG_CHECKING(for JDK in $JAVA_HOME)
- if test ! -x "$JAVA_HOME/bin/java"; then
+ if test ! -x "$JAVA_HOME/bin/java"; then
AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to
disable Java support)])
- else
- JAVA="$JAVA_HOME/bin/java"
- fi
- if test ! -x "$JAVA_HOME/bin/javac"; then
+ else
+ JAVA="$JAVA_HOME/bin/java"
+ fi
+ if test ! -x "$JAVA_HOME/bin/javac"; then
AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
- else
- JAVAC="$JAVA_HOME/bin/javac"
+ else
+ JAVAC="$JAVA_HOME/bin/javac"
fi
- if test ! -x "$JAVA_HOME/bin/javah"; then
+ if test ! -x "$JAVA_HOME/bin/javah"; then
AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
else
JAVAH="$JAVA_HOME/bin/javah"
@@ -463,10 +463,10 @@ if test "x$with_java_home" != "xno"; then
else
if test "`find $JAVA_HOME -name jni.h`" != ""; then
head=`find $JAVA_HOME -name jni.h | tail -1`
- dir=`dirname "$head"`
- JNI_CFLAGS="-I$dir"
+ dir=`dirname "$head"`
+ JNI_CFLAGS="-I$dir"
else
- AC_MSG_FAILURE([missing jni.h header file])
+ AC_MSG_FAILURE([missing jni.h header file])
fi
fi
AC_MSG_RESULT([$JNI_CFLAGS])
@@ -570,37 +570,37 @@ dnl Produce output files.
AC_CONFIG_HEADERS([config.h])
dnl
http://www.mail-archive.com/automake@gnu.org/msg10204.html
AC_CONFIG_FILES([appliance/make.sh],
- [chmod +x appliance/make.sh])
+ [chmod +x appliance/make.sh])
AC_CONFIG_FILES([appliance/update.sh],
- [chmod +x appliance/update.sh])
+ [chmod +x appliance/update.sh])
AC_CONFIG_FILES([appliance/supermin-split.sh],
- [chmod +x appliance/supermin-split.sh])
+ [chmod +x appliance/supermin-split.sh])
AC_CONFIG_FILES([appliance/supermin-make.sh],
- [chmod +x appliance/supermin-make.sh])
+ [chmod +x appliance/supermin-make.sh])
AC_CONFIG_FILES([appliance/libguestfs-supermin-helper],
- [chmod +x appliance/libguestfs-supermin-helper])
+ [chmod +x appliance/libguestfs-supermin-helper])
AC_CONFIG_FILES([Makefile
- src/Makefile fish/Makefile po/Makefile.in examples/Makefile
- appliance/Makefile
- appliance/debian/debirf.conf
- images/Makefile
- capitests/Makefile
- regressions/Makefile
- test-tool/Makefile
- ocaml/Makefile ocaml/examples/Makefile
- perl/Makefile
- python/Makefile
- ruby/Makefile ruby/Rakefile
- java/Makefile
- haskell/Makefile
- cat/Makefile
- df/Makefile
- inspector/Makefile
- v2v/Makefile
- libguestfs.pc
- gnulib/lib/Makefile
- gnulib/tests/Makefile
- ocaml/META perl/Makefile.PL])
+ src/Makefile fish/Makefile po/Makefile.in examples/Makefile
+ appliance/Makefile
+ appliance/debian/debirf.conf
+ images/Makefile
+ capitests/Makefile
+ regressions/Makefile
+ test-tool/Makefile
+ ocaml/Makefile ocaml/examples/Makefile
+ perl/Makefile
+ python/Makefile
+ ruby/Makefile ruby/Rakefile
+ java/Makefile
+ haskell/Makefile
+ cat/Makefile
+ df/Makefile
+ inspector/Makefile
+ v2v/Makefile
+ libguestfs.pc
+ gnulib/lib/Makefile
+ gnulib/tests/Makefile
+ ocaml/META perl/Makefile.PL])
AC_OUTPUT
dnl Produce summary.
diff --git a/contrib/README b/contrib/README
index 0d9bf0b..4f7329f 100644
--- a/contrib/README
+++ b/contrib/README
@@ -1,15 +1,15 @@
centos5.3-libguestfs.spec
- [REMOVED]
- This used to be a centos5.3 specfile. Please use the specfile
- from EL-5 here:
-
http://cvs.fedoraproject.org/viewvc/rpms/libguestfs/EL-5/
+ [REMOVED]
+ This used to be a centos5.3 specfile. Please use the specfile
+ from EL-5 here:
+
http://cvs.fedoraproject.org/viewvc/rpms/libguestfs/EL-5/
febootstrap/
- An experimental, non-working attempt to use febootstrap
- to install operating systems.
+ An experimental, non-working attempt to use febootstrap
+ to install operating systems.
fedora-libguestfs.spec
- [REMOVED]
- This used to be a Fedora 10+ specfile. Please use the specfile
- from Fedora instead:
-
http://cvs.fedoraproject.org/viewvc/rpms/libguestfs/devel/
+ [REMOVED]
+ This used to be a Fedora 10+ specfile. Please use the specfile
+ from Fedora instead:
+
http://cvs.fedoraproject.org/viewvc/rpms/libguestfs/devel/
diff --git a/daemon/configure.ac b/daemon/configure.ac
index 243f353..3bfd2ed 100644
--- a/daemon/configure.ac
+++ b/daemon/configure.ac
@@ -48,19 +48,19 @@ AM_PROG_CC_C_O
dnl Check for Augeas (now optional).
AC_CHECK_LIB([augeas],[aug_match],[
- LIBS="-laugeas $LIBS"
- have_augeas=yes
- dnl Check for functions not available in earlier versions of Augeas.
- AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
- ],[have_augeas=no])
+ LIBS="-laugeas $LIBS"
+ have_augeas=yes
+ dnl Check for functions not available in earlier versions of Augeas.
+ AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
+ ],[have_augeas=no])
if test "x$have_augeas" = "xyes"; then
- AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
+ AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
fi
dnl Check for XDR library.
AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
- AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
- ])
+ AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
+ ])
dnl Functions which may not be available in older distributions.
AC_CHECK_FUNCS([futimens listxattr llistxattr getxattr lgetxattr setxattr lsetxattr
removexattr lremovexattr])
@@ -68,14 +68,14 @@ AC_CHECK_FUNCS([futimens listxattr llistxattr getxattr lgetxattr
setxattr lsetxa
dnl For modified printf, we need glibc either (old-style)
dnl register_printf_function or (new-style) register_printf_specifier.
AC_CHECK_FUNC([register_printf_specifier],[
- AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
- [Define to 1 if you have new-style register_printf_specifier])
- ],[
- AC_CHECK_FUNC([register_printf_function],[
- AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
- [Define to 1 if you have old-style register_printf_function])
- ],[
- AC_MSG_FAILURE(
+ AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
+ [Define to 1 if you have new-style register_printf_specifier])
+ ],[
+ AC_CHECK_FUNC([register_printf_function],[
+ AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
+ [Define to 1 if you have old-style register_printf_function])
+ ],[
+ AC_MSG_FAILURE(
[No support for glibc-style extended printf formatters.
This means you either have a very old glibc (pre-2.0) or you
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 9aa831a..70a2351 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -48,9 +48,9 @@ extern void free_stringslen (char **argv, int len);
extern int command (char **stdoutput, char **stderror, const char *name, ...);
extern int commandr (char **stdoutput, char **stderror, const char *name, ...);
extern int commandv (char **stdoutput, char **stderror,
- char * const* const argv);
+ char * const* const argv);
extern int commandrv (char **stdoutput, char **stderror,
- char * const* const argv);
+ char * const* const argv);
extern char **split_lines (char *str);
diff --git a/daemon/debug.c b/daemon/debug.c
index 68320a3..13b7240 100644
--- a/daemon/debug.c
+++ b/daemon/debug.c
@@ -157,11 +157,11 @@ debug_fds (const char *subcmd, int argc, char *const *const argv)
if (S_ISLNK (statbuf.st_mode)) {
r = readlink (fname, link, sizeof link - 1);
if (r == -1) {
- reply_with_perror ("readline: %s", fname);
- fclose (fp);
- free (out);
- closedir (dir);
- return NULL;
+ reply_with_perror ("readline: %s", fname);
+ fclose (fp);
+ free (out);
+ closedir (dir);
+ return NULL;
}
link[r] = '\0';
diff --git a/daemon/devsparts.c b/daemon/devsparts.c
index 33579ba..1970e7d 100644
--- a/daemon/devsparts.c
+++ b/daemon/devsparts.c
@@ -46,8 +46,8 @@ do_list_devices (void)
while ((d = readdir (dir)) != NULL) {
if (strncmp (d->d_name, "sd", 2) == 0 ||
- strncmp (d->d_name, "hd", 2) == 0 ||
- strncmp (d->d_name, "vd", 2) == 0) {
+ strncmp (d->d_name, "hd", 2) == 0 ||
+ strncmp (d->d_name, "vd", 2) == 0) {
snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
/* RHBZ#514505: Some versions of qemu <= 0.10 add a
@@ -56,14 +56,14 @@ do_list_devices (void)
*/
int fd = open (buf, O_RDONLY);
if (fd == -1) {
- perror (buf);
- continue;
+ perror (buf);
+ continue;
}
close (fd);
if (add_string (&r, &size, &alloc, buf) == -1) {
- closedir (dir);
- return NULL;
+ closedir (dir);
+ return NULL;
}
}
}
@@ -100,8 +100,8 @@ do_list_partitions (void)
while ((d = readdir (dir)) != NULL) {
if (strncmp (d->d_name, "sd", 2) == 0 ||
- strncmp (d->d_name, "hd", 2) == 0 ||
- strncmp (d->d_name, "vd", 2) == 0) {
+ strncmp (d->d_name, "hd", 2) == 0 ||
+ strncmp (d->d_name, "vd", 2) == 0) {
snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
/* RHBZ#514505: Some versions of qemu <= 0.10 add a
@@ -110,8 +110,8 @@ do_list_partitions (void)
*/
int fd = open (buf, O_RDONLY);
if (fd == -1) {
- perror (buf);
- continue;
+ perror (buf);
+ continue;
}
close (fd);
@@ -122,26 +122,26 @@ do_list_partitions (void)
dir2 = opendir (buf);
if (!dir2) {
- reply_with_perror ("opendir: %s", buf);
- free_stringslen (r, size);
- return NULL;
+ reply_with_perror ("opendir: %s", buf);
+ free_stringslen (r, size);
+ return NULL;
}
while ((d = readdir (dir2)) != NULL) {
- if (strncmp (d->d_name, devname, strlen (devname)) == 0) {
- snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
-
- if (add_string (&r, &size, &alloc, buf) == -1) {
- closedir (dir2);
- closedir (dir);
- return NULL;
- }
- }
+ if (strncmp (d->d_name, devname, strlen (devname)) == 0) {
+ snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
+
+ if (add_string (&r, &size, &alloc, buf) == -1) {
+ closedir (dir2);
+ closedir (dir);
+ return NULL;
+ }
+ }
}
if (closedir (dir2) == -1) {
- reply_with_perror ("closedir: /sys/block/%s", devname);
- free_stringslen (r, size);
- return NULL;
+ reply_with_perror ("closedir: /sys/block/%s", devname);
+ free_stringslen (r, size);
+ return NULL;
}
}
}
diff --git a/daemon/dir.c b/daemon/dir.c
index a8f066f..5945862 100644
--- a/daemon/dir.c
+++ b/daemon/dir.c
@@ -123,8 +123,8 @@ recursive_mkdir (const char *path)
r = lstat (path, &buf);
if (r == -1) return -1;
if (!S_ISDIR (buf.st_mode)) {
- errno = ENOTDIR;
- return -1;
+ errno = ENOTDIR;
+ return -1;
}
return 0; /* OK - directory exists here already. */
}
diff --git a/daemon/ext2.c b/daemon/ext2.c
index 5a1d0fd..0f7a66c 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -77,31 +77,31 @@ do_tune2fs_l (char *device)
do { colon++; } while (*colon && isspace (*colon));
if (add_string (&ret, &size, &alloc, p) == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
if (strcmp (colon, "<none>") == 0 ||
- strcmp (colon, "<not available>") == 0 ||
- strcmp (colon, "(none)") == 0) {
- if (add_string (&ret, &size, &alloc, "") == -1) {
- free (out);
- return NULL;
- }
+ strcmp (colon, "<not available>") == 0 ||
+ strcmp (colon, "(none)") == 0) {
+ if (add_string (&ret, &size, &alloc, "") == -1) {
+ free (out);
+ return NULL;
+ }
} else {
- if (add_string (&ret, &size, &alloc, colon) == -1) {
- free (out);
- return NULL;
- }
+ if (add_string (&ret, &size, &alloc, colon) == -1) {
+ free (out);
+ return NULL;
+ }
}
}
else {
if (add_string (&ret, &size, &alloc, p) == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
if (add_string (&ret, &size, &alloc, "") == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
}
diff --git a/daemon/file.c b/daemon/file.c
index aab7e93..63d8dd2 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -97,18 +97,18 @@ do_cat (char *path)
if (size >= alloc) {
alloc += 8192;
if (alloc > max) {
- reply_with_error ("cat: %s: file is too large for message buffer",
- path);
- free (buf);
- close (fd);
- return NULL;
+ reply_with_error ("cat: %s: file is too large for message buffer",
+ path);
+ free (buf);
+ close (fd);
+ return NULL;
}
buf2 = realloc (buf, alloc);
if (buf2 == NULL) {
- reply_with_perror ("realloc");
- free (buf);
- close (fd);
- return NULL;
+ reply_with_perror ("realloc");
+ free (buf);
+ close (fd);
+ return NULL;
}
buf = buf2;
}
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index e8fb48f..07a1c5e 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -159,11 +159,11 @@ main (int argc, char *argv[])
p += 8;
p2 = strchr (p, ':');
if (p2) {
- *p2++ = '\0';
- host = p;
- r = strcspn (p2, " \n");
- p2[r] = '\0';
- port = p2;
+ *p2++ = '\0';
+ host = p;
+ r = strcspn (p2, " \n");
+ p2[r] = '\0';
+ port = p2;
}
}
}
@@ -209,7 +209,7 @@ main (int argc, char *argv[])
sock = socket (rr->ai_family, rr->ai_socktype, rr->ai_protocol);
if (sock != -1) {
if (connect (sock, rr->ai_addr, rr->ai_addrlen) == 0)
- break;
+ break;
perror ("connect");
close (sock);
@@ -578,40 +578,40 @@ commandrv (char **stdoutput, char **stderror, char * const* const
argv)
if (FD_ISSET (so_fd[0], &rset2)) { /* something on stdout */
r = read (so_fd[0], buf, sizeof buf);
if (r == -1) {
- perror ("read");
- goto quit;
+ perror ("read");
+ goto quit;
}
if (r == 0) { FD_CLR (so_fd[0], &rset); quit++; }
if (r > 0 && stdoutput) {
- so_size += r;
- p = realloc (*stdoutput, so_size);
- if (p == NULL) {
- perror ("realloc");
- goto quit;
- }
- *stdoutput = p;
- memcpy (*stdoutput + so_size - r, buf, r);
+ so_size += r;
+ p = realloc (*stdoutput, so_size);
+ if (p == NULL) {
+ perror ("realloc");
+ goto quit;
+ }
+ *stdoutput = p;
+ memcpy (*stdoutput + so_size - r, buf, r);
}
}
if (FD_ISSET (se_fd[0], &rset2)) { /* something on stderr */
r = read (se_fd[0], buf, sizeof buf);
if (r == -1) {
- perror ("read");
- goto quit;
+ perror ("read");
+ goto quit;
}
if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; }
if (r > 0 && stderror) {
- se_size += r;
- p = realloc (*stderror, se_size);
- if (p == NULL) {
- perror ("realloc");
- goto quit;
- }
- *stderror = p;
- memcpy (*stderror + se_size - r, buf, r);
+ se_size += r;
+ p = realloc (*stderror, se_size);
+ if (p == NULL) {
+ perror ("realloc");
+ goto quit;
+ }
+ *stderror = p;
+ memcpy (*stderror + se_size - r, buf, r);
}
}
}
@@ -643,7 +643,7 @@ commandrv (char **stdoutput, char **stderror, char * const* const
argv)
(*stderror)[se_size] = '\0';
se_size--;
while (se_size >= 0 && (*stderror)[se_size] == '\n')
- (*stderror)[se_size--] = '\0';
+ (*stderror)[se_size--] = '\0';
}
}
@@ -722,7 +722,7 @@ print_shell_quote (FILE *stream,
const void *const *args)
{
#define SAFE(c) (isalnum((c)) || \
- (c) == '/' || (c) == '-' || (c) == '_' || (c) == '.')
+ (c) == '/' || (c) == '-' || (c) == '_' || (c) ==
'.')
int i, len;
const char *str = *((const char **) (args[0]));
@@ -740,11 +740,11 @@ print_shell_quote (FILE *stream,
static int
print_sysroot_shell_quote (FILE *stream,
- const struct printf_info *info,
- const void *const *args)
+ const struct printf_info *info,
+ const void *const *args)
{
#define SAFE(c) (isalnum((c)) || \
- (c) == '/' || (c) == '-' || (c) == '_' || (c) == '.')
+ (c) == '/' || (c) == '-' || (c) == '_' || (c) ==
'.')
fputs (sysroot, stream);
return sysroot_len + print_shell_quote (stream, info, args);
}
@@ -752,7 +752,7 @@ print_sysroot_shell_quote (FILE *stream,
#ifdef HAVE_REGISTER_PRINTF_SPECIFIER
static int
print_arginfo (const struct printf_info *info,
- size_t n, int *argtypes, int *size)
+ size_t n, int *argtypes, int *size)
{
if (n > 0) {
argtypes[0] = PA_STRING;
diff --git a/daemon/inotify.c b/daemon/inotify.c
index 43f282d..4bc6f17 100644
--- a/daemon/inotify.c
+++ b/daemon/inotify.c
@@ -165,10 +165,10 @@ do_inotify_read (void)
int n, r;
r = read (inotify_fd, inotify_buf + inotify_posn,
- sizeof (inotify_buf) - inotify_posn);
+ sizeof (inotify_buf) - inotify_posn);
if (r == -1) {
if (errno == EWOULDBLOCK || errno == EAGAIN) /* End of list. */
- break;
+ break;
reply_with_perror ("read");
goto error;
}
@@ -190,18 +190,18 @@ do_inotify_read (void)
/* Have we got a complete event in the buffer? */
#ifdef __GNUC__
if (n + sizeof (struct inotify_event) > inotify_posn ||
- n + sizeof (struct inotify_event) + event->len > inotify_posn)
- break;
+ n + sizeof (struct inotify_event) + event->len > inotify_posn)
+ break;
#else
#error "this code needs fixing so it works on non-GCC compilers"
#endif
np = realloc (ret->guestfs_int_inotify_event_list_val,
- (ret->guestfs_int_inotify_event_list_len + 1) *
- sizeof (guestfs_int_inotify_event));
+ (ret->guestfs_int_inotify_event_list_len + 1) *
+ sizeof (guestfs_int_inotify_event));
if (np == NULL) {
- reply_with_perror ("realloc");
- goto error;
+ reply_with_perror ("realloc");
+ goto error;
}
ret->guestfs_int_inotify_event_list_val = np;
in =
&ret->guestfs_int_inotify_event_list_val[ret->guestfs_int_inotify_event_list_len];
@@ -212,12 +212,12 @@ do_inotify_read (void)
in->in_cookie = event->cookie;
if (event->len > 0)
- in->in_name = strdup (event->name);
+ in->in_name = strdup (event->name);
else
- in->in_name = strdup (""); /* Should have optional string fields XXX. */
+ in->in_name = strdup (""); /* Should have optional string fields
XXX. */
if (in->in_name == NULL) {
- reply_with_perror ("strdup");
- goto error;
+ reply_with_perror ("strdup");
+ goto error;
}
/* Estimate space used by this event in the message. */
@@ -279,7 +279,7 @@ do_inotify_files (void)
const char *name = events->guestfs_int_inotify_event_list_val[i].in_name;
if (name[0] != '\0')
- fprintf (fp, "%s\n", name);
+ fprintf (fp, "%s\n", name);
}
xdr_free ((xdrproc_t) xdr_guestfs_int_inotify_event_list, (char *) events);
diff --git a/daemon/link.c b/daemon/link.c
index 57e3538..29ae679 100644
--- a/daemon/link.c
+++ b/daemon/link.c
@@ -90,19 +90,19 @@ _link (const char *flag, int symbolic, const char *target, const char
*linkname)
if (flag)
r = command (NULL, &err,
- "ln", flag, "--", /* target could begin with '-' */
- buf_target ? : target, buf_linkname, NULL);
+ "ln", flag, "--", /* target could begin with
'-' */
+ buf_target ? : target, buf_linkname, NULL);
else
r = command (NULL, &err,
- "ln", "--",
- buf_target ? : target, buf_linkname, NULL);
+ "ln", "--",
+ buf_target ? : target, buf_linkname, NULL);
free (buf_linkname);
free (buf_target);
if (r == -1) {
reply_with_error ("ln%s%s: %s: %s: %s",
- flag ? " " : "",
- flag ? : "",
- target, linkname, err);
+ flag ? " " : "",
+ flag ? : "",
+ target, linkname, err);
free (err);
return -1;
}
diff --git a/daemon/lvm.c b/daemon/lvm.c
index 01b6435..624dcf3 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -93,7 +93,7 @@ do_pvs (void)
int r;
r = command (&out, &err,
- "/sbin/lvm", "pvs", "-o", "pv_name",
"--noheadings", NULL);
+ "/sbin/lvm", "pvs", "-o",
"pv_name", "--noheadings", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
@@ -113,7 +113,7 @@ do_vgs (void)
int r;
r = command (&out, &err,
- "/sbin/lvm", "vgs", "-o", "vg_name",
"--noheadings", NULL);
+ "/sbin/lvm", "vgs", "-o",
"vg_name", "--noheadings", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
@@ -133,9 +133,9 @@ do_lvs (void)
int r;
r = command (&out, &err,
- "/sbin/lvm", "lvs",
- "-o", "vg_name,lv_name", "--noheadings",
- "--separator", "/", NULL);
+ "/sbin/lvm", "lvs",
+ "-o", "vg_name,lv_name", "--noheadings",
+ "--separator", "/", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
@@ -179,7 +179,7 @@ do_pvcreate (char *device)
IS_DEVICE (device, -1);
r = command (NULL, &err,
- "/sbin/lvm", "pvcreate", device, NULL);
+ "/sbin/lvm", "pvcreate", device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@ -240,8 +240,8 @@ do_lvcreate (char *logvol, char *volgroup, int mbytes)
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
- "/sbin/lvm", "lvcreate",
- "-L", size, "-n", logvol, volgroup, NULL);
+ "/sbin/lvm", "lvcreate",
+ "-L", size, "-n", logvol, volgroup, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@ -267,8 +267,8 @@ do_lvresize (char *logvol, int mbytes)
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
- "/sbin/lvm", "lvresize",
- "-L", size, logvol, NULL);
+ "/sbin/lvm", "lvresize",
+ "-L", size, logvol, NULL);
if (r == -1) {
reply_with_error ("lvresize: %s", err);
free (err);
@@ -355,7 +355,7 @@ do_lvremove (char *device)
IS_DEVICE (device, -1);
r = command (NULL, &err,
- "/sbin/lvm", "lvremove", "-f", device, NULL);
+ "/sbin/lvm", "lvremove", "-f", device,
NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@ -376,7 +376,7 @@ do_vgremove (char *device)
int r;
r = command (NULL, &err,
- "/sbin/lvm", "vgremove", "-f", device, NULL);
+ "/sbin/lvm", "vgremove", "-f", device,
NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@ -399,7 +399,7 @@ do_pvremove (char *device)
IS_DEVICE (device, -1);
r = command (NULL, &err,
- "/sbin/lvm", "pvremove", "-ff", device, NULL);
+ "/sbin/lvm", "pvremove", "-ff", device,
NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@ -422,7 +422,7 @@ do_pvresize (char *device)
IS_DEVICE (device, -1);
r = command (NULL, &err,
- "/sbin/lvm", "pvresize", device, NULL);
+ "/sbin/lvm", "pvresize", device, NULL);
if (r == -1) {
reply_with_error ("pvresize: %s: %s", device, err);
free (err);
diff --git a/daemon/mount.c b/daemon/mount.c
index e7265fe..9754ca9 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -42,7 +42,7 @@ int root_mounted = 0;
int
do_mount_vfs (char *options, char *vfstype,
- char *device, char *mountpoint)
+ char *device, char *mountpoint)
{
int r, is_root;
char *mp;
@@ -65,10 +65,10 @@ do_mount_vfs (char *options, char *vfstype,
if (vfstype)
r = command (NULL, &error,
- "mount", "-o", options, "-t", vfstype, device, mp,
NULL);
+ "mount", "-o", options, "-t", vfstype,
device, mp, NULL);
else
r = command (NULL, &error,
- "mount", "-o", options, device, mp, NULL);
+ "mount", "-o", options, device, mp, NULL);
free (mp);
if (r == -1) {
reply_with_error ("mount: %s on %s: %s", device, mountpoint, error);
@@ -96,7 +96,7 @@ do_mount_ro (char *device, char *mountpoint)
int
do_mount_options (char *options, char *device,
- char *mountpoint)
+ char *mountpoint)
{
return do_mount_vfs (options, NULL, device, mountpoint);
}
@@ -176,22 +176,22 @@ mounts_or_mountpoints (int mp)
if (p2 != NULL) {
*p2 = '\0';
if (add_string (&ret, &size, &alloc, p) == -1) {
- free (out);
- return NULL;
+ free (out);
+ return NULL;
}
if (mp) {
- p2 += 4 + sysroot_len; /* skip " on /sysroot" */
- len = strcspn (p2, " ");
-
- if (len == 0) /* .. just /sysroot, so we turn it into "/" */
- p2 = (char *) "/";
- else
- p2[len] = '\0';
-
- if (add_string (&ret, &size, &alloc, p2) == -1) {
- free (out);
- return NULL;
- }
+ p2 += 4 + sysroot_len; /* skip " on /sysroot" */
+ len = strcspn (p2, " ");
+
+ if (len == 0) /* .. just /sysroot, so we turn it into "/" */
+ p2 = (char *) "/";
+ else
+ p2[len] = '\0';
+
+ if (add_string (&ret, &size, &alloc, p2) == -1) {
+ free (out);
+ return NULL;
+ }
}
}
@@ -277,8 +277,8 @@ do_umount_all (void)
p3 = p2 + strcspn (p2, " ");
*p3 = '\0';
if (add_string (&mounts, &size, &alloc, p2) == -1) {
- free (out);
- return -1;
+ free (out);
+ return -1;
}
}
diff --git a/daemon/proto.c b/daemon/proto.c
index acd6601..709f978 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -69,7 +69,7 @@ main_loop (int _sock)
if (len > GUESTFS_MESSAGE_MAX) {
fprintf (stderr, "guestfsd: incoming message is too long (%u bytes)\n",
- len);
+ len);
exit (1);
}
@@ -86,20 +86,20 @@ main_loop (int _sock)
int i, j;
for (i = 0; i < len; i += 16) {
- printf ("%04x: ", i);
- for (j = i; j < MIN (i+16, len); ++j)
- printf ("%02x ", (unsigned char) buf[j]);
- for (; j < i+16; ++j)
- printf (" ");
- printf ("|");
- for (j = i; j < MIN (i+16, len); ++j)
- if (isprint (buf[j]))
- printf ("%c", buf[j]);
- else
- printf (".");
- for (; j < i+16; ++j)
- printf (" ");
- printf ("|\n");
+ printf ("%04x: ", i);
+ for (j = i; j < MIN (i+16, len); ++j)
+ printf ("%02x ", (unsigned char) buf[j]);
+ for (; j < i+16; ++j)
+ printf (" ");
+ printf ("|");
+ for (j = i; j < MIN (i+16, len); ++j)
+ if (isprint (buf[j]))
+ printf ("%c", buf[j]);
+ else
+ printf (".");
+ for (; j < i+16; ++j)
+ printf (" ");
+ printf ("|\n");
}
}
#endif
@@ -147,11 +147,11 @@ main_loop (int _sock)
end_us = (int64_t) end_t.tv_sec * 1000000 + end_t.tv_usec;
elapsed_us = end_us - start_us;
fprintf (stderr, "proc %d (%s) took %d.%02d seconds\n",
- proc_nr,
- proc_nr >= 0 && proc_nr < GUESTFS_PROC_NR_PROCS
- ? function_names[proc_nr] : "UNKNOWN PROCEDURE",
- (int) (elapsed_us / 1000000),
- (int) ((elapsed_us / 10000) % 100));
+ proc_nr,
+ proc_nr >= 0 && proc_nr < GUESTFS_PROC_NR_PROCS
+ ? function_names[proc_nr] : "UNKNOWN PROCEDURE",
+ (int) (elapsed_us / 1000000),
+ (int) ((elapsed_us / 10000) % 100));
}
cont:
@@ -317,7 +317,7 @@ receive_file (receive_cb cb, void *opaque)
if (len > GUESTFS_MESSAGE_MAX) {
fprintf (stderr, "guestfsd: incoming message is too long (%u bytes)\n",
- len);
+ len);
exit (1);
}
@@ -341,7 +341,7 @@ receive_file (receive_cb cb, void *opaque)
if (verbose)
printf ("receive_file: got chunk: cancel = %d, len = %d, buf = %p\n",
- chunk.cancel, chunk.data.data_len, chunk.data.data_val);
+ chunk.cancel, chunk.data.data_len, chunk.data.data_val);
if (chunk.cancel) {
fprintf (stderr, "receive_file: received cancellation from library\n");
@@ -397,7 +397,7 @@ send_file_write (const void *buf, int len)
if (len > GUESTFS_MAX_CHUNK_SIZE) {
fprintf (stderr, "send_file_write: len (%d) > GUESTFS_MAX_CHUNK_SIZE
(%d)\n",
- len, GUESTFS_MAX_CHUNK_SIZE);
+ len, GUESTFS_MAX_CHUNK_SIZE);
return -1;
}
@@ -455,7 +455,7 @@ check_for_library_cancellation (void)
if (flag != GUESTFS_CANCEL_FLAG) {
fprintf (stderr, "check_for_library_cancellation: read 0x%x from library,
expected 0x%x\n",
- flag, GUESTFS_CANCEL_FLAG);
+ flag, GUESTFS_CANCEL_FLAG);
return 0;
}
diff --git a/daemon/readdir.c b/daemon/readdir.c
index e3851db..17fc619 100644
--- a/daemon/readdir.c
+++ b/daemon/readdir.c
@@ -63,7 +63,7 @@ do_readdir (char *path)
guestfs_int_dirent *p;
p = realloc (ret->guestfs_int_dirent_list_val,
- sizeof (guestfs_int_dirent) * (i+1));
+ sizeof (guestfs_int_dirent) * (i+1));
v.name = strdup (d->d_name);
if (!p || !v.name) {
reply_with_perror ("allocate");
diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c
index f512e26..e06d0bf 100644
--- a/daemon/sfdisk.c
+++ b/daemon/sfdisk.c
@@ -31,8 +31,8 @@
static int
sfdisk (char *device, int n, int cyls, int heads, int sectors,
- const char *extra_flag,
- char * const* const lines)
+ const char *extra_flag,
+ char * const* const lines)
{
FILE *fp;
char buf[256];
@@ -85,14 +85,14 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors,
int
do_sfdisk (char *device, int cyls, int heads, int sectors,
- char **lines)
+ char **lines)
{
return sfdisk (device, 0, cyls, heads, sectors, NULL, lines);
}
int
do_sfdisk_N (char *device, int n, int cyls, int heads, int sectors,
- char *line)
+ char *line)
{
const char *lines[2] = { line, NULL };
diff --git a/daemon/xattr.c b/daemon/xattr.c
index 23b00d8..a908a44 100644
--- a/daemon/xattr.c
+++ b/daemon/xattr.c
@@ -107,9 +107,9 @@ do_lremovexattr (char *xattr, char *path)
static guestfs_int_xattr_list *
getxattrs (char *path,
- ssize_t (*listxattr) (const char *path, char *list, size_t size),
- ssize_t (*getxattr) (const char *path, const char *name,
- void *value, size_t size))
+ ssize_t (*listxattr) (const char *path, char *list, size_t size),
+ ssize_t (*getxattr) (const char *path, const char *name,
+ void *value, size_t size))
{
ssize_t len, vlen;
char *buf = NULL;
@@ -175,15 +175,15 @@ getxattrs (char *path,
r->guestfs_int_xattr_list_val[j].attrval.attrval_len = vlen;
if (r->guestfs_int_xattr_list_val[j].attrname == NULL ||
- r->guestfs_int_xattr_list_val[j].attrval.attrval_val == NULL) {
+ r->guestfs_int_xattr_list_val[j].attrval.attrval_val == NULL) {
reply_with_perror ("malloc");
goto error;
}
CHROOT_IN;
vlen = getxattr (path, &buf[i],
- r->guestfs_int_xattr_list_val[j].attrval.attrval_val,
- vlen);
+ r->guestfs_int_xattr_list_val[j].attrval.attrval_val,
+ vlen);
CHROOT_OUT;
if (vlen == -1) {
reply_with_perror ("getxattr");
@@ -200,8 +200,8 @@ getxattrs (char *path,
if (r) {
if (r->guestfs_int_xattr_list_val)
for (i = 0; i < r->guestfs_int_xattr_list_len; ++i) {
- free (r->guestfs_int_xattr_list_val[i].attrname);
- free (r->guestfs_int_xattr_list_val[i].attrval.attrval_val);
+ free (r->guestfs_int_xattr_list_val[i].attrname);
+ free (r->guestfs_int_xattr_list_val[i].attrval.attrval_val);
}
free (r->guestfs_int_xattr_list_val);
}
@@ -211,8 +211,8 @@ getxattrs (char *path,
static int
_setxattr (char *xattr, char *val, int vallen, char *path,
- int (*setxattr) (const char *path, const char *name,
- const void *value, size_t size, int flags))
+ int (*setxattr) (const char *path, const char *name,
+ const void *value, size_t size, int flags))
{
int r;
@@ -229,7 +229,7 @@ _setxattr (char *xattr, char *val, int vallen, char *path,
static int
_removexattr (char *xattr, char *path,
- int (*removexattr) (const char *path, const char *name))
+ int (*removexattr) (const char *path, const char *name))
{
int r;
diff --git a/df/virt-df.pl b/df/virt-df.pl
index 25fd6a8..a1b2228 100755
--- a/df/virt-df.pl
+++ b/df/virt-df.pl
@@ -131,8 +131,8 @@ Print inodes instead of blocks.
=cut
GetOptions ("help|?" => \$help,
- "version" => \$version,
- "connect|c=s" => \$uri,
+ "version" => \$version,
+ "connect|c=s" => \$uri,
"csv" => \$csv,
"human-readable|human|h" => \$human,
"inodes|i" => \$inodes,
@@ -151,9 +151,9 @@ if (@ARGV == 0) {
my $conn;
if ($uri) {
- $conn = Sys::Virt->new (readonly => 1, address => $uri);
+ $conn = Sys::Virt->new (readonly => 1, address => $uri);
} else {
- $conn = Sys::Virt->new (readonly => 1);
+ $conn = Sys::Virt->new (readonly => 1);
}
my @doms = $conn->list_defined_domains ();
@@ -162,10 +162,10 @@ if (@ARGV == 0) {
my @domnames = map { $_->get_name () } @doms;
if (@domnames) {
- print_title ();
- foreach (@domnames) {
- do_df ($_);
- }
+ print_title ();
+ foreach (@domnames) {
+ do_df ($_);
+ }
}
} else {
print_title ();
@@ -177,9 +177,9 @@ sub do_df
my $g;
if ($uri) {
- $g = open_guest (\@_, address => $uri);
+ $g = open_guest (\@_, address => $uri);
} else {
- $g = open_guest (\@_);
+ $g = open_guest (\@_);
}
$g->launch ();
@@ -195,15 +195,15 @@ sub do_df
# Mount each partition in turn, and if mountable, do a statvfs on it.
foreach my $partition (@partitions) {
- my %stat;
- eval {
- $g->mount_ro ($partition, "/");
- %stat = $g->statvfs ("/");
- };
- if (!$@) {
- print_stat ($domname, $partition, \%stat);
- }
- $g->umount_all ();
+ my %stat;
+ eval {
+ $g->mount_ro ($partition, "/");
+ %stat = $g->statvfs ("/");
+ };
+ if (!$@) {
+ print_stat ($domname, $partition, \%stat);
+ }
+ $g->umount_all ();
}
}
@@ -216,38 +216,38 @@ sub print_stat
my @cols = ($domname, $partition);
if (!$inodes) {
- my $bsize = $stat->{bsize}; # block size
- my $blocks = $stat->{blocks}; # total number of blocks
- my $bfree = $stat->{bfree}; # blocks free (total)
- my $bavail = $stat->{bavail}; # blocks free (for non-root users)
-
- my $factor = $bsize / 1024;
-
- push @cols, $blocks*$factor; # total 1K blocks
- push @cols, ($blocks-$bfree)*$factor; # total 1K blocks used
- push @cols, $bavail*$factor; # total 1K blocks available
-
- # XXX %used column comes out different from the native 'df'
- # program. Need to check how 'df' calculates this.
- push @cols, 100.0 - 100.0 * $bavail / $blocks;
-
- if ($human) {
- $cols[2] = human_size ($cols[2]);
- $cols[3] = human_size ($cols[3]);
- $cols[4] = human_size ($cols[4]);
- }
+ my $bsize = $stat->{bsize}; # block size
+ my $blocks = $stat->{blocks}; # total number of blocks
+ my $bfree = $stat->{bfree}; # blocks free (total)
+ my $bavail = $stat->{bavail}; # blocks free (for non-root users)
+
+ my $factor = $bsize / 1024;
+
+ push @cols, $blocks*$factor; # total 1K blocks
+ push @cols, ($blocks-$bfree)*$factor; # total 1K blocks used
+ push @cols, $bavail*$factor; # total 1K blocks available
+
+ # XXX %used column comes out different from the native 'df'
+ # program. Need to check how 'df' calculates this.
+ push @cols, 100.0 - 100.0 * $bavail / $blocks;
+
+ if ($human) {
+ $cols[2] = human_size ($cols[2]);
+ $cols[3] = human_size ($cols[3]);
+ $cols[4] = human_size ($cols[4]);
+ }
} else {
- my $files = $stat->{files}; # total number of inodes
- my $ffree = $stat->{ffree}; # inodes free (total)
- my $favail = $stat->{favail}; # inodes free (for non-root users)
+ my $files = $stat->{files}; # total number of inodes
+ my $ffree = $stat->{ffree}; # inodes free (total)
+ my $favail = $stat->{favail}; # inodes free (for non-root users)
- push @cols, $files;
- push @cols, $files-$ffree;
- push @cols, $ffree;
+ push @cols, $files;
+ push @cols, $files-$ffree;
+ push @cols, $ffree;
- # XXX %used column comes out different from the native 'df'
- # program. Need to check how 'df' calculates this.
- push @cols, 100.0 - 100.0 * $favail / $files;
+ # XXX %used column comes out different from the native 'df'
+ # program. Need to check how 'df' calculates this.
+ push @cols, 100.0 - 100.0 * $favail / $files;
}
print_cols (@cols);
@@ -257,42 +257,42 @@ sub print_title
{
my @cols = (__"Virtual Machine", __"Filesystem");
if (!$inodes) {
- if (!$human) {
- push @cols, __"1K-blocks";
- } else {
- push @cols, __"Size";
- }
- push @cols, __"Used";
- push @cols, __"Available";
- push @cols, __"Use%";
+ if (!$human) {
+ push @cols, __"1K-blocks";
+ } else {
+ push @cols, __"Size";
+ }
+ push @cols, __"Used";
+ push @cols, __"Available";
+ push @cols, __"Use%";
} else {
- push @cols, __"Inodes";
- push @cols, __"IUsed";
- push @cols, __"IFree";
- push @cols, __"IUse%";
+ push @cols, __"Inodes";
+ push @cols, __"IUsed";
+ push @cols, __"IFree";
+ push @cols, __"IUse%";
}
if (!$csv) {
- # ignore $cols[0] in this mode
- printf "%-36s%10s %10s %10s %5s\n",
- $cols[1], $cols[2], $cols[3], $cols[4], $cols[5];
+ # ignore $cols[0] in this mode
+ printf "%-36s%10s %10s %10s %5s\n",
+ $cols[1], $cols[2], $cols[3], $cols[4], $cols[5];
} else {
- print (join (",", @cols), "\n");
+ print (join (",", @cols), "\n");
}
}
sub print_cols
{
if (!$csv) {
- my $label = sprintf "%s:%s", $_[0], $_[1];
+ my $label = sprintf "%s:%s", $_[0], $_[1];
- printf ("%-36s", $label);
- print "\n"," "x36 if length ($label) > 36;
+ printf ("%-36s", $label);
+ print "\n"," "x36 if length ($label) > 36;
- my $percent = sprintf "%3.1f%%", $_[5];
- printf ("%10s %10s %10s %5s\n", $_[2], $_[3], $_[4], $percent);
+ my $percent = sprintf "%3.1f%%", $_[5];
+ printf ("%10s %10s %10s %5s\n", $_[2], $_[3], $_[4], $percent);
} else {
- printf ("\"%s\",\"%s\",%d,%d,%d,%.1f%%\n", @_);
+ printf ("\"%s\",\"%s\",%d,%d,%d,%.1f%%\n", @_);
}
}
@@ -302,11 +302,11 @@ sub human_size
local $_ = shift;
if ($_ < 1024) {
- sprintf "%dK", $_;
+ sprintf "%dK", $_;
} elsif ($_ < 1024 * 1024) {
- sprintf "%.1fM", ($_ / 1024);
+ sprintf "%.1fM", ($_ / 1024);
} else {
- sprintf "%.1fG", ($_ / 1024 / 1024);
+ sprintf "%.1fG", ($_ / 1024 / 1024);
}
}
diff --git a/examples/to-xml.c b/examples/to-xml.c
index a62660c..2cf3de8 100644
--- a/examples/to-xml.c
+++ b/examples/to-xml.c
@@ -89,14 +89,14 @@ main (int argc, char *argv[])
int j;
for (j = 0; lvs[j] != NULL; ++j) {
if (strncmp (lvs[j], "/dev/", 5) == 0 &&
- strncmp (&lvs[j][5], vgs[i], len) == 0 &&
- lvs[j][len+5] == '/') {
- int64_t size;
- CALL (size = guestfs_blockdev_getsize64 (g, lvs[j]), -1);
- printf ("<logvol name=\"%s\" size=\"%" PRIi64
"\">\n", lvs[j], size);
- display_partition (g, lvs[j]);
- printf ("</logvol>\n");
- free (lvs[j]);
+ strncmp (&lvs[j][5], vgs[i], len) == 0 &&
+ lvs[j][len+5] == '/') {
+ int64_t size;
+ CALL (size = guestfs_blockdev_getsize64 (g, lvs[j]), -1);
+ printf ("<logvol name=\"%s\" size=\"%" PRIi64
"\">\n", lvs[j], size);
+ display_partition (g, lvs[j]);
+ printf ("</logvol>\n");
+ free (lvs[j]);
}
}
diff --git a/fish/destpaths.c b/fish/destpaths.c
index a9d65a5..f4f1318 100644
--- a/fish/destpaths.c
+++ b/fish/destpaths.c
@@ -112,24 +112,24 @@ complete_dest_paths_generator (const char *text, int state)
if (strs) { \
size_t i; \
size_t n = count_strings (strs); \
- \
+ \
if ( ! xalloc_oversized (nr_words + n, sizeof (struct word))) { \
- struct word *w; \
- w = realloc (words, sizeof (struct word) * (nr_words + n)); \
- \
- if (w == NULL) { \
- free_words (words, nr_words); \
- words = NULL; \
- nr_words = 0; \
- } else { \
- words = w; \
- for (i = 0; i < n; ++i) { \
- words[nr_words].name = strs[i]; \
- words[nr_words].is_dir = 0; \
- nr_words++; \
- } \
- } \
- free (strs); \
+ struct word *w; \
+ w = realloc (words, sizeof (struct word) * (nr_words + n)); \
+ \
+ if (w == NULL) { \
+ free_words (words, nr_words); \
+ words = NULL; \
+ nr_words = 0; \
+ } else { \
+ words = w; \
+ for (i = 0; i < n; ++i) { \
+ words[nr_words].name = strs[i]; \
+ words[nr_words].is_dir = 0; \
+ nr_words++; \
+ } \
+ } \
+ free (strs); \
} \
} \
} while (0)
@@ -157,46 +157,46 @@ complete_dest_paths_generator (const char *text, int state)
p = strrchr (text, '/');
dir = p && p > text ? strndup (text, p - text) : strdup
("/");
if (dir) {
- dirents = guestfs_readdir (g, dir);
-
- /* Prepend directory to names before adding them to the list
- * of words.
- */
- if (dirents) {
- size_t i;
-
- for (i = 0; i < dirents->len; ++i) {
- int err;
-
- if (strcmp (dirents->val[i].name, ".") != 0 &&
- strcmp (dirents->val[i].name, "..") != 0) {
- if (strcmp (dir, "/") == 0)
- err = asprintf (&p, "/%s", dirents->val[i].name);
- else
- err = asprintf (&p, "%s/%s", dir, dirents->val[i].name);
- if (err >= 0) {
- if (!xalloc_oversized (nr_words+1, sizeof (struct word))) {
- struct word *w;
-
- w = realloc (words, sizeof (struct word) * (nr_words+1));
- if (w == NULL) {
- free_words (words, nr_words);
- words = NULL;
- nr_words = 0;
- }
- else {
- words = w;
- words[nr_words].name = p;
- words[nr_words].is_dir = dirents->val[i].ftyp == 'd';
- nr_words++;
- }
- }
- }
- }
- }
-
- guestfs_free_dirent_list (dirents);
- }
+ dirents = guestfs_readdir (g, dir);
+
+ /* Prepend directory to names before adding them to the list
+ * of words.
+ */
+ if (dirents) {
+ size_t i;
+
+ for (i = 0; i < dirents->len; ++i) {
+ int err;
+
+ if (strcmp (dirents->val[i].name, ".") != 0 &&
+ strcmp (dirents->val[i].name, "..") != 0) {
+ if (strcmp (dir, "/") == 0)
+ err = asprintf (&p, "/%s", dirents->val[i].name);
+ else
+ err = asprintf (&p, "%s/%s", dir,
dirents->val[i].name);
+ if (err >= 0) {
+ if (!xalloc_oversized (nr_words+1, sizeof (struct word))) {
+ struct word *w;
+
+ w = realloc (words, sizeof (struct word) * (nr_words+1));
+ if (w == NULL) {
+ free_words (words, nr_words);
+ words = NULL;
+ nr_words = 0;
+ }
+ else {
+ words = w;
+ words[nr_words].name = p;
+ words[nr_words].is_dir = dirents->val[i].ftyp == 'd';
+ nr_words++;
+ }
+ }
+ }
+ }
+ }
+
+ guestfs_free_dirent_list (dirents);
+ }
}
}
@@ -219,7 +219,7 @@ complete_dest_paths_generator (const char *text, int state)
if (strncasecmp (word->name, text, len) == 0) {
if (word->is_dir)
- rl_completion_append_character = '/';
+ rl_completion_append_character = '/';
return strdup (word->name);
}
diff --git a/fish/fish.c b/fish/fish.c
index b0d123d..f245de1 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -91,36 +91,36 @@ static void
usage (void)
{
fprintf (stderr,
- _("guestfish: guest filesystem shell\n"
- "guestfish lets you edit virtual machine filesystems\n"
- "Copyright (C) 2009 Red Hat Inc.\n"
- "Usage:\n"
- " guestfish [--options] cmd [: cmd : cmd ...]\n"
- " guestfish -i libvirt-domain\n"
- " guestfish -i disk-image(s)\n"
- "or for interactive use:\n"
- " guestfish\n"
- "or from a shell script:\n"
- " guestfish <<EOF\n"
- " cmd\n"
- " ...\n"
- " EOF\n"
- "Options:\n"
- " -h|--cmd-help List available commands\n"
- " -h|--cmd-help cmd Display detailed help on 'cmd'\n"
- " -a|--add image Add image\n"
- " -D|--no-dest-paths Don't tab-complete paths from guest fs\n"
- " -f|--file file Read commands from file\n"
- " -i|--inspector Run virt-inspector to get disk mountpoints\n"
- " --listen Listen for remote commands\n"
- " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n"
- " -n|--no-sync Don't autosync\n"
- " --remote[=pid] Send commands to remote guestfish\n"
- " -r|--ro Mount read-only\n"
- " -v|--verbose Verbose messages\n"
- " -x Echo each command before executing it\n"
- " -V|--version Display version and exit\n"
- "For more information, see the manpage guestfish(1).\n"));
+ _("guestfish: guest filesystem shell\n"
+ "guestfish lets you edit virtual machine filesystems\n"
+ "Copyright (C) 2009 Red Hat Inc.\n"
+ "Usage:\n"
+ " guestfish [--options] cmd [: cmd : cmd ...]\n"
+ " guestfish -i libvirt-domain\n"
+ " guestfish -i disk-image(s)\n"
+ "or for interactive use:\n"
+ " guestfish\n"
+ "or from a shell script:\n"
+ " guestfish <<EOF\n"
+ " cmd\n"
+ " ...\n"
+ " EOF\n"
+ "Options:\n"
+ " -h|--cmd-help List available commands\n"
+ " -h|--cmd-help cmd Display detailed help on 'cmd'\n"
+ " -a|--add image Add image\n"
+ " -D|--no-dest-paths Don't tab-complete paths from guest
fs\n"
+ " -f|--file file Read commands from file\n"
+ " -i|--inspector Run virt-inspector to get disk
mountpoints\n"
+ " --listen Listen for remote commands\n"
+ " -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n"
+ " -n|--no-sync Don't autosync\n"
+ " --remote[=pid] Send commands to remote guestfish\n"
+ " -r|--ro Mount read-only\n"
+ " -v|--verbose Verbose messages\n"
+ " -x Echo each command before executing it\n"
+ " -V|--version Display version and exit\n"
+ "For more information, see the manpage guestfish(1).\n"));
}
int
@@ -191,31 +191,31 @@ main (int argc, char *argv[])
switch (c) {
case 0: /* options which are long only */
if (strcmp (long_options[option_index].name, "listen") == 0)
- remote_control_listen = 1;
+ remote_control_listen = 1;
else if (strcmp (long_options[option_index].name, "remote") == 0) {
- if (optarg) {
- if (sscanf (optarg, "%d", &remote_control) != 1) {
- fprintf (stderr, _("guestfish: --listen=PID: PID was not a number: %s\n"),
optarg);
- exit (1);
- }
- } else {
- p = getenv ("GUESTFISH_PID");
- if (!p || sscanf (p, "%d", &remote_control) != 1) {
- fprintf (stderr, _("guestfish: remote: $GUESTFISH_PID must be set to the PID of
the remote process\n"));
- exit (1);
- }
- }
+ if (optarg) {
+ if (sscanf (optarg, "%d", &remote_control) != 1) {
+ fprintf (stderr, _("guestfish: --listen=PID: PID was not a number:
%s\n"), optarg);
+ exit (1);
+ }
+ } else {
+ p = getenv ("GUESTFISH_PID");
+ if (!p || sscanf (p, "%d", &remote_control) != 1) {
+ fprintf (stderr, _("guestfish: remote: $GUESTFISH_PID must be set to the
PID of the remote process\n"));
+ exit (1);
+ }
+ }
} else {
- fprintf (stderr, _("guestfish: unknown long option: %s (%d)\n"),
- long_options[option_index].name, option_index);
- exit (1);
+ fprintf (stderr, _("guestfish: unknown long option: %s (%d)\n"),
+ long_options[option_index].name, option_index);
+ exit (1);
}
break;
case 'a':
if (access (optarg, R_OK) != 0) {
- perror (optarg);
- exit (1);
+ perror (optarg);
+ exit (1);
}
drv = malloc (sizeof (struct drv));
if (!drv) {
@@ -233,19 +233,19 @@ main (int argc, char *argv[])
case 'f':
if (file) {
- fprintf (stderr, _("guestfish: only one -f parameter can be given\n"));
- exit (1);
+ fprintf (stderr, _("guestfish: only one -f parameter can be
given\n"));
+ exit (1);
}
file = optarg;
break;
case 'h':
if (optarg)
- display_command (optarg);
+ display_command (optarg);
else if (argv[optind] && argv[optind][0] != '-')
- display_command (argv[optind++]);
+ display_command (argv[optind++]);
else
- list_commands ();
+ list_commands ();
exit (0);
case 'i':
@@ -255,15 +255,15 @@ main (int argc, char *argv[])
case 'm':
mp = malloc (sizeof (struct mp));
if (!mp) {
- perror ("malloc");
- exit (1);
+ perror ("malloc");
+ exit (1);
}
p = strchr (optarg, ':');
if (p) {
- *p = '\0';
- mp->mountpoint = p+1;
+ *p = '\0';
+ mp->mountpoint = p+1;
} else
- mp->mountpoint = "/";
+ mp->mountpoint = "/";
mp->device = optarg;
mp->next = mps;
mps = mp;
@@ -296,7 +296,7 @@ main (int argc, char *argv[])
default:
fprintf (stderr, _("guestfish: unexpected command line option 0x%x\n"),
- c);
+ c);
exit (1);
}
}
@@ -318,9 +318,9 @@ main (int argc, char *argv[])
strcpy (cmd, "a=`virt-inspector");
while (optind < argc) {
if (strlen (cmd) + strlen (argv[optind]) + strlen (argv[0]) + 60
- >= sizeof cmd) {
- fprintf (stderr, _("guestfish: virt-inspector command too long for fixed-size
buffer\n"));
- exit (1);
+ >= sizeof cmd) {
+ fprintf (stderr, _("guestfish: virt-inspector command too long for
fixed-size buffer\n"));
+ exit (1);
}
strcat (cmd, " '");
strcat (cmd, argv[optind]);
@@ -342,7 +342,7 @@ main (int argc, char *argv[])
if (verbose)
fprintf (stderr,
- "guestfish -i: running virt-inspector command:\n%s\n", cmd);
+ "guestfish -i: running virt-inspector command:\n%s\n", cmd);
r = system (cmd);
if (r == -1) {
@@ -518,12 +518,12 @@ script (int prompt)
if (prompt)
printf (_("\n"
- "Welcome to guestfish, the libguestfs filesystem interactive shell
for\n"
- "editing virtual machine filesystems.\n"
- "\n"
- "Type: 'help' for help with commands\n"
- " 'quit' to quit the shell\n"
- "\n"));
+ "Welcome to guestfish, the libguestfs filesystem interactive shell
for\n"
+ "editing virtual machine filesystems.\n"
+ "\n"
+ "Type: 'help' for help with commands\n"
+ " 'quit' to quit the shell\n"
+ "\n"));
while (!quit) {
char *pipe = NULL;
@@ -552,11 +552,11 @@ script (int prompt)
r = system (buf+1);
if (exit_on_error) {
- if (r == -1 ||
- (WIFSIGNALED (r) &&
- (WTERMSIG (r) == SIGINT || WTERMSIG (r) == SIGQUIT)) ||
- WEXITSTATUS (r) != 0)
- exit (1);
+ if (r == -1 ||
+ (WIFSIGNALED (r) &&
+ (WTERMSIG (r) == SIGINT || WTERMSIG (r) == SIGQUIT)) ||
+ WEXITSTATUS (r) != 0)
+ exit (1);
}
continue;
}
@@ -594,88 +594,88 @@ script (int prompt)
* specially. Bare parameters are delimited by whitespace.
*/
if (*p == '"') {
- p++;
- len = strcspn (p, "\"");
- if (p[len] == '\0') {
- fprintf (stderr, _("guestfish: unterminated double quote\n"));
- if (exit_on_error) exit (1);
- goto next_command;
- }
- if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t'))
{
- fprintf (stderr, _("guestfish: command arguments not separated by
whitespace\n"));
- if (exit_on_error) exit (1);
- goto next_command;
- }
- p[len] = '\0';
- pend = p[len+1] ? &p[len+2] : &p[len+1];
+ p++;
+ len = strcspn (p, "\"");
+ if (p[len] == '\0') {
+ fprintf (stderr, _("guestfish: unterminated double quote\n"));
+ if (exit_on_error) exit (1);
+ goto next_command;
+ }
+ if (p[len+1] && (p[len+1] != ' ' && p[len+1] !=
'\t')) {
+ fprintf (stderr, _("guestfish: command arguments not separated by
whitespace\n"));
+ if (exit_on_error) exit (1);
+ goto next_command;
+ }
+ p[len] = '\0';
+ pend = p[len+1] ? &p[len+2] : &p[len+1];
} else if (*p == '\'') {
- p++;
- len = strcspn (p, "'");
- if (p[len] == '\0') {
- fprintf (stderr, _("guestfish: unterminated single quote\n"));
- if (exit_on_error) exit (1);
- goto next_command;
- }
- if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t'))
{
- fprintf (stderr, _("guestfish: command arguments not separated by
whitespace\n"));
- if (exit_on_error) exit (1);
- goto next_command;
- }
- p[len] = '\0';
- pend = p[len+1] ? &p[len+2] : &p[len+1];
+ p++;
+ len = strcspn (p, "'");
+ if (p[len] == '\0') {
+ fprintf (stderr, _("guestfish: unterminated single quote\n"));
+ if (exit_on_error) exit (1);
+ goto next_command;
+ }
+ if (p[len+1] && (p[len+1] != ' ' && p[len+1] !=
'\t')) {
+ fprintf (stderr, _("guestfish: command arguments not separated by
whitespace\n"));
+ if (exit_on_error) exit (1);
+ goto next_command;
+ }
+ p[len] = '\0';
+ pend = p[len+1] ? &p[len+2] : &p[len+1];
} else if (*p == '|') {
- *p = '\0';
- pipe = p+1;
- continue;
- /*
+ *p = '\0';
+ pipe = p+1;
+ continue;
+ /*
} else if (*p == '[') {
- int c = 1;
- p++;
- pend = p;
- while (*pend && c != 0) {
- if (*pend == '[') c++;
- else if (*pend == ']') c--;
- pend++;
- }
- if (c != 0) {
- fprintf (stderr, _("guestfish: unterminated \"[...]\"
sequence\n"));
- if (exit_on_error) exit (1);
- goto next_command;
- }
- if (*pend && (*pend != ' ' && *pend != '\t')) {
- fprintf (stderr, _("guestfish: command arguments not separated by
whitespace\n"));
- if (exit_on_error) exit (1);
- goto next_command;
- }
- *(pend-1) = '\0';
- */
+ int c = 1;
+ p++;
+ pend = p;
+ while (*pend && c != 0) {
+ if (*pend == '[') c++;
+ else if (*pend == ']') c--;
+ pend++;
+ }
+ if (c != 0) {
+ fprintf (stderr, _("guestfish: unterminated \"[...]\"
sequence\n"));
+ if (exit_on_error) exit (1);
+ goto next_command;
+ }
+ if (*pend && (*pend != ' ' && *pend != '\t')) {
+ fprintf (stderr, _("guestfish: command arguments not separated by
whitespace\n"));
+ if (exit_on_error) exit (1);
+ goto next_command;
+ }
+ *(pend-1) = '\0';
+ */
} else if (*p != ' ' && *p != '\t') {
- /* If the first character is a ~ then note that this parameter
- * is a candidate for ~username expansion. NB this does not
- * apply to quoted parameters.
- */
- tilde_candidate = *p == '~';
- len = strcspn (p, " \t");
- if (p[len]) {
- p[len] = '\0';
- pend = &p[len+1];
- } else
- pend = &p[len];
+ /* If the first character is a ~ then note that this parameter
+ * is a candidate for ~username expansion. NB this does not
+ * apply to quoted parameters.
+ */
+ tilde_candidate = *p == '~';
+ len = strcspn (p, " \t");
+ if (p[len]) {
+ p[len] = '\0';
+ pend = &p[len+1];
+ } else
+ pend = &p[len];
} else {
- fprintf (stderr, _("guestfish: internal error parsing string at
'%s'\n"),
- p);
- abort ();
+ fprintf (stderr, _("guestfish: internal error parsing string at
'%s'\n"),
+ p);
+ abort ();
}
if (!tilde_candidate)
- argv[i] = p;
+ argv[i] = p;
else
- argv[i] = try_tilde_expansion (p);
+ argv[i] = try_tilde_expansion (p);
i++;
p = pend;
if (*p)
- p += strspn (p, " \t");
+ p += strspn (p, " \t");
}
if (i == sizeof argv / sizeof argv[0]) {
@@ -759,8 +759,8 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd)
r = system (pipecmd);
if (r == -1) {
- perror (pipecmd);
- _exit (1);
+ perror (pipecmd);
+ _exit (1);
}
_exit (WEXITSTATUS (r));
}
@@ -787,26 +787,26 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd)
r = 0;
}
else if (strcasecmp (cmd, "quit") == 0 ||
- strcasecmp (cmd, "exit") == 0 ||
- strcasecmp (cmd, "q") == 0) {
+ strcasecmp (cmd, "exit") == 0 ||
+ strcasecmp (cmd, "q") == 0) {
quit = 1;
r = 0;
}
else if (strcasecmp (cmd, "alloc") == 0 ||
- strcasecmp (cmd, "allocate") == 0)
+ strcasecmp (cmd, "allocate") == 0)
r = do_alloc (cmd, argc, argv);
else if (strcasecmp (cmd, "echo") == 0)
r = do_echo (cmd, argc, argv);
else if (strcasecmp (cmd, "edit") == 0 ||
- strcasecmp (cmd, "vi") == 0 ||
- strcasecmp (cmd, "emacs") == 0)
+ strcasecmp (cmd, "vi") == 0 ||
+ strcasecmp (cmd, "emacs") == 0)
r = do_edit (cmd, argc, argv);
else if (strcasecmp (cmd, "lcd") == 0)
r = do_lcd (cmd, argc, argv);
else if (strcasecmp (cmd, "glob") == 0)
r = do_glob (cmd, argc, argv);
else if (strcasecmp (cmd, "more") == 0 ||
- strcasecmp (cmd, "less") == 0)
+ strcasecmp (cmd, "less") == 0)
r = do_more (cmd, argc, argv);
else if (strcasecmp (cmd, "reopen") == 0)
r = do_reopen (cmd, argc, argv);
@@ -835,26 +835,26 @@ list_builtin_commands (void)
{
/* help and quit should appear at the top */
printf ("%-20s %s\n",
- "help", _("display a list of commands or help on a command"));
+ "help", _("display a list of commands or help on a
command"));
printf ("%-20s %s\n",
- "quit", _("quit guestfish"));
+ "quit", _("quit guestfish"));
printf ("%-20s %s\n",
- "alloc", _("allocate an image"));
+ "alloc", _("allocate an image"));
printf ("%-20s %s\n",
- "echo", _("display a line of text"));
+ "echo", _("display a line of text"));
printf ("%-20s %s\n",
- "edit", _("edit a file in the image"));
+ "edit", _("edit a file in the image"));
printf ("%-20s %s\n",
- "lcd", _("local change directory"));
+ "lcd", _("local change directory"));
printf ("%-20s %s\n",
- "glob", _("expand wildcards in command"));
+ "glob", _("expand wildcards in command"));
printf ("%-20s %s\n",
- "more", _("view a file in the pager"));
+ "more", _("view a file in the pager"));
printf ("%-20s %s\n",
- "reopen", _("close and reopen libguestfs handle"));
+ "reopen", _("close and reopen libguestfs handle"));
printf ("%-20s %s\n",
- "time", _("measure time taken to run command"));
+ "time", _("measure time taken to run command"));
/* actions are printed after this (see list_commands) */
}
@@ -867,95 +867,95 @@ display_builtin_command (const char *cmd)
if (strcasecmp (cmd, "alloc") == 0 ||
strcasecmp (cmd, "allocate") == 0)
printf (_("alloc - allocate an image\n"
- " alloc <filename> <size>\n"
- "\n"
- " This creates an empty (zeroed) file of the given size,\n"
- " and then adds so it can be further examined.\n"
- "\n"
- " For more advanced image creation, see qemu-img utility.\n"
- "\n"
- " Size can be specified (where <nn> means a number):\n"
- " <nn> number of kilobytes\n"
- " eg: 1440 standard 3.5\" floppy\n"
- " <nn>K or <nn>KB number of kilobytes\n"
- " <nn>M or <nn>MB number of megabytes\n"
- " <nn>G or <nn>GB number of gigabytes\n"
- " <nn>sects number of 512 byte sectors\n"));
+ " alloc <filename> <size>\n"
+ "\n"
+ " This creates an empty (zeroed) file of the given size,\n"
+ " and then adds so it can be further examined.\n"
+ "\n"
+ " For more advanced image creation, see qemu-img utility.\n"
+ "\n"
+ " Size can be specified (where <nn> means a number):\n"
+ " <nn> number of kilobytes\n"
+ " eg: 1440 standard 3.5\" floppy\n"
+ " <nn>K or <nn>KB number of kilobytes\n"
+ " <nn>M or <nn>MB number of megabytes\n"
+ " <nn>G or <nn>GB number of gigabytes\n"
+ " <nn>sects number of 512 byte sectors\n"));
else if (strcasecmp (cmd, "echo") == 0)
printf (_("echo - display a line of text\n"
- " echo [<params> ...]\n"
- "\n"
- " This echos the parameters to the terminal.\n"));
+ " echo [<params> ...]\n"
+ "\n"
+ " This echos the parameters to the terminal.\n"));
else if (strcasecmp (cmd, "edit") == 0 ||
- strcasecmp (cmd, "vi") == 0 ||
- strcasecmp (cmd, "emacs") == 0)
+ strcasecmp (cmd, "vi") == 0 ||
+ strcasecmp (cmd, "emacs") == 0)
printf (_("edit - edit a file in the image\n"
- " edit <filename>\n"
- "\n"
- " This is used to edit a file.\n"
- "\n"
- " It is the equivalent of (and is implemented by)\n"
- " running \"cat\", editing locally, and then
\"write-file\".\n"
- "\n"
- " Normally it uses $EDITOR, but if you use the aliases\n"
- " \"vi\" or \"emacs\" you will get those
editors.\n"
- "\n"
- " NOTE: This will not work reliably for large files\n"
- " (> 2 MB) or binary files containing \\0 bytes.\n"));
+ " edit <filename>\n"
+ "\n"
+ " This is used to edit a file.\n"
+ "\n"
+ " It is the equivalent of (and is implemented by)\n"
+ " running \"cat\", editing locally, and then
\"write-file\".\n"
+ "\n"
+ " Normally it uses $EDITOR, but if you use the aliases\n"
+ " \"vi\" or \"emacs\" you will get those
editors.\n"
+ "\n"
+ " NOTE: This will not work reliably for large files\n"
+ " (> 2 MB) or binary files containing \\0 bytes.\n"));
else if (strcasecmp (cmd, "lcd") == 0)
printf (_("lcd - local change directory\n"
- " lcd <directory>\n"
- "\n"
- " Change guestfish's current directory. This command is\n"
- " useful if you want to download files to a particular\n"
- " place.\n"));
+ " lcd <directory>\n"
+ "\n"
+ " Change guestfish's current directory. This command
is\n"
+ " useful if you want to download files to a particular\n"
+ " place.\n"));
else if (strcasecmp (cmd, "glob") == 0)
printf (_("glob - expand wildcards in command\n"
- " glob <command> [<args> ...]\n"
- "\n"
- " Glob runs <command> with wildcards expanded in any\n"
- " command args. Note that the command is run repeatedly\n"
- " once for each expanded argument.\n"));
+ " glob <command> [<args> ...]\n"
+ "\n"
+ " Glob runs <command> with wildcards expanded in any\n"
+ " command args. Note that the command is run repeatedly\n"
+ " once for each expanded argument.\n"));
else if (strcasecmp (cmd, "help") == 0)
printf (_("help - display a list of commands or help on a command\n"
- " help cmd\n"
- " help\n"));
+ " help cmd\n"
+ " help\n"));
else if (strcasecmp (cmd, "more") == 0 ||
- strcasecmp (cmd, "less") == 0)
+ strcasecmp (cmd, "less") == 0)
printf (_("more - view a file in the pager\n"
- " more <filename>\n"
- "\n"
- " This is used to view a file in the pager.\n"
- "\n"
- " It is the equivalent of (and is implemented by)\n"
- " running \"cat\" and using the pager.\n"
- "\n"
- " Normally it uses $PAGER, but if you use the alias\n"
- " \"less\" then it always uses \"less\".\n"
- "\n"
- " NOTE: This will not work reliably for large files\n"
- " (> 2 MB) or binary files containing \\0 bytes.\n"));
+ " more <filename>\n"
+ "\n"
+ " This is used to view a file in the pager.\n"
+ "\n"
+ " It is the equivalent of (and is implemented by)\n"
+ " running \"cat\" and using the pager.\n"
+ "\n"
+ " Normally it uses $PAGER, but if you use the alias\n"
+ " \"less\" then it always uses
\"less\".\n"
+ "\n"
+ " NOTE: This will not work reliably for large files\n"
+ " (> 2 MB) or binary files containing \\0 bytes.\n"));
else if (strcasecmp (cmd, "quit") == 0 ||
- strcasecmp (cmd, "exit") == 0 ||
- strcasecmp (cmd, "q") == 0)
+ strcasecmp (cmd, "exit") == 0 ||
+ strcasecmp (cmd, "q") == 0)
printf (_("quit - quit guestfish\n"
- " quit\n"));
+ " quit\n"));
else if (strcasecmp (cmd, "reopen") == 0)
printf (_("reopen - close and reopen the libguestfs handle\n"
- " reopen\n"
- "\n"
- "Close and reopen the libguestfs handle. It is not necessary to use\n"
- "this normally, because the handle is closed properly when guestfish\n"
- "exits. However this is occasionally useful for testing.\n"));
+ " reopen\n"
+ "\n"
+ "Close and reopen the libguestfs handle. It is not necessary to
use\n"
+ "this normally, because the handle is closed properly when
guestfish\n"
+ "exits. However this is occasionally useful for testing.\n"));
else if (strcasecmp (cmd, "time") == 0)
printf (_("time - measure time taken to run command\n"
- " time <command> [<args> ...]\n"
- "\n"
- " This runs <command> as usual, and prints the elapsed\n"
- " time afterwards.\n"));
+ " time <command> [<args> ...]\n"
+ "\n"
+ " This runs <command> as usual, and prints the
elapsed\n"
+ " time afterwards.\n"));
else
fprintf (stderr, _("%s: command not known, use -h to list all
commands\n"),
- cmd);
+ cmd);
}
void
diff --git a/fish/fish.h b/fish/fish.h
index a65fe1b..772d200 100644
--- a/fish/fish.h
+++ b/fish/fish.h
@@ -80,7 +80,7 @@ extern int do_more (const char *cmd, int argc, char *argv[]);
/* in rc.c (remote control) */
extern void rc_listen (void);
extern int rc_remote (int pid, const char *cmd, int argc, char *argv[],
- int exit_on_error);
+ int exit_on_error);
/* in reopen.c */
extern int do_reopen (const char *cmd, int argc, char *argv[]);
diff --git a/fish/glob.c b/fish/glob.c
index 581bc28..2731b2f 100644
--- a/fish/glob.c
+++ b/fish/glob.c
@@ -69,46 +69,46 @@ do_glob (const char *cmd, int argc, char *argv[])
if (argv[i][0] == '/') {
pp = guestfs_glob_expand (g, argv[i]);
if (pp == NULL) { /* real error in glob_expand */
- fprintf (stderr, _("glob: guestfs_glob_expand call failed: %s\n"),
- argv[i]);
- goto error0;
+ fprintf (stderr, _("glob: guestfs_glob_expand call failed: %s\n"),
+ argv[i]);
+ goto error0;
}
/* If there were no matches, then we add a single element list
* containing just the original argv[i] string.
*/
if (pp[0] == NULL) {
- char **pp2;
-
- pp2 = realloc (pp, sizeof (char *) * 2);
- if (pp2 == NULL) {
- perror ("realloc");
- free (pp);
- goto error0;
- }
- pp = pp2;
-
- pp[0] = strdup (argv[i]);
- if (pp[0] == NULL) {
- perror ("strdup");
- free (pp);
- goto error0;
- }
- pp[1] = NULL;
+ char **pp2;
+
+ pp2 = realloc (pp, sizeof (char *) * 2);
+ if (pp2 == NULL) {
+ perror ("realloc");
+ free (pp);
+ goto error0;
+ }
+ pp = pp2;
+
+ pp[0] = strdup (argv[i]);
+ if (pp[0] == NULL) {
+ perror ("strdup");
+ free (pp);
+ goto error0;
+ }
+ pp[1] = NULL;
}
}
/* Doesn't begin with '/' */
else {
pp = malloc (sizeof (char *) * 2);
if (pp == NULL) {
- perror ("malloc");
- goto error0;
+ perror ("malloc");
+ goto error0;
}
pp[0] = strdup (argv[i]);
if (pp[0] == NULL) {
- perror ("strdup");
- free (pp);
- goto error0;
+ perror ("strdup");
+ free (pp);
+ goto error0;
}
pp[1] = NULL;
}
@@ -130,8 +130,8 @@ do_glob (const char *cmd, int argc, char *argv[])
static void
glob_issue (char *cmd, int argc,
- char ***globs, int *posn, int *count,
- int *r)
+ char ***globs, int *posn, int *count,
+ int *r)
{
int i;
char *argv[argc+1];
diff --git a/fish/rc.c b/fish/rc.c
index 0d67a62..e88716c 100644
--- a/fish/rc.c
+++ b/fish/rc.c
@@ -131,52 +131,52 @@ rc_listen (void)
xdrstdio_create (&xdr, fp, XDR_DECODE);
if (!xdr_guestfish_hello (&xdr, &hello)) {
- fprintf (stderr, _("guestfish: protocol error: could not read 'hello'
message\n"));
- goto error;
+ fprintf (stderr, _("guestfish: protocol error: could not read
'hello' message\n"));
+ goto error;
}
if (strcmp (hello.vers, PACKAGE_VERSION) != 0) {
- fprintf (stderr, _("guestfish: protocol error: version mismatch, server version
'%s' does not match client version '%s'. The two versions must match
exactly.\n"),
- PACKAGE_VERSION,
- hello.vers);
- xdr_free ((xdrproc_t) xdr_guestfish_hello, (char *) &hello);
- goto error;
+ fprintf (stderr, _("guestfish: protocol error: version mismatch, server
version '%s' does not match client version '%s'. The two versions must
match exactly.\n"),
+ PACKAGE_VERSION,
+ hello.vers);
+ xdr_free ((xdrproc_t) xdr_guestfish_hello, (char *) &hello);
+ goto error;
}
xdr_free ((xdrproc_t) xdr_guestfish_hello, (char *) &hello);
while (xdr_guestfish_call (&xdr, &call)) {
- /* We have to extend and NULL-terminate the argv array. */
- argc = call.args.args_len;
- argv = realloc (call.args.args_val, (argc+1) * sizeof (char *));
- if (argv == NULL) {
- perror ("realloc");
- exit (1);
- }
- call.args.args_val = argv;
- argv[argc] = NULL;
-
- if (verbose) {
- fprintf (stderr, "guestfish(%d): %s", pid, call.cmd);
- for (i = 0; i < argc; ++i)
- fprintf (stderr, " %s", argv[i]);
- fprintf (stderr, "\n");
- }
-
- /* Run the command. */
- reply.r = issue_command (call.cmd, argv, NULL);
-
- xdr_free ((xdrproc_t) xdr_guestfish_call, (char *) &call);
-
- /* Send the reply. */
- xdrstdio_create (&xdr2, fp, XDR_ENCODE);
- (void) xdr_guestfish_reply (&xdr2, &reply);
- xdr_destroy (&xdr2);
-
- /* Exit on error? */
- if (call.exit_on_error && reply.r == -1) {
- unlink (sockpath);
- exit (1);
- }
+ /* We have to extend and NULL-terminate the argv array. */
+ argc = call.args.args_len;
+ argv = realloc (call.args.args_val, (argc+1) * sizeof (char *));
+ if (argv == NULL) {
+ perror ("realloc");
+ exit (1);
+ }
+ call.args.args_val = argv;
+ argv[argc] = NULL;
+
+ if (verbose) {
+ fprintf (stderr, "guestfish(%d): %s", pid, call.cmd);
+ for (i = 0; i < argc; ++i)
+ fprintf (stderr, " %s", argv[i]);
+ fprintf (stderr, "\n");
+ }
+
+ /* Run the command. */
+ reply.r = issue_command (call.cmd, argv, NULL);
+
+ xdr_free ((xdrproc_t) xdr_guestfish_call, (char *) &call);
+
+ /* Send the reply. */
+ xdrstdio_create (&xdr2, fp, XDR_ENCODE);
+ (void) xdr_guestfish_reply (&xdr2, &reply);
+ xdr_destroy (&xdr2);
+
+ /* Exit on error? */
+ if (call.exit_on_error && reply.r == -1) {
+ unlink (sockpath);
+ exit (1);
+ }
}
error:
@@ -192,7 +192,7 @@ rc_listen (void)
/* Remote control client. */
int
rc_remote (int pid, const char *cmd, int argc, char *argv[],
- int exit_on_error)
+ int exit_on_error)
{
guestfish_hello hello;
guestfish_call call;
diff --git a/fish/tilde.c b/fish/tilde.c
index 13e6cd8..f0a2259 100644
--- a/fish/tilde.c
+++ b/fish/tilde.c
@@ -64,8 +64,8 @@ try_tilde_expansion (char *str)
len = strlen (home) + strlen (rest);
str = malloc (len);
if (str == NULL) {
- perror ("malloc");
- exit (1);
+ perror ("malloc");
+ exit (1);
}
strcpy (str, home);
strcat (str, rest);
@@ -113,7 +113,7 @@ find_home_for_username (const char *username, int ulen)
setpwent ();
while ((pw = getpwent ()) != NULL) {
if (strlen (pw->pw_name) == ulen &&
- strncmp (username, pw->pw_name, ulen) == 0)
+ strncmp (username, pw->pw_name, ulen) == 0)
return pw->pw_dir;
}
diff --git a/fish/time.c b/fish/time.c
index aae9afe..ed00c18 100644
--- a/fish/time.c
+++ b/fish/time.c
@@ -47,8 +47,8 @@ do_time (const char *cmd, int argc, char *argv[])
end_us = (int64_t) end_t.tv_sec * 1000000 + end_t.tv_usec;
elapsed_us = end_us - start_us;
printf ("elapsed time: %d.%02d seconds\n",
- (int) (elapsed_us / 1000000),
- (int) ((elapsed_us / 10000) % 100));
+ (int) (elapsed_us / 1000000),
+ (int) ((elapsed_us / 10000) % 100));
return 0;
}
diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl
index 17c6375..943f32e 100755
--- a/inspector/virt-inspector.pl
+++ b/inspector/virt-inspector.pl
@@ -181,19 +181,19 @@ default.
=cut
GetOptions ("help|?" => \$help,
- "version" => \$version,
- "connect|c=s" => \$uri,
- "text" => sub { $output = "text" },
- "none" => sub { $output = "none" },
- "xml" => sub { $output = "xml" },
- "yaml" => sub { $output = "yaml" },
- "perl" => sub { $output = "perl" },
- "fish" => sub { $output = "fish" },
- "guestfish" => sub { $output = "fish" },
- "ro-fish" => sub { $output = "ro-fish" },
- "ro-guestfish" => sub { $output = "ro-fish" },
- "query" => sub { $output = "query" },
- "windows-registry" => \$windows_registry,
+ "version" => \$version,
+ "connect|c=s" => \$uri,
+ "text" => sub { $output = "text" },
+ "none" => sub { $output = "none" },
+ "xml" => sub { $output = "xml" },
+ "yaml" => sub { $output = "yaml" },
+ "perl" => sub { $output = "perl" },
+ "fish" => sub { $output = "fish" },
+ "guestfish" => sub { $output = "fish" },
+ "ro-fish" => sub { $output = "ro-fish" },
+ "ro-guestfish" => sub { $output = "ro-fish" },
+ "query" => sub { $output = "query" },
+ "windows-registry" => \$windows_registry,
) or pod2usage (2);
pod2usage (1) if $help;
if ($version) {
@@ -211,11 +211,11 @@ my @images;
if ($uri) {
my ($conn, $dom);
($g, $conn, $dom, @images) =
- open_guest (\@ARGV, rw => $rw, address => $uri);
+ open_guest (\@ARGV, rw => $rw, address => $uri);
} else {
my ($conn, $dom);
($g, $conn, $dom, @images) =
- open_guest (\@ARGV, rw => $rw);
+ open_guest (\@ARGV, rw => $rw);
}
$g->launch ();
@@ -286,10 +286,10 @@ my $oses = inspect_operating_systems ($g, \%fses);
if ($output !~ /.*fish$/) {
my $root_dev;
foreach $root_dev (sort keys %$oses) {
- my $os = $oses->{$root_dev};
- mount_operating_system ($g, $os);
- inspect_in_detail ($g, $os);
- $g->umount_all ();
+ my $os = $oses->{$root_dev};
+ mount_operating_system ($g, $os);
+ inspect_in_detail ($g, $os);
+ $g->umount_all ();
}
}
@@ -304,7 +304,7 @@ if ($output eq "fish" || $output eq "ro-fish") {
my $root_dev = $osdevs[0];
if ($output eq "ro-fish") {
- print "--ro ";
+ print "--ro ";
}
print "-a $_ " foreach @images;
@@ -313,7 +313,7 @@ if ($output eq "fish" || $output eq "ro-fish") {
# Have to mount / first. Luckily '/' is early in the ASCII
# character set, so this should be OK.
foreach (sort keys %$mounts) {
- print "-m $mounts->{$_}:$_ " if $_ ne "swap" && $_ ne
"none";
+ print "-m $mounts->{$_}:$_ " if $_ ne "swap" && $_
ne "none";
}
print "\n"
}
@@ -326,7 +326,7 @@ elsif ($output eq "perl") {
# YAML output
elsif ($output eq "yaml") {
die __"virt-inspector: no YAML support\n"
- unless exists $INC{"YAML/Any.pm"};
+ unless exists $INC{"YAML/Any.pm"};
print Dump(%$oses);
}
@@ -366,69 +366,69 @@ sub output_text_os
print __" Mountpoints:\n";
my $mounts = $os->{mounts};
foreach (sort keys %$mounts) {
- printf " %-30s %s\n", $mounts->{$_}, $_
+ printf " %-30s %s\n", $mounts->{$_}, $_
}
print __" Filesystems:\n";
my $filesystems = $os->{filesystems};
foreach (sort keys %$filesystems) {
- print " $_:\n";
- print " label: $filesystems->{$_}{label}\n"
- if exists $filesystems->{$_}{label};
- print " UUID: $filesystems->{$_}{uuid}\n"
- if exists $filesystems->{$_}{uuid};
- print " type: $filesystems->{$_}{fstype}\n"
- if exists $filesystems->{$_}{fstype};
- print " content: $filesystems->{$_}{content}\n"
- if exists $filesystems->{$_}{content};
+ print " $_:\n";
+ print " label: $filesystems->{$_}{label}\n"
+ if exists $filesystems->{$_}{label};
+ print " UUID: $filesystems->{$_}{uuid}\n"
+ if exists $filesystems->{$_}{uuid};
+ print " type: $filesystems->{$_}{fstype}\n"
+ if exists $filesystems->{$_}{fstype};
+ print " content: $filesystems->{$_}{content}\n"
+ if exists $filesystems->{$_}{content};
}
if (exists $os->{modprobe_aliases}) {
- my %aliases = %{$os->{modprobe_aliases}};
- my @keys = sort keys %aliases;
- if (@keys) {
- print __" Modprobe aliases:\n";
- foreach (@keys) {
- printf " %-30s %s\n", $_, $aliases{$_}->{modulename}
- }
- }
+ my %aliases = %{$os->{modprobe_aliases}};
+ my @keys = sort keys %aliases;
+ if (@keys) {
+ print __" Modprobe aliases:\n";
+ foreach (@keys) {
+ printf " %-30s %s\n", $_, $aliases{$_}->{modulename}
+ }
+ }
}
if (exists $os->{initrd_modules}) {
- my %modvers = %{$os->{initrd_modules}};
- my @keys = sort keys %modvers;
- if (@keys) {
- print __" Initrd modules:\n";
- foreach (@keys) {
- my @modules = @{$modvers{$_}};
- print " $_:\n";
- print " $_\n" foreach @modules;
- }
- }
+ my %modvers = %{$os->{initrd_modules}};
+ my @keys = sort keys %modvers;
+ if (@keys) {
+ print __" Initrd modules:\n";
+ foreach (@keys) {
+ my @modules = @{$modvers{$_}};
+ print " $_:\n";
+ print " $_\n" foreach @modules;
+ }
+ }
}
print __" Applications:\n";
my @apps = @{$os->{apps}};
foreach (@apps) {
- print " $_->{name} $_->{version}\n"
+ print " $_->{name} $_->{version}\n"
}
print __" Kernels:\n";
my @kernels = @{$os->{kernels}};
foreach (@kernels) {
- print " $_->{version} ($_->{arch})\n";
- my @modules = @{$_->{modules}};
- foreach (@modules) {
- print " $_\n";
- }
+ print " $_->{version} ($_->{arch})\n";
+ my @modules = @{$_->{modules}};
+ foreach (@modules) {
+ print " $_\n";
+ }
}
if (exists $os->{root}->{registry}) {
- print __" Windows Registry entries:\n";
- # These are just lumps of text - dump them out.
- foreach (@{$os->{root}->{registry}}) {
- print "$_\n";
- }
+ print __" Windows Registry entries:\n";
+ # These are just lumps of text - dump them out.
+ foreach (@{$os->{root}->{registry}}) {
+ print "$_\n";
+ }
}
}
@@ -486,11 +486,11 @@ sub output_xml_os
$xml->endTag("filesystems");
if (exists $os->{modprobe_aliases}) {
- my %aliases = %{$os->{modprobe_aliases}};
- my @keys = sort keys %aliases;
- if (@keys) {
+ my %aliases = %{$os->{modprobe_aliases}};
+ my @keys = sort keys %aliases;
+ if (@keys) {
$xml->startTag("modprobealiases");
- foreach (@keys) {
+ foreach (@keys) {
$xml->startTag("alias", "device" => $_);
foreach my $field ( [ "modulename" => "modulename"
],
@@ -500,24 +500,24 @@ sub output_xml_os
}
$xml->endTag("alias");
- }
+ }
$xml->endTag("modprobealiases");
- }
+ }
}
if (exists $os->{initrd_modules}) {
- my %modvers = %{$os->{initrd_modules}};
- my @keys = sort keys %modvers;
- if (@keys) {
+ my %modvers = %{$os->{initrd_modules}};
+ my @keys = sort keys %modvers;
+ if (@keys) {
$xml->startTag("initrds");
- foreach (@keys) {
- my @modules = @{$modvers{$_}};
+ foreach (@keys) {
+ my @modules = @{$modvers{$_}};
$xml->startTag("initrd", "version" => $_);
$xml->dataElement("module", $_) foreach @modules;
$xml->endTag("initrd");
- }
+ }
$xml->endTag("initrds");
- }
+ }
}
$xml->startTag("applications");
@@ -555,13 +555,13 @@ sub output_xml_os
my @kernels = @{$os->{kernels}};
foreach (@kernels) {
$xml->startTag("kernel",
- "version" => $_->{version},
- "arch" => $_->{arch});
+ "version" => $_->{version},
+ "arch" => $_->{arch});
$xml->startTag("modules");
- my @modules = @{$_->{modules}};
- foreach (@modules) {
+ my @modules = @{$_->{modules}};
+ foreach (@modules) {
$xml->dataElement("module", $_);
- }
+ }
$xml->endTag("modules");
$xml->dataElement("path", $_->{path})
if(defined($_->{path}));
$xml->dataElement("package", $_->{package})
if(defined($_->{package}));
@@ -571,10 +571,10 @@ sub output_xml_os
if (exists $os->{root}->{registry}) {
$xml->startTag("windowsregistryentries");
- # These are just lumps of text - dump them out.
- foreach (@{$os->{root}->{registry}}) {
+ # These are just lumps of text - dump them out.
+ foreach (@{$os->{root}->{registry}}) {
$xml->dataElement("windowsregistryentry", $_);
- }
+ }
$xml->endTag("windowsregistryentries");
}
@@ -632,7 +632,7 @@ sub output_query_windows
{
my $windows = "no";
foreach my $os (keys %$oses) {
- $windows="yes" if $oses->{$os}->{os} eq "windows";
+ $windows="yes" if $oses->{$os}->{os} eq "windows";
}
print "windows=$windows\n";
}
@@ -647,7 +647,7 @@ sub output_query_linux
{
my $linux = "no";
foreach my $os (keys %$oses) {
- $linux="yes" if $oses->{$os}->{os} eq "linux";
+ $linux="yes" if $oses->{$os}->{os} eq "linux";
}
print "linux=$linux\n";
}
@@ -662,7 +662,7 @@ sub output_query_rhel
{
my $rhel = "no";
foreach my $os (keys %$oses) {
- $rhel="yes" if ($oses->{$os}->{os} eq "linux" &&
+ $rhel="yes" if ($oses->{$os}->{os} eq "linux"
&&
$oses->{$os}->{distro} eq "rhel");
}
print "rhel=$rhel\n";
@@ -678,7 +678,7 @@ sub output_query_fedora
{
my $fedora = "no";
foreach my $os (keys %$oses) {
- $fedora="yes" if $oses->{$os}->{os} eq "linux" &&
$oses->{$os}->{distro} eq "fedora";
+ $fedora="yes" if $oses->{$os}->{os} eq "linux"
&& $oses->{$os}->{distro} eq "fedora";
}
print "fedora=$fedora\n";
}
@@ -693,7 +693,7 @@ sub output_query_debian
{
my $debian = "no";
foreach my $os (keys %$oses) {
- $debian="yes" if $oses->{$os}->{os} eq "linux" &&
$oses->{$os}->{distro} eq "debian";
+ $debian="yes" if $oses->{$os}->{os} eq "linux"
&& $oses->{$os}->{distro} eq "debian";
}
print "debian=$debian\n";
}
@@ -712,13 +712,13 @@ sub output_query_fullvirt
# are identified as paravirt.
# XXX Fails on Windows guests.
foreach my $os (keys %$oses) {
- foreach my $kernel (@{$oses->{$os}->{kernels}}) {
- my $is_pv = $kernel->{version} =~ m/xen/;
- unless ($is_pv) {
- print "fullvirt=yes\n";
- return;
- }
- }
+ foreach my $kernel (@{$oses->{$os}->{kernels}}) {
+ my $is_pv = $kernel->{version} =~ m/xen/;
+ unless ($is_pv) {
+ print "fullvirt=yes\n";
+ return;
+ }
+ }
}
print "fullvirt=no\n";
}
@@ -734,13 +734,13 @@ guest).
sub output_query_xen_domU_kernel
{
foreach my $os (keys %$oses) {
- foreach my $kernel (@{$oses->{$os}->{kernels}}) {
- my $is_xen = $kernel->{version} =~ m/xen/;
- if ($is_xen) {
- print "xen_domU_kernel=yes\n";
- return;
- }
- }
+ foreach my $kernel (@{$oses->{$os}->{kernels}}) {
+ my $is_xen = $kernel->{version} =~ m/xen/;
+ if ($is_xen) {
+ print "xen_domU_kernel=yes\n";
+ return;
+ }
+ }
}
print "xen_domU_kernel=no\n";
}
@@ -757,14 +757,14 @@ reasons).
sub output_query_xen_pv_drivers
{
foreach my $os (keys %$oses) {
- foreach my $kernel (@{$oses->{$os}->{kernels}}) {
- foreach my $module (@{$kernel->{modules}}) {
- if ($module =~ m/xen-/) {
- print "xen_pv_drivers=yes\n";
- return;
- }
- }
- }
+ foreach my $kernel (@{$oses->{$os}->{kernels}}) {
+ foreach my $module (@{$kernel->{modules}}) {
+ if ($module =~ m/xen-/) {
+ print "xen_pv_drivers=yes\n";
+ return;
+ }
+ }
+ }
}
print "xen_pv_drivers=no\n";
}
@@ -780,14 +780,14 @@ performance of KVM.
sub output_query_virtio_drivers
{
foreach my $os (keys %$oses) {
- foreach my $kernel (@{$oses->{$os}->{kernels}}) {
- foreach my $module (@{$kernel->{modules}}) {
- if ($module =~ m/virtio_/) {
- print "virtio_drivers=yes\n";
- return;
- }
- }
- }
+ foreach my $kernel (@{$oses->{$os}->{kernels}}) {
+ foreach my $module (@{$kernel->{modules}}) {
+ if ($module =~ m/virtio_/) {
+ print "virtio_drivers=yes\n";
+ return;
+ }
+ }
+ }
}
print "virtio_drivers=no\n";
}
@@ -805,11 +805,11 @@ sub output_query_userspace_arch
my %arches;
foreach my $os (keys %$oses) {
- $arches{$oses->{$os}->{arch}} = 1 if exists $oses->{$os}->{arch};
+ $arches{$oses->{$os}->{arch}} = 1 if exists $oses->{$os}->{arch};
}
foreach (sort keys %arches) {
- print "userspace_arch=$_\n";
+ print "userspace_arch=$_\n";
}
}
@@ -826,13 +826,13 @@ sub output_query_kernel_arch
my %arches;
foreach my $os (keys %$oses) {
- foreach my $kernel (@{$oses->{$os}->{kernels}}) {
- $arches{$kernel->{arch}} = 1 if exists $kernel->{arch};
- }
+ foreach my $kernel (@{$oses->{$os}->{kernels}}) {
+ $arches{$kernel->{arch}} = 1 if exists $kernel->{arch};
+ }
}
foreach (sort keys %arches) {
- print "kernel_arch=$_\n";
+ print "kernel_arch=$_\n";
}
}
diff --git a/java/com/redhat/et/libguestfs/LibGuestFSException.java
b/java/com/redhat/et/libguestfs/LibGuestFSException.java
index 1c7a224..c7bcc05 100644
--- a/java/com/redhat/et/libguestfs/LibGuestFSException.java
+++ b/java/com/redhat/et/libguestfs/LibGuestFSException.java
@@ -31,6 +31,6 @@ public class LibGuestFSException extends Exception {
public LibGuestFSException (String msg)
{
- super (msg);
+ super (msg);
}
}
diff --git a/java/t/GuestFS005Load.java b/java/t/GuestFS005Load.java
index a1d1c07..23f1611 100644
--- a/java/t/GuestFS005Load.java
+++ b/java/t/GuestFS005Load.java
@@ -21,13 +21,13 @@ import com.redhat.et.libguestfs.*;
public class GuestFS005Load {
public static void main (String[] argv)
{
- try {
- GuestFS g = new GuestFS ();
- g.close ();
- }
- catch (Exception exn) {
- System.err.println (exn);
- System.exit (1);
- }
+ try {
+ GuestFS g = new GuestFS ();
+ g.close ();
+ }
+ catch (Exception exn) {
+ System.err.println (exn);
+ System.exit (1);
+ }
}
}
diff --git a/java/t/GuestFS010Launch.java b/java/t/GuestFS010Launch.java
index 3d145bb..198ea85 100644
--- a/java/t/GuestFS010Launch.java
+++ b/java/t/GuestFS010Launch.java
@@ -22,21 +22,21 @@ import com.redhat.et.libguestfs.*;
public class GuestFS010Launch {
public static void main (String[] argv)
{
- try {
- GuestFS g = new GuestFS ();
- RandomAccessFile f = new RandomAccessFile ("test.img", "rw");
- f.setLength (500 * 1024 * 1024);
- f.close ();
- g.add_drive ("test.img");
- g.launch ();
- g.wait_ready ();
- g.close ();
- File f2 = new File ("test.img");
- f2.delete ();
- }
- catch (Exception exn) {
- System.err.println (exn);
- System.exit (1);
- }
+ try {
+ GuestFS g = new GuestFS ();
+ RandomAccessFile f = new RandomAccessFile ("test.img",
"rw");
+ f.setLength (500 * 1024 * 1024);
+ f.close ();
+ g.add_drive ("test.img");
+ g.launch ();
+ g.wait_ready ();
+ g.close ();
+ File f2 = new File ("test.img");
+ f2.delete ();
+ }
+ catch (Exception exn) {
+ System.err.println (exn);
+ System.exit (1);
+ }
}
}
diff --git a/java/t/GuestFS050LVCreate.java b/java/t/GuestFS050LVCreate.java
index 7430386..012d68b 100644
--- a/java/t/GuestFS050LVCreate.java
+++ b/java/t/GuestFS050LVCreate.java
@@ -22,35 +22,35 @@ import com.redhat.et.libguestfs.*;
public class GuestFS050LVCreate {
public static void main (String[] argv)
{
- try {
- GuestFS g = new GuestFS ();
-
- RandomAccessFile f = new RandomAccessFile ("test.img", "rw");
- f.setLength (500 * 1024 * 1024);
- f.close ();
-
- g.add_drive ("test.img");
- g.launch ();
- g.wait_ready ();
-
- g.pvcreate ("/dev/sda");
- g.vgcreate ("VG", new String[] {"/dev/sda"});
- g.lvcreate ("LV1", "VG", 200);
- g.lvcreate ("LV2", "VG", 200);
-
- String[] lvs = g.lvs ();
- assert lvs[0].equals ("/dev/VG/LV1");
- assert lvs[1].equals ("/dev/VG/LV2");
-
- g.sync ();
- g.close ();
-
- File f2 = new File ("test.img");
- f2.delete ();
- }
- catch (Exception exn) {
- System.err.println (exn);
- System.exit (1);
- }
+ try {
+ GuestFS g = new GuestFS ();
+
+ RandomAccessFile f = new RandomAccessFile ("test.img",
"rw");
+ f.setLength (500 * 1024 * 1024);
+ f.close ();
+
+ g.add_drive ("test.img");
+ g.launch ();
+ g.wait_ready ();
+
+ g.pvcreate ("/dev/sda");
+ g.vgcreate ("VG", new String[] {"/dev/sda"});
+ g.lvcreate ("LV1", "VG", 200);
+ g.lvcreate ("LV2", "VG", 200);
+
+ String[] lvs = g.lvs ();
+ assert lvs[0].equals ("/dev/VG/LV1");
+ assert lvs[1].equals ("/dev/VG/LV2");
+
+ g.sync ();
+ g.close ();
+
+ File f2 = new File ("test.img");
+ f2.delete ();
+ }
+ catch (Exception exn) {
+ System.err.println (exn);
+ System.exit (1);
+ }
}
}
diff --git a/m4/ocaml.m4 b/m4/ocaml.m4
index fa8c4ce..fddd6a0 100644
--- a/m4/ocaml.m4
+++ b/m4/ocaml.m4
@@ -26,15 +26,15 @@ AC_DEFUN([AC_PROG_OCAML],
AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
OCAMLBEST=byte
if test "$OCAMLOPT" = "no"; then
- AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
+ AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
else
- TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
- OCAMLOPT=no
- else
- OCAMLBEST=opt
- fi
+ TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+ if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+ AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
+ OCAMLOPT=no
+ else
+ OCAMLBEST=opt
+ fi
fi
AC_SUBST([OCAMLBEST])
@@ -42,24 +42,24 @@ AC_DEFUN([AC_PROG_OCAML],
# checking for ocamlc.opt
AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
if test "$OCAMLCDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
- else
- OCAMLC=$OCAMLCDOTOPT
- fi
+ TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+ if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+ AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
+ else
+ OCAMLC=$OCAMLCDOTOPT
+ fi
fi
# checking for ocamlopt.opt
if test "$OCAMLOPT" != "no" ; then
- AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
- if test "$OCAMLOPTDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
- else
- OCAMLOPT=$OCAMLOPTDOTOPT
- fi
+ AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
+ if test "$OCAMLOPTDOTOPT" != "no"; then
+ TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version*
*\(.*\)$|\1|p' `
+ if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+ AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
+ else
+ OCAMLOPT=$OCAMLOPTDOTOPT
+ fi
fi
fi
@@ -92,7 +92,7 @@ AC_DEFUN([AC_PROG_OCAMLLEX],
if test "$OCAMLLEX" != "no"; then
AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
if test "$OCAMLLEXDOTOPT" != "no"; then
- OCAMLLEX=$OCAMLLEXDOTOPT
+ OCAMLLEX=$OCAMLLEXDOTOPT
fi
fi
AC_SUBST([OCAMLLEX])
@@ -114,7 +114,7 @@ AC_DEFUN([AC_PROG_CAMLP4],
if test "$CAMLP4" != "no"; then
TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc])
+ AC_MSG_RESULT([versions differs from ocamlc])
CAMLP4=no
fi
fi
diff --git a/make-recipes.sh b/make-recipes.sh
index ebed325..b93b0b2 100755
--- a/make-recipes.sh
+++ b/make-recipes.sh
@@ -43,8 +43,8 @@ for f in recipes/*.sh; do
b=`basename $f .sh`
echo -n ' <li> <a href="#'$b'">'$b.sh
if [ -r recipes/$b.title ]; then
- echo -n ': '
- cat recipes/$b.title
+ echo -n ': '
+ cat recipes/$b.title
fi
echo '</a> </li>'
done
@@ -57,23 +57,23 @@ for f in recipes/*.sh; do
echo -n '<a name="'$b'"></a>'
echo -n '<h2>'$b'.sh'
if [ -r recipes/$b.title ]; then
- echo -n ': '
- cat recipes/$b.title
+ echo -n ': '
+ cat recipes/$b.title
fi
echo -n '<small style="font-size: 8pt; margin-left: 2em;"><a
href="#'$b'">permalink</a></small>'
echo '</h2>'
if [ -r recipes/$b.html ]; then
- cat recipes/$b.html
+ cat recipes/$b.html
fi
echo '<h3>'$b'.sh</h3>'
echo '<pre class="example">'
sed -e 's,&,\&,g' -e 's,<,\<,g' -e
's,>,\>,g' < $f
echo '</pre>'
if [ -r recipes/$b.example ]; then
- echo '<h3>Example output</h3>'
- echo '<pre>'
- sed -e 's,&,\&,g' -e 's,<,\<,g' -e
's,>,\>,g' < recipes/$b.example
- echo '</pre>'
+ echo '<h3>Example output</h3>'
+ echo '<pre>'
+ sed -e 's,&,\&,g' -e 's,<,\<,g' -e
's,>,\>,g' < recipes/$b.example
+ echo '</pre>'
fi
done
diff --git a/ocaml/t/guestfs_060_readdir.ml b/ocaml/t/guestfs_060_readdir.ml
index f333810..e9368a8 100644
--- a/ocaml/t/guestfs_060_readdir.ml
+++ b/ocaml/t/guestfs_060_readdir.ml
@@ -44,10 +44,10 @@ let () =
) dirs in
if dirs <> [ ".", 'd';
- "..", 'd';
- "lost+found", 'd';
- "p", 'd';
- "q", 'r' ] then
+ "..", 'd';
+ "lost+found", 'd';
+ "p", 'd';
+ "q", 'r' ] then
failwith "Guestfs.readdir returned incorrect result";
Guestfs.close g;
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 8e20593..72b0f7d 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -128,80 +128,80 @@ sub open_guest
my @images = ();
if (ref ($first) eq "ARRAY") {
- @images = @$first;
+ @images = @$first;
} elsif (ref ($first) eq "SCALAR") {
- @images = ($first);
+ @images = ($first);
} else {
- die __"open_guest: first parameter must be a string or an arrayref"
+ die __"open_guest: first parameter must be a string or an arrayref"
}
my ($conn, $dom);
if (-e $images[0]) {
- foreach (@images) {
- die __x("guest image {imagename} does not exist or is not readable",
- imagename => $_)
- unless -r $_;
- }
+ foreach (@images) {
+ die __x("guest image {imagename} does not exist or is not
readable",
+ imagename => $_)
+ unless -r $_;
+ }
} else {
- die __"open_guest: no libvirt support (install Sys::Virt, XML::XPath and
XML::XPath::XMLParser)"
- unless exists $INC{"Sys/Virt.pm"} &&
- exists $INC{"XML/XPath.pm"} &&
- exists $INC{"XML/XPath/XMLParser.pm"};
-
- die __"open_guest: too many domains listed on command line"
- if @images > 1;
-
- $conn = Sys::Virt->new (readonly => 1, @_);
- die __"open_guest: cannot connect to libvirt" unless $conn;
-
- my @doms = $conn->list_defined_domains ();
- my $isitinactive = 1;
- unless ($readwrite) {
- # In the case where we want read-only access to a domain,
- # allow the user to specify an active domain too.
- push @doms, $conn->list_domains ();
- $isitinactive = 0;
- }
- foreach (@doms) {
- if ($_->get_name () eq $images[0]) {
- $dom = $_;
- last;
- }
- }
-
- unless ($dom) {
- if ($isitinactive) {
- die __x("{imagename} is not the name of an inactive libvirt domain\n",
- imagename => $images[0]);
- } else {
- die __x("{imagename} is not the name of a libvirt domain\n",
- imagename => $images[0]);
- }
- }
-
- # Get the names of the image(s).
- my $xml = $dom->get_xml_description ();
-
- my $p = XML::XPath->new (xml => $xml);
- my @disks = $p->findnodes ('//devices/disk/source/@dev');
- push (@disks, $p->findnodes ('//devices/disk/source/@file'));
-
- die __x("{imagename} seems to have no disk devices\n",
- imagename => $images[0])
- unless @disks;
-
- @images = map { $_->getData } @disks;
+ die __"open_guest: no libvirt support (install Sys::Virt, XML::XPath and
XML::XPath::XMLParser)"
+ unless exists $INC{"Sys/Virt.pm"} &&
+ exists $INC{"XML/XPath.pm"} &&
+ exists $INC{"XML/XPath/XMLParser.pm"};
+
+ die __"open_guest: too many domains listed on command line"
+ if @images > 1;
+
+ $conn = Sys::Virt->new (readonly => 1, @_);
+ die __"open_guest: cannot connect to libvirt" unless $conn;
+
+ my @doms = $conn->list_defined_domains ();
+ my $isitinactive = 1;
+ unless ($readwrite) {
+ # In the case where we want read-only access to a domain,
+ # allow the user to specify an active domain too.
+ push @doms, $conn->list_domains ();
+ $isitinactive = 0;
+ }
+ foreach (@doms) {
+ if ($_->get_name () eq $images[0]) {
+ $dom = $_;
+ last;
+ }
+ }
+
+ unless ($dom) {
+ if ($isitinactive) {
+ die __x("{imagename} is not the name of an inactive libvirt
domain\n",
+ imagename => $images[0]);
+ } else {
+ die __x("{imagename} is not the name of a libvirt domain\n",
+ imagename => $images[0]);
+ }
+ }
+
+ # Get the names of the image(s).
+ my $xml = $dom->get_xml_description ();
+
+ my $p = XML::XPath->new (xml => $xml);
+ my @disks = $p->findnodes ('//devices/disk/source/@dev');
+ push (@disks, $p->findnodes ('//devices/disk/source/@file'));
+
+ die __x("{imagename} seems to have no disk devices\n",
+ imagename => $images[0])
+ unless @disks;
+
+ @images = map { $_->getData } @disks;
}
# We've now got the list of @images, so feed them to libguestfs.
my $g = Sys::Guestfs->new ();
foreach (@images) {
- if ($readwrite) {
- $g->add_drive ($_);
- } else {
- $g->add_drive_ro ($_);
- }
+ if ($readwrite) {
+ $g->add_drive ($_);
+ } else {
+ $g->add_drive_ro ($_);
+ }
}
return wantarray ? ($g, $conn, $dom, @images) : $g
@@ -239,7 +239,7 @@ sub _is_pv {
my $t = shift;
foreach (@_) {
- return 1 if $_ eq $t;
+ return 1 if $_ eq $t;
}
0;
}
@@ -271,8 +271,8 @@ sub resolve_windows_path
my $path = shift;
if (substr ($path, 0, 1) ne "/") {
- warn __"resolve_windows_path: path must start with a / character";
- return undef;
+ warn __"resolve_windows_path: path must start with a / character";
+ return undef;
}
my @elems = split (/\//, $path);
@@ -282,19 +282,19 @@ sub resolve_windows_path
$path = "/";
foreach my $dir (@elems) {
- my $found = 0;
- foreach ($g->ls ($path)) {
- if (lc ($_) eq lc ($dir)) {
- if ($path eq "/") {
- $path = "/$_";
- $found = 1;
- } else {
- $path = "$path/$_";
- $found = 1;
- }
- }
- }
- return undef unless $found;
+ my $found = 0;
+ foreach ($g->ls ($path)) {
+ if (lc ($_) eq lc ($dir)) {
+ if ($path eq "/") {
+ $path = "/$_";
+ $found = 1;
+ } else {
+ $path = "$path/$_";
+ $found = 1;
+ }
+ }
+ }
+ return undef unless $found;
}
return $path;
@@ -376,27 +376,27 @@ sub _elf_arch_to_canonical
local $_ = shift;
if ($_ eq "Intel 80386") {
- return "i386";
+ return "i386";
} elsif ($_ eq "Intel 80486") {
- return "i486"; # probably not in the wild
+ return "i486"; # probably not in the wild
} elsif ($_ eq "x86-64") {
- return "x86_64";
+ return "x86_64";
} elsif ($_ eq "AMD x86-64") {
- return "x86_64";
+ return "x86_64";
} elsif (/SPARC32/) {
- return "sparc";
+ return "sparc";
} elsif (/SPARC V9/) {
- return "sparc64";
+ return "sparc64";
} elsif ($_ eq "IA-64") {
- return "ia64";
+ return "ia64";
} elsif (/64.*PowerPC/) {
- return "ppc64";
+ return "ppc64";
} elsif (/PowerPC/) {
- return "ppc";
+ return "ppc";
} else {
- warn __x("returning non-canonical architecture type '{arch}'",
- arch => $_);
- return $_;
+ warn __x("returning non-canonical architecture type '{arch}'",
+ arch => $_);
+ return $_;
}
}
@@ -412,49 +412,49 @@ sub file_architecture
my $file = $g->file ($path);
if ($file =~ /ELF.*(?:executable|shared object|relocatable), (.+?),/) {
- # ELF executable or shared object. We need to convert
- # what file(1) prints into the canonical form.
- return _elf_arch_to_canonical ($1);
+ # ELF executable or shared object. We need to convert
+ # what file(1) prints into the canonical form.
+ return _elf_arch_to_canonical ($1);
} elsif ($file =~ /PE32 executable/) {
- return "i386"; # Win32 executable or DLL
+ return "i386"; # Win32 executable or DLL
} elsif ($file =~ /PE32\+ executable/) {
- return "x86_64"; # Win64 executable or DLL
+ return "x86_64"; # Win64 executable or DLL
}
elsif ($file =~ /cpio archive/) {
- # Probably an initrd.
- my $zcat = "cat";
- if ($file =~ /gzip/) {
- $zcat = "zcat";
- } elsif ($file =~ /bzip2/) {
- $zcat = "bzcat";
- }
-
- # Download and unpack it to find a binary file.
- my $dir = tempdir (CLEANUP => 1);
- $g->download ($path, "$dir/initrd");
-
- my $bins = join " ", map { "bin/$_" } @_initrd_binaries;
- my $cmd = "cd $dir && $zcat initrd | cpio --quiet -id $bins";
- my $r = system ($cmd);
- die __x("cpio command failed: {error}", error => $?)
- unless $r == 0;
-
- foreach my $bin (@_initrd_binaries) {
- if (-f "$dir/bin/$bin") {
- $_ = `file $dir/bin/$bin`;
- if (/ELF.*executable, (.+?),/) {
- return _elf_arch_to_canonical ($1);
- }
- }
- }
-
- die __x("file_architecture: no known binaries found in initrd image: {path}",
- path => $path);
+ # Probably an initrd.
+ my $zcat = "cat";
+ if ($file =~ /gzip/) {
+ $zcat = "zcat";
+ } elsif ($file =~ /bzip2/) {
+ $zcat = "bzcat";
+ }
+
+ # Download and unpack it to find a binary file.
+ my $dir = tempdir (CLEANUP => 1);
+ $g->download ($path, "$dir/initrd");
+
+ my $bins = join " ", map { "bin/$_" } @_initrd_binaries;
+ my $cmd = "cd $dir && $zcat initrd | cpio --quiet -id $bins";
+ my $r = system ($cmd);
+ die __x("cpio command failed: {error}", error => $?)
+ unless $r == 0;
+
+ foreach my $bin (@_initrd_binaries) {
+ if (-f "$dir/bin/$bin") {
+ $_ = `file $dir/bin/$bin`;
+ if (/ELF.*executable, (.+?),/) {
+ return _elf_arch_to_canonical ($1);
+ }
+ }
+ }
+
+ die __x("file_architecture: no known binaries found in initrd image:
{path}",
+ path => $path);
}
die __x("file_architecture: unknown architecture: {path}",
- path => $path);
+ path => $path);
}
=head1 OPERATING SYSTEM INSPECTION FUNCTIONS
@@ -689,84 +689,84 @@ sub inspect_partition
# First try 'file(1)' on it.
my $file = $g->file ($dev);
if ($file =~ /ext2 filesystem data/) {
- $r{fstype} = "ext2";
- $r{fsos} = "linux";
+ $r{fstype} = "ext2";
+ $r{fsos} = "linux";
} elsif ($file =~ /ext3 filesystem data/) {
- $r{fstype} = "ext3";
- $r{fsos} = "linux";
+ $r{fstype} = "ext3";
+ $r{fsos} = "linux";
} elsif ($file =~ /ext4 filesystem data/) {
- $r{fstype} = "ext4";
- $r{fsos} = "linux";
+ $r{fstype} = "ext4";
+ $r{fsos} = "linux";
} elsif ($file =~ m{Linux/i386 swap file}) {
- $r{fstype} = "swap";
- $r{fsos} = "linux";
- $r{is_swap} = 1;
+ $r{fstype} = "swap";
+ $r{fsos} = "linux";
+ $r{is_swap} = 1;
}
# If it's ext2/3/4, then we want the UUID and label.
if (exists $r{fstype} && $r{fstype} =~ /^ext/) {
- $r{uuid} = $g->get_e2uuid ($dev);
- $r{label} = $g->get_e2label ($dev);
+ $r{uuid} = $g->get_e2uuid ($dev);
+ $r{label} = $g->get_e2label ($dev);
}
# Try mounting it, fnarrr.
if (!$r{is_swap}) {
- $r{is_mountable} = 1;
- eval { $g->mount_ro ($dev, "/") };
- if ($@) {
- # It's not mountable, probably empty or some format
- # we don't understand.
- $r{is_mountable} = 0;
- goto OUT;
- }
-
- # Grub /boot?
- if ($g->is_file ("/grub/menu.lst") ||
- $g->is_file ("/grub/grub.conf")) {
- $r{content} = "linux-grub";
- _check_grub ($g, \%r);
- goto OUT;
- }
-
- # Linux root?
- if ($g->is_dir ("/etc") && $g->is_dir ("/bin")
&&
- $g->is_file ("/etc/fstab")) {
- $r{content} = "linux-root";
- $r{is_root} = 1;
- _check_linux_root ($g, \%r);
- goto OUT;
- }
-
- # Linux /usr/local.
- if ($g->is_dir ("/etc") && $g->is_dir ("/bin")
&&
- $g->is_dir ("/share") && !$g->exists ("/local")
&&
- !$g->is_file ("/etc/fstab")) {
- $r{content} = "linux-usrlocal";
- goto OUT;
- }
-
- # Linux /usr.
- if ($g->is_dir ("/etc") && $g->is_dir ("/bin")
&&
- $g->is_dir ("/share") && $g->exists ("/local")
&&
- !$g->is_file ("/etc/fstab")) {
- $r{content} = "linux-usr";
- goto OUT;
- }
-
- # Windows root?
- if ($g->is_file ("/AUTOEXEC.BAT") ||
- $g->is_file ("/autoexec.bat") ||
- $g->is_dir ("/Program Files") ||
- $g->is_dir ("/WINDOWS") ||
- $g->is_file ("/boot.ini") ||
- $g->is_file ("/ntldr")) {
- $r{fstype} = "ntfs"; # XXX this is a guess
- $r{fsos} = "windows";
- $r{content} = "windows-root";
- $r{is_root} = 1;
- _check_windows_root ($g, \%r, $use_windows_registry);
- goto OUT;
- }
+ $r{is_mountable} = 1;
+ eval { $g->mount_ro ($dev, "/") };
+ if ($@) {
+ # It's not mountable, probably empty or some format
+ # we don't understand.
+ $r{is_mountable} = 0;
+ goto OUT;
+ }
+
+ # Grub /boot?
+ if ($g->is_file ("/grub/menu.lst") ||
+ $g->is_file ("/grub/grub.conf")) {
+ $r{content} = "linux-grub";
+ _check_grub ($g, \%r);
+ goto OUT;
+ }
+
+ # Linux root?
+ if ($g->is_dir ("/etc") && $g->is_dir ("/bin")
&&
+ $g->is_file ("/etc/fstab")) {
+ $r{content} = "linux-root";
+ $r{is_root} = 1;
+ _check_linux_root ($g, \%r);
+ goto OUT;
+ }
+
+ # Linux /usr/local.
+ if ($g->is_dir ("/etc") && $g->is_dir ("/bin")
&&
+ $g->is_dir ("/share") && !$g->exists
("/local") &&
+ !$g->is_file ("/etc/fstab")) {
+ $r{content} = "linux-usrlocal";
+ goto OUT;
+ }
+
+ # Linux /usr.
+ if ($g->is_dir ("/etc") && $g->is_dir ("/bin")
&&
+ $g->is_dir ("/share") && $g->exists
("/local") &&
+ !$g->is_file ("/etc/fstab")) {
+ $r{content} = "linux-usr";
+ goto OUT;
+ }
+
+ # Windows root?
+ if ($g->is_file ("/AUTOEXEC.BAT") ||
+ $g->is_file ("/autoexec.bat") ||
+ $g->is_dir ("/Program Files") ||
+ $g->is_dir ("/WINDOWS") ||
+ $g->is_file ("/boot.ini") ||
+ $g->is_file ("/ntldr")) {
+ $r{fstype} = "ntfs"; # XXX this is a guess
+ $r{fsos} = "windows";
+ $r{content} = "windows-root";
+ $r{is_root} = 1;
+ _check_windows_root ($g, \%r, $use_windows_registry);
+ goto OUT;
+ }
}
OUT:
@@ -785,13 +785,13 @@ sub _check_linux_root
if ($g->exists ("/etc/redhat-release")) {
$r->{package_format} = "rpm";
- $_ = $g->cat ("/etc/redhat-release");
- if (/Fedora release (\d+)(?:\.(\d+))?/) {
- $r->{osdistro} = "fedora";
- $r->{os_major_version} = "$1";
- $r->{os_minor_version} = "$2" if(defined($2));
- $r->{package_management} = "yum";
- }
+ $_ = $g->cat ("/etc/redhat-release");
+ if (/Fedora release (\d+)(?:\.(\d+))?/) {
+ $r->{osdistro} = "fedora";
+ $r->{os_major_version} = "$1";
+ $r->{os_minor_version} = "$2" if(defined($2));
+ $r->{package_management} = "yum";
+ }
elsif (/(Red Hat Enterprise Linux|CentOS|Scientific Linux)/) {
my $distro = $1;
@@ -839,51 +839,51 @@ sub _check_linux_root
}
else {
- $r->{osdistro} = "redhat-based";
- }
+ $r->{osdistro} = "redhat-based";
+ }
} elsif ($g->is_file ("/etc/debian_version")) {
$r->{package_format} = "dpkg";
$r->{package_management} = "apt";
- $_ = $g->cat ("/etc/debian_version");
- if (/(\d+)\.(\d+)/) {
- $r->{osdistro} = "debian";
- $r->{os_major_version} = "$1";
- $r->{os_minor_version} = "$2";
- } else {
- $r->{osdistro} = "debian";
- }
+ $_ = $g->cat ("/etc/debian_version");
+ if (/(\d+)\.(\d+)/) {
+ $r->{osdistro} = "debian";
+ $r->{os_major_version} = "$1";
+ $r->{os_minor_version} = "$2";
+ } else {
+ $r->{osdistro} = "debian";
+ }
}
# Parse the contents of /etc/fstab. This is pretty vital so
# we can determine where filesystems are supposed to be mounted.
eval "\$_ = \$g->cat ('/etc/fstab');";
if (!$@ && $_) {
- my @lines = split /\n/;
- my @fstab;
- foreach (@lines) {
- my @fields = split /[ \t]+/;
- if (@fields >= 2) {
- my $spec = $fields[0]; # first column (dev/label/uuid)
- my $file = $fields[1]; # second column (mountpoint)
- if ($spec =~ m{^/} ||
- $spec =~ m{^LABEL=} ||
- $spec =~ m{^UUID=} ||
- $file eq "swap") {
- push @fstab, [$spec, $file]
- }
- }
- }
- $r->{fstab} = \@fstab if @fstab;
+ my @lines = split /\n/;
+ my @fstab;
+ foreach (@lines) {
+ my @fields = split /[ \t]+/;
+ if (@fields >= 2) {
+ my $spec = $fields[0]; # first column (dev/label/uuid)
+ my $file = $fields[1]; # second column (mountpoint)
+ if ($spec =~ m{^/} ||
+ $spec =~ m{^LABEL=} ||
+ $spec =~ m{^UUID=} ||
+ $file eq "swap") {
+ push @fstab, [$spec, $file]
+ }
+ }
+ }
+ $r->{fstab} = \@fstab if @fstab;
}
# Determine the architecture of this root.
my $arch;
foreach ("/bin/bash", "/bin/ls", "/bin/echo",
"/bin/rm", "/bin/sh") {
- if ($g->is_file ($_)) {
- $arch = file_architecture ($g, $_);
- last;
- }
+ if ($g->is_file ($_)) {
+ $arch = file_architecture ($g, $_);
+ last;
+ }
}
$r->{arch} = $arch if defined $arch;
@@ -907,31 +907,31 @@ sub _check_windows_root
$r->{boot_ini} = $boot_ini;
if (defined $r->{boot_ini}) {
- $_ = $g->cat ($boot_ini);
- my @lines = split /\n/;
- my $section;
- my $systemroot;
- foreach (@lines) {
- if (m/\[.*\]/) {
- $section = $1;
- } elsif (m/^default=.*?\\(\w+)$/i) {
- $systemroot = $1;
- last;
- } elsif (m/\\(\w+)=/) {
- $systemroot = $1;
- last;
- }
- }
-
- if (defined $systemroot) {
- $r->{systemroot} = resolve_windows_path ($g, "/$systemroot");
- if (defined $r->{systemroot}) {
- _check_windows_arch ($g, $r, $r->{systemroot});
- if ($use_windows_registry) {
- _check_windows_registry ($g, $r, $r->{systemroot});
- }
- }
- }
+ $_ = $g->cat ($boot_ini);
+ my @lines = split /\n/;
+ my $section;
+ my $systemroot;
+ foreach (@lines) {
+ if (m/\[.*\]/) {
+ $section = $1;
+ } elsif (m/^default=.*?\\(\w+)$/i) {
+ $systemroot = $1;
+ last;
+ } elsif (m/\\(\w+)=/) {
+ $systemroot = $1;
+ last;
+ }
+ }
+
+ if (defined $systemroot) {
+ $r->{systemroot} = resolve_windows_path ($g, "/$systemroot");
+ if (defined $r->{systemroot}) {
+ _check_windows_arch ($g, $r, $r->{systemroot});
+ if ($use_windows_registry) {
+ _check_windows_registry ($g, $r, $r->{systemroot});
+ }
+ }
+ }
}
}
@@ -945,7 +945,7 @@ sub _check_windows_arch
my $systemroot = shift;
my $cmd_exe =
- resolve_windows_path ($g, $r->{systemroot} . "/system32/cmd.exe");
+ resolve_windows_path ($g, $r->{systemroot} . "/system32/cmd.exe");
$r->{arch} = file_architecture ($g, $cmd_exe) if $cmd_exe;
}
@@ -961,16 +961,16 @@ sub _check_windows_registry
my $configdir = resolve_windows_path ($g, "$systemroot/system32/config");
if (defined $configdir) {
- my $softwaredir = resolve_windows_path ($g, "$configdir/software");
- if (defined $softwaredir) {
- _load_windows_registry ($g, $r, $softwaredir,
- "HKEY_LOCAL_MACHINE\\SOFTWARE");
- }
- my $systemdir = resolve_windows_path ($g, "$configdir/system");
- if (defined $systemdir) {
- _load_windows_registry ($g, $r, $systemdir,
- "HKEY_LOCAL_MACHINE\\System");
- }
+ my $softwaredir = resolve_windows_path ($g, "$configdir/software");
+ if (defined $softwaredir) {
+ _load_windows_registry ($g, $r, $softwaredir,
+ "HKEY_LOCAL_MACHINE\\SOFTWARE");
+ }
+ my $systemdir = resolve_windows_path ($g, "$configdir/system");
+ if (defined $systemdir) {
+ _load_windows_registry ($g, $r, $systemdir,
+ "HKEY_LOCAL_MACHINE\\System");
+ }
}
}
@@ -1004,8 +1004,8 @@ sub _load_windows_registry
close SAVEERR;
unless ($res == 0) {
- warn __x("reged command failed: {errormsg}", errormsg => $?);
- return;
+ warn __x("reged command failed: {errormsg}", errormsg => $?);
+ return;
}
# Some versions of reged segfault on inputs. If that happens we
@@ -1013,8 +1013,8 @@ sub _load_windows_registry
# it.
my $content;
unless (open F, "$dir/out") {
- warn __x("no output from reged command: {errormsg}", errormsg => $!);
- return;
+ warn __x("no output from reged command: {errormsg}", errormsg =>
$!);
+ return;
}
{ local $/ = undef; $content = <F>; }
close F;
@@ -1120,15 +1120,15 @@ sub inspect_operating_systems
my %oses = ();
foreach (sort keys %$fses) {
- if ($fses->{$_}->{is_root}) {
- my %r = (
- root => $fses->{$_},
- root_device => $_
- );
- _get_os_version ($g, \%r);
- _assign_mount_points ($g, $fses, \%r);
- $oses{$_} = \%r;
- }
+ if ($fses->{$_}->{is_root}) {
+ my %r = (
+ root => $fses->{$_},
+ root_device => $_
+ );
+ _get_os_version ($g, \%r);
+ _assign_mount_points ($g, $fses, \%r);
+ $oses{$_} = \%r;
+ }
}
return \%oses;
@@ -1165,22 +1165,22 @@ sub _assign_mount_points
# Use /etc/fstab if we have it to mount the rest.
if (exists $r->{root}->{fstab}) {
- my @fstab = @{$r->{root}->{fstab}};
- foreach (@fstab) {
- my ($spec, $file) = @$_;
-
- my ($dev, $fs) = _find_filesystem ($g, $fses, $spec);
- if ($dev) {
- $r->{mounts}->{$file} = $dev;
- $r->{filesystems}->{$dev} = $fs;
- if (exists $fs->{used}) {
- $fs->{used}++
- } else {
- $fs->{used} = 1
- }
+ my @fstab = @{$r->{root}->{fstab}};
+ foreach (@fstab) {
+ my ($spec, $file) = @$_;
+
+ my ($dev, $fs) = _find_filesystem ($g, $fses, $spec);
+ if ($dev) {
+ $r->{mounts}->{$file} = $dev;
+ $r->{filesystems}->{$dev} = $fs;
+ if (exists $fs->{used}) {
+ $fs->{used}++
+ } else {
+ $fs->{used} = 1
+ }
$fs->{spec} = $spec;
- }
- }
+ }
+ }
}
}
@@ -1192,27 +1192,27 @@ sub _find_filesystem
local $_ = shift;
if (/^LABEL=(.*)/) {
- my $label = $1;
- foreach (sort keys %$fses) {
- if (exists $fses->{$_}->{label} &&
- $fses->{$_}->{label} eq $label) {
- return ($_, $fses->{$_});
- }
- }
- warn __x("unknown filesystem label {label}\n", label => $label);
- return ();
+ my $label = $1;
+ foreach (sort keys %$fses) {
+ if (exists $fses->{$_}->{label} &&
+ $fses->{$_}->{label} eq $label) {
+ return ($_, $fses->{$_});
+ }
+ }
+ warn __x("unknown filesystem label {label}\n", label => $label);
+ return ();
} elsif (/^UUID=(.*)/) {
- my $uuid = $1;
- foreach (sort keys %$fses) {
- if (exists $fses->{$_}->{uuid} &&
- $fses->{$_}->{uuid} eq $uuid) {
- return ($_, $fses->{$_});
- }
- }
- warn __x("unknown filesystem UUID {uuid}\n", uuid => $uuid);
- return ();
+ my $uuid = $1;
+ foreach (sort keys %$fses) {
+ if (exists $fses->{$_}->{uuid} &&
+ $fses->{$_}->{uuid} eq $uuid) {
+ return ($_, $fses->{$_});
+ }
+ }
+ warn __x("unknown filesystem UUID {uuid}\n", uuid => $uuid);
+ return ();
} else {
- return ($_, $fses->{$_}) if exists $fses->{$_};
+ return ($_, $fses->{$_}) if exists $fses->{$_};
# The following is to handle the case where an fstab entry specifies a
# specific device rather than its label or uuid, and the libguestfs
@@ -1220,20 +1220,20 @@ sub _find_filesystem
# different driver.
# This will work as long as the underlying drivers recognise devices in
# the same order.
- if (m{^/dev/hd(.*)} && exists $fses->{"/dev/sd$1"}) {
- return ("/dev/sd$1", $fses->{"/dev/sd$1"});
- }
- if (m{^/dev/xvd(.*)} && exists $fses->{"/dev/sd$1"}) {
- return ("/dev/sd$1", $fses->{"/dev/sd$1"});
- }
- if (m{^/dev/mapper/(.*)-(.*)$} && exists $fses->{"/dev/$1/$2"}) {
- return ("/dev/$1/$2", $fses->{"/dev/$1/$2"});
- }
-
- return () if m{/dev/cdrom};
-
- warn __x("unknown filesystem {fs}\n", fs => $_);
- return ();
+ if (m{^/dev/hd(.*)} && exists $fses->{"/dev/sd$1"}) {
+ return ("/dev/sd$1", $fses->{"/dev/sd$1"});
+ }
+ if (m{^/dev/xvd(.*)} && exists $fses->{"/dev/sd$1"}) {
+ return ("/dev/sd$1", $fses->{"/dev/sd$1"});
+ }
+ if (m{^/dev/mapper/(.*)-(.*)$} && exists
$fses->{"/dev/$1/$2"}) {
+ return ("/dev/$1/$2", $fses->{"/dev/$1/$2"});
+ }
+
+ return () if m{/dev/cdrom};
+
+ warn __x("unknown filesystem {fs}\n", fs => $_);
+ return ();
}
}
@@ -1388,7 +1388,7 @@ sub inspect_in_detail
_check_for_applications ($g, $os);
_check_for_kernels ($g, $os);
if ($os->{os} eq "linux") {
- _find_modprobe_aliases ($g, $os);
+ _find_modprobe_aliases ($g, $os);
}
}
@@ -1402,34 +1402,34 @@ sub _check_for_applications
my $osn = $os->{os};
if ($osn eq "linux") {
- my $package_format = $os->{package_format};
- if (defined $package_format && $package_format eq "rpm") {
- my @lines = $g->command_lines
- (["rpm",
- "-q", "-a",
- "--qf", "%{name} %{epoch} %{version} %{release} %{arch}\n"]);
- foreach (@lines) {
- if (m/^(.*) (.*) (.*) (.*) (.*)$/) {
- my $epoch = $2;
- $epoch = "" if $epoch eq "(none)";
- my $app = {
- name => $1,
- epoch => $epoch,
- version => $3,
- release => $4,
- arch => $5
- };
- push @apps, $app
- }
- }
- }
+ my $package_format = $os->{package_format};
+ if (defined $package_format && $package_format eq "rpm") {
+ my @lines = $g->command_lines
+ (["rpm",
+ "-q", "-a",
+ "--qf", "%{name} %{epoch} %{version} %{release}
%{arch}\n"]);
+ foreach (@lines) {
+ if (m/^(.*) (.*) (.*) (.*) (.*)$/) {
+ my $epoch = $2;
+ $epoch = "" if $epoch eq "(none)";
+ my $app = {
+ name => $1,
+ epoch => $epoch,
+ version => $3,
+ release => $4,
+ arch => $5
+ };
+ push @apps, $app
+ }
+ }
+ }
} elsif ($osn eq "windows") {
- # XXX
- # I worked out a general plan for this, but haven't
- # implemented it yet. We can iterate over /Program Files
- # looking for *.EXE files, which we download, then use
- # i686-pc-mingw32-windres on, to find the VERSIONINFO
- # section, which has a lot of useful information.
+ # XXX
+ # I worked out a general plan for this, but haven't
+ # implemented it yet. We can iterate over /Program Files
+ # looking for *.EXE files, which we download, then use
+ # i686-pc-mingw32-windres on, to find the VERSIONINFO
+ # section, which has a lot of useful information.
}
$os->{apps} = \@apps;
@@ -1537,7 +1537,7 @@ sub _check_for_kernels
}
elsif ($os->{os} eq "windows") {
- # XXX
+ # XXX
}
}
@@ -1652,7 +1652,7 @@ sub _find_modprobe_aliases
for my $path ( $g->aug_match($pattern) ) {
$path =~ m{^/files(.*)/alias(?:\[\d*\])?$}
or die __x("{path} doesn't match augeas pattern",
- path => $path);
+ path => $path);
my $file = $1;
my $alias;
diff --git a/perl/t/500-lib-load.t b/perl/t/500-lib-load.t
index de928ae..7ce28c6 100644
--- a/perl/t/500-lib-load.t
+++ b/perl/t/500-lib-load.t
@@ -23,10 +23,10 @@ BEGIN {
eval "use Locale::TextDomain";;
if (exists $INC{"Locale/TextDomain.pm"}) {
- plan tests => 1;
+ plan tests => 1;
} else {
- plan skip_all => "no perl-libintl module";
- exit 0;
+ plan skip_all => "no perl-libintl module";
+ exit 0;
}
}
diff --git a/perl/t/510-lib-file-arch.t b/perl/t/510-lib-file-arch.t
index b0a96e9..c4b9d31 100644
--- a/perl/t/510-lib-file-arch.t
+++ b/perl/t/510-lib-file-arch.t
@@ -22,10 +22,10 @@ BEGIN {
use Test::More;
eval "use Locale::TextDomain";;
if (exists $INC{"Locale/TextDomain.pm"}) {
- plan tests => 17;
+ plan tests => 17;
} else {
- plan skip_all => "no perl-libintl module";
- exit 0;
+ plan skip_all => "no perl-libintl module";
+ exit 0;
}
}
diff --git a/perl/typemap b/perl/typemap
index 421e73a..97788d3 100644
--- a/perl/typemap
+++ b/perl/typemap
@@ -9,7 +9,7 @@ O_OBJECT_guestfs_h
$var = ($type) SvIV ((SV *) SvRV ($arg));
else {
warn (\"${Package}::$func_name(): $var is not a blessed SV
reference\");
- XSRETURN_UNDEF;
+ XSRETURN_UNDEF;
}
OUTPUT
diff --git a/recipes/squashfs.example b/recipes/squashfs.example
index 9dae930..f10d195 100644
--- a/recipes/squashfs.example
+++ b/recipes/squashfs.example
@@ -3,14 +3,14 @@ Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on test.sqsh, block size 131072.
[===============================================================|] 663/663 100%
Exportable Squashfs 4.0 filesystem, data block size 131072
- compressed data, compressed metadata, compressed fragments
- duplicates are removed
+ compressed data, compressed metadata, compressed fragments
+ duplicates are removed
Filesystem size 1518.07 Kbytes (1.48 Mbytes)
- 98.41% of uncompressed filesystem size (1542.53 Kbytes)
+ 98.41% of uncompressed filesystem size (1542.53 Kbytes)
Inode table size 8095 bytes (7.91 Kbytes)
- 35.59% of uncompressed inode table size (22748 bytes)
+ 35.59% of uncompressed inode table size (22748 bytes)
Directory table size 7612 bytes (7.43 Kbytes)
- 49.11% of uncompressed directory table size (15499 bytes)
+ 49.11% of uncompressed directory table size (15499 bytes)
Number of duplicate files found 6
Number of inodes 701
Number of files 663
@@ -22,9 +22,9 @@ Number of socket nodes 0
Number of directories 1
Number of ids (unique uids + gids) 1
Number of uids 1
- root (0)
+ root (0)
Number of gids 1
- root (0)
+ root (0)
total 1732
drwxr-xr-x 2 root root 15498 May 27 10:34 .
drwxr-xr-x 18 root root 0 May 29 08:44 ..
diff --git a/src/generator.ml b/src/generator.ml
index b6f6f42..9ef99bd 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -375,9 +375,9 @@ You probably don't want to call this function.");
List.map (
fun (name, ret) ->
[(name, (ret, [String "val"]), -1, [NotInFish; NotInDocs],
- [],
- "internal test function - do not use",
- "\
+ [],
+ "internal test function - do not use",
+ "\
This is an internal test function which is used to test whether
the automatically generated bindings can handle every possible
return type correctly.
@@ -386,9 +386,9 @@ It converts string C<val> to the return type.
You probably don't want to call this function.");
(name ^ "err", (ret, []), -1, [NotInFish; NotInDocs],
- [],
- "internal test function - do not use",
- "\
+ [],
+ "internal test function - do not use",
+ "\
This is an internal test function which is used to test whether
the automatically generated bindings can handle every possible
return type correctly.
@@ -822,8 +822,8 @@ or C<guestfs_download> functions which have a more complex
interface.");
("ll", (RString "listing", [String "directory"]), 5, [],
[], (* XXX Tricky to test because it depends on the exact format
- * of the 'ls -l' command, which changes between F10 and F11.
- *)
+ * of the 'ls -l' command, which changes between F10 and F11.
+ *)
"list the files in a directory (long format)",
"\
List the files in C<directory> (relative to the root directory,
@@ -1320,8 +1320,8 @@ or LVM logical volume). The filesystem type is C<fstype>,
for
example C<ext3>.");
("sfdisk", (RErr, [String "device";
- Int "cyls"; Int "heads"; Int "sectors";
- StringList "lines"]), 43, [DangerWillRobinson],
+ Int "cyls"; Int "heads"; Int
"sectors";
+ StringList "lines"]), 43, [DangerWillRobinson],
[],
"create partitions on a block device",
"\
@@ -1620,7 +1620,7 @@ This is the same as the C<lstat(2)> system call.");
("statvfs", (RStruct ("statbuf", "statvfs"), [String
"path"]), 54, [],
[InitSquashFS, Always, TestOutputStruct (
[["statvfs"; "/"]], [CompareWithInt ("namemax",
256);
- CompareWithInt ("bsize", 131072)])],
+ CompareWithInt ("bsize", 131072)])],
"get file system statistics",
"\
Returns file system statistics for any mounted file system.
@@ -2307,8 +2307,8 @@ This resizes (expands or shrinks) an existing LVM physical
volume to match the new size of the underlying device.");
("sfdisk_N", (RErr, [String "device"; Int "partnum";
- Int "cyls"; Int "heads"; Int "sectors";
- String "line"]), 99, [DangerWillRobinson],
+ Int "cyls"; Int "heads"; Int
"sectors";
+ String "line"]), 99, [DangerWillRobinson],
[],
"modify a single partition on a block device",
"\
@@ -2682,8 +2682,8 @@ If the parameter C<nrlines> is zero, this returns an empty
list.");
("df", (RString "output", []), 125, [],
[], (* XXX Tricky to test because it depends on the exact format
- * of the 'df' command and other imponderables.
- *)
+ * of the 'df' command and other imponderables.
+ *)
"report file system disk space usage",
"\
This command runs the C<df> command to report disk space used.
@@ -2694,8 +2694,8 @@ Use C<statvfs> from programs.");
("df_h", (RString "output", []), 126, [],
[], (* XXX Tricky to test because it depends on the exact format
- * of the 'df' command and other imponderables.
- *)
+ * of the 'df' command and other imponderables.
+ *)
"report file system disk space usage (human readable)",
"\
This command runs the C<df -h> command to report disk space used
@@ -2821,8 +2821,8 @@ It is just a convenient wrapper around
C<guestfs_mknod>.");
("umask", (RInt "oldmask", [Int "mask"]), 137, [],
[], (* XXX umask is one of those stateful things that we should
- * reset between each test.
- *)
+ * reset between each test.
+ *)
"set file mode creation mask (umask)",
"\
This function sets the mask used for creating new files and
@@ -2944,8 +2944,8 @@ is a symbolic link, then it returns the extended attributes
of the link itself.");
("setxattr", (RErr, [String "xattr";
- String "val"; Int "vallen"; (* will be BufferIn *)
- String "path"]), 143, [],
+ String "val"; Int "vallen"; (* will be
BufferIn *)
+ String "path"]), 143, [],
[],
"set extended attribute of a file or directory",
"\
@@ -2956,8 +2956,8 @@ The value is arbitrary 8 bit data.
See also: C<guestfs_lsetxattr>, L<attr(5)>.");
("lsetxattr", (RErr, [String "xattr";
- String "val"; Int "vallen"; (* will be BufferIn *)
- String "path"]), 144, [],
+ String "val"; Int "vallen"; (* will be
BufferIn *)
+ String "path"]), 144, [],
[],
"set extended attribute of a file or directory",
"\
@@ -3402,7 +3402,7 @@ let all_functions = non_daemon_functions @ daemon_functions
*)
let all_functions_sorted =
List.sort (fun (n1,_,_,_,_,_,_) (n2,_,_,_,_,_,_) ->
- compare n1 n2) all_functions
+ compare n1 n2) all_functions
(* Field types for structures. *)
type field =
@@ -3646,11 +3646,11 @@ let rec find s sub =
let rec loop i =
if i <= len-sublen then (
let rec loop2 j =
- if j < sublen then (
- if s.[i+j] = sub.[j] then loop2 (j+1)
- else -1
- ) else
- i (* found *)
+ if j < sublen then (
+ if s.[i+j] = sub.[j] then loop2 (j+1)
+ else -1
+ ) else
+ i (* found *)
in
let r = loop2 0 in
if r = -1 then loop (i+1) else r
@@ -3772,9 +3772,9 @@ let check_functions () =
let rec loop i =
if i >= len then false
else (
- let c = str.[i] in
- if c >= 'A' && c <= 'Z' then true
- else loop (i+1)
+ let c = str.[i] in
+ if c >= 'A' && c <= 'Z' then true
+ else loop (i+1)
)
in
loop 0
@@ -3784,34 +3784,34 @@ let check_functions () =
List.iter (
fun (name, _, _, _, _, _, _) ->
if String.length name >= 7 && String.sub name 0 7 = "guestfs"
then
- failwithf "function name %s does not need 'guestfs' prefix" name;
+ failwithf "function name %s does not need 'guestfs' prefix"
name;
if name = "" then
- failwithf "function name is empty";
+ failwithf "function name is empty";
if name.[0] < 'a' || name.[0] > 'z' then
- failwithf "function name %s must start with lowercase a-z" name;
+ failwithf "function name %s must start with lowercase a-z" name;
if String.contains name '-' then
- failwithf "function name %s should not contain '-', use '_'
instead."
- name
+ failwithf "function name %s should not contain '-', use '_'
instead."
+ name
) all_functions;
(* Check function parameter/return names. *)
List.iter (
fun (name, style, _, _, _, _, _) ->
let check_arg_ret_name n =
- if contains_uppercase n then
- failwithf "%s param/ret %s should not contain uppercase chars"
- name n;
- if String.contains n '-' || String.contains n '_' then
- failwithf "%s param/ret %s should not contain '-' or '_'"
- name n;
- if n = "value" then
- failwithf "%s has a param/ret called 'value', which causes conflicts in
the OCaml bindings, use something like 'val' or a more descriptive name"
name;
- if n = "int" || n = "char" || n = "short" || n =
"long" then
- failwithf "%s has a param/ret which conflicts with a C type (eg. 'int',
'char' etc.)" name;
- if n = "i" || n = "n" then
- failwithf "%s has a param/ret called 'i' or 'n', which will cause
some conflicts in the generated code" name;
- if n = "argv" || n = "args" then
- failwithf "%s has a param/ret called 'argv' or 'args', which will
cause some conflicts in the generated code" name
+ if contains_uppercase n then
+ failwithf "%s param/ret %s should not contain uppercase chars"
+ name n;
+ if String.contains n '-' || String.contains n '_' then
+ failwithf "%s param/ret %s should not contain '-' or
'_'"
+ name n;
+ if n = "value" then
+ failwithf "%s has a param/ret called 'value', which causes
conflicts in the OCaml bindings, use something like 'val' or a more descriptive
name" name;
+ if n = "int" || n = "char" || n = "short" || n =
"long" then
+ failwithf "%s has a param/ret which conflicts with a C type (eg.
'int', 'char' etc.)" name;
+ if n = "i" || n = "n" then
+ failwithf "%s has a param/ret called 'i' or 'n', which
will cause some conflicts in the generated code" name;
+ if n = "argv" || n = "args" then
+ failwithf "%s has a param/ret called 'argv' or 'args',
which will cause some conflicts in the generated code" name
in
(match fst style with
@@ -3820,7 +3820,7 @@ let check_functions () =
| RConstString n | RConstOptString n | RString n
| RStringList n | RStruct (n, _) | RStructList (n, _)
| RHashtable n | RBufferOut n ->
- check_arg_ret_name n
+ check_arg_ret_name n
);
List.iter (fun arg -> check_arg_ret_name (name_of_argt arg)) (snd style)
) all_functions;
@@ -3829,30 +3829,30 @@ let check_functions () =
List.iter (
fun (name, _, _, _, _, shortdesc, _) ->
if shortdesc.[0] <> Char.lowercase shortdesc.[0] then
- failwithf "short description of %s should begin with lowercase." name;
+ failwithf "short description of %s should begin with lowercase." name;
let c = shortdesc.[String.length shortdesc-1] in
if c = '\n' || c = '.' then
- failwithf "short description of %s should not end with . or \\n." name
+ failwithf "short description of %s should not end with . or \\n." name
) all_functions;
(* Check long dscriptions. *)
List.iter (
fun (name, _, _, _, _, _, longdesc) ->
if longdesc.[String.length longdesc-1] = '\n' then
- failwithf "long description of %s should not end with \\n." name
+ failwithf "long description of %s should not end with \\n." name
) all_functions;
(* Check proc_nrs. *)
List.iter (
fun (name, _, proc_nr, _, _, _, _) ->
if proc_nr <= 0 then
- failwithf "daemon function %s should have proc_nr > 0" name
+ failwithf "daemon function %s should have proc_nr > 0" name
) daemon_functions;
List.iter (
fun (name, _, proc_nr, _, _, _, _) ->
if proc_nr <> -1 then
- failwithf "non-daemon function %s should have proc_nr -1" name
+ failwithf "non-daemon function %s should have proc_nr -1" name
) non_daemon_functions;
let proc_nrs =
@@ -3864,10 +3864,10 @@ let check_functions () =
| [] -> ()
| [_] -> ()
| (name1,nr1) :: ((name2,nr2) :: _ as rest) when nr1 < nr2 ->
- loop rest
+ loop rest
| (name1,nr1) :: (name2,nr2) :: _ ->
- failwithf "%s and %s have conflicting procedure numbers (%d, %d)"
- name1 name2 nr1 nr2
+ failwithf "%s and %s have conflicting procedure numbers (%d, %d)"
+ name1 name2 nr1 nr2
in
loop proc_nrs;
@@ -3879,20 +3879,20 @@ let check_functions () =
*)
| name, _, _, _, [], _, _ -> ()
| name, _, _, _, tests, _, _ ->
- let funcs =
- List.map (
- fun (_, _, test) ->
- match seq_of_test test with
- | [] ->
- failwithf "%s has a test containing an empty sequence" name
- | cmds -> List.map List.hd cmds
- ) tests in
- let funcs = List.flatten funcs in
-
- let tested = List.mem name funcs in
-
- if not tested then
- failwithf "function %s has tests but does not test itself" name
+ let funcs =
+ List.map (
+ fun (_, _, test) ->
+ match seq_of_test test with
+ | [] ->
+ failwithf "%s has a test containing an empty sequence" name
+ | cmds -> List.map List.hd cmds
+ ) tests in
+ let funcs = List.flatten funcs in
+
+ let tested = List.mem name funcs in
+
+ if not tested then
+ failwithf "function %s has tests but does not test itself" name
) all_functions
(* 'pr' prints to the current output file. *)
@@ -3961,62 +3961,62 @@ let rec generate_actions_pod () =
List.iter (
fun (shortname, style, _, flags, _, _, longdesc) ->
if not (List.mem NotInDocs flags) then (
- let name = "guestfs_" ^ shortname in
- pr "=head2 %s\n\n" name;
- pr " ";
- generate_prototype ~extern:false ~handle:"handle" name style;
- pr "\n\n";
- pr "%s\n\n" longdesc;
- (match fst style with
- | RErr ->
- pr "This function returns 0 on success or -1 on error.\n\n"
- | RInt _ ->
- pr "On error this function returns -1.\n\n"
- | RInt64 _ ->
- pr "On error this function returns -1.\n\n"
- | RBool _ ->
- pr "This function returns a C truth value on success or -1 on
error.\n\n"
- | RConstString _ ->
- pr "This function returns a string, or NULL on error.
+ let name = "guestfs_" ^ shortname in
+ pr "=head2 %s\n\n" name;
+ pr " ";
+ generate_prototype ~extern:false ~handle:"handle" name style;
+ pr "\n\n";
+ pr "%s\n\n" longdesc;
+ (match fst style with
+ | RErr ->
+ pr "This function returns 0 on success or -1 on error.\n\n"
+ | RInt _ ->
+ pr "On error this function returns -1.\n\n"
+ | RInt64 _ ->
+ pr "On error this function returns -1.\n\n"
+ | RBool _ ->
+ pr "This function returns a C truth value on success or -1 on
error.\n\n"
+ | RConstString _ ->
+ pr "This function returns a string, or NULL on error.
The string is owned by the guest handle and must I<not> be freed.\n\n"
- | RConstOptString _ ->
- pr "This function returns a string which may be NULL.
+ | RConstOptString _ ->
+ pr "This function returns a string which may be NULL.
There is way to return an error from this function.
The string is owned by the guest handle and must I<not> be freed.\n\n"
- | RString _ ->
- pr "This function returns a string, or NULL on error.
+ | RString _ ->
+ pr "This function returns a string, or NULL on error.
I<The caller must free the returned string after use>.\n\n"
- | RStringList _ ->
- pr "This function returns a NULL-terminated array of strings
+ | RStringList _ ->
+ pr "This function returns a NULL-terminated array of strings
(like L<environ(3)>), or NULL if there was an error.
I<The caller must free the strings and the array after use>.\n\n"
- | RStruct (_, typ) ->
- pr "This function returns a C<struct guestfs_%s *>,
+ | RStruct (_, typ) ->
+ pr "This function returns a C<struct guestfs_%s *>,
or NULL if there was an error.
I<The caller must call C<guestfs_free_%s> after use>.\n\n" typ typ
- | RStructList (_, typ) ->
- pr "This function returns a C<struct guestfs_%s_list *>
+ | RStructList (_, typ) ->
+ pr "This function returns a C<struct guestfs_%s_list *>
(see E<lt>guestfs-structs.hE<gt>),
or NULL if there was an error.
I<The caller must call C<guestfs_free_%s_list> after use>.\n\n" typ typ
- | RHashtable _ ->
- pr "This function returns a NULL-terminated array of
+ | RHashtable _ ->
+ pr "This function returns a NULL-terminated array of
strings, or NULL if there was an error.
The array of strings will always have length C<2n+1>, where
C<n> keys and values alternate, followed by the trailing NULL entry.
I<The caller must free the strings and the array after use>.\n\n"
- | RBufferOut _ ->
- pr "This function returns a buffer, or NULL on error.
+ | RBufferOut _ ->
+ pr "This function returns a buffer, or NULL on error.
The size of the returned buffer is written to C<*size_r>.
I<The caller must free the returned buffer after use>.\n\n"
- );
- if List.mem ProtocolLimitWarning flags then
- pr "%s\n\n" protocol_limit_warning;
- if List.mem DangerWillRobinson flags then
- pr "%s\n\n" danger_will_robinson;
- match deprecation_notice flags with
- | None -> ()
- | Some txt -> pr "%s\n\n" txt
+ );
+ if List.mem ProtocolLimitWarning flags then
+ pr "%s\n\n" protocol_limit_warning;
+ if List.mem DangerWillRobinson flags then
+ pr "%s\n\n" danger_will_robinson;
+ match deprecation_notice flags with
+ | None -> ()
+ | Some txt -> pr "%s\n\n" txt
)
) all_functions_sorted
@@ -4028,23 +4028,23 @@ and generate_structs_pod () =
pr "\n";
pr " struct guestfs_%s {\n" typ;
List.iter (
- function
- | name, FChar -> pr " char %s;\n" name
- | name, FUInt32 -> pr " uint32_t %s;\n" name
- | name, FInt32 -> pr " int32_t %s;\n" name
- | name, (FUInt64|FBytes) -> pr " uint64_t %s;\n" name
- | name, FInt64 -> pr " int64_t %s;\n" name
- | name, FString -> pr " char *%s;\n" name
- | name, FBuffer ->
- pr " /* The next two fields describe a byte array. */\n";
- pr " uint32_t %s_len;\n" name;
- pr " char *%s;\n" name
- | name, FUUID ->
- pr " /* The next field is NOT nul-terminated, be careful when printing it:
*/\n";
- pr " char %s[32];\n" name
- | name, FOptPercent ->
- pr " /* The next field is [0..100] or -1 meaning 'not present':
*/\n";
- pr " float %s;\n" name
+ function
+ | name, FChar -> pr " char %s;\n" name
+ | name, FUInt32 -> pr " uint32_t %s;\n" name
+ | name, FInt32 -> pr " int32_t %s;\n" name
+ | name, (FUInt64|FBytes) -> pr " uint64_t %s;\n" name
+ | name, FInt64 -> pr " int64_t %s;\n" name
+ | name, FString -> pr " char *%s;\n" name
+ | name, FBuffer ->
+ pr " /* The next two fields describe a byte array. */\n";
+ pr " uint32_t %s_len;\n" name;
+ pr " char *%s;\n" name
+ | name, FUUID ->
+ pr " /* The next field is NOT nul-terminated, be careful when printing
it: */\n";
+ pr " char %s[32];\n" name
+ | name, FOptPercent ->
+ pr " /* The next field is [0..100] or -1 meaning 'not
present': */\n";
+ pr " float %s;\n" name
) cols;
pr " };\n";
pr " \n";
@@ -4055,7 +4055,7 @@ and generate_structs_pod () =
pr " \n";
pr " void guestfs_free_%s (struct guestfs_free_%s *);\n" typ typ;
pr " void guestfs_free_%s_list (struct guestfs_free_%s_list *);\n"
- typ typ;
+ typ typ;
pr "\n"
) structs
@@ -4078,20 +4078,20 @@ and generate_xdr () =
List.iter (
function
| typ, cols ->
- pr "struct guestfs_int_%s {\n" typ;
- List.iter (function
- | name, FChar -> pr " char %s;\n" name
- | name, FString -> pr " string %s<>;\n" name
- | name, FBuffer -> pr " opaque %s<>;\n" name
- | name, FUUID -> pr " opaque %s[32];\n" name
- | name, (FInt32|FUInt32) -> pr " int %s;\n" name
- | name, (FInt64|FUInt64|FBytes) -> pr " hyper %s;\n" name
- | name, FOptPercent -> pr " float %s;\n" name
- ) cols;
- pr "};\n";
- pr "\n";
- pr "typedef struct guestfs_int_%s guestfs_int_%s_list<>;\n" typ typ;
- pr "\n";
+ pr "struct guestfs_int_%s {\n" typ;
+ List.iter (function
+ | name, FChar -> pr " char %s;\n" name
+ | name, FString -> pr " string %s<>;\n" name
+ | name, FBuffer -> pr " opaque %s<>;\n" name
+ | name, FUUID -> pr " opaque %s[32];\n" name
+ | name, (FInt32|FUInt32) -> pr " int %s;\n" name
+ | name, (FInt64|FUInt64|FBytes) -> pr " hyper %s;\n"
name
+ | name, FOptPercent -> pr " float %s;\n" name
+ ) cols;
+ pr "};\n";
+ pr "\n";
+ pr "typedef struct guestfs_int_%s guestfs_int_%s_list<>;\n" typ
typ;
+ pr "\n";
) structs;
List.iter (
@@ -4101,58 +4101,58 @@ and generate_xdr () =
(match snd style with
| [] -> ()
| args ->
- pr "struct %s_args {\n" name;
- List.iter (
- function
- | String n -> pr " string %s<>;\n" n
- | OptString n -> pr " str *%s;\n" n
- | StringList n -> pr " str %s<>;\n" n
- | Bool n -> pr " bool %s;\n" n
- | Int n -> pr " int %s;\n" n
- | FileIn _ | FileOut _ -> ()
- ) args;
- pr "};\n\n"
+ pr "struct %s_args {\n" name;
+ List.iter (
+ function
+ | String n -> pr " string %s<>;\n" n
+ | OptString n -> pr " str *%s;\n" n
+ | StringList n -> pr " str %s<>;\n" n
+ | Bool n -> pr " bool %s;\n" n
+ | Int n -> pr " int %s;\n" n
+ | FileIn _ | FileOut _ -> ()
+ ) args;
+ pr "};\n\n"
);
(match fst style with
| RErr -> ()
| RInt n ->
- pr "struct %s_ret {\n" name;
- pr " int %s;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " int %s;\n" n;
+ pr "};\n\n"
| RInt64 n ->
- pr "struct %s_ret {\n" name;
- pr " hyper %s;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " hyper %s;\n" n;
+ pr "};\n\n"
| RBool n ->
- pr "struct %s_ret {\n" name;
- pr " bool %s;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " bool %s;\n" n;
+ pr "};\n\n"
| RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
| RString n ->
- pr "struct %s_ret {\n" name;
- pr " string %s<>;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " string %s<>;\n" n;
+ pr "};\n\n"
| RStringList n ->
- pr "struct %s_ret {\n" name;
- pr " str %s<>;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " str %s<>;\n" n;
+ pr "};\n\n"
| RStruct (n, typ) ->
- pr "struct %s_ret {\n" name;
- pr " guestfs_int_%s %s;\n" typ n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " guestfs_int_%s %s;\n" typ n;
+ pr "};\n\n"
| RStructList (n, typ) ->
- pr "struct %s_ret {\n" name;
- pr " guestfs_int_%s_list %s;\n" typ n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " guestfs_int_%s_list %s;\n" typ n;
+ pr "};\n\n"
| RHashtable n ->
- pr "struct %s_ret {\n" name;
- pr " str %s<>;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " str %s<>;\n" n;
+ pr "};\n\n"
| RBufferOut n ->
- pr "struct %s_ret {\n" name;
- pr " opaque %s<>;\n" n;
- pr "};\n\n"
+ pr "struct %s_ret {\n" name;
+ pr " opaque %s<>;\n" n;
+ pr "};\n\n"
);
) daemon_functions;
@@ -4245,18 +4245,18 @@ and generate_structs_h () =
fun (typ, cols) ->
pr "struct guestfs_%s {\n" typ;
List.iter (
- function
- | name, FChar -> pr " char %s;\n" name
- | name, FString -> pr " char *%s;\n" name
- | name, FBuffer ->
- pr " uint32_t %s_len;\n" name;
- pr " char *%s;\n" name
- | name, FUUID -> pr " char %s[32]; /* this is NOT nul-terminated, be careful
when printing */\n" name
- | name, FUInt32 -> pr " uint32_t %s;\n" name
- | name, FInt32 -> pr " int32_t %s;\n" name
- | name, (FUInt64|FBytes) -> pr " uint64_t %s;\n" name
- | name, FInt64 -> pr " int64_t %s;\n" name
- | name, FOptPercent -> pr " float %s; /* [0..100] or -1 */\n" name
+ function
+ | name, FChar -> pr " char %s;\n" name
+ | name, FString -> pr " char *%s;\n" name
+ | name, FBuffer ->
+ pr " uint32_t %s_len;\n" name;
+ pr " char *%s;\n" name
+ | name, FUUID -> pr " char %s[32]; /* this is NOT nul-terminated, be
careful when printing */\n" name
+ | name, FUInt32 -> pr " uint32_t %s;\n" name
+ | name, FInt32 -> pr " int32_t %s;\n" name
+ | name, (FUInt64|FBytes) -> pr " uint64_t %s;\n" name
+ | name, FInt64 -> pr " int64_t %s;\n" name
+ | name, FOptPercent -> pr " float %s; /* [0..100] or -1 */\n" name
) cols;
pr "};\n";
pr "\n";
@@ -4277,7 +4277,7 @@ and generate_actions_h () =
fun (shortname, style, _, _, _, _, _) ->
let name = "guestfs_" ^ shortname in
generate_prototype ~single_line:true ~newline:true ~handle:"handle"
- name style
+ name style
) all_functions
(* Generate the client-side dispatch stubs. *)
@@ -4310,12 +4310,12 @@ check_reply_header (guestfs_h *g,
}
if (hdr->vers != GUESTFS_PROTOCOL_VERSION) {
error (g, \"wrong protocol version (%%d/%%d)\",
- hdr->vers, GUESTFS_PROTOCOL_VERSION);
+ hdr->vers, GUESTFS_PROTOCOL_VERSION);
return -1;
}
if (hdr->direction != GUESTFS_DIRECTION_REPLY) {
error (g, \"unexpected message direction (%%d/%%d)\",
- hdr->direction, GUESTFS_DIRECTION_REPLY);
+ hdr->direction, GUESTFS_DIRECTION_REPLY);
return -1;
}
if (hdr->proc != proc_nr) {
@@ -4370,12 +4370,12 @@ check_state (guestfs_h *g, const char *caller)
(match fst style with
| RErr -> ()
| RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
| RInt _ | RInt64 _
| RBool _ | RString _ | RStringList _
| RStruct _ | RStructList _
| RHashtable _ | RBufferOut _ ->
- pr " struct %s_ret ret;\n" name
+ pr " struct %s_ret ret;\n" name
);
pr "};\n";
pr "\n";
@@ -4402,7 +4402,7 @@ check_state (guestfs_h *g, const char *caller)
pr " if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {\n";
pr " if (!xdr_guestfs_message_error (xdr, &ctx->err)) {\n";
pr " error (g, \"%%s: failed to parse reply error\",
\"%s\");\n"
- name;
+ name;
pr " return;\n";
pr " }\n";
pr " goto done;\n";
@@ -4411,15 +4411,15 @@ check_state (guestfs_h *g, const char *caller)
(match fst style with
| RErr -> ()
| RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
| RInt _ | RInt64 _
| RBool _ | RString _ | RStringList _
| RStruct _ | RStructList _
| RHashtable _ | RBufferOut _ ->
- pr " if (!xdr_%s_ret (xdr, &ctx->ret)) {\n" name;
- pr " error (g, \"%%s: failed to parse reply\",
\"%s\");\n" name;
- pr " return;\n";
- pr " }\n";
+ pr " if (!xdr_%s_ret (xdr, &ctx->ret)) {\n" name;
+ pr " error (g, \"%%s: failed to parse reply\",
\"%s\");\n" name;
+ pr " return;\n";
+ pr " }\n";
);
pr " done:\n";
@@ -4428,17 +4428,17 @@ check_state (guestfs_h *g, const char *caller)
(* Generate the action stub. *)
generate_prototype ~extern:false ~semicolon:false ~newline:true
- ~handle:"g" name style;
+ ~handle:"g" name style;
let error_code =
- match fst style with
- | RErr | RInt _ | RInt64 _ | RBool _ -> "-1"
- | RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
- | RString _ | RStringList _
- | RStruct _ | RStructList _
- | RHashtable _ | RBufferOut _ ->
- "NULL" in
+ match fst style with
+ | RErr | RInt _ | RInt64 _ | RBool _ -> "-1"
+ | RConstString _ | RConstOptString _ ->
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ | RString _ | RStringList _
+ | RStruct _ | RStructList _
+ | RHashtable _ | RBufferOut _ ->
+ "NULL" in
pr "{\n";
@@ -4460,28 +4460,28 @@ check_state (guestfs_h *g, const char *caller)
(* Send the main header and arguments. *)
(match snd style with
| [] ->
- pr " serial = guestfs__send_sync (g, GUESTFS_PROC_%s, NULL, NULL);\n"
- (String.uppercase shortname)
+ pr " serial = guestfs__send_sync (g, GUESTFS_PROC_%s, NULL,
NULL);\n"
+ (String.uppercase shortname)
| args ->
- List.iter (
- function
- | String n ->
- pr " args.%s = (char *) %s;\n" n n
- | OptString n ->
- pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
- | StringList n ->
- pr " args.%s.%s_val = (char **) %s;\n" n n n;
- pr " for (args.%s.%s_len = 0; %s[args.%s.%s_len]; args.%s.%s_len++) ;\n" n
n n n n n n;
- | Bool n ->
- pr " args.%s = %s;\n" n n
- | Int n ->
- pr " args.%s = %s;\n" n n
- | FileIn _ | FileOut _ -> ()
- ) args;
- pr " serial = guestfs__send_sync (g, GUESTFS_PROC_%s,\n"
- (String.uppercase shortname);
- pr " (xdrproc_t) xdr_%s_args, (char *) &args);\n"
- name;
+ List.iter (
+ function
+ | String n ->
+ pr " args.%s = (char *) %s;\n" n n
+ | OptString n ->
+ pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
+ | StringList n ->
+ pr " args.%s.%s_val = (char **) %s;\n" n n n;
+ pr " for (args.%s.%s_len = 0; %s[args.%s.%s_len];
args.%s.%s_len++) ;\n" n n n n n n n;
+ | Bool n ->
+ pr " args.%s = %s;\n" n n
+ | Int n ->
+ pr " args.%s = %s;\n" n n
+ | FileIn _ | FileOut _ -> ()
+ ) args;
+ pr " serial = guestfs__send_sync (g, GUESTFS_PROC_%s,\n"
+ (String.uppercase shortname);
+ pr " (xdrproc_t) xdr_%s_args, (char *) &args);\n"
+ name;
);
pr " if (serial == -1) {\n";
pr " guestfs_end_busy (g);\n";
@@ -4492,22 +4492,22 @@ check_state (guestfs_h *g, const char *caller)
(* Send any additional files (FileIn) requested. *)
let need_read_reply_label = ref false in
List.iter (
- function
- | FileIn n ->
- pr " {\n";
- pr " int r;\n";
- pr "\n";
- pr " r = guestfs__send_file_sync (g, %s);\n" n;
- pr " if (r == -1) {\n";
- pr " guestfs_end_busy (g);\n";
- pr " return %s;\n" error_code;
- pr " }\n";
- pr " if (r == -2) /* daemon cancelled */\n";
- pr " goto read_reply;\n";
- need_read_reply_label := true;
- pr " }\n";
- pr "\n";
- | _ -> ()
+ function
+ | FileIn n ->
+ pr " {\n";
+ pr " int r;\n";
+ pr "\n";
+ pr " r = guestfs__send_file_sync (g, %s);\n" n;
+ pr " if (r == -1) {\n";
+ pr " guestfs_end_busy (g);\n";
+ pr " return %s;\n" error_code;
+ pr " }\n";
+ pr " if (r == -2) /* daemon cancelled */\n";
+ pr " goto read_reply;\n";
+ need_read_reply_label := true;
+ pr " }\n";
+ pr "\n";
+ | _ -> ()
) (snd style);
(* Wait for the reply from the remote end. *)
@@ -4525,7 +4525,7 @@ check_state (guestfs_h *g, const char *caller)
pr "\n";
pr " if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_%s, serial) == -1)
{\n"
- (String.uppercase shortname);
+ (String.uppercase shortname);
pr " guestfs_end_busy (g);\n";
pr " return %s;\n" error_code;
pr " }\n";
@@ -4541,14 +4541,14 @@ check_state (guestfs_h *g, const char *caller)
(* Expecting to receive further files (FileOut)? *)
List.iter (
- function
- | FileOut n ->
- pr " if (guestfs__receive_file_sync (g, %s) == -1) {\n" n;
- pr " guestfs_end_busy (g);\n";
- pr " return %s;\n" error_code;
- pr " }\n";
- pr "\n";
- | _ -> ()
+ function
+ | FileOut n ->
+ pr " if (guestfs__receive_file_sync (g, %s) == -1) {\n" n;
+ pr " guestfs_end_busy (g);\n";
+ pr " return %s;\n" error_code;
+ pr " }\n";
+ pr "\n";
+ | _ -> ()
) (snd style);
pr " guestfs_end_busy (g);\n";
@@ -4556,28 +4556,28 @@ check_state (guestfs_h *g, const char *caller)
(match fst style with
| RErr -> pr " return 0;\n"
| RInt n | RInt64 n | RBool n ->
- pr " return ctx.ret.%s;\n" n
+ pr " return ctx.ret.%s;\n" n
| RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
| RString n ->
- pr " return ctx.ret.%s; /* caller will free */\n" n
+ pr " return ctx.ret.%s; /* caller will free */\n" n
| RStringList n | RHashtable n ->
- pr " /* caller will free this, but we need to add a NULL entry */\n";
- pr " ctx.ret.%s.%s_val =\n" n n;
- pr " safe_realloc (g, ctx.ret.%s.%s_val,\n" n n;
- pr " sizeof (char *) * (ctx.ret.%s.%s_len + 1));\n"
- n n;
- pr " ctx.ret.%s.%s_val[ctx.ret.%s.%s_len] = NULL;\n" n n n n;
- pr " return ctx.ret.%s.%s_val;\n" n n
+ pr " /* caller will free this, but we need to add a NULL entry
*/\n";
+ pr " ctx.ret.%s.%s_val =\n" n n;
+ pr " safe_realloc (g, ctx.ret.%s.%s_val,\n" n n;
+ pr " sizeof (char *) * (ctx.ret.%s.%s_len +
1));\n"
+ n n;
+ pr " ctx.ret.%s.%s_val[ctx.ret.%s.%s_len] = NULL;\n" n n n n;
+ pr " return ctx.ret.%s.%s_val;\n" n n
| RStruct (n, _) ->
- pr " /* caller will free this */\n";
- pr " return safe_memdup (g, &ctx.ret.%s, sizeof (ctx.ret.%s));\n" n n
+ pr " /* caller will free this */\n";
+ pr " return safe_memdup (g, &ctx.ret.%s, sizeof
(ctx.ret.%s));\n" n n
| RStructList (n, _) ->
- pr " /* caller will free this */\n";
- pr " return safe_memdup (g, &ctx.ret.%s, sizeof (ctx.ret.%s));\n" n n
+ pr " /* caller will free this */\n";
+ pr " return safe_memdup (g, &ctx.ret.%s, sizeof
(ctx.ret.%s));\n" n n
| RBufferOut n ->
- pr " *size_r = ctx.ret.%s.%s_len;\n" n n;
- pr " return ctx.ret.%s.%s_val; /* caller will free */\n" n n
+ pr " *size_r = ctx.ret.%s.%s_len;\n" n n;
+ pr " return ctx.ret.%s.%s_val; /* caller will free */\n" n n
);
pr "}\n\n"
@@ -4620,8 +4620,8 @@ and generate_daemon_actions_h () =
List.iter (
fun (name, style, _, _, _, _, _) ->
generate_prototype
- ~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
- name style;
+ ~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
+ name style;
) daemon_functions
(* Generate the server-side stubs. *)
@@ -4649,76 +4649,76 @@ and generate_daemon_actions () =
pr "static void %s_stub (XDR *xdr_in)\n" name;
pr "{\n";
let error_code =
- match fst style with
- | RErr | RInt _ -> pr " int r;\n"; "-1"
- | RInt64 _ -> pr " int64_t r;\n"; "-1"
- | RBool _ -> pr " int r;\n"; "-1"
- | RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
- | RString _ -> pr " char *r;\n"; "NULL"
- | RStringList _ | RHashtable _ -> pr " char **r;\n"; "NULL"
- | RStruct (_, typ) -> pr " guestfs_int_%s *r;\n" typ; "NULL"
- | RStructList (_, typ) -> pr " guestfs_int_%s_list *r;\n" typ;
"NULL"
- | RBufferOut _ ->
- pr " size_t size;\n";
- pr " char *r;\n";
- "NULL" in
+ match fst style with
+ | RErr | RInt _ -> pr " int r;\n"; "-1"
+ | RInt64 _ -> pr " int64_t r;\n"; "-1"
+ | RBool _ -> pr " int r;\n"; "-1"
+ | RConstString _ | RConstOptString _ ->
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ | RString _ -> pr " char *r;\n"; "NULL"
+ | RStringList _ | RHashtable _ -> pr " char **r;\n";
"NULL"
+ | RStruct (_, typ) -> pr " guestfs_int_%s *r;\n" typ;
"NULL"
+ | RStructList (_, typ) -> pr " guestfs_int_%s_list *r;\n" typ;
"NULL"
+ | RBufferOut _ ->
+ pr " size_t size;\n";
+ pr " char *r;\n";
+ "NULL" in
(match snd style with
| [] -> ()
| args ->
- pr " struct guestfs_%s_args args;\n" name;
- List.iter (
- function
- (* Note we allow the string to be writable, in order to
- * allow device name translation. This is safe because
- * we can modify the string (passed from RPC).
- *)
- | String n
- | OptString n -> pr " char *%s;\n" n
- | StringList n -> pr " char **%s;\n" n
- | Bool n -> pr " int %s;\n" n
- | Int n -> pr " int %s;\n" n
- | FileIn _ | FileOut _ -> ()
- ) args
+ pr " struct guestfs_%s_args args;\n" name;
+ List.iter (
+ function
+ (* Note we allow the string to be writable, in order to
+ * allow device name translation. This is safe because
+ * we can modify the string (passed from RPC).
+ *)
+ | String n
+ | OptString n -> pr " char *%s;\n" n
+ | StringList n -> pr " char **%s;\n" n
+ | Bool n -> pr " int %s;\n" n
+ | Int n -> pr " int %s;\n" n
+ | FileIn _ | FileOut _ -> ()
+ ) args
);
pr "\n";
(match snd style with
| [] -> ()
| args ->
- pr " memset (&args, 0, sizeof args);\n";
- pr "\n";
- pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name;
- pr " reply_with_error (\"%%s: daemon failed to decode procedure
arguments\", \"%s\");\n" name;
- pr " return;\n";
- pr " }\n";
- List.iter (
- function
- | String n -> pr " %s = args.%s;\n" n n
- | OptString n -> pr " %s = args.%s ? *args.%s : NULL;\n" n n n
- | StringList n ->
- pr " %s = realloc (args.%s.%s_val,\n" n n n;
- pr " sizeof (char *) * (args.%s.%s_len+1));\n" n n;
- pr " if (%s == NULL) {\n" n;
- pr " reply_with_perror (\"realloc\");\n";
- pr " goto done;\n";
- pr " }\n";
- pr " %s[args.%s.%s_len] = NULL;\n" n n n;
- pr " args.%s.%s_val = %s;\n" n n n;
- | Bool n -> pr " %s = args.%s;\n" n n
- | Int n -> pr " %s = args.%s;\n" n n
- | FileIn _ | FileOut _ -> ()
- ) args;
- pr "\n"
+ pr " memset (&args, 0, sizeof args);\n";
+ pr "\n";
+ pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name;
+ pr " reply_with_error (\"%%s: daemon failed to decode procedure
arguments\", \"%s\");\n" name;
+ pr " return;\n";
+ pr " }\n";
+ List.iter (
+ function
+ | String n -> pr " %s = args.%s;\n" n n
+ | OptString n -> pr " %s = args.%s ? *args.%s : NULL;\n" n n
n
+ | StringList n ->
+ pr " %s = realloc (args.%s.%s_val,\n" n n n;
+ pr " sizeof (char *) * (args.%s.%s_len+1));\n"
n n;
+ pr " if (%s == NULL) {\n" n;
+ pr " reply_with_perror (\"realloc\");\n";
+ pr " goto done;\n";
+ pr " }\n";
+ pr " %s[args.%s.%s_len] = NULL;\n" n n n;
+ pr " args.%s.%s_val = %s;\n" n n n;
+ | Bool n -> pr " %s = args.%s;\n" n n
+ | Int n -> pr " %s = args.%s;\n" n n
+ | FileIn _ | FileOut _ -> ()
+ ) args;
+ pr "\n"
);
(* Don't want to call the impl with any FileIn or FileOut
* parameters, since these go "outside" the RPC protocol.
*)
let args' =
- List.filter (function FileIn _ | FileOut _ -> false | _ -> true)
- (snd style) in
+ List.filter (function FileIn _ | FileOut _ -> false | _ -> true)
+ (snd style) in
pr " r = do_%s " name;
generate_c_call_args (fst style, args');
pr ";\n";
@@ -4732,63 +4732,63 @@ and generate_daemon_actions () =
* send its own reply.
*)
let no_reply =
- List.exists (function FileOut _ -> true | _ -> false) (snd style) in
+ List.exists (function FileOut _ -> true | _ -> false) (snd style) in
if no_reply then
- pr " /* do_%s has already sent a reply */\n" name
+ pr " /* do_%s has already sent a reply */\n" name
else (
- match fst style with
- | RErr -> pr " reply (NULL, NULL);\n"
- | RInt n | RInt64 n | RBool n ->
- pr " struct guestfs_%s_ret ret;\n" name;
- pr " ret.%s = r;\n" n;
- pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *) &ret);\n"
- name
- | RConstString _ | RConstOptString _ ->
- failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
- | RString n ->
- pr " struct guestfs_%s_ret ret;\n" name;
- pr " ret.%s = r;\n" n;
- pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *) &ret);\n"
- name;
- pr " free (r);\n"
- | RStringList n | RHashtable n ->
- pr " struct guestfs_%s_ret ret;\n" name;
- pr " ret.%s.%s_len = count_strings (r);\n" n n;
- pr " ret.%s.%s_val = r;\n" n n;
- pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *) &ret);\n"
- name;
- pr " free_strings (r);\n"
- | RStruct (n, _) ->
- pr " struct guestfs_%s_ret ret;\n" name;
- pr " ret.%s = *r;\n" n;
- pr " reply ((xdrproc_t) xdr_guestfs_%s_ret, (char *) &ret);\n"
- name;
- pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_ret, (char *) &ret);\n"
- name
- | RStructList (n, _) ->
- pr " struct guestfs_%s_ret ret;\n" name;
- pr " ret.%s = *r;\n" n;
- pr " reply ((xdrproc_t) xdr_guestfs_%s_ret, (char *) &ret);\n"
- name;
- pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_ret, (char *) &ret);\n"
- name
- | RBufferOut n ->
- pr " struct guestfs_%s_ret ret;\n" name;
- pr " ret.%s.%s_val = r;\n" n n;
- pr " ret.%s.%s_len = size;\n" n n;
- pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *) &ret);\n"
- name;
- pr " free (r);\n"
+ match fst style with
+ | RErr -> pr " reply (NULL, NULL);\n"
+ | RInt n | RInt64 n | RBool n ->
+ pr " struct guestfs_%s_ret ret;\n" name;
+ pr " ret.%s = r;\n" n;
+ pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name
+ | RConstString _ | RConstOptString _ ->
+ failwithf "RConstString|RConstOptString cannot be used by daemon
functions"
+ | RString n ->
+ pr " struct guestfs_%s_ret ret;\n" name;
+ pr " ret.%s = r;\n" n;
+ pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name;
+ pr " free (r);\n"
+ | RStringList n | RHashtable n ->
+ pr " struct guestfs_%s_ret ret;\n" name;
+ pr " ret.%s.%s_len = count_strings (r);\n" n n;
+ pr " ret.%s.%s_val = r;\n" n n;
+ pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name;
+ pr " free_strings (r);\n"
+ | RStruct (n, _) ->
+ pr " struct guestfs_%s_ret ret;\n" name;
+ pr " ret.%s = *r;\n" n;
+ pr " reply ((xdrproc_t) xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name;
+ pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name
+ | RStructList (n, _) ->
+ pr " struct guestfs_%s_ret ret;\n" name;
+ pr " ret.%s = *r;\n" n;
+ pr " reply ((xdrproc_t) xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name;
+ pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name
+ | RBufferOut n ->
+ pr " struct guestfs_%s_ret ret;\n" name;
+ pr " ret.%s.%s_val = r;\n" n n;
+ pr " ret.%s.%s_len = size;\n" n n;
+ pr " reply ((xdrproc_t) &xdr_guestfs_%s_ret, (char *)
&ret);\n"
+ name;
+ pr " free (r);\n"
);
(* Free the args. *)
(match snd style with
| [] ->
- pr "done: ;\n";
+ pr "done: ;\n";
| _ ->
- pr "done:\n";
- pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_args, (char *) &args);\n"
- name
+ pr "done:\n";
+ pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_args, (char *)
&args);\n"
+ name
);
pr "}\n\n";
@@ -4819,164 +4819,164 @@ and generate_daemon_actions () =
List.iter (
function
| typ, cols ->
- pr "static const char *lvm_%s_cols = \"%s\";\n"
- typ (String.concat "," (List.map fst cols));
- pr "\n";
-
- pr "static int lvm_tokenize_%s (char *str, guestfs_int_lvm_%s *r)\n" typ typ;
- pr "{\n";
- pr " char *tok, *p, *next;\n";
- pr " int i, j;\n";
- pr "\n";
- (*
- pr " fprintf (stderr, \"%%s: <<%%s>>\\n\", __func__,
str);\n";
- pr "\n";
- *)
- pr " if (!str) {\n";
- pr " fprintf (stderr, \"%%s: failed: passed a NULL string\\n\",
__func__);\n";
- pr " return -1;\n";
- pr " }\n";
- pr " if (!*str || isspace (*str)) {\n";
- pr " fprintf (stderr, \"%%s: failed: passed a empty string or one beginning
with whitespace\\n\", __func__);\n";
- pr " return -1;\n";
- pr " }\n";
- pr " tok = str;\n";
- List.iter (
- fun (name, coltype) ->
- pr " if (!tok) {\n";
- pr " fprintf (stderr, \"%%s: failed: string finished early, around
token %%s\\n\", __func__, \"%s\");\n" name;
- pr " return -1;\n";
- pr " }\n";
- pr " p = strchrnul (tok, ',');\n";
- pr " if (*p) next = p+1; else next = NULL;\n";
- pr " *p = '\\0';\n";
- (match coltype with
- | FString ->
- pr " r->%s = strdup (tok);\n" name;
- pr " if (r->%s == NULL) {\n" name;
- pr " perror (\"strdup\");\n";
- pr " return -1;\n";
- pr " }\n"
- | FUUID ->
- pr " for (i = j = 0; i < 32; ++j) {\n";
- pr " if (tok[j] == '\\0') {\n";
- pr " fprintf (stderr, \"%%s: failed to parse UUID from
'%%s'\\n\", __func__, tok);\n";
- pr " return -1;\n";
- pr " } else if (tok[j] != '-')\n";
- pr " r->%s[i++] = tok[j];\n" name;
- pr " }\n";
- | FBytes ->
- pr " if (sscanf (tok, \"%%\"SCNu64, &r->%s) != 1) {\n"
name;
- pr " fprintf (stderr, \"%%s: failed to parse size '%%s' from
token %%s\\n\", __func__, tok, \"%s\");\n" name;
- pr " return -1;\n";
- pr " }\n";
- | FInt64 ->
- pr " if (sscanf (tok, \"%%\"SCNi64, &r->%s) != 1) {\n"
name;
- pr " fprintf (stderr, \"%%s: failed to parse int '%%s' from token
%%s\\n\", __func__, tok, \"%s\");\n" name;
- pr " return -1;\n";
- pr " }\n";
- | FOptPercent ->
- pr " if (tok[0] == '\\0')\n";
- pr " r->%s = -1;\n" name;
- pr " else if (sscanf (tok, \"%%f\", &r->%s) != 1) {\n"
name;
- pr " fprintf (stderr, \"%%s: failed to parse float '%%s' from
token %%s\\n\", __func__, tok, \"%s\");\n" name;
- pr " return -1;\n";
- pr " }\n";
- | FBuffer | FInt32 | FUInt32 | FUInt64 | FChar ->
- assert false (* can never be an LVM column *)
- );
- pr " tok = next;\n";
- ) cols;
-
- pr " if (tok != NULL) {\n";
- pr " fprintf (stderr, \"%%s: failed: extra tokens at end of
string\\n\", __func__);\n";
- pr " return -1;\n";
- pr " }\n";
- pr " return 0;\n";
- pr "}\n";
- pr "\n";
-
- pr "guestfs_int_lvm_%s_list *\n" typ;
- pr "parse_command_line_%ss (void)\n" typ;
- pr "{\n";
- pr " char *out, *err;\n";
- pr " char *p, *pend;\n";
- pr " int r, i;\n";
- pr " guestfs_int_lvm_%s_list *ret;\n" typ;
- pr " void *newp;\n";
- pr "\n";
- pr " ret = malloc (sizeof *ret);\n";
- pr " if (!ret) {\n";
- pr " reply_with_perror (\"malloc\");\n";
- pr " return NULL;\n";
- pr " }\n";
- pr "\n";
- pr " ret->guestfs_int_lvm_%s_list_len = 0;\n" typ;
- pr " ret->guestfs_int_lvm_%s_list_val = NULL;\n" typ;
- pr "\n";
- pr " r = command (&out, &err,\n";
- pr " \"/sbin/lvm\", \"%ss\",\n" typ;
- pr " \"-o\", lvm_%s_cols, \"--unbuffered\",
\"--noheadings\",\n" typ;
- pr " \"--nosuffix\", \"--separator\", \",\",
\"--units\", \"b\", NULL);\n";
- pr " if (r == -1) {\n";
- pr " reply_with_error (\"%%s\", err);\n";
- pr " free (out);\n";
- pr " free (err);\n";
- pr " free (ret);\n";
- pr " return NULL;\n";
- pr " }\n";
- pr "\n";
- pr " free (err);\n";
- pr "\n";
- pr " /* Tokenize each line of the output. */\n";
- pr " p = out;\n";
- pr " i = 0;\n";
- pr " while (p) {\n";
- pr " pend = strchr (p, '\\n'); /* Get the next line of output.
*/\n";
- pr " if (pend) {\n";
- pr " *pend = '\\0';\n";
- pr " pend++;\n";
- pr " }\n";
- pr "\n";
- pr " while (*p && isspace (*p)) /* Skip any leading whitespace.
*/\n";
- pr " p++;\n";
- pr "\n";
- pr " if (!*p) { /* Empty line? Skip it. */\n";
- pr " p = pend;\n";
- pr " continue;\n";
- pr " }\n";
- pr "\n";
- pr " /* Allocate some space to store this next entry. */\n";
- pr " newp = realloc (ret->guestfs_int_lvm_%s_list_val,\n" typ;
- pr " sizeof (guestfs_int_lvm_%s) * (i+1));\n" typ;
- pr " if (newp == NULL) {\n";
- pr " reply_with_perror (\"realloc\");\n";
- pr " free (ret->guestfs_int_lvm_%s_list_val);\n" typ;
- pr " free (ret);\n";
- pr " free (out);\n";
- pr " return NULL;\n";
- pr " }\n";
- pr " ret->guestfs_int_lvm_%s_list_val = newp;\n" typ;
- pr "\n";
- pr " /* Tokenize the next entry. */\n";
- pr " r = lvm_tokenize_%s (p,
&ret->guestfs_int_lvm_%s_list_val[i]);\n" typ typ;
- pr " if (r == -1) {\n";
- pr " reply_with_error (\"failed to parse output of '%ss'
command\");\n" typ;
+ pr "static const char *lvm_%s_cols = \"%s\";\n"
+ typ (String.concat "," (List.map fst cols));
+ pr "\n";
+
+ pr "static int lvm_tokenize_%s (char *str, guestfs_int_lvm_%s *r)\n"
typ typ;
+ pr "{\n";
+ pr " char *tok, *p, *next;\n";
+ pr " int i, j;\n";
+ pr "\n";
+ (*
+ pr " fprintf (stderr, \"%%s: <<%%s>>\\n\",
__func__, str);\n";
+ pr "\n";
+ *)
+ pr " if (!str) {\n";
+ pr " fprintf (stderr, \"%%s: failed: passed a NULL string\\n\",
__func__);\n";
+ pr " return -1;\n";
+ pr " }\n";
+ pr " if (!*str || isspace (*str)) {\n";
+ pr " fprintf (stderr, \"%%s: failed: passed a empty string or one
beginning with whitespace\\n\", __func__);\n";
+ pr " return -1;\n";
+ pr " }\n";
+ pr " tok = str;\n";
+ List.iter (
+ fun (name, coltype) ->
+ pr " if (!tok) {\n";
+ pr " fprintf (stderr, \"%%s: failed: string finished early,
around token %%s\\n\", __func__, \"%s\");\n" name;
+ pr " return -1;\n";
+ pr " }\n";
+ pr " p = strchrnul (tok, ',');\n";
+ pr " if (*p) next = p+1; else next = NULL;\n";
+ pr " *p = '\\0';\n";
+ (match coltype with
+ | FString ->
+ pr " r->%s = strdup (tok);\n" name;
+ pr " if (r->%s == NULL) {\n" name;
+ pr " perror (\"strdup\");\n";
+ pr " return -1;\n";
+ pr " }\n"
+ | FUUID ->
+ pr " for (i = j = 0; i < 32; ++j) {\n";
+ pr " if (tok[j] == '\\0') {\n";
+ pr " fprintf (stderr, \"%%s: failed to parse UUID from
'%%s'\\n\", __func__, tok);\n";
+ pr " return -1;\n";
+ pr " } else if (tok[j] != '-')\n";
+ pr " r->%s[i++] = tok[j];\n" name;
+ pr " }\n";
+ | FBytes ->
+ pr " if (sscanf (tok, \"%%\"SCNu64, &r->%s) != 1)
{\n" name;
+ pr " fprintf (stderr, \"%%s: failed to parse size
'%%s' from token %%s\\n\", __func__, tok, \"%s\");\n" name;
+ pr " return -1;\n";
+ pr " }\n";
+ | FInt64 ->
+ pr " if (sscanf (tok, \"%%\"SCNi64, &r->%s) != 1)
{\n" name;
+ pr " fprintf (stderr, \"%%s: failed to parse int
'%%s' from token %%s\\n\", __func__, tok, \"%s\");\n" name;
+ pr " return -1;\n";
+ pr " }\n";
+ | FOptPercent ->
+ pr " if (tok[0] == '\\0')\n";
+ pr " r->%s = -1;\n" name;
+ pr " else if (sscanf (tok, \"%%f\", &r->%s) != 1)
{\n" name;
+ pr " fprintf (stderr, \"%%s: failed to parse float
'%%s' from token %%s\\n\", __func__, tok, \"%s\");\n" name;
+ pr " return -1;\n";
+ pr " }\n";
+ | FBuffer | FInt32 | FUInt32 | FUInt64 | FChar ->
+ assert false (* can never be an LVM column *)
+ );
+ pr " tok = next;\n";
+ ) cols;
+
+ pr " if (tok != NULL) {\n";
+ pr " fprintf (stderr, \"%%s: failed: extra tokens at end of
string\\n\", __func__);\n";
+ pr " return -1;\n";
+ pr " }\n";
+ pr " return 0;\n";
+ pr "}\n";
+ pr "\n";
+
+ pr "guestfs_int_lvm_%s_list *\n" typ;
+ pr "parse_command_line_%ss (void)\n" typ;
+ pr "{\n";
+ pr " char *out, *err;\n";
+ pr " char *p, *pend;\n";
+ pr " int r, i;\n";
+ pr " guestfs_int_lvm_%s_list *ret;\n" typ;
+ pr " void *newp;\n";
+ pr "\n";
+ pr " ret = malloc (sizeof *ret);\n";
+ pr " if (!ret) {\n";
+ pr " reply_with_perror (\"malloc\");\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr "\n";
+ pr " ret->guestfs_int_lvm_%s_list_len = 0;\n" typ;
+ pr " ret->guestfs_int_lvm_%s_list_val = NULL;\n" typ;
+ pr "\n";
+ pr " r = command (&out, &err,\n";
+ pr " \"/sbin/lvm\", \"%ss\",\n" typ;
+ pr " \"-o\", lvm_%s_cols, \"--unbuffered\",
\"--noheadings\",\n" typ;
+ pr " \"--nosuffix\", \"--separator\",
\",\", \"--units\", \"b\", NULL);\n";
+ pr " if (r == -1) {\n";
+ pr " reply_with_error (\"%%s\", err);\n";
+ pr " free (out);\n";
+ pr " free (err);\n";
+ pr " free (ret);\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr "\n";
+ pr " free (err);\n";
+ pr "\n";
+ pr " /* Tokenize each line of the output. */\n";
+ pr " p = out;\n";
+ pr " i = 0;\n";
+ pr " while (p) {\n";
+ pr " pend = strchr (p, '\\n'); /* Get the next line of output.
*/\n";
+ pr " if (pend) {\n";
+ pr " *pend = '\\0';\n";
+ pr " pend++;\n";
+ pr " }\n";
+ pr "\n";
+ pr " while (*p && isspace (*p)) /* Skip any leading whitespace.
*/\n";
+ pr " p++;\n";
+ pr "\n";
+ pr " if (!*p) { /* Empty line? Skip it. */\n";
+ pr " p = pend;\n";
+ pr " continue;\n";
+ pr " }\n";
+ pr "\n";
+ pr " /* Allocate some space to store this next entry. */\n";
+ pr " newp = realloc (ret->guestfs_int_lvm_%s_list_val,\n" typ;
+ pr " sizeof (guestfs_int_lvm_%s) * (i+1));\n" typ;
+ pr " if (newp == NULL) {\n";
+ pr " reply_with_perror (\"realloc\");\n";
pr " free (ret->guestfs_int_lvm_%s_list_val);\n" typ;
pr " free (ret);\n";
- pr " free (out);\n";
- pr " return NULL;\n";
- pr " }\n";
- pr "\n";
- pr " ++i;\n";
- pr " p = pend;\n";
- pr " }\n";
- pr "\n";
- pr " ret->guestfs_int_lvm_%s_list_len = i;\n" typ;
- pr "\n";
- pr " free (out);\n";
- pr " return ret;\n";
- pr "}\n"
+ pr " free (out);\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " ret->guestfs_int_lvm_%s_list_val = newp;\n" typ;
+ pr "\n";
+ pr " /* Tokenize the next entry. */\n";
+ pr " r = lvm_tokenize_%s (p,
&ret->guestfs_int_lvm_%s_list_val[i]);\n" typ typ;
+ pr " if (r == -1) {\n";
+ pr " reply_with_error (\"failed to parse output of '%ss'
command\");\n" typ;
+ pr " free (ret->guestfs_int_lvm_%s_list_val);\n" typ;
+ pr " free (ret);\n";
+ pr " free (out);\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr "\n";
+ pr " ++i;\n";
+ pr " p = pend;\n";
+ pr " }\n";
+ pr "\n";
+ pr " ret->guestfs_int_lvm_%s_list_len = i;\n" typ;
+ pr "\n";
+ pr " free (out);\n";
+ pr " return ret;\n";
+ pr "}\n"
) ["pv", lvm_pv_cols; "vg", lvm_vg_cols; "lv",
lvm_lv_cols]
@@ -5047,9 +5047,9 @@ static void print_table (char * const * const argv)
List.iter (
fun (_, _, _, _, tests, _, _) ->
let tests = filter_map (
- function
- | (_, (Always|If _|Unless _), test) -> Some test
- | (_, Disabled, _) -> None
+ function
+ | (_, (Always|If _|Unless _), test) -> Some test
+ | (_, Disabled, _) -> None
) tests in
let seq = List.concat (List.map seq_of_test tests) in
let cmds_tested = List.map List.hd seq in
@@ -5059,7 +5059,7 @@ static void print_table (char * const * const argv)
List.iter (
fun (name, _, _, _, _, _, _) ->
if not (Hashtbl.mem hash name) then
- pr " fprintf (stderr, \"warning: \\\"guestfs_%s\\\" has no
tests\\n\");\n" name
+ pr " fprintf (stderr, \"warning: \\\"guestfs_%s\\\" has no
tests\\n\");\n" name
) all_functions;
pr "}\n";
@@ -5073,7 +5073,7 @@ static void print_table (char * const * const argv)
let test_names =
List.map (
fun (name, _, _, _, tests, _, _) ->
- mapi (generate_one_test name) tests
+ mapi (generate_one_test name) tests
) (List.rev all_functions) in
let test_names = List.concat test_names in
let nr_tests = List.length test_names in
@@ -5305,54 +5305,54 @@ static int %s (void)
and generate_one_test_body name i test_name init test =
(match init with
| InitNone (* XXX at some point, InitNone and InitEmpty became
- * folded together as the same thing. Really we should
- * make InitNone do nothing at all, but the tests may
- * need to be checked to make sure this is OK.
- *)
+ * folded together as the same thing. Really we should
+ * make InitNone do nothing at all, but the tests may
+ * need to be checked to make sure this is OK.
+ *)
| InitEmpty ->
pr " /* InitNone|InitEmpty for %s */\n" test_name;
List.iter (generate_test_command_call test_name)
- [["blockdev_setrw"; "/dev/sda"];
- ["umount_all"];
- ["lvm_remove_all"]]
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"]]
| InitBasicFS ->
pr " /* InitBasicFS for %s: create ext2 on /dev/sda1 */\n" test_name;
List.iter (generate_test_command_call test_name)
- [["blockdev_setrw"; "/dev/sda"];
- ["umount_all"];
- ["lvm_remove_all"];
- ["sfdiskM"; "/dev/sda"; ","];
- ["mkfs"; "ext2"; "/dev/sda1"];
- ["mount"; "/dev/sda1"; "/"]]
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"];
+ ["sfdiskM"; "/dev/sda"; ","];
+ ["mkfs"; "ext2"; "/dev/sda1"];
+ ["mount"; "/dev/sda1"; "/"]]
| InitBasicFSonLVM ->
pr " /* InitBasicFSonLVM for %s: create ext2 on /dev/VG/LV */\n"
- test_name;
+ test_name;
List.iter (generate_test_command_call test_name)
- [["blockdev_setrw"; "/dev/sda"];
- ["umount_all"];
- ["lvm_remove_all"];
- ["sfdiskM"; "/dev/sda"; ","];
- ["pvcreate"; "/dev/sda1"];
- ["vgcreate"; "VG"; "/dev/sda1"];
- ["lvcreate"; "LV"; "VG"; "8"];
- ["mkfs"; "ext2"; "/dev/VG/LV"];
- ["mount"; "/dev/VG/LV"; "/"]]
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"];
+ ["sfdiskM"; "/dev/sda"; ","];
+ ["pvcreate"; "/dev/sda1"];
+ ["vgcreate"; "VG"; "/dev/sda1"];
+ ["lvcreate"; "LV"; "VG"; "8"];
+ ["mkfs"; "ext2"; "/dev/VG/LV"];
+ ["mount"; "/dev/VG/LV"; "/"]]
| InitSquashFS ->
pr " /* InitSquashFS for %s */\n" test_name;
List.iter (generate_test_command_call test_name)
- [["blockdev_setrw"; "/dev/sda"];
- ["umount_all"];
- ["lvm_remove_all"];
- ["mount_vfs"; "ro"; "squashfs"; "/dev/sdd";
"/"]]
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"];
+ ["mount_vfs"; "ro"; "squashfs";
"/dev/sdd"; "/"]]
);
let get_seq_last = function
| [] ->
- failwithf "%s: you cannot use [] (empty list) when expecting a command"
- test_name
+ failwithf "%s: you cannot use [] (empty list) when expecting a
command"
+ test_name
| seq ->
- let seq = List.rev seq in
- List.rev (List.tl seq), List.hd seq
+ let seq = List.rev seq in
+ List.rev (List.tl seq), List.hd seq
in
match test with
@@ -5364,10 +5364,10 @@ and generate_one_test_body name i test_name init test =
pr " const char *expected = \"%s\";\n" (c_quote expected);
let seq, last = get_seq_last seq in
let test () =
- pr " if (strcmp (r, expected) != 0) {\n";
- pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got
\\\"%%s\\\"\\n\", expected, r);\n" test_name;
- pr " return -1;\n";
- pr " }\n"
+ pr " if (strcmp (r, expected) != 0) {\n";
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got
\\\"%%s\\\"\\n\", expected, r);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5375,27 +5375,27 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputList for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- iteri (
- fun i str ->
- pr " if (!r[%d]) {\n" i;
- pr " fprintf (stderr, \"%s: short list returned from
command\\n\");\n" test_name;
- pr " print_strings (r);\n";
- pr " return -1;\n";
- pr " }\n";
+ iteri (
+ fun i str ->
+ pr " if (!r[%d]) {\n" i;
+ pr " fprintf (stderr, \"%s: short list returned from
command\\n\");\n" test_name;
+ pr " print_strings (r);\n";
+ pr " return -1;\n";
+ pr " }\n";
pr " {\n";
pr " const char *expected = \"%s\";\n" (c_quote
str);
- pr " if (strcmp (r[%d], expected) != 0) {\n" i;
- pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got
\\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i;
- pr " return -1;\n";
- pr " }\n";
- pr " }\n"
- ) expected;
- pr " if (r[%d] != NULL) {\n" (List.length expected);
- pr " fprintf (stderr, \"%s: extra elements returned from
command\\n\");\n"
- test_name;
- pr " print_strings (r);\n";
- pr " return -1;\n";
- pr " }\n"
+ pr " if (strcmp (r[%d], expected) != 0) {\n" i;
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\"
but got \\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i;
+ pr " return -1;\n";
+ pr " }\n";
+ pr " }\n"
+ ) expected;
+ pr " if (r[%d] != NULL) {\n" (List.length expected);
+ pr " fprintf (stderr, \"%s: extra elements returned from
command\\n\");\n"
+ test_name;
+ pr " print_strings (r);\n";
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5403,28 +5403,28 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputListOfDevices for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- iteri (
- fun i str ->
- pr " if (!r[%d]) {\n" i;
- pr " fprintf (stderr, \"%s: short list returned from
command\\n\");\n" test_name;
- pr " print_strings (r);\n";
- pr " return -1;\n";
- pr " }\n";
+ iteri (
+ fun i str ->
+ pr " if (!r[%d]) {\n" i;
+ pr " fprintf (stderr, \"%s: short list returned from
command\\n\");\n" test_name;
+ pr " print_strings (r);\n";
+ pr " return -1;\n";
+ pr " }\n";
pr " {\n";
pr " const char *expected = \"%s\";\n" (c_quote
str);
- pr " r[%d][5] = 's';\n" i;
- pr " if (strcmp (r[%d], expected) != 0) {\n" i;
- pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got
\\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i;
- pr " return -1;\n";
- pr " }\n";
- pr " }\n"
- ) expected;
- pr " if (r[%d] != NULL) {\n" (List.length expected);
- pr " fprintf (stderr, \"%s: extra elements returned from
command\\n\");\n"
- test_name;
- pr " print_strings (r);\n";
- pr " return -1;\n";
- pr " }\n"
+ pr " r[%d][5] = 's';\n" i;
+ pr " if (strcmp (r[%d], expected) != 0) {\n" i;
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\"
but got \\\"%%s\\\"\\n\", expected, r[%d]);\n" test_name i;
+ pr " return -1;\n";
+ pr " }\n";
+ pr " }\n"
+ ) expected;
+ pr " if (r[%d] != NULL) {\n" (List.length expected);
+ pr " fprintf (stderr, \"%s: extra elements returned from
command\\n\");\n"
+ test_name;
+ pr " print_strings (r);\n";
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5432,12 +5432,12 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputInt for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- pr " if (r != %d) {\n" expected;
- pr " fprintf (stderr, \"%s: expected %d but got %%d\\n\","
- test_name expected;
- pr " (int) r);\n";
- pr " return -1;\n";
- pr " }\n"
+ pr " if (r != %d) {\n" expected;
+ pr " fprintf (stderr, \"%s: expected %d but got
%%d\\n\","
+ test_name expected;
+ pr " (int) r);\n";
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5445,12 +5445,12 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputIntOp for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- pr " if (! (r %s %d)) {\n" op expected;
- pr " fprintf (stderr, \"%s: expected %s %d but got %%d\\n\","
- test_name op expected;
- pr " (int) r);\n";
- pr " return -1;\n";
- pr " }\n"
+ pr " if (! (r %s %d)) {\n" op expected;
+ pr " fprintf (stderr, \"%s: expected %s %d but got
%%d\\n\","
+ test_name op expected;
+ pr " (int) r);\n";
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5458,11 +5458,11 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputTrue for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- pr " if (!r) {\n";
- pr " fprintf (stderr, \"%s: expected true, got false\\n\");\n"
- test_name;
- pr " return -1;\n";
- pr " }\n"
+ pr " if (!r) {\n";
+ pr " fprintf (stderr, \"%s: expected true, got
false\\n\");\n"
+ test_name;
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5470,11 +5470,11 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputFalse for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- pr " if (r) {\n";
- pr " fprintf (stderr, \"%s: expected false, got true\\n\");\n"
- test_name;
- pr " return -1;\n";
- pr " }\n"
+ pr " if (r) {\n";
+ pr " fprintf (stderr, \"%s: expected false, got
true\\n\");\n"
+ test_name;
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5482,20 +5482,20 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputLength for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- pr " int j;\n";
- pr " for (j = 0; j < %d; ++j)\n" expected;
- pr " if (r[j] == NULL) {\n";
- pr " fprintf (stderr, \"%s: short list returned\\n\");\n"
- test_name;
- pr " print_strings (r);\n";
- pr " return -1;\n";
- pr " }\n";
- pr " if (r[j] != NULL) {\n";
- pr " fprintf (stderr, \"%s: long list returned\\n\");\n"
- test_name;
- pr " print_strings (r);\n";
- pr " return -1;\n";
- pr " }\n"
+ pr " int j;\n";
+ pr " for (j = 0; j < %d; ++j)\n" expected;
+ pr " if (r[j] == NULL) {\n";
+ pr " fprintf (stderr, \"%s: short list
returned\\n\");\n"
+ test_name;
+ pr " print_strings (r);\n";
+ pr " return -1;\n";
+ pr " }\n";
+ pr " if (r[j] != NULL) {\n";
+ pr " fprintf (stderr, \"%s: long list
returned\\n\");\n"
+ test_name;
+ pr " print_strings (r);\n";
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5505,14 +5505,14 @@ and generate_one_test_body name i test_name init test =
let seq, last = get_seq_last seq in
let len = String.length expected in
let test () =
- pr " if (size != %d) {\n" len;
- pr " fprintf (stderr, \"%s: returned size of buffer wrong, expected %d
but got %%zu\\n\", size);\n" test_name len;
- pr " return -1;\n";
- pr " }\n";
- pr " if (strncmp (r, expected, size) != 0) {\n";
- pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got
\\\"%%s\\\"\\n\", expected, r);\n" test_name;
- pr " return -1;\n";
- pr " }\n"
+ pr " if (size != %d) {\n" len;
+ pr " fprintf (stderr, \"%s: returned size of buffer wrong,
expected %d but got %%zu\\n\", size);\n" test_name len;
+ pr " return -1;\n";
+ pr " }\n";
+ pr " if (strncmp (r, expected, size) != 0) {\n";
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got
\\\"%%s\\\"\\n\", expected, r);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n"
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5520,44 +5520,44 @@ and generate_one_test_body name i test_name init test =
pr " /* TestOutputStruct for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
let test () =
- List.iter (
- function
- | CompareWithInt (field, expected) ->
- pr " if (r->%s != %d) {\n" field expected;
- pr " fprintf (stderr, \"%s: %s was %%d, expected
%d\\n\",\n"
- test_name field expected;
- pr " (int) r->%s);\n" field;
- pr " return -1;\n";
- pr " }\n"
- | CompareWithIntOp (field, op, expected) ->
- pr " if (!(r->%s %s %d)) {\n" field op expected;
- pr " fprintf (stderr, \"%s: %s was %%d, expected %s
%d\\n\",\n"
- test_name field op expected;
- pr " (int) r->%s);\n" field;
- pr " return -1;\n";
- pr " }\n"
- | CompareWithString (field, expected) ->
- pr " if (strcmp (r->%s, \"%s\") != 0) {\n" field
expected;
- pr " fprintf (stderr, \"%s: %s was \"%%s\", expected
\"%s\"\\n\",\n"
- test_name field expected;
- pr " r->%s);\n" field;
- pr " return -1;\n";
- pr " }\n"
- | CompareFieldsIntEq (field1, field2) ->
- pr " if (r->%s != r->%s) {\n" field1 field2;
- pr " fprintf (stderr, \"%s: %s (%%d) <> %s
(%%d)\\n\",\n"
- test_name field1 field2;
- pr " (int) r->%s, (int) r->%s);\n" field1 field2;
- pr " return -1;\n";
- pr " }\n"
- | CompareFieldsStrEq (field1, field2) ->
- pr " if (strcmp (r->%s, r->%s) != 0) {\n" field1 field2;
- pr " fprintf (stderr, \"%s: %s (\"%%s\") <> %s
(\"%%s\")\\n\",\n"
- test_name field1 field2;
- pr " r->%s, r->%s);\n" field1 field2;
- pr " return -1;\n";
- pr " }\n"
- ) checks
+ List.iter (
+ function
+ | CompareWithInt (field, expected) ->
+ pr " if (r->%s != %d) {\n" field expected;
+ pr " fprintf (stderr, \"%s: %s was %%d, expected
%d\\n\",\n"
+ test_name field expected;
+ pr " (int) r->%s);\n" field;
+ pr " return -1;\n";
+ pr " }\n"
+ | CompareWithIntOp (field, op, expected) ->
+ pr " if (!(r->%s %s %d)) {\n" field op expected;
+ pr " fprintf (stderr, \"%s: %s was %%d, expected %s
%d\\n\",\n"
+ test_name field op expected;
+ pr " (int) r->%s);\n" field;
+ pr " return -1;\n";
+ pr " }\n"
+ | CompareWithString (field, expected) ->
+ pr " if (strcmp (r->%s, \"%s\") != 0) {\n" field
expected;
+ pr " fprintf (stderr, \"%s: %s was \"%%s\",
expected \"%s\"\\n\",\n"
+ test_name field expected;
+ pr " r->%s);\n" field;
+ pr " return -1;\n";
+ pr " }\n"
+ | CompareFieldsIntEq (field1, field2) ->
+ pr " if (r->%s != r->%s) {\n" field1 field2;
+ pr " fprintf (stderr, \"%s: %s (%%d) <> %s
(%%d)\\n\",\n"
+ test_name field1 field2;
+ pr " (int) r->%s, (int) r->%s);\n" field1
field2;
+ pr " return -1;\n";
+ pr " }\n"
+ | CompareFieldsStrEq (field1, field2) ->
+ pr " if (strcmp (r->%s, r->%s) != 0) {\n" field1
field2;
+ pr " fprintf (stderr, \"%s: %s (\"%%s\") <>
%s (\"%%s\")\\n\",\n"
+ test_name field1 field2;
+ pr " r->%s, r->%s);\n" field1 field2;
+ pr " return -1;\n";
+ pr " }\n"
+ ) checks
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
@@ -5576,84 +5576,84 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
| name :: args ->
(* Look up the command to find out what args/ret it has. *)
let style =
- try
- let _, style, _, _, _, _, _ =
- List.find (fun (n, _, _, _, _, _, _) -> n = name) all_functions in
- style
- with Not_found ->
- failwithf "%s: in test, command %s was not found" test_name name in
+ try
+ let _, style, _, _, _, _, _ =
+ List.find (fun (n, _, _, _, _, _, _) -> n = name) all_functions in
+ style
+ with Not_found ->
+ failwithf "%s: in test, command %s was not found" test_name name in
if List.length (snd style) <> List.length args then
- failwithf "%s: in test, wrong number of args given to %s"
- test_name name;
+ failwithf "%s: in test, wrong number of args given to %s"
+ test_name name;
pr " {\n";
List.iter (
- function
- | OptString n, "NULL" -> ()
- | String n, arg
- | OptString n, arg ->
- pr " const char *%s = \"%s\";\n" n (c_quote arg);
- | Int _, _
- | Bool _, _
- | FileIn _, _ | FileOut _, _ -> ()
- | StringList n, arg ->
- let strs = string_split " " arg in
- iteri (
- fun i str ->
+ function
+ | OptString n, "NULL" -> ()
+ | String n, arg
+ | OptString n, arg ->
+ pr " const char *%s = \"%s\";\n" n (c_quote arg);
+ | Int _, _
+ | Bool _, _
+ | FileIn _, _ | FileOut _, _ -> ()
+ | StringList n, arg ->
+ let strs = string_split " " arg in
+ iteri (
+ fun i str ->
pr " const char *%s_%d = \"%s\";\n" n i (c_quote
str);
- ) strs;
- pr " const char *%s[] = {\n" n;
- iteri (
- fun i _ -> pr " %s_%d,\n" n i
- ) strs;
- pr " NULL\n";
- pr " };\n";
+ ) strs;
+ pr " const char *%s[] = {\n" n;
+ iteri (
+ fun i _ -> pr " %s_%d,\n" n i
+ ) strs;
+ pr " NULL\n";
+ pr " };\n";
) (List.combine (snd style) args);
let error_code =
- match fst style with
- | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
- | RInt64 _ -> pr " int64_t r;\n"; "-1"
- | RConstString _ | RConstOptString _ ->
- pr " const char *r;\n"; "NULL"
- | RString _ -> pr " char *r;\n"; "NULL"
- | RStringList _ | RHashtable _ ->
- pr " char **r;\n";
- pr " int i;\n";
- "NULL"
- | RStruct (_, typ) ->
- pr " struct guestfs_%s *r;\n" typ; "NULL"
- | RStructList (_, typ) ->
- pr " struct guestfs_%s_list *r;\n" typ; "NULL"
- | RBufferOut _ ->
- pr " char *r;\n";
- pr " size_t size;\n";
- "NULL" in
+ match fst style with
+ | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
+ | RInt64 _ -> pr " int64_t r;\n"; "-1"
+ | RConstString _ | RConstOptString _ ->
+ pr " const char *r;\n"; "NULL"
+ | RString _ -> pr " char *r;\n"; "NULL"
+ | RStringList _ | RHashtable _ ->
+ pr " char **r;\n";
+ pr " int i;\n";
+ "NULL"
+ | RStruct (_, typ) ->
+ pr " struct guestfs_%s *r;\n" typ; "NULL"
+ | RStructList (_, typ) ->
+ pr " struct guestfs_%s_list *r;\n" typ; "NULL"
+ | RBufferOut _ ->
+ pr " char *r;\n";
+ pr " size_t size;\n";
+ "NULL" in
pr " suppress_error = %d;\n" (if expect_error then 1 else 0);
pr " r = guestfs_%s (g" name;
(* Generate the parameters. *)
List.iter (
- function
- | OptString _, "NULL" -> pr ", NULL"
- | String n, _
- | OptString n, _ ->
+ function
+ | OptString _, "NULL" -> pr ", NULL"
+ | String n, _
+ | OptString n, _ ->
pr ", %s" n
- | FileIn _, arg | FileOut _, arg ->
- pr ", \"%s\"" (c_quote arg)
- | StringList n, _ ->
- pr ", %s" n
- | Int _, arg ->
- let i =
- try int_of_string arg
- with Failure "int_of_string" ->
- failwithf "%s: expecting an int, but got '%s'" test_name arg in
- pr ", %d" i
- | Bool _, arg ->
- let b = bool_of_string arg in pr ", %d" (if b then 1 else 0)
+ | FileIn _, arg | FileOut _, arg ->
+ pr ", \"%s\"" (c_quote arg)
+ | StringList n, _ ->
+ pr ", %s" n
+ | Int _, arg ->
+ let i =
+ try int_of_string arg
+ with Failure "int_of_string" ->
+ failwithf "%s: expecting an int, but got '%s'"
test_name arg in
+ pr ", %d" i
+ | Bool _, arg ->
+ let b = bool_of_string arg in pr ", %d" (if b then 1 else 0)
) (List.combine (snd style) args);
(match fst style with
@@ -5664,9 +5664,9 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
pr ");\n";
if not expect_error then
- pr " if (r == %s)\n" error_code
+ pr " if (r == %s)\n" error_code
else
- pr " if (r != %s)\n" error_code;
+ pr " if (r != %s)\n" error_code;
pr " return -1;\n";
(* Insert the test code. *)
@@ -5680,13 +5680,13 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
| RConstString _ | RConstOptString _ -> ()
| RString _ | RBufferOut _ -> pr " free (r);\n"
| RStringList _ | RHashtable _ ->
- pr " for (i = 0; r[i] != NULL; ++i)\n";
- pr " free (r[i]);\n";
- pr " free (r);\n"
+ pr " for (i = 0; r[i] != NULL; ++i)\n";
+ pr " free (r[i]);\n";
+ pr " free (r);\n"
| RStruct (_, typ) ->
- pr " guestfs_free_%s (r);\n" typ
+ pr " guestfs_free_%s (r);\n" typ
| RStructList (_, typ) ->
- pr " guestfs_free_%s_list (r);\n" typ
+ pr " guestfs_free_%s_list (r);\n" typ
);
pr " }\n"
@@ -5730,7 +5730,7 @@ and generate_fish_cmds () =
fun (name, _, _, flags, _, shortdesc, _) ->
let name = replace_char name '_' '-' in
pr " printf (\"%%-20s %%s\\n\", \"%s\",
_(\"%s\"));\n"
- name shortdesc
+ name shortdesc
) all_functions_sorted;
pr " printf (\" %%s\\n\",";
pr " _(\"Use -h <cmd> / help <cmd> to show detailed help
for a command.\"));\n";
@@ -5744,52 +5744,52 @@ and generate_fish_cmds () =
fun (name, style, _, flags, _, shortdesc, longdesc) ->
let name2 = replace_char name '_' '-' in
let alias =
- try find_map (function FishAlias n -> Some n | _ -> None) flags
- with Not_found -> name in
+ try find_map (function FishAlias n -> Some n | _ -> None) flags
+ with Not_found -> name in
let longdesc = replace_str longdesc "C<guestfs_" "C<" in
let synopsis =
- match snd style with
- | [] -> name2
- | args ->
- sprintf "%s <%s>"
- name2 (String.concat "> <" (List.map name_of_argt args)) in
+ match snd style with
+ | [] -> name2
+ | args ->
+ sprintf "%s <%s>"
+ name2 (String.concat "> <" (List.map name_of_argt args))
in
let warnings =
- if List.mem ProtocolLimitWarning flags then
- ("\n\n" ^ protocol_limit_warning)
- else "" in
+ if List.mem ProtocolLimitWarning flags then
+ ("\n\n" ^ protocol_limit_warning)
+ else "" in
(* For DangerWillRobinson commands, we should probably have
* guestfish prompt before allowing you to use them (especially
* in interactive mode). XXX
*)
let warnings =
- warnings ^
- if List.mem DangerWillRobinson flags then
- ("\n\n" ^ danger_will_robinson)
- else "" in
+ warnings ^
+ if List.mem DangerWillRobinson flags then
+ ("\n\n" ^ danger_will_robinson)
+ else "" in
let warnings =
- warnings ^
- match deprecation_notice flags with
- | None -> ""
- | Some txt -> "\n\n" ^ txt in
+ warnings ^
+ match deprecation_notice flags with
+ | None -> ""
+ | Some txt -> "\n\n" ^ txt in
let describe_alias =
- if name <> alias then
- sprintf "\n\nYou can use '%s' as an alias for this command." alias
- else "" in
+ if name <> alias then
+ sprintf "\n\nYou can use '%s' as an alias for this command."
alias
+ else "" in
pr " if (";
pr "strcasecmp (cmd, \"%s\") == 0" name;
if name <> name2 then
- pr " || strcasecmp (cmd, \"%s\") == 0" name2;
+ pr " || strcasecmp (cmd, \"%s\") == 0" name2;
if name <> alias then
- pr " || strcasecmp (cmd, \"%s\") == 0" alias;
+ pr " || strcasecmp (cmd, \"%s\") == 0" alias;
pr ")\n";
pr " pod2text (\"%s\", _(\"%s\"), %S);\n"
- name2 shortdesc
- (" " ^ synopsis ^ "\n\n" ^ longdesc ^ warnings ^ describe_alias);
+ name2 shortdesc
+ (" " ^ synopsis ^ "\n\n" ^ longdesc ^ warnings ^
describe_alias);
pr " else\n"
) all_functions;
pr " display_builtin_command (cmd);\n";
@@ -5809,41 +5809,41 @@ and generate_fish_cmds () =
pr "\n"
);
List.iter (
- function
- | name, FString ->
- pr " printf (\"%%s%s: %%s\\n\", indent, %s->%s);\n" name typ
name
- | name, FUUID ->
- pr " printf (\"%s: \");\n" name;
- pr " for (i = 0; i < 32; ++i)\n";
- pr " printf (\"%%s%%c\", indent, %s->%s[i]);\n" typ name;
- pr " printf (\"\\n\");\n"
- | name, FBuffer ->
- pr " printf (\"%%s%s: \", indent);\n" name;
- pr " for (i = 0; i < %s->%s_len; ++i)\n" typ name;
- pr " if (isprint (%s->%s[i]))\n" typ name;
- pr " printf (\"%%s%%c\", indent, %s->%s[i]);\n" typ
name;
- pr " else\n";
- pr " printf (\"%%s\\\\x%%02x\", indent, %s->%s[i]);\n"
typ name;
- pr " printf (\"\\n\");\n"
- | name, (FUInt64|FBytes) ->
- pr " printf (\"%%s%s: %%\" PRIu64 \"\\n\", indent,
%s->%s);\n"
- name typ name
- | name, FInt64 ->
- pr " printf (\"%%s%s: %%\" PRIi64 \"\\n\", indent,
%s->%s);\n"
- name typ name
- | name, FUInt32 ->
- pr " printf (\"%%s%s: %%\" PRIu32 \"\\n\", indent,
%s->%s);\n"
- name typ name
- | name, FInt32 ->
- pr " printf (\"%%s%s: %%\" PRIi32 \"\\n\", indent,
%s->%s);\n"
- name typ name
- | name, FChar ->
- pr " printf (\"%%s%s: %%c\\n\", indent, %s->%s);\n"
- name typ name
- | name, FOptPercent ->
- pr " if (%s->%s >= 0) printf (\"%%s%s: %%g %%%%\\n\", indent,
%s->%s);\n"
- typ name name typ name;
- pr " else printf (\"%%s%s: \\n\", indent);\n" name
+ function
+ | name, FString ->
+ pr " printf (\"%%s%s: %%s\\n\", indent, %s->%s);\n"
name typ name
+ | name, FUUID ->
+ pr " printf (\"%s: \");\n" name;
+ pr " for (i = 0; i < 32; ++i)\n";
+ pr " printf (\"%%s%%c\", indent, %s->%s[i]);\n" typ
name;
+ pr " printf (\"\\n\");\n"
+ | name, FBuffer ->
+ pr " printf (\"%%s%s: \", indent);\n" name;
+ pr " for (i = 0; i < %s->%s_len; ++i)\n" typ name;
+ pr " if (isprint (%s->%s[i]))\n" typ name;
+ pr " printf (\"%%s%%c\", indent, %s->%s[i]);\n"
typ name;
+ pr " else\n";
+ pr " printf (\"%%s\\\\x%%02x\", indent,
%s->%s[i]);\n" typ name;
+ pr " printf (\"\\n\");\n"
+ | name, (FUInt64|FBytes) ->
+ pr " printf (\"%%s%s: %%\" PRIu64 \"\\n\", indent,
%s->%s);\n"
+ name typ name
+ | name, FInt64 ->
+ pr " printf (\"%%s%s: %%\" PRIi64 \"\\n\", indent,
%s->%s);\n"
+ name typ name
+ | name, FUInt32 ->
+ pr " printf (\"%%s%s: %%\" PRIu32 \"\\n\", indent,
%s->%s);\n"
+ name typ name
+ | name, FInt32 ->
+ pr " printf (\"%%s%s: %%\" PRIi32 \"\\n\", indent,
%s->%s);\n"
+ name typ name
+ | name, FChar ->
+ pr " printf (\"%%s%s: %%c\\n\", indent, %s->%s);\n"
+ name typ name
+ | name, FOptPercent ->
+ pr " if (%s->%s >= 0) printf (\"%%s%s: %%g %%%%\\n\",
indent, %s->%s);\n"
+ typ name name typ name;
+ pr " else printf (\"%%s%s: \\n\", indent);\n" name
) cols;
pr "}\n";
pr "\n";
@@ -5853,7 +5853,7 @@ and generate_fish_cmds () =
pr "}\n";
pr "\n";
pr "static void print_%s_list (struct guestfs_%s_list *%ss)\n"
- typ typ typ;
+ typ typ typ;
pr "{\n";
pr " int i;\n";
pr "\n";
@@ -5882,53 +5882,53 @@ and generate_fish_cmds () =
| RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ
| RStructList (_, typ) -> pr " struct guestfs_%s_list *r;\n" typ
| RBufferOut _ ->
- pr " char *r;\n";
- pr " size_t size;\n";
+ pr " char *r;\n";
+ pr " size_t size;\n";
);
List.iter (
- function
- | String n
- | OptString n
- | FileIn n
- | FileOut n -> pr " const char *%s;\n" n
- | StringList n -> pr " char **%s;\n" n
- | Bool n -> pr " int %s;\n" n
- | Int n -> pr " int %s;\n" n
+ function
+ | String n
+ | OptString n
+ | FileIn n
+ | FileOut n -> pr " const char *%s;\n" n
+ | StringList n -> pr " char **%s;\n" n
+ | Bool n -> pr " int %s;\n" n
+ | Int n -> pr " int %s;\n" n
) (snd style);
(* Check and convert parameters. *)
let argc_expected = List.length (snd style) in
pr " if (argc != %d) {\n" argc_expected;
pr " fprintf (stderr, _(\"%%s should have %%d parameter(s)\\n\"),
cmd, %d);\n"
- argc_expected;
+ argc_expected;
pr " fprintf (stderr, _(\"type 'help %%s' for help on
%%s\\n\"), cmd, cmd);\n";
pr " return -1;\n";
pr " }\n";
iteri (
- fun i ->
- function
- | String name -> pr " %s = argv[%d];\n" name i
- | OptString name ->
- pr " %s = strcmp (argv[%d], \"\") != 0 ? argv[%d] : NULL;\n"
- name i i
- | FileIn name ->
- pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] :
\"/dev/stdin\";\n"
- name i i
- | FileOut name ->
- pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] :
\"/dev/stdout\";\n"
- name i i
- | StringList name ->
- pr " %s = parse_string_list (argv[%d]);\n" name i
- | Bool name ->
- pr " %s = is_true (argv[%d]) ? 1 : 0;\n" name i
- | Int name ->
- pr " %s = atoi (argv[%d]);\n" name i
+ fun i ->
+ function
+ | String name -> pr " %s = argv[%d];\n" name i
+ | OptString name ->
+ pr " %s = strcmp (argv[%d], \"\") != 0 ? argv[%d] :
NULL;\n"
+ name i i
+ | FileIn name ->
+ pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] :
\"/dev/stdin\";\n"
+ name i i
+ | FileOut name ->
+ pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] :
\"/dev/stdout\";\n"
+ name i i
+ | StringList name ->
+ pr " %s = parse_string_list (argv[%d]);\n" name i
+ | Bool name ->
+ pr " %s = is_true (argv[%d]) ? 1 : 0;\n" name i
+ | Int name ->
+ pr " %s = atoi (argv[%d]);\n" name i
) (snd style);
(* Call C API function. *)
let fn =
- try find_map (function FishAction n -> Some n | _ -> None) flags
- with Not_found -> sprintf "guestfs_%s" name in
+ try find_map (function FishAction n -> Some n | _ -> None) flags
+ with Not_found -> sprintf "guestfs_%s" name in
pr " r = %s " fn;
generate_c_call_args ~handle:"g" style;
pr ";\n";
@@ -5937,54 +5937,54 @@ and generate_fish_cmds () =
(match fst style with
| RErr -> pr " return r;\n"
| RInt _ ->
- pr " if (r == -1) return -1;\n";
- pr " printf (\"%%d\\n\", r);\n";
- pr " return 0;\n"
+ pr " if (r == -1) return -1;\n";
+ pr " printf (\"%%d\\n\", r);\n";
+ pr " return 0;\n"
| RInt64 _ ->
- pr " if (r == -1) return -1;\n";
- pr " printf (\"%%\" PRIi64 \"\\n\", r);\n";
- pr " return 0;\n"
+ pr " if (r == -1) return -1;\n";
+ pr " printf (\"%%\" PRIi64 \"\\n\", r);\n";
+ pr " return 0;\n"
| RBool _ ->
- pr " if (r == -1) return -1;\n";
- pr " if (r) printf (\"true\\n\"); else printf
(\"false\\n\");\n";
- pr " return 0;\n"
+ pr " if (r == -1) return -1;\n";
+ pr " if (r) printf (\"true\\n\"); else printf
(\"false\\n\");\n";
+ pr " return 0;\n"
| RConstString _ ->
- pr " if (r == NULL) return -1;\n";
- pr " printf (\"%%s\\n\", r);\n";
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " printf (\"%%s\\n\", r);\n";
+ pr " return 0;\n"
| RConstOptString _ ->
- pr " printf (\"%%s\\n\", r ? : \"(null)\");\n";
- pr " return 0;\n"
+ pr " printf (\"%%s\\n\", r ? :
\"(null)\");\n";
+ pr " return 0;\n"
| RString _ ->
- pr " if (r == NULL) return -1;\n";
- pr " printf (\"%%s\\n\", r);\n";
- pr " free (r);\n";
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " printf (\"%%s\\n\", r);\n";
+ pr " free (r);\n";
+ pr " return 0;\n"
| RStringList _ ->
- pr " if (r == NULL) return -1;\n";
- pr " print_strings (r);\n";
- pr " free_strings (r);\n";
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " print_strings (r);\n";
+ pr " free_strings (r);\n";
+ pr " return 0;\n"
| RStruct (_, typ) ->
- pr " if (r == NULL) return -1;\n";
- pr " print_%s (r);\n" typ;
- pr " guestfs_free_%s (r);\n" typ;
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " print_%s (r);\n" typ;
+ pr " guestfs_free_%s (r);\n" typ;
+ pr " return 0;\n"
| RStructList (_, typ) ->
- pr " if (r == NULL) return -1;\n";
- pr " print_%s_list (r);\n" typ;
- pr " guestfs_free_%s_list (r);\n" typ;
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " print_%s_list (r);\n" typ;
+ pr " guestfs_free_%s_list (r);\n" typ;
+ pr " return 0;\n"
| RHashtable _ ->
- pr " if (r == NULL) return -1;\n";
- pr " print_table (r);\n";
- pr " free_strings (r);\n";
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " print_table (r);\n";
+ pr " free_strings (r);\n";
+ pr " return 0;\n"
| RBufferOut _ ->
- pr " if (r == NULL) return -1;\n";
- pr " fwrite (r, size, 1, stdout);\n";
- pr " free (r);\n";
- pr " return 0;\n"
+ pr " if (r == NULL) return -1;\n";
+ pr " fwrite (r, size, 1, stdout);\n";
+ pr " free (r);\n";
+ pr " return 0;\n"
);
pr "}\n";
pr "\n"
@@ -5997,14 +5997,14 @@ and generate_fish_cmds () =
fun (name, _, _, flags, _, _, _) ->
let name2 = replace_char name '_' '-' in
let alias =
- try find_map (function FishAlias n -> Some n | _ -> None) flags
- with Not_found -> name in
+ try find_map (function FishAlias n -> Some n | _ -> None) flags
+ with Not_found -> name in
pr " if (";
pr "strcasecmp (cmd, \"%s\") == 0" name;
if name <> name2 then
- pr " || strcasecmp (cmd, \"%s\") == 0" name2;
+ pr " || strcasecmp (cmd, \"%s\") == 0" name2;
if name <> alias then
- pr " || strcasecmp (cmd, \"%s\") == 0" alias;
+ pr " || strcasecmp (cmd, \"%s\") == 0" alias;
pr ")\n";
pr " return run_%s (cmd, argc, argv);\n" name;
pr " else\n";
@@ -6051,12 +6051,12 @@ static const char *const commands[] = {
let commands =
List.map (
fun (name, _, _, flags, _, _, _) ->
- let name2 = replace_char name '_' '-' in
- let alias =
- try find_map (function FishAlias n -> Some n | _ -> None) flags
- with Not_found -> name in
+ let name2 = replace_char name '_' '-' in
+ let alias =
+ try find_map (function FishAlias n -> Some n | _ -> None) flags
+ with Not_found -> name in
- if name <> alias then [name2; alias] else [name2]
+ if name <> alias then [name2; alias] else [name2]
) all_functions in
let commands = List.flatten commands in
@@ -6111,7 +6111,7 @@ and generate_fish_actions_pod () =
let all_functions_sorted =
List.filter (
fun (_, _, _, flags, _, _, _) ->
- not (List.mem NotInFish flags || List.mem NotInDocs flags)
+ not (List.mem NotInFish flags || List.mem NotInDocs flags)
) all_functions_sorted in
let rex = Str.regexp "C<guestfs_\\([^>]+\\)>" in
@@ -6119,47 +6119,47 @@ and generate_fish_actions_pod () =
List.iter (
fun (name, style, _, flags, _, _, longdesc) ->
let longdesc =
- Str.global_substitute rex (
- fun s ->
- let sub =
- try Str.matched_group 1 s
- with Not_found ->
- failwithf "error substituting C<guestfs_...> in longdesc of function
%s" name in
- "C<" ^ replace_char sub '_' '-' ^ ">"
- ) longdesc in
+ Str.global_substitute rex (
+ fun s ->
+ let sub =
+ try Str.matched_group 1 s
+ with Not_found ->
+ failwithf "error substituting C<guestfs_...> in longdesc of
function %s" name in
+ "C<" ^ replace_char sub '_' '-' ^
">"
+ ) longdesc in
let name = replace_char name '_' '-' in
let alias =
- try find_map (function FishAlias n -> Some n | _ -> None) flags
- with Not_found -> name in
+ try find_map (function FishAlias n -> Some n | _ -> None) flags
+ with Not_found -> name in
pr "=head2 %s" name;
if name <> alias then
- pr " | %s" alias;
+ pr " | %s" alias;
pr "\n";
pr "\n";
pr " %s" name;
List.iter (
- function
- | String n -> pr " %s" n
- | OptString n -> pr " %s" n
- | StringList n -> pr " '%s ...'" n
- | Bool _ -> pr " true|false"
- | Int n -> pr " %s" n
- | FileIn n | FileOut n -> pr " (%s|-)" n
+ function
+ | String n -> pr " %s" n
+ | OptString n -> pr " %s" n
+ | StringList n -> pr " '%s ...'" n
+ | Bool _ -> pr " true|false"
+ | Int n -> pr " %s" n
+ | FileIn n | FileOut n -> pr " (%s|-)" n
) (snd style);
pr "\n";
pr "\n";
pr "%s\n\n" longdesc;
if List.exists (function FileIn _ | FileOut _ -> true
- | _ -> false) (snd style) then
- pr "Use C<-> instead of a filename to read/write from
stdin/stdout.\n\n";
+ | _ -> false) (snd style) then
+ pr "Use C<-> instead of a filename to read/write from
stdin/stdout.\n\n";
if List.mem ProtocolLimitWarning flags then
- pr "%s\n\n" protocol_limit_warning;
+ pr "%s\n\n" protocol_limit_warning;
if List.mem DangerWillRobinson flags then
- pr "%s\n\n" danger_will_robinson;
+ pr "%s\n\n" danger_will_robinson;
match deprecation_notice flags with
| None -> ()
@@ -6200,7 +6200,7 @@ and generate_prototype ?(extern = true) ?(static = false)
?(semicolon = true)
);
let next () =
if !comma then (
- if single_line then pr ", " else pr ",\n\t\t"
+ if single_line then pr ", " else pr ",\n\t\t"
);
comma := true
in
@@ -6208,18 +6208,18 @@ and generate_prototype ?(extern = true) ?(static = false)
?(semicolon = true)
function
| String n
| OptString n ->
- next ();
- if not in_daemon then pr "const char *%s" n
- else pr "char *%s" n
+ next ();
+ if not in_daemon then pr "const char *%s" n
+ else pr "char *%s" n
| StringList n ->
- next ();
- if not in_daemon then pr "char * const* const %s" n
- else pr "char **%s" n
+ next ();
+ if not in_daemon then pr "char * const* const %s" n
+ else pr "char **%s" n
| Bool n -> next (); pr "int %s" n
| Int n -> next (); pr "int %s" n
| FileIn n
| FileOut n ->
- if not in_daemon then (next (); pr "const char *%s" n)
+ if not in_daemon then (next (); pr "const char *%s" n)
) (snd style);
if is_RBufferOut then (next (); pr "size_t *size_r");
);
@@ -6248,8 +6248,8 @@ and generate_c_call_args ?handle ?(decl = false) style =
if not decl then (
match fst style with
| RBufferOut _ ->
- next ();
- pr "&size"
+ next ();
+ pr "&size"
| _ -> ()
);
pr ")"
@@ -6364,45 +6364,45 @@ copy_table (char * const * argv)
List.iter (
fun (typ, cols) ->
let has_optpercent_col =
- List.exists (function (_, FOptPercent) -> true | _ -> false) cols in
+ List.exists (function (_, FOptPercent) -> true | _ -> false) cols in
pr "static CAMLprim value\n";
pr "copy_%s (const struct guestfs_%s *%s)\n" typ typ typ;
pr "{\n";
pr " CAMLparam0 ();\n";
if has_optpercent_col then
- pr " CAMLlocal3 (rv, v, v2);\n"
+ pr " CAMLlocal3 (rv, v, v2);\n"
else
- pr " CAMLlocal2 (rv, v);\n";
+ pr " CAMLlocal2 (rv, v);\n";
pr "\n";
pr " rv = caml_alloc (%d, 0);\n" (List.length cols);
iteri (
- fun i col ->
- (match col with
- | name, FString ->
- pr " v = caml_copy_string (%s->%s);\n" typ name
- | name, FBuffer ->
- pr " v = caml_alloc_string (%s->%s_len);\n" typ name;
- pr " memcpy (String_val (v), %s->%s, %s->%s_len);\n"
- typ name typ name
- | name, FUUID ->
- pr " v = caml_alloc_string (32);\n";
- pr " memcpy (String_val (v), %s->%s, 32);\n" typ name
- | name, (FBytes|FInt64|FUInt64) ->
- pr " v = caml_copy_int64 (%s->%s);\n" typ name
- | name, (FInt32|FUInt32) ->
- pr " v = caml_copy_int32 (%s->%s);\n" typ name
- | name, FOptPercent ->
- pr " if (%s->%s >= 0) { /* Some %s */\n" typ name name;
- pr " v2 = caml_copy_double (%s->%s);\n" typ name;
- pr " v = caml_alloc (1, 0);\n";
- pr " Store_field (v, 0, v2);\n";
- pr " } else /* None */\n";
- pr " v = Val_int (0);\n";
- | name, FChar ->
- pr " v = Val_int (%s->%s);\n" typ name
- );
- pr " Store_field (rv, %d, v);\n" i
+ fun i col ->
+ (match col with
+ | name, FString ->
+ pr " v = caml_copy_string (%s->%s);\n" typ name
+ | name, FBuffer ->
+ pr " v = caml_alloc_string (%s->%s_len);\n" typ name;
+ pr " memcpy (String_val (v), %s->%s, %s->%s_len);\n"
+ typ name typ name
+ | name, FUUID ->
+ pr " v = caml_alloc_string (32);\n";
+ pr " memcpy (String_val (v), %s->%s, 32);\n" typ name
+ | name, (FBytes|FInt64|FUInt64) ->
+ pr " v = caml_copy_int64 (%s->%s);\n" typ name
+ | name, (FInt32|FUInt32) ->
+ pr " v = caml_copy_int32 (%s->%s);\n" typ name
+ | name, FOptPercent ->
+ pr " if (%s->%s >= 0) { /* Some %s */\n" typ name name;
+ pr " v2 = caml_copy_double (%s->%s);\n" typ name;
+ pr " v = caml_alloc (1, 0);\n";
+ pr " Store_field (v, 0, v2);\n";
+ pr " } else /* None */\n";
+ pr " v = Val_int (0);\n";
+ | name, FChar ->
+ pr " v = Val_int (%s->%s);\n" typ name
+ );
+ pr " Store_field (rv, %d, v);\n" i
) cols;
pr " CAMLreturn (rv);\n";
pr "}\n";
@@ -6410,7 +6410,7 @@ copy_table (char * const * argv)
pr "static CAMLprim value\n";
pr "copy_%s_list (const struct guestfs_%s_list *%ss)\n"
- typ typ typ;
+ typ typ typ;
pr "{\n";
pr " CAMLparam0 ();\n";
pr " CAMLlocal2 (rv, v);\n";
@@ -6434,10 +6434,10 @@ copy_table (char * const * argv)
List.iter (
fun (name, style, _, _, _, _, _) ->
let params =
- "gv" :: List.map (fun arg -> name_of_argt arg ^ "v") (snd style)
in
+ "gv" :: List.map (fun arg -> name_of_argt arg ^ "v") (snd
style) in
let needs_extra_vs =
- match fst style with RConstOptString _ -> true | _ -> false in
+ match fst style with RConstOptString _ -> true | _ -> false in
pr "CAMLprim value\n";
pr "ocaml_guestfs_%s (value %s" name (List.hd params);
@@ -6447,18 +6447,18 @@ copy_table (char * const * argv)
(match params with
| [p1; p2; p3; p4; p5] ->
- pr " CAMLparam5 (%s);\n" (String.concat ", " params)
+ pr " CAMLparam5 (%s);\n" (String.concat ", " params)
| p1 :: p2 :: p3 :: p4 :: p5 :: rest ->
- pr " CAMLparam5 (%s);\n" (String.concat ", " [p1; p2; p3; p4;
p5]);
- pr " CAMLxparam%d (%s);\n"
- (List.length rest) (String.concat ", " rest)
+ pr " CAMLparam5 (%s);\n" (String.concat ", " [p1; p2; p3;
p4; p5]);
+ pr " CAMLxparam%d (%s);\n"
+ (List.length rest) (String.concat ", " rest)
| ps ->
- pr " CAMLparam%d (%s);\n" (List.length ps) (String.concat ", "
ps)
+ pr " CAMLparam%d (%s);\n" (List.length ps) (String.concat ",
" ps)
);
if not needs_extra_vs then
- pr " CAMLlocal1 (rv);\n"
+ pr " CAMLlocal1 (rv);\n"
else
- pr " CAMLlocal3 (rv, v, v2);\n";
+ pr " CAMLlocal3 (rv, v, v2);\n";
pr "\n";
pr " guestfs_h *g = Guestfs_val (gv);\n";
@@ -6467,47 +6467,47 @@ copy_table (char * const * argv)
pr "\n";
List.iter (
- function
- | String n
- | FileIn n
- | FileOut n ->
- pr " const char *%s = String_val (%sv);\n" n n
- | OptString n ->
- pr " const char *%s =\n" n;
- pr " %sv != Val_int (0) ? String_val (Field (%sv, 0)) : NULL;\n"
- n n
- | StringList n ->
- pr " char **%s = ocaml_guestfs_strings_val (g, %sv);\n" n n
- | Bool n ->
- pr " int %s = Bool_val (%sv);\n" n n
- | Int n ->
- pr " int %s = Int_val (%sv);\n" n n
+ function
+ | String n
+ | FileIn n
+ | FileOut n ->
+ pr " const char *%s = String_val (%sv);\n" n n
+ | OptString n ->
+ pr " const char *%s =\n" n;
+ pr " %sv != Val_int (0) ? String_val (Field (%sv, 0)) :
NULL;\n"
+ n n
+ | StringList n ->
+ pr " char **%s = ocaml_guestfs_strings_val (g, %sv);\n" n n
+ | Bool n ->
+ pr " int %s = Bool_val (%sv);\n" n n
+ | Int n ->
+ pr " int %s = Int_val (%sv);\n" n n
) (snd style);
let error_code =
- match fst style with
- | RErr -> pr " int r;\n"; "-1"
- | RInt _ -> pr " int r;\n"; "-1"
- | RInt64 _ -> pr " int64_t r;\n"; "-1"
- | RBool _ -> pr " int r;\n"; "-1"
- | RConstString _ | RConstOptString _ ->
- pr " const char *r;\n"; "NULL"
- | RString _ -> pr " char *r;\n"; "NULL"
- | RStringList _ ->
- pr " int i;\n";
- pr " char **r;\n";
- "NULL"
- | RStruct (_, typ) ->
- pr " struct guestfs_%s *r;\n" typ; "NULL"
- | RStructList (_, typ) ->
- pr " struct guestfs_%s_list *r;\n" typ; "NULL"
- | RHashtable _ ->
- pr " int i;\n";
- pr " char **r;\n";
- "NULL"
- | RBufferOut _ ->
- pr " char *r;\n";
- pr " size_t size;\n";
- "NULL" in
+ match fst style with
+ | RErr -> pr " int r;\n"; "-1"
+ | RInt _ -> pr " int r;\n"; "-1"
+ | RInt64 _ -> pr " int64_t r;\n"; "-1"
+ | RBool _ -> pr " int r;\n"; "-1"
+ | RConstString _ | RConstOptString _ ->
+ pr " const char *r;\n"; "NULL"
+ | RString _ -> pr " char *r;\n"; "NULL"
+ | RStringList _ ->
+ pr " int i;\n";
+ pr " char **r;\n";
+ "NULL"
+ | RStruct (_, typ) ->
+ pr " struct guestfs_%s *r;\n" typ; "NULL"
+ | RStructList (_, typ) ->
+ pr " struct guestfs_%s_list *r;\n" typ; "NULL"
+ | RHashtable _ ->
+ pr " int i;\n";
+ pr " char **r;\n";
+ "NULL"
+ | RBufferOut _ ->
+ pr " char *r;\n";
+ pr " size_t size;\n";
+ "NULL" in
pr "\n";
pr " caml_enter_blocking_section ();\n";
@@ -6517,10 +6517,10 @@ copy_table (char * const * argv)
pr " caml_leave_blocking_section ();\n";
List.iter (
- function
- | StringList n ->
- pr " ocaml_guestfs_free_strings (%s);\n" n;
- | String _ | OptString _ | Bool _ | Int _ | FileIn _ | FileOut _ -> ()
+ function
+ | StringList n ->
+ pr " ocaml_guestfs_free_strings (%s);\n" n;
+ | String _ | OptString _ | Bool _ | Int _ | FileIn _ | FileOut _ -> ()
) (snd style);
pr " if (r == %s)\n" error_code;
@@ -6531,37 +6531,37 @@ copy_table (char * const * argv)
| RErr -> pr " rv = Val_unit;\n"
| RInt _ -> pr " rv = Val_int (r);\n"
| RInt64 _ ->
- pr " rv = caml_copy_int64 (r);\n"
+ pr " rv = caml_copy_int64 (r);\n"
| RBool _ -> pr " rv = Val_bool (r);\n"
| RConstString _ ->
- pr " rv = caml_copy_string (r);\n"
+ pr " rv = caml_copy_string (r);\n"
| RConstOptString _ ->
- pr " if (r) { /* Some string */\n";
- pr " v = caml_alloc (1, 0);\n";
- pr " v2 = caml_copy_string (r);\n";
- pr " Store_field (v, 0, v2);\n";
- pr " } else /* None */\n";
- pr " v = Val_int (0);\n";
+ pr " if (r) { /* Some string */\n";
+ pr " v = caml_alloc (1, 0);\n";
+ pr " v2 = caml_copy_string (r);\n";
+ pr " Store_field (v, 0, v2);\n";
+ pr " } else /* None */\n";
+ pr " v = Val_int (0);\n";
| RString _ ->
- pr " rv = caml_copy_string (r);\n";
- pr " free (r);\n"
+ pr " rv = caml_copy_string (r);\n";
+ pr " free (r);\n"
| RStringList _ ->
- pr " rv = caml_copy_string_array ((const char **) r);\n";
- pr " for (i = 0; r[i] != NULL; ++i) free (r[i]);\n";
- pr " free (r);\n"
+ pr " rv = caml_copy_string_array ((const char **) r);\n";
+ pr " for (i = 0; r[i] != NULL; ++i) free (r[i]);\n";
+ pr " free (r);\n"
| RStruct (_, typ) ->
- pr " rv = copy_%s (r);\n" typ;
- pr " guestfs_free_%s (r);\n" typ;
+ pr " rv = copy_%s (r);\n" typ;
+ pr " guestfs_free_%s (r);\n" typ;
| RStructList (_, typ) ->
- pr " rv = copy_%s_list (r);\n" typ;
- pr " guestfs_free_%s_list (r);\n" typ;
+ pr " rv = copy_%s_list (r);\n" typ;
+ pr " guestfs_free_%s_list (r);\n" typ;
| RHashtable _ ->
- pr " rv = copy_table (r);\n";
- pr " for (i = 0; r[i] != NULL; ++i) free (r[i]);\n";
- pr " free (r);\n";
+ pr " rv = copy_table (r);\n";
+ pr " for (i = 0; r[i] != NULL; ++i) free (r[i]);\n";
+ pr " free (r);\n";
| RBufferOut _ ->
- pr " rv = caml_alloc_string (size);\n";
- pr " memcpy (String_val (rv), r, size);\n";
+ pr " rv = caml_alloc_string (size);\n";
+ pr " memcpy (String_val (rv), r, size);\n";
);
pr " CAMLreturn (rv);\n";
@@ -6569,14 +6569,14 @@ copy_table (char * const * argv)
pr "\n";
if List.length params > 5 then (
- pr "CAMLprim value\n";
- pr "ocaml_guestfs_%s_byte (value *argv, int argn)\n" name;
- pr "{\n";
- pr " return ocaml_guestfs_%s (argv[0]" name;
- iteri (fun i _ -> pr ", argv[%d]" i) (List.tl params);
- pr ");\n";
- pr "}\n";
- pr "\n"
+ pr "CAMLprim value\n";
+ pr "ocaml_guestfs_%s_byte (value *argv, int argn)\n" name;
+ pr "{\n";
+ pr " return ocaml_guestfs_%s (argv[0]" name;
+ iteri (fun i _ -> pr ", argv[%d]" i) (List.tl params);
+ pr ");\n";
+ pr "}\n";
+ pr "\n"
)
) all_functions
@@ -6585,14 +6585,14 @@ and generate_ocaml_structure_decls () =
fun (typ, cols) ->
pr "type %s = {\n" typ;
List.iter (
- function
- | name, FString -> pr " %s : string;\n" name
- | name, FBuffer -> pr " %s : string;\n" name
- | name, FUUID -> pr " %s : string;\n" name
- | name, (FBytes|FInt64|FUInt64) -> pr " %s : int64;\n" name
- | name, (FInt32|FUInt32) -> pr " %s : int32;\n" name
- | name, FChar -> pr " %s : char;\n" name
- | name, FOptPercent -> pr " %s : float option;\n" name
+ function
+ | name, FString -> pr " %s : string;\n" name
+ | name, FBuffer -> pr " %s : string;\n" name
+ | name, FUUID -> pr " %s : string;\n" name
+ | name, (FBytes|FInt64|FUInt64) -> pr " %s : int64;\n" name
+ | name, (FInt32|FUInt32) -> pr " %s : int32;\n" name
+ | name, FChar -> pr " %s : char;\n" name
+ | name, FOptPercent -> pr " %s : float option;\n" name
) cols;
pr "}\n";
pr "\n"
@@ -6738,7 +6738,7 @@ DESTROY (g)
| RStringList _
| RStruct _ | RStructList _
| RHashtable _ ->
- pr "void\n" (* all lists returned implictly on the stack *)
+ pr "void\n" (* all lists returned implictly on the stack *)
);
(* Call and arguments. *)
pr "%s " name;
@@ -6746,148 +6746,148 @@ DESTROY (g)
pr "\n";
pr " guestfs_h *g;\n";
iteri (
- fun i ->
- function
- | String n | FileIn n | FileOut n -> pr " char *%s;\n" n
- | OptString n ->
- (*
http://www.perlmonks.org/?node_id=554277
- * Note that the implicit handle argument means we have
- * to add 1 to the ST(x) operator.
- *)
- pr " char *%s = SvOK(ST(%d)) ? SvPV_nolen(ST(%d)) : NULL;\n" n
(i+1) (i+1)
- | StringList n -> pr " char **%s;\n" n
- | Bool n -> pr " int %s;\n" n
- | Int n -> pr " int %s;\n" n
+ fun i ->
+ function
+ | String n | FileIn n | FileOut n -> pr " char *%s;\n" n
+ | OptString n ->
+ (*
http://www.perlmonks.org/?node_id=554277
+ * Note that the implicit handle argument means we have
+ * to add 1 to the ST(x) operator.
+ *)
+ pr " char *%s = SvOK(ST(%d)) ? SvPV_nolen(ST(%d)) : NULL;\n"
n (i+1) (i+1)
+ | StringList n -> pr " char **%s;\n" n
+ | Bool n -> pr " int %s;\n" n
+ | Int n -> pr " int %s;\n" n
) (snd style);
let do_cleanups () =
- List.iter (
- function
- | String _ | OptString _ | Bool _ | Int _
- | FileIn _ | FileOut _ -> ()
- | StringList n -> pr " free (%s);\n" n
- ) (snd style)
+ List.iter (
+ function
+ | String _ | OptString _ | Bool _ | Int _
+ | FileIn _ | FileOut _ -> ()
+ | StringList n -> pr " free (%s);\n" n
+ ) (snd style)
in
(* Code. *)
(match fst style with
| RErr ->
- pr "PREINIT:\n";
- pr " int r;\n";
- pr " PPCODE:\n";
- pr " r = guestfs_%s " name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (r == -1)\n";
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
+ pr "PREINIT:\n";
+ pr " int r;\n";
+ pr " PPCODE:\n";
+ pr " r = guestfs_%s " name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (r == -1)\n";
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
| RInt n
| RBool n ->
- pr "PREINIT:\n";
- pr " int %s;\n" n;
- pr " CODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == -1)\n" n;
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
- pr " RETVAL = newSViv (%s);\n" n;
- pr " OUTPUT:\n";
- pr " RETVAL\n"
+ pr "PREINIT:\n";
+ pr " int %s;\n" n;
+ pr " CODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == -1)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
+ pr " RETVAL = newSViv (%s);\n" n;
+ pr " OUTPUT:\n";
+ pr " RETVAL\n"
| RInt64 n ->
- pr "PREINIT:\n";
- pr " int64_t %s;\n" n;
- pr " CODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == -1)\n" n;
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
- pr " RETVAL = my_newSVll (%s);\n" n;
- pr " OUTPUT:\n";
- pr " RETVAL\n"
+ pr "PREINIT:\n";
+ pr " int64_t %s;\n" n;
+ pr " CODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == -1)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
+ pr " RETVAL = my_newSVll (%s);\n" n;
+ pr " OUTPUT:\n";
+ pr " RETVAL\n"
| RConstString n ->
- pr "PREINIT:\n";
- pr " const char *%s;\n" n;
- pr " CODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == NULL)\n" n;
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
- pr " RETVAL = newSVpv (%s, 0);\n" n;
- pr " OUTPUT:\n";
- pr " RETVAL\n"
+ pr "PREINIT:\n";
+ pr " const char *%s;\n" n;
+ pr " CODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == NULL)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
+ pr " RETVAL = newSVpv (%s, 0);\n" n;
+ pr " OUTPUT:\n";
+ pr " RETVAL\n"
| RConstOptString n ->
- pr "PREINIT:\n";
- pr " const char *%s;\n" n;
- pr " CODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == NULL)\n" n;
- pr " RETVAL = &PL_sv_undef;\n";
- pr " else\n";
- pr " RETVAL = newSVpv (%s, 0);\n" n;
- pr " OUTPUT:\n";
- pr " RETVAL\n"
+ pr "PREINIT:\n";
+ pr " const char *%s;\n" n;
+ pr " CODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == NULL)\n" n;
+ pr " RETVAL = &PL_sv_undef;\n";
+ pr " else\n";
+ pr " RETVAL = newSVpv (%s, 0);\n" n;
+ pr " OUTPUT:\n";
+ pr " RETVAL\n"
| RString n ->
- pr "PREINIT:\n";
- pr " char *%s;\n" n;
- pr " CODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == NULL)\n" n;
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
- pr " RETVAL = newSVpv (%s, 0);\n" n;
- pr " free (%s);\n" n;
- pr " OUTPUT:\n";
- pr " RETVAL\n"
+ pr "PREINIT:\n";
+ pr " char *%s;\n" n;
+ pr " CODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == NULL)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
+ pr " RETVAL = newSVpv (%s, 0);\n" n;
+ pr " free (%s);\n" n;
+ pr " OUTPUT:\n";
+ pr " RETVAL\n"
| RStringList n | RHashtable n ->
- pr "PREINIT:\n";
- pr " char **%s;\n" n;
- pr " int i, n;\n";
- pr " PPCODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == NULL)\n" n;
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
- pr " for (n = 0; %s[n] != NULL; ++n) /**/;\n" n;
- pr " EXTEND (SP, n);\n";
- pr " for (i = 0; i < n; ++i) {\n";
- pr " PUSHs (sv_2mortal (newSVpv (%s[i], 0)));\n" n;
- pr " free (%s[i]);\n" n;
- pr " }\n";
- pr " free (%s);\n" n;
+ pr "PREINIT:\n";
+ pr " char **%s;\n" n;
+ pr " int i, n;\n";
+ pr " PPCODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == NULL)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
+ pr " for (n = 0; %s[n] != NULL; ++n) /**/;\n" n;
+ pr " EXTEND (SP, n);\n";
+ pr " for (i = 0; i < n; ++i) {\n";
+ pr " PUSHs (sv_2mortal (newSVpv (%s[i], 0)));\n" n;
+ pr " free (%s[i]);\n" n;
+ pr " }\n";
+ pr " free (%s);\n" n;
| RStruct (n, typ) ->
- let cols = cols_of_struct typ in
- generate_perl_struct_code typ cols name style n do_cleanups
+ let cols = cols_of_struct typ in
+ generate_perl_struct_code typ cols name style n do_cleanups
| RStructList (n, typ) ->
- let cols = cols_of_struct typ in
- generate_perl_struct_list_code typ cols name style n do_cleanups
+ let cols = cols_of_struct typ in
+ generate_perl_struct_list_code typ cols name style n do_cleanups
| RBufferOut n ->
- pr "PREINIT:\n";
- pr " char *%s;\n" n;
- pr " size_t size;\n";
- pr " CODE:\n";
- pr " %s = guestfs_%s " n name;
- generate_c_call_args ~handle:"g" style;
- pr ";\n";
- do_cleanups ();
- pr " if (%s == NULL)\n" n;
- pr " croak (\"%s: %%s\", guestfs_last_error (g));\n"
name;
- pr " RETVAL = newSVpv (%s, size);\n" n;
- pr " free (%s);\n" n;
- pr " OUTPUT:\n";
- pr " RETVAL\n"
+ pr "PREINIT:\n";
+ pr " char *%s;\n" n;
+ pr " size_t size;\n";
+ pr " CODE:\n";
+ pr " %s = guestfs_%s " n name;
+ generate_c_call_args ~handle:"g" style;
+ pr ";\n";
+ do_cleanups ();
+ pr " if (%s == NULL)\n" n;
+ pr " croak (\"%s: %%s\", guestfs_last_error
(g));\n" name;
+ pr " RETVAL = newSVpv (%s, size);\n" n;
+ pr " free (%s);\n" n;
+ pr " OUTPUT:\n";
+ pr " RETVAL\n"
);
pr "\n"
@@ -6911,29 +6911,29 @@ and generate_perl_struct_list_code typ cols name style n
do_cleanups =
List.iter (
function
| name, FString ->
- pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s,
0), 0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, newSVpv
(%s->val[i].%s, 0), 0);\n"
+ name (String.length name) n name
| name, FUUID ->
- pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s,
32), 0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, newSVpv
(%s->val[i].%s, 32), 0);\n"
+ name (String.length name) n name
| name, FBuffer ->
- pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s,
%s->val[i].%s_len), 0);\n"
- name (String.length name) n name n name
+ pr " (void) hv_store (hv, \"%s\", %d, newSVpv
(%s->val[i].%s, %s->val[i].%s_len), 0);\n"
+ name (String.length name) n name n name
| name, (FBytes|FUInt64) ->
- pr " (void) hv_store (hv, \"%s\", %d, my_newSVull
(%s->val[i].%s), 0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, my_newSVull
(%s->val[i].%s), 0);\n"
+ name (String.length name) n name
| name, FInt64 ->
- pr " (void) hv_store (hv, \"%s\", %d, my_newSVll
(%s->val[i].%s), 0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, my_newSVll
(%s->val[i].%s), 0);\n"
+ name (String.length name) n name
| name, (FInt32|FUInt32) ->
- pr " (void) hv_store (hv, \"%s\", %d, newSVnv (%s->val[i].%s),
0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, newSVnv
(%s->val[i].%s), 0);\n"
+ name (String.length name) n name
| name, FChar ->
- pr " (void) hv_store (hv, \"%s\", %d, newSVpv
(&%s->val[i].%s, 1), 0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, newSVpv
(&%s->val[i].%s, 1), 0);\n"
+ name (String.length name) n name
| name, FOptPercent ->
- pr " (void) hv_store (hv, \"%s\", %d, newSVnv (%s->val[i].%s),
0);\n"
- name (String.length name) n name
+ pr " (void) hv_store (hv, \"%s\", %d, newSVnv
(%s->val[i].%s), 0);\n"
+ name (String.length name) n name
) cols;
pr " PUSHs (sv_2mortal (newRV ((SV *) hv)));\n";
pr " }\n";
@@ -6956,29 +6956,29 @@ and generate_perl_struct_code typ cols name style n do_cleanups =
match col with
| name, FString ->
- pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 0)));\n"
- n name
+ pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 0)));\n"
+ n name
| name, FBuffer ->
- pr " PUSHs (sv_2mortal (newSVpv (%s->%s, %s->%s_len)));\n"
- n name n name
+ pr " PUSHs (sv_2mortal (newSVpv (%s->%s,
%s->%s_len)));\n"
+ n name n name
| name, FUUID ->
- pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 32)));\n"
- n name
+ pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 32)));\n"
+ n name
| name, (FBytes|FUInt64) ->
- pr " PUSHs (sv_2mortal (my_newSVull (%s->%s)));\n"
- n name
+ pr " PUSHs (sv_2mortal (my_newSVull (%s->%s)));\n"
+ n name
| name, FInt64 ->
- pr " PUSHs (sv_2mortal (my_newSVll (%s->%s)));\n"
- n name
+ pr " PUSHs (sv_2mortal (my_newSVll (%s->%s)));\n"
+ n name
| name, (FInt32|FUInt32) ->
- pr " PUSHs (sv_2mortal (newSVnv (%s->%s)));\n"
- n name
+ pr " PUSHs (sv_2mortal (newSVnv (%s->%s)));\n"
+ n name
| name, FChar ->
- pr " PUSHs (sv_2mortal (newSVpv (&%s->%s, 1)));\n"
- n name
+ pr " PUSHs (sv_2mortal (newSVpv (&%s->%s, 1)));\n"
+ n name
| name, FOptPercent ->
- pr " PUSHs (sv_2mortal (newSVnv (%s->%s)));\n"
- n name
+ pr " PUSHs (sv_2mortal (newSVnv (%s->%s)));\n"
+ n name
) cols;
pr " free (%s);\n" n
@@ -7072,18 +7072,18 @@ sub new {
List.iter (
fun (name, style, _, flags, _, _, longdesc) ->
if not (List.mem NotInDocs flags) then (
- let longdesc = replace_str longdesc "C<guestfs_"
"C<$h-E<gt>" in
- pr "=item ";
- generate_perl_prototype name style;
- pr "\n\n";
- pr "%s\n\n" longdesc;
- if List.mem ProtocolLimitWarning flags then
- pr "%s\n\n" protocol_limit_warning;
- if List.mem DangerWillRobinson flags then
- pr "%s\n\n" danger_will_robinson;
- match deprecation_notice flags with
- | None -> ()
- | Some txt -> pr "%s\n\n" txt
+ let longdesc = replace_str longdesc "C<guestfs_"
"C<$h-E<gt>" in
+ pr "=item ";
+ generate_perl_prototype name style;
+ pr "\n\n";
+ pr "%s\n\n" longdesc;
+ if List.mem ProtocolLimitWarning flags then
+ pr "%s\n\n" protocol_limit_warning;
+ if List.mem DangerWillRobinson flags then
+ pr "%s\n\n" danger_will_robinson;
+ match deprecation_notice flags with
+ | None -> ()
+ | Some txt -> pr "%s\n\n" txt
)
) all_functions_sorted;
@@ -7136,9 +7136,9 @@ and generate_perl_prototype name style =
comma := true;
match arg with
| String n | OptString n | Bool n | Int n | FileIn n | FileOut n ->
- pr "$%s" n
+ pr "$%s" n
| StringList n ->
- pr "\\@%s" n
+ pr "\\@%s" n
) (snd style);
pr ");"
@@ -7293,47 +7293,47 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr "\n";
pr " dict = PyDict_New ();\n";
List.iter (
- function
- | name, FString ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyString_FromString (%s->%s));\n"
- typ name
- | name, FBuffer ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyString_FromStringAndSize (%s->%s,
%s->%s_len));\n"
- typ name typ name
- | name, FUUID ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyString_FromStringAndSize (%s->%s,
32));\n"
- typ name
- | name, (FBytes|FUInt64) ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromUnsignedLongLong (%s->%s));\n"
- typ name
- | name, FInt64 ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromLongLong (%s->%s));\n"
- typ name
- | name, FUInt32 ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromUnsignedLong (%s->%s));\n"
- typ name
- | name, FInt32 ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromLong (%s->%s));\n"
- typ name
- | name, FOptPercent ->
- pr " if (%s->%s >= 0)\n" typ name;
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyFloat_FromDouble ((double)
%s->%s));\n"
- typ name;
- pr " else {\n";
- pr " Py_INCREF (Py_None);\n";
- pr " PyDict_SetItemString (dict, \"%s\", Py_None);" name;
- pr " }\n"
- | name, FChar ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyString_FromStringAndSize (&dirent->%s,
1));\n" name
+ function
+ | name, FString ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyString_FromString (%s->%s));\n"
+ typ name
+ | name, FBuffer ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyString_FromStringAndSize (%s->%s,
%s->%s_len));\n"
+ typ name typ name
+ | name, FUUID ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyString_FromStringAndSize (%s->%s,
32));\n"
+ typ name
+ | name, (FBytes|FUInt64) ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyLong_FromUnsignedLongLong
(%s->%s));\n"
+ typ name
+ | name, FInt64 ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyLong_FromLongLong (%s->%s));\n"
+ typ name
+ | name, FUInt32 ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyLong_FromUnsignedLong
(%s->%s));\n"
+ typ name
+ | name, FInt32 ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyLong_FromLong (%s->%s));\n"
+ typ name
+ | name, FOptPercent ->
+ pr " if (%s->%s >= 0)\n" typ name;
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyFloat_FromDouble ((double)
%s->%s));\n"
+ typ name;
+ pr " else {\n";
+ pr " Py_INCREF (Py_None);\n";
+ pr " PyDict_SetItemString (dict, \"%s\", Py_None);"
name;
+ pr " }\n"
+ | name, FChar ->
+ pr " PyDict_SetItemString (dict, \"%s\",\n" name;
+ pr " PyString_FromStringAndSize
(&dirent->%s, 1));\n" name
) cols;
pr " return dict;\n";
pr "};\n";
@@ -7365,30 +7365,30 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " PyObject *py_r;\n";
let error_code =
- match fst style with
- | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
- | RInt64 _ -> pr " int64_t r;\n"; "-1"
- | RConstString _ | RConstOptString _ ->
- pr " const char *r;\n"; "NULL"
- | RString _ -> pr " char *r;\n"; "NULL"
- | RStringList _ | RHashtable _ -> pr " char **r;\n"; "NULL"
- | RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ; "NULL"
- | RStructList (_, typ) ->
- pr " struct guestfs_%s_list *r;\n" typ; "NULL"
- | RBufferOut _ ->
- pr " char *r;\n";
- pr " size_t size;\n";
- "NULL" in
+ match fst style with
+ | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
+ | RInt64 _ -> pr " int64_t r;\n"; "-1"
+ | RConstString _ | RConstOptString _ ->
+ pr " const char *r;\n"; "NULL"
+ | RString _ -> pr " char *r;\n"; "NULL"
+ | RStringList _ | RHashtable _ -> pr " char **r;\n";
"NULL"
+ | RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ;
"NULL"
+ | RStructList (_, typ) ->
+ pr " struct guestfs_%s_list *r;\n" typ; "NULL"
+ | RBufferOut _ ->
+ pr " char *r;\n";
+ pr " size_t size;\n";
+ "NULL" in
List.iter (
- function
- | String n | FileIn n | FileOut n -> pr " const char *%s;\n" n
- | OptString n -> pr " const char *%s;\n" n
- | StringList n ->
- pr " PyObject *py_%s;\n" n;
- pr " const char **%s;\n" n
- | Bool n -> pr " int %s;\n" n
- | Int n -> pr " int %s;\n" n
+ function
+ | String n | FileIn n | FileOut n -> pr " const char *%s;\n" n
+ | OptString n -> pr " const char *%s;\n" n
+ | StringList n ->
+ pr " PyObject *py_%s;\n" n;
+ pr " const char **%s;\n" n
+ | Bool n -> pr " int %s;\n" n
+ | Int n -> pr " int %s;\n" n
) (snd style);
pr "\n";
@@ -7396,22 +7396,22 @@ py_guestfs_close (PyObject *self, PyObject *args)
(* Convert the parameters. *)
pr " if (!PyArg_ParseTuple (args, (char *) \"O";
List.iter (
- function
- | String _ | FileIn _ | FileOut _ -> pr "s"
- | OptString _ -> pr "z"
- | StringList _ -> pr "O"
- | Bool _ -> pr "i" (* XXX Python has booleans? *)
- | Int _ -> pr "i"
+ function
+ | String _ | FileIn _ | FileOut _ -> pr "s"
+ | OptString _ -> pr "z"
+ | StringList _ -> pr "O"
+ | Bool _ -> pr "i" (* XXX Python has booleans? *)
+ | Int _ -> pr "i"
) (snd style);
pr ":guestfs_%s\",\n" name;
pr " &py_g";
List.iter (
- function
- | String n | FileIn n | FileOut n -> pr ", &%s" n
- | OptString n -> pr ", &%s" n
- | StringList n -> pr ", &py_%s" n
- | Bool n -> pr ", &%s" n
- | Int n -> pr ", &%s" n
+ function
+ | String n | FileIn n | FileOut n -> pr ", &%s" n
+ | OptString n -> pr ", &%s" n
+ | StringList n -> pr ", &py_%s" n
+ | Bool n -> pr ", &%s" n
+ | Int n -> pr ", &%s" n
) (snd style);
pr "))\n";
@@ -7419,11 +7419,11 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " g = get_handle (py_g);\n";
List.iter (
- function
- | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
- | StringList n ->
- pr " %s = get_string_list (py_%s);\n" n n;
- pr " if (!%s) return NULL;\n" n
+ function
+ | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
+ | StringList n ->
+ pr " %s = get_string_list (py_%s);\n" n n;
+ pr " if (!%s) return NULL;\n" n
) (snd style);
pr "\n";
@@ -7433,10 +7433,10 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr ";\n";
List.iter (
- function
- | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
- | StringList n ->
- pr " free (%s);\n" n
+ function
+ | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
+ | StringList n ->
+ pr " free (%s);\n" n
) (snd style);
pr " if (r == %s) {\n" error_code;
@@ -7447,37 +7447,37 @@ py_guestfs_close (PyObject *self, PyObject *args)
(match fst style with
| RErr ->
- pr " Py_INCREF (Py_None);\n";
- pr " py_r = Py_None;\n"
+ pr " Py_INCREF (Py_None);\n";
+ pr " py_r = Py_None;\n"
| RInt _
| RBool _ -> pr " py_r = PyInt_FromLong ((long) r);\n"
| RInt64 _ -> pr " py_r = PyLong_FromLongLong (r);\n"
| RConstString _ -> pr " py_r = PyString_FromString (r);\n"
| RConstOptString _ ->
- pr " if (r)\n";
- pr " py_r = PyString_FromString (r);\n";
- pr " else {\n";
- pr " Py_INCREF (Py_None);\n";
- pr " py_r = Py_None;\n";
- pr " }\n"
+ pr " if (r)\n";
+ pr " py_r = PyString_FromString (r);\n";
+ pr " else {\n";
+ pr " Py_INCREF (Py_None);\n";
+ pr " py_r = Py_None;\n";
+ pr " }\n"
| RString _ ->
- pr " py_r = PyString_FromString (r);\n";
- pr " free (r);\n"
+ pr " py_r = PyString_FromString (r);\n";
+ pr " free (r);\n"
| RStringList _ ->
- pr " py_r = put_string_list (r);\n";
- pr " free_strings (r);\n"
+ pr " py_r = put_string_list (r);\n";
+ pr " free_strings (r);\n"
| RStruct (_, typ) ->
- pr " py_r = put_%s (r);\n" typ;
- pr " guestfs_free_%s (r);\n" typ
+ pr " py_r = put_%s (r);\n" typ;
+ pr " guestfs_free_%s (r);\n" typ
| RStructList (_, typ) ->
- pr " py_r = put_%s_list (r);\n" typ;
- pr " guestfs_free_%s_list (r);\n" typ
+ pr " py_r = put_%s_list (r);\n" typ;
+ pr " guestfs_free_%s_list (r);\n" typ
| RHashtable n ->
- pr " py_r = put_table (r);\n";
- pr " free_strings (r);\n"
+ pr " py_r = put_table (r);\n";
+ pr " free_strings (r);\n"
| RBufferOut _ ->
- pr " py_r = PyString_FromStringAndSize (r, size);\n";
- pr " free (r);\n"
+ pr " py_r = PyString_FromStringAndSize (r, size);\n";
+ pr " free (r);\n"
);
pr " return py_r;\n";
@@ -7492,7 +7492,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
fun (name, _, _, _, _, _, _) ->
pr " { (char *) \"%s\", py_guestfs_%s, METH_VARARGS, NULL
},\n"
- name name
+ name name
) all_functions;
pr " { NULL, NULL, 0, NULL }\n";
pr "};\n";
@@ -7585,36 +7585,36 @@ class GuestFS:
pr ":\n";
if not (List.mem NotInDocs flags) then (
- let doc = replace_str longdesc "C<guestfs_" "C<g." in
- let doc =
+ let doc = replace_str longdesc "C<guestfs_" "C<g." in
+ let doc =
match fst style with
- | RErr | RInt _ | RInt64 _ | RBool _
- | RConstOptString _ | RConstString _
- | RString _ | RBufferOut _ -> doc
- | RStringList _ ->
- doc ^ "\n\nThis function returns a list of strings."
- | RStruct (_, typ) ->
- doc ^ sprintf "\n\nThis function returns a dictionary, with keys matching the
various fields in the guestfs_%s structure." typ
- | RStructList (_, typ) ->
- doc ^ sprintf "\n\nThis function returns a list of %ss. Each %s is
represented as a dictionary." typ typ
- | RHashtable _ ->
- doc ^ "\n\nThis function returns a dictionary." in
- let doc =
- if List.mem ProtocolLimitWarning flags then
- doc ^ "\n\n" ^ protocol_limit_warning
- else doc in
- let doc =
- if List.mem DangerWillRobinson flags then
- doc ^ "\n\n" ^ danger_will_robinson
- else doc in
- let doc =
- match deprecation_notice flags with
- | None -> doc
- | Some txt -> doc ^ "\n\n" ^ txt in
- let doc = pod2text ~width:60 name doc in
- let doc = List.map (fun line -> replace_str line "\\" "\\\\") doc
in
- let doc = String.concat "\n " doc in
- pr " u\"\"\"%s\"\"\"\n" doc;
+ | RErr | RInt _ | RInt64 _ | RBool _
+ | RConstOptString _ | RConstString _
+ | RString _ | RBufferOut _ -> doc
+ | RStringList _ ->
+ doc ^ "\n\nThis function returns a list of strings."
+ | RStruct (_, typ) ->
+ doc ^ sprintf "\n\nThis function returns a dictionary, with keys
matching the various fields in the guestfs_%s structure." typ
+ | RStructList (_, typ) ->
+ doc ^ sprintf "\n\nThis function returns a list of %ss. Each %s is
represented as a dictionary." typ typ
+ | RHashtable _ ->
+ doc ^ "\n\nThis function returns a dictionary." in
+ let doc =
+ if List.mem ProtocolLimitWarning flags then
+ doc ^ "\n\n" ^ protocol_limit_warning
+ else doc in
+ let doc =
+ if List.mem DangerWillRobinson flags then
+ doc ^ "\n\n" ^ danger_will_robinson
+ else doc in
+ let doc =
+ match deprecation_notice flags with
+ | None -> doc
+ | Some txt -> doc ^ "\n\n" ^ txt in
+ let doc = pod2text ~width:60 name doc in
+ let doc = List.map (fun line -> replace_str line "\\"
"\\\\") doc in
+ let doc = String.concat "\n " doc in
+ pr " u\"\"\"%s\"\"\"\n" doc;
);
pr " return libguestfsmod.%s " name;
generate_py_call_args ~handle:"self._o" (snd style);
@@ -7647,20 +7647,20 @@ and pod2text ~width name longdesc =
let rec loop i =
let line = input_line chan in
if i = 1 then (* discard the first line of output *)
- loop (i+1)
+ loop (i+1)
else (
- let line = triml line in
- lines := line :: !lines;
- loop (i+1)
+ let line = triml line in
+ lines := line :: !lines;
+ loop (i+1)
) in
let lines = try loop 1 with End_of_file -> List.rev !lines in
Unix.unlink filename;
(match Unix.close_process_in chan with
| Unix.WEXITED 0 -> ()
| Unix.WEXITED i ->
- failwithf "pod2text: process exited with non-zero status (%d)" i
+ failwithf "pod2text: process exited with non-zero status (%d)" i
| Unix.WSIGNALED i | Unix.WSTOPPED i ->
- failwithf "pod2text: process signalled or stopped by signal %d" i
+ failwithf "pod2text: process signalled or stopped by signal %d" i
);
Hashtbl.add pod2text_memo key lines;
let chan = open_out pod2text_memo_filename in
@@ -7737,55 +7737,55 @@ static VALUE ruby_guestfs_close (VALUE gv)
pr " Data_Get_Struct (gv, guestfs_h, g);\n";
pr " if (!g)\n";
pr " rb_raise (rb_eArgError, \"%%s: used handle after closing
it\", \"%s\");\n"
- name;
+ name;
pr "\n";
List.iter (
- function
- | String n | FileIn n | FileOut n ->
- pr " Check_Type (%sv, T_STRING);\n" n;
- pr " const char *%s = StringValueCStr (%sv);\n" n n;
- pr " if (!%s)\n" n;
- pr " rb_raise (rb_eTypeError, \"expected string for parameter %%s of
%%s\",\n";
- pr " \"%s\", \"%s\");\n" n name
- | OptString n ->
- pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n
n
- | StringList n ->
- pr " char **%s;\n" n;
- pr " Check_Type (%sv, T_ARRAY);\n" n;
- pr " {\n";
- pr " int i, len;\n";
- pr " len = RARRAY_LEN (%sv);\n" n;
- pr " %s = guestfs_safe_malloc (g, sizeof (char *) * (len+1));\n"
- n;
- pr " for (i = 0; i < len; ++i) {\n";
- pr " VALUE v = rb_ary_entry (%sv, i);\n" n;
- pr " %s[i] = StringValueCStr (v);\n" n;
- pr " }\n";
- pr " %s[len] = NULL;\n" n;
- pr " }\n";
- | Bool n ->
- pr " int %s = RTEST (%sv);\n" n n
- | Int n ->
- pr " int %s = NUM2INT (%sv);\n" n n
+ function
+ | String n | FileIn n | FileOut n ->
+ pr " Check_Type (%sv, T_STRING);\n" n;
+ pr " const char *%s = StringValueCStr (%sv);\n" n n;
+ pr " if (!%s)\n" n;
+ pr " rb_raise (rb_eTypeError, \"expected string for parameter
%%s of %%s\",\n";
+ pr " \"%s\", \"%s\");\n" n name
+ | OptString n ->
+ pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) :
NULL;\n" n n n
+ | StringList n ->
+ pr " char **%s;\n" n;
+ pr " Check_Type (%sv, T_ARRAY);\n" n;
+ pr " {\n";
+ pr " int i, len;\n";
+ pr " len = RARRAY_LEN (%sv);\n" n;
+ pr " %s = guestfs_safe_malloc (g, sizeof (char *) *
(len+1));\n"
+ n;
+ pr " for (i = 0; i < len; ++i) {\n";
+ pr " VALUE v = rb_ary_entry (%sv, i);\n" n;
+ pr " %s[i] = StringValueCStr (v);\n" n;
+ pr " }\n";
+ pr " %s[len] = NULL;\n" n;
+ pr " }\n";
+ | Bool n ->
+ pr " int %s = RTEST (%sv);\n" n n
+ | Int n ->
+ pr " int %s = NUM2INT (%sv);\n" n n
) (snd style);
pr "\n";
let error_code =
- match fst style with
- | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
- | RInt64 _ -> pr " int64_t r;\n"; "-1"
- | RConstString _ | RConstOptString _ ->
- pr " const char *r;\n"; "NULL"
- | RString _ -> pr " char *r;\n"; "NULL"
- | RStringList _ | RHashtable _ -> pr " char **r;\n"; "NULL"
- | RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ; "NULL"
- | RStructList (_, typ) ->
- pr " struct guestfs_%s_list *r;\n" typ; "NULL"
- | RBufferOut _ ->
- pr " char *r;\n";
- pr " size_t size;\n";
- "NULL" in
+ match fst style with
+ | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
+ | RInt64 _ -> pr " int64_t r;\n"; "-1"
+ | RConstString _ | RConstOptString _ ->
+ pr " const char *r;\n"; "NULL"
+ | RString _ -> pr " char *r;\n"; "NULL"
+ | RStringList _ | RHashtable _ -> pr " char **r;\n";
"NULL"
+ | RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ;
"NULL"
+ | RStructList (_, typ) ->
+ pr " struct guestfs_%s_list *r;\n" typ; "NULL"
+ | RBufferOut _ ->
+ pr " char *r;\n";
+ pr " size_t size;\n";
+ "NULL" in
pr "\n";
pr " r = guestfs_%s " name;
@@ -7793,10 +7793,10 @@ static VALUE ruby_guestfs_close (VALUE gv)
pr ";\n";
List.iter (
- function
- | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
- | StringList n ->
- pr " free (%s);\n" n
+ function
+ | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
+ | StringList n ->
+ pr " free (%s);\n" n
) (snd style);
pr " if (r == %s)\n" error_code;
@@ -7805,52 +7805,52 @@ static VALUE ruby_guestfs_close (VALUE gv)
(match fst style with
| RErr ->
- pr " return Qnil;\n"
+ pr " return Qnil;\n"
| RInt _ | RBool _ ->
- pr " return INT2NUM (r);\n"
+ pr " return INT2NUM (r);\n"
| RInt64 _ ->
- pr " return ULL2NUM (r);\n"
+ pr " return ULL2NUM (r);\n"
| RConstString _ ->
- pr " return rb_str_new2 (r);\n";
+ pr " return rb_str_new2 (r);\n";
| RConstOptString _ ->
- pr " if (r)\n";
- pr " return rb_str_new2 (r);\n";
- pr " else\n";
- pr " return Qnil;\n";
+ pr " if (r)\n";
+ pr " return rb_str_new2 (r);\n";
+ pr " else\n";
+ pr " return Qnil;\n";
| RString _ ->
- pr " VALUE rv = rb_str_new2 (r);\n";
- pr " free (r);\n";
- pr " return rv;\n";
+ pr " VALUE rv = rb_str_new2 (r);\n";
+ pr " free (r);\n";
+ pr " return rv;\n";
| RStringList _ ->
- pr " int i, len = 0;\n";
- pr " for (i = 0; r[i] != NULL; ++i) len++;\n";
- pr " VALUE rv = rb_ary_new2 (len);\n";
- pr " for (i = 0; r[i] != NULL; ++i) {\n";
- pr " rb_ary_push (rv, rb_str_new2 (r[i]));\n";
- pr " free (r[i]);\n";
- pr " }\n";
- pr " free (r);\n";
- pr " return rv;\n"
+ pr " int i, len = 0;\n";
+ pr " for (i = 0; r[i] != NULL; ++i) len++;\n";
+ pr " VALUE rv = rb_ary_new2 (len);\n";
+ pr " for (i = 0; r[i] != NULL; ++i) {\n";
+ pr " rb_ary_push (rv, rb_str_new2 (r[i]));\n";
+ pr " free (r[i]);\n";
+ pr " }\n";
+ pr " free (r);\n";
+ pr " return rv;\n"
| RStruct (_, typ) ->
- let cols = cols_of_struct typ in
- generate_ruby_struct_code typ cols
+ let cols = cols_of_struct typ in
+ generate_ruby_struct_code typ cols
| RStructList (_, typ) ->
- let cols = cols_of_struct typ in
- generate_ruby_struct_list_code typ cols
+ let cols = cols_of_struct typ in
+ generate_ruby_struct_list_code typ cols
| RHashtable _ ->
- pr " VALUE rv = rb_hash_new ();\n";
- pr " int i;\n";
- pr " for (i = 0; r[i] != NULL; i+=2) {\n";
- pr " rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2 (r[i+1]));\n";
- pr " free (r[i]);\n";
- pr " free (r[i+1]);\n";
- pr " }\n";
- pr " free (r);\n";
- pr " return rv;\n"
+ pr " VALUE rv = rb_hash_new ();\n";
+ pr " int i;\n";
+ pr " for (i = 0; r[i] != NULL; i+=2) {\n";
+ pr " rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2
(r[i+1]));\n";
+ pr " free (r[i]);\n";
+ pr " free (r[i+1]);\n";
+ pr " }\n";
+ pr " free (r);\n";
+ pr " return rv;\n"
| RBufferOut _ ->
- pr " VALUE rv = rb_str_new (r, size);\n";
- pr " free (r);\n";
- pr " return rv;\n";
+ pr " VALUE rv = rb_str_new (r, size);\n";
+ pr " free (r);\n";
+ pr " return rv;\n";
);
pr "}\n";
@@ -7884,23 +7884,23 @@ and generate_ruby_struct_code typ cols =
List.iter (
function
| name, FString ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new2
(r->%s));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new2
(r->%s));\n" name name
| name, FBuffer ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new (r->%s,
r->%s_len));\n" name name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new
(r->%s, r->%s_len));\n" name name name
| name, FUUID ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new (r->%s,
32));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_str_new
(r->%s, 32));\n" name name
| name, (FBytes|FUInt64) ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), ULL2NUM
(r->%s));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), ULL2NUM
(r->%s));\n" name name
| name, FInt64 ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), LL2NUM (r->%s));\n"
name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), LL2NUM
(r->%s));\n" name name
| name, FUInt32 ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), UINT2NUM
(r->%s));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), UINT2NUM
(r->%s));\n" name name
| name, FInt32 ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), INT2NUM
(r->%s));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), INT2NUM
(r->%s));\n" name name
| name, FOptPercent ->
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_dbl2big
(r->%s));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), rb_dbl2big
(r->%s));\n" name name
| name, FChar -> (* XXX wrong? *)
- pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), ULL2NUM
(r->%s));\n" name name
+ pr " rb_hash_aset (rv, rb_str_new2 (\"%s\"), ULL2NUM
(r->%s));\n" name name
) cols;
pr " guestfs_free_%s (r);\n" typ;
pr " return rv;\n"
@@ -7914,23 +7914,23 @@ and generate_ruby_struct_list_code typ cols =
List.iter (
function
| name, FString ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_str_new2
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_str_new2
(r->val[i].%s));\n" name name
| name, FBuffer ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_str_new
(r->val[i].%s, r->val[i].%s_len));\n" name name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_str_new
(r->val[i].%s, r->val[i].%s_len));\n" name name name
| name, FUUID ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_str_new
(r->val[i].%s, 32));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_str_new
(r->val[i].%s, 32));\n" name name
| name, (FBytes|FUInt64) ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), ULL2NUM
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), ULL2NUM
(r->val[i].%s));\n" name name
| name, FInt64 ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), LL2NUM
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), LL2NUM
(r->val[i].%s));\n" name name
| name, FUInt32 ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), UINT2NUM
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), UINT2NUM
(r->val[i].%s));\n" name name
| name, FInt32 ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), INT2NUM
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), INT2NUM
(r->val[i].%s));\n" name name
| name, FOptPercent ->
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_dbl2big
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), rb_dbl2big
(r->val[i].%s));\n" name name
| name, FChar -> (* XXX wrong? *)
- pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), ULL2NUM
(r->val[i].%s));\n" name name
+ pr " rb_hash_aset (hv, rb_str_new2 (\"%s\"), ULL2NUM
(r->val[i].%s));\n" name name
) cols;
pr " rb_ary_push (rv, hv);\n";
pr " }\n";
@@ -8010,41 +8010,41 @@ public class GuestFS {
List.iter (
fun (name, style, _, flags, _, shortdesc, longdesc) ->
if not (List.mem NotInDocs flags); then (
- let doc = replace_str longdesc "C<guestfs_" "C<g." in
- let doc =
- if List.mem ProtocolLimitWarning flags then
- doc ^ "\n\n" ^ protocol_limit_warning
- else doc in
- let doc =
- if List.mem DangerWillRobinson flags then
- doc ^ "\n\n" ^ danger_will_robinson
- else doc in
- let doc =
- match deprecation_notice flags with
- | None -> doc
- | Some txt -> doc ^ "\n\n" ^ txt in
- let doc = pod2text ~width:60 name doc in
- let doc = List.map ( (* RHBZ#501883 *)
- function
- | "" -> "<p>"
- | nonempty -> nonempty
- ) doc in
- let doc = String.concat "\n * " doc in
-
- pr " /**\n";
- pr " * %s\n" shortdesc;
- pr " * <p>\n";
- pr " * %s\n" doc;
- pr " * @throws LibGuestFSException\n";
- pr " */\n";
- pr " ";
+ let doc = replace_str longdesc "C<guestfs_" "C<g." in
+ let doc =
+ if List.mem ProtocolLimitWarning flags then
+ doc ^ "\n\n" ^ protocol_limit_warning
+ else doc in
+ let doc =
+ if List.mem DangerWillRobinson flags then
+ doc ^ "\n\n" ^ danger_will_robinson
+ else doc in
+ let doc =
+ match deprecation_notice flags with
+ | None -> doc
+ | Some txt -> doc ^ "\n\n" ^ txt in
+ let doc = pod2text ~width:60 name doc in
+ let doc = List.map ( (* RHBZ#501883 *)
+ function
+ | "" -> "<p>"
+ | nonempty -> nonempty
+ ) doc in
+ let doc = String.concat "\n * " doc in
+
+ pr " /**\n";
+ pr " * %s\n" shortdesc;
+ pr " * <p>\n";
+ pr " * %s\n" doc;
+ pr " * @throws LibGuestFSException\n";
+ pr " */\n";
+ pr " ";
);
generate_java_prototype ~public:true ~semicolon:false name style;
pr "\n";
pr " {\n";
pr " if (g == 0)\n";
pr " throw new LibGuestFSException (\"%s: handle is
closed\");\n"
- name;
+ name;
pr " ";
if fst style <> RErr then pr "return ";
pr "_%s " name;
@@ -8108,13 +8108,13 @@ and generate_java_prototype ?(public=false) ?(privat=false)
?(native=false)
| OptString n
| FileIn n
| FileOut n ->
- pr "String %s" n
+ pr "String %s" n
| StringList n ->
- pr "String[] %s" n
+ pr "String[] %s" n
| Bool n ->
- pr "boolean %s" n
+ pr "boolean %s" n
| Int n ->
- pr "int %s" n
+ pr "int %s" n
) (snd style);
pr ")\n";
@@ -8145,8 +8145,8 @@ public class %s {
| name, (FUInt32|FInt32) -> pr " public int %s;\n" name
| name, FChar -> pr " public char %s;\n" name
| name, FOptPercent ->
- pr " /* The next field is [0..100] or -1 meaning 'not present':
*/\n";
- pr " public float %s;\n" name
+ pr " /* The next field is [0..100] or -1 meaning 'not present':
*/\n";
+ pr " public float %s;\n" name
) cols;
pr "}\n"
@@ -8210,9 +8210,9 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
| RConstString _ | RConstOptString _ | RString _
| RBufferOut _ -> pr "jstring ";
| RStruct _ | RHashtable _ ->
- pr "jobject ";
+ pr "jobject ";
| RStringList _ | RStructList _ ->
- pr "jobjectArray ";
+ pr "jobjectArray ";
);
pr "JNICALL\n";
pr "Java_com_redhat_et_libguestfs_GuestFS_";
@@ -8220,107 +8220,107 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
pr "\n";
pr " (JNIEnv *env, jobject obj, jlong jg";
List.iter (
- function
- | String n
- | OptString n
- | FileIn n
- | FileOut n ->
- pr ", jstring j%s" n
- | StringList n ->
- pr ", jobjectArray j%s" n
- | Bool n ->
- pr ", jboolean j%s" n
- | Int n ->
- pr ", jint j%s" n
+ function
+ | String n
+ | OptString n
+ | FileIn n
+ | FileOut n ->
+ pr ", jstring j%s" n
+ | StringList n ->
+ pr ", jobjectArray j%s" n
+ | Bool n ->
+ pr ", jboolean j%s" n
+ | Int n ->
+ pr ", jint j%s" n
) (snd style);
pr ")\n";
pr "{\n";
pr " guestfs_h *g = (guestfs_h *) (long) jg;\n";
let error_code, no_ret =
- match fst style with
- | RErr -> pr " int r;\n"; "-1", ""
- | RBool _
- | RInt _ -> pr " int r;\n"; "-1", "0"
- | RInt64 _ -> pr " int64_t r;\n"; "-1", "0"
- | RConstString _ -> pr " const char *r;\n"; "NULL",
"NULL"
- | RConstOptString _ -> pr " const char *r;\n"; "NULL",
"NULL"
- | RString _ ->
- pr " jstring jr;\n";
- pr " char *r;\n"; "NULL", "NULL"
- | RStringList _ ->
- pr " jobjectArray jr;\n";
- pr " int r_len;\n";
- pr " jclass cl;\n";
- pr " jstring jstr;\n";
- pr " char **r;\n"; "NULL", "NULL"
- | RStruct (_, typ) ->
- pr " jobject jr;\n";
- pr " jclass cl;\n";
- pr " jfieldID fl;\n";
- pr " struct guestfs_%s *r;\n" typ; "NULL", "NULL"
- | RStructList (_, typ) ->
- pr " jobjectArray jr;\n";
- pr " jclass cl;\n";
- pr " jfieldID fl;\n";
- pr " jobject jfl;\n";
- pr " struct guestfs_%s_list *r;\n" typ; "NULL",
"NULL"
- | RHashtable _ -> pr " char **r;\n"; "NULL", "NULL"
- | RBufferOut _ ->
- pr " jstring jr;\n";
- pr " char *r;\n";
- pr " size_t size;\n";
- "NULL", "NULL" in
+ match fst style with
+ | RErr -> pr " int r;\n"; "-1", ""
+ | RBool _
+ | RInt _ -> pr " int r;\n"; "-1", "0"
+ | RInt64 _ -> pr " int64_t r;\n"; "-1", "0"
+ | RConstString _ -> pr " const char *r;\n"; "NULL",
"NULL"
+ | RConstOptString _ -> pr " const char *r;\n"; "NULL",
"NULL"
+ | RString _ ->
+ pr " jstring jr;\n";
+ pr " char *r;\n"; "NULL", "NULL"
+ | RStringList _ ->
+ pr " jobjectArray jr;\n";
+ pr " int r_len;\n";
+ pr " jclass cl;\n";
+ pr " jstring jstr;\n";
+ pr " char **r;\n"; "NULL", "NULL"
+ | RStruct (_, typ) ->
+ pr " jobject jr;\n";
+ pr " jclass cl;\n";
+ pr " jfieldID fl;\n";
+ pr " struct guestfs_%s *r;\n" typ; "NULL",
"NULL"
+ | RStructList (_, typ) ->
+ pr " jobjectArray jr;\n";
+ pr " jclass cl;\n";
+ pr " jfieldID fl;\n";
+ pr " jobject jfl;\n";
+ pr " struct guestfs_%s_list *r;\n" typ; "NULL",
"NULL"
+ | RHashtable _ -> pr " char **r;\n"; "NULL",
"NULL"
+ | RBufferOut _ ->
+ pr " jstring jr;\n";
+ pr " char *r;\n";
+ pr " size_t size;\n";
+ "NULL", "NULL" in
List.iter (
- function
- | String n
- | OptString n
- | FileIn n
- | FileOut n ->
- pr " const char *%s;\n" n
- | StringList n ->
- pr " int %s_len;\n" n;
- pr " const char **%s;\n" n
- | Bool n
- | Int n ->
- pr " int %s;\n" n
+ function
+ | String n
+ | OptString n
+ | FileIn n
+ | FileOut n ->
+ pr " const char *%s;\n" n
+ | StringList n ->
+ pr " int %s_len;\n" n;
+ pr " const char **%s;\n" n
+ | Bool n
+ | Int n ->
+ pr " int %s;\n" n
) (snd style);
let needs_i =
- (match fst style with
- | RStringList _ | RStructList _ -> true
- | RErr | RBool _ | RInt _ | RInt64 _ | RConstString _
- | RConstOptString _
- | RString _ | RBufferOut _ | RStruct _ | RHashtable _ -> false) ||
- List.exists (function StringList _ -> true | _ -> false) (snd style) in
+ (match fst style with
+ | RStringList _ | RStructList _ -> true
+ | RErr | RBool _ | RInt _ | RInt64 _ | RConstString _
+ | RConstOptString _
+ | RString _ | RBufferOut _ | RStruct _ | RHashtable _ -> false) ||
+ List.exists (function StringList _ -> true | _ -> false) (snd style) in
if needs_i then
- pr " int i;\n";
+ pr " int i;\n";
pr "\n";
(* Get the parameters. *)
List.iter (
- function
- | String n
- | FileIn n
- | FileOut n ->
- pr " %s = (*env)->GetStringUTFChars (env, j%s, NULL);\n" n n
- | OptString n ->
- (* This is completely undocumented, but Java null becomes
- * a NULL parameter.
- *)
- pr " %s = j%s ? (*env)->GetStringUTFChars (env, j%s, NULL) : NULL;\n"
n n n
- | StringList n ->
- pr " %s_len = (*env)->GetArrayLength (env, j%s);\n" n n;
- pr " %s = guestfs_safe_malloc (g, sizeof (char *) * (%s_len+1));\n" n n;
- pr " for (i = 0; i < %s_len; ++i) {\n" n;
- pr " jobject o = (*env)->GetObjectArrayElement (env, j%s, i);\n"
- n;
- pr " %s[i] = (*env)->GetStringUTFChars (env, o, NULL);\n" n;
- pr " }\n";
- pr " %s[%s_len] = NULL;\n" n n;
- | Bool n
- | Int n ->
- pr " %s = j%s;\n" n n
+ function
+ | String n
+ | FileIn n
+ | FileOut n ->
+ pr " %s = (*env)->GetStringUTFChars (env, j%s, NULL);\n" n n
+ | OptString n ->
+ (* This is completely undocumented, but Java null becomes
+ * a NULL parameter.
+ *)
+ pr " %s = j%s ? (*env)->GetStringUTFChars (env, j%s, NULL) :
NULL;\n" n n n
+ | StringList n ->
+ pr " %s_len = (*env)->GetArrayLength (env, j%s);\n" n n;
+ pr " %s = guestfs_safe_malloc (g, sizeof (char *) *
(%s_len+1));\n" n n;
+ pr " for (i = 0; i < %s_len; ++i) {\n" n;
+ pr " jobject o = (*env)->GetObjectArrayElement (env, j%s,
i);\n"
+ n;
+ pr " %s[i] = (*env)->GetStringUTFChars (env, o, NULL);\n" n;
+ pr " }\n";
+ pr " %s[%s_len] = NULL;\n" n n;
+ | Bool n
+ | Int n ->
+ pr " %s = j%s;\n" n n
) (snd style);
(* Make the call. *)
@@ -8330,23 +8330,23 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
(* Release the parameters. *)
List.iter (
- function
- | String n
- | FileIn n
- | FileOut n ->
- pr " (*env)->ReleaseStringUTFChars (env, j%s, %s);\n" n n
- | OptString n ->
- pr " if (j%s)\n" n;
- pr " (*env)->ReleaseStringUTFChars (env, j%s, %s);\n" n n
- | StringList n ->
- pr " for (i = 0; i < %s_len; ++i) {\n" n;
- pr " jobject o = (*env)->GetObjectArrayElement (env, j%s, i);\n"
- n;
- pr " (*env)->ReleaseStringUTFChars (env, o, %s[i]);\n" n;
- pr " }\n";
- pr " free (%s);\n" n
- | Bool n
- | Int n -> ()
+ function
+ | String n
+ | FileIn n
+ | FileOut n ->
+ pr " (*env)->ReleaseStringUTFChars (env, j%s, %s);\n" n n
+ | OptString n ->
+ pr " if (j%s)\n" n;
+ pr " (*env)->ReleaseStringUTFChars (env, j%s, %s);\n" n n
+ | StringList n ->
+ pr " for (i = 0; i < %s_len; ++i) {\n" n;
+ pr " jobject o = (*env)->GetObjectArrayElement (env, j%s,
i);\n"
+ n;
+ pr " (*env)->ReleaseStringUTFChars (env, o, %s[i]);\n" n;
+ pr " }\n";
+ pr " free (%s);\n" n
+ | Bool n
+ | Int n -> ()
) (snd style);
(* Check for errors. *)
@@ -8363,39 +8363,39 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
| RInt64 _ -> pr " return (jlong) r;\n"
| RConstString _ -> pr " return (*env)->NewStringUTF (env,
r);\n"
| RConstOptString _ ->
- pr " return (*env)->NewStringUTF (env, r); /* XXX r NULL? */\n"
+ pr " return (*env)->NewStringUTF (env, r); /* XXX r NULL? */\n"
| RString _ ->
- pr " jr = (*env)->NewStringUTF (env, r);\n";
- pr " free (r);\n";
- pr " return jr;\n"
+ pr " jr = (*env)->NewStringUTF (env, r);\n";
+ pr " free (r);\n";
+ pr " return jr;\n"
| RStringList _ ->
- pr " for (r_len = 0; r[r_len] != NULL; ++r_len) ;\n";
- pr " cl = (*env)->FindClass (env, \"java/lang/String\");\n";
- pr " jstr = (*env)->NewStringUTF (env, \"\");\n";
- pr " jr = (*env)->NewObjectArray (env, r_len, cl, jstr);\n";
- pr " for (i = 0; i < r_len; ++i) {\n";
- pr " jstr = (*env)->NewStringUTF (env, r[i]);\n";
- pr " (*env)->SetObjectArrayElement (env, jr, i, jstr);\n";
- pr " free (r[i]);\n";
- pr " }\n";
- pr " free (r);\n";
- pr " return jr;\n"
+ pr " for (r_len = 0; r[r_len] != NULL; ++r_len) ;\n";
+ pr " cl = (*env)->FindClass (env,
\"java/lang/String\");\n";
+ pr " jstr = (*env)->NewStringUTF (env, \"\");\n";
+ pr " jr = (*env)->NewObjectArray (env, r_len, cl, jstr);\n";
+ pr " for (i = 0; i < r_len; ++i) {\n";
+ pr " jstr = (*env)->NewStringUTF (env, r[i]);\n";
+ pr " (*env)->SetObjectArrayElement (env, jr, i, jstr);\n";
+ pr " free (r[i]);\n";
+ pr " }\n";
+ pr " free (r);\n";
+ pr " return jr;\n"
| RStruct (_, typ) ->
- let jtyp = java_name_of_struct typ in
- let cols = cols_of_struct typ in
- generate_java_struct_return typ jtyp cols
+ let jtyp = java_name_of_struct typ in
+ let cols = cols_of_struct typ in
+ generate_java_struct_return typ jtyp cols
| RStructList (_, typ) ->
- let jtyp = java_name_of_struct typ in
- let cols = cols_of_struct typ in
- generate_java_struct_list_return typ jtyp cols
+ let jtyp = java_name_of_struct typ in
+ let cols = cols_of_struct typ in
+ generate_java_struct_list_return typ jtyp cols
| RHashtable _ ->
- (* XXX *)
- pr " throw_exception (env, \"%s: internal error: please let us know how to
make a Java HashMap from JNI bindings!\");\n" name;
- pr " return NULL;\n"
+ (* XXX *)
+ pr " throw_exception (env, \"%s: internal error: please let us know
how to make a Java HashMap from JNI bindings!\");\n" name;
+ pr " return NULL;\n"
| RBufferOut _ ->
- pr " jr = (*env)->NewStringUTF (env, r); /* XXX size */\n";
- pr " free (r);\n";
- pr " return jr;\n"
+ pr " jr = (*env)->NewStringUTF (env, r); /* XXX size */\n";
+ pr " free (r);\n";
+ pr " return jr;\n"
);
pr "}\n";
@@ -8408,37 +8408,37 @@ and generate_java_struct_return typ jtyp cols =
List.iter (
function
| name, FString ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
- pr " (*env)->SetObjectField (env, jr, fl, (*env)->NewStringUTF (env,
r->%s));\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jr, fl, (*env)->NewStringUTF (env,
r->%s));\n" name;
| name, FUUID ->
- pr " {\n";
- pr " char s[33];\n";
- pr " memcpy (s, r->%s, 32);\n" name;
- pr " s[32] = 0;\n";
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
- pr " (*env)->SetObjectField (env, jr, fl, (*env)->NewStringUTF (env,
s));\n";
- pr " }\n";
+ pr " {\n";
+ pr " char s[33];\n";
+ pr " memcpy (s, r->%s, 32);\n" name;
+ pr " s[32] = 0;\n";
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jr, fl, (*env)->NewStringUTF
(env, s));\n";
+ pr " }\n";
| name, FBuffer ->
- pr " {\n";
- pr " int len = r->%s_len;\n" name;
- pr " char s[len+1];\n";
- pr " memcpy (s, r->%s, len);\n" name;
- pr " s[len] = 0;\n";
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
- pr " (*env)->SetObjectField (env, jr, fl, (*env)->NewStringUTF (env,
s));\n";
- pr " }\n";
+ pr " {\n";
+ pr " int len = r->%s_len;\n" name;
+ pr " char s[len+1];\n";
+ pr " memcpy (s, r->%s, len);\n" name;
+ pr " s[len] = 0;\n";
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jr, fl, (*env)->NewStringUTF
(env, s));\n";
+ pr " }\n";
| name, (FBytes|FUInt64|FInt64) ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"J\");\n" name;
- pr " (*env)->SetLongField (env, jr, fl, r->%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"J\");\n" name;
+ pr " (*env)->SetLongField (env, jr, fl, r->%s);\n" name;
| name, (FUInt32|FInt32) ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"I\");\n" name;
- pr " (*env)->SetLongField (env, jr, fl, r->%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"I\");\n" name;
+ pr " (*env)->SetLongField (env, jr, fl, r->%s);\n" name;
| name, FOptPercent ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"F\");\n" name;
- pr " (*env)->SetFloatField (env, jr, fl, r->%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"F\");\n" name;
+ pr " (*env)->SetFloatField (env, jr, fl, r->%s);\n" name;
| name, FChar ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"C\");\n" name;
- pr " (*env)->SetLongField (env, jr, fl, r->%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"C\");\n" name;
+ pr " (*env)->SetLongField (env, jr, fl, r->%s);\n" name;
) cols;
pr " free (r);\n";
pr " return jr;\n"
@@ -8451,37 +8451,37 @@ and generate_java_struct_list_return typ jtyp cols =
List.iter (
function
| name, FString ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
- pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env,
r->val[i].%s));\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF
(env, r->val[i].%s));\n" name;
| name, FUUID ->
- pr " {\n";
- pr " char s[33];\n";
- pr " memcpy (s, r->val[i].%s, 32);\n" name;
- pr " s[32] = 0;\n";
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
- pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env,
s));\n";
- pr " }\n";
+ pr " {\n";
+ pr " char s[33];\n";
+ pr " memcpy (s, r->val[i].%s, 32);\n" name;
+ pr " s[32] = 0;\n";
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF
(env, s));\n";
+ pr " }\n";
| name, FBuffer ->
- pr " {\n";
- pr " int len = r->val[i].%s_len;\n" name;
- pr " char s[len+1];\n";
- pr " memcpy (s, r->val[i].%s, len);\n" name;
- pr " s[len] = 0;\n";
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
- pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env,
s));\n";
- pr " }\n";
+ pr " {\n";
+ pr " int len = r->val[i].%s_len;\n" name;
+ pr " char s[len+1];\n";
+ pr " memcpy (s, r->val[i].%s, len);\n" name;
+ pr " s[len] = 0;\n";
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"Ljava/lang/String;\");\n" name;
+ pr " (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF
(env, s));\n";
+ pr " }\n";
| name, (FBytes|FUInt64|FInt64) ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"J\");\n" name;
- pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"J\");\n" name;
+ pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n"
name;
| name, (FUInt32|FInt32) ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"I\");\n" name;
- pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"I\");\n" name;
+ pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n"
name;
| name, FOptPercent ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"F\");\n" name;
- pr " (*env)->SetFloatField (env, jfl, fl, r->val[i].%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"F\");\n" name;
+ pr " (*env)->SetFloatField (env, jfl, fl, r->val[i].%s);\n"
name;
| name, FChar ->
- pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"C\");\n" name;
- pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n" name;
+ pr " fl = (*env)->GetFieldID (env, cl, \"%s\",
\"C\");\n" name;
+ pr " (*env)->SetLongField (env, jfl, fl, r->val[i].%s);\n"
name;
) cols;
pr " (*env)->SetObjectArrayElement (env, jfl, i, jfl);\n";
pr " }\n";
@@ -8579,71 +8579,71 @@ last_error h = do
List.iter (
fun (name, style, _, _, _, _, _) ->
if can_generate style then (
- pr "foreign import ccall unsafe \"guestfs_%s\" c_%s\n" name name;
- pr " :: ";
- generate_haskell_prototype ~handle:"GuestfsP" style;
- pr "\n";
- pr "\n";
- pr "%s :: " name;
- generate_haskell_prototype ~handle:"GuestfsH" ~hs:true style;
- pr "\n";
- pr "%s %s = do\n" name
- (String.concat " " ("h" :: List.map name_of_argt (snd style)));
- pr " r <- ";
- (* Convert pointer arguments using with* functions. *)
- List.iter (
- function
- | FileIn n
- | FileOut n
- | String n -> pr "withCString %s $ \\%s -> " n n
- | OptString n -> pr "maybeWith withCString %s $ \\%s -> " n n
- | StringList n -> pr "withMany withCString %s $ \\%s -> withArray0 nullPtr
%s $ \\%s -> " n n n n
- | Bool _ | Int _ -> ()
- ) (snd style);
- (* Convert integer arguments. *)
- let args =
- List.map (
- function
- | Bool n -> sprintf "(fromBool %s)" n
- | Int n -> sprintf "(fromIntegral %s)" n
- | FileIn n | FileOut n | String n | OptString n | StringList n -> n
- ) (snd style) in
- pr "withForeignPtr h (\\p -> c_%s %s)\n" name
- (String.concat " " ("p" :: args));
- (match fst style with
- | RErr | RInt _ | RInt64 _ | RBool _ ->
- pr " if (r == -1)\n";
- pr " then do\n";
- pr " err <- last_error h\n";
- pr " fail err\n";
- | RConstString _ | RConstOptString _ | RString _
- | RStringList _ | RStruct _
- | RStructList _ | RHashtable _ | RBufferOut _ ->
- pr " if (r == nullPtr)\n";
- pr " then do\n";
- pr " err <- last_error h\n";
- pr " fail err\n";
- );
- (match fst style with
- | RErr ->
- pr " else return ()\n"
- | RInt _ ->
- pr " else return (fromIntegral r)\n"
- | RInt64 _ ->
- pr " else return (fromIntegral r)\n"
- | RBool _ ->
- pr " else return (toBool r)\n"
- | RConstString _
- | RConstOptString _
- | RString _
- | RStringList _
- | RStruct _
- | RStructList _
- | RHashtable _
- | RBufferOut _ ->
- pr " else return ()\n" (* XXXXXXXXXXXXXXXXXXXX *)
- );
- pr "\n";
+ pr "foreign import ccall unsafe \"guestfs_%s\" c_%s\n" name
name;
+ pr " :: ";
+ generate_haskell_prototype ~handle:"GuestfsP" style;
+ pr "\n";
+ pr "\n";
+ pr "%s :: " name;
+ generate_haskell_prototype ~handle:"GuestfsH" ~hs:true style;
+ pr "\n";
+ pr "%s %s = do\n" name
+ (String.concat " " ("h" :: List.map name_of_argt (snd
style)));
+ pr " r <- ";
+ (* Convert pointer arguments using with* functions. *)
+ List.iter (
+ function
+ | FileIn n
+ | FileOut n
+ | String n -> pr "withCString %s $ \\%s -> " n n
+ | OptString n -> pr "maybeWith withCString %s $ \\%s -> " n n
+ | StringList n -> pr "withMany withCString %s $ \\%s -> withArray0
nullPtr %s $ \\%s -> " n n n n
+ | Bool _ | Int _ -> ()
+ ) (snd style);
+ (* Convert integer arguments. *)
+ let args =
+ List.map (
+ function
+ | Bool n -> sprintf "(fromBool %s)" n
+ | Int n -> sprintf "(fromIntegral %s)" n
+ | FileIn n | FileOut n | String n | OptString n | StringList n -> n
+ ) (snd style) in
+ pr "withForeignPtr h (\\p -> c_%s %s)\n" name
+ (String.concat " " ("p" :: args));
+ (match fst style with
+ | RErr | RInt _ | RInt64 _ | RBool _ ->
+ pr " if (r == -1)\n";
+ pr " then do\n";
+ pr " err <- last_error h\n";
+ pr " fail err\n";
+ | RConstString _ | RConstOptString _ | RString _
+ | RStringList _ | RStruct _
+ | RStructList _ | RHashtable _ | RBufferOut _ ->
+ pr " if (r == nullPtr)\n";
+ pr " then do\n";
+ pr " err <- last_error h\n";
+ pr " fail err\n";
+ );
+ (match fst style with
+ | RErr ->
+ pr " else return ()\n"
+ | RInt _ ->
+ pr " else return (fromIntegral r)\n"
+ | RInt64 _ ->
+ pr " else return (fromIntegral r)\n"
+ | RBool _ ->
+ pr " else return (toBool r)\n"
+ | RConstString _
+ | RConstOptString _
+ | RString _
+ | RStringList _
+ | RStruct _
+ | RStructList _
+ | RHashtable _
+ | RBufferOut _ ->
+ pr " else return ()\n" (* XXXXXXXXXXXXXXXXXXXX *)
+ );
+ pr "\n";
)
) all_functions
@@ -8748,89 +8748,89 @@ print_strings (char * const* const argv)
List.iter (
fun (name, style, _, _, _, _, _) ->
if String.sub name (String.length name - 3) 3 <> "err" then (
- pr "/* Test normal return. */\n";
- generate_prototype ~extern:false ~semicolon:false ~newline:true
- ~handle:"g" ~prefix:"guestfs_" name style;
- pr "{\n";
- (match fst style with
- | RErr ->
- pr " return 0;\n"
- | RInt _ ->
- pr " int r;\n";
- pr " sscanf (val, \"%%d\", &r);\n";
- pr " return r;\n"
- | RInt64 _ ->
- pr " int64_t r;\n";
- pr " sscanf (val, \"%%\" SCNi64, &r);\n";
- pr " return r;\n"
- | RBool _ ->
- pr " return strcmp (val, \"true\") == 0;\n"
- | RConstString _
- | RConstOptString _ ->
- (* Can't return the input string here. Return a static
- * string so we ensure we get a segfault if the caller
- * tries to free it.
- *)
- pr " return \"static string\";\n"
- | RString _ ->
- pr " return strdup (val);\n"
- | RStringList _ ->
- pr " char **strs;\n";
- pr " int n, i;\n";
- pr " sscanf (val, \"%%d\", &n);\n";
- pr " strs = safe_malloc (g, (n+1) * sizeof (char *));\n";
- pr " for (i = 0; i < n; ++i) {\n";
- pr " strs[i] = safe_malloc (g, 16);\n";
- pr " snprintf (strs[i], 16, \"%%d\", i);\n";
- pr " }\n";
- pr " strs[n] = NULL;\n";
- pr " return strs;\n"
- | RStruct (_, typ) ->
- pr " struct guestfs_%s *r;\n" typ;
- pr " r = safe_calloc (g, sizeof *r, 1);\n";
- pr " return r;\n"
- | RStructList (_, typ) ->
- pr " struct guestfs_%s_list *r;\n" typ;
- pr " r = safe_calloc (g, sizeof *r, 1);\n";
- pr " sscanf (val, \"%%d\", &r->len);\n";
- pr " r->val = safe_calloc (g, r->len, sizeof *r->val);\n";
- pr " return r;\n"
- | RHashtable _ ->
- pr " char **strs;\n";
- pr " int n, i;\n";
- pr " sscanf (val, \"%%d\", &n);\n";
- pr " strs = safe_malloc (g, (n*2+1) * sizeof (*strs));\n";
- pr " for (i = 0; i < n; ++i) {\n";
- pr " strs[i*2] = safe_malloc (g, 16);\n";
- pr " strs[i*2+1] = safe_malloc (g, 16);\n";
- pr " snprintf (strs[i*2], 16, \"%%d\", i);\n";
- pr " snprintf (strs[i*2+1], 16, \"%%d\", i);\n";
- pr " }\n";
- pr " strs[n*2] = NULL;\n";
- pr " return strs;\n"
- | RBufferOut _ ->
- pr " return strdup (val);\n"
- );
- pr "}\n";
- pr "\n"
+ pr "/* Test normal return. */\n";
+ generate_prototype ~extern:false ~semicolon:false ~newline:true
+ ~handle:"g" ~prefix:"guestfs_" name style;
+ pr "{\n";
+ (match fst style with
+ | RErr ->
+ pr " return 0;\n"
+ | RInt _ ->
+ pr " int r;\n";
+ pr " sscanf (val, \"%%d\", &r);\n";
+ pr " return r;\n"
+ | RInt64 _ ->
+ pr " int64_t r;\n";
+ pr " sscanf (val, \"%%\" SCNi64, &r);\n";
+ pr " return r;\n"
+ | RBool _ ->
+ pr " return strcmp (val, \"true\") == 0;\n"
+ | RConstString _
+ | RConstOptString _ ->
+ (* Can't return the input string here. Return a static
+ * string so we ensure we get a segfault if the caller
+ * tries to free it.
+ *)
+ pr " return \"static string\";\n"
+ | RString _ ->
+ pr " return strdup (val);\n"
+ | RStringList _ ->
+ pr " char **strs;\n";
+ pr " int n, i;\n";
+ pr " sscanf (val, \"%%d\", &n);\n";
+ pr " strs = safe_malloc (g, (n+1) * sizeof (char *));\n";
+ pr " for (i = 0; i < n; ++i) {\n";
+ pr " strs[i] = safe_malloc (g, 16);\n";
+ pr " snprintf (strs[i], 16, \"%%d\", i);\n";
+ pr " }\n";
+ pr " strs[n] = NULL;\n";
+ pr " return strs;\n"
+ | RStruct (_, typ) ->
+ pr " struct guestfs_%s *r;\n" typ;
+ pr " r = safe_calloc (g, sizeof *r, 1);\n";
+ pr " return r;\n"
+ | RStructList (_, typ) ->
+ pr " struct guestfs_%s_list *r;\n" typ;
+ pr " r = safe_calloc (g, sizeof *r, 1);\n";
+ pr " sscanf (val, \"%%d\", &r->len);\n";
+ pr " r->val = safe_calloc (g, r->len, sizeof
*r->val);\n";
+ pr " return r;\n"
+ | RHashtable _ ->
+ pr " char **strs;\n";
+ pr " int n, i;\n";
+ pr " sscanf (val, \"%%d\", &n);\n";
+ pr " strs = safe_malloc (g, (n*2+1) * sizeof (*strs));\n";
+ pr " for (i = 0; i < n; ++i) {\n";
+ pr " strs[i*2] = safe_malloc (g, 16);\n";
+ pr " strs[i*2+1] = safe_malloc (g, 16);\n";
+ pr " snprintf (strs[i*2], 16, \"%%d\", i);\n";
+ pr " snprintf (strs[i*2+1], 16, \"%%d\", i);\n";
+ pr " }\n";
+ pr " strs[n*2] = NULL;\n";
+ pr " return strs;\n"
+ | RBufferOut _ ->
+ pr " return strdup (val);\n"
+ );
+ pr "}\n";
+ pr "\n"
) else (
- pr "/* Test error return. */\n";
- generate_prototype ~extern:false ~semicolon:false ~newline:true
- ~handle:"g" ~prefix:"guestfs_" name style;
- pr "{\n";
- pr " error (g, \"error\");\n";
- (match fst style with
- | RErr | RInt _ | RInt64 _ | RBool _ ->
- pr " return -1;\n"
- | RConstString _ | RConstOptString _
- | RString _ | RStringList _ | RStruct _
- | RStructList _
- | RHashtable _
- | RBufferOut _ ->
- pr " return NULL;\n"
- );
- pr "}\n";
- pr "\n"
+ pr "/* Test error return. */\n";
+ generate_prototype ~extern:false ~semicolon:false ~newline:true
+ ~handle:"g" ~prefix:"guestfs_" name style;
+ pr "{\n";
+ pr " error (g, \"error\");\n";
+ (match fst style with
+ | RErr | RInt _ | RInt64 _ | RBool _ ->
+ pr " return -1;\n"
+ | RConstString _ | RConstOptString _
+ | RString _ | RStringList _ | RStruct _
+ | RStructList _
+ | RHashtable _
+ | RBufferOut _ ->
+ pr " return NULL;\n"
+ );
+ pr "}\n";
+ pr "\n"
)
) tests
@@ -8845,15 +8845,15 @@ let () =
let mkargs args =
String.concat " " (
List.map (
- function
- | CallString s -> "\"" ^ s ^ "\""
- | CallOptString None -> "None"
- | CallOptString (Some s) -> sprintf "(Some \"%s\")" s
- | CallStringList xs ->
- "[|" ^ String.concat ";" (List.map (sprintf
"\"%s\"") xs) ^ "|]"
- | CallInt i when i >= 0 -> string_of_int i
- | CallInt i (* when i < 0 *) -> "(" ^ string_of_int i ^ ")"
- | CallBool b -> string_of_bool b
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "None"
+ | CallOptString (Some s) -> sprintf "(Some \"%s\")" s
+ | CallStringList xs ->
+ "[|" ^ String.concat ";" (List.map (sprintf
"\"%s\"") xs) ^ "|]"
+ | CallInt i when i >= 0 -> string_of_int i
+ | CallInt i (* when i < 0 *) -> "(" ^ string_of_int i ^
")"
+ | CallBool b -> string_of_bool b
) args
)
in
@@ -8879,14 +8879,14 @@ my $g = Sys::Guestfs->new ();
let mkargs args =
String.concat ", " (
List.map (
- function
- | CallString s -> "\"" ^ s ^ "\""
- | CallOptString None -> "undef"
- | CallOptString (Some s) -> sprintf "\"%s\"" s
- | CallStringList xs ->
- "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
- | CallInt i -> string_of_int i
- | CallBool b -> if b then "1" else "0"
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "undef"
+ | CallOptString (Some s) -> sprintf "\"%s\"" s
+ | CallStringList xs ->
+ "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
+ | CallInt i -> string_of_int i
+ | CallBool b -> if b then "1" else "0"
) args
)
in
@@ -8909,14 +8909,14 @@ g = guestfs.GuestFS ()
let mkargs args =
String.concat ", " (
List.map (
- function
- | CallString s -> "\"" ^ s ^ "\""
- | CallOptString None -> "None"
- | CallOptString (Some s) -> sprintf "\"%s\"" s
- | CallStringList xs ->
- "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
- | CallInt i -> string_of_int i
- | CallBool b -> if b then "1" else "0"
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "None"
+ | CallOptString (Some s) -> sprintf "\"%s\"" s
+ | CallStringList xs ->
+ "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
+ | CallInt i -> string_of_int i
+ | CallBool b -> if b then "1" else "0"
) args
)
in
@@ -8939,14 +8939,14 @@ g = Guestfs::create()
let mkargs args =
String.concat ", " (
List.map (
- function
- | CallString s -> "\"" ^ s ^ "\""
- | CallOptString None -> "nil"
- | CallOptString (Some s) -> sprintf "\"%s\"" s
- | CallStringList xs ->
- "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
- | CallInt i -> string_of_int i
- | CallBool b -> string_of_bool b
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "nil"
+ | CallOptString (Some s) -> sprintf "\"%s\"" s
+ | CallStringList xs ->
+ "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
+ | CallInt i -> string_of_int i
+ | CallBool b -> string_of_bool b
) args
)
in
@@ -8973,15 +8973,15 @@ public class Bindtests {
let mkargs args =
String.concat ", " (
List.map (
- function
- | CallString s -> "\"" ^ s ^ "\""
- | CallOptString None -> "null"
- | CallOptString (Some s) -> sprintf "\"%s\"" s
- | CallStringList xs ->
- "new String[]{" ^
- String.concat "," (List.map (sprintf "\"%s\"") xs) ^
"}"
- | CallInt i -> string_of_int i
- | CallBool b -> string_of_bool b
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "null"
+ | CallOptString (Some s) -> sprintf "\"%s\"" s
+ | CallStringList xs ->
+ "new String[]{" ^
+ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "}"
+ | CallInt i -> string_of_int i
+ | CallBool b -> string_of_bool b
) args
)
in
@@ -9015,16 +9015,16 @@ main = do
let mkargs args =
String.concat " " (
List.map (
- function
- | CallString s -> "\"" ^ s ^ "\""
- | CallOptString None -> "Nothing"
- | CallOptString (Some s) -> sprintf "(Just \"%s\")" s
- | CallStringList xs ->
- "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
- | CallInt i when i < 0 -> "(" ^ string_of_int i ^ ")"
- | CallInt i -> string_of_int i
- | CallBool true -> "True"
- | CallBool false -> "False"
+ function
+ | CallString s -> "\"" ^ s ^ "\""
+ | CallOptString None -> "Nothing"
+ | CallOptString (Some s) -> sprintf "(Just \"%s\")" s
+ | CallStringList xs ->
+ "[" ^ String.concat "," (List.map (sprintf
"\"%s\"") xs) ^ "]"
+ | CallInt i when i < 0 -> "(" ^ string_of_int i ^ ")"
+ | CallInt i -> string_of_int i
+ | CallBool true -> "True"
+ | CallBool false -> "False"
) args
)
in
@@ -9040,44 +9040,44 @@ main = do
*)
and generate_lang_bindtests call =
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList []; CallBool false;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList []; CallBool false;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString None;
- CallStringList []; CallBool false;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList []; CallBool false;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString ""; CallOptString (Some "def");
- CallStringList []; CallBool false;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList []; CallBool false;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString ""; CallOptString (Some "");
- CallStringList []; CallBool false;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList []; CallBool false;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool false;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"; "2"]; CallBool false;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList ["1"; "2"]; CallBool false;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool true;
- CallInt 0; CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool true;
+ CallInt 0; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt (-1); CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool false;
+ CallInt (-1); CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt (-2); CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool false;
+ CallInt (-2); CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt 1; CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool false;
+ CallInt 1; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt 2; CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool false;
+ CallInt 2; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt 4095; CallString "123"; CallString "456"];
+ CallStringList ["1"]; CallBool false;
+ CallInt 4095; CallString "123"; CallString "456"];
call "test0" [CallString "abc"; CallOptString (Some
"def");
- CallStringList ["1"]; CallBool false;
- CallInt 0; CallString ""; CallString ""]
+ CallStringList ["1"]; CallBool false;
+ CallInt 0; CallString ""; CallString ""]
(* XXX Add here tests of the return and error functions. *)
diff --git a/src/gettext.h b/src/gettext.h
index 209921e..93f32e5 100644
--- a/src/gettext.h
+++ b/src/gettext.h
@@ -132,8 +132,8 @@ inline
#endif
static const char *
pgettext_aux (const char *domain,
- const char *msg_ctxt_id, const char *msgid,
- int category)
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
{
const char *translation = dcgettext (domain, msg_ctxt_id, category);
if (translation == msg_ctxt_id)
@@ -151,9 +151,9 @@ inline
#endif
static const char *
npgettext_aux (const char *domain,
- const char *msg_ctxt_id, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
{
const char *translation =
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
@@ -191,8 +191,8 @@ inline
#endif
static const char *
dcpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- int category)
+ const char *msgctxt, const char *msgid,
+ int category)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
@@ -214,10 +214,10 @@ dcpgettext_expr (const char *domain,
translation = dcgettext (domain, msg_ctxt_id, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
+ free (msg_ctxt_id);
#endif
if (translation != msg_ctxt_id)
- return translation;
+ return translation;
}
return msgid;
}
@@ -236,9 +236,9 @@ inline
#endif
static const char *
dcnpgettext_expr (const char *domain,
- const char *msgctxt, const char *msgid,
- const char *msgid_plural, unsigned long int n,
- int category)
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
@@ -260,10 +260,10 @@ dcnpgettext_expr (const char *domain,
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
- free (msg_ctxt_id);
+ free (msg_ctxt_id);
#endif
if (!(translation == msg_ctxt_id || translation == msgid_plural))
- return translation;
+ return translation;
}
return (n == 1 ? msgid : msgid_plural);
}
diff --git a/src/guestfs.c b/src/guestfs.c
index 40e702e..64c327b 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -562,7 +562,7 @@ xread (int fd, void *buf, size_t len)
r = read (fd, buf, len);
if (r == -1) {
if (errno == EINTR || errno == EAGAIN)
- continue;
+ continue;
return -1;
}
@@ -743,7 +743,7 @@ add_cmdline (guestfs_h *g, const char *str)
int
guestfs_config (guestfs_h *g,
- const char *qemu_param, const char *qemu_value)
+ const char *qemu_param, const char *qemu_value)
{
if (qemu_param[0] != '-') {
error (g, _("guestfs_config: parameter must begin with '-'
character"));
@@ -932,27 +932,27 @@ guestfs_launch (guestfs_h *g)
/* Empty element of "." means cwd. */
if (len == 0 || (len == 1 && *pelem == '.')) {
if (g->verbose)
- fprintf (stderr,
- "looking for supermin appliance in current directory\n");
+ fprintf (stderr,
+ "looking for supermin appliance in current directory\n");
if (dir_contains_files (".",
- supermin_name, supermin_hostfiles_name,
- "kmod.whitelist", NULL)) {
- if (build_supermin_appliance (g, ".", &kernel, &initrd) == -1)
- return -1;
- break;
+ supermin_name, supermin_hostfiles_name,
+ "kmod.whitelist", NULL)) {
+ if (build_supermin_appliance (g, ".", &kernel, &initrd) == -1)
+ return -1;
+ break;
}
}
/* Look at <path>/supermin* etc. */
else {
if (g->verbose)
- fprintf (stderr, "looking for supermin appliance in %s\n", pelem);
+ fprintf (stderr, "looking for supermin appliance in %s\n", pelem);
if (dir_contains_files (pelem,
- supermin_name, supermin_hostfiles_name,
- "kmod.whitelist", NULL)) {
- if (build_supermin_appliance (g, pelem, &kernel, &initrd) == -1)
- return -1;
- break;
+ supermin_name, supermin_hostfiles_name,
+ "kmod.whitelist", NULL)) {
+ if (build_supermin_appliance (g, pelem, &kernel, &initrd) == -1)
+ return -1;
+ break;
}
}
@@ -972,27 +972,27 @@ guestfs_launch (guestfs_h *g)
/* Empty element or "." means cwd. */
if (len == 0 || (len == 1 && *pelem == '.')) {
- if (g->verbose)
- fprintf (stderr,
- "looking for appliance in current directory\n");
- if (dir_contains_files (".", kernel_name, initrd_name, NULL)) {
- kernel = safe_strdup (g, kernel_name);
- initrd = safe_strdup (g, initrd_name);
- break;
- }
+ if (g->verbose)
+ fprintf (stderr,
+ "looking for appliance in current directory\n");
+ if (dir_contains_files (".", kernel_name, initrd_name, NULL)) {
+ kernel = safe_strdup (g, kernel_name);
+ initrd = safe_strdup (g, initrd_name);
+ break;
+ }
}
/* Look at <path>/kernel etc. */
else {
- if (g->verbose)
- fprintf (stderr, "looking for appliance in %s\n", pelem);
-
- if (dir_contains_files (pelem, kernel_name, initrd_name, NULL)) {
- kernel = safe_malloc (g, len + strlen (kernel_name) + 2);
- initrd = safe_malloc (g, len + strlen (initrd_name) + 2);
- sprintf (kernel, "%s/%s", pelem, kernel_name);
- sprintf (initrd, "%s/%s", pelem, initrd_name);
- break;
- }
+ if (g->verbose)
+ fprintf (stderr, "looking for appliance in %s\n", pelem);
+
+ if (dir_contains_files (pelem, kernel_name, initrd_name, NULL)) {
+ kernel = safe_malloc (g, len + strlen (kernel_name) + 2);
+ initrd = safe_malloc (g, len + strlen (initrd_name) + 2);
+ sprintf (kernel, "%s/%s", pelem, kernel_name);
+ sprintf (initrd, "%s/%s", pelem, initrd_name);
+ break;
+ }
}
pelem = pend + 1;
@@ -1003,7 +1003,7 @@ guestfs_launch (guestfs_h *g)
if (kernel == NULL || initrd == NULL) {
error (g, _("cannot find %s or %s on LIBGUESTFS_PATH (current path =
%s)"),
- kernel_name, initrd_name, g->path);
+ kernel_name, initrd_name, g->path);
goto cleanup0;
}
@@ -1051,10 +1051,10 @@ guestfs_launch (guestfs_h *g)
/* Linux kernel command line. */
snprintf (append, sizeof append,
- LINUX_CMDLINE "guestfs=%s:%d%s%s%s",
- VMCHANNEL_ADDR, VMCHANNEL_PORT,
- g->verbose ? " guestfs_verbose=1" : "",
- g->append ? " " : "", g->append ? g->append :
"");
+ LINUX_CMDLINE "guestfs=%s:%d%s%s%s",
+ VMCHANNEL_ADDR, VMCHANNEL_PORT,
+ g->verbose ? " guestfs_verbose=1" : "",
+ g->append ? " " : "", g->append ? g->append :
"");
snprintf (memsize_str, sizeof memsize_str, "%d", g->memsize);
@@ -1081,8 +1081,8 @@ guestfs_launch (guestfs_h *g)
*
http://git.savannah.gnu.org/cgit/qemu.git/commit/?id=c92ef6a22d3c71538fcc...
*/
snprintf (vmchannel, sizeof vmchannel,
- "user,vlan=0,guestfwd=tcp:%s:%d-unix:%s,server,nowait",
- VMCHANNEL_ADDR, VMCHANNEL_PORT, unixsock);
+ "user,vlan=0,guestfwd=tcp:%s:%d-unix:%s,server,nowait",
+ VMCHANNEL_ADDR, VMCHANNEL_PORT, unixsock);
add_cmdline (g, "-net");
add_cmdline (g, vmchannel);
@@ -1092,8 +1092,8 @@ guestfs_launch (guestfs_h *g)
* syntax, or if not then we'll get a quick failure.
*/
snprintf (vmchannel, sizeof vmchannel,
- "channel,%d:unix:%s,server,nowait",
- VMCHANNEL_PORT, unixsock);
+ "channel,%d:unix:%s,server,nowait",
+ VMCHANNEL_PORT, unixsock);
add_cmdline (g, "-net");
add_cmdline (g, vmchannel);
@@ -1119,7 +1119,7 @@ guestfs_launch (guestfs_h *g)
if (g->verbose) {
fprintf (stderr, "%s", g->qemu);
for (i = 0; g->cmdline[i]; ++i)
- fprintf (stderr, " %s", g->cmdline[i]);
+ fprintf (stderr, " %s", g->cmdline[i]);
fprintf (stderr, "\n");
}
@@ -1172,11 +1172,11 @@ guestfs_launch (guestfs_h *g)
*/
for (;;) {
if (kill (qemu_pid, 0) == -1) /* qemu's gone away, we aren't needed */
- _exit (0);
+ _exit (0);
if (kill (parent_pid, 0) == -1) {
- /* Parent's gone away, qemu still around, so kill qemu. */
- kill (qemu_pid, 9);
- _exit (0);
+ /* Parent's gone away, qemu still around, so kill qemu. */
+ kill (qemu_pid, 9);
+ _exit (0);
}
sleep (2);
}
@@ -1257,8 +1257,8 @@ guestfs_launch (guestfs_h *g)
g->stdout_watch =
g->main_loop->add_handle (g->main_loop, g, g->fd[1],
- GUESTFS_HANDLE_READABLE,
- stdout_event, NULL);
+ GUESTFS_HANDLE_READABLE,
+ stdout_event, NULL);
if (g->stdout_watch == -1) {
error (g, _("could not watch qemu stdout"));
goto cleanup3;
@@ -1309,7 +1309,7 @@ guestfs_launch (guestfs_h *g)
*/
static int
build_supermin_appliance (guestfs_h *g, const char *path,
- char **kernel, char **initrd)
+ char **kernel, char **initrd)
{
char cmd[4096];
int r, len;
@@ -1321,10 +1321,10 @@ build_supermin_appliance (guestfs_h *g, const char *path,
snprintf (*initrd, len+8, "%s/initrd", g->tmpdir);
snprintf (cmd, sizeof cmd,
- "PATH='%s':$PATH "
- "libguestfs-supermin-helper '%s' %s %s",
- path,
- path, *kernel, *initrd);
+ "PATH='%s':$PATH "
+ "libguestfs-supermin-helper '%s' %s %s",
+ path,
+ path, *kernel, *initrd);
r = system (cmd);
if (r == -1 || WEXITSTATUS(r) != 0) {
@@ -1528,7 +1528,7 @@ guestfs_set_ready (guestfs_h *g)
{
if (g->state != BUSY) {
error (g, _("guestfs_set_ready: called when in state %d != BUSY"),
- g->state);
+ g->state);
return -1;
}
g->state = READY;
@@ -1540,7 +1540,7 @@ guestfs_set_busy (guestfs_h *g)
{
if (g->state != READY) {
error (g, _("guestfs_set_busy: called when in state %d != READY"),
- g->state);
+ g->state);
return -1;
}
g->state = BUSY;
@@ -1605,7 +1605,7 @@ child_cleanup (guestfs_h *g)
*/
static void
stdout_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
- int watch, int fd, int events)
+ int watch, int fd, int events)
{
char buf[4096];
int n;
@@ -1613,8 +1613,8 @@ stdout_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
#if 0
if (g->verbose)
fprintf (stderr,
- "stdout_event: %p g->state = %d, fd = %d, events = 0x%x\n",
- g, g->state, fd, events);
+ "stdout_event: %p g->state = %d, fd = %d, events = 0x%x\n",
+ g, g->state, fd, events);
#endif
if (g->fd[1] != fd) {
@@ -1649,7 +1649,7 @@ stdout_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
*/
static void
sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
- int watch, int fd, int events)
+ int watch, int fd, int events)
{
XDR xdr;
u_int32_t len;
@@ -1657,8 +1657,8 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
if (g->verbose)
fprintf (stderr,
- "sock_read_event: %p g->state = %d, fd = %d, events = 0x%x\n",
- g, g->state, fd, events);
+ "sock_read_event: %p g->state = %d, fd = %d, events = 0x%x\n",
+ g, g->state, fd, events);
if (g->sock != fd) {
error (g, _("sock_read_event: internal error: %d != %d"), g->sock, fd);
@@ -1670,7 +1670,7 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
g->msg_in = safe_realloc (g, g->msg_in, g->msg_in_allocated);
}
n = read (g->sock, g->msg_in + g->msg_in_size,
- g->msg_in_allocated - g->msg_in_size);
+ g->msg_in_allocated - g->msg_in_size);
if (n == 0) {
/* Disconnected. */
child_cleanup (g);
@@ -1702,14 +1702,14 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
if (len == GUESTFS_LAUNCH_FLAG) {
if (g->state != LAUNCHING)
error (g, _("received magic signature from guestfsd, but in state %d"),
- g->state);
+ g->state);
else if (g->msg_in_size != 4)
error (g, _("received magic signature from guestfsd, but msg size is
%d"),
- g->msg_in_size);
+ g->msg_in_size);
else {
g->state = READY;
if (g->launch_done_cb)
- g->launch_done_cb (g, g->launch_done_cb_data);
+ g->launch_done_cb (g, g->launch_done_cb_data);
}
goto cleanup;
@@ -1730,7 +1730,7 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
*/
if (len > GUESTFS_MESSAGE_MAX) {
error (g, _("message length (%u) > maximum possible size (%d)"),
- len, GUESTFS_MESSAGE_MAX);
+ len, GUESTFS_MESSAGE_MAX);
goto cleanup;
}
@@ -1744,17 +1744,17 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
for (i = 0; i < g->msg_in_size; i += 16) {
printf ("%04x: ", i);
for (j = i; j < MIN (i+16, g->msg_in_size); ++j)
- printf ("%02x ", (unsigned char) g->msg_in[j]);
+ printf ("%02x ", (unsigned char) g->msg_in[j]);
for (; j < i+16; ++j)
- printf (" ");
+ printf (" ");
printf ("|");
for (j = i; j < MIN (i+16, g->msg_in_size); ++j)
- if (isprint (g->msg_in[j]))
- printf ("%c", g->msg_in[j]);
- else
- printf (".");
+ if (isprint (g->msg_in[j]))
+ printf ("%c", g->msg_in[j]);
+ else
+ printf (".");
for (; j < i+16; ++j)
- printf (" ");
+ printf (" ");
printf ("|\n");
}
}
@@ -1792,14 +1792,14 @@ sock_read_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
*/
static void
sock_write_event (struct guestfs_main_loop *ml, guestfs_h *g, void *data,
- int watch, int fd, int events)
+ int watch, int fd, int events)
{
int n, err;
if (g->verbose)
fprintf (stderr,
- "sock_write_event: %p g->state = %d, fd = %d, events = 0x%x\n",
- g, g->state, fd, events);
+ "sock_write_event: %p g->state = %d, fd = %d, events =
0x%x\n",
+ g, g->state, fd, events);
if (g->sock != fd) {
error (g, _("sock_write_event: internal error: %d != %d"), g->sock,
fd);
@@ -1813,10 +1813,10 @@ sock_write_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
if (g->verbose)
fprintf (stderr, "sock_write_event: writing %d bytes ...\n",
- g->msg_out_size - g->msg_out_pos);
+ g->msg_out_size - g->msg_out_pos);
n = write (g->sock, g->msg_out + g->msg_out_pos,
- g->msg_out_size - g->msg_out_pos);
+ g->msg_out_size - g->msg_out_pos);
if (n == -1) {
err = errno;
if (err != EAGAIN)
@@ -1849,7 +1849,7 @@ sock_write_event (struct guestfs_main_loop *ml, guestfs_h *g, void
*data,
void
guestfs_set_send_callback (guestfs_h *g,
- guestfs_send_cb cb, void *opaque)
+ guestfs_send_cb cb, void *opaque)
{
g->send_cb = cb;
g->send_cb_data = opaque;
@@ -1857,7 +1857,7 @@ guestfs_set_send_callback (guestfs_h *g,
void
guestfs_set_reply_callback (guestfs_h *g,
- guestfs_reply_cb cb, void *opaque)
+ guestfs_reply_cb cb, void *opaque)
{
g->reply_cb = cb;
g->reply_cb_data = opaque;
@@ -1865,7 +1865,7 @@ guestfs_set_reply_callback (guestfs_h *g,
void
guestfs_set_log_message_callback (guestfs_h *g,
- guestfs_log_message_cb cb, void *opaque)
+ guestfs_log_message_cb cb, void *opaque)
{
g->log_message_cb = cb;
g->log_message_cb_data = opaque;
@@ -1873,7 +1873,7 @@ guestfs_set_log_message_callback (guestfs_h *g,
void
guestfs_set_subprocess_quit_callback (guestfs_h *g,
- guestfs_subprocess_quit_cb cb, void *opaque)
+ guestfs_subprocess_quit_cb cb, void *opaque)
{
g->subprocess_quit_cb = cb;
g->subprocess_quit_cb_data = opaque;
@@ -1881,7 +1881,7 @@ guestfs_set_subprocess_quit_callback (guestfs_h *g,
void
guestfs_set_launch_done_callback (guestfs_h *g,
- guestfs_launch_done_cb cb, void *opaque)
+ guestfs_launch_done_cb cb, void *opaque)
{
g->launch_done_cb = cb;
g->launch_done_cb_data = opaque;
@@ -1922,8 +1922,8 @@ guestfs__switch_to_sending (guestfs_h *g)
g->sock_watch =
g->main_loop->add_handle (g->main_loop, g, g->sock,
- GUESTFS_HANDLE_WRITABLE,
- sock_write_event, NULL);
+ GUESTFS_HANDLE_WRITABLE,
+ sock_write_event, NULL);
if (g->sock_watch == -1) {
error (g, _("add_handle failed"));
return -1;
@@ -1945,8 +1945,8 @@ guestfs__switch_to_receiving (guestfs_h *g)
g->sock_watch =
g->main_loop->add_handle (g->main_loop, g, g->sock,
- GUESTFS_HANDLE_READABLE,
- sock_read_event, NULL);
+ GUESTFS_HANDLE_READABLE,
+ sock_read_event, NULL);
if (g->sock_watch == -1) {
error (g, _("add_handle failed"));
return -1;
@@ -1971,7 +1971,7 @@ send_cb (guestfs_h *g, void *data)
int
guestfs__send_sync (guestfs_h *g, int proc_nr,
- xdrproc_t xdrp, char *args)
+ xdrproc_t xdrp, char *args)
{
struct guestfs_message_header hdr;
XDR xdr;
@@ -2096,7 +2096,7 @@ guestfs__send_file_sync (guestfs_h *g, const char *filename)
err = send_file_data_sync (g, buf, r);
if (err < 0) {
if (err == -2) /* daemon sent cancellation */
- send_file_cancellation_sync (g);
+ send_file_cancellation_sync (g);
return err;
}
}
@@ -2193,7 +2193,7 @@ send_file_chunk_sync (guestfs_h *g, int cancel, const char *buf,
size_t buflen)
if (!xdr_guestfs_chunk (&xdr, &chunk)) {
error (g, _("xdr_guestfs_chunk failed (buf = %p, buflen = %zu)"),
- buf, buflen);
+ buf, buflen);
xdr_destroy (&xdr);
goto cleanup1;
}
@@ -2269,7 +2269,7 @@ check_for_daemon_cancellation (guestfs_h *g)
if (flag != GUESTFS_CANCEL_FLAG) {
error (g, _("check_for_daemon_cancellation: read 0x%x from daemon, expected
0x%x\n"),
- flag, GUESTFS_CANCEL_FLAG);
+ flag, GUESTFS_CANCEL_FLAG);
return 0;
}
@@ -2327,7 +2327,7 @@ guestfs__receive_file_sync (guestfs_h *g, const char *filename)
if (g->verbose)
fprintf (stderr, "%s: waiting for daemon to acknowledge cancellation\n",
- __func__);
+ __func__);
xdrmem_create (&xdr, fbuf, sizeof fbuf, XDR_ENCODE);
xdr_uint32_t (&xdr, &flag);
@@ -2350,8 +2350,8 @@ guestfs__receive_file_sync (guestfs_h *g, const char *filename)
*/
struct receive_file_ctx {
int count; /* 0 if receive_file_cb not called, or
- * else count number of chunks.
- */
+ * else count number of chunks.
+ */
guestfs_chunk *chunks; /* Array of chunks. */
};
@@ -2390,7 +2390,7 @@ receive_file_cb (guestfs_h *g, void *data, XDR *xdr)
/* Copy the chunk to the list. */
ctx->chunks = safe_realloc (g, ctx->chunks,
- sizeof (guestfs_chunk) * (ctx->count+1));
+ sizeof (guestfs_chunk) * (ctx->count+1));
ctx->chunks[ctx->count] = chunk;
ctx->count++;
}
@@ -2448,7 +2448,7 @@ receive_file_data_sync (guestfs_h *g, void **buf, size_t *len_r)
if (buf) {
*buf = safe_realloc (g, *buf, len + ctx.chunks[i].data.data_len);
memcpy (*buf+len, ctx.chunks[i].data.data_val,
- ctx.chunks[i].data.data_len);
+ ctx.chunks[i].data.data_len);
}
len += ctx.chunks[i].data.data_len;
}
@@ -2462,7 +2462,7 @@ receive_file_data_sync (guestfs_h *g, void **buf, size_t *len_r)
static int
select_add_handle (guestfs_main_loop *mlv, guestfs_h *g, int fd, int events,
- guestfs_handle_event_cb cb, void *data)
+ guestfs_handle_event_cb cb, void *data)
{
struct select_main_loop *ml = (struct select_main_loop *) mlv;
@@ -2472,9 +2472,9 @@ select_add_handle (guestfs_main_loop *mlv, guestfs_h *g, int fd, int
events,
}
if ((events & ~(GUESTFS_HANDLE_READABLE |
- GUESTFS_HANDLE_WRITABLE |
- GUESTFS_HANDLE_HANGUP |
- GUESTFS_HANDLE_ERROR)) != 0) {
+ GUESTFS_HANDLE_WRITABLE |
+ GUESTFS_HANDLE_HANGUP |
+ GUESTFS_HANDLE_ERROR)) != 0) {
error (g, _("set of events (0x%x) contains unknown events"), events);
return -1;
}
@@ -2507,7 +2507,7 @@ select_add_handle (guestfs_main_loop *mlv, guestfs_h *g, int fd, int
events,
ml->max_fd = fd;
ml->handle_cb_data =
safe_realloc (g, ml->handle_cb_data,
- sizeof (struct select_handle_cb_data) * (ml->max_fd+1));
+ sizeof (struct select_handle_cb_data) * (ml->max_fd+1));
}
ml->handle_cb_data[fd].cb = cb;
ml->handle_cb_data[fd].g = g;
@@ -2544,7 +2544,7 @@ select_remove_handle (guestfs_main_loop *mlv, guestfs_h *g, int fd)
ml->max_fd--;
ml->handle_cb_data =
safe_realloc (g, ml->handle_cb_data,
- sizeof (struct select_handle_cb_data) * (ml->max_fd+1));
+ sizeof (struct select_handle_cb_data) * (ml->max_fd+1));
}
ml->nr_fds--;
@@ -2554,7 +2554,7 @@ select_remove_handle (guestfs_main_loop *mlv, guestfs_h *g, int fd)
static int
select_add_timeout (guestfs_main_loop *mlv, guestfs_h *g, int interval,
- guestfs_handle_timeout_cb cb, void *data)
+ guestfs_handle_timeout_cb cb, void *data)
{
//struct select_main_loop *ml = (struct select_main_loop *) mlv;
@@ -2597,7 +2597,7 @@ select_main_loop_run (guestfs_main_loop *mlv, guestfs_h *g)
r = select (ml->max_fd+1, &rset2, &wset2, &xset2, NULL);
if (r == -1) {
if (errno == EINTR || errno == EAGAIN)
- continue;
+ continue;
perrorf (g, "select");
ml->is_running = 0;
return -1;
@@ -2606,17 +2606,17 @@ select_main_loop_run (guestfs_main_loop *mlv, guestfs_h *g)
for (fd = 0; r > 0 && fd <= ml->max_fd; ++fd) {
events = 0;
if (FD_ISSET (fd, &rset2))
- events |= GUESTFS_HANDLE_READABLE;
+ events |= GUESTFS_HANDLE_READABLE;
if (FD_ISSET (fd, &wset2))
- events |= GUESTFS_HANDLE_WRITABLE;
+ events |= GUESTFS_HANDLE_WRITABLE;
if (FD_ISSET (fd, &xset2))
- events |= GUESTFS_HANDLE_ERROR | GUESTFS_HANDLE_HANGUP;
+ events |= GUESTFS_HANDLE_ERROR | GUESTFS_HANDLE_HANGUP;
if (events) {
- r--;
- ml->handle_cb_data[fd].cb ((guestfs_main_loop *) ml,
- ml->handle_cb_data[fd].g,
- ml->handle_cb_data[fd].data,
- fd, fd, events);
+ r--;
+ ml->handle_cb_data[fd].cb ((guestfs_main_loop *) ml,
+ ml->handle_cb_data[fd].g,
+ ml->handle_cb_data[fd].data,
+ fd, fd, events);
}
}
}
diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c
index f37656a..3dc0328 100644
--- a/test-tool/test-tool.c
+++ b/test-tool/test-tool.c
@@ -57,19 +57,19 @@ static void
usage (void)
{
printf (_("libguestfs-test-tool: interactive test tool\n"
- "Copyright (C) 2009 Red Hat Inc.\n"
- "Usage:\n"
- " libguestfs-test-tool [--options]\n"
- "Options:\n"
- " --help Display usage\n"
- " --helper libguestfs-test-tool-helper\n"
- " Helper program (default: %s)\n"
- " --qemudir dir Specify QEMU source directory\n"
- " --qemu qemu Specify QEMU binary\n"
- " --timeout n\n"
- " -t n Set launch timeout (default: %d seconds)\n"
- ),
- DEFAULT_HELPER, DEFAULT_TIMEOUT);
+ "Copyright (C) 2009 Red Hat Inc.\n"
+ "Usage:\n"
+ " libguestfs-test-tool [--options]\n"
+ "Options:\n"
+ " --help Display usage\n"
+ " --helper libguestfs-test-tool-helper\n"
+ " Helper program (default: %s)\n"
+ " --qemudir dir Specify QEMU source directory\n"
+ " --qemu qemu Specify QEMU binary\n"
+ " --timeout n\n"
+ " -t n Set launch timeout (default: %d seconds)\n"
+ ),
+ DEFAULT_HELPER, DEFAULT_TIMEOUT);
}
int
@@ -101,25 +101,25 @@ main (int argc, char *argv[])
switch (c) {
case 0: /* options which are long only */
if (strcmp (long_options[option_index].name, "helper") == 0)
- helper = optarg;
+ helper = optarg;
else if (strcmp (long_options[option_index].name, "qemu") == 0)
- set_qemu (optarg, 0);
+ set_qemu (optarg, 0);
else if (strcmp (long_options[option_index].name, "qemudir") == 0)
- set_qemu (optarg, 1);
+ set_qemu (optarg, 1);
else {
- fprintf (stderr,
- _("libguestfs-test-tool: unknown long option: %s (%d)\n"),
- long_options[option_index].name, option_index);
- exit (1);
+ fprintf (stderr,
+ _("libguestfs-test-tool: unknown long option: %s (%d)\n"),
+ long_options[option_index].name, option_index);
+ exit (1);
}
break;
case 't':
if (sscanf (optarg, "%d", &timeout) != 1 || timeout < 0) {
- fprintf (stderr,
- _("libguestfs-test-tool: invalid timeout: %s\n"),
- optarg);
- exit (1);
+ fprintf (stderr,
+ _("libguestfs-test-tool: invalid timeout: %s\n"),
+ optarg);
+ exit (1);
}
break;
@@ -129,8 +129,8 @@ main (int argc, char *argv[])
default:
fprintf (stderr,
- _("libguestfs-test-tool: unexpected command line option 0x%x\n"),
- c);
+ _("libguestfs-test-tool: unexpected command line option
0x%x\n"),
+ c);
exit (1);
}
}
@@ -152,19 +152,19 @@ main (int argc, char *argv[])
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to create libguestfs handle\n"));
+ _("libguestfs-test-tool: failed to create libguestfs handle\n"));
exit (1);
}
if (guestfs_add_drive (g, tmpf) == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to add drive '%s'\n"),
- tmpf);
+ _("libguestfs-test-tool: failed to add drive '%s'\n"),
+ tmpf);
exit (1);
}
if (guestfs_add_drive (g, isof) == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to add drive '%s'\n"),
- isof);
+ _("libguestfs-test-tool: failed to add drive '%s'\n"),
+ isof);
exit (1);
}
@@ -175,7 +175,7 @@ main (int argc, char *argv[])
exit (1);
}
printf ("library version:
%"PRIi64".%"PRIi64".%"PRIi64"%s\n",
- vers->major, vers->minor, vers->release, vers->extra);
+ vers->major, vers->minor, vers->release, vers->extra);
guestfs_free_version (vers);
printf ("guestfs_get_append: %s\n", guestfs_get_append (g) ? :
"(null)");
@@ -188,7 +188,7 @@ main (int argc, char *argv[])
/* Launch the guest handle. */
if (guestfs_launch (g) == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to launch appliance\n"));
+ _("libguestfs-test-tool: failed to launch appliance\n"));
exit (1);
}
@@ -199,7 +199,7 @@ main (int argc, char *argv[])
if (guestfs_wait_ready (g) == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed or timed out in
'wait_ready'\n"));
+ _("libguestfs-test-tool: failed or timed out in
'wait_ready'\n"));
exit (1);
}
@@ -211,31 +211,31 @@ main (int argc, char *argv[])
/* Create the filesystem and mount everything. */
if (guestfs_sfdiskM (g, "/dev/sda", sfdisk_lines) == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to run sfdisk\n"));
+ _("libguestfs-test-tool: failed to run sfdisk\n"));
exit (1);
}
if (guestfs_mkfs (g, "ext2", "/dev/sda1") == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to mkfs.ext2\n"));
+ _("libguestfs-test-tool: failed to mkfs.ext2\n"));
exit (1);
}
if (guestfs_mount (g, "/dev/sda1", "/") == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to mount /dev/sda1 on /\n"));
+ _("libguestfs-test-tool: failed to mount /dev/sda1 on /\n"));
exit (1);
}
if (guestfs_mkdir (g, "/iso") == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to mkdir /iso\n"));
+ _("libguestfs-test-tool: failed to mkdir /iso\n"));
exit (1);
}
if (guestfs_mount (g, "/dev/sdb", "/iso") == -1) {
fprintf (stderr,
- _("libguestfs-test-tool: failed to mount /dev/sdb on /iso\n"));
+ _("libguestfs-test-tool: failed to mount /dev/sdb on /iso\n"));
exit (1);
}
@@ -243,7 +243,7 @@ main (int argc, char *argv[])
str = guestfs_command (g, helper_args);
if (str == NULL) {
fprintf (stderr,
- _("libguestfs-test-tool: could not run helper program, or helper
failed\n"));
+ _("libguestfs-test-tool: could not run helper program, or helper
failed\n"));
exit (1);
}
free (str);
@@ -282,8 +282,8 @@ set_qemu (const char *path, int use_wrapper)
if (!use_wrapper) {
if (access (path, X_OK) == -1) {
fprintf (stderr,
- _("Binary '%s' does not exist or is not executable\n"),
- path);
+ _("Binary '%s' does not exist or is not executable\n"),
+ path);
exit (1);
}
@@ -296,8 +296,8 @@ set_qemu (const char *path, int use_wrapper)
if (stat (buffer, &statbuf) == -1 ||
!S_ISDIR (statbuf.st_mode)) {
fprintf (stderr,
- _("%s: does not look like a qemu source directory\n"),
- path);
+ _("%s: does not look like a qemu source directory\n"),
+ path);
exit (1);
}
@@ -312,10 +312,10 @@ set_qemu (const char *path, int use_wrapper)
fp = fdopen (fd, "w");
fprintf (fp,
- "#!/bin/sh -\n"
- "qemudir='%s'\n"
- "\"$qemudir\"/",
- path);
+ "#!/bin/sh -\n"
+ "qemudir='%s'\n"
+ "\"$qemudir\"/",
+ path);
/* Select the right qemu binary for the wrapper script. */
#ifdef __i386__
@@ -349,7 +349,7 @@ preruncheck (void)
"available. Expected to find it in '%s'\n"
"\n"
"Use the --helper option to specify the location of this program.\n"),
- helper);
+ helper);
exit (1);
}
@@ -372,7 +372,7 @@ preruncheck (void)
_("Test tool helper program %s\n"
"is not statically linked. This is a build error when this test tool\n"
"was built.\n"),
- helper);
+ helper);
exit (1);
}
}
@@ -399,11 +399,11 @@ make_files (void)
close (fd);
snprintf (cmd, sizeof cmd, "mkisofs -quiet -rJT -o '%s'
'%s'",
- isof, helper);
+ isof, helper);
r = system (cmd);
if (r == -1 || WEXITSTATUS(r) != 0) {
fprintf (stderr,
- _("mkisofs command failed: %s\n"), cmd);
+ _("mkisofs command failed: %s\n"), cmd);
exit (1);
}
diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl
index fb1f220..11d7cfd 100755
--- a/v2v/virt-v2v.pl
+++ b/v2v/virt-v2v.pl
@@ -160,9 +160,9 @@ Set the output guest name.
=cut
GetOptions ("help|?" => \$help,
- "version" => \$version,
- "connect|c=s" => \$uri,
- "output|o=s" => \$output,
+ "version" => \$version,
+ "connect|c=s" => \$uri,
+ "output|o=s" => \$output,
) or pod2usage (2);
pod2usage (1) if $help;
if ($version) {
@@ -192,7 +192,7 @@ my @partitions = get_partitions ($g);
# Now query each one to build up a picture of what's in it.
my %fses =
inspect_all_partitions ($g, \@partitions,
- use_windows_registry => $use_windows_registry);
+ use_windows_registry => $use_windows_registry);
#print "fses -----------\n";
#print Dumper(\%fses);
--
1.6.4.212.g4719
From 7d4c9fb1a00360570557997a97951cfe94d53d68 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 10:55:34 -0400
Subject: [PATCH 2/2] Document and enforce the new spaces-only indentation policy.
* cfg.mk (disable_temporarily): Remove sc_TAB_in_indentation,
to enable the "make syntax-check" that enforces this.
* .x-sc_TAB_in_indentation: New file. Exceptions.
* HACKING: Document the policy, with tips on how to conform.
---
.x-sc_TAB_in_indentation | 8 ++++++++
HACKING | 23 +++++++++++++++++++++++
cfg.mk | 5 ++---
3 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 .x-sc_TAB_in_indentation
diff --git a/.x-sc_TAB_in_indentation b/.x-sc_TAB_in_indentation
new file mode 100644
index 0000000..c73edf2
--- /dev/null
+++ b/.x-sc_TAB_in_indentation
@@ -0,0 +1,8 @@
+^appliance/debian/modules/
+^images/
+^COPYING$
+^\.gitmodules$
+(^|\/)ChangeLog[^/]*$
+(^|\/)(?:GNU)?[Mm]akefile[^/]*$
+\.(am|mk)$
+^po/Rules-quot$
diff --git a/HACKING b/HACKING
index c6a3022..090b918 100644
--- a/HACKING
+++ b/HACKING
@@ -24,6 +24,29 @@ Please make sure that the code compiles without warnings.
Please test any changes.
+Code indentation
+----------------------------------------------------------------------
+Our C source code generally adheres to some basic code-formatting
+conventions. The existing code base is not totally consistent on this
+front, but we do prefer that contributed code be formatted similarly.
+In short, use spaces-not-TABs for indentation, use 4 spaces for each
+indentation level, and other than that, follow the K&R style.
+
+If you use Emacs, add the following to one of one of your start-up files
+(e.g., ~/.emacs), to help ensure that you get indentation right:
+
+ ;;; When editing C sources in libguestfs, use this style.
+ (defun libguestfs-c-mode ()
+ "C mode with adjusted defaults for use with libguestfs."
+ (interactive)
+ (c-set-style "K&R")
+ (setq indent-tabs-mode nil) ; indent using spaces, not TABs
+ (setq c-indent-level 4)
+ (setq c-basic-offset 4))
+ (add-hook 'c-mode-hook
+ '(lambda () (if (string-match "/libguestfs" (buffer-file-name))
+ (libguestfs-c-mode))))
+
Directories
----------------------------------------------------------------------
diff --git a/cfg.mk b/cfg.mk
index e92c34f..7130cea 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -65,7 +65,6 @@ local-checks-to-skip = \
disable_temporarily = \
sc_makefile_TAB_only_indentation \
sc_unmarked_diagnostics \
- sc_TAB_in_indentation \
sc_prohibit_ctype_h \
sc_prohibit_asprintf \
sc_m4_quote_check \
@@ -107,10 +106,10 @@ sc_prohibit_ctype_h:
1>&2; exit 1; } || :
# Ensure that no C source file uses TABs for indentation.
+# Exclude some version-controlled symlinks.
sc_TAB_in_indentation:
@grep -lE '^ * ' /dev/null \
- $$($(VC_LIST_EXCEPT) \
- | grep -E '\.[ch](\.in)?$$') && \
+ $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found TAB(s) used for indentation in C sources;'\
'use spaces' 1>&2; exit 1; } || :
--
1.6.4.212.g4719