static kv plug[PLUGIN_MAX];
static uchar g_tmpfplen;
static uchar blk_shift = BLK_SHIFT_512;
-static bool interrupted = FALSE;
-static bool rangesel = FALSE;
/* Retain old signal handlers */
#ifdef __linux__
/* Buffer to store plugins control pipe location */
static char g_pipepath[TMP_LEN_MAX] __attribute__ ((aligned));
+/* MISC NON-PERSISTENT INTERNAL BINARY STATES */
+
/* Plugin control initialization status */
-static bool g_plinit = FALSE;
+#define STATE_PLUGIN_INIT 0x1
+#define STATE_INTERRUPTED 0x2
+#define STATE_RANGESEL 0x4
+
+static uchar g_states;
/* Options to identify file mime */
#if defined(__APPLE__)
{
(void) sig;
- interrupted = TRUE;
+ g_states |= STATE_INTERRUPTED;
}
static uint xatoi(const char *str)
if (*file == '_')
return run_cmd_as_plugin(*path, file, newpath, runfile);
- if (!g_plinit) {
+ if (!(g_states & STATE_PLUGIN_INIT)) {
plctrl_init();
- g_plinit = TRUE;
+ g_states |= STATE_PLUGIN_INIT;
}
fd = open(g_pipepath, O_RDONLY | O_NONBLOCK);
dir_blocks += dirwalk(buf, &sb);
- if (interrupted) {
+ if (g_states & STATE_INTERRUPTED) {
closedir(dirp);
return n;
}
else
num_files = num_saved;
- if (interrupted) {
+ if (g_states & STATE_INTERRUPTED) {
closedir(dirp);
return n;
}
mvprintw(lastln, 0, "%d/%d [%d:%s] %cu:%s free:%s files:%lu %lldB %s",
cur + 1, ndents, cfg.selmode,
- (rangesel ? "*" : (nselected ? xitoa(nselected) : "")),
+ ((g_states & STATE_RANGESEL) ? "*" : (nselected ? xitoa(nselected) : "")),
c, buf, coolsize(get_fs_info(path, FREE)), num_files,
(ll)pent->blocks << blk_shift, ptr);
} else { /* light or detail mode */
mvprintw(lastln, 0, "%d/%d [%d:%s] %s%s %s %s %s [%s]",
cur + 1, ndents, cfg.selmode,
- (rangesel ? "*" : (nselected ? xitoa(nselected) : "")),
+ ((g_states & STATE_RANGESEL) ? "*" : (nselected ? xitoa(nselected) : "")),
sort, buf, get_lsperms(pent->mode), coolsize(pent->size), ptr, base);
}
} else
printwarn(&presel);
populate(path, lastname);
- if (interrupted) {
- interrupted = FALSE;
+ if (g_states & STATE_INTERRUPTED) {
+ g_states &= ~STATE_INTERRUPTED;
cfg.apparentsz = 0;
cfg.blkorder = 0;
blk_shift = BLK_SHIFT_512;
goto nochange;
startselection();
- if (rangesel)
- rangesel = FALSE;
+ if (g_states & STATE_RANGESEL)
+ g_states &= ~STATE_RANGESEL;
/* Toggle selection status */
dents[cur].flags ^= FILE_SELECTED;
goto nochange;
startselection();
- rangesel ^= TRUE;
+ g_states ^= STATE_RANGESEL;
if (stat(path, &sb) == -1) {
printwarn(&presel);
goto nochange;
}
- if (rangesel) { /* Range selection started */
+ if (g_states & STATE_RANGESEL) { /* Range selection started */
inode = sb.st_ino;
selstartid = cur;
continue;
goto nochange;
startselection();
- if (rangesel)
- rangesel = FALSE;
+ if (g_states & STATE_RANGESEL)
+ g_states &= ~STATE_RANGESEL;
selstartid = 0;
selendid = ndents - 1;