%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% HTMLforTeX by Anthony Phan.
% file: htmlinux.tex (system-dependent control sequences)
% last modification: December 9, 2003.
%
% SYSTEM DEPENDENT !!!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This file does not so much things. Feel free to make changes.
% (but, please, change file's name or send me suggestions)
%
\immediate\write16{Beware: system-dependent control sequences
that have been tested on a decent Linux based system.}%
%
\catcode`\@=11
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% COLORS, IMAGES AND SOUND
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \choose@color#1 \restore@color \define@color#1#2
% \default@color \highlight@color
% must be defined. They appear explicitely
% in htm2tex.tex
%
% Next control sequence needs some external programs
% assuming dvips specifications.
%
\def\imagesf{0.623}% System oriented
\def\@pnmtops{pnmtops -scale \imagesf\space -dpi 600
	-nocenter -noturn -nosetpage}%
\def\@infinite{infinite}% may be nice for `loop' attribute
\def\finite@loop#1#2{\ifx\@loop\@infinite#2\else#1\fi}%
%
% shell script
%
\def\shell@loop#1{\finite@loop{loop=1;
		while test $loop -le \@loop;
		do loop=$[$loop+1]; #1; done &}%$ (dollar just for matching)
		{while true; do #1; done &}}%
%
\def\HTMLmultimedia{%
\def\with@distant@URL@do##1{}%wget \@URL -O TeXscape.tmp; ##1 TeXscape.tmp}%
\def\HTMLspecial##1{\special{html:<##1>}}%
\def\HTMLmedia{\ifx\@URL\undefined\else
	\decode@URL
	\expandafter\@find@suffix\@URL\in{
	[gif][GIF]={\with@URL@do{giftopnm} | \@pnmtops}
	[jpg][JPG][jpe][JPE][jpeg][JPEG]={%
		\with@URL@do{djpeg -pnm} | \@pnmtops}
	[pic][pict][PIC][PICT]={picttopnm \decoded@URL | \@pnmtops}
	[png][PNG]={\with@URL@do{pngtopnm} | \@pnmtops}
	[ras][RAS]={\with@URL@do{rasttopnm}| \@pnmtops}
	[tif][TIF][tiff][TIFF]={\with@URL@do{tifftopnm} | \@pnmtops}
	[xbm][XBM]={\with@URL@do{xbmtopbm} | \@pnmtops}
	[avi][AVI][mov][MOV][mpeg][MPEG][mpg][MPG][qt][QT]={%
		\with@URL@do{xanim \finite@loop{+l\@loop\space+Ze}{} -Zr +q} &}
%	[mpeg][MPEG][mpg][MPG]={%
%		\shell@loop{mpeg_play -controls off -quiet \decoded@URL}}
	% [mid][MID][midi][MIDI][snd][SND] are not supported
	[aif][AIF][aiff][AIFF][au][AU][wav][WAV]={%
		\shell@loop{\with@URL@do{play}}}
	[mp3][MP3]={\shell@loop{\with@URL@do{mpg123 -q}}}
	}%
	\ifx\@result\@default\message{[unknown file format]}%
	\else\special{psfile="`\@result"}\fi\fi}%
	}%
%
\def\HTMLcolors{%
	\let\bg@leaders=\bg@solid@leaders
        \let\bg@backbox=\bg@solid@backbox
	\def\define@color##1##2{\expandafter\define@@color##2\@@##1}%
	\def\choose@color##1{\let\current@color=##1%
		\special{color push \current@color}}%
	\def\background@color##1{\special{background ##1}}%
	\def\restore@color{\special{color pop}}}%
%
\def\default@color{rgb 0.0 0.0 0.0}% black
\def\current@color{rgb 0.0 0.0 0.0}%
\def\bg@color{rgb 1.0 1.0 1.0}% white
\def\highlight@color{rgb 0.4 0.0 0.0}% brown
%
% Trick: how to remove ``pt'' in the output of \the<dimen>
%
\def\@nodimen#1{\expandafter\@@nodimen\the#1}%
{\catcode`\p=12\catcode`\t=12\gdef\@@nodimen#1pt{#1}}%
%
{\catcode`\#=12 \catcode`\*=6
\gdef\define@@color*1*2\@@*3{%
	\ifx*1#\define@@@color*2\@@*3%
	\else\def*3{*1*2}\fi}}%
\def\define@@@color#1#2#3#4#5#6\@@#7{%
	\dimen@"#1#2pt\divide\dimen@255\edef#7{rgb \@nodimen\dimen@}%
	\dimen@"#3#4pt\divide\dimen@255\edef#7{#7\space\@nodimen\dimen@}%
	\dimen@"#5#6pt\divide\dimen@255\edef#7{#7\space\@nodimen\dimen@}}%
%
\HTMLcolors
\HTMLmultimedia
\catcode`\@=12
\endinput
