#!/bin/sh
# Module: MIME 
# build-mime-types.sh 
# Derechos Reservados (c) 2002 Sandino Araico Sánchez
# Derechos Reservados (c) 2002 Presidencia de la República
# Copyright (c) 2002 Sandino Araico Sánchez All rights reserved

# --COMIENZA LICENCIA EN ESPAÑOL MEXICANO-------------------------------------
# Por éste medio se otroga permiso, libre de cargo, a cualquier persona que
# obtenga una copia de este software y archivos de documentación asociados
# (el "Software"), a utilizar el Software sin restricción, incluyendo sin 
# limitación los derechos de usar, copiar, modificar, unir, publicar, 
# distribuir y/o vender copias de el Software, y permitir lo mismo a personas 
# a quienes les sea entregado el software, siempre y cuando los avisos de 
# Derechos reservados y Copyright que aparecen arriba y éste permiso (en 
# español y en inglés) aparezcan en todas las copias de el Software y que 
# tanto los avisos de Derechos reservados y Copyright que aparecen arriba como
# éste permiso (en español y en inglés) aparezcan en la documentación de
# soporte.
#
# ESTE SOFTWARE SE PROVEE "TAL CUAL", SIN NINGUNA GARANTÍA DE NINGÚN TIPO,
# EXPRESA O IMPLÍCITA, INCLUYENDO PERO NO LIMITÁNDOSE A LAS GARANTÍAS DE
# MERCANTIBILIDAD, ADECUACIÓN PARA UN PROPÓSITO EN PARTICULAR Y NO 
# INFRACCIÓN DE LOS DERECHOS DE TERCERAS PARTES. EN NINGÚN MOMENTO EL O LOS 
# TITULARES DE LOS DERECHOS DE AUTOR Y COPYRIGHT INCLUIDOS EN ESTE AVISO SERÁN
# RESPONSABLES POR CUALQUIER RECLAMACIÓN O POR CUALQUIER DAÑO ESPECIAL,
# INDIRECTO O CONSECUENTE, O CUALQUIER DAÑO QUE RESULTE DE LA PÉRDIDA DE USO,
# DATOS O GANANCIAS, YA SEA EN UNA ACCIÓN DE CONTRATO, NEGLIGENCIA U OTRA 
# ACCIÓN TORTUORIA, RESULTANTE DE O EN CONEXIÓN CON EL USO O DESEMPEÑO DE
# ESTE SOFTWARE.
#
# Excepto que se incluya en éste aviso, no se debe usar el nombre de ningún 
# titular de Derechos de autor o Copyright en publicidad o de otra manera 
# psra promover la venta, uso u otros tratos en este Software sin previa 
# autorización por escrito del titular de Derechos de autor o Copyright.
# --TERMINA LICENCIA----------------------------------------------------------
#
# --BEGIN LICENSE IN US ENGLISH-----------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, provided that the above
# copyright and "Derechos reservados" notices and this permission notice  
# (in spanish and english) appear in all copies of the Software and that both 
# the above copyright and "Derechos reservados" notices and this permission 
# notice (in spanish and english) appear in supporting documentation.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT AND "DERECHOS DE 
# AUTOR" HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 
# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# 
# Except as contained in this notice, the name of a copyright or "Derechos de
# autor" holder shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written 
# authorization of the copyright or "Derechos de autor" holder.
# --END LICENSE---------------------------------------------------------------

# Changelog:
# 2002-05-16 Sandino Araico Sánchez - Script to build mime-types.inc
 
cat > mime-types.inc <<EOF
<?
# Module: MIME 
# mime-types.inc 
/* This is an automatically-generated file.
 * The source file is mime.src.
 * This file should not be edited by hand, instead mime.src should be edited 
 * and ./build-mime-types.sh should be executed after.
 *
 * Este es un archivo generado automáticamente.
 * El archivo fuente es mime.src.
 * Este archivo no debe editarse a mano, en su lugar debe esitarse mime.src
 * y después ./build-mime-types.sh debe ser ejecutado.
 */

if(!defined("__HOPP_MIME_TYPES"))
{
define ("__HOPP_MIME_TYPES",1);
#---------------------------------------------------------------------

EOF

for i in `cat mime.src | grep -v '#' | cut -d ' ' -f 1` ; do
	for j in `cat mime.src | grep $i | cut -d ' ' -f 2-999` ; do
		k=`echo $j | sed 's/^\.//'`
		echo "if(!defined('__HOPP_MIME_TYPE_$k'))" >> mime-types.inc
		echo "	define ('__HOPP_MIME_TYPE_$k', '$i');" >> mime-types.inc
	done
done

cat >> mime-types.inc <<EOF
#---------------------------------------------------------------------
} //__HOPP_MIME_TYPES
?>
EOF


