"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/reports/r_email.c" between
free-sa-1.6.2.tar.gz and free-sa-2.0.0b6p7.tar.gz

About: Free-SA is a fast statistic analyzer for daemons log files (with SVG bar/pie graphics support). Beta version.

r_email.c  (free-sa-1.6.2):r_email.c  (free-sa-2.0.0b6p7)
#include "global.h" #include "global.h"
size_t maxvname = 0L; size_t maxvname = 0L;
#define LENNO 4L #define LENNO 4L
#define LENCONN 7L #define LENCONN 7L
#define LENBYTES 15L #define LENBYTES 15L
void ReportEmail(void) { void ReportEmail(void) {
FILE *ER; FILE *ER;
short int i; short int i, j;
int nolen = (int)SAmax(LENNO, strlen(loc->No)), int nolen = (int)SAmax(LENNO, strlen(loc->No)),
userlen = (int)SAmax(maxvname, strlen(loc->User)), userlen = (int)SAmax(maxvname, strlen(loc->User)),
connlen = (int)SAmax(LENCONN, strlen(loc->Connections)), connlen = (int)SAmax(LENCONN, strlen(loc->Connections)),
byteslen = (int)SAmax(LENBYTES, strlen(loc->Bytes)); byteslen = (int)SAmax(LENBYTES, strlen(loc->Bytes));
char stext[FILENAMESIZE * 2L], tfname[FILENAMESIZE]; char stext[FILENAMESIZE * 2L], tfname[FILENAMESIZE];
/* ER: open */ /* ER: open */
if (cfg.ER[0] == '-' && cfg.ER[1] == '\0') ER = stdout; if (cfg.email_address[0] == '-' && cfg.email_address[1] == '\0') ER = stdout ;
else { else {
SAsnprintf(tfname, sizeof(tfname), "%s/%s", cfg.TmpDir, icfg.ERname); SAsnprintf(tfname, sizeof(tfname), "%s/%s", cfg.cache_directory, icfg.ERn ame);
ER = SAfopenI("w", tfname); ER = SAfopenI("w", tfname);
} }
/* ER: header */ /* ER: header */
SAfprintf(ER, "\ SAfprintf(ER, "%*s %-*s %*s %*s",
%*s p s p s c p d l\n\ nolen, loc->No, userlen, loc->User, connlen, loc->Connections, bytesl
%*s %-*s %*s %*s a a d d c s l c\n\ en, loc->Bytes);
%*s f f n n t t d f\n", for (j = 0; j < icfg.LFcsscount; j++) SAfprintf(ER, " %hd", j);
nolen + userlen + connlen + byteslen + 3, " ", SAfputs("\n", ER);
nolen, loc->No, userlen, loc->User, connlen, loc->Connections, bytesl
en, loc->Bytes,
nolen + userlen + connlen + byteslen + 3, " ");
/* ER: separator */ /* ER: separator */
for (i = 0; i < nolen + userlen + connlen + byteslen + 8 + 4 + 7; i++) SAfwr for (i = 0; i < nolen + userlen + connlen + byteslen + 8 + 4 + 7; i++) SAfpu
ite1("=", 1L, ER); ts("=", ER);
SAfwrite1("\n", 1L, ER); SAfputs("\n", ER);
/* ER: body */ /* ER: body */
for (i = 0; i < icfg.ueCount; i++) for (i = 0; i < icfg.ueCount; i++)
if (Users[i].count) if (Users[i].U.count) {
SAfprintf(ER, "%*hd %-*s %"SATSEP"*d %*s %c %c %c %c %c %c %c %c\n", SAfprintf(ER, "%*hd %-*s %"SATSEP"*d %*s", nolen, i + 1, userlen, Use
nolen, i + 1, rs[i].vname, connlen, Users[i].U.count, byteslen, icfg.SAB(Users[i].U.bytes));
userlen, Users[i].vname, for (j = 0; j < icfg.LFcsscount; j++) SAfprintf(ER, " %c", (Users[i].
connlen, Users[i].count, LF[j].count ? '+' : ' '));
byteslen, icfg.SAB(Users[i].Bytes), SAfputs("\n", ER);
(Users[i].TTcount[PAF]) ? '1' : ' ', }
(Users[i].TTcount[SAF]) ? '2' : ' ',
(Users[i].TTcount[PDN]) ? '3' : ' ',
(Users[i].TTcount[SDN]) ? '4' : ' ',
(Users[i].TTcount[CCT]) ? '5' : ' ',
(Users[i].TTcount[PST]) ? '6' : ' ',
(Users[i].TTcount[DLD]) ? '7' : ' ',
(Users[i].TTcount[LCF]) ? '8' : ' ');
/* ER: separator */ /* ER: separator */
for (i = 0; i < nolen + userlen + connlen + byteslen + 8 + 4 + 7; i++) SAfwr for (i = 0; i < nolen + userlen + connlen + byteslen + 8 + 4 + 7; i++) SAfpu
ite1("=", 1L, ER); ts("=", ER);
SAfwrite1("\n", 1L, ER); SAfputs("\n", ER);
/* ER: total and average */ /* ER: total and average */
SAfprintf(ER, "%*s %-*s %"SATSEP"*d %*s\n", nolen, " ", userlen, loc->TOTAL, connlen, ccCount, byteslen, icfg.SAB(ccBytes)); SAfprintf(ER, "%*s %-*s %"SATSEP"*d %*s\n", nolen, " ", userlen, loc->TOTAL, connlen, ccCount, byteslen, icfg.SAB(ccBytes));
SAfprintf(ER, "%*s %-*s %"SATSEP"*d %*s\n", nolen, " ", userlen, loc->AVERAG E, connlen, ccCount / ccueCount, byteslen, icfg.SAB(ccBytes / ccueCount)); SAfprintf(ER, "%*s %-*s %"SATSEP"*d %*s\n", nolen, " ", userlen, loc->AVERAG E, connlen, ccCount / ccueCount, byteslen, icfg.SAB(ccBytes / ccueCount));
/* ER: close and mail */ /* ER: close and mail */
if (!(cfg.ER[0] == '-' && cfg.ER[1] == '\0')) { if (!(cfg.email_address[0] == '-' && cfg.email_address[1] == '\0')) {
SAfclose(ER, icfg.ERname); SAfclose(ER);
SAsnprintf(stext, sizeof(stext), "%s -s \"[%s] %s %s\" %s < %s", CMDMAILX SAsnprintf(stext, sizeof(stext), "%s -s \"[%s] %s %s\" %s < %s", CMDMAILX
, PROGNAME, icfg.Period, cfg.Name, cfg.ER, tfname); , PROGNAME, icfg.Period, cfg.configuration_name, cfg.email_address, tfname);
SAsystem(CMDSH, CMDSH, "-c", stext, NULL); SAsystem(CMDSH, CMDSH, "-c", stext, NULL);
SAunlink(tfname); SAunlink(tfname);
} }
} }
 End of changes. 8 change blocks. 
35 lines changed or deleted 25 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS