#!/usr/bin/ksh
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# vxpref - CGI script to view the patchdiag.xref file from Sun
#
# Author: Bernd Schemmer, Bernd.Schemmer@gmx.de
#
# credits: Heiner Steven (heiner.steven@odn.de)
#
# History: 03/08/2005 0.0.1 /bs - initial release
# 03/09/2005 0.0.2 /bs - minor enhancements
# 04/04/2005 0.0.3 /bs - made the local patch directory variabel
# massiv performance enhancements
# 04/06/2005 0.0.4 /bs - minor performance enhancements
# 06/13/2005 0.0.5 /bs - corrected a bug in the handling of obsolete patches
#
#
#
# Installation: Copy the script to the cgi-bin directory of your web server
#
# Usage: create a link for the script without any parameter
#
# License: Freeware
#
# disable filename globbing
set -f
__VERSION="0.0.5"
__SCRIPTNAME="${0##*/}"
AUTHOR="Bernd Schemmer"
AUTHOR_EMAIL_ADDRESS="Bernd.Schemmer@gmx.de"
AUTHOR_MESSAGE="
vxpref version
${__VERSION}.
written by ${AUTHOR}, ${AUTHOR_EMAIL_ADDRESS}
"
AUTHOR_MESSAGE_SHORT="
vxpref version
${__VERSION}.
(c) ${AUTHOR_EMAIL_ADDRESS}
"
# change the following variables to your need
#
PATCHDIAG_XREF_FILE_DIR="/export/install/tools"
PATCHDIAG_XREF_FILE="${PATCHDIAG_XREF_FILE_DIR}/patchdiag.xref"
LOCAL_PATCH_DIRECTORY="/export/install/All_Patches"
### -----------------------------------------------------------------
### Subroutines
#
# Code for ConvertString based on a script from
# Heiner Steven (heiner.steven@odn.de)
#
ConvertString() {
echo "$1" | awk '
BEGIN {
hextab ["0"] = 0; hextab ["8"] = 8;
hextab ["1"] = 1; hextab ["9"] = 9;
hextab ["2"] = 2; hextab ["A"] = hextab ["a"] = 10
hextab ["3"] = 3; hextab ["B"] = hextab ["b"] = 11;
hextab ["4"] = 4; hextab ["C"] = hextab ["c"] = 12;
hextab ["5"] = 5; hextab ["D"] = hextab ["d"] = 13;
hextab ["6"] = 6; hextab ["E"] = hextab ["e"] = 14;
hextab ["7"] = 7; hextab ["F"] = hextab ["f"] = 15;
if ("'"$EncodedLF"'" == "yes") EncodedLF = 1; else EncodedLF = 0
}
{
decoded = ""
i = 1
len = length ($0)
while ( i <= len ) {
c = substr ($0, i, 1)
if ( c == "%" ) {
if ( i+2 <= len ) {
c1 = substr ($0, i+1, 1)
c2 = substr ($0, i+2, 1)
if ( hextab [c1] == "" || hextab [c2] == "" ) {
print "WARNING: invalid hex encoding: %" c1 c2 | \
"cat >&2"
} else {
code = 0 + hextab [c1] * 16 + hextab [c2] + 0
#print "\ncode=", code
c = sprintf ("%c", code)
i = i + 2
}
} else {
print "WARNING: invalid % encoding: " substr ($0, i, len - i)
}
} else if ( c == "+" ) { # special handling: "+" means " "
c = " "
}
decoded = decoded c
++i
}
if ( EncodedLF ) {
printf "%s", decoded # no line newline on output
} else {
print decoded
}
}
' -
}
### -----------------------------------------------------------------
# old and not alaways working version
XConvertString() {
typeset SRC_STRING="$*"
bash -c "printf '$( echo "$( echo "${SRC_STRING}" | tr "+" " " )" | sed 's/%/\\x/g' )' "
}
### -----------------------------------------------------------------
## substr
##
## get a substring of a string
##
## usage: variable=$( substr sourceStr pos length )
## or substr sourceStr pos length resultStr
##
## returns: 1 - parameter missing
## 0 - parameter okay
##
substr() {
typeset resultstr=""
typeset THISRC=1
if [ "$1"x != ""x ] ; then
typeset s=$1
typeset p=$2
typeset l=$3
[ "$l"x = ""x ] && l=${#s}
[ "$p"x = ""x ] && p=1
resultstr="$( echo $s | cut -c${p}-$((${p}+${l}-1)) )"
THISRC=0
else
THISRC=1
resultstr="$1"
fi
if [ "$4"x != ""x ] ; then
eval $4=\"${resultstr}\"
else
echo ${resultstr}
fi
return ${THISRC}
}
### -----------------------------------------------------------------
LogMsg() {
typeset THISMSG="$*"
[ "${PAGE_TYPE}" = "html" ] && echo "${THISMSG}
" || echo "${THISMSG}"
}
### -----------------------------------------------------------------
LogErrorMsg() {
typeset THISMSG="$*"
LogMsg "ERROR: ${THISMSG}"
}
### -----------------------------------------------------------------
LogWarningMsg() {
typeset THISMSG="$*"
LogMsg "WARNING: ${THISMSG}"
}
### -----------------------------------------------------------------
LogInfoMsg() {
typeset THISMSG="$*"
LogMsg "INFO: ${THISMSG}"
}
### -----------------------------------------------------------------
GetXrefFileVersion() {
typeset THISFILE="$1"
typeset XREF_VERSION=""
typeset XREF_HEADER_MARKER="## PATCHDIAG TOOL CROSS-REFERENCE FILE AS OF"
if [ -f ${PATCHDIAG_XREF_FILE} ] ; then
XREF_VERSION=$( grep "${XREF_HEADER_MARKER}" ${THISFILE} )
XREF_VERSION=${XREF_VERSION#*AS OF}
XREF_VERSION=${XREF_VERSION%*##}
fi
echo ${XREF_VERSION}
}
### -----------------------------------------------------------------
PrintPageHeader() {
if [ "${PAGE_TYPE}" = "html" ] ; then
cat <
Patchdiag xref
EOT
else
cat <"
echo ""
else
echo ""
fi
}
### -----------------------------------------------------------------
PrintEmptyFrame() {
PrintPageHeader
PrintPageFooter
}
### -----------------------------------------------------------------
PrintFrameSet() {
cat <
Patchdiag.xref - Analyse