[PHP-DEV] Is this a bug?

2003-03-25 Thread Tony Bibbs
Are there instances you all can think of where doing a header('location: 
$url'); causes a loss of all session data?  I have a case I can reproduce 
consistently where doing a header() refresh or echoing out an HTML page 
with a meta refresh both cause resulting page to lose session.  My hunch 
is that I may not be accounting for some ingrained PHP handling and that 
this isn't a bug but I can't be sure.  

If required, I can submit the offending code but I'll hold off in case 
there is an obvious answer.

-- 
Tony Bibbs  "I guess you have to remember that those who don't
[EMAIL PROTECTED]  hunt or fish often see those of us who do as  
harmlessly strange and sort of amusing. When you  
think about it, that might be a fair assessment." 
--Unknown



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] linking against ststic librarys

2003-01-18 Thread Tony Leake
Hi,

is it possible to create an extension that links against a static
library.

If it is could someone point me to an extension that does this, or
explain how to do it.

Thanks
Tony




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Java Extension Build Method

2002-12-06 Thread Tony J. White

> Under the heading "Build java module with -ljava" you mention that there
> were crashing problems because libjava.so was linked agains pthread and
> apache wasn't. This is not uncommon problem for other libraries such as
> oci8. You can link apache with pthread which will prevent the segfaults. See
> oci8 manual page for instructions.

Thanks for the tip.

I built apache with -lpthread and I was able to get a little bit farther with
linking the java module with -ljava.For the first time I was able to run the
following script through apache:
http://www.tjw.org/php_java/classloader.phps

However, I had other problems that keep this build method from working right.

The code
$system = new Java('java.lang.System');
would hang apache.  Why the more advanced classloader.php example worked and
this one didn't I have no idea.   Both examples worked fine in the CLI
build of PHP.

I also noticed that if i create the JVM in PHP_MINIT_FUNCTION() instead of
creating it on the first request for java, apache hangs for every java
request.  This works fine in the CLI build.  Since I get no segfault and
strace -p gives me no output at all, I'm stumped.

-Tony



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] persistent java virtual machine under PHP

2002-12-06 Thread Tony J. White

> This is contrary to my experiences. But we have discussed this earlier
> today.

After reviewing the thread, I think the problem you are experiencing is related
to the fact that each instance of PHP is running a seperate JVM.  It's not
that the JVM is being destroyed.

Therefore when you have apache running with say 5 httpd children, you will be
running 5 seperate JVM's each with it's own environment.  So if you tried
to keep a Java variable active from request to request, it would disappear
once your apache KeepAliveTimeout was up.

Does that sound about right?

-Tony




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] sapi/servlet configuration error

2002-12-05 Thread Tony J. White

On Thu, 5 Dec 2002, Ray Hunter wrote:
> This is the line in my Makefile:
>
> sapi/servlet/java.lo: sapi/servlet/java.c
>   $(LIBTOOL) --mode=compile $(CC)  -Isapi/servlet/
> -I/home/rhunter/src/php4/sapi/servlet/ $(COMMON_FLAGS) $(CFLAGS_CLEAN)
> $(EXTRA_CFLAGS) -prefer-pic -c sapi/servlet/java.c -o
> sapi/servlet/java.lo
>
> Is that correct?

That chunk is added by the macro PHP_ADD_SOURCES() in sapi/servlet/config.m4.

If there is no line that _starts_ with 'sapi/servlet/java.c :', then the
sapi/servlet/Makefile.frag is not being included properly.

If it's not, try changing the PHP_ADD_MAKEFILE_FRAGMENT like I indicated,
then run:

make clean
rm -r configure autom4te.cache
./buildconf
./configure --with...
make

You will need to have installed the required packages to do this though
(e.g. automake, autoconfig, etc. )

-Tony

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] persistent java virtual machine under PHP

2002-12-05 Thread Tony J. White


On Thu, 5 Dec 2002, [ISO-8859-2] Maróy Ákos wrote:
> > Actually, the JVM is unloaded by php.  In the latest CVS the code from
>
> I see. But if you dlclose()-it, what happens to open resources, like
> open file descriptors, network sockets, etc? It seems to be a crude way
> of unloading the JVM...

Oops!  That should have read "the JVM is _NOT_ unloaded by php.".

Once loaded the JVM remains loaded by the PHP process.  When php scripts
finish or variables are unset() DeleteLocalRef() is called on the JVM to
allow the JVM to garbage collect unused resources, but the JVM remains
running.

-Tony

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] sapi/servlet configuration error

2002-12-05 Thread Tony J. White

On Thu, 5 Dec 2002, Ray Hunter wrote:
> make: *** No rule to make target `sapi/servlet/java.c', needed by
> `sapi/servlet/java.lo'.  Stop.

It looks like the sapi/servlet/Makefile.frag is not being added to your
Makefile.

Can you verify that there is no line in your main Makefile that starts with
"sapi/servlet/java.c : "?

