phcpack_2.4.88_e448e94a/src/Ada/Main/main_output_feedback.adb

 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
33
34
35
36
37
38
39
40
41
42
43
44
with text_io;                           use text_io;
with Standard_Integer_Numbers_io;       use Standard_Integer_Numbers_io;
with Ada.Characters.Latin_1;

package body Main_Output_Feedback is

  function main_feedback ( input,output : string ) return integer;
  pragma Import(C,main_feedback,"main_feedback");

  procedure Main ( infilename,outfilename : in string;
                   verbose : in integer32 := 0 ) is

  -- DESCRIPTION :
  --   Checks whether the infilename and outfilename are not empty,
  --   appends the '\0' end of string character to the names,
  --   before calling the C function main_feedback.

    NUL : constant character := Ada.Characters.Latin_1.NUL;
    res : integer;

  begin
    if verbose > 0 then
      put("At verbose level "); put(verbose,1);
      put_line(", in main_output_feedback.Main ...");
    end if;
    if infilename = "" or else outfilename = "" then
      new_line;
      put_line("Usage: phc -k input_file output_file");
      new_line;
    else
      if verbose > 0 then
        put_line("reading from " & infilename);
        put_line("writing to " & outfilename);
        put_line("Calling feedback...");
      end if;
      res := main_feedback(infilename & NUL,outfilename & NUL);
      if verbose > 0 then
        put("Return code from the C function main_feedback : ");
        put(integer32(res),1); new_line;
      end if;
    end if;
  end Main;

end Main_Output_Feedback;