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
1 2008-12-04 Wojciech Polak <polak@gnu.org>
2
3 * include/mailutils/cpp/url.h, libmu_cpp/url.cc,
4 examples/cpp/addr.cc, examples/cpp/url-parse.cc:
5 Reflect recent API changes.
6
1 2008-12-03 Sergey Poznyakoff <gray@gnu.org.ua> 7 2008-12-03 Sergey Poznyakoff <gray@gnu.org.ua>
2 8
3 * testsuite/etc/mailutils.rc.in: New file. 9 * testsuite/etc/mailutils.rc.in: New file.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21 #include <iostream> 21 #include <iostream>
22 #include <cstring>
22 #include <mailutils/cpp/mailutils.h> 23 #include <mailutils/cpp/mailutils.h>
23 24
24 #include <mailutils/filter.h> 25 #include <mailutils/filter.h>
......
1 /* 1 /*
2 GNU Mailutils -- a suite of utilities for electronic mail 2 GNU Mailutils -- a suite of utilities for electronic mail
3 Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 GNU Mailutils is free software; you can redistribute it and/or modify 5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21 #include <iostream> 21 #include <iostream>
22 #include <vector>
22 #include <mailutils/cpp/mailutils.h> 23 #include <mailutils/cpp/mailutils.h>
23 24
24 #include <cstdlib> 25 #include <cstdlib>
...@@ -49,7 +50,11 @@ main () ...@@ -49,7 +50,11 @@ main ()
49 cout << "\thost <" << url.getHost () << ">" << endl; 50 cout << "\thost <" << url.getHost () << ">" << endl;
50 cout << "\tport " << url.getPort () << endl; 51 cout << "\tport " << url.getPort () << endl;
51 cout << "\tpath <" << url.getPath () << ">" << endl; 52 cout << "\tpath <" << url.getPath () << ">" << endl;
52 cout << "\tquery <" << url.getQuery () << ">" << endl; 53
54 vector<string> params = url.getQuery ();
55 for (vector<string>::size_type i = 0; i != params.size (); i++) {
56 cout << "\tquery[" << i << "] <" << params[i] << ">" << endl;
57 }
53 } 58 }
54 catch (Exception& e) { 59 catch (Exception& e) {
55 cerr << e.method () << ": " << e.msgError () << endl; 60 cerr << e.method () << ": " << e.msgError () << endl;
......
1 /* 1 /*
2 GNU Mailutils -- a suite of utilities for electronic mail 2 GNU Mailutils -- a suite of utilities for electronic mail
3 Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
23 23
24 #include <iostream> 24 #include <iostream>
25 #include <string> 25 #include <string>
26 #include <vector>
26 #include <mailutils/url.h> 27 #include <mailutils/url.h>
27 28
28 namespace mailutils 29 namespace mailutils
...@@ -50,7 +51,7 @@ class Url ...@@ -50,7 +51,7 @@ class Url
50 std::string getAuth (); 51 std::string getAuth ();
51 std::string getHost (); 52 std::string getHost ();
52 std::string getPath (); 53 std::string getPath ();
53 std::string getQuery (); 54 std::vector<std::string> getQuery ();
54 }; 55 };
55 56
56 } 57 }
......
1 /* 1 /*
2 GNU Mailutils -- a suite of utilities for electronic mail 2 GNU Mailutils -- a suite of utilities for electronic mail
3 Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
20 20
21 #include <mailutils/cpp/url.h> 21 #include <mailutils/cpp/url.h>
22 #include <mailutils/cpp/error.h> 22 #include <mailutils/cpp/error.h>
23 #include <mailutils/cpp/error.h>
23 #include <errno.h> 24 #include <errno.h>
24 25
25 using namespace mailutils; 26 using namespace mailutils;
...@@ -77,7 +78,9 @@ std::string ...@@ -77,7 +78,9 @@ std::string
77 Url :: getScheme () 78 Url :: getScheme ()
78 { 79 {
79 int status = mu_url_get_scheme (url, buf, sizeof (buf), NULL); 80 int status = mu_url_get_scheme (url, buf, sizeof (buf), NULL);
80 if (status) 81 if (status == MU_ERR_NOENT)
82 return "";
83 else if (status)
81 throw Exception ("Url::getScheme", status); 84 throw Exception ("Url::getScheme", status);
82 return std::string (buf); 85 return std::string (buf);
83 } 86 }
...@@ -86,7 +89,9 @@ std::string ...@@ -86,7 +89,9 @@ std::string
86 Url :: getUser () 89 Url :: getUser ()
87 { 90 {
88 int status = mu_url_get_user (url, buf, sizeof (buf), NULL); 91 int status = mu_url_get_user (url, buf, sizeof (buf), NULL);
89 if (status) 92 if (status == MU_ERR_NOENT)
93 return "";
94 else if (status)
90 throw Exception ("Url::getUser", status); 95 throw Exception ("Url::getUser", status);
91 return std::string (buf); 96 return std::string (buf);
92 } 97 }
...@@ -95,7 +100,9 @@ std::string ...@@ -95,7 +100,9 @@ std::string
95 Url :: getPasswd () 100 Url :: getPasswd ()
96 { 101 {
97 int status = mu_url_get_passwd (url, buf, sizeof (buf), NULL); 102 int status = mu_url_get_passwd (url, buf, sizeof (buf), NULL);
98 if (status) 103 if (status == MU_ERR_NOENT)
104 return "";
105 else if (status)
99 throw Exception ("Url::getPasswd", status); 106 throw Exception ("Url::getPasswd", status);
100 return std::string (buf); 107 return std::string (buf);
101 } 108 }
...@@ -104,7 +111,9 @@ std::string ...@@ -104,7 +111,9 @@ std::string
104 Url :: getAuth () 111 Url :: getAuth ()
105 { 112 {
106 int status = mu_url_get_auth (url, buf, sizeof (buf), NULL); 113 int status = mu_url_get_auth (url, buf, sizeof (buf), NULL);
107 if (status) 114 if (status == MU_ERR_NOENT)
115 return "";
116 else if (status)
108 throw Exception ("Url::getAuth", status); 117 throw Exception ("Url::getAuth", status);
109 return std::string (buf); 118 return std::string (buf);
110 } 119 }
...@@ -113,7 +122,9 @@ std::string ...@@ -113,7 +122,9 @@ std::string
113 Url :: getHost () 122 Url :: getHost ()
114 { 123 {
115 int status = mu_url_get_host (url, buf, sizeof (buf), NULL); 124 int status = mu_url_get_host (url, buf, sizeof (buf), NULL);
116 if (status) 125 if (status == MU_ERR_NOENT)
126 return "";
127 else if (status)
117 throw Exception ("Url::getHost", status); 128 throw Exception ("Url::getHost", status);
118 return std::string (buf); 129 return std::string (buf);
119 } 130 }
...@@ -122,17 +133,28 @@ std::string ...@@ -122,17 +133,28 @@ std::string
122 Url :: getPath () 133 Url :: getPath ()
123 { 134 {
124 int status = mu_url_get_path (url, buf, sizeof (buf), NULL); 135 int status = mu_url_get_path (url, buf, sizeof (buf), NULL);
125 if (status) 136 if (status == MU_ERR_NOENT)
137 return "";
138 else if (status)
126 throw Exception ("Url::getPath", status); 139 throw Exception ("Url::getPath", status);
127 return std::string (buf); 140 return std::string (buf);
128 } 141 }
129 142
130 std::string 143 std::vector<std::string>
131 Url :: getQuery () 144 Url :: getQuery ()
132 { 145 {
133 int status = mu_url_get_query (url, buf, sizeof (buf), NULL); 146 size_t argc;
147 char **argv;
148
149 int status = mu_url_sget_query (url, &argc, &argv);
134 if (status) 150 if (status)
135 throw Exception ("Url::getQuery", status); 151 throw Exception ("Url::getQuery", status);
136 return std::string (buf); 152
153 std::vector<std::string> params;
154
155 for (int i = 0; i < argc; i++)
156 params.push_back (argv[i]);
157
158 return params;
137 } 159 }
138 160
......