From: Sebastien M. <sma...@us...> - 2005-08-22 10:11:55
|
Update of /cvsroot/libetpan/libetpan/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6031/tests Modified Files: smtpsend.c Log Message: Windows (minimum) port Index: smtpsend.c =================================================================== RCS file: /cvsroot/libetpan/libetpan/tests/smtpsend.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- smtpsend.c 7 Jan 2004 03:30:49 -0000 1.3 +++ smtpsend.c 22 Aug 2005 10:11:42 -0000 1.4 @@ -4,25 +4,31 @@ */ #include <libetpan/libetpan.h> -#include <netdb.h> -#include <netinet/in.h> -#include <sys/socket.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> -#include <sys/mman.h> #include <sys/stat.h> -#include <unistd.h> -#include <sys/ioctl.h> #include <fcntl.h> -#include <pwd.h> +#ifdef _MSC_VER +# include "win_etpan.h" +# include "../src/bsd/getopt.h" +# define STDIN_FILENO _fileno( stdin) +#else +# include <netdb.h> +# include <netinet/in.h> +# include <sys/socket.h> +# include <sys/mman.h> +# include <unistd.h> +# include <sys/ioctl.h> +# include <pwd.h> -#define _GNU_SOURCE -#include <getopt.h> +# define _GNU_SOURCE +# include <getopt.h> +#endif /* globals */ char *smtp_server; -uint smtp_port = 25; +uint16_t smtp_port = 25; char *smtp_user; char *smtp_password; char *smtp_from; @@ -43,6 +49,7 @@ memset(message, 0, sizeof(struct mem_message)); +#ifndef MMAP_UNAVAILABLE /* if stdin is a file whose size is known, try to mmap it */ if (!fstat(0, &sb) && S_ISREG(sb.st_mode) && sb.st_size >= 0) { message->len = sb.st_size; @@ -50,6 +57,7 @@ STDIN_FILENO, 0)) != MAP_FAILED) return 0; } +#endif /* read the buffer from stdin by blocks, until EOF or error. save the message in a mmap_string */ @@ -84,6 +92,7 @@ } char *guessfrom() { +#ifndef _MSC_VER uid_t uid; struct passwd *pw; char hostname[256]; @@ -111,13 +120,18 @@ else snprintf(gfrom, len, "#%u@%s", uid, hostname); return gfrom; +#else + return NULL; +#endif } void release(struct mem_message *message) { if (message->mstring != NULL) mmap_string_free(message->mstring); +#ifndef MMAP_UNAVAILABLE else if (message->data != NULL) munmap(message->data, message->len); +#endif } int send_message(char *data, size_t len, char**rcpts) { @@ -228,7 +242,7 @@ smtp_server = strdup(optarg); break; case 'p': - smtp_port = strtoul(optarg, NULL, 10); + smtp_port = (uint16_t) strtoul(optarg, NULL, 10); break; case 'u': if (smtp_user != NULL) |