1 /* $Id$ */
2 /*-
3  * Copyright (c) 2003-2006 Benedikt Meurer <benny@xfce.org>
4  * All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301 USA
20  */
21 
22 #if !defined(LIBXFCE4UTIL_INSIDE_LIBXFCE4UTIL_H) && !defined(LIBXFCE4UTIL_COMPILATION)
23 #error "Only <libxfce4util/libxfce4util.h> can be included directly, this file may disappear or change contents"
24 #endif
25 
26 #ifndef __XFCE_MISCUTILS_H__
27 #define __XFCE_MISCUTILS_H__
28 
29 #include <glib.h>
30 
31 #include <libxfce4util/xfce-debug.h>
32 
33 G_BEGIN_DECLS
34 
xfce_str_is_empty(const gchar * str)35 static inline gboolean xfce_str_is_empty (const gchar *str)
36 {
37   return str == NULL || *str == '\0';
38 }
39 
40 const gchar* xfce_version_string (void) G_GNUC_PURE;
41 
42 const gchar* xfce_get_homedir    (void) G_GNUC_PURE;
43 
44 gchar*       xfce_get_homefile_r (gchar *buffer,
45                                   size_t length,
46                                   const gchar *format,
47                                   ...);
48 
49 const gchar* xfce_get_userdir    (void) G_GNUC_PURE;
50 
51 gchar*       xfce_get_userfile_r (gchar *buffer,
52                                   size_t length,
53                                   const gchar *format,
54                                   ...);
55 
56 #if defined(G_HAVE_ISO_VARARGS)
57 
58 #define xfce_get_homefile(...)                             \
59   (g_build_filename (xfce_get_homedir (), __VA_ARGS__))
60 
61 #define xfce_get_userfile(...)                             \
62   (g_build_filename (xfce_get_userdir (), __VA_ARGS__))
63 
64 #elif defined(G_HAVE_GNUC_VARARGS)
65 
66 #define xfce_get_homefile(first_element...)                \
67   (g_build_filename (xfce_get_homedir (), ## first_element))
68 
69 #define xfce_get_userfile(first_element...)                \
70   (g_build_filename (xfce_get_userdir (), ## first_element))
71 
72 #else
73 
74 static gchar*
xfce_get_homefile(const gchar * first_element,...)75 xfce_get_homefile (const gchar *first_element, ...)
76 {
77 #error "Implement this, if you see this error!"
78 }
79 
80 static gchar*
xfce_get_userfile(const gchar * first_element,...)81 xfce_get_userfile (const gchar *first_element, ...)
82 {
83 #error "Implement this, if you see this error!"
84 }
85 
86 #endif
87 
88 gchar* xfce_gethostname                      (void) G_GNUC_MALLOC;
89 
90 gchar* xfce_expand_variables                 (const gchar  *command,
91                                               gchar       **envp) G_GNUC_MALLOC;
92 
93 void   xfce_append_quoted                    (GString      *string,
94                                               const gchar  *unquoted);
95 
96 gchar* xfce_expand_desktop_entry_field_codes (const gchar  *command,
97                                               GSList       *uri_list,
98                                               const gchar  *icon,
99                                               const gchar  *name,
100                                               const gchar  *uri,
101                                               gboolean      requires_terminal) G_GNUC_MALLOC;
102 
103 G_END_DECLS
104 
105 #endif /* __XFCE_MISCUTILS_H__ */
106