%%
%% This is file `modules.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% modules.dtx  (with options: `package')
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{modules}[2006/01/13 v0.9a Semantic Markup]

\newif\ifmod@env\mod@envfalse
\newif\ifmod@id\mod@idfalse
\newif\ifmod@display\mod@displayfalse
\newif\ifmod@uses\mod@usesfalse
\newif\ifmod@usesqualified\mod@usesqualifiedfalse
\DeclareOption{env}{\mod@envtrue}
\DeclareOption{id}{\mod@idtrue}
\DeclareOption{uses}{\mod@usestrue}
\DeclareOption{display}{\mod@displaytrue}
\DeclareOption{usesqualified}{\mod@usesqualifiedtrue}
\def\modtrue{\mod@idtrue\mod@usestrue\mod@displaytrue\mod@usesqualifiedtrue}
\DeclareOption{draft}{\modtrue}
\DeclareOption{all}{\modtrue}
\ProcessOptions
\RequirePackage{keyval}[1997/11/10]
\define@key{module}{cd}{}
\define@key{module}{id}{%
  \edef\this@module{\expandafter\noexpand\csname module@defs@#1\endcsname}%
  \edef\this@qualified@module{\expandafter\noexpand\csname module@defs@qualified@#1\endcsname}%
  \global\@namedef{module@defs@#1}{}
  \global\@namedef{module@defs@qualified@#1}{}
  \def\mod@id{#1}}
\newenvironment{module}[1][]{\setkeys{module}{#1}\ifmod@env\show@mod@keys{module}\fi}{}
\def\show@mod@keys@aux{%
\@ifundefined{mod@id}{}{\ifmod@id{id=\mod@id},\fi}%
\@ifundefined{mod@display}{}{\ifmod@display{display=\mod@display}\fi}
\@ifundefined{mod@uses}{\relax}{\ifmod@uses{uses=\mod@uses},\fi}
\@ifundefined{mod@usesqualified}\relax\else
            \ifmod@usesqualified{usesqualified=\mod@usesqualified},\fi\fi}
\def\clear@mod@keys{\let\mod@usesqualified=\relax\mod@uses=\relax
            \let\st@id=\relax\let\st@display=\relax}
\def\show@mod@keys#1{\footnote{#1[\show@mod@keys@aux]}\clear@mod@keys}
\def\activate@defs#1{\csname module@defs@#1\endcsname}
\def\export@defs#1{\@ifundefined{mod@id}{}{
    \expandafter\expandafter\expandafter
         \g@addto@macro\expandafter
         \this@module\expandafter{\csname module@defs@#1\endcsname}}}
\newcommand{\importmodule}[2][]{\def\@test{#1}%
\ifx\@test\@empty\else\requiremodules{#1}\fi
\activate@defs{#2}\export@defs{#2}}
\define@key{symdef}{aliases}{}
\define@key{symdef}{local}[true]{\@symdeflocaltrue}
\define@key{symdef}{cmml}{}
\define@key{symdef}{cattrs}{}
\define@key{symdef}{definitionURL}{}
\newif\if@symdeflocal
\def\symdef{\@ifnextchar[{\@symdef}{\@symdef[]}}
\def\@symdef[#1]#2{\@ifnextchar[{\@@symdef[#1]{#2}}{\@@symdef[#1]{#2}[0]}}
\def\@@symdef[#1]#2[#3]#4{%
\@symdeflocalfalse\setkeys{symdef}{#1}
   \expandafter\providecommand\csname modules@#2@pres\endcsname[#3]{#4}
   \expandafter\def\csname#2\endcsname{\csname modules@#2@pres\endcsname}
   \if@symdeflocal\else
   \@ifundefined{mod@id}{}{
   \expandafter\g@addto@macro\this@module{\expandafter\providecommand\csname modules@#2@pres\endcsname[#3]{#4}}%
   \expandafter\g@addto@macro\this@module{\expandafter\def\csname#2\endcsname{\csname modules@#2@pres\endcsname}}
   \expandafter\g@addto@macro\this@qualified@module{\expandafter\providecommand\csname modules@#2@pres@qualified\endcsname[#3]{#4}}%
   \expandafter\g@addto@macro\this@qualified@module{\expandafter\def\csname#2atqualified\endcsname{\csname modules@#2@pres@qualified\endcsname}}
   }\fi}
\def\redefine#1[#2]#3{\expandafter\renewcommand\csname modules@#1@pres\endcsname[#2]{#3}}
\let\abbrdef\symdef
\def\mod@simplify#1{\expandafter\mod@simpl#1/\relax}
\def\mod@simpl#1/#2\relax{%\message{ 1 = #1, 2 = #2 }%
\def\mod@test{}\ifx\mod@blaaaa\mod@test\edef\mod@savedprefix{}\def\mod@blaaaa{aaa}\else\fi
\def\mod@comp{#2}\ifx\mod@test\mod@comp\edef\mod@savedprefix{\mod@savedprefix#1}%
\else\mod@simplhelp#1/#2\relax\fi}
\def\mod@simplhelp#1/#2/#3\relax{%
\def\mod@test{}\def\mod@tust{#2}\def\mod@tist{#3}\def\mod@tost{..}\ifx\mod@test\mod@tist%
\ifx\mod@tost\mod@tust\edef\mod@savedprefix{}\else\edef\mod@savedprefix
{\mod@savedprefix#1/#2}\fi \else\ifx\mod@tost\mod@tust\mod@simpl#3\relax%
\else\edef\mod@savedprefix{\mod@savedprefix#1/}\mod@simplhelp#2/#3\relax\fi\fi}%
\newif\ifmodules
\gdef\reg{}
\def\mod@update#1{\def\mod@empty{}
\ifx\reg\mod@empty\xdef\reg{#1}\else\xdef\reg{#1@\reg}\fi}
\def\mod@check#1@#2///#3\relax{%
\def\mod@empty{}\def\mod@one{#1}\def\mod@two{#2}\def\mod@three{#3}%
\expandafter\ifx\mod@three\mod@one\modulestrue\else\ifx\mod@two\mod@empty\modulesfalse%
\else\mod@check#2///#3\relax\fi\fi}
\def\mod@search#1{%
\modulesfalse\expandafter\mod@check\reg @///#1\relax%
\ifmodules\else\mod@update{#1}\fi}
\def\mod@reguse#1{\modulesfalse\expandafter\mod@check\reg @///#1\relax}
\def\mod@prefix{}
\def\mod@updatedpre#1{
  \edef\mod@prefix{\mod@prefix\mod@pathprefix@check#1/\relax}}
\def\mod@pathprefix@check#1/#2\relax{%
\ifx\\#2\\% no slash in string
\else\mod@ReturnAfterFi{#1/\mod@pathprefix@help#2\relax}%
\fi}
\def\mod@pathprefix@help#1/#2\relax{%
\ifx\\#2\\% end of recursion
\else\mod@ReturnAfterFi{#1/\mod@pathprefix@help#2\relax}%
\fi}
\long\def\mod@ReturnAfterFi#1\fi{\fi#1}
\def\mod@pathpostfix@check#1/#2\relax{% slash
\ifx\\#2\\%no slash in string
#1\else\mod@ReturnAfterFi{\mod@pathpostfix@help#2\relax}%
\fi}
\def\mod@pathpostfix@help#1/#2\relax{%
\ifx\\#2\\%
#1\else\mod@ReturnAfterFi{\mod@pathpostfix@help#2\relax}%
\fi}
\def\mod@updatedpost#1{%
\edef\mod@savedprefix{\mod@savedprefix\mod@pathpostfix@check#1/\relax} }
\def\mod@updatesms{\edef\mod@savedprefix{\mod@savedprefix.sms}}
\newcommand{\requiremodules}[1]{%
{\mod@updatedpre{#1} % add the new file to the already existing path
\let\mod@savedprefix\mod@prefix  % add the path to the new file to the prefix
\mod@updatedpost{#1}
\def\mod@blaaaa{} % macro used in the simplify function (remove .. from the prefix)
\mod@simplify{\mod@savedprefix} % remove |xxx/..| from the path (in case it exists)
\mod@reguse{\mod@savedprefix}
\ifmodules\else
\mod@updatesms    % update the file to contain the .sms extension
\let\newreg\reg   % use to compare, in case the .sms file was loaded before
\mod@search{\mod@savedprefix} % update registry
\ifx\newreg\reg\else\input{\mod@savedprefix}\fi % check if the registry was updated and load if necessary
\fi}}
\def\sinput#1{
{\mod@updatedpre{#1} % add the new file to the already existing path
\let\mod@savedprefix\mod@prefix  % add the path to the new file to the prefix
\mod@updatedpost{#1}
\def\mod@blaaaa{} % macro used in the simplify function (remove .. from the prefix)
\mod@simplify{\mod@savedprefix} % remove |xxx/..| from the path (in case it exists)
\mod@reguse{\mod@savedprefix}
\let\newreg\reg   % use to compare, in case the .sms file was loaded before
\mod@search{\mod@savedprefix} % update registry
\ifx\newreg\reg%\message{This file has been previously introduced}
\else\input{\mod@savedprefix}\fi}}
\def\requirepackage#1#2{\makeatletter\input{#1.sty}\makeatother}
\endinput
%%
%% End of file `modules.sty'.
