view src/lib/hostpid.c @ 8076:bbfbc84f795c HEAD

Added clock_gettime() compatibility function for systems without it.
author Timo Sirainen <tss@iki.fi>
date Thu, 07 Aug 2008 15:05:40 -0400
parents c832be51c7ac
children b9faf4db2a9f
line wrap: on
line source

/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "hostpid.h"

#include <unistd.h>

const char *my_hostname = NULL;
const char *my_pid = NULL;

void hostpid_init(void)
{
	static char hostname[256], pid[MAX_INT_STRLEN];

	if (gethostname(hostname, sizeof(hostname)-1) == -1)
		i_strocpy(hostname, "unknown", sizeof(hostname));
	hostname[sizeof(hostname)-1] = '\0';
	my_hostname = hostname;

	i_strocpy(pid, dec2str(getpid()), sizeof(pid));
	my_pid = pid;
}