Skip to content

Commit 911e5ed

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

File tree

4 files changed

+123
-7
lines changed

4 files changed

+123
-7
lines changed

sapi/apache/php_apache.c

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
#include <stddef.h>
2727
#endif
2828

29+
#ifdef NETWARE
30+
#ifdef NEW_LIBC /* Works fine for both Winsock and Berkeley sockets */
31+
#include <netinet/in.h>
32+
#else
33+
#include <sys/socket.h>
34+
#endif
35+
#endif /* NETWARE */
36+
2937
#include "php.h"
3038
#include "ext/standard/head.h"
3139
#include "php_globals.h"
@@ -51,7 +59,7 @@ int php_apache_info_id;
5159
php_apache_info_struct php_apache_info;
5260
#endif
5361

54-
#ifdef PHP_WIN32
62+
#if defined(PHP_WIN32) || defined(NETWARE)
5563
#include "zend.h"
5664
#include "ap_compat.h"
5765
#else
@@ -101,7 +109,7 @@ static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRML
101109
static PHP_MINIT_FUNCTION(apache)
102110
{
103111
#ifdef ZTS
104-
ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), php_apache_globals_ctor, NULL);
112+
ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (void (*)(void *, void ***))php_apache_globals_ctor, NULL); /* Type-casting done due to NetWare */
105113
#else
106114
php_apache_globals_ctor(&php_apache_info TSRMLS_CC);
107115
#endif
@@ -133,6 +141,9 @@ zend_module_entry apache_module_entry = {
133141
Terminate apache process after this request */
134142
PHP_FUNCTION(apache_child_terminate)
135143
{
144+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
145+
EnterClib();
146+
#endif
136147
#ifndef MULTITHREAD
137148
if (AP(terminate_child)) {
138149
ap_child_terminate( ((request_rec *)SG(server_context)) );
@@ -142,6 +153,9 @@ PHP_FUNCTION(apache_child_terminate)
142153
#else
143154
php_error(E_WARNING, "apache_child_terminate() is not supported in this build");
144155
#endif
156+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
157+
ExitClib();
158+
#endif
145159
}
146160
/* }}} */
147161

@@ -153,6 +167,9 @@ PHP_FUNCTION(apache_note)
153167
char *note_val;
154168
int arg_count = ARG_COUNT(ht);
155169

170+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
171+
EnterClib();
172+
#endif
156173
if (arg_count<1 || arg_count>2 ||
157174
zend_get_parameters_ex(arg_count, &arg_name, &arg_val) ==FAILURE ) {
158175
WRONG_PARAM_COUNT;
@@ -166,6 +183,9 @@ PHP_FUNCTION(apache_note)
166183
table_set(((request_rec *)SG(server_context))->notes, (*arg_name)->value.str.val, (*arg_val)->value.str.val);
167184
}
168185

186+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
187+
ExitClib();
188+
#endif
169189
if (note_val) {
170190
RETURN_STRING(note_val, 1);
171191
} else {
@@ -180,7 +200,7 @@ PHP_MINFO_FUNCTION(apache)
180200
{
181201
module *modp = NULL;
182202
char output_buf[128];
183-
#if !defined(WIN32) && !defined(WINNT)
203+
#if !defined(WIN32) && !defined(WINNT) /* This seems to be working for NetWare */
184204
char name[64];
185205
char modulenames[1024];
186206
char *p;
@@ -192,6 +212,9 @@ PHP_MINFO_FUNCTION(apache)
192212
extern gid_t group_id;
193213
extern int max_requests_per_child;
194214

215+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
216+
EnterClib();
217+
#endif
195218
serv = ((request_rec *) SG(server_context))->server;
196219

197220

@@ -201,6 +224,10 @@ PHP_MINFO_FUNCTION(apache)
201224
php_info_print_table_row(1, "Apache for Windows 95/NT");
202225
php_info_print_table_end();
203226
php_info_print_table_start();
227+
#elif defined(NETWARE)
228+
php_info_print_table_row(1, "Apache for NetWare");
229+
php_info_print_table_end();
230+
php_info_print_table_start();
204231
#else
205232
php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE);
206233
php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET);
@@ -216,15 +243,15 @@ PHP_MINFO_FUNCTION(apache)
216243
php_info_print_table_row(2, "Apache API Version", output_buf);
217244
sprintf(output_buf, "%s:%u", serv->server_hostname, serv->port);
218245
php_info_print_table_row(2, "Hostname:Port", output_buf);
219-
#if !defined(WIN32) && !defined(WINNT)
246+
#if !defined(WIN32) && !defined(WINNT) /* This seems to be working for NetWare */
220247
sprintf(output_buf, "%s(%d)/%d", user_name, (int)user_id, (int)group_id);
221248
php_info_print_table_row(2, "User/Group", output_buf);
222249
sprintf(output_buf, "Per Child: %d - Keep Alive: %s - Max Per Connection: %d", max_requests_per_child, serv->keep_alive ? "on":"off", serv->keep_alive_max);
223250
php_info_print_table_row(2, "Max Requests", output_buf);
224251
#endif
225252
sprintf(output_buf, "Connection: %d - Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout);
226253
php_info_print_table_row(2, "Timeouts", output_buf);
227-
#if !defined(WIN32) && !defined(WINNT)
254+
#if !defined(WIN32) && !defined(WINNT) /* This seems to be working for NetWare */
228255
php_info_print_table_row(2, "Server Root", server_root);
229256

230257
strcpy(modulenames, "");
@@ -238,6 +265,7 @@ PHP_MINFO_FUNCTION(apache)
238265
strcat(modulenames, ", ");
239266
}
240267
}
268+
/* But here for NetWare, it seems to be showing all modules instead of just the loaded ones */
241269
php_info_print_table_row(2, "Loaded Modules", modulenames);
242270
#endif
243271

@@ -292,6 +320,9 @@ PHP_MINFO_FUNCTION(apache)
292320
}
293321
php_info_print_table_end();
294322
}
323+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
324+
ExitClib();
325+
#endif
295326
}
296327
/* }}} */
297328

