[dd40e6]: qsa_check Maximize Restore History

Download this file

qsa_check    113 lines (97 with data), 1.7 kB

#!/bin/sh

need_qsa="QSA 1.1.4 (or newer, for QT3) is needed"

#Output error message (if not silent)
print_fail() {
 echo " $msg"
 if [ -n "$msg_ex" ]
 then
  echo " $msg_ex"
 fi
 if [ -n "$silent" ]
 then
  #die 'silently'
  return 1
 fi
 echo " $need_qsa"
 return 1
}

try_it() {

if [ -z "$1" ]
then
 QSAINCDIR=$QTDIR/include
else
 QSAINCDIR=$1
fi
echo "Looking for QSA includes at $QSAINCDIR"
msg_ex=''

if [ -r $QSAINCDIR/qsaglobal.h ]
then
 vers=`grep 'define.*QSA_VERSION_M' <$QSAINCDIR/qsaglobal.h |sed 's/#define//'`
 major=`echo $vers |sed 's/.*MAJOR *\([0-9]*\).*/\\1/'`
 minor=`echo $vers |sed 's/.*MINOR *\([0-9]*\).*/\\1/'`
 micro=`echo $vers |sed 's/.*MICRO *\([0-9]*\).*/\\1/'`
 tvers="(version $major.$minor.$micro)"
 if [ $major -ne 1 ]
 then
  msg="Bad version of QSA found $tvers."
  print_fail
  return 1
 fi
 if [ $minor -lt 1 ]
 then
  msg="Too old version of QSA found $tvers."
  print_fail
  return 1
 fi
 if [ $minor -gt 1 ]
 then
  msg_ex="QSA 1.2.x (or newer) is only for QT4. We are using QT3."
  msg="Too recent version of QSA found $tvers."
  print_fail
  return 1
 fi
 if [ $micro -lt 4 ]
 then
  msg_ex="QSA version 1.1.3 or older have bugs that are critical to PDF editor."
  msg="Too old version of QSA found $tvers."
  print_fail
  return 1
 fi
 #ok ... found
 echo "Foud usable QSA $tvers."
 return 0
else
 msg="QSA not found."
 print_fail
 return 1
fi
}

if [ -n "$1" ]
then
 #look at custom place
 try_it $1
 exit $?
fi

silent=1

# try QTDIR first
try_it
ret=$?

if [ $ret -eq 0 ]
then
 exit 0
fi

# try something other then

try_it /usr/qt/3/include
ret=$?

if [ $ret -eq 0 ]
then
 exit 0
fi

try_it /usr/include
ret=$?

if [ $ret -eq 0 ]
then
 exit 0
fi

echo "$need_qsa"

exit $ret