📄 libgnome-gnome-util.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>gnome-util</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="GNOME Library Reference Manual"><link rel="up" href="ch01s04.html" title="Miscellaneous"><link rel="prev" href="ch01s04.html" title="Miscellaneous"><link rel="next" href="libgnome-gnome-sound.html" title="gnome-sound"><meta name="generator" content="GTK-Doc V1.7 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="libgnome.html" title="GNOME Library (libgnome)"></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="2"><tr valign="middle"><td><a accesskey="p" href="ch01s04.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="ch01s04.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GNOME Library Reference Manual</th><td><a accesskey="n" href="libgnome-gnome-sound.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id2822350" class="shortcut">Top</a>  |  <a href="#id2822642" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="libgnome-gnome-util"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id2822350"></a><span class="refentrytitle">gnome-util</span></h2><p>gnome-util — Miscellaneous utility functions.</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include <libgnome/libgnome.h>#define <a href="libgnome-gnome-util.html#gnome-is-program-in-path">gnome_is_program_in_path</a> (program)const char* <a href="libgnome-gnome-util.html#g-extension-pointer">g_extension_pointer</a> (const char *path);#define <a href="libgnome-gnome-util.html#gnome-util-prepend-user-home">gnome_util_prepend_user_home</a> (x)#define <a href="libgnome-gnome-util.html#gnome-util-home-file">gnome_util_home_file</a> (afile)char* <a href="libgnome-gnome-util.html#gnome-util-user-shell">gnome_util_user_shell</a> (void);int <a href="libgnome-gnome-util.html#gnome-setenv">gnome_setenv</a> (const char *name, const char *value, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> overwrite);void <a href="libgnome-gnome-util.html#gnome-unsetenv">gnome_unsetenv</a> (const char *name);void <a href="libgnome-gnome-util.html#gnome-clearenv">gnome_clearenv</a> (void);#define <a href="libgnome-gnome-util.html#g-concat-dir-and-file">g_concat_dir_and_file</a> (dir,file)#define <a href="libgnome-gnome-util.html#g-file-exists">g_file_exists</a> (filename)#define <a href="libgnome-gnome-util.html#g-unix-error-string">g_unix_error_string</a> (error_num)#define <a href="libgnome-gnome-util.html#gnome-util-user-home">gnome_util_user_home</a> ()#define <a href="libgnome-gnome-util.html#g-copy-vector">g_copy_vector</a> (vec)#define <a href="libgnome-gnome-util.html#gnome-libdir-file">gnome_libdir_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-datadir-file">gnome_datadir_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-sound-file">gnome_sound_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-pixmap-file">gnome_pixmap_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-config-file">gnome_config_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-unconditional-libdir-file">gnome_unconditional_libdir_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-unconditional-datadir-file">gnome_unconditional_datadir_file</a>(f)#define <a href="libgnome-gnome-util.html#gnome-unconditional-sound-file">gnome_unconditional_sound_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-unconditional-pixmap-file">gnome_unconditional_pixmap_file</a> (f)#define <a href="libgnome-gnome-util.html#gnome-unconditional-config-file">gnome_unconditional_config_file</a> (f)</pre></div><div class="refsect1" lang="en"><a name="id2822642"></a><h2>Description</h2><p>The functions in this section provide some shortcuts to finding certain filepaths. There are also some functions for manipulating environment variables forthose systems that do not have <code class="function"><code class="function">getenv()</code></code> and similarfunctions.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> Many of the function in here are now deprecated in favour of similar functions in glib. The preferred replacement function in those cases is indicated below. </p></div></div><div class="refsect1" lang="en"><a name="id2822684"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2822695"></a><h3><a name="gnome-is-program-in-path"></a>gnome_is_program_in_path()</h3><a class="indexterm" name="id2822710"></a><pre class="programlisting">#define gnome_is_program_in_path(program)</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_is_program_in_path</code> is deprecated and should not be used in newly-written code.</p></div><p>Deprecated, use <ahref="/usr/share/gtk-doc/html/glib/glib-Miscellaneous-Utility-Functions.html#g-find-program-in-path"><span class="type">g_find_program_in_path</span></a></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>program</code></em> :</span></td><td> A program name.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> if program is not on the path or a stringallocated with <ahref="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a> with the full path name of the programfound.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2822802"></a><h3><a name="g-extension-pointer"></a>g_extension_pointer ()</h3><a class="indexterm" name="id2822815"></a><pre class="programlisting">const char* g_extension_pointer (const char *path);</pre><p>Extracts the extension from the end of a filename (the part after the final'.' in the filename).</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>path</code></em> :</span></td><td> A filename or file path.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> A pointer to the extension part of the filename, or apointer to the end of the string if the filename does nothave an extension.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2822880"></a><h3><a name="gnome-util-prepend-user-home"></a>gnome_util_prepend_user_home()</h3><a class="indexterm" name="id2822893"></a><pre class="programlisting">#define gnome_util_prepend_user_home(x)</pre><p>Prepends the home directory of the user to a filename.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>x</code></em> :</span></td><td>A relative filename in the user's home directory.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>A string containing <em class="parameter"><code>x</code></em> with the user's home directory path prepended.The string should be freed with <ahref="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longer required.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2822957"></a><h3><a name="gnome-util-home-file"></a>gnome_util_home_file()</h3><a class="indexterm" name="id2822970"></a><pre class="programlisting">#define gnome_util_home_file(afile)</pre><p>Similar to <a href="libgnome-gnome-util.html#gnome-util-prepend-user-home"><code class="function">gnome_util_prepend_user_home()</code></a>, except that "/home/fred/.gnome2",instead of just "/home/fred/" is put on the front.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>afile</code></em> :</span></td><td> A filename relative to the user's .gnome2 directory.Returns: A string containing <em class="parameter"><code>afile</code></em> with the user's home directory path and"/.gnome2" prepended. The string should be freed with <ahref="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when no longerrequired.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2823036"></a><h3><a name="gnome-util-user-shell"></a>gnome_util_user_shell ()</h3><a class="indexterm" name="id2823049"></a><pre class="programlisting">char* gnome_util_user_shell (void);</pre><p>Retrieves the user's preferred shell.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> A newly allocated string that is the path to the shell.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2823090"></a><h3><a name="gnome-setenv"></a>gnome_setenv ()</h3><a class="indexterm" name="id2823103"></a><pre class="programlisting">int gnome_setenv (const char *name, const char *value, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> overwrite);</pre><p>Adds "<em class="parameter"><code>name</code></em>=<em class="parameter"><code>value</code></em>" to the environment. Note that on systems without setenv,this leaks memory so please do not use inside a loop or anything like that.The semantics are the same as the glibc <code class="function">setenv()</code> (if <code class="function">setenv()</code> exists, it isused).</p><p>If <em class="parameter"><code>overwrite</code></em> is <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> and the variable already exists in the environment,then <code class="literal">0</code> is returned and the value is not changed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>name</code></em> :</span></td><td> An environment variable name.</td></tr><tr><td><span class="term"><em class="parameter"><code>value</code></em> :</span></td><td> The value to assign to the environment variable.</td></tr><tr><td><span class="term"><em class="parameter"><code>overwrite</code></em> :</span></td><td> If <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -