[Freeswitch-svn] [commit] r2564 - freeswitch/trunk/src/mod/languages/mod_php

Freeswitch SVN anthm at freeswitch.org
Thu Sep 7 20:51:41 EDT 2006


Author: anthm
Date: Thu Sep  7 20:51:40 2006
New Revision: 2564

Modified:
   freeswitch/trunk/src/mod/languages/mod_php/Makefile
   freeswitch/trunk/src/mod/languages/mod_php/mod_php.c

Log:
update

Modified: freeswitch/trunk/src/mod/languages/mod_php/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_php/Makefile	(original)
+++ freeswitch/trunk/src/mod/languages/mod_php/Makefile	Thu Sep  7 20:51:40 2006
@@ -1,29 +1,33 @@
-CFLAGS += -I$(PREFIX)/include/php/TSRM -I$(PREFIX)/include/php/main/ -I$(PREFIX)/include/php/Zend/ -I$(PREFIX)/include/php/
+#Usage: /usr/local/freeswitch/bin/php-config [--prefix|--includes|--ldflags|--libs|--extension-dir|--include-dir|--php-binary|--version]
+PCFG=$(PREFIX)/bin/php-config
+
+LCFLAGS=-fPIC -DZTS -DPTHREADS
+CFLAGS += `$(PCFG) --includes`
 PHPMOD=freeswitch
-LDFLAGS += -lphp4
+LDFLAGS += `$(PCFG) --ldflags` -lcrypt -lcrypt -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lphp5
 
 all:	depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PHPMOD).$(DYNAMIC_LIB_EXTEN)
 
 depends:
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install php-4.4.4.tar.gz --prefix=$(PREFIX) --enable-embed
+	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install php-5.1.6.tar.gz --prefix=$(PREFIX) --enable-embed=static --enable-static --with-pic
 %.o:  %.c
-	$(CC) -fPIC $(CFLAGS) -c $< -o $@
+	$(CC) $(LCFLAGS) $(CFLAGS) -c $< -o $@
 
 reswig: 
 	rm -f switch_swig_wrap.c config.m4 CREDITS *$(PHPMOD)*
 	swig -lswitch_swig.i -ignoremissing -DMULTIPLICITY -php -module $(PHPMOD) switch_swig.c
 	patch -p0 -i fix.diff
 
-switch_swig_wrap.o: switch_swig_wrap.c
-	$(CC) -w $(CFLAGS) -c $< -o $@
+switch_swig_wrap.o: switch_swig_wrap.c Makefile
+	$(CC) $(LCFLAGS) -w $(CFLAGS) -c $< -o $@
 
 
-$(PHPMOD).$(DYNAMIC_LIB_EXTEN): $(MODNAME).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o
+$(PHPMOD).$(DYNAMIC_LIB_EXTEN): $(MODNAME).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o Makefile
 	$(CC) $(SOLINK) -o php_$(PHPMOD).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o $(LDFLAGS)
 
 
-$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS)
-	$(CC) -fPIC $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN)  $(MODNAME).o $(OBJS) $(LDFLAGS)
+$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS) Makefile
+	$(CC) $(LCFLAGS) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN)  $(MODNAME).o $(OBJS) $(LDFLAGS)
 
 clean:
 	rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~

Modified: freeswitch/trunk/src/mod/languages/mod_php/mod_php.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_php/mod_php.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_php/mod_php.c	Thu Sep  7 20:51:40 2006
@@ -30,7 +30,15 @@
  * mod_php.c -- PHP Module
  *
  */
-#include <switch.h>
+
+#ifndef _REENTRANT
+#define _REENTRANT
+#endif
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include "php.h"
 #include "php_variables.h"
 #include "ext/standard/info.h"
@@ -42,6 +50,8 @@
 #include "TSRM.h"
 #include "ext/standard/php_standard.h"
 
+#include <switch.h>
+
 const char modname[] = "mod_php";
 
 static int php_freeswitch_startup(sapi_module_struct *sapi_module)
@@ -239,8 +249,8 @@
 
 	SG(request_info).argc = request_context->argc;
 	SG(request_info).argv = request_context->argv;
-
 	SG(request_info).path_translated    = estrdup(request_context->argv[0]);
+
 }
 
 static void freeswitch_request_dtor(switch_php_obj_t *request_context TSRMLS_DC)
@@ -276,10 +286,10 @@
 	uint32_t len = strlen((char *) data) + ulen + 2;
 	char *mydata = switch_core_session_alloc(session, len);
 
-	snprintf(mydata, len, "-q %s %s", data, uuid);
-	
 	TSRMLS_FETCH();
 
+	snprintf(mydata, len, "%s %s", data, uuid);
+
 	request_context = (switch_php_obj_t *) switch_core_session_alloc(session, sizeof(*request_context));
 
 	request_context->session = session;
@@ -333,6 +343,15 @@
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
+
+	php_core_globals *core_globals;
+
+	tsrm_startup(128, 1, 0, NULL);
+	core_globals = ts_resource(core_globals_id);
+	
+	sapi_startup(&fs_sapi_module);
+	fs_sapi_module.startup(&fs_sapi_module);
+	
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &php_module_interface;
 



More information about the Freeswitch-svn mailing list