v21i050: Pascal to C translator, Part05/32

Rich Salz rsalz at uunet.uu.net
Tue Mar 27 06:31:11 AEST 1990


Submitted-by: Dave Gillespie <daveg at csvax.caltech.edu>
Posting-number: Volume 21, Issue 50
Archive-name: p2c/part05

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 5 (of 32)."
# Contents:  HP/import/sysglobals.imp src/COPYING src/stuff.c
# Wrapped by rsalz at litchi.bbn.com on Mon Mar 26 14:29:29 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'HP/import/sysglobals.imp' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'HP/import/sysglobals.imp'\"
else
echo shar: Extracting \"'HP/import/sysglobals.imp'\" \(13046 characters\)
sed "s/^X//" >'HP/import/sysglobals.imp' <<'END_OF_FILE'
X
X
X{IncludeFrom=sysglobals <p2c/sysglobals.h>}
X
X
X{*VarStrings=1} {*ExportSymbol=}
X
X
Xmodule sysglobals;  
X
Xexport 
X
Xtype fsidctype = packed array[1..20] of char; 
Xconst 
X  fsidc = fsidctype['Rev.  3.1  18-Jul-85'];   
X                             (*20 CHARS: VERSION,DATE,TIME OF FILE SYS*)
X  mminint = -32768;          (*MINIMUM SHORT INTEGER VALUE*)
X  mmaxint =  32767;          (*MAXIMUM SHORT INTEGER VALUE*)
X  maxunit = 50;              (*MAXIMUM PHYSICAL UNIT NUMBER*)
X  passleng = 16;             (*NUMBER OF CHARS IN A PASSWORD*)
X  vidleng = 16;              (*NUMBER OF CHARS IN A VOLUME NAME*)
X  tidleng = 16;              (*NUMBER OF CHARS IN A FILE TITLE*)
X  fidleng = 120;             (*NUMBER OF CHARS IN FILE NAME*)
X  fblksize = 512;            (*STANDARD FILE BUFFER LENGTH*)
X  maxsc=63;                  (*LARGEST SELECT CODE *)
X  minlevel=1;                (*LOWEST INTERRUPT LEVEL*)
X  maxlevel=6;                (*LARGEST MASKABLE INTERRUPT LEVEL*)
X      
X  
Xtype  
X
X  byte = 0..255; 
X  shortint = mminint..mmaxint;  
X  ipointer = ^integer;
X  charptr = ^char;
X  textpntr = ^text; 
X  string80 = string[80];
X  string255 = string[255];
X  suffixtype = string[5];
X  string255ptr = ^string255; 
X
X                                                              
X  unitnum = 0..maxunit; 
X  vid = string[vidleng]; 
X  tid = string[tidleng];
X  fid = string[fidleng];
X  passtype = string[passleng];
X
X  filekind = (untypedfile,      {directory entry} 
X              badfile,          {bad blocks}
X              codefile,         {executable or linkable}
X              textfile,         {UCSD format text with editor environment}
X              asciifile,        {L.I.F. ASCII format text strings}
X              datafile,         {file of  <data type, e.g. char, integer,etc.>}
X              sysfile,          {system (BOOT) file}
X     fkind7,  fkind8,  fkind9,  
X     fkind10, fkind11, fkind12, 
X     fkind13, fkind14, lastfkind);      {reserved for future expansion}
X
X  
X                                                           (*FILE INFORMATION*)
X
Xwindow = packed array [0..maxint] of char;
Xwindowp = ^window;
X
X
Xfibp = ^fib;
X
Xamrequesttype = (readbytes, writebytes, flush, writeeol, readtoeol, clearunit, 
X          setcursor, getcursor, startread, startwrite, unitstatus, seekeof); 
Xamtype = procedure (fp: fibp; request: amrequesttype; 
X                           anyvar buffer: window; bufsize, position: integer); 
Xeotproc = procedure(fp: fibp); 
X
Xfib = packed record 
X           fwindow: windowp;                         (*BUFFER VARIABLE...F^ *)
X           flistptr: fibp;                            (* LIST OF OPEN FILES *)
X       {declaration and type information}
X           frecsize: integer;                 (* SIZE OF ONE LOGICAL RECORD *)
X           feft: shortint;                            (* EXTERNAL FILE TYPE *)
X           fkind: filekind;                                    (* FILE KIND *)
X           fistextvar:  boolean;                  (* FILE IS LINE FORMATTED *)
X           fbuffered:   boolean;               (* HAS 512 BYTE BLOCK BUFFER *)
X           fanonymous: boolean;                         (* FILE HAS NO NAME *)
X           fisnew:  boolean;                (* WAS CREATED THIS ASSOCIATION *)
X           freadable, fwriteable: boolean;            (* FILE ACCESS RIGHTS *)
X       {state information}
X           freadmode, fbufvalid: boolean;         (*F^ AND LOOKAHEAD STATES *)
X           feoln: boolean;                          (* F^ IS AN END OF LINE *) 
X           feof: boolean;                 (* TRIED TO READ PAST END OF FILE *)
X           fmodified: boolean;                     (* FILE HAS CHANGED SIZE *)
X           fbufchanged: boolean;              (* BUFFER NEEDS TO BE WRITTEN *)
X       {file size and position}
X           fpos:  integer;           (* FILE POINTER, CURRENT FILE POSITION *)
X           fleof: integer;         (*LOGICAL END OF FILE, CURRENT FILE SIZE *)
X           fpeof: integer;        (*PHYSICAL END OF FILE, MAXIMUM FILE SIZE *)
X       {buffering and low level formatting information}
X           flastpos:  integer;                   (* FILE POSITION OF BUFFER *)
X           freptcnt:  shortint;                  (* SPACE COMPRESSION COUNT *)
X           am:  amtype;                              (*BUFFER METHOD MODULE *)
X       {file association info}
X           fstartaddress: integer;         (*EXECUTION ADDRESS IN BOOT FILE *)
X           fvid: vid;                                        (* VOLUME NAME *)
X           ffpw: passtype;                                 (* FILE PASSWORD *)
X           ftid: tid;                                          (* FILE NAME *)
X           pathid:  integer;     (* ADDITIONAL SYSTEM DEPENDENT INFORMATION *)
X           fanonctr: shortint;                      (* TEMP FILE IDENTIFIER *)
X           foptstring: string255ptr;               (* OPTIONAL STRING PARAM *)
X       {byte block transfer information}
X           fileid:  integer; (* START BYTE OF FILE, OR OTHER IDENTIFICATION *)
X           fb0,fb1,                                 (* FOR FUTURE EXPANSION *)
X           fnosrmtemp,                   (*TRUE IF NO SRM TEMP FILE CREATED *)
X           fwaitonlock,                  (*TRUE IF SRM SHOULD WAIT FOR LOCK *)
X           fpurgeoldlink,            (*TRUE IF OLD SRM LINK IS TO BE PURGED *)
X           foverwritten,                    (*TRUE IF OPENED WITH OVERWRITE *)
X           fsavepathid,               (*TRUE IF PATHID NOT UNIQUE TO FILEID *)
X           flockable,                     (*TRUE IF FILE OPENED AS LOCKABLE *)
X           flocked,                                (*TRUE IF FILE IS LOCKED *)
X           fbusy        : boolean;               (*TRUE IF DRIVER IS ACTIVE *)
X           funit        : unitnum;                   (*PHYSICAL UNIT NUMBER *)
X           feot         : eotproc;         (*CALLED WHEN TRANSFER COMPLETES *)
X           fxpos        : integer;                (* X POSITION FOR  GOTOXY *)
X           fypos        : integer;                (* Y POSITION FOR  GOTOXY *)
X           foldfileid   : integer;    (* FILEID FOR OLD SRM FILE ON REWRITE *)
X       {for future expansion}
X           fextra:  array[0..2] of integer;
X           fextra2: shortint;
X       {large miscellaneous fields sometimes present}
X           case integer of 
X             0: ( {minimal FIB ends here} );
X             1: (ftitle:  fid);        (* FILE NAME, EXCEPT VOLUME AND SIZE *)
X             2: (fbuffer: packed array [0..fblksize-1] of char); 
X        end (*FIB*) ;
X
X
Xdamrequesttype = (getvolumename, setvolumename, getvolumedate, setvolumedate,  
X changename, purgename, 
X openfile, createfile, overwritefile, closefile, purgefile,
X stretchit, makedirectory, crunch, opendirectory, closedirectory, catalog,
X stripname, setunitprefix, openvolume, duplicatelink, openparentdir,
X catpasswords,setpasswords,lockfile,unlockfile,openunit); 
X  
Xdamtype = procedure (anyvar f: fib; unum:unitnum; request: damrequesttype); 
X  
Xunitentry =  {unitable entry definition}
X    packed record
X      dam: damtype;                     {directory access method}
X      tm:  amtype;                      {byte block transfer method}
X      sc: byte;                         {select code}
X      ba: byte;                         {bus address} 
X      du: byte;                         {disc unit}  
X      dv: byte;                         {disc volume}
X      byteoffset: integer;              {physical starting byte of volume} 
X      devid: integer;                   {identifier (Amigo identify sequence)} 
X      uvid: vid;                        {volume id}
X      dvrtemp: integer;                 {temp for driver use only; init to 0!}
X      dvrtemp2: shortint;               {temp for driver use only; init to 0!}
X      letter: char;                     {device specifier letter}
X      offline,                          {unit absent or down flag}
X      uisinteractive,                   {user can edit input}
X      umediavalid,                      {medium not changed since last access}
X      uuppercase:   boolean;            {volume name must be uppercased}
X      uisfixed: boolean;                {fixed/removeable media flag}
X      ureportchange: boolean;           {driver mode: report/ignore media change}
X      pad: 0..1;                        {   (bit not used yet)  }
X      case uisblkd: boolean of          {blocked volume flag}
X        true: (umaxbytes: integer)      {volume size in bytes }
X    end;  {unitentry}
X    
Xunitabletype = array [unitnum] of unitentry;                   (*0 NOT USED*)
Xamtabletype  = array[filekind] of amtype; 
Xsuftabletype = array[filekind] of suffixtype; 
Xefttabletype = array[filekind] of shortint; 
X
Xunitableptr     = ^unitabletype;
Xamtableptrtype  = ^amtabletype; 
Xsuftableptrtype = ^suftabletype; 
Xefttableptrtype = ^efttabletype; 
X  
X  
Xiorsltwd = 
X            { *note* the ioresult enumerations have been partitioned into two
X              mutually-exclusive groups: those beginning with 'z' are reserved
X              for the low-level drivers , and those beginning
X              with 'i' are reserved for the higher-level routines.}
X             
X             (inoerror,zbadblock,ibadunit,zbadmode,ztimeout,
X              ilostunit,ilostfile,ibadtitle,inoroom,inounit,
X              inofile,idupfile,inotclosed,inotopen,ibadformat,
X              znosuchblk,znodevice,zinitfail,zprotected,
X              zstrangei,zbadhardware,zcatchall,zbaddma,
X              inotvalidsize,inotreadable,inotwriteable,inotdirect,
X              idirfull,istrovfl,ibadclose,ieof,
X              zuninitialized,znoblock,znotready,znomedium,
X              inodirectory,ibadfiletype,ibadvalue,icantstretch,
X              ibadrequest, inotlockable, ifilelocked, ifileunlocked, 
X              idirnotempty, itoomanyopen, inoaccess, ibadpass, ifilenotdir, 
X              inotondir, ineedtempdir, isrmcatchall, zmediumchanged,
X              {end marker} endioerrs);
X  
Xproctype=procedure;
Xsctype=0..maxsc;
Xleveltype=minlevel..maxlevel;
Xpisrib = ^isrib;
Xisrproctype = procedure(isribptr: pisrib);
Xisrib = {isr information block}
X   packed record
X     intregaddr: charptr;       {interrupt register address}
X     intregmask: byte;          {interrupt register mask}
X     intregvalue: byte;         {interrupt register target value after masking}
X     chainflag: boolean;        {chaining flag}
X     proc: isrproctype;         {isr}
X     link: pisrib;              {pointer to next isrib in linked list}
X   end;
X 
Xinttabletype = array [1..7] of pisrib;
X
Xaction = procedure; 
X
Xdaterec         = packed record
X                    year        : 0..100;       (*100 IS TEMP DISK FLAG*)
X                    day         : 0..31;        (*DAY OF MONTH*)
X                    month       : 0..12;        (*0 ==> DATE NOT MEANINGFUL*)
X                  end; 
X
Xtimerec         = packed record
X                    hour        : 0..23;
X                    minute      : 0..59;
X                    centisecond : 0..5999;
X                  end; 
X  
Xdatetimerec     = packed record
X                    date        : daterec;
X                    time        : timerec;
X                  end;
X
Xvar
X(*========= MANY OF THE FOLLOWING HAVE HARDCODED
X            ADDRESSES IN COMPILER AND ELSEWHERE  =====*)
X       
X(*** ERROR RECOVERY  ***)
X  sysescapecode:        shortint; 
X  openfileptr:  anyptr; 
X  recoverblock: anyptr; 
X  
X(*** MEMORY MANAGEMENT ***)
X  heapmax:      anyptr; 
X  heapbase:     anyptr; 
X  
X(*** I/O DRIVERS ***)
X  sysioresult:          integer; 
X  hardwarestatus:       integer;
X  locklevel:      integer; 
X  unitable: unitableptr;
X  interrupttable: inttabletype;
X  endisrhook:  integer;
X  actionspending: integer; 
X  
X(*** FILE SYSTEM ***)
X  gfiles: array[0..5] of textpntr;    
X  {  [0] INPUT          [3] (unused)
X     [1] OUTPUT         [4] LISTING 
X     [2] KEYBOARD       [5] (unused)   }
X  
X  amtable:     amtableptrtype;                  {pointer to access methods }
X  suffixtable: suftableptrtype;                 {pointer to list of suffixes}
X  efttable:    efttableptrtype;                 {pointer to LIF file types}
X  sysunit: integer;
X  syvid,dkvid: vid;                           (*SYSUNIT VOLID & DEFAULT VOLID*)
X  syslibrary: fid; 
X  
X  (*** DEBUGGER HOOK ***)
X  debugger: procedure(p1, p2, p3: integer); 
X  
X  (*** CLEAR I/O HOOK ***)
X  cleariohook : procedure;    
X  
X  perminttable: inttabletype;
X  
X  deferredaction: array[1..10] of action; 
X  
X  serialtextamhook: amtype;             {access method for serial devices}
X  
X  sysname[-574]: packed array[1..10] of char; 
X  
X  sysflag[-302]: packed record
X    reserved1, reserved2, nointhpib, crtconfigreg, 
X    nokeyboard, highlightsxorbiggraphics, biggraphics,
X    alpha50: boolean; 
X    end; 
X
X  sysflag2[hex('FFFFFEDA')]: packed record    {extend to 8 digits SFB 4/26/85}
X                             pad7to1    : 0..127;
X                             prompresent: boolean;
X                           end;
X                           
X  endsysvars : shortint;   {must be last thing
X                            in SYSGLOBALS}
X  
X
Xend.
X
END_OF_FILE
if test 13046 -ne `wc -c <'HP/import/sysglobals.imp'`; then
    echo shar: \"'HP/import/sysglobals.imp'\" unpacked with wrong size!
