%%%  WEB Change File for DVItype (Win32 version)
%%%  Time-stamp: "97/01/04 21:47:19 mik"
%%%
%%%  Copyright (C) 1991, 92, 93, 94, 95, 96, 97
%%%	Christian Schenk  <cschenk@berlin.snafu.de>
%%%
%%%  This file is part of MiKTeX.
%%%
%%%  MiKTeX is free software; you can redistribute it and/or
%%%  modify it under the terms of the GNU General Public License as
%%%  published by the Free Software Foundation; either version 2, or (at
%%%  your option) any later version.
%%%  
%%%  MiKTeX is distributed in the hope that it will be useful, but
%%%  WITHOUT ANY WARRANTY; without even the implied warranty of
%%%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%%%  General Public License for more details.
%%%  
%%%  You should have received a copy of the GNU General Public License
%%%  along with MiKTeX; if not, write to the Free Software
%%%  Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
%%%  USA.

@x
\def\title{DVI$\,$\lowercase{type}}
@y
\def\MiKTeX{MiK\TeX}
\def\title{DVI$\,$\lowercase{type} for Win32 (\MiKTeX\ 1.06)}
@z

%% **     3  ******************************************************************

@x
procedure initialize; {this procedure gets things started properly}
  var i:integer; {loop index for initializations}
  begin print_ln(banner);@/
@y
@<External C routines@>@/
procedure initialize; {this procedure gets things started properly}
  var i:integer; {loop index for initializations}
  begin print(banner); miktex_banner(output); write_ln;@/
@z

%% **     5  ******************************************************************

