~ubuntu-branches/ubuntu/lucid/rsyslog/lucid-updates

1.2.6 by Michael Biebl
Import upstream version 3.22.0
1
/* gethostn - a small diagnostic utility to show what the
2
 * gethostname() API returns. Of course, this tool duplicates
3
 * functionality already found in other tools. But the point is
4
 * that the API shall be called by a program that is compiled like
5
 * rsyslogd and does exactly what rsyslog does.
6
 *
7
 * Copyright 2008 Rainer Gerhards and Adiscon GmbH.
8
 *
9
 * This file is part of rsyslog.
10
 *
11
 * Rsyslog is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation, either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * Rsyslog is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with Rsyslog.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
25
 */
26
27
#include "config.h"
28
#include <stdio.h>
29
#include <stdlib.h>
30
#include <unistd.h>
31
32
int main(int __attribute__((unused)) argc, char __attribute__((unused)) *argv[])
33
{
34
	char hostname[4096]; /* this should always be sufficient ;) */
35
	int err;
36
37
	err = gethostname(hostname, sizeof(hostname));
38
39
	if(err) {
40
		perror("gethostname failed");
41
		exit(1);
42
	}
43
44
	printf("hostname of this system is '%s'.\n", hostname);
45
46
	return 0;
47
}