Back to index

nagios-plugins  1.4.16
gethostname.c File Reference
#include <config.h>
#include <unistd.h>
#include <string.h>
#include <stddef.h>

Go to the source code of this file.


int gethostname (char *name, size_t len)

Function Documentation

int gethostname ( char *  name,
size_t  len 

Definition at line 43 of file gethostname.c.

  struct utsname uts;

  if (uname (&uts) == -1)
    return -1;
  if (len > sizeof (uts.nodename))
      /* More space than we need is available.  */
      name[sizeof (uts.nodename)] = '\0';
      len = sizeof (uts.nodename);
  strncpy (name, uts.nodename, len);
  strcpy (name, "");            /* Hardcode your system name if you want.  */
  return 0;

Here is the caller graph for this function: