1998-02-27 04:54:42 +00:00
|
|
|
/* Chmod command -- for the Midnight Commander
|
|
|
|
Copyright (C) 1994 Radek Doulik
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2000-08-22 22:50:00 +00:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1998-02-27 04:54:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h> /* For errno on SunOS systems */
|
|
|
|
/* Needed for the extern declarations of integer parameters */
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-09-07 17:52:19 +00:00
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 01:08:30 +00:00
|
|
|
#include "global.h"
|
2002-11-14 07:25:18 +00:00
|
|
|
#include "tty.h" /* A_REVERSE */
|
|
|
|
#include "color.h" /* dialog_colors */
|
|
|
|
#include "dlg.h" /* add_widget() */
|
|
|
|
#include "widget.h" /* NORMAL_BUTTON */
|
|
|
|
#include "dialog.h" /* do_refresh() */
|
|
|
|
#include "wtools.h" /* message() */
|
|
|
|
#include "panel.h" /* do_file_mark() */
|
|
|
|
#include "main.h" /* update_panels() */
|
1998-02-27 04:54:42 +00:00
|
|
|
#include "chmod.h"
|
|
|
|
|
|
|
|
static int single_set;
|
|
|
|
|
|
|
|
#define PX 5
|
|
|
|
#define PY 2
|
|
|
|
|
|
|
|
#define FX 40
|
|
|
|
#define FY 2
|
|
|
|
|
|
|
|
#define BX 6
|
|
|
|
#define BY 17
|
|
|
|
|
|
|
|
#define TX 40
|
|
|
|
#define TY 12
|
|
|
|
|
|
|
|
#define PERMISSIONS 12
|
|
|
|
#define BUTTONS 6
|
|
|
|
|
|
|
|
#define B_MARKED B_USER
|
|
|
|
#define B_ALL B_USER+1
|
|
|
|
#define B_SETMRK B_USER+2
|
|
|
|
#define B_CLRMRK B_USER+3
|
|
|
|
|
2001-07-24 15:04:21 +00:00
|
|
|
static int mode_change, need_update;
|
|
|
|
static int c_file, end_chmod;
|
1998-02-27 04:54:42 +00:00
|
|
|
|
2001-07-24 15:04:21 +00:00
|
|
|
static umode_t and_mask, or_mask, c_stat;
|
|
|
|
static char *c_fname, *c_fown, *c_fgrp;
|
1998-02-27 04:54:42 +00:00
|
|
|
|
|
|
|
static WLabel *statl;
|
|
|
|
|
2001-07-24 15:04:21 +00:00
|
|
|
static struct {
|
1998-02-27 04:54:42 +00:00
|
|
|
mode_t mode;
|
|
|
|
char *text;
|
|
|
|
int selected;
|
|
|
|
WCheck *check;
|
|
|
|
} check_perm[PERMISSIONS] =
|
|
|
|
{
|
1998-03-25 05:16:00 +00:00
|
|
|
{ S_IXOTH, N_("execute/search by others"), 0, 0, },
|
|
|
|
{ S_IWOTH, N_("write by others"), 0, 0, },
|
|
|
|
{ S_IROTH, N_("read by others"), 0, 0, },
|
|
|
|
{ S_IXGRP, N_("execute/search by group"), 0, 0, },
|
|
|
|
{ S_IWGRP, N_("write by group"), 0, 0, },
|
|
|
|
{ S_IRGRP, N_("read by group"), 0, 0, },
|
|
|
|
{ S_IXUSR, N_("execute/search by owner"), 0, 0, },
|
|
|
|
{ S_IWUSR, N_("write by owner"), 0, 0, },
|
|
|
|
{ S_IRUSR, N_("read by owner"), 0, 0, },
|
|
|
|
{ S_ISVTX, N_("sticky bit"), 0, 0, },
|
|
|
|
{ S_ISGID, N_("set group ID on execution"), 0, 0, },
|
|
|
|
{ S_ISUID, N_("set user ID on execution"), 0, 0, },
|
1998-02-27 04:54:42 +00:00
|
|
|
};
|
|
|
|
|
2001-07-24 15:04:21 +00:00
|
|
|
static struct {
|
1998-02-27 04:54:42 +00:00
|
|
|
int ret_cmd, flags, y, x;
|
|
|
|
char *text;
|
|
|
|
} chmod_but[BUTTONS] =
|
|
|
|
{
|
1998-03-25 05:16:00 +00:00
|
|
|
{ B_CANCEL, NORMAL_BUTTON, 2, 33, N_("&Cancel") },
|
|
|
|
{ B_ENTER, DEFPUSH_BUTTON, 2, 17, N_("&Set") },
|
|
|
|
{ B_CLRMRK, NORMAL_BUTTON, 0, 42, N_("C&lear marked") },
|
|
|
|
{ B_SETMRK, NORMAL_BUTTON, 0, 27, N_("S&et marked") },
|
|
|
|
{ B_MARKED, NORMAL_BUTTON, 0, 12, N_("&Marked all") },
|
|
|
|
{ B_ALL, NORMAL_BUTTON, 0, 0, N_("Set &all") },
|
1998-02-27 04:54:42 +00:00
|
|
|
};
|
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
static void chmod_toggle_select (Dlg_head *h)
|
1998-02-27 04:54:42 +00:00
|
|
|
{
|
2002-09-02 18:03:15 +00:00
|
|
|
int Id = h->current->dlg_id - BUTTONS + single_set * 2;
|
1998-02-27 04:54:42 +00:00
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
attrset (COLOR_NORMAL);
|
1998-02-27 04:54:42 +00:00
|
|
|
check_perm[Id].selected ^= 1;
|
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, PY + PERMISSIONS - Id, PX + 1);
|
1998-02-27 04:54:42 +00:00
|
|
|
addch ((check_perm[Id].selected) ? '*' : ' ');
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, PY + PERMISSIONS - Id, PX + 3);
|
1998-02-27 04:54:42 +00:00
|
|
|
}
|
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
static void chmod_refresh (Dlg_head *h)
|
1998-02-27 04:54:42 +00:00
|
|
|
{
|
2002-09-02 18:03:15 +00:00
|
|
|
common_dialog_repaint (h);
|
|
|
|
|
1998-02-27 04:54:42 +00:00
|
|
|
attrset (COLOR_NORMAL);
|
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
draw_box (h, PY, PX, PERMISSIONS + 2, 33);
|
|
|
|
draw_box (h, FY, FX, 10, 25);
|
1998-02-27 04:54:42 +00:00
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, FY + 1, FX + 2);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("Name"));
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, FY + 3, FX + 2);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("Permissions (Octal)"));
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, FY + 5, FX + 2);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("Owner name"));
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, FY + 7, FX + 2);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("Group name"));
|
1998-02-27 04:54:42 +00:00
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, TY, TX);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("Use SPACE to change"));
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, TY + 1, TX);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("an option, ARROW KEYS"));
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, TY + 2, TX);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("to move between options"));
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_move (h, TY + 3, TX);
|
1998-03-25 05:16:00 +00:00
|
|
|
addstr (_("and T or INS to mark"));
|
2002-09-02 18:03:15 +00:00
|
|
|
|
|
|
|
attrset (COLOR_HOT_NORMAL);
|
|
|
|
|
|
|
|
dlg_move (h, PY, PX + 1);
|
|
|
|
addstr (_(" Permission "));
|
|
|
|
dlg_move (h, FY, FX + 1);
|
|
|
|
addstr (_(" File "));
|
1998-02-27 04:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int chmod_callback (Dlg_head *h, int Par, int Msg)
|
|
|
|
{
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 01:08:30 +00:00
|
|
|
char buffer [BUF_TINY];
|
1998-02-27 04:54:42 +00:00
|
|
|
|
|
|
|
switch (Msg) {
|
|
|
|
case DLG_ACTION:
|
|
|
|
if (Par >= BUTTONS - single_set * 2){
|
|
|
|
c_stat ^= check_perm[Par - BUTTONS + single_set * 2].mode;
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 01:08:30 +00:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
|
1998-02-27 04:54:42 +00:00
|
|
|
label_set_text (statl, buffer);
|
2002-09-02 18:03:15 +00:00
|
|
|
chmod_toggle_select (h);
|
1998-02-27 04:54:42 +00:00
|
|
|
mode_change = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLG_KEY:
|
|
|
|
if ((Par == 'T' || Par == 't' || Par == KEY_IC) &&
|
2002-09-02 18:03:15 +00:00
|
|
|
h->current->dlg_id >= BUTTONS - single_set * 2) {
|
|
|
|
chmod_toggle_select (h);
|
1998-02-27 04:54:42 +00:00
|
|
|
if (Par == KEY_IC)
|
2002-09-02 18:03:15 +00:00
|
|
|
dlg_one_down (h);
|
1998-02-27 04:54:42 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
2001-06-05 16:41:44 +00:00
|
|
|
|
1998-02-27 04:54:42 +00:00
|
|
|
case DLG_DRAW:
|
2002-09-02 18:03:15 +00:00
|
|
|
chmod_refresh (h);
|
1998-02-27 04:54:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-13 04:01:04 +00:00
|
|
|
static Dlg_head *
|
2002-09-02 18:03:15 +00:00
|
|
|
init_chmod (void)
|
1998-02-27 04:54:42 +00:00
|
|
|
{
|
|
|
|
int i;
|
2002-09-02 18:03:15 +00:00
|
|
|
Dlg_head *ch_dlg;
|
1998-02-27 04:54:42 +00:00
|
|
|
|
|
|
|
do_refresh ();
|
|
|
|
end_chmod = c_file = need_update = 0;
|
|
|
|
single_set = (cpanel->marked < 2) ? 2 : 0;
|
|
|
|
|
2002-09-02 18:03:15 +00:00
|
|
|
ch_dlg =
|
|
|
|
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
|
2002-09-03 07:42:36 +00:00
|
|
|
chmod_callback, "[Chmod]", _("Chmod command"),
|
|
|
|
DLG_CENTER);
|
1998-02-27 04:54:42 +00:00
|
|
|
|
|
|
|
for (i = 0; i < BUTTONS; i++) {
|
|
|
|
if (i == 2 && single_set)
|
|
|
|
break;
|
|
|
|
else
|
2002-09-02 18:03:15 +00:00
|
|
|
add_widget (ch_dlg,
|
|
|
|
button_new (BY + chmod_but[i].y - single_set,
|
|
|
|
BX + chmod_but[i].x,
|
|
|
|
chmod_but[i].ret_cmd,
|
|
|
|
chmod_but[i].flags,
|
2003-09-01 00:18:37 +00:00
|
|
|
_(chmod_but[i].text), 0, 0));
|
1998-02-27 04:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < PERMISSIONS; i++) {
|
2002-09-02 18:03:15 +00:00
|
|
|
check_perm[i].check =
|
|
|
|
check_new (PY + (PERMISSIONS - i), PX + 2, 0,
|
2003-09-01 00:18:37 +00:00
|
|
|
_(check_perm[i].text));
|
1998-02-27 04:54:42 +00:00
|
|
|
add_widget (ch_dlg, check_perm[i].check);
|
|
|
|
}
|
2002-09-02 18:03:15 +00:00
|
|
|
|
|
|
|
return ch_dlg;
|
1998-02-27 04:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int stat_file (char *filename, struct stat *st)
|
|
|
|
{
|
|
|
|
if (mc_stat (filename, st))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void chmod_done (void)
|
|
|
|
{
|
|
|
|
if (need_update)
|
1998-04-30 03:21:52 +00:00
|
|
|
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
1998-02-27 04:54:42 +00:00
|
|
|
repaint_screen ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *next_file (void)
|
|
|
|
{
|
|
|
|
while (!cpanel->dir.list[c_file].f.marked)
|
|
|
|
c_file++;
|
|
|
|
|
|
|
|
return cpanel->dir.list[c_file].fname;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_chmod (struct stat *sf)
|
|
|
|
{
|
|
|
|
sf->st_mode &= and_mask;
|
|
|
|
sf->st_mode |= or_mask;
|
|
|
|
if (mc_chmod (cpanel->dir.list [c_file].fname, sf->st_mode) == -1)
|
2002-12-08 01:12:18 +00:00
|
|
|
message (1, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
|
1998-02-27 04:54:42 +00:00
|
|
|
cpanel->dir.list [c_file].fname, unix_error_string (errno));
|
|
|
|
|
|
|
|
do_file_mark (cpanel, c_file, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_mask (struct stat *sf)
|
|
|
|
{
|
|
|
|
char *fname;
|
|
|
|
|
|
|
|
need_update = end_chmod = 1;
|
|
|
|
do_chmod (sf);
|
|
|
|
|
|
|
|
do {
|
|
|
|
fname = next_file ();
|
|
|
|
if (!stat_file (fname, sf))
|
|
|
|
return;
|
|
|
|
c_stat = sf->st_mode;
|
|
|
|
|
|
|
|
do_chmod (sf);
|
|
|
|
} while (cpanel->marked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void chmod_cmd (void)
|
|
|
|
{
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 01:08:30 +00:00
|
|
|
char buffer [BUF_TINY];
|
1998-02-27 04:54:42 +00:00
|
|
|
char *fname;
|
|
|
|
int i;
|
|
|
|
struct stat sf_stat;
|
2002-09-02 18:03:15 +00:00
|
|
|
Dlg_head *ch_dlg;
|
1998-02-27 04:54:42 +00:00
|
|
|
|
|
|
|
do { /* do while any files remaining */
|
2002-09-02 18:03:15 +00:00
|
|
|
ch_dlg = init_chmod ();
|
1998-02-27 04:54:42 +00:00
|
|
|
if (cpanel->marked)
|
|
|
|
fname = next_file (); /* next marked file */
|
|
|
|
else
|
|
|
|
fname = selection (cpanel)->fname; /* single file */
|
|
|
|
|
|
|
|
if (!stat_file (fname, &sf_stat)){ /* get status of file */
|
|
|
|
destroy_dlg (ch_dlg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
c_stat = sf_stat.st_mode;
|
|
|
|
mode_change = 0; /* clear changes flag */
|
|
|
|
|
|
|
|
/* set check buttons */
|
|
|
|
for (i = 0; i < PERMISSIONS; i++){
|
|
|
|
check_perm[i].check->state = (c_stat & check_perm[i].mode) ? 1 : 0;
|
|
|
|
check_perm[i].selected = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the labels */
|
|
|
|
c_fname = name_trunc (fname, 21);
|
2003-09-01 00:18:37 +00:00
|
|
|
add_widget (ch_dlg, label_new (FY+2, FX+2, c_fname));
|
1998-02-27 04:54:42 +00:00
|
|
|
c_fown = name_trunc (get_owner (sf_stat.st_uid), 21);
|
2003-09-01 00:18:37 +00:00
|
|
|
add_widget (ch_dlg, label_new (FY+6, FX+2, c_fown));
|
1998-02-27 04:54:42 +00:00
|
|
|
c_fgrp = name_trunc (get_group (sf_stat.st_gid), 21);
|
2003-09-01 00:18:37 +00:00
|
|
|
add_widget (ch_dlg, label_new (FY+8, FX+2, c_fgrp));
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 01:08:30 +00:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
|
2003-09-01 00:18:37 +00:00
|
|
|
statl = label_new (FY+4, FX+2, buffer);
|
1998-02-27 04:54:42 +00:00
|
|
|
add_widget (ch_dlg, statl);
|
|
|
|
|
|
|
|
run_dlg (ch_dlg); /* retrieve an action */
|
|
|
|
|
|
|
|
/* do action */
|
|
|
|
switch (ch_dlg->ret_value){
|
|
|
|
case B_ENTER:
|
|
|
|
if (mode_change)
|
|
|
|
if (mc_chmod (fname, c_stat) == -1)
|
2002-12-08 01:12:18 +00:00
|
|
|
message (1, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
|
1998-02-27 04:54:42 +00:00
|
|
|
fname, unix_error_string (errno));
|
|
|
|
need_update = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_CANCEL:
|
|
|
|
end_chmod = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_ALL:
|
|
|
|
case B_MARKED:
|
|
|
|
and_mask = or_mask = 0;
|
|
|
|
and_mask = ~and_mask;
|
|
|
|
|
|
|
|
for (i = 0; i < PERMISSIONS; i++) {
|
1999-05-03 18:57:48 +00:00
|
|
|
if (check_perm[i].selected || ch_dlg->ret_value == B_ALL) {
|
1998-02-27 04:54:42 +00:00
|
|
|
if (check_perm[i].check->state & C_BOOL)
|
|
|
|
or_mask |= check_perm[i].mode;
|
|
|
|
else
|
|
|
|
and_mask &= ~check_perm[i].mode;
|
1999-05-03 18:57:48 +00:00
|
|
|
}
|
1998-02-27 04:54:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
apply_mask (&sf_stat);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_SETMRK:
|
|
|
|
and_mask = or_mask = 0;
|
|
|
|
and_mask = ~and_mask;
|
|
|
|
|
|
|
|
for (i = 0; i < PERMISSIONS; i++) {
|
|
|
|
if (check_perm[i].selected)
|
|
|
|
or_mask |= check_perm[i].mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_mask (&sf_stat);
|
|
|
|
break;
|
|
|
|
case B_CLRMRK:
|
|
|
|
and_mask = or_mask = 0;
|
|
|
|
and_mask = ~and_mask;
|
|
|
|
|
|
|
|
for (i = 0; i < PERMISSIONS; i++) {
|
|
|
|
if (check_perm[i].selected)
|
|
|
|
and_mask &= ~check_perm[i].mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_mask (&sf_stat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpanel->marked && ch_dlg->ret_value!=B_CANCEL) {
|
|
|
|
do_file_mark (cpanel, c_file, 0);
|
|
|
|
need_update = 1;
|
|
|
|
}
|
|
|
|
destroy_dlg (ch_dlg);
|
|
|
|
} while (cpanel->marked && !end_chmod);
|
|
|
|
chmod_done ();
|
|
|
|
}
|
|
|
|
|