Signal scanout after nodes edit

This commit is contained in:
Michiel Broek 2002-07-13 15:10:00 +00:00
parent e9562655ae
commit 55ed2dd121
2 changed files with 257 additions and 238 deletions

View File

@ -37,6 +37,7 @@ v0.35.03 06-Jul-2002
mbsetup: mbsetup:
Enabled setting of nodelist override settings in menu 7.x.3 Enabled setting of nodelist override settings in menu 7.x.3
After nodes setup edit the semafore scanout is set.
script: script:
The bbsdoor.sh and rundoor.sh scripts are now only installed The bbsdoor.sh and rundoor.sh scripts are now only installed

View File

@ -98,14 +98,15 @@ int CountNoderec(void)
int OpenNoderec(void) int OpenNoderec(void)
{ {
FILE *fin, *fout; FILE *fin, *fout;
char fnin[PATH_MAX], fnout[PATH_MAX]; char *fnin, *fnout, group[13];
char group[13];
long oldsize;
int i, old_fgroups, old_mgroups; int i, old_fgroups, old_mgroups;
long oldfilegrp, oldmailgrp; long oldsize, oldfilegrp, oldmailgrp;
fnin = calloc(PATH_MAX, sizeof(char));
fnout = calloc(PATH_MAX, sizeof(char));
sprintf(fnin, "%s/etc/nodes.data", getenv("MBSE_ROOT")); sprintf(fnin, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
sprintf(fnout, "%s/etc/nodes.temp", getenv("MBSE_ROOT")); sprintf(fnout, "%s/etc/nodes.temp", getenv("MBSE_ROOT"));
if ((fin = fopen(fnin, "r")) != NULL) { if ((fin = fopen(fnin, "r")) != NULL) {
if ((fout = fopen(fnout, "w")) != NULL) { if ((fout = fopen(fnout, "w")) != NULL) {
NodeUpdated = 0; NodeUpdated = 0;
@ -128,9 +129,7 @@ int OpenNoderec(void)
oldmailgrp = nodeshdr.mailgrp; oldmailgrp = nodeshdr.mailgrp;
old_fgroups = oldfilegrp / 13; old_fgroups = oldfilegrp / 13;
old_mgroups = oldmailgrp / 13; old_mgroups = oldmailgrp / 13;
if ((oldsize != sizeof(nodes) || if ((oldsize != sizeof(nodes) || (CFG.tic_groups != old_fgroups) || (CFG.toss_groups != old_mgroups))) {
(CFG.tic_groups != old_fgroups) ||
(CFG.toss_groups != old_mgroups))) {
NodeUpdated = 1; NodeUpdated = 1;
if (oldsize != sizeof(nodes)) if (oldsize != sizeof(nodes))
Syslog('+', "Upgraded %s, format changed", fnin); Syslog('+', "Upgraded %s, format changed", fnin);
@ -146,9 +145,8 @@ int OpenNoderec(void)
fwrite(&nodeshdr, sizeof(nodeshdr), 1, fout); fwrite(&nodeshdr, sizeof(nodeshdr), 1, fout);
/* /*
* The datarecord is filled with zero's before each * The datarecord is filled with zero's before each read,
* read, so if the format changed, the new fields * so if the format changed, the new fields will be empty.
* will be empty.
*/ */
memset(&nodes, 0, sizeof(nodes)); memset(&nodes, 0, sizeof(nodes));
while (fread(&nodes, oldsize, 1, fin) == 1) { while (fread(&nodes, oldsize, 1, fin) == 1) {
@ -168,8 +166,7 @@ int OpenNoderec(void)
} }
if (old_fgroups < CFG.tic_groups) { if (old_fgroups < CFG.tic_groups) {
/* /*
* The size increased, fill with * The size increased, fill with blank records
* blank records
*/ */
memset(&group, 0, 13); memset(&group, 0, 13);
for (i = (old_fgroups + 1); i <= CFG.tic_groups; i++) for (i = (old_fgroups + 1); i <= CFG.tic_groups; i++)
@ -192,10 +189,15 @@ int OpenNoderec(void)
fclose(fin); fclose(fin);
fclose(fout); fclose(fout);
free(fnin);
free(fnout);
return 0; return 0;
} else } else
return -1; return -1;
} }
free(fnin);
free(fnout);
return -1; return -1;
} }
@ -203,13 +205,14 @@ int OpenNoderec(void)
void CloseNoderec(int Force) void CloseNoderec(int Force)
{ {
char fin[PATH_MAX], fout[PATH_MAX]; char *fin, *fout, group[13];
FILE *fi, *fo; FILE *fi, *fo;
int i; int i;
char group[13];
st_list *nod = NULL, *tmp; st_list *nod = NULL, *tmp;
unsigned long crc1, crc2; unsigned long crc1, crc2;
fin = calloc(PATH_MAX, sizeof(char));
fout = calloc(PATH_MAX, sizeof(char));
sprintf(fin, "%s/etc/nodes.data", getenv("MBSE_ROOT")); sprintf(fin, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
sprintf(fout,"%s/etc/nodes.temp", getenv("MBSE_ROOT")); sprintf(fout,"%s/etc/nodes.temp", getenv("MBSE_ROOT"));
@ -251,12 +254,18 @@ void CloseNoderec(int Force)
fclose(fo); fclose(fo);
unlink(fout); unlink(fout);
chmod(fin, 0640); chmod(fin, 0640);
free(fin);
free(fout);
Syslog('+', "Updated \"nodes.data\""); Syslog('+', "Updated \"nodes.data\"");
CreateSema((char *)"scanout");
return; return;
} }
} }
chmod(fin, 0640); chmod(fin, 0640);
working(1, 0, 0); working(1, 0, 0);
free(fin);
free(fout);
unlink(fout); unlink(fout);
} }
@ -266,11 +275,12 @@ int AppendNoderec(void);
int AppendNoderec(void) int AppendNoderec(void)
{ {
FILE *fil; FILE *fil;
char ffile[PATH_MAX]; char *ffile, group[13];
char group[13];
int i; int i;
ffile = calloc(PATH_MAX, sizeof(char));
sprintf(ffile, "%s/etc/nodes.temp", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/nodes.temp", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
memset(&nodes, 0, sizeof(nodes)); memset(&nodes, 0, sizeof(nodes));
/* /*
@ -291,8 +301,11 @@ int AppendNoderec(void)
fwrite(&group, 13, 1, fil); fwrite(&group, 13, 1, fil);
fclose(fil); fclose(fil);
NodeUpdated = 1; NodeUpdated = 1;
free(ffile);
return 0; return 0;
} else }
free(ffile);
return -1; return -1;
} }
@ -300,13 +313,17 @@ int AppendNoderec(void)
int GroupInNode(char *Group, int Mail) int GroupInNode(char *Group, int Mail)
{ {
char temp[PATH_MAX], group[13]; char *temp, group[13];
FILE *no; FILE *no;
int i, groups, RetVal = 0; int i, groups, RetVal = 0;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/nodes.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
if ((no = fopen(temp, "r")) == NULL) if ((no = fopen(temp, "r")) == NULL) {
free(temp);
return 0; return 0;
}
free(temp);
fread(&nodeshdr, sizeof(nodeshdr), 1, no); fread(&nodeshdr, sizeof(nodeshdr), 1, no);
fseek(no, 0, SEEK_SET); fseek(no, 0, SEEK_SET);
@ -354,6 +371,7 @@ int CheckAka(fidoaddr A)
errmsg((char *)"Error aka connected to %d message and/or %d tic areas", mcnt, tcnt); errmsg((char *)"Error aka connected to %d message and/or %d tic areas", mcnt, tcnt);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }