Back to index

courier  0.68.2
Classes | Defines | Functions
msghash.h File Reference
#include <md5/md5.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  msghashinfo

Defines

#define MD5_INTERNAL
#define MSGHASH_MARGIN
#define MSGHASH_LINESIZE   256 /* Fixed size of the line buffer */
#define MSGHASH_HIMARGIN   5

Functions

void msghash_init (struct msghashinfo *)
void msghash_line (struct msghashinfo *, const char *)
void msghash_finish (struct msghashinfo *)

Class Documentation

struct msghashinfo

Definition at line 22 of file msghash.h.

Class Members
unsigned long c_bot_cnt
unsigned long c_entire_cnt
unsigned long c_top_cnt
char cur_header
char headerlinebuf
unsigned headerlinebuf_size
int inheader
char linebuf
unsigned linebuf_head
unsigned linebuf_tail
MD5_DIGEST md1
MD5_DIGEST md2
unsigned numlines

Define Documentation

#define MD5_INTERNAL

Definition at line 9 of file msghash.h.

#define MSGHASH_HIMARGIN   5

Definition at line 17 of file msghash.h.

#define MSGHASH_LINESIZE   256 /* Fixed size of the line buffer */

Definition at line 15 of file msghash.h.

#define MSGHASH_MARGIN
Value:
3             /* First/last N lines of message which
                                   ** are ignored for partial hashes
                                   */

Definition at line 14 of file msghash.h.


Function Documentation

void msghash_finish ( struct msghashinfo )

Definition at line 143 of file msghash.c.

{
       if (p->numlines < MSGHASH_HIMARGIN)
       {
              memcpy(&p->c_top, &p->c_entire, sizeof(p->c_top));
              p->c_top_cnt=p->c_entire_cnt;

              memcpy(&p->c_bot, &p->c_entire, sizeof(p->c_bot));
              p->c_bot_cnt=p->c_entire_cnt;
       }

       md5_context_endstream(&p->c_top, p->c_top_cnt);
       md5_context_endstream(&p->c_bot, p->c_bot_cnt);

       md5_context_digest(&p->c_top, p->md1);
       md5_context_digest(&p->c_bot, p->md2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void msghash_init ( struct msghashinfo )

Definition at line 38 of file msghash.c.

{
       p->numlines=0;
       p->inheader=1;
       p->cur_header[0]=0;
       p->headerlinebuf_size=0;
       md5_context_init(&p->c_entire);
       md5_context_init(&p->c_top);
       md5_context_init(&p->c_bot);
       p->c_entire_cnt=0;
       p->c_top_cnt=0;
       p->c_bot_cnt=0;
       p->linebuf_head=0;
       p->linebuf_tail=0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void msghash_line ( struct msghashinfo ,
const char *   
)

Definition at line 90 of file msghash.c.

{
unsigned long ll;

       if (!p->inheader)
       {
              p->headerlinebuf_size=0;
              ll=0;
              while (*l)
              {
                     if ( isalpha((int)(unsigned char)*l) &&
                            ll < sizeof(p->headerlinebuf)-1)
                            p->headerlinebuf[ll++] = *l;
                     ++l;
              }
              p->headerlinebuf[ll]=0;

              do_msghash_line(p, p->headerlinebuf);
              return;
       }

       if (*l == 0)
       {
              p->inheader=0;
              if (strcmp(p->cur_header, "subject") == 0)
                     do_msghash_line(p, p->headerlinebuf);
                     /* Count the subject header */
              return;
       }
       if (!isspace(*l))
       {
              if (strcmp(p->cur_header, "subject") == 0)
                     do_msghash_line(p, p->headerlinebuf);
              for (ll=0; ll<sizeof(p->cur_header)-1; ll++)
              {
                     if (l[ll] == ':')    break;
                     p->cur_header[ll]=tolower( (int)(unsigned char)l[ll]);
              }
              p->cur_header[ll]=0;
              p->headerlinebuf_size=0;
       }
       while (*l)
       {
              if ( isalpha((int)(unsigned char)*l) &&
                     p->headerlinebuf_size <
                            sizeof(p->headerlinebuf)-1)
                     p->headerlinebuf[p->headerlinebuf_size
                                   ++] = *l;
              ++l;
       }
       p->headerlinebuf[p->headerlinebuf_size]=0;
}

Here is the call graph for this function:

Here is the caller graph for this function: