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
1da17967
...
1da179679b3e0b59f9fb3cba683a1a35b5e12240
authored
2000-09-06 21:01:06 +0000
by
Jakob Kaivo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fix some buglets in mailx, prepare some commands for GNU extensions
1 parent
d685b048
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
55 deletions
mail/echo.c
mail/followup.c
mail/headers.c
mail/mail.h
mail/reply.c
mail/set.c
mail/table.c
mail/unset.c
mail/util.c
mail/write.c
mail/echo.c
View file @
1da1796
...
...
@@ -25,8 +25,11 @@ int
mail_echo
(
int
argc
,
char
**
argv
)
{
int
i
=
0
;
for
(
i
=
1
;
i
<
argc
-
1
;
i
++
)
printf
(
"%s "
,
argv
[
i
]);
printf
(
"%s
\n
"
,
argv
[
argc
]);
if
(
argc
>
1
)
{
for
(
i
=
1
;
i
<
argc
-
1
;
i
++
)
printf
(
"%s "
,
argv
[
i
]);
printf
(
"%s
\n
"
,
argv
[
argc
-
1
]);
}
return
0
;
}
...
...
mail/followup.c
View file @
1da1796
...
...
@@ -18,7 +18,7 @@
#include "mail.h"
/*
* fo[llowup] [m
essage]
* fo[llowup] [m
sglist] -- GNU extension
* F[ollowup] [msglist]
*/
...
...
mail/headers.c
View file @
1da1796
...
...
@@ -18,36 +18,51 @@
#include "mail.h"
/*
* h[eaders] [message]
* h[eaders] [msglist] -- GNU extension
*/
/*
* NOTE: check for messages near each other and only print them once
* should probably build a dynamic msglist for this
*/
int
mail_headers
(
int
argc
,
char
**
argv
)
{
char
buf
[
64
];
int
low
=
1
,
high
=
total
,
middle
=
cursor
;
int
lines
=
util_getlines
()
-
2
;
if
(
argc
>
2
)
return
1
;
if
(
argc
==
2
)
middle
=
strtol
(
argv
[
1
],
NULL
,
10
);
if
(
lines
<
total
)
int
low
=
1
,
high
=
total
,
*
list
=
NULL
,
i
=
0
;
int
lines
=
util_getlines
();
int
num
=
util_expand_msglist
(
argc
,
argv
,
&
list
);
if
(
num
==
0
)
{
low
=
middle
-
(
lines
/
2
);
if
(
low
<
1
)
low
=
1
;
high
=
low
+
lines
;
if
(
high
>
total
)
list
=
malloc
(
sizeof
(
int
));
*
list
=
cursor
;
num
=
1
;
}
lines
=
(
lines
/
num
)
-
2
;
for
(
i
=
0
;
i
<
num
;
i
++
)
{
if
(
lines
<
total
)
{
high
=
total
;
low
=
high
-
lines
;
low
=
list
[
i
]
-
(
lines
/
2
);
if
(
low
<
1
)
low
=
1
;
high
=
low
+
lines
;
if
(
high
>
total
)
{
high
=
total
;
low
=
high
-
lines
;
}
}
memset
(
buf
,
'\0'
,
64
);
snprintf
(
buf
,
64
,
"from %d-%d"
,
low
,
high
);
util_do_command
(
buf
);
}
memset
(
buf
,
'\0'
,
64
);
snprintf
(
buf
,
64
,
"from %d-%d"
,
low
,
high
);
return
util_do_command
(
buf
);
free
(
list
);
return
0
;
}
...
...
mail/mail.h
View file @
1da1796
...
...
@@ -140,7 +140,7 @@ struct mail_command_entry util_find_entry __P((char *cmd));
int
util_getcols
__P
((
void
));
int
util_getlines
__P
((
void
));
struct
mail_env_entry
*
util_find_env
__P
((
char
*
var
));
int
util_printenv
__P
((
void
));
int
util_printenv
__P
((
int
set
));
#ifdef __cplusplus
}
...
...
mail/reply.c
View file @
1da1796
...
...
@@ -18,8 +18,8 @@
#include "mail.h"
/*
* r[eply] [m
essage]
* r[espond] [m
essage]
* r[eply] [m
sglist] -- GNU extension
* r[espond] [m
sglist] -- GNU extension
* R[eply] [msglist]
* R[espond] [msglist]
*/
...
...
mail/set.c
View file @
1da1796
...
...
@@ -30,7 +30,7 @@ mail_set (int argc, char **argv)
{
if
(
argc
<
2
)
{
return
util_printenv
();
return
util_printenv
(
1
);
}
else
{
...
...
@@ -42,6 +42,8 @@ mail_set (int argc, char **argv)
if
(
!
strncmp
(
"no"
,
argv
[
i
],
2
))
{
entry
=
util_find_env
(
&
argv
[
i
][
2
]);
if
(
entry
==
NULL
)
return
1
;
entry
->
set
=
0
;
free
(
entry
->
value
);
}
...
...
@@ -57,14 +59,18 @@ mail_set (int argc, char **argv)
}
value
=
strdup
(
&
var
[
j
+
1
]);
entry
=
util_find_env
(
var
);
free
(
var
);
if
(
entry
==
NULL
)
return
1
;
entry
->
set
=
1
;
free
(
entry
->
value
);
entry
->
value
=
value
;
free
(
var
);
}
else
{
entry
=
util_find_env
(
argv
[
i
]);
if
(
entry
==
NULL
)
return
1
;
entry
->
set
=
1
;
free
(
entry
->
value
);
entry
->
value
=
NULL
;
...
...
mail/table.c
View file @
1da1796
...
...
@@ -24,8 +24,7 @@ const struct mail_command_entry mail_command_table[] = {
{
"C"
,
"Copy"
,
mail_copy
,
"C[opy] [msglist]"
},
{
"cd"
,
"cd"
,
mail_cd
,
"cd [directory]"
},
{
"ch"
,
"chdir"
,
mail_cd
,
"ch[dir] directory"
},
{
"c"
,
"copy"
,
mail_copy
,
"c[opy] [file]
\n
c[opy] [msglist] file"
},
{
"c"
,
"copy"
,
mail_copy
,
"c[opy] [[msglist] file]"
},
{
"d"
,
"delete"
,
mail_delete
,
"d[elete] [msglist]"
},
{
"di"
,
"discard"
,
mail_discard
,
"di[scard] [header-field...]"
},
...
...
@@ -40,12 +39,12 @@ const struct mail_command_entry mail_command_table[] = {
{
"fi"
,
"file"
,
mail_file
,
"fi[le] [file]"
},
{
"fold"
,
"folder"
,
mail_file
,
"fold[er] [file]"
},
{
"folders"
,
"folders"
,
mail_folders
,
"folders"
},
{
"fo"
,
"followup"
,
mail_followup
,
"fo[llowup] [m
essage
]"
},
{
"fo"
,
"followup"
,
mail_followup
,
"fo[llowup] [m
sglist
]"
},
{
"f"
,
"from"
,
mail_from
,
"f[rom] [msglist]"
},
{
"g"
,
"group"
,
mail_alias
,
"g[roup] [alias [address...]]"
},
{
"h"
,
"headers"
,
mail_headers
,
"h[eaders] [m
essage
]"
},
{
"hel"
,
"help"
,
mail_help
,
"hel[p] [command]"
},
{
"h"
,
"headers"
,
mail_headers
,
"h[eaders] [m
sglist
]"
},
{
"hel"
,
"help"
,
mail_help
,
"hel[p] [command
...
]"
},
{
"ho"
,
"hold"
,
mail_hold
,
"ho[ld] [msglist]"
},
{
"i"
,
"if"
,
mail_if
,
"i[f] s|r"
},
/* FIXME */
{
"ig"
,
"ignore"
,
mail_discard
,
"ig[nore] [header-field...]"
},
...
...
@@ -55,18 +54,17 @@ const struct mail_command_entry mail_command_table[] = {
{
"n"
,
"next"
,
mail_next
,
"n[ext] [message]"
},
{
"P"
,
"Print"
,
mail_print
,
"P[rint] [msglist]"
},
{
"pi"
,
"pipe"
,
mail_pipe
,
"pi[pe] [[msglist] command]"
},
{
"pre"
,
"preserve"
,
mail_hold
,
"pre[serve
r
] [msglist]"
},
{
"pre"
,
"preserve"
,
mail_hold
,
"pre[serve] [msglist]"
},
{
"prev"
,
"previous"
,
mail_previous
,
"prev[ious] [message]"
},
{
"p"
,
"print"
,
mail_print
,
"p[rint] [msglist]"
},
{
"q"
,
"quit"
,
mail_quit
,
"q[uit]"
},
{
"R"
,
"Reply"
,
mail_reply
,
"R[eply] [msglist]"
},
{
"R"
,
"Respond"
,
mail_reply
,
"R[espond] [msglist]"
},
{
"r"
,
"reply"
,
mail_reply
,
"r[eply] [m
essage
]"
},
{
"r"
,
"respond"
,
mail_reply
,
"r[espond] [m
essage
]"
},
{
"r"
,
"reply"
,
mail_reply
,
"r[eply] [m
sglist
]"
},
{
"r"
,
"respond"
,
mail_reply
,
"r[espond] [m
sglist
]"
},
{
"ret"
,
"retain"
,
mail_retain
,
"ret[ain] [header-field]"
},
{
"S"
,
"Save"
,
mail_save
,
"S[ave] [msglist]"
},
{
"s"
,
"save"
,
mail_save
,
"s[ave] [file]
\n
s[ave] [msglist] file"
},
{
"s"
,
"save"
,
mail_save
,
"s[ave] [[msglist] file]"
},
{
"se"
,
"set"
,
mail_set
,
"se[t] [name[=[string]]...] [name=number...] [noname...]"
},
{
"sh"
,
"shell"
,
mail_shell
,
"sh[ell]"
},
...
...
@@ -81,11 +79,10 @@ const struct mail_command_entry mail_command_table[] = {
{
"uns"
,
"unset"
,
mail_unset
,
"uns[et] name..."
},
{
"v"
,
"visual"
,
mail_visual
,
"v[isual] [msglist]"
},
{
"W"
,
"Write"
,
mail_write
,
"W[rite] [msglist]"
},
{
"w"
,
"write"
,
mail_write
,
"w[rite] [file]
\n
w[rite] [msglist] file"
},
{
"w"
,
"write"
,
mail_write
,
"w[rite] [[msglist] file]"
},
{
"x"
,
"xit"
,
mail_exit
,
"x[it]"
},
{
"z"
,
""
,
mail_z
,
"z[+|-]"
},
{
"?"
,
"?"
,
mail_help
,
"? [command]"
},
{
"?"
,
"?"
,
mail_help
,
"? [command
...
]"
},
{
"!"
,
""
,
mail_bang
,
"!command"
},
{
"="
,
"="
,
mail_eq
,
"="
},
{
"#"
,
"#"
,
NULL
,
"# comment"
},
...
...
mail/unset.c
View file @
1da1796
...
...
@@ -18,26 +18,27 @@
#include "mail.h"
/*
* uns[et]
name...
* uns[et]
[name...] -- GNU extension
*/
int
mail_unset
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
2
)
return
1
;
return
util_printenv
(
0
)
;
else
{
int
status
=
0
,
i
=
1
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
char
*
buf
=
malloc
((
6
+
strlen
(
argv
[
i
]))
*
sizeof
(
char
));
char
*
buf
=
malloc
((
7
+
strlen
(
argv
[
i
]))
*
sizeof
(
char
));
strcpy
(
buf
,
"set no"
);
strcat
(
buf
,
argv
[
i
]);
if
(
!
util_do_command
(
buf
))
status
=
1
;
free
(
buf
);
}
return
status
;
}
return
1
;
}
...
...
mail/util.c
View file @
1da1796
...
...
@@ -36,9 +36,6 @@ util_ll_add (node *c, int data)
{
c
->
next
=
malloc
(
sizeof
(
node
));
c
->
data
=
data
;
/* c->env_entry.var = NULL;
c->env_entry.set = 0;
c->env_entry.value = NULL;*/
c
->
next
->
env_entry
.
var
=
NULL
;
c
->
next
->
env_entry
.
set
=
0
;
c
->
next
->
env_entry
.
value
=
NULL
;
...
...
@@ -380,6 +377,9 @@ util_find_env (char *variable)
int
len
=
strlen
(
var
),
need_free
=
0
;
node
*
t
;
if
(
len
<
1
)
return
NULL
;
if
(
len
==
strlen
(
"ask"
)
&&
!
strcmp
(
"ask"
,
var
))
{
var
=
strdup
(
"asksub"
);
...
...
@@ -407,7 +407,7 @@ util_find_env (char *variable)
return
&
(
env_cursor
->
env_entry
);
}
}
/* env_cursor = util_ll_add (env_cursor, 0); */
env_cursor
->
env_entry
.
var
=
strdup
(
var
);
env_cursor
->
env_entry
.
set
=
0
;
env_cursor
->
env_entry
.
value
=
NULL
;
...
...
@@ -422,12 +422,12 @@ util_find_env (char *variable)
* print the environment
*/
int
util_printenv
(
void
)
util_printenv
(
int
set
)
{
for
(
env_cursor
=
environment
;
env_cursor
!=
NULL
;
env_cursor
=
env_cursor
->
next
)
{
if
(
env_cursor
->
env_entry
.
set
)
if
(
env_cursor
->
env_entry
.
set
==
set
)
{
printf
(
"%s"
,
env_cursor
->
env_entry
.
var
);
if
(
env_cursor
->
env_entry
.
value
!=
NULL
)
...
...
mail/write.c
View file @
1da1796
...
...
@@ -18,9 +18,9 @@
#include "mail.h"
/*
* w[rite] [file]
GNU extension
* w[rite] [file]
--
GNU extension
* w[rite] [msglist] file
* W[rite] [msglist]
GNU extension
* W[rite] [msglist]
--
GNU extension
*/
/*
...
...
Please
register
or
sign in
to post a comment