1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6<refentry id="sd_journal_get_catalog" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8  <refentryinfo>
9    <title>sd_journal_get_catalog</title>
10    <productname>systemd</productname>
11  </refentryinfo>
12
13  <refmeta>
14    <refentrytitle>sd_journal_get_catalog</refentrytitle>
15    <manvolnum>3</manvolnum>
16  </refmeta>
17
18  <refnamediv>
19    <refname>sd_journal_get_catalog</refname>
20    <refname>sd_journal_get_catalog_for_message_id</refname>
21    <refpurpose>Retrieve message catalog entry</refpurpose>
22  </refnamediv>
23
24  <refsynopsisdiv>
25    <funcsynopsis>
26      <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
27
28      <funcprototype>
29        <funcdef>int <function>sd_journal_get_catalog</function></funcdef>
30        <paramdef>sd_journal *<parameter>j</parameter></paramdef>
31        <paramdef>char **<parameter>ret</parameter></paramdef>
32      </funcprototype>
33
34      <funcprototype>
35        <funcdef>int <function>sd_journal_get_catalog_for_message_id</function></funcdef>
36        <paramdef>sd_id128_t <parameter>id</parameter></paramdef>
37        <paramdef>char **<parameter>ret</parameter></paramdef>
38      </funcprototype>
39
40    </funcsynopsis>
41  </refsynopsisdiv>
42
43  <refsect1>
44    <title>Description</title>
45
46    <para><function>sd_journal_get_catalog()</function> retrieves a
47    message catalog entry for the current journal entry. This will
48    look up an entry in the message catalog by using the
49    <literal>MESSAGE_ID=</literal> field of the current journal entry.
50    Before returning the entry all journal field names in the catalog
51    entry text enclosed in "@" will be replaced by the respective
52    field values of the current entry. If a field name referenced in
53    the message catalog entry does not exist, in the current journal
54    entry, the "@" will be removed, but the field name otherwise left
55    untouched.</para>
56
57    <para><function>sd_journal_get_catalog_for_message_id()</function>
58    works similar to <function>sd_journal_get_catalog()</function> but
59    the entry is looked up by the specified message ID (no open
60    journal context is necessary for this), and no field substitution
61    is performed.</para>
62
63    <para>For more information about the journal message catalog
64    please refer to the <ulink
65    url="https://www.freedesktop.org/wiki/Software/systemd/catalog">Journal
66    Message Catalogs</ulink> documentation page.</para>
67  </refsect1>
68
69  <refsect1>
70    <title>Return Value</title>
71
72    <para><function>sd_journal_get_catalog()</function> and
73    <function>sd_journal_get_catalog_for_message_id()</function>
74    return 0 on success or a negative errno-style error code. If no
75    matching message catalog entry is found, -ENOENT is
76    returned.</para>
77
78    <para>On successful return, <parameter>ret</parameter> points to a
79    new string, which must be freed with
80    <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
81    </para>
82  </refsect1>
83
84  <refsect1>
85    <title>Notes</title>
86
87    <para>Function <function>sd_journal_get_catalog()</function> is thread-agnostic and only
88    a single specific thread may operate on a given object during its entire lifetime. It's safe to allocate multiple
89    independent objects and use each from a specific thread in parallel. However, it's not safe to allocate such an
90    object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don't
91    operate on it at the very same time.</para>
92
93    <para>Function <function>sd_journal_get_catalog_for_message_id()</function> is are thread-safe and may be called in
94    parallel from multiple threads.</para>
95
96    <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
97  </refsect1>
98
99  <refsect1>
100    <title>See Also</title>
101
102    <para>
103      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
104      <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
105      <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
106      <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
107      <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
108      <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
109      <citerefentry project='man-pages'><refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum></citerefentry>
110    </para>
111  </refsect1>
112
113</refentry>
114