OSDN Git Service

New Language: Ada
[pf3gnuchains/gcc-fork.git] / gcc / ada / osint.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                                O S I N T                                 --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.108 $
10 --                                                                          --
11 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28
29 --  This package contains the low level, operating system routines used in
30 --  the GNAT compiler and binder for command line processing and file input
31 --  output. The specification is suitable for use with MS-DOS, Unix, and
32 --  similar systems. Note that for input source and library information
33 --  files, the line terminator may be either CR/LF or LF alone, and the
34 --  DOS-style EOF (16#1A#) character marking the end of the text in a
35 --  file may be used in all systems including Unix. This allows for more
36 --  convenient processing of DOS files in a Unix environment.
37
38 with GNAT.OS_Lib; use GNAT.OS_Lib;
39 with System;      use System;
40 with Types;       use Types;
41
42 package Osint is
43
44    procedure Set_Main_File_Name (Name : String);
45    --  Set the main file name for Gnatmake.
46
47    function Normalize_Directory_Name (Directory : String) return String_Ptr;
48    --  Verify and normalize a directory name. If directory name is invalid,
49    --  this will return an empty string. Otherwise it will insure a trailing
50    --  slash and make other normalizations.
51
52    type File_Type is (Source, Library, Config);
53
54    function Find_File
55      (N :    File_Name_Type;
56       T :    File_Type)
57       return File_Name_Type;
58    --  Finds a source or library file depending on the value of T following
59    --  the directory search order rules unless N is the name of the file
60    --  just read with Next_Main_File and already contains directiory
61    --  information, in which case just look in the Primary_Directory.
62    --  Returns File_Name_Type of the full file name if found, No_File if
63    --  file not found. Note that for the special case of gnat.adc, only the
64    --  compilation environment directory is searched, i.e. the directory
65    --  where the ali and object files are written. Another special case is
66    --  when Debug_Generated_Code is set and the file name ends on ".dg",
67    --  in which case we look for the generated file only in the current
68    --  directory, since that is where it is always built.
69
70    function Get_Switch_Character return Character;
71    pragma Import (C, Get_Switch_Character, "__gnat_get_switch_character");
72    Switch_Character : constant Character := Get_Switch_Character;
73    --  Set to the default switch character (note that minus is always an
74    --  acceptable alternative switch character)
75
76    function Get_File_Names_Case_Sensitive return Int;
77    pragma Import (C, Get_File_Names_Case_Sensitive,
78                     "__gnat_get_file_names_case_sensitive");
79    File_Names_Case_Sensitive : constant Boolean :=
80                                Get_File_Names_Case_Sensitive /= 0;
81    --  Set to indicate whether the operating system convention is for file
82    --  names to be case sensitive (e.g., in Unix, set True), or non case
83    --  sensitive (e.g., in OS/2, set False).
84
85    procedure Canonical_Case_File_Name (S : in out String);
86    --  Given a file name, converts it to canonical case form. For systems
87    --  where file names are case sensitive, this procedure has no effect.
88    --  If file names are not case sensitive (i.e. for example if you have
89    --  the file "xyz.adb", you can refer to it as XYZ.adb or XyZ.AdB), then
90    --  this call converts the given string to canonical all lower case form,
91    --  so that two file names compare equal if they refer to the same file.
92
93    function Number_Of_Files return Int;
94    --  gives the total number of filenames found on the command line.
95
96    procedure Add_File (File_Name : String);
97    --  Called by the subprogram processing the command line for each
98    --  file name found.
99
100    procedure Set_Output_Object_File_Name (Name : String);
101    --  Called by the subprogram processing the command line when an
102    --  output object file name is found.
103
104    type Program_Type is (Compiler, Binder, Make);
105    Program : Program_Type;
106    --  Program currently running (set by Initialize below)
107
108    procedure Initialize (P : Program_Type);
109    --  This routine scans parameters and initializes for the first call to
110    --  Next_Main_Source (Compiler or Make) or Next_Main_Lib_File (Binder).
111    --  It also resets any of the variables in package Opt in response to
112    --  command switch settings.
113    --
114    --  Initialize may terminate execution if the parameters are invalid or some
115    --  other fatal error is encountered. The interface is set up to
116    --  accomodate scanning a series of files (e.g. as the result of
117    --  wild card references in DOS, or an expanded list of source files
118    --  in Unix). Of course it is perfectly possible to ignore this in
119    --  the implementation and provide for opening only one file.
120    --  The parameter P is the program (Compiler, Binder or Make) that is
121    --  actually running.
122
123    procedure Find_Program_Name;
124    --  Put simple name of current program being run (excluding the directory
125    --  path) in Name_Buffer, with the length in Name_Len.
126
127    function Program_Name (Nam : String) return String_Access;
128    --  In the native compilation case, Create a string containing Nam. In
129    --  the cross compilation case, looks at the prefix of the current
130    --  program being run and prepend it to Nam. For instance if the program
131    --  being run is <target>-gnatmake and Nam is "gcc", the returned value
132    --  will be a pointer to "<target>-gcc". This function clobbers
133    --  Name_Buffer and Name_Len.
134
135    procedure Write_Program_Name;
136    --  Writes name of program as invoked to standard output
137
138    procedure Fail (S1 : String; S2 : String := ""; S3 : String := "");
139    --  Outputs error messages S1 & S2 & S3 preceeded by the name of the
140    --  executing program and exits with E_Fatal.
141
142    function Is_Directory_Separator (C : Character) return Boolean;
143    --  Returns True if C is a directory separator
144
145    function Get_Directory (Name : File_Name_Type) return File_Name_Type;
146    --  Get the prefix directory name (if any) from Name. The last separator
147    --  is preserved. Return No_File if there is no directory part in the
148    --  name.
149
150    function Is_Readonly_Library (File : File_Name_Type) return Boolean;
151    --  Check if this library file is a read-only file.
152
153    function Strip_Directory (Name : File_Name_Type) return File_Name_Type;
154    --  Strips the prefix directory name (if any) from Name. Returns the
155    --  stripped name.
156
157    function Strip_Suffix (Name : File_Name_Type) return File_Name_Type;
158    --  Strips the suffix (the '.' and whatever comes after it) from Name.
159    --  Returns the stripped name.
160
161    function Executable_Name (Name : File_Name_Type) return File_Name_Type;
162    --  Given a file name it adds the appropriate suffix at the end so that
163    --  it becomes the name of the executable on the system at end. For
164    --  instance under DOS it adds the ".exe" suffix, whereas under UNIX no
165    --  suffix is added.
166
167    function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type;
168    --  Returns the time stamp of file Name. Name should include relative
169    --  path information in order to locate it. If the source file cannot be
170    --  opened, or Name = No_File, and all blank time stamp is returned (this is
171    --  not an error situation).
172
173    procedure Record_Time_From_Last_Bind;
174    --  Trigger the computing of the time from the last bind of the same
175    --  program.
176
177    function Time_From_Last_Bind return Nat;
178    --  This function give an approximate number of minute from the last bind.
179    --  It bases its computation on file stamp and therefore does gibe not
180    --  any meaningful result before the new output binder file is written.
181    --  So it returns Nat'last if
182    --   - it is the first bind of this  specific program
183    --   - Record_Time_From_Last_Bind was not Called first
184    --   - Close_Binder_Output was not called first
185    --  otherwise returns the number of minutes
186    --  till the last bind. The computation does not try to be completely
187    --  accurate and in particular does not take leap years into account.
188
189    type String_Access_List is array (Positive range <>) of String_Access;
190    --  Deferenced type used to return a list of file specs in
191    --  To_Canonical_File_List.
192
193    type String_Access_List_Access is access all String_Access_List;
194    --  Type used to return a String_Access_List  without dragging in secondary
195    --  stack.
196
197    function To_Canonical_File_List
198      (Wildcard_Host_File : String; Only_Dirs : Boolean)
199    return String_Access_List_Access;
200    --  Expand a wildcard host syntax file or directory specification (e.g. on
201    --  a VMS host, any file or directory spec that contains:
202    --  "*", or "%", or "...")
203    --  and return a list of valid Unix syntax file or directory specs.
204    --  If Only_Dirs is True, then only return directories.
205
206    function To_Canonical_Dir_Spec
207      (Host_Dir     : String;
208       Prefix_Style : Boolean)
209       return String_Access;
210    --  Convert a host syntax directory specification (e.g. on a VMS host:
211    --  "SYS$DEVICE:[DIR]") to canonical (Unix) syntax (e.g. "/sys$device/dir").
212    --  If Prefix_Style then make it a valid file specification prefix.
213    --  A file specification prefix is a directory specification that
214    --  can be appended with a simple file specification to yield a valid
215    --  absolute or relative path to a file. On a conversion to Unix syntax
216    --  this simply means the spec has a trailing slash ("/").
217
218    function To_Canonical_File_Spec
219      (Host_File : String)
220       return String_Access;
221    --  Convert a host syntax file specification (e.g. on a VMS host:
222    --  "SYS$DEVICE:[DIR]FILE.EXT;69 to canonical (Unix) syntax (e.g.
223    --  "/sys$device/dir/file.ext.69").
224
225    function To_Canonical_Path_Spec
226      (Host_Path : String)
227       return String_Access;
228    --  Convert a host syntax Path specification (e.g. on a VMS host:
229    --  "SYS$DEVICE:[BAR],DISK$USER:[FOO] to canonical (Unix) syntax (e.g.
230    --  "/sys$device/foo:disk$user/foo").
231
232    function To_Host_Dir_Spec
233      (Canonical_Dir : String;
234       Prefix_Style  : Boolean)
235       return String_Access;
236    --  Convert a canonical syntax directory specification to host syntax.
237    --  The Prefix_Style flag is currently ignored but should be set to
238    --  False.
239
240    function To_Host_File_Spec
241      (Canonical_File : String)
242       return String_Access;
243    --  Convert a canonical syntax file specification to host syntax.
244
245    -------------------------
246    -- Search Dir Routines --
247    -------------------------
248
249    procedure Add_Default_Search_Dirs;
250    --  This routine adds the default search dirs indicated by the
251    --  environment variables and sdefault package.
252
253    procedure Add_Lib_Search_Dir (Dir : String);
254    --  Add Dir at the end of the library file search path
255
256    procedure Add_Src_Search_Dir (Dir : String);
257    --  Add Dir at the end of the source file search path
258
259    procedure Get_Next_Dir_In_Path_Init
260      (Search_Path : String_Access);
261    function  Get_Next_Dir_In_Path
262      (Search_Path : String_Access)
263       return        String_Access;
264    --  These subprograms are used to parse out the directory names in a
265    --  search path specified by a Search_Path argument. The procedure
266    --  initializes an internal pointer to point to the initial directory
267    --  name, and calls to the function return sucessive directory names,
268    --  with a null pointer marking the end of the list.
269
270    function Get_Primary_Src_Search_Directory return String_Ptr;
271    --  Retrieved the primary directory (directory containing the main source
272    --   file for Gnatmake.
273
274    function Nb_Dir_In_Src_Search_Path return Natural;
275    function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr;
276    --  Functions to access the directory names in the source search path
277
278    function Nb_Dir_In_Obj_Search_Path return Natural;
279    function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr;
280    --  Functions to access the directory names in the Object search path
281
282    Include_Search_File : constant String_Access
283      := new String'("ada_source_path");
284    Objects_Search_File : constant String_Access
285      := new String'("ada_object_path");
286
287    --  Files containg the default include or objects search directories.
288
289    function Read_Default_Search_Dirs
290      (Search_Dir_Prefix : String_Access;
291       Search_File : String_Access;
292       Search_Dir_Default_Name : String_Access)
293      return String_Access;
294    --  Read and return the default search directories from the file located
295    --  in Search_Dir_Prefix (as modified by update_path) and named Search_File.
296    --  If no such file exists or an error occurs then instead return the
297    --  Search_Dir_Default_Name (as modified by update_path).
298
299    -----------------------
300    -- Source File Input --
301    -----------------------
302
303    --  Source file input routines are used by the compiler to read the main
304    --  source files and the subsidiary source files (e.g. with'ed units), and
305    --  also by the binder to check presence/time stamps of sources.
306
307    function More_Source_Files return Boolean;
308    --  Indicates whether more source file remain to be processed. Returns
309    --  False right away if no source files, or if all source files have
310    --  been processed.
311
312    function Next_Main_Source return File_Name_Type;
313    --  This function returns the name of the next main source file specified
314    --  on the command line. It is an error to call Next_Main_Source if no more
315    --  source files exist (i.e. Next_Main_Source may be called only if a
316    --  previous call to More_Source_Files returned True). This name is the
317    --  simple file name (without any directory information).
318
319    procedure Read_Source_File
320      (N   : File_Name_Type;
321       Lo  : Source_Ptr;
322       Hi  : out Source_Ptr;
323       Src : out Source_Buffer_Ptr;
324       T   : File_Type := Source);
325    --  Allocates a Source_Buffer of appropriate length and then reads the
326    --  entire contents of the source file N into the buffer. The address of
327    --  the allocated buffer is returned in Src.
328    --
329    --  Each line of text is terminated by one of the sequences:
330    --
331    --    CR
332    --    CR/LF
333    --    LF/CR
334    --    LF
335
336    --  The source is terminated by an EOF (16#1A#) character, which is
337    --  the last charcater of the returned source bufer (note that any
338    --  EOF characters in positions other than the last source character
339    --  are treated as representing blanks).
340    --
341    --  The logical lower bound of the source buffer is the input value of Lo,
342    --  and on exit Hi is set to the logical upper bound of the source buffer.
343    --  Note that the returned value in Src points to an array with a physical
344    --  lower bound of zero. This virtual origin addressing approach means that
345    --  a constrained array pointer can be used with a low bound of zero which
346    --  results in more efficient code.
347    --
348    --  If the given file cannot be opened, then the action depends on whether
349    --  this file is the current main unit (i.e. its name matches the name
350    --  returned by the most recent call to Next_Main_Source). If so, then the
351    --  failure to find the file is a fatal error, an error message is output,
352    --  and program execution is terminated. Otherwise (for the case of a
353    --  subsidiary source loaded directly or indirectly using with), a file
354    --  not found condition causes null to be set as the result value.
355    --
356    --  Note that the name passed to this function is the simple file name,
357    --  without any directory information. The implementation is responsible
358    --  for searching for the file in the appropriate directories.
359    --
360    --  Note the special case that if the file name is gnat.adc, then the
361    --  search for the file is done ONLY in the directory corresponding to
362    --  the current compilation environment, i.e. in the same directory
363    --  where the ali and object files will be written.
364
365    function Full_Source_Name return File_Name_Type;
366    function Current_Source_File_Stamp return Time_Stamp_Type;
367    --  Returns the full name/time stamp of the source file most recently read
368    --  using Read_Source_File. Calling this routine entails no source file
369    --  directory lookup penalty.
370
371    function Full_Source_Name (N : File_Name_Type) return File_Name_Type;
372    function Source_File_Stamp (N : File_Name_Type) return Time_Stamp_Type;
373    --  Returns the full name/time stamp of the source file whose simple name
374    --  is N which should not include path information. Note that if the file
375    --  cannot be located No_File is returned for the first routine and an
376    --  all blank time stamp is returned for the second (this is not an error
377    --  situation). The full name includes the appropriate directory
378    --  information. The source file directory lookup penalty is incurred
379    --  every single time the routines are called unless you have previously
380    --  called Source_File_Data (Cache => True). See below.
381
382    function Matching_Full_Source_Name
383      (N    : File_Name_Type;
384       T    : Time_Stamp_Type)
385       return File_Name_Type;
386    --  Same semantics than Full_Source_Name but will search on the source
387    --  path until a source file with time stamp matching T is found. If
388    --  none is found returns No_File.
389
390    procedure Source_File_Data (Cache : Boolean);
391    --  By default source file data (full source file name and time stamp)
392    --  are looked up every time a call to Full_Source_Name (N) or
393    --  Source_File_Stamp (N) is made. This may be undesirable in certain
394    --  applications as this is uselessly slow if source file data does not
395    --  change during program execution. When this procedure is called with
396    --  Cache => True access to source file data does not encurr a penalty if
397    --  this data was previously retrieved.
398
399    -------------------------------------------
400    -- Representation of Library Information --
401    -------------------------------------------
402
403    --  Associated with each compiled source file is library information,
404    --  a string of bytes whose exact format is described in the body of
405    --  Lib.Writ. Compiling a source file generates this library information
406    --  for the compiled unit, and access the library information for units
407    --  that were compiled previously on which the unit being compiled depends.
408
409    --  How this information is stored is up to the implementation of this
410    --  package. At the interface level, this information is simply associated
411    --  with its corresponding source.
412
413    --  Several different implementations are possible:
414
415    --    1. The information could be directly associated with the source file,
416    --       e.g. placed in a resource fork of this file on the Mac, or on
417    --       MS-DOS, written to the source file after the end of file mark.
418
419    --    2. The information could be written into the generated object module
420    --       if the system supports the inclusion of arbitrary informational
421    --       byte streams into object files. In this case there must be a naming
422    --       convention that allows object files to be located given the name of
423    --       the corresponding source file.
424
425    --    3. The information could be written to a separate file, whose name is
426    --       related to the name of the source file by a fixed convention.
427
428    --  Which of these three methods is chosen depends on the contraints of the
429    --  host operating system. The interface described here is independent of
430    --  which of these approaches is used.
431
432    -------------------------------
433    -- Library Information Input --
434    -------------------------------
435
436    --  These subprograms are used by the binder to read library information
437    --  files, see section above for representation of these files.
438
439    function More_Lib_Files return Boolean;
440    --  Indicates whether more library information files remain to be processed.
441    --  Returns False right away if no source files, or if all source files
442    --  have been processed.
443
444    function Next_Main_Lib_File return File_Name_Type;
445    --  This function returns the name of the next library info file specified
446    --  on the command line. It is an error to call Next_Main_Lib_File if no
447    --  more library information files exist (i.e. Next_Main_Lib_File may be
448    --  called only if a previous call to More_Lib_Files returned True). This
449    --  name is the simple name, excluding any directory information.
450
451    function Read_Library_Info
452      (Lib_File  : File_Name_Type;
453       Fatal_Err : Boolean := False)
454       return      Text_Buffer_Ptr;
455    --  Allocates a Text_Buffer of appropriate length and reads in the entire
456    --  source of the library information from the library information file
457    --  whose name is given by the parameter Name.
458    --
459    --  See description of Read_Source_File for details on the format of the
460    --  returned text buffer (the format is identical). THe lower bound of
461    --  the Text_Buffer is always zero
462    --
463    --  If the specified file cannot be opened, then the action depends on
464    --  Fatal_Err. If Fatal_Err is True, an error message is given and the
465    --  compilation is abandoned. Otherwise if Fatal_Err is False, then null
466    --  is returned. Note that the Lib_File is a simple name which does not
467    --  include any directory information. The implementation is responsible
468    --  for searching for the file in appropriate directories.
469    --
470    --  If Opt.Check_Object_Consistency is set to True then this routine
471    --  checks whether the object file corresponding to the Lib_File is
472    --  consistent with it. The object file is inconsistent if the object
473    --  does not exist or if it has an older time stamp than Lib_File.
474    --  This check is not performed when the Lib_File is "locked" (i.e.
475    --  read/only) because in this case the object file may be buried
476    --  in a library. In case of inconsistencies Read_Library_Info
477    --  behaves as if it did not find Lib_File (namely if Fatal_Err is
478    --  False, null is returned).
479
480    procedure Read_Library_Info
481      (Name : out File_Name_Type;
482       Text : out Text_Buffer_Ptr);
483    --  The procedure version of Read_Library_Info is used from the compiler
484    --  to read an existing ali file associated with the main unit. If the
485    --  ALI file exists, then its file name is returned in Name, and its
486    --  text is returned in Text. If the file does not exist, then Text is
487    --  set to null.
488
489    function Full_Library_Info_Name return File_Name_Type;
490    function Full_Object_File_Name return File_Name_Type;
491    --  Returns the full name of the library/object file most recently read
492    --  using Read_Library_Info, including appropriate directory information.
493    --  Calling this routine entails no library file directory lookup
494    --  penalty. Note that the object file corresponding to a library file
495    --  is not actually read. Its time stamp is fected when the flag
496    --  Opt.Check_Object_Consistency is set.
497
498    function Current_Library_File_Stamp return Time_Stamp_Type;
499    function Current_Object_File_Stamp return Time_Stamp_Type;
500    --  The time stamps of the files returned by the previous two routines.
501    --  It is an error to call Current_Object_File_Stamp if
502    --  Opt.Check_Object_Consistency is set to False.
503
504    function Full_Lib_File_Name (N : File_Name_Type) return File_Name_Type;
505    function Library_File_Stamp (N : File_Name_Type) return Time_Stamp_Type;
506    --  Returns the full name/time stamp of library file N. N should not
507    --  include path information. Note that if the file cannot be located
508    --  No_File is returned for the first routine and an all blank time stamp
509    --  is returned for the second (this is not an error situation). The
510    --  full name includes the appropriate directory information. The library
511    --  file directory lookup penalty is incurred every single time this
512    --  routine is called.
513
514    function Object_File_Name (N : File_Name_Type) return File_Name_Type;
515    --  Constructs the name of the object file corresponding to library
516    --  file N. If N is a full file name than the returned file name will
517    --  also be a full file name. Note that no lookup in the library file
518    --  directories is done for this file. This routine merely constructs
519    --  the name.
520
521    --------------------------------
522    -- Library Information Output --
523    --------------------------------
524
525    --  These routines are used by the compiler to generate the library
526    --  information file for the main source file being compiled. See section
527    --  above for a discussion of how library information files are stored.
528
529    procedure Create_Output_Library_Info;
530    --  Creates the output library information file for the source file which
531    --  is currently being compiled (i.e. the file which was most recently
532    --  returned by Next_Main_Source).
533
534    procedure Write_Library_Info (Info : String);
535    --  Writes the contents of the referenced string to the library information
536    --  file for the main source file currently being compiled (i.e. the file
537    --  which was most recently opened with a call to Read_Next_File). Info
538    --  represents a single line in the file, but does not contain any line
539    --  termination characters. The implementation of Write_Library_Info is
540    --  responsible for adding necessary end of line and end of file control
541    --  characters to the generated file.
542
543    procedure Close_Output_Library_Info;
544    --  Closes the file created by Create_Output_Library_Info, flushing any
545    --  buffers etc from writes by Write_Library_Info.
546
547    function Lib_File_Name (Source_File : File_Name_Type) return File_Name_Type;
548    --  Given the name of a source file, returns the name of the corresponding
549    --  library information file. This may be the name of the object file, or
550    --  of a separate file used to store the library information. In either case
551    --  the returned result is suitable for use in a call to Read_Library_Info.
552    --  Note: this subprogram is in this section because it is used by the
553    --  compiler to determine the proper library information names to be placed
554    --  in the generated library information file.
555
556    ------------------------------
557    -- Debug Source File Output --
558    ------------------------------
559
560    --  These routines are used by the compiler to generate the debug source
561    --  file for the Debug_Generated_Code (-gnatD switch) option. Note that
562    --  debug source file writing occurs at a completely different point in
563    --  the processing from library information output, so the code in the
564    --  body can assume these functions are never used at the same time.
565
566    function Create_Debug_File (Src : File_Name_Type) return File_Name_Type;
567    --  Given the simple name of a source file, this routine creates the
568    --  corresponding debug file, and returns its full name.
569
570    procedure Write_Debug_Info (Info : String);
571    --  Writes contents of given string as next line of the current debug
572    --  source file created by the most recent call to Get_Debug_Name. Info
573    --  does not contain any end of line or other formatting characters.
574
575    procedure Close_Debug_File;
576    --  Close current debug file created by the most recent call to
577    --  Get_Debug_Name.
578
579    function Debug_File_Eol_Length return Nat;
580    --  Returns the number of characters (1 for NL, 2 for CR/LF) written
581    --  at the end of each line by Write_Debug_Info.
582
583    --------------------------------
584    -- Semantic Tree Input-Output --
585    --------------------------------
586
587    procedure Tree_Create;
588    --  Creates the tree output file for the source file which is currently
589    --  being compiled (i.e. the file which was most recently returned by
590    --  Next_Main_Source), and initializes Tree_IO.Tree_Write for output.
591
592    procedure Tree_Close;
593    --  Closes the file previously opened by Tree_Create
594
595    -------------------
596    -- Binder Output --
597    -------------------
598
599    --  These routines are used by the binder to generate the C source file
600    --  containing the binder output. The format of this file is described
601    --  in the package Bindfmt.
602
603    procedure Create_Binder_Output
604      (Output_File_Name : String;
605       Typ              : Character;
606       Bfile            : out Name_Id);
607    --  Creates the binder output file. Typ is one of
608    --
609    --    'c'   create output file for case of generating C
610    --    'b'   create body file for case of generating Ada
611    --    's'   create spec file for case of generating Ada
612    --
613    --  If Output_File_Name is null, then a default name is used based on
614    --  the name of the most recently accessed main source file name. If
615    --  Output_File_Name is non-null then it is the full path name of the
616    --  file to be output (in the case of Ada, it must have an extension
617    --  of adb, and the spec file is created by changing the last character
618    --  from b to s. On return, Bfile also contains the Name_Id for the
619    --  generated file name.
620
621    procedure Write_Binder_Info (Info : String);
622    --  Writes the contents of the referenced string to the binder output file
623    --  created by a previous call to Create_Binder_Output. Info represents a
624    --  single line in the file, but does not contain any line termination
625    --  characters. The implementation of Write_Binder_Info is responsible
626    --  for adding necessary end of line and end of file control characters
627    --  as required by the operating system.
628
629    procedure Close_Binder_Output;
630    --  Closes the file created by Create_Binder_Output, flushing any
631    --  buffers etc from writes by Write_Binder_Info.
632
633    -----------------
634    -- Termination --
635    -----------------
636
637    type Exit_Code_Type is (
638       E_Success,    -- No warnings or errors
639       E_Warnings,   -- Compiler warnings generated
640       E_No_Code,    -- No code generated
641       E_No_Compile, -- Compilation not needed (smart recompilation)
642       E_Errors,     -- Compiler error messages generated
643       E_Fatal,      -- Fatal (serious) error, e.g. source file not found
644       E_Abort);     -- Internally detected compiler error
645
646    procedure Exit_Program (Exit_Code : Exit_Code_Type);
647    --  A call to Exit_Program terminates execution with the given status.
648    --  A status of zero indicates normal completion, a non-zero status
649    --  indicates abnormal termination.
650
651    -------------------------
652    -- Command Line Access --
653    -------------------------
654
655    --  Direct interface to command line parameters. (We don't want to use
656    --  the predefined command line package because it defines functions
657    --  returning string)
658
659    function Arg_Count return Natural;
660    pragma Import (C, Arg_Count, "__gnat_arg_count");
661    --  Get number of arguments (note: optional globbing may be enabled)
662
663    procedure Fill_Arg (A : System.Address; Arg_Num : Integer);
664    pragma Import (C, Fill_Arg, "__gnat_fill_arg");
665    --  Store one argument
666
667    function Len_Arg (Arg_Num : Integer) return Integer;
668    pragma Import (C, Len_Arg, "__gnat_len_arg");
669    --  Get length of argument
670
671 end Osint;