Perhaps you could try changing the line (from sapi/servlet/config.m4)

PHP_ADD_MAKEFILE_FRAGMENT(sapi/servlet/Makefile.frag)

to just

PHP_ADD_MAKEFILE_FRAGMENT

In case $ext_srcdir is something other than 'sapi/servlet' for some reason.

-Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Java Extension Build Method

2002-12-05 Thread Tony J. White

The /ext/java module is an odd duck compared to other php extentions in that
it uses DL_LOAD() to load libjava instead of being linked and that it is
always built as a module (.so) instead of being built static into php.

I've spent some time over the past couple weeks investigating why this is
done and experimenting with different build methods.  Although, i haven't
come up with any breakthroughs in makeing the java extension build any
other way, I've compiled some notes on the subject:

http://tjw.org/php_java/build_notes.php

I think I have a pretty good handle on why things are the way they are, but
am I missing something?

-Tony

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] persistent java virtual machine under PHP

2002-12-05 Thread Tony J. White

On Wed, 4 Dec 2002, [ISO-8859-2] Maróy Ákos wrote:
> What happens is that the function jvm_create() gets called regularly
> when requesting new pages using the Java extension, from the function
> java_call_function_handler():
>
>if (!JG(jenv)) jvm_create(TSRMLS_C);

Actually, the JVM is unloaded by php.  In the latest CVS the code from
destroy_jvm() has been removed that tried to dlclose() the JVM.  This was
done because it is impossible to dlclose() a JVM because DestroyJavaVM()
is broken in all JNI implementations.

It the code you reference JG(env) is a global variable that is the jenv of
the currently running JVM.  Of course a new JVM needs to be created by every
instance of PHP (so every httpd child in apache).  The code is misleading
because in past versions of PHP, the module tried to unload the JVM and load it
again every time a ini setting was changed.  This code should be removed
and jvm_create() should be instead placed in the PHP_MINIT() function, that
way the JVM will be loaded when apache is started instead of the first time
java() is used by PHP.  I'll get to it eventually unless someone beats me to
it.

-Tony


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Java extension fixes

2002-12-05 Thread Tony J. White

On Wed, 4 Dec 2002, Ray Hunter wrote:
> Will this fix the errors that occur with running PHP as a servlet in
> tomcat?

Basically, if you were using ini_set() anywhere, or using .htaccess files to
change any php settings, this patch should prevent errors/crashing.

-Tony

>
> --
> Ray
>
> On Wed, 2002-12-04 at 01:20, Sebastian Bergmann wrote:
> > "Tony J. White" wrote:
> > > Can someone please add this to CVS or should I contact Sam Ruby (the
> > > orignal author) to do it?
> >
> >   Committed,
> > Sebastian
> >
> > --
> >   Sebastian Bergmann
> >   http://sebastian-bergmann.de/ http://phpOpenTracker.de/
> >
> >   Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] CVS Account Request: tjw

2002-11-25 Thread Tony J. White
Submit fixes for php4/ext/java/ only.

Rasmus instructed me to fill out this form.



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Java extension fixes

2002-11-25 Thread Tony J. White

I think the reason DL_ERROR is defined in java.c for win32 platforms is that
there is no dlerror() function for win32.  I'm only guessing because I have
no win32 platform to test on.

On unix platforms, DL_ERROR is defined in zend.h as the function name for the
dlerror() equivalent.

Can someone verify that there is a dlerror() function for win32?  Here is the
current code from java.c

#ifdef PHP_WIN32
#include "win32/winutil.h"
#define DL_ERROR php_win_err
#endif

-Tony


On Mon, 25 Nov 2002, Dan Kalowsky wrote:

> Comments on the patch.
>
> Don't redefine DL_ERROR, this should already be  defined by the ZEND
> engine, but just check to make sure ;)
>
> All of your build problems are known problems.  If you can fix them,
> excellent!  Just wondering if this has been tested against windows
> where the most prevalent errors seem to be the improper
> loading/unloading of the JVM.
>
>
> On Monday, November 25, 2002, at 01:00 AM, Tony J. White wrote:
>
> >
> > I'm made a stability fix to the PHP Java extension.  A full
> > description of the
> > changes as well as the updated java.c file (and patch) can be found
> > here:
> >
> > http://tjw.org/php_java/
> >
> > Can someone please add this to CVS or should I contact Sam Ruby (the
> > orignal
> > author) to do it?
> >
> > -Tony
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>  >---<
> Dan Kalowsky"Momma take this badge offa me,
> http://www.deadmime.org/~dankI can't use it anymore."
> [EMAIL PROTECTED]- "Knockin on Heavens Door",
> [EMAIL PROTECTED]Bob Dylan
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Java extension fixes

2002-11-24 Thread Tony J . White

I'm made a stability fix to the PHP Java extension.  A full description of the
changes as well as the updated java.c file (and patch) can be found here:

http://tjw.org/php_java/

Can someone please add this to CVS or should I contact Sam Ruby (the orignal 
author) to do it?

