#!/bin/sh

# This file is part of the KDE project
# Copyright (C) 2002 Paul Chitescu <paulc-devel@null.ro>
# License: Open Source, Use On Your Own Risk
#
# Konqueror/Embedded ZIP List to HTML data filter
#
# Requires: sh, sed, zipinfo (unzip)
#
# Usage: in your konq-embedrc file,
#
# [MIME Handlers]
# application/zip,.zip=|text/html|/path/to/this/file

# you shouldn't need to change anything below
sedhtml='s/&/\&amp;/g; s/"/\&quot;/g; s/</\&lt;/g; s/>/\&gt;/g'
title='zip: '`echo -n "$FILTER_URL" | sed "$sedhtml"`
echo -n "<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY>"
echo "<PRE><B>$title</B><BR/><HR/>"
case "$FILTER_URL" in
file:/*)
    zipinfo -1 `echo "$FILTER_URL" | sed 's,^file:,,'` | sed "$sedhtml"
    ;;
*)
    tmpf=/tmp/.konqe-dl-$$.zip
    cat >$tmpf
    zipinfo -1 $tmpf | sed "$sedhtml"
    rm $tmpf
    ;;
esac
echo '</PRE></BODY></HTML>'
