[gmime] Added new constructor functions GMimeStreamFs and GMimeStreamFile that take a path
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Added new constructor functions GMimeStreamFs and GMimeStreamFile that take a path
- Date: Mon, 12 Aug 2013 13:45:33 +0000 (UTC)
commit 07959e164042488c24e1615623cce0f7993b7ae5
Author: Jeffrey Stedfast <fejj gnome org>
Date: Mon Aug 12 09:44:05 2013 -0400
Added new constructor functions GMimeStreamFs and GMimeStreamFile that take a path
2013-08-12 Jeffrey Stedfast <fejj gnome org>
* gmime/gmime-stream-file.c (g_mime_stream_file_new_for_path): New
convenience function that handles opening the file for you.
* gmime/gmime-stream-fs.c (g_mime_stream_fs_new_for_path): New
convenience function that handles opening the file for you.
ChangeLog | 8 ++++++++
TODO | 9 +++++++++
docs/reference/gmime-sections.txt | 2 ++
gmime/gmime-stream-file.c | 31 +++++++++++++++++++++++++++++++
gmime/gmime-stream-file.h | 2 ++
gmime/gmime-stream-fs.c | 27 +++++++++++++++++++++++++++
gmime/gmime-stream-fs.h | 2 ++
mono/gmime-api.raw | 17 +++++++++++++++--
8 files changed, 96 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7e561b1..8c60b00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-12 Jeffrey Stedfast <fejj gnome org>
+
+ * gmime/gmime-stream-file.c (g_mime_stream_file_new_for_path): New
+ convenience function that handles opening the file for you.
+
+ * gmime/gmime-stream-fs.c (g_mime_stream_fs_new_for_path): New
+ convenience function that handles opening the file for you.
+
2013-08-11 Jeffrey Stedfast <fejj gnome org>
* gmime/gmime-message.c (g_mime_message_set_reply_to): Fixed this
diff --git a/TODO b/TODO
index 612fac1..472f14c 100644
--- a/TODO
+++ b/TODO
@@ -13,6 +13,15 @@ GMime 2.8 / 3.0 Planning:
InternetAddressList to be more consistent with the recipient
functions as well as being less error-prone.
+- Modify GMimeStream APIs to take GCancellable and GError arguments.
+
+- Modify g_mime_parser_construct_message() and
+ g_mime_parser_construct_part() methods take GCancellable and GError
+ arguments.
+
+- Should GMimeStreamGIO be modified to take only a GInputStream or a
+ GOutputStream and do away with the GFile API?
+
GMime 2.6 Planning:
===================
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 6606cc0..875bce2 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -104,6 +104,7 @@ GMIME_STREAM_CAT_GET_CLASS
GMimeStreamFile
g_mime_stream_file_new
g_mime_stream_file_new_with_bounds
+g_mime_stream_file_new_for_path
g_mime_stream_file_get_owner
g_mime_stream_file_set_owner
@@ -125,6 +126,7 @@ GMIME_STREAM_FILE_GET_CLASS
GMimeStreamFs
g_mime_stream_fs_new
g_mime_stream_fs_new_with_bounds
+g_mime_stream_fs_new_for_path
g_mime_stream_fs_get_owner
g_mime_stream_fs_set_owner
diff --git a/gmime/gmime-stream-file.c b/gmime/gmime-stream-file.c
index dbdd89c..23eff65 100644
--- a/gmime/gmime-stream-file.c
+++ b/gmime/gmime-stream-file.c
@@ -370,6 +370,8 @@ g_mime_stream_file_new (FILE *fp)
GMimeStreamFile *fstream;
gint64 start;
+ g_return_val_if_fail (fp != NULL, NULL);
+
#ifdef G_OS_WIN32
_setmode (_fileno (fp), O_BINARY);
#endif
@@ -405,6 +407,8 @@ g_mime_stream_file_new_with_bounds (FILE *fp, gint64 start, gint64 end)
{
GMimeStreamFile *fstream;
+ g_return_val_if_fail (fp != NULL, NULL);
+
#ifdef G_OS_WIN32
_setmode (_fileno (fp), O_BINARY);
#endif
@@ -419,6 +423,33 @@ g_mime_stream_file_new_with_bounds (FILE *fp, gint64 start, gint64 end)
/**
+ * g_mime_stream_file_new_for_path:
+ * @path: the path to a file
+ * @mode: as in fopen(3)
+ *
+ * Creates a new #GMimeStreamFile object for the specified @path.
+ *
+ * Returns: a stream using for reading and/or writing to the specified
+ * file path or %NULL on error.
+ *
+ * Since: 2.6.18
+ **/
+GMimeStream *
+g_mime_stream_file_new_for_path (const char *path, const char *mode)
+{
+ FILE *fp;
+
+ g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (mode != NULL, NULL);
+
+ if (!(fp = fopen (path, mode)))
+ return NULL;
+
+ return g_mime_stream_file_new (fp);
+}
+
+
+/**
* g_mime_stream_file_get_owner:
* @stream: a #GMimeStreamFile
*
diff --git a/gmime/gmime-stream-file.h b/gmime/gmime-stream-file.h
index 5e23ea8..99a7941 100644
--- a/gmime/gmime-stream-file.h
+++ b/gmime/gmime-stream-file.h
@@ -64,6 +64,8 @@ GType g_mime_stream_file_get_type (void);
GMimeStream *g_mime_stream_file_new (FILE *fp);
GMimeStream *g_mime_stream_file_new_with_bounds (FILE *fp, gint64 start, gint64 end);
+GMimeStream *g_mime_stream_file_new_for_path (const char *path, const char *mode);
+
gboolean g_mime_stream_file_get_owner (GMimeStreamFile *stream);
void g_mime_stream_file_set_owner (GMimeStreamFile *stream, gboolean owner);
diff --git a/gmime/gmime-stream-fs.c b/gmime/gmime-stream-fs.c
index 8288767..61c8ec5 100644
--- a/gmime/gmime-stream-fs.c
+++ b/gmime/gmime-stream-fs.c
@@ -464,6 +464,33 @@ g_mime_stream_fs_new_with_bounds (int fd, gint64 start, gint64 end)
/**
+ * g_mime_stream_fs_new_for_path:
+ * @path: the path to a file
+ * @flags: as in open(2)
+ * @mode: as in open(2)
+ *
+ * Creates a new #GMimeStreamFs object for the specified @path.
+ *
+ * Returns: a stream using for reading and/or writing to the specified
+ * file path or %NULL on error.
+ *
+ * Since: 2.6.18
+ **/
+GMimeStream *
+g_mime_stream_fs_new_for_path (const char *path, int flags, int mode)
+{
+ int fd;
+
+ g_return_val_if_fail (path != NULL, NULL);
+
+ if ((fd = g_open (path, flags, mode)) == -1)
+ return NULL;
+
+ return g_mime_stream_fs_new (fd);
+}
+
+
+/**
* g_mime_stream_fs_get_owner:
* @stream: a #GMimeStreamFs
*
diff --git a/gmime/gmime-stream-fs.h b/gmime/gmime-stream-fs.h
index d5db626..b928065 100644
--- a/gmime/gmime-stream-fs.h
+++ b/gmime/gmime-stream-fs.h
@@ -64,6 +64,8 @@ GType g_mime_stream_fs_get_type (void);
GMimeStream *g_mime_stream_fs_new (int fd);
GMimeStream *g_mime_stream_fs_new_with_bounds (int fd, gint64 start, gint64 end);
+GMimeStream *g_mime_stream_fs_new_for_path (const char *path, int flags, int mode);
+
gboolean g_mime_stream_fs_get_owner (GMimeStreamFs *stream);
void g_mime_stream_fs_set_owner (GMimeStreamFs *stream, gboolean owner);
diff --git a/mono/gmime-api.raw b/mono/gmime-api.raw
index 3d24714..12a5ff5 100644
--- a/mono/gmime-api.raw
+++ b/mono/gmime-api.raw
@@ -2058,6 +2058,12 @@
<parameter type="FILE*" name="fp" />
</parameters>
</constructor>
+ <constructor cname="g_mime_stream_file_new_for_path">
+ <parameters>
+ <parameter type="const-char*" name="path" />
+ <parameter type="const-char*" name="mode" />
+ </parameters>
+ </constructor>
<constructor cname="g_mime_stream_file_new_with_bounds">
<parameters>
<parameter type="FILE*" name="fp" />
@@ -2111,6 +2117,13 @@
<parameter type="int" name="fd" />
</parameters>
</constructor>
+ <constructor cname="g_mime_stream_fs_new_for_path">
+ <parameters>
+ <parameter type="const-char*" name="path" />
+ <parameter type="int" name="flags" />
+ <parameter type="int" name="mode" />
+ </parameters>
+ </constructor>
<constructor cname="g_mime_stream_fs_new_with_bounds">
<parameters>
<parameter type="int" name="fd" />
@@ -3210,8 +3223,8 @@
<method name="HeaderPrintf" cname="g_mime_utils_header_printf" shared="true">
<return-type type="char*" />
<parameters>
- <parameter type="const-char*" name="format" />
- <parameter ellipsis="true" />
+ <parameter type="const-char*" name="format" printf_format="true" />
+ <parameter ellipsis="true" printf_format_args="true" />
</parameters>
</method>
<method name="QuoteString" cname="g_mime_utils_quote_string" shared="true">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]