-Tony

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] updating php_error messages

2002-11-12 Thread Tony Leake
Hi,

I have noticed in the TODO file in head one of the items is:

* Change PHP error messages, so that they point to pages or sections
in the PHP Manual.

I have a few weeks of spare evenings coming up so if anyone wants me to 
I'm happy to wade through and make the changes. As far as I can see it's
just a case of changing php_error to php_error_docref and adding 
NULL TSRMLS_CC as the first argument.

I don't have karma to do this so either I would need it or I could
supply patches. 

Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Freeing memory

2002-11-09 Thread Tony Leake
Hi Wez,

I wrote a pecl extension called ecasound which interacts with an audio
processing library. Now the way that ecasound is written will change in
future versions and will have a fully interactive mode, all other
implementations (perl, python c++ etc) have been re-written so that they
open up a couple of pipes, fork and then exec ecasound in the child
process so using the interactive mode instead of  linking against the
librarys. What I would like to do is to make the PHP implementation work
in the same way as all of the others but of course PHP does not yet have
full 2 way communication with a child process. 

I agree that extending proc_open may be the best solution but while I
would be willing to do the work I'm not sure that I can at the moment. 
Working with processes etc in c is fairly new to me and so are PHP
extensions so trying to extend someone else's function that already
looks fairly complex may be beyond me at this time (also I do not know
anything about programming under win32).

Maybe I'll take another look though as If this would really be the best
way to implement the functionality I need then it may be a good learning
exercise :)

Tony


On Sat, 2002-11-09 at 19:52, Wez Furlong wrote:
> Hi Tony,
> 
> What kind of things are you planning to do?
> proc_open seems ideal to extend for this purpose, and works on win32.
> 
> --Wez.
> 
> On 09/11/02, "Tony Leake" <[EMAIL PROTECTED]> wrote:
> > The whole picture is that i want to control a child process completely 
> > from within php. A bit like popen or proc_open but with 2 independent
> > pipes to the child's stdin and stdout that I can read and write to. So
> > I'm basically wrapping the c functions pipe(), dup2() and friends. Once
> > I have it all working I will offer to add the functions into the pcntl
> > extension if they're wanted. 
> 
> 
> 
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Freeing memory

2002-11-09 Thread Tony Leake
The whole picture is that i want to control a child process completely 
from within php. A bit like popen or proc_open but with 2 independent
pipes to the child's stdin and stdout that I can read and write to. So
I'm basically wrapping the c functions pipe(), dup2() and friends. Once
I have it all working I will offer to add the functions into the pcntl
extension if they're wanted. 

Anyway the code in the pipe function that was giving me the warnings is
as follows:

PHP_FUNCTION(pipe)
{
pipe_r_le_struct *st_pipe_r;
pipe_w_le_struct *st_pipe_w;
zval *read;
zval *write;
int pipe_fd[2];

if( pipe(pipe_fd ) <0 ){
php_error( E_ERROR, "Could not create pipe" );
}

st_pipe_r = emalloc( sizeof( pipe_r_le_struct ) );
st_pipe_w = emalloc( sizeof( pipe_w_le_struct ) );

st_pipe_r->fd = pipe_fd[0];
st_pipe_w->fd = pipe_fd[1];

MAKE_STD_ZVAL( read );
MAKE_STD_ZVAL( write );

ZEND_REGISTER_RESOURCE( read, st_pipe_r, le_pipe_r )
ZEND_REGISTER_RESOURCE( write, st_pipe_w, le_pipe_w )


array_init( return_value );
add_assoc_resource( return_value, "read", Z_RESVAL_P( read ) );
add_assoc_resource( return_value, "write", Z_RESVAL_P( write ) );

}

If i use FREE_ZVAL() at the end of this function I can get rid of the
warnings but I would guess this is the wrong place and it should be
taken care of in a cleanup function when the request has finished.

Please excuse me if I am missing something obvious here, as you may
guess I'm still finding my feet writing PHP extensions.

Tony


On Sat, 2002-11-09 at 08:56, Andi Gutmans wrote:
> Actually zval_ptr_dtor() is probably more suitable.
> In any case, is this zval something you keep locally in your extension or 
> are you returning/adding it to the engine's symbol table? If so, the engine 
> should take care of the memory automatically as long as you've done 
> everything correctly.
> Maybe you should explain in more detail what you're doing.
> Andi
> 




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Freeing memory

2002-11-09 Thread Tony Leake

Hi,

I am getting the following output from a php script that calls an
extension I am writing (I have compiled the extension with
--enable-debug)


/home/phpcvs/php4_head/ext/pipe/pipe.c(245) :  Freeing 0x0822568C (12
bytes), script=test.php
/home/phpcvs/php4_head/ext/pipe/pipe.c(244) :  Freeing 0x0822564C (12
bytes), script=test.php

where lines lines 245 and 244 are:
MAKE_STD_ZVAL(read);
MAKE_STD_ZVAL(write);

