summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-05-19 15:02:13 +0000
committerJeffrey Stedfast <fejj@src.gnome.org>2003-05-19 15:02:13 +0000
commit1cd43a65b1410cbd0fad14f704a6316b5b4b25c6 (patch)
treeb6d59cf29952ca21d38aae51daaeec552ef9b3fb
parent2024449cf3e03e9f40e1ad8afa20ba8b4e84ac54 (diff)
downloadgmime-1cd43a65b1410cbd0fad14f704a6316b5b4b25c6.tar.gz
Updated some.
2003-05-19 Jeffrey Stedfast <fejj@ximian.com> * docs/reference/*: Updated some. * gmime/gmime-multipart-signed.c: Same as below. * gmime/gmime-multipart-encrypted.c: Fixed the prototypes for write_to_stream(). * gmime/gmime-gpg-context.c (gpg_ctx_new): Initialise seen_eof1 to TRUE. (gpg_ctx_set_ostream): Set seen_eof1 to FALSE here, this way we only ever check for EOF for gpg's stdout if we care about the data received from it. (gpg_ctx_parse_status): Remove the hack that set seen_eof1 to TRUE when we received a TRUST status from gpg when verifying a signature. Same for when importing signatures. (gpg_ctx_op_step): Only FD_SET() fd's that we have not finished reading from. (gpg_ctx_op_exited): #if 0'd for now since we aren't using it anymore. Keeping it around for historical reasons and in case we find we really do need it back.
-rw-r--r--ChangeLog23
-rw-r--r--docs/reference/data-wrappers.sgml14
-rw-r--r--docs/reference/gmime-docs.sgml2
-rw-r--r--docs/reference/streams.sgml46
-rw-r--r--gmime/gmime-gpg-context.c38
-rw-r--r--gmime/gmime-multipart-encrypted.c2
-rw-r--r--gmime/gmime-multipart-signed.c2
7 files changed, 81 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index c88c13b5..8ab7b692 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2003-05-19 Jeffrey Stedfast <fejj@ximian.com>
+
+ * docs/reference/*: Updated some.
+
+ * gmime/gmime-multipart-signed.c: Same as below.
+
+ * gmime/gmime-multipart-encrypted.c: Fixed the prototypes for
+ write_to_stream().
+
+ * gmime/gmime-gpg-context.c (gpg_ctx_new): Initialise seen_eof1 to
+ TRUE.
+ (gpg_ctx_set_ostream): Set seen_eof1 to FALSE here, this way we
+ only ever check for EOF for gpg's stdout if we care about the data
+ received from it.
+ (gpg_ctx_parse_status): Remove the hack that set seen_eof1 to TRUE
+ when we received a TRUST status from gpg when verifying a
+ signature. Same for when importing signatures.
+ (gpg_ctx_op_step): Only FD_SET() fd's that we have not finished
+ reading from.
+ (gpg_ctx_op_exited): #if 0'd for now since we aren't using it
+ anymore. Keeping it around for historical reasons and in case we
+ find we really do need it back.
+
2003-04-15 Jeffrey Stedfast <fejj@ximian.com>
* README: Bumped version to 2.0.6
diff --git a/docs/reference/data-wrappers.sgml b/docs/reference/data-wrappers.sgml
index e3959888..103c65e3 100644
--- a/docs/reference/data-wrappers.sgml
+++ b/docs/reference/data-wrappers.sgml
@@ -10,11 +10,13 @@
</refnamediv>
<refsect1 id="data-wrapper-overview">
<title>Overview of Data Wrappers</title>
- <para>Data wrappers are a very simple concept. They wrap
- data. Actually, they wrap around a source stream and contain
- information about the format of the source stream. This makes
- writing a data wrapper to a stream incredibly easy because it will
- decode the data into its raw form before writing it to the output
- stream for you.</para>
+
+ <para>Data wrappers are very simple. A GMimeDataWrapper object
+ contains both a stream and an encoding-type. The encoding-type
+ (such as GMIME_PART_ENCODING_BASE64) is used by
+ g_mime_data_wrapper_write_to_stream() in order to decode the data
+ into its unencoded form. This means that you, the application
+ programmer, do not need to worry about decoding the content stream
+ yourself.</para>
</refsect1>
</refentry>
diff --git a/docs/reference/gmime-docs.sgml b/docs/reference/gmime-docs.sgml
index 8fe8a0ac..18427c74 100644
--- a/docs/reference/gmime-docs.sgml
+++ b/docs/reference/gmime-docs.sgml
@@ -69,7 +69,7 @@
<surname>Stedfast</surname>
<affiliation>
<address>
- <email>fejj@helixcode.com</email>
+ <email>fejj@ximian.com</email>
</address>
</affiliation>
</author>
diff --git a/docs/reference/streams.sgml b/docs/reference/streams.sgml
index 1ccd1899..de2926f3 100644
--- a/docs/reference/streams.sgml
+++ b/docs/reference/streams.sgml
@@ -11,7 +11,10 @@
<refsect1 id="stream-overview">
<title>Overview of Streams</title>
<para>Streams are the fundamental method for reading and writing
- data used by GMime.</para>
+ data used by GMime. You'll probably notice that the basic API is
+ similar to that of the low-level Unix I/O layer (read(), write(),
+ lseek(), etc) with some additional nicities such as a printf-like
+ function.</para>
<para>The three (3) basic stream types are: GMimeStreamFile,
GMimeStreamFs and GMimeStreamMem. You can manipulate all three
@@ -22,13 +25,11 @@
<para>GMimeStreamFile and GMimeStreamFs are very similar in that
they are both meant for reading and writing data to the file
system (in the form of files). Since GMimeStreamFile is an
- abstracted layer above the libc FILE type, one of the added
- benefits is buffered I/O. GMimeStreamFs, on the other hand, is an
- abstracted layer above UNIX file descriptors. While a
- GMimeStreamFs can be used on top of a UNIX socket, you must be
- careful because sockets are not seekable. It is suggested that you
- use a GMimeStreamBuffer in cache mode if you intend to be able to
- seek, we will get to this advanced stream type later.</para>
+ abstracted layer above the standard libc FILE type, one of the
+ added benefits is buffered I/O. GMimeStreamFs, on the other hand,
+ is an abstracted layer above Unix file descriptors. While a
+ GMimeStreamFs can be used on top of a UNIX socket or pipe, you
+ must be careful because sockets and pipes are not seekable.</para>
<para>Unlike the previous 2 stream types, GMimeStreamMem does not
interact with the file system at all (except maybe the swap
@@ -37,33 +38,36 @@
want to create a temporary file on disk.</para>
<para>The four (4) advanced stream types are GMimeStreamMmap,
- GMimeStreamNull, GMimeStreamBuffer (as was mentioned previously)
- and GMimeStreamFilter.</para>
+ GMimeStreamNull, GMimeStreamBuffer and GMimeStreamFilter.</para>
<para>Our most simple stream, GMimeStreamNull, is the stream
equivalent of /dev/null on Unix systems. The main difference is
- that GMimeStreamNull records the number of bytes written to
- it.</para>
+ that GMimeStreamNull records the number of bytes written to it -
+ you may find this useful if you need to know the number of bytes a
+ GMimeObject (for example) will require.</para>
<para>GMimeStreamMmap is a memory-mapped stream. This isn't
guarenteed to work on all systems since not all systems support
the POSIX mmap system call, but for those that do - this might
present a faster stream than GMimeStreamFs and/or
- GMimeStreamFile.</para>
+ GMimeStreamFile. You'll have to do some experimentation to know
+ for sure.</para>
- <para>The GMimeStreamBuffer type inherits from any other type of
- stream and has 3 modes: block reads, block writes, and cached
+ <para>The GMimeStreamBuffer can be used on top of any other type
+ of stream and has 3 modes: block reads, block writes, and cached
reads. Block reads are especially useful if you will be making a
lot of small reads from a stream that accesses the file
system. Block writes are useful for very much the same reason. The
final mode, cached reads, can become memory intensive but can be
very helpful when inheriting from a stream that does not support
- seeking.</para>
+ seeking (Note: this mode is the least tested so be careful using
+ it).</para>
- <para>Our final stream type, GMimeStreamFilter, also inherits from
- another stream. This stream, as you may have guessed, filters
- reads and writes to its inherited stream. For example, one could
- write a compression filter and apply it to a GMimeStreamFilter and
- any further reads or writes would be compressed.</para>
+ <para>Our final stream type, GMimeStreamFilter, can also be used
+ on top of another stream. This stream, as you may have guessed,
+ filters reads and writes to its inherited stream. For example, one
+ could write a compression filter and apply it to a
+ GMimeStreamFilter and any further reads or writes would be
+ (un)compressed.</para>
</refsect1>
</refentry>
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index 429e674f..2de90eab 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -283,7 +283,7 @@ gpg_ctx_new (GMimeSession *session, const char *path)
g_object_ref (session);
gpg->userid_hint = g_hash_table_new (g_str_hash, g_str_equal);
gpg->complete = FALSE;
- gpg->seen_eof1 = FALSE;
+ gpg->seen_eof1 = TRUE;
gpg->seen_eof2 = FALSE;
gpg->pid = (pid_t) -1;
gpg->exit_status = 0;
@@ -407,6 +407,7 @@ gpg_ctx_set_ostream (struct _GpgCtx *gpg, GMimeStream *ostream)
if (gpg->ostream)
g_mime_stream_unref (gpg->ostream);
gpg->ostream = ostream;
+ gpg->seen_eof1 = FALSE;
}
static const char *
@@ -868,11 +869,6 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, GError **err)
} else if (!strncmp (status, "ULTIMATE", 8)) {
gpg->trust = GPG_TRUST_ULTIMATE;
}
-
- /* Since verifying a signature will never produce output
- on gpg's stdout descriptor, we use this EOF bit for
- making sure that we get a TRUST metric. */
- gpg->seen_eof1 = TRUE;
} else if (!strncmp (status, "VALIDSIG", 8)) {
gpg->validsig = TRUE;
} else if (!strncmp (status, "BADSIG", 6)) {
@@ -901,13 +897,10 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, GError **err)
}
break;
case GPG_CTX_MODE_IMPORT:
- /* hack to work around the fact that gpg
- doesn't write anything to stdout when
- importing keys */
- if (!strncmp (status, "IMPORT_RES", 10))
- gpg->seen_eof1 = TRUE;
+ /* no-op */
break;
case GPG_CTX_MODE_EXPORT:
+ /* no-op */
break;
}
}
@@ -960,12 +953,21 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, GError **err)
retry:
FD_ZERO (&rdset);
- FD_SET (gpg->stdout_fd, &rdset);
- FD_SET (gpg->stderr_fd, &rdset);
- FD_SET (gpg->status_fd, &rdset);
- maxfd = MAX (gpg->stdout_fd, gpg->stderr_fd);
- maxfd = MAX (maxfd, gpg->status_fd);
+ if (!gpg->seen_eof1) {
+ FD_SET (gpg->stdout_fd, &rdset);
+ maxfd = MAX (maxfd, gpg->stdout_fd);
+ }
+
+ if (!gpg->seen_eof2) {
+ FD_SET (gpg->stderr_fd, &rdset);
+ maxfd = MAX (maxfd, gpg->stderr_fd);
+ }
+
+ if (!gpg->complete) {
+ FD_SET (gpg->status_fd, &rdset);
+ maxfd = MAX (maxfd, gpg->status_fd);
+ }
if (gpg->stdin_fd != -1 || gpg->passwd_fd != -1) {
FD_ZERO (&wrset);
@@ -981,6 +983,8 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, GError **err)
wrsetp = &wrset;
}
+ g_assert (maxfd > 0);
+
timeout.tv_sec = 10; /* timeout in seconds */
timeout.tv_usec = 0;
@@ -1174,6 +1178,7 @@ gpg_ctx_op_complete (struct _GpgCtx *gpg)
return gpg->complete && gpg->seen_eof1 && gpg->seen_eof2;
}
+#if 0
static gboolean
gpg_ctx_op_exited (struct _GpgCtx *gpg)
{
@@ -1189,6 +1194,7 @@ gpg_ctx_op_exited (struct _GpgCtx *gpg)
return FALSE;
}
+#endif
static void
gpg_ctx_op_cancel (struct _GpgCtx *gpg)
diff --git a/gmime/gmime-multipart-encrypted.c b/gmime/gmime-multipart-encrypted.c
index ac8379e4..580ffdb9 100644
--- a/gmime/gmime-multipart-encrypted.c
+++ b/gmime/gmime-multipart-encrypted.c
@@ -54,7 +54,7 @@ static const char *multipart_encrypted_get_header (GMimeObject *object, const ch
static void multipart_encrypted_remove_header (GMimeObject *object, const char *header);
static void multipart_encrypted_set_content_type (GMimeObject *object, GMimeContentType *content_type);
static char *multipart_encrypted_get_headers (GMimeObject *object);
-static int multipart_encrypted_write_to_stream (GMimeObject *object, GMimeStream *stream);
+static ssize_t multipart_encrypted_write_to_stream (GMimeObject *object, GMimeStream *stream);
static GMimeMultipartClass *parent_class = NULL;
diff --git a/gmime/gmime-multipart-signed.c b/gmime/gmime-multipart-signed.c
index 35aa7d05..81b57283 100644
--- a/gmime/gmime-multipart-signed.c
+++ b/gmime/gmime-multipart-signed.c
@@ -50,7 +50,7 @@ static const char *multipart_signed_get_header (GMimeObject *object, const char
static void multipart_signed_remove_header (GMimeObject *object, const char *header);
static void multipart_signed_set_content_type (GMimeObject *object, GMimeContentType *content_type);
static char *multipart_signed_get_headers (GMimeObject *object);
-static int multipart_signed_write_to_stream (GMimeObject *object, GMimeStream *stream);
+static ssize_t multipart_signed_write_to_stream (GMimeObject *object, GMimeStream *stream);
static GMimeMultipartClass *parent_class = NULL;