fi
# end of 'HP/import/sysglobals.imp'
fi
if test -f 'src/COPYING' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/COPYING'\"
else
echo shar: Extracting \"'src/COPYING'\" \(12488 characters\)
sed "s/^X//" >'src/COPYING' <<'END_OF_FILE'
X
X		    GNU GENERAL PUBLIC LICENSE
X		     Version 1, February 1989
X
X Copyright (C) 1989 Free Software Foundation, Inc.
X                    675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X			    Preamble
X
X  The license agreements of most software companies try to keep users
Xat the mercy of those companies.  By contrast, our General Public
XLicense is intended to guarantee your freedom to share and change free
Xsoftware--to make sure the software is free for all its users.  The
XGeneral Public License applies to the Free Software Foundation's
Xsoftware and to any other program whose authors commit to using it.
XYou can use it for your programs, too.
X
X  When we speak of free software, we are referring to freedom, not
Xprice.  Specifically, the General Public License is designed to make
Xsure that you have the freedom to give away or sell copies of free
Xsoftware, that you receive source code or can get it if you want it,
Xthat you can change the software or use pieces of it in new free
Xprograms; and that you know you can do these things.
X
X  To protect your rights, we need to make restrictions that forbid
Xanyone to deny you these rights or to ask you to surrender the rights.
XThese restrictions translate to certain responsibilities for you if you
Xdistribute copies of the software, or if you modify it.
X
X  For example, if you distribute copies of a such a program, whether
Xgratis or for a fee, you must give the recipients all the rights that
Xyou have.  You must make sure that they, too, receive or can get the
Xsource code.  And you must tell them their rights.
X
X  We protect your rights with two steps: (1) copyright the software, and
X(2) offer you this license which gives you legal permission to copy,
Xdistribute and/or modify the software.
X
X  Also, for each author's protection and ours, we want to make certain
Xthat everyone understands that there is no warranty for this free
Xsoftware.  If the software is modified by someone else and passed on, we
Xwant its recipients to know that what they have is not the original, so
Xthat any problems introduced by others will not reflect on the original
Xauthors' reputations.
X
X  The precise terms and conditions for copying, distribution and
Xmodification follow.
X
X		    GNU GENERAL PUBLIC LICENSE
X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X  0. This License Agreement applies to any program or other work which
Xcontains a notice placed by the copyright holder saying it may be
Xdistributed under the terms of this General Public License.  The
X"Program", below, refers to any such program or work, and a "work based
Xon the Program" means either the Program or any work containing the
XProgram or a portion of it, either verbatim or with modifications.  Each
Xlicensee is addressed as "you".
X
X  1. You may copy and distribute verbatim copies of the Program's source
Xcode as you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy an appropriate copyright notice and
Xdisclaimer of warranty; keep intact all the notices that refer to this
XGeneral Public License and to the absence of any warranty; and give any
Xother recipients of the Program a copy of this General Public License
Xalong with the Program.  You may charge a fee for the physical act of
Xtransferring a copy.
X
X  2. You may modify your copy or copies of the Program or any portion of
Xit, and copy and distribute such modifications under the terms of Paragraph
X1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating that
X    you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish, that
X    in whole or in part contains the Program or any part thereof, either
X    with or without modifications, to be licensed at no charge to all
X    third parties under the terms of this General Public License (except
X    that you may choose to grant warranty protection to some or all
X    third parties, at your option).
X
X    c) If the modified program normally reads commands interactively when
X    run, you must cause it, when started running for such interactive use
X    in the simplest and most usual way, to print or display an
X    announcement including an appropriate copyright notice and a notice
X    that there is no warranty (or else, saying that you provide a
X    warranty) and that users may redistribute the program under these
X    conditions, and telling the user how to view a copy of this General
X    Public License.
X
X    d) You may charge a fee for the physical act of transferring a
X    copy, and you may at your option offer warranty protection in
X    exchange for a fee.
X
XMere aggregation of another independent work with the Program (or its
Xderivative) on a volume of a storage or distribution medium does not bring
Xthe other work under the scope of these terms.
X
X  3. You may copy and distribute the Program (or a portion or derivative of
Xit, under Paragraph 2) in object code or executable form under the terms of
XParagraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal charge
X    for the cost of distribution) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
XSource code for a work means the preferred form of the work for making
Xmodifications to it.  For an executable file, complete source code means
Xall the source code for all modules it contains; but, as a special
Xexception, it need not include source code for modules which are standard
Xlibraries that accompany the operating system on which the executable
Xfile runs, or for standard header files or definitions files that
Xaccompany that operating system.
X
X  4. You may not copy, modify, sublicense, distribute or transfer the
XProgram except as expressly provided under this General Public License.
XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
Xthe Program is void, and will automatically terminate your rights to use
Xthe Program under this License.  However, parties who have received
Xcopies, or rights to use copies, from you under this General Public
XLicense will not have their licenses terminated so long as such parties
Xremain in full compliance.
X
X  5. By copying, distributing or modifying the Program (or any work based
Xon the Program) you indicate your acceptance of this license to do so,
Xand all its terms and conditions.
X
X  6. Each time you redistribute the Program (or any work based on the
XProgram), the recipient automatically receives a license from the original
Xlicensor to copy, distribute or modify the Program subject to these
Xterms and conditions.  You may not impose any further restrictions on the
Xrecipients' exercise of the rights granted herein.
X
X  7. The Free Software Foundation may publish revised and/or new versions
Xof the General Public License from time to time.  Such new versions will
Xbe similar in spirit to the present version, but may differ in detail to
Xaddress new problems or concerns.
X
XEach version is given a distinguishing version number.  If the Program
Xspecifies a version number of the license which applies to it and "any
Xlater version", you have the option of following the terms and conditions
Xeither of that version or of any later version published by the Free
XSoftware Foundation.  If the Program does not specify a version number of
Xthe license, you may choose any version ever published by the Free Software
XFoundation.
X
X  8. If you wish to incorporate parts of the Program into other free
Xprograms whose distribution conditions are different, write to the author
Xto ask for permission.  For software which is copyrighted by the Free
XSoftware Foundation, write to the Free Software Foundation; we sometimes
Xmake exceptions for this.  Our decision will be guided by the two goals
Xof preserving the free status of all derivatives of our free software and
Xof promoting the sharing and reuse of software generally.
X
X			    NO WARRANTY
X
X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
XREPAIR OR CORRECTION.
X
X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
XPOSSIBILITY OF SUCH DAMAGES.
X
X		     END OF TERMS AND CONDITIONS
X
X	Appendix: How to Apply These Terms to Your New Programs
X
X  If you develop a new program, and you want it to be of the greatest
Xpossible use to humanity, the best way to achieve this is to make it
Xfree software which everyone can redistribute and change under these
Xterms.
X
X  To do so, attach the following notices to the program.  It is safest to
Xattach them to the start of each source file to most effectively convey
Xthe exclusion of warranty; and each file should have at least the
X"copyright" line and a pointer to where the full notice is found.
X
X    <one line to give the program's name and a brief idea of what it does.>
X    Copyright (C) 19yy  <name of author>
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 1, or (at your option)
X    any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    You should have received a copy of the GNU General Public License
X    along with this program; if not, write to the Free Software
X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XAlso add information on how to contact you by electronic and paper mail.
X
XIf the program is interactive, make it output a short notice like this
Xwhen it starts in an interactive mode:
X
X    Gnomovision version 69, Copyright (C) 19xx name of author
X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
X    This is free software, and you are welcome to redistribute it
X    under certain conditions; type `show c' for details.
X
XThe hypothetical commands `show w' and `show c' should show the
Xappropriate parts of the General Public License.  Of course, the
Xcommands you use may be called something other than `show w' and `show
Xc'; they could even be mouse-clicks or menu items--whatever suits your
Xprogram.
X
XYou should also get your employer (if you work as a programmer) or your
Xschool, if any, to sign a "copyright disclaimer" for the program, if
Xnecessary.  Here a sample; alter the names:
X
X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
X  program `Gnomovision' (a program to direct compilers to make passes
X  at assemblers) written by James Hacker.
X
X  <signature of Ty Coon>, 1 April 1989
X  Ty Coon, President of Vice
X
XThat's all there is to it!
END_OF_FILE
if test 12488 -ne `wc -c <'src/COPYING'`; then
    echo shar: \"'src/COPYING'\" unpacked with wrong size!
fi
# end of 'src/COPYING'
fi
if test -f 'src/stuff.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/stuff.c'\"
else
echo shar: Extracting \"'src/stuff.c'\" \(13512 characters\)
sed "s/^X//" >'src/stuff.c' <<'END_OF_FILE'
X/* "p2c", a Pascal to C translator.
X   Copyright (C) 1989 David Gillespie.
X   Author's address: daveg at csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
X
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation (any version).
X
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
XGNU General Public License for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with this program; see the file COPYING.  If not, write to
Xthe Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
X
X
X
X#define PROTO_STUFF_C
X#include "trans.h"
X
X
X
X
X
X
X/* Called regularly, for debugging purposes */
X
Xvoid debughook()
X{
X#if 0
X    Symbol *sp;
X    Meaning *mp;
X    static int flag = 0;
X
X    sp = findsymbol_opt("DEFSTIPPLES");
X    if (sp) {
X	mp = sp->mbase;
X	if (mp) {
X	    flag = 1;
X	    if (mp->sym != sp || mp->snext)
X		intwarning("debughook", "Inconsistent!");
X	} else
X	    if (flag)
X		intwarning("debughook", "Missing!");
X    }
X#endif
X}
X
X
X
X
X
X
X/* The "Strlist" data type, like in NEWASM */
X
X
X/* Add a string to end of strlist */
X
XStrlist *strlist_append(base, s)
Xregister Strlist **base;
Xregister char *s;
X{
X    register Strlist *p;
X
X    while (*base)
X        base = &(*base)->next;
X    *base = p = ALLOCV(sizeof(Strlist) + strlen(s), Strlist, strlists);
X    p->next = NULL;
X    p->value = 0;
X    strcpy(p->s, s);
X    return p;
X}
X
X
X
X/* Insert a string at front of strlist */
X
XStrlist *strlist_insert(base, s)
Xregister Strlist **base;
Xregister char *s;
X{
X    register Strlist *p;
X
X    p = ALLOCV(sizeof(Strlist) + strlen(s), Strlist, strlists);
X    p->next = *base;
X    *base = p;
X    p->value = 0;
X    strcpy(p->s, s);
X    return p;
X}
X
X
X
X/* Add a string to a sorted strlist */
X
XStrlist *strlist_add(base, s)
Xregister Strlist **base;
Xregister char *s;
X{
X    register Strlist *p;
X
X    while ((p = *base) && strcmp(p->s, s) < 0)
X        base = &p->next;
X    if (!p || strcmp(p->s, s)) {
X        p = ALLOCV(sizeof(Strlist) + strlen(s), Strlist, strlists);
X        p->next = *base;
X        *base = p;
X        strcpy(p->s, s);
X    }
X    p->value = 0;
X    return p;
X}
X
X
X
X/* Append two strlists together */
X
Xvoid strlist_mix(base, sl)
Xregister Strlist **base;
XStrlist *sl;
X{
X    if (sl) {
X	while (*base)
X	    base = &(*base)->next;
X	*base = sl;
X    }
X}
X
X
X
X/* Remove the first element of a strlist */
X
Xvoid strlist_eat(base)
Xregister Strlist **base;
X{
X    register Strlist *p;
X
X    if ((p = *base) != NULL) {
X        *base = p->next;
X        FREE(p);
X    }
X}
X
X
X
X/* Remove all elements of a strlist */
X
Xvoid strlist_empty(base)
Xregister Strlist **base;
X{
X    register Strlist *p;
X
X    if (!base) {
X	intwarning("strlist_empty", "NULL base pointer [312]");
X	return;
X    }
X    while ((p = *base) != NULL) {
X        *base = p->next;
X        FREE(p);
X    }
X}
X
X
X
X/* Remove first occurrence of a given string */
X
Xvoid strlist_remove(base, s)
Xregister Strlist **base;
Xregister char *s;
X{
X    register Strlist *p;
X
X    while ((p = *base) != NULL) {
X	if (!strcmp(p->s, s)) {
X	    *base = p->next;
X	    FREE(p);
X	} else
X	    base = &p->next;
X    }
X}
X
X
X
X/* Remove a given entry from a strlist */
X
Xvoid strlist_delete(base, sl)
Xregister Strlist **base, *sl;
X{
X    register Strlist *p;
X
X    while ((p = *base) && p != sl)
X        base = &p->next;
X    if (p) {
X        *base = p->next;
X        FREE(p);
X    }
X}
X
X
X
X/* Find the first occurrence of a string */
X
XStrlist *strlist_find(base, s)
Xregister Strlist *base;
Xregister char *s;
X{
X    if (!s)
X	return NULL;
X    while (base && strcmp(base->s, s))
X        base = base->next;
X    return base;
X}
X
X
X
X/* Case-insensitive version of strlist_find */
X
XStrlist *strlist_cifind(base, s)
Xregister Strlist *base;
Xregister char *s;
X{
X    if (!s)
X	return NULL;
X    while (base && strcicmp(base->s, s))
X        base = base->next;
X    return base;
X}
X
X
X
X
X
X
X/* String comparisons */
X
X
Xint strcincmp(s1, s2, n)
Xregister char *s1, *s2;
Xregister int n;
X{
X    register unsigned char ch1, ch2;
X
X    while (--n >= 0) {
X        if (!(ch1 = *s1++))
X            return (*s2) ? -1 : 0;
X        if (!(ch2 = *s2++))
X            return 1;
X        if (islower(ch1))
X            ch1 = _toupper(ch1);
X        if (islower(ch2))
X            ch2 = _toupper(ch2);
X        if (ch1 != ch2)
X            return ch1 - ch2;
X    }
X    return 0;
X}
X
X
X
Xint strcicmp(s1, s2)
Xregister char *s1, *s2;
X{
X    register unsigned char ch1, ch2;
X
X    for (;;) {
X        if (!(ch1 = *s1++))
X            return (*s2) ? -1 : 0;
X        if (!(ch2 = *s2++))
X            return 1;
X        if (islower(ch1))
X            ch1 = _toupper(ch1);
X        if (islower(ch2))
X            ch2 = _toupper(ch2);
X        if (ch1 != ch2)
X            return ch1 - ch2;
X    }
X}
X
X
X
X
X
X
X/* File name munching */
X
X
Xvoid fixfname(fn, ext)
Xchar *fn, *ext;
X{
X    char *cp, *cp2;
X
X    if (!ext)
X        return;
X    cp = my_strrchr(fn, '.');
X    cp2 = my_strrchr(fn, '/');
X    if (cp && (!cp2 || cp > cp2)) {
X        if (!cp[1])     /* remove trailing '.' */
X            *cp = 0;
X    } else {
X        strcat(fn, ".");
X        strcat(fn, ext);
X    }
X}
X
X
X
Xvoid removesuffix(fn)
Xchar *fn;
X{
X    char *cp, *cp2;
X
X    cp = my_strrchr(fn, '.');
X    if (!cp)
X        return;
X#if defined(unix) || defined(__unix)
X    cp2 = my_strrchr(fn, '/');
X    if (cp2 && cp < cp2)
X        return;
X#endif
X    *cp = 0;
X}
X
X
X
X
X
X
X/* Dynamically-allocated strings */
X
X
Xchar *stralloc(s)
Xchar *s;
X{
X    register char *buf = ALLOC(strlen(s) + 1, char, strings);
X    strcpy(buf, s);
X    return buf;
X}
X
X
X
Xvoid strchange(v, s)
Xchar **v, *s;
X{
X    s = stralloc(s);   /* do this first in case **v and *s overlap */
X    FREE(*v);
X    *v = s;
X}
X
X
X
X
X
X/* Handy string formatting */
X
X#define NUMBUF 8
Xstatic char *(formatbuf[NUMBUF]);
Xstatic int nextformat = -1;
X
X#define getformat()  ((nextformat=(nextformat+1)%NUMBUF), formatbuf[nextformat])
X
X
X#define FF_UCASE   0x1
X#define FF_LCASE   0x2
X#define FF_REMSUFF 0x4
X#define FF_UNDER   0x8     /* Thanks to William Bader for suggesting these */
X#define FF_PRESERVE 0x10
X#define FF_REMSLASH 0x20
X#define FF_REMUNDER 0x40
X
XStatic void cvcase(buf, flags)
Xchar *buf;
Xint flags;
X{
X    char *cp, *cp2;
X    int ulflag, i;
X
X    if (flags & FF_PRESERVE) {
X        ulflag = 0;
X	for (cp = buf; *cp; cp++) {
X	    if (isupper(*cp))
X		ulflag |= 1;
X	    else if (islower(*cp))
X		ulflag |= 2;
X	}
X	if (ulflag == 3)
X	    flags &= ~(FF_UCASE | FF_LCASE);
X    }
X    if ((flags & FF_UNDER) && *buf) {
X        for (cp = buf + 1; *cp; cp++) {
X            if (isupper(*cp) && islower(cp[-1])) {
X		for (i = strlen(cp); i >= 0; i--)
X		    cp[i+1] = cp[i];
X		*cp++ = '_';
X	    }
X	}
X    }
X    if (flags & FF_UCASE) {
X	if (flags & FF_LCASE) {
X	    for (cp = buf; *cp; cp++) {
X		if (cp == buf || !isalpha(cp[-1]))
X		    *cp = toupper(*cp);
X		else
X		    *cp = tolower(*cp);
X	    }
X	} else
X	    upc(buf);
X    } else if (flags & FF_LCASE)
X	lwc(buf);
X    if (flags & FF_REMUNDER) {
X	for (cp = cp2 = buf; *cp; cp++) {
X	    if (isalnum(*cp))
X		*cp2++ = *cp;
X	}
X	if (cp2 > buf)
X	    *cp2 = 0;
X    }
X}
X
X
Xchar *format_gen(fmt, i1, i2, dbl, s1, s2, s3)
Xchar *fmt;
Xlong i1, i2;
Xdouble dbl;
Xchar *s1, *s2, *s3;
X{
X    char *buf = getformat();
X    char *dst = buf, *src = fmt, *cp, *cp2, *saves2 = s2;
X    int wid, prec;
X    int flags;
X    char fmtbuf[50], *fp;
X
X    debughook();
X    while (*src) {
X	if (*src != '%') {
X	    *dst++ = *src++;
X	    continue;
X	}
X	src++;
X	wid = -1;
X	prec = -1;
X	flags = 0;
X	fp = fmtbuf;
X	*fp++ = '%';
X	for (;;) {
X	    if (*src == '-' || *src == '+' || *src == ' ' || *src == '#') {
X		*fp++ = *src;
X	    } else if (*src == '^') {
X		flags |= FF_UCASE;
X	    } else if (*src == '_') {
X		flags |= FF_LCASE;
X	    } else if (*src == 'R') {
X		flags |= FF_REMSUFF;
X	    } else if (*src == '~') {
X		flags |= FF_UNDER;
X	    } else if (*src == '!') {
X		flags |= FF_REMUNDER;
X	    } else if (*src == '?') {
X		flags |= FF_PRESERVE;
X	    } else if (*src == '/') {
X		flags |= FF_REMSLASH;
X	    } else
X		break;
X	    src++;
X	}
X	if (isdigit(*src)) {
X	    wid = 0;
X	    while (isdigit(*src))
X		wid = wid*10 + (*fp++ = *src++) - '0';
X	} else if (*src == '*') {
X	    src++;
X	    wid = i1;
X	    sprintf(fp, "%d", wid);
X	    fp = fp + strlen(fp);
X	    if (wid < 0)
X		wid = -wid;
X	    i1 = i2;
X	}
X	if (*src == '.') {
X	    if (*++src == '*') {
X		prec = i1;
X		i1 = i2;
X		src++;
X	    } else {
X		prec = 0;
X		while (isdigit(*src))
X		    prec = prec*10 + (*src++) - '0';
X	    }
X	    sprintf(fp, ".%d", prec);
X	    fp = fp + strlen(fp);
X	}
X	if (*src == 'l' || *src == 'h')
X	    src++;
X	switch (*src) {
X
X	  case '%':
X	    *dst++ = '%';
X	    break;
X
X	  case 'H':
X	    strcpy(dst, p2c_home);
X	    dst = dst + strlen(dst);
X	    break;
X
X	  case 'd':
X	  case 'i':
X	  case 'o':
X	  case 'u':
X	  case 'x':
X	  case 'X':
X	    *fp++ = 'l';
X	    *fp++ = *src;
X	    *fp = 0;
X	    sprintf(dst, fmtbuf, i1);
X	    i1 = i2;
X	    cvcase(dst, flags);
X	    dst = dst + strlen(dst);
X	    break;
X
X	  case 'c':
X	    *fp++ = *src;
X	    *fp = 0;
X	    sprintf(dst, fmtbuf, (int)i1);
X	    i1 = i2;
X	    cvcase(dst, flags);
X	    dst = dst + strlen(dst);
X	    break;
X
X	  case 'e':
X	  case 'E':
X	  case 'f':
X	  case 'g':
X	  case 'G':
X	    *fp++ = *src;
X	    *fp++ = 0;
X	    sprintf(dst, fmtbuf, dbl);
X	    cvcase(dst, flags);
X	    dst = dst + strlen(dst);
X	    break;
X
X	  case 's':
X	  case 'S':
X	    *fp++ = 's';
X	    *fp = 0;
X	    if (*src == 'S' && saves2) {
X		cp = saves2;
X	    } else {
X		cp = s1;
X		s1 = s2;
X		s2 = s3;
X	    }
X	    if (flags & FF_REMSUFF) {
X		cp = format_s("%s", cp);
X		removesuffix(cp);
X	    }
X	    if (flags & FF_REMSLASH) {
X		cp2 = cp + strlen(cp);
X		while (cp2 >= cp &&
X		       *cp2 != '/' && *cp2 != '\\' &&
X		       *cp2 != ']' && *cp2 != ':')
X		    cp2--;
X		if (cp2[1])
X		    cp = cp2 + 1;
X	    }
X	    sprintf(dst, fmtbuf, cp);
X	    cvcase(dst, flags);
X	    dst = dst + strlen(dst);
X	    break;
X
X	}
X	src++;
X    }
X    *dst = 0;
X    return buf;
X}
X
X
X
X
Xchar *format_none(fmt)
Xchar *fmt;
X{
X    return format_gen(fmt, 0L, 0L, 0.0, NULL, NULL, NULL);
X}
X
X
Xchar *format_d(fmt, a1)
Xchar *fmt;
Xint a1;
X{
X    return format_gen(fmt, a1, 0L, (double)a1, NULL, NULL, NULL);
X}
X
X
Xchar *format_g(fmt, a1)
Xchar *fmt;
Xdouble a1;
X{
X    return format_gen(fmt, (long)a1, 0L, a1, NULL, NULL, NULL);
X}
X
X
Xchar *format_s(fmt, a1)
Xchar *fmt, *a1;
X{
X    return format_gen(fmt, 0L, 0L, 0.0, a1, NULL, NULL);
X}
X
X
Xchar *format_ss(fmt, a1, a2)
Xchar *fmt, *a1, *a2;
X{
X    return format_gen(fmt, 0L, 0L, 0.0, a1, a2, NULL);
X}
X
X
Xchar *format_sd(fmt, a1, a2)
Xchar *fmt, *a1;
Xint a2;
X{
X    return format_gen(fmt, a2, 0L, (double)a2, a1, NULL, NULL);
X}
X
X
Xchar *format_ds(fmt, a1, a2)
Xchar *fmt, *a2;
Xlong a1;
X{
X    return format_gen(fmt, a1, 0L, (double)a1, a2, NULL, NULL);
X}
X
X
Xchar *format_dd(fmt, a1, a2)
Xchar *fmt;
Xlong a1, a2;
X{
X    return format_gen(fmt, a1, a2, (double)a1, NULL, NULL, NULL);
X}
X
X
Xchar *format_sss(fmt, a1, a2, a3)
Xchar *fmt, *a1, *a2, *a3;
X{
X    return format_gen(fmt, 0L, 0L, 0.0, a1, a2, a3);
X}
X
X
Xchar *format_ssd(fmt, a1, a2, a3)
Xchar *fmt, *a1, *a2;
Xlong a3;
X{
X    return format_gen(fmt, a3, 0L, (double)a3, a1, a2, NULL);
X}
X
X
Xchar *format_sds(fmt, a1, a2, a3)
Xchar *fmt, *a1, *a3;
Xlong a2;
X{
X    return format_gen(fmt, a2, 0L, (double)a2, a1, a3, NULL);
X}
X
X
X
X
X/* String conversions */
X
Xint my_toupper(c)
Xint c;
X{
X    if (islower(c))
X	return _toupper(c);
X    else
X	return c;
X}
X
X
Xint my_tolower(c)
Xint c;
X{
X    if (isupper(c))
X	return _tolower(c);
X    else
X	return c;
X}
X
X
Xvoid upc(s)
Xregister char *s;
X{
X    for (; *s; s++)
X        *s = toupper(*s);
X}
X
X
Xvoid lwc(s)
Xregister char *s;
X{
X    for (; *s; s++)
X        *s = tolower(*s);
X}
X
X
Xchar *strupper(s)
Xregister char *s;
X{
X    char *dest = getformat();
X    register char *s2 = dest;
X    while (*s)
X        *s2++ = toupper(*s++);
X    *s2 = 0;
X    return dest;
X}
X
X
Xchar *strlower(s)
Xregister char *s;
X{
X    char *dest = getformat();
X    register char *s2 = dest;
X    while (*s)
X        *s2++ = tolower(*s++);
X    *s2 = 0;
X    return dest;
X}
X
X
X
Xchar *my_strchr(cp, c)
Xregister char *cp;
Xint c;
X{
X    while (*cp && *cp != c)
X	cp++;
X    if (*cp)
X	return cp;
X    else
X	return NULL;
X}
X
X
Xchar *my_strrchr(cp, c)
Xregister char *cp;
Xint c;
X{
X    register char *cp2 = NULL;
X    while (*cp) {
X	if (*cp == c)
X	    cp2 = cp;
X	cp++;
X    }
X    return cp2;
X}
X
X
Xchar *my_strtok(cp, delim)
Xchar *cp, *delim;
X{
X    static char *ptr;
X
X    if (cp)
X	ptr = cp;
X    while (*ptr && my_strchr(delim, *ptr))
X	ptr++;
X    if (!*ptr)
X	return NULL;
X    cp = ptr;
X    while (*ptr && !my_strchr(delim, *ptr))
X	ptr++;
X    *ptr++ = 0;
X    return cp;
X}
X
X
X
Xlong my_strtol(buf, ret, base)
Xchar *buf, **ret;
Xint base;
X{
X    unsigned long val = 0;
X    int dig, sign = 1;
X
X    while (isspace(*buf))
X	buf++;
X    if (*buf == '+')
X	buf++;
X    else if (*buf == '-') {
X	sign = -1;
X	buf++;
X    }
X    if (*buf == '0') {
X	if ((buf[1] == 'x' || buf[1] == 'X') &&
X	    (base == 0 || base == 16)) {
X	    buf++;
X	    base = 16;
X	} else if (base == 0)
X	    base = 8;
X	buf++;
X    }
X    for (;;) {
X	if (isdigit(*buf))
X	    dig = *buf - '0';
X	else if (*buf >= 'a')
X	    dig = *buf - 'a' + 10;
X	else if (*buf >= 'A')
X	    dig = *buf - 'A' + 10;
X	else
X	    break;
X	if (dig >= base)
X	    break;
X	val = val * base + dig;
X	buf++;
X    }
X    if (ret)
X	*ret = buf;
X    if (sign > 0)
X	return val;
X    else
X	return -val;
X}
X
X
X
X
Xvoid init_stuff()
X{
X    int i;
X
X    for (i = 0; i < NUMBUF; i++)
X        formatbuf[i] = ALLOC(1000, char, misc);
X}
X
X
X
X
X/* End. */
X
X
END_OF_FILE
if test 13512 -ne `wc -c <'src/stuff.c'`; then
    echo shar: \"'src/stuff.c'\" unpacked with wrong size!
fi
# end of 'src/stuff.c'
fi
echo shar: End of archive 5 \(of 32\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 32 archives.
    echo "Now see PACKNOTES and the README"
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.



More information about the Comp.sources.unix mailing list