Does this mean that I need to free the memory from the zvals when the
script exits, or is this just information?

Thanks for your help
Tony



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] newbie: url parms

2002-11-05 Thread Tony Leake
On Tue, 2002-11-05 at 09:32, Geert Arts wrote:
> Hi,
> 
> I just seem not to be able to pass variables from a URL to a PHP script.
> When I do something like http://localhost/test.php?variablex=valuex  variablex is 
>empty (or does even not 
> exist?)
> 
> I'm running php 4.2.3 and apache 1.3.27 under Windows.

You will find your answer on this page of the fine manual
http://www.php.net/manual/en/reserved.variables.php

Please note that this is not the correct forum for this question. This
forum deals with writing the PHP language in 'c' not writing scripts
with PHP.

The correct forum is php-general.details of which you can find here:

http://www.php.net/mailing-lists.php

Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Global HashTables & access violations

2002-10-21 Thread Tony Leake
On Mon, 2002-10-21 at 20:19, Brian 'Bex' Huff wrote:

> Ive written an extension to PHP that (among other things) uses a global 
> HashTable object for a mini cache.  I fill it, and then have a simple 
> PHP function to pull a string out of the cache, and return it.  However, 
> I keep getting wierd internal access violations whenever I try to use it.
> 
Hi Brian,

I can't help with your specific problems but there are a couple of
shortcuts you can use in your module. 

You can get the string length of your arguments as they are passes in,
see below.

Also there are macros for returning values which I believe are the
preferred way of doing things. I have made the change in your code below
to show how to get the string length passed in.

you have 2 functions for returning strings :
RETURN_STRING(char *s, int dup) 
and 
RETURN_STRINGL(char *s, int l, int dup) if you know the length of the
string.
int dup, should be 1 unless you estrdup or emalloc the string.

these 2 functions seem to have aliases RETVAL_STRING and RETVAL_STRINGL
I'm not sure which version is preferred.

see for further info
http://zend.com/apidoc/zend.returning.php


HTH
Tony


> PHP_FUNCTION(idc_env)
> {
>HashTable *env = IDC_G(server_environment);
>zval **value = NULL;
>char *valueStr = NULL;
>int argc = ZEND_NUM_ARGS();
>char *name = NULL;
 /* NEW LINE, and line below modified */
 long name_length; 
>if (zend_parse_parameters(argc TSRMLS_CC, "s", &name, &name_length) == FAILURE)
>  return;
> 
>if (zend_hash_find(env, name, strlen(name) + 1,
>   (void **) &value) == SUCCESS)
>{
>  if ((*value)->type == IS_STRING)
>  {
>valueStr = Z_STRVAL_PP(value);
>return_value->type = IS_STRING;
>return_value->value.str.len = Z_STRLEN_PP(value);
>return_value->value.str.val = estrdup(valueStr);
 
/* previous 3 lines can be replaced with */
RETURN_STRINGL(valueStr, Z_STRLEN_PP(value), 1 );
>  }
>}
> }
> 



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] 4.2.3pre1

2002-10-21 Thread Tony Bibbs
All this on a Dell Inspiron 5000 running RH7.3.  I compiled PHP apache
module just fine.  Compiling it as a CGI I get:

gcc: sapi/cli/php_cli.o: No such file or directory
gcc: sapi/cli/getopt.o: No such file or directory

This a bug or did I miss something?

--Tony




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] library calls from within php functions

2002-10-20 Thread Tony Leake
On Sun, 2002-10-20 at 10:07, Wez Furlong wrote:

> Aside from that, I can't see any obvious mistakes.
> 

Ok, I solved it. I declared a zval called read, then tried to call the
read function. DOH !

Thanks for your help anyway
Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] library calls from within php functions

2002-10-20 Thread Tony Leake
On Sun, 2002-10-20 at 09:34, Wez Furlong wrote:

Thanks for the fast reply Wez,

> There's not much we can tell you about this unless you post the
> rest of the lines of that function.

See below for the code

> 
> Perhaps you did not include  ?

Yep thats there, I used exec_skel to create the basic module.
> 
> Note:  always prefer this:
> 
>   read(fd, buf, sizeof(buf));
> 
> to this:
> 
>   read(fd, buf, 1024);

Thanks, done that.

OK, what I'm trying to achieve is basically wrapping pipe, read and
write so in a php script I can create 2 pipes, fork the process using 
pcntl_fork() and have 2 way non blocking communication with more control
than proc_open()

I have so far written this function that creates the pipe and returns an
array of the pipes descriptors:

