@@ -210,22 +210,21 @@ const std::string http_utils::http_post_encoding_multipart_formdata =
210210 MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA;
211211
212212
213- size_t http_utils::tokenize_url (
213+ std::vector<std::string> http_utils::tokenize_url (
214214 const std::string& str,
215- std::vector<std::string>& result,
216215 const char separator
217216)
218217{
219- string_utilities::string_split (str, result, separator);
220- return result.size ();
218+ return string_utilities::string_split (str, separator);
221219}
222220
223- void http_utils::standardize_url (const std::string& url, std::string& result )
221+ std::string http_utils::standardize_url (const std::string& url)
224222{
225- std::string n_url;
226- string_utilities::regex_replace (url, " (\\ /)+" , " /" , n_url);
223+ std::string n_url = string_utilities::regex_replace (url, " (\\ /)+" , " /" );
227224 std::string::size_type n_url_length = n_url.length ();
228225
226+ std::string result;
227+
229228 if (n_url_length > 1 && n_url[n_url_length - 1 ] == ' /' )
230229 {
231230 result = n_url.substr (0 , n_url_length - 1 );
@@ -234,14 +233,17 @@ void http_utils::standardize_url(const std::string& url, std::string& result)
234233 {
235234 result = n_url;
236235 }
236+
237+ return result;
237238}
238239
239- void get_ip_str (
240+ std::string get_ip_str (
240241 const struct sockaddr *sa,
241- std::string& result,
242242 socklen_t maxlen
243243)
244244{
245+ std::string result;
246+
245247 if (sa)
246248 {
247249 int addrlen = sizeof (sockaddr_in);
@@ -256,16 +258,8 @@ void get_ip_str(
256258 result = to_ret;
257259 }
258260 }
259- }
260261
261- std::string get_ip_str_new (
262- const struct sockaddr * sa,
263- socklen_t maxlen
264- )
265- {
266- std::string to_ret;
267- get_ip_str (sa, to_ret, maxlen);
268- return to_ret;
262+ return result;
269263}
270264
271265unsigned short get_port (const struct sockaddr * sa)
@@ -355,7 +349,7 @@ ip_representation::ip_representation(const std::string& ip)
355349 if (ip.find (' :' ) != std::string::npos) // IPV6
356350 {
357351 ip_version = http_utils::IPV6;
358- string_utilities::string_split (ip, parts , ' :' , false );
352+ parts = string_utilities::string_split (ip, ' :' , false );
359353 int y = 0 ;
360354 for (unsigned int i = 0 ; i < parts.size (); i++)
361355 {
@@ -385,8 +379,7 @@ ip_representation::ip_representation(const std::string& ip)
385379 }
386380 if (parts[i].find (' .' ) != std::string::npos)
387381 {
388- vector<string> subparts;
389- string_utilities::string_split (parts[i], subparts, ' .' );
382+ vector<string> subparts = string_utilities::string_split (parts[i], ' .' );
390383 if (subparts.size () == 4 )
391384 {
392385 for (unsigned int ii = 0 ; ii < subparts.size (); ii++)
@@ -447,7 +440,7 @@ ip_representation::ip_representation(const std::string& ip)
447440 else // IPV4
448441 {
449442 ip_version = http_utils::IPV4;
450- string_utilities::string_split (ip, parts , ' .' );
443+ parts = string_utilities::string_split (ip, ' .' );
451444 if (parts.size () == 4 )
452445 {
453446 for (unsigned int i = 0 ; i < parts.size (); i++)
@@ -487,26 +480,22 @@ bool ip_representation::operator <(const ip_representation& b) const
487480 return false ;
488481}
489482
490- size_t load_file (const char * filename, char ** content )
483+ char * load_file (const char *filename )
491484{
485+ char * content = NULL ;
486+
492487 ifstream fp (filename, ios::in | ios::binary | ios::ate);
493488 if (fp.is_open ())
494489 {
495490 int size = fp.tellg ();
496- * content = (char *) malloc (size * sizeof (char ));
491+ content = (char *) malloc (size * sizeof (char ));
497492 fp.seekg (0 , ios::beg);
498- fp.read (* content, size);
493+ fp.read (content, size);
499494 fp.close ();
500- return size ;
495+ return content ;
501496 }
502497 else
503498 throw file_access_exception ();
504- }
505-
506- char * load_file (const char *filename)
507- {
508- char * content = NULL ;
509- load_file (filename, &content);
510499 return content;
511500}
512501
0 commit comments