Commit 5845b9ae 5845b9ae92508c10e2c1d1124b3813cac2a4dff7 by Wojciech Polak

Updated to the new libmu_cpp.

1 parent 63c14513
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -37,30 +38,30 @@ parse (const char *str)
try {
Address address (str);
count = address.GetCount ();
count = address.getCount ();
cout << str << "=> count " << count << endl;
for (no = 1; no <= count; no++)
{
bool isgroup = address.IsGroup (no);
bool isgroup = address.isGroup (no);
cout << no << " ";
if (isgroup)
cout << "group " << address.GetPersonal (no) << endl;
cout << "group " << address.getPersonal (no) << endl;
else
cout << "email " << address.GetEmail (no) << endl;
cout << "email " << address.getEmail (no) << endl;
if (!isgroup)
cout << " personal " << address.GetPersonal (no) << endl;
cout << " personal " << address.getPersonal (no) << endl;
cout << " comments " << address.GetComments (no) << endl;
cout << " local-part " << address.GetLocalPart (no)
<< " domain " << address.GetDomain (no) << endl;
cout << " route " << address.GetRoute (no) << endl;
cout << " comments " << address.getComments (no) << endl;
cout << " local-part " << address.getLocalPart (no)
<< " domain " << address.getDomain (no) << endl;
cout << " route " << address.getRoute (no) << endl;
}
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
cout << endl;
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
/* This is an example program to illustrate the use of stream functions.
......@@ -40,10 +41,10 @@ main ()
connect_again:
try {
stream.Open ();
stream.open ();
}
catch (Stream::EAgain) {
stream.Wait (MU_STREAM_READY_WR);
stream.wait (MU_STREAM_READY_WR);
goto connect_again;
}
......@@ -53,14 +54,14 @@ main ()
stream << wbuf;
}
catch (Stream::EAgain) {
stream.Wait (MU_STREAM_READY_WR);
off += stream.GetWriten ();
stream.wait (MU_STREAM_READY_WR);
off += stream.getWriten ();
goto write_again;
}
if (stream.GetWriten () != wbuf.length ())
if (stream.getWriten () != wbuf.length ())
{
cerr << "stream.GetWriten() != wbuf length" << endl;
cerr << "stream.getWriten() != wbuf length" << endl;
exit (1);
}
......@@ -71,15 +72,15 @@ main ()
stream >> rbuf;
}
catch (Stream::EAgain) {
stream.Wait (MU_STREAM_READY_RD);
stream.wait (MU_STREAM_READY_RD);
goto read_again;
}
cout << rbuf.substr (0, stream.GetReadn ());
cout << rbuf.substr (0, stream.getReadn ());
}
while (stream.GetReadn ());
while (stream.getReadn ());
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
exit (1);
}
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -36,28 +37,28 @@ main (int argc, char **argv)
}
try {
StdioStream *in = new StdioStream(stdin, 0);
in->Open ();
StdioStream *in = new StdioStream (stdin, 0);
in->open ();
FilterStream cvt;
cvt.IconvCreate (*in, (string)argv[1], (string)argv[2], 0, mu_fallback_none);
cvt.Open ();
cvt.iconvCreate (*in, (string)argv[1], (string)argv[2], 0, mu_fallback_none);
cvt.open ();
delete in;
StdioStream out (stdout, 0);
out.Open ();
out.open ();
do {
cvt.Read (buffer, sizeof (buffer), total);
out.SequentialWrite (buffer, cvt.GetReadn ());
total += cvt.GetReadn ();
} while (cvt.GetReadn ());
cvt.read (buffer, sizeof (buffer), total);
out.sequentialWrite (buffer, cvt.getReadn ());
total += cvt.getReadn ();
} while (cvt.getReadn ());
out.Flush ();
out.flush ();
delete in;
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
exit (1);
}
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -37,9 +38,9 @@ print (List& lst)
{
Iterator itr (lst);
for (itr.First (); !itr.IsDone (); itr++)
for (itr.first (); !itr.isDone (); itr++)
{
char* text = (char *) itr.Current ();
char* text = (char *) itr.current ();
cout << text << endl;
}
}
......@@ -52,7 +53,7 @@ next (Iterator* itr, char *arg)
if (skip == 0)
cout << "next arg?" << endl;
while (skip--)
itr->Next ();
itr->next ();
}
void
......@@ -68,10 +69,10 @@ del (List& lst, int argc, char **argv)
while (--argc)
{
try {
lst.Remove (strdup (*++argv));
lst.remove (strdup (*++argv));
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
}
}
......@@ -90,10 +91,10 @@ add (List& lst, int argc, char **argv)
while (--argc)
{
try {
lst.Append (strdup (*++argv));
lst.append (strdup (*++argv));
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
}
}
......@@ -111,10 +112,10 @@ prep (List& lst, int argc, char **argv)
while (--argc)
{
try {
lst.Prepend (strdup (*++argv));
lst.prepend (strdup (*++argv));
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
}
}
......@@ -130,10 +131,10 @@ repl (List& lst, int argc, char **argv)
}
try {
lst.Replace (argv[1], strdup (argv[2]));
lst.replace (argv[1], strdup (argv[2]));
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
}
......@@ -168,23 +169,23 @@ find (Iterator* itr, char* arg)
return;
}
itr->Current ((void**) &text);
for (itr->First (); !itr->IsDone (); itr->Next ())
itr->current ((void**) &text);
for (itr->first (); !itr->isDone (); itr->next ())
{
char *item;
itr->Current ((void**) &item);
itr->current ((void**) &item);
if (!strcmp (arg, item))
return;
}
cerr << arg << " not in list" << endl;
for (itr->First (); !itr->IsDone (); itr->Next ())
for (itr->first (); !itr->isDone (); itr->next ())
{
char *item;
itr->Current ((void**) &item);
itr->current ((void**) &item);
if (!strcmp (text, item))
return;
}
......@@ -217,7 +218,7 @@ shell (List& lst)
for (num = 0; num < NITR; num++)
{
itr[num] = new Iterator (lst);
itr[num]->First ();
itr[num]->first ();
}
num = 0;
......@@ -229,26 +230,26 @@ shell (List& lst)
char **argv;
try {
itr[num]->Current ((void**) &text);
itr[num]->current ((void**) &text);
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
cout << num << ":(" << (text ? text : "NULL") << ")> ";
if (cin.getline (buf, sizeof (buf)).eof ())
return;
rc = argcv_get (buf, "", "#", &argc, &argv);
rc = mu_argcv_get (buf, "", "#", &argc, &argv);
if (rc)
cerr << "argcv_get: " << rc << endl;
cerr << "mu_argcv_get: " << rc << endl;
if (argc > 0)
{
if (!strcmp (argv[0], "next"))
next (itr[num], argv[1]);
else if (!strcmp (argv[0], "first"))
itr[num]->First ();
itr[num]->first ();
else if (!strcmp (argv[0], "del"))
del (lst, argc, argv);
else if (!strcmp (argv[0], "add"))
......@@ -279,7 +280,7 @@ shell (List& lst)
text = (char*) lst[n];
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
// else
......@@ -289,7 +290,7 @@ shell (List& lst)
else
cerr << "?" << endl;
}
argcv_free (argc, argv);
mu_argcv_free (argc, argv);
}
}
......@@ -319,17 +320,17 @@ main (int argc, char **argv)
try {
List lst;
lst.SetComparator (string_comp);
lst.setComparator (string_comp);
while (argc--)
{
lst.Append (*argv++);
lst.append (*argv++);
}
shell (lst);
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
}
return 0;
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -31,7 +32,7 @@ main (int argc, char **argv)
try {
FileStream stream ((std::string) file, MU_STREAM_READ);
stream.Open ();
stream.open ();
Mailcap mailcap (stream);
......@@ -39,7 +40,7 @@ main (int argc, char **argv)
size_t count = 0;
string buffer;
count = mailcap.GetCount ();
count = mailcap.getCount ();
for (i = 1; i <= count; i++)
{
size_t j;
......@@ -47,26 +48,26 @@ main (int argc, char **argv)
cout << "entry[" << i << "]\n";
MailcapEntry entry = mailcap.GetEntry (i);
MailcapEntry entry = mailcap.getEntry (i);
/* typefield. */
buffer = entry.GetTypeField ();
buffer = entry.getTypeField ();
cout << "\ttypefield: " << buffer << endl;
/* view-command. */
buffer = entry.GetViewCommand ();
buffer = entry.getViewCommand ();
cout << "\tview-command: " << buffer << endl;
/* fields. */
fields_count = entry.FieldsCount ();
fields_count = entry.fieldsCount ();
for (j = 1; j <= fields_count; j++)
{
try {
buffer = entry.GetField (j);
buffer = entry.getField (j);
}
catch (Exception& e) {
cerr << e.Method () << ": cannot retrieve field "
<< j << ": " << e.MsgError () << endl;
cerr << e.method () << ": cannot retrieve field "
<< j << ": " << e.msgError () << endl;
}
cout << "\tfields[" << j << "]: " << buffer << endl;
}
......@@ -75,7 +76,7 @@ main (int argc, char **argv)
}
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
exit (1);
}
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -31,11 +32,11 @@ read_and_print (Stream *in, Stream& out)
{
char buffer[128];
in->SequentialReadLine (buffer, sizeof (buffer));
while (in->GetReadn ())
in->sequentialReadLine (buffer, sizeof (buffer));
while (in->getReadn ())
{
out.SequentialWrite (buffer, in->GetReadn ());
in->SequentialReadLine (buffer, sizeof (buffer));
out.sequentialWrite (buffer, in->getReadn ());
in->sequentialReadLine (buffer, sizeof (buffer));
}
}
......@@ -46,21 +47,21 @@ createFilter (bool read_stdin, char *cmdline, int flags)
if (read_stdin)
{
StdioStream *in = new StdioStream (stdin, 0);
in->Open ();
in->open ();
FilterProgStream *stream = new FilterProgStream (cmdline, in);
stream->Open ();
stream->open ();
return stream;
}
else
{
ProgStream *stream = new ProgStream (cmdline, flags);
stream->Open ();
stream->open ();
return stream;
}
}
catch (Exception& e) {
cerr << progname << ": cannot create program filter stream: "
<< e.Method () << ": " << e.MsgError () << endl;
<< e.method () << ": " << e.msgError () << endl;
exit (1);
}
}
......@@ -89,20 +90,20 @@ main (int argc, char *argv[])
exit (1);
}
argcv_string (argc - i, &argv[i], &cmdline);
mu_argcv_string (argc - i, &argv[i], &cmdline);
stream = createFilter (read_stdin, cmdline, flags);
try {
StdioStream out (stdout, 0);
out.Open ();
out.open ();
read_and_print (stream, out);
delete stream;
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
exit (1);
}
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -33,7 +34,7 @@ int main (int argc, char* argv[])
if (argc == 1)
exit (0);
mu_register_local_mbox_formats();
mu_register_local_mbox_formats ();
Message msg;
Header hdr;
......@@ -42,22 +43,22 @@ int main (int argc, char* argv[])
MailboxDefault mbox (argv[1]);
mbox.Open (MU_STREAM_READ);
total = mbox.MessagesCount ();
mbox.open (MU_STREAM_READ);
total = mbox.messagesCount ();
cout << "Total: " << total << endl;
for (int msgno = 1; msgno <= total; msgno++)
{
msg = mbox[msgno];
hdr = msg.GetHeader ();
hdr = msg.getHeader ();
cout << hdr[MU_HEADER_FROM] << " "
<< hdr[MU_HEADER_SUBJECT] << endl;
}
mbox.Close ();
mbox.close ();
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
exit (1);
}
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004, 2006 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
......@@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
#include <iostream>
......@@ -39,19 +40,19 @@ main ()
try {
Url url (str);
url.Parse ();
cout << "\tscheme <" << url.GetScheme () << ">" << endl;
cout << "\tuser <" << url.GetUser () << ">" << endl;
cout << "\tpasswd <" << url.GetPasswd () << ">" << endl;
cout << "\tauth <" << url.GetAuth () << ">" << endl;
cout << "\thost <" << url.GetHost () << ">" << endl;
cout << "\tport " << url.GetPort () << endl;
cout << "\tpath <" << url.GetPath () << ">" << endl;
cout << "\tquery <" << url.GetQuery () << ">" << endl;
url.parse ();
cout << "\tscheme <" << url.getScheme () << ">" << endl;
cout << "\tuser <" << url.getUser () << ">" << endl;
cout << "\tpasswd <" << url.getPasswd () << ">" << endl;
cout << "\tauth <" << url.getAuth () << ">" << endl;
cout << "\thost <" << url.getHost () << ">" << endl;
cout << "\tport " << url.getPort () << endl;
cout << "\tpath <" << url.getPath () << ">" << endl;
cout << "\tquery <" << url.getQuery () << ">" << endl;
}
catch (Exception& e) {
cerr << e.Method () << ": " << e.MsgError () << endl;
cerr << e.method () << ": " << e.msgError () << endl;
goto again;
}
}
......