PHP_FUNCTION(pipe)
{

pipe_r_le_struct *st_pipe_r;
pipe_w_le_struct *st_pipe_w;
zval *read;
zval *write;
int pipe_fd[2];

if(pipe(pipe_fd) <0){
php_error(E_ERROR, "Could not create pipe");
}

st_pipe_r=emalloc(sizeof(pipe_r_le_struct));
st_pipe_w=emalloc(sizeof(pipe_w_le_struct));

st_pipe_r->fd=pipe_fd[0];
st_pipe_w->fd=pipe_fd[1];

MAKE_STD_ZVAL(read);
MAKE_STD_ZVAL(write);

ZEND_REGISTER_RESOURCE(read, st_pipe_r, le_pipe_r)
ZEND_REGISTER_RESOURCE(write, st_pipe_w, le_pipe_w)

array_init(return_value);
add_assoc_resource(return_value, "read", Z_RESVAL_P(read));
add_assoc_resource(return_value, "write", Z_RESVAL_P(write));

}
This function appears to work as expected

and now I'm trying to write functions that will read and write from the
pipe. So far I have this, it isn't finished as you will see.

PHP_FUNCTION(pipe_read)
{
pipe_r_le_struct *st_pipe_r;
zval *read;
zval * res;
char buf[1024];

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) ==
FAILURE) {
return;
}

ZEND_FETCH_RESOURCE(st_pipe_r, pipe_r_le_struct *, &res, -1,
"pipe_r", le_pipe_r);

if(!st_pipe_r) RETURN_FALSE;

read(fd, buf, sizeof(buf));
}

I was just testing that it still compiles and it fails on the 
read(fd, buf, sizeof(buf)); line. with the error  
called object is not a function

As I mentioned if I move that line into a c function it compiles fine.

Thanks
Tony 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] library calls from within php functions

2002-10-20 Thread Tony Leake
Hi, 

I am working on an extension that makes use of the pipe, read and write 
library calls on a linux platform. 

When I try to put this line 
read(fd, buf, 1024);
inside a php function ( PHP_FUNCTION(read_pipe) ) it fails to compile
with the following warning:
called object is not a function.

If I move the same line into a standard c function it compiles without
error. 

So my question is, is there some problem trying to make library calls
from within php functions? although other calls seem to work fine.

Thanks for any help
Tony 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] help needed with config.m4 script

2002-09-25 Thread Tony Leake

On Wed, 2002-09-25 at 22:48, Jani Taskinen wrote:
> 
>   The 2nd last line I added should take care of it.
>   You also might want to add the include path with 'PHP_ADD_INCLUDE'
>   macro..in case the header files are not in /usr/include.. :)
> 
>   --Jani
>   
Thanks a lot Jani, problem solved :)

Tony
 



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] help needed with config.m4 script

2002-09-25 Thread Tony Leake

Hello, 

I am having problems with an extension, I think with the config.m4
script.

If I build the extension into the php source tree it works fine and
links correctly. If I build it as a shared object either within the
source tree as --with-audio=shared or outside the source tree running
phpize the .so file builds but it doesn't link to the external lib. 

If I run ldd on the .so it doesn't seem to be trying to link.

Can anyone see what I'm doing wrong?

thanks 
Tony

contents of config.m4

PHP_ARG_WITH(audio, for audio support,
[  --with-audio Include audio support])


if test "$PHP_AUDIO" != "no"; then

SEARCH_PATH="/usr/local /usr"
SEARCH_FOR="/include/ecasound/ecasoundc.h"
if test -r $PHP_AUDIO/; then # path given as parameter
  AUDIO_DIR=$PHP_AUDIO
else # search default path list
  AC_MSG_CHECKING([for ecasound files in default path])
  for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
  AUDIO_DIR=$i
  AC_MSG_RESULT(found in $i)
fi
  done
fi

if test -z "$AUDIO_DIR"; then
  AC_MSG_RESULT([Ecasound header files not found])
  AC_MSG_ERROR([Please reinstall the ecasound distribution])
fi

  PHP_ADD_LIBRARY_WITH_PATH(ecasoundc, $AUDIO_DIR/lib,
AUDIO_SHARED_LIBADD)

  PHP_EXTENSION(audio, $ext_shared)
fi


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] CVS Account Request: tony

2002-09-22 Thread Tony Leake

