Back to index

courier  0.68.2
Functions
rfc822_getaddrs.c File Reference
#include "rfc822.h"
#include <stdlib.h>

Go to the source code of this file.

Functions

static void cntlen (char c, void *p)
static void cntlensep (const char *p, void *ptr)
static void saveaddr (char c, void *ptr)
static void saveaddrsep (const char *p, void *ptr)
char * rfc822_getaddrs (const struct rfc822a *rfc)
static void saveaddrsep_wrap (const char *p, void *ptr)
char * rfc822_getaddrs_wrap (const struct rfc822a *rfc, int w)

Function Documentation

static void cntlen ( char  c,
void *  p 
) [static]

Definition at line 11 of file rfc822_getaddrs.c.

{
       c=c;
       ++ *(size_t *)p;
}

Here is the caller graph for this function:

static void cntlensep ( const char *  p,
void *  ptr 
) [static]

Definition at line 17 of file rfc822_getaddrs.c.

{
       while (*p)    cntlen(*p++, ptr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* rfc822_getaddrs ( const struct rfc822a rfc)

Definition at line 32 of file rfc822_getaddrs.c.

{
       size_t addrbuflen=0;
       char   *addrbuf, *ptr;

       if (rfc822_print(rfc, &cntlen, &cntlensep, &addrbuflen) < 0)
              return NULL;

       if (!(addrbuf=malloc(addrbuflen+1)))
              return (0);

       ptr=addrbuf;
       if (rfc822_print(rfc, &saveaddr, &saveaddrsep, &ptr) < 0)
       {
              free(addrbuf);
              return NULL;
       }

       addrbuf[addrbuflen]=0;
       return (addrbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* rfc822_getaddrs_wrap ( const struct rfc822a rfc,
int  w 
)

Definition at line 65 of file rfc822_getaddrs.c.

{
       size_t addrbuflen=0;
       char   *addrbuf, *ptr, *start, *lastnl;

       if (rfc822_print(rfc, &cntlen, &cntlensep, &addrbuflen) < 0)
              return NULL;

       if (!(addrbuf=malloc(addrbuflen+1)))
              return (0);

       ptr=addrbuf;

       if (rfc822_print(rfc, &saveaddr, &saveaddrsep_wrap, &ptr) < 0)
       {
              free(addrbuf);
              return NULL;
       }

       addrbuf[addrbuflen]=0;

       for (lastnl=0, start=ptr=addrbuf; *ptr; )
       {
              while (*ptr && *ptr != '\n')       ptr++;
              if (ptr-start < w)
              {
                     if (lastnl)   *lastnl=' ';
                     lastnl=ptr;
                     if (*ptr)     ++ptr;
              }
              else
              {
                     if (lastnl)
                            start=lastnl+1;
                     else
                     {
                            start=ptr+1;
                            if (*ptr)     ++ptr;
                     }
                     lastnl=0;
              }
       }
       return (addrbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void saveaddr ( char  c,
void *  ptr 
) [static]

Definition at line 22 of file rfc822_getaddrs.c.

{
       *(*(char **)ptr)++=c;
}

Here is the caller graph for this function:

static void saveaddrsep ( const char *  p,
void *  ptr 
) [static]

Definition at line 27 of file rfc822_getaddrs.c.

{
       while (*p)    saveaddr(*p++, ptr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void saveaddrsep_wrap ( const char *  p,
void *  ptr 
) [static]

Definition at line 54 of file rfc822_getaddrs.c.

{
int    c;

       while ((c=*p++) != 0)
       {
              if (c == ' ') c='\n';
              saveaddr(c, ptr);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: