File: libxfce4util-Miscellaneous-Utilities.html

package info (click to toggle)
libxfce4util 4.20.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,568 kB
  • sloc: ansic: 5,483; sh: 5,064; makefile: 229; python: 128; sed: 16
file content (464 lines) | stat: -rw-r--r-- 21,289 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Miscellaneous Utilities: libxfce4util Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="libxfce4util Reference Manual">
<link rel="up" href="ch01.html" title="[Insert title here]">
<link rel="prev" href="libxfce4util-Software-Licenses.html" title="Software Licenses">
<link rel="next" href="libxfce4util-POSIX-Signal-Handling.html" title="POSIX Signal Handling">
<meta name="generator" content="GTK-Doc V1.34.0 (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="#libxfce4util-Miscellaneous-Utilities.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="libxfce4util-Software-Licenses.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="libxfce4util-POSIX-Signal-Handling.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="libxfce4util-Miscellaneous-Utilities"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="libxfce4util-Miscellaneous-Utilities.top_of_page"></a>Miscellaneous Utilities</span></h2>
<p>Miscellaneous Utilities — miscellaneous file-related utility functions.</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="libxfce4util-Miscellaneous-Utilities.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_proto_type">
<col class="functions_proto_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">const <span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-homedir" title="xfce_get_homedir ()">xfce_get_homedir</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-homefile" title="xfce_get_homefile()">xfce_get_homefile</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-homefile-r" title="xfce_get_homefile_r ()">xfce_get_homefile_r</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">const <span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-userdir" title="xfce_get_userdir ()">xfce_get_userdir</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-userfile" title="xfce_get_userfile()">xfce_get_userfile</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-userfile-r" title="xfce_get_userfile_r ()">xfce_get_userfile_r</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-gethostname" title="xfce_gethostname ()">xfce_gethostname</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-expand-variables" title="xfce_expand_variables ()">xfce_expand_variables</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="libxfce4util-Miscellaneous-Utilities.html#xfce-append-quoted" title="xfce_append_quoted ()">xfce_append_quoted</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-expand-desktop-entry-field-codes" title="xfce_expand_desktop_entry_field_codes ()">xfce_expand_desktop_entry_field_codes</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gchar</span> *
</td>
<td class="function_name">
<a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-unescape-desktop-entry-value" title="xfce_unescape_desktop_entry_value ()">xfce_unescape_desktop_entry_value</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="libxfce4util-Miscellaneous-Utilities.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;libxfce4util/libxfce4util.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="libxfce4util-Miscellaneous-Utilities.description"></a><h2>Description</h2>
<p>Miscellaneous file-related utility functions.</p>
</div>
<div class="refsect1">
<a name="libxfce4util-Miscellaneous-Utilities.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="xfce-get-homedir"></a><h3>xfce_get_homedir ()</h3>
<pre class="programlisting">const <span class="returnvalue">gchar</span> *
xfce_get_homedir (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Similar to <code class="function">g_get_home_dir()</code> in functionality but will never return NULL.
While <code class="function">g_get_home_dir()</code> may return NULL under certain circumstances, this
function is garantied to never ever return NULL, but always return a
valid character pointer with the absolute path to the user's home directory.</p>
<p>The returned string is owned by libxfce4util and must not be freed by
the caller.</p>
<div class="refsect3">
<a name="xfce-get-homedir.returns"></a><h4>Returns</h4>
<p> the path to the current user's home directory.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-get-homefile"></a><h3>xfce_get_homefile()</h3>
<pre class="programlisting">#define             xfce_get_homefile(...)</pre>
</div>
<hr>
<div class="refsect2">
<a name="xfce-get-homefile-r"></a><h3>xfce_get_homefile_r ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> *
xfce_get_homefile_r (<em class="parameter"><code><span class="type">gchar</span> *buffer</code></em>,
                     <em class="parameter"><code><span class="type">size_t</span> length</code></em>,
                     <em class="parameter"><code>const <span class="type">gchar</span> *format</code></em>,
                     <em class="parameter"><code>...</code></em>);</pre>
<p>Similar in functionality to <a class="link" href="libxfce4util-Miscellaneous-Utilities.html#xfce-get-homefile" title="xfce_get_homefile()"><span class="type">xfce_get_homefile</span></a>, but uses a user
defined <em class="parameter"><code>buffer</code></em>
 instead of allocating a new buffer.</p>
<p>xfce_get_homefile_r uses safe string operations, that says, it garanties
that the resulting string is always zero terminated, as long as the
<em class="parameter"><code>length</code></em>
 is greater than zero.</p>
<div class="refsect3">
<a name="xfce-get-homefile-r.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" 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>buffer</p></td>
<td class="parameter_description"><p>pointer to a user provided destination buffer.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>length</p></td>
<td class="parameter_description"><p>size of <em class="parameter"><code>buffer</code></em>
in bytes.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>format</p></td>
<td class="parameter_description"><p>printf style format string.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>the arguments to substitute in the output.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="xfce-get-homefile-r.returns"></a><h4>Returns</h4>
<p> pointer to <em class="parameter"><code>buffer</code></em>
.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-get-userdir"></a><h3>xfce_get_userdir ()</h3>
<pre class="programlisting">const <span class="returnvalue">gchar</span> *
xfce_get_userdir (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Safe way to retrieve the path to the user's ".xfce4" directory. The path
to the current user's ".xfce4" directory is either taken from the
environment variable XFCE4HOME if defined, or if unset, is gained by
concatenating the path to the user's home directory and the ".xfce4".
That says, it will, by default, return the path "$HOME/.xfce4", where
$HOME is replaced with the absolute path to the user's home directory.</p>
<p>The returned string is managed by libxfce4util and must not be freed by
the caller.</p>
<div class="refsect3">
<a name="xfce-get-userdir.returns"></a><h4>Returns</h4>
<p> the path to the current user's ".xfce4" directory.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-get-userfile"></a><h3>xfce_get_userfile()</h3>
<pre class="programlisting">#define             xfce_get_userfile(...)</pre>
</div>
<hr>
<div class="refsect2">
<a name="xfce-get-userfile-r"></a><h3>xfce_get_userfile_r ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> *
xfce_get_userfile_r (<em class="parameter"><code><span class="type">gchar</span> *buffer</code></em>,
                     <em class="parameter"><code><span class="type">size_t</span> length</code></em>,
                     <em class="parameter"><code>const <span class="type">gchar</span> *format</code></em>,
                     <em class="parameter"><code>...</code></em>);</pre>
<div class="refsect3">
<a name="xfce-get-userfile-r.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" 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>buffer</p></td>
<td class="parameter_description"><p>user provided destination buffer.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>length</p></td>
<td class="parameter_description"><p>size of <em class="parameter"><code>buffer</code></em>
in bytes.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>format</p></td>
<td class="parameter_description"><p>printf style format string.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>arguments to substitute in the output.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="xfce-get-userfile-r.returns"></a><h4>Returns</h4>
<p> pointer to <em class="parameter"><code>buffer</code></em>
.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-gethostname"></a><h3>xfce_gethostname ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> *
xfce_gethostname (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Portable way to query the hostname of the node running the process. This
function does not ever return <code class="literal">NULL</code>, but always returns a string containing
the current node's hostname.</p>
<div class="refsect3">
<a name="xfce-gethostname.returns"></a><h4>Returns</h4>
<p> the current node's hostname. The string has to be freed
by the caller using <code class="function">g_free()</code>.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-expand-variables"></a><h3>xfce_expand_variables ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> *
xfce_expand_variables (<em class="parameter"><code>const <span class="type">gchar</span> *command</code></em>,
                       <em class="parameter"><code><span class="type">gchar</span> **envp</code></em>);</pre>
<p>Expands shell like environment variables and tilde (~/ and ~user/ are both supported)
in <em class="parameter"><code>command</code></em>
.</p>
<div class="refsect3">
<a name="xfce-expand-variables.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" 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>command</p></td>
<td class="parameter_description"><p>Input string or <code class="literal">NULL</code>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>envp</p></td>
<td class="parameter_description"><p>Addition environment variables to take into account. These
variables have higher priority than the ones in the process's
environment.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="xfce-expand-variables.returns"></a><h4>Returns</h4>
<p> <code class="literal">NULL</code> on error, else the string, which should be freed using
<code class="function">g_free()</code> when no longer needed.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-4-2.html#api-index-4.2">4.2</a></p>
</div>
<hr>
<div class="refsect2">
<a name="xfce-append-quoted"></a><h3>xfce_append_quoted ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
xfce_append_quoted (<em class="parameter"><code><span class="type">GString</span> *string</code></em>,
                    <em class="parameter"><code>const <span class="type">gchar</span> *unquoted</code></em>);</pre>
<div class="warning">
<p><code class="literal">xfce_append_quoted</code> has been deprecated since version 4.17 and should not be used in newly-written code.</p>
<p>Renamed to <a class="link" href="libxfce4util-Xfce-String-Functions.html#xfce-g-string-append-quoted" title="xfce_g_string_append_quoted ()"><code class="function">xfce_g_string_append_quoted()</code></a></p>
</div>
<p>An alias of <a class="link" href="libxfce4util-Xfce-String-Functions.html#xfce-g-string-append-quoted" title="xfce_g_string_append_quoted ()"><code class="function">xfce_g_string_append_quoted()</code></a>.</p>
<div class="refsect3">
<a name="xfce-append-quoted.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" 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>string</p></td>
<td class="parameter_description"><p>A <span class="type">GString</span>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>unquoted</p></td>
<td class="parameter_description"><p>A literal string.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-expand-desktop-entry-field-codes"></a><h3>xfce_expand_desktop_entry_field_codes ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> *
xfce_expand_desktop_entry_field_codes (<em class="parameter"><code>const <span class="type">gchar</span> *command</code></em>,
                                       <em class="parameter"><code><span class="type">GSList</span> *uri_list</code></em>,
                                       <em class="parameter"><code>const <span class="type">gchar</span> *icon</code></em>,
                                       <em class="parameter"><code>const <span class="type">gchar</span> *name</code></em>,
                                       <em class="parameter"><code>const <span class="type">gchar</span> *uri</code></em>,
                                       <em class="parameter"><code><span class="type">gboolean</span> requires_terminal</code></em>);</pre>
<p>Expands field codes in <em class="parameter"><code>command</code></em>
 according to Freedesktop.org Desktop Entry Specification.</p>
<div class="refsect3">
<a name="xfce-expand-desktop-entry-field-codes.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" 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>command</p></td>
<td class="parameter_description"><p>Input string (command to expand) or <code class="literal">NULL</code>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>uri_list</p></td>
<td class="parameter_description"><p>Input string list (filename/URL field) or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> utf8]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>icon</p></td>
<td class="parameter_description"><p>Input string (icon field) or <code class="literal">NULL</code>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>name</p></td>
<td class="parameter_description"><p>Input string (name field) or <code class="literal">NULL</code>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>uri</p></td>
<td class="parameter_description"><p>Input string (URI field) or <code class="literal">NULL</code>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>requires_terminal</p></td>
<td class="parameter_description"><p>Input boolean.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="xfce-expand-desktop-entry-field-codes.returns"></a><h4>Returns</h4>
<p> <code class="literal">NULL</code> on error, else the string, which should be freed using <code class="function">g_free()</code> when
no longer needed.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="xfce-unescape-desktop-entry-value"></a><h3>xfce_unescape_desktop_entry_value ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> *
xfce_unescape_desktop_entry_value (<em class="parameter"><code>const <span class="type">gchar</span> *value</code></em>);</pre>
<p>Unescapes sequences in <em class="parameter"><code>value</code></em>
 according to Freedesktop.org Desktop Entry Specification.</p>
<div class="refsect3">
<a name="xfce-unescape-desktop-entry-value.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" 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>Value string to replace escape sequences.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="xfce-unescape-desktop-entry-value.returns"></a><h4>Returns</h4>
<p> <code class="literal">NULL</code> on error, else the string, which should be freed using <code class="function">g_free()</code> when
no longer needed.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-4-18.html#api-index-4.18">4.18</a></p>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.34.0</div>
</body>
</html>