1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  *  Copyright (C) 2007-2011  Kouhei Sutou <kou@clear-code.com>
4  *
5  *  This library is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Lesser General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef __CUT_UTILS_H__
21 #define __CUT_UTILS_H__
22 
23 #include <glib.h>
24 
25 G_BEGIN_DECLS
26 
27 typedef enum {
28     CUT_READ,
29     CUT_WRITE
30 } CutPipeMode;
31 
32 #define cut_utils_report_error(error) do        \
33 {                                               \
34     gchar *inspected;                           \
35                                                 \
36     inspected = gcut_error_inspect(error);      \
37     g_warning("%s", inspected);                 \
38     g_free(inspected);                          \
39     g_error_free(error);                        \
40 } while (0)
41 
42 gchar   *cut_utils_create_regex_pattern (const gchar *string);
43 GList   *cut_utils_filter_to_regexs     (const gchar **filters);
44 gboolean cut_utils_filter_match         (GList *regexs,
45                                          const gchar *name);
46 void     cut_utils_append_indent        (GString *string,
47                                          guint    size);
48 void     cut_utils_append_xml_element_with_value
49                                         (GString     *string,
50                                          guint        indent,
51                                          const gchar *element_name,
52                                          const gchar *value);
53 void     cut_utils_append_xml_element_with_boolean_value
54                                         (GString     *string,
55                                          guint        indent,
56                                          const gchar *element_name,
57                                          gboolean     boolean);
58 gchar  **cut_utils_strv_concat          (const gchar **str_array,
59                                          ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
60 
61 void     cut_utils_close_pipe           (int         *pipe,
62                                          CutPipeMode  mode);
63 
64 const gchar *cut_utils_get_cutter_command_path (void);
65 
66 gchar       *cut_utils_expand_path           (const gchar *path);
67 gchar       *cut_utils_expand_path_va_list   (const gchar *path, va_list args);
68 
69 gboolean     cut_utils_remove_path           (const char  *path,
70                                               GError     **error);
71 gboolean     cut_utils_remove_path_recursive (const char  *path,
72                                               GError     **error);
73 
74 gchar       *cut_utils_regex_replace         (const gchar  *pattern,
75                                               const gchar  *string,
76                                               const gchar  *replacement,
77                                               GError      **error);
78 
79 GList       *cut_utils_parse_gdb_backtrace   (const gchar  *gdb_backtrace);
80 
81 gchar       *cut_utils_double_to_string      (gdouble       value);
82 
83 gint         cut_utils_compare_string        (gconstpointer data1,
84                                               gconstpointer data2);
85 gint         cut_utils_compare_direct        (gconstpointer data1,
86                                               gconstpointer data2);
87 
88 #ifdef G_OS_WIN32
89 const gchar *cut_win32_base_path                     (void);
90 const gchar *cut_win32_icons_dir                     (void);
91 const gchar *cut_win32_ui_data_dir                   (void);
92 gchar       *cut_win32_build_module_dir_name         (const gchar *type);
93 gchar       *cut_win32_build_factory_module_dir_name (const gchar *type);
94 gboolean     cut_win32_kill_process                  (GPid pid,
95                                                       guint exit_code);
96 #endif
97 
98 G_END_DECLS
99 
100 #endif /* __CUT_UTILS_H__ */
101 
102 /*
103 vi:ts=4:nowrap:ai:expandtab:sw=4
104 */
105