/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* Portions
#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
#include <sys/types.h>
+#include <ac/stdlib.h>
+#include <ac/string.h> /* get memcmp() */
-#ifdef HAVE_SYS_UUID_H
+#ifdef HAVE_UUID_TO_STR
# include <sys/uuid.h>
#elif defined( _WIN32 )
# include <rpc.h>
#include <lutil.h>
-#ifndef HAVE_SYS_UUID_H
+/* not needed for Windows */
+#if !defined(HAVE_UUID_TO_STR) && !defined(_WIN32)
static unsigned char *
lutil_eaddr( void )
{
free(buf);
return NULL;
-#elif defined (SIOCGIFADDR)
+#elif defined( SIOCGIFADDR ) && defined( AFLINK )
char buf[sizeof(struct ifreq) * 32];
struct ifconf ifc;
struct ifreq *ifr;
if (memcmp(eaddr, zero, sizeof(eaddr)) == 0) {
/* XXX - who knows? */
lutil_entropy( eaddr, sizeof(eaddr) );
- eaddr[0] |= 0x80; /* turn it into a mutlicast address */
+ eaddr[0] |= 0x80; /* turn it into a multicast address */
}
return eaddr;
size_t
lutil_uuidstr( char *buf, size_t len )
{
-#ifdef HAVE_SYS_UUID_H
+#ifdef HAVE_UUID_TO_STR
uuid_t uu = {0};
unsigned rc;
char *s;
}
strncpy( buf, uuidstr, len );
- free( uuidstr );
+ RpcStringFree( &uuidstr );
return uuidlen;
struct timeval tv;
unsigned long long tl;
unsigned char *nl;
- unsigned short t2, t3, s1, n1, n2, n3;
+ unsigned short t2, t3, s1;
unsigned int t1;
/*
(unsigned) nl[2], (unsigned) nl[3],
(unsigned) nl[4], (unsigned) nl[5] );
- return (t1 < len) ? t1 : 0;
+ return (0 < t1 && t1 < len) ? t1 : 0;
#endif
}
{
char buf1[8], buf2[64];
-#ifndef HAVE_SYS_UUID_H
+#ifndef HAVE_UUID_TO_STR
unsigned char *p = lutil_eaddr();
if( p ) {