* Added some functions to missing.c: str[n]casecmp,
authormiquels <miquels>
Sun, 19 Sep 1999 16:38:00 +0000 (16:38 +0000)
committermiquels <miquels>
Sun, 19 Sep 1999 16:38:00 +0000 (16:38 +0000)
  gethostname, inet_ntoa
* Check for -rdynamic flag in configure

Make.inc.in
configure.in
src/include/autoconf.h.in
src/include/missing.h
src/lib/dict.c
src/lib/misc.c
src/lib/missing.c
src/lib/valuepair.c
src/main/Makefile
src/main/radiusd.c

index 8aa8461..c9012c5 100644 (file)
@@ -23,6 +23,7 @@ RANLIB                = @RANLIB@
 INCLUDE                = 
 CFLAGS         = $(INCLUDE) @CFLAGS@
 LDFLAGS                = @LDFLAGS@
+RDYNAMIC       = @RDYNAMIC@
 
 LCRYPT         = @CRYPTLIB@
 LDBM           = @DBMLIB@
index 312c5a8..1284308 100644 (file)
@@ -236,6 +236,11 @@ AC_CHECK_FUNCS( \
        snprintf \
        vsnprintf \
        setsid \
+       strncasecmp \
+       strcasecmp \
+       inet_aton \
+       gethostname \
+       setlinebuf \
 )
 
 dnl Check for socklen_t
