mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-05 20:06:54 +02:00
34 lines
744 B
C
34 lines
744 B
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* gethostname.c
|
|
* gethostname using uname
|
|
*
|
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* IDENTIFICATION
|
|
* $PostgreSQL: pgsql/src/port/gethostname.c,v 1.10 2008/01/01 19:46:00 momjian Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#include "c.h"
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
int
|
|
gethostname(char *name, int namelen)
|
|
{
|
|
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;
|
|
}
|