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
014fc925
...
014fc9250450751f3f0bd6a9f36da8ba7cca7e49
authored
2005-07-26 06:28:10 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mailbox_create): Rewritten using registrar_lookup()
1 parent
a84aa11a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
65 deletions
mailbox/mailbox.c
mailbox/mailbox.c
View file @
014fc92
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2004
, 2005
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
...
...
@@ -47,84 +47,65 @@
int
mailbox_create
(
mailbox_t
*
pmbox
,
const
char
*
name
)
{
int
status
=
EINVAL
;
record_t
record
=
NULL
;
int
(
*
m_init
)
__P
((
mailbox_t
))
=
NULL
;
int
(
*
u_init
)
__P
((
url_t
))
=
NULL
;
iterator_t
iterator
;
list_t
list
;
int
found
=
0
;
if
(
pmbox
==
NULL
)
return
MU_ERR_OUT_PTR_NULL
;
/* Look in the registrar, for a match */
registrar_get_list
(
&
list
);
status
=
list_get_iterator
(
list
,
&
iterator
);
if
(
status
!=
0
)
return
status
;
for
(
iterator_first
(
iterator
);
!
iterator_is_done
(
iterator
);
iterator_next
(
iterator
))
if
(
registrar_lookup
(
name
,
&
record
)
==
0
)
{
iterator_current
(
iterator
,
(
void
**
)
&
record
);
if
(
record_is_scheme
(
record
,
name
))
{
record_get_mailbox
(
record
,
&
m_init
);
record_get_url
(
record
,
&
u_init
);
if
(
m_init
&&
u_init
)
int
(
*
m_init
)
__P
((
mailbox_t
))
=
NULL
;
int
(
*
u_init
)
__P
((
url_t
))
=
NULL
;
record_get_mailbox
(
record
,
&
m_init
);
record_get_url
(
record
,
&
u_init
);
if
(
m_init
&&
u_init
)
{
int
status
;
url_t
url
;
mailbox_t
mbox
;
/* Allocate memory for mbox. */
mbox
=
calloc
(
1
,
sizeof
(
*
mbox
));
if
(
mbox
==
NULL
)
return
ENOMEM
;
/* Initialize the internal lock now, so the concrete mailbox
could use it. */
status
=
monitor_create
(
&
mbox
->
monitor
,
0
,
mbox
);
if
(
status
!=
0
)
{
found
=
1
;
break
;
mailbox_destroy
(
&
mbox
)
;
return
status
;
}
}
}
iterator_destroy
(
&
iterator
);
if
(
found
)
{
url_t
url
=
NULL
;
mailbox_t
mbox
;
/* Allocate memory for mbox. */
mbox
=
calloc
(
1
,
sizeof
(
*
mbox
));
if
(
mbox
==
NULL
)
return
ENOMEM
;
/* Initialize the internal lock now, so the concrete mailbox
could use it. */
status
=
monitor_create
(
&
(
mbox
->
monitor
),
0
,
mbox
);
if
(
status
!=
0
)
{
mailbox_destroy
(
&
mbox
);
return
status
;
}
/* Parse the url, it may be a bad one and we should bailout if this
failed. */
if
((
status
=
url_create
(
&
url
,
name
))
!=
0
||
(
status
=
u_init
(
url
))
!=
0
)
{
mailbox_destroy
(
&
mbox
);
return
status
;
}
mbox
->
url
=
url
;
/* Create the folder before initializing the concrete mailbox.
The mailbox needs it's back pointer. */
status
=
folder_create
(
&
mbox
->
folder
,
name
);
if
(
status
==
0
)
status
=
m_init
(
mbox
);
/* Create the concrete mailbox type. */
if
(
status
!=
0
)
mailbox_destroy
(
&
mbox
);
else
*
pmbox
=
mbox
;
/* Parse the url, it may be a bad one and we should bailout if this
failed. */
if
((
status
=
url_create
(
&
url
,
name
))
!=
0
||
(
status
=
u_init
(
url
))
!=
0
)
{
mailbox_destroy
(
&
mbox
);
return
status
;
}
mbox
->
url
=
url
;
/* Create the folder before initializing the concrete mailbox.
The mailbox needs it's back pointer. */
status
=
folder_create
(
&
mbox
->
folder
,
name
);
if
(
status
==
0
)
status
=
m_init
(
mbox
);
/* Create the concrete mailbox type. */
if
(
status
!=
0
)
mailbox_destroy
(
&
mbox
);
else
*
pmbox
=
mbox
;
}
else
status
=
MU_ERR_NO_HANDLER
;
return
status
;
return
MU_ERR_NO_HANDLER
;
}
void
...
...
Please
register
or
sign in
to post a comment