%%
%% This is file `bkm-dvips-2019-12-03.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bookmark-frozen.dtx  (with options: `dvipsfrozen')
%% 
%% This is a generated file.
%% 
%% Project: bookmark
%% Version: 2020-11-06 v1.29
%% 
%% Copyright (C)
%%    2007-2011 Heiko Oberdiek
%%    2016-2020 Oberdiek Package Support Group
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://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".
%% 
%% The Current Maintainers of this work are
%% Heiko Oberdiek and the Oberdiek Package Support Group
%% https://github.com/ho-tex/bookmark/issues
%% 
%% 
%% This work consists of the main source file bookmark.dtx and bookmark-frozen.dtx
%% and the derived files
%%    bookmark.sty, bookmark.pdf, bookmark.ins, bookmark.drv,
%%    bkm-dvipdfm.def, bkm-dvips.def, bkm-pdftex.def, bkm-vtex.def,
%%    bkm-dvipdfm-2019-12-03.def, bkm-dvips-2019-12-03.def,
%%    bkm-pdftex-2019-12-03.def, bkm-vtex-2019-12-03.def,
%%    bookmark-example.tex.
%% 
\def\BKM@SourceLocation{%
  \ifx\BKM@DO@srcfile\@empty
    \ifx\BKM@DO@srcline\@empty
    \else
      .\MessageBreak
      Source: line \BKM@DO@srcline
    \fi
  \else
    \ifx\BKM@DO@srcline\@empty
      .\MessageBreak
      Source: file `\BKM@DO@srcfile'%
    \else
      .\MessageBreak
      Source: file `\BKM@DO@srcfile', line \BKM@DO@srcline
    \fi
  \fi
}
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{bkm-dvips.def}%
  [2019/12/03 v1.28 bookmark driver for dvips (HO)]%
