"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sort.c" between
sarg-2.3.11.tar.gz and sarg-2.4.0.tar.gz

About: SARG ia a Squid Analysis Report Generator.

sort.c  (sarg-2.3.11):sort.c  (sarg-2.4.0)
/* /*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2013 * 1998, 2015
* *
* SARG donations: * SARG donations:
* please look at http://sarg.sourceforge.net/donations.php * please look at http://sarg.sourceforge.net/donations.php
* Support: * Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374 * http://sourceforge.net/projects/sarg/forums/forum/363374
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
skipping to change at line 46 skipping to change at line 46
void tmpsort(const struct userinfostruct *uinfo) void tmpsort(const struct userinfostruct *uinfo)
{ {
int cstatus; int cstatus;
char csort[MAXLEN]; char csort[MAXLEN];
char arqou[MAXLEN], arqin[MAXLEN]; char arqou[MAXLEN], arqin[MAXLEN];
const char *field1="2,2"; const char *field1="2,2";
const char *field2="1,1"; const char *field2="1,1";
const char *field3="3,3"; const char *field3="3,3";
const char *order; const char *order;
if((UserSort & USER_SORT_CONNECT) != 0) { if ((UserSort & USER_SORT_CONNECT) != 0) {
field1="1,1"; field1="1,1";
field2="2,2"; field2="2,2";
field3="3,3"; field3="3,3";
} else if((UserSort & USER_SORT_SITE) != 0) { } else if ((UserSort & USER_SORT_SITE) != 0) {
field1="3,3"; field1="3,3";
field2="2,2"; field2="2,2";
field3="1,1"; field3="1,1";
} else if((UserSort & USER_SORT_TIME) != 0) { } else if ((UserSort & USER_SORT_TIME) != 0) {
field1="5,5"; field1="5,5";
field2="2,2"; field2="2,2";
field3="1,1"; field3="1,1";
} }
if((UserSort & USER_SORT_REVERSE) == 0) if ((UserSort & USER_SORT_REVERSE) == 0)
order=""; order="";
else else
order="-r"; order="-r";
if (snprintf(arqin,sizeof(arqin),"%s/%s.utmp",tmp,uinfo->filename)>=sizeo f(arqin)) { if (snprintf(arqin,sizeof(arqin),"%s/%s.utmp",tmp,uinfo->filename)>=sizeo f(arqin)) {
debuga(_("Path too long: ")); debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.utmp\n",tmp,uinfo->filename); debuga_more("%s/%s.utmp\n",tmp,uinfo->filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (snprintf(arqou,sizeof(arqou),"%s/htmlrel.txt",tmp)>=sizeof(arqou)) { if (snprintf(arqou,sizeof(arqou),"%s/htmlrel.txt",tmp)>=sizeof(arqou)) {
debuga(_("Path too long: ")); debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/htmlrel.txt\n",tmp); debuga_more("%s/htmlrel.txt\n",tmp);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if(debug) { if (debug) {
debuga(_("Sorting file \"%s\"\n"),arqin); debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),arqin);
} }
if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof( csort)) { if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof( csort)) {
debuga(_("Command too long: ")); debuga(__FILE__,__LINE__,_("Sort command too long when sorting fi
debuga_more("sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o le \"%s\" to \"%s\"\n"),arqin,arqou);
\"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
cstatus=system(csort); cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) { if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus)) debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEX
; ITSTATUS(cstatus));
debuga(_("sort command: %s\n"),csort); debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!KeepTempLog && unlink(arqin)) { if (!KeepTempLog && unlink(arqin)) {
debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno)); debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqin,st rerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return; return;
} }
/*! /*!
The function sorts the \c unsort file in the temporary directory. These files co rrespond The function sorts the \c unsort file in the temporary directory. These files co rrespond
to the format described in \ref UserUnsortLog. to the format described in \ref UserUnsortLog.
skipping to change at line 120 skipping to change at line 119
The sorted files are written in files with the extension \c log and the name of the unsorted The sorted files are written in files with the extension \c log and the name of the unsorted
file without the \c unsort extension. The unsorted file is deleted just after th e sorting. file without the \c unsort extension. The unsorted file is deleted just after th e sorting.
*/ */
void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo) void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo)
{ {
char csort[MAXLEN]; char csort[MAXLEN];
const char *user; const char *user;
int cstatus; int cstatus;
int clen; int clen;
if(debug) { if (debug) {
debuga(_("Sorting log %s/%s.user_unsort\n"),tmp,uinfo->filename); snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,uinfo->filen
ame);
debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),csort);
} }
user=uinfo->filename; user=uinfo->filename;
clen=snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"%s/%s.user_log\" \"%s/%s.user_unsort\"", clen=snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"%s/%s.user_log\" \"%s/%s.user_unsort\"",
tmp, tmp, user, tmp, user); tmp, tmp, user, tmp, user);
if (clen>=sizeof(csort)) { if (clen>=sizeof(csort)) {
/* TRANSLATORS: The message is followed by the command that is to o long. */ /* TRANSLATORS: The message is followed by the command that is to o long. */
debuga(_("User name too long to sort with command ")); debuga(__FILE__,__LINE__,_("User name too long to sort with comma nd "));
debuga_more("sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"% s/%s.user_log\" \"%s/%s.user_unsort\"", debuga_more("sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"% s/%s.user_log\" \"%s/%s.user_unsort\"",
tmp, tmp, user, tmp, user); tmp, tmp, user, tmp, user);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
cstatus=system(csort); cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) { if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus)) debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEX
; ITSTATUS(cstatus));
debuga(_("sort command: %s\n"),csort); debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,user)>=sizeof(cs ort)) { if (snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,user)>=sizeof(cs ort)) {
debuga(_("User name too long to manufacture file name ")); debuga(__FILE__,__LINE__,_("User name too long to manufacture fil e name "));
debuga_more("%s/%s.user_unsort\n",tmp,user); debuga_more("%s/%s.user_unsort\n",tmp,user);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!KeepTempLog && unlink(csort)) { if (!KeepTempLog && unlink(csort)) {
debuga(_("Cannot delete \"%s\": %s\n"),csort,strerror(errno)); debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),csort,st rerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return; return;
} }
/*! /*!
Get the internationalized text to display when reporting the sort criterion and order Get the internationalized text to display when reporting the sort criterion and order
of a user list. of a user list.
\param label A pointer to set to the string of the sort criterion name. \param label A pointer to set to the string of the sort criterion name.
\param order A pointer to set to the string of the sort order name \param order A pointer to set to the string of the sort order name
*/ */
void sort_labels(const char **label,const char **order) void sort_labels(const char **label,const char **order)
{ {
if((UserSort & USER_SORT_CONNECT) != 0) { if ((UserSort & USER_SORT_CONNECT) != 0) {
*label=_("connect"); *label=_("connect");
} else if((UserSort & USER_SORT_SITE) != 0) { } else if ((UserSort & USER_SORT_SITE) != 0) {
*label=_("site"); *label=_("site");
} else if((UserSort & USER_SORT_TIME) != 0) { } else if ((UserSort & USER_SORT_TIME) != 0) {
*label=_("time"); *label=pgettext("duration","time");
} else { } else {
*label=_("bytes"); *label=_("bytes");
} }
if((UserSort & USER_SORT_REVERSE) == 0) if ((UserSort & USER_SORT_REVERSE) == 0)
*order=_("normal"); *order=_("normal");
else else
*order=_("reverse"); *order=_("reverse");
} }
 End of changes. 21 change blocks. 
30 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)