Add manual-paths test executable with cmake build support.
[platform/upstream/dbus.git] / test / manual-paths.c
1 /*
2  * Simple manual paths check
3  *
4  * syntax:  manual-paths
5  *
6 */
7
8 #include "config.h"
9 #include "dbus/dbus-list.h"
10 #include "dbus/dbus-internals.h"
11 #include "dbus/dbus-sysdeps.h"
12
13 #include <stdio.h>
14
15 dbus_bool_t print_install_root()
16 {
17   char runtime_prefix[1000];
18
19   if (!_dbus_get_install_root(runtime_prefix, sizeof(runtime_prefix)))
20     {
21       fprintf(stderr, "dbus_get_install_root() failed\n");
22       return FALSE;
23     }
24   fprintf(stdout, "dbus_get_install_root() returned '%s'\n", runtime_prefix);
25   return TRUE;
26 }
27
28 dbus_bool_t print_service_dirs()
29 {
30   DBusList *dirs;
31   DBusList *link;
32   dirs = NULL;
33
34   if (!_dbus_get_standard_session_servicedirs (&dirs))
35     _dbus_assert_not_reached ("couldn't get standard dirs");
36
37   while ((link = _dbus_list_pop_first_link (&dirs)))
38     {
39       printf ("default service dir: %s\n", (char *)link->data);
40       dbus_free (link->data);
41       _dbus_list_free_link (link);
42     }
43   dbus_free (dirs);
44   return TRUE;
45 }
46
47 dbus_bool_t print_replace_install_prefix(const char *s)
48 {
49   const char *s2 = _dbus_replace_install_prefix(s);
50   if (!s2)
51     return FALSE;
52
53   fprintf(stdout, "replaced '%s' by '%s'\n", s, s2);
54   return TRUE;
55 }
56
57 int
58 main (int argc, char **argv)
59 {
60   if (!print_install_root())
61     return -1;
62
63   if (!print_service_dirs())
64     return -2;
65
66   if (!print_replace_install_prefix(DBUS_BINDIR "/dbus-daemon"))
67     return -3;
68
69   if (!print_replace_install_prefix("c:\\Windows\\System32\\testfile"))
70     return -4;
71
72   return 0;
73 }