\def\BKM@PSHeaderFile#1{%
  \special{header=#1}%
}
\def\BKM@filename{\jobname.out.ps}
\BKM@PSHeaderFile\BKM@filename
\RequirePackage{atveryend}[2009/12/07]
\AfterLastShipout{\BKM@pdfmark@out}
\def\BKM@pdfmark@out{%
  \if@filesw
    \newwrite\BKM@file
    \immediate\openout\BKM@file=\BKM@filename\relax
    \BKM@write{\@percentchar!}%
    \BKM@write{/pdfmark where{pop}}%
    \BKM@write{%
      {%
        /globaldict where{pop globaldict}{userdict}ifelse%
        /pdfmark/cleartomark load put%
      }%
    }%
    \BKM@write{ifelse}%
  \else
    \let\BKM@write\@gobble
    \let\BKM@DO@entry\@gobbletwo
  \fi
}
\def\BKM@write#{%
  \immediate\write\BKM@file
}
\def\BKM@DO@entry#1#2{%
  \begingroup
    \kvsetkeys{BKM@DO}{#1}%
    \ifx\BKM@DO@srcfile\@empty
    \else
      \BKM@UnescapeHex\BKM@DO@srcfile
    \fi
    \def\BKM@DO@title{#2}%
    \BKM@UnescapeHex\BKM@DO@title
    \expandafter\expandafter\expandafter\BKM@getx
        \csname BKM@\BKM@DO@id\endcsname\@empty\@empty
    \let\BKM@attr\@empty
    \ifx\BKM@DO@flags\@empty
    \else
      \edef\BKM@attr{\BKM@attr/F \BKM@DO@flags}%
    \fi
    \ifx\BKM@DO@color\@empty
    \else
      \edef\BKM@attr{\BKM@attr/C[\BKM@DO@color]}%
    \fi
    \let\BKM@action\@empty
    \ifx\BKM@DO@gotor\@empty
      \ifx\BKM@DO@dest\@empty
        \ifx\BKM@DO@named\@empty
          \ifx\BKM@DO@rawaction\@empty
            \ifx\BKM@DO@uri\@empty
              \ifx\BKM@DO@page\@empty
                \PackageError{bookmark}{%
                  Missing action\BKM@SourceLocation
                }\@ehc
                \edef\BKM@action{%
                  /Action/GoTo%
                  /Page 1%
                  /View[/Fit]%
                }%
              \else
                \ifx\BKM@DO@view\@empty
                  \def\BKM@DO@view{Fit}%
                \fi
                \edef\BKM@action{%
                  /Action/GoTo%
                  /Page \BKM@DO@page
                  /View[/\BKM@DO@view]%
                }%
              \fi
            \else
              \BKM@UnescapeHex\BKM@DO@uri
              \BKM@EscapeString\BKM@DO@uri
              \edef\BKM@action{%
                /Action<<%
                  /Subtype/URI%
                  /URI(\BKM@DO@uri)%
                >>%
              }%
            \fi
          \else
            \BKM@UnescapeHex\BKM@DO@rawaction
            \edef\BKM@action{%
              /Action<<%
                \BKM@DO@rawaction
              >>%
            }%
          \fi
        \else
          \BKM@EscapeName\BKM@DO@named
          \edef\BKM@action{%
            /Action<<%
              /Subtype/Named%
              /N/\BKM@DO@named
            >>%
          }%
        \fi
      \else
        \BKM@UnescapeHex\BKM@DO@dest
        \BKM@EscapeString\BKM@DO@dest
        \edef\BKM@action{%
          /Action/GoTo%
          /Dest(\BKM@DO@dest)cvn%
        }%
      \fi
    \else
      \ifx\BKM@DO@dest\@empty
        \ifx\BKM@DO@page\@empty
          \def\BKM@DO@page{1}%
        \fi
        \ifx\BKM@DO@view\@empty
          \def\BKM@DO@view{Fit}%
        \fi
        \edef\BKM@action{%
          /Page \BKM@DO@page
          /View[/\BKM@DO@view]%
        }%
      \else
        \BKM@UnescapeHex\BKM@DO@dest
        \BKM@EscapeString\BKM@DO@dest
        \edef\BKM@action{%
          /Dest(\BKM@DO@dest)cvn%
        }%
      \fi
      \BKM@UnescapeHex\BKM@DO@gotor
      \BKM@EscapeString\BKM@DO@gotor
      \edef\BKM@action{%
        /Action/GoToR%
        /File(\BKM@DO@gotor)%
        \BKM@action
      }%
    \fi
    \BKM@write{[}%
    \BKM@write{/Title(\BKM@DO@title)}%
    \ifnum\BKM@x@childs>\z@
      \BKM@write{/Count \ifBKM@DO@open\else-\fi\BKM@x@childs}%
    \fi
    \ifx\BKM@attr\@empty
    \else
      \BKM@write{\BKM@attr}%
    \fi
    \BKM@write{\BKM@action}%
    \BKM@write{/OUT pdfmark}%
  \endgroup
}
\RequirePackage{auxhook}
\AddLineBeginMainAux{%
  \string\providecommand\string\BKM@entry[2]{}%
}
\newcount\BKM@id
\BKM@id=\z@
\@namedef{BKM@0}{000}
\newif\ifBKM@sw
\newcommand*{\bookmark}[2][]{%
  \if@filesw
    \begingroup
      \BKM@InitSourceLocation
      \def\bookmark@text{#2}%
      \BKM@setup{#1}%
      \ifx\BKM@srcfile\@empty
      \else
        \BKM@EscapeHex\BKM@srcfile
      \fi
      \edef\BKM@prev{\the\BKM@id}%
      \global\advance\BKM@id\@ne
      \BKM@swtrue
      \@whilesw\ifBKM@sw\fi{%
        \ifnum\ifBKM@startatroot\z@\else\BKM@prev\fi=\z@
          \BKM@startatrootfalse
          \expandafter\xdef\csname BKM@\the\BKM@id\endcsname{%
            0{\BKM@level}0%
          }%
          \BKM@swfalse
        \else
          \expandafter\expandafter\expandafter\BKM@getx
              \csname BKM@\BKM@prev\endcsname
          \ifnum\BKM@level>\BKM@x@level\relax
            \expandafter\xdef\csname BKM@\the\BKM@id\endcsname{%
              {\BKM@prev}{\BKM@level}0%
            }%
            \ifnum\BKM@prev>\z@
              \BKM@CalcExpr\BKM@CalcResult\BKM@x@childs+1%
              \expandafter\xdef\csname BKM@\BKM@prev\endcsname{%
                {\BKM@x@parent}{\BKM@x@level}{\BKM@CalcResult}%
              }%
            \fi
            \BKM@swfalse
          \else
            \let\BKM@prev\BKM@x@parent
          \fi
        \fi
      }%
      \pdfstringdef\BKM@title{\bookmark@text}%
      \edef\BKM@FLAGS{\BKM@PrintStyle}%
      \csname BKM@HypDestOptHook\endcsname
      \BKM@EscapeHex\BKM@dest
      \BKM@EscapeHex\BKM@uri
      \BKM@EscapeHex\BKM@gotor
      \BKM@EscapeHex\BKM@rawaction
      \BKM@EscapeHex\BKM@title
      \immediate\write\@mainaux{%
        \string\BKM@entry{%
          id=\number\BKM@id
          \ifBKM@open
            \ifnum\BKM@level<\BKM@openlevel
              ,open%
            \fi
          \fi
          \BKM@auxentry{dest}%
          \BKM@auxentry{named}%
          \BKM@auxentry{uri}%
          \BKM@auxentry{gotor}%
          \BKM@auxentry{page}%
          \BKM@auxentry{view}%
          \BKM@auxentry{rawaction}%
          \BKM@auxentry{color}%
          \ifnum\BKM@FLAGS>\z@
            ,flags=\BKM@FLAGS
          \fi
          \BKM@auxentry{srcline}%
          \BKM@auxentry{srcfile}%
        }{\BKM@title}%
      }%
    \endgroup
  \fi
}
\def\BKM@getx#1#2#3{%
  \def\BKM@x@parent{#1}%
  \def\BKM@x@level{#2}%
  \def\BKM@x@childs{#3}%
}
\def\BKM@auxentry#1{%
  \expandafter\ifx\csname BKM@#1\endcsname\@empty
  \else
    ,#1={\csname BKM@#1\endcsname}%
  \fi
}
\def\BKM@InitSourceLocation{%
  \edef\BKM@srcline{\the\inputlineno}%
  \BKM@LuaTeX@InitFile
  \ifx\BKM@srcfile\@empty
    \ltx@IfUndefined{currfilepath}{}{%
      \edef\BKM@srcfile{\currfilepath}%
    }%
  \fi
}
\ifluatex
  \ifnum\luatexversion>36 %
    \def\BKM@LuaTeX@InitFile{%
      \begingroup
        \ltx@LocToksA={}%
      \edef\x{\endgroup
        \def\noexpand\BKM@srcfile{%
          \the\expandafter\ltx@LocToksA
          \directlua{%
             if status and status.filename then %
               tex.settoks('ltx@LocToksA', status.filename)%
             end%
          }%
        }%
      }\x
    }%
  \else
    \let\BKM@LuaTeX@InitFile\relax
  \fi
\else
  \let\BKM@LuaTeX@InitFile\relax
\fi
\SetupKeyvalOptions{family=BKM@DO,prefix=BKM@DO@}
\DeclareStringOption[0]{id}
\DeclareBoolOption{open}
\DeclareStringOption{flags}
\DeclareStringOption{color}
\DeclareStringOption{dest}
\DeclareStringOption{named}
\DeclareStringOption{uri}
\DeclareStringOption{gotor}
\DeclareStringOption{page}
\DeclareStringOption{view}
\DeclareStringOption{rawaction}
\DeclareStringOption{srcline}
\DeclareStringOption{srcfile}
\AtBeginDocument{%
  \let\BKM@entry\BKM@DO@entry
}
\ifBKM@atend
  \AfterLastShipout{%
    \BKM@EndHook
  }%
\fi
\endinput
%%
%% End of file `bkm-dvips-2019-12-03.def'.
