hyanantha Thu Oct 24 08:08:54 2002 EDT Modified files: (Branch: PHP_4_2_0) /php4/win32 sendmail.c sendmail.h Log: NetWare related changes/modifications. Index: php4/win32/sendmail.c diff -u php4/win32/sendmail.c:1.24.2.1 php4/win32/sendmail.c:1.24.2.2 --- php4/win32/sendmail.c:1.24.2.1 Tue May 14 10:17:04 2002 +++ php4/win32/sendmail.c Thu Oct 24 08:08:54 2002 @@ -1,6 +1,6 @@ /* - * PHP Sendmail for Windows. + * PHP Sendmail for Windows and NetWare. * * This file is rewriten specificly for PHPFI. Some functionality * has been removed (MIME and file attachments). This code was @@ -18,17 +18,31 @@ * */ -/* $Id: sendmail.c,v 1.24.2.1 2002/05/14 14:17:04 mfischer Exp $ */ +/* $Id: sendmail.c,v 1.24.2.2 2002/10/24 12:08:54 hyanantha Exp $ */ #include "php.h" /*php specific */ #include <stdio.h> #include <stdlib.h> +#ifndef NETWARE #include <winsock.h> +#else /* NETWARE */ +#ifdef USE_WINSOCK +/*#include <ws2nlm.h>*/ +#include <novsock2.h> +#else +#include <sys/socket.h> /* For struct sockaddr, 'PF_INET' and 'AF_INET' */ +#include <netinet\in.h> /* For struct sockaddr_in */ +#include <netdb.h> /* For struct hostent */ +/*#include <ws2name.h>*/ +#endif /* USE_WINSOCK */ +#endif /* NETWARE */ #include "time.h" #include <string.h> +#ifndef NETWARE #include <malloc.h> #include <memory.h> #include <winbase.h> +#endif /* NETWARE */ #include "sendmail.h" #include "php_ini.h" @@ -51,18 +65,34 @@ char Buffer[MAIL_BUFFER_SIZE]; /* socket related data */ +#ifdef NETWARE +typedef int SOCKET; /* Borrowed from winsock\novsock2.h */ +typedef struct sockaddr_in SOCKADDR_IN; +typedef struct sockaddr * LPSOCKADDR; +typedef struct hostent * LPHOSTENT; + +#define INVALID_SOCKET (SOCKET)(~0) /* Borrowed from winsock\novsock2.h */ +#endif /* NETWARE */ SOCKET sc; +#ifndef NETWARE WSADATA Data; struct hostent *adr; +#endif /* NETWARE */ SOCKADDR_IN sock_in; +#ifndef NETWARE int WinsockStarted; /* values set by the constructor */ char *AppName; +#endif /* NETWARE */ char MailHost[HOST_NAME_LEN]; char LocalHost[HOST_NAME_LEN]; #endif char seps[] = " ,\t\n"; +#ifndef NETWARE char *php_mailer = "PHP 4.0 WIN32"; +#else +char *php_mailer = "PHP 4.0 NetWare"; +#endif /* NETWARE */ char *get_header(char *h, char *headers); @@ -88,7 +118,8 @@ {"Bad Message Return Path"}, {"Bad Mail Host"}, {"Bad Message File"}, - {"\"sendmail_from\" NOT set in php.ini"}, + {"\"sendmail_from\" NOT set in php.ini"}, + {"Mailserver rejected our \"sendmail_from\" setting"} /* 20 */ }; @@ -113,7 +144,9 @@ int ret; char *RPath = NULL; +#ifndef NETWARE WinsockStarted = FALSE; +#endif if (host == NULL) { *error = BAD_MAIL_HOST; @@ -127,8 +160,10 @@ if (INI_STR("sendmail_from")){ RPath = estrdup(INI_STR("sendmail_from")); - } else { - *error = W32_SM_SENDMAIL_FROM_NOT_SET; + } else { + + *error = W32_SM_SENDMAIL_FROM_NOT_SET; + return FAILURE; } @@ -166,7 +201,14 @@ */ shutdown(sc, 0); +#ifndef NETWARE closesocket(sc); +#else + /* closesocket commented out since it was giving undefined symbol linker +error + close added in its place + */ + close(sc); +#endif /* NETWARE */ } @@ -180,11 +222,14 @@ //*******************************************************************/ char *GetSMErrorText(int index) { - + + if (MIN_ERROR_INDEX <= index && index < MAX_ERROR_INDEX) { - return (ErrorMessages[index]); + return (ErrorMessages[index]); + } else { - return (ErrorMessages[UNKNOWN_ERROR]); + return (ErrorMessages[UNKNOWN_ERROR]); + } } @@ -258,10 +303,13 @@ /* Send mail to all Cc rcpt's */ efree(tempMailTo); if (headers && (pos1 = strstr(headers, "Cc:"))) { - if (NULL == (pos2 = strstr(pos1, "\r\n"))) { - tempMailTo = estrndup(pos1, strlen(pos1)); + if (NULL == (pos2 = strstr(pos1, "\r\n"))) { + + tempMailTo = estrndup(pos1, strlen(pos1)); + } else { - tempMailTo = estrndup(pos1, pos2-pos1); + tempMailTo = estrndup(pos1, pos2-pos1); + } token = strtok(tempMailTo, ","); @@ -454,7 +502,11 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ +#ifndef NETWARE int Post(LPCSTR msg) +#else +int Post(char * msg) +#endif /* NETWARE */ { int len = strlen(msg); int slen; @@ -529,7 +581,11 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ +#ifndef NETWARE unsigned long GetAddr(LPSTR szHost) +#else +unsigned long GetAddr(char * szHost) +#endif /* NETWARE */ { LPHOSTENT lpstHost; u_long lAddr = INADDR_ANY; @@ -545,7 +601,11 @@ lpstHost = gethostbyname(szHost); if (lpstHost) { /* success */ +#ifndef NETWARE lAddr = *((u_long FAR *) (lpstHost->h_addr)); +#else + lAddr = *((u_long *) (lpstHost->h_addr)); +#endif /* NETWARE */ } else { lAddr = INADDR_ANY; /* failure */ } Index: php4/win32/sendmail.h diff -u php4/win32/sendmail.h:1.3.2.1 php4/win32/sendmail.h:1.3.2.2 --- php4/win32/sendmail.h:1.3.2.1 Tue May 14 10:17:04 2002 +++ php4/win32/sendmail.h Thu Oct 24 08:08:54 2002 @@ -1,6 +1,8 @@ #if !defined(sendmail_h) /* Sentry, use file only if it's not already included. */ #define sendmail_h +#ifndef NETWARE #include <windows.h> +#endif #define HOST_NAME_LEN 256 #define MAX_APPNAME_LENGHT 100 @@ -39,9 +41,17 @@ int MailConnect(); int PostHeader(char *, char *, char *, char *, char *); +#ifndef NETWARE int Post(LPCSTR); +#else +int Post(char *); +#endif int Ack(); +#ifndef NETWARE unsigned long GetAddr(LPSTR szHost); +#else +unsigned long GetAddr(char * szHost); +#endif
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php