chiark / gitweb /
journalctl: add --priority= switch for filtering by priority
[elogind.git] / man / sd-id128.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of systemd.
7
8   Copyright 2012 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd-id128">
25
26         <refentryinfo>
27                 <title>sd-id128</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>sd-id128</refentrytitle>
42                 <manvolnum>3</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>sd-id128</refname>
47                 <refname>sd_id128_t</refname>
48                 <refname>SD_ID128_MAKE</refname>
49                 <refname>SD_ID128_FORMAT_STR</refname>
50                 <refname>SD_ID128_FORMAT_VAL</refname>
51                 <refname>sd_id128_equal</refname>
52                 <refpurpose>APIs for processing 128 bit IDs</refpurpose>
53         </refnamediv>
54
55         <refsynopsisdiv>
56                 <funcsynopsis>
57                         <funcsynopsisinfo>#include &lt;systemd/sd-id128.h&gt;</funcsynopsisinfo>
58                 </funcsynopsis>
59
60                 <cmdsynopsis>
61                         <command>pkg-config --cflags --libs libsystemd-id128</command>
62                 </cmdsynopsis>
63
64         </refsynopsisdiv>
65
66         <refsect1>
67                 <title>Description</title>
68
69                 <para><filename>sd-id128.h</filename> provides APIs to
70                 process and generate 128 bit ID values. The 128 bit ID
71                 values processed and generated by these APIs are a
72                 generalization of OSF UUIDs as defined by <ulink
73                 url="http://tools.ietf.org/html/rfc4122">RFC
74                 4122</ulink>, though use a simpler string
75                 formatting. These functions impose no structure on the
76                 used IDs, much unlike OSF UUIDs or Microsoft GUIDs,
77                 but are fully compatible with those types of IDs.
78                 </para>
79
80                 <para>See
81                 <citerefentry><refentrytitle>sd_id128_to_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
82                 <citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
83                 <citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
84                 for more information about the implemented
85                 functions.</para>
86
87                 <para>A 128 bit ID is implemented as the following
88                 union type:</para>
89
90                 <programlisting>typedef union sd_id128 {
91         uint8_t bytes[16];
92         uint64_t qwords[2];
93 } sd_id128_t;</programlisting>
94
95                 <para>This union type allows accessing the 128 bit ID
96                 as 16 separate bytes or two 64 bit words. It is generally
97                 safer to access the ID components by their 8 bit array
98                 to avoid endianness issues. This union is intended to
99                 be passed call-by-value (as opposed to
100                 call-by-reference) and may be directly manipulated by
101                 clients.</para>
102
103                 <para>A couple of macros are defined to denote and
104                 decode 128 bit IDs:</para>
105
106                 <para><function>SD_ID128_MAKE()</function> may be used
107                 to write a 128 bit ID in source code. A commonly used
108                 idiom is to give 128 bit IDs names using this macro:</para>
109
110                 <programlisting>#define SD_MESSAGE_COREDUMP SD_ID128_MAKE(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)</programlisting>
111
112                 <para><function>SD_ID128_FORMAT_STR</function> and
113                 <function>SD_ID128_FORMAT_VAL()</function> may be used
114                 to format a 128 bit ID in a
115                 <citerefentry><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
116                 format string, as shown in the following
117                 example:</para>
118
119                 <programlisting>int main(int argc, char *argv[]) {
120         sd_id128_t id;
121         id = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07);
122         printf("The ID encoded in this C file is " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(id));
123         return 0;
124 }</programlisting>
125
126                 <para>Use <function>sd_id128_equal()</function> to compare two 128 bit IDs:</para>
127
128                 <programlisting>int main(int argc, char *argv[]) {
129         sd_id128_t a, b, c;
130         a = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07);
131         b = SD_ID128_MAKE(f2,28,88,9c,5f,09,44,15,9d,d7,04,77,58,cb,e7,3e);
132         c = a;
133         assert(sd_id128_equal(a, c));
134         assert(!sd_id128_equal(a, b));
135         return 0;
136 }</programlisting>
137
138                 <para>Note that new, randomized IDs may be generated
139                 with
140                 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
141                 <literal>--new-id</literal> option.</para>
142         </refsect1>
143
144         <refsect1>
145                 <title>Notes</title>
146
147                 <para>These APIs are implemented as a shared library,
148                 which can be compiled and linked to with the
149                 <literal>libsystemd-id128</literal>
150                 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
151                 file.</para>
152
153         </refsect1>
154
155         <refsect1>
156                 <title>See Also</title>
157                 <para>
158                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
159                         <citerefentry><refentrytitle>sd_id128_to_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160                         <citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161                         <citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
162                         <citerefentry><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163                         <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
164                         <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
165                         <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
166                         <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>
167                 </para>
168         </refsect1>
169
170 </refentry>