+//! Log file where the user agent data are written.
+static char UserAgentTempLog[MAXLEN]="";
+
+static struct tm UserAgentStartDate;
+static struct tm UserAgentEndDate;
+
+/*!
+ * Open the temporary file to store the useragent entries to be
+ * reported.
+ *
+ * \return The file handle. It must be closed when the data have
+ * been written.
+ */
+FILE *UserAgent_Open(void)
+{
+ FILE *fp_ou;
+
+ if (UserAgentTempLog[0]) {
+ debuga(__FILE__,__LINE__,_("Useragent log already opened\n"));
+ exit(EXIT_FAILURE);
+ }
+ snprintf(UserAgentTempLog,sizeof(UserAgentTempLog),"%s/squagent.int_unsort",tmp);
+ if ((fp_ou=fopen(UserAgentTempLog,"w"))==NULL) {
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),UserAgentTempLog,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ memset(&UserAgentStartDate,0,sizeof(UserAgentStartDate));
+ memset(&UserAgentEndDate,0,sizeof(UserAgentEndDate));
+ return(fp_ou);
+}
+
+/*!
+ * Write a user agent entry into the temporary log.
+ *
+ * \param fp The file opened by UserAgent_Open().
+ * \param Ip The IP address using this agent.
+ * \param User The user name.
+ * \param Agent The user agent string.
+ */
+void UserAgent_Write(FILE *fp,const char *Ip,const char *User,const char *Agent)
+{
+ fprintf(fp,"%s\t%s\t%s\n",Ip,Agent,User);
+ useragent_count++;
+}
+
+/*!
+ * Read the user provided useragent file and create
+ * a temporary file with the data to report.
+ */
+void UserAgent_Readlog(void)