#!/bin/sh
#
# Modify a xpm file such, that it can be directly included into resource files
#
# written by: Harald Albrecht, albrecht@igpm.rwth-aachen.de
# 1.00 (03.05.1994)
#

if test "$3" = "" 
then 
    echo "usage: xpm2rsc <source xpm file> <resource file> \\"
    echo "               <resource entry to add/replace>"
    echo ""
    echo "<source xpm file>  Name of the file with the pixmap in xpm format"
    echo "<resource file>    Name of the resource file to which the xpm file"
    echo "                   is to be added"
    echo "<resource entry>   Name of the resource entry, e.g. *.ok.normalFace"
    exit
fi

ReplaceEntry=`echo "$3" | sed -e "s/\\*/\\\\\\\\\\*/g; s/\\?/\\\\\\\\\\?/g"`
sed -e "/$ReplaceEntry: \\\\/,/};/ d" $2 > /usr/tmp/xpm2rsc
echo "$3: \\" >> /usr/tmp/xpm2rsc
sed -e "s/\",/\",\\\\n\\\\/g;s/{/{\\\\n\\\\/g;s/\\*\\//\\*\\/\\\\n\\\\/g" $1 >> /usr/tmp/xpm2rsc
mv -f /usr/tmp/xpm2rsc $2

echo "$1 added/replaced."
