Commit 525ea4cc 525ea4cc63319df0863a54cd7f2e5b9c690331bf by Wojciech Polak

* include/mailutils/cpp/url.h, libmu_cpp/url.cc,

examples/cpp/addr.cc, examples/cpp/url-parse.cc:
Reflect recent API changes.
1 parent a675cd6b
2008-12-04 Wojciech Polak <polak@gnu.org>
* include/mailutils/cpp/url.h, libmu_cpp/url.cc,
examples/cpp/addr.cc, examples/cpp/url-parse.cc:
Reflect recent API changes.
2008-12-03 Sergey Poznyakoff <gray@gnu.org.ua>
* testsuite/etc/mailutils.rc.in: New file.
......
......@@ -19,6 +19,7 @@
*/
#include <iostream>
#include <cstring>
#include <mailutils/cpp/mailutils.h>
#include <mailutils/filter.h>
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -19,6 +19,7 @@
*/
#include <iostream>
#include <vector>
#include <mailutils/cpp/mailutils.h>
#include <cstdlib>
......@@ -49,7 +50,11 @@ main ()
cout << "\thost <" << url.getHost () << ">" << endl;
cout << "\tport " << url.getPort () << endl;
cout << "\tpath <" << url.getPath () << ">" << endl;
cout << "\tquery <" << url.getQuery () << ">" << endl;
vector<string> params = url.getQuery ();
for (vector<string>::size_type i = 0; i != params.size (); i++) {
cout << "\tquery[" << i << "] <" << params[i] << ">" << endl;
}
}
catch (Exception& e) {
cerr << e.method () << ": " << e.msgError () << endl;
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -23,6 +23,7 @@
#include <iostream>
#include <string>
#include <vector>
#include <mailutils/url.h>
namespace mailutils
......@@ -50,7 +51,7 @@ class Url
std::string getAuth ();
std::string getHost ();
std::string getPath ();
std::string getQuery ();
std::vector<std::string> getQuery ();
};
}
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -20,6 +20,7 @@
#include <mailutils/cpp/url.h>
#include <mailutils/cpp/error.h>
#include <mailutils/cpp/error.h>
#include <errno.h>
using namespace mailutils;
......@@ -77,7 +78,9 @@ std::string
Url :: getScheme ()
{
int status = mu_url_get_scheme (url, buf, sizeof (buf), NULL);
if (status)
if (status == MU_ERR_NOENT)
return "";
else if (status)
throw Exception ("Url::getScheme", status);
return std::string (buf);
}
......@@ -86,7 +89,9 @@ std::string
Url :: getUser ()
{
int status = mu_url_get_user (url, buf, sizeof (buf), NULL);
if (status)
if (status == MU_ERR_NOENT)
return "";
else if (status)
throw Exception ("Url::getUser", status);
return std::string (buf);
}
......@@ -95,7 +100,9 @@ std::string
Url :: getPasswd ()
{
int status = mu_url_get_passwd (url, buf, sizeof (buf), NULL);
if (status)
if (status == MU_ERR_NOENT)
return "";
else if (status)
throw Exception ("Url::getPasswd", status);
return std::string (buf);
}
......@@ -104,7 +111,9 @@ std::string
Url :: getAuth ()
{
int status = mu_url_get_auth (url, buf, sizeof (buf), NULL);
if (status)
if (status == MU_ERR_NOENT)
return "";
else if (status)
throw Exception ("Url::getAuth", status);
return std::string (buf);
}
......@@ -113,7 +122,9 @@ std::string
Url :: getHost ()
{
int status = mu_url_get_host (url, buf, sizeof (buf), NULL);
if (status)
if (status == MU_ERR_NOENT)
return "";
else if (status)
throw Exception ("Url::getHost", status);
return std::string (buf);
}
......@@ -122,17 +133,28 @@ std::string
Url :: getPath ()
{
int status = mu_url_get_path (url, buf, sizeof (buf), NULL);
if (status)
if (status == MU_ERR_NOENT)
return "";
else if (status)
throw Exception ("Url::getPath", status);
return std::string (buf);
}
std::string
std::vector<std::string>
Url :: getQuery ()
{
int status = mu_url_get_query (url, buf, sizeof (buf), NULL);
size_t argc;
char **argv;
int status = mu_url_sget_query (url, &argc, &argv);
if (status)
throw Exception ("Url::getQuery", status);
return std::string (buf);
std::vector<std::string> params;
for (int i = 0; i < argc; i++)
params.push_back (argv[i]);
return params;
}
......