summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CIAO/DAnCE/RepositoryManager/URL_Parser.cpp')
-rw-r--r--CIAO/DAnCE/RepositoryManager/URL_Parser.cpp71
1 files changed, 37 insertions, 34 deletions
diff --git a/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp b/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp
index 25ddcc9fa3c..3024606da7f 100644
--- a/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp
+++ b/CIAO/DAnCE/RepositoryManager/URL_Parser.cpp
@@ -20,15 +20,18 @@ URL_Parser::parse_args (int argc, ACE_TCHAR *argv[])
case 'd':
this->debug_ = true;
break;
- case 'u':
- success = parseURL (get_opt.opt_arg ());
- break;
+ case 'u':
+ success = parseURL (get_opt.opt_arg ());
+ break;
// Usage fallthrough.
default:
success = false;
}
+
if (this->hostname_ == 0 || this->filename_ == 0)
- success = false;
+ {
+ success = false;
+ }
return success;
}
@@ -50,34 +53,37 @@ bool URL_Parser::parseURL (char* url)
url += ACE_OS::strlen ("http://");
if (url[0] == '/')
- {
- this->filename_ = ACE_OS::strdup (url);
- }
+ {
+ this->filename_ = ACE_OS::strdup (url);
+ }
else
- { ptr = ACE_OS::strstr (url, ":");
- if (ptr)
- this->port_ = ACE_OS::atoi (ptr + 1);
- else
- ptr = ACE_OS::strstr (url, "/");
-
- if(!ptr)
- success = false;
- else
{
- size_t host_len = ptr - url;
- ACE_NEW_RETURN (this->hostname_, char [host_len + 1], false);
- ACE_OS::strncpy (this->hostname_, url, host_len);
- this->hostname_ [host_len] = '\0';
- ptr = ACE_OS::strstr (ptr, "/");
+ ptr = ACE_OS::strstr (url, ":");
if (ptr)
- {
- this->filename_ = ACE_OS::strdup(ptr);
- }
+ this->port_ = ACE_OS::atoi (ptr + 1);
else
+ ptr = ACE_OS::strstr (url, "/");
+
+ if(!ptr)
success = false;
+ else
+ {
+ size_t host_len = ptr - url;
+ ACE_NEW_RETURN (this->hostname_, char [host_len + 1], false);
+ ACE_OS::strncpy (this->hostname_, url, host_len);
+ this->hostname_ [host_len] = '\0';
+ ptr = ACE_OS::strstr (ptr, "/");
+ if (ptr)
+ {
+ this->filename_ = ACE_OS::strdup(ptr);
+ }
+ else
+ {
+ success = false;
+ }
+ }
}
- }
- return success;
+ return success;
}
@@ -86,17 +92,14 @@ void URL_Parser::Error (void)
ACE_DEBUG ((LM_DEBUG, "./http_client -u http://hostname:port/filename [-d]\n"));
}
-
- URL_Parser::~URL_Parser()
- {
- if(this->hostname_)
+URL_Parser::~URL_Parser()
+{
+ if(this->hostname_)
{
delete [] this->hostname_;
- this->hostname_ =0;
}
- if (this->filename_)
+ if (this->filename_)
{
ACE_OS::free (this->filename_);
- this->filename_ = 0;
}
- }
+}