Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

gethostname.c File Reference

#include "c.h"
#include <sys/utsname.h>
Include dependency graph for gethostname.c:

Go to the source code of this file.

Functions

int gethostname (char *name, int namelen)

Function Documentation

int gethostname ( char *  name,
int  namelen 
)

Definition at line 20 of file gethostname.c.

{
    static struct utsname mname;
    static int  called = 0;

    if (!called)
    {
        called++;
        uname(&mname);
    }
    strncpy(name, mname.nodename, (SYS_NMLN < namelen ? SYS_NMLN : namelen));

    return 0;
}