Back to index

courier  0.68.2
Functions
pcpdauthme.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>
#include <sysconfdir.h>
#include "calendardir.h"

Go to the source code of this file.

Functions

char * auth_myhostname ()

Function Documentation

char* auth_myhostname ( )

Definition at line 35 of file pcpdauthme.c.

{
char    buf[1024];
static char *my_hostname=0;
FILE   *f;

       if (my_hostname == 0)
       {
              buf[0]=0;

              f=fopen(HOSTNAMEFILE, "r");

              if (!f)
                     f=fopen(HOSTNAMEFILE2, "r");

              if (f != 0)
              {
              char *p;

                     if (fgets(buf, sizeof(buf), f) == NULL)
                            buf[0]=0;
                     fclose(f);

                     if ((p=strchr(buf, '\n')) != 0)
                            *p=0;
              }

              if (buf[0] == 0 && gethostname(buf, sizeof(buf)-1))
                     strcpy(buf, "localhost");

              if ((my_hostname=malloc(strlen(buf)+1)) == 0)
              {
                     fprintf(stderr, "NOTICE: malloc: out of memory.\n");
                     return strdup("localhost");
              }

              strcpy(my_hostname, buf);
       }
       return (my_hostname);
}

Here is the call graph for this function:

Here is the caller graph for this function: