%%%  WEB Change File for GFtoDVI (Win32 version)
%%%  Time-stamp: "97/01/03 18:13:36 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{GF$\,$\lowercase{to}$\,$DVI}
@y
\def\MiKTeX{MiK\TeX}
\def\title{GF$\,$\lowercase{to}$\,$DVI for Win32 (\MiKTeX\ 1.06)}
@z

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

@x
var @<Globals in the outer block@>@/
procedure initialize; {this procedure gets things started properly}
  var @!i,@!j,@!m,@!n:integer; {loop indices for initializations}
  begin print_ln(banner);@/
@y
var @<Globals in the outer block@>@/
@<External C routines@> @;
procedure initialize; {this procedure gets things started properly}
  var @!i,@!j,@!m,@!n:integer; {loop indices for initializations}
  begin print(banner); miktex_banner(output); write_ln;@/
  term_in:=input;
@z

%% **     8  ******************************************************************

@x
@p procedure jump_out;
begin goto final_end;
end;
@y
@p procedure jump_out;
begin c4p_exit(1);
end;
@z

%% **    11  ******************************************************************

@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=255 {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=-127 {ordinal number of the smallest element of |text_char|}
@d last_text_char=128 {ordinal number of the largest element of |text_char|}
@z

%% **     47  ******************************************************************

@x
@p procedure open_gf_file; {prepares to read packed bytes in |gf_file|}
begin reset(gf_file,name_of_file);
cur_loc:=0;
end;
@#
procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
begin reset(tfm_file,name_of_file);
end;
@#
procedure open_dvi_file; {prepares to write packed bytes in |dvi_file|}
begin rewrite(dvi_file,name_of_file);
end;
@y
@p function open_gf_file : boolean; {prepares to read packed bytes in |gf_file|}
begin if not c4p_try_fopen (gf_file,name_of_file,c4p_rb_mode) then
   open_gf_file:=false
else begin
   reset(gf_file);
   cur_loc:=0;
   open_gf_file:=true;
end;
end;
@#
procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
begin if not mt_open_tfm_file(tfm_file,name_of_file) then c4p_exit(1);
reset(tfm_file);
end;
@#
procedure open_dvi_file; {prepares to write packed bytes in |dvi_file|}
begin c4p_fopen (dvi_file,name_of_file,c4p_wb_mode,true);
end;
@z

%% **    78  ******************************************************************

@x
@d home_font_area=max_keyword+16 {string number for system-dependent font area}
@y
@z

%% **    87  ******************************************************************

@x
@ The file names we shall deal with for illustrative purposes have the
following structure:  If the name contains `\.>' or `\.:', the file area
consists of all characters up to and including the final such character;
otherwise the file area is null.  If the remaining file name contains
`\..', the file extension consists of all such characters from the first
remaining `\..' to the end, otherwise the file extension is null.
@^system dependencies@>

We can scan such file names easily by using two global variables that keep track
of the occurrences of area and extension delimiters:

@<Glob...@>=
@!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any}
@!ext_delimiter:pool_pointer; {the relevant `\..', if any}

@ Font metric files whose areas are not given
explicitly are assumed to appear in a standard system area called
|home_font_area|.  This system area name will, of course, vary from place
to place. The program here sets it to `\.{TeXfonts:}'.
@^system dependencies@>
@.TeXfonts@>

@<Initialize the strings@>=
l:=9; init_str9("T")("e")("X")("f")("o")("n")("t")("s")(":")(home_font_area);@/
@y
@ The file names we shall deal with for illustrative purposes have the
following structure:  If the name contains `\./', the file area
consists of all characters up to and including the final such character;
otherwise the file area is null.  If the remaining file name contains
`\..', the file extension consists of all such characters from the first
remaining `\..' to the end, otherwise the file extension is null.
@^system dependencies@>

We can scan such file names easily by using two global variables that keep track
of the occurrences of area and extension delimiters:

@<Glob...@>=
@!area_delimiter:pool_pointer; {the most recent `\./>', if any}
@!ext_delimiter:pool_pointer; {the relevant `\..', if any}

@

@z

%% **    90  ******************************************************************

@x
else  begin if (c=">")or(c=":") then
@y
else  begin if (c="/") then
@z

%% **    92  ******************************************************************

@x
for k:=name_length+1 to file_name_size do name_of_file[k]:=' ';
@y
for k:=name_length+1 to file_name_size do name_of_file[k]:=chr(0);
@z

%% **    94  ******************************************************************

@x
    pack_file_name(cur_name,cur_area,cur_ext); open_gf_file;
    if not eof(gf_file) then goto found;
    print_nl('Oops... I can''t find file '); print(name_of_file);
@y
    pack_file_name(cur_name,cur_area,cur_ext);
    if open_gf_file then goto found;
    print_nl('Oops... I can''t find gf file');
@z

%% **    98  ******************************************************************

@x
  begin if length(font_area[f])=0 then font_area[f]:=home_font_area;
  pack_file_name(font_name[f],font_area[f],tfm_ext);
  open_tfm_file; read_font_info(f,font_at[f]);
  if font_area[f]=home_font_area then font_area[f]:=null_string;
@y
  begin font_area[f]:=null_string;
  pack_file_name(font_name[f],font_area[f],tfm_ext);
  open_tfm_file; read_font_info(f,font_at[f]);
  font_area[f]:=null_string;
@z

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

@x
@p procedure write_dvi(@!a,@!b:dvi_index);
var k:dvi_index;
begin for k:=a to b do write(dvi_file,dvi_buf[k]);
end;
@y
@p procedure write_dvi(@!a,@!b:dvi_index);
begin c4p_buf_write(dvi_file,c4p_ptr(dvi_buf[a]),b-a+1);
end;
@z

%% **    47  ******************************************************************

@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@>=
function mt_open_tfm_file (var f:byte_file; n:integer) : boolean; forward;
procedure miktex_banner (var f:text_file); forward;
@z
