Skip to content

Commit 2410f76

Browse files
author
Anantha Kesari H Y
committed
NetWare related changes/modifications.
1 parent 911e5ed commit 2410f76

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

win32/sendmail.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* PHP Sendmail for Windows.
3+
* PHP Sendmail for Windows and NetWare.
44
*
55
* This file is rewriten specificly for PHPFI. Some functionality
66
* has been removed (MIME and file attachments). This code was
@@ -23,12 +23,26 @@
2323
#include "php.h" /*php specific */
2424
#include <stdio.h>
2525
#include <stdlib.h>
26+
#ifndef NETWARE
2627
#include <winsock.h>
28+
#else /* NETWARE */
29+
#ifdef USE_WINSOCK
30+
/*#include <ws2nlm.h>*/
31+
#include <novsock2.h>
32+
#else
33+
#include <sys/socket.h> /* For struct sockaddr, 'PF_INET' and 'AF_INET' */
34+
#include <netinet\in.h> /* For struct sockaddr_in */
35+
#include <netdb.h> /* For struct hostent */
36+
/*#include <ws2name.h>*/
37+
#endif /* USE_WINSOCK */
38+
#endif /* NETWARE */
2739
#include "time.h"
2840
#include <string.h>
41+
#ifndef NETWARE
2942
#include <malloc.h>
3043
#include <memory.h>
3144
#include <winbase.h>
45+
#endif /* NETWARE */
3246
#include "sendmail.h"
3347
#include "php_ini.h"
3448

@@ -51,18 +65,34 @@ static char *months[] =
5165
char Buffer[MAIL_BUFFER_SIZE];
5266

5367
/* socket related data */
68+
#ifdef NETWARE
69+
typedef int SOCKET; /* Borrowed from winsock\novsock2.h */
70+
typedef struct sockaddr_in SOCKADDR_IN;
71+
typedef struct sockaddr * LPSOCKADDR;
72+
typedef struct hostent * LPHOSTENT;
73+
74+
#define INVALID_SOCKET (SOCKET)(~0) /* Borrowed from winsock\novsock2.h */
75+
#endif /* NETWARE */
5476
SOCKET sc;
77+
#ifndef NETWARE
5578
WSADATA Data;
5679
struct hostent *adr;
80+
#endif /* NETWARE */
5781
SOCKADDR_IN sock_in;
82+
#ifndef NETWARE
5883
int WinsockStarted;
5984
/* values set by the constructor */
6085
char *AppName;
86+
#endif /* NETWARE */
6187
char MailHost[HOST_NAME_LEN];
6288
char LocalHost[HOST_NAME_LEN];
6389
#endif
6490
char seps[] = " ,\t\n";
91+
#ifndef NETWARE
6592
char *php_mailer = "PHP 4.0 WIN32";
93+
#else
94+
char *php_mailer = "PHP 4.0 NetWare";
95+
#endif /* NETWARE */
6696

6797
char *get_header(char *h, char *headers);
6898

@@ -89,6 +119,7 @@ static char *ErrorMessages[] =
89119
{"Bad Mail Host"},
90120
{"Bad Message File"},
91121
{"\"sendmail_from\" NOT set in php.ini"},
122+
92123
{"Mailserver rejected our \"sendmail_from\" setting"} /* 20 */
93124
};
94125

@@ -113,7 +144,9 @@ int TSendMail(char *host, int *error,
113144
int ret;
114145
char *RPath = NULL;
115146

147+
#ifndef NETWARE
116148
WinsockStarted = FALSE;
149+
#endif
117150

118151
if (host == NULL) {
119152
*error = BAD_MAIL_HOST;
@@ -128,7 +161,9 @@ int TSendMail(char *host, int *error,
128161
if (INI_STR("sendmail_from")){
129162
RPath = estrdup(INI_STR("sendmail_from"));
130163
} else {
164+
131165
*error = W32_SM_SENDMAIL_FROM_NOT_SET;
166+
132167
return FAILURE;
133168
}
134169

@@ -166,7 +201,14 @@ void TSMClose()
166201
*/
167202

168203
shutdown(sc, 0);
204+
#ifndef NETWARE
169205
closesocket(sc);
206+
#else
207+
/* closesocket commented out since it was giving undefined symbol linker error
208+
close added in its place
209+
*/
210+
close(sc);
211+
#endif /* NETWARE */
170212
}
171213

172214

@@ -181,10 +223,13 @@ void TSMClose()
181223
char *GetSMErrorText(int index)
182224
{
183225

226+
184227
if (MIN_ERROR_INDEX <= index && index < MAX_ERROR_INDEX) {
185228
return (ErrorMessages[index]);
229+
186230
} else {
187231
return (ErrorMessages[UNKNOWN_ERROR]);
232+
188233
}
189234
}
190235

@@ -259,9 +304,12 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
259304
efree(tempMailTo);
260305
if (headers && (pos1 = strstr(headers, "Cc:"))) {
261306
if (NULL == (pos2 = strstr(pos1, "\r\n"))) {
307+
262308
tempMailTo = estrndup(pos1, strlen(pos1));
309+
263310
} else {
264311
tempMailTo = estrndup(pos1, pos2-pos1);
312+
265313
}
266314

267315
token = strtok(tempMailTo, ",");
@@ -454,7 +502,11 @@ int MailConnect()
454502
// Author/Date: jcar 20/9/96
455503
// History:
456504
//********************************************************************/
505+
#ifndef NETWARE
457506
int Post(LPCSTR msg)
507+
#else
508+
int Post(char * msg)
509+
#endif /* NETWARE */
458510
{
459511
int len = strlen(msg);
460512
int slen;
@@ -529,7 +581,11 @@ int Ack()
529581
// Author/Date: jcar 20/9/96
530582
// History:
531583
//********************************************************************/
584+
#ifndef NETWARE
532585
unsigned long GetAddr(LPSTR szHost)
586+
#else
587+
unsigned long GetAddr(char * szHost)
588+
#endif /* NETWARE */
533589
{
534590
LPHOSTENT lpstHost;
535591
u_long lAddr = INADDR_ANY;
@@ -545,7 +601,11 @@ unsigned long GetAddr(LPSTR szHost)
545601

546602
lpstHost = gethostbyname(szHost);
547603
if (lpstHost) { /* success */
604+
#ifndef NETWARE
548605
lAddr = *((u_long FAR *) (lpstHost->h_addr));
606+
#else
607+
lAddr = *((u_long *) (lpstHost->h_addr));
608+
#endif /* NETWARE */
549609
} else {
550610
lAddr = INADDR_ANY; /* failure */
551611
}

win32/sendmail.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#if !defined(sendmail_h) /* Sentry, use file only if it's not already included. */
22
#define sendmail_h
3+
#ifndef NETWARE
34
#include <windows.h>
5+
#endif
46

57
#define HOST_NAME_LEN 256
68
#define MAX_APPNAME_LENGHT 100
@@ -39,9 +41,17 @@ char *GetSMErrorText(int index);
3941

4042
int MailConnect();
4143
int PostHeader(char *, char *, char *, char *, char *);
44+
#ifndef NETWARE
4245
int Post(LPCSTR);
46+
#else
47+
int Post(char *);
48+
#endif
4349
int Ack();
50+
#ifndef NETWARE
4451
unsigned long GetAddr(LPSTR szHost);
52+
#else
53+
unsigned long GetAddr(char * szHost);
54+
#endif
4555

4656

4757

0 commit comments

Comments
 (0)