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

Re: Compile pbs ...



On Thu, 2003-02-13 at 14:01, rmkml wrote:
> and same pb on src/stormwall.c
> 
> FreeBSD don't have getopt.h include,
> FreeBSD use internal fonction libc ...
> and FreeBSD don't have getopt_long() ...
> 
> Could You Help Me ?

Try the attached patch - should apply with nothing but offsets. Sorry it
took a while, been away from internet connected computer since thursday
:P

Let me know if you encounter any other portability issues, I am very
keen to support FreeBSD (well, all free operating systems).

-- 
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/gianni-at-ecsc.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
Index: configure.in
===================================================================
RCS file: /home/scara/cvsroot/firestorm/configure.in,v
retrieving revision 1.48
diff -u -r1.48 configure.in
--- configure.in	7 Feb 2003 20:28:35 -0000	1.48
+++ configure.in	15 Feb 2003 11:02:11 -0000
@@ -31,7 +31,7 @@
 AC_HEADER_STDC
 AC_CHECK_HEADERS([arpa/inet.h errno.h fcntl.h netinet/in.h])
 AC_CHECK_HEADERS([stdlib.h string.h sys/socket.h sys/time.h unistd.h])
-AC_CHECK_HEADERS([sys/uio.h sys/resource.h])
+AC_CHECK_HEADERS([sys/uio.h sys/resource.h getopt.h])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -40,7 +40,7 @@
 AC_STRUCT_TM
 
 dnl Check for library functions
-AC_CHECK_FUNCS([tzset sigaction getrusage])
+AC_CHECK_FUNCS([tzset sigaction getrusage getopt_long])
 
 dnl Check for memory mapped IO support
 havemm="no"
Index: src/firecat.c
===================================================================
RCS file: /home/scara/cvsroot/firestorm/src/firecat.c,v
retrieving revision 1.61
diff -u -r1.61 firecat.c
--- src/firecat.c	7 Feb 2003 21:37:39 -0000	1.61
+++ src/firecat.c	15 Feb 2003 11:05:08 -0000
@@ -3,11 +3,14 @@
 * Copyright (c) 2002 Gianni Tedesco
 * This program is released under the terms of the GNU GPL version 2
 */
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <unistd.h>
+#ifdef HAVE_GETOPT_H
 #include <getopt.h>
+#endif
 #include <fcntl.h>
 #include <string.h>
 #include <netinet/in.h>
@@ -34,6 +37,7 @@
 
 #include <firecat.h>
 
+#ifdef HAVE_GETOPT_LONG
 struct option opts[]={
 	{"plugin-dir", 	1, 0, 'p'},
 	{"options", 	1, 0, 'o'},
@@ -43,6 +47,7 @@
 	{"help", 	0, 0, 'h'},
 	{NULL, 0, 0, 0}
 };
+#endif
 
 /* Store argv[0] */
 static char *cmd;
@@ -253,8 +258,13 @@
 	decode_init();
 
 	/* Do command line args */
+#ifdef HAVE_GETOPT_LONG
 	while( (c=getopt_long(argc, argv, "p:q:if:o:h?",
-		(const struct option *)&opts, &opti))!=-1 ) {
+		(const struct option *)&opts, &opti))!=-1 )
+#else
+	while( (c=getopt(argc, argv, "p:q:if:o:h?"))!=-1 )
+#endif
+	{
 		switch (c) {
 		case 'i':
 			m=MODE_IDX;
Index: src/stormwall.c
===================================================================
RCS file: /home/scara/cvsroot/firestorm/src/stormwall.c,v
retrieving revision 1.26
diff -u -r1.26 stormwall.c
--- src/stormwall.c	15 Jan 2003 11:28:39 -0000	1.26
+++ src/stormwall.c	15 Feb 2003 11:06:32 -0000
@@ -6,12 +6,15 @@
 * This is the stormwall daemon, it wakes up when firestorm tells it,
 * and it sends files off to a central server or whatever.
 */
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#ifdef HAVE_GETOPT_H
 #include <getopt.h>
+#endif
 #include <dirent.h>
 #include <syslog.h>
 #include <netdb.h>
@@ -169,19 +172,27 @@
 	uid_t uid=0;
 	gid_t gid=0;
 	char *root_dir=NULL;
+#ifdef HAVE_GETOPT_LONG
 	struct option opts[]={
 		{"uid", 1, 0, 'u'},
 		{"gid", 1, 0, 'g'},
 		{"root", 1, 0, 'r'},
 		{NULL, 0, 0, 0}
 	};
+#endif
 
 	/* Open up syslog connection */
 	openlog("stormwall", LOG_DAEMON, 0);
 
 	/* Parse the command line arguments */
+#ifdef HAVE_GETOPT_LONG
 	while( (c=getopt_long(argc,argv,"u:g:r:",
-		(const struct option *)&opts, &opti))!=-1 ) {
+		(const struct option *)&opts, &opti))!=-1 )
+#else
+	while( (c=getopt(argc,argv,"u:g:r:"))!=-1 ) 
+	
+#endif
+	{
 		switch (c) {
 		case 'u':
 			if ( strtouint(optarg,&uid) ) goto err;

Attachment: signature.asc
Description: This is a digitally signed message part