This file is indexed.

/usr/share/ada/adainclude/dbus-ada/d_bus-arguments.adb is in libdbusada0.2-dev 0.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
--
--  D_Bus/Ada - An Ada binding to D-Bus
--
--  Copyright (C) 2011  Reto Buerki <reet@codelabs.ch>
--
--  This program is free software; you can redistribute it and/or
--  modify it under the terms of the GNU General Public License
--  as published by the Free Software Foundation; either version 2
--  of the License, or (at your option) any later version.
--
--  This program is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with this program; if not, write to the Free Software
--  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
--  USA.
--
--  As a special exception, if other files instantiate generics from this
--  unit,  or  you  link  this  unit  with  other  files  to  produce  an
--  executable   this  unit  does  not  by  itself  cause  the  resulting
--  executable to  be  covered by the  GNU General  Public License.  This
--  exception does  not  however  invalidate  any  other reasons why  the
--  executable file might be covered by the GNU Public License.
--

with Ada.Tags;

with Interfaces.C;

with dbus_types_h;

package body D_Bus.Arguments is

   package C renames Interfaces.C;

   -------------------------------------------------------------------------

   procedure Append
     (List     : in out Argument_List_Type;
      New_Item :        Argument_Type'Class)
   is
   begin
      List.Data.Append (New_Item => New_Item);
   end Append;

   -------------------------------------------------------------------------

   function Deserialize
     (D_Args : not null access dbus_message_h.DBusMessageIter)
      return Argument_List_Type
   is
      use type C.int;
      use type dbus_types_h.dbus_bool_t;

      Result : Arguments.Argument_List_Type;
   begin
      loop
         declare
            Type_Code : C.int;
            Type_Char : String (1 .. 1);
            Type_Tag  : Ada.Tags.Tag;
         begin
            Type_Code := dbus_message_h.dbus_message_iter_get_arg_type
              (arg1 => D_Args);

            if Type_Code /= 0 then
               Type_Char (1) := Character'Val (Type_Code);

               begin
                  Type_Tag := Ada.Tags.Internal_Tag (Type_Char);

               exception
                  when Ada.Tags.Tag_Error =>
                     raise D_Bus_Error with "Unknown type code '"
                       & Type_Char & "' in message";
               end;

               Arguments.Append
                 (List     => Result,
                  New_Item => Argument_Type'Class
                    (Marshaling.Make_Object
                       (The_Tag => Type_Tag,
                        Params  => D_Args)));
            end if;

            exit when dbus_message_h.dbus_message_iter_next
              (arg1 => D_Args) = 0;
         end;
      end loop;

      return Result;
   end Deserialize;

   -------------------------------------------------------------------------

   function First_Element
     (List : Argument_List_Type)
      return Argument_Type'Class
   is
   begin
      return List.Data.First_Element;

   exception
      when Constraint_Error =>
         raise No_Arguments with "Argument list is empty";
   end First_Element;

   -------------------------------------------------------------------------

   function Get_Code (Arg : Argument_Type'Class) return Integer
   is
      Tag  : constant String := Get_Tag (Arg);
      Code : ASCII_Code;
   begin
      begin
         Code := ASCII_Code'Value (Tag);

      exception
         when Constraint_Error =>
            raise D_Bus_Error with "Argument tag '" & Tag
              & "' not found in type code table";
      end;

      return Code_Table (Code);
   end Get_Code;

   -------------------------------------------------------------------------

   function Get_Count (List : Argument_List_Type) return Natural
   is
   begin
      return Natural (List.Data.Length);
   end Get_Count;

   -------------------------------------------------------------------------

   function Get_Signature (Arg : Basic_Type) return String
   is
   begin
      return Get_Tag (Arg => Argument_Type'Class (Arg));
   end Get_Signature;

   -------------------------------------------------------------------------

   function Get_Tag (Arg : Argument_Type'Class) return String
   is
   begin
      return Ada.Tags.External_Tag (T => Arg'Tag);
   end Get_Tag;

   -------------------------------------------------------------------------

   function Is_Empty (List : Argument_List_Type) return Boolean
   is
   begin
      return List.Data.Is_Empty;
   end Is_Empty;

   -------------------------------------------------------------------------

   procedure Iterate
     (List    : Argument_List_Type;
      Process : not null access procedure (Arg : Argument_Type'Class))
   is
      procedure Process_Arg (Position : ALP.Cursor);
      --  Call the process procedure for an arg in the list.

      procedure Process_Arg (Position : ALP.Cursor)
      is
         Arg : constant Argument_Type'Class := ALP.Element (Position);
      begin
         Process (Arg);
      end Process_Arg;
   begin
      List.Data.Iterate (Process_Arg'Access);
   end Iterate;

   -------------------------------------------------------------------------

   function Last_Element
     (List : Argument_List_Type)
      return Argument_Type'Class
   is
   begin
      return List.Data.Last_Element;

   exception
      when Constraint_Error =>
         raise No_Arguments with "Argument list is empty";
   end Last_Element;

   -------------------------------------------------------------------------

   procedure Serialize
     (Args   : Argument_List_Type;
      D_Args : not null access dbus_message_h.DBusMessageIter)
   is
      procedure To_D_Bus (Arg : Argument_Type'Class);
      --  Append given argument to D-Bus message arguments.

      procedure To_D_Bus (Arg : Argument_Type'Class)
      is
      begin
         Arg.Serialize (D_Msg => D_Args);
      end To_D_Bus;
   begin
      Arguments.Iterate
        (List    => Args,
         Process => To_D_Bus'Access);
   end Serialize;

end D_Bus.Arguments;