@echo off
rem aiftool.bat
echo AIF tool
echo Copyright (C) Symbian 1998

if "%1"=="" goto help
if "%1"=="/?" goto help
if "%1"=="/h" goto help
if "%1"=="/H" goto help

if "%temp%"=="" goto notemp1
if not exist %temp%\nul goto notemp1
set _tempdir=%temp%
goto gottemp
:notemp1

if "%tmp%"=="" goto notemp2
if not exist %tmp%\nul goto notemp2
set _tempdir=%tmp%
goto gottemp
:notemp2

set _tempdir=C:

:gottemp

echo Compiling resource file
cpp -I\. -I..\inc -I..\..\epoc32\include < %1.RSS > %1.RPP
rcomp -oaif.Rsc -h%1.rs~ -i%1.RSS -s%1.RPP
if errorlevel==1 goto terminated
rem if not exist \epoc32\wins\c\aiftool\nul md \epoc32\wins\c\aiftool
copy aif.rsc %_tempdir%\aif.rsc
del %1.rs~
del %1.rpp
del aif.rsc

echo Copying mbm
copy %2 %_tempdir%\aif.mbm
if errorlevel==1 goto terminated

echo Running AIF writer
call \epoc32\release\winc\deb\aiftool.exe %_tempdir%\
copy %_tempdir%\out.aif %1.aif

goto end

:help

echo.
echo AIFTOOL filename mbmname
echo Use this command to produce an AIF from
echo -	a resource file containing language, caption
echo 	and capability specifications
echo -	a multi-bitmap file containing icons and masks
echo 	in various sizes
echo Specify
echo	filename: the name of the input resource file; the
echo		.rss extension is added by AIFTOOL
echo	mbmname: the name of the input .mbm file: you
echo		must specify the extension
goto finalend

:terminated
echo Error: conversion terminated :-(

:end
erase %_tempdir%\aif.rsc
erase %_tempdir%\aif.mbm
erase %_tempdir%\out.aif

:finalend
set _tempdir=