@x
@!name_length=50; {a file name shouldn't be longer than this}
@y
@!name_length=50; {a file name shouldn't be longer than this}
@!namez_length=51;
@z

%% **     7  ******************************************************************

@x
@p procedure jump_out;
begin goto final_end;
end;
@y
@d goto_final_end==c4p_longjmp(env_buf,1)

@p procedure jump_out;
begin goto_final_end
end;
@z

%% **     9  ******************************************************************

@x
@d text_char == char {the data type of characters in text files}
@d first_text_char=0 {ordinal number of the smallest element of |text_char|}
@d last_text_char=127 {ordinal number of the largest element of |text_char|}
@y
@d text_char == char {the data type of characters in text files}
@d first_text_char=0 {ordinal number of the smallest element of |text_char|}
@d last_text_char=127 {ordinal number of the largest element of |text_char|}
@z

%% **    23  ******************************************************************

@x
@ To prepare these files for input, we |reset| them. An extension of
\PASCAL\ is needed in the case of |tfm_file|, since we want to associate
it with external files whose names are specified dynamically (i.e., not
known at compile time). The following code assumes that `|reset(f,s)|'
does this, when |f| is a file variable and |s| is a string variable that
specifies the file name. If |eof(f)| is true immediately after
|reset(f,s)| has acted, we assume that no file named |s| is accessible.
@^system dependencies@>

@p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|}
begin reset(dvi_file);
cur_loc:=0;
end;
@#
procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
begin reset(tfm_file,cur_name);
end;
@y
@ To prepare these files for input, we first open and then |reset| them.
@^system dependencies@>

@p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|}
begin
if (c4pargc <> 2) then
 abort('Usage: dvitype inputfile');
c4p_fopen(dvi_file,c4p_argv[1],c4p_rb_mode,true);
reset(dvi_file);
cur_loc:=0;
end;
@#
procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
begin
 mt_open_tfm_file (tfm_file, cur_name);
end;
@z

%% **    24  ******************************************************************

@x
@!cur_name:packed array[1..name_length] of char; {external name,
  with no lower case letters}
@y
@!cur_name:packed array[1..namez_length] of char; {external name,
  with no lower case letters}
@z

%% **    28  ******************************************************************

@x
Such routines are, of course, highly system dependent. They are implemented
here in terms of two assumed system routines called |set_pos| and |cur_pos|.
The call |set_pos(f,n)| moves to item |n| in file |f|, unless |n| is
negative or larger than the total number of items in |f|; in the latter
case, |set_pos(f,n)| moves to the end of file |f|.
The call |cur_pos(f)| gives the total number of items in |f|, if
|eof(f)| is true; we use |cur_pos| only in such a situation.

@p function dvi_length:integer;
begin set_pos(dvi_file,-1); dvi_length:=cur_pos(dvi_file);
end;
@#
procedure move_to_byte(n:integer);
begin set_pos(dvi_file,n); cur_loc:=n;
end;
@y
Such routines are, of course, highly system dependent. They are implemented
here in terms of two system routines called |@!c4p_fseek()| and
|@!c4p_ftell()|.
The call |c4p_fseek(f,n,@!c4p_set)| moves to byte |n| in file |f|.
The call |c4p_fseek(f,n,@!c4p_end)| moves to the end of file |f|.
The call |c4p_ftell(f)| gives the total number of bytes in |f|, if
|eof(f)| is true; we use |c4p_ftell()| only in such a situation.

@p function dvi_length:integer;
begin c4p_fseek(dvi_file,0,c4p_end); dvi_length:=c4p_ftell(dvi_file);
end;
@#
procedure move_to_byte(n:integer);
begin c4p_fseek(dvi_file,n,c4p_set); cur_loc:=n;
end;
@z

%% **    33  ******************************************************************

@x
@!tfm_conv:real; {\.{DVI} units per absolute \.{TFM} unit}
@y
@!tfm_conv:longreal; {\.{DVI} units per absolute \.{TFM} unit}
@z

%% **    39  ******************************************************************

@x
@!conv:real; {converts \.{DVI} units to pixels}
@!true_conv:real; {converts unmagnified \.{DVI} units to pixels}
@y
@!conv:longreal; {converts \.{DVI} units to pixels}
@!true_conv:longreal; {converts unmagnified \.{DVI} units to pixels}
@z

%% **    41  ******************************************************************

@x
@!resolution:real; {pixels per inch}
@y
@!resolution:longreal; {pixels per inch}
@z

%% **    46  ******************************************************************

@x
begin update_terminal; reset(term_in);
@y
begin update_terminal; get(term_in);
@z

%% **    50  ******************************************************************

@x
begin rewrite(term_out); {prepare the terminal for output}
write_ln(term_out,banner);
@y
begin term_out:=output; term_in:=input; {prepare the terminal for output}
{|write_ln(term_out,banner);|}
@z

%% **    64  ******************************************************************

@x
@d default_directory_name=='TeXfonts:' {change this to the correct name}
@d default_directory_name_length=9 {change this to the correct length}

@<Glob...@>=
@!default_directory:packed array[1..default_directory_name_length] of char;

@ @<Set init...@>=
default_directory:=default_directory_name;
@y
@d default_directory_name=='[TeX]Font Metric Dirs:'
@d default_directory_name_length=22
@d default_directory_namez_length=23

@<Glob...@>=
@!default_directory:packed array[1..default_directory_namez_length] of char;

@ @<Set init...@>=
c4p_strcpy (default_directory, default_directory_name);
@z

%% **    66  ******************************************************************

@x
@<Move font name into the |cur_name| string@>=
for k:=1 to name_length do cur_name[k]:=' ';
if p=0 then
  begin for k:=1 to default_directory_name_length do
    cur_name[k]:=default_directory[k];
  r:=default_directory_name_length;
  end
else r:=0;
@y
@<Move font name into the |cur_name| string@>=
for k:=1 to name_length do cur_name[k]:=chr(0);
if p=0 then
  begin for k:=1 to default_directory_name_length do
    cur_name[k]:=default_directory[k];
  cur_name[default_directory_name_length+1]:=chr(0);
  r:=default_directory_name_length;
  end
else r:=0;
@z

@x
  if (names[k]>="a")and(names[k]<="z") then
      cur_name[r]:=xchr[names[k]-@'40]
  else cur_name[r]:=xchr[names[k]];
  end;
cur_name[r+1]:='.'; cur_name[r+2]:='T'; cur_name[r+3]:='F'; cur_name[r+4]:='M'
@y
  cur_name[r]:=xchr[names[k]];
  end;
cur_name[r+1]:='.'; cur_name[r+2]:='t'; cur_name[r+3]:='f'; cur_name[r+4]:='m'
@z

%% **   107  ******************************************************************

@x
@p begin initialize; {get all variables initialized}
@y
@p begin
if c4p_setjmp (env_buf) <> 0 then goto final_end;
initialize; {get all variables initialized}
@z

%% **   112  ******************************************************************

@x
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@^system dependencies@>
@y
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@^system dependencies@>

@ @<External C routines@>=
procedure mt_open_tfm_file (var f:byte_file; n:integer); forward;
procedure miktex_banner (var f:text_file); forward;

@ @<Globals...@>=
@!env_buf : c4p_jmp_buf;
@z
