%%%  WEB Change File for GFtoPK (Win32 version)
%%%  Time-stamp: "97/01/03 18:13:59 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{GFtoPK}
@y
\def\MiKTeX{MiK\TeX}
\def\title{GFtoPK for Win32 (\MiKTeX\ 1.06)}
@z

%% **     4  ******************************************************************

@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

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

@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

%% **    10  ******************************************************************

@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

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

@x
@ To prepare the |gf_file| for input, we |reset| it.

@p procedure open_gf_file; {prepares to read packed bytes in |gf_file|}
begin reset(gf_file);
gf_loc := 0 ;
end;

@ To prepare the |pk_file| for output, we |rewrite| it.

@p procedure open_pk_file; {prepares to write packed bytes in |pk_file|}
begin rewrite(pk_file);
pk_loc := 0 ; pk_open := true ;
end;
@y
@ To prepare the |gf_file| for input, we open it via |c4p_fopen()|.
@^system dependencies@>

@p procedure open_gf_file; {prepares to read packed bytes in |gf_file|}
begin
if (c4pargc <> 3) then
 abort('Usage: gftopk inputfile outputpfile');
c4p_fopen(gf_file,c4p_argv[1],c4p_rb_mode,true); reset(gf_file);
gf_loc := 0 ;
end;

@ The |pk_file| is opened for binary output.

@p procedure open_pk_file; {prepares to write packed bytes in |pk_file|}
begin
if (c4pargc <> 3) then
 abort('Usage: gftopk inputfile outputfile');
c4p_fopen(pk_file,c4p_argv[2],c4p_wb_mode,true);
pk_loc := 0 ; pk_open := true ;
end;
@z

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

@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.
@^system dependencies@>

@p procedure find_gf_length ;
begin
   set_pos(gf_file, -1) ; gf_len := cur_pos(gf_file) ;
end ;
@#
procedure move_to_byte(@!n : integer) ;
begin
   set_pos(gf_file, n); gf_loc := n ;
end ;
@y
Such routines are, of course, highly system dependent.  They are implemented
here in terms of two 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.
@^system dependencies@>

@p procedure find_gf_length ;
begin
c4p_fseek(gf_file,0,c4p_end); gf_len:=c4p_ftell(gf_file);
end;
@#
procedure move_to_byte(@!n : integer) ;
begin c4p_fseek(gf_file,n,c4p_set); gf_loc:=n;
end;
@z

%% **    83  ******************************************************************

@x
comment := preamble_comment ;
@y
c4p_strcpy (comment, preamble_comment);
@z

%% **    86  ******************************************************************

@x
@ Finally, the main program.

@p begin
  initialize ;
  convert_gf_file ;
  @<Check for un-rasterized locaters@> ;
  print_ln(gf_len:1,' bytes packed to ',pk_loc:1,' bytes.') ;
final_end : end .
@y
@ Finally, the main program.

@p begin
  if c4p_setjmp(env_buf) <> 0 then goto final_end;
  initialize ;
  convert_gf_file ;
  @<Check for un-rasterized locaters@> ;
  print_ln(gf_len:1,' bytes packed to ',pk_loc:1,' bytes.') ;
  c4p_exit (0);
final_end :
  c4p_exit (1);
end .
@z

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

@x
@ A few more globals.

@<Glob...@>=
@y
@ A few more globals.

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

%% **    88  ******************************************************************

@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 miktex_banner (var f:text_file); forward;
@z
