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 [4/5] - in /webservices/axis2/trunk/c/util/src: ./
platforms/unix/ platforms/windows/
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/date_time_util_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/date_time_util_windows.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/date_time_util_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/date_time_util_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
@@ -19,8 +18,7 @@
#include <platforms/windows/axutil_date_time_util_windows.h>
AXIS2_EXTERN int AXIS2_CALL
-axis2_platform_get_milliseconds(
- )
+axis2_platform_get_milliseconds()
{
struct _timeb timebuffer;
char *timeline;
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=805365&r1=805364&r2=805365&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 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
@@ -35,21 +34,20 @@
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]))))
+ index = (int)strlen(filespec) - 1;
+ if(index >= 0 && (filespec[index] == '/' || (filespec[index] == '\\' && !IsDBCSLeadByte(
+ filespec[index - 1]))))
filespec[index] = '\0';
strcat(filespec, "/*");
- dirp = (AXIS2_DIR *) malloc(sizeof(AXIS2_DIR));
+ dirp = (AXIS2_DIR *)malloc(sizeof(AXIS2_DIR));
dirp->offset = 0;
dirp->finished = 0;
- if ((handle = (long)_findfirst(filespec, &(dirp->fileinfo))) < 0)
- /* We are sure that the difference lies within the long range */
+ if((handle = (long)_findfirst(filespec, &(dirp->fileinfo))) < 0)
+ /* We are sure that the difference lies within the long range */
{
- if (errno == ENOENT || errno == EINVAL)
+ if(errno == ENOENT || errno == EINVAL)
dirp->finished = 1;
else
{
@@ -71,12 +69,12 @@
AXIS2_DIR * _dirp)
{
int iret = -1;
- if (!_dirp)
+ if(!_dirp)
return iret;
iret = _findclose(_dirp->handle);
- if (_dirp->dirname)
+ if(_dirp->dirname)
free(_dirp->dirname);
- if (_dirp)
+ if(_dirp)
free(_dirp);
return iret;
@@ -86,12 +84,12 @@
axis2_readdir(
AXIS2_DIR * _dirp)
{
- if (!_dirp || _dirp->finished)
+ if(!_dirp || _dirp->finished)
return NULL;
- if (_dirp->offset != 0)
+ if(_dirp->offset != 0)
{
- if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
+ if(_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
{
_dirp->finished = 1;
return NULL;
@@ -99,9 +97,9 @@
}
_dirp->offset++;
- strcpy(_dirp->dent.d_name, _dirp->fileinfo.name); /*, _MAX_FNAME+1); */
+ 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_reclen = (unsigned short)strlen(_dirp->dent.d_name);
_dirp->dent.d_off = _dirp->offset;
return &(_dirp->dent);
@@ -113,15 +111,15 @@
struct dirent *_entry,
struct dirent **__result)
{
- if (!_dirp || _dirp->finished)
+ if(!_dirp || _dirp->finished)
{
*__result = NULL;
return -1;
}
- if (_dirp->offset != 0)
+ if(_dirp->offset != 0)
{
- if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
+ if(_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0)
{
_dirp->finished = 1;
*__result = NULL;
@@ -130,9 +128,9 @@
}
_dirp->offset++;
- strcpy(_dirp->dent.d_name, _dirp->fileinfo.name); /*, _MAX_FNAME+1); */
+ 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_reclen = (unsigned short)strlen(_dirp->dent.d_name);
_dirp->dent.d_off = _dirp->offset;
memcpy(_entry, &_dirp->dent, sizeof(*_entry));
@@ -157,15 +155,15 @@
filespec = malloc(strlen(dirp->dirname) + 2 + 1);
strcpy(filespec, dirp->dirname);
- index = (int) (strlen(filespec) - 1);
- if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
+ index = (int)(strlen(filespec) - 1);
+ if(index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
filespec[index] = '\0';
strcat(filespec, "/*");
- if ((handle = (long)_findfirst(filespec, &(dirp->fileinfo))) < 0)
- /* We are sure that the difference lies within the int range */
+ if((handle = (long)_findfirst(filespec, &(dirp->fileinfo))) < 0)
+ /* We are sure that the difference lies within the int range */
{
- if (errno == ENOENT || errno == EINVAL)
+ if(errno == ENOENT || errno == EINVAL)
dirp->finished = 1;
}
dirp->handle = handle;
@@ -186,9 +184,13 @@
axis2_scandir(
const char *_dirname,
struct dirent **__namelist[],
- int (*selector) (const struct dirent * entry),
- int (*compare) (const struct dirent ** __d1,
- const struct dirent ** __d2))
+ int
+ (*selector)(
+ const struct dirent * entry),
+ int
+ (*compare)(
+ const struct dirent ** __d1,
+ const struct dirent ** __d2))
{
AXIS2_DIR *dirp = NULL;
struct dirent **vector = NULL;
@@ -196,31 +198,31 @@
int vector_size = 0;
int nfiles = 0;
- if (__namelist == NULL)
+ if(__namelist == NULL)
{
return -1;
}
dirp = axis2_opendir(_dirname);
- if (!dirp)
+ if(!dirp)
{
return -1;
}
dp = axis2_readdir(dirp);
- while (dp)
+ while(dp)
{
int dsize = 0;
struct dirent *newdp = NULL;
- if (selector && (*selector) (dp) == 0)
+ if(selector && (*selector)(dp) == 0)
{
dp = axis2_readdir(dirp);
continue;
}
- if (nfiles == vector_size)
+ if(nfiles == vector_size)
{
struct dirent **newv;
- if (vector_size == 0)
+ if(vector_size == 0)
{
vector_size = 10;
}
@@ -229,11 +231,8 @@
vector_size *= 2;
}
- newv =
- (struct dirent **) realloc(vector,
- vector_size *
- sizeof(struct dirent *));
- if (!newv)
+ newv = (struct dirent **)realloc(vector, vector_size * sizeof(struct dirent *));
+ if(!newv)
{
return -1;
}
@@ -241,14 +240,14 @@
}
/*dsize =
- (int) sizeof(struct dirent) +
- (int) ((strlen(dp->d_name) + 1) * sizeof(char));*/
- dsize = (int) sizeof(struct dirent);
- newdp = (struct dirent *) malloc(dsize);
+ (int) sizeof(struct dirent) +
+ (int) ((strlen(dp->d_name) + 1) * sizeof(char));*/
+ dsize = (int)sizeof(struct dirent);
+ newdp = (struct dirent *)malloc(dsize);
- if (newdp == NULL)
+ if(newdp == NULL)
{
- while (nfiles-- > 0)
+ while(nfiles-- > 0)
{
free(vector[nfiles]);
}
@@ -256,7 +255,7 @@
return -1;
}
- vector[nfiles++] = (struct dirent *) memcpy(newdp, dp, dsize);
+ vector[nfiles++] = (struct dirent *)memcpy(newdp, dp, dsize);
dp = axis2_readdir(dirp);
}
@@ -264,7 +263,7 @@
*__namelist = vector;
- if (compare)
+ if(compare)
{
qsort(*__namelist, nfiles, sizeof(struct dirent *), compare);
}
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=805365&r1=805364&r2=805365&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 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
@@ -41,45 +40,45 @@
int __err,
int __showerr)
{
- switch (__err)
+ 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");
+ 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) '?';
+ return (int)'?';
}
AXIS2_EXTERN int AXIS2_CALL
axis2_getopt(
int __argc,
- char *const *__argv,
+ char * const *__argv,
const char *__shortopts)
{
static char *pos = "";
char *olstindex = NULL;
- if (!*pos)
+ if(!*pos)
{
/* no option or invalid option */
- if (optind >= __argc || *(pos = __argv[optind]) != '-')
+ if(optind >= __argc || *(pos = __argv[optind]) != '-')
{
pos = "";
return -1;
}
/*-- option*/
- if (pos[1] && *++pos == '-')
+ if(pos[1] && *++pos == '-')
{
++optind;
pos = "";
@@ -87,45 +86,45 @@
}
}
- if ((optopt = (int) *pos++) == (int) ':')
+ if((optopt = (int)*pos++) == (int)':')
{
- if (optopt == (int) '-')
+ if(optopt == (int)'-')
return -1;
- if (!*pos)
+ if(!*pos)
++optind;
- if (*__shortopts != ':')
+ if(*__shortopts != ':')
return _axis2_opt_error(optopt, AXIS2_OPT_ERR_BAD_ARG, opterr);
_axis2_opt_error(optopt, AXIS2_OPT_ERR_INVALID_OPTION, opterr);
}
else
{
olstindex = strchr(__shortopts, optopt);
- if (!olstindex)
+ if(!olstindex)
{
- if (optopt == (int) '-')
+ if(optopt == (int)'-')
return -1;
- if (!*pos)
+ if(!*pos)
++optind;
- if (*__shortopts != ':')
+ 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 || *++olstindex != ':')
+ if(!olstindex || *++olstindex != ':')
{
optarg = NULL;
- if (!*pos)
+ if(!*pos)
++optind;
}
else
{
- if (*pos)
+ if(*pos)
optarg = pos;
- else if (__argc <= ++optind)
+ else if(__argc <= ++optind)
{
pos = "";
- if (*__shortopts == ':')
+ if(*__shortopts == ':')
return _axis2_opt_error(-1, AXIS2_OPT_ERR_BAD_ARG, opterr);
return _axis2_opt_error(optopt, AXIS2_OPT_ERR_NO_ARG, opterr);
}
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/thread_mutex_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/thread_mutex_windows.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/thread_mutex_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/thread_mutex_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
@@ -25,19 +24,19 @@
{
axutil_thread_mutex_t *lock = NULL;
axutil_allocator_t *allocator = NULL;
- if (!data)
+ if(!data)
return AXIS2_FAILURE;
- lock = (axutil_thread_mutex_t *) data;
+ lock = (axutil_thread_mutex_t *)data;
allocator = lock->allocator;
- if (lock->type == thread_mutex_critical_section)
+ if(lock->type == thread_mutex_critical_section)
{
DeleteCriticalSection(&lock->section);
}
else
{
- if (!CloseHandle(lock->handle))
+ if(!CloseHandle(lock->handle))
{
return AXIS2_FAILURE;
}
@@ -54,12 +53,10 @@
{
axutil_thread_mutex_t *mutex = NULL;
- mutex =
- (axutil_thread_mutex_t *) AXIS2_MALLOC(allocator,
- sizeof(axutil_thread_mutex_t));
+ mutex = (axutil_thread_mutex_t *)AXIS2_MALLOC(allocator, sizeof(axutil_thread_mutex_t));
mutex->allocator = allocator;
- if (flags == AXIS2_THREAD_MUTEX_DEFAULT) /*unnested */
+ if(flags == AXIS2_THREAD_MUTEX_DEFAULT) /*unnested */
{
/* Use an auto-reset signaled event, ready to accept one
* waiting thread.
@@ -79,14 +76,14 @@
axutil_thread_mutex_lock(
axutil_thread_mutex_t * mutex)
{
- if (mutex->type == thread_mutex_critical_section)
+ if(mutex->type == thread_mutex_critical_section)
{
EnterCriticalSection(&mutex->section);
}
else
{
DWORD rv = WaitForSingleObject(mutex->handle, INFINITE);
- if ((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED))
+ if((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED))
{
return AXIS2_FAILURE;
/*can be either BUSY or an os specific error */
@@ -100,14 +97,14 @@
axutil_thread_mutex_t * mutex)
{
- if (mutex->type == thread_mutex_critical_section)
+ if(mutex->type == thread_mutex_critical_section)
{
/* TODO :implement trylock for critical section */
}
else
{
DWORD rv = WaitForSingleObject(mutex->handle, 0);
- if ((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED))
+ if((rv != WAIT_OBJECT_0) && (rv != WAIT_ABANDONED))
{
/*can be either BUSY or an os specific error */
return AXIS2_FAILURE;
@@ -120,21 +117,21 @@
axutil_thread_mutex_unlock(
axutil_thread_mutex_t * mutex)
{
- if (mutex->type == thread_mutex_critical_section)
+ if(mutex->type == thread_mutex_critical_section)
{
LeaveCriticalSection(&mutex->section);
}
- else if (mutex->type == thread_mutex_unnested_event)
+ else if(mutex->type == thread_mutex_unnested_event)
{
- if (!SetEvent(mutex->handle))
+ if(!SetEvent(mutex->handle))
{
/*os specific error */
return AXIS2_FAILURE;
}
}
- else if (mutex->type == thread_mutex_nested_mutex)
+ else if(mutex->type == thread_mutex_nested_mutex)
{
- if (!ReleaseMutex(mutex->handle))
+ if(!ReleaseMutex(mutex->handle))
{
/*os specific error */
return AXIS2_FAILURE;
@@ -147,5 +144,5 @@
axutil_thread_mutex_destroy(
axutil_thread_mutex_t * mutex)
{
- return thread_mutex_cleanup((void *) mutex);
+ return thread_mutex_cleanup((void *)mutex);
}
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/thread_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/thread_windows.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/thread_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/thread_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
@@ -28,7 +27,7 @@
axutil_threadattr_t *new = NULL;
new = AXIS2_MALLOC(allocator, sizeof(axutil_threadattr_t));
- if (!new)
+ if(!new)
{
/*AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE) */
return NULL;
@@ -63,7 +62,7 @@
axutil_threadattr_t * attr,
const axutil_env_t * env)
{
- if (1 == attr->detach)
+ if(1 == attr->detach)
{
return AXIS2_TRUE;
}
@@ -83,7 +82,7 @@
dummy_worker(
void *opaque)
{
- axutil_thread_t *thd = (axutil_thread_t *) opaque;
+ axutil_thread_t *thd = (axutil_thread_t *)opaque;
TlsSetValue(tls_axutil_thread, thd->td);
return thd->func(thd, thd->data);
}
@@ -99,9 +98,9 @@
unsigned long temp;
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;
}
@@ -114,7 +113,7 @@
/* Use 0 for Thread Stack Size, because that will default the stack to the
* same size as the calling thread.
*/
- if ((handle =
+ if((handle =
CreateThread(NULL, attr &&
attr->stacksize > 0 ? attr->stacksize : 0,
(unsigned long (AXIS2_THREAD_FUNC *) (void *))
@@ -123,7 +122,7 @@
return NULL;
}
- if (attr && attr->detach)
+ if(attr && attr->detach)
{
CloseHandle(handle);
}
@@ -139,11 +138,11 @@
axutil_allocator_t * allocator)
{
axis2_status_t status = AXIS2_SUCCESS;
- if (thd)
+ if(thd)
{
AXIS2_FREE(allocator, thd);
}
- if (status)
+ if(status)
{
ExitThread(0);
}
@@ -155,18 +154,17 @@
axis2_os_thread_current(
void)
{
- HANDLE hthread = (HANDLE) TlsGetValue(tls_axutil_thread);
+ HANDLE hthread = (HANDLE)TlsGetValue(tls_axutil_thread);
HANDLE hproc;
- if (hthread)
+ if(hthread)
{
return hthread;
}
hproc = GetCurrentProcess();
hthread = GetCurrentThread();
- if (!DuplicateHandle
- (hproc, hthread, hproc, &hthread, 0, FALSE, DUPLICATE_SAME_ACCESS))
+ if(!DuplicateHandle(hproc, hthread, hproc, &hthread, 0, FALSE, DUPLICATE_SAME_ACCESS))
{
return NULL;
}
@@ -186,16 +184,15 @@
axutil_thread_join(
axutil_thread_t * thd)
{
- axis2_status_t rv = AXIS2_SUCCESS,
- rv1;
+ axis2_status_t rv = AXIS2_SUCCESS, rv1;
- if (!thd->td)
+ if(!thd->td)
{
/* Can not join on detached threads */
return AXIS2_FAILURE;
}
rv1 = WaitForSingleObject(thd->td, INFINITE);
- if (rv1 == WAIT_OBJECT_0 || rv1 == WAIT_ABANDONED)
+ if(rv1 == WAIT_OBJECT_0 || rv1 == WAIT_ABANDONED)
{
/*rv = AXIS2_INCOMPLETE; */
}
@@ -211,7 +208,7 @@
axutil_thread_detach(
axutil_thread_t * thd)
{
- if (thd->td && CloseHandle(thd->td))
+ if(thd->td && CloseHandle(thd->td))
{
thd->td = NULL;
return AXIS2_SUCCESS;
@@ -242,9 +239,11 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axutil_thread_once(
axutil_thread_once_t * control,
- void (*func) (void))
+ void
+ (*func)(
+ void))
{
- if (!InterlockedExchange(&control->value, 1))
+ if(!InterlockedExchange(&control->value, 1))
{
func();
}
Modified: webservices/axis2/trunk/c/util/src/platforms/windows/uuid_gen_windows.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/windows/uuid_gen_windows.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/windows/uuid_gen_windows.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/windows/uuid_gen_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
@@ -22,40 +21,41 @@
#include <string.h>
#include <axutil_utils_defines.h>
-AXIS2_EXTERN axis2_char_t * AXIS2_CALL
-axutil_platform_uuid_gen(char *s)
+AXIS2_EXTERN axis2_char_t * AXIS2_CALL
+axutil_platform_uuid_gen(
+ char *s)
{
RPC_STATUS retval;
UUID uuid;
unsigned char *str;
axis2_char_t * retstr;
- if (!s)
+ if(!s)
{
return NULL;
}
retstr = s;
- retval = UuidCreate(&uuid);
- if (retval == RPC_S_UUID_LOCAL_ONLY)
+ retval = UuidCreate(&uuid);
+ if(retval == RPC_S_UUID_LOCAL_ONLY)
{
printf("warning - unique within computer \n");
- }
- else if (retval == RPC_S_UUID_NO_ADDRESS)
+ }
+ else if(retval == RPC_S_UUID_NO_ADDRESS)
{
return NULL;
}
retval = UuidToStringA(&uuid, &str);
- if (retval == RPC_S_OK)
+ if(retval == RPC_S_OK)
{
strcpy(retstr, (char *)str);
RpcStringFree(&str);
}
- else if (retval == RPC_S_OUT_OF_MEMORY)
+ else if(retval == RPC_S_OUT_OF_MEMORY)
{
return NULL;
}
return retstr;
-}
\ No newline at end of file
+}
Modified: webservices/axis2/trunk/c/util/src/properties.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/properties.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/properties.c (original)
+++ webservices/axis2/trunk/c/util/src/properties.c Tue Aug 18 11:24:00 2009
@@ -22,14 +22,17 @@
#define MAX_SIZE 1024
#define MAX_ALLOC (MAX_SIZE * 64)
-axis2_char_t *axutil_properties_read(
+axis2_char_t *
+axutil_properties_read(
FILE *input,
const axutil_env_t *env);
-axis2_char_t *axutil_properties_read_next(
+axis2_char_t *
+axutil_properties_read_next(
axis2_char_t *cur);
-axis2_char_t *axutil_properties_trunk_and_dup(
+axis2_char_t *
+axutil_properties_trunk_and_dup(
axis2_char_t *start,
axis2_char_t *end,
const axutil_env_t *env);
@@ -47,11 +50,9 @@
AXIS2_ENV_CHECK(env, NULL);
- properties =
- (axutil_properties_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axutil_properties_t));
+ properties = (axutil_properties_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_properties_t));
- if (!properties)
+ if(!properties)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Not enough memory");
@@ -71,17 +72,16 @@
axis2_char_t *value = NULL;
axutil_hash_index_t *hi = NULL;
- if (properties->prop_hash)
+ if(properties->prop_hash)
{
- for (hi = axutil_hash_first(properties->prop_hash, env); hi;
- hi = axutil_hash_next(env, hi))
+ for(hi = axutil_hash_first(properties->prop_hash, env); hi; hi = axutil_hash_next(env, hi))
{
- axutil_hash_this(hi, (void *) &key, NULL, (void *) &value);
- if (key)
+ axutil_hash_this(hi, (void *)&key, NULL, (void *)&value);
+ if(key)
{
AXIS2_FREE(env->allocator, key);
}
- if (value)
+ if(value)
{
AXIS2_FREE(env->allocator, value);
}
@@ -89,7 +89,7 @@
axutil_hash_free(properties->prop_hash, env);
}
- if (properties)
+ if(properties)
{
AXIS2_FREE(env->allocator, properties);
}
@@ -118,15 +118,15 @@
AXIS2_PARAM_CHECK(env->error, key, AXIS2_FAILURE);
old = axutil_properties_get_property(properties, env, key);
- if (old)
+ if(old)
{
AXIS2_FREE(env->allocator, old);
- axutil_hash_set(properties->prop_hash, key,
- AXIS2_HASH_KEY_STRING, axutil_strdup(env, value));
+ axutil_hash_set(properties->prop_hash, key, AXIS2_HASH_KEY_STRING,
+ axutil_strdup(env, value));
return AXIS2_SUCCESS;
}
- axutil_hash_set(properties->prop_hash, axutil_strdup(env, key),
- AXIS2_HASH_KEY_STRING, axutil_strdup(env, value));
+ axutil_hash_set(properties->prop_hash, axutil_strdup(env, key), AXIS2_HASH_KEY_STRING,
+ axutil_strdup(env, value));
return AXIS2_SUCCESS;
}
@@ -150,15 +150,14 @@
AXIS2_PARAM_CHECK(env->error, output, AXIS2_FAILURE);
- if (properties->prop_hash)
+ if(properties->prop_hash)
{
- for (hi = axutil_hash_first(properties->prop_hash, env); hi;
- hi = axutil_hash_next(env, hi))
+ for(hi = axutil_hash_first(properties->prop_hash, env); hi; hi = axutil_hash_next(env, hi))
{
- axutil_hash_this(hi, (void *) &key, NULL, (void *) &value);
- if (key)
+ axutil_hash_this(hi, (void *)&key, NULL, (void *)&value);
+ if(key)
{
- if (!value)
+ if(!value)
{
value = axutil_strdup(env, "");
}
@@ -194,13 +193,13 @@
prop_hash = properties->prop_hash;
input = fopen(input_filename, "r+");
- if (!input)
+ if(!input)
{
return AXIS2_FAILURE;
}
buffer = axutil_properties_read(input, env);
- if (!buffer)
+ if(!buffer)
{
sprintf(loginfo, "error in reading file\n");
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, loginfo);
@@ -208,23 +207,22 @@
return AXIS2_FAILURE;
}
- for (cur = axutil_properties_read_next(buffer); *cur;
- cur = axutil_properties_read_next(++cur))
+ for(cur = axutil_properties_read_next(buffer); *cur; cur = axutil_properties_read_next(++cur))
{
- if (*cur == '\r')
+ if(*cur == '\r')
{
*cur = '\0';
}
- else if (*cur != '\0' && *cur != '\n' && status == LINE_STARTED)
+ else if(*cur != '\0' && *cur != '\n' && status == LINE_STARTED)
{
tag = cur;
status = LINE_MIDWAY;
}
/* equal found just create a property */
- else if (*cur == '=' && status == LINE_MIDWAY)
+ else if(*cur == '=' && status == LINE_MIDWAY)
{
*cur = '\0';
- if (status != LINE_MIDWAY)
+ if(status != LINE_MIDWAY)
{
sprintf(loginfo, "equal apear in wrong place around %s\n", tag);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, loginfo);
@@ -235,16 +233,16 @@
key = axutil_properties_trunk_and_dup(tag, cur, env);
}
/* right next to the equal found */
- else if (status == EQUAL_FOUND)
+ else if(status == EQUAL_FOUND)
{
tag = cur;
status = LINE_HALFWAY;
}
- else if (*cur == '\n')
+ else if(*cur == '\n')
{
*cur = '\0';
- if (status == LINE_HALFWAY)
+ if(status == LINE_HALFWAY)
{
tag = axutil_properties_trunk_and_dup(tag, cur, env);
axutil_hash_set(prop_hash, key, AXIS2_HASH_KEY_STRING, tag);
@@ -252,21 +250,21 @@
status = LINE_STARTED;
}
}
- if (status == LINE_HALFWAY)
+ if(status == LINE_HALFWAY)
{
*cur = '\0';
tag = axutil_properties_trunk_and_dup(tag, cur, env);
axutil_hash_set(prop_hash, key, AXIS2_HASH_KEY_STRING, tag);
status = LINE_STARTED;
}
- if (status != LINE_STARTED)
+ if(status != LINE_STARTED)
{
sprintf(loginfo, "error parsing properties\n");
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, loginfo);
AXIS2_FREE(env->allocator, buffer);
return AXIS2_FAILURE;
}
- if (input)
+ if(input)
{
fclose(input);
}
@@ -279,12 +277,13 @@
axis2_char_t *cur)
{
/* ignore comment */
- if (*cur == '#')
+ if(*cur == '#')
{
- for (; *cur != '\n' && *cur != '\0'; cur++);
+ for(; *cur != '\n' && *cur != '\0'; cur++)
+ ;
}
/* check '\\''\n' case */
- if (*cur == '\\' && *(cur + 1) == '\n')
+ if(*cur == '\\' && *(cur + 1) == '\n')
{
/* ignore two axis2_char_ts */
*(cur++) = ' ';
@@ -299,10 +298,12 @@
axis2_char_t *end,
const axutil_env_t *env)
{
- for (; *start == ' '; start++); /* remove front spaces */
- for (end--; *end == ' '; end--); /* remove rear spaces */
+ for(; *start == ' '; start++)
+ ; /* remove front spaces */
+ for(end--; *end == ' '; end--)
+ ; /* remove rear spaces */
*(++end) = '\0';
- start = (axis2_char_t *) axutil_strdup(env, start);
+ start = (axis2_char_t *)axutil_strdup(env, start);
return start;
}
@@ -317,35 +318,30 @@
size_t curr_alloc = MAX_SIZE * 2;
size_t total_alloc = curr_alloc;
- out_stream =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * curr_alloc);
- if (!out_stream)
+ out_stream = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * curr_alloc);
+ if(!out_stream)
{
return NULL;
}
do
{
- nread =
- fread(out_stream + ncount, sizeof(axis2_char_t), MAX_SIZE, input);
+ nread = fread(out_stream + ncount, sizeof(axis2_char_t), MAX_SIZE, input);
ncount += nread;
- if (ncount + MAX_SIZE > total_alloc)
+ if(ncount + MAX_SIZE > total_alloc)
{
axis2_char_t *new_stream = NULL;
- if (curr_alloc < MAX_ALLOC)
+ if(curr_alloc < MAX_ALLOC)
{
curr_alloc *= 2;
}
total_alloc += curr_alloc;
- new_stream =
- AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * total_alloc);
- if (!new_stream)
+ new_stream = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * total_alloc);
+ if(!new_stream)
{
- if (out_stream)
+ if(out_stream)
{
AXIS2_FREE(env->allocator, out_stream);
}
@@ -353,14 +349,14 @@
}
memcpy(new_stream, out_stream, sizeof(axis2_char_t) * ncount);
- if (out_stream)
+ if(out_stream)
{
AXIS2_FREE(env->allocator, out_stream);
}
out_stream = new_stream;
}
}
- while (nread == MAX_SIZE);
+ while(nread == MAX_SIZE);
out_stream[ncount] = '\0';
return out_stream;
Modified: webservices/axis2/trunk/c/util/src/property.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/property.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/property.c (original)
+++ webservices/axis2/trunk/c/util/src/property.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
@@ -35,11 +34,9 @@
AXIS2_ENV_CHECK(env, NULL);
- property =
- (axutil_property_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axutil_property_t));
+ property = (axutil_property_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_property_t));
- if (!property)
+ if(!property)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
@@ -65,9 +62,9 @@
AXIS2_ENV_CHECK(env, NULL);
- property = (axutil_property_t *) axutil_property_create(env);
+ property = (axutil_property_t *)axutil_property_create(env);
- if (!property)
+ if(!property)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
@@ -87,22 +84,22 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (property->value)
+ if(property->value)
{
- if (property->scope != AXIS2_SCOPE_APPLICATION)
+ if(property->scope != AXIS2_SCOPE_APPLICATION)
{
- if (property->free_func && property->own_value)
+ if(property->free_func && property->own_value)
{
property->free_func(property->value, env);
}
- else if (property->own_value)
+ else if(property->own_value)
{
AXIS2_FREE(env->allocator, property->value);
}
}
}
- if (property)
+ if(property)
{
AXIS2_FREE(env->allocator, property);
}
@@ -141,15 +138,15 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (property->value)
+ if(property->value)
{
- if (property->scope != AXIS2_SCOPE_APPLICATION)
+ if(property->scope != AXIS2_SCOPE_APPLICATION)
{
- if (property->free_func && property->own_value)
+ if(property->free_func && property->own_value)
{
property->free_func(property->value, env);
}
- else if (property->own_value)
+ else if(property->own_value)
{
AXIS2_FREE(env->allocator, property->value);
}
Modified: webservices/axis2/trunk/c/util/src/qname.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/qname.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/qname.c (original)
+++ webservices/axis2/trunk/c/util/src/qname.c Tue Aug 18 11:24:00 2009
@@ -51,17 +51,16 @@
AXIS2_ENV_CHECK(env, NULL);
/* localpart can't be null */
- if (!localpart)
+ if(!localpart)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL parameter was passed when a non NULL parameter was expected");
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "NULL parameter was passed when a non NULL parameter was expected");
return NULL;
}
- qname =
- (axutil_qname_t *) AXIS2_MALLOC(env->allocator, sizeof(axutil_qname_t));
- if (!qname)
+ qname = (axutil_qname_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_qname_t));
+ if(!qname)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -74,8 +73,8 @@
qname->namespace_uri = NULL;
qname->ref = 1;
- qname->localpart = (axis2_char_t *) axutil_strdup(env, localpart);
- if (!(qname->localpart))
+ qname->localpart = (axis2_char_t *)axutil_strdup(env, localpart);
+ if(!(qname->localpart))
{
AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -84,12 +83,12 @@
return NULL;
}
- if (prefix)
+ if(prefix)
{
- qname->prefix = (axis2_char_t *) axutil_strdup(env, prefix);
+ qname->prefix = (axis2_char_t *)axutil_strdup(env, prefix);
}
- if (prefix && !(qname->prefix))
+ if(prefix && !(qname->prefix))
{
AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -98,13 +97,12 @@
return NULL;
}
- if (namespace_uri)
+ if(namespace_uri)
{
- qname->namespace_uri =
- (axis2_char_t *) axutil_strdup(env, namespace_uri);
+ qname->namespace_uri = (axis2_char_t *)axutil_strdup(env, namespace_uri);
}
- if (namespace_uri && !(qname->namespace_uri))
+ if(namespace_uri && !(qname->namespace_uri))
{
AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -125,24 +123,24 @@
qname->ref--;
- if (qname->ref > 0)
+ if(qname->ref > 0)
{
return;
}
- if (qname->localpart)
+ if(qname->localpart)
{
AXIS2_FREE(env->allocator, qname->localpart);
}
- if (qname->namespace_uri)
+ if(qname->namespace_uri)
{
AXIS2_FREE(env->allocator, qname->namespace_uri);
}
- if (qname->prefix)
+ if(qname->prefix)
{
AXIS2_FREE(env->allocator, qname->prefix);
}
- if (qname->qname_string)
+ if(qname->qname_string)
{
AXIS2_FREE(env->allocator, qname->qname_string);
}
@@ -163,16 +161,16 @@
AXIS2_ENV_CHECK(env, AXIS2_FALSE);
- if (!qname2)
+ if(!qname2)
{
- AXIS2_ERROR_SET_ERROR_NUMBER(env->error,
- AXIS2_ERROR_INVALID_NULL_PARAM);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL parameter was passed when a non NULL parameter was expected");
+ AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "NULL parameter was passed when a non NULL parameter was expected");
AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE);
return AXIS2_FALSE;
}
- if (qname->localpart && qname2->localpart)
+ if(qname->localpart && qname2->localpart)
{
localparts_differ = axutil_strcmp(qname->localpart, qname2->localpart);
}
@@ -181,10 +179,9 @@
localparts_differ = ((qname->localpart) || (qname2->localpart));
}
- if (qname->namespace_uri && qname2->namespace_uri)
+ if(qname->namespace_uri && qname2->namespace_uri)
{
- uris_differ =
- axutil_strcmp(qname->namespace_uri, qname2->namespace_uri);
+ uris_differ = axutil_strcmp(qname->namespace_uri, qname2->namespace_uri);
}
else
{
@@ -201,7 +198,7 @@
{
AXIS2_ENV_CHECK(env, NULL);
- if (!qname)
+ if(!qname)
{
return NULL;
}
@@ -243,22 +240,21 @@
const axutil_env_t *env)
{
AXIS2_ENV_CHECK(env, NULL);
- if (qname->qname_string)
+ if(qname->qname_string)
{
return qname->qname_string;
}
- if (!(qname->namespace_uri) || axutil_strcmp(qname->namespace_uri, "") == 0)
+ if(!(qname->namespace_uri) || axutil_strcmp(qname->namespace_uri, "") == 0)
{
qname->qname_string = axutil_strdup(env, qname->localpart);
}
- else if (!(qname->prefix) || axutil_strcmp(qname->prefix, "") == 0)
+ else if(!(qname->prefix) || axutil_strcmp(qname->prefix, "") == 0)
{
axis2_char_t *temp_string1 = NULL;
temp_string1 = axutil_stracat(env, qname->localpart, "|");
- qname->qname_string =
- axutil_stracat(env, temp_string1, qname->namespace_uri);
- if (temp_string1)
+ qname->qname_string = axutil_stracat(env, temp_string1, qname->namespace_uri);
+ if(temp_string1)
{
AXIS2_FREE(env->allocator, temp_string1);
}
@@ -274,15 +270,15 @@
temp_string3 = axutil_stracat(env, temp_string2, "|");
qname->qname_string = axutil_stracat(env, temp_string3, qname->prefix);
- if (temp_string1)
+ if(temp_string1)
{
AXIS2_FREE(env->allocator, temp_string1);
}
- if (temp_string2)
+ if(temp_string2)
{
AXIS2_FREE(env->allocator, temp_string2);
}
- if (temp_string3)
+ if(temp_string3)
{
AXIS2_FREE(env->allocator, temp_string3);
}
@@ -302,20 +298,20 @@
axis2_char_t *next = NULL;
axis2_char_t *temp_string = NULL;
axutil_qname_t *qname = NULL;
- if (!qstring || axutil_strcmp(qstring, "") == 0)
+ if(!qstring || axutil_strcmp(qstring, "") == 0)
return NULL;
temp_string = axutil_strdup(env, qstring);
index = strchr(temp_string, '|');
- if (index)
+ if(index)
{
next = index + 1;
temp_string[index - temp_string] = '\0';
localpart = temp_string;
index = strchr(next, '|');
- if (index)
+ if(index)
{
prefix = index + 1;
next[index - next] = '\0';
@@ -333,7 +329,7 @@
/** only localpart is there in this qname */
qname = axutil_qname_create(env, temp_string, NULL, NULL);
}
- if (temp_string)
+ if(temp_string)
{
AXIS2_FREE(env->allocator, temp_string);
}
Modified: webservices/axis2/trunk/c/util/src/rand.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/rand.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/rand.c (original)
+++ webservices/axis2/trunk/c/util/src/rand.c Tue Aug 18 11:24:00 2009
@@ -1,4 +1,3 @@
-
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -27,7 +26,7 @@
unsigned int *seedp)
{
*seedp = *seedp * 1103515245 + 12345;
- return ((unsigned) (*seedp / (2 * AXIS2_RAND_MAX)) % AXIS2_RAND_MAX);
+ return ((unsigned)(*seedp / (2 * AXIS2_RAND_MAX)) % AXIS2_RAND_MAX);
}
AXIS2_EXTERN int AXIS2_CALL
@@ -38,16 +37,16 @@
{
int rand = -1;
float range = 0.0;
- if (start < 0 || end <= 0)
+ if(start < 0 || end <= 0)
return -1;
- if (start >= AXIS2_RAND_MAX || end > AXIS2_RAND_MAX)
+ if(start >= AXIS2_RAND_MAX || end > AXIS2_RAND_MAX)
return -1;
- if (end <= start)
+ if(end <= start)
return -1;
range = (float)(end - start);
rand = axutil_rand(seedp);
- rand = start + (int) (range * rand / (AXIS2_RAND_MAX + 1.0));
+ rand = start + (int)(range * rand / (AXIS2_RAND_MAX + 1.0));
return rand;
}
Modified: webservices/axis2/trunk/c/util/src/stack.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/stack.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/stack.c (original)
+++ webservices/axis2/trunk/c/util/src/stack.c Tue Aug 18 11:24:00 2009
@@ -43,10 +43,9 @@
AXIS2_ENV_CHECK(env, NULL);
- stack =
- (axutil_stack_t *) AXIS2_MALLOC(env->allocator, sizeof(axutil_stack_t));
+ stack = (axutil_stack_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_stack_t));
- if (!stack)
+ if(!stack)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -58,10 +57,8 @@
stack->capacity = AXIS2_STACK_DEFAULT_CAPACITY;
stack->is_empty_stack = AXIS2_TRUE;
- stack->data =
- AXIS2_MALLOC(env->allocator,
- sizeof(void *) * AXIS2_STACK_DEFAULT_CAPACITY);
- if (!stack->data)
+ stack->data = AXIS2_MALLOC(env->allocator, sizeof(void *) * AXIS2_STACK_DEFAULT_CAPACITY);
+ if(!stack->data)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -79,7 +76,7 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (stack->data)
+ if(stack->data)
{
AXIS2_FREE(env->allocator, stack->data);
}
@@ -95,16 +92,16 @@
void *value = NULL;
AXIS2_ENV_CHECK(env, NULL);
- if (stack->is_empty_stack == AXIS2_TRUE || stack->size == 0)
+ if(stack->is_empty_stack == AXIS2_TRUE || stack->size == 0)
{
return NULL;
}
- if (stack->size > 0)
+ if(stack->size > 0)
{
value = stack->data[stack->size - 1];
stack->data[stack->size - 1] = NULL;
stack->size--;
- if (stack->size == 0)
+ if(stack->size == 0)
{
stack->is_empty_stack = AXIS2_TRUE;
}
@@ -121,7 +118,7 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
- if ((stack->size < stack->capacity) && (stack->capacity > 0))
+ if((stack->size < stack->capacity) && (stack->capacity > 0))
{
stack->data[stack->size++] = value;
}
@@ -132,7 +129,7 @@
int new_capacity = stack->capacity + AXIS2_STACK_DEFAULT_CAPACITY;
new_data = AXIS2_MALLOC(env->allocator, sizeof(void *) * new_capacity);
- if (!new_data)
+ if(!new_data)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -164,7 +161,7 @@
axutil_stack_t *stack,
const axutil_env_t *env)
{
- if (stack->size > 0)
+ if(stack->size > 0)
{
return stack->data[stack->size - 1];
}
@@ -177,7 +174,7 @@
const axutil_env_t *env,
int i)
{
- if ((stack->size == 0) || (i < 0) || (i >= stack->size))
+ if((stack->size == 0) || (i < 0) || (i >= stack->size))
{
return NULL;
}
Modified: webservices/axis2/trunk/c/util/src/stream.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/stream.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/stream.c (original)
+++ webservices/axis2/trunk/c/util/src/stream.c Tue Aug 18 11:24:00 2009
@@ -81,11 +81,9 @@
axutil_stream_t *stream = NULL;
AXIS2_ENV_CHECK(env, NULL);
- stream =
- (axutil_stream_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axutil_stream_t));
+ stream = (axutil_stream_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_stream_t));
- if (!stream)
+ if(!stream)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -109,11 +107,11 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- switch (stream->stream_type)
+ switch(stream->stream_type)
{
- case AXIS2_STREAM_BASIC:
+ case AXIS2_STREAM_BASIC:
{
- if (stream->buffer_head)
+ if(stream->buffer_head)
{
AXIS2_FREE(env->allocator, stream->buffer_head);
}
@@ -121,15 +119,15 @@
stream->len = -1;
break;
}
- case AXIS2_STREAM_FILE:
+ case AXIS2_STREAM_FILE:
{
stream->fp = NULL;
stream->len = -1;
break;
}
- case AXIS2_STREAM_SOCKET:
+ case AXIS2_STREAM_SOCKET:
{
- if (stream->fp)
+ if(stream->fp)
{
fclose(stream->fp);
}
@@ -137,8 +135,8 @@
stream->len = -1;
break;
}
- default:
- break;
+ default:
+ break;
}
AXIS2_FREE(env->allocator, stream);
@@ -153,7 +151,7 @@
{
axutil_stream_t *stream_l = NULL;
- stream_l = (axutil_stream_t *) stream;
+ stream_l = (axutil_stream_t *)stream;
axutil_stream_free(stream_l, env);
return;
}
@@ -163,9 +161,9 @@
axutil_stream_t *stream,
const axutil_env_t *env)
{
- if (stream->fp)
+ if(stream->fp)
{
- if (fflush(stream->fp))
+ if(fflush(stream->fp))
{
return AXIS2_FAILURE;
}
@@ -178,11 +176,11 @@
axutil_stream_t *stream,
const axutil_env_t *env)
{
- switch (stream->stream_type)
+ switch(stream->stream_type)
{
- case AXIS2_STREAM_BASIC:
+ case AXIS2_STREAM_BASIC:
{
- if (stream->buffer_head)
+ if(stream->buffer_head)
{
AXIS2_FREE(env->allocator, stream->buffer_head);
}
@@ -190,11 +188,11 @@
stream->len = -1;
break;
}
- case AXIS2_STREAM_FILE:
+ case AXIS2_STREAM_FILE:
{
- if (stream->fp)
+ if(stream->fp)
{
- if (fclose(stream->fp))
+ if(fclose(stream->fp))
{
return AXIS2_FAILURE;
}
@@ -203,11 +201,11 @@
stream->len = -1;
break;
}
- case AXIS2_STREAM_SOCKET:
+ case AXIS2_STREAM_SOCKET:
{
- if (stream->fp)
+ if(stream->fp)
{
- if (fclose(stream->fp))
+ if(fclose(stream->fp))
{
return AXIS2_FAILURE;
}
@@ -216,8 +214,8 @@
stream->len = -1;
break;
}
- default:
- break;
+ default:
+ break;
}
return AXIS2_SUCCESS;
@@ -232,7 +230,7 @@
AXIS2_ENV_CHECK(env, NULL);
stream = axutil_stream_create_internal(env);
- if (!stream)
+ if(!stream)
{
/*
* We leave the error returned by the
@@ -244,15 +242,13 @@
stream->read = axutil_stream_read_basic;
stream->write = axutil_stream_write_basic;
stream->skip = axutil_stream_skip_basic;
- stream->buffer =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- AXIS2_STREAM_DEFAULT_BUF_SIZE *
- sizeof(axis2_char_t));
+ stream->buffer = (axis2_char_t *)AXIS2_MALLOC(env->allocator, AXIS2_STREAM_DEFAULT_BUF_SIZE
+ * sizeof(axis2_char_t));
stream->buffer_head = stream->buffer;
stream->len = 0;
stream->max_len = AXIS2_STREAM_DEFAULT_BUF_SIZE;
- if (!stream->buffer)
+ if(!stream->buffer)
{
axutil_stream_free(stream, env);
return NULL;
@@ -271,15 +267,15 @@
char *buf = NULL;
buf = stream->buffer;
- if (!buf)
+ if(!buf)
{
return -1;
}
- if (!buffer)
+ if(!buffer)
{
return -1;
}
- if ((int)(count - 1) > stream->len)
+ if((int)(count - 1) > stream->len)
/* We are sure that the difference lies within the int range */
{
len = stream->len;
@@ -296,7 +292,7 @@
*/
stream->len -= len;
stream->buffer = buf + len;
- ((axis2_char_t *) buffer)[len] = '\0';
+ ((axis2_char_t *)buffer)[len] = '\0';
return len;
}
@@ -309,18 +305,16 @@
{
int new_len = 0;
- if (!buffer)
+ if(!buffer)
return -1;
new_len = (int)(stream->len + count);
/* We are sure that the difference lies within the int range */
- if (new_len > stream->max_len)
+ if(new_len > stream->max_len)
{
- axis2_char_t *tmp = (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) *
- (new_len +
- AXIS2_STREAM_DEFAULT_BUF_SIZE));
- if (!tmp)
+ axis2_char_t *tmp = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t)
+ * (new_len + AXIS2_STREAM_DEFAULT_BUF_SIZE));
+ if(!tmp)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return -1;
@@ -335,8 +329,7 @@
stream->buffer = tmp;
stream->buffer_head = tmp;
}
- memcpy(stream->buffer + (stream->len * sizeof(axis2_char_t)), buffer,
- count);
+ memcpy(stream->buffer + (stream->len * sizeof(axis2_char_t)), buffer, count);
stream->len += (int)count;
/* We are sure that the difference lies within the int range */
return (int)count;
@@ -358,9 +351,9 @@
{
int del_len = 0;
- if (count > 0)
+ if(count > 0)
{
- if (count <= stream->len)
+ if(count <= stream->len)
{
del_len = count;
}
@@ -404,7 +397,7 @@
AXIS2_ENV_CHECK(env, NULL);
stream = axutil_stream_create_internal(env);
- if (!stream)
+ if(!stream)
{
/*
* We leave the error returned by the
@@ -431,16 +424,15 @@
{
FILE *fp = NULL;
- if (!stream->fp)
+ if(!stream->fp)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_FD, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on invalid file descriptor");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Trying to do operation on invalid file descriptor");
return -1;
}
fp = stream->fp;
- if (!buffer)
+ if(!buffer)
{
return -1;
}
@@ -458,16 +450,15 @@
int len = 0;
FILE *fp = NULL;
- if (!(stream->fp))
+ if(!(stream->fp))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_FD, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on invalid file descriptor");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Trying to do operation on invalid file descriptor");
return -1;
}
fp = stream->fp;
- if (!buffer)
+ if(!buffer)
return -1;
len = (int)fwrite(buffer, sizeof(axis2_char_t), count, fp);
/* We are sure that the difference lies within the int range */
@@ -482,14 +473,13 @@
{
int c = -1;
int i = count;
- if (!(stream->fp))
+ if(!(stream->fp))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_FD, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on invalid file descriptor");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Trying to do operation on invalid file descriptor");
return -1;
}
- while (EOF != (c = fgetc(stream->fp)) && i > 0)
+ while(EOF != (c = fgetc(stream->fp)) && i > 0)
{
i--;
}
@@ -508,7 +498,7 @@
AXIS2_ENV_CHECK(env, NULL);
stream = axutil_stream_create_internal(env);
- if (!stream)
+ if(!stream)
{
/*
* We leave the error returned by the
@@ -540,14 +530,14 @@
axis2_char_t *temp = NULL;
#endif
- if (-1 == stream->socket)
+ if(-1 == stream->socket)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on closed/not-opened socket");
+ "Trying to do operation on closed/not-opened socket");
return -1;
}
- if (!buffer)
+ if(!buffer)
{
return -1;
}
@@ -558,8 +548,8 @@
if (len > 1)
{
temp =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- (len + 1) * sizeof(axis2_char_t));
+ (axis2_char_t *) AXIS2_MALLOC(env->allocator,
+ (len + 1) * sizeof(axis2_char_t));
if (temp)
{
memcpy(temp, buffer, len * sizeof(axis2_char_t));
@@ -584,14 +574,14 @@
axis2_char_t *temp = NULL;
#endif
- if (-1 == stream->socket)
+ if(-1 == stream->socket)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on closed/not-opened socket");
+ "Trying to do operation on closed/not-opened socket");
return -1;
}
- if (!buffer)
+ if(!buffer)
return -1;
len = (int)send(stream->socket, buffer, (int)count, 0);
/* We are sure that the difference lies within the int range */
@@ -599,8 +589,8 @@
if (len > 0)
{
temp =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- (len + 1) * sizeof(axis2_char_t));
+ (axis2_char_t *) AXIS2_MALLOC(env->allocator,
+ (len + 1) * sizeof(axis2_char_t));
if (temp)
{
memcpy(temp, buffer, len * sizeof(axis2_char_t));
@@ -621,34 +611,32 @@
int count)
{
int len = 0;
- int received = 0;
+ int received = 0;
char buffer[2];
- if (-1 == stream->socket)
+ if(-1 == stream->socket)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on closed/not-opened socket");
+ "Trying to do operation on closed/not-opened socket");
return -1;
}
- while (len < count)
+ while(len < count)
{
received = recv(stream->socket, buffer, 1, 0);
- if (received == 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Socket has being shutdown");
- return -1;
- }
- if (received < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Error while trying to read the socke");
- return -1;
- }
- len += received;
+ if(received == 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Socket has being shutdown");
+ return -1;
+ }
+ if(received < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error while trying to read the socke");
+ return -1;
+ }
+ len += received;
}
return len;
}
@@ -665,14 +653,14 @@
/* Added to prevent a segfault */
AXIS2_PARAM_CHECK(env->error, stream, -1);
- if (-1 == stream->socket)
+ if(-1 == stream->socket)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Trying to do operation on closed/not-opened socket");
+ "Trying to do operation on closed/not-opened socket");
return -1;
}
- if (!buffer)
+ if(!buffer)
{
return -1;
}
Modified: webservices/axis2/trunk/c/util/src/string.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/string.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/string.c (original)
+++ webservices/axis2/trunk/c/util/src/string.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
@@ -40,19 +39,16 @@
AXIS2_ENV_CHECK(env, NULL);
/* str can't be null */
- if (!str)
+ if(!str)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "NULL parameter was passed when a non NULL parameter was expected");
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "NULL parameter was passed when a non NULL parameter was expected");
return NULL;
}
- string =
- (axutil_string_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axutil_string_t));
- if (!string)
+ string = (axutil_string_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_string_t));
+ if(!string)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -65,21 +61,18 @@
string->length = axutil_strlen(str);
- if (string->length < 0)
+ if(string->length < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "NULL parameter was passed when a non NULL parameter was expected");
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "NULL parameter was passed when a non NULL parameter was expected");
axutil_string_free(string, env);
return NULL;
}
- string->buffer =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * (string->length +
- 1));
- if (!(string->buffer))
+ string->buffer = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t)
+ * (string->length + 1));
+ if(!(string->buffer))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -100,19 +93,16 @@
AXIS2_ENV_CHECK(env, NULL);
/* str can't be null */
- if (!str || !(*str))
+ if(!str || !(*str))
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "NULL parameter was passed when a non NULL parameter was expected");
+ "NULL parameter was passed when a non NULL parameter was expected");
return NULL;
}
- string =
- (axutil_string_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axutil_string_t));
- if (!string)
+ string = (axutil_string_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_string_t));
+ if(!string)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -124,12 +114,11 @@
string->ref_count = 1;
string->owns_buffer = AXIS2_TRUE;
- if (string->length < 0)
+ if(string->length < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "NULL parameter was passed when a non NULL parameter was expected");
+ "NULL parameter was passed when a non NULL parameter was expected");
axutil_string_free(string, env);
return NULL;
}
@@ -146,20 +135,17 @@
AXIS2_ENV_CHECK(env, NULL);
/* str can't be null */
- if (!str)
+ if(!str)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "NULL parameter was passed when a non NULL parameter was expected");
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "NULL parameter was passed when a non NULL parameter was expected");
return NULL;
}
- string =
- (axutil_string_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axutil_string_t));
- if (!string)
+ string = (axutil_string_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_string_t));
+ if(!string)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -171,12 +157,11 @@
string->ref_count = 1;
string->owns_buffer = AXIS2_FALSE;
- if (string->length < 0)
+ if(string->length < 0)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
- AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "NULL parameter was passed when a non NULL parameter was expected");
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "NULL parameter was passed when a non NULL parameter was expected");
axutil_string_free(string, env);
return NULL;
}
@@ -189,19 +174,19 @@
struct axutil_string *string,
const axutil_env_t *env)
{
- if (!string)
+ if(!string)
{
return;
}
string->ref_count--;
- if (string->ref_count > 0)
+ if(string->ref_count > 0)
{
return;
}
- if (string->owns_buffer && string->buffer)
+ if(string->owns_buffer && string->buffer)
{
AXIS2_FREE(env->allocator, string->buffer);
}
@@ -216,7 +201,7 @@
const axutil_env_t * env,
const struct axutil_string *string1)
{
- if (!string || !string1)
+ if(!string || !string1)
{
return AXIS2_FALSE;
}
@@ -229,7 +214,7 @@
struct axutil_string *string,
const axutil_env_t *env)
{
- if (!string)
+ if(!string)
{
return NULL;
}
@@ -244,7 +229,7 @@
const struct axutil_string *string,
const axutil_env_t *env)
{
- if (!string)
+ if(!string)
{
return NULL;
}
@@ -258,7 +243,7 @@
const axutil_env_t *env)
{
int error_return = -1;
- if (!string)
+ if(!string)
{
return error_return;
}
@@ -276,20 +261,19 @@
const axutil_env_t *env,
const void *ptr)
{
- if (ptr)
+ if(ptr)
{
int len = axutil_strlen(ptr);
- axis2_char_t *str = (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) *
- (len + 1));
- if (!str)
+ axis2_char_t *str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t)
+ * (len + 1));
+ if(!str)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
return NULL;
}
memcpy(str, ptr, len + 1);
- return (void *) str;
+ return (void *)str;
}
else
{
@@ -307,10 +291,8 @@
AXIS2_PARAM_CHECK(env->error, ptr, NULL);
- str =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * (n + 1));
- if (!str)
+ str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (n + 1));
+ if(!str)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -319,7 +301,7 @@
memcpy(str, ptr, n);
str[n] = '\0';
- return (void *) str;
+ return (void *)str;
}
AXIS2_EXTERN void *AXIS2_CALL
@@ -330,10 +312,10 @@
{
const axis2_char_t *cp;
- for (cp = ptr; n > 0; n--, cp++)
+ for(cp = ptr; n > 0; n--, cp++)
{
- if (*cp == c)
- return (char *) cp; /* Casting away the const here */
+ if(*cp == c)
+ return (char *)cp; /* Casting away the const here */
}
return NULL;
@@ -351,13 +333,11 @@
AXIS2_PARAM_CHECK(env->error, ptr, NULL);
end = axutil_memchr(ptr, '\0', n);
- if (end)
- n = (int)(end - (axis2_char_t *) ptr);
- /* We are sure that the difference lies within the int range */
- str =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * (n + 1));
- if (!str)
+ if(end)
+ n = (int)(end - (axis2_char_t *)ptr);
+ /* We are sure that the difference lies within the int range */
+ str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (n + 1));
+ if(!str)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -366,7 +346,7 @@
memcpy(str, ptr, n);
str[n] = '\0';
- return (void *) str;
+ return (void *)str;
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -374,9 +354,7 @@
const axutil_env_t *env,
...)
{
- axis2_char_t *cp,
- *argp,
- *str;
+ axis2_char_t *cp, *argp, *str;
size_t saved_lengths[MAX_SAVED_LENGTHS];
int nargs = 0;
int str_len = 0;
@@ -389,59 +367,59 @@
va_start(adummy, env);
cp = va_arg(adummy, axis2_char_t *);
- while (cp)
+ while(cp)
{
size_t cplen = strlen(cp);
- if (nargs < MAX_SAVED_LENGTHS)
+ if(nargs < MAX_SAVED_LENGTHS)
{
saved_lengths[nargs++] = cplen;
}
len += cplen;
- cp = va_arg(adummy, axis2_char_t *);
- }
+cp = va_arg(adummy, axis2_char_t *);
+}
- va_end(adummy);
+va_end(adummy);
- /* Allocate the required string */
- str_len = (int)(sizeof(axis2_char_t) * (len + 1));
- /* We are sure that the difference lies within the int range */
- str = (axis2_char_t *) AXIS2_MALLOC(env->allocator, str_len);
- if (!str)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
- return NULL;
- }
- cp = str;
+/* Allocate the required string */
+str_len = (int)(sizeof(axis2_char_t) * (len + 1));
+/* We are sure that the difference lies within the int range */
+str = (axis2_char_t *) AXIS2_MALLOC(env->allocator, str_len);
+if (!str)
+{
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
+ return NULL;
+}
+cp = str;
- /* Pass two --- copy the argument strings into the result space */
+/* Pass two --- copy the argument strings into the result space */
- va_start(adummy, env);
+va_start(adummy, env);
- nargs = 0;
- argp = va_arg(adummy, axis2_char_t *);
- while (argp)
+nargs = 0;
+argp = va_arg(adummy, axis2_char_t *);
+while (argp)
+{
+ if (nargs < MAX_SAVED_LENGTHS)
{
- if (nargs < MAX_SAVED_LENGTHS)
- {
- len = saved_lengths[nargs++];
- }
- else
- {
- len = strlen(argp);
- }
-
- memcpy(cp, argp, len);
- cp += len;
- argp = va_arg(adummy, axis2_char_t *);
+ len = saved_lengths[nargs++];
+ }
+ else
+ {
+ len = strlen(argp);
}
- va_end(adummy);
+ memcpy(cp, argp, len);
+ cp += len;
+ argp = va_arg(adummy, axis2_char_t *);
+}
- /* Return the result string */
+va_end(adummy);
- *cp = '\0';
- return str;
+/* Return the result string */
+
+*cp = '\0';
+return str;
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -455,28 +433,25 @@
int len1 = 0;
int len2 = 0;
- if (!s1 && !s2)
+ if(!s1 && !s2)
{
return NULL;
}
- if (!s1)
+ if(!s1)
{
- return (axis2_char_t *) axutil_strdup(env, s2);
+ return (axis2_char_t *)axutil_strdup(env, s2);
}
- if (!s2)
+ if(!s2)
{
- return (axis2_char_t *) axutil_strdup(env, s1);
+ return (axis2_char_t *)axutil_strdup(env, s1);
}
len1 = axutil_strlen(s1);
len2 = axutil_strlen(s2);
alloc_len = len1 + len2 + 1;
- ret =
- (axis2_char_t *) AXIS2_MALLOC(env->allocator,
- alloc_len * sizeof(axis2_char_t));
+ ret = (axis2_char_t *)AXIS2_MALLOC(env->allocator, alloc_len * sizeof(axis2_char_t));
memcpy(ret, s1, len1 * sizeof(axis2_char_t));
- memcpy((ret + len1 * sizeof(axis2_char_t)), s2,
- len2 * sizeof(axis2_char_t));
+ memcpy((ret + len1 * sizeof(axis2_char_t)), s2, len2 * sizeof(axis2_char_t));
ret[alloc_len * sizeof(axis2_char_t) - sizeof(axis2_char_t)] = '\0';
return ret;
}
@@ -486,7 +461,7 @@
const axis2_char_t *s1,
const axis2_char_t *s2)
{
- if (s1 && s2)
+ if(s1 && s2)
{
return strcmp(s1, s2);
}
@@ -502,7 +477,7 @@
const axis2_char_t *s2,
int n)
{
- if (s1 && s2)
+ if(s1 && s2)
{
return strncmp(s1, s2, n);
}
@@ -517,7 +492,7 @@
const axis2_char_t *s)
{
int error_return = -1;
- if (s)
+ if(s)
{
return (axis2_ssize_t)strlen(s);
/* We are sure that the difference lies within the axis2_ssize_t range */
@@ -530,30 +505,30 @@
const axis2_char_t *s1,
const axis2_char_t *s2)
{
- while (*s1 != '\0' && *s2 != '\0')
+ while(*s1 != '\0' && *s2 != '\0')
{
- if (*s1 >= 'A' && *s1 <= 'Z' && *s2 >= 'a' && *s2 <= 'z')
+ if(*s1 >= 'A' && *s1 <= 'Z' && *s2 >= 'a' && *s2 <= 'z')
{
- if (*s2 - *s1 - (char) 32 != 0)
+ if(*s2 - *s1 - (char)32 != 0)
{
return 1;
}
}
- else if (*s1 >= 'a' && *s1 <= 'z' && *s2 >= 'A' && *s2 <= 'Z')
+ else if(*s1 >= 'a' && *s1 <= 'z' && *s2 >= 'A' && *s2 <= 'Z')
{
- if (*s1 - *s2 - 32 != 0)
+ if(*s1 - *s2 - 32 != 0)
{
return 1;
}
}
- else if (*s1 - *s2 != 0)
+ else if(*s1 - *s2 != 0)
{
return 1;
}
s1++;
s2++;
}
- if (*s1 != *s2)
+ if(*s1 != *s2)
{
return 1;
}
@@ -567,13 +542,12 @@
const axis2_char_t *s2,
const int n)
{
- axis2_char_t *str1 = (axis2_char_t *) s1,
- *str2 = (axis2_char_t *) s2;
- int i = (int) n;
+ axis2_char_t *str1 = (axis2_char_t *)s1, *str2 = (axis2_char_t *)s2;
+ int i = (int)n;
- while (--i >= 0 && toupper((int)*str1) == toupper((int)*str2++))
+ while(--i >= 0 && toupper((int)*str1) == toupper((int)*str2++))
{
- if (toupper((int)*str1++) == '\0')
+ if(toupper((int)*str1++) == '\0')
{
return (0);
}
@@ -594,7 +568,7 @@
const axis2_char_t *s,
axis2_char_t ch)
{
- return (axis2_char_t *) strchr(s, ch);
+ return (axis2_char_t *)strchr(s, ch);
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -602,17 +576,16 @@
const axis2_char_t *_s,
axis2_char_t _ch)
{
- int i,
- ilen = axutil_strlen(_s);
- if (ilen < 1)
+ int i, ilen = axutil_strlen(_s);
+ if(ilen < 1)
{
return NULL;
}
- for (i = ilen - 1; i >= 0; i--)
+ for(i = ilen - 1; i >= 0; i--)
{
- if (_s[i] == _ch)
+ if(_s[i] == _ch)
{
- return (axis2_char_t *) (_s + i);
+ return (axis2_char_t *)(_s + i);
}
}
return NULL;
@@ -627,14 +600,14 @@
{
axis2_char_t *newstr = NULL;
axis2_char_t *index = NULL;
- if (!str)
+ if(!str)
{
return NULL;
}
newstr = axutil_strdup(env, str);
index = strchr(newstr, s1);
- while (index)
+ while(index)
{
newstr[index - newstr] = (axis2_char_t)s2;
/* We are sure that the conversion is safe */
@@ -652,21 +625,21 @@
axis2_char_t *_p = NULL;
axis2_char_t *ret = NULL;
- if (!_s)
+ if(!_s)
{
return NULL;
}
- _p = (axis2_char_t *) _s;
- if (!_trim)
+ _p = (axis2_char_t *)_s;
+ if(!_trim)
{
_trim = " \t\r\n";
}
- while (*_p)
+ while(*_p)
{
- if (!strchr(_trim, *_p))
+ if(!strchr(_trim, *_p))
{
- ret = (axis2_char_t *) axutil_strdup(env, _p);
+ ret = (axis2_char_t *)axutil_strdup(env, _p);
break;
}
++_p;
@@ -684,29 +657,29 @@
axis2_char_t *_s = NULL;
axis2_char_t *ret = NULL;
- if (_in)
+ if(_in)
{
_s = axutil_strdup(env, _in);
}
- if (!_s)
+ if(!_s)
{
return NULL;
}
__tail = _s + axutil_strlen(_s);
- if (!_trim)
+ if(!_trim)
{
_trim = " \t\n\r";
}
- while (_s < __tail--)
+ while(_s < __tail--)
{
- if (!strchr(_trim, *__tail))
+ if(!strchr(_trim, *__tail))
{
ret = _s;
break;
}
*__tail = 0;
}
- if (!ret && _s)
+ if(!ret && _s)
{
AXIS2_FREE(env->allocator, _s);
}
@@ -724,7 +697,7 @@
_p = axutil_strltrim(env, _s, _trim);
_q = axutil_strrtrim(env, _p, _trim);
- if (_p)
+ if(_p)
{
AXIS2_FREE(env->allocator, _p);
}
@@ -738,9 +711,9 @@
axis2_char_t new)
{
axis2_char_t *str_returns = str;
- for (; *str != '\0'; str++)
+ for(; *str != '\0'; str++)
{
- if (*str == old)
+ if(*str == old)
{
*str = new;
}
@@ -760,7 +733,7 @@
/* We are sure that the difference lies within the int range */
pos_to_shift = len - s + 1;
- if (len <= s)
+ if(len <= s)
{
return NULL;
}
@@ -779,7 +752,7 @@
length = (int)strlen(str);
/* We are sure that the difference lies within the int range */
ptr = str;
- if (length <= e)
+ if(length <= e)
{
return NULL;
}
@@ -793,7 +766,7 @@
axis2_char_t *str)
{
axis2_char_t *temp_str = NULL;
- for (temp_str = str; *temp_str != '\0'; temp_str++)
+ for(temp_str = str; *temp_str != '\0'; temp_str++)
{
*temp_str = (axis2_char_t)tolower((int)*temp_str);
/* We are sure that the conversion is safe */
@@ -806,7 +779,7 @@
axis2_char_t *str)
{
axis2_char_t *temp_str = NULL;
- for (temp_str = str; *temp_str != '\0'; temp_str++)
+ for(temp_str = str; *temp_str != '\0'; temp_str++)
{
*temp_str = (axis2_char_t)toupper((int)*temp_str);
/* We are sure that the conversion is safe */
@@ -819,32 +792,31 @@
const axis2_char_t *haystack,
const axis2_char_t *needle)
{
- axis2_char_t start,
- current;
+ axis2_char_t start, current;
size_t len;
- if (!haystack || !needle)
+ if(!haystack || !needle)
{
return NULL;
}
- if ((start = *needle++))
+ if((start = *needle++))
{
len = strlen(needle);
do
{
do
{
- if (!(current = *haystack++))
+ if(!(current = *haystack++))
{
return NULL;
}
}
- while (toupper((int)current) != toupper((int)start));
+ while(toupper((int)current) != toupper((int)start));
}
- while (axutil_strncasecmp(haystack, needle, (int)len));
+ while(axutil_strncasecmp(haystack, needle, (int)len));
/* We are sure that the difference lies within the int range */
haystack--;
}
- return (axis2_char_t *) haystack;
+ return (axis2_char_t *)haystack;
}
Modified: webservices/axis2/trunk/c/util/src/string_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/string_util.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/string_util.c (original)
+++ webservices/axis2/trunk/c/util/src/string_util.c Tue Aug 18 11:24:00 2009
@@ -33,12 +33,12 @@
axis2_char_t *index = NULL;
- if (!in || !*in)
+ if(!in || !*in)
{
return NULL;
}
list = axutil_array_list_create(env, 10);
- if (!list)
+ if(!list)
{
return NULL;
}
@@ -49,22 +49,20 @@
do
{
index = strchr(str, delim);
- if ((!index) && str && *str)
+ if((!index) && str && *str)
{
- axutil_array_list_add(list, env,
- axutil_strdup(env, str));
+ axutil_array_list_add(list, env, axutil_strdup(env, str));
break;
}
rest = index + 1;
str[index - str] = '\0';
- if (str && *str)
+ if(str && *str)
{
- axutil_array_list_add(list, env,
- axutil_strdup(env, str));
+ axutil_array_list_add(list, env, axutil_strdup(env, str));
}
- if (!rest || !*rest)
+ if(!rest || !*rest)
{
break;
}
@@ -73,8 +71,8 @@
index = NULL;
}
- while (loop_state);
- if (temp)
+ while(loop_state);
+ if(temp)
{
AXIS2_FREE(env->allocator, temp);
}
@@ -92,20 +90,20 @@
axis2_char_t *rest = NULL;
axis2_char_t *index = NULL;
- if (!in && !*in)
+ if(!in && !*in)
{
return NULL;
}
list = axutil_array_list_create(env, 2);
- if (!list)
+ if(!list)
{
return NULL;
}
str = axutil_strdup(env, in);
index = strchr(str, delim);
- if (!index)
+ if(!index)
{
axutil_array_list_add(list, env, str);
axutil_array_list_add(list, env, axutil_strdup(env, ""));
@@ -131,13 +129,13 @@
axis2_char_t *rest = NULL;
axis2_char_t *index = NULL;
- if (!in && !*in)
+ if(!in && !*in)
{
return NULL;
}
list = axutil_array_list_create(env, 2);
- if (!list)
+ if(!list)
{
return NULL;
}
@@ -145,7 +143,7 @@
str = axutil_strdup(env, in);
index = axutil_rindex(str, (axis2_char_t)delim);
/* We are sure that the conversion is safe */
- if (!index)
+ if(!index)
{
axutil_array_list_add(list, env, axutil_strdup(env, ""));
axutil_array_list_add(list, env, str);
Modified: webservices/axis2/trunk/c/util/src/thread_pool.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/thread_pool.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/thread_pool.c (original)
+++ webservices/axis2/trunk/c/util/src/thread_pool.c Tue Aug 18 11:24:00 2009
@@ -30,11 +30,9 @@
{
axutil_thread_pool_t *pool = NULL;
- pool =
- (axutil_thread_pool_t *) AXIS2_MALLOC(allocator,
- sizeof(axutil_thread_pool_t));
+ pool = (axutil_thread_pool_t *)AXIS2_MALLOC(allocator, sizeof(axutil_thread_pool_t));
- if (!pool)
+ if(!pool)
{
return NULL;
}
@@ -47,11 +45,11 @@
axutil_thread_pool_free(
axutil_thread_pool_t *pool)
{
- if (!pool)
+ if(!pool)
{
return;
}
- if (!pool->allocator)
+ if(!pool->allocator)
{
return;
}
@@ -65,11 +63,11 @@
axutil_thread_start_t func,
void *data)
{
- if (!pool)
+ if(!pool)
{
return NULL;
}
- if (!pool->allocator)
+ if(!pool->allocator)
{
return NULL;
}
@@ -81,7 +79,7 @@
axutil_thread_pool_t *pool,
axutil_thread_t *thd)
{
- if (!pool || !thd)
+ if(!pool || !thd)
{
return AXIS2_FAILURE;
}
@@ -93,7 +91,7 @@
axutil_thread_pool_t *pool,
axutil_thread_t *thd)
{
- if (!pool || !thd)
+ if(!pool || !thd)
{
return AXIS2_FAILURE;
}
@@ -105,7 +103,7 @@
axutil_thread_pool_t *pool,
axutil_thread_t *thd)
{
- if (!pool || !thd)
+ if(!pool || !thd)
{
return AXIS2_FAILURE;
}
@@ -120,22 +118,20 @@
axutil_error_t *error = NULL;
allocator = axutil_allocator_clone(system_env->allocator);
error = axutil_error_create(allocator);
- return axutil_env_create_with_error_log_thread_pool(allocator,
- error, system_env->log,
- system_env->
- thread_pool);
+ return axutil_env_create_with_error_log_thread_pool(allocator, error, system_env->log,
+ system_env-> thread_pool);
}
AXIS2_EXTERN void AXIS2_CALL
axutil_free_thread_env(
struct axutil_env *thread_env)
{
- if (!thread_env)
+ if(!thread_env)
{
return;
}
- if (--(thread_env->ref) > 0)
+ if(--(thread_env->ref) > 0)
{
return;
}
@@ -143,7 +139,7 @@
/* log, thread_pool and allocator are shared, so do not free them */
thread_env->log = NULL;
thread_env->thread_pool = NULL;
- if (thread_env->error)
+ if(thread_env->error)
{
AXIS2_ERROR_FREE(thread_env->error);
}
Modified: webservices/axis2/trunk/c/util/src/types.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/types.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/types.c (original)
+++ webservices/axis2/trunk/c/util/src/types.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
@@ -22,11 +21,10 @@
axutil_atoi(
const char *s)
{
- int i,
- n;
+ int i, n;
n = 0;
- for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
+ for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
{
n = 10 * n + (s[i] - '0');
}
@@ -41,7 +39,7 @@
int64_t n;
n = 0;
- for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
+ for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
{
n = 10 * n + (s[i] - '0');
}
@@ -58,7 +56,7 @@
uint64_t n;
n = 0;
- for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
+ for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
{
n = 10 * n + (s[i] - '0');
}
@@ -79,7 +77,7 @@
int64_t n;
n = 0;
- for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
+ for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
{
n = 10 * n + (s[i] - '0');
}