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

📄 glib-shell-related-utilities.html

📁 最新gtk中文资料集
💻 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>Shell-related Utilities</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><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-URI-Functions.html" title="URI Functions"><link rel="next" href="glib-Commandline-option-parser.html" title="Commandline option parser"><meta name="generator" content="GTK-Doc V1.9 (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"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"><link rel="index" href="ix09.html" title="Index of new symbols in 2.14"><link rel="index" href="ix10.html" title="Index of new symbols in 2.16"></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="glib-URI-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-Commandline-option-parser.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="#id3123915" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id3124045" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="glib-Shell-related-Utilities"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3123915"></a><span class="refentrytitle">Shell-related Utilities</span></h2><p>Shell-related Utilities &#8212; shell-like commandline handling</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;enum                <a class="link" href="glib-Shell-related-Utilities.html#GShellError">GShellError</a>;#define             <a class="link" href="glib-Shell-related-Utilities.html#G-SHELL-ERROR:CAPS">G_SHELL_ERROR</a><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Shell-related-Utilities.html#g-shell-parse-argv">g_shell_parse_argv</a>                  (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *command_line,                                                         <a class="link" href="glib-Basic-Types.html#gint">gint</a> *argcp,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> ***argvp,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Shell-related-Utilities.html#g-shell-quote">g_shell_quote</a>                       (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *unquoted_string);<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Shell-related-Utilities.html#g-shell-unquote">g_shell_unquote</a>                     (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *quoted_string,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre></div><div class="refsect1" lang="en"><a name="id3124045"></a><h2>Description</h2><p></p></div><div class="refsect1" lang="en"><a name="id3124059"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3124069"></a><h3><a name="GShellError"></a>enum GShellError</h3><a class="indexterm" name="id3124082"></a><pre class="programlisting">typedef enum{  /* mismatched or otherwise mangled quoting */  G_SHELL_ERROR_BAD_QUOTING,  /* string to be parsed was empty */  G_SHELL_ERROR_EMPTY_STRING,  G_SHELL_ERROR_FAILED} GShellError;</pre><p>Error codes returned by shell functions.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="G-SHELL-ERROR-BAD-QUOTING:CAPS"></a><code class="literal">G_SHELL_ERROR_BAD_QUOTING</code></span></p></td><td>Mismatched or otherwise mangled quoting.</td></tr><tr><td><p><span class="term"><a name="G-SHELL-ERROR-EMPTY-STRING:CAPS"></a><code class="literal">G_SHELL_ERROR_EMPTY_STRING</code></span></p></td><td>String to be parsed was empty.</td></tr><tr><td><p><span class="term"><a name="G-SHELL-ERROR-FAILED:CAPS"></a><code class="literal">G_SHELL_ERROR_FAILED</code></span></p></td><td>Some other error.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3124174"></a><h3><a name="G-SHELL-ERROR:CAPS"></a>G_SHELL_ERROR</h3><a class="indexterm" name="id3124187"></a><pre class="programlisting">#define G_SHELL_ERROR g_shell_error_quark ()</pre><p>Error domain for shell functions. Errors in this domain willbe from the <a class="link" href="glib-Shell-related-Utilities.html#GShellError"><span class="type">GShellError</span></a> enumeration. See <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for information onerror domains.</p></div><hr><div class="refsect2" lang="en"><a name="id3124220"></a><h3><a name="g-shell-parse-argv"></a>g_shell_parse_argv ()</h3><a class="indexterm" name="id3124233"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            g_shell_parse_argv                  (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *command_line,                                                         <a class="link" href="glib-Basic-Types.html#gint">gint</a> *argcp,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> ***argvp,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Parses a command line into an argument vector, in much the same waythe shell would, but without many of the expansions the shell wouldperform (variable expansion, globs, operators, filename expansion,etc. are not supported). The results are defined to be the same asthose you would get from a UNIX98 /bin/sh, as long as the inputcontains none of the unsupported shell expansions. If the inputdoes contain such expansions, they are passed throughliterally. Possible errors are those from the <a class="link" href="glib-Shell-related-Utilities.html#G-SHELL-ERROR:CAPS"><span class="type">G_SHELL_ERROR</span></a>domain. Free the returned vector with <a class="link" href="glib-String-Utility-Functions.html#g-strfreev"><code class="function">g_strfreev()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>command_line</code></em>&#160;:</span></p></td><td> command line to parse</td></tr><tr><td><p><span class="term"><em class="parameter"><code>argcp</code></em>&#160;:</span></p></td><td> return location for number of args</td></tr><tr><td><p><span class="term"><em class="parameter"><code>argvp</code></em>&#160;:</span></p></td><td> return location for array of args</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> return location for error</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if error set</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3124407"></a><h3><a name="g-shell-quote"></a>g_shell_quote ()</h3><a class="indexterm" name="id3124420"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              g_shell_quote                       (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *unquoted_string);</pre><p>Quotes a string so that the shell (/bin/sh) will interpret thequoted string to mean <em class="parameter"><code>unquoted_string</code></em>. If you pass a filename tothe shell, for example, you should first quote it with thisfunction.  The return value must be freed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>. Thequoting style used is undefined (single or double quotes may beused).</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>unquoted_string</code></em>&#160;:</span></p></td><td> a literal string</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> quoted string</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3124502"></a><h3><a name="g-shell-unquote"></a>g_shell_unquote ()</h3><a class="indexterm" name="id3124514"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              g_shell_unquote                     (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *quoted_string,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Unquotes a string as the shell (/bin/sh) would. Only handlesquotes; if a string contains file globs, arithmetic operators,variables, backticks, redirections, or other special-to-the-shellfeatures, the result will be different from the result a real shellwould produce (the variables, backticks, etc. will be passedthrough literally instead of being expanded). This function isguaranteed to succeed if applied to the result of<a class="link" href="glib-Shell-related-Utilities.html#g-shell-quote"><code class="function">g_shell_quote()</code></a>. If it fails, it returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> and sets theerror. The <em class="parameter"><code>quoted_string</code></em> need not actually contain quoted orescaped text; <a class="link" href="glib-Shell-related-Utilities.html#g-shell-unquote"><code class="function">g_shell_unquote()</code></a> simply goes through the string andunquotes/unescapes anything that the shell would. Both single anddouble quotes are handled, as are escapes including escapednewlines. The return value must be freed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>. Possibleerrors are in the <a class="link" href="glib-Shell-related-Utilities.html#G-SHELL-ERROR:CAPS"><span class="type">G_SHELL_ERROR</span></a> domain.</p><p>Shell quoting rules are a bit strange. Single quotes preserve theliteral string exactly. escape sequences are not allowed; not even\' - if you want a ' in the quoted text, you have to do somethinglike 'foo'\''bar'.  Double quotes allow $, `, ", \, and newline tobe escaped with backslash. Otherwise double quotes preserve thingsliterally.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>quoted_string</code></em>&#160;:</span></p></td><td> shell-quoted string</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> error return location or NULL</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> an unquoted string</td></tr></tbody></table></div></div></div><div class="refsect1" lang="en"><a name="id3124676"></a><div class="refsect2" lang="en"><a name="id3124677"></a></div><hr><div class="refsect2" lang="en"><a name="id3124678"></a></div></div></div></body></html>

⌨️ 快捷键说明

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