[cvslog] (2004-12-23 00:12:45 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Wed Dec 22 18:12:45 CST 2004


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2004-12-23 00:12:45 UTC
Commited by: Bryan Drewery <lordares at shatow.net>

Modified files:
     lib/eggdrop/dns.c lib/eggdrop/string.c lib/eggdrop/string.h

Log message:

* Added shuffleArray(char **, int len) to string.c
* Dns cached pools are now shuffled before callback

---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/dns.c
diff -u eggdrop1.9/lib/eggdrop/dns.c:1.12 eggdrop1.9/lib/eggdrop/dns.c:1.13
--- eggdrop1.9/lib/eggdrop/dns.c:1.12	Wed Dec 22 13:03:08 2004
+++ eggdrop1.9/lib/eggdrop/dns.c	Wed Dec 22 18:12:34 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: dns.c,v 1.12 2004/12/22 19:03:08 lordares Exp $";
+static const char rcsid[] = "$Id: dns.c,v 1.13 2004/12/23 00:12:34 lordares Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -184,6 +184,7 @@
 	/* Search our cache for the same query */
 	cache_id = cache_find(host);
 	if (cache_id >= 0) {
+		shuffleArray(cache[cache_id].answer.list, cache[cache_id].answer.len);
 	        callback(client_data, host, cache[cache_id].answer.list);
 	        return(-1);
 	}
@@ -265,6 +266,7 @@
 	/* Search our cache for the same query */
 	cache_id = cache_find(ip);
 	if (cache_id >= 0) {
+		shuffleArray(cache[cache_id].answer.list, cache[cache_id].answer.len);
         	callback(client_data, ip, cache[cache_id].answer.list);
 	        return(-1);
 	}
Index: eggdrop1.9/lib/eggdrop/string.c
diff -u eggdrop1.9/lib/eggdrop/string.c:1.3 eggdrop1.9/lib/eggdrop/string.c:1.4
--- eggdrop1.9/lib/eggdrop/string.c:1.3	Sun Oct 17 00:14:06 2004
+++ eggdrop1.9/lib/eggdrop/string.c	Wed Dec 22 18:12:34 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: string.c,v 1.3 2004/10/17 05:14:06 stdarg Exp $";
+static const char rcsid[] = "$Id: string.c,v 1.4 2004/12/23 00:12:34 lordares Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>				/* egg_return_val_if_fail	*/
@@ -268,3 +268,18 @@
 		str++;
 	}
 }
+
+/* Arrange the N elements of ARRAY in random order. */
+void shuffleArray(char *array[], size_t n)
+{
+	size_t j = 0, i = 0;
+	char *temp = NULL;
+
+	for (i = 0; i < n; i++) {
+		j = i + random() / (RAND_MAX / (n - i) + 1);
+		temp = array[j];
+		array[j] = array[i];
+		array[i] = temp;
+	}
+}
+
Index: eggdrop1.9/lib/eggdrop/string.h
diff -u eggdrop1.9/lib/eggdrop/string.h:1.3 eggdrop1.9/lib/eggdrop/string.h:1.4
--- eggdrop1.9/lib/eggdrop/string.h:1.3	Mon Oct  4 10:48:29 2004
+++ eggdrop1.9/lib/eggdrop/string.h	Wed Dec 22 18:12:34 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: string.h,v 1.3 2004/10/04 15:48:29 stdarg Exp $
+ * $Id: string.h,v 1.4 2004/12/23 00:12:34 lordares Exp $
  */
 
 #ifndef _EGG_STRING_H_
@@ -37,4 +37,6 @@
 void egg_append_static_str(char **dest, int *remaining, const char *src);
 void egg_append_str(char **dest, int *cur, int *max, const char *src);
 
+void shuffleArray(char **array, size_t n);
+
 #endif /* !_EGG_STRING_H_ */
----------------------- End of diff -----------------------



More information about the Changes mailing list