@@ -310,6 +341,9 @@ PHP_FUNCTION(virtual)
310341
pval **filename;
311342
request_rec *rr = NULL;
312343

344+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
345+
EnterClib();
346+
#endif
313347
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
314348
WRONG_PARAM_COUNT;
315349
}
@@ -318,12 +352,18 @@ PHP_FUNCTION(virtual)
318352
if (!(rr = sub_req_lookup_uri ((*filename)->value.str.val, ((request_rec *) SG(server_context))))) {
319353
php_error(E_WARNING, "Unable to include '%s' - URI lookup failed", (*filename)->value.str.val);
320354
if (rr) destroy_sub_req (rr);
355+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
356+
ExitClib();
357+
#endif
321358
RETURN_FALSE;
322359
}
323360

324361
if (rr->status != 200) {
325362
php_error(E_WARNING, "Unable to include '%s' - error finding URI", (*filename)->value.str.val);
326363
if (rr) destroy_sub_req (rr);
364+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
365+
ExitClib();
366+
#endif
327367
RETURN_FALSE;
328368
}
329369

@@ -333,9 +373,15 @@ PHP_FUNCTION(virtual)
333373
if (run_sub_req(rr)) {
334374
php_error(E_WARNING, "Unable to include '%s' - request execution failed", (*filename)->value.str.val);
335375
if (rr) destroy_sub_req (rr);
376+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
377+
ExitClib();
378+
#endif
336379
RETURN_FALSE;
337380
} else {
338381
if (rr) destroy_sub_req (rr);
382+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
383+
ExitClib();
384+
#endif
339385
RETURN_TRUE;
340386
}
341387
}
@@ -348,8 +394,14 @@ PHP_FUNCTION(getallheaders)
348394
array_header *env_arr;
349395
table_entry *tenv;
350396
int i;
351-
397+
398+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
399+
EnterClib();
400+
#endif
352401
if (array_init(return_value) == FAILURE) {
402+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
403+
ExitClib();
404+
#endif
353405
RETURN_FALSE;
354406
}
355407
env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
@@ -361,9 +413,15 @@ PHP_FUNCTION(getallheaders)
361413
continue;
362414
}
363415
if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
416+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
417+
ExitClib();
418+
#endif
364419
RETURN_FALSE;
365420
}
366421
}
422+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
423+
ExitClib();
424+
#endif
367425
}
368426
/* }}} */
369427