To put audio extension into PECL (details at 
http://www.webwise-data.co.uk/php_audio/php_audio_extension.html )

And to develop/maintain that extension. Also to work with DJ Anubis to develop a 
unified audio/multimedia extension.

-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Sound Extension proposed API

2002-09-11 Thread Tony Leake

> Hi,
> 
> Great, sound media systems come to PHP. Wrapping ecasound is a good
idea.
> Maybe I'll try to have XMMS module follow it too ;-)
> Would be nice to have a unified sound wrapper in PHP, say a metaclass
which
> could control other systems (xmms, eca, xine...).
> 
> DJ Anubis

Hi,

A unified wrapper is a great idea, ecasound is a little over the top for
all of the stuff that xmms excels at.

I'm away from friday for just over a week, lets put our heads together
then and see what ideas we can come up with.

Regards
Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Sound Extension proposed API

2002-09-10 Thread Tony Leake



Hi, 

Following my posts last week I have now written up my proposed API for
my sound extension. There is too much to post here so I have made it
available at:
http://www.webwise-data.co.uk/ecasound.html and would welcome any
comments. 

If there are no objections I will apply for a cvs account in a couple of
weeks when I am ready to go alpa with this to place it into PECL.

Regards
Tony Leake 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Sound API for php

2002-09-08 Thread Tony Leake

On Sun, 2002-09-08 at 11:00, Wez Furlong wrote:
> 
> That fits with our naming conventions; however, I think that Andi
> was hoping you would post a little bit info about the parameters
> of the main functions that you expect people to use; something like
> this:
> 
>   bool audio_play_file(string filename);
>   Plays an audio file to the default sound output device
> 
I haven't yet worked out what the parameters will be, I haven't even
worked out what all of the functions will be. The only functions I have
written so far are the ones that wrap the standard ecasound
instructions. Give me a couple of days and I'll post again with a full
proposed api for my first release, params and all, taking into account
yours and Andi's suggestions. 


> I don't think there is a need to make this into two separate extensions
> (it just makes things harder for the end user) - you can link to as many
> libs as you like from your extension.

Ok


> 
> You can use any license you like when your code is in pear/PECL (so long
> as it allows "joe public" to download your code from the php.net server).
> The license incompatibility only affects whether your extension can be
> bundled/distributed with the PHP core. (as was the case with my mailparse
> extension...)
> 
Cool, I have also noted Andi's comment in reply to this, I will contact
the author as I feel that even if it's not required I should do it as a
matter of courtesy.

Regards
Tony



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Sound API for php

2002-09-07 Thread Tony Leake


Andi Gutmans wrote:
> You might want to put this into Pear. In any case, if you want to post
the 
> API just to get people's input (naming conventions of functions and so
on) 
> feel free to post here.
> 
Thanks for the suggestion to put this into Pear. I have subscribed to
the dev list and I'll see what they think :)

Regarding the API, I am planning 3 sets of functions. 

1) Ecasound functions that simply wrap the Ecasound Control Interface. 
I have named these:

eci_init();
eci_command();
eci_error();
etc, I really want to use this naming convention as it is exactly the
same as the interface available in perl, python etc. 

2) Higher level functions for manipulating sound files. These are what I
would expect to be of most interest to others. As I mentioned before
scripting ecasound is tricky so simple functions to play or convert
files would be useful.

I am planning to name these with the audio_ prefix, ie
audio_playfile();
audio_convert_file();
audio_new_chain();

Is this a good idea, I thought of the audio_ prefix to clear up any
confusion with other functions, but it will mean some function names
will be a little long for example, audio_chain_set_position(); is this
too long?

3) will be midi functions,this is a long way off yet so I haven't given
it too much thought yet. Also it is likely to be a separate module as it
will need to link against a separate library and I can't think of any
PHP modules that link against 2 libs.

One last question. I'm sure I read somewhere that the PHP licence is not
compatible with the GPL. Is this true? If so what do I need to do is a
simple agreement from the ecasound maintainer enough or will he need to
release it under the PHP licence as well?

Regards
Tony Leake  


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Sound API for php

2002-09-07 Thread Tony Leake


> For the 'web-side' of things - could these conversion function be
>used,
> to convert files on the webserver? Or even something like:
> song.wav -> convert_to_mp3 -> stream_on_socket
> song.mp3 -> convert_to_windows_media -> stream_on_socket

There's no reason why you couldn't convert files on the webserver, 
it will convert files that it sees on it's local file system. 

Ecasound will not stream over a socket (AFAIK). It's standard out 
is a soundcard via either ALSA or OSS drivers. It's an interesting
point though and the guy who wrote and maintains the library is pretty
good at adding functionality. 

As far as windows media goes, it's not a supported format and I would
guess it never will be.

> 
> And can it read mp3 or whatever 'about' information is stored in the
> audio file?
> 

Ecasound doesn't have this functionality, although this is something I
have thought about and would be looking to implement it at some point. 
I'm sure it can't be that hard to read in the file headers.

If you would like further information about ecasound, you can find it at
http://www.wakkanet.fi/~kaiv/ecasound/welcome.html

regards
Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Sound API for php

2002-09-07 Thread Tony Leake

Hi,

I have started to write an audio api for PHP.

I have written a wrapper to ecasound which is a very powerful
audio processing library that runs on Linux and I believe several
other *NIX's. At the simple end it will play audio files in most
audio formats (wav, mp3, ogg-vorbis, AIFF etc) and convert files
between any supported formats.

At the higher end, ecasound can be used to create a full multi-track
recording/mixing system in just a few lines of code.

Ecasound currently has bindings for c, c++, perl and python so I
decided to address the balance to write PHP bindings. I currently
have this working and am testing it. It will then be possible to
write advanced audio applications in PHP with a Gtk interface.

My next stage will be to write higher level functions for simple
tasks such as playing an MP3 file, as, like most powerful libraries,
the ecasound interface can be cryptic at times.

Further on I plan to write midi functions once I find a suitable
library.

