LCOV - code coverage report
Current view: top level - glib/gio/tests - gdbus-daemon.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 0 33 0.0 %
Date: 2024-04-23 05:16:05 Functions: 0 1 0.0 %
Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : #include "config.h"
       2                 :            : 
       3                 :            : #include "gdbusdaemon.h"
       4                 :            : #include <glib/gi18n.h>
       5                 :            : 
       6                 :            : int
       7                 :          0 : main (int argc, char *argv[])
       8                 :            : {
       9                 :            :   GDBusDaemon *daemon;
      10                 :            :   GMainLoop *loop;
      11                 :          0 :   const char *address = NULL;
      12                 :          0 :   const char *config_file = NULL;
      13                 :          0 :   GError *error = NULL;
      14                 :          0 :   gboolean print_address = FALSE;
      15                 :          0 :   gboolean print_env = FALSE;
      16                 :            :   GOptionContext *context;
      17                 :          0 :   GOptionEntry entries[] = {
      18                 :            :     { "address", 0, 0, G_OPTION_ARG_STRING, &address, N_("Address to listen on"), NULL },
      19                 :            :     { "config-file", 0, 0, G_OPTION_ARG_STRING, &config_file, N_("Ignored, for compat with GTestDbus"), NULL },
      20                 :            :     { "print-address", 0, 0, G_OPTION_ARG_NONE, &print_address, N_("Print address"), NULL },
      21                 :            :     { "print-env", 0, 0, G_OPTION_ARG_NONE, &print_env, N_("Print address in shell mode"), NULL },
      22                 :            :     G_OPTION_ENTRY_NULL
      23                 :            :   };
      24                 :            : 
      25                 :          0 :   context = g_option_context_new ("");
      26                 :          0 :   g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
      27                 :          0 :   g_option_context_set_summary (context,
      28                 :            :     N_("Run a dbus service"));
      29                 :          0 :   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
      30                 :            : 
      31                 :          0 :   error = NULL;
      32         [ #  # ]:          0 :   if (!g_option_context_parse (context, &argc, &argv, &error))
      33                 :            :     {
      34                 :          0 :       g_printerr ("%s\n", error->message);
      35                 :          0 :       return 1;
      36                 :            :     }
      37                 :            : 
      38                 :          0 :   g_option_context_free (context);
      39                 :            : 
      40         [ #  # ]:          0 :   if (argc != 1)
      41                 :            :     {
      42                 :          0 :       g_printerr (_("Wrong args\n"));
      43                 :          0 :       return 1;
      44                 :            :     }
      45                 :            : 
      46                 :            : 
      47                 :          0 :   loop = g_main_loop_new (NULL, FALSE);
      48                 :            : 
      49         [ #  # ]:          0 :   if (argc >= 2)
      50                 :          0 :     address = argv[1];
      51                 :            : 
      52                 :          0 :   daemon = _g_dbus_daemon_new (address, NULL, &error);
      53         [ #  # ]:          0 :   if (daemon == NULL)
      54                 :            :     {
      55                 :          0 :       g_printerr ("Can't init bus: %s\n", error->message);
      56                 :          0 :       return 1;
      57                 :            :     }
      58                 :            : 
      59         [ #  # ]:          0 :   if (print_env)
      60                 :          0 :     g_print ("export DBUS_SESSION_BUS_ADDRESS=\"%s\"\n", _g_dbus_daemon_get_address (daemon));
      61                 :            : 
      62         [ #  # ]:          0 :   if (print_address)
      63                 :          0 :     g_print ("%s\n", _g_dbus_daemon_get_address (daemon));
      64                 :            : 
      65                 :          0 :   g_main_loop_run (loop);
      66                 :            : 
      67                 :          0 :   g_main_loop_unref (loop);
      68                 :            : 
      69                 :          0 :   return 0;
      70                 :            : }

Generated by: LCOV version 1.14