Uwe Girlich's patch to handle OSes (e.g., SINIX) that lack

"strncasecmp()" or "mkstemp()"; add in source to the GNU "libc"
versions, and have the "configure" script check for the routines in
question and set up the Makefile to build from our versions if they're
missing.

svn path=/trunk/; revision=745
This commit is contained in:
Guy Harris 1999-10-01 21:41:38 +00:00
parent 57772323ad
commit 056ae6eb5e
4 changed files with 142 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
# $Id: Makefile.am,v 1.76 1999/09/24 04:59:45 gram Exp $
# $Id: Makefile.am,v 1.77 1999/10/01 21:41:38 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@ -147,10 +147,14 @@ EXTRA_ethereal_SOURCES = \
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

View File

@ -1,4 +1,4 @@
# $Id: configure.in,v 1.47 1999/09/30 16:24:07 gram Exp $
# $Id: configure.in,v 1.48 1999/10/01 21:41:38 guy Exp $
dnl Process this file with autoconf to produce a configure script.
AC_INIT(etypes.h)
@ -165,6 +165,24 @@ fi
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)

69
mkstemp.c Normal file
View File

@ -0,0 +1,69 @@
/* 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;
}

46
strncasecmp.c Normal file
View File

@ -0,0 +1,46 @@
/* 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;
}