Changed variable name current to block

This commit is contained in:
Ashish Kumar Yadav 2020-11-15 13:24:15 +05:30
parent 230229c482
commit 6101909568

View file

@ -44,8 +44,8 @@ void
buttonhandler(int signal, siginfo_t *si, void *ucontext) buttonhandler(int signal, siginfo_t *si, void *ucontext)
{ {
signal = si->si_value.sival_int >> 8; signal = si->si_value.sival_int >> 8;
for (Block *current = blocks; current->pathu; current++) for (Block *block = blocks; block->pathu; block++)
if (current->signal == signal) if (block->signal == signal)
switch (fork()) { switch (fork()) {
case -1: case -1:
perror("buttonhandler - fork"); perror("buttonhandler - fork");
@ -53,7 +53,7 @@ buttonhandler(int signal, siginfo_t *si, void *ucontext)
case 0: case 0:
{ {
char button[] = { '0' + (si->si_value.sival_int & 0xff), '\0' }; char button[] = { '0' + (si->si_value.sival_int & 0xff), '\0' };
char *arg[] = { current->pathc, button, NULL }; char *arg[] = { block->pathc, button, NULL };
close(ConnectionNumber(dpy)); close(ConnectionNumber(dpy));
setsid(); setsid();
@ -155,18 +155,18 @@ setupsignals()
sa.sa_flags |= SA_NODEFER; sa.sa_flags |= SA_NODEFER;
sa.sa_mask = blocksigmask; sa.sa_mask = blocksigmask;
sa.sa_sigaction = sighandler; sa.sa_sigaction = sighandler;
for (Block *current = blocks; current->pathu; current++) for (Block *block = blocks; block->pathu; block++)
if (current->signal > 0) if (block->signal > 0)
sigaction(SIGRTMIN + current->signal, &sa, NULL); sigaction(SIGRTMIN + block->signal, &sa, NULL);
} }
void void
sighandler(int signal, siginfo_t *si, void *ucontext) sighandler(int signal, siginfo_t *si, void *ucontext)
{ {
signal -= SIGRTMIN; signal -= SIGRTMIN;
for (Block *current = blocks; current->pathu; current++) for (Block *block = blocks; block->pathu; block++)
if (current->signal == signal) if (block->signal == signal)
getcmd(current, si->si_value.sival_int); getcmd(block, si->si_value.sival_int);
setroot(); setroot();
} }
@ -177,9 +177,9 @@ statusloop()
/* first run */ /* first run */
sigprocmask(SIG_BLOCK, &blocksigmask, NULL); sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
for (Block *current = blocks; current->pathu; current++) for (Block *block = blocks; block->pathu; block++)
if (current->interval >= 0) if (block->interval >= 0)
getcmd(current, NILL); getcmd(block, NILL);
setroot(); setroot();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
sleep(SLEEPINTERVAL); sleep(SLEEPINTERVAL);
@ -187,9 +187,9 @@ statusloop()
/* main loop */ /* main loop */
while (statuscontinue) { while (statuscontinue) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL); sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
for (Block *current = blocks; current->pathu; current++) for (Block *block = blocks; block->pathu; block++)
if (current->interval > 0 && i % current->interval == 0) if (block->interval > 0 && i % block->interval == 0)
getcmd(current, NILL); getcmd(block, NILL);
setroot(); setroot();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
sleep(SLEEPINTERVAL); sleep(SLEEPINTERVAL);
@ -210,84 +210,84 @@ updatestatus()
char *s = statusstr; char *s = statusstr;
char *c, *p; /* for cmdoutcur and cmdoutprv */ char *c, *p; /* for cmdoutcur and cmdoutprv */
const char *d; /* for delimiter */ const char *d; /* for delimiter */
Block *current = blocks; Block *block = blocks;
/* checking half of the function */ /* checking half of the function */
/* find the first non-empty block */ /* find the first non-empty block */
for (;; current++) { for (;; block++) {
/* all blocks are empty */ /* all blocks are empty */
if (!current->pathu) if (!block->pathu)
return 0; return 0;
/* contents of the current block changed */ /* contents of the block changed */
if (*current->cmdoutcur != *current->cmdoutprv) if (*block->cmdoutcur != *block->cmdoutprv)
goto update0; goto update0;
/* skip delimiter handler for the first non-empty block */ /* skip delimiter handler for the first non-empty block */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0')
goto skipdelimc; goto skipdelimc;
} }
/* main loop */ /* main loop */
for (; current->pathu; current++) { for (; block->pathu; block++) {
/* contents of the current block changed */ /* contents of the block changed */
if (*current->cmdoutcur != *current->cmdoutprv) if (*block->cmdoutcur != *block->cmdoutprv)
goto update1; goto update1;
/* delimiter handler */ /* delimiter handler */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0')
s += delimlength; s += delimlength;
/* skip over empty blocks */ /* skip over empty blocks */
else else
continue; continue;
skipdelimc: skipdelimc:
/* checking for the first byte has been done */ /* checking for the first byte has been done */
c = current->cmdoutcur + 1, p = current->cmdoutprv + 1; c = block->cmdoutcur + 1, p = block->cmdoutprv + 1;
for (; *c != '\n' && *c != '\0'; c++, p++) for (; *c != '\n' && *c != '\0'; c++, p++)
/* contents of the current block changed */ /* contents of the block changed */
if (*c != *p) { if (*c != *p) {
s += c - current->cmdoutcur; s += c - block->cmdoutcur;
goto update2; goto update2;
} }
s += c - current->cmdoutcur; s += c - block->cmdoutcur;
/* byte containing info about signal number for the block */ /* byte containing info about signal number for the block */
if (current->pathc && current->signal) if (block->pathc && block->signal)
s++; s++;
} }
return 0; return 0;
/* updating half of the function */ /* updating half of the function */
/* find the first non-empty block */ /* find the first non-empty block */
for (;; current++) { for (;; block++) {
/* all blocks are empty */ /* all blocks are empty */
if (!current->pathu) if (!block->pathu)
return 1; return 1;
update0: update0:
/* don't add delimiter before the first non-empty block */ /* don't add delimiter before the first non-empty block */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0')
goto skipdelimu; goto skipdelimu;
*current->cmdoutprv = *current->cmdoutcur; *block->cmdoutprv = *block->cmdoutcur;
} }
/* main loop */ /* main loop */
for (; current->pathu; current++) { for (; block->pathu; block++) {
update1: update1:
/* delimiter handler */ /* delimiter handler */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') { if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0') {
d = delim; d = delim;
while (*d != '\0') while (*d != '\0')
*(s++) = *(d++); *(s++) = *(d++);
*(s++) = '\n'; /* to mark the end of delimiter */ *(s++) = '\n'; /* to mark the end of delimiter */
/* skip over empty blocks */ /* skip over empty blocks */
} else { } else {
*current->cmdoutprv = *current->cmdoutcur; *block->cmdoutprv = *block->cmdoutcur;
continue; continue;
} }
skipdelimu: skipdelimu:
c = current->cmdoutcur, p = current->cmdoutprv; c = block->cmdoutcur, p = block->cmdoutprv;
update2: update2:
do { do {
*(s++) = *c; *(s++) = *c;
*p = *c; *p = *c;
c++, p++; c++, p++;
} while (*c != '\n' && *c != '\0'); } while (*c != '\n' && *c != '\0');
if (current->pathc && current->signal) if (block->pathc && block->signal)
*(s++) = current->signal; *(s++) = block->signal;
} }
*s = '\0'; *s = '\0';
return 1; return 1;
@ -342,9 +342,9 @@ main(int argc, char *argv[])
sigaddset(&blocksigmask, SIGHUP); sigaddset(&blocksigmask, SIGHUP);
sigaddset(&blocksigmask, SIGINT); sigaddset(&blocksigmask, SIGINT);
sigaddset(&blocksigmask, SIGTERM); sigaddset(&blocksigmask, SIGTERM);
for (Block *current = blocks; current->pathu; current++) for (Block *block = blocks; block->pathu; block++)
if (current->signal > 0) if (block->signal > 0)
sigaddset(&blocksigmask, SIGRTMIN + current->signal); sigaddset(&blocksigmask, SIGRTMIN + block->signal);
setupsignals(); setupsignals();
statusloop(); statusloop();
unlink(LOCKFILE); unlink(LOCKFILE);