root/src/filemanager/chattr.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. chattr_is_modifiable
  2. chattr_fill_str
  3. fileattrtext_fill
  4. fileattrtext_callback
  5. fileattrtext_new
  6. chattr_draw_select
  7. chattr_toggle_select
  8. chattrboxes_draw_scrollbar
  9. chattrboxes_draw
  10. chattrboxes_rename
  11. checkboxes_save_state
  12. chattrboxes_down
  13. chattrboxes_page_down
  14. chattrboxes_end
  15. chattrboxes_up
  16. chattrboxes_page_up
  17. chattrboxes_home
  18. chattrboxes_execute_cmd
  19. chattrboxes_key
  20. chattrboxes_callback
  21. chattrboxes_handle_mouse_event
  22. chattrboxes_mouse_callback
  23. chattrboxes_new
  24. chattr_init
  25. chattr_dlg_create
  26. chattr_done
  27. next_file
  28. try_chattr
  29. do_chattr
  30. chattr_apply_mask
  31. chattr_cmd
  32. chattr_get_as_str

   1 /*
   2    Chattr command -- for the Midnight Commander
   3 
   4    Copyright (C) 2020
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Andrew Borodin <aborodin@vmail.ru>, 2020
   9 
  10    This file is part of the Midnight Commander.
  11 
  12    The Midnight Commander is free software: you can redistribute it
  13    and/or modify it under the terms of the GNU General Public License as
  14    published by the Free Software Foundation, either version 3 of the License,
  15    or (at your option) any later version.
  16 
  17    The Midnight Commander is distributed in the hope that it will be useful,
  18    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20    GNU General Public License for more details.
  21 
  22    You should have received a copy of the GNU General Public License
  23    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  24  */
  25 
  26 /** \file chattr.c
  27  *  \brief Source: chattr command
  28  */
  29 
  30 /* TODO: change attributes recursively (ticket #3109) */
  31 
  32 #include <config.h>
  33 
  34 #include <errno.h>
  35 #include <sys/types.h>
  36 #include <sys/stat.h>
  37 
  38 #include <e2p/e2p.h>
  39 #include <ext2fs/ext2_fs.h>
  40 
  41 #include "lib/global.h"
  42 
  43 #include "lib/tty/tty.h"        /* tty_print*() */
  44 #include "lib/tty/color.h"      /* tty_setcolor() */
  45 #include "lib/skin.h"           /* COLOR_NORMAL, DISABLED_COLOR */
  46 #include "lib/vfs/vfs.h"
  47 #include "lib/widget.h"
  48 
  49 #include "src/keybind-defaults.h"       /* chattr_map */
  50 
  51 #include "midnight.h"           /* current_panel */
  52 #include "panel.h"              /* do_file_mark() */
  53 
  54 #include "chattr.h"
  55 
  56 /*** global variables ****************************************************************************/
  57 
  58 /*** file scope macro definitions ****************************************************************/
  59 
  60 #define B_MARKED B_USER
  61 #define B_SETALL (B_USER + 1)
  62 #define B_SETMRK (B_USER + 2)
  63 #define B_CLRMRK (B_USER + 3)
  64 
  65 #define BUTTONS  6
  66 
  67 #define CHATTRBOXES(x) ((WChattrBoxes *)(x))
  68 
  69 /*** file scope type declarations ****************************************************************/
  70 
  71 typedef struct WFileAttrText WFileAttrText;
  72 
  73 struct WFileAttrText
  74 {
  75     Widget widget;              /* base class */
  76 
  77     char *filename;
  78     int filename_width;         /* cached width of file name */
  79     char attrs[32 + 1];         /* 32 bits in attributes (unsigned long) */
  80 };
  81 
  82 typedef struct WChattrBoxes WChattrBoxes;
  83 
  84 struct WChattrBoxes
  85 {
  86     WGroup base;                /* base class */
  87 
  88     int pos;                    /* The current checkbox selected */
  89     int top;                    /* The first flag displayed */
  90 };
  91 
  92 /*** file scope variables ************************************************************************/
  93 
  94 /* see /usr/include/ext2fs/ext2_fs.h
  95  *
  96  * EXT2_SECRM_FL            0x00000001 -- Secure deletion
  97  * EXT2_UNRM_FL             0x00000002 -- Undelete
  98  * EXT2_COMPR_FL            0x00000004 -- Compress file
  99  * EXT2_SYNC_FL             0x00000008 -- Synchronous updates
 100  * EXT2_IMMUTABLE_FL        0x00000010 -- Immutable file
 101  * EXT2_APPEND_FL           0x00000020 -- writes to file may only append
 102  * EXT2_NODUMP_FL           0x00000040 -- do not dump file
 103  * EXT2_NOATIME_FL          0x00000080 -- do not update atime
 104  * * Reserved for compression usage...
 105  * EXT2_DIRTY_FL            0x00000100
 106  * EXT2_COMPRBLK_FL         0x00000200 -- One or more compressed clusters
 107  * EXT2_NOCOMPR_FL          0x00000400 -- Access raw compressed data
 108  * * nb: was previously EXT2_ECOMPR_FL
 109  * EXT4_ENCRYPT_FL          0x00000800 -- encrypted inode
 110  * * End compression flags --- maybe not all used
 111  * EXT2_BTREE_FL            0x00001000 -- btree format dir
 112  * EXT2_INDEX_FL            0x00001000 -- hash-indexed directory
 113  * EXT2_IMAGIC_FL           0x00002000
 114  * EXT3_JOURNAL_DATA_FL     0x00004000 -- file data should be journaled
 115  * EXT2_NOTAIL_FL           0x00008000 -- file tail should not be merged
 116  * EXT2_DIRSYNC_FL          0x00010000 -- Synchronous directory modifications
 117  * EXT2_TOPDIR_FL           0x00020000 -- Top of directory hierarchies
 118  * EXT4_HUGE_FILE_FL        0x00040000 -- Set to each huge file
 119  * EXT4_EXTENTS_FL          0x00080000 -- Inode uses extents
 120  * EXT4_VERITY_FL           0x00100000 -- Verity protected inode
 121  * EXT4_EA_INODE_FL         0x00200000 -- Inode used for large EA
 122  * EXT4_EOFBLOCKS_FL        0x00400000 was here, unused
 123  * FS_NOCOW_FL              0x00800000 -- Do not cow file
 124  * EXT4_SNAPFILE_FL         0x01000000 -- Inode is a snapshot
 125  *                          0x02000000 -- unused yet
 126  * EXT4_SNAPFILE_DELETED_FL 0x04000000 -- Snapshot is being deleted
 127  * EXT4_SNAPFILE_SHRUNK_FL  0x08000000 -- Snapshot shrink has completed
 128  * EXT4_INLINE_DATA_FL      0x10000000 -- Inode has inline data
 129  * EXT4_PROJINHERIT_FL      0x20000000 -- Create with parents projid
 130  * EXT4_CASEFOLD_FL         0x40000000 -- Casefolded file
 131  *                          0x80000000 -- unused yet
 132  */
 133 
 134 static struct
 135 {
 136     unsigned long flags;
 137     char attr;
 138     const char *text;
 139     gboolean selected;
 140     gboolean state;             /* state of checkboxes */
 141 } check_attr[] =
 142 {
 143     /* *INDENT-OFF* */
 144     { EXT2_SECRM_FL,        's', N_("Secure deletion"),               FALSE, FALSE },
 145     { EXT2_UNRM_FL,         'u', N_("Undelete"),                      FALSE, FALSE },
 146     { EXT2_SYNC_FL,         'S', N_("Synchronous updates"),           FALSE, FALSE },
 147     { EXT2_DIRSYNC_FL,      'D', N_("Synchronous directory updates"), FALSE, FALSE },
 148     { EXT2_IMMUTABLE_FL,    'i', N_("Immutable"),                     FALSE, FALSE },
 149     { EXT2_APPEND_FL,       'a', N_("Append only"),                   FALSE, FALSE },
 150     { EXT2_NODUMP_FL,       'd', N_("No dump"),                       FALSE, FALSE },
 151     { EXT2_NOATIME_FL,      'A', N_("No update atime"),               FALSE, FALSE },
 152     { EXT2_COMPR_FL,        'c', N_("Compress"),                      FALSE, FALSE },
 153 #ifdef EXT2_COMPRBLK_FL
 154     /* removed in v1.43-WIP-2015-05-18
 155        ext2fsprogs 4a05268cf86f7138c78d80a53f7e162f32128a3d 2015-04-12 */
 156     { EXT2_COMPRBLK_FL,     'B', N_("Compressed clusters"),           FALSE, FALSE },
 157 #endif
 158 #ifdef EXT2_DIRTY_FL
 159     /* removed in v1.43-WIP-2015-05-18
 160        ext2fsprogs 4a05268cf86f7138c78d80a53f7e162f32128a3d 2015-04-12 */
 161     { EXT2_DIRTY_FL,        'Z', N_("Compressed dirty file"),         FALSE, FALSE },
 162 #endif
 163 #ifdef EXT2_NOCOMPR_FL
 164     /* removed in v1.43-WIP-2015-05-18
 165        ext2fsprogs 4a05268cf86f7138c78d80a53f7e162f32128a3d 2015-04-12 */
 166     { EXT2_NOCOMPR_FL,      'X', N_("Compression raw access"),        FALSE, FALSE },
 167 #endif
 168 #ifdef EXT4_ENCRYPT_FL
 169     { EXT4_ENCRYPT_FL,      'E', N_("Encrypted inode"),               FALSE, FALSE },
 170 #endif
 171     { EXT3_JOURNAL_DATA_FL, 'j', N_("Journaled data"),                FALSE, FALSE },
 172     { EXT2_INDEX_FL,        'I', N_("Indexed directory"),             FALSE, FALSE },
 173     { EXT2_NOTAIL_FL,       't', N_("No tail merging"),               FALSE, FALSE },
 174     { EXT2_TOPDIR_FL,       'T', N_("Top of directory hierarchies"),  FALSE, FALSE },
 175     { EXT4_EXTENTS_FL,      'e', N_("Inode uses extents"),            FALSE, FALSE },
 176 #ifdef EXT4_HUGE_FILE_FL
 177     /* removed in v1.43.9
 178        ext2fsprogs 4825daeb0228e556444d199274b08c499ac3706c 2018-02-06 */
 179     { EXT4_HUGE_FILE_FL,    'h', N_("Huge_file"),                     FALSE, FALSE },
 180 #endif
 181     { FS_NOCOW_FL,          'C', N_("No COW"),                        FALSE, FALSE },
 182 #ifdef EXT4_CASEFOLD_FL
 183     /* added in v1.45.0
 184        ext2fsprogs 1378bb6515e98a27f0f5c220381d49d20544204e 2018-12-01 */
 185     { EXT4_CASEFOLD_FL,     'F', N_("Casefolded file"),               FALSE, FALSE },
 186 #endif
 187 #ifdef EXT4_INLINE_DATA_FL
 188     { EXT4_INLINE_DATA_FL,  'N', N_("Inode has inline data"),         FALSE, FALSE },
 189 #endif
 190 #ifdef EXT4_PROJINHERIT_FL
 191     /* added in v1.43-WIP-2016-05-12
 192        ext2fsprogs e1cec4464bdaf93ea609de43c5cdeb6a1f553483 2016-03-07
 193                    97d7e2fdb2ebec70c3124c1a6370d28ec02efad0 2016-05-09 */
 194     { EXT4_PROJINHERIT_FL,  'P', N_("Project hierarchy"),             FALSE, FALSE },
 195 #endif
 196 #ifdef EXT4_VERITY_FL
 197     /* added in v1.44.4
 198        ext2fsprogs faae7aa00df0abe7c6151fc4947aa6501b981ee1 2018-08-14
 199        v1.44.5
 200        ext2fsprogs 7e5a95e3d59719361661086ec7188ca6e674f139 2018-08-21 */
 201     { EXT4_VERITY_FL,       'V', N_("Verity protected inode"),        FALSE, FALSE }
 202 #endif
 203     /* *INDENT-ON* */
 204 };
 205 
 206 /* number of attributes */
 207 static const size_t check_attr_num = G_N_ELEMENTS (check_attr);
 208 
 209 /* modifable attribute numbers */
 210 static int check_attr_mod[32];
 211 static int check_attr_mod_num = 0;      /* 0..31 */
 212 
 213 /* maximum width of attribute text */
 214 static int check_attr_width = 0;
 215 
 216 static struct
 217 {
 218     int ret_cmd;
 219     button_flags_t flags;
 220     int width;
 221     const char *text;
 222     Widget *button;
 223 } chattr_but[BUTTONS] =
 224 {
 225     /* *INDENT-OFF* */
 226     /* 0 */ { B_SETALL, NORMAL_BUTTON, 0, N_("Set &all"),      NULL },
 227     /* 1 */ { B_MARKED, NORMAL_BUTTON, 0, N_("&Marked all"),   NULL },
 228     /* 2 */ { B_SETMRK, NORMAL_BUTTON, 0, N_("S&et marked"),   NULL },
 229     /* 3 */ { B_CLRMRK, NORMAL_BUTTON, 0, N_("C&lear marked"), NULL },
 230     /* 4 */ { B_ENTER, DEFPUSH_BUTTON, 0, N_("&Set"),          NULL },
 231     /* 5 */ { B_CANCEL, NORMAL_BUTTON, 0, N_("&Cancel"),       NULL }
 232     /* *INDENT-ON* */
 233 };
 234 
 235 static gboolean flags_changed;
 236 static int current_file;
 237 static gboolean ignore_all;
 238 
 239 static unsigned long and_mask, or_mask, flags;
 240 
 241 static WFileAttrText *file_attr;
 242 
 243 /* x-coord of widget in the dialog */
 244 static const int wx = 3;
 245 
 246 /* --------------------------------------------------------------------------------------------- */
 247 /*** file scope functions ************************************************************************/
 248 /* --------------------------------------------------------------------------------------------- */
 249 
 250 static inline gboolean
 251 chattr_is_modifiable (size_t i)
     /* [previous][next][first][last][top][bottom][index][help]  */
 252 {
 253     return ((check_attr[i].flags & EXT2_FL_USER_MODIFIABLE) != 0);
 254 }
 255 
 256 /* --------------------------------------------------------------------------------------------- */
 257 
 258 static void
 259 chattr_fill_str (unsigned long attr, char *str)
     /* [previous][next][first][last][top][bottom][index][help]  */
 260 {
 261     size_t i;
 262 
 263     for (i = 0; i < check_attr_num; i++)
 264         str[i] = (attr & check_attr[i].flags) != 0 ? check_attr[i].attr : '-';
 265 
 266     str[check_attr_num] = '\0';
 267 }
 268 
 269 /* --------------------------------------------------------------------------------------------- */
 270 
 271 static void
 272 fileattrtext_fill (WFileAttrText * fat, unsigned long attr)
     /* [previous][next][first][last][top][bottom][index][help]  */
 273 {
 274     chattr_fill_str (attr, fat->attrs);
 275     widget_draw (WIDGET (fat));
 276 }
 277 
 278 /* --------------------------------------------------------------------------------------------- */
 279 
 280 static cb_ret_t
 281 fileattrtext_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 282 {
 283     WFileAttrText *fat = (WFileAttrText *) w;
 284 
 285     switch (msg)
 286     {
 287     case MSG_DRAW:
 288         {
 289             int color;
 290             size_t i;
 291 
 292             color = COLOR_NORMAL;
 293             tty_setcolor (color);
 294 
 295             if (w->cols > fat->filename_width)
 296             {
 297                 widget_gotoyx (w, 0, (w->cols - fat->filename_width) / 2);
 298                 tty_print_string (fat->filename);
 299             }
 300             else
 301             {
 302                 widget_gotoyx (w, 0, 0);
 303                 tty_print_string (str_trunc (fat->filename, w->cols));
 304             }
 305 
 306             /* hope that w->cols is greater than check_attr_num */
 307             widget_gotoyx (w, 1, (w->cols - check_attr_num) / 2);
 308             for (i = 0; i < check_attr_num; i++)
 309             {
 310                 /* Do not set new color for each symbol. Try to use previous color. */
 311                 if (chattr_is_modifiable (i))
 312                 {
 313                     if (color == DISABLED_COLOR)
 314                     {
 315                         color = COLOR_NORMAL;
 316                         tty_setcolor (color);
 317                     }
 318                 }
 319                 else
 320                 {
 321                     if (color != DISABLED_COLOR)
 322                     {
 323                         color = DISABLED_COLOR;
 324                         tty_setcolor (color);
 325                     }
 326                 }
 327 
 328                 tty_print_char (fat->attrs[i]);
 329             }
 330             return MSG_HANDLED;
 331         }
 332 
 333     case MSG_RESIZE:
 334         {
 335             Widget *wo = WIDGET (w->owner);
 336 
 337             widget_default_callback (w, sender, msg, parm, data);
 338             /* intially file name may be wider than screen */
 339             if (fat->filename_width > wo->cols - wx * 2)
 340             {
 341                 w->x = wo->x + wx;
 342                 w->cols = wo->cols - wx * 2;
 343             }
 344             return MSG_HANDLED;
 345         }
 346 
 347     case MSG_DESTROY:
 348         g_free (fat->filename);
 349         return MSG_HANDLED;
 350 
 351     default:
 352         return widget_default_callback (w, sender, msg, parm, data);
 353     }
 354 }
 355 
 356 /* --------------------------------------------------------------------------------------------- */
 357 
 358 static WFileAttrText *
 359 fileattrtext_new (int y, int x, const char *filename, unsigned long attr)
     /* [previous][next][first][last][top][bottom][index][help]  */
 360 {
 361     WFileAttrText *fat;
 362     int width, cols;
 363 
 364     width = str_term_width1 (filename);
 365     cols = MAX (width, (int) check_attr_num);
 366 
 367     fat = g_new (WFileAttrText, 1);
 368     widget_init (WIDGET (fat), y, x, 2, cols, fileattrtext_callback, NULL);
 369 
 370     fat->filename = g_strdup (filename);
 371     fat->filename_width = width;
 372     fileattrtext_fill (fat, attr);
 373 
 374     return fat;
 375 }
 376 
 377 /* --------------------------------------------------------------------------------------------- */
 378 
 379 static void
 380 chattr_draw_select (const Widget * w, gboolean selected)
     /* [previous][next][first][last][top][bottom][index][help]  */
 381 {
 382     widget_gotoyx (w, 0, -1);
 383     tty_print_char (selected ? '*' : ' ');
 384     widget_gotoyx (w, 0, 1);
 385 }
 386 
 387 /* --------------------------------------------------------------------------------------------- */
 388 
 389 static void
 390 chattr_toggle_select (const WChattrBoxes * cb, int Id)
     /* [previous][next][first][last][top][bottom][index][help]  */
 391 {
 392     Widget *w;
 393 
 394     /* find checkbox */
 395     w = WIDGET (g_list_nth_data (GROUP (cb)->widgets, Id - cb->top));
 396 
 397     check_attr[Id].selected = !check_attr[Id].selected;
 398 
 399     tty_setcolor (COLOR_NORMAL);
 400     chattr_draw_select (w, check_attr[Id].selected);
 401 }
 402 
 403 /* --------------------------------------------------------------------------------------------- */
 404 
 405 static inline void
 406 chattrboxes_draw_scrollbar (const WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 407 {
 408     const Widget *w = CONST_WIDGET (cb);
 409     int max_line;
 410     int line;
 411     int i;
 412 
 413     /* Are we at the top? */
 414     widget_gotoyx (w, 0, w->cols);
 415     if (cb->top == 0)
 416         tty_print_one_vline (TRUE);
 417     else
 418         tty_print_char ('^');
 419 
 420     max_line = w->lines - 1;
 421 
 422     /* Are we at the bottom? */
 423     widget_gotoyx (w, max_line, w->cols);
 424     if (cb->top + w->lines == check_attr_mod_num || w->lines >= check_attr_mod_num)
 425         tty_print_one_vline (TRUE);
 426     else
 427         tty_print_char ('v');
 428 
 429     /* Now draw the nice relative pointer */
 430     line = 1 + (cb->pos * (w->lines - 2)) / check_attr_mod_num;
 431 
 432     for (i = 1; i < max_line; i++)
 433     {
 434         widget_gotoyx (w, i, w->cols);
 435         if (i != line)
 436             tty_print_one_vline (TRUE);
 437         else
 438             tty_print_char ('*');
 439     }
 440 }
 441 
 442 /* --------------------------------------------------------------------------------------------- */
 443 
 444 static void
 445 chattrboxes_draw (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 446 {
 447     Widget *w = WIDGET (cb);
 448     int i;
 449     GList *l;
 450     const int *colors;
 451 
 452     colors = widget_get_colors (w);
 453     tty_setcolor (colors[DLG_COLOR_NORMAL]);
 454     tty_fill_region (w->y, w->x - 1, w->lines, w->cols + 1, ' ');
 455 
 456     /* redraw checkboxes */
 457     group_default_callback (w, NULL, MSG_DRAW, 0, NULL);
 458 
 459     /* draw scrollbar */
 460     tty_setcolor (colors[DLG_COLOR_NORMAL]);
 461     if (!mc_global.tty.slow_terminal && check_attr_mod_num > w->lines)
 462         chattrboxes_draw_scrollbar (cb);
 463 
 464     /* mark selected checkboxes */
 465     for (i = cb->top, l = GROUP (cb)->widgets; l != NULL; i++, l = g_list_next (l))
 466         chattr_draw_select (WIDGET (l->data), check_attr[i].selected);
 467 }
 468 
 469 /* --------------------------------------------------------------------------------------------- */
 470 
 471 static void
 472 chattrboxes_rename (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 473 {
 474     Widget *w = WIDGET (cb);
 475     gboolean active;
 476     int i;
 477     GList *l;
 478     char btext[BUF_SMALL];      /* FIXME: is 128 bytes enough? */
 479 
 480     active = widget_get_state (w, WST_ACTIVE);
 481 
 482     /* lock the group to avoid redraw of checkboxes individually */
 483     if (active)
 484         widget_set_state (w, WST_SUSPENDED, TRUE);
 485 
 486     for (i = cb->top, l = GROUP (cb)->widgets; l != NULL; i++, l = g_list_next (l))
 487     {
 488         WCheck *c = CHECK (l->data);
 489         int m;
 490 
 491         m = check_attr_mod[i];
 492         g_snprintf (btext, sizeof (btext), "(%c) %s", check_attr[m].attr, check_attr[m].text);
 493         check_set_text (c, btext);
 494         c->state = check_attr[m].state;
 495     }
 496 
 497     /* unlock */
 498     if (active)
 499         widget_set_state (w, WST_ACTIVE, TRUE);
 500 
 501     widget_draw (w);
 502 }
 503 
 504 /* --------------------------------------------------------------------------------------------- */
 505 
 506 static void
 507 checkboxes_save_state (const WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 508 {
 509     int i;
 510     GList *l;
 511 
 512     for (i = cb->top, l = GROUP (cb)->widgets; l != NULL; i++, l = g_list_next (l))
 513     {
 514         int m;
 515 
 516         m = check_attr_mod[i];
 517         check_attr[m].state = CHECK (l->data)->state;
 518     }
 519 }
 520 
 521 /* --------------------------------------------------------------------------------------------- */
 522 
 523 static cb_ret_t
 524 chattrboxes_down (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 525 {
 526     if (cb->pos == cb->top + WIDGET (cb)->lines - 1)
 527     {
 528         /* We are on the last checkbox.
 529            Keep this position. */
 530 
 531         if (cb->pos == check_attr_mod_num - 1)
 532             /* get out of widget */
 533             return MSG_NOT_HANDLED;
 534 
 535         /* emulate scroll of checkboxes */
 536         checkboxes_save_state (cb);
 537         cb->pos++;
 538         cb->top++;
 539         chattrboxes_rename (cb);
 540     }
 541     else                        /* cb->pos > cb-top */
 542     {
 543         GList *l;
 544 
 545         /* select next checkbox */
 546         cb->pos++;
 547         l = g_list_next (GROUP (cb)->current);
 548         widget_select (WIDGET (l->data));
 549     }
 550 
 551     return MSG_HANDLED;
 552 }
 553 
 554 /* --------------------------------------------------------------------------------------------- */
 555 
 556 static cb_ret_t
 557 chattrboxes_page_down (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 558 {
 559     WGroup *g = GROUP (cb);
 560     GList *l;
 561 
 562     if (cb->pos == check_attr_mod_num - 1)
 563     {
 564         /* We are on the last checkbox.
 565            Keep this position.
 566            Do nothing. */
 567         l = g_list_last (g->widgets);
 568     }
 569     else
 570     {
 571         int i = WIDGET (cb)->lines;
 572 
 573         checkboxes_save_state (cb);
 574 
 575         if (cb->top > check_attr_mod_num - 2 * i)
 576             i = check_attr_mod_num - i - cb->top;
 577         if (cb->top + i < 0)
 578             i = -cb->top;
 579         if (i == 0)
 580         {
 581             cb->pos = check_attr_mod_num - 1;
 582             cb->top += i;
 583             l = g_list_last (g->widgets);
 584         }
 585         else
 586         {
 587             cb->pos += i;
 588             cb->top += i;
 589             l = g_list_nth (g->widgets, cb->pos - cb->top);
 590         }
 591 
 592         chattrboxes_rename (cb);
 593     }
 594 
 595     widget_select (WIDGET (l->data));
 596 
 597     return MSG_HANDLED;
 598 }
 599 
 600 /* --------------------------------------------------------------------------------------------- */
 601 
 602 static cb_ret_t
 603 chattrboxes_end (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 604 {
 605     GList *l;
 606 
 607     checkboxes_save_state (cb);
 608     cb->pos = check_attr_mod_num - 1;
 609     cb->top = cb->pos - WIDGET (cb)->lines + 1;
 610     l = g_list_last (GROUP (cb)->widgets);
 611     chattrboxes_rename (cb);
 612     widget_select (WIDGET (l->data));
 613 
 614     return MSG_HANDLED;
 615 }
 616 
 617 /* --------------------------------------------------------------------------------------------- */
 618 
 619 static cb_ret_t
 620 chattrboxes_up (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 621 {
 622     if (cb->pos == cb->top)
 623     {
 624         /* We are on the first checkbox.
 625            Keep this position. */
 626 
 627         if (cb->top == 0)
 628             /* get out of widget */
 629             return MSG_NOT_HANDLED;
 630 
 631         /* emulate scroll of checkboxes */
 632         checkboxes_save_state (cb);
 633         cb->pos--;
 634         cb->top--;
 635         chattrboxes_rename (cb);
 636     }
 637     else                        /* cb->pos > cb-top */
 638     {
 639         GList *l;
 640 
 641         /* select previous checkbox */
 642         cb->pos--;
 643         l = g_list_previous (GROUP (cb)->current);
 644         widget_select (WIDGET (l->data));
 645     }
 646 
 647     return MSG_HANDLED;
 648 }
 649 
 650 /* --------------------------------------------------------------------------------------------- */
 651 
 652 static cb_ret_t
 653 chattrboxes_page_up (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 654 {
 655     WGroup *g = GROUP (cb);
 656     GList *l;
 657 
 658     if (cb->pos == 0 && cb->top == 0)
 659     {
 660         /* We are on the first checkbox.
 661            Keep this position.
 662            Do nothing. */
 663         l = g_list_first (g->widgets);
 664     }
 665     else
 666     {
 667         int i = WIDGET (cb)->lines;
 668 
 669         checkboxes_save_state (cb);
 670 
 671         if (cb->top < i)
 672             i = cb->top;
 673         if (i == 0)
 674         {
 675             cb->pos = 0;
 676             cb->top -= i;
 677             l = g_list_first (g->widgets);
 678         }
 679         else
 680         {
 681             cb->pos -= i;
 682             cb->top -= i;
 683             l = g_list_nth (g->widgets, cb->pos - cb->top);
 684         }
 685 
 686         chattrboxes_rename (cb);
 687     }
 688 
 689     widget_select (WIDGET (l->data));
 690 
 691     return MSG_HANDLED;
 692 }
 693 
 694 /* --------------------------------------------------------------------------------------------- */
 695 
 696 static cb_ret_t
 697 chattrboxes_home (WChattrBoxes * cb)
     /* [previous][next][first][last][top][bottom][index][help]  */
 698 {
 699     GList *l;
 700 
 701     checkboxes_save_state (cb);
 702     cb->pos = 0;
 703     cb->top = 0;
 704     l = g_list_first (GROUP (cb)->widgets);
 705     chattrboxes_rename (cb);
 706     widget_select (WIDGET (l->data));
 707 
 708     return MSG_HANDLED;
 709 }
 710 
 711 /* --------------------------------------------------------------------------------------------- */
 712 
 713 static cb_ret_t
 714 chattrboxes_execute_cmd (WChattrBoxes * cb, long command)
     /* [previous][next][first][last][top][bottom][index][help]  */
 715 {
 716     switch (command)
 717     {
 718     case CK_Down:
 719         return chattrboxes_down (cb);
 720 
 721     case CK_PageDown:
 722         return chattrboxes_page_down (cb);
 723 
 724     case CK_Bottom:
 725         return chattrboxes_end (cb);
 726 
 727     case CK_Up:
 728         return chattrboxes_up (cb);
 729 
 730     case CK_PageUp:
 731         return chattrboxes_page_up (cb);
 732 
 733     case CK_Top:
 734         return chattrboxes_home (cb);
 735 
 736     case CK_Mark:
 737     case CK_MarkAndDown:
 738         {
 739             chattr_toggle_select (cb, cb->pos); /* FIXME */
 740             if (command == CK_MarkAndDown)
 741                 chattrboxes_down (cb);
 742 
 743             return MSG_HANDLED;
 744         }
 745 
 746     default:
 747         return MSG_NOT_HANDLED;
 748     }
 749 }
 750 
 751 /* --------------------------------------------------------------------------------------------- */
 752 
 753 static cb_ret_t
 754 chattrboxes_key (WChattrBoxes * cb, int key)
     /* [previous][next][first][last][top][bottom][index][help]  */
 755 {
 756     long command;
 757 
 758     command = widget_lookup_key (WIDGET (cb), key);
 759     if (command == CK_IgnoreKey)
 760         return MSG_NOT_HANDLED;
 761     return chattrboxes_execute_cmd (cb, command);
 762 }
 763 
 764 /* --------------------------------------------------------------------------------------------- */
 765 
 766 static cb_ret_t
 767 chattrboxes_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
     /* [previous][next][first][last][top][bottom][index][help]  */
 768 {
 769     WChattrBoxes *cb = CHATTRBOXES (w);
 770     WGroup *g = GROUP (w);
 771 
 772     switch (msg)
 773     {
 774     case MSG_DRAW:
 775         chattrboxes_draw (cb);
 776         return MSG_HANDLED;
 777 
 778     case MSG_NOTIFY:
 779         {
 780             /* handle checkboxes */
 781             int i;
 782 
 783             i = g_list_index (g->widgets, sender);
 784             if (i >= 0)
 785             {
 786                 int m;
 787 
 788                 i += cb->top;
 789                 m = check_attr_mod[i];
 790                 flags ^= check_attr[m].flags;
 791                 fileattrtext_fill (file_attr, flags);
 792                 chattr_toggle_select (cb, i);
 793                 flags_changed = TRUE;
 794                 return MSG_HANDLED;
 795             }
 796         }
 797         return MSG_NOT_HANDLED;
 798 
 799     case MSG_CHANGED_FOCUS:
 800         /* sender is one of chattr checkboxes */
 801         if (widget_get_state (sender, WST_FOCUSED))
 802         {
 803             int i;
 804 
 805             i = g_list_index (g->widgets, sender);
 806             cb->pos = cb->top + i;
 807         }
 808         return MSG_HANDLED;
 809 
 810     case MSG_KEY:
 811         {
 812             cb_ret_t ret;
 813 
 814             ret = chattrboxes_key (cb, parm);
 815             if (ret != MSG_HANDLED)
 816                 ret = group_default_callback (w, NULL, MSG_KEY, parm, NULL);
 817 
 818             return ret;
 819         }
 820 
 821     case MSG_ACTION:
 822         return chattrboxes_execute_cmd (cb, parm);
 823 
 824     case MSG_DESTROY:
 825         /* save all states */
 826         checkboxes_save_state (cb);
 827         MC_FALLTHROUGH;
 828 
 829     default:
 830         return group_default_callback (w, sender, msg, parm, data);
 831     }
 832 }
 833 
 834 /* --------------------------------------------------------------------------------------------- */
 835 
 836 static int
 837 chattrboxes_handle_mouse_event (Widget * w, Gpm_Event * event)
     /* [previous][next][first][last][top][bottom][index][help]  */
 838 {
 839     int mou;
 840 
 841     mou = mouse_handle_event (w, event);
 842     if (mou == MOU_UNHANDLED)
 843         mou = group_handle_mouse_event (w, event);
 844 
 845     return mou;
 846 }
 847 
 848 /* --------------------------------------------------------------------------------------------- */
 849 
 850 static void
 851 chattrboxes_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
     /* [previous][next][first][last][top][bottom][index][help]  */
 852 {
 853     WChattrBoxes *cb = CHATTRBOXES (w);
 854 
 855     (void) event;
 856 
 857     switch (msg)
 858     {
 859     case MSG_MOUSE_SCROLL_UP:
 860         chattrboxes_up (cb);
 861         break;
 862 
 863     case MSG_MOUSE_SCROLL_DOWN:
 864         chattrboxes_down (cb);
 865         break;
 866 
 867     default:
 868         break;
 869     }
 870 }
 871 
 872 /* --------------------------------------------------------------------------------------------- */
 873 
 874 static WChattrBoxes *
 875 chattrboxes_new (int y, int x, int height, int width)
     /* [previous][next][first][last][top][bottom][index][help]  */
 876 {
 877     WChattrBoxes *cb;
 878     Widget *w;
 879 
 880     if (height <= 0)
 881         height = 1;
 882 
 883     cb = g_new0 (WChattrBoxes, 1);
 884     w = WIDGET (cb);
 885     group_init (GROUP (cb), y, x, height, width, chattrboxes_callback, chattrboxes_mouse_callback);
 886     w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR;
 887     w->mouse_handler = chattrboxes_handle_mouse_event;
 888     w->keymap = chattr_map;
 889 
 890     return cb;
 891 }
 892 
 893 /* --------------------------------------------------------------------------------------------- */
 894 
 895 static void
 896 chattr_init (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 897 {
 898     static gboolean i18n = FALSE;
 899     size_t i;
 900 
 901     for (i = 0; i < check_attr_num; i++)
 902         check_attr[i].selected = FALSE;
 903 
 904     if (i18n)
 905         return;
 906 
 907     i18n = TRUE;
 908 
 909     for (i = 0; i < check_attr_num; i++)
 910         if (chattr_is_modifiable (i))
 911         {
 912             int width;
 913 
 914 #ifdef ENABLE_NLS
 915             check_attr[i].text = _(check_attr[i].text);
 916 #endif
 917 
 918             check_attr_mod[check_attr_mod_num++] = i;
 919 
 920             width = 4 + str_term_width1 (check_attr[i].text);   /* "(Q) text " */
 921             check_attr_width = MAX (check_attr_width, width);
 922         }
 923 
 924     check_attr_width += 1 + 3 + 1;      /* mark, [x] and space */
 925 
 926     for (i = 0; i < BUTTONS; i++)
 927     {
 928 #ifdef ENABLE_NLS
 929         chattr_but[i].text = _(chattr_but[i].text);
 930 #endif
 931 
 932         chattr_but[i].width = str_term_width1 (chattr_but[i].text) + 3; /* [], spaces and w/o & */
 933         if (chattr_but[i].flags == DEFPUSH_BUTTON)
 934             chattr_but[i].width += 2;   /* <> */
 935     }
 936 }
 937 
 938 /* --------------------------------------------------------------------------------------------- */
 939 
 940 static WDialog *
 941 chattr_dlg_create (const char *fname, unsigned long attr)
     /* [previous][next][first][last][top][bottom][index][help]  */
 942 {
 943     const Widget *mw = CONST_WIDGET (midnight_dlg);
 944     gboolean single_set;
 945     WDialog *ch_dlg;
 946     int lines, cols;
 947     int checkboxes_lines = check_attr_mod_num;
 948     size_t i;
 949     int y;
 950     Widget *dw;
 951     WGroup *dg, *cbg;
 952     WChattrBoxes *cb;
 953     const int cb_scrollbar_width = 1;
 954 
 955     /* prepate to set up checkbox states */
 956     for (i = 0; i < check_attr_num; i++)
 957         check_attr[i].state = chattr_is_modifiable (i) && (attr & check_attr[i].flags) != 0;
 958 
 959     cols = check_attr_width + cb_scrollbar_width;
 960 
 961     single_set = (current_panel->marked < 2);
 962 
 963     lines = 5 + checkboxes_lines + 4;
 964     if (!single_set)
 965         lines += 3;
 966 
 967     if (lines >= mw->lines - 2)
 968     {
 969         int dl;
 970 
 971         dl = lines - (mw->lines - 2);
 972         lines -= dl;
 973         checkboxes_lines -= dl;
 974     }
 975 
 976     ch_dlg =
 977         dlg_create (TRUE, 0, 0, lines, cols + wx * 2, WPOS_CENTER, FALSE, dialog_colors,
 978                     dlg_default_callback, NULL, "[Chattr]", _("Chattr command"));
 979     dg = GROUP (ch_dlg);
 980     dw = WIDGET (ch_dlg);
 981 
 982     y = 2;
 983     file_attr = fileattrtext_new (y, wx, fname, attr);
 984     group_add_widget_autopos (dg, file_attr, WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
 985     y += WIDGET (file_attr)->lines;
 986     group_add_widget (dg, hline_new (y++, -1, -1));
 987 
 988     if (cols < WIDGET (file_attr)->cols)
 989     {
 990         cols = WIDGET (file_attr)->cols;
 991         cols = MIN (cols, mw->cols - wx * 2);
 992         widget_set_size (dw, dw->y, dw->x, lines, cols + wx * 2);
 993     }
 994 
 995     cb = chattrboxes_new (y++, wx, checkboxes_lines, cols);
 996     cbg = GROUP (cb);
 997     group_add_widget_autopos (dg, cb, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
 998 
 999     /* create checkboxes */
1000     for (i = 0; i < (size_t) check_attr_mod_num && i < (size_t) checkboxes_lines; i++)
1001     {
1002         int m;
1003         WCheck *check;
1004 
1005         m = check_attr_mod[i];
1006 
1007         check = check_new (i, 0, check_attr[m].state, NULL);
1008         group_add_widget (cbg, check);
1009     }
1010 
1011     chattrboxes_rename (cb);
1012 
1013     y += i - 1;
1014     cols = 0;
1015 
1016     for (i = single_set ? (BUTTONS - 2) : 0; i < BUTTONS; i++)
1017     {
1018         if (i == 0 || i == BUTTONS - 2)
1019             group_add_widget (dg, hline_new (y++, -1, -1));
1020 
1021         chattr_but[i].button = WIDGET (button_new (y, dw->cols / 2 + 1 - chattr_but[i].width,
1022                                                    chattr_but[i].ret_cmd, chattr_but[i].flags,
1023                                                    chattr_but[i].text, NULL));
1024         group_add_widget (dg, chattr_but[i].button);
1025 
1026         i++;
1027         chattr_but[i].button = WIDGET (button_new (y++, dw->cols / 2 + 2, chattr_but[i].ret_cmd,
1028                                                    chattr_but[i].flags, chattr_but[i].text, NULL));
1029         group_add_widget (dg, chattr_but[i].button);
1030 
1031         /* two buttons in a row */
1032         cols = MAX (cols, chattr_but[i - 1].button->cols + 1 + chattr_but[i].button->cols);
1033     }
1034 
1035     /* adjust dialog size and button positions */
1036     cols += 6;
1037     if (cols > dw->cols)
1038     {
1039         widget_set_size (dw, dw->y, dw->x, lines, cols);
1040 
1041         /* dialog center */
1042         cols = dw->x + dw->cols / 2 + 1;
1043 
1044         for (i = single_set ? (BUTTONS - 2) : 0; i < BUTTONS; i++)
1045         {
1046             Widget *b;
1047 
1048             b = chattr_but[i++].button;
1049             widget_set_size (b, b->y, cols - b->cols, b->lines, b->cols);
1050 
1051             b = chattr_but[i].button;
1052             widget_set_size (b, b->y, cols + 1, b->lines, b->cols);
1053         }
1054     }
1055 
1056     /* select first checkbox */
1057     cbg->current = cbg->widgets;
1058     widget_select (WIDGET (cb));
1059 
1060     return ch_dlg;
1061 }
1062 
1063 /* --------------------------------------------------------------------------------------------- */
1064 
1065 static void
1066 chattr_done (gboolean need_update)
     /* [previous][next][first][last][top][bottom][index][help]  */
1067 {
1068     if (need_update)
1069         update_panels (UP_OPTIMIZE, UP_KEEPSEL);
1070     repaint_screen ();
1071 }
1072 
1073 /* --------------------------------------------------------------------------------------------- */
1074 
1075 static const char *
1076 next_file (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1077 {
1078     while (!current_panel->dir.list[current_file].f.marked)
1079         current_file++;
1080 
1081     return current_panel->dir.list[current_file].fname;
1082 }
1083 
1084 /* --------------------------------------------------------------------------------------------- */
1085 
1086 static gboolean
1087 try_chattr (const char *p, unsigned long m)
     /* [previous][next][first][last][top][bottom][index][help]  */
1088 {
1089     while (fsetflags (p, m) == -1 && !ignore_all)
1090     {
1091         int my_errno = errno;
1092         int result;
1093         char *msg;
1094 
1095         msg =
1096             g_strdup_printf (_("Cannot chattr \"%s\"\n%s"), x_basename (p),
1097                              unix_error_string (my_errno));
1098         result =
1099             query_dialog (MSG_ERROR, msg, D_ERROR, 4, _("&Ignore"), _("Ignore &all"), _("&Retry"),
1100                           _("&Cancel"));
1101         g_free (msg);
1102 
1103         switch (result)
1104         {
1105         case 0:
1106             /* try next file */
1107             return TRUE;
1108 
1109         case 1:
1110             ignore_all = TRUE;
1111             /* try next file */
1112             return TRUE;
1113 
1114         case 2:
1115             /* retry this file */
1116             break;
1117 
1118         case 3:
1119         default:
1120             /* stop remain files processing */
1121             return FALSE;
1122         }
1123     }
1124 
1125     return TRUE;
1126 }
1127 
1128 /* --------------------------------------------------------------------------------------------- */
1129 
1130 static gboolean
1131 do_chattr (const vfs_path_t * p, unsigned long m)
     /* [previous][next][first][last][top][bottom][index][help]  */
1132 {
1133     gboolean ret;
1134 
1135     m &= and_mask;
1136     m |= or_mask;
1137 
1138     ret = try_chattr (vfs_path_as_str (p), m);
1139 
1140     do_file_mark (current_panel, current_file, 0);
1141 
1142     return ret;
1143 }
1144 
1145 /* --------------------------------------------------------------------------------------------- */
1146 
1147 static void
1148 chattr_apply_mask (vfs_path_t * vpath, unsigned long m)
     /* [previous][next][first][last][top][bottom][index][help]  */
1149 {
1150     gboolean ok;
1151 
1152     if (!do_chattr (vpath, m))
1153         return;
1154 
1155     do
1156     {
1157         const char *fname;
1158 
1159         fname = next_file ();
1160         ok = (fgetflags (fname, &m) == 0);
1161 
1162         if (!ok)
1163         {
1164             /* if current file was deleted outside mc -- try next file */
1165             /* decrease current_panel->marked */
1166             do_file_mark (current_panel, current_file, 0);
1167 
1168             /* try next file */
1169             ok = TRUE;
1170         }
1171         else
1172         {
1173             vpath = vfs_path_from_str (fname);
1174             flags = m;
1175             ok = do_chattr (vpath, m);
1176             vfs_path_free (vpath);
1177         }
1178     }
1179     while (ok && current_panel->marked != 0);
1180 }
1181 
1182 /* --------------------------------------------------------------------------------------------- */
1183 /*** public functions ****************************************************************************/
1184 /* --------------------------------------------------------------------------------------------- */
1185 
1186 void
1187 chattr_cmd (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1188 {
1189     gboolean need_update = FALSE;
1190     gboolean end_chattr = FALSE;
1191 
1192     chattr_init ();
1193 
1194     current_file = 0;
1195     ignore_all = FALSE;
1196 
1197     do
1198     {                           /* do while any files remaining */
1199         vfs_path_t *vpath;
1200         WDialog *ch_dlg;
1201         const char *fname, *fname2;
1202         size_t i;
1203         int result;
1204 
1205         if (!vfs_current_is_local ())
1206         {
1207             message (D_ERROR, MSG_ERROR, "%s",
1208                      _("Cannot change attributes on non-local filesystems"));
1209             break;
1210         }
1211 
1212         do_refresh ();
1213 
1214         need_update = FALSE;
1215         end_chattr = FALSE;
1216 
1217         if (current_panel->marked != 0)
1218             fname = next_file ();       /* next marked file */
1219         else
1220             fname = selection (current_panel)->fname;   /* single file */
1221 
1222         vpath = vfs_path_from_str (fname);
1223         fname2 = vfs_path_as_str (vpath);
1224 
1225         if (fgetflags (fname2, &flags) != 0)
1226         {
1227             message (D_ERROR, MSG_ERROR, _("Cannot get flags of \"%s\"\n%s"), fname,
1228                      unix_error_string (errno));
1229             vfs_path_free (vpath);
1230             break;
1231         }
1232 
1233         flags_changed = FALSE;
1234 
1235         ch_dlg = chattr_dlg_create (fname, flags);
1236         result = dlg_run (ch_dlg);
1237         dlg_destroy (ch_dlg);
1238 
1239         switch (result)
1240         {
1241         case B_CANCEL:
1242             end_chattr = TRUE;
1243             break;
1244 
1245         case B_ENTER:
1246             if (flags_changed)
1247             {
1248                 if (current_panel->marked <= 1)
1249                 {
1250                     /* single or last file */
1251                     if (fsetflags (fname2, flags) == -1 && !ignore_all)
1252                         message (D_ERROR, MSG_ERROR, _("Cannot chattr \"%s\"\n%s"), fname,
1253                                  unix_error_string (errno));
1254                     end_chattr = TRUE;
1255                 }
1256                 else if (!try_chattr (fname2, flags))
1257                 {
1258                     /* stop multiple files processing */
1259                     result = B_CANCEL;
1260                     end_chattr = TRUE;
1261                 }
1262             }
1263 
1264             need_update = TRUE;
1265             break;
1266 
1267         case B_SETALL:
1268         case B_MARKED:
1269             or_mask = 0;
1270             and_mask = ~0;
1271 
1272             for (i = 0; i < check_attr_num; i++)
1273                 if (chattr_is_modifiable (i) && (check_attr[i].selected || result == B_SETALL))
1274                 {
1275                     if (check_attr[i].state)
1276                         or_mask |= check_attr[i].flags;
1277                     else
1278                         and_mask &= ~check_attr[i].flags;
1279                 }
1280 
1281             chattr_apply_mask (vpath, flags);
1282             need_update = TRUE;
1283             end_chattr = TRUE;
1284             break;
1285 
1286         case B_SETMRK:
1287             or_mask = 0;
1288             and_mask = ~0;
1289 
1290             for (i = 0; i < check_attr_num; i++)
1291                 if (chattr_is_modifiable (i) && check_attr[i].selected)
1292                     or_mask |= check_attr[i].flags;
1293 
1294             chattr_apply_mask (vpath, flags);
1295             need_update = TRUE;
1296             end_chattr = TRUE;
1297             break;
1298 
1299         case B_CLRMRK:
1300             or_mask = 0;
1301             and_mask = ~0;
1302 
1303             for (i = 0; i < check_attr_num; i++)
1304                 if (chattr_is_modifiable (i) && check_attr[i].selected)
1305                     and_mask &= ~check_attr[i].flags;
1306 
1307             chattr_apply_mask (vpath, flags);
1308             need_update = TRUE;
1309             end_chattr = TRUE;
1310             break;
1311 
1312         default:
1313             break;
1314         }
1315 
1316         if (current_panel->marked != 0 && result != B_CANCEL)
1317         {
1318             do_file_mark (current_panel, current_file, 0);
1319             need_update = TRUE;
1320         }
1321 
1322         vfs_path_free (vpath);
1323 
1324     }
1325     while (current_panel->marked != 0 && !end_chattr);
1326 
1327     chattr_done (need_update);
1328 }
1329 
1330 /* --------------------------------------------------------------------------------------------- */
1331 
1332 const char *
1333 chattr_get_as_str (unsigned long attr)
     /* [previous][next][first][last][top][bottom][index][help]  */
1334 {
1335     static char str[32 + 1];    /* 32 bits in attributes (unsigned long) */
1336 
1337     chattr_fill_str (attr, str);
1338 
1339     return str;
1340 }
1341 
1342 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */