gmime r1554 - in trunk: . build/vs2008 examples gmime
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1554 - in trunk: . build/vs2008 examples gmime
- Date: Sat, 4 Apr 2009 16:29:22 +0000 (UTC)
Author: fejj
Date: Sat Apr 4 16:29:22 2009
New Revision: 1554
URL: http://svn.gnome.org/viewvc/gmime?rev=1554&view=rev
Log:
2009-04-04 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-stream-fs.c: Ported to Windows by #including io.h
* examples/basic-example.c: Reverted to the old GMimeStreamFs logic
and #included io.h for G_OS_WIN32 systems.
* examples/imap-example.c: Ported to Windows by #including io.h and
using g_ascii_strcasecmp().
Modified:
trunk/ChangeLog
trunk/build/vs2008/gmime.vcproj
trunk/examples/basic-example.c
trunk/examples/imap-example.c
trunk/gmime/gmime-stream-fs.c
trunk/gmime/gmime-utils.c
Modified: trunk/build/vs2008/gmime.vcproj
==============================================================================
--- trunk/build/vs2008/gmime.vcproj (original)
+++ trunk/build/vs2008/gmime.vcproj Sat Apr 4 16:29:22 2009
@@ -339,6 +339,10 @@
>
</File>
<File
+ RelativePath="..\..\gmime\gmime-stream-fs.h"
+ >
+ </File>
+ <File
RelativePath="..\..\gmime\gmime-stream-mem.h"
>
</File>
@@ -559,6 +563,10 @@
>
</File>
<File
+ RelativePath="..\..\gmime\gmime-stream-fs.c"
+ >
+ </File>
+ <File
RelativePath="..\..\gmime\gmime-stream-mem.c"
>
</File>
Modified: trunk/examples/basic-example.c
==============================================================================
--- trunk/examples/basic-example.c (original)
+++ trunk/examples/basic-example.c Sat Apr 4 16:29:22 2009
@@ -22,18 +22,23 @@
#include <config.h>
#endif
+#include <glib.h>
+#include <gmime/gmime.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <errno.h>
-
-#include <glib.h>
-#include <gmime/gmime.h>
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
#ifndef G_OS_WIN32
-static char *path = "/usr/bin/gpg";
-/*static char *userid = "pgp-mime xtorshun org";*/
-static char *passphrase = "PGP/MIME is rfc2015, now go and read it.";
+static const char *path = "/usr/bin/gpg";
+static const char *passphrase = "no.secret";
typedef struct _ExampleSession ExampleSession;
typedef struct _ExampleSessionClass ExampleSessionClass;
@@ -96,26 +101,19 @@
static char *
request_passwd (GMimeSession *session, const char *prompt, gboolean secret, const char *item, GError **err)
{
-#if 0
- char buffer[256];
-
- fprintf (stdout, "%s\nPassphrase: %s\n", prompt, passphrase);
- fgets (buffer, 255, stdin);
- buffer[strlen (buffer) - 1] = '\0'; /* chop off \n */
-#endif
- return g_strdup (/*buffer*/passphrase);
+ return g_strdup (passphrase);
}
#endif /* ! G_OS_WIN32 */
static GMimeMessage *
-parse_message (FILE *fp)
+parse_message (int fd)
{
GMimeMessage *message;
GMimeParser *parser;
GMimeStream *stream;
/* create a stream to read from the file descriptor */
- stream = g_mime_stream_file_new (fp);
+ stream = g_mime_stream_fs_new (fd);
/* create a new parser object to parse the stream */
parser = g_mime_parser_new_with_stream (stream);
@@ -343,13 +341,13 @@
GMimeCipherContext *ctx;
#endif
GMimeMessage *message;
- FILE *fp;
+ int fd;
if (argc < 2) {
printf ("Usage: a.out <message file>\n");
return 0;
} else {
- if ((fp = fopen (argv[1], "rt")) == NULL) {
+ if ((fd = open (argv[1], O_RDONLY)) == -1) {
fprintf (stderr, "Cannot open message `%s': %s\n", argv[1], g_strerror (errno));
return 0;
}
@@ -359,7 +357,7 @@
g_mime_init (0);
/* parse the message */
- message = parse_message (fp);
+ message = parse_message (fd);
/* count the number of parts in the message */
count_parts_in_message (message);
Modified: trunk/examples/imap-example.c
==============================================================================
--- trunk/examples/imap-example.c (original)
+++ trunk/examples/imap-example.c Sat Apr 4 16:29:22 2009
@@ -22,19 +22,22 @@
#include <config.h>
#endif
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <gmime/gmime.h>
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <errno.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-
-#include <gmime/gmime.h>
-
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
static char *
basename (char *path)
@@ -553,7 +556,7 @@
part->envelope = NULL;
part->subparts = NULL;
- if (!strcasecmp (part->content.type, "multipart")) {
+ if (!g_ascii_strcasecmp (part->content.type, "multipart")) {
list = NULL;
tail = (struct _bodystruct *) &list;
@@ -569,7 +572,7 @@
}
part->subparts = list;
- } else if (!strcasecmp (part->content.type, "message") && !strcasecmp (part->content.subtype, "rfc822")) {
+ } else if (!g_ascii_strcasecmp (part->content.type, "message") && !g_ascii_strcasecmp (part->content.subtype, "rfc822")) {
part->envelope = decode_envelope (&inptr, inend);
part->subparts = bodystruct_part_decode (&inptr, inend);
} else {
@@ -617,13 +620,13 @@
fputc ('\n', stderr);
- if (!strcasecmp (part->content.type, "multipart")) {
+ if (!g_ascii_strcasecmp (part->content.type, "multipart")) {
part = part->subparts;
while (part != NULL) {
bodystruct_dump (part, depth + 1);
part = part->next;
}
- } else if (!strcasecmp (part->content.type, "message") && !strcasecmp (part->content.subtype, "rfc822")) {
+ } else if (!g_ascii_strcasecmp (part->content.type, "message") && !g_ascii_strcasecmp (part->content.subtype, "rfc822")) {
depth++;
for (i = 0; i < depth; i++)
Modified: trunk/gmime/gmime-stream-fs.c
==============================================================================
--- trunk/gmime/gmime-stream-fs.c (original)
+++ trunk/gmime/gmime-stream-fs.c Sat Apr 4 16:29:22 2009
@@ -23,18 +23,28 @@
#include <config.h>
#endif
+#include <glib.h>
+
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <errno.h>
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
#include "gmime-stream-fs.h"
-
#ifndef HAVE_FSYNC
+#ifdef G_OS_WIN32
+static int fsync (int fd) { return _commit (fd); }
+#else
static int fsync (int fd) { return 0; }
#endif
+#endif
/**
Modified: trunk/gmime/gmime-utils.c
==============================================================================
--- trunk/gmime/gmime-utils.c (original)
+++ trunk/gmime/gmime-utils.c Sat Apr 4 16:29:22 2009
@@ -25,6 +25,8 @@
#define _GNU_SOURCE
+#include <glib.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,6 +46,7 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <process.h>
+#define getpid() _getpid()
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]