2003-11-12 00:52:45 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* gethostname.c
|
|
|
|
* gethostname using uname
|
|
|
|
*
|
2004-08-29 06:13:13 +02:00
|
|
|
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
2003-11-12 00:52:45 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2004-08-29 06:13:13 +02:00
|
|
|
* $PostgreSQL: pgsql/src/port/gethostname.c,v 1.5 2004/08/29 04:13:12 momjian Exp $
|
2003-11-12 00:52:45 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-08-24 16:07:50 +02:00
|
|
|
|
|
|
|
#include "c.h"
|
1997-12-19 14:35:17 +01:00
|
|
|
|
1997-12-19 03:27:20 +01:00
|
|
|
#include <string.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));
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return 0;
|
1997-12-19 03:27:20 +01:00
|
|
|
}
|