smartfilter.c denied.c authfail.c charset.c
squidguard_log.c squidguard_report.c auth.c download.c grepday.c
dansguardian_log.c dansguardian_report.c realtime.c btree_cache.c
- usertab.c userinfo.c)
+ usertab.c userinfo.c longline.c)
FOREACH(f ${SRC})
ADD_FILE_DEPENDENCIES(${f} ${CMAKE_BINARY_DIR}/config.h ${CMAKE_SOURCE_DIR}/include/conf.h ${CMAKE_SOURCE_DIR}/include/info.h ${CMAKE_SOURCE_DIR}/include/defs.h)
smartfilter.c denied.c authfail.c charset.c \
squidguard_log.c squidguard_report.c auth.c download.c grepday.c \
dansguardian_log.c dansguardian_report.c realtime.c btree_cache.c \
- usertab.c userinfo.c
+ usertab.c userinfo.c longline.c
OBJS = $(patsubst %.c,%.o,$(SRCS))
--- /dev/null
+/*! \file util.c
+\brief Various useful functions.
+*/
+
+
+/*! \def INITIAL_LINE_BUFFER_SIZE
+The initial buffer size to allocate to read a long line from a text file.
+*/
+
+
+
+
+
+
+/*! \fn int longline_prepare(struct longlinestruct *line)
+Prepare the buffer to read long text lines from a file.
+
+The memory allocated by this function must be freed with a call to
+longline_free().
+
+\param line The buffer to initialize.
+
+\retval 0 No error.
+\retval -1 Not enough memory.
+*/
+
+
+
+
+
+/*! \fn char *longline_read(FILE *fp_in,struct longlinestruct *line)
+Read one long line of text from a file. If the buffer is too short, it is
+expended until the line can fit in it.
+
+The function always read as many bytes as can fit in the buffer and split the lines
+to return one line at a time to the caller. The returned lines are always terminated
+by a null ASCII character. The CR or LF are removed.
+
+Any empty line is skipped.
+
+\param fp_in The file to read.
+\param line The buffer initialized by longline_preapre().
+
+\return A pointer to the beginning of the string in the buffer or NULL if it is
+the last string read.
+
+\note If not enough memory is available to read the line, the program is terminated
+with an error message.
+*/
+
+
+
+
+
+/*! \fn void longline_free(struct longlinestruct *line)
+Free the memory allocated by longline_prepare().
+
+\param line The buffer to free.
+*/
-/*! \def INITIAL_LINE_BUFFER_SIZE
-The initial buffer size to allocate to read a long line from a text file.
-*/
-
-
-
-
/*! \var static char mtab1[12][4];
The list of the months.
*/
itself in place. If set to \c zero, the directory is removed too.
*/
-
-
-
-
-/*! \fn int longline_prepare(struct longlinestruct *line)
-Prepare the buffer to read long text lines from a file.
-
-The memory allocated by this function must be freed with a call to
-longline_free().
-
-\param line The buffer to initialize.
-
-\retval 0 No error.
-\retval -1 Not enough memory.
-*/
-
-
-
-
-
-/*! \fn char *longline_read(FILE *fp_in,struct longlinestruct *line)
-Read one long line of text from a file. If the buffer is too short, it is
-expended until the line can fit in it.
-
-The function always read as many bytes as can fit in the buffer and split the lines
-to return one line at a time to the caller. The returned lines are always terminated
-by a null ASCII character. The CR or LF are removed.
-
-Any empty line is skipped.
-
-\param fp_in The file to read.
-\param line The buffer initialized by longline_preapre().
-
-\return A pointer to the beginning of the string in the buffer or NULL if it is
-the last string read.
-
-\note If not enough memory is available to read the line, the program is terminated
-with an error message.
-*/
-
-
-
-
-
-/*! \fn void longline_free(struct longlinestruct *line)
-Free the memory allocated by longline_prepare().
-
-\param line The buffer to free.
-*/
void useragent(void);
// userinfo.c
-struct userinfostruct *userinfo_create(const char *userid);
+/*@shared@*/struct userinfostruct *userinfo_create(const char *userid);
void userinfo_free(void);
-struct userinfostruct *userinfo_find_from_file(const char *filename);
-struct userinfostruct *userinfo_find_from_id(const char *id);
+/*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename);
+/*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id);
// usertab.c
void init_usertab(const char *UserTabFile);
--- /dev/null
+/*
+ * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
+ * 1998, 2010
+ *
+ * SARG donations:
+ * please look at http://sarg.sourceforge.net/donations.php
+ * Support:
+ * http://sourceforge.net/projects/sarg/forums/forum/363374
+ * ---------------------------------------------------------------------
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#include "include/conf.h"
+#include "include/defs.h"
+
+#define INITIAL_LINE_BUFFER_SIZE 32768
+
+int longline_prepare(struct longlinestruct *line)
+{
+ line->size=INITIAL_LINE_BUFFER_SIZE;
+ line->buffer=malloc(line->size);
+ if (!line->buffer)
+ return(-1);
+ line->start=0;
+ line->end=0;
+ line->length=0;
+ return(0);
+}
+
+char *longline_read(FILE *fp_in,struct longlinestruct *line)
+{
+ int i;
+ char *newbuf;
+ size_t nread;
+
+ if (!line->buffer) return(NULL);
+
+ while (1) {
+ for (i=line->end ; i<line->length && (line->buffer[i]=='\n' || line->buffer[i]=='\r') ; i++);
+ if (i<line->length) {
+ line->end=i;
+ break;
+ }
+ nread=(feof(fp_in)) ? 0 : fread(line->buffer,1,line->size,fp_in);
+ if (nread==0) return(NULL);
+ line->length=nread;
+ line->end=0;
+ }
+
+ line->start=line->end;
+ while (1) {
+ for (i=line->end ; i<line->length && line->buffer[i]!='\n' && line->buffer[i]!='\r' ; i++);
+ line->end=i;
+ if (line->end<line->length) break;
+
+ if (line->start>0) {
+ for (i=line->start ; i<line->length ; i++) line->buffer[i-line->start]=line->buffer[i];
+ line->length-=line->start;
+ line->end-=line->start;
+ line->start=0;
+ }
+ if (line->length>=line->size) {
+ line->size+=8192;
+ newbuf=realloc(line->buffer,line->size);
+ if (!newbuf) {
+ debuga(_("Not enough memory to read one more line from the input log file\n"));
+ exit(EXIT_FAILURE);
+ }
+ line->buffer=newbuf;
+ }
+ nread=(feof(fp_in)) ? 0 : fread(line->buffer+line->length,1,line->size-line->length,fp_in);
+ if (nread==0) {
+ if (line->end<=line->start) return(NULL);
+ if (line->end>=line->size) {
+ line->end=line->size;
+ line->size++;
+ newbuf=realloc(line->buffer,line->size);
+ if (!newbuf) {
+ debuga(_("Not enough memory to read one more line from the input log file\n"));
+ exit(EXIT_FAILURE);
+ }
+ line->buffer=newbuf;
+ }
+ line->buffer[line->end]='\0';
+ return(line->buffer+line->start);
+ }
+ line->length+=nread;
+ }
+ line->buffer[line->end++]='\0';
+ return(line->buffer+line->start);
+}
+
+void longline_free(struct longlinestruct *line)
+{
+ if (line->buffer) {
+ free(line->buffer);
+ line->buffer=NULL;
+ }
+}
-DRLIM_STRING="%d"
-DICONV_CONST
-DHAVE_LC_MESSAGES=1
+-D__GNUC__
#define USE_GETWORD_BACKTRACE 0
#endif
-#define INITIAL_LINE_BUFFER_SIZE 32768
-
static char mtab1[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
//! The list of the HTTP codes to exclude from the report.
}
}
-int longline_prepare(struct longlinestruct *line)
-{
- line->size=INITIAL_LINE_BUFFER_SIZE;
- line->buffer=malloc(line->size);
- if (!line->buffer)
- return(-1);
- line->start=0;
- line->end=0;
- line->length=0;
- return(0);
-}
-
-char *longline_read(FILE *fp_in,struct longlinestruct *line)
-{
- int i;
- char *newbuf;
- size_t nread;
-
- if (!line->buffer) return(NULL);
-
- while (1) {
- for (i=line->end ; i<line->length && (line->buffer[i]=='\n' || line->buffer[i]=='\r') ; i++);
- if (i<line->length) {
- line->end=i;
- break;
- }
- nread=(feof(fp_in)) ? 0 : fread(line->buffer,1,line->size,fp_in);
- if (nread==0) return(NULL);
- line->length=nread;
- line->end=0;
- }
-
- line->start=line->end;
- while (1) {
- for (i=line->end ; i<line->length && line->buffer[i]!='\n' && line->buffer[i]!='\r' ; i++);
- line->end=i;
- if (line->end<line->length) break;
-
- if (line->start>0) {
- for (i=line->start ; i<line->length ; i++) line->buffer[i-line->start]=line->buffer[i];
- line->length-=line->start;
- line->end-=line->start;
- line->start=0;
- }
- if (line->length>=line->size) {
- line->size+=8192;
- newbuf=realloc(line->buffer,line->size);
- if (!newbuf) {
- debuga(_("Not enough memory to read one more line from the input log file\n"));
- exit(EXIT_FAILURE);
- }
- line->buffer=newbuf;
- }
- nread=(feof(fp_in)) ? 0 : fread(line->buffer+line->length,1,line->size-line->length,fp_in);
- if (nread==0) {
- if (line->end<=line->start) return(NULL);
- if (line->end>=line->size) {
- line->end=line->size;
- line->size++;
- newbuf=realloc(line->buffer,line->size);
- if (!newbuf) {
- debuga(_("Not enough memory to read one more line from the input log file\n"));
- exit(EXIT_FAILURE);
- }
- line->buffer=newbuf;
- }
- line->buffer[line->end]='\0';
- return(line->buffer+line->start);
- }
- line->length+=nread;
- }
- line->buffer[line->end++]='\0';
- return(line->buffer+line->start);
-}
-
-void longline_free(struct longlinestruct *line)
-{
- if (line->buffer) {
- free(line->buffer);
- line->buffer=NULL;
- }
-}