Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsEUCSampler Class Reference

#include <nsPSMDetectors.h>

List of all members.

Public Member Functions

 nsEUCSampler ()
PRBool EnoughData ()
PRBool GetSomeData ()
PRBool Sample (const char *aIn, PRUint32 aLen)
void CalFreq ()
float GetScore (const float *aFirstByteFreq, float aFirstByteWeight, const float *aSecondByteFreq, float aSecondByteWeight)
float GetScore (const float *array1, const float *array2)

Private Attributes

PRUint32 mTotal
PRUint32 mThreshold
PRInt8 mState
PRUint32 mFirstByteCnt [94]
PRUint32 mSecondByteCnt [94]
float mFirstByteFreq [94]
float mSecondByteFreq [94]

Detailed Description

Definition at line 181 of file nsPSMDetectors.h.


Constructor & Destructor Documentation

Definition at line 183 of file nsPSMDetectors.h.

                   {
      mTotal =0;
      mThreshold = 200;
         mState = 0;
      PRInt32 i;
      for(i=0;i<94;i++)
          mFirstByteCnt[i] = mSecondByteCnt[i]=0;
    }

Member Function Documentation

Definition at line 265 of file nsPSMDetectors.cpp.

{
   PRUint32 i;
   for(i = 0 ; i < 94; i++) {
      mFirstByteFreq[i] = (float)mFirstByteCnt[i] / (float)mTotal;
      mSecondByteFreq[i] = (float)mSecondByteCnt[i] / (float)mTotal;
   }
}

Here is the caller graph for this function:

Definition at line 191 of file nsPSMDetectors.h.

{ return mTotal > mThreshold; }

Here is the caller graph for this function:

float nsEUCSampler::GetScore ( const float *  aFirstByteFreq,
float  aFirstByteWeight,
const float *  aSecondByteFreq,
float  aSecondByteWeight 
)

Definition at line 246 of file nsPSMDetectors.cpp.

{
   return aFirstByteWeight * GetScore(aFirstByteFreq, mFirstByteFreq) +
          aSecondByteWeight * GetScore(aSecondByteFreq, mSecondByteFreq);
}

Here is the caller graph for this function:

float nsEUCSampler::GetScore ( const float *  array1,
const float *  array2 
)

Definition at line 253 of file nsPSMDetectors.cpp.

{
   float s;
   float sum=0.0;
   PRUint16 i;
   for(i=0;i<94;i++) {
     s = array1[i] - array2[i];
     sum += s * s;
   }
   return (float)sqrt((double)sum) / 94.0f;
}

Definition at line 192 of file nsPSMDetectors.h.

{ return mTotal > 1; }

Here is the caller graph for this function:

PRBool nsEUCSampler::Sample ( const char *  aIn,
PRUint32  aLen 
)

Definition at line 200 of file nsPSMDetectors.cpp.

{
    if(mState == 1)
        return PR_FALSE;
    const unsigned char* p = (const unsigned char*) aIn;
    if(aLen + mTotal > 0x80000000) 
       aLen = 0x80000000 - mTotal;

     PRUint32 i;
     for(i=0; (i<aLen) && (1 != mState) ;i++,p++)
     {
        switch(mState) {
           case 0:
             if( *p & 0x0080)  
             {
                if((0x00ff == *p) || ( 0x00a1 > *p)) {
                   mState = 1;
                } else {
                   mTotal++;
                   mFirstByteCnt[*p - 0x00a1]++;
                   mState = 2;
                }
             }
             break;
           case 1:
             break;
           case 2:
             if( *p & 0x0080)  
             {
                if((0x00ff == *p) || ( 0x00a1 > *p)) {
                   mState = 1;
                } else {
                   mTotal++;
                   mSecondByteCnt[*p - 0x00a1]++;
                   mState = 0;
                }
             } else {
                mState = 1;
             }
             break;
           default:
             mState = 1;
        }
     }
   return (1 != mState  );
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 202 of file nsPSMDetectors.h.

float nsEUCSampler::mFirstByteFreq[94] [private]

Definition at line 204 of file nsPSMDetectors.h.

Definition at line 203 of file nsPSMDetectors.h.

float nsEUCSampler::mSecondByteFreq[94] [private]

Definition at line 205 of file nsPSMDetectors.h.

PRInt8 nsEUCSampler::mState [private]

Definition at line 201 of file nsPSMDetectors.h.

Definition at line 200 of file nsPSMDetectors.h.

Definition at line 199 of file nsPSMDetectors.h.


The documentation for this class was generated from the following files: