OSDN Git Service

Update a number of broken links in comments.
[pg-rex/syncrep.git] / src / port / gethostname.c
1 /*-------------------------------------------------------------------------
2  *
3  * gethostname.c
4  *        gethostname using uname
5  *
6  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * IDENTIFICATION
10  *        $PostgreSQL: pgsql/src/port/gethostname.c,v 1.12 2010/01/02 16:58:13 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14
15 #include "c.h"
16
17 #include <sys/utsname.h>
18
19 int
20 gethostname(char *name, int namelen)
21 {
22         static struct utsname mname;
23         static int      called = 0;
24
25         if (!called)
26         {
27                 called++;
28                 uname(&mname);
29         }
30         strncpy(name, mname.nodename, (SYS_NMLN < namelen ? SYS_NMLN : namelen));
31
32         return 0;
33 }