@@ -384,7 +442,13 @@ PHP_FUNCTION(apache_setenv)
384442
else break;
385443
}
386444

445+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
446+
EnterClib();
447+
#endif
387448
ap_table_setn(r->subprocess_env, ap_pstrndup(r->pool, var, var_len), ap_pstrndup(r->pool, val, val_len));
449+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
450+
ExitClib();
451+
#endif
388452
RETURN_TRUE;
389453
}
390454
/* }}} */
@@ -396,6 +460,9 @@ PHP_FUNCTION(apache_lookup_uri)
396460
pval **filename;
397461
request_rec *rr=NULL;
398462

463+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
464+
EnterClib();
465+
#endif
399466
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
400467
WRONG_PARAM_COUNT;
401468
}
@@ -458,6 +525,9 @@ PHP_FUNCTION(apache_lookup_uri)
458525
}
459526

460527
destroy_sub_req(rr);
528+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
529+
ExitClib();
530+
#endif
461531
}
462532
/* }}} */
463533

@@ -471,6 +541,9 @@ PHP_FUNCTION(apache_exec_uri)
471541
request_rec *rr=NULL;
472542
TSRMLS_FETCH();
473543

544+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
545+
EnterClib();
546+
#endif
474547
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
475548
WRONG_PARAM_COUNT;
476549
}
@@ -482,6 +555,9 @@ PHP_FUNCTION(apache_exec_uri)
482555
}
483556
RETVAL_LONG(ap_run_sub_req(rr));
484557
ap_destroy_sub_req(rr);
558+
#if defined(NETWARE) && defined(NETWARE_CLIB_BROKER)
559+
ExitClib();
560+
#endif
485561
}
486562
#endif
487563

sapi/apache/sapi_apache.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
#include <stddef.h>
2828
#endif
2929

30+
#ifdef NETWARE
31+
#ifdef NEW_LIBC /* Works fine for both Winsock and Berkeley sockets */
32+
#include <netinet/in.h>
33+
#else
34+
#include <sys/socket.h>
35+
#endif
36+
#endif /* NETWARE */
37+
3038
#include "php.h"
3139

3240
#include "httpd.h"

sapi/apache2filter/sapi_apache2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
#include "ap_mpm.h"
4444

4545
#include "php_apache.h"
46-
46+
47+
#ifdef NETWARE
48+
#undef shutdown /* To avoid Winsock confusion */
49+
#endif
50+
4751
/* A way to specify the location of the php.ini dir in an apache directive */
4852
char *apache2_php_ini_path_override = NULL;
4953

sapi/cli/php_cli.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
#include "win32/time.h"
3434
#include "win32/signal.h"
3535
#include <process.h>
36+
#elif defined(NETWARE)
37+
#ifdef NEW_LIBC
38+
#include <sys/timeval.h>
39+
#else
40+
#include "netware/time_nw.h"
41+
#endif
42+
/*#include "netware/signal_nw.h"*/
43+
/*#include "netware/env.h"*/ /* Temporary */
44+
/*#include <process.h>*/
45+
#ifdef USE_WINSOCK
46+
#include <novsock2.h>
47+
#endif
3648
#else
3749
#include "build-defs.h"
3850
#endif
@@ -362,6 +374,15 @@ int main(int argc, char *argv[])
362374

363375
/* startup after we get the above ini override se we get things right */
364376
if (php_module_startup(&cli_sapi_module)==FAILURE) {
377+
#ifdef NETWARE
378+
/* Without the below two functions, it will leak memory!!
379+
Don't know why they were not there in the first place.
380+
*/
381+
sapi_shutdown();
382+
#ifdef ZTS
383+
tsrm_shutdown();
384+
#endif
385+
#endif
365386
return FAILURE;
366387
}
367388

@@ -644,6 +665,13 @@ int main(int argc, char *argv[])
644665

645666
php_module_shutdown(TSRMLS_C);
646667

668+
#ifdef NETWARE
669+
/* Without the below function, it will leak memory!!
670+
Don't know why it was not there in the first place.
671+
*/
672+
sapi_shutdown();
673+
#endif
674+
647675
#ifdef ZTS
648676
tsrm_shutdown();
649677
#endif

0 commit comments

Comments
 (0)