view src/lib/hostpid.c @ 4891:6ab2712f1a93 HEAD

Only imap binary was actually working.
author Timo Sirainen <tss@iki.fi>
date Sun, 10 Dec 2006 14:35:02 +0200
parents 9df02b1533b3
children 18173a52f721
line wrap: on
line source

/* Copyright (c) 2002-2003 Timo Sirainen */

#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 (my_hostname == NULL) {
		if (gethostname(hostname, sizeof(hostname)-1) == -1)
			strocpy(hostname, "unknown", sizeof(hostname));
		hostname[sizeof(hostname)-1] = '\0';

		my_hostname = hostname;
	}

	if (my_pid == NULL) {
		strocpy(pid, dec2str(getpid()), sizeof(pid));
		my_pid = pid;
	}
}