char olduser[MAX_USER_LEN], csort[MAXLEN];
char wger[MAXLEN], top1[MAXLEN], top2[MAXLEN], top3[MAXLEN], user[MAX_USER_LEN];
char strip1[MAXLEN], strip2[MAXLEN], strip3[MAXLEN], strip4[MAXLEN], strip5[MAXLEN], strip6[MAXLEN], strip7[MAXLEN];
- char buf[MAXLEN];
+ char *buf;
+ char warea[MAXLEN];
int totuser=0;
time_t t;
struct tm *local;
int cstatus;
- char warea[MAXLEN];
struct getwordstruct gwarea;
struct generalitemstruct item;
+ longline line;
snprintf(wger,sizeof(wger),"%s/sarg-general",dirname);
if((fp_in=fopen(wger,"r"))==NULL) {
olduser[0]='\0';
totuser=0;
- while(fgets(warea,sizeof(warea),fp_in)) {
- ger_read(warea,&item,wger);
+ if ((line=longline_create())==NULL) {
+ debuga(_("Not enough memory to read file %s\n"),wger);
+ exit(EXIT_FAILURE);
+ }
+
+ while((buf=longline_read(fp_in,line))!=NULL) {
+ ger_read(buf,&item,wger);
if(item.total) continue;
if(strcmp(olduser,item.user) != 0)
{
tnacc+=item.nacc;
tnelap+=item.nelap;
}
+ fclose(fp_in);
+ longline_destroy(&line);
if (olduser[0] != '\0') {
#if defined(__FreeBSD__)
ttnelap+=tnelap;
}
- fclose(fp_in);
fclose(fp_top2);
sprintf(csort,"sort -n -T \"%s\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2);
while(fgets(warea,sizeof(warea),fp_top1))
{
+ fixendofline(warea);
getword_start(&gwarea,warea);
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
debuga(_("There is an invalid user ID in file %s\n"),top1);
debuga(_("There is an invalid number of access in file %s\n"),top1);
exit(EXIT_FAILURE);
}
- if (getword_atoll(&elap,&gwarea,'\t')<0) {
+ if (getword_atoll(&elap,&gwarea,'\0')<0) {
debuga(_("There is an invalid elapsed time in file %s\n"),top1);
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
- while(fgets(buf,sizeof(buf),fp_top3)!=NULL)
- fputs(buf,stdout);
+ while(fgets(warea,sizeof(warea),fp_top3)!=NULL)
+ fputs(warea,stdout);
} else {
- snprintf(buf,sizeof(buf),"\"%s\" -s \"SARG %s, %s\" \"%s\" <\"%s\"",MailUtility,_("Report"),asctime(local),email,top3);
- cstatus=system(buf);
+ snprintf(warea,sizeof(warea),"\"%s\" -s \"SARG %s, %s\" \"%s\" <\"%s\"",MailUtility,_("Report"),asctime(local),email,top3);
+ cstatus=system(warea);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("command: %s\n"),buf);
+ debuga(_("command: %s\n"),warea);
exit(EXIT_FAILURE);
}
}