Back to index

courier  0.68.2
Functions
rfc2045appendurl.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "rfc2045.h"

Go to the source code of this file.

Functions

void rfc2045_enomem ()
static void get_method_path (const char *p, const char **method, unsigned *methodl, const char **path)
char * rfc2045_append_url (const char *base, const char *loc)
char * rfc2045_content_base (struct rfc2045 *p)

Function Documentation

static void get_method_path ( const char *  p,
const char **  method,
unsigned *  methodl,
const char **  path 
) [static]

Definition at line 29 of file rfc2045appendurl.c.

{
unsigned      i;

       for (i=0; p && p[i]; i++)
       {
              if (p[i] == ':')
              {
                     *method=p;
                     *methodl= ++i;
                     *path=p+i;
                     return;
              }

              if (!isalpha( (int)(unsigned char)p[i]))
                     break;
       }

       *method=0;
       *methodl=0;
       *path=p;
}

Here is the caller graph for this function:

char* rfc2045_append_url ( const char *  base,
const char *  loc 
)

Definition at line 55 of file rfc2045appendurl.c.

{
const char *base_method;
unsigned base_method_l;
const char *base_path;

const char *loc_method;
unsigned loc_method_l;
const char *loc_path;
char *buf, *q;

       get_method_path(base, &base_method, &base_method_l, &base_path);
       get_method_path(loc, &loc_method, &loc_method_l, &loc_path);

       if (loc_method_l)
       {
              buf=malloc(strlen(loc)+1);
              if (!buf)
                     return NULL;
              else
                     strcpy(buf, loc);
              return (buf);
       }

       loc_method=base_method;
       loc_method_l=base_method_l;

       if (!base_path)      base_path="";
       if (!loc_path)       loc_path="";

       buf=malloc(loc_method_l + strlen(base_path)+strlen(loc_path) + 3);

       if (!buf)
       {
              return NULL;
       }

       if (loc_method_l)
              memcpy(buf, loc_method, loc_method_l);
       buf[loc_method_l]=0;

       q=buf + loc_method_l;

       strcat(strcpy(q, base_path), "/");

       if ( loc_path[0] == '/')
       {
       char *r;

              if (loc_path[1] == '/')
                     /* Location is absolute */
              {
                     *q=0;
              }

              /* Relative to top of base */

              else if ( q[0] == '/' && q[1] == '/' &&
                     (r=strchr(q+2, '/')) != 0)
              {
                     *r=0;
              }
              else
                     *q=0;  /* No sys in base, just start with / */
       }

       strcat(q, loc_path);

       return (buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* rfc2045_content_base ( struct rfc2045 p)

Definition at line 126 of file rfc2045appendurl.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void rfc2045_enomem ( )

Definition at line 44 of file pcp.c.

{
       fprintf(stderr, "Out of memory.\n");
       exit(1);
}