diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-10 09:18:26 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-11 16:59:00 +0200 |
commit | 29c45dc4348e7db61aa80ba1657cbc2d8b1a19ee (patch) | |
tree | 82cedba74276d810467c79a990d7952b90852e8a /man/sd_journal_stream_fd.xml | |
parent | Get rid of strerror_safe() (diff) | |
download | systemd-29c45dc4348e7db61aa80ba1657cbc2d8b1a19ee.tar.xz systemd-29c45dc4348e7db61aa80ba1657cbc2d8b1a19ee.zip |
man: use external .c files for three examples
This way it's much easier to test that the code compiles without issues.
It's also easier to edit the code.
Indentation in one of the examples is reduced to two spaces. This is what we
use in man pages to make them fit on screen better.
Diffstat (limited to 'man/sd_journal_stream_fd.xml')
-rw-r--r-- | man/sd_journal_stream_fd.xml | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/man/sd_journal_stream_fd.xml b/man/sd_journal_stream_fd.xml index af2234e77d..40d2804121 100644 --- a/man/sd_journal_stream_fd.xml +++ b/man/sd_journal_stream_fd.xml @@ -100,33 +100,7 @@ <para>Creating a log stream suitable for <citerefentry project='man-pages'><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>:</para> - <programlisting>#include <syslog.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <systemd/sd-journal.h> -#include <systemd/sd-daemon.h> - -int main(int argc, char *argv[]) { - int fd; - FILE *log; - fd = sd_journal_stream_fd("test", LOG_INFO, 1); - if (fd < 0) { - fprintf(stderr, "Failed to create stream fd: %s\n", strerror(-fd)); - return 1; - } - log = fdopen(fd, "w"); - if (!log) { - fprintf(stderr, "Failed to create file object: %m\n"); - close(fd); - return 1; - } - fprintf(log, "Hello World!\n"); - fprintf(log, SD_WARNING "This is a warning!\n"); - fclose(log); - return 0; -}</programlisting> - + <programlisting><xi:include href="journal-stream-fd.c" parse="text" /></programlisting> </refsect1> <refsect1> |