File: config.adb

package info (click to toggle)
dbusada 0.6.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 748 kB
  • sloc: ada: 5,892; ansic: 98; makefile: 81; sh: 47
file content (45 lines) | stat: -rw-r--r-- 1,055 bytes parent folder | download | duplicates (8)
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
with Ada.Text_IO;
with Ada.Directories;
with Ada.Strings.Unbounded;

with Utils;

pragma Elaborate_All (Utils);

package body Config is

   use Ada.Strings.Unbounded;

   Addr_File   : constant String := "./dbusada.addr";
   Remote_Addr : Unbounded_String;

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

   procedure Init
   is
      Counter : Natural := 0;
   begin
      loop
         exit when Ada.Directories.Exists (Name => Addr_File);
         if Counter > 400 then
            raise Config_Error with "D-Bus test server not available";
         end if;

         delay 0.01;
         Counter := Counter + 1;
      end loop;

      Remote_Addr := To_Unbounded_String
        (Utils.Read_Line_From_File (Filename => Addr_File));
      Ada.Text_IO.Put_Line ("* Using test server at " & Service_Addr);
   end Init;

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

   function Service_Addr return String
   is
   begin
      return To_String (Remote_Addr);
   end Service_Addr;

end Config;