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 2006/06/04 05:09:41 UTC
svn commit: r411506 [20/27] - in /webservices/axis2/trunk/c: axiom/include/
axiom/src/attachments/ axiom/src/om/ axiom/src/parser/guththila/
axiom/src/parser/libxml2/ axiom/src/soap/ axiom/test/om/ axiom/test/soap/
guththila/src/ include/ modules/core/...
Modified: webservices/axis2/trunk/c/util/src/log.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/log.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/log.c (original)
+++ webservices/axis2/trunk/c/util/src/log.c Sat Jun 3 20:09:08 2006
@@ -26,9 +26,9 @@
struct axis2_log_impl
{
- axis2_log_t log;
- void *stream;
- axis2_thread_mutex_t *mutex;
+ axis2_log_t log;
+ void *stream;
+ axis2_thread_mutex_t *mutex;
};
#define AXIS2_INTF_TO_IMPL(log) ((axis2_log_impl_t*)(log))
@@ -36,26 +36,26 @@
axis2_status_t AXIS2_CALL
axis2_log_impl_free (axis2_allocator_t *allocator, axis2_log_t *log)
{
- axis2_log_impl_t *log_impl = NULL;
-
+ axis2_log_impl_t *log_impl = NULL;
+
if (NULL != log )
{
log_impl = AXIS2_INTF_TO_IMPL(log);
- if(NULL != log_impl->mutex)
+ if(NULL != log_impl->mutex)
{
axis2_thread_mutex_destroy(log_impl->mutex);
- log_impl->mutex = NULL;
- }
- if (NULL != AXIS2_INTF_TO_IMPL(log)->stream)
- {
- axis2_file_handler_close(log_impl->stream);
- log_impl->stream = NULL;
+ log_impl->mutex = NULL;
+ }
+ if (NULL != AXIS2_INTF_TO_IMPL(log)->stream)
+ {
+ axis2_file_handler_close(log_impl->stream);
+ log_impl->stream = NULL;
}
if ( NULL != log->ops)
{
- AXIS2_FREE (allocator, log->ops);
- log->ops = NULL;
+ AXIS2_FREE (allocator, log->ops);
+ log->ops = NULL;
}
AXIS2_FREE (allocator, log_impl);
}
@@ -64,51 +64,51 @@
/* function prototypes */
axis2_status_t AXIS2_CALL axis2_log_impl_write (axis2_log_t *log,
- const axis2_char_t *buffer, axis2_log_levels_t level,
- const axis2_char_t *file, const int line);
+ const axis2_char_t *buffer, axis2_log_levels_t level,
+ const axis2_char_t *file, const int line);
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_log_impl_write_to_file(FILE *fd,
- axis2_thread_mutex_t *mutex, axis2_log_levels_t level,
- const axis2_char_t * file, const int line, const axis2_char_t * value);
+ axis2_thread_mutex_t *mutex, axis2_log_levels_t level,
+ const axis2_char_t * file, const int line, const axis2_char_t * value);
AXIS2_EXTERN axis2_log_t * AXIS2_CALL
axis2_log_create (axis2_allocator_t * allocator, axis2_log_ops_t * ops,
- axis2_char_t * stream_name)
+ axis2_char_t * stream_name)
{
axis2_log_impl_t *log_impl;
- axis2_char_t *path_home;
- axis2_char_t log_file_name[500];
- axis2_char_t log_dir[500];
- axis2_char_t tmp_filename[100];
-
+ axis2_char_t *path_home;
+ axis2_char_t log_file_name[500];
+ axis2_char_t log_dir[500];
+ axis2_char_t tmp_filename[100];
+
if (!allocator)
return NULL;
log_impl = (axis2_log_impl_t *) AXIS2_MALLOC (allocator,
- sizeof (axis2_log_impl_t));
+ sizeof (axis2_log_impl_t));
if (!log_impl)
return NULL;
-
- log_impl->mutex = axis2_thread_mutex_create(allocator,
- AXIS2_THREAD_MUTEX_DEFAULT);
-
- if (!log_impl->mutex)
- {
- fprintf(stderr,"cannot create log mutex \n");
- return NULL;
- }
-
- /* default log file is axis2.log */
- if (stream_name)
- AXIS2_SNPRINTF(tmp_filename,100,"%s",stream_name);
- else
- AXIS2_SNPRINTF(tmp_filename,100,"%s","axis2.log");
-
- /* we write all logs to AXIS2C_HOME/logs if it is set otherwise
- * to the working dir
- */
+
+ log_impl->mutex = axis2_thread_mutex_create(allocator,
+ AXIS2_THREAD_MUTEX_DEFAULT);
+
+ if (!log_impl->mutex)
+ {
+ fprintf(stderr,"cannot create log mutex \n");
+ return NULL;
+ }
+
+ /* default log file is axis2.log */
+ if (stream_name)
+ AXIS2_SNPRINTF(tmp_filename,100,"%s",stream_name);
+ else
+ AXIS2_SNPRINTF(tmp_filename,100,"%s","axis2.log");
+
+ /* we write all logs to AXIS2C_HOME/logs if it is set otherwise
+ * to the working dir
+ */
if (stream_name && !(AXIS2_RINDEX(stream_name, AXIS2_PATH_SEP_CHAR)))
{
if (NULL != (path_home = AXIS2_GETENV("AXIS2C_HOME")))
@@ -136,22 +136,22 @@
{
AXIS2_SNPRINTF(log_file_name, 500, "%s", tmp_filename);
}
-
- axis2_thread_mutex_lock(log_impl->mutex);
-
- log_impl->stream = axis2_file_handler_open(log_file_name,"a+");
-
- axis2_thread_mutex_unlock(log_impl->mutex);
+
+ axis2_thread_mutex_lock(log_impl->mutex);
+
+ log_impl->stream = axis2_file_handler_open(log_file_name,"a+");
+
+ axis2_thread_mutex_unlock(log_impl->mutex);
if(NULL == log_impl->stream)
{
log_impl->log.ops = NULL;
axis2_log_impl_free(allocator, &(log_impl->log));
return NULL;
- }
- /* by default, log is enabled */
- log_impl->log.enabled = 1;
- log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;
+ }
+ /* by default, log is enabled */
+ log_impl->log.enabled = 1;
+ log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;
if (ops)
log_impl->log.ops = ops;
@@ -163,7 +163,7 @@
if (!log_impl->log.ops)
{
- axis2_log_impl_free(allocator,(axis2_log_t*)log_impl);
+ axis2_log_impl_free(allocator,(axis2_log_t*)log_impl);
return NULL;
}
log_impl->log.ops->free = axis2_log_impl_free;
@@ -176,7 +176,7 @@
/*TODO:remove this method*/
axis2_status_t AXIS2_CALL
axis2_log_impl_write (axis2_log_t *log, const axis2_char_t *buffer,
- axis2_log_levels_t level, const axis2_char_t *file, const int line)
+ axis2_log_levels_t level, const axis2_char_t *file, const int line)
{
if (!log || !buffer)
return -1;
@@ -204,7 +204,7 @@
level_str = "[...TRACE...] ";
break;
}
- fprintf(stderr,"%s %s(%d) %s\n", level_str, file, line, buffer);
+ fprintf(stderr,"%s %s(%d) %s\n", level_str, file, line, buffer);
}
return 0;
@@ -213,20 +213,20 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_write_to_file(FILE *fd, axis2_thread_mutex_t *mutex,
- axis2_log_levels_t level, const axis2_char_t *file,
- const int line, const axis2_char_t *value)
+ axis2_log_levels_t level, const axis2_char_t *file,
+ const int line, const axis2_char_t *value)
{
char *level_str = "";
- if (!fd)
- return -1;
- /**
+ if (!fd)
+ return -1;
+ /**
* print all critical and error logs irrespective of log->level setting
- */
+ */
switch (level)
{
- case AXIS2_LOG_LEVEL_CRITICAL:
- level_str = "[critical] ";
+ case AXIS2_LOG_LEVEL_CRITICAL:
+ level_str = "[critical] ";
break;
case AXIS2_LOG_LEVEL_ERROR:
level_str = "[error] ";
@@ -244,211 +244,211 @@
level_str = "[...TRACE...] ";
break;
}
- axis2_thread_mutex_lock(mutex);
+ axis2_thread_mutex_lock(mutex);
if (file)
- fprintf(fd,"[%s] %s%s(%d) %s\n", axis2_log_impl_get_time_str(),
- level_str, file, line, value);
+ fprintf(fd,"[%s] %s%s(%d) %s\n", axis2_log_impl_get_time_str(),
+ level_str, file, line, value);
else
- fprintf(fd,"[%s] %s %s\n", axis2_log_impl_get_time_str(),
- level_str, value);
- fflush(fd);
- axis2_thread_mutex_unlock(mutex);
-
- return 0;
+ fprintf(fd,"[%s] %s %s\n", axis2_log_impl_get_time_str(),
+ level_str, value);
+ fflush(fd);
+ axis2_thread_mutex_unlock(mutex);
+
+ return 0;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_log_debug(axis2_log_t *log, const axis2_char_t *filename,
- const int linenumber, const axis2_char_t *format,...)
+ const int linenumber, const axis2_char_t *format,...)
{
- FILE *fd = NULL;
- axis2_thread_mutex_t *mutex = NULL;
-
- if (!log || !format)
- return -1;
-
- if (!log->enabled)
- return -1;
-
- if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
- {
- fprintf(stderr,"Stream is not found\n");
- return -1;
- }
-
- if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
- {
- fprintf(stderr,"Log mutex is not found\n");
- return -1;
- }
-
- if (AXIS2_LOG_LEVEL_DEBUG <= log->level)
- {
- char value[AXIS2_LEN_VALUE+1];
- va_list ap;
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_DEBUG, filename,
- linenumber, value);
- }
- return 0;
+ FILE *fd = NULL;
+ axis2_thread_mutex_t *mutex = NULL;
+
+ if (!log || !format)
+ return -1;
+
+ if (!log->enabled)
+ return -1;
+
+ if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
+ {
+ fprintf(stderr,"Stream is not found\n");
+ return -1;
+ }
+
+ if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+ {
+ fprintf(stderr,"Log mutex is not found\n");
+ return -1;
+ }
+
+ if (AXIS2_LOG_LEVEL_DEBUG <= log->level)
+ {
+ char value[AXIS2_LEN_VALUE+1];
+ va_list ap;
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_DEBUG, filename,
+ linenumber, value);
+ }
+ return 0;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_log_info(axis2_log_t *log, const axis2_char_t *format,...)
{
- FILE *fd = NULL;
- axis2_thread_mutex_t *mutex = NULL;
-
- if (!log || !format)
- return -1;
-
- if (!log->enabled)
- return -1;
-
- if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
- {
- fprintf(stderr,"Stream is not found\n");
- return -1;
- }
-
- if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
- {
- fprintf(stderr,"Log mutex is not found\n");
- return -1;
- }
-
- if (AXIS2_LOG_LEVEL_INFO <= log->level)
- {
- char value[AXIS2_LEN_VALUE+1];
- va_list ap;
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_INFO, NULL, -1,
- value);
- }
- return 0;
+ FILE *fd = NULL;
+ axis2_thread_mutex_t *mutex = NULL;
+
+ if (!log || !format)
+ return -1;
+
+ if (!log->enabled)
+ return -1;
+
+ if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
+ {
+ fprintf(stderr,"Stream is not found\n");
+ return -1;
+ }
+
+ if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+ {
+ fprintf(stderr,"Log mutex is not found\n");
+ return -1;
+ }
+
+ if (AXIS2_LOG_LEVEL_INFO <= log->level)
+ {
+ char value[AXIS2_LEN_VALUE+1];
+ va_list ap;
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_INFO, NULL, -1,
+ value);
+ }
+ return 0;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_log_warning(axis2_log_t *log, const axis2_char_t *filename,
- const int linenumber, const axis2_char_t *format,...)
+ const int linenumber, const axis2_char_t *format,...)
{
- FILE *fd = NULL;
- axis2_thread_mutex_t *mutex = NULL;
-
- if (!log || !format)
- return -1;
-
- if (!log->enabled)
- return -1;
-
- if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
- {
- fprintf(stderr,"Stream is not found\n");
- return -1;
- }
-
- if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
- {
- fprintf(stderr,"Log mutex is not found\n");
- return -1;
- }
-
- if (AXIS2_LOG_LEVEL_WARNING <= log->level)
- {
- char value[AXIS2_LEN_VALUE+1];
- va_list ap;
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_WARNING,
- filename, linenumber, value);
- }
- return 0;
+ FILE *fd = NULL;
+ axis2_thread_mutex_t *mutex = NULL;
+
+ if (!log || !format)
+ return -1;
+
+ if (!log->enabled)
+ return -1;
+
+ if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
+ {
+ fprintf(stderr,"Stream is not found\n");
+ return -1;
+ }
+
+ if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+ {
+ fprintf(stderr,"Log mutex is not found\n");
+ return -1;
+ }
+
+ if (AXIS2_LOG_LEVEL_WARNING <= log->level)
+ {
+ char value[AXIS2_LEN_VALUE+1];
+ va_list ap;
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_WARNING,
+ filename, linenumber, value);
+ }
+ return 0;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_log_error(axis2_log_t *log, const axis2_char_t *filename,
- const int linenumber, const axis2_char_t *format,...)
+ const int linenumber, const axis2_char_t *format,...)
{
- FILE *fd = NULL;
- axis2_thread_mutex_t *mutex = NULL;
-
- char value[AXIS2_LEN_VALUE+1];
- va_list ap;
-
- if (!log || !format)
- return -1;
-
- if (!log->enabled)
- return -1;
-
- if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
- {
- fprintf(stderr,"Stream is not found\n");
- return -1;
- }
-
- if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
- {
- fprintf(stderr,"Log mutex is not found\n");
- return -1;
- }
-
-
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_ERROR, filename,
- linenumber, value);
- return 0;
+ FILE *fd = NULL;
+ axis2_thread_mutex_t *mutex = NULL;
+
+ char value[AXIS2_LEN_VALUE+1];
+ va_list ap;
+
+ if (!log || !format)
+ return -1;
+
+ if (!log->enabled)
+ return -1;
+
+ if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
+ {
+ fprintf(stderr,"Stream is not found\n");
+ return -1;
+ }
+
+ if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+ {
+ fprintf(stderr,"Log mutex is not found\n");
+ return -1;
+ }
+
+
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_ERROR, filename,
+ linenumber, value);
+ return 0;
}
-
+
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_log_critical(axis2_log_t *log, const axis2_char_t *filename,
- const int linenumber, const axis2_char_t *format,...)
+ const int linenumber, const axis2_char_t *format,...)
{
- FILE *fd = NULL;
- axis2_thread_mutex_t *mutex = NULL;
-
- char value[AXIS2_LEN_VALUE+1];
- va_list ap;
- if (!log || !format)
- return -1;
-
- if (!log->enabled)
- return -1;
-
- if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
- {
- fprintf(stderr,"Stream is not found\n");
- return -1;
- }
-
- if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
- {
- fprintf(stderr,"Log mutex is not found\n");
- return -1;
- }
-
-
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_CRITICAL, filename,
- linenumber, value);
- return 0;
+ FILE *fd = NULL;
+ axis2_thread_mutex_t *mutex = NULL;
+
+ char value[AXIS2_LEN_VALUE+1];
+ va_list ap;
+ if (!log || !format)
+ return -1;
+
+ if (!log->enabled)
+ return -1;
+
+ if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
+ {
+ fprintf(stderr,"Stream is not found\n");
+ return -1;
+ }
+
+ if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+ {
+ fprintf(stderr,"Log mutex is not found\n");
+ return -1;
+ }
+
+
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_CRITICAL, filename,
+ linenumber, value);
+ return 0;
}
AXIS2_EXTERN axis2_char_t * AXIS2_CALL
axis2_log_impl_get_time_str(void)
{
time_t tp;
- char *time_str;
+ char *time_str;
tp = time(&tp);
time_str = ctime(&tp);
if(NULL == time_str)
@@ -465,43 +465,43 @@
#ifdef AXIS2_TRACE
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_log_impl_log_trace(axis2_log_t *log, const axis2_char_t *filename,
- const int linenumber, const axis2_char_t *format,...)
+ const int linenumber, const axis2_char_t *format,...)
{
- FILE *fd = NULL;
- axis2_thread_mutex_t *mutex = NULL;
-
- if (!log || !format)
- return -1;
-
- if (!log->enabled)
- return -1;
-
- if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
- {
- fprintf(stderr,"Stream is not found\n");
- return -1;
- }
-
- if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
- {
- fprintf(stderr,"Log mutex is not found\n");
- return -1;
- }
-
- if (AXIS2_LOG_LEVEL_TRACE <= log->level)
- {
- char value[AXIS2_LEN_VALUE+1];
- va_list ap;
- va_start(ap, format);
- AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
- va_end(ap);
- axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_TRACE, filename,
- linenumber, value);
- }
- return 0;
+ FILE *fd = NULL;
+ axis2_thread_mutex_t *mutex = NULL;
+
+ if (!log || !format)
+ return -1;
+
+ if (!log->enabled)
+ return -1;
+
+ if (NULL == (fd = AXIS2_INTF_TO_IMPL(log)->stream))
+ {
+ fprintf(stderr,"Stream is not found\n");
+ return -1;
+ }
+
+ if (NULL == (mutex = AXIS2_INTF_TO_IMPL(log)->mutex))
+ {
+ fprintf(stderr,"Log mutex is not found\n");
+ return -1;
+ }
+
+ if (AXIS2_LOG_LEVEL_TRACE <= log->level)
+ {
+ char value[AXIS2_LEN_VALUE+1];
+ va_list ap;
+ va_start(ap, format);
+ AXIS2_VSNPRINTF(value, AXIS2_LEN_VALUE, format, ap);
+ va_end(ap);
+ axis2_log_impl_write_to_file(fd, mutex, AXIS2_LOG_LEVEL_TRACE, filename,
+ linenumber, value);
+ }
+ return 0;
}
#else
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_log_impl_log_trace(axis2_log_t *log,
- const axis2_char_t *filename, const int linenumber,
- const axis2_char_t *format,...) { return AXIS2_SUCCESS;}
+ const axis2_char_t *filename, const int linenumber,
+ const axis2_char_t *format,...) { return AXIS2_SUCCESS;}
#endif
Modified: webservices/axis2/trunk/c/util/src/minizip/archive_extract.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/minizip/archive_extract.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/minizip/archive_extract.c (original)
+++ webservices/axis2/trunk/c/util/src/minizip/archive_extract.c Sat Jun 3 20:09:08 2006
@@ -37,267 +37,267 @@
extern int AXIS2_ALPHASORT();
int axis2_mkdir(dir_name)
- const axis2_char_t* dir_name;
+ const axis2_char_t* dir_name;
{
int value=0;
- #ifdef WIN32
- value = mkdir(dir_name);
- #else
- value = mkdir (dir_name,0775);
- #endif
- return value;
+ #ifdef WIN32
+ value = mkdir(dir_name);
+ #else
+ value = mkdir (dir_name,0775);
+ #endif
+ return value;
}
int axis2_create_dir (new_dir)
- axis2_char_t *new_dir;
+ axis2_char_t *new_dir;
{
- axis2_char_t *buffer ;
- axis2_char_t *p;
- int len = (int)strlen(new_dir);
-
- if (len <= 0)
- return 0;
-
- buffer = (axis2_char_t*)malloc(len+1);
- strcpy(buffer,new_dir);
-
- if (buffer[len-1] == '/')
- {
- buffer[len-1] = '\0';
- }
-
- if (axis2_mkdir(buffer) == 0)
- {
- free(buffer);
- return 1;
- }
-
- p = buffer+1;
- while (1)
- {
- axis2_char_t hold;
-
- while(*p && *p != '\\' && *p != '/')
- p++;
- hold = *p;
- *p = 0;
- if ((axis2_mkdir(buffer) == -1))
- {
- free(buffer);
- return 0;
- }
- if (hold == 0)
- break;
- *p++ = hold;
- }
- free(buffer);
- return 1;
+ axis2_char_t *buffer ;
+ axis2_char_t *p;
+ int len = (int)strlen(new_dir);
+
+ if (len <= 0)
+ return 0;
+
+ buffer = (axis2_char_t*)malloc(len+1);
+ strcpy(buffer,new_dir);
+
+ if (buffer[len-1] == '/')
+ {
+ buffer[len-1] = '\0';
+ }
+
+ if (axis2_mkdir(buffer) == 0)
+ {
+ free(buffer);
+ return 1;
+ }
+
+ p = buffer+1;
+ while (1)
+ {
+ axis2_char_t hold;
+
+ while(*p && *p != '\\' && *p != '/')
+ p++;
+ hold = *p;
+ *p = 0;
+ if ((axis2_mkdir(buffer) == -1))
+ {
+ free(buffer);
+ return 0;
+ }
+ if (hold == 0)
+ break;
+ *p++ = hold;
+ }
+ free(buffer);
+ return 1;
}
int axis2_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
- unzFile uf;
- const int* popt_extract_without_path;
- int* popt_overwrite;
- const axis2_char_t* password;
+ unzFile uf;
+ const int* popt_extract_without_path;
+ int* popt_overwrite;
+ const axis2_char_t* password;
{
- axis2_char_t filename_inzip[256];
- axis2_char_t* filename_withoutpath;
- axis2_char_t* p;
- int err=UNZ_OK;
- FILE *fout=NULL;
- void* buf;
- uInt size_buf;
-
- unz_file_info file_info;
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
-
- if (err!=UNZ_OK)
- {
- return err;
- }
-
- size_buf = WRITEBUFFERSIZE;
- buf = (void*)malloc(size_buf);
- if (buf==NULL)
- return UNZ_INTERNALERROR;
+ axis2_char_t filename_inzip[256];
+ axis2_char_t* filename_withoutpath;
+ axis2_char_t* p;
+ int err=UNZ_OK;
+ FILE *fout=NULL;
+ void* buf;
+ uInt size_buf;
+
+ unz_file_info file_info;
+ err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
+
+ if (err!=UNZ_OK)
+ {
+ return err;
+ }
+
+ size_buf = WRITEBUFFERSIZE;
+ buf = (void*)malloc(size_buf);
+ if (buf==NULL)
+ return UNZ_INTERNALERROR;
p = filename_withoutpath = filename_inzip;
- while ((*p) != '\0')
- {
- if (((*p)=='/') || ((*p)=='\\'))
- filename_withoutpath = p+1;
- p++;
- }
-
- if ((*filename_withoutpath)=='\0')
- {
- if ((*popt_extract_without_path)==0)
- {
- axis2_mkdir(filename_inzip);
- }
- }
- else
- {
- const axis2_char_t* write_filename;
- int skip=0;
-
- if ((*popt_extract_without_path)==0)
- write_filename = filename_inzip;
- else
- write_filename = filename_withoutpath;
-
- err = unzOpenCurrentFilePassword(uf,password);
-
- if ((skip==0) && (err==UNZ_OK))
- {
- fout=fopen(write_filename,"wb");
-
- if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
- (filename_withoutpath!=(axis2_char_t*)filename_inzip))
- {
- axis2_char_t c=*(filename_withoutpath-1);
- *(filename_withoutpath-1)='\0';
- axis2_create_dir(write_filename);
- *(filename_withoutpath-1)=c;
- fout=fopen(write_filename,"wb");
- }
-
- }
-
- if (fout!=NULL)
- {
- do
- {
- err = unzReadCurrentFile(uf,buf,size_buf);
- if (err<0)
- {
- break;
- }
- if (err>0)
- if (fwrite(buf,err,1,fout)!=1)
- {
- err=UNZ_ERRNO;
- break;
- }
- }
- while (err>0);
- if (fout)
- fclose(fout);
-
- }
-
- if (err==UNZ_OK)
- {
- err = unzCloseCurrentFile (uf);
- }
- else
- unzCloseCurrentFile(uf);
- }
+ while ((*p) != '\0')
+ {
+ if (((*p)=='/') || ((*p)=='\\'))
+ filename_withoutpath = p+1;
+ p++;
+ }
+
+ if ((*filename_withoutpath)=='\0')
+ {
+ if ((*popt_extract_without_path)==0)
+ {
+ axis2_mkdir(filename_inzip);
+ }
+ }
+ else
+ {
+ const axis2_char_t* write_filename;
+ int skip=0;
+
+ if ((*popt_extract_without_path)==0)
+ write_filename = filename_inzip;
+ else
+ write_filename = filename_withoutpath;
+
+ err = unzOpenCurrentFilePassword(uf,password);
+
+ if ((skip==0) && (err==UNZ_OK))
+ {
+ fout=fopen(write_filename,"wb");
+
+ if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
+ (filename_withoutpath!=(axis2_char_t*)filename_inzip))
+ {
+ axis2_char_t c=*(filename_withoutpath-1);
+ *(filename_withoutpath-1)='\0';
+ axis2_create_dir(write_filename);
+ *(filename_withoutpath-1)=c;
+ fout=fopen(write_filename,"wb");
+ }
+
+ }
+
+ if (fout!=NULL)
+ {
+ do
+ {
+ err = unzReadCurrentFile(uf,buf,size_buf);
+ if (err<0)
+ {
+ break;
+ }
+ if (err>0)
+ if (fwrite(buf,err,1,fout)!=1)
+ {
+ err=UNZ_ERRNO;
+ break;
+ }
+ }
+ while (err>0);
+ if (fout)
+ fclose(fout);
+
+ }
+
+ if (err==UNZ_OK)
+ {
+ err = unzCloseCurrentFile (uf);
+ }
+ else
+ unzCloseCurrentFile(uf);
+ }
- free(buf);
- return err;
+ free(buf);
+ return err;
}
int axis2_extract(uf,opt_extract_without_path,opt_overwrite,password)
- unzFile uf;
- int opt_extract_without_path;
- int opt_overwrite;
- const axis2_char_t* password;
+ unzFile uf;
+ int opt_extract_without_path;
+ int opt_overwrite;
+ const axis2_char_t* password;
{
- uLong i;
- unz_global_info gi;
- int err;
-
- err = unzGetGlobalInfo (uf,&gi);
- if (err!=UNZ_OK)
- return -1;
-
- for (i=0;i<gi.number_entry;i++)
- {
- if (axis2_extract_currentfile(uf,&opt_extract_without_path,
- &opt_overwrite,
- password) != UNZ_OK)
- break;
-
- if ((i+1)<gi.number_entry)
- {
- err = unzGoToNextFile(uf);
- if (err!=UNZ_OK)
- {
- return -1;
- break;
- }
- }
- }
+ uLong i;
+ unz_global_info gi;
+ int err;
+
+ err = unzGetGlobalInfo (uf,&gi);
+ if (err!=UNZ_OK)
+ return -1;
+
+ for (i=0;i<gi.number_entry;i++)
+ {
+ if (axis2_extract_currentfile(uf,&opt_extract_without_path,
+ &opt_overwrite,
+ password) != UNZ_OK)
+ break;
+
+ if ((i+1)<gi.number_entry)
+ {
+ err = unzGoToNextFile(uf);
+ if (err!=UNZ_OK)
+ {
+ return -1;
+ break;
+ }
+ }
+ }
- return 0;
+ return 0;
}
-
-
+
+
int aar_extract(axis2_char_t *d_name)
{
- const axis2_char_t *zipfilename=NULL;
- const axis2_char_t *filename_to_extract=NULL;
- const axis2_char_t *password=NULL;
- axis2_char_t filename_try[MAXFILENAME+16] = "";
- int opt_do_extract_withoutpath=0;
- int opt_overwrite=0;
- int opt_extractdir=0;
- const axis2_char_t *dir_name=NULL;
- unzFile uf=NULL;
- zlib_filefunc_def ffunc;
-
- if (zipfilename == NULL)
- zipfilename = d_name;
-
- filename_to_extract = d_name;
-
- if (zipfilename!=NULL)
- {
- strncpy(filename_try, zipfilename,MAXFILENAME-1);
- filename_try[ MAXFILENAME ] = '\0';
-
- axis2_fill_win32_filefunc(&ffunc);
- uf = AXIS2_UNZOPEN2(zipfilename,ffunc);
- if (uf==NULL)
- {
- strcat(filename_try,".zip");
-
- uf = AXIS2_UNZOPEN2(zipfilename,ffunc);
- }
- }
-
- if (uf==NULL)
- return -1;
-
- if (opt_extractdir && chdir(dir_name))
- exit(-1);
-
- return axis2_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
- unzCloseCurrentFile(uf);
- return 0;
+ const axis2_char_t *zipfilename=NULL;
+ const axis2_char_t *filename_to_extract=NULL;
+ const axis2_char_t *password=NULL;
+ axis2_char_t filename_try[MAXFILENAME+16] = "";
+ int opt_do_extract_withoutpath=0;
+ int opt_overwrite=0;
+ int opt_extractdir=0;
+ const axis2_char_t *dir_name=NULL;
+ unzFile uf=NULL;
+ zlib_filefunc_def ffunc;
+
+ if (zipfilename == NULL)
+ zipfilename = d_name;
+
+ filename_to_extract = d_name;
+
+ if (zipfilename!=NULL)
+ {
+ strncpy(filename_try, zipfilename,MAXFILENAME-1);
+ filename_try[ MAXFILENAME ] = '\0';
+
+ axis2_fill_win32_filefunc(&ffunc);
+ uf = AXIS2_UNZOPEN2(zipfilename,ffunc);
+ if (uf==NULL)
+ {
+ strcat(filename_try,".zip");
+
+ uf = AXIS2_UNZOPEN2(zipfilename,ffunc);
+ }
+ }
+
+ if (uf==NULL)
+ return -1;
+
+ if (opt_extractdir && chdir(dir_name))
+ exit(-1);
+
+ return axis2_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
+ unzCloseCurrentFile(uf);
+ return 0;
}
int axis2_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
- unzFile uf;
- const axis2_char_t* filename;
- int opt_extract_without_path;
- int opt_overwrite;
- const axis2_char_t* password;
+ unzFile uf;
+ const axis2_char_t* filename;
+ int opt_extract_without_path;
+ int opt_overwrite;
+ const axis2_char_t* password;
{
- if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
- return -1;
+ if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
+ return -1;
- if (axis2_extract_currentfile(uf,&opt_extract_without_path,
- &opt_overwrite,
- password) == UNZ_OK)
- return 0;
- else
- return -1;
+ if (axis2_extract_currentfile(uf,&opt_extract_without_path,
+ &opt_overwrite,
+ password) == UNZ_OK)
+ return 0;
+ else
+ return -1;
}
@@ -305,37 +305,37 @@
-
+
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_archive_extract()
{
- struct dirent **namelist;
- int n;
- axis2_char_t *ptr;
-
- n = scandir(".", &namelist, 0, alphasort);
- if (n < 0)
- return AXIS2_FALSE;
- else
- {
- while(n--)
- {
- if ((strcmp(namelist[n]->d_name, ".")== 0) ||
- (strcmp(namelist[n]->d_name, "..") == 0))
- return (AXIS2_FALSE);
-
- ptr = AXIS2_RINDEX(namelist[n]->d_name, '.');
-
- if ((ptr != NULL) &&
- (((strcmp(ptr, AXIS2_AAR_SUFFIX) == 0)) || (strcmp(ptr, AXIS2_MAR_SUFFIX) == 0)))
- {
- aar_extract(namelist[n]->d_name);
- }
- free(namelist[n]);
- }
- free(namelist);
- }
- return (AXIS2_TRUE);
+ struct dirent **namelist;
+ int n;
+ axis2_char_t *ptr;
+
+ n = scandir(".", &namelist, 0, alphasort);
+ if (n < 0)
+ return AXIS2_FALSE;
+ else
+ {
+ while(n--)
+ {
+ if ((strcmp(namelist[n]->d_name, ".")== 0) ||
+ (strcmp(namelist[n]->d_name, "..") == 0))
+ return (AXIS2_FALSE);
+
+ ptr = AXIS2_RINDEX(namelist[n]->d_name, '.');
+
+ if ((ptr != NULL) &&
+ (((strcmp(ptr, AXIS2_AAR_SUFFIX) == 0)) || (strcmp(ptr, AXIS2_MAR_SUFFIX) == 0)))
+ {
+ aar_extract(namelist[n]->d_name);
+ }
+ free(namelist[n]);
+ }
+ free(namelist);
+ }
+ return (AXIS2_TRUE);
}
Modified: webservices/axis2/trunk/c/util/src/minizip/unzip.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/minizip/unzip.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/minizip/unzip.c (original)
+++ webservices/axis2/trunk/c/util/src/minizip/unzip.c Sat Jun 3 20:09:08 2006
@@ -625,14 +625,14 @@
/* we check the magic */
if (err==UNZ_OK)
- {
+ {
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
- }
+ }
else if (uMagic!=0x02014b50)
- {
+ {
err=UNZ_BADZIPFILE;
- }
+ }
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
@@ -709,12 +709,12 @@
uSizeRead = extraFieldBufferSize;
if (lSeek!=0)
- {
+ {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
- }
+ }
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
@@ -736,12 +736,12 @@
uSizeRead = commentBufferSize;
if (lSeek!=0)
- {
+ {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
- }
+ }
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
@@ -1002,12 +1002,12 @@
if (err==UNZ_OK)
- {
+ {
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE;
- }
+ }
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
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=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/network_handler.c (original)
+++ webservices/axis2/trunk/c/util/src/network_handler.c Sat Jun 3 20:09:08 2006
@@ -29,29 +29,29 @@
AXIS2_EXTERN axis2_socket_t AXIS2_CALL
axis2_network_handler_open_socket(const axis2_env_t *env, char *server, int port)
{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
- struct sockaddr_in sock_addr;
- struct linger ll;
- int nodelay = 1;
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ struct sockaddr_in sock_addr;
+ struct linger ll;
+ int nodelay = 1;
#if defined(WIN32)
if (is_init_socket == 0)
{
- axis2_init_socket();
- is_init_socket = 1;
+ axis2_init_socket();
+ is_init_socket = 1;
}
#endif
AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
AXIS2_PARAM_CHECK(env->error, server, AXIS2_CRTICAL_FAILURE);
- if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- /*nnn 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;
- }
-
+ if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ /*nnn 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;
+ }
+
memset(&sock_addr,0,sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
sock_addr.sin_addr.s_addr = inet_addr(server);/*nnn arpa/inet.d */
@@ -66,59 +66,59 @@
if (NULL != lphost)
sock_addr.sin_addr.s_addr =
- ((struct in_addr*)lphost->h_addr)->s_addr;
+ ((struct in_addr*)lphost->h_addr)->s_addr;
else
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS,
- AXIS2_FAILURE);
+ AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
}
sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
- /** Connect to server */
+ /** Connect to server */
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);
+ 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));
- ll.l_onoff = 1;
+ 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));
- return sock;
+ return sock;
}
AXIS2_EXTERN axis2_socket_t AXIS2_CALL
axis2_network_handler_create_server_socket(const axis2_env_t *env, int port)
{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
- axis2_socket_t i = 0;
- struct sockaddr_in sock_addr;
-
- AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ axis2_socket_t i = 0;
+ struct sockaddr_in sock_addr;
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
#if defined(WIN32)
if (is_init_socket == 0)
{
- axis2_init_socket();
- is_init_socket = 1;
+ axis2_init_socket();
+ is_init_socket = 1;
}
#endif
- sock = socket(AF_INET, SOCK_STREAM, 0);
- if(sock < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
- /** Address re-use */
- i = 1;
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR ,(char*) &i,
- sizeof(axis2_socket_t));/*nnn casted 4th param to char* */
- /** Exec behaviour */
- AXIS2_CLOSE_SOCKET_ON_EXIT(sock)
-
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if(sock < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+ /** Address re-use */
+ i = 1;
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR ,(char*) &i,
+ sizeof(axis2_socket_t));/*nnn casted 4th param to char* */
+ /** Exec behaviour */
+ AXIS2_CLOSE_SOCKET_ON_EXIT(sock)
+
memset(&sock_addr,0,sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
@@ -129,16 +129,16 @@
if (bind(sock, (struct sockaddr*)&sock_addr, sizeof(sock_addr)) < 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED,
- AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
+ AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
if(listen(sock, 50) < 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_LISTEN_FAILED,
AXIS2_FAILURE);
return AXIS2_INVALID_SOCKET;
}
- return sock;
+ return sock;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -146,57 +146,57 @@
{
int i = 0;
char buf[32];
- AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
- if(socket < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET,
- AXIS2_FAILURE);
- return AXIS2_FAILURE;
- }
+ AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
+ if(socket < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET,
+ AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
shutdown(socket, AXIS2_SHUT_WR);
i = recv(socket, buf, 32, 0);
AXIS2_CLOSE_SOCKET(socket);
- return AXIS2_SUCCESS;
+ return AXIS2_SUCCESS;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_network_handler_set_sock_option(const axis2_env_t *env, axis2_socket_t socket,
- int option, int value)
+ int option, int value)
{
- if(option == SO_RCVTIMEO || option == SO_SNDTIMEO)
- {
- struct timeval tv;
- /* we deal with milliseconds */
- tv.tv_sec = value/1000;
- tv.tv_usec = (value%1000) * 1000;
- setsockopt(socket, SOL_SOCKET, option, (char*) &tv, sizeof(tv));
- return AXIS2_SUCCESS;
- }
- return AXIS2_FAILURE;
+ if(option == SO_RCVTIMEO || option == SO_SNDTIMEO)
+ {
+ struct timeval tv;
+ /* we deal with milliseconds */
+ tv.tv_sec = value/1000;
+ tv.tv_usec = (value%1000) * 1000;
+ setsockopt(socket, SOL_SOCKET, option, (char*) &tv, sizeof(tv));
+ return AXIS2_SUCCESS;
+ }
+ return AXIS2_FAILURE;
}
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
axis2_network_handler_svr_socket_accept(const axis2_env_t *env,
- axis2_socket_t svr_socket)
+ axis2_socket_t svr_socket)
{
- struct sockaddr cli_addr;
-
- struct linger ll;
- int nodelay = 1;
- axis2_socket_len_t cli_len = 0;
- axis2_socket_t cli_socket = AXIS2_INVALID_SOCKET;
-
- AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
-
- cli_len = sizeof(cli_addr);
- cli_socket = accept(svr_socket, (struct sockaddr *)&cli_addr, &cli_len);
+ struct sockaddr cli_addr;
+
+ struct linger ll;
+ int nodelay = 1;
+ axis2_socket_len_t cli_len = 0;
+ axis2_socket_t cli_socket = AXIS2_INVALID_SOCKET;
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
+
+ cli_len = sizeof(cli_addr);
+ cli_socket = accept(svr_socket, (struct sockaddr *)&cli_addr, &cli_len);
if (cli_socket < 0)
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[Axis2][network_handler] Socket accept \
- failed");
-
- setsockopt(cli_socket, IPPROTO_TCP, TCP_NODELAY, &nodelay,
- sizeof(nodelay));
- ll.l_onoff = 1;
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[Axis2][network_handler] Socket accept \
+ failed");
+
+ setsockopt(cli_socket, IPPROTO_TCP, TCP_NODELAY, &nodelay,
+ sizeof(nodelay));
+ ll.l_onoff = 1;
ll.l_linger = 5;
setsockopt(cli_socket, SOL_SOCKET, SO_LINGER , &ll, sizeof(struct linger));
return cli_socket;
@@ -205,37 +205,37 @@
#if defined (WIN32)
axis2_bool_t axis2_init_socket()
{
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
- int sock_opt = SO_SYNCHRONOUS_NONALERT;
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+ int sock_opt = SO_SYNCHRONOUS_NONALERT;
- wVersionRequested = MAKEWORD( 2, 2 );
+ wVersionRequested = MAKEWORD( 2, 2 );
- err = WSAStartup( wVersionRequested, &wsaData );
+ err = WSAStartup( wVersionRequested, &wsaData );
- if ( err != 0 )
- return 0; //WinSock 2.2 not found
+ if ( err != 0 )
+ return 0; //WinSock 2.2 not found
- // Confirm that the WinSock DLL supports 2.2.
- // Note that if the DLL supports versions greater
- // than 2.2 in addition to 2.2, it will still return
- // 2.2 in wVersion since that is the version we
- // requested.
+ // Confirm that the WinSock DLL supports 2.2.
+ // Note that if the DLL supports versions greater
+ // than 2.2 in addition to 2.2, it will still return
+ // 2.2 in wVersion since that is the version we
+ // requested.
- if ( LOBYTE( wsaData.wVersion ) != 2 ||
- HIBYTE( wsaData.wVersion ) != 2 )
- {
- WSACleanup( );
- return 0; //WinSock 2.2 not supported
- }
- /**
- * Enable the use of sockets as filehandles
- */
- setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&sock_opt,
- sizeof(sock_opt));
- return 1;
+ if ( LOBYTE( wsaData.wVersion ) != 2 ||
+ HIBYTE( wsaData.wVersion ) != 2 )
+ {
+ WSACleanup( );
+ return 0; //WinSock 2.2 not supported
+ }
+ /**
+ * Enable the use of sockets as filehandles
+ */
+ setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&sock_opt,
+ sizeof(sock_opt));
+ return 1;
}
#endif
Modified: webservices/axis2/trunk/c/util/src/param.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/param.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/param.c (original)
+++ webservices/axis2/trunk/c/util/src/param.c Sat Jun 3 20:09:08 2006
@@ -40,38 +40,38 @@
axis2_char_t* AXIS2_CALL
axis2_param_get_name(axis2_param_t *param,
- const axis2_env_t *env);
-
+ const axis2_env_t *env);
+
void* AXIS2_CALL
axis2_param_get_value(axis2_param_t *param,
- const axis2_env_t *env);
-
+ const axis2_env_t *env);
+
axis2_status_t AXIS2_CALL
axis2_param_set_name(axis2_param_t *param,
- const axis2_env_t *env,
- axis2_char_t *name);
+ const axis2_env_t *env,
+ axis2_char_t *name);
axis2_status_t AXIS2_CALL
axis2_param_set_value(axis2_param_t *param,
- const axis2_env_t *env,
- void *value);
+ const axis2_env_t *env,
+ void *value);
axis2_bool_t AXIS2_CALL
axis2_param_is_locked(axis2_param_t *param,
- const axis2_env_t *env);
+ const axis2_env_t *env);
axis2_status_t AXIS2_CALL
axis2_param_set_locked(axis2_param_t *param,
- const axis2_env_t *env,
- axis2_bool_t value);
+ const axis2_env_t *env,
+ axis2_bool_t value);
int AXIS2_CALL
axis2_param_get_param_type(axis2_param_t *param,
- const axis2_env_t *env);
+ const axis2_env_t *env);
axis2_status_t AXIS2_CALL
axis2_param_set_param_type(axis2_param_t *param,
- const axis2_env_t *env,
- int type);
+ const axis2_env_t *env,
+ int type);
axis2_status_t AXIS2_CALL
axis2_param_set_attributes(
@@ -97,12 +97,12 @@
axis2_status_t AXIS2_CALL
axis2_param_free(axis2_param_t *param,
- const axis2_env_t *env);
+ const axis2_env_t *env);
/******************************************************************************/
AXIS2_EXTERN axis2_param_t* AXIS2_CALL
axis2_param_create(const axis2_env_t *env,
- axis2_char_t *name, void *value)
+ axis2_char_t *name, void *value)
{
axis2_param_impl_t *param_impl = NULL;
@@ -124,11 +124,11 @@
param_impl->value_list = NULL;
param_impl->param.ops =
- AXIS2_MALLOC (env->allocator, sizeof(axis2_param_ops_t));
- if(NULL == param_impl->param.ops)
+ AXIS2_MALLOC (env->allocator, sizeof(axis2_param_ops_t));
+ if(NULL == param_impl->param.ops)
{
axis2_param_free(&(param_impl->param), env);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
param_impl->param.ops->value_free = NULL;
@@ -140,9 +140,9 @@
param_impl->param.ops->is_locked = axis2_param_is_locked;
param_impl->param.ops->set_locked = axis2_param_set_locked;
param_impl->param.ops->get_param_type =
- axis2_param_get_param_type;
+ axis2_param_get_param_type;
param_impl->param.ops->set_param_type =
- axis2_param_set_param_type;
+ axis2_param_set_param_type;
param_impl->param.ops->set_attributes =
axis2_param_set_attributes;
param_impl->param.ops->get_attributes =
@@ -160,7 +160,7 @@
axis2_char_t* AXIS2_CALL
axis2_param_get_name(axis2_param_t *param,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
AXIS2_ENV_CHECK(env, NULL);
@@ -169,7 +169,7 @@
void* AXIS2_CALL
axis2_param_get_value(axis2_param_t *param,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
AXIS2_ENV_CHECK(env, NULL);
@@ -178,8 +178,8 @@
axis2_status_t AXIS2_CALL
axis2_param_set_name(axis2_param_t *param,
- const axis2_env_t *env,
- axis2_char_t *name)
+ const axis2_env_t *env,
+ axis2_char_t *name)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -189,8 +189,8 @@
axis2_status_t AXIS2_CALL
axis2_param_set_value(axis2_param_t *param,
- const axis2_env_t *env,
- void *value)
+ const axis2_env_t *env,
+ void *value)
{
void *param_value = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -213,7 +213,7 @@
axis2_bool_t AXIS2_CALL
axis2_param_is_locked(axis2_param_t *param,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
return AXIS2_INTF_TO_IMPL(param)->locked;
@@ -221,8 +221,8 @@
axis2_status_t AXIS2_CALL
axis2_param_set_locked(axis2_param_t *param,
- const axis2_env_t *env,
- axis2_bool_t value)
+ const axis2_env_t *env,
+ axis2_bool_t value)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -232,7 +232,7 @@
int AXIS2_CALL
axis2_param_get_param_type(axis2_param_t *param,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -241,8 +241,8 @@
axis2_status_t AXIS2_CALL
axis2_param_set_param_type(axis2_param_t *param,
- const axis2_env_t *env,
- int type)
+ const axis2_env_t *env,
+ int type)
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -337,7 +337,7 @@
axis2_status_t AXIS2_CALL
axis2_param_free(axis2_param_t *param,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
axis2_param_impl_t *param_impl = NULL;
void *param_value = NULL;
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=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/param_container.c (original)
+++ webservices/axis2/trunk/c/util/src/param_container.c Sat Jun 3 20:09:08 2006
@@ -18,42 +18,42 @@
/**
* @brief Param container struct impl
- * Container for params
+ * Container for params
*/
typedef struct axis2_param_container_impl
{
- axis2_param_container_t param_container;
+ axis2_param_container_t param_container;
axis2_hash_t *params;
axis2_array_list_t *params_list;
} axis2_param_container_impl_t;
#define AXIS2_INTF_TO_IMPL(param_container) \
- ((axis2_param_container_impl_t *)param_container)
+ ((axis2_param_container_impl_t *)param_container)
/************************* Function prototypes ********************************/
axis2_status_t AXIS2_CALL
- axis2_param_container_free (axis2_param_container_t *param_container,
- const axis2_env_t *env);
+ axis2_param_container_free (axis2_param_container_t *param_container,
+ const axis2_env_t *env);
axis2_status_t AXIS2_CALL
axis2_param_container_add_param (axis2_param_container_t *param_container,
- const axis2_env_t *env,
- axis2_param_t *param);
-
+ const axis2_env_t *env,
+ axis2_param_t *param);
+
axis2_param_t * AXIS2_CALL
axis2_param_container_get_param (axis2_param_container_t *param_container,
- const axis2_env_t *env,
- const axis2_char_t *name);
+ const axis2_env_t *env,
+ const axis2_char_t *name);
axis2_array_list_t * AXIS2_CALL
axis2_param_container_get_params (axis2_param_container_t *param_container,
- const axis2_env_t *env);
+ const axis2_env_t *env);
axis2_bool_t AXIS2_CALL
axis2_param_container_is_param_locked (axis2_param_container_t *param_container,
- const axis2_env_t *env,
- const axis2_char_t *param_name);
+ const axis2_env_t *env,
+ const axis2_char_t *param_name);
/************************** End of function prototypes ************************/
@@ -62,67 +62,67 @@
{
axis2_param_container_impl_t *param_container_impl = NULL;
- AXIS2_ENV_CHECK(env, NULL);
-
- param_container_impl = (axis2_param_container_impl_t *) AXIS2_MALLOC(env->
+ AXIS2_ENV_CHECK(env, NULL);
+
+ param_container_impl = (axis2_param_container_impl_t *) AXIS2_MALLOC(env->
allocator, sizeof(axis2_param_container_impl_t));
-
- if(NULL == param_container_impl)
+
+ if(NULL == param_container_impl)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
-
+
param_container_impl->params = NULL;
param_container_impl->params_list = NULL;
param_container_impl->params = axis2_hash_make (env);
- if(NULL == param_container_impl->params)
+ if(NULL == param_container_impl->params)
{
axis2_param_container_free(&(param_container_impl->param_container), env);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
- param_container_impl->param_container.ops =
- AXIS2_MALLOC (env->allocator, sizeof(axis2_param_container_ops_t));
- if(NULL == param_container_impl->param_container.ops)
+ param_container_impl->param_container.ops =
+ AXIS2_MALLOC (env->allocator, sizeof(axis2_param_container_ops_t));
+ if(NULL == param_container_impl->param_container.ops)
{
axis2_param_container_free(&(param_container_impl->param_container), env);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
- param_container_impl->param_container.ops->free = axis2_param_container_free;
- param_container_impl->param_container.ops->add_param =
+ param_container_impl->param_container.ops->free = axis2_param_container_free;
+ param_container_impl->param_container.ops->add_param =
axis2_param_container_add_param;
- param_container_impl->param_container.ops->get_param =
+ param_container_impl->param_container.ops->get_param =
axis2_param_container_get_param;
- param_container_impl->param_container.ops->get_params =
+ param_container_impl->param_container.ops->get_params =
axis2_param_container_get_params;
- param_container_impl->param_container.ops->is_param_locked =
+ param_container_impl->param_container.ops->is_param_locked =
axis2_param_container_is_param_locked;
-
- return &(param_container_impl->param_container);
+
+ return &(param_container_impl->param_container);
}
/*************************** Start of op impls *************************/
axis2_status_t AXIS2_CALL
axis2_param_container_free (axis2_param_container_t *param_container,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
axis2_param_container_impl_t *param_container_impl = NULL;
axis2_status_t status = AXIS2_SUCCESS;
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
param_container_impl = AXIS2_INTF_TO_IMPL(param_container);
- if(NULL != param_container->ops)
- AXIS2_FREE(env->allocator, param_container->ops);
-
- if(NULL != param_container_impl->params)
+ if(NULL != param_container->ops)
+ AXIS2_FREE(env->allocator, param_container->ops);
+
+ if(NULL != param_container_impl->params)
{
axis2_hash_index_t *hi = NULL;
void *val = NULL;
@@ -139,7 +139,7 @@
}
val = NULL;
}
- axis2_hash_free(param_container_impl->params, env);
+ axis2_hash_free(param_container_impl->params, env);
}
if(param_container_impl->params_list)
{
@@ -150,7 +150,7 @@
AXIS2_ARRAY_LIST_FREE(param_container_impl->params_list, env);
param_container_impl->params_list = NULL;
}
-
+
AXIS2_FREE(env->allocator, param_container_impl);
return status;
}
@@ -168,24 +168,24 @@
axis2_status_t AXIS2_CALL
axis2_param_container_add_param (axis2_param_container_t *param_container,
- const axis2_env_t *env,
- axis2_param_t *param)
+ const axis2_env_t *env,
+ axis2_param_t *param)
{
axis2_param_container_impl_t *param_container_impl = NULL;
axis2_char_t *param_name = NULL;
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE);
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE);
param_container_impl = AXIS2_INTF_TO_IMPL(param_container);
- if (NULL == param_container_impl->params)
- {
- param_container_impl->params = axis2_hash_make (env);
+ if (NULL == param_container_impl->params)
+ {
+ param_container_impl->params = axis2_hash_make (env);
if(!param_container_impl->params)
{
return AXIS2_FAILURE;
}
- }
+ }
param_name = AXIS2_PARAM_GET_NAME(param, env);
if(!param_name)
{
@@ -193,27 +193,27 @@
AXIS2_FAILURE);
return AXIS2_FAILURE;
}
- axis2_hash_set (param_container_impl->params
- , param_name, AXIS2_HASH_KEY_STRING, param);
-
- return AXIS2_SUCCESS;
+ axis2_hash_set (param_container_impl->params
+ , param_name, AXIS2_HASH_KEY_STRING, param);
+
+ return AXIS2_SUCCESS;
}
axis2_param_t * AXIS2_CALL
axis2_param_container_get_param (axis2_param_container_t *param_container,
- const axis2_env_t *env,
- const axis2_char_t *name)
+ const axis2_env_t *env,
+ const axis2_char_t *name)
{
- AXIS2_ENV_CHECK(env, NULL);
-
- return (axis2_param_t *)(axis2_hash_get (AXIS2_INTF_TO_IMPL(param_container)->
- params, name, AXIS2_HASH_KEY_STRING));
+ AXIS2_ENV_CHECK(env, NULL);
+
+ return (axis2_param_t *)(axis2_hash_get (AXIS2_INTF_TO_IMPL(param_container)->
+ params, name, AXIS2_HASH_KEY_STRING));
}
axis2_array_list_t * AXIS2_CALL
axis2_param_container_get_params (axis2_param_container_t *param_container,
- const axis2_env_t *env)
+ const axis2_env_t *env)
{
axis2_param_container_impl_t *param_container_impl = NULL;
axis2_hash_index_t *index_i = 0;
@@ -247,24 +247,24 @@
}
}
- return param_container_impl->params_list;
+ return param_container_impl->params_list;
}
axis2_bool_t AXIS2_CALL
axis2_param_container_is_param_locked (axis2_param_container_t *param_container,
- const axis2_env_t *env,
- const axis2_char_t *param_name)
+ const axis2_env_t *env,
+ const axis2_char_t *param_name)
{
axis2_param_t *param = NULL;
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- param = (axis2_param_t *)(axis2_hash_get (AXIS2_INTF_TO_IMPL(
+ param = (axis2_param_t *)(axis2_hash_get (AXIS2_INTF_TO_IMPL(
param_container)->params, param_name, AXIS2_HASH_KEY_STRING));
if(!param)
{
/* In this case we consider param is not locked */
return AXIS2_FALSE;
- }
- return AXIS2_PARAM_IS_LOCKED(param, env);
+ }
+ return AXIS2_PARAM_IS_LOCKED(param, env);
}
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=411506&r1=411505&r2=411506&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 Sat Jun 3 20:09:08 2006
@@ -21,18 +21,18 @@
axis2_threadattr_create(axis2_allocator_t* allocator)
{
int stat = 0;
- axis2_threadattr_t *new = NULL;
+ axis2_threadattr_t *new = NULL;
new = AXIS2_MALLOC(allocator, sizeof(axis2_threadattr_t));
- if(NULL == new)
- {
- return NULL;
- }
+ if(NULL == new)
+ {
+ return NULL;
+ }
stat = pthread_attr_init(&(new->attr));
if (stat != 0)
- {
- AXIS2_FREE(allocator, new);
+ {
+ AXIS2_FREE(allocator, new);
return NULL;
}
return new;
@@ -44,13 +44,13 @@
{
axis2_threadattr_t *attr = data;
int rv;
-
+
rv = pthread_attr_destroy(&attr->attr);
-
- if(0 != rv)
- {
- return AXIS2_FAILURE;
- }
+
+ if(0 != rv)
+ {
+ return AXIS2_FAILURE;
+ }
return AXIS2_SUCCESS;
}
@@ -60,10 +60,10 @@
axis2_threadattr_detach_set(axis2_threadattr_t *attr, axis2_bool_t detached)
{
if (0 == pthread_attr_setdetachstate(&attr->attr, DETACH_ARG(detached)))
- {
+ {
return AXIS2_SUCCESS;
}
- return AXIS2_FAILURE;
+ return AXIS2_FAILURE;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -72,9 +72,9 @@
int state = 0;
pthread_attr_getdetachstate(&attr->attr, &state);
if (state == 1)
- {
+ {
return AXIS2_TRUE;
- }
+ }
return AXIS2_FALSE;
}
@@ -86,21 +86,21 @@
AXIS2_EXTERN axis2_thread_t* AXIS2_CALL
axis2_thread_create(axis2_allocator_t* allocator, axis2_threadattr_t *attr,
- axis2_thread_start_t func, void *data)
+ axis2_thread_start_t func, void *data)
{
axis2_status_t stat;
pthread_attr_t *temp = NULL;
- axis2_thread_t *new = NULL;
+ axis2_thread_t *new = NULL;
new = (axis2_thread_t *)AXIS2_MALLOC(allocator, sizeof(axis2_thread_t));
if (NULL == new)
- {
+ {
return NULL;
}
new->td = (pthread_t *)AXIS2_MALLOC(allocator, sizeof(pthread_t));
if (NULL == new->td)
- {
+ {
return NULL;
}
@@ -108,16 +108,16 @@
new->func = func;
if (NULL != attr)
- {
+ {
temp = &attr->attr;
- }
+ }
else
- {
+ {
temp = NULL;
- }
+ }
if ((stat = pthread_create(new->td, temp, dummy_worker, new)) == 0)
- {
+ {
return new;
}
return NULL;
@@ -157,17 +157,17 @@
{
void *thread_stat;
if (0 == pthread_join(*thd->td,(void *)&thread_stat))
- {
+ {
return AXIS2_SUCCESS;
}
- return AXIS2_FAILURE;
+ return AXIS2_FAILURE;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_thread_detach(axis2_thread_t *thd)
{
if (0 == pthread_detach(*(thd->td)))
- {
+ {
return AXIS2_SUCCESS;
}
return AXIS2_FAILURE;
@@ -175,17 +175,17 @@
void axis2_thread_yield(void)
{
- return;
+ return;
}
AXIS2_EXTERN axis2_os_thread_t* AXIS2_CALL
axis2_os_thread_get(axis2_thread_t *thd)
{
- if(NULL == thd)
- {
- return NULL;
- }
- return thd->td;
+ if(NULL == thd)
+ {
+ return NULL;
+ }
+ return thd->td;
}
AXIS2_EXTERN axis2_thread_once_t* AXIS2_CALL
@@ -193,11 +193,11 @@
{
static const pthread_once_t once_init = PTHREAD_ONCE_INIT;
axis2_thread_once_t *control = AXIS2_MALLOC(allocator,
- sizeof(axis2_thread_once_t));
- if(NULL == control)
- {
- return NULL;;
- }
+ sizeof(axis2_thread_once_t));
+ if(NULL == control)
+ {
+ return NULL;;
+ }
(control)->once = once_init;
return control;
}
@@ -213,41 +213,41 @@
axis2_thread_mutex_create(axis2_allocator_t *allocator, unsigned int flags)
{
axis2_thread_mutex_t *new_mutex = NULL;
-
+
new_mutex = AXIS2_MALLOC(allocator, sizeof(axis2_thread_mutex_t));
new_mutex->allocator = allocator;
if (pthread_mutex_init(&new_mutex->mutex, NULL) != 0)
- {
- AXIS2_FREE(allocator, new_mutex);
- return NULL;
- }
- return new_mutex;
+ {
+ AXIS2_FREE(allocator, new_mutex);
+ return NULL;
+ }
+ return new_mutex;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_thread_mutex_lock(axis2_thread_mutex_t *mutex)
{
- return pthread_mutex_lock(&mutex->mutex);
+ return pthread_mutex_lock(&mutex->mutex);
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_thread_mutex_unlock(axis2_thread_mutex_t *mutex)
{
if(pthread_mutex_unlock(&mutex->mutex) != 0)
- {
- return AXIS2_FAILURE;
- }
- return AXIS2_SUCCESS;
+ {
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_thread_mutex_destroy(axis2_thread_mutex_t *mutex)
{
- if(0 != pthread_mutex_destroy(&mutex->mutex))
- {
- return AXIS2_FAILURE;
- }
+ if(0 != pthread_mutex_destroy(&mutex->mutex))
+ {
+ return AXIS2_FAILURE;
+ }
AXIS2_FREE(mutex->allocator, mutex);
- return AXIS2_SUCCESS;
+ return AXIS2_SUCCESS;
}
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=411506&r1=411505&r2=411506&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 Sat Jun 3 20:09:08 2006
@@ -40,7 +40,7 @@
#include <platforms/unix/axis2_uuid_gen_unix.h>
#include <platforms/axis2_platform_auto_sense.h>
-
+
/* We need these static variables to track throughout the program execution */
static axis2_bool_t axis2_uuid_gen_is_first = AXIS2_TRUE;
static struct axis2_uuid_st axis2_uuid_static;
@@ -52,19 +52,19 @@
struct timeval time_now;
struct timeval tv;
unsigned long long time_val;
- unsigned long long time_val2;
- unsigned short int clck = 0;
- axis2_uuid_t *ret_uuid = NULL;
- unsigned short int time_high_version = 0;
-
+ unsigned long long time_val2;
+ unsigned short int clck = 0;
+ axis2_uuid_t *ret_uuid = NULL;
+ unsigned short int time_high_version = 0;
+
if(AXIS2_TRUE == axis2_uuid_gen_is_first)
{
char *mac_addr = axis2_uuid_get_mac_addr();
memcpy(axis2_uuid_static.mac, mac_addr, 6);
axis2_uuid_static.time_seq = 0;
axis2_uuid_static.clock = 0;
- free(mac_addr);
- axis2_uuid_gen_is_first = AXIS2_FALSE;
+ free(mac_addr);
+ axis2_uuid_gen_is_first = AXIS2_FALSE;
}
/*
* GENERATE TIME
@@ -77,16 +77,16 @@
/* check whether system time changed since last retrieve */
if(!(time_now.tv_sec == axis2_uuid_static.time_last.tv_sec
&& time_now.tv_usec ==
- axis2_uuid_static.time_last.tv_usec)) {
+ axis2_uuid_static.time_last.tv_usec)) {
/* reset time sequence counter and continue */
axis2_uuid_static.time_seq = 0;
}
/* until we are out of UUIDs per tick, increment
the time/tick sequence counter and continue */
- while(axis2_uuid_static.time_seq < UUIDS_PER_TICK)
- {
- axis2_uuid_static.time_seq++;
+ while(axis2_uuid_static.time_seq < UUIDS_PER_TICK)
+ {
+ axis2_uuid_static.time_seq++;
}
/* sleep for 1000ns (1us) */
tv.tv_sec = 0;
@@ -95,29 +95,29 @@
time_val = (unsigned long long)time_now.tv_sec * 10000000ull;
time_val += (unsigned long long)time_now.tv_usec * 10ull;
-
- ret_uuid = malloc(sizeof(axis2_uuid_t));
-
+
+ ret_uuid = malloc(sizeof(axis2_uuid_t));
+
time_val += UUID_TIMEOFFSET;
/* compensate for low resolution system clock by adding
the time/tick sequence counter */
if (axis2_uuid_static.time_seq > 0)
time_val += (unsigned long long)axis2_uuid_static.time_seq;
-
- time_val2 = time_val;
- ret_uuid->time_low = (unsigned long)time_val2;
- time_val2 >>= 32;
- ret_uuid->time_mid = (unsigned short int)time_val2;
- time_val2 >>= 16;
- 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;
- time_high_version &= 0xFFF0;
- time_high_version |= 0x0001;
- ret_uuid->time_high_version = time_high_version;
-
- /*
+
+ time_val2 = time_val;
+ ret_uuid->time_low = (unsigned long)time_val2;
+ time_val2 >>= 32;
+ ret_uuid->time_mid = (unsigned short int)time_val2;
+ time_val2 >>= 16;
+ 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;
+ time_high_version &= 0xFFF0;
+ time_high_version |= 0x0001;
+ ret_uuid->time_high_version = time_high_version;
+
+ /*
* GENERATE CLOCK
*/
@@ -127,24 +127,24 @@
/* 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 < axis2_uuid_static.time_last.tv_sec ||
- (time_now.tv_sec == axis2_uuid_static.time_last.tv_sec
- && time_now.tv_usec <
- axis2_uuid_static.time_last.tv_usec)))
- {
- srand(time_now.tv_usec);
- clck = rand();
- }
+ (time_now.tv_sec == axis2_uuid_static.time_last.tv_sec
+ && time_now.tv_usec <
+ axis2_uuid_static.time_last.tv_usec)))
+ {
+ srand(time_now.tv_usec);
+ clck = rand();
+ }
else
- {
+ {
clck++;
- }
+ }
clck %= (2<<14);
/* store back new clock sequence */
axis2_uuid_static.clock = clck;
-
+
clck &= 0x1FFF;
- clck |= 0x2000;
+ clck |= 0x2000;
/*
* FINISH
@@ -152,76 +152,76 @@
/* remember current system time for next iteration */
axis2_uuid_static.time_last.tv_sec = time_now.tv_sec;
axis2_uuid_static.time_last.tv_usec = time_now.tv_usec;
-
- if(NULL == ret_uuid)
- {
- return NULL;
- }
- ret_uuid->clock_variant = clck;
- memcpy(ret_uuid->mac_addr, axis2_uuid_static.mac, 6);
- return ret_uuid;
+
+ if(NULL == ret_uuid)
+ {
+ return NULL;
+ }
+ ret_uuid->clock_variant = clck;
+ memcpy(ret_uuid->mac_addr, axis2_uuid_static.mac, 6);
+ return ret_uuid;
}
axis2_char_t* AXIS2_CALL
axis2_platform_uuid_gen(char *s)
{
- axis2_uuid_t *uuid_struct = NULL;
- axis2_char_t *uuid_str = NULL;
- unsigned char mac[7];
- char mac_hex[13];
+ axis2_uuid_t *uuid_struct = NULL;
+ axis2_char_t *uuid_str = NULL;
+ unsigned char mac[7];
+ char mac_hex[13];
if(NULL == s)
{
return NULL;
- }
- uuid_struct = axis2_uuid_gen_v1();
- if(NULL == uuid_struct)
- {
- return NULL;
- }
- uuid_str = s;
- if(NULL == 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);
+ }
+ uuid_struct = axis2_uuid_gen_v1();
+ if(NULL == uuid_struct)
+ {
+ return NULL;
+ }
+ uuid_str = s;
+ if(NULL == 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);
free(uuid_struct);
uuid_struct = NULL;
- return uuid_str;
+ return uuid_str;
}
#ifdef HAVE_LINUX_IF_H
char * AXIS2_CALL
axis2_uuid_get_mac_addr()
{
- struct ifreq ifr;
- struct sockaddr *sa;
- int s = 0;
- int i = 0;
- char *buffer = NULL;
-
-
- if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
- return NULL;
- sprintf(ifr.ifr_name, "eth0");
- if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
- {
- close(s);
- return NULL;
- }
- buffer = (char*)malloc(6*sizeof(char));
-
- sa = (struct sockaddr *)&ifr.ifr_addr;
- for (i = 0; i < 6; i++)
- buffer[i] = (unsigned char)(sa->sa_data[i] & 0xff);
- close(s);
- return buffer;
+ struct ifreq ifr;
+ struct sockaddr *sa;
+ int s = 0;
+ int i = 0;
+ char *buffer = NULL;
+
+
+ if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
+ return NULL;
+ sprintf(ifr.ifr_name, "eth0");
+ if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
+ {
+ close(s);
+ return NULL;
+ }
+ buffer = (char*)malloc(6*sizeof(char));
+
+ sa = (struct sockaddr *)&ifr.ifr_addr;
+ for (i = 0; i < 6; i++)
+ buffer[i] = (unsigned char)(sa->sa_data[i] & 0xff);
+ close(s);
+ return buffer;
}
#else
@@ -231,63 +231,63 @@
char * AXIS2_CALL
axis2_uuid_get_mac_addr()
{
- unsigned char eth_addr[6];
- int sock;
- int i;
- struct lifconf lic;
- struct lifreq *lifrs;
- struct lifnum num;
-
- /* How many interfaces do we have? */
- sock=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
- num.lifn_family=AF_INET;
- num.lifn_flags=0;
- ioctl(sock,SIOCGLIFNUM,&num);
-
- /* get details of the interfaces */
- lifrs = malloc( (num.lifn_count + 1) * sizeof(*lifrs));
- if (NULL == lifrs) {
- exit(1); /* what is the right error handling here ? */
- }
- lic.lifc_family=AF_INET;
- lic.lifc_flags=0;
- lic.lifc_len=sizeof(lifrs);
- lic.lifc_buf=(caddr_t)lifrs;
- ioctl(sock,SIOCGLIFCONF,&lic);
-
- /* Get the ethernet address for each of them */
- for(i=0;i<num.lifn_count;i++)
- {
- struct sockaddr_in *soapip,*soapmac;
- struct arpreq ar;
-
- /* Get IP address of interface i */
- ioctl(sock,SIOCGLIFADDR,&(lifrs[ i ]));
- soapip=(struct sockaddr_in *)&(lifrs[ i ].lifr_addr);
-
-
- /* Get ethernet address */
- soapmac=(struct sockaddr_in *)&(ar.arp_pa);
- *soapmac=*soapip;
-
- if(ioctl(sock,SIOCGARP,&ar) == 0)
- {
- int j;
- char *buffer = malloc(6);
-
- if (buffer) {
- for (j = 0 ; j < 6 ; ++j) {
- buffer[j] = ((unsigned char *)&(ar.arp_ha.sa_data))[j];
- }
- }
- close(sock);
- free(lifrs);
- return buffer;
- }
- }
- close(sock);
- free(lifrs);
- return NULL;
+ unsigned char eth_addr[6];
+ int sock;
+ int i;
+ struct lifconf lic;
+ struct lifreq *lifrs;
+ struct lifnum num;
+
+ /* How many interfaces do we have? */
+ sock=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
+ num.lifn_family=AF_INET;
+ num.lifn_flags=0;
+ ioctl(sock,SIOCGLIFNUM,&num);
+
+ /* get details of the interfaces */
+ lifrs = malloc( (num.lifn_count + 1) * sizeof(*lifrs));
+ if (NULL == lifrs) {
+ exit(1); /* what is the right error handling here ? */
+ }
+ lic.lifc_family=AF_INET;
+ lic.lifc_flags=0;
+ lic.lifc_len=sizeof(lifrs);
+ lic.lifc_buf=(caddr_t)lifrs;
+ ioctl(sock,SIOCGLIFCONF,&lic);
+
+ /* Get the ethernet address for each of them */
+ for(i=0;i<num.lifn_count;i++)
+ {
+ struct sockaddr_in *soapip,*soapmac;
+ struct arpreq ar;
+
+ /* Get IP address of interface i */
+ ioctl(sock,SIOCGLIFADDR,&(lifrs[ i ]));
+ soapip=(struct sockaddr_in *)&(lifrs[ i ].lifr_addr);
+
+
+ /* Get ethernet address */
+ soapmac=(struct sockaddr_in *)&(ar.arp_pa);
+ *soapmac=*soapip;
+
+ if(ioctl(sock,SIOCGARP,&ar) == 0)
+ {
+ int j;
+ char *buffer = malloc(6);
+
+ if (buffer) {
+ for (j = 0 ; j < 6 ; ++j) {
+ buffer[j] = ((unsigned char *)&(ar.arp_ha.sa_data))[j];
+ }
+ }
+ close(sock);
+ free(lifrs);
+ return buffer;
+ }
+ }
+ close(sock);
+ free(lifrs);
+ return NULL;
}
#endif
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/axis2_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/axis2_windows.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/axis2_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/axis2_windows.c Sat Jun 3 20:09:08 2006
@@ -22,21 +22,21 @@
std::string* getPlatformErrorMessage(long errorNumber)
{
- std::string* returningString = new std::string();
+ std::string* returningString = new std::string();
LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errorNumber,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL );
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errorNumber,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL );
- returningString->append((LPTSTR)lpMsgBuf);
+ returningString->append((LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
-
+
return returningString;
}
*/
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/dir_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/dir_windows.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/dir_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/dir_windows.c Sat Jun 3 20:09:08 2006
@@ -25,216 +25,216 @@
DIR * AXIS2_CALL opendir(const char *_dirname)
{
- DIR *dirp;
- char *filespec;
- long handle;
- int index;
-
- filespec = malloc(strlen(_dirname) + 2 + 1);
- strcpy(filespec, _dirname);
- index = (int)strlen(filespec) - 1;
- if (index >= 0 && (filespec[index] == '/' ||
- (filespec[index] == '\\' && !IsDBCSLeadByte(filespec[index-1]))))
- filespec[index] = '\0';
- strcat(filespec, "/*");
-
- dirp = (DIR *) malloc(sizeof(DIR));
- dirp->offset = 0;
- dirp->finished = 0;
-
- if ((handle = _findfirst(filespec, &(dirp->fileinfo))) < 0)
- {
- if (errno == ENOENT || errno == EINVAL)
- dirp->finished = 1;
- else
- {
- free(dirp);
- free(filespec);
- return NULL;
- }
- }
- dirp->dirname = strdup(_dirname);
- dirp->handle = handle;
- free(filespec);
+ DIR *dirp;
+ char *filespec;
+ long handle;
+ int index;
+
+ filespec = malloc(strlen(_dirname) + 2 + 1);
+ strcpy(filespec, _dirname);
+ index = (int)strlen(filespec) - 1;
+ if (index >= 0 && (filespec[index] == '/' ||
+ (filespec[index] == '\\' && !IsDBCSLeadByte(filespec[index-1]))))
+ filespec[index] = '\0';
+ strcat(filespec, "/*");
+
+ dirp = (DIR *) malloc(sizeof(DIR));
+ dirp->offset = 0;
+ dirp->finished = 0;
+
+ if ((handle = _findfirst(filespec, &(dirp->fileinfo))) < 0)
+ {
+ if (errno == ENOENT || errno == EINVAL)
+ dirp->finished = 1;
+ else
+ {
+ free(dirp);
+ free(filespec);
+ return NULL;
+ }
+ }
+ dirp->dirname = strdup(_dirname);
+ dirp->handle = handle;
+ free(filespec);
- return dirp;
+ return dirp;
}
int AXIS2_CALL closedir(DIR *_dirp)
{
- int iret = -1;
- if (!_dirp)
- return iret;
- iret = _findclose(_dirp->handle);
- if (iret == 0 && _dirp->dirname)
- free(_dirp->dirname);
- if (iret == 0 && _dirp)
- free(_dirp);
+ int iret = -1;
+ if (!_dirp)
+ return iret;
+ iret = _findclose(_dirp->handle);
+ if (iret == 0 && _dirp->dirname)
+ free(_dirp->dirname);
+ if (iret == 0 && _dirp)
+ free(_dirp);
- return iret;
+ return iret;
}
struct dirent * AXIS2_CALL readdir(DIR *_dirp)
{
- if (!_dirp || _dirp->finished)
- return NULL;
+ if (!_dirp || _dirp->finished)
+ return NULL;
- if (_dirp->offset != 0)
- {
- if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
- {
- _dirp->finished = 1;
- return NULL;
- }
- }
- _dirp->offset++;
-
- strcpy(_dirp->dent.d_name, _dirp->fileinfo.name);/*, _MAX_FNAME+1);*/
- _dirp->dent.d_ino = 1;
- _dirp->dent.d_reclen = (unsigned short)strlen(_dirp->dent.d_name);
- _dirp->dent.d_off = _dirp->offset;
+ if (_dirp->offset != 0)
+ {
+ if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
+ {
+ _dirp->finished = 1;
+ return NULL;
+ }
+ }
+ _dirp->offset++;
+
+ strcpy(_dirp->dent.d_name, _dirp->fileinfo.name);/*, _MAX_FNAME+1);*/
+ _dirp->dent.d_ino = 1;
+ _dirp->dent.d_reclen = (unsigned short)strlen(_dirp->dent.d_name);
+ _dirp->dent.d_off = _dirp->offset;
- return &(_dirp->dent);
+ return &(_dirp->dent);
}
int AXIS2_CALL readdir_r(DIR *_dirp, struct dirent *_entry, struct dirent **__result)
{
- if (!_dirp || _dirp->finished)
- {
- *__result = NULL;
- return -1;
- }
-
- if (_dirp->offset != 0)
- {
- if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
- {
- _dirp->finished = 1;
- *__result = NULL;
- return -1;
- }
- }
- _dirp->offset++;
-
- strcpy(_dirp->dent.d_name, _dirp->fileinfo.name);/*, _MAX_FNAME+1);*/
- _dirp->dent.d_ino = 1;
- _dirp->dent.d_reclen = (unsigned short)strlen(_dirp->dent.d_name);
- _dirp->dent.d_off = _dirp->offset;
+ if (!_dirp || _dirp->finished)
+ {
+ *__result = NULL;
+ return -1;
+ }
+
+ if (_dirp->offset != 0)
+ {
+ if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
+ {
+ _dirp->finished = 1;
+ *__result = NULL;
+ return -1;
+ }
+ }
+ _dirp->offset++;
+
+ strcpy(_dirp->dent.d_name, _dirp->fileinfo.name);/*, _MAX_FNAME+1);*/
+ _dirp->dent.d_ino = 1;
+ _dirp->dent.d_reclen = (unsigned short)strlen(_dirp->dent.d_name);
+ _dirp->dent.d_off = _dirp->offset;
- memcpy(_entry, &_dirp->dent, sizeof(*_entry));
+ memcpy(_entry, &_dirp->dent, sizeof(*_entry));
- *__result = &_dirp->dent;
+ *__result = &_dirp->dent;
- return 0;
+ return 0;
}
int AXIS2_CALL rewinddir(DIR *dirp)
{
- char *filespec;
- long handle;
- int index;
-
- _findclose(dirp->handle);
-
- dirp->offset = 0;
- dirp->finished = 0;
-
- filespec = malloc(strlen(dirp->dirname) + 2 + 1);
- strcpy(filespec, dirp->dirname);
- index = (int)(strlen(filespec) - 1);
- if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
- filespec[index] = '\0';
- strcat(filespec, "/*");
-
- if ((handle = _findfirst(filespec, &(dirp->fileinfo))) < 0)
- {
- if (errno == ENOENT || errno == EINVAL)
- dirp->finished = 1;
- }
- dirp->handle = handle;
- free(filespec);
+ char *filespec;
+ long handle;
+ int index;
+
+ _findclose(dirp->handle);
+
+ dirp->offset = 0;
+ dirp->finished = 0;
+
+ filespec = malloc(strlen(dirp->dirname) + 2 + 1);
+ strcpy(filespec, dirp->dirname);
+ index = (int)(strlen(filespec) - 1);
+ if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
+ filespec[index] = '\0';
+ strcat(filespec, "/*");
+
+ if ((handle = _findfirst(filespec, &(dirp->fileinfo))) < 0)
+ {
+ if (errno == ENOENT || errno == EINVAL)
+ dirp->finished = 1;
+ }
+ dirp->handle = handle;
+ free(filespec);
- return 0;
+ return 0;
}
AXIS2_DECLARE_DATA int alphasort(const struct dirent **__d1, const struct dirent **__d2)
{
- return strcoll((*__d1)->d_name,(*__d2)->d_name);
+ return strcoll((*__d1)->d_name,(*__d2)->d_name);
}
int AXIS2_CALL scandir(const char *_dirname, struct dirent **__namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **__d1, const struct dirent **__d2))
{
- DIR *dirp = NULL;
- struct dirent **vector = NULL;
- struct dirent *dp = NULL;
- int vector_size = 0;
- int nfiles = 0;
-
- if (__namelist == NULL)
- {
- return -1;
- }
-
- if (!(dirp = opendir(_dirname)))
- {
- return -1;
- }
-
- while ((dp = readdir(dirp)) != NULL)
- {
- int dsize = 0;
- struct dirent *newdp = NULL;
-
- if (selector && (*selector)(dp) == 0)
- {
- continue;
- }
-
- if (nfiles == vector_size)
- {
- struct dirent **newv;
- if (vector_size == 0)
- {
- vector_size = 10;
- }
- else
- {
- vector_size *= 2;
- }
-
- newv = (struct dirent **) realloc (vector, vector_size * sizeof (struct dirent *));
- if (!newv) {
- return -1;
- }
- vector = newv;
- }
-
- dsize = (int)sizeof (struct dirent) + (int)((strlen(dp->d_name) + 1) * sizeof(char));
- newdp = (struct dirent *) malloc(dsize);
-
- if (newdp == NULL)
- {
- while (nfiles-- > 0)
- {
- free(vector[nfiles]);
- }
- free(vector);
- return -1;
- }
-
- vector[nfiles++] = (struct dirent *) memcpy(newdp, dp, dsize);
- }
-
- closedir(dirp);
-
- *__namelist = vector;
-
- if (compare)
- {
- qsort (*__namelist, nfiles, sizeof(struct dirent *), compare);
- }
+ DIR *dirp = NULL;
+ struct dirent **vector = NULL;
+ struct dirent *dp = NULL;
+ int vector_size = 0;
+ int nfiles = 0;
+
+ if (__namelist == NULL)
+ {
+ return -1;
+ }
+
+ if (!(dirp = opendir(_dirname)))
+ {
+ return -1;
+ }
+
+ while ((dp = readdir(dirp)) != NULL)
+ {
+ int dsize = 0;
+ struct dirent *newdp = NULL;
+
+ if (selector && (*selector)(dp) == 0)
+ {
+ continue;
+ }
+
+ if (nfiles == vector_size)
+ {
+ struct dirent **newv;
+ if (vector_size == 0)
+ {
+ vector_size = 10;
+ }
+ else
+ {
+ vector_size *= 2;
+ }
+
+ newv = (struct dirent **) realloc (vector, vector_size * sizeof (struct dirent *));
+ if (!newv) {
+ return -1;
+ }
+ vector = newv;
+ }
+
+ dsize = (int)sizeof (struct dirent) + (int)((strlen(dp->d_name) + 1) * sizeof(char));
+ newdp = (struct dirent *) malloc(dsize);
+
+ if (newdp == NULL)
+ {
+ while (nfiles-- > 0)
+ {
+ free(vector[nfiles]);
+ }
+ free(vector);
+ return -1;
+ }
+
+ vector[nfiles++] = (struct dirent *) memcpy(newdp, dp, dsize);
+ }
+
+ closedir(dirp);
+
+ *__namelist = vector;
+
+ if (compare)
+ {
+ qsort (*__namelist, nfiles, sizeof(struct dirent *), compare);
+ }
- return nfiles;
+ return nfiles;
}
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/getopt_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/getopt_windows.c?rev=411506&r1=411505&r2=411506&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/getopt_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/getopt_windows.c Sat Jun 3 20:09:08 2006
@@ -4,96 +4,96 @@
#include <platforms/windows/axis2_getopt_windows.h>
-int opterr = 1; /*default - log error*/
-int optind = 1;
-int optopt;
-char* optarg;
-
-#define AXIS2_OPT_ERR_NO_ARG 1
-#define AXIS2_OPT_ERR_INVALID_OPTION 2
-#define AXIS2_OPT_ERR_BAD_ARG 3
+int opterr = 1; /*default - log error*/
+int optind = 1;
+int optopt;
+char* optarg;
+
+#define AXIS2_OPT_ERR_NO_ARG 1
+#define AXIS2_OPT_ERR_INVALID_OPTION 2
+#define AXIS2_OPT_ERR_BAD_ARG 3
int _axis2_opt_error(int __optopt, int __err, int __showerr)
{
- switch(__err)
- {
- case AXIS2_OPT_ERR_NO_ARG:
- if (__showerr)
- fprintf(stderr," option requires an argument -- %c\n", __optopt);
- break;
- case AXIS2_OPT_ERR_INVALID_OPTION:
- if (__showerr)
- fprintf(stderr," illegal option -- %c\n", __optopt);
- break;
- case AXIS2_OPT_ERR_BAD_ARG:
- return (int)':';
- default:
- if (__showerr)
- fprintf(stderr, "unknown\n");
- }
- return (int)'?';
+ switch(__err)
+ {
+ case AXIS2_OPT_ERR_NO_ARG:
+ if (__showerr)
+ fprintf(stderr," option requires an argument -- %c\n", __optopt);
+ break;
+ case AXIS2_OPT_ERR_INVALID_OPTION:
+ if (__showerr)
+ fprintf(stderr," illegal option -- %c\n", __optopt);
+ break;
+ case AXIS2_OPT_ERR_BAD_ARG:
+ return (int)':';
+ default:
+ if (__showerr)
+ fprintf(stderr, "unknown\n");
+ }
+ return (int)'?';
}
AXIS2_EXTERN int AXIS2_CALL
axis2_getopt(int __argc, char * const *__argv, const char *__shortopts)
{
- static char *pos = "";
- char *olstindex;
+ static char *pos = "";
+ char *olstindex;
- if (!*pos)
- {
- /* no option or invalid option*/
- if (optind >= __argc || *(pos = __argv[optind]) != '-')
- {
- pos = "";
- return -1;
- }
- /*-- option*/
- if (pos[1] && *++pos == '-')
- {
- ++optind;
- pos = "";
- return -1;
- }
- }
-
- if ((optopt = (int)*pos++) == (int)':' ||
- !(olstindex = strchr(__shortopts, optopt)))
- {
-
- if (optopt == (int)'-')
- return -1;
- if (!*pos)
- ++optind;
- if (*__shortopts != ':')
- return _axis2_opt_error(optopt,AXIS2_OPT_ERR_BAD_ARG,opterr);
- _axis2_opt_error(optopt,AXIS2_OPT_ERR_INVALID_OPTION,opterr);
- }
-
- if (*++olstindex != ':')
- {
- optarg = NULL;
- if (!*pos)
- ++optind;
- }
- else
- {
- if (*pos)
- optarg = pos;
- else if (__argc <= ++optind)
- {
- pos = "";
- if (*__shortopts == ':')
- return _axis2_opt_error(-1,AXIS2_OPT_ERR_BAD_ARG,opterr);
- return _axis2_opt_error(optopt,AXIS2_OPT_ERR_NO_ARG,opterr);
- }
- else
- optarg = __argv[optind];
- pos = "";
- ++optind;
- }
- return optopt;
+ if (!*pos)
+ {
+ /* no option or invalid option*/
+ if (optind >= __argc || *(pos = __argv[optind]) != '-')
+ {
+ pos = "";
+ return -1;
+ }
+ /*-- option*/
+ if (pos[1] && *++pos == '-')
+ {
+ ++optind;
+ pos = "";
+ return -1;
+ }
+ }
+
+ if ((optopt = (int)*pos++) == (int)':' ||
+ !(olstindex = strchr(__shortopts, optopt)))
+ {
+
+ if (optopt == (int)'-')
+ return -1;
+ if (!*pos)
+ ++optind;
+ if (*__shortopts != ':')
+ return _axis2_opt_error(optopt,AXIS2_OPT_ERR_BAD_ARG,opterr);
+ _axis2_opt_error(optopt,AXIS2_OPT_ERR_INVALID_OPTION,opterr);
+ }
+
+ if (*++olstindex != ':')
+ {
+ optarg = NULL;
+ if (!*pos)
+ ++optind;
+ }
+ else
+ {
+ if (*pos)
+ optarg = pos;
+ else if (__argc <= ++optind)
+ {
+ pos = "";
+ if (*__shortopts == ':')
+ return _axis2_opt_error(-1,AXIS2_OPT_ERR_BAD_ARG,opterr);
+ return _axis2_opt_error(optopt,AXIS2_OPT_ERR_NO_ARG,opterr);
+ }
+ else
+ optarg = __argv[optind];
+ pos = "";
+ ++optind;
+ }
+ return optopt;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org