1
1
Description: Further fixes to the build on the GNU Hurd
2
2
- include <sys/file.h> for LOCK_EX
3
- define MAXHOSTNAMELEN if absent
3
- look harder for the maximum length of a hostname
4
Forwarded: http://gitorious.org/dma/dma/merge_requests/5
5
5
Author: Peter Pentchev <roam@ringlet.net>
6
Last-Update: 2010-10-16
6
Last-Update: 2011-02-23
33
+ * A quick'n'dirty hack to get dma to build on the GNU Hurd.
34
+ * A real fix would dynamically allocate the hostname array.
36
+#ifndef MAXHOSTNAMELEN
37
+#define MAXHOSTNAMELEN 1024
32
- static char name[MAXHOSTNAMELEN+1];
33
+ static size_t namelen = 0;
34
+ static char *name = NULL;
35
static int initialized = 0;
42
+#ifdef _SC_HOST_NAME_MAX
47
+ scval = sysconf(_SC_HOST_NAME_MAX);
50
+ namelen = (size_t)scval;
51
+ if ((long)namelen != scval)
60
+ namelen = HOST_NAME_MAX + 1;
62
+#ifdef MAXHOSTNAMELEN
63
+ namelen = MAXHOSTNAMELEN + 1;
71
+ name = malloc(namelen);
73
+ return ("(unknown hostname)");
76
if (config.mailname != NULL && config.mailname[0] != '\0') {
77
- snprintf(name, sizeof(name), "%s", config.mailname);
78
+ snprintf(name, namelen, "%s", config.mailname);
82
if (config.mailnamefile != NULL && config.mailnamefile[0] != '\0') {
83
fp = fopen(config.mailnamefile, "r");
85
- res = fgets(name, sizeof(name), fp);
86
+ res = fgets(name, namelen, fp);
94
- if (gethostname(name, sizeof(name)) != 0)
95
+ if (gethostname(name, namelen) != 0)
96
strcpy(name, "(unknown hostname)");