Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / src / port / gethostname.c
blobad8fefa4b334b84f9dec7e6c0f7842a07efc7f20
1 /*-------------------------------------------------------------------------
3 * gethostname.c
4 * gethostname using uname
6 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * IDENTIFICATION
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
15 #include "c.h"
17 #include <sys/utsname.h>
19 int
20 gethostname(char *name, int namelen)
22 static struct utsname mname;
23 static int called = 0;
25 if (!called)
27 called++;
28 uname(&mname);
30 strncpy(name, mname.nodename, (SYS_NMLN < namelen ? SYS_NMLN : namelen));
32 return 0;