Ethereal-dev: [ethereal-dev] Changes for SINIX machines

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date Next Thread Next
From: Uwe Girlich <Uwe.Girlich@xxxxxxxxxxx>
Date: Fri, 1 Oct 1999 07:50:21 +0200
Here comes the unified diff for the changes in Makefile.am and configure.in.
These are necessary to get a clean compile under SINIX machines. I would even 
think all SVR4 UNIX systems should profit form these changes.

I had to change capture.c too because the new variable capture_child was
used and declared as extern in globals.h but not defined in capture.c.

---- cut here ----
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ethereal/Makefile.am,v
retrieving revision 1.76
diff -u -r1.76 Makefile.am
--- Makefile.am	1999/09/24 04:59:45	1.76
+++ Makefile.am	1999/10/01 05:15:44
@@ -147,10 +147,14 @@
 	snprintf.h	\
 	snprintf-imp.h	\
 	strerror.c	\
-	strerror.h
+	strerror.h	\
+	strncasecmp.c	\
+	mkstemp.c
 
-ethereal_DEPENDENCIES = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a gtk/libui.a
-ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a gtk/libui.a @SNMP_A@
+ethereal_DEPENDENCIES = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ \
+@STRNCASECMP_O@ @MKSTEMP_O@ wiretap/libwiretap.a gtk/libui.a
+ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ \
+@STRNCASECMP_O@ @MKSTEMP_O@ wiretap/libwiretap.a gtk/libui.a @SNMP_A@
 
 ps.c: print.ps rdps
 	./rdps $(srcdir)/print.ps ps.c
Index: capture.c
===================================================================
RCS file: /cvsroot/ethereal/capture.c,v
retrieving revision 1.74
diff -u -r1.74 capture.c
--- capture.c	1999/09/30 06:49:53	1.74
+++ capture.c	1999/10/01 05:15:47
@@ -83,6 +83,8 @@
 #include "prefs.h"
 #include "globals.h"
 
+gboolean capture_child;
+
 static void capture_stop_cb(GtkWidget *, gpointer);
 static void capture_pcap_cb(u_char *, const struct pcap_pkthdr *,
   const u_char *);
Index: configure.in
===================================================================
RCS file: /cvsroot/ethereal/configure.in,v
retrieving revision 1.46
diff -u -r1.46 configure.in
--- configure.in	1999/09/24 14:59:32	1.46
+++ configure.in	1999/10/01 05:15:48
@@ -164,6 +164,24 @@
 AC_SUBST(STRERROR_C)
 AC_SUBST(STRERROR_O)
 
+AC_CHECK_FUNC(strncasecmp, STRNCASECMP_O="",
+  STRNCASECMP_O="strncasecmp.o")
+if test "$ac_cv_func_strncasecmp" = no ; then
+  STRNCASECMP_C="strncasecmp.c"
+  STRNCASECMP_O="strncasecmp.o"
+fi
+AC_SUBST(STRNCASECMP_C)
+AC_SUBST(STRNCASECMP_O)
+
+AC_CHECK_FUNC(mkstemp, MKSTEMP_O="",
+  MKSTEMP_O="mkstemp.o")
+if test "$ac_cv_func_mkstemp" = no ; then
+  MKSTEMP_C="mkstemp.c"
+  MKSTEMP_O="mkstemp.o"
+fi
+AC_SUBST(MKSTEMP_C)
+AC_SUBST(MKSTEMP_O)
+
 dnl blank for now, but will be used in future
 AC_SUBST(ethereal_SUBDIRS)
---- cut here too ----

And now the new files mkstemp.c and strncasecmp.c. I took them from a 
current GNU C library and removed the strange prototype macros.

---- mkstemp.c ----
/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

#ifndef __set_errno
#define __set_errno(x) errno=(x) 
#endif

/* Generate a unique temporary file name from TEMPLATE.
   The last six characters of TEMPLATE must be "XXXXXX";
   they are replaced with a string that makes the filename unique.
   Returns a file descriptor open on the file for reading and writing.  */
int
mkstemp (template)
     char *template;
{
  static const char letters[]
    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  size_t len;
  size_t i;

  len = strlen (template);
  if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
    {
      __set_errno (EINVAL);
      return -1;
    }

  if (sprintf (&template[len - 5], "%.5u",
	       (unsigned int) getpid () % 100000) != 5)
    /* Inconceivable lossage.  */
    return -1;

  for (i = 0; i < sizeof (letters); ++i)
    {
      int fd;

      template[len - 6] = letters[i];

      fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
      if (fd >= 0)
	return fd;
    }

  /* We return the null string if we can't find a unique file name.  */
  template[0] = '\0';
  return -1;
}
---- End of mkstemp.c ----


---- strncasecmp.c ----
/* Copyright (C) 1992, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB.  If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.  */

#include <ansidecl.h>
#include <string.h>
#include <ctype.h>

/* Compare no more than N characters of S1 and S2,
   ignoring case, returning less than, equal to or
   greater than zero if S1 is lexicographically less
   than, equal to or greater than S2.  */
int
strncasecmp (const char *s1, const char *s2, size_t n)
{
  register const unsigned char *p1 = (const unsigned char *) s1;
  register const unsigned char *p2 = (const unsigned char *) s2;
  unsigned char c1, c2;

  if (p1 == p2 || n == 0)
    return 0;

  do
    {
      c1 = tolower (*p1++);
      c2 = tolower (*p2++);
      if (c1 == '\0' || c1 != c2)
	return c1 - c2;
    } while (--n > 0);

  return c1 - c2;
}
---- End of strncasecmp.c ----

 
-- 
Dr. Uwe Girlich              email: Uwe.Girlich@xxxxxxxxxxx
Philosys Software GmbH       www: www.philosys.de
Edisonstrasse 6              phone: +49 89 321407-44
D-85716 Unterschleissheim    fax: +49 89 321407-12