Added two macro examples:
[zuwinko.git] / src / filemanager / fileopctx.c
blobd12e18f00ba3d86e617f5c9a537bbd9058837c2c
1 /* File operation contexts for the Midnight Commander
3 Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2007
4 Free Software Foundation, Inc.
6 Authors: Federico Mena <federico@nuclecu.unam.mx>
7 Miguel de Icaza <miguel@nuclecu.unam.mx>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 /** \file fileopctx.c
25 * \brief Source: file operation contexts
26 * \date 1998-2007
27 * \author Federico Mena <federico@nuclecu.unam.mx>
28 * \author Miguel de Icaza <miguel@nuclecu.unam.mx>
31 #include <config.h>
33 #include <unistd.h>
35 #include "lib/global.h"
36 #include "fileopctx.h"
37 #include "filegui.h"
38 #include "lib/search.h"
39 #include "lib/vfs/mc-vfs/vfs.h"
41 /*** global variables ****************************************************************************/
43 /*** file scope macro definitions ****************************************************************/
45 /*** file scope type declarations ****************************************************************/
47 /*** file scope variables ************************************************************************/
49 /*** file scope functions ************************************************************************/
50 /* --------------------------------------------------------------------------------------------- */
52 /* --------------------------------------------------------------------------------------------- */
53 /*** public functions ****************************************************************************/
54 /* --------------------------------------------------------------------------------------------- */
56 /**
57 * \fn FileOpContext * file_op_context_new (FileOperation op)
58 * \param op file operation struct
59 * \return The newly-created context, filled with the default file mask values.
61 * Creates a new file operation context with the default values. If you later want
62 * to have a user interface for this, call file_op_context_create_ui().
65 FileOpContext *
66 file_op_context_new (FileOperation op)
68 FileOpContext *ctx;
70 ctx = g_new0 (FileOpContext, 1);
71 ctx->operation = op;
72 ctx->eta_secs = 0.0;
73 ctx->progress_bytes = 0;
74 ctx->op_preserve = TRUE;
75 ctx->do_reget = 1;
76 ctx->stat_func = mc_lstat;
77 ctx->preserve = TRUE;
78 ctx->preserve_uidgid = (geteuid () == 0);
79 ctx->umask_kill = 0777777;
80 ctx->erase_at_end = TRUE;
82 return ctx;
85 /* --------------------------------------------------------------------------------------------- */
86 /**
87 * \fn void file_op_context_destroy (FileOpContext *ctx)
88 * \param ctx The file operation context to destroy.
90 * Destroys the specified file operation context and its associated UI data, if
91 * it exists.
94 void
95 file_op_context_destroy (FileOpContext * ctx)
97 g_return_if_fail (ctx != NULL);
99 file_op_context_destroy_ui (ctx);
100 mc_search_free (ctx->search_handle);
101 /** \todo FIXME: do we need to free ctx->dest_mask? */
102 g_free (ctx);
105 /* --------------------------------------------------------------------------------------------- */
107 FileOpTotalContext *
108 file_op_total_context_new (void)
110 FileOpTotalContext *tctx;
111 tctx = g_new0 (FileOpTotalContext, 1);
112 tctx->ask_overwrite = TRUE;
113 tctx->is_toplevel_file = TRUE;
114 return tctx;
117 /* --------------------------------------------------------------------------------------------- */
119 void
120 file_op_total_context_destroy (FileOpTotalContext * tctx)
122 g_free (tctx);
125 /* --------------------------------------------------------------------------------------------- */