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
0908e210
...
0908e2108247ae700d37138d970eff061251408e
authored
2004-01-12 12:29:29 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Auto-detection of MH format
1 parent
54759f99
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
9 deletions
mailbox/mh/folder.c
mailbox/mh/folder.c
View file @
0908e21
...
...
@@ -21,20 +21,113 @@
#ifdef ENABLE_MH
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <url0.h>
#include <folder0.h>
#include <registrar0.h>
static
int
_mh_folder_init
(
folder_t
folder
ARG_UNUSED
)
{
return
0
;
}
/* Check if NAME is a valid MH message name */
static
int
mh_message_name_p
(
const
char
*
name
)
{
for
(
;
*
name
;
name
++
)
if
(
!
isdigit
(
*
name
))
return
0
;
return
1
;
}
/* Check if directory NAME is a valid MH folder directory */
static
int
mh_dir_p
(
const
char
*
name
)
{
DIR
*
dir
;
struct
dirent
*
entry
;
int
result
=
0
;
dir
=
opendir
(
name
);
if
(
!
dir
)
return
1
;
/* Maybe yes */
while
(
!
result
&&
(
entry
=
readdir
(
dir
)))
{
switch
(
entry
->
d_name
[
0
])
{
case
'.'
:
result
=
strcmp
(
entry
->
d_name
,
".mh_sequences"
)
==
0
;
break
;
case
','
:
result
=
mh_message_name_p
(
entry
->
d_name
+
1
);
break
;
default:
result
=
mh_message_name_p
(
entry
->
d_name
);
break
;
}
}
closedir
(
dir
);
return
result
;
}
static
int
_mh_is_scheme
(
record_t
record
,
const
char
*
url
)
{
if
(
!
url
||
!
record
->
scheme
)
return
0
;
if
(
strncmp
(
record
->
scheme
,
url
,
strlen
(
record
->
scheme
))
==
0
)
return
1
;
if
(
strncmp
(
MU_PATH_SCHEME
,
url
,
MU_PATH_SCHEME_LEN
)
==
0
)
{
/* Attemp auto-detection */
struct
stat
st
;
if
(
stat
(
url
,
&
st
)
<
0
)
return
1
;
/* mailbox_open will complain */
if
(
!
S_ISDIR
(
st
.
st_mode
))
return
0
;
return
mh_dir_p
(
url
);
}
return
0
;
}
/*
MH url
mh:path
*/
static
int
_mh_url_init
(
url_t
url
)
{
return
amd_url_init
(
url
,
MU_MH_SCHEME
);
}
static
struct
_record
_mh_record
=
{
MU_MH_SCHEME
,
_
url_mh
_init
,
/* Url init. */
_
mh_url
_init
,
/* Url init. */
_mailbox_mh_init
,
/* Mailbox init. */
NULL
,
/* Mailer init. */
_
folder_mh
_init
,
/* Folder init. */
_
mh_folder
_init
,
/* Folder init. */
NULL
,
/* back pointer. */
NULL
,
/* _is_scheme method. */
_mh_is_scheme
,
/* _is_scheme method. */
NULL
,
/* _get_url method. */
NULL
,
/* _get_mailbox method. */
NULL
,
/* _get_mailer method. */
...
...
@@ -42,12 +135,6 @@ static struct _record _mh_record =
};
record_t
mh_record
=
&
_mh_record
;
int
_folder_mh_init
(
folder_t
folder
ARG_UNUSED
)
{
return
0
;
}
#else
#include <stdio.h>
#include <registrar0.h>
...
...
Please
register
or
sign in
to post a comment