Back to index

courier  0.68.2
Functions | Variables
rfc2045tryboundary.c File Reference
#include "rfc2045.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

void rfc2045_add_buf (char **, size_t *, size_t *, const char *, size_t)
static void boundary_chk_add (const char *p, size_t l)
static int boundary_chk (const char *p, size_t l, void *ptr)
static int try_boundary (struct rfc2045 *p, struct rfc2045src *src)
int rfc2045_try_boundary (struct rfc2045 *p, struct rfc2045src *src, const char *boundary)

Variables

static const char * boundary_chk_val
static size_t boundary_chk_val_len
static char * boundary_chk_buf
static size_t boundary_chk_bufsize
static size_t boundary_chk_buflen
static int boundary_chk_flag

Function Documentation

static int boundary_chk ( const char *  p,
size_t  l,
void *  ptr 
) [static]

Definition at line 39 of file rfc2045tryboundary.c.

{
static size_t i, j;

       for (j=i=0; i<l; i++)
       {
              if (p[i] == '\n')
              {
                     boundary_chk_add(p+j, i-j);

                     if (boundary_chk_buflen >= boundary_chk_val_len+2 &&
                            boundary_chk_buf[0] == '-' &&
                            boundary_chk_buf[1] == '-' &&
                            strncasecmp(boundary_chk_val,
                                   boundary_chk_buf+2,
                                   boundary_chk_val_len) == 0)
                                   boundary_chk_flag=1;
                                   
                     boundary_chk_buflen=0;
                     j=i+1;
              }
       }
       boundary_chk_add(p+j, l-j);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void boundary_chk_add ( const char *  p,
size_t  l 
) [static]

Definition at line 31 of file rfc2045tryboundary.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void rfc2045_add_buf ( char **  ,
size_t *  ,
size_t *  ,
const char *  ,
size_t   
)

Definition at line 173 of file rfc2045.c.

{
       if (len + *buflen > *bufsize)
       {
       size_t newsize=len+*buflen+256;
       char   *p= *bufptr ? (char *)realloc(*bufptr, newsize):
                            (char *)malloc(newsize);

              if (!p)
              {
                     rfc2045_enomem();
                     return;
              }
              *bufptr=p;
              *bufsize=newsize;
       }

       memcpy(*bufptr + *buflen, p, len);
       *buflen += len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int rfc2045_try_boundary ( struct rfc2045 p,
struct rfc2045src src,
const char *  boundary 
)

Definition at line 108 of file rfc2045tryboundary.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static int try_boundary ( struct rfc2045 p,
struct rfc2045src src 
) [static]

Definition at line 65 of file rfc2045tryboundary.c.

{
int    rc;
char   buf[512];
int    n, cnt;
off_t  ps;

       if (p->firstpart)
       {
              for (p=p->firstpart; p; p=p->next)
                     if ((rc=try_boundary(p, src)) != 0)
                            return (rc);
              return (0);
       }

       if (p->content_transfer_encoding &&
              strcmp(p->content_transfer_encoding, "base64") == 0)
              return (0);

       boundary_chk_flag=0;
       boundary_chk_buflen=0;

       if ((*src->seek_func)(p->startbody, src->arg) == -1)    return (-1);
       rfc2045_cdecode_start(p, boundary_chk, 0);

       ps=p->startbody;
       while (ps < p->endbody)
       {
              if (p->endbody - ps < sizeof(buf))
                     cnt=p->endbody-ps;
              else   cnt=sizeof(buf);
              n=(*src->read_func)(buf, cnt, src->arg);
              if (n <= 0)   return (-1);
              rfc2045_cdecode(p, buf, n);
              ps += n;
              if (boundary_chk_flag)      break;
       }
       rfc2045_cdecode_end(p);
       if (boundary_chk_buflen)
              boundary_chk("\n", 1, 0);   /* Flush out partial line */
       return (boundary_chk_flag);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* boundary_chk_buf [static]

Definition at line 27 of file rfc2045tryboundary.c.

size_t boundary_chk_buflen [static]

Definition at line 28 of file rfc2045tryboundary.c.

size_t boundary_chk_bufsize [static]

Definition at line 28 of file rfc2045tryboundary.c.

int boundary_chk_flag [static]

Definition at line 29 of file rfc2045tryboundary.c.

const char* boundary_chk_val [static]

Definition at line 25 of file rfc2045tryboundary.c.

size_t boundary_chk_val_len [static]

Definition at line 26 of file rfc2045tryboundary.c.