Bug!

Eugeny Balahonov johnball@bay.da.ru
Thu Dec 9 01:12:00 GMT 1999


Hello egcs-bugs,

  My egcs 2.91.66 write:

  Internal compiler error 980711

  On string:

  typedef std::set<TInMsgRec> TInMsgRecSet;

  Current source:


/***************************************************************************
                          main.cpp  -  description
                             -------------------
    begin                : ðÔÎ äÅË  3 10:17:52 EET 1999
    copyright            : (C) 1999 by Eugeny Balahonov
    email                : johnball@bmz.gomel.by
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string>
#include <set>
#include <time.h>
#include "ConfigUnit.h"
#include "oracle_interface.h"
#include "LogUnit.h"
#include "Utils.h"

const int MAX_LOG_LINE = 1024;

// --------------------------------------------------------------------------------------------------------------------------------------------

struct TInMsgRec
{
 time_t DateTime;
 std::string ID;
 std::string From;
 unsigned int Size;
 std::string Relay;

 TInMsgRec()
 {
   Size = 0;
 }

 TInMsgRec(TInMsgRec& InMsgRec)
 {
   Size = 0;
   operator=(InMsgRec);
 }

 bool operator<(TInMsgRec& InMsgRec)
 {
   return (ID < InMsgRec.ID);
 }

 TInMsgRec& operator=(TInMsgRec& InMsgRec)
 {
   ID = InMsgRec.ID;
   From = InMsgRec.From;
   Size = InMsgRec.Size;
   Relay = InMsgRec.Relay;
 }
}

typedef std::set<TInMsgRec> TInMsgRecSet;
//^^^^^^^ This is internal error of egcs ^^^^^^

TInMsgRecSet InMsgRecSet;

// --------------------------------------------------------------------------------------------------------------------------------------------

time_t GetLogStringTime(char* S)
{
 struct tm Time;
 time_t CurrentTime;
 time(&CurrentTime);
 struct tm* TempTime = localtime(&CurrentTime);
 memcpy(&Time, TempTime, sizeof(tm));
 int Month = Time.tm_mon;

 char* Word = GetWord(S, 0);
 if (!Word)
  return 0;

 if (strcmp(Word, "Jan") == 0)
  Time.tm_mon = 0;
 else if (strcmp(Word, "Feb") == 0)
  Time.tm_mon = 1;
 else if (strcmp(Word, "Mar") == 0)
  Time.tm_mon = 2;
 else if (strcmp(Word, "Apr") == 0)
  Time.tm_mon = 3;
 else if (strcmp(Word, "May") == 0)
  Time.tm_mon = 4;
 else if (strcmp(Word, "Jun") == 0)
  Time.tm_mon = 5;
 else if (strcmp(Word, "Jul") == 0)
  Time.tm_mon = 6;
 else if (strcmp(Word, "Aug") == 0)
  Time.tm_mon = 7;
 else if (strcmp(Word, "Sep") == 0)
  Time.tm_mon = 8;
 else if (strcmp(Word, "Oct") == 0)
  Time.tm_mon = 9;
 else if (strcmp(Word, "Nov") == 0)
  Time.tm_mon = 10;
 else if (strcmp(Word, "Dec") == 0)
  Time.tm_mon = 11;

 delete[] Word;

 Word = GetWord(S, 1);
 if (!Word)
  return 0;
 Time.tm_mday = atoi(Word);
 delete[] Word;

 Word = GetWord(S, 2);
 if (!Word)
  return 0;

 char* SubWord = GetWord(Word, 0, ':');
 if (!SubWord)
 {
  delete[] Word;
  return 0;
 }
 Time.tm_hour = atoi(SubWord);
 delete[] SubWord;

 SubWord = GetWord(Word, 1, ':');
 if (!SubWord)
 {
  delete[] Word;
  return 0;
 }
 Time.tm_min = atoi(SubWord);
 delete[] SubWord;

 SubWord = GetWord(Word, 2, ':');
 if (!SubWord)
 {
  delete[] Word;
  return 0;
 }
 Time.tm_sec = atoi(SubWord);
 delete[] SubWord;

 Time.tm_wday = 0;
 Time.tm_yday = 0;

 if (Month > Time.tm_mon)
  Time.tm_year++;

 delete[] Word;
 return mktime(&Time);
}

// --------------------------------------------------------------------------------------------------------------------------------------------

int main(int argc, char *argv[])
{
 Log << Level(1) << Info << Time << "Start mail traffic analyzer." << endl;
 Log << Level(2) << Info << Time << "Reading configuration file" << endl;

 if (!AppConfig.Load())
 {
  Log << Error << Time << "Error of read config file." << endl;
  exit(-1);
 }

 // Opening log file for analyzing
 FILE* MailLogFile = fopen(AppConfig.MailLog, "r");

 if (MailLogFile == NULL)
 {
   Log << Error << Time << "Error of open file " << AppConfig.MailLog << endl;
   exit(-1);
 }
 else
  Log << Level(2) << Info << Time << "Mail log " << AppConfig.MailLog << " successfull open." << endl;

 cout.flush();

 Log << Level(2) << Info << Time << "Connecting to Oracle database ..." << endl;
 COracle Oracle;
 try
 {
  Oracle.Connect(AppConfig.OraUserName, AppConfig.OraPassword, AppConfig.OraConnectString);
 }
 catch (char* ErrorMsg)
 {
  Log << Error << Time << "Error  of connecting with Oracle. Oracle error message: \n" << ErrorMsg << endl;
  exit(-1);
 }
 Log << Level(2) << Info << Time << "Connected to Oracle succesfully." << endl;

 Log << Level(3) << Info << Time << "Getting date and time of last analyzed record of mail log file..." << endl;

 time_t LastRecordTime = 0;
 try
 {
  LastRecordTime = Oracle.GetLastRecordDate();
 }
 catch (char* ErrorMsg)
 {
  Log << Error << Time << "Error of getting date and time of last analyzed record of mail log file. Oracle error message: \n" << ErrorMsg << endl;
  exit(-1);
 }

 char Temp[512];
 strcpy(Temp, ctime(&LastRecordTime));
 Log << Level(3) << Info << Time << "Time of last analyzed record is \"" << Temp << "\"" << endl;

 Log << Level(2) << Info << Time << "Analyze log file ..." << endl;

 char Buf[MAX_LOG_LINE];
 while (!feof(MailLogFile))
 {
   fgets(Buf, MAX_LOG_LINE, MailLogFile);
   time_t DateTime = GetLogStringTime(Buf);
   if (DateTime <= LastRecordTime)
   {
    Log << Level(4) << Info << Time << "Skipping string (old time):\n" << Buf << endl;
    continue;
   }

   char* Word = GetWord(Buf, 4);
   if (!Word)
   {
    Log << Level(4) << Info << Time << "Skipping string (Bad string):\n" << Buf << endl;
    continue;
   }

   if (!strstr(Word, "sendmail"))
   {
     Log << Level(4) << Info << Time << "Skipping string (Not found word \"sendmail\"):\n" << Buf << endl;
     delete[] Word;
     continue;
   }
   delete[] Word;

   char* Word = GetWord(Buf, 6);
   if (!Word)
   {
    Log << Level(4) << Info << Time << "Skipping string (Bad string):\n" << Buf << endl;
    continue;
   }

   if (strstr(Word, "from="))
   {
    char* ID = GetWord(Buf, 5);
    if (!ID)
    {
     delete[] Word;
     continue;
    }

    char* Addr = ExtractValue('<', '>', Word);
    if (!Addr)
    {
     delete[] Word;
     continue;
    }

    TInMsgRec InMsgRec;
    InMsgRec.DateTime = DateTime;
    InMsgRec.ID = ID;
    InMsgRec.From = Addr;
    delete[] ID;
    delete[] Addr;
    delete[] Word;

    Word = GetWord(Buf, 7);
    if (!Word)
     continue;

    ID = GetWord(Word, 1, '=');
    delete[] Word;
    if (!ID)
     continue;

    if (ID[strlen(ID) - 1] == ',')
     ID[strlen(ID) - 1] = 0;

    InMsgRec.Size = atoi(ID);
    delete[] ID;

    Word = GetWord(Buf, 14);
    if (!Word)
     continue;

    ID = GetWord(Word, 1, '=');
    delete[] Word;
    if (!ID)
     continue;

    InMsgRec.Relay = ID;
    delete[] ID;

    InMsgRecSet.insert(InMsgRec);
   }
   else
   {


   }
 }

 fclose(MailLogFile);
 Log << Level(2) << Info << Time << "File \"" << AppConfig.MailLog << "\" successfull closed." << endl;

 Log << Level(2) << Info << Time << "Disconnecting from Oracle database ..." << endl;
 Oracle.Disconnect();

 Log << Level(1) << Info << Time << "Exit success." << endl;
 return EXIT_SUCCESS;
}
  
  
  

Best regards,
 Eugeny                          mailto:johnball@bay.da.ru




More information about the Gcc-bugs mailing list