1
1
2
2
/*
3
- * PHP Sendmail for Windows.
3
+ * PHP Sendmail for Windows and NetWare .
4
4
*
5
5
* This file is rewriten specificly for PHPFI. Some functionality
6
6
* has been removed (MIME and file attachments). This code was
23
23
#include "php.h" /*php specific */
24
24
#include <stdio.h>
25
25
#include <stdlib.h>
26
+ #ifndef NETWARE
26
27
#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 */
27
39
#include "time.h"
28
40
#include <string.h>
41
+ #ifndef NETWARE
29
42
#include <malloc.h>
30
43
#include <memory.h>
31
44
#include <winbase.h>
45
+ #endif /* NETWARE */
32
46
#include "sendmail.h"
33
47
#include "php_ini.h"
34
48
@@ -51,18 +65,34 @@ static char *months[] =
51
65
char Buffer [MAIL_BUFFER_SIZE ];
52
66
53
67
/* 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 */
54
76
SOCKET sc ;
77
+ #ifndef NETWARE
55
78
WSADATA Data ;
56
79
struct hostent * adr ;
80
+ #endif /* NETWARE */
57
81
SOCKADDR_IN sock_in ;
82
+ #ifndef NETWARE
58
83
int WinsockStarted ;
59
84
/* values set by the constructor */
60
85
char * AppName ;
86
+ #endif /* NETWARE */
61
87
char MailHost [HOST_NAME_LEN ];
62
88
char LocalHost [HOST_NAME_LEN ];
63
89
#endif
64
90
char seps [] = " ,\t\n" ;
91
+ #ifndef NETWARE
65
92
char * php_mailer = "PHP 4.0 WIN32" ;
93
+ #else
94
+ char * php_mailer = "PHP 4.0 NetWare" ;
95
+ #endif /* NETWARE */
66
96
67
97
char * get_header (char * h , char * headers );
68
98
@@ -89,6 +119,7 @@ static char *ErrorMessages[] =
89
119
{"Bad Mail Host" },
90
120
{"Bad Message File" },
91
121
{"\"sendmail_from\" NOT set in php.ini" },
122
+
92
123
{"Mailserver rejected our \"sendmail_from\" setting" } /* 20 */
93
124
};
94
125
@@ -113,7 +144,9 @@ int TSendMail(char *host, int *error,
113
144
int ret ;
114
145
char * RPath = NULL ;
115
146
147
+ #ifndef NETWARE
116
148
WinsockStarted = FALSE;
149
+ #endif
117
150
118
151
if (host == NULL ) {
119
152
* error = BAD_MAIL_HOST ;
@@ -128,7 +161,9 @@ int TSendMail(char *host, int *error,
128
161
if (INI_STR ("sendmail_from" )){
129
162
RPath = estrdup (INI_STR ("sendmail_from" ));
130
163
} else {
164
+
131
165
* error = W32_SM_SENDMAIL_FROM_NOT_SET ;
166
+
132
167
return FAILURE ;
133
168
}
134
169
@@ -166,7 +201,14 @@ void TSMClose()
166
201
*/
167
202
168
203
shutdown (sc , 0 );
204
+ #ifndef NETWARE
169
205
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 */
170
212
}
171
213
172
214
@@ -181,10 +223,13 @@ void TSMClose()
181
223
char * GetSMErrorText (int index )
182
224
{
183
225
226
+
184
227
if (MIN_ERROR_INDEX <= index && index < MAX_ERROR_INDEX ) {
185
228
return (ErrorMessages [index ]);
229
+
186
230
} else {
187
231
return (ErrorMessages [UNKNOWN_ERROR ]);
232
+
188
233
}
189
234
}
190
235
@@ -259,9 +304,12 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
259
304
efree (tempMailTo );
260
305
if (headers && (pos1 = strstr (headers , "Cc:" ))) {
261
306
if (NULL == (pos2 = strstr (pos1 , "\r\n" ))) {
307
+
262
308
tempMailTo = estrndup (pos1 , strlen (pos1 ));
309
+
263
310
} else {
264
311
tempMailTo = estrndup (pos1 , pos2 - pos1 );
312
+
265
313
}
266
314
267
315
token = strtok (tempMailTo , "," );
@@ -454,7 +502,11 @@ int MailConnect()
454
502
// Author/Date: jcar 20/9/96
455
503
// History:
456
504
//********************************************************************/
505
+ #ifndef NETWARE
457
506
int Post (LPCSTR msg )
507
+ #else
508
+ int Post (char * msg )
509
+ #endif /* NETWARE */
458
510
{
459
511
int len = strlen (msg );
460
512
int slen ;
@@ -529,7 +581,11 @@ int Ack()
529
581
// Author/Date: jcar 20/9/96
530
582
// History:
531
583
//********************************************************************/
584
+ #ifndef NETWARE
532
585
unsigned long GetAddr (LPSTR szHost )
586
+ #else
587
+ unsigned long GetAddr (char * szHost )
588
+ #endif /* NETWARE */
533
589
{
534
590
LPHOSTENT lpstHost ;
535
591
u_long lAddr = INADDR_ANY ;
@@ -545,7 +601,11 @@ unsigned long GetAddr(LPSTR szHost)
545
601
546
602
lpstHost = gethostbyname (szHost );
547
603
if (lpstHost ) { /* success */
604
+ #ifndef NETWARE
548
605
lAddr = * ((u_long FAR * ) (lpstHost -> h_addr ));
606
+ #else
607
+ lAddr = * ((u_long * ) (lpstHost -> h_addr ));
608
+ #endif /* NETWARE */
549
609
} else {
550
610
lAddr = INADDR_ANY ; /* failure */
551
611
}
0 commit comments