Path : /usr/share/gtk-doc/html/libuser/ |
Current File : //usr/share/gtk-doc/html/libuser/libuser-value.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>value: libuser Reference Manual</title> <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> <link rel="home" href="index.html" title="libuser Reference Manual"> <link rel="up" href="ch01.html" title="libuser"> <link rel="prev" href="libuser-config.html" title="config"> <link rel="next" href="libuser-entity.html" title="entity"> <meta name="generator" content="GTK-Doc V1.24 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> <td width="100%" align="left" class="shortcuts"> <a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span> <a href="#libuser-value.description" class="shortcut">Description</a></span> </td> <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> <td><a accesskey="u" href="ch01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> <td><a accesskey="p" href="libuser-config.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> <td><a accesskey="n" href="libuser-entity.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> </tr></table> <div class="refentry"> <a name="libuser-value"></a><div class="titlepage"></div> <div class="refnamediv"><table width="100%"><tr> <td valign="top"> <h2><span class="refentrytitle"><a name="libuser-value.top_of_page"></a>value</span></h2> <p>value — Simplified interface to GValue types used in libuser entities.</p> </td> <td class="gallery_image" valign="top" align="right"></td> </tr></table></div> <div class="refsect1"> <a name="libuser-value.functions"></a><h2>Functions</h2> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="functions_return"> <col class="functions_name"> </colgroup> <tbody> <tr> <td class="define_keyword">#define</td> <td class="function_name"><a class="link" href="libuser-value.html#LU-VALUE-INVALID-ID:CAPS" title="LU_VALUE_INVALID_ID">LU_VALUE_INVALID_ID</a></td> </tr> <tr> <td class="function_type"> <span class="returnvalue">char</span> * </td> <td class="function_name"> <a class="link" href="libuser-value.html#lu-value-strdup" title="lu_value_strdup ()">lu_value_strdup</a> <span class="c_punctuation">()</span> </td> </tr> <tr> <td class="function_type"> <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> </td> <td class="function_name"> <a class="link" href="libuser-value.html#lu-value-init-set-attr-from-string" title="lu_value_init_set_attr_from_string ()">lu_value_init_set_attr_from_string</a> <span class="c_punctuation">()</span> </td> </tr> <tr> <td class="function_type"> <span class="returnvalue">void</span> </td> <td class="function_name"> <a class="link" href="libuser-value.html#lu-value-init-set-id" title="lu_value_init_set_id ()">lu_value_init_set_id</a> <span class="c_punctuation">()</span> </td> </tr> <tr> <td class="function_type"> <span class="returnvalue">id_t</span> </td> <td class="function_name"> <a class="link" href="libuser-value.html#lu-value-get-id" title="lu_value_get_id ()">lu_value_get_id</a> <span class="c_punctuation">()</span> </td> </tr> <tr> <td class="function_type"> <span class="returnvalue">int</span> </td> <td class="function_name"> <a class="link" href="libuser-value.html#lu-values-equal" title="lu_values_equal ()">lu_values_equal</a> <span class="c_punctuation">()</span> </td> </tr> </tbody> </table></div> </div> <div class="refsect1"> <a name="libuser-value.includes"></a><h2>Includes</h2> <pre class="synopsis">#include <libuser/user.h> </pre> </div> <div class="refsect1"> <a name="libuser-value.description"></a><h2>Description</h2> <p>Libuser entities store attribute values as <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a>, which allows representing any possible data type. Only a few types are needed in practice; the only types applications should hard-code are <a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-LONG:CAPS"><code class="literal">G_TYPE_LONG</code></a> and <a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-STRING:CAPS"><code class="literal">G_TYPE_STRING</code></a> (<a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-STRING:CAPS"><code class="literal">G_TYPE_STRING</code></a> can usually be used as a fallback for other number types).</p> <p>The only currently used data types that are not conveniently supported using the above types are <span class="type">uid_t</span> and <span class="type">gid_t</span> (which can be together represented in <span class="type">id_t</span>), because they can support values outside of the range of <a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#glong"><span class="type">glong</span></a>. Helper functions are provided to convert values between <span class="type">id_t</span> and <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a>, even if the value is stored using <a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-STRING:CAPS"><code class="literal">G_TYPE_STRING</code></a>. The <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> types used for storing <span class="type">id_t</span> values are an internal implementation detail of libuser and applications should not rely on them.</p> <p>Values of each attribute are expected to have a specific type, documented in the documentation of the specific attribute name. Using other types (e.g. using <a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-STRING:CAPS"><code class="literal">G_TYPE_STRING</code></a> for <a class="link" href="libuser-entity.html#LU-UIDNUMBER:CAPS" title="LU_UIDNUMBER"><code class="literal">LU_UIDNUMBER</code></a>) is not allowed and results in undefined behavior. You can use <a class="link" href="libuser-value.html#lu-value-strdup" title="lu_value_strdup ()"><code class="function">lu_value_strdup()</code></a> and <a class="link" href="libuser-value.html#lu-value-init-set-attr-from-string" title="lu_value_init_set_attr_from_string ()"><code class="function">lu_value_init_set_attr_from_string()</code></a> for conversion between strings and values appropriate for a specific attribute.</p> </div> <div class="refsect1"> <a name="libuser-value.functions_details"></a><h2>Functions</h2> <div class="refsect2"> <a name="LU-VALUE-INVALID-ID:CAPS"></a><h3>LU_VALUE_INVALID_ID</h3> <pre class="programlisting">#define LU_VALUE_INVALID_ID ((id_t)-1) </pre> <p>An <span class="type">id_t</span> value that matches no valid user or group ID.</p> </div> <hr> <div class="refsect2"> <a name="lu-value-strdup"></a><h3>lu_value_strdup ()</h3> <pre class="programlisting"><span class="returnvalue">char</span> * lu_value_strdup (<em class="parameter"><code>const <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> *value</code></em>);</pre> <p>Converts <em class="parameter"><code>value</code></em> , of any type used by libuser, to a string. Preferable to hard-coding checks for expected value types.</p> <div class="refsect3"> <a name="id-1.2.3.6.3.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> <col width="200px" class="parameters_annotations"> </colgroup> <tbody><tr> <td class="parameter_name"><p>value</p></td> <td class="parameter_description"><p><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a></p></td> <td class="parameter_annotations"> </td> </tr></tbody> </table></div> </div> <div class="refsect3"> <a name="id-1.2.3.6.3.6"></a><h4>Returns</h4> <p> string, should be freed by <a href="https://developer.gnome.org/glib/unstable/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a></p> </div> </div> <hr> <div class="refsect2"> <a name="lu-value-init-set-attr-from-string"></a><h3>lu_value_init_set_attr_from_string ()</h3> <pre class="programlisting"><a href="https://developer.gnome.org/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> lu_value_init_set_attr_from_string (<em class="parameter"><code><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> *value</code></em>, <em class="parameter"><code>const <span class="type">char</span> *attr</code></em>, <em class="parameter"><code>const <span class="type">char</span> *string</code></em>, <em class="parameter"><code><span class="type">struct lu_error</span> **error</code></em>);</pre> <p>Initializes a zero-filled (uninitialized) <em class="parameter"><code>value</code></em> for storing a value of attribute <em class="parameter"><code>attr</code></em> and sets it to the contents of <em class="parameter"><code>string</code></em> . To see whether a specific type is used for an attribute, see the documentation of that attribute.</p> <p>The error messages returned from this function don't contain the input string, to allow the caller to output at least partially usable error message without disclosing the invalid string in e.g. <code class="filename">/etc/shadow</code>, which might be somebody's misplaced password.</p> <div class="refsect3"> <a name="id-1.2.3.6.4.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> <col width="200px" class="parameters_annotations"> </colgroup> <tbody> <tr> <td class="parameter_name"><p>value</p></td> <td class="parameter_description"><p><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a></p></td> <td class="parameter_annotations"> </td> </tr> <tr> <td class="parameter_name"><p>attr</p></td> <td class="parameter_description"><p>Attribute name</p></td> <td class="parameter_annotations"> </td> </tr> <tr> <td class="parameter_name"><p>string</p></td> <td class="parameter_description"><p>The string to convert</p></td> <td class="parameter_annotations"> </td> </tr> <tr> <td class="parameter_name"><p>error</p></td> <td class="parameter_description"><p>Filled with a <a class="link" href="libuser-error.html#lu-error" title="struct lu_error"><span class="type">lu_error</span></a> if an error occurs, or <a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>attr</code></em> is unknown</p></td> <td class="parameter_annotations"> </td> </tr> </tbody> </table></div> </div> <div class="refsect3"> <a name="id-1.2.3.6.4.7"></a><h4>Returns</h4> <p> <a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error or if <em class="parameter"><code>attr</code></em> is unknown</p> </div> </div> <hr> <div class="refsect2"> <a name="lu-value-init-set-id"></a><h3>lu_value_init_set_id ()</h3> <pre class="programlisting"><span class="returnvalue">void</span> lu_value_init_set_id (<em class="parameter"><code><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> *value</code></em>, <em class="parameter"><code><span class="type">id_t</span> id</code></em>);</pre> <p>Initializes a zero-filled (uninitialized) <em class="parameter"><code>value</code></em> with an unspecified type and sets it to <em class="parameter"><code>id</code></em> .</p> <div class="refsect3"> <a name="id-1.2.3.6.5.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> <col width="200px" class="parameters_annotations"> </colgroup> <tbody> <tr> <td class="parameter_name"><p>value</p></td> <td class="parameter_description"><p><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a></p></td> <td class="parameter_annotations"> </td> </tr> <tr> <td class="parameter_name"><p>id</p></td> <td class="parameter_description"><p>User or group ID.</p></td> <td class="parameter_annotations"> </td> </tr> </tbody> </table></div> </div> </div> <hr> <div class="refsect2"> <a name="lu-value-get-id"></a><h3>lu_value_get_id ()</h3> <pre class="programlisting"><span class="returnvalue">id_t</span> lu_value_get_id (<em class="parameter"><code>const <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> *value</code></em>);</pre> <p>Get the contents of <em class="parameter"><code>value</code></em> . <em class="parameter"><code>value</code></em> should be initialized by <a class="link" href="libuser-value.html#lu-value-init-set-id" title="lu_value_init_set_id ()"><code class="function">lu_value_init_set_id()</code></a> or use <a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-LONG:CAPS"><code class="literal">G_TYPE_LONG</code></a> or <a href="https://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#G-TYPE-STRING:CAPS"><code class="literal">G_TYPE_STRING</code></a>.</p> <p>If <em class="parameter"><code>value</code></em> does not contain a valid <span class="type">id_t</span> value, <a class="link" href="libuser-value.html#LU-VALUE-INVALID-ID:CAPS" title="LU_VALUE_INVALID_ID"><code class="literal">LU_VALUE_INVALID_ID</code></a> is returned.</p> <div class="refsect3"> <a name="id-1.2.3.6.6.6"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> <col width="200px" class="parameters_annotations"> </colgroup> <tbody><tr> <td class="parameter_name"><p>value</p></td> <td class="parameter_description"><p><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a></p></td> <td class="parameter_annotations"> </td> </tr></tbody> </table></div> </div> <div class="refsect3"> <a name="id-1.2.3.6.6.7"></a><h4>Returns</h4> <p> ID value or <a class="link" href="libuser-value.html#LU-VALUE-INVALID-ID:CAPS" title="LU_VALUE_INVALID_ID"><code class="literal">LU_VALUE_INVALID_ID</code></a></p> </div> </div> <hr> <div class="refsect2"> <a name="lu-values-equal"></a><h3>lu_values_equal ()</h3> <pre class="programlisting"><span class="returnvalue">int</span> lu_values_equal (<em class="parameter"><code>const <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> *a</code></em>, <em class="parameter"><code>const <a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> *b</code></em>);</pre> <p>Check whether <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em> have the same type and value.</p> <div class="refsect3"> <a name="id-1.2.3.6.7.5"></a><h4>Parameters</h4> <div class="informaltable"><table width="100%" border="0"> <colgroup> <col width="150px" class="parameters_name"> <col class="parameters_description"> <col width="200px" class="parameters_annotations"> </colgroup> <tbody> <tr> <td class="parameter_name"><p>a</p></td> <td class="parameter_description"><p><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a></p></td> <td class="parameter_annotations"> </td> </tr> <tr> <td class="parameter_name"><p>b</p></td> <td class="parameter_description"><p><a href="https://developer.gnome.org/gobject/unstable/gobject-Generic-values.html#GValue"><span class="type">GValue</span></a></p></td> <td class="parameter_annotations"> </td> </tr> </tbody> </table></div> </div> <div class="refsect3"> <a name="id-1.2.3.6.7.6"></a><h4>Returns</h4> <p> <a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><span class="type">TRUE</span></a> if <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em> have the same type and value</p> </div> </div> </div> <div class="refsect1"> <a name="libuser-value.other_details"></a><h2>Types and Values</h2> </div> </div> <div class="footer"> <hr>Generated by GTK-Doc V1.24</div> </body> </html>