From f0f3b040dfa062021d3a193e5a19c380eb5e908d Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 29 Aug 2011 17:53:24 +0530 Subject: modify to the way we used XDR definitions files (.x files) Earlier: step 1: copy the existing .x files to /tmp step 2: generate '.[ch]' files using 'rpcgen .x' step 3: check diff with the to the existing files, add only your part of changes back to the original file. (ignore other changes). step 4: there is another file to write wrapper functions to convert structures to/from XDR buffers, update it with your new structure. step 5: use these wrapper functions in the newly written procedures. step 6: commit :-| Now: step 1: update (mostly adding only) the .x file step 2: run '/extras/generate-xdr-files.sh .x' command step 3: implement rpc procedure to handle the request/response. step 4: commit :-) Change-Id: I219f9159fc980438c86e847c6b030be96e595ea2 BUG: 3488 Reviewed-on: http://review.gluster.com/341 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- extras/generate-xdr-files.sh | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 extras/generate-xdr-files.sh (limited to 'extras') diff --git a/extras/generate-xdr-files.sh b/extras/generate-xdr-files.sh new file mode 100755 index 000000000..fd1733bc8 --- /dev/null +++ b/extras/generate-xdr-files.sh @@ -0,0 +1,100 @@ +#!/bin/sh + +_init () +{ + xfile="$1"; + # TODO: check the validity of .x file + + 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; + + cat >$dst_file < + This file is part of GlusterFS. + + GlusterFS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + GlusterFS is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + . +*/ + +#include "xdr-common.h" + +EOF + + cat $src_file >> $dst_file; + +} + +main () +{ + if [ $# -ne 1 ]; then + echo "wrong number of arguments given" + echo " $0 .x" + exit 1; + fi + + + echo -n "writing the XDR routine file ($tmp_cfile) ... "; + rm -f $tmp_cfile; + rpcgen -c -o $tmp_cfile $xfile; + + # get rid of warnings in xdr .c file due to "unused variable 'buf'" + sed -i -e 's:buf;$:buf;\ + buf = NULL;:' $tmp_cfile; + + sed -i '/int i;/d' $tmp_cfile; + + echo "OK"; + + # 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:\(.*\)-\(.*\)_H_RPCGEN:\1_\2_H_RPCGEN: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" + + # now move the destination file to actual original file + echo -n "updating existing files ... "; + mv $tmp1_hfile $hfile; + mv $tmp1_cfile $cfile; + + # remove unwanted temporary files (if any) + rm -f $tmp_cfile $tmp1_cfile $tmp1_hfile + + echo "OK" + +} + +_init "$@" && main "$@"; -- cgit