diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-11-24 16:53:34 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-11-24 16:53:34 +0200 |
commit | 2ef58f17e48b99f5c95c2c90e8ba9a4190663dd8 (patch) | |
tree | 82cf09cd7934344dcc2b110fc498e64b407e1339 /libmu_auth | |
parent | 27f9a867f4fcfaf29a22349043eaddcb60c2694e (diff) | |
download | mailutils-2ef58f17e48b99f5c95c2c90e8ba9a4190663dd8.tar.gz mailutils-2ef58f17e48b99f5c95c2c90e8ba9a4190663dd8.tar.bz2 |
New type of stream: static memory stream.
Static memory stream is a read-only stream whose transport is
an arbitrary area of memory. Such streams allow the programmer
to access C strings using streams interface.
* include/mailutils/stream.h (mu_static_memory_stream_create): New
proto.
* libmailutils/stream/memory_stream.c (mu_static_memory_stream_create): New
function.
* imap4d/append.c (imap4d_append0): Use static memory stream to
create a temporary message.
* imap4d/preauth.c (decode64_buf): Use static memory stream.
* libmailutils/base/rfc2047.c (mu_rfc2047_decode): Likewise.
* libmailutils/mime/mimehdr.c (mu_mimehdr_decode_param): Likewise.
* libmu_auth/ldap.c (chk_md5, chk_sha, chk_ssha): Likewise.
* libmu_sieve/extensions/vacation.c (build_mime): Likewise.
Diffstat (limited to 'libmu_auth')
-rw-r--r-- | libmu_auth/ldap.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c index 5de7834ab..6a763aa81 100644 --- a/libmu_auth/ldap.c +++ b/libmu_auth/ldap.c @@ -598,10 +598,9 @@ chk_md5 (const char *db_pass, const char *pass) mu_md5_process_bytes (pass, strlen (pass), &md5context); mu_md5_finish_ctx (&md5context, md5digest); - mu_memory_stream_create (&str, 0); + mu_static_memory_stream_create (&str, db_pass, strlen (db_pass)); mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_AUTOCLOSE); - mu_stream_write (str, db_pass, strlen (db_pass), NULL); mu_stream_read (flt, (char*) d1, sizeof d1, NULL); mu_stream_destroy (&flt); @@ -620,11 +619,10 @@ chk_smd5 (const char *db_pass, const char *pass) mu_stream_t str = NULL, flt = NULL; size_t size; - mu_memory_stream_create (&str, 0); + size = strlen (db_pass); + mu_static_memory_stream_create (&str, db_pass, size); mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_AUTOCLOSE); - size = strlen (db_pass); - mu_stream_write (str, db_pass, size, NULL); d1 = malloc (size); if (!d1) @@ -665,10 +663,9 @@ chk_sha (const char *db_pass, const char *pass) mu_sha1_process_bytes (pass, strlen (pass), &sha1context); mu_sha1_finish_ctx (&sha1context, sha1digest); - mu_memory_stream_create (&str, 0); + mu_static_memory_stream_create (&str, db_pass, strlen (db_pass)); mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_AUTOCLOSE); - mu_stream_write (str, db_pass, strlen (db_pass), NULL); mu_stream_read (flt, (char*) d1, sizeof d1, NULL); mu_stream_destroy (&flt); @@ -687,11 +684,10 @@ chk_ssha (const char *db_pass, const char *pass) mu_stream_t str = NULL, flt = NULL; size_t size; - mu_memory_stream_create (&str, 0); + size = strlen (db_pass); + mu_static_memory_stream_create (&str, db_pass, size); mu_filter_create (&flt, str, "base64", MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_AUTOCLOSE); - size = strlen (db_pass); - mu_stream_write (str, db_pass, size, NULL); d1 = malloc (size); if (!d1) |