home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG022.ARC / PASTOOLS.LBR / LIBLINK.PAS < prev    next >
Pascal/Delphi Source File  |  1979-12-31  |  2KB  |  69 lines

  1. { liblink.pas
  2.     turbo pascal preprocessor for library link
  3.       by K.Nakazato  Ver. 1.0   September 16, 1984 }
  4.  
  5. const
  6.   name_length =16;
  7.   max_name    =32;
  8.   line_length =128;
  9.   max_buf     =$3FFF;
  10.   Σefault_name='LIB.INC';
  11. typσ
  12.   symbol=(nosym,namesym,externalsym,scansym);
  13.   linetype   =string[line_length];
  14.   stringtype =string[name_length];
  15.   stringarray
  16.     =record
  17.        number:integer;
  18.        name  :array [1..max_name] of stringtype
  19.      end;
  20.   link =^table;
  21.   table=record
  22.           next:link;
  23.           name:stringtype;
  24.           index:integer
  25.         end;
  26. var
  27.   root:link;
  28.   infile,outfile:text;
  29.   infile_name,outfile_name:stringtype;
  30.   bufindex:array [0..max_name] of integer;
  31.   buffer  :array [1..max_buf ] of char;
  32.   arg,scan_,external_:stringarray;
  33.   error:boolean;
  34.  
  35. {$I LIB.INC}
  36. {#scan lib.lib}
  37. {#external getarg,set_buffer,set_string,make_table,condense,make_library}
  38.  
  39. procedure init;
  40. var j:integer;
  41. begin
  42.   getarg(arg);
  43.   if arg.number<1 then
  44.     begin
  45.       writeln('Library linker');
  46.       writeln('usage: >liblink main_file_name [include_file_name]');
  47.       writeln('  When "include_file_name" is absent, "LIB.INC" is assumed.');
  48.       halt
  49.     end
  50.   else infile_name:=arg.name[1];
  51.   if arg.number<2 then outfile_name:=default_name
  52.                   else outfile_name:=arg.name[2]
  53. end;
  54.  
  55. var i:integer;
  56. begin
  57.   init; error:=false; bufindex[0]:=1;
  58.   set_buffer(infile_name,bufindex[0]);
  59.   set_string(scansym,scan_);
  60.   set_string(externalsym,external_);
  61.   for i:=1 to scan_.number do
  62.     begin
  63.       bufindex[i]:=bufindex[i-1];
  64.       set_buffer(scan_.name[i],bufindex[i])
  65.     end;
  66.   new(root); make_table(external_); condense;
  67.   if not error then make_library
  68. end.
  69.