My question is, is there any interest in bundling an audio extension
with PHP. If not then I will run this on sourceforge as a separate
project, but if there is I will publish my proposed api to ensure that
it is compatible with the rest
of PHP.

Regards
Tony Leake



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Patch for bug/feature request 16119

2002-08-27 Thread Tony Leake

Hi, 

I have written a patch for the above feature request to implement an
array_swap function. 

array_swap($array, $key1, $key2), where keys can be either index or
assoc and array content can be any combination of string, long, array
and object. 

This is my first patch and I am hoping to contribute more to php in the
future so if you don't want to use the patch for any reason, I would be
grateful for any pointers or comments on the code. 

Regards 
Tony Leake 



diff -Nur php-4.2.2/ext/standard/array.c php-4.2.2_devel/ext/standard/array.c
--- php-4.2.2/ext/standard/array.c	2002-04-24 16:29:38.0 +0100
+++ php-4.2.2_devel/ext/standard/array.c	2002-08-27 19:09:16.0 +0100
@@ -3366,6 +3366,89 @@
 }
 /* }}} */
 
+
+/* {{{ proto bool  array_swap(array input_array, int index1, int index2)
+   swaps 2 elements in an array */
+PHP_FUNCTION( array_swap )
+{
+	zval *input_arr, *temp_arr;
+	zval **tmp1, **tmp2;
+	zval *key1;
+	zval *key2;
+
+	if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "azz", &input_arr, &key1, &key2 ) !=SUCCESS ){
+		RETURN_FALSE;
+	}
+	
+
+	MAKE_STD_ZVAL( temp_arr );
+	*temp_arr = *input_arr;
+	SEPARATE_ZVAL( &temp_arr );
+	
+if ( Z_TYPE_P(key1)==IS_LONG && Z_TYPE_P(key2)==IS_LONG ){
+		
+		if ( zend_hash_index_find( Z_ARRVAL_P( temp_arr ), Z_LVAL_P( key1 ), (void**)&tmp1 )!=SUCCESS){
+			php_error( E_WARNING, "Key 1 does not exist" );
+			return;
+		}
+		
+		if ( zend_hash_index_find( Z_ARRVAL_P( temp_arr ), Z_LVAL_P( key2 ), (void**)&tmp2 )!=SUCCESS){
+			php_error( E_WARNING, "Key 2 does not exist" );
+			return;
+		}
+		
+		add_index_zval( input_arr, Z_LVAL_P( key1 ), *tmp2 );
+		add_index_zval( input_arr, Z_LVAL_P( key2 ), *tmp1 );
+
+	} else if ( Z_TYPE_P( key1 )==IS_LONG && Z_TYPE_P( key2 )==IS_STRING ){
+		
+		if ( zend_hash_index_find( Z_ARRVAL_P( temp_arr ), Z_LVAL_P( key1 ), (void**)&tmp1 )!=SUCCESS){
+			php_error( E_WARNING, "Key 1 does not exist" );
+			return;
+		}
+		
+		if ( zend_hash_find( Z_ARRVAL_P( temp_arr ), Z_STRVAL_P( key2 ), Z_STRLEN_P( key2 )+1, (void**)&tmp2 )!=SUCCESS){
+			php_error( E_WARNING, "Key 2 does not exist" );
+			return;
+		}
+		
+		add_index_zval( input_arr, Z_LVAL_P( key1 ), *tmp2 );
+		add_assoc_zval( input_arr, Z_STRVAL_P( key2 ), *tmp1);
+
+	} else if ( Z_TYPE_P( key1 )==IS_STRING && Z_TYPE_P( key2 )==IS_LONG){
+		
+		if ( zend_hash_find( Z_ARRVAL_P( temp_arr ), Z_STRVAL_P(key1), Z_STRLEN_P( key1 )+1, (void**)&tmp1 )!=SUCCESS){
+			php_error( E_WARNING, "Key 1 does not exist" );
+			return;
+		}
+		
+		if ( zend_hash_index_find( Z_ARRVAL_P( temp_arr ), Z_LVAL_P( key2 ), (void**)&tmp2 )!=SUCCESS){
+			php_error( E_WARNING, "Key 2 does not exist" );
+			return;
+		}
+		
+		add_assoc_zval( input_arr, Z_STRVAL_P( key1 ), *tmp2);
+		add_index_zval( input_arr, Z_LVAL_P( key2 ), *tmp1 );
+		
+	}else{
+		
+		if ( zend_hash_find( Z_ARRVAL_P( temp_arr ), Z_STRVAL_P( key1 ), Z_STRLEN_P( key1 )+1, (void**)&tmp1 )!=SUCCESS){
+			php_error( E_WARNING, "Key 1 does not exist" );
+			return;
+		}
+		
+		if ( zend_hash_find( Z_ARRVAL_P( temp_arr ), Z_STRVAL_P(key2), Z_STRLEN_P( key2 )+1, (void**)&tmp2 )!=SUCCESS){
+			php_error( E_WARNING, "Key 2 does not exist" );
+			return;
+		}
+		
+		add_assoc_zval( input_arr, Z_STRVAL_P( key1 ), *tmp2);
+		add_assoc_zval( input_arr, Z_STRVAL_P( key2 ), *tmp1);
+	}
+	
+	RETURN_TRUE;
+}
+/* }}} */
 /*
  * Local variables:
  * tab-width: 4
diff -Nur php-4.2.2/ext/standard/basic_functions.c php-4.2.2_devel/ext/standard/basic_functions.c
--- php-4.2.2/ext/standard/basic_functions.c	2002-05-11 20:23:05.0 +0100
+++ php-4.2.2_devel/ext/standard/basic_functions.c	2002-08-27 19:11:34.0 +0100
@@ -793,6 +793,7 @@
 	PHP_FE(array_map,		NULL)
 	PHP_FE(array_chunk,		NULL)
 	PHP_FE(array_key_exists,		NULL)
+	PHP_FE(array_swap,first_arg_force_ref)
 
 	/* aliases from array.c */
 	PHP_FALIAS(pos, current,  first_arg_force_ref)
