%%
%% This is file `pdfcrypt.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pdfcrypt.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2001, 2006, 2007 by
%%    Heiko Oberdiek <oberdiek@uni-freiburg.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file pdfcrypt.dtx
%% and the derived files
%%    pdfcrypt.sty, pdfcrypt.pdf, pdfcrypt.ins, pdfcrypt.drv.
%% 
\expandafter\edef\csname pc@endinput\endcsname{%
  \catcode`\noexpand\@=\the\catcode`\@\relax
  \noexpand\endinput
}
\catcode`\@=11 %

\expandafter\ifx\csname @firstoftwo\endcsname\relax
  \long\def\@firstoftwo#1#2{#1}%
\fi

\expandafter\ifx\csname @secondoftwo\endcsname\relax
  \long\def\@secondoftwo#1#2{#2}%
\fi

\expandafter\ifx\csname @ifundefined\endcsname\relax
  \def\@ifundefined#1{%
    \expandafter\ifx\csname #1\endcsname\relax
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
\fi

\@ifundefined{@ifnextchar}{%
  \long\def\@ifnextchar#1#2#3{%
    \let\reserved@d=#1%
    \def\reserved@a{#2}%
    \def\reserved@b{#3}%
    \futurelet\@let@token\@ifnch
  }%
  \def\@ifnch{%
    \ifx\@let@token\@sptoken
      \let\reserved@c\@xifnch
    \else
      \ifx\@let@token\reserved@d
        \let\reserved@c\reserved@a
      \else
        \let\reserved@c\reserved@b
      \fi
    \fi
    \reserved@c
  }%
  \begingroup
    \def\:{\global\let\@sptoken= }%
    \: %
    \def\:{\@xifnch}%
    \expandafter\gdef\: {\futurelet\@let@token\@ifnch}%
  \endgroup
}{}

\@ifundefined{ProvidesPackage}{%
  \def\ProvidesPackage#1{%
    \@ifnextchar[{\pc@ProvidesPackage{#1}}%
                 {\pc@ProvidesPackage{#1}[]}%
  }%
  \def\pc@ProvidesPackage#1[#2]{%
    \immediate\write-1{Package: #1 #2}%
  }%
}{}

\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \input infwarerr.sty\relax
\else
  \RequirePackage{infwarerr}%
\fi

\@ifundefined{@gobble}{%
  \long\def\@gobble#1{}%
}{}

\@ifundefined{@empty}{%
  \def\@empty{}%
}{}
\ProvidesPackage{pdfcrypt}%
  [2007/04/26 v1.0 Setting pdf encryption (HO)]%
\@ifundefined{pdfcryptsetup}{%
  \let\pdfcryptsetup\@gobble
}{%
  \@PackageWarningNoLine{pdfcrypt}{Package pdfcrypt is already loaded}%
  \pc@endinput
}
\newif\ifpc@nopdfcrypt
\ifx Y\nopdfcrypt
  \@PackageWarningNoLine{pdfcrypt}{%
    Encryption disabled by \string \nopdfcrypt\space request%
  }%
  \global\pc@nopdfcrypttrue
\fi
\let\pc@driver\@empty
\begingroup
  % pdfTeX detection
  \@ifundefined{pdfoutput}{%
  }{%
    \ifcase\pdfoutput
    \else
      \@ifundefined{pdfcrypt}{%
        \@PackageError{pdfcrypt}{%
          PDF encryption is not supported with this pdfTeX%
        }{%
          Encryption support was added in 0.14h (2001/03/10)\MessageBreak
          and removed in 1.10a (2003/01/16).%
        }%
        \endgroup
        \pc@endinput
      }{%
        \gdef\pc@driver{pdftex}%
      }%
    \fi
  }%
  % VTeX detection
  \@ifundefined{OpMode}{%
  }{%
    \ifnum\OpMode=1 %
      \ifnum\@ifundefined{VTeXversion}0\VTeXversion<735 %
        \@PackageError{pdfcrypt}{%
          PDF encryption is not supported with this VTeX%
        }{%
          You need VTeX 7.35 or higher.%
        }%
        \endgroup
        \pc@endinput
      \else
        \gdef\pc@driver{vtex}%
      \fi
    \fi
  }%
\endgroup
\@ifundefined{@makeother}{%
  \def\@makeother#1{\catcode`#1=12\relax}%
}{}

\@ifundefined{g@addto@macro}{%
  \long\def\g@addto@macro#1#2{%
    \begingroup
      \toks@\expandafter{#1#2}%
      \xdef#1{\the\toks@}%
    \endgroup
  }%
}{}

\@ifundefined{@namedef}{%
  \def\@namedef#1{\expandafter\def\csname#1\endcsname}%
}{}

\@ifundefined{@nameuse}{%
  \def\@nameuse#1{\csname #1\endcsname}%
}{}

\def\pc@KeyvalRestore{%
  \let\pc@KeyvalRestore\@undefined
}

\let\pcOrg@NeedsTeXFormat\NeedsTeXFormat
\@ifundefined{NeedsTeXFormat}{%
  \def\NeedsTeXFormat#1{}%
  \g@addto@macro\pc@KeyvalRestore{%
    \let\NeedsTeXFormat\pcOrg@NeedsTeXFormat
  }%
}{}

\let\pcOrg@DeclareOption\DeclareOption
\@ifundefined{DeclareOption}{%
  \def\DeclareOption#1#2{#2}%
  \g@addto@macro\pc@KeyvalRestore{%
    \let\DeclareOption\pcOrg@DeclareOption
  }%
}{}

\let\pcOrg@ExecuteOptions\ExecuteOptions
\@ifundefined{ExecuteOptions}{%
  \def\ExecuteOptions#1{}%
  \g@addto@macro\pc@KeyvalRestore{%
    \let\ExecuteOptions\pcOrg@ExecuteOptions
  }%
}{}

\let\pcOrg@ProcessOptions\ProcessOptions
\@ifundefined{ProcessOptions}{%
  \def\ProcessOptions{}%
  \g@addto@macro\pc@KeyvalRestore{%
    \let\ProcessOptions\pcOrg@ProcessOptions
  }%
}{}%

\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \input keyval.sty\relax
\else
  \RequirePackage{keyval}%
\fi
\pc@KeyvalRestore
\@ifundefined{@dblarg}{%
  \long\def\@dblarg#1{\@ifnextchar[{#1}{\@xdblarg{#1}}}%
  \long\def\@xdblarg#1#2{#1[{#2}]{#2}}%
}{}

\newif\ifpc@set
\newif\ifpc@print
\newif\ifpc@copy
\newif\ifpc@edit
\newif\ifpc@annotate
\newif\ifpc@debug
\let\pc@owner\@empty
\let\pc@user\@empty

\pc@printtrue
\pc@copytrue
\pc@edittrue
\pc@annotatetrue

\edef\pc@temp{\catcode`\noexpand\"=\the\catcode`\"\relax}
\@makeother\"
\def\pc@set{%
  \@PackageInfo{pdfcrypt}{%
    \ifpc@debug
      \ifx\pc@owner\@empty
        No owner password%
      \else
        Owner password: `\pc@owner'%
      \fi
      \MessageBreak
      \ifx\pc@user\@empty
        No user password%
      \else
        User password: `\pc@user'%
      \fi
      \MessageBreak
      Flags: %
      \ifpc@print   \else no\fi print, %
      \ifpc@copy    \else no\fi copy, %
      \ifpc@edit    \else no\fi edit, %
      \ifpc@annotate\else no\fi annotate%
      \MessageBreak
    \fi
    \ifpc@nopdfcrypt
      Encryption is disabled by `\string\nopdfcrypt'%
    \else
      Encryption is set for `\pc@driver'%
    \fi
  }%
  \ifpc@nopdfcrypt
  \else
    \@ifundefined{pc@set@\pc@driver}{%
      \ifx\pc@driver\@empty
        \@PackageError{pdfcrypt}{No driver for encryption %
          support found}\@ehc
      \else
        \@PackageError{pdfcrypt}{Cannot set encryption for %
          unknown driver `\pc@driver'}\@ehc
      \fi
    }{%
      \@nameuse{pc@set@\pc@driver}%
    }%
  \fi
}
\def\pc@set@pdftex{%
  \ifnum\pdftexversion<100 %
    \pc@set@pdftexold
  \else
    \pc@set@pdftexnew
  \fi
}
\def\pc@set@pdftexold{%
  \pdfcrypt{%
    owner "\pc@owner" %
    user "\pc@user" %
    \ifpc@print   \else no\fi print %
    \ifpc@copy    \else no\fi copy %
    \ifpc@edit    \else no\fi edit %
    \ifpc@annotate\else no\fi annotate%
  }%
}
\def\pc@set@pdftexnew{%
  \pdfcrypt
    owner{\pc@owner}%
    user{\pc@user}%
    \ifpc@print   \else no\fi print %
    \ifpc@copy    \else no\fi copy %
    \ifpc@edit    \else no\fi edit %
    \ifpc@annotate\else no\fi annotate%
  \relax
}
\def\pc@set@vtex{%
  \immediate\special{!security %
    O=\pc@MakeVTeXString\pc@owner,%
    U=\pc@MakeVTeXString\pc@user,%
    P\ifpc@print +\else -\fi,%
    C\ifpc@copy +\else -\fi,%
    M\ifpc@edit +\else -\fi,%
    A\ifpc@annotate +\else -\fi
  }%
}
\def\pc@MakeVTeXString#1{%
  "\expandafter\pc@@MakeVTeXString#1"\@nil"%
}
\def\pc@@MakeVTeXString#1"#2\@nil{%
  #1%
  \ifx\\#2\\%
  \else
    ""%
    \@ReturnAfterFi{%
      \pc@@MakeVTeXString#2\@nil
    }%
  \fi
}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
\pc@temp

\begingroup
  \catcode`\ =12 \gdef\pc@spaceother{ }\catcode`\ =10\relax
  \catcode`\|=0 %
  \catcode`\\=12 %
  |gdef|pc@DefString#1#2{%
    |def#1{#2}%
    |edef#1{|expandafter|strip@prefix|meaning#1}%
    |edef#1{|expandafter|pc@SpaceToOther#1 |@nil}%
    |edef#1{|expandafter|pc@EscapeRemove#1|@empty\|@empty|@nil}%
  }%
  |gdef|pc@EscapeRemove#1\#2#3|@nil{%
    #1#2%
    |ifx|\#3|\%
    |else
      |@ReturnAfterFi{%
        |pc@EscapeRemove#3|@nil
      }%
    |fi
  }%
|endgroup
\def\pc@SpaceToOther#1 #2\@nil{%
  #1%
  \ifx\\#2\\%
  \else
    \pc@spaceother
    \@ReturnAfterFi{%
      \pc@SpaceToOther#2\@nil
    }%
  \fi
}

\def\pc@boolkey{\@dblarg\pc@@boolkey}
\def\pc@@boolkey[#1]#2#3{%
  \lowercase{\def\pc@temp{#3}}%
  \ifx\pc@temp\@empty
    \let\pc@temp\pc@true
  \fi
  \ifx\pc@temp\pc@true
  \else
    \ifx\pc@temp\pc@false
    \else
      \let\pc@temp\relax
    \fi
  \fi
  \ifx\pc@temp\relax
    \@PackageWarning{pdfcrypt}{%
      Unexpected value \string`#3\string' of %
      option \string`#2\string'\MessageBreak
      instead of %
      \string`true\string' or \string`false\string'%
    }%
  \else
    \csname pc@#2\pc@temp\endcsname
  \fi
}
\def\pc@true{true}
\def\pc@false{false}

\define@key{pc}{set}[true]{%
  \pc@boolkey{set}{#1}%
}
\define@key{pc}{pdftex}[]{%
  \def\pc@driver{pdftex}%
}
\define@key{pc}{vtex}[]{%
  \def\pc@driver{vtex}%
}
\define@key{pc}{print}[true]{%
  \pc@boolkey{print}{#1}%
}
\define@key{pc}{copy}[true]{%
  \pc@boolkey{copy}{#1}%
}
\define@key{pc}{edit}[true]{%
  \pc@boolkey{edit}{#1}%
}
\define@key{pc}{annotate}[true]{%
  \pc@boolkey{annotate}{#1}%
}
\define@key{pc}{all}[]{%
  \pc@boolkey{print}{true}%
  \pc@boolkey{copy}{true}%
  \pc@boolkey{edit}{true}%
  \pc@boolkey{annotate}{true}%
}
\define@key{pc}{none}[]{%
  \pc@boolkey{print}{false}%
  \pc@boolkey{copy}{false}%
  \pc@boolkey{edit}{false}%
  \pc@boolkey{annotate}{false}%
}

\define@key{pc}{owner}{%
  \pc@DefString\pc@owner{#1}%
}
\define@key{pc}{user}{%
  \pc@DefString\pc@user{#1}%
}
\define@key{pc}{debug}[true]{%
  \pc@boolkey{debug}{#1}%
}

\def\pdfcryptsetup#1{%
  \setkeys{pc}{#1}%
  \ifpc@set
    \pc@set
    \global\let\pc@set\relax
    \gdef\pdfcryptsetup##1{%
      \@PackageWarning{pdfcrypt}{%
        Encryption options are already set\MessageBreak
        new values are ignored%
      }%
    }%
  \fi
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname @onlypreamble\endcsname\relax
\else
  \@onlypreamble\pdfcryptsetup
\fi
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname InputIfFileExists\endcsname\relax
  \@PackageInfo{pdfcrypt}{%
    Configuration file pdfcrypt.cfg not supported.%
  }%
\else
  \let\pc@ExecuteOptions\ExecuteOptions
  \InputIfFileExists{pdfcrypt.cfg}{}{}%
  \let\ExecuteOptions\pc@ExecuteOptions
\fi
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname @classoptionslist\endcsname\relax
  \expandafter\pc@endinput
\fi
\def\pc@ProcessOptionsWithKV{%
  \let\pc@temp\@empty
  \@for\CurrentOption:=\@classoptionslist\do{%
    \@ifundefined{KV@pc@\CurrentOption}{}{%
      \edef\pc@temp{\pc@temp,\CurrentOption,}%
      \@expandtwoargs\@removeelement\CurrentOption
        \@unusedoptionlist\@unusedoptionlist
    }%
  }%
  \edef\pc@temp{%
    \noexpand\pdfcryptsetup{%
      \pc@temp\@ptionlist{\@currname.\@currext}%
    }%
  }%
  \pc@temp
}
\pc@ProcessOptionsWithKV
\AtEndOfPackage{\let\@unprocessedoptions\relax}
\AtBeginDocument{\pc@set}

\pc@endinput
\endinput
%%
%% End of file `pdfcrypt.sty'.
