Changed time reset

This commit is contained in:
Michiel Broek 2004-09-26 12:03:31 +00:00
parent feb9025394
commit 63bd7ffa18

View File

@ -448,14 +448,42 @@ int EditUsrRec2(void)
} }
void Reset_Time(void);
void Reset_Time(void)
{
char *temp;
FILE *pLimits;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/limits.data", getenv("MBSE_ROOT"));
if ((pLimits = fopen(temp,"r")) == NULL) {
WriteError("$Can't open %s", temp);
} else {
fread(&LIMIThdr, sizeof(LIMIThdr), 1, pLimits);
while (fread(&LIMIT, sizeof(LIMIT), 1, pLimits) == 1) {
if (LIMIT.Security == usrconfig.Security.level) {
if (LIMIT.Time)
usrconfig.iTimeLeft = LIMIT.Time;
else
usrconfig.iTimeLeft = 86400;
usrconfig.iTimeUsed = 0;
break;
}
}
fclose(pLimits);
}
free(temp);
}
/* /*
* Edit one record, return -1 if there are errors, 0 if ok. * Edit one record, return -1 if there are errors, 0 if ok.
*/ */
int EditUsrRec(int Area) int EditUsrRec(int Area)
{ {
FILE *fil, *pLimits; FILE *fil;
char mfile[PATH_MAX], *temp; char mfile[PATH_MAX];
long offset; long offset;
int j = 0; int j = 0;
unsigned long crc, crc1; unsigned long crc, crc1;
@ -522,25 +550,7 @@ int EditUsrRec(int Area)
case 13:E_BOOL( 8,68, usrconfig.OL_ExtInfo, "Add ^Extended Message Info^ in OLR download") case 13:E_BOOL( 8,68, usrconfig.OL_ExtInfo, "Add ^Extended Message Info^ in OLR download")
case 14:E_BOOL( 9,68, usrconfig.Email, "User has a ^private email^ mailbox") case 14:E_BOOL( 9,68, usrconfig.Email, "User has a ^private email^ mailbox")
case 15:if (yes_no((char *)"Reset time left for today") == 1) { case 15:if (yes_no((char *)"Reset time left for today") == 1) {
temp = calloc(PATH_MAX, sizeof(char)); Reset_Time();
sprintf(temp, "%s/etc/limits.data", getenv("MBSE_ROOT"));
if ((pLimits = fopen(temp,"r")) == NULL) {
WriteError("$Can't open %s", temp);
} else {
fread(&LIMIThdr, sizeof(LIMIThdr), 1, pLimits);
while (fread(&LIMIT, sizeof(LIMIT), 1, pLimits) == 1) {
if (LIMIT.Security == usrconfig.Security.level) {
if (LIMIT.Time)
usrconfig.iTimeLeft = LIMIT.Time;
else
usrconfig.iTimeLeft = 86400;
usrconfig.iTimeUsed = 0;
break;
}
}
fclose(pLimits);
}
free(temp);
} }
break; break;
case 16:EditUsrRec2(); case 16:EditUsrRec2();