2 Common code for testing functions in src/execute.c file.
4 Copyright (C) 2013-2016
6 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/vfs.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 (void)
53 vfs_file_is_local__vpath__captured
= g_ptr_array_new ();
57 vfs_file_is_local__deinit (void)
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
;
84 do_execute__init (void)
86 do_execute__command__captured
= NULL
;
87 do_execute__lc_shell__captured
= NULL
;
91 do_execute__deinit (void)
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 (void)
115 mc_getlocalcopy__pathname_vpath__captured
= NULL
;
116 mc_getlocalcopy__return_value
= NULL
;
120 mc_getlocalcopy__deinit (void)
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
;
162 message__deinit (void)
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 ();
193 mc_stat__deinit (void)
195 g_ptr_array_foreach (mc_stat__vpath__captured
, (GFunc
) vfs_path_free
, NULL
);
196 g_ptr_array_free (mc_stat__vpath__captured
, TRUE
);
197 mc_stat__vpath__captured
= NULL
;
200 /* --------------------------------------------------------------------------------------------- */
203 static vfs_path_t
*mc_ungetlocalcopy__pathname_vpath__captured
;
205 static vfs_path_t
*mc_ungetlocalcopy__local_vpath__captured
;
206 /* @ThenReturnValue */
207 static int mc_ungetlocalcopy__return_value
= 0;
211 mc_ungetlocalcopy (const vfs_path_t
* pathname_vpath
, const vfs_path_t
* local_vpath
,
212 gboolean has_changed_ignored
)
214 (void) has_changed_ignored
;
216 mc_ungetlocalcopy__pathname_vpath__captured
= vfs_path_clone (pathname_vpath
);
217 mc_ungetlocalcopy__local_vpath__captured
= vfs_path_clone (local_vpath
);
218 return mc_ungetlocalcopy__return_value
;
222 mc_ungetlocalcopy__init (void)
224 mc_ungetlocalcopy__pathname_vpath__captured
= NULL
;
225 mc_ungetlocalcopy__local_vpath__captured
= NULL
;
229 mc_ungetlocalcopy__deinit (void)
231 vfs_path_free (mc_ungetlocalcopy__pathname_vpath__captured
);
232 vfs_path_free (mc_ungetlocalcopy__local_vpath__captured
);
235 /* --------------------------------------------------------------------------------------------- */
241 str_init_strings (NULL
);
244 vfs_setup_work_dir ();
246 vfs_file_is_local__init ();
248 mc_getlocalcopy__init ();
251 mc_ungetlocalcopy__init ();
254 /* --------------------------------------------------------------------------------------------- */
260 mc_ungetlocalcopy__deinit ();
263 mc_getlocalcopy__deinit ();
264 do_execute__deinit ();
265 vfs_file_is_local__deinit ();
268 str_uninit_strings ();
271 /* --------------------------------------------------------------------------------------------- */