You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sh...@apache.org on 2009/08/18 13:24:02 UTC
svn commit: r805365 [3/5] - in /webservices/axis2/trunk/c/util/src: ./
platforms/unix/ platforms/windows/
Modified: webservices/axis2/trunk/c/util/src/linked_list.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/linked_list.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/linked_list.c (original)
+++ webservices/axis2/trunk/c/util/src/linked_list.c Tue Aug 18 11:24:00 2009
@@ -30,25 +30,25 @@
entry_t *first;
/**
- * The last element in the list.
- */
+ * The last element in the list.
+ */
entry_t *last;
/**
- * A count of the number of structural modifications that have been made to
- * the list (that is, insertions and removals). Structural modifications
- * are ones which change the list size or affect how iterations would
- * behave. This field is available for use by Iterator and ListIterator,
- * in order to set an error code in response
- * to the next op on the iterator. This <i>fail-fast</i> behavior
- * saves the user from many subtle bugs otherwise possible from concurrent
- * modification during iteration.
- * <p>
- *
- * To make lists fail-fast, increment this field by just 1 in the
- * <code>add(int, Object)</code> and <code>remove(int)</code> methods.
- * Otherwise, this field may be ignored.
- */
+ * A count of the number of structural modifications that have been made to
+ * the list (that is, insertions and removals). Structural modifications
+ * are ones which change the list size or affect how iterations would
+ * behave. This field is available for use by Iterator and ListIterator,
+ * in order to set an error code in response
+ * to the next op on the iterator. This <i>fail-fast</i> behavior
+ * saves the user from many subtle bugs otherwise possible from concurrent
+ * modification during iteration.
+ * <p>
+ *
+ * To make lists fail-fast, increment this field by just 1 in the
+ * <code>add(int, Object)</code> and <code>remove(int)</code> methods.
+ * Otherwise, this field may be ignored.
+ */
int mod_count;
};
@@ -61,7 +61,7 @@
AXIS2_ENV_CHECK(env, NULL);
linked_list = AXIS2_MALLOC(env->allocator, sizeof(axutil_linked_list_t));
- if (!linked_list)
+ if(!linked_list)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -81,8 +81,8 @@
const axutil_env_t *env,
void *data)
{
- entry_t *entry = (entry_t *) AXIS2_MALLOC(env->allocator, sizeof(entry_t));
- if (!entry)
+ entry_t *entry = (entry_t *)AXIS2_MALLOC(env->allocator, sizeof(entry_t));
+ if(!entry)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -104,7 +104,7 @@
AXIS2_PARAM_CHECK(env->error, e, AXIS2_FAILURE);
linked_list->mod_count++;
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
linked_list->first = linked_list->last = e;
}
@@ -124,11 +124,10 @@
axutil_linked_list_t *linked_list,
const axutil_env_t *env)
{
- entry_t *current = NULL,
- *next = NULL;
+ entry_t *current = NULL, *next = NULL;
current = linked_list->first;
- while (current)
+ while(current)
{
next = current->next;
AXIS2_FREE(env->allocator, current);
@@ -145,11 +144,11 @@
int n)
{
entry_t *e = NULL;
- if (n < linked_list->size / 2)
+ if(n < linked_list->size / 2)
{
e = linked_list->first;
/* n less than size/2, iterate from start */
- while (n > 0)
+ while(n > 0)
{
e = e->next;
n = n - 1;
@@ -159,7 +158,7 @@
{
e = linked_list->last;
/* n greater than size/2, iterate from end */
- while ((n = n + 1) < linked_list->size)
+ while((n = n + 1) < linked_list->size)
{
e = e->previous;
}
@@ -177,18 +176,18 @@
AXIS2_PARAM_CHECK(env->error, e, AXIS2_FAILURE);
linked_list->mod_count++;
linked_list->size--;
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
linked_list->first = linked_list->last = NULL;
}
else
{
- if (e == linked_list->first)
+ if(e == linked_list->first)
{
linked_list->first = e->next;
e->next->previous = NULL;
}
- else if (e == linked_list->last)
+ else if(e == linked_list->last)
{
linked_list->last = e->previous;
e->previous->next = NULL;
@@ -208,10 +207,9 @@
const axutil_env_t *env,
int index)
{
- if (index < 0 || index > linked_list->size)
+ if(index < 0 || index > linked_list->size)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INDEX_OUT_OF_BOUNDS,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INDEX_OUT_OF_BOUNDS, AXIS2_FAILURE);
return AXIS2_FALSE;
}
return AXIS2_TRUE;
@@ -223,10 +221,9 @@
const axutil_env_t *env,
int index)
{
- if (index < 0 || index >= linked_list->size)
+ if(index < 0 || index >= linked_list->size)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INDEX_OUT_OF_BOUNDS,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INDEX_OUT_OF_BOUNDS, AXIS2_FAILURE);
return AXIS2_FALSE;
}
return AXIS2_TRUE;
@@ -237,7 +234,7 @@
axutil_linked_list_t *linked_list,
const axutil_env_t *env)
{
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_SUCH_ELEMENT, AXIS2_FAILURE);
return NULL;
@@ -251,7 +248,7 @@
axutil_linked_list_t *linked_list,
const axutil_env_t *env)
{
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_SUCH_ELEMENT, AXIS2_FAILURE);
return NULL;
@@ -267,7 +264,7 @@
{
void *r;
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_SUCH_ELEMENT, AXIS2_FAILURE);
return NULL;
@@ -277,7 +274,7 @@
linked_list->size--;
r = linked_list->first->data;
- if (linked_list->first->next)
+ if(linked_list->first->next)
{
linked_list->first->next->previous = NULL;
}
@@ -298,7 +295,7 @@
{
void *r = NULL;
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_SUCH_ELEMENT, AXIS2_FAILURE);
return NULL;
@@ -308,7 +305,7 @@
linked_list->size--;
r = linked_list->last->data;
- if (linked_list->last->previous)
+ if(linked_list->last->previous)
{
linked_list->last->previous->next = NULL;
}
@@ -334,7 +331,7 @@
e = axutil_linked_list_create_entry(env, o);
linked_list->mod_count++;
- if (linked_list->size == 0)
+ if(linked_list->size == 0)
{
linked_list->first = linked_list->last = e;
}
@@ -372,9 +369,9 @@
AXIS2_PARAM_CHECK(env->error, o, AXIS2_FALSE);
e = linked_list->first;
- while (e)
+ while(e)
{
- if (o == e->data)
+ if(o == e->data)
return AXIS2_TRUE;
e = e->next;
}
@@ -411,9 +408,9 @@
AXIS2_PARAM_CHECK(env->error, o, AXIS2_FALSE);
e = linked_list->first;
- while (e)
+ while(e)
{
- if (o == e->data)
+ if(o == e->data)
{
return axutil_linked_list_remove_entry(linked_list, env, e);
}
@@ -427,7 +424,7 @@
axutil_linked_list_t *linked_list,
const axutil_env_t *env)
{
- if (linked_list->size > 0)
+ if(linked_list->size > 0)
{
linked_list->mod_count++;
linked_list->first = NULL;
@@ -479,13 +476,13 @@
axutil_linked_list_check_bounds_inclusive(linked_list, env, index);
e = axutil_linked_list_create_entry(env, o);
- if (index < linked_list->size)
+ if(index < linked_list->size)
{
linked_list->mod_count++;
after = axutil_linked_list_get_entry(linked_list, env, index);
e->next = after;
e->previous = after->previous;
- if (after->previous == NULL)
+ if(after->previous == NULL)
linked_list->first = e;
else
after->previous->next = e;
@@ -524,9 +521,9 @@
AXIS2_PARAM_CHECK(env->error, o, AXIS2_FAILURE);
e = linked_list->first;
- while (e)
+ while(e)
{
- if (o == e->data)
+ if(o == e->data)
return index;
index++;
e = e->next;
@@ -546,9 +543,9 @@
index = linked_list->size - 1;
e = linked_list->last;
- while (e)
+ while(e)
{
- if (o == e->data)
+ if(o == e->data)
return index;
index--;
e = e->previous;
@@ -564,10 +561,9 @@
int i = 0;
void **array;
entry_t *e;
- array = (void **) AXIS2_MALLOC(env->allocator,
- linked_list->size * sizeof(void *));
+ array = (void **)AXIS2_MALLOC(env->allocator, linked_list->size * sizeof(void *));
e = linked_list->first;
- for (i = 0; i < linked_list->size; i++)
+ for(i = 0; i < linked_list->size; i++)
{
array[i] = e->data;
e = e->next;
Modified: webservices/axis2/trunk/c/util/src/log.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/log.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/log.c (original)
+++ webservices/axis2/trunk/c/util/src/log.c Tue Aug 18 11:24:00 2009
@@ -59,10 +59,7 @@
#define AXUTIL_INTF_TO_IMPL(log) ((axutil_log_impl_t*)(log))
-static const axutil_log_ops_t axutil_log_ops_var = {
- axutil_log_impl_free,
- axutil_log_impl_write
-};
+static const axutil_log_ops_t axutil_log_ops_var = { axutil_log_impl_free, axutil_log_impl_write };
static void AXIS2_CALL
axutil_log_impl_free(
@@ -71,19 +68,19 @@
{
axutil_log_impl_t *log_impl = NULL;
- if (log)
+ if(log)
{
log_impl = AXUTIL_INTF_TO_IMPL(log);
- if (log_impl->mutex)
+ if(log_impl->mutex)
{
axutil_thread_mutex_destroy(log_impl->mutex);
}
- if (log_impl->stream)
+ if(log_impl->stream)
{
axutil_file_handler_close(log_impl->stream);
}
- if (log_impl->file_name)
+ if(log_impl->file_name)
{
AXIS2_FREE(allocator, log_impl->file_name);
}
@@ -103,19 +100,17 @@
axis2_char_t log_dir[AXUTIL_LOG_FILE_NAME_SIZE];
axis2_char_t tmp_filename[AXUTIL_LOG_FILE_NAME_SIZE];
- if (!allocator)
+ if(!allocator)
return NULL;
- log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
- sizeof(axutil_log_impl_t));
+ log_impl = (axutil_log_impl_t *)AXIS2_MALLOC(allocator, sizeof(axutil_log_impl_t));
- if (!log_impl)
+ if(!log_impl)
return NULL;
- log_impl->mutex =
- axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);
+ log_impl->mutex = axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);
- if (!log_impl->mutex)
+ if(!log_impl->mutex)
{
fprintf(stderr, "cannot create log mutex \n");
return NULL;
@@ -126,7 +121,7 @@
#endif
/* default log file is axis2.log */
- if (stream_name)
+ if(stream_name)
AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", stream_name);
else
AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", "axis2.log");
@@ -134,39 +129,34 @@
/* we write all logs to AXIS2C_HOME/logs if it is set otherwise
* to the working dir
*/
- if (stream_name && !(axutil_rindex(stream_name, AXIS2_PATH_SEP_CHAR)))
+ if(stream_name && !(axutil_rindex(stream_name, AXIS2_PATH_SEP_CHAR)))
{
path_home = AXIS2_GETENV("AXIS2C_HOME");
- if (path_home)
+ if(path_home)
{
- AXIS2_SNPRINTF(log_dir, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s",
- path_home, AXIS2_PATH_SEP_CHAR, "logs");
- if (AXIS2_SUCCESS ==
- axutil_file_handler_access(log_dir, AXIS2_F_OK))
+ AXIS2_SNPRINTF(log_dir, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", path_home,
+ AXIS2_PATH_SEP_CHAR, "logs");
+ if(AXIS2_SUCCESS == axutil_file_handler_access(log_dir, AXIS2_F_OK))
{
- AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE,
- "%s%c%s", log_dir, AXIS2_PATH_SEP_CHAR, tmp_filename);
+ AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", log_dir,
+ AXIS2_PATH_SEP_CHAR, tmp_filename);
}
else
{
- fprintf(stderr, "log folder %s does not exist - log file %s "\
+ fprintf(stderr, "log folder %s does not exist - log file %s "
"is written to . dir\n", log_dir, tmp_filename);
- AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s",
- tmp_filename);
+ AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", tmp_filename);
}
}
else
{
- fprintf(stderr,
- "AXIS2C_HOME is not set - log is written to . dir\n");
- AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s",
- tmp_filename);
+ fprintf(stderr, "AXIS2C_HOME is not set - log is written to . dir\n");
+ AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", tmp_filename);
}
}
else
{
- AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s",
- tmp_filename);
+ AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", tmp_filename);
}
log_impl->file_name = AXIS2_MALLOC(allocator, AXUTIL_LOG_FILE_NAME_SIZE);
log_impl->log.size = AXUTIL_LOG_FILE_SIZE;
@@ -175,18 +165,18 @@
axutil_thread_mutex_lock(log_impl->mutex);
log_impl->stream = axutil_file_handler_open(log_file_name, "a+");
- axutil_log_impl_rotate((axutil_log_t *) log_impl);
+ axutil_log_impl_rotate((axutil_log_t *)log_impl);
axutil_thread_mutex_unlock(log_impl->mutex);
- if (!log_impl->stream)
+ if(!log_impl->stream)
log_impl->stream = stderr;
/* by default, log is enabled */
log_impl->log.enabled = 1;
log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;
- if (ops)
+ if(ops)
{
log_impl->log.ops = ops;
}
@@ -206,12 +196,12 @@
const axis2_char_t *file,
const int line)
{
- if (log && log->enabled && buffer)
+ if(log && log->enabled && buffer)
{
axutil_log_impl_t *l = AXUTIL_INTF_TO_IMPL(log);
- if (!l->mutex)
+ if(!l->mutex)
fprintf(stderr, "Log mutex is not found\n");
- if (!l->stream)
+ if(!l->stream)
fprintf(stderr, "Stream is not found\n");
if(level <= log->level || level == AXIS2_LOG_LEVEL_CRITICAL)
{
@@ -219,7 +209,7 @@
}
}
#ifndef AXIS2_NO_LOG_FILE
- else if (buffer)
+ else if(buffer)
fprintf(stderr, "please check your log and buffer");
#endif
else
@@ -240,45 +230,44 @@
FILE *fd = NULL;
/**
- * print all critical and error logs irrespective of log->level setting
- */
+ * print all critical and error logs irrespective of log->level setting
+ */
- switch (level)
+ switch(level)
{
- case AXIS2_LOG_LEVEL_CRITICAL:
- level_str = "[critical] ";
- break;
- case AXIS2_LOG_LEVEL_ERROR:
- level_str = "[error] ";
- break;
- case AXIS2_LOG_LEVEL_WARNING:
- level_str = "[warning] ";
- break;
- case AXIS2_LOG_LEVEL_INFO:
- level_str = "[info] ";
- break;
- case AXIS2_LOG_LEVEL_DEBUG:
- level_str = "[debug] ";
- break;
- case AXIS2_LOG_LEVEL_TRACE:
- level_str = "[...TRACE...] ";
- break;
- case AXIS2_LOG_LEVEL_USER:
- break;
+ case AXIS2_LOG_LEVEL_CRITICAL:
+ level_str = "[critical] ";
+ break;
+ case AXIS2_LOG_LEVEL_ERROR:
+ level_str = "[error] ";
+ break;
+ case AXIS2_LOG_LEVEL_WARNING:
+ level_str = "[warning] ";
+ break;
+ case AXIS2_LOG_LEVEL_INFO:
+ level_str = "[info] ";
+ break;
+ case AXIS2_LOG_LEVEL_DEBUG:
+ level_str = "[debug] ";
+ break;
+ case AXIS2_LOG_LEVEL_TRACE:
+ level_str = "[...TRACE...] ";
+ break;
+ case AXIS2_LOG_LEVEL_USER:
+ break;
}
axutil_thread_mutex_lock(mutex);
axutil_log_impl_rotate(log);
fd = log_impl->stream;
-
- if (fd)
+
+ if(fd)
{
- if (file)
- fprintf(fd, "[%s] %s%s(%d) %s\n", axutil_log_impl_get_time_str(),
- level_str, file, line, value);
+ if(file)
+ fprintf(fd, "[%s] %s%s(%d) %s\n", axutil_log_impl_get_time_str(), level_str, file,
+ line, value);
else
- fprintf(fd, "[%s] %s %s\n", axutil_log_impl_get_time_str(), level_str,
- value);
+ fprintf(fd, "[%s] %s %s\n", axutil_log_impl_get_time_str(), level_str, value);
fflush(fd);
}
axutil_thread_mutex_unlock(mutex);
@@ -294,11 +283,11 @@
axutil_log_impl_t *log_impl = AXUTIL_INTF_TO_IMPL(log);
if(log_impl->file_name)
size = axutil_file_handler_size(log_impl->file_name);
-
+
if(size >= log->size)
{
- AXIS2_SNPRINTF(old_log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s%s",
- log_impl->file_name, ".old");
+ AXIS2_SNPRINTF(old_log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s%s", log_impl->file_name,
+ ".old");
axutil_file_handler_close(log_impl->stream);
old_log_fd = axutil_file_handler_open(old_log_file_name, "w+");
log_impl->stream = axutil_file_handler_open(log_impl->file_name, "r");
@@ -331,8 +320,7 @@
const axis2_char_t *format,
...)
{
- if (log && log->ops && log->ops->write &&
- format && log->enabled)
+ if(log && log->ops && log->ops->write && format && log->enabled)
{
if(AXIS2_LOG_LEVEL_DEBUG <= log->level)
{
@@ -358,8 +346,7 @@
const axis2_char_t *format,
...)
{
- if (log && log->ops && log->ops->write &&
- format && log->enabled)
+ if(log && log->ops && log->ops->write && format && log->enabled)
{
if(AXIS2_LOG_LEVEL_DEBUG <= log->level && log->level != AXIS2_LOG_LEVEL_USER)
{
@@ -383,8 +370,7 @@
const axis2_char_t *format,
...)
{
- if (log && log->ops && log->ops->write &&
- format && log->enabled)
+ if(log && log->ops && log->ops->write && format && log->enabled)
{
if(AXIS2_LOG_LEVEL_INFO <= log->level && log->level != AXIS2_LOG_LEVEL_USER)
{
@@ -410,8 +396,7 @@
const axis2_char_t *format,
...)
{
- if (log && log->ops && log->ops->write &&
- format && log->enabled)
+ if(log && log->ops && log->ops->write && format && log->enabled)
{
if(AXIS2_LOG_LEVEL_WARNING <= log->level && log->level != AXIS2_LOG_LEVEL_USER)
{
@@ -437,8 +422,7 @@
const axis2_char_t *format,
...)
{
- if (log && log->ops && log->ops->write &&
- format && log->enabled)
+ if(log && log->ops && log->ops->write && format && log->enabled)
{
char value[AXIS2_LEN_VALUE + 1];
va_list ap;
@@ -461,8 +445,7 @@
const axis2_char_t *format,
...)
{
- if (log && log->ops && log->ops->write &&
- format && log->enabled)
+ if(log && log->ops && log->ops->write && format && log->enabled)
{
char value[AXIS2_LEN_VALUE + 1];
va_list ap;
@@ -485,11 +468,11 @@
char *time_str;
tp = time(&tp);
time_str = ctime(&tp);
- if (!time_str)
+ if(!time_str)
{
return NULL;
}
- if ('\n' == time_str[strlen(time_str) - 1])
+ if('\n' == time_str[strlen(time_str) - 1])
{
time_str[strlen(time_str) - 1] = '\0';
}
@@ -502,19 +485,17 @@
{
axutil_log_impl_t *log_impl;
- if (!allocator)
+ if(!allocator)
return NULL;
- log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
- sizeof(axutil_log_impl_t));
+ log_impl = (axutil_log_impl_t *)AXIS2_MALLOC(allocator, sizeof(axutil_log_impl_t));
- if (!log_impl)
+ if(!log_impl)
return NULL;
- log_impl->mutex =
- axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);
+ log_impl->mutex = axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);
- if (!log_impl->mutex)
+ if(!log_impl->mutex)
{
fprintf(stderr, "cannot create log mutex \n");
return NULL;
@@ -545,20 +526,20 @@
{
if (log && log->ops && log->ops->write &&
format && log->enabled)
+ {
+ if(AXIS2_LOG_LEVEL_TRACE <= log->level && log->level != AXIS2_LOG_LEVEL_USER)
{
- if(AXIS2_LOG_LEVEL_TRACE <= log->level && log->level != AXIS2_LOG_LEVEL_USER)
- {
- char value[AXIS2_LEN_VALUE + 1];
- va_list ap;
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- log->ops->write(log, value, AXIS2_LOG_LEVEL_TRACE, file, line);
- }
+ char value[AXIS2_LEN_VALUE + 1];
+ va_list ap;
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ log->ops->write(log, value, AXIS2_LOG_LEVEL_TRACE, file, line);
}
+ }
#ifndef AXIS2_NO_LOG_FILE
else
- fprintf(stderr, "please check your log and buffer");
+ fprintf(stderr, "please check your log and buffer");
#endif
}
Modified: webservices/axis2/trunk/c/util/src/md5.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/md5.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/md5.c (original)
+++ webservices/axis2/trunk/c/util/src/md5.c Tue Aug 18 11:24:00 2009
@@ -52,12 +52,9 @@
const unsigned char *input,
unsigned int len);
-static unsigned char PADDING[64] =
-{
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
+static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* F, G, H and I are basic MD5 functions.
*/
@@ -101,8 +98,8 @@
axutil_md5_ctx_t *context;
AXIS2_ENV_CHECK(env, NULL);
- context = (axutil_md5_ctx_t *) AXIS2_MALLOC(env->allocator, sizeof(axutil_md5_ctx_t));
- if (!context)
+ context = (axutil_md5_ctx_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_md5_ctx_t));
+ if(!context)
{
return NULL;
}
@@ -122,7 +119,7 @@
const axutil_env_t *env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (md5_ctx)
+ if(md5_ctx)
{
AXIS2_FREE(env->allocator, md5_ctx);
}
@@ -143,19 +140,19 @@
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((unsigned int)inputLen << 3))
- < ((unsigned int)inputLen << 3))
+ if((context->count[0] += ((unsigned int)inputLen << 3)) < ((unsigned int)inputLen << 3))
context->count[1]++;
context->count[1] += (unsigned int)inputLen >> 29;
partLen = 64 - idx;
/* Transform as many times as possible. */
- if (inputLen >= partLen) {
+ if(inputLen >= partLen)
+ {
memcpy(&context->buffer[idx], input, partLen);
md5_transform(context->state, context->buffer);
- for (i = partLen; i + 63 < inputLen; i += 64)
+ for(i = partLen; i + 63 < inputLen; i += 64)
md5_transform(context->state, &input[i]);
idx = 0;
@@ -200,10 +197,10 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axutil_md5(
- const axutil_env_t *env,
- unsigned char digest[AXIS2_MD5_DIGESTSIZE],
- const void *input_str,
- size_t inputLen)
+ const axutil_env_t *env,
+ unsigned char digest[AXIS2_MD5_DIGESTSIZE],
+ const void *input_str,
+ size_t inputLen)
{
const unsigned char *input = input_str;
axutil_md5_ctx_t *ctx;
@@ -211,11 +208,11 @@
AXIS2_ENV_CHECK(env, AXIS2_FALSE);
ctx = axutil_md5_ctx_create(env);
- if (!ctx)
+ if(!ctx)
return AXIS2_FAILURE;
-
- rv = axutil_md5_update(ctx, env, input, inputLen);
- if (rv != AXIS2_SUCCESS)
+
+ rv = axutil_md5_update(ctx, env, input, inputLen);
+ if(rv != AXIS2_SUCCESS)
return rv;
rv = axutil_md5_final(ctx, env, digest);
@@ -229,21 +226,21 @@
const unsigned char block[64])
{
unsigned int a = state[0], b = state[1], c = state[2], d = state[3],
- x[AXIS2_MD5_DIGESTSIZE];
+ x[AXIS2_MD5_DIGESTSIZE];
decode(x, block, 64);
/* Round 1 */
- FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
- FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
- FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
- FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
- FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
- FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
- FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
- FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
- FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
- FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
+ FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
+ FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
+ FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
+ FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
+ FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
+ FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
+ FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
+ FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
+ FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
+ FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
@@ -252,58 +249,58 @@
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
- GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
- GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
+ GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
+ GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
- GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
- GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
+ GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
+ GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
- GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
+ GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
+ GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
- GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
+ GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
+ GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
- GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
+ GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
+ GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
- HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
- HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
+ HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
+ HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
- HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
- HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
+ HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
+ HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
+ HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
- HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
- HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
- HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
+ HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
+ HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
+ HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
+ HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
+ HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
- II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
- II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
+ II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
+ II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
+ II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
+ II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
- II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
+ II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
+ II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
+ II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
+ II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
- II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
+ II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
+ II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
@@ -325,9 +322,10 @@
unsigned int i, j;
unsigned int k;
- for (i = 0, j = 0; j < len; i++, j += 4) {
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ {
k = input[i];
- output[j] = (unsigned char)(k & 0xff);
+ output[j] = (unsigned char)(k & 0xff);
output[j + 1] = (unsigned char)((k >> 8) & 0xff);
output[j + 2] = (unsigned char)((k >> 16) & 0xff);
output[j + 3] = (unsigned char)((k >> 24) & 0xff);
@@ -345,8 +343,8 @@
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((unsigned int)input[j]) |
- (((unsigned int)input[j + 1]) << 8) |
- (((unsigned int)input[j + 2]) << 16) |
- (((unsigned int)input[j + 3]) << 24);
+ output[i] = ((unsigned int)input[j]) |
+ (((unsigned int)input[j + 1]) << 8) |
+ (((unsigned int)input[j + 2]) << 16) |
+ (((unsigned int)input[j + 3]) << 24);
}
Modified: webservices/axis2/trunk/c/util/src/network_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/network_handler.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/network_handler.c (original)
+++ webservices/axis2/trunk/c/util/src/network_handler.c Tue Aug 18 11:24:00 2009
@@ -22,8 +22,6 @@
#include <fcntl.h>
-
-
#if defined(WIN32)
/* fix for an older version of winsock2.h */
#if !defined(SO_EXCLUSIVEADDRUSE)
@@ -34,7 +32,7 @@
#if defined(WIN32)
static int is_init_socket = 0;
axis2_bool_t axis2_init_socket(
- );
+);
#endif
AXIS2_EXTERN axis2_socket_t AXIS2_CALL
@@ -60,20 +58,20 @@
AXIS2_PARAM_CHECK(env->error, server, AXIS2_INVALID_SOCKET);
#ifndef WIN32
- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- /*AF_INET is not defined in sys/socket.h but PF_INET */
+ if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ /*AF_INET is not defined in sys/socket.h but PF_INET */
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
#else
- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
- /* In Win 32 if the socket creation failed it return 0 not a negative value */
+ if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
+ /* In Win 32 if the socket creation failed it return 0 not a negative value */
{
- char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- /* Get the detailed error message */
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ /* Get the detailed error message */
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
@@ -81,9 +79,9 @@
memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = inet_addr(server); /*arpa/inet.d */
+ sock_addr.sin_addr.s_addr = inet_addr(server); /*arpa/inet.d */
- if (sock_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
+ if(sock_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
{
/*
* server may be a host name
@@ -91,34 +89,30 @@
struct hostent *lphost = NULL;
lphost = gethostbyname(server);
- if (lphost)
+ if(lphost)
{
- sock_addr.sin_addr.s_addr =
- ((struct in_addr *) lphost->h_addr)->s_addr;
+ sock_addr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
}
else
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
}
- sock_addr.sin_port = htons((axis2_unsigned_short_t) port);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
/* Connect to server */
- if (connect(sock, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0)
+ if(connect(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
{
AXIS2_CLOSE_SOCKET(sock);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
- setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &nodelay,
- sizeof(nodelay));
+ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, sizeof(nodelay));
ll.l_onoff = 1;
ll.l_linger = 5;
- setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &ll,
- sizeof(struct linger));
+ setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *)&ll, sizeof(struct linger));
return sock;
}
@@ -142,27 +136,27 @@
sock = socket(AF_INET, SOCK_STREAM, 0);
#ifndef WIN32
- if (sock < 0)
+ if(sock < 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
#else
- if (sock == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if (sock == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_INVALID_SOCKET;
- }
+ }
#endif
/* Address re-use */
i = 1;
#if defined(WIN32)
- setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
+ setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
#else
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
#endif
/* Exec behaviour */
@@ -170,19 +164,17 @@
sock_addr.sin_family = AF_INET;
sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = htons((axis2_unsigned_short_t) port);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
/* Bind the socket to our port number */
- if (bind(sock, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0)
+ if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
- if (listen(sock, 50) < 0)
+ if(listen(sock, 50) < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_LISTEN_FAILED,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_LISTEN_FAILED, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
return sock;
@@ -196,7 +188,7 @@
int i = 0;
char buf[32];
AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
- if (socket < 0)
+ if(socket < 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
return AXIS2_FAILURE;
@@ -215,27 +207,27 @@
int option,
int value)
{
- if (option == SO_RCVTIMEO || option == SO_SNDTIMEO)
+ if(option == SO_RCVTIMEO || option == SO_SNDTIMEO)
{
#if defined(WIN32)
- DWORD tv = value; /* windows expects milliseconds in a DWORD */
+ DWORD tv = value; /* windows expects milliseconds in a DWORD */
#else
struct timeval tv;
/* we deal with milliseconds */
tv.tv_sec = value / 1000;
tv.tv_usec = (value % 1000) * 1000;
#endif
- setsockopt(socket, SOL_SOCKET, option, (char *) &tv, sizeof(tv));
+ setsockopt(socket, SOL_SOCKET, option, (char *)&tv, sizeof(tv));
+ return AXIS2_SUCCESS;
+ }
+ else if(option == SO_REUSEADDR)
+ {
+ if((setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&value, sizeof(value))) < 0)
+ {
+ return AXIS2_FAILURE;
+ }
return AXIS2_SUCCESS;
}
- else if (option == SO_REUSEADDR)
- {
- if ((setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&value, sizeof(value))) < 0)
- {
- return AXIS2_FAILURE;
- }
- return AXIS2_SUCCESS;
- }
return AXIS2_FAILURE;
}
@@ -252,21 +244,21 @@
AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
cli_len = sizeof(cli_addr);
- cli_socket = accept(svr_socket, (struct sockaddr *) &cli_addr, &cli_len);
+ cli_socket = accept(svr_socket, (struct sockaddr *)&cli_addr, &cli_len);
#ifndef WIN32
- if (cli_socket < 0)
- {
+ if(cli_socket < 0)
+ {
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "[Axis2][network_handler] Socket accept \
+ "[Axis2][network_handler] Socket accept \
failed");
- }
+ }
#else
- if (cli_socket == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- }
+ if (cli_socket == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ }
#endif
setsockopt(svr_socket, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, (int)sizeof(nodelay));
@@ -281,7 +273,7 @@
#if defined (WIN32)
axis2_bool_t
axis2_init_socket(
- )
+)
{
WORD wVersionRequested;
WSADATA wsaData;
@@ -291,7 +283,7 @@
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0)
- return 0; /* WinSock 2.2 not found */
+ return 0; /* WinSock 2.2 not found */
/* Confirm that the WinSock DLL supports 2.2.
* Note that if the DLL supports versions greater
@@ -303,7 +295,7 @@
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
{
WSACleanup();
- return 0; /* WinSock 2.2 not supported */
+ return 0; /* WinSock 2.2 not supported */
}
return 1;
}
@@ -318,7 +310,7 @@
axis2_socket_len_t len = sizeof(addr);
char *ret = NULL;
memset(&addr, 0, sizeof(addr));
- if (getsockname(socket, (struct sockaddr *) &addr, &len) < 0)
+ if(getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
{
return NULL;
}
@@ -335,7 +327,7 @@
axis2_socket_len_t len = sizeof(addr);
char *ret = NULL;
memset(&addr, 0, sizeof(addr));
- if (getpeername(socket, (struct sockaddr *) &addr, &len) < 0)
+ if(getpeername(socket, (struct sockaddr *)&addr, &len) < 0)
{
return NULL;
}
@@ -345,10 +337,10 @@
AXIS2_EXTERN axis2_socket_t AXIS2_CALL
axutil_network_handler_create_dgram_svr_socket(
- const axutil_env_t *env,
- int port)
+ const axutil_env_t *env,
+ int port)
{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
struct sockaddr_in sock_addr;
AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
@@ -362,40 +354,40 @@
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#ifndef WIN32
- if (sock < 0)
+ if(sock < 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
#else
- if (sock == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if (sock == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_INVALID_SOCKET;
- }
+ }
#endif
/* Exec behaviour */
AXIS2_CLOSE_SOCKET_ON_EXIT(sock) memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = htons((axis2_unsigned_short_t) port);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
/* Bind the socket to our port number */
- if (bind(sock, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0)
+ if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
return sock;
}
AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_handler_open_dgram_socket(const axutil_env_t *env)
+axutil_network_handler_open_dgram_socket(
+ const axutil_env_t *env)
{
axis2_socket_t sock = AXIS2_INVALID_SOCKET;
#if defined(WIN32)
@@ -407,20 +399,20 @@
#endif
#ifndef WIN32
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- /*AF_INET is not defined in sys/socket.h but PF_INET */
+ if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ /*AF_INET is not defined in sys/socket.h but PF_INET */
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
#else
- if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
- /* In Win 32 if the socket creation failed it return 0 not a negative value */
+ if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
+ /* In Win 32 if the socket creation failed it return 0 not a negative value */
{
- char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- /* Get the detailed error message */
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ /* Get the detailed error message */
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
@@ -434,65 +426,70 @@
* lesser than the actual data a failure will be returned.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_read_dgram(const axutil_env_t *env, axis2_socket_t sock,
- axis2_char_t *buffer, int *buf_len,
- axis2_char_t **addr, int *port)
-{
- struct sockaddr_in sender_address;
- int received = 0;
- unsigned int sender_address_size = sizeof(sender_address);
-
- received = recvfrom(sock,
- buffer,
- *buf_len,
- 0,
- (struct sockaddr *)&sender_address,
- &sender_address_size);
+axutil_network_handler_read_dgram(
+ const axutil_env_t *env,
+ axis2_socket_t sock,
+ axis2_char_t *buffer,
+ int *buf_len,
+ axis2_char_t **addr,
+ int *port)
+{
+ struct sockaddr_in sender_address;
+ int received = 0;
+ unsigned int sender_address_size = sizeof(sender_address);
+
+ received = recvfrom(sock, buffer, *buf_len, 0, (struct sockaddr *)&sender_address,
+ &sender_address_size);
#ifdef WIN32
- if (SOCKET_ERROR == received)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if (SOCKET_ERROR == received)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_FAILURE;
- }
+ }
#else
- if (received < 0)
- {
+ if(received < 0)
+ {
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
- }
+ }
#endif
- if (port && addr)
- {
- *port = ntohs(sender_address.sin_port);
- *addr = inet_ntoa(sender_address.sin_addr);
- }
- *buf_len = received;
- return AXIS2_SUCCESS;
+ if(port && addr)
+ {
+ *port = ntohs(sender_address.sin_port);
+ *addr = inet_ntoa(sender_address.sin_addr);
+ }
+ *buf_len = received;
+ return AXIS2_SUCCESS;
}
/*
* Sends a datagram to the specified location.
*/
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_send_dgram(const axutil_env_t *env, axis2_socket_t sock,
- axis2_char_t *buff, int *buf_len,
- axis2_char_t *addr, int dest_port, int *source_port)
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axutil_network_handler_send_dgram(
+ const axutil_env_t *env,
+ axis2_socket_t sock,
+ axis2_char_t *buff,
+ int *buf_len,
+ axis2_char_t *addr,
+ int dest_port,
+ int *source_port)
{
struct sockaddr_in recv_addr, source_addr;
- int send_bytes = 0;
+ int send_bytes = 0;
unsigned int recv_addr_size = 0;
- unsigned int source_addr_size = sizeof(source_addr);
- recv_addr_size = sizeof(recv_addr);
+ unsigned int source_addr_size = sizeof(source_addr);
+ recv_addr_size = sizeof(recv_addr);
- memset(&recv_addr, 0, sizeof(recv_addr));
- memset(&recv_addr, 0, sizeof(source_addr));
+ memset(&recv_addr, 0, sizeof(recv_addr));
+ memset(&recv_addr, 0, sizeof(source_addr));
- recv_addr.sin_addr.s_addr = inet_addr(addr);
- if (recv_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
+ recv_addr.sin_addr.s_addr = inet_addr(addr);
+ if(recv_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
{
/*
* server may be a host name
@@ -500,91 +497,88 @@
struct hostent *lphost = NULL;
lphost = gethostbyname(addr);
- if (lphost)
+ if(lphost)
{
- recv_addr.sin_addr.s_addr =
- ((struct in_addr *) lphost->h_addr)->s_addr;
+ recv_addr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
}
else
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
return AXIS2_FAILURE;
}
}
- recv_addr.sin_family = AF_INET;
- recv_addr.sin_port = htons((axis2_unsigned_short_t)dest_port);
+ recv_addr.sin_family = AF_INET;
+ recv_addr.sin_port = htons((axis2_unsigned_short_t)dest_port);
- send_bytes = sendto(sock,
- buff,
- *buf_len,
- 0,
- (struct sockaddr *) &recv_addr,
- recv_addr_size);
+ send_bytes = sendto(sock, buff, *buf_len, 0, (struct sockaddr *)&recv_addr, recv_addr_size);
- getsockname(sock, (struct sockaddr *)&source_addr, &source_addr_size);
+ getsockname(sock, (struct sockaddr *)&source_addr, &source_addr_size);
#ifdef WIN32
- if (send_bytes == SOCKET_ERROR)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if (send_bytes == SOCKET_ERROR)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_FAILURE;
- }
+ }
#else
- if (send_bytes < 0)
- {
+ if(send_bytes < 0)
+ {
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_FAILURE;
- }
+ }
#endif
- if (source_port)
- {
- *source_port = ntohs(source_addr.sin_port);
- }
- *buf_len = send_bytes;
- return AXIS2_SUCCESS;
+ if(source_port)
+ {
+ *source_port = ntohs(source_addr.sin_port);
+ }
+ *buf_len = send_bytes;
+ return AXIS2_SUCCESS;
}
-
AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_bind_socket(const axutil_env_t *env, axis2_socket_t sock, int port)
+axutil_network_handler_bind_socket(
+ const axutil_env_t *env,
+ axis2_socket_t sock,
+ int port)
{
- struct sockaddr_in source_addr;
+ struct sockaddr_in source_addr;
- memset(&source_addr, 0, sizeof(source_addr));
- source_addr.sin_family = AF_INET;
- source_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- source_addr.sin_port = htons((axis2_unsigned_short_t)port);
+ memset(&source_addr, 0, sizeof(source_addr));
+ source_addr.sin_family = AF_INET;
+ source_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ source_addr.sin_port = htons((axis2_unsigned_short_t)port);
#ifdef WIN32
- if (bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) == SOCKET_ERROR)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if (bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) == SOCKET_ERROR)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_FAILURE;
- }
+ }
#else
- if (bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) < 0)
- {
+ if(bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) < 0)
+ {
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
- }
+ }
#endif
- return AXIS2_SUCCESS;
+ return AXIS2_SUCCESS;
}
AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_hadler_create_multicast_svr_socket(const axutil_env_t *env, int port,
- axis2_char_t *mul_addr)
+axutil_network_hadler_create_multicast_svr_socket(
+ const axutil_env_t *env,
+ int port,
+ axis2_char_t *mul_addr)
{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
struct sockaddr_in sock_addr;
- struct ip_mreq mc_req;
+ struct ip_mreq mc_req;
AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
#if defined(WIN32)
@@ -597,20 +591,20 @@
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#ifndef WIN32
- if (sock < 0)
+ if(sock < 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_FAILURE;
}
#else
- if (sock == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if (sock == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_FAILURE;
- }
+ }
#endif
/* Exec behaviour */
@@ -618,37 +612,34 @@
sock_addr.sin_family = AF_INET;
sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = htons((axis2_unsigned_short_t) port);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
/* Bind the socket to our port number */
- if (bind(sock, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0)
+ if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
-
- /* Send an IGMP request to join the multicast group */
- mc_req.imr_multiaddr.s_addr = inet_addr(mul_addr);
- mc_req.imr_interface.s_addr = htonl(INADDR_ANY) ;
+
+ /* Send an IGMP request to join the multicast group */
+ mc_req.imr_multiaddr.s_addr = inet_addr(mul_addr);
+ mc_req.imr_interface.s_addr = htonl(INADDR_ANY);
#ifdef WIN32
- if ((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mc_req, sizeof(mc_req))) == SOCKET_ERROR) {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ if ((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mc_req, sizeof(mc_req))) == SOCKET_ERROR)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
return AXIS2_FAILURE;
- }
+ }
#else
- if ((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mc_req, sizeof(mc_req))) < 0) {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ if((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mc_req, sizeof(mc_req))) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
return AXIS2_FAILURE;
- }
+ }
#endif
return sock;
}
-
-
-
-
Modified: webservices/axis2/trunk/c/util/src/param.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/param.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/param.c (original)
+++ webservices/axis2/trunk/c/util/src/param.c Tue Aug 18 11:24:00 2009
@@ -51,7 +51,7 @@
AXIS2_ENV_CHECK(env, NULL);
param = AXIS2_MALLOC(env->allocator, sizeof(axutil_param_t));
- if (!param)
+ if(!param)
{
AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Not enough memory");
@@ -60,7 +60,7 @@
}
param->name = axutil_strdup(env, name);
- param->value = value; /* shallow copy. */
+ param->value = value; /* shallow copy. */
param->locked = AXIS2_FALSE;
param->type = AXIS2_TEXT_PARAM;
param->attrs = NULL;
@@ -104,18 +104,18 @@
{
void *param_value = NULL;
param_value = axutil_param_get_value(param, env);
- if (param_value)
+ if(param_value)
{
- if (param && param->value_free)
+ if(param && param->value_free)
{
param->value_free(param_value, env);
}
- else /* we assume that param value is axis2_char_t* */
+ else /* we assume that param value is axis2_char_t* */
{
AXIS2_FREE(env->allocator, param_value);
}
}
- param->value = (void *) value;
+ param->value = (void *)value;
return AXIS2_SUCCESS;
}
@@ -163,13 +163,12 @@
{
AXIS2_PARAM_CHECK(env->error, attrs, AXIS2_FAILURE);
- if (param->attrs)
+ if(param->attrs)
{
axutil_hash_index_t *i = NULL;
void *v = NULL;
- for (i = axutil_hash_first(param->attrs, env); i;
- i = axutil_hash_next(env, i))
+ for(i = axutil_hash_first(param->attrs, env); i; i = axutil_hash_next(env, i))
{
axutil_hash_this(i, NULL, NULL, &v);
axutil_generic_obj_free(v, env);
@@ -197,19 +196,16 @@
{
AXIS2_PARAM_CHECK(env->error, value_list, AXIS2_FAILURE);
- if (param->value_list)
+ if(param->value_list)
{
- int i = 0,
- size = 0;
+ int i = 0, size = 0;
size = axutil_array_list_size(param->value_list, env);
- for (i = 0; i < size; i++)
+ for(i = 0; i < size; i++)
{
axutil_param_t *param = NULL;
- param =
- (axutil_param_t *) axutil_array_list_get(param->value_list, env,
- i);
+ param = (axutil_param_t *)axutil_array_list_get(param->value_list, env, i);
axutil_param_free(param, env);
}
axutil_array_list_free(param->value_list, env);
@@ -236,25 +232,24 @@
axis2_char_t *param_name = NULL;
param_value = axutil_param_get_value(param, env);
- if (param_value)
+ if(param_value)
{
- if (param && param->value_free)
+ if(param && param->value_free)
{
param->value_free(param_value, env);
}
- else /* we assume that param value is axis2_char_t* */
+ else /* we assume that param value is axis2_char_t* */
{
AXIS2_FREE(env->allocator, param_value);
}
}
- if (param->attrs)
+ if(param->attrs)
{
axutil_hash_index_t *i = NULL;
void *v = NULL;
- for (i = axutil_hash_first(param->attrs, env); i;
- i = axutil_hash_next(env, i))
+ for(i = axutil_hash_first(param->attrs, env); i; i = axutil_hash_next(env, i))
{
axutil_hash_this(i, NULL, NULL, &v);
axutil_generic_obj_free(v, env);
@@ -262,20 +257,17 @@
axutil_hash_free(param->attrs, env);
}
- if (param->value_list)
+ if(param->value_list)
{
- int i = 0,
- size = 0;
+ int i = 0, size = 0;
size = axutil_array_list_size(param->value_list, env);
- for (i = 0; i < size; i++)
+ for(i = 0; i < size; i++)
{
axutil_param_t *param_l = NULL;
- param_l =
- (axutil_param_t *) axutil_array_list_get(param->value_list, env,
- i);
- if (param_l)
+ param_l = (axutil_param_t *)axutil_array_list_get(param->value_list, env, i);
+ if(param_l)
{
axutil_param_free(param_l, env);
}
Modified: webservices/axis2/trunk/c/util/src/param_container.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/param_container.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/param_container.c (original)
+++ webservices/axis2/trunk/c/util/src/param_container.c Tue Aug 18 11:24:00 2009
@@ -31,12 +31,10 @@
AXIS2_ENV_CHECK(env, NULL);
- param_container =
- (axutil_param_container_t *) AXIS2_MALLOC(env->allocator,
- sizeof
- (axutil_param_container_t));
+ param_container = (axutil_param_container_t *)AXIS2_MALLOC(env->allocator,
+ sizeof(axutil_param_container_t));
- if (!param_container)
+ if(!param_container)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Not enough memory");
@@ -48,7 +46,7 @@
param_container->params_list = axutil_array_list_create(env, 0);
param_container->params = axutil_hash_make(env);
- if (!param_container->params)
+ if(!param_container->params)
{
axutil_param_container_free(param_container, env);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -66,17 +64,17 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (param_container->params)
+ if(param_container->params)
{
axutil_hash_index_t *hi = NULL;
void *val = NULL;
- for (hi = axutil_hash_first(param_container->params, env); hi;
- hi = axutil_hash_next(env, hi))
+ for(hi = axutil_hash_first(param_container->params, env); hi; hi
+ = axutil_hash_next(env, hi))
{
axutil_param_t *param = NULL;
axutil_hash_this(hi, NULL, NULL, &val);
- param = (axutil_param_t *) val;
- if (param)
+ param = (axutil_param_t *)val;
+ if(param)
{
axutil_param_free(param, env);
param = NULL;
@@ -85,7 +83,7 @@
}
axutil_hash_free(param_container->params, env);
}
- if (param_container->params_list)
+ if(param_container->params_list)
{
/* This is the array list which is returned when all params are
* requested from param_container. Params referenced here are
@@ -107,7 +105,7 @@
axutil_param_container_t *param_container_l = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- param_container_l = (axutil_param_container_t *) param_container;
+ param_container_l = (axutil_param_container_t *)param_container;
axutil_param_container_free(param_container_l, env);
return;
}
@@ -123,24 +121,22 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE);
- if (!(param_container->params))
+ if(!(param_container->params))
{
param_container->params = axutil_hash_make(env);
- if (!param_container->params)
+ if(!param_container->params)
{
return AXIS2_FAILURE;
}
}
param_name = axutil_param_get_name(param, env);
- if (!param_name)
+ if(!param_name)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PARAM,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PARAM, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid param state");
return AXIS2_FAILURE;
}
- axutil_hash_set(param_container->params, param_name, AXIS2_HASH_KEY_STRING,
- param);
+ axutil_hash_set(param_container->params, param_name, AXIS2_HASH_KEY_STRING, param);
return AXIS2_SUCCESS;
}
@@ -151,9 +147,7 @@
const axutil_env_t *env,
const axis2_char_t *name)
{
- return (axutil_param_t
- *) (axutil_hash_get(param_container->params, name,
- AXIS2_HASH_KEY_STRING));
+ return (axutil_param_t *)(axutil_hash_get(param_container->params, name, AXIS2_HASH_KEY_STRING));
}
AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
@@ -165,10 +159,10 @@
axis2_status_t status = AXIS2_FAILURE;
void *value = NULL;
- if (!param_container->params_list)
+ if(!param_container->params_list)
{
param_container->params_list = axutil_array_list_create(env, 0);
- if (!param_container->params_list)
+ if(!param_container->params_list)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Not enough memory");
@@ -176,13 +170,12 @@
}
}
- for (index_i = axutil_hash_first(param_container->params, env); index_i;
- index_i = axutil_hash_next(env, index_i))
+ for(index_i = axutil_hash_first(param_container->params, env); index_i; index_i
+ = axutil_hash_next(env, index_i))
{
axutil_hash_this(index_i, NULL, NULL, &value);
- status =
- axutil_array_list_add(param_container->params_list, env, value);
- if (AXIS2_SUCCESS != status)
+ status = axutil_array_list_add(param_container->params_list, env, value);
+ if(AXIS2_SUCCESS != status)
{
axutil_array_list_free(param_container->params_list, env);
return NULL;
@@ -200,11 +193,9 @@
{
axutil_param_t *param = NULL;
- param =
- (axutil_param_t
- *) (axutil_hash_get(param_container->params, param_name,
- AXIS2_HASH_KEY_STRING));
- if (!param)
+ param = (axutil_param_t *)(axutil_hash_get(param_container->params, param_name,
+ AXIS2_HASH_KEY_STRING));
+ if(!param)
{
/* In this case we consider param is not locked */
return AXIS2_FALSE;
Modified: webservices/axis2/trunk/c/util/src/platforms/unix/date_time_util_unix.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/unix/date_time_util_unix.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/unix/date_time_util_unix.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/unix/date_time_util_unix.c Tue Aug 18 11:24:00 2009
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,8 +18,7 @@
#include <platforms/unix/axutil_date_time_util_unix.h>
AXIS2_EXTERN int AXIS2_CALL
-axis2_platform_get_milliseconds(
- )
+axis2_platform_get_milliseconds()
{
struct timeb t_current;
int milliseconds;
Modified: webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c Tue Aug 18 11:24:00 2009
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -27,13 +26,13 @@
axutil_threadattr_t *new = NULL;
new = AXIS2_MALLOC(allocator, sizeof(axutil_threadattr_t));
- if (!new)
+ if(!new)
{
return NULL;
}
stat = pthread_attr_init(&(new->attr));
- if (stat != 0)
+ if(stat != 0)
{
AXIS2_FREE(allocator, new);
return NULL;
@@ -51,7 +50,7 @@
rv = pthread_attr_destroy(&(attr->attr));
- if (0 != rv)
+ if(0 != rv)
{
return AXIS2_FAILURE;
}
@@ -65,7 +64,7 @@
axutil_threadattr_t * attr,
axis2_bool_t detached)
{
- if (0 == pthread_attr_setdetachstate(&(attr->attr), DETACH_ARG(detached)))
+ if(0 == pthread_attr_setdetachstate(&(attr->attr), DETACH_ARG(detached)))
{
return AXIS2_SUCCESS;
}
@@ -78,7 +77,7 @@
{
int state = 0;
pthread_attr_getdetachstate(&(attr->attr), &state);
- if (state == 1)
+ if(state == 1)
{
return AXIS2_TRUE;
}
@@ -89,7 +88,7 @@
dummy_worker(
void *opaque)
{
- axutil_thread_t *thread = (axutil_thread_t *) opaque;
+ axutil_thread_t *thread = (axutil_thread_t *)opaque;
return thread->func(thread, thread->data);
}
@@ -104,14 +103,14 @@
pthread_attr_t *temp = NULL;
axutil_thread_t *new = NULL;
- new = (axutil_thread_t *) AXIS2_MALLOC(allocator, sizeof(axutil_thread_t));
+ new = (axutil_thread_t *)AXIS2_MALLOC(allocator, sizeof(axutil_thread_t));
- if (!new)
+ if(!new)
{
return NULL;
}
- new->td = (pthread_t *) AXIS2_MALLOC(allocator, sizeof(pthread_t));
- if (!new->td)
+ new->td = (pthread_t *)AXIS2_MALLOC(allocator, sizeof(pthread_t));
+ if(!new->td)
{
return NULL;
}
@@ -120,7 +119,7 @@
new->func = func;
new->try_exit = AXIS2_FALSE;
- if (attr)
+ if(attr)
{
temp = &(attr->attr);
}
@@ -129,7 +128,7 @@
temp = NULL;
}
- if ((stat = pthread_create(new->td, temp, dummy_worker, new)) == 0)
+ if((stat = pthread_create(new->td, temp, dummy_worker, new)) == 0)
{
return new;
}
@@ -157,14 +156,14 @@
axutil_allocator_t * allocator)
{
- if (thd)
+ if(thd)
{
- while (!thd->try_exit)
- {
+ while(!thd->try_exit)
+ {
sleep(1);
- }
-
- if (thd->td)
+ }
+
+ if(thd->td)
{
AXIS2_FREE(allocator, thd->td);
}
@@ -179,7 +178,7 @@
axutil_thread_t * thd)
{
void *thread_stat;
- if (0 == pthread_join(*(thd->td), (void *) (&thread_stat)))
+ if(0 == pthread_join(*(thd->td), (void *)(&thread_stat)))
{
return AXIS2_SUCCESS;
}
@@ -190,7 +189,7 @@
axutil_thread_detach(
axutil_thread_t * thd)
{
- if (0 == pthread_detach(*(thd->td)))
+ if(0 == pthread_detach(*(thd->td)))
{
thd->try_exit = AXIS2_TRUE;
return AXIS2_SUCCESS;
@@ -205,7 +204,6 @@
return;
}
-
/**
* function is used to allocate a new key. This key now becomes valid for all threads in our process.
* When a key is created, the value it points to defaults to NULL. Later on each thread may change
@@ -214,12 +212,14 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axutil_thread_key_create(
axutil_threadkey_t * axis2_key,
- void (*destructor) (void *))
+ void
+ (*destructor)(
+ void *))
{
int rc = -1;
pthread_key_t key = axis2_key->key;
rc = pthread_key_create(&key, destructor);
- if (0 == rc)
+ if(0 == rc)
return AXIS2_SUCCESS;
else
return AXIS2_FAILURE;
@@ -252,7 +252,7 @@
int rc = -1;
pthread_key_t key = axis2_key->key;
rc = pthread_setspecific(key, value);
- if (0 == rc)
+ if(0 == rc)
return AXIS2_SUCCESS;
else
return AXIS2_FAILURE;
@@ -262,7 +262,7 @@
axis2_os_thread_get(
axutil_thread_t * thd)
{
- if (!thd)
+ if(!thd)
{
return NULL;
}
@@ -274,16 +274,15 @@
axutil_allocator_t * allocator)
{
#if defined(AXIS2_SOLARIS) && (__GNUC__ <= 3)
- static const pthread_once_t once_init = { PTHREAD_ONCE_INIT };
+ static const pthread_once_t once_init =
+ { PTHREAD_ONCE_INIT};
#else
static const pthread_once_t once_init = PTHREAD_ONCE_INIT;
#endif
- axutil_thread_once_t *control = AXIS2_MALLOC(allocator,
- sizeof(axutil_thread_once_t));
- if (!control)
+ axutil_thread_once_t *control = AXIS2_MALLOC(allocator, sizeof(axutil_thread_once_t));
+ if(!control)
{
- return NULL;
- ;
+ return NULL;;
}
(control)->once = once_init;
return control;
@@ -292,7 +291,9 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axutil_thread_once(
axutil_thread_once_t * control,
- void (*func) (void))
+ void
+ (*func)(
+ void))
{
return pthread_once(&(control->once), func);
}
@@ -308,7 +309,7 @@
new_mutex = AXIS2_MALLOC(allocator, sizeof(axutil_thread_mutex_t));
new_mutex->allocator = allocator;
- if (pthread_mutex_init(&(new_mutex->mutex), NULL) != 0)
+ if(pthread_mutex_init(&(new_mutex->mutex), NULL) != 0)
{
AXIS2_FREE(allocator, new_mutex);
return NULL;
@@ -327,7 +328,7 @@
axutil_thread_mutex_unlock(
axutil_thread_mutex_t * mutex)
{
- if (pthread_mutex_unlock(&(mutex->mutex)) != 0)
+ if(pthread_mutex_unlock(&(mutex->mutex)) != 0)
{
return AXIS2_FAILURE;
}
@@ -338,7 +339,7 @@
axutil_thread_mutex_destroy(
axutil_thread_mutex_t * mutex)
{
- if (0 != pthread_mutex_destroy(&(mutex->mutex)))
+ if(0 != pthread_mutex_destroy(&(mutex->mutex)))
{
return AXIS2_FAILURE;
}
Modified: webservices/axis2/trunk/c/util/src/platforms/unix/uuid_gen_unix.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/unix/uuid_gen_unix.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/unix/uuid_gen_unix.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/unix/uuid_gen_unix.c Tue Aug 18 11:24:00 2009
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -55,8 +54,7 @@
static struct axutil_uuid_st axutil_uuid_static;
axutil_uuid_t *AXIS2_CALL
-axutil_uuid_gen_v1(
- )
+axutil_uuid_gen_v1()
{
struct timeval time_now;
struct timeval tv;
@@ -66,7 +64,7 @@
axutil_uuid_t *ret_uuid = NULL;
unsigned short int time_high_version = 0;
- if (AXIS2_TRUE == axutil_uuid_gen_is_first)
+ if(AXIS2_TRUE == axutil_uuid_gen_is_first)
{
char *mac_addr = axutil_uuid_get_mac_addr();
memcpy(axutil_uuid_static.mac, mac_addr, 6);
@@ -80,21 +78,20 @@
*/
/* determine current system time and sequence counter */
- if (gettimeofday(&time_now, NULL) == -1)
+ if(gettimeofday(&time_now, NULL) == -1)
return NULL;
/* check whether system time changed since last retrieve */
- if (!
- (time_now.tv_sec == axutil_uuid_static.time_last.tv_sec &&
- time_now.tv_usec == axutil_uuid_static.time_last.tv_usec))
+ if(!(time_now.tv_sec == axutil_uuid_static.time_last.tv_sec && time_now.tv_usec
+ == axutil_uuid_static.time_last.tv_usec))
{
/* reset time sequence counter and continue */
axutil_uuid_static.time_seq = 0;
}
/* until we are out of UUIDs per tick, increment
- the time/tick sequence counter and continue */
- while (axutil_uuid_static.time_seq < UUIDS_PER_TICK)
+ the time/tick sequence counter and continue */
+ while(axutil_uuid_static.time_seq < UUIDS_PER_TICK)
{
axutil_uuid_static.time_seq++;
}
@@ -102,27 +99,27 @@
tv.tv_sec = 0;
tv.tv_usec = 1;
/*
- The following select causes severe performance problems.
- Hence commenting out. I am not sure why this is required. - Samisa.
- select(0, NULL, NULL, NULL, &tv); */
+ The following select causes severe performance problems.
+ Hence commenting out. I am not sure why this is required. - Samisa.
+ select(0, NULL, NULL, NULL, &tv); */
- time_val = (unsigned long long) time_now.tv_sec * 10000000ull;
- time_val += (unsigned long long) time_now.tv_usec * 10ull;
+ time_val = (unsigned long long)time_now.tv_sec * 10000000ull;
+ time_val += (unsigned long long)time_now.tv_usec * 10ull;
ret_uuid = malloc(sizeof(axutil_uuid_t));
time_val += UUID_TIMEOFFSET;
/* compensate for low resolution system clock by adding
- the time/tick sequence counter */
- if (axutil_uuid_static.time_seq > 0)
- time_val += (unsigned long long) axutil_uuid_static.time_seq;
+ the time/tick sequence counter */
+ if(axutil_uuid_static.time_seq > 0)
+ time_val += (unsigned long long)axutil_uuid_static.time_seq;
time_val2 = time_val;
- ret_uuid->time_low = (unsigned long) time_val2;
+ ret_uuid->time_low = (unsigned long)time_val2;
time_val2 >>= 32;
- ret_uuid->time_mid = (unsigned short int) time_val2;
+ ret_uuid->time_mid = (unsigned short int)time_val2;
time_val2 >>= 16;
- time_high_version = (unsigned short int) time_val2;
+ time_high_version = (unsigned short int)time_val2;
/* store the 60 LSB of the time in the UUID and make version 1 */
time_high_version <<= 4;
@@ -138,11 +135,10 @@
clck = axutil_uuid_static.clock;
/* generate new random clock sequence (initially or if the
- time has stepped backwards) or else just increase it */
- if (clck == 0 ||
- (time_now.tv_sec < axutil_uuid_static.time_last.tv_sec ||
- (time_now.tv_sec == axutil_uuid_static.time_last.tv_sec &&
- time_now.tv_usec < axutil_uuid_static.time_last.tv_usec)))
+ time has stepped backwards) or else just increase it */
+ if(clck == 0 || (time_now.tv_sec < axutil_uuid_static.time_last.tv_sec || (time_now.tv_sec
+ == axutil_uuid_static.time_last.tv_sec && time_now.tv_usec
+ < axutil_uuid_static.time_last.tv_usec)))
{
srand(time_now.tv_usec);
clck = rand();
@@ -166,7 +162,7 @@
axutil_uuid_static.time_last.tv_sec = time_now.tv_sec;
axutil_uuid_static.time_last.tv_usec = time_now.tv_usec;
- if (!ret_uuid)
+ if(!ret_uuid)
{
return NULL;
}
@@ -184,26 +180,24 @@
unsigned char mac[7];
char mac_hex[13];
- if (!s)
+ if(!s)
{
return NULL;
}
uuid_struct = axutil_uuid_gen_v1();
- if (!uuid_struct)
+ if(!uuid_struct)
{
return NULL;
}
uuid_str = s;
- if (!uuid_str)
+ if(!uuid_str)
{
return NULL;
}
memcpy(mac, uuid_struct->mac_addr, 6);
- sprintf(mac_hex, "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3],
- mac[4], mac[5]);
- sprintf(uuid_str, "%08x-%04x-%04x-%04x-%s", uuid_struct->time_low,
- uuid_struct->time_mid, uuid_struct->time_high_version,
- uuid_struct->clock_variant, mac_hex);
+ sprintf(mac_hex, "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ sprintf(uuid_str, "%08x-%04x-%04x-%04x-%s", uuid_struct->time_low, uuid_struct->time_mid,
+ uuid_struct->time_high_version, uuid_struct->clock_variant, mac_hex);
free(uuid_struct);
uuid_struct = NULL;
return uuid_str;
@@ -213,7 +207,7 @@
char *AXIS2_CALL
axutil_uuid_get_mac_addr(
- )
+)
{
struct ifreq ifr;
struct ifreq *IFR;
@@ -226,7 +220,7 @@
int ok = AXIS2_FALSE;
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
- return NULL;
+ return NULL;
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
@@ -254,12 +248,12 @@
{
sa = (struct sockaddr *) &ifr.ifr_addr;
for (i = 0; i < 6; i++)
- buffer[i] = (unsigned char) (sa->sa_data[i] & 0xff);
+ buffer[i] = (unsigned char) (sa->sa_data[i] & 0xff);
}
else
{
for (i = 0; i < 6; i++)
- buffer[i] = (unsigned char) ((AXIS2_LOCAL_MAC_ADDR[i]) - '0');
+ buffer[i] = (unsigned char) ((AXIS2_LOCAL_MAC_ADDR[i]) - '0');
}
close(s);
return buffer;
@@ -275,7 +269,7 @@
char *AXIS2_CALL
axutil_uuid_get_mac_addr(
- )
+)
{
struct ifaddrs *ifap;
struct ifaddrs *ifap_head;
@@ -285,7 +279,7 @@
char *data_ptr;
if (getifaddrs(&ifap_head) < 0)
- return NULL;
+ return NULL;
for (ifap = ifap_head; ifap != NULL; ifap = ifap->ifa_next)
{
if (ifap->ifa_addr != NULL && ifap->ifa_addr->sa_family == AF_LINK)
@@ -296,7 +290,7 @@
{
data_ptr = malloc(6 * sizeof(char));
for (i = 0; i < 6 && i < sdl->sdl_alen; i++, ucp++)
- data_ptr[i] = (unsigned char) (*ucp & 0xff);
+ data_ptr[i] = (unsigned char) (*ucp & 0xff);
freeifaddrs(ifap_head);
return data_ptr;
@@ -309,12 +303,11 @@
# else /* Solaris-ish */
/* code modified from that posted on:
-* http://forum.sun.com/jive/thread.jspa?threadID=84804&tstart=30
-*/
+ * http://forum.sun.com/jive/thread.jspa?threadID=84804&tstart=30
+ */
char *AXIS2_CALL
-axutil_uuid_get_mac_addr(
- )
+axutil_uuid_get_mac_addr()
{
char hostname[MAXHOSTNAMELEN];
char *data_ptr;
@@ -324,27 +317,27 @@
int s;
int i;
- if (gethostname(hostname, sizeof(hostname)) < 0)
+ if(gethostname(hostname, sizeof(hostname)) < 0)
return NULL;
- if ((he = gethostbyname(hostname)) == NULL)
+ if((he = gethostbyname(hostname)) == NULL)
return NULL;
- if ((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
return NULL;
memset(&ar, 0, sizeof(ar));
- sa = (struct sockaddr_in *) ((void *) &(ar.arp_pa));
+ sa = (struct sockaddr_in *)((void *)&(ar.arp_pa));
sa->sin_family = AF_INET;
memcpy(&(sa->sin_addr), *(he->h_addr_list), sizeof(struct in_addr));
- if (ioctl(s, SIOCGARP, &ar) < 0)
+ if(ioctl(s, SIOCGARP, &ar) < 0)
{
close(s);
return NULL;
}
close(s);
- if (!(ar.arp_flags & ATF_COM))
+ if(!(ar.arp_flags & ATF_COM))
return NULL;
data_ptr = malloc(6 * sizeof(char));
- for (i = 0; i < 6; i++)
- data_ptr[i] = (unsigned char) (ar.arp_ha.sa_data[i] & 0xff);
+ for(i = 0; i < 6; i++)
+ data_ptr[i] = (unsigned char)(ar.arp_ha.sa_data[i] & 0xff);
return data_ptr;
}
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/axutil_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/axutil_windows.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/axutil_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/axutil_windows.c Tue Aug 18 11:24:00 2009
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -16,11 +15,9 @@
* limitations under the License.
*/
-
-
#include <windows/axutil_windows.h>
#include <stdio.h>
-
+
/*
@@ -43,64 +40,54 @@
return returningString;
}
-*/
-AXIS2_EXTERN HMODULE AXIS2_CALL
-callLoadLib(char *lib)
+ */
+AXIS2_EXTERN HMODULE AXIS2_CALL
+callLoadLib(
+ char *lib)
{
- /* Disable display of the critical-error-handler message box */
- SetErrorMode(SEM_FAILCRITICALERRORS);
+ /* Disable display of the critical-error-handler message box */
+ SetErrorMode(SEM_FAILCRITICALERRORS);
return LoadLibraryEx(lib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
-
-AXIS2_EXTERN struct tm *AXIS2_CALL
+AXIS2_EXTERN struct tm *AXIS2_CALL
axis2_win_gmtime(
const time_t * timep,
- struct tm *result)
+ struct tm *result)
{
return gmtime(timep);
}
-AXIS2_EXTERN void AXIS2_CALL
-axutil_win32_get_last_error(axis2_char_t *buf,
- unsigned int buf_size)
+AXIS2_EXTERN void AXIS2_CALL
+axutil_win32_get_last_error(
+ axis2_char_t *buf,
+ unsigned int buf_size)
{
- LPVOID lpMsgBuf;
- int rc = GetLastError();
- sprintf( buf, "DLL Load Error %d: ", rc );
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- rc,
- 0,
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
- if (lpMsgBuf)
- {
- strncat( buf, (char*)lpMsgBuf, buf_size - strlen( buf ) - 1 );
- }
- LocalFree( lpMsgBuf );
+ LPVOID lpMsgBuf;
+ int rc = GetLastError();
+ sprintf(buf, "DLL Load Error %d: ", rc);
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, 0,
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+ if(lpMsgBuf)
+ {
+ strncat(buf, (char*)lpMsgBuf, buf_size - strlen(buf) - 1);
+ }
+ LocalFree(lpMsgBuf);
}
-AXIS2_EXTERN void AXIS2_CALL
-axutil_win32_get_last_wsa_error(axis2_char_t *buf,
- unsigned int buf_size)
-{
- LPVOID lpMsgBuf;
- int rc = WSAGetLastError();
- sprintf( buf, "Winsock error %d: ", rc );
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- rc,
- 0,
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
- if (lpMsgBuf)
- {
- strncat( buf, (char*)lpMsgBuf, buf_size - strlen( buf ) - 1 );
- }
- LocalFree( lpMsgBuf );
+AXIS2_EXTERN void AXIS2_CALL
+axutil_win32_get_last_wsa_error(
+ axis2_char_t *buf,
+ unsigned int buf_size)
+{
+ LPVOID lpMsgBuf;
+ int rc = WSAGetLastError();
+ sprintf(buf, "Winsock error %d: ", rc);
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, 0,
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+ if(lpMsgBuf)
+ {
+ strncat(buf, (char*)lpMsgBuf, buf_size - strlen(buf) - 1);
+ }
+ LocalFree(lpMsgBuf);
}