spawn_glib_23.0.0_440f8b8a/source/spawn/spawn-channels.ads

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
--
--  Copyright (C) 2018-2022, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0
--

--  It is Glib's version of the package.

with Ada.Streams;

with Glib.IOChannel;
private with Glib.Main;

limited with Spawn.Internal;

private package Spawn.Channels is

   type Channels (Process : not null access Spawn.Internal.Process'Class) is
     private;

   procedure Setup_Channels
     (Self                : in out Channels;
      Standard_Input_PTY  : Boolean;
      Standard_Output_PTY : Boolean;
      Standard_Error_PTY  : Boolean);

   procedure Close_Child_Descriptors (Self : in out Channels);

   procedure Shutdown_Channels (Self : in out Channels);

   procedure Shutdown_Stdin (Self : in out Channels);

   procedure Shutdown_Stdout (Self : in out Channels);

   procedure Shutdown_Stderr (Self : in out Channels);

   function Child_Stdin (Self : Channels) return Glib.Gint;

   function Child_Stdout (Self : Channels) return Glib.Gint;

   function Child_Stderr (Self : Channels) return Glib.Gint;

   function PTY_Slave (Self : Channels) return Glib.Gint;

   procedure Start_Watch (Self : in out Channels);

   procedure Write_Stdin
     (Self : in out Channels;
      Data : Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset);

   procedure Read_Stdout
     (Self : in out Channels;
      Data : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset);

   procedure Read_Stderr
     (Self : in out Channels;
      Data : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset);

   function Is_Active (Self : Channels) return Boolean;

private

   use type Glib.Gint;

   type Channels (Process : not null access Spawn.Internal.Process'Class) is
      record
         Stdin_Parent  : Glib.IOChannel.Giochannel := null;
         Stdin_Child   : Glib.Gint := -1;
         Stdin_Event   : Glib.Main.G_Source_Id := Glib.Main.No_Source_Id;
         Stdin_Lock    : Glib.Gboolean := 0;

         Stdout_Parent : Glib.IOChannel.Giochannel := null;
         Stdout_Child  : Glib.Gint := -1;
         Stdout_Event  : Glib.Main.G_Source_Id := Glib.Main.No_Source_Id;
         Stdout_Lock   : Glib.Gboolean := 0;

         Stderr_Parent : Glib.IOChannel.Giochannel := null;
         Stderr_Child  : Glib.Gint := -1;
         Stderr_Event  : Glib.Main.G_Source_Id := Glib.Main.No_Source_Id;
         Stderr_Lock   : Glib.Gboolean := 0;

         PTY_Slave     : Glib.Gint := -1;
      end record;

end Spawn.Channels;