\ProvidesFile{ref_alts.tex}[2012/12/19 texlinks implementations]
%% a study of alternatives to implement texlinks, 
%% counting tokens, not meant to work.

\def\baseref{\httpbaseref{<base>}}                 % 5 + b
\def\repsubbaseref{\httpbaseref{<base>/<ppath>}}   % 6 + b + p → 11 + 2b + p
                                                   %             2S
\def\baseurl{<base>}                               % 2 + b
\def\urlbaseref{\httpbaseref\baseurl}              % 4
\def\urlsubbaseref{\httpbaseref{\baseurl/<ppath>}} % 7 + p     → 13 + b + p
                                                   %             3S
\def\subbaseref#1{\baseref{<ppath>/#1}}            % 8 + p     → 13 + b + p
                                                   %             2S
                                         
\def\html{.html}                                                   
\def\bytopicreppathref#1{%
    \mirrorctanref{<cat-path>/bytopic\html\##1}    % 9 + c + t

\def\catpath{<cat-path>/}                          % 3 + c
\def\bytopiccatpathref#1{%
    \mirrorctanref{\catpath bytopic\html\##1}      % 9 + t
\def\CatPkgCatPathRef#1{%
    \mirrorctanref{\catpath entries/#1\html}}      % 9 + e
\def\catalogueref#1{\mirrorctanref{<cat-path>/#1}} % 8 + c
\def\bytopiccatref#1{%
    \catalogueref{bytopic\html\##1}}               % 9 + t
\def\CatPkgRef#1{\catalogueref{entries/#1\html}}   % 9 + e
    %% + #2 ... {\pkgnamefmt{#2}} → 7

\def\ctanorg{ctan.org/}                            % 3 + o
\def\mirrcorg{mirror\ctanorg}                      % 3 + m
\def\httpancref#1#2{\httpref{#1\##2}}             % 10
\def\bytopicancref{%
    \httpancref{\mirrcorg\catpath bytopic\html}}   % 8 + t
\def\bytopicurlref#1{%
    \httpref{\mirrcorg\catpath bytopic\html\##1}} % 11 + t
\def\CatPkgUrlRef#1{%
    \httpref{\mirrcorg\catpath entries/#1\html}}  % 11 + e
    %% + #2 ... {\pkgnamefmt{#2}} → 7
    
\def\Ct@nPkgRef#1#2#3{#1{pkg/#2}{\pkgnamefmt{#3}}}% 16 + k
\def\CtanPkgRef{\Ct@nPkgRef\ctanorgbaseref}        % 4
\def\TugCtanPkgRef{\Ct@nPkgRef\tugctanorgbaseref}  % 4
\def\WwwCtanPkgRef{\Ct@nPkgRef\wwwctanorgbaseref}  % 4
\def\CatPkgRef#1#2{\catalogueref{entries/#1\html}%
                                {\pkgnamefmt{#2}}}% 16 + e

\def\oCtanPkgRef#1#2{%
    \ctanorgbaseref{pkg/#1}{\pkgnamefmt{#2}}}     % 15 + k
\def\oTugCtanPkgRef#1#2{%
    \tugctanorgbaseref{pkg/#1}{\pkgnamefmt{#2}}}  % 15 + k
\def\oWwwCtanPkgRef#1#2{%
    \wwwctanorgbaseref{pkg/#1}{\pkgnamefmt{#2}}}  % 15 + k
\def\CatPkgRef...{...}                            % 16 + e

\def\mk@pkg@ref#1#2#3{#1{#2}{\pkgnamefmt{#3}}}    % 15
\def\CatPkgRef#1{%
    \mk@pkg@ref\catalogueref{entries/#1\html}}    % 10 + e
\def\CtanPkgRef#1{%
    \mk@pkg@ref\ctanorgbaseref{pkg/#1}}            % 9 + k
\def\TugCtanPkgRef#1{%
    \mk@pkg@ref\tugctanorgbaseref{pkg/#1}}         % 9 + k
\def\WwwCtanPkgRef#1{%
    \mk@pkg@ref\wwwctanorgbaseref{pkg/#1}}         % 9 + k

\def\Ct@nPkgRef#1#2{\mk@pkg@ref#1{pkg/#2}}        % 10 + k
\def\CtanPkgRef   {\Ct@nPkgRef   \ctanorgbaseref}  % 4
\def\TugCtanPkgRef{\Ct@nPkgRef\tugctanorgbaseref}  % 4
\def\WwwCtanPkgRef{\Ct@nPkgRef\wwwctanorgbaseref}  % 4
\def\CatPkgRef...{...}                            % 10 + e

\def\@double@first@arg#1#2{#1{#2}{#2}}            % 11
\def\ctanpkgref#1{\CtanPkgRef{#1}{#1}}            % 10 (4x?? 2x?)
\def\ctanpkgref{\@double@first@arg\CtanPkgRef}     % 4 (4x?? 2x?)
