DragonFly BSD
DragonFly bugs List (threaded) for 2009-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[issue1555] [PATCH] dma: changes for Linux compilation


From: "Michel Salim \(via DragonFly issue tracker\)" <sinknull@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 03 Oct 2009 17:00:33 +0000

New submission from Michel Salim <salimma@fedoraproject.org>:

This patch modifies the minimum number of files needed to get dma to compile on
Linux. I've tried to make sure that the code should still compile unchanged on
DF, but you'd want to test before committing this, certainly.

Two things I am not sure about:

- My simplistic definition of getprogname() -- is it safe to just make it always
  return "dma" ? Linux has no functional equivalent
- substituting sizeof([ph]->sa) for [ph]->sa.ss_len

Do let me know if there are any changes needed -- it'd be great to have DMA
working out-of-the-box on Linux. Also, are there any sample configuration files,
beyond the dma.8 documentation?

----------
files: 0001-Changes-to-dma-to-allow-for-compilation-on-Linux.patch
messages: 7542
nosy: msylvan
status: unread
title: [PATCH] dma: changes for Linux compilation

_____________________________________________________
DragonFly issue tracker <bugs@lists.dragonflybsd.org>
<http://bugs.dragonflybsd.org/issue1555>
_____________________________________________________
From 24f507b3b2c0809050edea6079d69b7eb892b72e Mon Sep 17 00:00:00 2001
From: Michel Alexandre Salim <salimma@fedoraproject.org>
Date: Sat, 3 Oct 2009 12:51:59 -0400
Subject: [PATCH] Changes to dma to allow for compilation on Linux.

---
 libexec/dma/Makefile.linux |   37 +++++++++++++++++++++++++++++++++++++
 libexec/dma/dma.c          |    4 ++++
 libexec/dma/dma.h          |    8 ++++++++
 libexec/dma/dns.c          |    2 +-
 libexec/dma/net.c          |    2 +-
 5 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 libexec/dma/Makefile.linux

diff --git a/libexec/dma/Makefile.linux b/libexec/dma/Makefile.linux
new file mode 100644
index 0000000..6526fa9
--- /dev/null
+++ b/libexec/dma/Makefile.linux
@@ -0,0 +1,37 @@
+CC=gcc
+CFLAGS=
+LDADD= -lssl -lcrypto
+
+INSTALL=install -p
+DESTDIR=
+PREFIX=/usr
+SBIN=${PREFIX}/sbin
+CONFDIR=${PREFIX}/etc
+MAN=${PREFIX}/share/man
+
+all: dma
+
+clean:
+	-rm .depend dma *.[do]
+	-rm aliases_parse.[ch] aliases_scan.c reallocf.c strlcpy.c
+ 
+install: all
+	${INSTALL} -d ${DESTDIR}${SBIN} ${DESTDIR}${CONFDIR}
+	${INSTALL} -d ${DESTDIR}${MAN}/man8
+	${INSTALL} -m 0755 dma ${DESTDIR}${SBIN}
+	${INSTALL} -m 0644 dma.8 ${DESTDIR}${MAN}/man8/
+
+aliases_parse.c: aliases_parse.y
+	byacc -d -o aliases_parse.c aliases_parse.y
+
+aliases_scan.c: aliases_scan.l
+	lex -t aliases_scan.l > aliases_scan.c
+
+dma: aliases_parse.c aliases_scan.c reallocf.c strlcpy.c
+	${CC} -DLINUX ${LDADD} -o dma *.c
+
+reallocf.c:
+	ln -sf ../../lib/libc/stdlib/reallocf.c .
+
+strlcpy.c:
+	ln -sf ../../lib/libc/string/strlcpy.c
diff --git a/libexec/dma/dma.c b/libexec/dma/dma.c
index dadf056..621209c 100644
--- a/libexec/dma/dma.c
+++ b/libexec/dma/dma.c
@@ -295,7 +295,11 @@ retry:
 			exit(1);
 		}
 		if (gettimeofday(&now, NULL) == 0 &&
+#ifndef LINUX
 		    (now.tv_sec - st.st_mtimespec.tv_sec > MAX_TIMEOUT)) {
+#else
+		    ((time_t)now.tv_sec - st.st_mtime > MAX_TIMEOUT)) {
+#endif
 			asprintf(__DECONST(void *, &errmsg),
 				 "Could not deliver for the last %d seconds. Giving up.",
 				 MAX_TIMEOUT);
diff --git a/libexec/dma/dma.h b/libexec/dma/dma.h
index c96ae19..8ca9f44 100644
--- a/libexec/dma/dma.h
+++ b/libexec/dma/dma.h
@@ -52,6 +52,14 @@
 #endif  /* __GNUC__ */
 #endif
 
+#ifdef LINUX
+#ifndef __DECONST
+#define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
+#endif
+
+#define getprogname() "dma"
+#endif
+
 #define VERSION	"DragonFly Mail Agent"
 
 #define BUF_SIZE	2048
diff --git a/libexec/dma/dns.c b/libexec/dma/dns.c
index 8cfdd04..e40b790 100644
--- a/libexec/dma/dns.c
+++ b/libexec/dma/dns.c
@@ -97,7 +97,7 @@ add_host(int pref, const char *host, int port, struct mx_hostentry **he, size_t
 		p->ai.ai_addr = NULL;
 		bcopy(res->ai_addr, &p->sa, p->ai.ai_addrlen);
 
-		getnameinfo((struct sockaddr *)&p->sa, p->sa.ss_len,
+		getnameinfo((struct sockaddr *)&p->sa, sizeof(p->sa),
 			    p->addr, sizeof(p->addr),
 			    NULL, 0, NI_NUMERICHOST);
 
diff --git a/libexec/dma/net.c b/libexec/dma/net.c
index e3c563d..e8e80eb 100644
--- a/libexec/dma/net.c
+++ b/libexec/dma/net.c
@@ -290,7 +290,7 @@ open_connection(struct mx_hostentry *h)
 		return (-1);
 	}
 
-	if (connect(fd, (struct sockaddr *)&h->sa, h->sa.ss_len) < 0) {
+	if (connect(fd, (struct sockaddr *)&h->sa, sizeof(h->sa)) < 0) {
 		syslog(LOG_INFO, "connect to %s [%s] failed: %m",
 		       h->host, h->addr);
 		close(fd);
-- 
1.6.5.rc2



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]