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
77828c25
...
77828c2505965ebaa7a295cd9819c5c7302bbe41
authored
2002-09-21 19:12:55 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Use new configuration functions.
1 parent
15c5d562
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
87 deletions
mh/inc.c
mh/mh_argp.c
mh/mh_init.c
mh/refile.c
mh/scan.c
mh/inc.c
View file @
77828c2
...
...
@@ -81,7 +81,7 @@ opt_handler (int key, char *arg, void *unused)
break
;
case
'c'
:
changecur
=
arg
[
0
]
==
'y'
;
changecur
=
is_true
(
arg
)
;
break
;
case
'+'
:
...
...
@@ -98,7 +98,7 @@ opt_handler (int key, char *arg, void *unused)
break
;
case
'T'
:
truncate_source
=
arg
[
0
]
==
'y'
;
truncate_source
=
is_true
(
arg
)
;
break
;
case
'w'
:
...
...
@@ -243,7 +243,7 @@ main (int argc, char **argv)
}
if
(
changecur
)
mh_
save_context
();
mh_
global_save_state
();
mailbox_close
(
output
);
mailbox_destroy
(
&
output
);
...
...
mh/mh_argp.c
View file @
77828c2
...
...
@@ -97,7 +97,7 @@ mh_argp_parse (int argc, char **argv,
data
.
handler
=
handler
;
data
.
doc
=
argp_doc
;
p
=
mh_
profile_value
(
program_invocation_short_name
,
NULL
);
p
=
mh_
global_profile_get
(
program_invocation_short_name
,
NULL
);
if
(
p
)
{
int
_argc
;
...
...
mh/mh_init.c
View file @
77828c2
...
...
@@ -23,12 +23,6 @@
#include <sys/stat.h>
#include <stdarg.h>
char
*
current_folder
=
NULL
;
size_t
current_message
=
0
;
mh_context_t
*
context
;
mh_context_t
*
profile
;
mh_context_t
*
sequences
;
char
mh_list_format
[]
=
"%4(msg)%<(cur)+%| %>%<{replied}-%?{encrypted}E%| %>"
"%02(mon{date})/%02(mday{date})"
...
...
@@ -61,70 +55,8 @@ mh_init ()
void
mh_init2
()
{
char
*
mh_sequences_name
;
char
*
seq_name
,
*
ctx_name
;
char
*
p
;
mu_path_folder_dir
=
mh_get_dir
();
p
=
getenv
(
"CONTEXT"
);
if
(
!
p
)
p
=
"context"
;
ctx_name
=
mh_expand_name
(
p
,
0
);
context
=
mh_context_create
(
ctx_name
,
1
);
mh_context_read
(
context
);
if
(
current_folder
)
current_folder
=
mu_tilde_expansion
(
current_folder
,
"/"
,
NULL
);
else
current_folder
=
mh_context_get_value
(
context
,
"Current-Folder"
,
mh_profile_value
(
"Inbox"
,
"inbox"
));
mh_sequences_name
=
mh_profile_value
(
"mh-sequences"
,
MH_SEQUENCES_FILE
);
p
=
mh_expand_name
(
current_folder
,
0
);
asprintf
(
&
seq_name
,
"%s/%s"
,
p
,
mh_sequences_name
);
free
(
p
);
sequences
=
mh_context_create
(
seq_name
,
1
);
if
(
mh_context_read
(
sequences
)
==
0
)
{
p
=
mh_context_get_value
(
sequences
,
"cur"
,
"0"
);
current_message
=
strtoul
(
p
,
NULL
,
10
);
}
}
char
*
mh_profile_value
(
char
*
name
,
char
*
defval
)
{
return
mh_context_get_value
(
profile
,
name
,
defval
);
}
void
mh_read_profile
()
{
char
*
p
;
p
=
getenv
(
"MH"
);
if
(
p
)
p
=
mu_tilde_expansion
(
p
,
"/"
,
NULL
);
else
{
char
*
home
=
mu_get_homedir
();
if
(
!
home
)
abort
();
/* shouldn't happen */
asprintf
(
&
p
,
"%s/%s"
,
home
,
MH_USER_PROFILE
);
free
(
home
);
}
profile
=
mh_context_create
(
p
,
1
);
mh_context_read
(
profile
);
}
void
mh_save_context
()
{
char
buf
[
64
];
snprintf
(
buf
,
sizeof
buf
,
"%d"
,
current_message
);
mh_context_set_value
(
sequences
,
"cur"
,
buf
);
mh_context_write
(
sequences
);
mh_current_folder
();
mh_global_sequences_get
(
"cur"
,
NULL
);
}
int
...
...
@@ -207,7 +139,7 @@ mh_is_my_name (char *name)
}
int
mh_check_folder
(
char
*
pathname
)
mh_check_folder
(
char
*
pathname
,
int
confirm
)
{
char
*
p
;
struct
stat
st
;
...
...
@@ -221,10 +153,10 @@ mh_check_folder (char *pathname)
{
if
(
errno
==
ENOENT
)
{
if
(
mh_getyn
(
"Create folder
\"
%s
\"
"
,
p
))
if
(
!
confirm
||
mh_getyn
(
"Create folder
\"
%s
\"
"
,
p
))
{
int
perm
=
0711
;
char
*
pb
=
mh_
profile_value
(
"Folder-Protect"
,
NULL
);
char
*
pb
=
mh_
global_profile_get
(
"Folder-Protect"
,
NULL
);
if
(
pb
)
perm
=
strtoul
(
pb
,
NULL
,
8
);
if
(
mkdir
(
p
,
perm
))
...
...
@@ -354,7 +286,7 @@ mh_open_folder (const char *folder, int create)
int
flags
=
MU_STREAM_READ
;
name
=
mh_expand_name
(
folder
,
1
);
if
(
create
&&
mh_check_folder
(
name
))
if
(
create
&&
mh_check_folder
(
name
,
1
))
exit
(
0
);
if
(
mailbox_create_default
(
&
mbox
,
name
))
...
...
@@ -381,7 +313,7 @@ mh_open_folder (const char *folder, int create)
char
*
mh_get_dir
()
{
char
*
mhdir
=
mh_
profile_value
(
"Path"
,
"Mail"
);
char
*
mhdir
=
mh_
global_profile_get
(
"Path"
,
"Mail"
);
if
(
mhdir
[
0
]
!=
'/'
)
{
char
*
p
=
mu_get_homedir
();
...
...
mh/refile.c
View file @
77828c2
...
...
@@ -27,8 +27,8 @@ static char args_doc[] = "messages folder [folder...]";
static
struct
argp_option
options
[]
=
{
{
"folder"
,
'f'
,
"FOLDER"
,
0
,
"Specify folder to operate upon"
},
{
"draft"
,
'd'
,
NULL
,
0
,
"Use <mh-dir>/draft as the source message"
},
{
"link"
,
'l'
,
"BOOL"
,
OPTION_ARG_OPTIONAL
,
"Preserve the source folder copy"
},
{
"preserve"
,
'p'
,
"BOOL"
,
OPTION_ARG_OPTIONAL
,
"Try to preserve message sequence numbers"
},
{
"link"
,
'l'
,
"BOOL"
,
OPTION_ARG_OPTIONAL
,
"
(not implemented)
Preserve the source folder copy"
},
{
"preserve"
,
'p'
,
"BOOL"
,
OPTION_ARG_OPTIONAL
,
"
(not implemented)
Try to preserve message sequence numbers"
},
{
"source"
,
's'
,
"FOLDER"
,
0
,
"Specify source folder. FOLDER will became the current folder after the program exits."
},
{
"src"
,
0
,
NULL
,
OPTION_ALIAS
,
NULL
},
{
"file"
,
'F'
,
"FILE"
,
0
,
"Use FILE as the source message"
},
...
...
@@ -136,11 +136,11 @@ opt_handler (int key, char *arg, void *unused)
break
;
case
'l'
:
link_flag
=
arg
[
0
]
==
'y'
;
link_flag
=
is_true
(
arg
)
;
break
;
case
'p'
:
preserve_flag
=
arg
[
0
]
==
'y'
;
preserve_flag
=
is_true
(
arg
)
;
break
;
case
's'
:
...
...
@@ -158,7 +158,7 @@ opt_handler (int key, char *arg, void *unused)
}
void
_close_folder
(
void
*
unuse
s
,
mailbox_t
mbox
)
_close_folder
(
void
*
unuse
d
,
mailbox_t
mbox
)
{
mailbox_close
(
mbox
);
mailbox_destroy
(
&
mbox
);
...
...
mh/scan.c
View file @
77828c2
...
...
@@ -82,7 +82,7 @@ opt_handler (int key, char *arg, void *unused)
break
;
case
'c'
:
clear
=
arg
[
0
]
==
'y'
;
clear
=
is_true
(
arg
)
;
break
;
case
'F'
:
...
...
@@ -94,7 +94,7 @@ opt_handler (int key, char *arg, void *unused)
break
;
case
'H'
:
header
=
arg
[
0
]
==
'y'
;
header
=
is_true
(
arg
)
;
break
;
case
'w'
:
...
...
@@ -107,7 +107,7 @@ opt_handler (int key, char *arg, void *unused)
break
;
case
'r'
:
reverse
=
arg
[
0
]
==
'y'
;
reverse
=
is_true
(
arg
)
;
break
;
case
'i'
:
...
...
@@ -210,6 +210,7 @@ scan (mailbox_t mbox)
for
(
i
=
1
;
i
<=
total
;
i
++
)
list_message
(
mbox
,
i
,
buffer
,
width
);
clear_screen
();
mh_global_save_state
();
return
0
;
}
...
...
Please
register
or
sign in
to post a comment