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
0a1c0c33
...
0a1c0c336d1e4884d9c2440595b49923a113cd05
authored
2006-03-07 15:07:53 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(base64_encode): Split into two functions
(B_encode): New function for RFC 2047 encoding
1 parent
d83990fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
5 deletions
mailbox/filter_trans.c
mailbox/filter_trans.c
View file @
0a1c0c3
...
...
@@ -450,10 +450,10 @@ base64_decode (const char *iptr, size_t isize, char *optr, size_t osize,
return
consumed
;
}
#define BASE64_LINE_MAX 77
static
int
base64_encode
(
const
char
*
iptr
,
size_t
isize
,
char
*
optr
,
size_t
osize
,
size_t
*
nbytes
,
int
*
line_len
)
base64_encode_internal
(
const
char
*
iptr
,
size_t
isize
,
char
*
optr
,
size_t
osize
,
size_t
*
nbytes
,
int
*
line_len
,
int
line_max
)
{
size_t
consumed
=
0
;
int
pad
=
0
;
...
...
@@ -466,7 +466,7 @@ base64_encode (const char *iptr, size_t isize, char *optr, size_t osize,
pad
=
1
;
while
(((
consumed
+
3
)
<=
isize
&&
(
*
nbytes
+
4
)
<=
osize
)
||
pad
)
{
if
(
*
line_len
==
76
)
if
(
line_max
&&
*
line_len
==
line_max
)
{
*
optr
++
=
'\n'
;
(
*
nbytes
)
++
;
...
...
@@ -488,6 +488,15 @@ base64_encode (const char *iptr, size_t isize, char *optr, size_t osize,
}
static
int
base64_encode
(
const
char
*
iptr
,
size_t
isize
,
char
*
optr
,
size_t
osize
,
size_t
*
nbytes
,
int
*
line_len
)
{
return
base64_encode_internal
(
iptr
,
isize
,
optr
,
osize
,
nbytes
,
line_len
,
76
);
}
static
int
base64_init
(
mu_filter_t
filter
)
{
struct
_trans_stream
*
ts
;
...
...
@@ -519,10 +528,42 @@ static struct _mu_filter_record _base64_filter =
NULL
};
static
int
B_encode
(
const
char
*
iptr
,
size_t
isize
,
char
*
optr
,
size_t
osize
,
size_t
*
nbytes
,
int
*
line_len
)
{
return
base64_encode_internal
(
iptr
,
isize
,
optr
,
osize
,
nbytes
,
line_len
,
0
);
}
static
int
B_init
(
mu_filter_t
filter
)
{
struct
_trans_stream
*
ts
;
ts
=
calloc
(
sizeof
(
*
ts
),
1
);
if
(
ts
==
NULL
)
return
ENOMEM
;
ts
->
min_size
=
4
;
ts
->
s_buf
=
calloc
(
ts
->
min_size
,
1
);
if
(
ts
->
s_buf
==
NULL
)
{
free
(
ts
);
return
ENOMEM
;
}
ts
->
transcoder
=
(
filter
->
type
==
MU_FILTER_DECODE
)
?
base64_decode
:
B_encode
;
filter
->
_read
=
trans_read
;
filter
->
_destroy
=
trans_destroy
;
filter
->
data
=
ts
;
return
0
;
}
static
struct
_mu_filter_record
_B_filter
=
{
"B"
,
base64
_init
,
B
_init
,
NULL
,
NULL
,
NULL
...
...
Please
register
or
sign in
to post a comment