cvs: php4 /ext/ircg ircg_common.c
| From: | Sascha Schumann | Date: | Mon, 28 Apr 2003 18:02:37 +0000 |
| Subject: | cvs: php4 /ext/ircg ircg_common.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20544@lists.php.net to get a copy of this message | ||
sas Mon Apr 28 14:02:37 2003 EDT
Modified files:
/php4/ext/ircg ircg_common.c
Log:
untested compatibility layer support for apache2
Index: php4/ext/ircg/ircg_common.c
diff -u php4/ext/ircg/ircg_common.c:1.5 php4/ext/ircg/ircg_common.c:1.6
--- php4/ext/ircg/ircg_common.c:1.5 Mon Apr 28 12:51:24 2003
+++ php4/ext/ircg/ircg_common.c Mon Apr 28 14:02:37 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg_common.c,v 1.5 2003/04/28 16:51:24 sas Exp $ */
+/* $Id: ircg_common.c,v 1.6 2003/04/28 18:02:37 sas Exp $ */
#include "php.h"
@@ -36,11 +36,14 @@
static int (*php_ircg_sapi_get_target_uid)(uid_t * TSRMLS_DC);
static int (*php_ircg_sapi_get_target_gid)(gid_t * TSRMLS_DC);
+/* Apache 1.3 definitions */
+
static int is_apache;
static uid_t *php_ircg_ap_user_id;
static gid_t *php_ircg_ap_group_id;
+
typedef struct {
unsigned long a;
int fd;
@@ -84,6 +87,55 @@
int proto_num;
} ircg_request_rec;
+/* Apache 2.0 definitions */
+
+static int is_apache2;
+
+static void *php_ircg_apa2_core_module;
+static void (*php_ircg_apa2_get_module_config)(void *, void *);
+
+typedef struct {
+ void *a;
+ uid_t user_id;
+ gid_t group_id;
+} ircg_apa2_unixd_config_rec;
+
+static ircg_apa2_unixd_config_rec *php_ircg_apa2_unixd_config;
+
+typedef struct {
+ void *a;
+ int fd;
+} ircg_apr_unix_socket;
+
+typedef struct {
+ void *a[8];
+ unsigned b;
+ enum { REALLY_NOTHING } c;
+ signed int d;
+ int e;
+ void *f[2];
+ long g;
+
+ void *conn_config;
+} ircg_apa2_conn_rec;
+
+typedef struct {
+ void *a;
+ ircg_apa2_conn_rec *connection;
+
+ void *b[5];
+ int c[3];
+ char *d;
+
+ int proto_num;
+} ircg_apa2_request_rec;
+
+
+typedef struct {
+ int a;
+ ircg_apa2_request_rec *r;
+} ircg_apa2_php_struct;
+
#include "main/SAPI.h"
static int php_ircg_force_http_10(TSRMLS_D)
@@ -97,15 +149,25 @@
r->proto_num = 1000;
return SUCCESS;
}
+ } else if (is_apache2) {
+ ircg_apa2_php_struct *p = SG(server_context);
+
+ /* ensure that we are not accidentially hitting something else */
+ if (p && p->r && (p->r->proto_num == 9
+ || (p->r->proto_num >= 1000 && p->r->proto_num <= 2000))) {
+ p->r->proto_num = 1000;
+ return SUCCESS;
+ }
}
return FAILURE;
}
static int php_ircg_get_fd(int *nfd TSRMLS_DC)
{
+ int fd = -1;
+
if (is_apache) {
ircg_request_rec *r = SG(server_context);
- int fd;
fd = r->connection->client->x.fd;
@@ -113,12 +175,26 @@
fd = r->connection->client->x.apfd->fd;
}
- if (fd >= 0 && fd < 130000) {
- *nfd = fd;
- return SUCCESS;
+ } else if (is_apache2) {
+ ircg_apa2_php_struct *p = SG(server_context);
+
+ if (p) {
+ ircg_apr_unix_socket *s;
+
+ s = php_ircg_apa2_get_module_config(p->r->connection->conn_config,
+ php_ircg_apa2_core_module);
+
+ if (s) {
+ fd = s->fd;
+ }
}
}
+ if (fd >= 0 && fd < 130000) {
+ *nfd = fd;
+ return SUCCESS;
+ }
+
return FAILURE;
}
@@ -127,6 +203,9 @@
if (is_apache) {
*obj = *php_ircg_ap_user_id;
return SUCCESS;
+ } else if (is_apache2) {
+ *obj = php_ircg_apa2_unixd_config->user_id;
+ return SUCCESS;
}
return FAILURE;
}
@@ -136,6 +215,9 @@
if (is_apache) {
*obj = *php_ircg_ap_group_id;
return SUCCESS;
+ } else if (is_apache2) {
+ *obj = php_ircg_apa2_unixd_config->group_id;
+ return SUCCESS;
}
return FAILURE;
}
@@ -151,7 +233,16 @@
is_apache = 1;
php_ircg_ap_user_id = dlsym(NULL, "ap_user_id");
php_ircg_ap_group_id = dlsym(NULL, "ap_group_id");
+ } else if (strcmp(sapi_module.name, "apache2filter") == 0
+ || strcmp(sapi_module.name, "apache2handler") == 0) {
+ is_apache2 = 1;
+
+ php_ircg_apa2_core_module = dlsym(NULL, "core_module");
+ php_ircg_apa2_get_module_config = dlsym(NULL,
+ "ap_get_module_config");
+ php_ircg_apa2_unixd_config = dlsym(NULL, "unixd_config");
}
+
p = dlsym(NULL, "sapi_get_fd");
php_ircg_sapi_get_fd = p ? p : php_ircg_get_fd;