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 [5/5] - in /webservices/axis2/trunk/c/util/src: ./
platforms/unix/ platforms/windows/
Modified: webservices/axis2/trunk/c/util/src/uri.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/uri.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/uri.c (original)
+++ webservices/axis2/trunk/c/util/src/uri.c Tue Aug 18 11:24:00 2009
@@ -194,9 +194,9 @@
axutil_uri_t *uri = NULL;
AXIS2_ENV_CHECK(env, NULL);
- uri = (axutil_uri_t *) AXIS2_MALLOC(env->allocator, sizeof(axutil_uri_t));
+ uri = (axutil_uri_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_uri_t));
- if (!uri)
+ if(!uri)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -213,7 +213,7 @@
uri->fragment = NULL;
uri->hostent = NULL;
uri->port = 0;
- uri->is_ipv6 = 0;
+ uri->is_ipv6 = 0;
return uri;
}
@@ -225,55 +225,55 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if (uri->scheme)
+ if(uri->scheme)
{
AXIS2_FREE(env->allocator, uri->scheme);
uri->scheme = NULL;
}
- if (uri->hostinfo)
+ if(uri->hostinfo)
{
AXIS2_FREE(env->allocator, uri->hostinfo);
uri->hostinfo = NULL;
}
- if (uri->user)
+ if(uri->user)
{
AXIS2_FREE(env->allocator, uri->user);
uri->user = NULL;
}
- if (uri->password)
+ if(uri->password)
{
AXIS2_FREE(env->allocator, uri->password);
uri->password = NULL;
}
- if (uri->hostname)
+ if(uri->hostname)
{
AXIS2_FREE(env->allocator, uri->hostname);
uri->hostname = NULL;
}
- if (uri->port_str)
+ if(uri->port_str)
{
AXIS2_FREE(env->allocator, uri->port_str);
uri->port_str = NULL;
}
- if (uri->path)
+ if(uri->path)
{
AXIS2_FREE(env->allocator, uri->path);
uri->path = NULL;
}
- if (uri->query)
+ if(uri->query)
{
AXIS2_FREE(env->allocator, uri->query);
uri->query = NULL;
}
- if (uri->fragment)
+ if(uri->fragment)
{
AXIS2_FREE(env->allocator, uri->fragment);
uri->fragment = NULL;
@@ -304,12 +304,11 @@
const axis2_char_t *hostinfo;
axis2_char_t *endstr;
int port;
- int v6_offset1 = 0,
- v6_offset2 = 0;
+ int v6_offset1 = 0, v6_offset2 = 0;
AXIS2_PARAM_CHECK(env->error, uri_str, NULL);
- uri = (axutil_uri_t *) axutil_uri_create(env);
+ uri = (axutil_uri_t *)axutil_uri_create(env);
/* Initialize the structure. parse_uri() and parse_uri_components()
* can be called more than once per request.
@@ -320,7 +319,7 @@
* it assumes forward branches are untaken and backwards are taken. That's
* the reason for the gotos.
*/
- if (uri_str[0] == '/')
+ if(uri_str[0] == '/')
{
/* RFC2396 #4.3 says that two leading slashes mean we have an
* authority component, not a path! Fixing this looks scary
@@ -331,44 +330,44 @@
* case of three or more slashes there would seem to be no
* ambiguity, so it is a path after all.
*/
- if (uri_str[1] == '/' && uri_str[2] != '/')
+ if(uri_str[1] == '/' && uri_str[2] != '/')
{
s = uri_str + 2;
goto deal_with_authority;
}
- deal_with_path:
+ deal_with_path:
/* we expect uri to point to first character of path ... remember
* that the path could be empty -- http://foobar?query for example
*/
s = uri_str;
- if ((!uri->hostinfo && uri_str[0] == '/' && uri_str[1] == '/') ||
- (!uri->scheme && uri_str[0] == ':'))
+ if((!uri->hostinfo && uri_str[0] == '/' && uri_str[1] == '/') || (!uri->scheme
+ && uri_str[0] == ':'))
{
- if (uri)
+ if(uri)
{
axutil_uri_free(uri, env);
}
uri = NULL;
goto end;
}
- while ((uri_delims[*(unsigned char *) s] & NOTEND_PATH) == 0)
+ while((uri_delims[*(unsigned char *)s] & NOTEND_PATH) == 0)
{
++s;
}
- if (s != uri_str)
+ if(s != uri_str)
{
uri->path = axutil_strmemdup(uri_str, s - uri_str, env);
}
- if (*s == 0)
+ if(*s == 0)
{
goto end;
}
- if (*s == '?')
+ if(*s == '?')
{
++s;
s1 = strchr(s, '#');
- if (s1)
+ if(s1)
{
uri->fragment = axutil_strdup(env, s1 + 1);
uri->query = axutil_strmemdup(s, s1 - s, env);
@@ -387,33 +386,33 @@
/* find the scheme: */
s = uri_str;
- while ((uri_delims[*(unsigned char *) s] & NOTEND_SCHEME) == 0)
+ while((uri_delims[*(unsigned char *)s] & NOTEND_SCHEME) == 0)
{
++s;
}
/* scheme must be non-empty and followed by :// */
- if (s == uri_str || s[0] != ':' || s[1] != '/' || s[2] != '/')
+ if(s == uri_str || s[0] != ':' || s[1] != '/' || s[2] != '/')
{
- if (uri->scheme)
+ if(uri->scheme)
{
AXIS2_FREE(env->allocator, uri->scheme);
uri->scheme = NULL;
}
s = uri_str; /* restart from beginning as the loop must have ended in
- * in a wrong place. */
- goto deal_with_authority; /* backwards predicted taken! */
+ * in a wrong place. */
+ goto deal_with_authority;
+ /* backwards predicted taken! */
}
uri->scheme = axutil_strmemdup(uri_str, s - uri_str, env);
s += 3;
- deal_with_authority:
- hostinfo = s;
- while ((uri_delims[*(unsigned char *) s] & NOTEND_HOSTINFO) == 0)
+ deal_with_authority: hostinfo = s;
+ while((uri_delims[*(unsigned char *)s] & NOTEND_HOSTINFO) == 0)
{
++s;
}
- uri_str = s; /* whatever follows hostinfo is start of uri */
+ uri_str = s; /* whatever follows hostinfo is start of uri */
uri->hostinfo = axutil_strmemdup(hostinfo, uri_str - hostinfo, env);
/* If there's a username:password@host:port, the @ we want is the last @...
@@ -425,36 +424,35 @@
{
--s;
}
- while (s >= hostinfo && *s != '@');
- if (s < hostinfo)
+ while(s >= hostinfo && *s != '@');
+ if(s < hostinfo)
{
/* again we want the common case to be fall through */
- deal_with_host:
+ deal_with_host:
/* We expect hostinfo to point to the first character of
* the hostname. If there's a port it is the first colon,
* except with IPv6.
*/
- if (*hostinfo == '[')
+ if(*hostinfo == '[')
{
- if (*(hostinfo + 1) == ']')
+ if(*(hostinfo + 1) == ']')
{
- if (uri)
+ if(uri)
{
axutil_uri_free(uri, env);
}
uri = NULL;
goto end;
}
- if ((*(hostinfo + 1) >= '0' && *(hostinfo + 1) <= '9') ||
- (*(hostinfo + 1) >= 'a' && *(hostinfo + 1) <= 'z') ||
- (*(hostinfo + 1) >= 'A' && *(hostinfo + 1) <= 'Z') ||
- (*(hostinfo + 1) == ':' && *(hostinfo + 2) == ':'))
+ if((*(hostinfo + 1) >= '0' && *(hostinfo + 1) <= '9') || (*(hostinfo + 1) >= 'a'
+ && *(hostinfo + 1) <= 'z') || (*(hostinfo + 1) >= 'A' && *(hostinfo + 1) <= 'Z')
+ || (*(hostinfo + 1) == ':' && *(hostinfo + 2) == ':'))
{
uri->is_ipv6 = 1;
}
else
{
- if (uri)
+ if(uri)
{
axutil_uri_free(uri, env);
}
@@ -464,60 +462,56 @@
v6_offset1 = 1;
v6_offset2 = 2;
s = axutil_memchr(hostinfo, ']', uri_str - hostinfo);
- if (!s)
+ if(!s)
{
- if (uri)
+ if(uri)
{
axutil_uri_free(uri, env);
}
uri = NULL;
goto end;
}
- if (*++s != ':')
+ if(*++s != ':')
{
- s = NULL; /* no port */
+ s = NULL; /* no port */
}
}
- else if (!*hostinfo || (*hostinfo >= '0' && *hostinfo <= '9') ||
- (*hostinfo >= 'a' && *hostinfo <= 'z') ||
- (*hostinfo >= 'A' && *hostinfo <= 'Z') ||
- *hostinfo == '?' || *hostinfo == '/' || *hostinfo == '#')
+ else if(!*hostinfo || (*hostinfo >= '0' && *hostinfo <= '9') || (*hostinfo >= 'a'
+ && *hostinfo <= 'z') || (*hostinfo >= 'A' && *hostinfo <= 'Z') || *hostinfo == '?'
+ || *hostinfo == '/' || *hostinfo == '#')
{
s = axutil_memchr(hostinfo, ':', uri_str - hostinfo);
}
else
{
- if (uri)
+ if(uri)
{
axutil_uri_free(uri, env);
}
uri = NULL;
goto end;
}
- if (!s)
+ if(!s)
{
/* we expect the common case to have no port */
- uri->hostname =
- axutil_strmemdup(hostinfo + v6_offset1,
- uri_str - hostinfo - v6_offset2, env);
+ uri->hostname = axutil_strmemdup(hostinfo + v6_offset1,
+ uri_str - hostinfo - v6_offset2, env);
goto deal_with_path;
}
- uri->hostname =
- axutil_strmemdup(hostinfo + v6_offset1, s - hostinfo - v6_offset2,
- env);
+ uri->hostname = axutil_strmemdup(hostinfo + v6_offset1, s - hostinfo - v6_offset2, env);
++s;
uri->port_str = axutil_strmemdup(s, uri_str - s, env);
- if (uri_str != s)
+ if(uri_str != s)
{
port = strtol(uri->port_str, &endstr, 10);
uri->port = (axis2_port_t)port;
/* We are sure that the conversion is safe */
- if (*endstr == '\0')
+ if(*endstr == '\0')
{
goto deal_with_path;
}
/* Invalid characters after ':' found */
- if (uri)
+ if(uri)
{
axutil_uri_free(uri, env);
}
@@ -530,7 +524,7 @@
/* first colon delimits username:password */
s1 = axutil_memchr(hostinfo, ':', s - hostinfo);
- if (s1)
+ if(s1)
{
uri->user = axutil_strmemdup(hostinfo, s1 - hostinfo, env);
++s1;
@@ -543,9 +537,8 @@
hostinfo = s + 1;
goto deal_with_host;
- /* End of function call */
- end:
- return uri;
+ /* End of function call */
+ end: return uri;
}
/* Special case for CONNECT parsing: it comes with the hostinfo part only */
@@ -567,8 +560,8 @@
AXIS2_PARAM_CHECK(env->error, hostinfo, NULL);
- uri = (axutil_uri_t *) axutil_uri_create(env);
- if (!uri)
+ uri = (axutil_uri_t *)axutil_uri_create(env);
+ if(!uri)
{
return NULL;
}
@@ -582,16 +575,16 @@
/* We expect hostinfo to point to the first character of
* the hostname. There must be a port, separated by a colon
*/
- if (*hostinfo == '[')
+ if(*hostinfo == '[')
{
- if (*(hostinfo + 1) == ']')
+ if(*(hostinfo + 1) == ']')
{
axutil_uri_free(uri, env);
return NULL;
}
uri->is_ipv6 = 1;
rsb = strchr(hostinfo, ']');
- if (!rsb || *(rsb + 1) != ':')
+ if(!rsb || *(rsb + 1) != ':')
{
axutil_uri_free(uri, env);
return NULL;
@@ -601,10 +594,9 @@
* IPv6 addresses beginning with "::"
*/
s = rsb + 1;
- if ((*(hostinfo + 1) >= '0' && *(hostinfo + 1) <= '9') ||
- (*(hostinfo + 1) >= 'a' && *(hostinfo + 1) <= 'z') ||
- (*(hostinfo + 1) >= 'A' && *(hostinfo + 1) <= 'Z') ||
- (*(hostinfo + 1) == ':' && *(hostinfo + 2) == ':'))
+ if((*(hostinfo + 1) >= '0' && *(hostinfo + 1) <= '9') || (*(hostinfo + 1) >= 'a'
+ && *(hostinfo + 1) <= 'z') || (*(hostinfo + 1) >= 'A' && *(hostinfo + 1) <= 'Z')
+ || (*(hostinfo + 1) == ':' && *(hostinfo + 2) == ':'))
{
++hostinfo;
}
@@ -615,9 +607,8 @@
}
v6_offset1 = 1;
}
- else if ((*hostinfo >= '0' && *hostinfo <= '9') ||
- (*hostinfo >= 'a' && *hostinfo <= 'z') ||
- (*hostinfo >= 'A' && *hostinfo <= 'Z'))
+ else if((*hostinfo >= '0' && *hostinfo <= '9') || (*hostinfo >= 'a' && *hostinfo <= 'z')
+ || (*hostinfo >= 'A' && *hostinfo <= 'Z'))
{
s = strchr(hostinfo, ':');
}
@@ -626,7 +617,7 @@
axutil_uri_free(uri, env);
return NULL;
}
- if (!s)
+ if(!s)
{
axutil_uri_free(uri, env);
return NULL;
@@ -635,10 +626,10 @@
/* We are sure that the difference lies within the int range */
++s;
uri->port_str = axutil_strdup(env, s);
- if (*s != '\0')
+ if(*s != '\0')
{
- uri->port = (unsigned short) strtol(uri->port_str, &endstr, 10);
- if (*endstr == '\0')
+ uri->port = (unsigned short)strtol(uri->port_str, &endstr, 10);
+ if(*endstr == '\0')
{
return uri;
}
@@ -658,14 +649,14 @@
AXIS2_PARAM_CHECK(env->error, base, NULL);
AXIS2_PARAM_CHECK(env->error, uri, NULL);
- if (!uri || !base || !base->is_initialized || !uri->is_initialized)
+ if(!uri || !base || !base->is_initialized || !uri->is_initialized)
{
return NULL;
}
/* The interesting bit is the path. */
- if (!uri->path)
+ if(!uri->path)
{
- if (!uri->hostname)
+ if(!uri->hostname)
{
/* is this compatible with is_initialised? Harmless in any case */
uri->path = base->path ? base->path : axutil_strdup(env, "/");
@@ -678,7 +669,7 @@
uri->path = axutil_strdup(env, "/");
}
}
- else if (uri->path[0] != '/')
+ else if(uri->path[0] != '/')
{
size_t baselen;
const char *basepath = base->path ? base->path : "/";
@@ -689,16 +680,16 @@
temp = path;
/* if base is nonsensical, bail out */
- if (basepath[0] != '/')
+ if(basepath[0] != '/')
{
return NULL;
}
/* munch "up" components at the start, and chop them from base path */
- while (!strncmp(path, "../", 3))
+ while(!strncmp(path, "../", 3))
{
- while (base_end > basepath)
+ while(base_end > basepath)
{
- if (*--base_end == '/')
+ if(*--base_end == '/')
{
break;
}
@@ -706,52 +697,50 @@
path += 3;
}
/* munch "here" components at the start */
- while (!strncmp(path, "./", 2))
+ while(!strncmp(path, "./", 2))
{
path += 2;
}
baselen = base_end - basepath + 1;
- uri->path =
- AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * baselen + strlen(path) + 1);
+ uri->path = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * baselen + strlen(path) + 1);
memcpy(uri->path, basepath, baselen);
strcpy(uri->path + baselen, path);
- if (temp)
+ if(temp)
{
AXIS2_FREE(env->allocator, temp);
}
}
/* The trivial bits are everything-but-path */
- if (!uri->scheme)
+ if(!uri->scheme)
{
uri->scheme = axutil_strdup(env, base->scheme);
}
- if (!uri->hostinfo)
+ if(!uri->hostinfo)
{
uri->hostinfo = axutil_strdup(env, base->hostinfo);
}
- if (!uri->user)
+ if(!uri->user)
{
uri->user = axutil_strdup(env, base->user);
}
- if (!uri->password)
+ if(!uri->password)
{
uri->password = axutil_strdup(env, base->password);
}
- if (!uri->hostname)
+ if(!uri->hostname)
{
uri->hostname = axutil_strdup(env, base->hostname);
}
- if (!uri->port_str)
+ if(!uri->port_str)
{
uri->port_str = axutil_strdup(env, base->port_str);
}
- if (!uri->hostent)
+ if(!uri->hostent)
{
uri->hostent = base->hostent;
}
- if (!uri->port)
+ if(!uri->port)
{
uri->port = base->port;
}
@@ -770,14 +759,14 @@
axutil_uri_t *temp = NULL;
uptr = axutil_uri_parse_string(env, uri);
- if (!uptr && AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error))
+ if(!uptr && AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error))
{
return uptr;
}
temp = uptr;
uptr = axutil_uri_resolve_relative(env, base, uptr);
- if (!uptr)
+ if(!uptr)
{
axutil_uri_free(temp, env);
}
@@ -790,11 +779,11 @@
{
schemes_t *scheme;
- if (scheme_str)
+ if(scheme_str)
{
- for (scheme = schemes; scheme->name; ++scheme)
+ for(scheme = schemes; scheme->name; ++scheme)
{
- if (axutil_strcasecmp(scheme_str, scheme->name) == 0)
+ if(axutil_strcasecmp(scheme_str, scheme->name) == 0)
{
return scheme->default_port;
}
@@ -810,7 +799,7 @@
{
axutil_uri_t *new_uri = NULL;
- new_uri = (axutil_uri_t *) axutil_uri_create(env);
+ new_uri = (axutil_uri_t *)axutil_uri_create(env);
new_uri->scheme = axutil_strdup(env, uri->scheme);
new_uri->hostinfo = axutil_strdup(env, uri->hostinfo);
@@ -845,58 +834,42 @@
AXIS2_ENV_CHECK(env, NULL);
/* If suppressing the site part, omit both user name & scheme://hostname */
- if (!(flags & AXIS2_URI_UNP_OMITSITEPART))
+ if(!(flags & AXIS2_URI_UNP_OMITSITEPART))
{
/* Construct a "user:password@" string, honoring the passed
* AXIS2_URI_UNP_ flags: */
- if (uri->user || uri->password)
+ if(uri->user || uri->password)
{
- ret =
- axutil_strcat(env,
- (uri->user &&
- !(flags & AXIS2_URI_UNP_OMITUSER)) ? uri->
- user : "", (uri->password &&
- !(flags & AXIS2_URI_UNP_OMITPASSWORD))
- ? ":" : "", (uri->password &&
- !(flags &
- AXIS2_URI_UNP_OMITPASSWORD))
- ? ((flags & AXIS2_URI_UNP_REVEALPASSWORD) ? uri->
- password : "XXXXXXXX") : "", ((uri->user &&
- !(flags &
- AXIS2_URI_UNP_OMITUSER))
- || (uri->password
- && !(flags &
- AXIS2_URI_UNP_OMITPASSWORD)))
- ? "@" : "", NULL);
+ ret = axutil_strcat(env, (uri->user && !(flags & AXIS2_URI_UNP_OMITUSER)) ? uri-> user
+ : "", (uri->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD)) ? ":" : "",
+ (uri->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD)) ? ((flags
+ & AXIS2_URI_UNP_REVEALPASSWORD) ? uri-> password : "XXXXXXXX") : "",
+ ((uri->user && !(flags & AXIS2_URI_UNP_OMITUSER)) || (uri->password && !(flags
+ & AXIS2_URI_UNP_OMITPASSWORD))) ? "@" : "", NULL);
temp = ret;
}
/* Construct scheme://site string */
- if (uri->hostname)
+ if(uri->hostname)
{
int is_default_port;
- const axis2_char_t *lbrk = "",
- *rbrk = "";
+ const axis2_char_t *lbrk = "", *rbrk = "";
- if (uri->is_ipv6)
- { /* v6 literal */
+ if(uri->is_ipv6)
+ { /* v6 literal */
lbrk = "[";
rbrk = "]";
}
- is_default_port = (uri->port_str == NULL || uri->port == 0 ||
- uri->port ==
- axutil_uri_port_of_scheme(uri->scheme));
-
- if (uri->scheme)
- {
- ret =
- axutil_strcat(env, uri->scheme, "://", ret, lbrk,
- uri->hostname, rbrk,
- is_default_port ? "" : ":",
- is_default_port ? "" : uri->port_str, NULL);
- if (temp)
+ is_default_port = (uri->port_str == NULL || uri->port == 0 || uri->port
+ == axutil_uri_port_of_scheme(uri->scheme));
+
+ if(uri->scheme)
+ {
+ ret = axutil_strcat(env, uri->scheme, "://", ret, lbrk, uri->hostname, rbrk,
+ is_default_port ? "" : ":", is_default_port ? "" : uri->port_str, NULL);
+ if(temp)
{
AXIS2_FREE(env->allocator, temp);
}
@@ -908,15 +881,13 @@
* Thus, if no scheme, we omit "//" too, eventhough
* it is a part of authority.
*/
- ret =
- axutil_strcat(env, ret, lbrk, uri->hostname, rbrk,
- is_default_port ? "" : ":",
- is_default_port ? "" : uri->port_str, NULL);
+ ret = axutil_strcat(env, ret, lbrk, uri->hostname, rbrk,
+ is_default_port ? "" : ":", is_default_port ? "" : uri->port_str, NULL);
/*ret =
- axutil_strcat(env, "//", ret, lbrk, uri->hostname, rbrk,
- is_default_port ? "" : ":",
- is_default_port ? "" : uri->port_str, NULL);*/
- if (temp)
+ axutil_strcat(env, "//", ret, lbrk, uri->hostname, rbrk,
+ is_default_port ? "" : ":",
+ is_default_port ? "" : uri->port_str, NULL);*/
+ if(temp)
{
AXIS2_FREE(env->allocator, temp);
}
@@ -926,21 +897,15 @@
}
/* Should we suppress all path info? */
- if (!(flags & AXIS2_URI_UNP_OMITPATHINFO))
+ if(!(flags & AXIS2_URI_UNP_OMITPATHINFO))
{
/* Append path, query and fragment strings: */
- ret =
- axutil_strcat(env, ret, (uri->path) ? uri->path : "",
- (uri->query &&
- !(flags & AXIS2_URI_UNP_OMITQUERY_ONLY)) ? "?" : "",
- (uri->query &&
- !(flags & AXIS2_URI_UNP_OMITQUERY_ONLY)) ? uri->
- query : "", (uri->fragment &&
- !(flags & AXIS2_URI_UNP_OMITFRAGMENT_ONLY)) ? "#"
- : NULL, (uri->fragment &&
- !(flags & AXIS2_URI_UNP_OMITFRAGMENT_ONLY)) ? uri->
- fragment : NULL, NULL);
- if (temp)
+ ret = axutil_strcat(env, ret, (uri->path) ? uri->path : "", (uri->query && !(flags
+ & AXIS2_URI_UNP_OMITQUERY_ONLY)) ? "?" : "", (uri->query && !(flags
+ & AXIS2_URI_UNP_OMITQUERY_ONLY)) ? uri-> query : "", (uri->fragment && !(flags
+ & AXIS2_URI_UNP_OMITFRAGMENT_ONLY)) ? "#" : NULL, (uri->fragment && !(flags
+ & AXIS2_URI_UNP_OMITFRAGMENT_ONLY)) ? uri-> fragment : NULL, NULL);
+ if(temp)
{
AXIS2_FREE(env->allocator, temp);
}
Modified: webservices/axis2/trunk/c/util/src/url.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/url.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/url.c (original)
+++ webservices/axis2/trunk/c/util/src/url.c Tue Aug 18 11:24:00 2009
@@ -32,7 +32,9 @@
axis2_char_t *server;
};
-static int is_safe_or_unreserve (char c);
+static int
+is_safe_or_unreserve(
+ char c);
AXIS2_EXTERN axutil_url_t *AXIS2_CALL
axutil_url_create(
@@ -46,16 +48,14 @@
AXIS2_ENV_CHECK(env, NULL);
AXIS2_PARAM_CHECK(env->error, protocol, NULL);
- if (!protocol || !*protocol ||
- strstr(protocol, "://") ||
- (host && strchr(host, '/')))
+ if(!protocol || !*protocol || strstr(protocol, "://") || (host && strchr(host, '/')))
{
return NULL;
}
- url = (axutil_url_t *) AXIS2_MALLOC(env->allocator, sizeof(axutil_url_t));
+ url = (axutil_url_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_url_t));
- if (!url)
+ if(!url)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
@@ -67,9 +67,9 @@
url->server = NULL;
url->query = NULL;
- if (host)
+ if(host)
{
- url->host = (axis2_char_t *) axutil_strdup(env, host);
+ url->host = (axis2_char_t *)axutil_strdup(env, host);
url->port = port;
}
else
@@ -79,29 +79,29 @@
/** if the path is not starting with / we have to make it so
*/
- if (path)
+ if(path)
{
axis2_char_t *params = NULL;
axis2_char_t *temp = NULL;
- if (path[0] == '/')
+ if(path[0] == '/')
{
- temp = (axis2_char_t *) axutil_strdup(env, path);
+ temp = (axis2_char_t *)axutil_strdup(env, path);
}
else
{
temp = axutil_stracat(env, "/", path);
}
params = strchr(temp, '?');
- if (!params)
+ if(!params)
{
params = strchr(temp, '#');
}
- if (params)
+ if(params)
{
- url->query = (axis2_char_t *) axutil_strdup(env, params);
+ url->query = (axis2_char_t *)axutil_strdup(env, params);
*params = '\0';
}
- url->path = (axis2_char_t *) axutil_strdup(env, temp);
+ url->path = (axis2_char_t *)axutil_strdup(env, temp);
AXIS2_FREE(env->allocator, temp);
}
@@ -116,7 +116,7 @@
/**
* Only accepted format is :
* protocol://host:port/path
- * Added file:///path
+ * Added file:///path
* port is optional and the default port is assumed
* if path is not present / (root) is assumed
*/
@@ -132,20 +132,20 @@
AXIS2_PARAM_CHECK(env->error, str_url, NULL);
tmp_url_str = axutil_strdup(env, str_url);
- if (!tmp_url_str)
+ if(!tmp_url_str)
{
return NULL;
}
protocol = tmp_url_str;
host = strstr(tmp_url_str, "://");
- if (!host)
+ if(!host)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
-
+
AXIS2_FREE(env->allocator, tmp_url_str);
return NULL;
}
- if (axutil_strlen(host) < 3 * sizeof(axis2_char_t))
+ if(axutil_strlen(host) < 3 * sizeof(axis2_char_t))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid IP or hostname");
@@ -154,7 +154,7 @@
}
*host = '\0';
host += 3 * sizeof(axis2_char_t); /* skip "://" part */
- if (axutil_strlen(host) <= 0)
+ if(axutil_strlen(host) <= 0)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid IP or hostname");
@@ -164,7 +164,7 @@
/* if the url is file:// thing we need the protocol and
* path only
*/
- if (0 == axutil_strcasecmp(protocol, (const axis2_char_t *) "file"))
+ if(0 == axutil_strcasecmp(protocol, (const axis2_char_t *)"file"))
{
ret = axutil_url_create(env, protocol, NULL, 0, host);
AXIS2_FREE(env->allocator, tmp_url_str);
@@ -172,10 +172,10 @@
}
port_str = strchr(host, ':');
- if (!port_str)
+ if(!port_str)
{
path = strchr(host, '/');
- if (!path)
+ if(!path)
{
path = strchr(host, '?');
}
@@ -183,11 +183,11 @@
{
*path++ = '\0';
}
- if (!path)
+ if(!path)
{
path = strchr(host, '#');
}
- if (!path)
+ if(!path)
{
/* No path - assume def path ('/') */
/* here we have protocol + host + def port + def path */
@@ -212,10 +212,10 @@
{
*port_str++ = '\0';
path = strchr(port_str, '/');
- if (!path)
+ if(!path)
{
path = strchr(port_str, '?');
- if (path)
+ if(path)
{
*path = '\0';
port = AXIS2_ATOI(port_str);
@@ -227,17 +227,17 @@
*path++ = '\0';
port = AXIS2_ATOI(port_str);
}
- if (!path)
+ if(!path)
{
path = strchr(port_str, '#');
- if (path)
+ if(path)
{
*path = '\0';
port = AXIS2_ATOI(port_str);
*path = '#';
}
}
- if (!path)
+ if(!path)
{
port = AXIS2_ATOI(port_str);
/* here we have protocol + host + port + def path */
@@ -247,7 +247,7 @@
}
else
{
- if (axutil_strlen(path) > 0)
+ if(axutil_strlen(path) > 0)
{
axis2_char_t *path_temp = NULL;
@@ -275,27 +275,27 @@
axutil_url_t *url,
const axutil_env_t *env)
{
- if (url->protocol)
+ if(url->protocol)
{
AXIS2_FREE(env->allocator, url->protocol);
url->protocol = NULL;
}
- if (url->host)
+ if(url->host)
{
AXIS2_FREE(env->allocator, url->host);
url->host = NULL;
}
- if (url->server)
+ if(url->server)
{
AXIS2_FREE(env->allocator, url->server);
url->server = NULL;
}
- if (url->path)
+ if(url->path)
{
AXIS2_FREE(env->allocator, url->path);
url->path = NULL;
}
- if (url->query)
+ if(url->query)
{
AXIS2_FREE(env->allocator, url->query);
url->query = NULL;
@@ -315,42 +315,38 @@
axis2_bool_t print_port = AXIS2_FALSE;
AXIS2_PARAM_CHECK(env->error, url, NULL);
- if (!url->protocol)
+ if(!url->protocol)
{
return NULL;
}
- if (url->port != 0 &&
- url->port != axutil_uri_port_of_scheme(url->protocol))
+ if(url->port != 0 && url->port != axutil_uri_port_of_scheme(url->protocol))
{
print_port = AXIS2_TRUE;
sprintf(port_str, "%d", url->port);
}
len = axutil_strlen(url->protocol) + 6;
- if (url->host)
+ if(url->host)
{
len += axutil_strlen(url->host);
}
- if (url->path)
+ if(url->path)
{
len += axutil_strlen(url->path);
}
- if (url->query)
+ if(url->query)
{
len += axutil_strlen(url->query);
}
- if (print_port)
+ if(print_port)
{
len += axutil_strlen(port_str) + 1;
}
- external_form = (axis2_char_t *) AXIS2_MALLOC(env->allocator, len);
- sprintf(external_form, "%s://%s%s%s%s%s", url->protocol,
- (url->host) ? url->host : "",
- (print_port) ? ":" : "",
- (print_port) ? port_str : "",
- (url->path) ? url->path : "",
- (url->query) ? url->query : "");
+ external_form = (axis2_char_t *)AXIS2_MALLOC(env->allocator, len);
+ sprintf(external_form, "%s://%s%s%s%s%s", url->protocol, (url->host) ? url->host : "",
+ (print_port) ? ":" : "", (print_port) ? port_str : "", (url->path) ? url->path : "",
+ (url->query) ? url->query : "");
return external_form;
}
@@ -361,7 +357,7 @@
axis2_char_t *protocol)
{
AXIS2_PARAM_CHECK(env->error, protocol, AXIS2_FAILURE);
- if (url->protocol)
+ if(url->protocol)
{
AXIS2_FREE(env->allocator, url->protocol);
url->protocol = NULL;
@@ -389,31 +385,28 @@
axis2_bool_t print_port = AXIS2_FALSE;
AXIS2_PARAM_CHECK(env->error, host, AXIS2_FAILURE);
- if (url->host)
+ if(url->host)
{
AXIS2_FREE(env->allocator, url->host);
}
url->host = axutil_strdup(env, host);
- if (url->server)
+ if(url->server)
{
AXIS2_FREE(env->allocator, url->server);
}
- if (!url->host)
+ if(!url->host)
{
return AXIS2_SUCCESS;
}
len += axutil_strlen(url->host);
- if (url->port != 0 && (!url->protocol ||
- url->port != axutil_uri_port_of_scheme(url->protocol)))
+ if(url->port != 0 && (!url->protocol || url->port != axutil_uri_port_of_scheme(url->protocol)))
{
print_port = AXIS2_TRUE;
sprintf(port_str, "%d", url->port);
len += axutil_strlen(port_str) + 1;
}
- url->server = (axis2_char_t *) AXIS2_MALLOC(env->allocator, len);
- sprintf(url->server, "%s%s%s", url->host,
- (print_port) ? ":" : "",
- (print_port) ? port_str : "");
+ url->server = (axis2_char_t *)AXIS2_MALLOC(env->allocator, len);
+ sprintf(url->server, "%s%s%s", url->host, (print_port) ? ":" : "", (print_port) ? port_str : "");
return AXIS2_SUCCESS;
}
@@ -436,23 +429,23 @@
AXIS2_PARAM_CHECK(env->error, server, AXIS2_FAILURE);
temp = axutil_strdup(env, server);
- if (temp && *temp == ':')
+ if(temp && *temp == ':')
{
AXIS2_FREE(env->allocator, temp);
return AXIS2_FAILURE;
}
- if (strchr(temp, '/'))
+ if(strchr(temp, '/'))
{
AXIS2_FREE(env->allocator, temp);
return AXIS2_FAILURE;
}
- if (url->server)
+ if(url->server)
{
AXIS2_FREE(env->allocator, url->server);
}
- if (url->host)
+ if(url->host)
{
AXIS2_FREE(env->allocator, url->host);
}
@@ -461,7 +454,7 @@
url->server = axutil_strdup(env, server);
port_str = strchr(temp, ':');
- if (port_str)
+ if(port_str)
{
*port_str++ = '\0';
url->port = AXIS2_ATOI(port_str);
@@ -481,31 +474,28 @@
axis2_char_t port_str[8];
axis2_bool_t print_port = AXIS2_FALSE;
- if (!url->server && !url->host)
+ if(!url->server && !url->host)
{
return NULL;
}
- else if (!url->host)
+ else if(!url->host)
{
AXIS2_FREE(env->allocator, url->server);
return NULL;
}
- else if (url->server)
+ else if(url->server)
{
return url->server;
}
len += axutil_strlen(url->host);
- if (url->port != 0 && (!url->protocol ||
- url->port != axutil_uri_port_of_scheme(url->protocol)))
+ if(url->port != 0 && (!url->protocol || url->port != axutil_uri_port_of_scheme(url->protocol)))
{
print_port = AXIS2_TRUE;
sprintf(port_str, "%d", url->port);
len += axutil_strlen(port_str);
}
- url->server = (axis2_char_t *) AXIS2_MALLOC(env->allocator, len + 1);
- sprintf(url->server, "%s%s%s", url->host,
- (print_port) ? ":" : "",
- (print_port) ? port_str : "");
+ url->server = (axis2_char_t *)AXIS2_MALLOC(env->allocator, len + 1);
+ sprintf(url->server, "%s%s%s", url->host, (print_port) ? ":" : "", (print_port) ? port_str : "");
return url->server;
}
@@ -518,31 +508,28 @@
axis2_ssize_t len = 0;
axis2_char_t port_str[8];
axis2_bool_t print_port = AXIS2_FALSE;
- if (url->port == port)
+ if(url->port == port)
{
return AXIS2_SUCCESS;
}
url->port = port;
- if (url->server)
+ if(url->server)
{
AXIS2_FREE(env->allocator, url->server);
}
- if (!url->host)
+ if(!url->host)
{
return AXIS2_SUCCESS;
}
len += axutil_strlen(url->host);
- if (url->port != 0 && (!url->protocol ||
- url->port != axutil_uri_port_of_scheme(url->protocol)))
+ if(url->port != 0 && (!url->protocol || url->port != axutil_uri_port_of_scheme(url->protocol)))
{
print_port = AXIS2_TRUE;
sprintf(port_str, "%d", url->port);
len += axutil_strlen(port_str) + 1;
}
- url->server = (axis2_char_t *) AXIS2_MALLOC(env->allocator, len);
- sprintf(url->server, "%s%s%s", url->host,
- (print_port) ? ":" : "",
- (print_port) ? port_str : "");
+ url->server = (axis2_char_t *)AXIS2_MALLOC(env->allocator, len);
+ sprintf(url->server, "%s%s%s", url->host, (print_port) ? ":" : "", (print_port) ? port_str : "");
return AXIS2_SUCCESS;
}
@@ -551,9 +538,9 @@
axutil_url_t *url,
const axutil_env_t *env)
{
- if (!url->port)
+ if(!url->port)
{
- return axutil_uri_port_of_scheme(url->protocol);
+ return axutil_uri_port_of_scheme(url->protocol);
}
return url->port;
}
@@ -565,7 +552,7 @@
axis2_char_t * path)
{
AXIS2_PARAM_CHECK(env->error, path, AXIS2_FAILURE);
- if (url->path)
+ if(url->path)
{
AXIS2_FREE(env->allocator, url->path);
}
@@ -589,22 +576,21 @@
axis2_char_t *temp = NULL;
axutil_url_t *ret = NULL;
- if (url->path && url->query)
+ if(url->path && url->query)
{
temp = axutil_stracat(env, url->path, url->query);
}
- else if (url->path)
+ else if(url->path)
{
temp = axutil_strdup(env, url->path);
}
- else if (url->query)
+ else if(url->query)
{
temp = axutil_strdup(env, url->query);
}
- ret = axutil_url_create(env, url->protocol, url->host, url->port,
- url->path);
- if (temp)
+ ret = axutil_url_create(env, url->protocol, url->host, url->port, url->path);
+ if(temp)
{
AXIS2_FREE(env->allocator, temp);
}
@@ -623,86 +609,86 @@
return uri;
}
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-axutil_url_encode (
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axutil_url_encode(
const axutil_env_t *env,
axis2_char_t *dest,
- axis2_char_t *buff, int len)
+ axis2_char_t *buff,
+ int len)
{
axis2_char_t string[4];
axis2_char_t *expand_buffer = NULL;
- axis2_char_t *temp = NULL;
+ axis2_char_t *temp = NULL;
int i;
- for (i = 0; i < len && buff[i]; i++)
+ for(i = 0; i < len && buff[i]; i++)
{
- if (isalnum (buff[i]) || is_safe_or_unreserve (buff[i]))
+ if(isalnum(buff[i]) || is_safe_or_unreserve(buff[i]))
{
- sprintf (string, "%c", buff[i]);
+ sprintf(string, "%c", buff[i]);
}
else
{
/* %%%x is to print % mark with the hex value */
- sprintf (string, "%%%x", buff[i]);
+ sprintf(string, "%%%x", buff[i]);
}
- if (((int)strlen (dest) + 4) > len)
+ if(((int)strlen(dest) + 4) > len)
{
- expand_buffer =
- (axis2_char_t *) AXIS2_MALLOC (env->allocator, len * 2);
- memset (expand_buffer, 0, len * 2);
+ expand_buffer = (axis2_char_t *)AXIS2_MALLOC(env->allocator, len * 2);
+ memset(expand_buffer, 0, len * 2);
len *= 2;
- temp = memmove (expand_buffer, dest, strlen (dest));
- if(dest)
- {
- AXIS2_FREE(env->allocator, dest);
- dest = NULL;
- }
- dest = temp;
+ temp = memmove(expand_buffer, dest, strlen(dest));
+ if(dest)
+ {
+ AXIS2_FREE(env->allocator, dest);
+ dest = NULL;
+ }
+ dest = temp;
}
- strcat (dest, string);
+ strcat(dest, string);
}
return dest;
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axutil_url_get_query(
- axutil_url_t *url,
- const axutil_env_t *env)
+ axutil_url_t *url,
+ const axutil_env_t *env)
{
- return url->query;
+ return url->query;
}
-
static int
-is_safe_or_unreserve (char c)
+is_safe_or_unreserve(
+ char c)
{
- char safe[] = { '-', '_', '.', '~'};
- char reserve[] = { ';', '/', '?', ':', '@', '&', '=', '#', '[', ']', '!',
- '$', '\'', '(', ')', '*', '+', ','};
-
-/* These are reserved and safe charaters , got from RFC
- *
- * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "="
- * safe = "$" | "-" | "_" | "." | "+"
- */
+ char safe[] = { '-', '_', '.', '~' };
+ char reserve[] = { ';', '/', '?', ':', '@', '&', '=', '#', '[', ']', '!', '$', '\'', '(', ')',
+ '*', '+', ',' };
+
+ /* These are reserved and safe charaters , got from RFC
+ *
+ * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "="
+ * safe = "$" | "-" | "_" | "." | "+"
+ */
int flag = 0;
int i = 0;
- int size = sizeof (safe) / sizeof (safe[0]);
- for (i = 0; i < size; i++)
+ int size = sizeof(safe) / sizeof(safe[0]);
+ for(i = 0; i < size; i++)
{
- if (c == safe[i])
+ if(c == safe[i])
{
flag = 1;
return flag;
}
}
- size = sizeof (reserve) / sizeof (reserve[0]);
- for (i = 0; i < size; i++)
+ size = sizeof(reserve) / sizeof(reserve[0]);
+ for(i = 0; i < size; i++)
{
- if (c == reserve[i])
+ if(c == reserve[i])
{
flag = 0;
return flag;
Modified: webservices/axis2/trunk/c/util/src/utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/utils.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/utils.c (original)
+++ webservices/axis2/trunk/c/util/src/utils.c Tue Aug 18 11:24:00 2009
@@ -51,9 +51,9 @@
tmp2 = AXIS2_MALLOC(env->allocator, 2 * (sizeof(axis2_char_t *)));
memset(tmp2, 0, 2 * sizeof(axis2_char_t *));
- if (tmpl[0] == '/')
+ if(tmpl[0] == '/')
{
- tmp1 = (axis2_char_t *) tmpl;
+ tmp1 = (axis2_char_t *)tmpl;
tmp1++;
resource = axutil_strdup(env, tmp1);
}
@@ -63,20 +63,20 @@
}
i = (int)strlen(resource);
/* We are sure that the difference lies within the int range */
- if (resource[i] == '/')
+ if(resource[i] == '/')
{
resource[i] = '\0';
}
tmp1 = strchr(resource, '?');
- if (tmp1)
+ if(tmp1)
{
axis2_char_t *tmp4 = NULL;
-
+
tmp4 = tmp1;
tmp1++;
resource[tmp4 - resource] = '\0';
- if (*tmp1 && ((tmp1 - resource) < (int)strlen(resource) - 1))
- /* We are sure that the difference lies within the int range */
+ if(*tmp1 && ((tmp1 - resource) < (int)strlen(resource) - 1))
+ /* We are sure that the difference lies within the int range */
{
query = tmp1;
/*
@@ -90,27 +90,27 @@
i = (int)strlen(resource);
/* We are sure that the difference lies within the int range */
- if (!strchr(resource, '{') && !strchr(resource, '}'))
+ if(!strchr(resource, '{') && !strchr(resource, '}'))
{
i = 0;
}
- for (j = 0; j < i; j++)
+ for(j = 0; j < i; j++)
{
- if (!in_tok)
+ if(!in_tok)
{
- if (resource[j] == '}')
+ if(resource[j] == '}')
{
AXIS2_FREE(env->allocator, resource);
return AXIS2_FAILURE;
}
- else if (resource[j] == '{')
+ else if(resource[j] == '{')
{
- if (j + 1 == i || resource[j + 1] == '}')
+ if(j + 1 == i || resource[j + 1] == '}')
{
AXIS2_FREE(env->allocator, resource);
return AXIS2_FAILURE;
}
- else if (resource[j + 1] == '{')
+ else if(resource[j + 1] == '{')
{
j++;
}
@@ -122,14 +122,14 @@
}
else
{
- if (resource[j] == '{')
+ if(resource[j] == '{')
{
AXIS2_FREE(env->allocator, resource);
return AXIS2_FAILURE;
}
- else if (resource[j] == '}')
+ else if(resource[j] == '}')
{
- if (j + 1 < i && resource[j + 1] == '}')
+ if(j + 1 < i && resource[j + 1] == '}')
{
j++;
}
@@ -140,7 +140,7 @@
}
}
}
- if (in_tok)
+ if(in_tok)
{
AXIS2_FREE(env->allocator, resource);
return AXIS2_FAILURE;
@@ -148,9 +148,9 @@
/* Validity of template guaranteed if not returned */
- if (url[0] == '/')
+ if(url[0] == '/')
{
- tmp1 = (axis2_char_t *) url;
+ tmp1 = (axis2_char_t *)url;
tmp1++;
url_resource = axutil_strdup(env, tmp1);
}
@@ -162,22 +162,22 @@
/* We are sure that the difference lies within the int range */
- if (url_resource[i] == '/')
+ if(url_resource[i] == '/')
{
url_resource[i] = '\0';
}
i = 0;
url_tmp = url_resource;
tmp1 = strchr(url_resource, '?');
- if (tmp1)
+ if(tmp1)
{
axis2_char_t *tmp4 = NULL;
-
+
tmp4 = tmp1;
tmp1++;
url_resource[tmp4 - url_resource] = '\0';
- if (*tmp1 && ((tmp1 - url_resource) < (int)strlen(url_resource) - 1))
- /* We are sure that the difference lies within the int range */
+ if(*tmp1 && ((tmp1 - url_resource) < (int)strlen(url_resource) - 1))
+ /* We are sure that the difference lies within the int range */
{
url_query = tmp1;
}
@@ -186,20 +186,20 @@
/* Simplest case match */
- if (!strchr(resource, '{'))
+ if(!strchr(resource, '{'))
{
- if (strcmp(resource, url_resource) == 0)
+ if(strcmp(resource, url_resource) == 0)
{
finished = AXIS2_TRUE;
}
}
- while (!finished)
+ while(!finished)
{
tmp4 = strchr(tmp1, '{');
- if (tmp4 && tmp4[1])
+ if(tmp4 && tmp4[1])
{
- if (tmp4[1] != '{')
+ if(tmp4[1] != '{')
{
axis2_char_t *tmp5 = NULL;
axis2_char_t *tmp6 = NULL;
@@ -212,25 +212,25 @@
tmp2[0] = AXIS2_MALLOC(env->allocator, (i + 1) * sizeof(char));
strncpy(tmp2[0], tmp1, i);
tmp2[0][i] = '\0';
- if (url_tmp && *url_tmp)
+ if(url_tmp && *url_tmp)
{
tmp6 = url_tmp;
tmp5 = strstr(tmp6, tmp2[0]);
- if (tmp5)
+ if(tmp5)
{
tmp5 += strlen(tmp2[0]);
tmp7 = tmp4;
tmp8 = tmp4;
tmp7++;
- if (*tmp7)
+ if(*tmp7)
{
axis2_bool_t finished_tmp = AXIS2_FALSE;
- while (!finished_tmp)
+ while(!finished_tmp)
{
tmp6 = strchr(tmp8, '}');
- if (tmp6 && *tmp6)
+ if(tmp6 && *tmp6)
{
- if (tmp6[1] != '}')
+ if(tmp6[1] != '}')
{
tmp8 = tmp6 + 1;
break;
@@ -241,18 +241,18 @@
finished_tmp = AXIS2_TRUE;
}
}
- if (!finished_tmp && !strchr(tmp8, '{'))
+ if(!finished_tmp && !strchr(tmp8, '{'))
{
tmp7 = tmp8 + strlen(tmp8);
}
else
{
- while (!finished_tmp)
+ while(!finished_tmp)
{
tmp6 = strchr(tmp8, '{');
- if (tmp6 && tmp6[1])
+ if(tmp6 && tmp6[1])
{
- if (tmp6[1] != '{')
+ if(tmp6[1] != '{')
{
tmp7 = tmp6;
break;
@@ -264,7 +264,7 @@
}
}
}
- if (!finished_tmp)
+ if(!finished_tmp)
{
i = (int)(tmp7 - tmp8);
tmp9 = AXIS2_MALLOC(env->allocator, (i + 1) * sizeof(char));
@@ -272,10 +272,10 @@
tmp9[i] = '\0';
}
}
- if (tmp9 && *tmp9)
+ if(tmp9 && *tmp9)
{
tmp6 = strstr(tmp5, tmp9);
- AXIS2_FREE (env->allocator, tmp9);
+ AXIS2_FREE(env->allocator, tmp9);
tmp9 = NULL;
}
else
@@ -283,7 +283,7 @@
tmp6 = strchr(tmp5, '/');
}
/* Logic for saving the match */
- if (tmp6 && tmp6 != tmp5)
+ if(tmp6 && tmp6 != tmp5)
{
i = (int)(tmp6 - tmp5);
url_tmp = tmp6;
@@ -306,17 +306,17 @@
{
break;
}
- while (!finished)
+ while(!finished)
{
tmp1 = tmp4 + 1;
tmp4 = strchr(tmp1, '}');
- if (tmp4 && *tmp4)
+ if(tmp4 && *tmp4)
{
- if (tmp4[1] != '}')
+ if(tmp4[1] != '}')
{
/* Logic for saving the key for the match */
i = (int)(tmp4 - tmp1);
- if (tmp2[0])
+ if(tmp2[0])
{
AXIS2_FREE(env->allocator, tmp2[0]);
}
@@ -325,7 +325,8 @@
tmp2[0][i] = '\0';
tmp3 = ret;
ret_count++;
- ret = AXIS2_MALLOC(env->allocator, ret_count * 2 * (sizeof(axis2_char_t *)));
+ ret = AXIS2_MALLOC(env->allocator, ret_count * 2
+ * (sizeof(axis2_char_t *)));
memset(ret, 0, ret_count * 2 * sizeof(axis2_char_t *));
for(i = 0; i < ret_count - 1; i++)
{
@@ -356,7 +357,7 @@
else
{
/* Result of mismatch at the simplest case */
- if (!strchr(resource, '{'))
+ if(!strchr(resource, '{'))
{
finished = AXIS2_FALSE;
break;
@@ -365,27 +366,27 @@
}
tmp1 = tmp4 + 1;
}
- if (resource)
+ if(resource)
{
AXIS2_FREE(env->allocator, resource);
}
- if (url_resource)
+ if(url_resource)
{
AXIS2_FREE(env->allocator, url_resource);
}
- if (tmp2)
+ if(tmp2)
{
- if (tmp2[0])
+ if(tmp2[0])
{
AXIS2_FREE(env->allocator, tmp2[0]);
}
- if (tmp2[1])
+ if(tmp2[1])
{
AXIS2_FREE(env->allocator, tmp2[1]);
}
AXIS2_FREE(env->allocator, tmp2);
}
- if (finished)
+ if(finished)
{
status = AXIS2_SUCCESS;
}
@@ -405,24 +406,24 @@
int i = 0;
ret = AXIS2_MALLOC(env->allocator, 2 * (sizeof(axis2_char_t *)));
memset(ret, 0, 2 * sizeof(axis2_char_t *));
- tmp = (axis2_char_t *) request;
+ tmp = (axis2_char_t *)request;
tmp = strstr(tmp, axis2_request_url_prefix);
- if (tmp)
+ if(tmp)
{
service_str = tmp;
tmp += axutil_strlen(axis2_request_url_prefix);
/*break stop on first prefix as user may have prefix in service name */
}
- if (service_str)
+ if(service_str)
{
service_str += axutil_strlen(axis2_request_url_prefix);
- if ('\0' != *service_str)
+ if('\0' != *service_str)
{
- if (*service_str == '/')
- service_str++; /*to remove the leading '/' */
+ if(*service_str == '/')
+ service_str++; /*to remove the leading '/' */
tmp = strchr(service_str, '/');
- if (tmp)
+ if(tmp)
{
i = (int)(tmp - service_str);
ret[0] = AXIS2_MALLOC(env->allocator, i * sizeof(char) + 1);
@@ -431,15 +432,14 @@
/* Now search for the op */
service_str = tmp;
- if ('\0' != *service_str)
+ if('\0' != *service_str)
{
service_str++;
tmp = strchr(service_str, '?');
- if (tmp)
+ if(tmp)
{
i = (int)(tmp - service_str);
- ret[1] =
- AXIS2_MALLOC(env->allocator, i * sizeof(char) + 1);
+ ret[1] = AXIS2_MALLOC(env->allocator, i * sizeof(char) + 1);
strncpy(ret[1], service_str, i);
ret[1][i] = '\0';
}
@@ -471,38 +471,38 @@
char *qscan;
char c;
- for (scan = s; (c = *scan) != '\0'; ++scan, ++len)
+ for(scan = s; (c = *scan) != '\0'; ++scan, ++len)
{
- if (c == '<' || c == '>')
- extra += 3; /* < or > */
- else if (c == '&')
- extra += 4; /* & */
- else if (quotes && c == '"')
- extra += 5; /* " */
+ if(c == '<' || c == '>')
+ extra += 3; /* < or > */
+ else if(c == '&')
+ extra += 4; /* & */
+ else if(quotes && c == '"')
+ extra += 5; /* " */
}
/* nothing to do */
- if (extra == 0)
+ if(extra == 0)
return NULL;
qstr = AXIS2_MALLOC(env->allocator, len + extra + 1);
- for (scan = s, qscan = qstr; (c = *scan) != '\0'; ++scan)
+ for(scan = s, qscan = qstr; (c = *scan) != '\0'; ++scan)
{
- if (c == '<')
+ if(c == '<')
{
*qscan++ = '&';
*qscan++ = 'l';
*qscan++ = 't';
*qscan++ = ';';
}
- else if (c == '>')
+ else if(c == '>')
{
*qscan++ = '&';
*qscan++ = 'g';
*qscan++ = 't';
*qscan++ = ';';
}
- else if (c == '&')
+ else if(c == '&')
{
*qscan++ = '&';
*qscan++ = 'a';
@@ -510,7 +510,7 @@
*qscan++ = 'p';
*qscan++ = ';';
}
- else if (quotes && c == '"')
+ else if(quotes && c == '"')
{
*qscan++ = '&';
*qscan++ = 'q';
@@ -529,7 +529,6 @@
return qstr;
}
-
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axutil_url_decode(
const axutil_env_t *env,
@@ -539,9 +538,9 @@
AXIS2_PARAM_CHECK(env->error, dest, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, src, AXIS2_FAILURE);
- for (; *src != '\0'; ++dest, ++src)
+ for(; *src != '\0'; ++dest, ++src)
{
- if (src[0] == '%' && isxdigit(src[1]) && isxdigit(src[2]))
+ if(src[0] == '%' && isxdigit(src[1]) && isxdigit(src[2]))
{
*dest = (axis2_char_t)(axutil_hexit(src[1]) * 16 + axutil_hexit(src[2]));
/* We are sure that the conversion is safe */
@@ -558,21 +557,22 @@
}
AXIS2_EXTERN int AXIS2_CALL
-axutil_hexit(axis2_char_t c)
+axutil_hexit(
+ axis2_char_t c)
{
- if (c >= '0' && c <= '9')
+ if(c >= '0' && c <= '9')
{
return c - '0';
}
- if (c >= 'a' && c <= 'f')
+ if(c >= 'a' && c <= 'f')
{
return c - 'a' + 10;
}
- if (c >= 'A' && c <= 'F')
+ if(c >= 'A' && c <= 'F')
{
return c - 'A' + 10;
}
- return 0;
+ return 0;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -586,21 +586,19 @@
int i = 0;
axis2_byte_t *bytes = NULL;
- length = (int) axutil_strlen(char_buffer);
- bytes = (axis2_byte_t *)
- AXIS2_MALLOC(env->allocator, length * sizeof(axis2_byte_t));
+ length = (int)axutil_strlen(char_buffer);
+ bytes = (axis2_byte_t *)AXIS2_MALLOC(env->allocator, length * sizeof(axis2_byte_t));
- if (!bytes)
+ if(!bytes)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "No memory. Cannot create byte buffer");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create byte buffer");
return AXIS2_FAILURE;
}
- for (i = 0; i < length; i++)
+ for(i = 0; i < length; i++)
{
- bytes[i] = (axis2_byte_t) char_buffer[i];
+ bytes[i] = (axis2_byte_t)char_buffer[i];
}
*byte_buffer = bytes;
*byte_buffer_size = length;
Modified: webservices/axis2/trunk/c/util/src/uuid_gen.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/uuid_gen.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/uuid_gen.c (original)
+++ webservices/axis2/trunk/c/util/src/uuid_gen.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,7 +24,7 @@
axis2_char_t *str = AXIS2_MALLOC(env->allocator, 40 * sizeof(char));
axutil_platform_uuid_gen(str);
- if (!str)
+ if(!str)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UUID_GEN_FAILED, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "AXIS2_ERROR_UUID_GEN_FAILED");
Modified: webservices/axis2/trunk/c/util/src/version.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/version.c?rev=805365&r1=805364&r2=805365&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/version.c (original)
+++ webservices/axis2/trunk/c/util/src/version.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