summaryrefslogtreecommitdiffstats
path: root/build-aux/xdrgen
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/xdrgen')
-rwxr-xr-xbuild-aux/xdrgen90
1 files changed, 47 insertions, 43 deletions
diff --git a/build-aux/xdrgen b/build-aux/xdrgen
index b5f33d372..e826111b9 100755
--- a/build-aux/xdrgen
+++ b/build-aux/xdrgen
@@ -1,23 +1,9 @@
#!/bin/bash
-_init ()
-{
- xfile="$1";
-
- cfile="${1%.x}.c";
- hfile="${1%.x}.h";
-
- tmp_cfile="$1.c";
-
- tmp1_hfile="$1.h.tmp";
- tmp1_cfile="$1.c.tmp";
-
-}
-
append_licence_header ()
{
- src_file=$1;
- dst_file=$2;
+ local src_file=$1;
+ local dst_file=$2;
cat >$dst_file <<EOF
/*
@@ -47,47 +33,65 @@ EOF
}
-main ()
+gen_sources ()
{
- if [ $# -ne 1 ]; then
- echo "wrong number of arguments given"
- echo " $0 <XDR-definition-file>.x"
- exit 1;
- fi
+ local xfile="$1";
+
+ local cfile="${1%.x}.c";
+ local hfile="${1%.x}.h";
+ local tmp_cfile="$1.c.tmp";
+ local tmp_hfile="$1.h.tmp";
- echo -n "writing the XDR routine file ($tmp_cfile) ... ";
+ rm -f $cfile;
+ rpcgen -c -o $cfile $xfile;
+ append_licence_header $cfile $tmp_cfile;
+ mv $tmp_cfile $cfile;
+ # remove unwanted temporary files (if any)
rm -f $tmp_cfile;
- rpcgen -c -o $tmp_cfile $xfile;
+ echo "Generated $cfile"
+ return
+}
+
+gen_headers ()
+{
+ local xfile="$1";
+
+ local cfile="${1%.x}.c";
+ local hfile="${1%.x}.h";
- echo "OK";
+ local tmp_cfile="$1.c.tmp";
+ local tmp_hfile="$1.h.tmp";
# no need for a temporary file here as there are no changes from glusterfs
- echo -n "writing the XDR header file ($hfile) ... ";
rm -f $hfile;
rpcgen -h -o $hfile $xfile;
-
# the '#ifdef' part of file should be fixed
sed -i -e 's/-/_/g' $hfile;
-
- echo "OK";
-
- echo -n "writing licence header to the generated files ... ";
- # Write header to temp file and append generated file
- append_licence_header $hfile $tmp1_hfile;
- append_licence_header $tmp_cfile $tmp1_cfile;
- echo "OK"
-
+ # Gen header to temp file and append generated file
+ append_licence_header $hfile $tmp_hfile;
# now move the destination file to actual original file
- echo -n "updating existing files ... ";
- mv $tmp1_hfile $hfile;
- mv $tmp1_cfile $cfile;
+ mv $tmp_hfile $hfile;
+ rm -f $tmp_hfile;
+ echo "Generated $hfile";
+ return
+}
- # remove unwanted temporary files (if any)
- rm -f $tmp_cfile $tmp1_cfile $tmp1_hfile
+main ()
+{
+ if [ $# -ne 2 ]; then
+ echo "wrong number of arguments given"
+ echo " $0 [header|source] <XDR-definition-file>.x"
+ exit 1;
+ fi
- echo "OK"
+ if [ $1 == "header" ]; then
+ gen_headers $2
+ fi
+ if [ $1 == "source" ]; then
+ gen_sources $2
+ fi
}
-_init "$@" && main "$@";
+main "$@";