Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
c9a1fa06
...
c9a1fa06415629abfbc181b62432709a032c8254
authored
2006-12-25 22:11:10 +0000
by
Wojciech Polak
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Updated to the current API 1.0
1 parent
97fa0963
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
346 additions
and
334 deletions
libmu_cpp/Makefile.am
libmu_cpp/address.cc
libmu_cpp/filter.cc
libmu_cpp/header.cc
libmu_cpp/iterator.cc
libmu_cpp/list.cc
libmu_cpp/mailbox.cc
libmu_cpp/mailcap.cc
libmu_cpp/mailer.cc
libmu_cpp/message.cc
libmu_cpp/pop3.cc
libmu_cpp/stream.cc
libmu_cpp/url.cc
libmu_cpp/Makefile.am
View file @
c9a1fa0
...
...
@@ -14,7 +14,8 @@
##
## You should have received a copy of the GNU General Public License
## along with this program; 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
INCLUDES
=
@MU_COMMON_INCLUDES@ @INTLINCS@
...
...
@@ -36,7 +37,6 @@ libmu_cpp_la_SOURCES = \
stream.cc
\
url.cc
libmu_cpp_la_DEPENDENCIES
=
@MU_LTLIBOBJS@
libmu_cpp_la_LIBADD
=
@MU_LTLIBOBJS@ @MU_COMMON_LIBRARIES@
libmu_cpp_la_LIBADD
=
@MU_COMMON_LIBRARIES@
libmu_cpp_la_LDFLAGS
=
-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
...
...
libmu_cpp/address.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/address.h>
...
...
@@ -29,12 +30,12 @@ using namespace mailutils;
Address
::
Address
(
const
std
::
string
&
str
)
{
int
status
=
address_create
(
&
addr
,
str
.
c_str
());
int
status
=
mu_
address_create
(
&
addr
,
str
.
c_str
());
if
(
status
)
throw
Exception
(
"Address::Address"
,
status
);
}
Address
::
Address
(
const
address_t
addr
)
Address
::
Address
(
const
mu_
address_t
addr
)
{
if
(
addr
==
0
)
throw
Exception
(
"Address::Address"
,
EINVAL
);
...
...
@@ -44,14 +45,14 @@ Address :: Address (const address_t addr)
Address
::
~
Address
()
{
address_destroy
(
&
addr
);
mu_
address_destroy
(
&
addr
);
}
bool
Address
::
I
sGroup
(
size_t
n
)
Address
::
i
sGroup
(
size_t
n
)
{
int
isgroup
;
int
status
=
address_is_group
(
addr
,
n
,
&
isgroup
);
int
status
=
mu_
address_is_group
(
addr
,
n
,
&
isgroup
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::IsGroup"
,
status
);
else
if
(
status
==
ENOENT
)
...
...
@@ -61,81 +62,81 @@ Address :: IsGroup (size_t n)
}
size_t
Address
::
G
etCount
()
Address
::
g
etCount
()
{
size_t
count
;
address_get_count
(
addr
,
&
count
);
mu_
address_get_count
(
addr
,
&
count
);
return
count
;
}
std
::
string
Address
::
G
etEmail
(
size_t
n
)
Address
::
g
etEmail
(
size_t
n
)
{
int
status
=
address_get_email
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
int
status
=
mu_
address_get_email
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::
G
etEmail"
,
status
);
throw
Address
::
EInval
(
"Address::
g
etEmail"
,
status
);
else
if
(
status
==
ENOENT
)
throw
Address
::
ENoent
(
"Address::
G
etEmail"
,
status
);
throw
Address
::
ENoent
(
"Address::
g
etEmail"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Address
::
G
etLocalPart
(
size_t
n
)
Address
::
g
etLocalPart
(
size_t
n
)
{
int
status
=
address_get_local_part
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
int
status
=
mu_
address_get_local_part
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::
G
etLocalPart"
,
status
);
throw
Address
::
EInval
(
"Address::
g
etLocalPart"
,
status
);
else
if
(
status
==
ENOENT
)
throw
Address
::
ENoent
(
"Address::
G
etLocalPart"
,
status
);
throw
Address
::
ENoent
(
"Address::
g
etLocalPart"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Address
::
G
etDomain
(
size_t
n
)
Address
::
g
etDomain
(
size_t
n
)
{
int
status
=
address_get_domain
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
int
status
=
mu_
address_get_domain
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::
G
etDomain"
,
status
);
throw
Address
::
EInval
(
"Address::
g
etDomain"
,
status
);
else
if
(
status
==
ENOENT
)
throw
Address
::
ENoent
(
"Address::
G
etDomain"
,
status
);
throw
Address
::
ENoent
(
"Address::
g
etDomain"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Address
::
G
etPersonal
(
size_t
n
)
Address
::
g
etPersonal
(
size_t
n
)
{
int
status
=
address_get_personal
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
int
status
=
mu_
address_get_personal
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::
G
etPersonal"
,
status
);
throw
Address
::
EInval
(
"Address::
g
etPersonal"
,
status
);
else
if
(
status
==
ENOENT
)
throw
Address
::
ENoent
(
"Address::
G
etPersonal"
,
status
);
throw
Address
::
ENoent
(
"Address::
g
etPersonal"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Address
::
G
etComments
(
size_t
n
)
Address
::
g
etComments
(
size_t
n
)
{
int
status
=
address_get_comments
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
int
status
=
mu_
address_get_comments
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::
G
etComments"
,
status
);
throw
Address
::
EInval
(
"Address::
g
etComments"
,
status
);
else
if
(
status
==
ENOENT
)
throw
Address
::
ENoent
(
"Address::
G
etComments"
,
status
);
throw
Address
::
ENoent
(
"Address::
g
etComments"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Address
::
G
etRoute
(
size_t
n
)
Address
::
g
etRoute
(
size_t
n
)
{
int
status
=
address_get_route
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
int
status
=
mu_
address_get_route
(
addr
,
n
,
buf
,
sizeof
(
buf
),
0
);
if
(
status
==
EINVAL
)
throw
Address
::
EInval
(
"Address::
G
etRoute"
,
status
);
throw
Address
::
EInval
(
"Address::
g
etRoute"
,
status
);
else
if
(
status
==
ENOENT
)
throw
Address
::
ENoent
(
"Address::
G
etRoute"
,
status
);
throw
Address
::
ENoent
(
"Address::
g
etRoute"
,
status
);
return
std
::
string
(
buf
);
}
...
...
libmu_cpp/filter.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/filter.h>
...
...
@@ -26,32 +27,32 @@ using namespace mailutils;
//
void
FilterStream
::
C
reate
(
Stream
&
transport
,
FilterStream
::
c
reate
(
Stream
&
transport
,
const
std
::
string
&
code
,
int
mode
,
int
flag
)
{
int
status
=
filter_create
(
&
this
->
stm
,
int
status
=
mu_
filter_create
(
&
this
->
stm
,
transport
.
stm
,
code
.
c_str
(),
mode
,
flag
);
if
(
status
)
throw
Exception
(
"FilterStream::
C
reate"
,
status
);
throw
Exception
(
"FilterStream::
c
reate"
,
status
);
this
->
input
=
new
Stream
(
transport
);
}
void
FilterStream
::
I
convCreate
(
Stream
&
transport
,
FilterStream
::
i
convCreate
(
Stream
&
transport
,
const
std
::
string
&
fromcode
,
const
std
::
string
&
tocode
,
int
flags
,
enum
mu_iconv_fallback_mode
fallback_mode
)
{
int
status
=
filter_iconv_create
(
&
this
->
stm
,
transport
.
stm
,
int
status
=
mu_
filter_iconv_create
(
&
this
->
stm
,
transport
.
stm
,
fromcode
.
c_str
(),
tocode
.
c_str
(),
flags
,
fallback_mode
);
if
(
status
)
throw
Exception
(
"FilterStream::
I
convCreate"
,
status
);
throw
Exception
(
"FilterStream::
i
convCreate"
,
status
);
this
->
input
=
new
Stream
(
transport
);
}
...
...
libmu_cpp/header.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/header.h>
...
...
@@ -31,7 +32,7 @@ Header :: Header ()
{
}
Header
::
Header
(
const
header_t
hdr
)
Header
::
Header
(
const
mu_
header_t
hdr
)
{
if
(
hdr
==
0
)
throw
Exception
(
"Header::Header"
,
EINVAL
);
...
...
@@ -40,13 +41,13 @@ Header :: Header (const header_t hdr)
}
std
::
string
Header
::
G
etValue
(
const
std
::
string
&
name
)
Header
::
g
etValue
(
const
std
::
string
&
name
)
{
char
*
c_val
;
int
status
=
header_aget_value
(
hdr
,
name
.
c_str
(),
&
c_val
);
int
status
=
mu_
header_aget_value
(
hdr
,
name
.
c_str
(),
&
c_val
);
if
(
status
)
throw
Exception
(
"Header::
G
etValue"
,
status
);
throw
Exception
(
"Header::
g
etValue"
,
status
);
std
::
string
val
(
c_val
);
free
(
c_val
);
...
...
@@ -56,6 +57,6 @@ Header :: GetValue (const std::string& name)
std
::
string
Header
::
operator
[]
(
const
std
::
string
&
name
)
{
return
this
->
G
etValue
(
name
);
return
this
->
g
etValue
(
name
);
}
...
...
libmu_cpp/iterator.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/iterator.h>
...
...
@@ -29,14 +30,14 @@ using namespace mailutils;
Iterator
::
Iterator
(
const
List
&
lst
)
{
int
status
=
list_get_iterator
(
lst
.
mu_list
,
&
mu_iter
);
int
status
=
mu_
list_get_iterator
(
lst
.
mu_list
,
&
mu_iter
);
if
(
status
)
throw
Exception
(
"Iterator::Iterator"
,
status
);
this
->
pList
=
(
List
*
)
&
lst
;
}
Iterator
::
Iterator
(
const
iterator_t
iter
)
Iterator
::
Iterator
(
const
mu_
iterator_t
iter
)
{
if
(
iter
==
0
)
throw
Exception
(
"Iterator::Iterator"
,
EINVAL
);
...
...
@@ -47,70 +48,70 @@ Iterator :: Iterator (const iterator_t iter)
Iterator
::
~
Iterator
()
{
iterator_destroy
(
&
mu_iter
);
mu_
iterator_destroy
(
&
mu_iter
);
}
void
Iterator
::
F
irst
()
Iterator
::
f
irst
()
{
iterator_first
(
mu_iter
);
mu_
iterator_first
(
mu_iter
);
}
void
Iterator
::
N
ext
()
Iterator
::
n
ext
()
{
iterator_next
(
mu_iter
);
mu_
iterator_next
(
mu_iter
);
}
Iterator
&
Iterator
::
operator
++
(
int
)
{
iterator_next
(
mu_iter
);
mu_
iterator_next
(
mu_iter
);
return
*
this
;
}
void
Iterator
::
C
urrent
(
void
**
pitem
)
Iterator
::
c
urrent
(
void
**
pitem
)
{
int
status
=
iterator_current
(
mu_iter
,
pitem
);
int
status
=
mu_
iterator_current
(
mu_iter
,
pitem
);
if
(
status
)
throw
Exception
(
"Iterator::
C
urrent"
,
status
);
throw
Exception
(
"Iterator::
c
urrent"
,
status
);
}
void
*
Iterator
::
C
urrent
()
Iterator
::
c
urrent
()
{
void
*
pitem
;
int
status
=
iterator_current
(
mu_iter
,
&
pitem
);
int
status
=
mu_
iterator_current
(
mu_iter
,
&
pitem
);
if
(
status
)
throw
Exception
(
"Iterator::
C
urrent"
,
status
);
throw
Exception
(
"Iterator::
c
urrent"
,
status
);
return
pitem
;
}
bool
Iterator
::
I
sDone
()
Iterator
::
i
sDone
()
{
return
(
bool
)
iterator_is_done
(
mu_iter
);
return
(
bool
)
mu_
iterator_is_done
(
mu_iter
);
}
List
&
Iterator
::
G
etList
()
Iterator
::
g
etList
()
{
if
(
!
pList
)
throw
Exception
(
"Iterator::
G
etList"
,
ENOTSUP
);
throw
Exception
(
"Iterator::
g
etList"
,
ENOTSUP
);
return
*
pList
;
}
void
Iterator
::
D
up
(
Iterator
*&
piter
,
const
Iterator
&
orig
)
Iterator
::
d
up
(
Iterator
*&
piter
,
const
Iterator
&
orig
)
{
iterator_t
iter
;
mu_
iterator_t
iter
;
int
status
=
iterator_dup
(
&
iter
,
orig
.
mu_iter
);
int
status
=
mu_
iterator_dup
(
&
iter
,
orig
.
mu_iter
);
if
(
status
)
throw
Exception
(
"Iterator::
D
up"
,
status
);
throw
Exception
(
"Iterator::
d
up"
,
status
);
piter
->
mu_iter
=
iter
;
}
...
...
libmu_cpp/list.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/list.h>
...
...
@@ -29,12 +30,12 @@ using namespace mailutils;
List
::
List
()
{
int
status
=
list_create
(
&
mu_list
);
int
status
=
mu_
list_create
(
&
mu_list
);
if
(
status
)
throw
Exception
(
"List::List"
,
status
);
}
List
::
List
(
const
list_t
lst
)
List
::
List
(
const
mu_
list_t
lst
)
{
if
(
lst
==
0
)
throw
Exception
(
"List::List"
,
EINVAL
);
...
...
@@ -44,65 +45,65 @@ List :: List (const list_t lst)
List
::
~
List
()
{
list_destroy
(
&
mu_list
);
mu_
list_destroy
(
&
mu_list
);
}
void
List
::
A
ppend
(
void
*
item
)
List
::
a
ppend
(
void
*
item
)
{
int
status
=
list_append
(
mu_list
,
item
);
int
status
=
mu_
list_append
(
mu_list
,
item
);
if
(
status
)
throw
Exception
(
"List::
A
ppend"
,
status
);
throw
Exception
(
"List::
a
ppend"
,
status
);
}
void
List
::
P
repend
(
void
*
item
)
List
::
p
repend
(
void
*
item
)
{
int
status
=
list_prepend
(
mu_list
,
item
);
int
status
=
mu_
list_prepend
(
mu_list
,
item
);
if
(
status
)
throw
Exception
(
"List::
P
repend"
,
status
);
throw
Exception
(
"List::
p
repend"
,
status
);
}
void
List
::
Insert
(
void
*
item
,
void
*
new_item
)
List
::
insert
(
void
*
item
,
void
*
new_item
,
int
insert_before
)
{
int
status
=
list_insert
(
mu_list
,
item
,
new_item
);
int
status
=
mu_list_insert
(
mu_list
,
item
,
new_item
,
insert_before
);
if
(
status
)
throw
Exception
(
"List::
I
nsert"
,
status
);
throw
Exception
(
"List::
i
nsert"
,
status
);
}
void
List
::
R
emove
(
void
*
item
)
List
::
r
emove
(
void
*
item
)
{
int
status
=
list_remove
(
mu_list
,
item
);
int
status
=
mu_
list_remove
(
mu_list
,
item
);
if
(
status
)
throw
Exception
(
"List::
R
emove"
,
status
);
throw
Exception
(
"List::
r
emove"
,
status
);
}
void
List
::
R
eplace
(
void
*
old_item
,
void
*
new_item
)
List
::
r
eplace
(
void
*
old_item
,
void
*
new_item
)
{
int
status
=
list_replace
(
mu_list
,
old_item
,
new_item
);
int
status
=
mu_
list_replace
(
mu_list
,
old_item
,
new_item
);
if
(
status
)
throw
Exception
(
"List::
R
eplace"
,
status
);
throw
Exception
(
"List::
r
eplace"
,
status
);
}
void
List
::
G
et
(
size_t
index
,
void
**
pitem
)
List
::
g
et
(
size_t
index
,
void
**
pitem
)
{
int
status
=
list_get
(
mu_list
,
index
,
pitem
);
int
status
=
mu_
list_get
(
mu_list
,
index
,
pitem
);
if
(
status
)
throw
Exception
(
"List::
G
et"
,
status
);
throw
Exception
(
"List::
g
et"
,
status
);
}
void
*
List
::
G
et
(
size_t
index
)
List
::
g
et
(
size_t
index
)
{
void
*
pitem
;
int
status
=
list_get
(
mu_list
,
index
,
&
pitem
);
int
status
=
mu_
list_get
(
mu_list
,
index
,
&
pitem
);
if
(
status
)
throw
Exception
(
"List::
G
et"
,
status
);
throw
Exception
(
"List::
g
et"
,
status
);
return
pitem
;
}
...
...
@@ -110,62 +111,62 @@ List :: Get (size_t index)
void
*
List
::
operator
[]
(
size_t
index
)
{
return
this
->
G
et
(
index
);
return
this
->
g
et
(
index
);
}
void
List
::
T
oArray
(
void
**
array
,
size_t
count
,
size_t
*
pcount
)
List
::
t
oArray
(
void
**
array
,
size_t
count
,
size_t
*
pcount
)
{
int
status
=
list_to_array
(
mu_list
,
array
,
count
,
pcount
);
int
status
=
mu_
list_to_array
(
mu_list
,
array
,
count
,
pcount
);
if
(
status
)
throw
Exception
(
"List::
T
oArray"
,
status
);
throw
Exception
(
"List::
t
oArray"
,
status
);
}
void
List
::
L
ocate
(
void
*
item
,
void
**
ret_item
)
List
::
l
ocate
(
void
*
item
,
void
**
ret_item
)
{
int
status
=
list_locate
(
mu_list
,
item
,
ret_item
);
int
status
=
mu_
list_locate
(
mu_list
,
item
,
ret_item
);
if
(
status
)
throw
Exception
(
"List::
L
ocate"
,
status
);
throw
Exception
(
"List::
l
ocate"
,
status
);
}
bool
List
::
I
sEmpty
()
List
::
i
sEmpty
()
{
return
(
bool
)
list_is_empty
(
mu_list
);
return
(
bool
)
mu_
list_is_empty
(
mu_list
);
}
size_t
List
::
C
ount
()
List
::
c
ount
()
{
size_t
count
=
0
;
int
status
=
list_count
(
mu_list
,
&
count
);
int
status
=
mu_
list_count
(
mu_list
,
&
count
);
if
(
status
)
throw
Exception
(
"List::
C
ount"
,
status
);
throw
Exception
(
"List::
c
ount"
,
status
);
return
count
;
}
void
List
::
Do
(
list_action_t
*
action
,
void
*
cbdata
)
List
::
apply
(
mu_
list_action_t
*
action
,
void
*
cbdata
)
{
int
status
=
list_do
(
mu_list
,
action
,
cbdata
);
int
status
=
mu_
list_do
(
mu_list
,
action
,
cbdata
);
if
(
status
)
throw
Exception
(
"List::
Do
"
,
status
);
throw
Exception
(
"List::
apply
"
,
status
);
}
list_comparator_t
List
::
SetComparator
(
list_comparator_t
comp
)
mu_
list_comparator_t
List
::
setComparator
(
mu_
list_comparator_t
comp
)
{
return
list_set_comparator
(
mu_list
,
comp
);
return
mu_
list_set_comparator
(
mu_list
,
comp
);
}
void
List
::
SetDestroyItem
(
void
(
*
destroy_item
)
(
void
*
item
))
List
::
setDestroyItem
(
void
(
*
mu_
destroy_item
)
(
void
*
item
))
{
int
status
=
list_set_destroy_item
(
mu_list
,
destroy_item
);
int
status
=
mu_list_set_destroy_item
(
mu_list
,
mu_
destroy_item
);
if
(
status
)
throw
Exception
(
"List::
S
etDestroyItem"
,
status
);
throw
Exception
(
"List::
s
etDestroyItem"
,
status
);
}
...
...
libmu_cpp/mailbox.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/mailbox.h>
...
...
@@ -29,37 +30,37 @@ using namespace mailutils;
//
void
MailboxBase
::
O
pen
(
int
flag
)
MailboxBase
::
o
pen
(
int
flag
)
{
int
status
=
mailbox_open
(
mbox
,
flag
);
int
status
=
m
u_m
ailbox_open
(
mbox
,
flag
);
if
(
status
)
throw
Exception
(
"MailboxBase::
O
pen"
,
status
);
throw
Exception
(
"MailboxBase::
o
pen"
,
status
);
}
void
MailboxBase
::
C
lose
()
MailboxBase
::
c
lose
()
{
int
status
=
mailbox_close
(
mbox
);
int
status
=
m
u_m
ailbox_close
(
mbox
);
if
(
status
)
throw
Exception
(
"MailboxBase::
C
lose"
,
status
);
throw
Exception
(
"MailboxBase::
c
lose"
,
status
);
}
size_t
MailboxBase
::
M
essagesCount
()
MailboxBase
::
m
essagesCount
()
{
size_t
total
;
mailbox_messages_count
(
mbox
,
&
total
);
m
u_m
ailbox_messages_count
(
mbox
,
&
total
);
return
total
;
}
Message
&
MailboxBase
::
G
etMessage
(
size_t
num
)
MailboxBase
::
g
etMessage
(
size_t
num
)
{
message_t
c_msg
;
m
u_m
essage_t
c_msg
;
int
status
=
mailbox_get_message
(
mbox
,
num
,
&
c_msg
);
int
status
=
m
u_m
ailbox_get_message
(
mbox
,
num
,
&
c_msg
);
if
(
status
)
throw
Exception
(
"MailboxBase::
G
etMessage"
,
status
);
throw
Exception
(
"MailboxBase::
g
etMessage"
,
status
);
return
*
new
Message
(
c_msg
);
}
...
...
@@ -67,7 +68,7 @@ MailboxBase :: GetMessage (size_t num)
Message
&
MailboxBase
::
operator
[]
(
size_t
num
)
{
return
this
->
G
etMessage
(
num
);
return
this
->
g
etMessage
(
num
);
}
//
...
...
@@ -76,12 +77,12 @@ MailboxBase :: operator [] (size_t num)
Mailbox
::
Mailbox
(
const
std
::
string
&
name
)
{
int
status
=
mailbox_create
(
&
mbox
,
name
.
c_str
());
int
status
=
m
u_m
ailbox_create
(
&
mbox
,
name
.
c_str
());
if
(
status
)
throw
Exception
(
"Mailbox::Mailbox"
,
status
);
}
Mailbox
::
Mailbox
(
const
mailbox_t
mbox
)
Mailbox
::
Mailbox
(
const
m
u_m
ailbox_t
mbox
)
{
if
(
mbox
==
0
)
throw
Exception
(
"Mailbox::Mailbox"
,
EINVAL
);
...
...
@@ -91,7 +92,7 @@ Mailbox :: Mailbox (const mailbox_t mbox)
Mailbox
::
~
Mailbox
()
{
mailbox_destroy
(
&
mbox
);
m
u_m
ailbox_destroy
(
&
mbox
);
}
//
...
...
@@ -100,12 +101,12 @@ Mailbox :: ~Mailbox ()
MailboxDefault
::
MailboxDefault
(
const
std
::
string
&
name
)
{
int
status
=
mailbox_create_default
(
&
mbox
,
name
.
c_str
());
int
status
=
m
u_m
ailbox_create_default
(
&
mbox
,
name
.
c_str
());
if
(
status
)
throw
Exception
(
"MailboxDefault::MailboxDefault"
,
status
);
}
MailboxDefault
::
MailboxDefault
(
const
mailbox_t
mbox
)
MailboxDefault
::
MailboxDefault
(
const
m
u_m
ailbox_t
mbox
)
{
if
(
mbox
==
0
)
throw
Exception
(
"MailboxDefault::MailboxDefault"
,
EINVAL
);
...
...
@@ -115,6 +116,6 @@ MailboxDefault :: MailboxDefault (const mailbox_t mbox)
MailboxDefault
::
~
MailboxDefault
()
{
mailbox_destroy
(
&
mbox
);
m
u_m
ailbox_destroy
(
&
mbox
);
}
...
...
libmu_cpp/mailcap.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/mailcap.h>
...
...
@@ -49,23 +50,23 @@ Mailcap :: ~Mailcap ()
}
size_t
Mailcap
::
G
etCount
()
Mailcap
::
g
etCount
()
{
size_t
count
=
0
;
int
status
=
mu_mailcap_entries_count
(
mailcap
,
&
count
);
if
(
status
)
throw
Exception
(
"Mailcap::
G
etCount"
,
status
);
throw
Exception
(
"Mailcap::
g
etCount"
,
status
);
return
count
;
}
MailcapEntry
&
Mailcap
::
G
etEntry
(
size_t
i
)
Mailcap
::
g
etEntry
(
size_t
i
)
{
mu_mailcap_entry_t
c_entry
;
int
status
=
mu_mailcap_get_entry
(
mailcap
,
i
,
&
c_entry
);
if
(
status
)
throw
Exception
(
"Mailcap::
G
etEntry"
,
status
);
throw
Exception
(
"Mailcap::
g
etEntry"
,
status
);
MailcapEntry
*
entry
=
new
MailcapEntry
(
c_entry
);
return
*
entry
;
...
...
@@ -84,42 +85,42 @@ MailcapEntry :: MailcapEntry (mu_mailcap_entry_t entry)
}
size_t
MailcapEntry
::
F
ieldsCount
()
MailcapEntry
::
f
ieldsCount
()
{
size_t
count
=
0
;
int
status
=
mu_mailcap_entry_fields_count
(
entry
,
&
count
);
if
(
status
)
throw
Exception
(
"MailcapEntry::
F
ieldsCount"
,
status
);
throw
Exception
(
"MailcapEntry::
f
ieldsCount"
,
status
);
return
count
;
}
std
::
string
MailcapEntry
::
G
etField
(
size_t
i
)
MailcapEntry
::
g
etField
(
size_t
i
)
{
int
status
=
mu_mailcap_entry_get_field
(
entry
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"MailcapEntry::
G
etField"
,
status
);
throw
Exception
(
"MailcapEntry::
g
etField"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
MailcapEntry
::
G
etTypeField
()
MailcapEntry
::
g
etTypeField
()
{
int
status
=
mu_mailcap_entry_get_typefield
(
entry
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"MailcapEntry::
G
etTypeField"
,
status
);
throw
Exception
(
"MailcapEntry::
g
etTypeField"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
MailcapEntry
::
G
etViewCommand
()
MailcapEntry
::
g
etViewCommand
()
{
int
status
=
mu_mailcap_entry_get_viewcommand
(
entry
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"MailcapEntry::
G
etViewCommand"
,
status
);
throw
Exception
(
"MailcapEntry::
g
etViewCommand"
,
status
);
return
std
::
string
(
buf
);
}
...
...
libmu_cpp/mailer.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/mailer.h>
...
...
@@ -28,12 +29,12 @@ using namespace mailutils;
Mailer
::
Mailer
(
const
std
::
string
&
url
)
{
int
status
=
mailer_create
(
&
mailer
,
url
.
c_str
());
int
status
=
m
u_m
ailer_create
(
&
mailer
,
url
.
c_str
());
if
(
status
)
throw
Exception
(
"Mailer::Mailer"
,
status
);
}
Mailer
::
Mailer
(
const
mailer_t
mailer
)
Mailer
::
Mailer
(
const
m
u_m
ailer_t
mailer
)
{
if
(
mailer
==
0
)
throw
Exception
(
"Mailer::Mailer"
,
EINVAL
);
...
...
@@ -43,32 +44,32 @@ Mailer :: Mailer (const mailer_t mailer)
Mailer
::
~
Mailer
()
{
mailer_destroy
(
&
mailer
);
m
u_m
ailer_destroy
(
&
mailer
);
}
void
Mailer
::
O
pen
(
int
flags
)
Mailer
::
o
pen
(
int
flags
)
{
int
status
=
mailer_open
(
mailer
,
flags
);
int
status
=
m
u_m
ailer_open
(
mailer
,
flags
);
if
(
status
)
throw
Exception
(
"Mailer::
O
pen"
,
status
);
throw
Exception
(
"Mailer::
o
pen"
,
status
);
}
void
Mailer
::
C
lose
()
Mailer
::
c
lose
()
{
int
status
=
mailer_close
(
mailer
);
int
status
=
m
u_m
ailer_close
(
mailer
);
if
(
status
)
throw
Exception
(
"Mailer::
C
lose"
,
status
);
throw
Exception
(
"Mailer::
c
lose"
,
status
);
}
void
Mailer
::
S
endMessage
(
const
Message
&
msg
,
const
Address
&
from
,
Mailer
::
s
endMessage
(
const
Message
&
msg
,
const
Address
&
from
,
const
Address
&
to
)
{
int
status
=
mailer_send_message
(
mailer
,
msg
.
msg
,
int
status
=
m
u_m
ailer_send_message
(
mailer
,
msg
.
msg
,
from
.
addr
,
to
.
addr
);
if
(
status
)
throw
Exception
(
"Mailer::
S
endMessage"
,
status
);
throw
Exception
(
"Mailer::
s
endMessage"
,
status
);
}
...
...
libmu_cpp/message.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/message.h>
...
...
@@ -32,7 +33,7 @@ Message :: Message ()
{
}
Message
::
Message
(
const
message_t
msg
)
Message
::
Message
(
const
m
u_m
essage_t
msg
)
{
if
(
msg
==
0
)
throw
Exception
(
"Message::Message"
,
EINVAL
);
...
...
@@ -41,13 +42,13 @@ Message :: Message (const message_t msg)
}
Header
&
Message
::
G
etHeader
()
Message
::
g
etHeader
()
{
header_t
c_hdr
;
mu_
header_t
c_hdr
;
int
status
=
message_get_header
(
msg
,
&
c_hdr
);
int
status
=
m
u_m
essage_get_header
(
msg
,
&
c_hdr
);
if
(
status
)
throw
Exception
(
"Message::
G
etHeader"
,
status
);
throw
Exception
(
"Message::
g
etHeader"
,
status
);
return
*
new
Header
(
c_hdr
);
}
...
...
libmu_cpp/pop3.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/pop3.h>
...
...
@@ -51,214 +52,214 @@ Pop3 :: ~Pop3 ()
}
void
Pop3
::
S
etCarrier
(
const
Stream
&
carrier
)
Pop3
::
s
etCarrier
(
const
Stream
&
carrier
)
{
int
status
=
mu_pop3_set_carrier
(
pop3
,
carrier
.
stm
);
if
(
status
)
throw
Exception
(
"Pop3::
S
etCarrier"
,
status
);
throw
Exception
(
"Pop3::
s
etCarrier"
,
status
);
this
->
pStream
=
(
Stream
*
)
&
carrier
;
}
Stream
&
Pop3
::
G
etCarrier
()
Pop3
::
g
etCarrier
()
{
return
*
pStream
;
}
void
Pop3
::
C
onnect
()
Pop3
::
c
onnect
()
{
int
status
=
mu_pop3_connect
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
C
onnect"
,
status
);
throw
Exception
(
"Pop3::
c
onnect"
,
status
);
}
void
Pop3
::
D
isconnect
()
Pop3
::
d
isconnect
()
{
int
status
=
mu_pop3_disconnect
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
D
isconnect"
,
status
);
throw
Exception
(
"Pop3::
d
isconnect"
,
status
);
}
void
Pop3
::
S
etTimeout
(
int
timeout
)
Pop3
::
s
etTimeout
(
int
timeout
)
{
int
status
=
mu_pop3_set_timeout
(
pop3
,
timeout
);
if
(
status
)
throw
Exception
(
"Pop3::
S
etTimeout"
,
status
);
throw
Exception
(
"Pop3::
s
etTimeout"
,
status
);
}
int
Pop3
::
G
etTimeout
()
Pop3
::
g
etTimeout
()
{
int
timeout
;
int
status
=
mu_pop3_get_timeout
(
pop3
,
&
timeout
);
if
(
status
)
throw
Exception
(
"Pop3::
G
etTimeout"
,
status
);
throw
Exception
(
"Pop3::
g
etTimeout"
,
status
);
return
timeout
;
}
void
Pop3
::
S
tls
()
Pop3
::
s
tls
()
{
int
status
=
mu_pop3_stls
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
S
tls"
,
status
);
throw
Exception
(
"Pop3::
s
tls"
,
status
);
}
Iterator
&
Pop3
::
C
apa
()
Pop3
::
c
apa
()
{
iterator_t
mu_itr
;
mu_
iterator_t
mu_itr
;
int
status
=
mu_pop3_capa
(
pop3
,
&
mu_itr
);
if
(
status
)
throw
Exception
(
"Pop3::
C
apa"
,
status
);
throw
Exception
(
"Pop3::
c
apa"
,
status
);
return
*
new
Iterator
(
mu_itr
);
}
void
Pop3
::
D
ele
(
unsigned
int
msgno
)
Pop3
::
d
ele
(
unsigned
int
msgno
)
{
int
status
=
mu_pop3_dele
(
pop3
,
msgno
);
if
(
status
)
throw
Exception
(
"Pop3::
D
ele"
,
status
);
throw
Exception
(
"Pop3::
d
ele"
,
status
);
}
size_t
Pop3
::
L
ist
(
unsigned
int
msgno
)
Pop3
::
l
ist
(
unsigned
int
msgno
)
{
size_t
msg_octet
;
int
status
=
mu_pop3_list
(
pop3
,
msgno
,
&
msg_octet
);
if
(
status
)
throw
Exception
(
"Pop3::
L
ist"
,
status
);
throw
Exception
(
"Pop3::
l
ist"
,
status
);
return
msg_octet
;
}
Iterator
&
Pop3
::
L
istAll
()
Pop3
::
l
istAll
()
{
iterator_t
mu_itr
;
mu_
iterator_t
mu_itr
;
int
status
=
mu_pop3_list_all
(
pop3
,
&
mu_itr
);
if
(
status
)
throw
Exception
(
"Pop3::
L
istAll"
,
status
);
throw
Exception
(
"Pop3::
l
istAll"
,
status
);
return
*
new
Iterator
(
mu_itr
);
}
void
Pop3
::
N
oop
()
Pop3
::
n
oop
()
{
int
status
=
mu_pop3_noop
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
N
oop"
,
status
);
throw
Exception
(
"Pop3::
n
oop"
,
status
);
}
void
Pop3
::
P
ass
(
const
char
*
pass
)
Pop3
::
p
ass
(
const
char
*
pass
)
{
int
status
=
mu_pop3_pass
(
pop3
,
pass
);
if
(
status
)
throw
Exception
(
"Pop3::
P
ass"
,
status
);
throw
Exception
(
"Pop3::
p
ass"
,
status
);
}
void
Pop3
::
Q
uit
()
Pop3
::
q
uit
()
{
int
status
=
mu_pop3_quit
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
Q
uit"
,
status
);
throw
Exception
(
"Pop3::
q
uit"
,
status
);
}
Stream
&
Pop3
::
R
etr
(
unsigned
int
msgno
)
Pop3
::
r
etr
(
unsigned
int
msgno
)
{
stream_t
c_stm
;
mu_
stream_t
c_stm
;
int
status
=
mu_pop3_retr
(
pop3
,
msgno
,
&
c_stm
);
if
(
status
)
throw
Exception
(
"Pop3::
R
etr"
,
status
);
throw
Exception
(
"Pop3::
r
etr"
,
status
);
return
*
new
Stream
(
c_stm
);
}
void
Pop3
::
R
set
()
Pop3
::
r
set
()
{
int
status
=
mu_pop3_rset
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
R
set"
,
status
);
throw
Exception
(
"Pop3::
r
set"
,
status
);
}
void
Pop3
::
S
tat
(
unsigned
int
*
count
,
size_t
*
octets
)
Pop3
::
s
tat
(
unsigned
int
*
count
,
size_t
*
octets
)
{
int
status
=
mu_pop3_stat
(
pop3
,
count
,
octets
);
if
(
status
)
throw
Exception
(
"Pop3::
S
tat"
,
status
);
throw
Exception
(
"Pop3::
s
tat"
,
status
);
}
Stream
&
Pop3
::
T
op
(
unsigned
int
msgno
,
unsigned
int
lines
)
Pop3
::
t
op
(
unsigned
int
msgno
,
unsigned
int
lines
)
{
stream_t
c_stm
;
mu_
stream_t
c_stm
;
int
status
=
mu_pop3_top
(
pop3
,
msgno
,
lines
,
&
c_stm
);
if
(
status
)
throw
Exception
(
"Pop3::
T
op"
,
status
);
throw
Exception
(
"Pop3::
t
op"
,
status
);
return
*
new
Stream
(
c_stm
);
}
void
Pop3
::
U
ser
(
const
char
*
user
)
Pop3
::
u
ser
(
const
char
*
user
)
{
int
status
=
mu_pop3_user
(
pop3
,
user
);
if
(
status
)
throw
Exception
(
"Pop3::
U
ser"
,
status
);
throw
Exception
(
"Pop3::
u
ser"
,
status
);
}
size_t
Pop3
::
R
eadLine
(
char
*
buf
,
size_t
buflen
)
Pop3
::
r
eadLine
(
char
*
buf
,
size_t
buflen
)
{
size_t
nread
;
int
status
=
mu_pop3_readline
(
pop3
,
buf
,
buflen
,
&
nread
);
if
(
status
)
throw
Exception
(
"Pop3::
R
eadLine"
,
status
);
throw
Exception
(
"Pop3::
r
eadLine"
,
status
);
}
size_t
Pop3
::
R
esponse
(
char
*
buf
,
size_t
buflen
)
Pop3
::
r
esponse
(
char
*
buf
,
size_t
buflen
)
{
size_t
nread
;
int
status
=
mu_pop3_response
(
pop3
,
buf
,
buflen
,
&
nread
);
if
(
status
)
throw
Exception
(
"Pop3::
R
esponse"
,
status
);
throw
Exception
(
"Pop3::
r
esponse"
,
status
);
}
void
Pop3
::
S
endLine
(
const
char
*
line
)
Pop3
::
s
endLine
(
const
char
*
line
)
{
int
status
=
mu_pop3_sendline
(
pop3
,
line
);
if
(
status
)
throw
Exception
(
"Pop3::
S
endLine"
,
status
);
throw
Exception
(
"Pop3::
s
endLine"
,
status
);
}
void
Pop3
::
S
end
()
Pop3
::
s
end
()
{
int
status
=
mu_pop3_send
(
pop3
);
if
(
status
)
throw
Exception
(
"Pop3::
S
end"
,
status
);
throw
Exception
(
"Pop3::
s
end"
,
status
);
}
...
...
libmu_cpp/stream.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/stream.h>
...
...
@@ -33,7 +34,7 @@ Stream :: Stream ()
reference
();
}
Stream
::
Stream
(
const
stream_t
stm
)
Stream
::
Stream
(
const
mu_
stream_t
stm
)
{
if
(
stm
==
0
)
throw
Exception
(
"Stream::Stream"
,
EINVAL
);
...
...
@@ -53,112 +54,112 @@ Stream :: ~Stream ()
{
if
(
dereference
())
{
C
lose
();
c
lose
();
if
(
this
->
stm
)
stream_destroy
(
&
stm
,
NULL
);
mu_
stream_destroy
(
&
stm
,
NULL
);
}
}
void
Stream
::
O
pen
()
Stream
::
o
pen
()
{
int
status
=
stream_open
(
stm
);
int
status
=
mu_
stream_open
(
stm
);
if
(
status
==
EAGAIN
)
throw
Stream
::
EAgain
(
"Stream::
O
pen"
,
status
);
throw
Stream
::
EAgain
(
"Stream::
o
pen"
,
status
);
else
if
(
status
)
throw
Exception
(
"Stream::
O
pen"
,
status
);
throw
Exception
(
"Stream::
o
pen"
,
status
);
this
->
opened
=
true
;
}
void
Stream
::
C
lose
()
Stream
::
c
lose
()
{
if
(
this
->
opened
)
{
int
status
=
stream_close
(
stm
);
int
status
=
mu_
stream_close
(
stm
);
if
(
status
)
throw
Exception
(
"Stream::
C
lose"
,
status
);
throw
Exception
(
"Stream::
c
lose"
,
status
);
this
->
opened
=
false
;
}
}
void
Stream
::
S
etWaitFlags
(
int
flags
)
Stream
::
s
etWaitFlags
(
int
flags
)
{
this
->
wflags
=
flags
;
}
void
Stream
::
W
ait
()
Stream
::
w
ait
()
{
int
status
=
stream_wait
(
stm
,
&
wflags
,
NULL
);
int
status
=
mu_
stream_wait
(
stm
,
&
wflags
,
NULL
);
if
(
status
)
throw
Exception
(
"Stream::
W
ait"
,
status
);
throw
Exception
(
"Stream::
w
ait"
,
status
);
}
void
Stream
::
W
ait
(
int
flags
)
Stream
::
w
ait
(
int
flags
)
{
this
->
wflags
=
flags
;
int
status
=
stream_wait
(
stm
,
&
wflags
,
NULL
);
int
status
=
mu_
stream_wait
(
stm
,
&
wflags
,
NULL
);
if
(
status
)
throw
Exception
(
"Stream::
W
ait"
,
status
);
throw
Exception
(
"Stream::
w
ait"
,
status
);
}
void
Stream
::
R
ead
(
char
*
rbuf
,
size_t
size
,
off_t
offset
)
Stream
::
r
ead
(
char
*
rbuf
,
size_t
size
,
off_t
offset
)
{
int
status
=
stream_read
(
stm
,
rbuf
,
size
,
offset
,
&
readn
);
int
status
=
mu_
stream_read
(
stm
,
rbuf
,
size
,
offset
,
&
readn
);
if
(
status
==
EAGAIN
)
throw
Stream
::
EAgain
(
"Stream::
R
ead"
,
status
);
throw
Stream
::
EAgain
(
"Stream::
r
ead"
,
status
);
else
if
(
status
)
throw
Exception
(
"Stream::
R
ead"
,
status
);
throw
Exception
(
"Stream::
r
ead"
,
status
);
}
void
Stream
::
W
rite
(
const
std
::
string
&
wbuf
,
size_t
size
,
off_t
offset
)
Stream
::
w
rite
(
const
std
::
string
&
wbuf
,
size_t
size
,
off_t
offset
)
{
int
status
=
stream_write
(
stm
,
wbuf
.
c_str
(),
size
,
offset
,
&
writen
);
int
status
=
mu_
stream_write
(
stm
,
wbuf
.
c_str
(),
size
,
offset
,
&
writen
);
if
(
status
==
EAGAIN
)
throw
Stream
::
EAgain
(
"Stream::
W
rite"
,
status
);
throw
Stream
::
EAgain
(
"Stream::
w
rite"
,
status
);
else
if
(
status
)
throw
Exception
(
"Stream::
W
rite"
,
status
);
throw
Exception
(
"Stream::
w
rite"
,
status
);
}
void
Stream
::
R
eadLine
(
char
*
rbuf
,
size_t
size
,
off_t
offset
)
Stream
::
r
eadLine
(
char
*
rbuf
,
size_t
size
,
off_t
offset
)
{
int
status
=
stream_readline
(
stm
,
rbuf
,
size
,
offset
,
&
readn
);
int
status
=
mu_
stream_readline
(
stm
,
rbuf
,
size
,
offset
,
&
readn
);
if
(
status
==
EAGAIN
)
throw
Stream
::
EAgain
(
"Stream::
R
eadLine"
,
status
);
throw
Stream
::
EAgain
(
"Stream::
r
eadLine"
,
status
);
else
if
(
status
)
throw
Exception
(
"Stream::
R
eadLine"
,
status
);
throw
Exception
(
"Stream::
r
eadLine"
,
status
);
}
void
Stream
::
S
equentialReadLine
(
char
*
rbuf
,
size_t
size
)
Stream
::
s
equentialReadLine
(
char
*
rbuf
,
size_t
size
)
{
int
status
=
stream_sequential_readline
(
stm
,
rbuf
,
size
,
&
readn
);
int
status
=
mu_
stream_sequential_readline
(
stm
,
rbuf
,
size
,
&
readn
);
if
(
status
)
throw
Exception
(
"Stream::
S
equentialReadLine"
,
status
);
throw
Exception
(
"Stream::
s
equentialReadLine"
,
status
);
}
void
Stream
::
S
equentialWrite
(
const
std
::
string
&
wbuf
,
size_t
size
)
Stream
::
s
equentialWrite
(
const
std
::
string
&
wbuf
,
size_t
size
)
{
int
status
=
stream_sequential_write
(
stm
,
wbuf
.
c_str
(),
size
);
int
status
=
mu_
stream_sequential_write
(
stm
,
wbuf
.
c_str
(),
size
);
if
(
status
)
throw
Exception
(
"Stream::
S
equentialWrite"
,
status
);
throw
Exception
(
"Stream::
s
equentialWrite"
,
status
);
}
void
Stream
::
F
lush
()
Stream
::
f
lush
()
{
int
status
=
stream_flush
(
stm
);
int
status
=
mu_
stream_flush
(
stm
);
if
(
status
)
throw
Exception
(
"Stream::
F
lush"
,
status
);
throw
Exception
(
"Stream::
f
lush"
,
status
);
}
namespace
mailutils
...
...
@@ -166,7 +167,7 @@ namespace mailutils
Stream
&
operator
<<
(
Stream
&
stm
,
const
std
::
string
&
wbuf
)
{
stm
.
W
rite
(
wbuf
,
wbuf
.
length
(),
0
);
stm
.
w
rite
(
wbuf
,
wbuf
.
length
(),
0
);
return
stm
;
}
...
...
@@ -174,7 +175,7 @@ namespace mailutils
operator
>>
(
Stream
&
stm
,
std
::
string
&
rbuf
)
{
char
tmp
[
1024
];
stm
.
R
ead
(
tmp
,
sizeof
(
tmp
),
0
);
stm
.
r
ead
(
tmp
,
sizeof
(
tmp
),
0
);
rbuf
=
std
::
string
(
tmp
);
return
stm
;
}
...
...
@@ -186,7 +187,7 @@ namespace mailutils
TcpStream
::
TcpStream
(
const
std
::
string
&
host
,
int
port
,
int
flags
)
{
int
status
=
tcp_stream_create
(
&
stm
,
host
.
c_str
(),
port
,
flags
);
int
status
=
mu_
tcp_stream_create
(
&
stm
,
host
.
c_str
(),
port
,
flags
);
if
(
status
)
throw
Exception
(
"TcpStream::TcpStream"
,
status
);
}
...
...
@@ -197,7 +198,7 @@ TcpStream :: TcpStream (const std::string& host, int port, int flags)
FileStream
::
FileStream
(
const
std
::
string
&
filename
,
int
flags
)
{
int
status
=
file_stream_create
(
&
stm
,
filename
.
c_str
(),
flags
);
int
status
=
mu_
file_stream_create
(
&
stm
,
filename
.
c_str
(),
flags
);
if
(
status
)
throw
Exception
(
"FileStream::FileStream"
,
status
);
}
...
...
@@ -208,7 +209,7 @@ FileStream :: FileStream (const std::string& filename, int flags)
StdioStream
::
StdioStream
(
FILE
*
fp
,
int
flags
)
{
int
status
=
stdio_stream_create
(
&
stm
,
fp
,
flags
);
int
status
=
mu_
stdio_stream_create
(
&
stm
,
fp
,
flags
);
if
(
status
)
throw
Exception
(
"StdioStream::StdioStream"
,
status
);
}
...
...
@@ -219,7 +220,7 @@ StdioStream :: StdioStream (FILE* fp, int flags)
ProgStream
::
ProgStream
(
const
std
::
string
&
progname
,
int
flags
)
{
int
status
=
prog_stream_create
(
&
stm
,
progname
.
c_str
(),
flags
);
int
status
=
mu_
prog_stream_create
(
&
stm
,
progname
.
c_str
(),
flags
);
if
(
status
)
throw
Exception
(
"ProgStream::ProgStream"
,
status
);
}
...
...
@@ -231,7 +232,7 @@ ProgStream :: ProgStream (const std::string& progname, int flags)
FilterProgStream
::
FilterProgStream
(
const
std
::
string
&
progname
,
Stream
&
input
)
{
int
status
=
filter_prog_stream_create
(
&
stm
,
progname
.
c_str
(),
int
status
=
mu_
filter_prog_stream_create
(
&
stm
,
progname
.
c_str
(),
input
.
stm
);
this
->
input
=
new
Stream
(
input
);
if
(
status
)
...
...
@@ -241,7 +242,7 @@ FilterProgStream :: FilterProgStream (const std::string& progname,
FilterProgStream
::
FilterProgStream
(
const
std
::
string
&
progname
,
Stream
*
input
)
{
int
status
=
filter_prog_stream_create
(
&
stm
,
progname
.
c_str
(),
int
status
=
mu_
filter_prog_stream_create
(
&
stm
,
progname
.
c_str
(),
input
->
stm
);
this
->
input
=
new
Stream
(
*
input
);
if
(
status
)
...
...
libmu_cpp/url.cc
View file @
c9a1fa0
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
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
...
...
@@ -12,9 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include <mailutils/cpp/url.h>
...
...
@@ -29,19 +30,19 @@ using namespace mailutils;
Url
::
Url
(
const
std
::
string
&
str
)
{
int
status
=
url_create
(
&
url
,
str
.
c_str
());
int
status
=
mu_
url_create
(
&
url
,
str
.
c_str
());
if
(
status
)
throw
Exception
(
"Url::Url"
,
status
);
}
Url
::
Url
(
const
char
*
str
)
{
int
status
=
url_create
(
&
url
,
str
);
int
status
=
mu_
url_create
(
&
url
,
str
);
if
(
status
)
throw
Exception
(
"Url::Url"
,
status
);
}
Url
::
Url
(
const
url_t
url
)
Url
::
Url
(
const
mu_
url_t
url
)
{
if
(
url
==
0
)
throw
Exception
(
"Url::Url"
,
EINVAL
);
...
...
@@ -51,87 +52,87 @@ Url :: Url (const url_t url)
Url
::
~
Url
()
{
url_destroy
(
&
url
);
mu_
url_destroy
(
&
url
);
}
void
Url
::
P
arse
()
Url
::
p
arse
()
{
int
status
=
url_parse
(
url
);
int
status
=
mu_
url_parse
(
url
);
if
(
status
)
throw
Exception
(
"Url::
P
arse"
,
status
);
throw
Exception
(
"Url::
p
arse"
,
status
);
}
long
Url
::
G
etPort
()
Url
::
g
etPort
()
{
long
port
;
int
status
=
url_get_port
(
url
,
&
port
);
int
status
=
mu_
url_get_port
(
url
,
&
port
);
if
(
status
)
throw
Exception
(
"Url::
G
etPort"
,
status
);
throw
Exception
(
"Url::
g
etPort"
,
status
);
return
port
;
}
std
::
string
Url
::
G
etScheme
()
Url
::
g
etScheme
()
{
int
status
=
url_get_scheme
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_scheme
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etScheme"
,
status
);
throw
Exception
(
"Url::
g
etScheme"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Url
::
G
etUser
()
Url
::
g
etUser
()
{
int
status
=
url_get_user
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_user
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etUser"
,
status
);
throw
Exception
(
"Url::
g
etUser"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Url
::
G
etPasswd
()
Url
::
g
etPasswd
()
{
int
status
=
url_get_passwd
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_passwd
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etPasswd"
,
status
);
throw
Exception
(
"Url::
g
etPasswd"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Url
::
G
etAuth
()
Url
::
g
etAuth
()
{
int
status
=
url_get_auth
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_auth
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etAuth"
,
status
);
throw
Exception
(
"Url::
g
etAuth"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Url
::
G
etHost
()
Url
::
g
etHost
()
{
int
status
=
url_get_host
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_host
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etHost"
,
status
);
throw
Exception
(
"Url::
g
etHost"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Url
::
G
etPath
()
Url
::
g
etPath
()
{
int
status
=
url_get_path
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_path
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etPath"
,
status
);
throw
Exception
(
"Url::
g
etPath"
,
status
);
return
std
::
string
(
buf
);
}
std
::
string
Url
::
G
etQuery
()
Url
::
g
etQuery
()
{
int
status
=
url_get_query
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
int
status
=
mu_
url_get_query
(
url
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
status
)
throw
Exception
(
"Url::
G
etQuery"
,
status
);
throw
Exception
(
"Url::
g
etQuery"
,
status
);
return
std
::
string
(
buf
);
}
...
...
Please
register
or
sign in
to post a comment