⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-miscellaneous-utility-functions.html

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<html xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Miscellaneous Utility Functions</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.0"><link rel="start" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-utilities.html" title="GLib Utilities"><link rel="prev" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="next" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><meta name="generator" content="GTK-Doc V1.4 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Hook-Functions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-utilities.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">GLib Reference Manual</th><td><a accesskey="n" href="glib-Lexical-Scanner.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Miscellaneous-Utility-Functions"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><span class="refentrytitle">Miscellaneous Utility Functions</span></h2><p>Miscellaneous Utility Functions &#8212; a selection of portable utility functions.</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;glib.h&gt;const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-application-name">g_get_application_name</a>         (void);void        <a href="glib-Miscellaneous-Utility-Functions.html#g-set-application-name">g_set_application_name</a>          (const <a href="glib-Basic-Types.html#gchar">gchar</a> *application_name);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-get-prgname">g_get_prgname</a>                   (void);void        <a href="glib-Miscellaneous-Utility-Functions.html#g-set-prgname">g_set_prgname</a>                   (const <a href="glib-Basic-Types.html#gchar">gchar</a> *prgname);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-getenv">g_getenv</a>                       (const <a href="glib-Basic-Types.html#gchar">gchar</a> *variable);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Miscellaneous-Utility-Functions.html#g-setenv">g_setenv</a>                        (const <a href="glib-Basic-Types.html#gchar">gchar</a> *variable,                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *value,                                             <a href="glib-Basic-Types.html#gboolean">gboolean</a> overwrite);void        <a href="glib-Miscellaneous-Utility-Functions.html#g-unsetenv">g_unsetenv</a>                      (const <a href="glib-Basic-Types.html#gchar">gchar</a> *variable);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-user-name">g_get_user_name</a>                (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-real-name">g_get_real_name</a>                (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-user-cache-dir">g_get_user_cache_dir</a>           (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-user-data-dir">g_get_user_data_dir</a>            (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-user-config-dir">g_get_user_config_dir</a>          (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* const * <a href="glib-Miscellaneous-Utility-Functions.html#g-get-system-data-dirs">g_get_system_data_dirs</a> (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* const * <a href="glib-Miscellaneous-Utility-Functions.html#g-get-system-config-dirs">g_get_system_config_dirs</a>                                            (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-home-dir">g_get_home_dir</a>                 (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-get-tmp-dir">g_get_tmp_dir</a>                  (void);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-get-current-dir">g_get_current_dir</a>               (void);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-basename">g_basename</a>                     (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name);#define     <a href="glib-Miscellaneous-Utility-Functions.html#g-dirname">g_dirname</a><a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Miscellaneous-Utility-Functions.html#g-path-is-absolute">g_path_is_absolute</a>              (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name);const <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Miscellaneous-Utility-Functions.html#g-path-skip-root">g_path_skip_root</a>               (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-path-get-basename">g_path_get_basename</a>             (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-path-get-dirname">g_path_get_dirname</a>              (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-build-filename">g_build_filename</a>                (const <a href="glib-Basic-Types.html#gchar">gchar</a> *first_element,                                             ...);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-build-path">g_build_path</a>                    (const <a href="glib-Basic-Types.html#gchar">gchar</a> *separator,                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *first_element,                                             ...);<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Miscellaneous-Utility-Functions.html#g-find-program-in-path">g_find_program_in_path</a>          (const <a href="glib-Basic-Types.html#gchar">gchar</a> *program);<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Miscellaneous-Utility-Functions.html#g-bit-nth-lsf">g_bit_nth_lsf</a>                   (<a href="glib-Basic-Types.html#gulong">gulong</a> mask,                                             <a href="glib-Basic-Types.html#gint">gint</a> nth_bit);<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Miscellaneous-Utility-Functions.html#g-bit-nth-msf">g_bit_nth_msf</a>                   (<a href="glib-Basic-Types.html#gulong">gulong</a> mask,                                             <a href="glib-Basic-Types.html#gint">gint</a> nth_bit);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Miscellaneous-Utility-Functions.html#g-bit-storage">g_bit_storage</a>                   (<a href="glib-Basic-Types.html#gulong">gulong</a> number);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Miscellaneous-Utility-Functions.html#g-spaced-primes-closest">g_spaced_primes_closest</a>         (<a href="glib-Basic-Types.html#guint">guint</a> num);void        <a href="glib-Miscellaneous-Utility-Functions.html#g-atexit">g_atexit</a>                        (<a href="glib-Miscellaneous-Utility-Functions.html#GVoidFunc">GVoidFunc</a> func);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Miscellaneous-Utility-Functions.html#g-parse-debug-string">g_parse_debug_string</a>            (const <a href="glib-Basic-Types.html#gchar">gchar</a> *string,                                             const <a href="glib-Miscellaneous-Utility-Functions.html#GDebugKey">GDebugKey</a> *keys,                                             <a href="glib-Basic-Types.html#guint">guint</a> nkeys);            <a href="glib-Miscellaneous-Utility-Functions.html#GDebugKey">GDebugKey</a>;void        (<a href="glib-Miscellaneous-Utility-Functions.html#GVoidFunc">*GVoidFunc</a>)                    (void);void        (<a href="glib-Miscellaneous-Utility-Functions.html#GFreeFunc">*GFreeFunc</a>)                    (<a href="glib-Basic-Types.html#gpointer">gpointer</a> data);void        <a href="glib-Miscellaneous-Utility-Functions.html#g-qsort-with-data">g_qsort_with_data</a>               (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> pbase,                                             <a href="glib-Basic-Types.html#gint">gint</a> total_elems,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> size,                                             <a href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);void        <a href="glib-Miscellaneous-Utility-Functions.html#g-nullify-pointer">g_nullify_pointer</a>               (<a href="glib-Basic-Types.html#gpointer">gpointer</a> *nullify_location);</pre></div><div class="refsect1" lang="en"><a name="id3020698"></a><h2>Description</h2><p>These are portable utility functions.</p></div><div class="refsect1" lang="en"><a name="id3020708"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3020714"></a><h3><a name="g-get-application-name"></a>g_get_application_name ()</h3><a class="indexterm" name="id3020725"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_application_name         (void);</pre><p>Gets a human-readable name for the application, as set by<a href="glib-Miscellaneous-Utility-Functions.html#g-set-application-name"><code class="function">g_set_application_name()</code></a>. This name should be localized ifpossible, and is intended for display to the user.  Contrast with<a href="glib-Miscellaneous-Utility-Functions.html#g-get-prgname"><code class="function">g_get_prgname()</code></a>, which gets a non-localized name. If<a href="glib-Miscellaneous-Utility-Functions.html#g-set-application-name"><code class="function">g_set_application_name()</code></a> has not been called, returns the result of<a href="glib-Miscellaneous-Utility-Functions.html#g-get-prgname"><code class="function">g_get_prgname()</code></a> (which may be <code class="literal">NULL</code> if <a href="glib-Miscellaneous-Utility-Functions.html#g-set-prgname"><code class="function">g_set_prgname()</code></a> has also notbeen called).</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>&#160;:</span></td><td> human-readable application name. may return <code class="literal">NULL</code></td></tr></tbody></table></div><p>Since  2.2</p></div><hr><div class="refsect2" lang="en"><a name="id3020841"></a><h3><a name="g-set-application-name"></a>g_set_application_name ()</h3><a class="indexterm" name="id3020852"></a><pre class="programlisting">void        g_set_application_name          (const <a href="glib-Basic-Types.html#gchar">gchar</a> *application_name);</pre><p>Sets a human-readable name for the application. This name should belocalized if possible, and is intended for display to the user.Contrast with <a href="glib-Miscellaneous-Utility-Functions.html#g-set-prgname"><code class="function">g_set_prgname()</code></a>, which sets a non-localized name.<a href="glib-Miscellaneous-Utility-Functions.html#g-set-prgname"><code class="function">g_set_prgname()</code></a> will be called automatically by <ahref="../gtk/gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>,but <a href="glib-Miscellaneous-Utility-Functions.html#g-set-application-name"><code class="function">g_set_application_name()</code></a> will not.</p><p>Note that for thread safety reasons, this function can onlybe called once.</p><p>The application name will be used in contexts such as error messages,or when displaying an application's name in the task list.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>application_name</code></em>&#160;:</span></td><td> localized name of the application</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3020958"></a><h3><a name="g-get-prgname"></a>g_get_prgname ()</h3><a class="indexterm" name="id3020969"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_get_prgname                   (void);</pre><p>Gets the name of the program. This name should <span class="emphasis"><em>not</em></span> be localized,contrast with <a href="glib-Miscellaneous-Utility-Functions.html#g-get-application-name"><code class="function">g_get_application_name()</code></a>.(If you are using GDK or GTK+ the program name is set in <ahref="../gdk/gdk-General.html#gdk-init"><code class="function">gdk_init()</code></a>, whichis called by <ahref="../gtk/gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>. The program name is found by taking the lastcomponent of <code class="literal">argv[0]</code>.)</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>&#160;:</span></td><td>the name of the program.   The returned string belongs to GLib and must not be modified or freed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3021051"></a><h3><a name="g-set-prgname"></a>g_set_prgname ()</h3><a class="indexterm" name="id3021061"></a><pre class="programlisting">void        g_set_prgname                   (const <a href="glib-Basic-Types.html#gchar">gchar</a> *prgname);</pre><p>Sets the name of the program. This name should <span class="emphasis"><em>not</em></span> be localized, contrast with <a href="glib-Miscellaneous-Utility-Functions.html#g-set-application-name"><code class="function">g_set_application_name()</code></a>. Note that for thread-safetyreasons this function can only be called once.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>prgname</code></em>&#160;:</span></td><td>the name of the program.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3021125"></a><h3><a name="g-getenv"></a>g_getenv ()</h3><a class="indexterm" name="id3021135"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_getenv                       (const <a href="glib-Basic-Types.html#gchar">gchar</a> *variable);</pre><p>Returns the value of an environment variable. The name and valueare in the GLib file name encoding. On Unix, this means the actualbytes which might or might not be in some consistent character setand encoding. On Windows, it is in UTF-8. On Windows, in case theenvironment variable's value contains references to otherenvironment variables, they are expanded.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>variable</code></em>&#160;:</span></td><td> the environment variable to get, in the GLib file name encoding.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> the value of the environment variable, or <code class="literal">NULL</code> ifthe environment variable is not found. The returned string may beoverwritten by the next call to <a href="glib-Miscellaneous-Utility-Functions.html#g-getenv"><code class="function">g_getenv()</code></a>, <a href="glib-Miscellaneous-Utility-Functions.html#g-setenv"><code class="function">g_setenv()</code></a> or<a href="glib-Miscellaneous-Utility-Functions.html#g-unsetenv"><code class="function">g_unsetenv()</code></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3021242"></a><h3><a name="g-setenv"></a>g_setenv ()</h3><a class="indexterm" name="id3021252"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_setenv                        (const <a href="glib-Basic-Types.html#gchar">gchar</a> *variable,                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *value,                                             <a href="glib-Basic-Types.html#gboolean">gboolean</a> overwrite);</pre><p>Sets an environment variable. Both the variable's name and valueshould be in the GLib file name encoding. On Unix, this means thatthey can be any sequence of bytes. On Windows, they should be inUTF-8.</p><p>Note that on some systems, when variables are overwritten, the memory used for the previous variables and its value isn't reclaimed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>variable</code></em>&#160;:</span></td><td> the environment variable to set, must not contain '='.</td></tr><tr><td><span class="term"><em class="parameter"><code>value</code></em>&#160;:</span></td><td> the value for to set the variable to.</td></tr><tr><td><span class="term"><em class="parameter"><code>overwrite</code></em>&#160;:</span></td><td> whether to change the variable if it already exists.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td> <code class="literal">FALSE</code> if the environment variable couldn't be set.</td></tr></tbody></table></div><p>Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3021377"></a><h3><a name="g-unsetenv"></a>g_unsetenv ()</h3><a class="indexterm" name="id3021388"></a><pre class="programlisting">void        g_unsetenv                      (const <a href="glib-Basic-Types.html#gchar">gchar</a> *variable);</pre><p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -