As described in the Epistula document, the CreateMessageID function generates ids with the following components:- - Date and time of the form YYYYMMDD.hhmmss - A 'last second' counter or LSC (see below) - The client IP address - A nmemonc of 'ep' (Epistula) or 'ds' (Dissemino) So the overall form is YYYYMMDD.hhmmss.LSC_clientIP_ep@domainName To cope with system clock retartations this function uses a static variable of 'latest known time' (LKT) and a dynamic variable of 'last-second' counter (LSC). The LKT has an intial value of midnight, Jan 1st, 0000. The process begins by reading the clock to an accuracy of one second. If the clock shows a LATER time than the LKT, the LKT is set equal to the clock and the LSC is set to 0 (this always happens in the first instance). If the clock shows a time EQUAL to or EARLIER than the LKT, the LKT is unchanged but the LSC is incremented by 1. In ALL cases the id is formed of the LKT and the LSC, however where the clock was found to have an EARLIER time than the LKT, the LKT and the LSC are separated by an underscore rather than a period. Returns: None

Return TypeFunction nameArguments
voidCreateMessageID(hzString&,hzDomain&,)

Declared in file: hzMailer.h
Defined in file : hzMailer.cpp

Function Logic:

0:START 1:items 2:unknown 3:LKT LSC 4:unknown 5:bUscore 6:items 7:items 8:unknown 9:items 10:items 11:items items items mailId 12: No text

Function body:

void CreateMessageID (hzString& mailId)hzDomain& domain, 
{
   //  Category: Mailer
   //  
   //  As described in the Epistula document, the CreateMessageID function generates ids with the following components:-
   //  
   //  - Date and time of the form YYYYMMDD.hhmmss
   //  - A 'last second' counter or LSC (see below)
   //  - The client IP address
   //  - A nmemonc of 'ep' (Epistula) or 'ds' (Dissemino)
   //  
   //  So the overall form is YYYYMMDD.hhmmss.LSC_clientIP_ep@domainName
   //  
   //  To cope with system clock retartations this function uses a static variable of 'latest known time' (LKT) and a dynamic variable of 'last-second' counter (LSC). The LKT has
   //  an intial value of midnight, Jan 1st, 0000. The process begins by reading the clock to an accuracy of one second. If the clock shows a LATER time than the LKT, the LKT is
   //  set equal to the clock and the LSC is set to 0 (this always happens in the first instance). If the clock shows a time EQUAL to or EARLIER than the LKT, the LKT is unchanged
   //  but the LSC is incremented by 1. In ALL cases the id is formed of the LKT and the LSC, however where the clock was found to have an EARLIER time than the LKT, the LKT and
   //  the LSC are separated by an underscore rather than a period.
   //  
   //  Arguments: 1) MailId This will contain the generate message id.
   //     2) domain Domain name (final part of id)
   //  
   //  Returns: None
   static  hzXDate     LKT ;       //  Last known time
   hzChain     Z ;                 //  Working chain buffer
   hzXDate     now ;               //  Current time
   uint32_t    LSC ;               //  Last second counter
   bool        bUscore = false ;   //  Use underscore
   //  Read system clock
   now.SysDateTime() ;
   if (now.AsEpoch() > LKT.AsEpoch())
   {
       LKT = now ;
       LSC = 0;
   }
   else
   {
       if (now.AsEpoch() < LKT.AsEpoch())
           bUscore = true ;
       LSC++ ;
   }
   Z.Printf("%04d%02d%02d%02d%02d%02d", LKT.Year(), LKT.Month(), LKT.Day(), LKT.Hour(), LKT.Min(), LKT.Sec()) ;
   if (bUscore)
       Z.AddByte(CHAR_USCORE) ;
   else
       Z.AddByte(CHAR_PERIOD) ;
   Z.Printf("%d", LSC) ;
   Z.AddByte(CHAR_AT) ;
   Z << domain ;
   //  Z.Printf("%04d%02d%02d%02d%02d%02d.%d.%s@%s",
   //  d.Year(), d.Month(), d.Day(), d.Hour(), d.Min(), d.Sec(), getpid(), *s_EmailSystem, *_hzGlobal_Hostname) ;
   mailId = Z ;
}