Back to index

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

Go to the source code of this file.

Functions

void error (const char *)
void cgihttpscriptptr_init ()
const char * cgihttpscriptptr ()

Variables

static char * scriptptr = 0

Function Documentation

const char* cgihttpscriptptr ( )

Definition at line 31 of file cgihttpscriptptr.c.

{
       if (!scriptptr)
       {
       char   *p=getenv("SCRIPT_NAME");
       char   *h=getenv("HTTP_HOST");
       char   *q;

              if (!h)       h="";
              if (!p)       p="";

              q=malloc(strlen(p)+strlen(h)+sizeof("http://"));
              if (!q)       error("Out of memory.");
              sprintf(q, "http:%s%s%s", (*h ? "//":""), h, p);
              scriptptr=q;
       }
       return (scriptptr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file cgihttpscriptptr.c.

{
       /* Reinitialisation required when running as fastcgi */
       if (scriptptr) {
              free(scriptptr);
              scriptptr=0;
       }
}
void error ( const char *  )

Definition at line 23 of file showmsg2html.c.

{
       fprintf(stderr, "%s\n", p);
       exit(1);
}

Variable Documentation

char* scriptptr = 0 [static]

Definition at line 18 of file cgihttpscriptptr.c.