# $Id: check_common_fn,v 1.4 2003/02/26 17:55:56 rocky Exp $

have_cmp() {
    if cmp /dev/null /dev/null > /dev/null 2>&1; then
	:
    else

	return 1;
    fi

    if cmp /dev/zero /dev/null > /dev/null 2>&1; then
	return 1;
    fi

    return 0;
}

do_cksum() {
    while read CRC SIZE NAME; do
	CRC2=0; SIZE2=0; NAME2=""
	if cksum "$NAME" | (
		read CRC2 SIZE2 NAME2

		if [ "$CRC" != "$CRC2" ]; then
		    echo "$0: CRC didn't match for $NAME ($CRC != $CRC2)"
		    return 0;
		fi

		if [ "$SIZE" != "$SIZE2" ]; then
		    echo "$0: SIZE didn't match for $NAME ($SIZE != $SIZE2)"
		    return 0;
		fi

		return 1
	    );
	    then
	    return 1; 
	fi
    done

    return 0;
}

have_cksum() {
    if cksum /dev/null > /dev/null 2>&1; then
	:
    else
	return 1;
    fi

    return 0;
}

check_result() {
  RC=$1
  shift
  msg=$*
  if test $RC -ne 0 ; then 
    if test $RC -ne 77 ; then
      echo "$0: $msg failed."
      exit $RC
    else 
      echo "$0: $msg skipped."
    fi
  else 
    echo "$0: $msg ok."
  fi
}

#;;; Local Variables: ***
#;;; mode:shell-script ***
#;;; eval: (sh-set-shell "bash") ***
#;;; End: ***
