You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2007/01/08 10:42:33 UTC

svn commit: r493998 - in /webservices/axis2/trunk/c/util: include/axis2_rand.h src/rand.c

Author: samisa
Date: Mon Jan  8 01:42:32 2007
New Revision: 493998

URL: http://svn.apache.org/viewvc?view=rev&rev=493998
Log:
Fixed formatting

Modified:
    webservices/axis2/trunk/c/util/include/axis2_rand.h
    webservices/axis2/trunk/c/util/src/rand.c

Modified: webservices/axis2/trunk/c/util/include/axis2_rand.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_rand.h?view=diff&rev=493998&r1=493997&r2=493998
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_rand.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_rand.h Mon Jan  8 01:42:32 2007
@@ -27,53 +27,50 @@
 {
 #endif
 
-/**
- * @defgroup axis2_rand rand
- * @ingroup axis2_util
- * @{
- */
-
-/**
- * @file axis2_rand.h
- * @brief A simple thread safe and reentrant random number generator
- */
-
-/**
- * This is reentrant and thread safe simple random number generator
- * function. it is passed an pointer to an unsigned int state value 
- * which is used inside the function and changed in each call.
- * @param seedp pointer to an unsigned int used as the internal state
- * @return int <code>int<code>
- */
-AXIS2_EXTERN int AXIS2_CALL
-axis2_rand(
-    unsigned int *seedp);
-
-/**
- * This is reentrant and thread safe simple random number generator
- * function. it is passed an pointer to an unsigned int state value 
- * which is used inside the function and changed in each call. Also 
- * it is passed a range in which the random number is selected
- * @param seedp pointer to an unsigned int used as the internal state
- * @param start start of the range
- * @param end end of the range
- * @return int If invalid range is entered -1 is returned <code>int<code>
- */
-AXIS2_EXTERN int AXIS2_CALL
-axis2_rand_with_range(
-    unsigned int *seedp,
-    int start,
-    int end);
-
-/**
- * A random seed value generated based on the time
- */
-AXIS2_EXTERN unsigned int AXIS2_CALL
-axis2_rand_get_seed_value_based_on_time(
-    const axis2_env_t *env);
+    /**
+     * @defgroup axis2_rand rand
+     * @ingroup axis2_util
+     * @{
+     */
+
+    /**
+     * @file axis2_rand.h
+     * @brief A simple thread safe and reentrant random number generator
+     */
+
+    /**
+     * This is reentrant and thread safe simple random number generator
+     * function. it is passed an pointer to an unsigned int state value
+     * which is used inside the function and changed in each call.
+     * @param seedp pointer to an unsigned int used as the internal state
+     * @return int <code>int<code>
+     */
+    AXIS2_EXTERN int AXIS2_CALL
+    axis2_rand(unsigned int *seedp);
+
+    /**
+     * This is reentrant and thread safe simple random number generator
+     * function. it is passed an pointer to an unsigned int state value
+     * which is used inside the function and changed in each call. Also
+     * it is passed a range in which the random number is selected
+     * @param seedp pointer to an unsigned int used as the internal state
+     * @param start start of the range
+     * @param end end of the range
+     * @return int If invalid range is entered -1 is returned <code>int<code>
+     */
+    AXIS2_EXTERN int AXIS2_CALL
+    axis2_rand_with_range(unsigned int *seedp,
+        int start,
+        int end);
+
+    /**
+     * A random seed value generated based on the time
+     */
+    AXIS2_EXTERN unsigned int AXIS2_CALL
+    axis2_rand_get_seed_value_based_on_time(const axis2_env_t *env);
+
+    /** @} */
 
-/** @} */
-    
 #ifdef __cplusplus
 }
 #endif

Modified: webservices/axis2/trunk/c/util/src/rand.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/rand.c?view=diff&rev=493998&r1=493997&r2=493998
==============================================================================
--- webservices/axis2/trunk/c/util/src/rand.c (original)
+++ webservices/axis2/trunk/c/util/src/rand.c Mon Jan  8 01:42:32 2007
@@ -23,34 +23,31 @@
 #define AXIS2_RAND_MAX 32768
 
 AXIS2_EXTERN int AXIS2_CALL
-axis2_rand(
-    unsigned int *seedp)
+axis2_rand(unsigned int *seedp)
 {
     *seedp = *seedp * 1103515245 + 12345;
-    return((unsigned)(*seedp/(2 * AXIS2_RAND_MAX)) % AXIS2_RAND_MAX);
+    return((unsigned)(*seedp / (2 * AXIS2_RAND_MAX)) % AXIS2_RAND_MAX);
 }
 
 AXIS2_EXTERN int AXIS2_CALL
-axis2_rand_with_range(
-    unsigned int *seedp,
+axis2_rand_with_range(unsigned int *seedp,
     int start,
     int end)
 {
     int rand = -1;
     float range = 0.0;
-    if(start < 0 || end <= 0) return -1;
-    if(start >= AXIS2_RAND_MAX || end > AXIS2_RAND_MAX) return -1;
-    if(end <= start) return -1;
-  
+    if (start < 0 || end <= 0) return -1;
+    if (start >= AXIS2_RAND_MAX || end > AXIS2_RAND_MAX) return -1;
+    if (end <= start) return -1;
+
     range = end - start;
     rand = axis2_rand(seedp);
-    rand = 1+(int) (range * rand / (AXIS2_RAND_MAX + 1.0));
+    rand = 1 + (int)(range * rand / (AXIS2_RAND_MAX + 1.0));
     return rand;
 }
 
 AXIS2_EXTERN unsigned int AXIS2_CALL
-axis2_rand_get_seed_value_based_on_time(
-    const axis2_env_t *env)
+axis2_rand_get_seed_value_based_on_time(const axis2_env_t *env)
 {
     axis2_date_time_t *date = axis2_date_time_create(env);
     unsigned int rand_var = AXIS2_DATE_TIME_GET_YEAR(date, env);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org