diff -Nur php-4.2.2/ext/standard/php_array.h php-4.2.2_devel/ext/standard/php_array.h
--- php-4.2.2/ext/standard/php_array.h	2001-12-11 15:30:34.0 +
+++ php-4.2.2_devel/ext/standard/php_array.h	2002-08-27 19:09:39.0 +0100
@@ -81,6 +81,7 @@
 PHP_FUNCTION(array_map);
 PHP_FUNCTION(array_key_exists);
 PHP_FUNCTION(array_chunk);
+PHP_FUNCTION(array_swap);
 
 HashTable* php_splice(HashTable *, int, int, zval ***, int, HashTable **);
 PHPAPI void php_array_merge(HashTable *dest, HashTable *src, int recursive);



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] help with duplicate flag in string functions

2002-07-25 Thread Tony Leake

Hi, 

I'm just starting out writing modules by reading api docs on zend.com
and reading source code of existing modules. 

Several functions (example:) 
add_next_index_string(zval *array, char *str, int duplicate)  

have the int duplicate flag, the docs say,  The flag duplicate specifies
whether the string contents have to be copied to Zend internal memory.

but how do I know if the string should be copied to memory, in the
simple functions I'm writing it seams to make no difference whether I
set this to 1 or 0 but it must do something?

Thanks for your time
Tony


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Bug #14191: Canot compile to '.so' lib for use with Apache 2

2001-11-22 Thread tony

From: [EMAIL PROTECTED]
Operating system: Linux - TurboLinux Server 6.5
PHP version:  4.0.6
PHP Bug Type: Compile Failure
Bug description:  Canot compile to '.so' lib for use with Apache 2

PHP fails to 'make' with apache 2 for use as a '.so' lib.
The configure Script was:

./configure --with-mysql --enable-force-cgi-redirect
--with-apxs2=/usr/local/apache2/bin/apxs

Configuring finished successfully, the make command stops with the
following error message:

-

Making all in apache2filter
make[2]: Entering directory `/tmp/php-4.0.6/sapi/apache2filter'
make[3]: Entering directory `/tmp/php-4.0.6/sapi/apache2filter'
/bin/sh /tmp/php-4.0.6/libtool --silent --mode=compile
gcc  -I. -I/tmp/php-4.0.6/sapi/apache2filter -I/tmp/php-4.0.6/main
-I/tmp/ph
p-4.0.6 -I/usr/local/apache2/include -I/tmp/php-4.0.6/Zend
-I/tmp/php-4.0.6/
ext/mysql/libmysql -I/tmp/php-4.0.6/ext/xml/expat/xmltok
-I/tmp/php-4.0.6/ex
t/xml/expat/xmlparse -I/tmp/php-4.0.6/TSRM  -D_REENTRANT -DSUPPORT_UTF8
-DXM
L_BYTE_ORDER=12 -I../TSRM -DTHREAD=1 -g -O2 -pthread  -c sapi_apache2.c
sapi_apache2.c: In function `php_input_filter':
sapi_apache2.c:248: warning: passing arg 4 of `ap_get_brigade' from
incompatible pointer type
sapi_apache2.c: In function `php_output_filter':
sapi_apache2.c:337: too few arguments to function `ap_save_brigade'
sapi_apache2.c: In function `php_register_hook':
sapi_apache2.c:443: warning: passing arg 2 of `ap_register_input_filter'
from incompatible pointer type
make[3]: *** [sapi_apache2.lo] Error 1
make[3]: Leaving directory `/tmp/php-4.0.6/sapi/apache2filter'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/tmp/php-4.0.6/sapi/apache2filter'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/php-4.0.6/sapi'
make: *** [all-recursive] Error 1

-

-- 
Edit bug report at: http://bugs.php.net/?id=14191&edit=1


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]