2 Common code for testing functions in src/execute.c file.
6 The Free Software Foundation, Inc.
9 Slava Zanko <slavazanko@gmail.com>, 2013
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "lib/widget.h"
28 #include "lib/strutil.h"
29 #include "lib/vfs/path.h"
30 #include "src/vfs/local/local.c"
32 #include "src/execute.h"
34 /* --------------------------------------------------------------------------------------------- */
37 static GPtrArray
*vfs_file_is_local__vpath__captured
;
39 /* @ThenReturnValue */
40 static gboolean vfs_file_is_local__return_value
;
44 vfs_file_is_local (const vfs_path_t
* vpath
)
46 g_ptr_array_add (vfs_file_is_local__vpath__captured
, vfs_path_clone (vpath
));
47 return vfs_file_is_local__return_value
;
51 vfs_file_is_local__init ()
53 vfs_file_is_local__vpath__captured
= g_ptr_array_new ();
57 vfs_file_is_local__deinit ()
59 g_ptr_array_foreach (vfs_file_is_local__vpath__captured
, (GFunc
) vfs_path_free
, NULL
);
60 g_ptr_array_free (vfs_file_is_local__vpath__captured
, TRUE
);
63 /* --------------------------------------------------------------------------------------------- */
65 void do_execute (const char *lc_shell
, const char *command
, int flags
);
68 static char *do_execute__lc_shell__captured
;
70 static char *do_execute__command__captured
;
72 static int do_execute__flags__captured
;
76 do_execute (const char *lc_shell
, const char *command
, int flags
)
78 do_execute__lc_shell__captured
= g_strdup (lc_shell
);
79 do_execute__command__captured
= g_strdup (command
);
80 do_execute__flags__captured
= flags
;
86 do_execute__command__captured
= NULL
;
87 do_execute__lc_shell__captured
= NULL
;
93 g_free (do_execute__lc_shell__captured
);
94 g_free (do_execute__command__captured
);
97 /* --------------------------------------------------------------------------------------------- */
100 static vfs_path_t
*mc_getlocalcopy__pathname_vpath__captured
;
101 /* @ThenReturnValue */
102 static vfs_path_t
*mc_getlocalcopy__return_value
;
106 mc_getlocalcopy (const vfs_path_t
* pathname_vpath
)
108 mc_getlocalcopy__pathname_vpath__captured
= vfs_path_clone (pathname_vpath
);
109 return mc_getlocalcopy__return_value
;
113 mc_getlocalcopy__init ()
115 mc_getlocalcopy__pathname_vpath__captured
= NULL
;
116 mc_getlocalcopy__return_value
= NULL
;
120 mc_getlocalcopy__deinit ()
122 vfs_path_free (mc_getlocalcopy__pathname_vpath__captured
);
125 /* --------------------------------------------------------------------------------------------- */
129 static int message_flags__captured
;
132 static char *message_title__captured
;
135 static char *message_text__captured
;
139 message (int flags
, const char *title
, const char *text
, ...)
143 message_flags__captured
= flags
;
145 message_title__captured
= (title
== MSG_ERROR
) ? g_strdup (_("Error")) : g_strdup (title
);
148 message_text__captured
= g_strdup_vprintf (text
, ap
);
156 message_flags__captured
= 0;
157 message_title__captured
= NULL
;
158 message_text__captured
= NULL
;
164 g_free (message_title__captured
);
165 g_free (message_text__captured
);
168 /* --------------------------------------------------------------------------------------------- */
171 static GPtrArray
*mc_stat__vpath__captured
= NULL
;
172 /* @ThenReturnValue */
173 static int mc_stat__return_value
= 0;
177 mc_stat (const vfs_path_t
* vpath
, struct stat
*stat_ignored
)
180 if (mc_stat__vpath__captured
!= NULL
)
181 g_ptr_array_add (mc_stat__vpath__captured
, vfs_path_clone (vpath
));
182 return mc_stat__return_value
;
189 mc_stat__vpath__captured
= g_ptr_array_new ();
195 g_ptr_array_foreach (mc_stat__vpath__captured
, (GFunc
) vfs_path_free
, NULL
);
196 g_ptr_array_free (mc_stat__vpath__captured
, TRUE
);
199 /* --------------------------------------------------------------------------------------------- */
202 static vfs_path_t
*mc_ungetlocalcopy__pathname_vpath__captured
;
204 static vfs_path_t
*mc_ungetlocalcopy__local_vpath__captured
;
205 /* @ThenReturnValue */
206 static int mc_ungetlocalcopy__return_value
= 0;
210 mc_ungetlocalcopy (const vfs_path_t
* pathname_vpath
, const vfs_path_t
* local_vpath
,
211 gboolean has_changed_ignored
)
213 (void) has_changed_ignored
;
215 mc_ungetlocalcopy__pathname_vpath__captured
= vfs_path_clone (pathname_vpath
);
216 mc_ungetlocalcopy__local_vpath__captured
= vfs_path_clone (local_vpath
);
217 return mc_ungetlocalcopy__return_value
;
221 mc_ungetlocalcopy__init ()
223 mc_ungetlocalcopy__pathname_vpath__captured
= NULL
;
224 mc_ungetlocalcopy__local_vpath__captured
= NULL
;
228 mc_ungetlocalcopy__deinit ()
230 vfs_path_free (mc_ungetlocalcopy__pathname_vpath__captured
);
231 vfs_path_free (mc_ungetlocalcopy__local_vpath__captured
);
234 /* --------------------------------------------------------------------------------------------- */
240 str_init_strings (NULL
);
243 vfs_setup_work_dir ();
245 vfs_file_is_local__init ();
247 mc_getlocalcopy__init ();
250 mc_ungetlocalcopy__init ();
253 /* --------------------------------------------------------------------------------------------- */
259 mc_ungetlocalcopy__deinit ();
262 mc_getlocalcopy__deinit ();
263 do_execute__deinit ();
264 vfs_file_is_local__deinit ();
267 str_uninit_strings ();
270 /* --------------------------------------------------------------------------------------------- */