reSIProcate/stack  9694
Classes | Defines | Functions
DateCategory.cxx File Reference
#include <time.h>
#include "resip/stack/DateCategory.hxx"
#include "resip/stack/Transport.hxx"
#include "rutil/Data.hxx"
#include "rutil/DnsUtil.hxx"
#include "rutil/Logger.hxx"
#include "rutil/ParseBuffer.hxx"
#include "rutil/Socket.hxx"
Include dependency graph for DateCategory.cxx:

Go to the source code of this file.

Classes

struct  days
struct  months

Defines

#define RESIPROCATE_SUBSYSTEM   Subsystem::SIP

Functions

static unsigned int dayofweek_hash (register const char *str, register unsigned int len)
struct daysin_dayofweek_word_set (register const char *str, register unsigned int len)
static unsigned int month_hash (register const char *str, register unsigned int len)
static void pad2 (const int x, EncodeStream &str)

Define Documentation

#define RESIPROCATE_SUBSYSTEM   Subsystem::SIP

Definition at line 19 of file DateCategory.cxx.


Function Documentation

static unsigned int dayofweek_hash ( register const char *  str,
register unsigned int  len 
) [static]

Definition at line 184 of file DateCategory.cxx.

References len.

Referenced by resip::DateCategory::DayOfWeekFromData(), and in_dayofweek_word_set().

{
  static unsigned char asso_values[] =
    {
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
       1, 13, 13, 13, 13, 13, 13,  5, 13, 13,
      13, 13, 13,  2,  0, 13, 13,  7, 13, 13,
      13, 13, 13, 13, 13, 13, 13,  7, 13, 13,
       0,  0, 13, 13,  4,  0, 13, 13, 13, 13,
       0,  0, 13, 13,  0, 13,  0,  0, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
      13, 13, 13, 13, 13, 13
    };
  register int hval = len;

  switch (hval)
    {
      default: /*FALLTHRU*/
      case 3:
        hval += asso_values[(unsigned char)str[2]];
        /*FALLTHRU*/
      case 2:
        hval += asso_values[(unsigned char)str[1]];
        /*FALLTHRU*/
      case 1:
        hval += asso_values[(unsigned char)str[0]];
        break;
    }
  return hval;
}
struct days* in_dayofweek_word_set ( register const char *  str,
register unsigned int  len 
) [read]

Definition at line 237 of file DateCategory.cxx.

References dayofweek_hash(), and days::name.

{
   static const unsigned int MIN_WORD_LENGTH = 3;
   static const unsigned int MAX_WORD_LENGTH = 3;
   static const int MAX_HASH_VALUE = 12;
   
   static struct days wordlist[] =
    {
      {""}, {""}, {""},
      {"Tue", Tue},
      {"Fri", Fri},
      {"Sun", Sun},
      {""},
      {"Thu", Thu},
      {"Mon", Mon},
      {""},
      {"Wed", Wed},
      {""},
      {"Sat", Sat}
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = dayofweek_hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register const char *s = wordlist[key].name;

          if (*str == *s && !strcmp (str + 1, s + 1))
            return &wordlist[key];
        }
    }
  return 0;
}

Here is the call graph for this function:

static unsigned int month_hash ( register const char *  str,
register unsigned int  len 
) [static]

Definition at line 332 of file DateCategory.cxx.

References len.

Referenced by resip::DateCategory::MonthFromData().

{
   static unsigned char asso_values[] =
      {
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 15, 34, 34,  8, 34,
         5, 34, 34, 34,  0, 34, 34, 10,  3, 14,
         34, 34, 34,  9, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 10,  0,  0,
         34,  0, 34, 10, 34, 34, 34, 34,  4, 34,
         0,  0,  0, 34,  0, 34,  0,  0,  0, 34,
         34, 10, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
         34, 34, 34, 34, 34, 34
      };
   register int hval = len;

   switch (hval)
   {
      default: /*FALLTHRU*/
      case 3:
         hval += asso_values[(unsigned char)str[2]];
         /*FALLTHRU*/
      case 2:
         hval += asso_values[(unsigned char)str[1]];
         /*FALLTHRU*/
      case 1:
         hval += asso_values[(unsigned char)str[0]];
         break;
   }
   return hval;
}
static void pad2 ( const int  x,
EncodeStream str 
) [static]

Definition at line 583 of file DateCategory.cxx.

References resip::Symbols::ZERO.

Referenced by resip::DateCategory::encodeParsed().

{
   if (x < 10)
   {
      str << Symbols::ZERO[0];
   }
   str << x;
}