]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
busctl: add introspect --xml-interface
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 21 Apr 2019 20:23:45 +0000 (22:23 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Apr 2019 20:58:29 +0000 (22:58 +0200)
This wraps the call to org.freedesktop.DBus.Introspectable.Introspect.
Using "busctl call" directly is inconvenient because busctl escapes the
string before printing.

Example:
$ busctl introspect --xml org.freedesktop.systemd1 /org/freedesktop/systemd1 | pygmentize -lxml | less -RF

man/busctl.xml
src/busctl/busctl.c

index e4c7fcb283ae4371ffeed986e364433cd8057097..328c1016227a635adb7d90037d47d7fd0da7eed5 100644 (file)
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--xml-interface</option></term>
+
+        <listitem>
+          <para>When used with the <command>introspect</command> call, dump the XML description received from
+          the D-Bus <constant>org.freedesktop.DBus.Introspectable.Introspect</constant> call instead of the
+          normal output.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--json=</option><replaceable>MODE</replaceable></term>
 
index 02f12dc70138bd466f6caeb6603bf9eb6f98ea37..86efc02bd8c32da09721c9d44001c2d8aff9915c 100644 (file)
@@ -50,6 +50,7 @@ static size_t arg_snaplen = 4096;
 static bool arg_list = false;
 static bool arg_quiet = false;
 static bool arg_verbose = false;
+static bool arg_xml_interface = false;
 static bool arg_expect_reply = true;
 static bool arg_auto_start = true;
 static bool arg_allow_interactive_authorization = true;
@@ -948,6 +949,12 @@ static int introspect(int argc, char **argv, void *userdata) {
         if (r < 0)
                 return bus_log_parse_error(r);
 
+        if (arg_xml_interface) {
+                /* Just dump the received XML and finish */
+                puts(xml);
+                return 0;
+        }
+
         /* First, get list of all properties */
         r = parse_xml_introspect(argv[2], xml, &ops, members);
         if (r < 0)
@@ -2255,6 +2262,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_SIZE,
                 ARG_LIST,
                 ARG_VERBOSE,
+                ARG_XML_INTERFACE,
                 ARG_EXPECT_REPLY,
                 ARG_AUTO_START,
                 ARG_ALLOW_INTERACTIVE_AUTHORIZATION,
@@ -2284,6 +2292,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "list",                            no_argument,       NULL, ARG_LIST                            },
                 { "quiet",                           no_argument,       NULL, 'q'                                 },
                 { "verbose",                         no_argument,       NULL, ARG_VERBOSE                         },
+                { "xml-interface",                   no_argument,       NULL, ARG_XML_INTERFACE                   },
                 { "expect-reply",                    required_argument, NULL, ARG_EXPECT_REPLY                    },
                 { "auto-start",                      required_argument, NULL, ARG_AUTO_START                      },
                 { "allow-interactive-authorization", required_argument, NULL, ARG_ALLOW_INTERACTIVE_AUTHORIZATION },
@@ -2388,6 +2397,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_verbose = true;
                         break;
 
+                case ARG_XML_INTERFACE:
+                        arg_xml_interface = true;
+                        break;
+
                 case ARG_EXPECT_REPLY:
                         r = parse_boolean(optarg);
                         if (r < 0)