@@ -245,6 +250,19 @@ AC_TRY_COMPILE([#include <sys/types.h>
   AC_DEFINE(HAVE_SOCKLEN_T),
 )
 
+dnl Check if the C compiler supports -rdynamic
+AC_MSG_CHECKING(whether $CC accepts -rdynamic...)
+OFLAGS="$CLAGS"
+CFLAGS="$CFLAGS -rdynamic"
+AC_TRY_COMPILE([], [int x = 0],RDYNAMIC=-rdynamic)
+AC_SUBST(RDYNAMIC)
+if test -n "$RDYNAMIC"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+CFLAGS="$OFLAGS"
+
 dnl Check for libcrypt
 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
 AC_CHECK_LIB(crypt, crypt,
index 9db351d..7460c4f 100644 (file)
@@ -44,18 +44,33 @@ config.h - created by autoconf; contains defines generated by autoconf
 /* Make dictionary case-independant */
 #undef WITH_DICT_NOCASE
 
+/* Define if you have the gethostname function.  */
+#undef HAVE_GETHOSTNAME
+
 /* Define if you have the getopt_long function.  */
 #undef HAVE_GETOPT_LONG
 
+/* Define if you have the inet_aton function.  */
+#undef HAVE_INET_ATON
+
 /* Define if you have the lockf function.  */
 #undef HAVE_LOCKF
 
+/* Define if you have the setlinebuf function.  */
+#undef HAVE_SETLINEBUF
+
 /* Define if you have the setsid function.  */
 #undef HAVE_SETSID
 
 /* Define if you have the snprintf function.  */
 #undef HAVE_SNPRINTF
 
+/* Define if you have the strcasecmp function.  */
+#undef HAVE_STRCASECMP
+
+/* Define if you have the strncasecmp function.  */
+#undef HAVE_STRNCASECMP
+
 /* Define if you have the strsignal function.  */
 #undef HAVE_STRSIGNAL
 
index 5d469c0..cef1b38 100644 (file)
 char *crypt(char *key, char *salt);
 #endif
 
-#ifdef __EMX__
-#define OS2
-/* EMX does not have SIGIOT */
-#define SIGIOT SIGTERM
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(char *s1, char *s2, int n);
+#endif
 
-/* EMX does not have this functions and must be implemented */
-#define strncasecmp    strncmp
-#define strcasecmp    strcmp
-#define inet_aton(x,y)     0
-#define setlinebuf(x)     0
-#define gethostname(x,y)  strncpy(x,getenv("HOSTNAME"),y)
+#ifndef HAVE_STRCASECMP
+int strcasecmp(char *s1, char *s2);
+#endif
+
+#ifndef HAVE_INET_ATON
+struct in_addr;
+int inet_aton(char *cp, struct in_addr *inp);
+#endif
+
+#ifndef HAVE_GETHOSTNAME
+int gethostname(char *name, int len);
+#endif
 
+#ifndef HAVE_SETLINEBUF
+#define setlinebuf(x)     0
 #endif
 
index 09852a0..456c9e1 100644 (file)
@@ -21,7 +21,7 @@ static const char rcsid[] = "$Id$";
 #endif
 
 #include       "libradius.h"
-#include    "missing.h"
+#include       "missing.h"
 
 static DICT_ATTR       *dictionary_attributes;
 static DICT_VALUE      *dictionary_values;
index 4e65df0..2f1ace2 100644 (file)
@@ -1,21 +1,21 @@
 /*
  * misc.c      Various miscellaneous functions.
  *
- * Version:     @(#)misc.c  1.00  19-Jul-1999  miquels@cistron.nl
+ * Version:    $Id$
  */
 
-char misc_sccsid[] =
-"@(#)misc.c    1.00 Copyright 1999 Cistron Internet Services B.V.";
+static const char rcsid[] =
+"$Id$";
 
 #include       "autoconf.h"
 
+#include       <stdio.h>
 #include       <sys/types.h>
 #include       <sys/socket.h>
 #include       <sys/time.h>
 #include       <netinet/in.h>
 #include       <arpa/inet.h>
 
-#include       <stdio.h>
 #include       <stdlib.h>
 #include       <string.h>
 #include       <netdb.h>
@@ -25,7 +25,7 @@ char misc_sccsid[] =
 #include       <signal.h>
 
 #include       "libradius.h"
-#include    "missing.h"
+#include       "missing.h"
 
 int            librad_dodns = 1;
 int            librad_debug = 0;
index 37ce1d3..8cdc3c1 100644 (file)
@@ -13,6 +13,9 @@ static const char rcsid[] = "$Id$";
 #include       <stdio.h>
 #include       <stdlib.h>
 #include       <sys/types.h>
+#include       <sys/socket.h>
+#include       <netinet/in.h>
+#include       <arpa/inet.h>
 
 #include       "missing.h"
 
@@ -24,3 +27,65 @@ char *crypt(char *key, char *salt)
 }
 #endif
 
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(char *s1, char *s2, int n)
+{
+       int             dif;
+       unsigned char   *p1, *p2;
+
+       p1 = (unsigned char *)s1;
+       p2 = (unsigned char *)s2;
+       dif = 0;
+
+       while (n != 0) {
+               if (*p1 == 0 && *p2 == 0)
+                       break;
+               if ((dif = s1 - s2) != 0)
+                       break;
+               p1++;
+               p2++;
+               n--;
+       }
+       return dif;
+}
+#endif
+
+#ifndef HAVE_STRCASECMP
+int strcasecmp(char *s1, char *s2)
+{
+       int             l1, l2;
+
+       l1 = strlen(s1);
+       l2 = strlen(s2);
+       if (l2 > l1) l1 = l2;
+
+       return strncasecmp(s1, s2, l1);
+}
+#endif
+
+#ifndef HAVE_INET_ATON
+int inet_aton(char *cp, struct in_addr *inp)
+{
+       int     a1, a2, a3, a4;
+
+       if (sscanf(cp, "%d.%d.%d.%d", &a1, &a2, &a3, &a4) != 4)
+               return 0;
+
+       inp->s_addr = htonl((a1 << 24) + (a2 << 16) + (a3 << 8) + a4);
+       return 1;
+}
+#endif
+
+#ifndef HAVE_GETHOSTNAME
+int gethostname(char *name, int len)
+{
+       char            *h;
+
+       h = getenv("HOSTNAME");
+       if (strlen(h) + 1 > len)
+               return -1;
+       strcpy(name, h);
+       return 0;
+}
+#endif
+
index 9ec3cc2..d1d84dc 100644 (file)
@@ -19,7 +19,7 @@ static const char rcsid[] = "$Id$";
 #include       <ctype.h>
 
 #include       "libradius.h"
-#include    "missing.h"
+#include       "missing.h"
 
 #if HAVE_MALLOC_H
 #  include     <malloc.h>
index 66d5696..44f327f 100644 (file)
@@ -10,7 +10,7 @@ SERVER_OBJS   = radiusd.o files.o util.o acct.o nas.o log.o valuepair.o \
 INCLUDES       = ../include/radiusd.h ../include/conf.h ../include/modules.h
 
 CFLAGS         += -I../include
-LDFLAGS                += -L../lib -rdynamic
+LDFLAGS                += -L../lib $(RDYNAMIC)
 LIBS           += -lradius
 
 all:   radiusd radwho radzap raduse radclient $(BUILDDBM)
index c4dde0c..1485b7a 100644 (file)
@@ -160,8 +160,12 @@ int main(int argc, char **argv)
        signal(SIGHUP, sig_hup);
        signal(SIGINT, sig_fatal);
        signal(SIGQUIT, sig_fatal);
+#ifdef SIGTRAP
        signal(SIGTRAP, sig_fatal);
+#endif
+#ifdef SIGIOT
        signal(SIGIOT, sig_fatal);
+#endif
        signal(SIGTERM, sig_fatal);
        signal(SIGCHLD, sig_cleanup);
 #if 0