Back to index

courier  0.68.2
Functions | Variables
comverp.c File Reference
#include "comverp.h"
#include "courier.h"
#include "comctlfile.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

size_t verp_encode (const char *receipient, char *buf)
char * verp_getsender (struct ctlfile *ctf, const char *receipient)

Variables

static const char xdigit [] = "0123456789ABCDEF"

Function Documentation

size_t verp_encode ( const char *  receipient,
char *  buf 
)

Definition at line 20 of file comverp.c.

{
size_t i=1;
unsigned j;

       while (*receipient)
       {
              if (*receipient == '@' && strchr(receipient+1, '@') == 0)
              {
                     if (buf)      *buf++ = '=';
                     ++i;
                     ++receipient;
                     continue;
              }

              switch (*receipient) {
              case '=':
                     if (strchr(receipient, '@'))
                     {
                            if (buf)      *buf++ = *receipient;

                            ++receipient;
                            ++i;
                            break;
                     }

                     /* UUCP, no @, must encode it */

              case '@':
              case ':':
              case '%':
              case '!':
              case '+':
              case '-':
              case '[':
              case ']':
                     j=(unsigned)(unsigned char)*receipient++;

                     if (buf)
                     {
                            *buf++='+';
                            *buf++=xdigit[ j / 16 ];
                            *buf++=xdigit[ j % 16 ];
                     }
                     i += 3;
                     break;
              default:
                     if (buf)      *buf++ = *receipient;

                     ++receipient;
                     ++i;
              }
       }
       if (buf)      *buf=0;
       return (i);
}

Here is the caller graph for this function:

char* verp_getsender ( struct ctlfile ctf,
const char *  receipient 
)

Definition at line 82 of file comverp.c.

{
const char *p, *r;
char   *q, *s;

       if (ctf->sender[0] == '\0')
              return (strcpy(courier_malloc(1), ""));

       p=ctf->sender;

       if (ctlfile_searchfirst(ctf, COMCTLFILE_VERP) < 0 ||
              (r=strrchr(p, '@')) == 0)
              return (strcpy(courier_malloc(strlen(p)+1), p));
              /* VERP not set */

       q=courier_malloc(strlen(p)+1+verp_encode(receipient, 0));
       memcpy(q, p, r-p);
       s=q + (r-p);
       *s++='-';
       s += verp_encode(receipient, s)-1;
       strcpy(s, r);
       return (q);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char xdigit[] = "0123456789ABCDEF" [static]

Definition at line 12 of file comverp.c.