Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  get_hostname.c

  Sprache: C
 

/*++
/* NAME
/* get_hostname 3
/* SUMMARY
/* network name lookup
/* SYNOPSIS
/* #include <get_hostname.h>
/*
/* const char *get_hostname()
/* DESCRIPTION
/* get_hostname() returns the local hostname as obtained
/* via gethostname() or its moral equivalent. This routine
/* goes to great length to avoid dependencies on any network
/* services.
/* DIAGNOSTICS
/* Fatal errors: no hostname, invalid hostname.
/* SEE ALSO
/* valid_hostname(3)
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/


/* System library. */

#include <sys_defs.h>
#include <sys/param.h>
#include <string.h>
#include <unistd.h>

#if (MAXHOSTNAMELEN < 256)
#undef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif

/* Utility library. */

#include "mymalloc.h"
#include "msg.h"
#include "valid_hostname.h"
#include "get_hostname.h"

/* Local stuff. */

static char *my_host_name;

/* get_hostname - look up my host name */

const char *get_hostname(void)
{
    char    namebuf[MAXHOSTNAMELEN + 1];

    /*
     * The gethostname() call is not (or not yet) in ANSI or POSIX, but it is
     * part of the socket interface library. We avoid the more politically-
     * correct uname() routine because that has no portable way of dealing
     * with long (FQDN) hostnames.
     * 
     * DO NOT CALL GETHOSTBYNAME FROM THIS FUNCTION. IT BREAKS MAILDIR DELIVERY
     * AND OTHER THINGS WHEN THE MACHINE NAME IS NOT FOUND IN /ETC/HOSTS OR
     * CAUSES PROCESSES TO HANG WHEN THE NETWORK IS DISCONNECTED.
     * 
     * POSTFIX NO LONGER NEEDS A FULLY QUALIFIED HOSTNAME. INSTEAD POSTFIX WILL
     * USE A DEFAULT DOMAIN NAME "LOCALDOMAIN".
     */

    if (my_host_name == 0) {
 /* DO NOT CALL GETHOSTBYNAME FROM THIS FUNCTION */
 if (gethostname(namebuf, sizeof(namebuf)) < 0)
     msg_fatal("gethostname: %m");
 namebuf[MAXHOSTNAMELEN] = 0;
 /* DO NOT CALL GETHOSTBYNAME FROM THIS FUNCTION */
 if (valid_hostname(namebuf, DO_GRIPE) == 0)
     msg_fatal("unable to use my own hostname");
 /* DO NOT CALL GETHOSTBYNAME FROM THIS FUNCTION */
 my_host_name = mystrdup(namebuf);
    }
    return (my_host_name);
}

Messung V0.5 in Prozent
C=71 H=94 G=83

¤ Dauer der Verarbeitung: 0.21 Sekunden  (vorverarbeitet am  2026-08-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002