diff options
Diffstat (limited to 'man')
-rw-r--r-- | man/id128-app-specific.c | 11 | ||||
-rw-r--r-- | man/journal-iterate-unique.c | 25 | ||||
-rw-r--r-- | man/sd_bus_new.xml | 14 | ||||
-rw-r--r-- | man/sd_id128_get_machine.xml | 12 | ||||
-rw-r--r-- | man/sd_journal_query_unique.xml | 27 | ||||
-rw-r--r-- | man/sd_login_monitor_new.xml | 26 |
6 files changed, 58 insertions, 57 deletions
diff --git a/man/id128-app-specific.c b/man/id128-app-specific.c new file mode 100644 index 0000000000..b81e50ff32 --- /dev/null +++ b/man/id128-app-specific.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <systemd/sd-id128.h> + +#define OUR_APPLICATION_ID SD_ID128_MAKE(c2,73,27,73,23,db,45,4e,a6,3b,b9,6e,79,b5,3e,97) + +int main(int argc, char *argv[]) { + sd_id128_t id; + sd_id128_get_machine_app_specific(OUR_APPLICATION_ID, &id); + printf("Our application ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(id)); + return 0; +} diff --git a/man/journal-iterate-unique.c b/man/journal-iterate-unique.c new file mode 100644 index 0000000000..fcf92e7b3f --- /dev/null +++ b/man/journal-iterate-unique.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <string.h> +#include <systemd/sd-journal.h> + +int main(int argc, char *argv[]) { + sd_journal *j; + const void *d; + size_t l; + int r; + + r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); + if (r < 0) { + fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); + return 1; + } + r = sd_journal_query_unique(j, "_SYSTEMD_UNIT"); + if (r < 0) { + fprintf(stderr, "Failed to query journal: %s\n", strerror(-r)); + return 1; + } + SD_JOURNAL_FOREACH_UNIQUE(j, d, l) + printf("%.*s\n", (int) l, (const char*) d); + sd_journal_close(j); + return 0; +} diff --git a/man/sd_bus_new.xml b/man/sd_bus_new.xml index 5180ae7815..59117676fd 100644 --- a/man/sd_bus_new.xml +++ b/man/sd_bus_new.xml @@ -96,13 +96,13 @@ block is left:</para> <programlisting>{ - __attribute__((cleanup(sd_bus_unrefp)) sd_bus *bus = NULL; - int r; - … - r = sd_bus_default(&bus); - if (r < 0) - fprintf(stderr, "Failed to allocate bus: %s\n", strerror(-r)); - … + __attribute__((cleanup(sd_bus_unrefp)) sd_bus *bus = NULL; + int r; + … + r = sd_bus_default(&bus); + if (r < 0) + fprintf(stderr, "Failed to allocate bus: %s\n", strerror(-r)); + … }</programlisting> <para><function>sd_bus_ref()</function> and <function>sd_bus_unref()</function> diff --git a/man/sd_id128_get_machine.xml b/man/sd_id128_get_machine.xml index 954fd2e6a7..9587aa7d66 100644 --- a/man/sd_id128_get_machine.xml +++ b/man/sd_id128_get_machine.xml @@ -120,17 +120,7 @@ <para>Here's a simple example for an application specific machine ID:</para> - <programlisting>#include <systemd/sd-id128.h> -#include <stdio.h> - -#define OUR_APPLICATION_ID SD_ID128_MAKE(c2,73,27,73,23,db,45,4e,a6,3b,b9,6e,79,b5,3e,97) - -int main(int argc, char *argv[]) { - sd_id128_t id; - sd_id128_get_machine_app_specific(OUR_APPLICATION_ID, &id); - printf("Our application ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(id)); - return 0; -}</programlisting> + <programlisting><xi:include href="id128-app-specific.c" parse="text" /></programlisting> </example> </refsect1> diff --git a/man/sd_journal_query_unique.xml b/man/sd_journal_query_unique.xml index 0bbc479f22..c62f333eab 100644 --- a/man/sd_journal_query_unique.xml +++ b/man/sd_journal_query_unique.xml @@ -140,32 +140,7 @@ following example lists all unit names referenced in the journal:</para> - <programlisting>#include <stdio.h> -#include <string.h> -#include <systemd/sd-journal.h> - -int main(int argc, char *argv[]) { - sd_journal *j; - const void *d; - size_t l; - int r; - - r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); - if (r < 0) { - fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); - return 1; - } - r = sd_journal_query_unique(j, "_SYSTEMD_UNIT"); - if (r < 0) { - fprintf(stderr, "Failed to query journal: %s\n", strerror(-r)); - return 1; - } - SD_JOURNAL_FOREACH_UNIQUE(j, d, l) - printf("%.*s\n", (int) l, (const char*) d); - sd_journal_close(j); - return 0; -}</programlisting> - + <programlisting><xi:include href="journal-iterate-unique.c" parse="text" /></programlisting> </refsect1> <refsect1> diff --git a/man/sd_login_monitor_new.xml b/man/sd_login_monitor_new.xml index 23f685bb31..d914e51d0d 100644 --- a/man/sd_login_monitor_new.xml +++ b/man/sd_login_monitor_new.xml @@ -115,13 +115,13 @@ code block is left:</para> <programlisting>{ - __attribute__((cleanup(sd_login_monitor_unrefp)) sd_login_monitor *m = NULL; - int r; - … - r = sd_login_monitor_default(&m); - if (r < 0) - fprintf(stderr, "Failed to allocate login monitor object: %s\n", strerror(-r)); - … + __attribute__((cleanup(sd_login_monitor_unrefp)) sd_login_monitor *m = NULL; + int r; + … + r = sd_login_monitor_default(&m); + if (r < 0) + fprintf(stderr, "Failed to allocate login monitor object: %s\n", strerror(-r)); + … }</programlisting> <para><function>sd_login_monitor_flush()</function> may be used to @@ -176,13 +176,13 @@ int msec; sd_login_monitor_get_timeout(m, &t); if (t == (uint64_t) -1) - msec = -1; + msec = -1; else { - struct timespec ts; - uint64_t n; - clock_gettime(CLOCK_MONOTONIC, &ts); - n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; - msec = t > n ? (int) ((t - n + 999) / 1000) : 0; + struct timespec ts; + uint64_t n; + clock_gettime(CLOCK_MONOTONIC, &ts); + n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; + msec = t > n ? (int) ((t - n + 999) / 1000) : 0; }</programlisting> <para>The code above does not do any error checking for brevity's |