[PHP-DEV] Re: [Zend Engine 2] FYI: PHP/threads

2003-03-05 Thread Alan Knowles
Timm Friebe wrote:

I've been playing around with the (not new) idea of introducing threads
into PHP userland (maybe something to think about havin in PHP6?). What
came out of it is available at [1], offering an object oriented API (in
comparison to PECL/threads [2]).
 

-one of the reasons to not try object stuff initially (although it was 
in the todo) was to try and find out the issues :) - more below

Maybe someone here would like to pick up on this idea or give some
directions to what would have to be done to make this actually work
dependably. I'm experiencing the same issues as with PECL/threads -
variable "confusion" (local function arguments with same names in two
threads affect each other), Engine unstability (Warning: ... in ... on
line -18182899), but could get a couple of samples[3] to work quite
well.
Maybe the userland API could be adopted by PECL/threads? Is anyone still
working at this or was development given up?
not totally given up.. - but it's kind of a low priority unfortunatly 
(as it would be very nice)

To try and go through some of the issues with threads:
http://talks.php.net/show/kongress-gtk-future-2002/14
gives a few clues...
the reality is that all the zend_ctor... methods etc. are thread safe 
(assuming you compiled with the experimental zts flag) - this however 
introduces lots of problems when working with threads as the zend engine 
will allocate memory to the wrong thread, and hence try and free it when 
that thread closes.

what you demonstrated was the idea of copying the object instance from 
one thread to another (unfortunatly you also have to copy the object 
definition - eg. the opcodes) to make it work.. - whats worse is that 
you have to create memory that the engine doesnt know about.. - and then 
pass it too the new instance.. and tell the new instance that it is now 
incharge of that memory..

the idea of a thread_include() function was that it would be a starting 
point which would be idiot proof from the user (and less complex from 
the coding side..) - and would not involve the complexity of opcode 
replications (which would have to use something like the code in 
bcompiler..)

Hope this doesnt put you off.. - as I would still love to see it in PHPx 
somewhere :)

I guess the other issue was to try and ensure it was cross platform (as 
in reality most of those gtk apps are going to have to run on windows).. 
- so Shane did an amazing amount of work building the cross platform 
library..

Regards
Alan




1] http://sitten-polizei.de/php/threads-0.1alpha.tar.gz
2] http://cvs.php.net/cvs.php/pear/PECL/threads
3] http://sitten-polizei.de/php/threads/tests/?file=mythread.php
  http://sitten-polizei.de/php/threads/tests/?file=timer.php
  http://sitten-polizei.de/php/threads/tests/?file=simple.php
  http://sitten-polizei.de/php/threads/tests/?file=calendar.php
  etc.
- Timm
 

 


--
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com



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


Re: [PHP-DEV] parser generator for php

2003-02-26 Thread Alan Knowles
Pete James wrote:

I hope that this is not the wrong venue for this.

I've seen references to questions about this before, but is there any
tool similar to yacc, written in php?
It's not written in PHP - but it generates PHP code
have a look at http://php-sharp.sourceforge.net
In CVS is
phpLex a derivative of csLex (requires mono/.net runtime)
phpJay a derivative of Jay (a bison type grammer parser)
There are a few examples in the PHPSharp folder. look for .lex & .jay files.

phpLex is a bit better tested as I've been using it on 
HTML_Template_Flexy as well..

Regards
Alan

I know that there is the tokenizer ext., which forms one half of the
equation.  Perl, Python, etc, have their YAPP, and YAPPS tools.  Is
something similar in the works for PHP?
Thanks,
Pete.
 



--
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com



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


Re: [PHP-DEV] Mono & PHP

2003-02-03 Thread Alan Knowles
I'm having fun with it :)
/usr/src/php/php5/ext/sockets/php_sockets.h:89: conflicting types for 
`SOCKET'
/usr/include/mono/io-layer/uglify.h:38: previous declaration of `SOCKET'

also had a bit of trouble with mono's exception.h including config.h 
(which wasnt installed into the bulid stuff)

(hacked mono's header for the time being)

not sure if that's an old version of mono though..

Regards
Alan

Sterling Hughes wrote:

I spent a little time this weekend implementing an extension that allows
PHP to load .NET classes on the Unix environment - 100% open source, by
leveraging the mono library(*).  For more information, view the README
file in the distribution by downloading the file
http://www.edwardbear.org/php_mono_0_1.tar.gz.

Its PHP5 only, as that's what I've switched to for all new development.
Hi Ho.


$Console = new Mono('System.Console');
$Console->WriteLine('Hello World, PHP is .NET ready!');
?>

- Sterling "No More Extensions Needed" Hughes

(*) Mono is much more than library, of course.  But it links to/uses the
mono library.

PS:  I'll be adding it into PECL in a little bit, I want to finish the
type proxying code.  I'd also like to add all of the object and method
caching.

PPS: If anyone has suggestions for a better way of doing type proxying
than what's described in the README, please let me know.

 



--
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com



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



Re: [PHP-DEV] Reducing the number of system calls for includes

2003-01-24 Thread Alan Knowles
Apart from tidying up the include stuff.. - for this specific case, is 
it worth cosidering precompiling all the files into a single bytecode 
file?, thats what bcompiler ends up doing for classes.. etc. then 
manually indicate that you want to recompile the bundle, I'm guessing 
the actual PHP code doesnt change that much.. - (although bcompiler 
doesnt handle staightline PHP it might help on the classes..)...

Regards
Alan



Rasmus Lerdorf wrote:

Eliminating realpath for fully qualified paths make sense to me.

But...  don't you Y! guys use php-a?  Shouldn't this hide that overhead 
completely from you by completely eliminating all the stats on a 
require/include after the initial compilation?  Or is this just a 
   

It doesn't eliminate it at all, no.  These checks are still done even on 
accelerated includes in both zend cache and ioncube.

-Rasmus


 



--
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com



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



Re: [PHP-DEV] $this scope (was T_PAAMAYIM_NEKUDOTAYIM)

2002-12-16 Thread Alan Knowles
It would be usefull to have a direction on this, - It's come up a number 
of times in bug reports.

It has a number of uses (primarily breaking large classes up, into 
smaller components..), and a clearer way to write code than using a huge 
inheritance tree.. - It may not be correct OO code, by the book, but it 
is usefull in certian situations.

It can be regarded as a feature, but if it is going to change at some 
point in the future, it's better to make that very clear now, rather 
than get a big backlash when we change it, and more people have worked 
out this little trick (and start to rely on it...)

Technically I guess overload is the real way it should be done in ZE2.

Regards
Alan



Brad LaFountain wrote:

--- Bertrand Mansion <[EMAIL PROTECTED]> wrote:
 

<[EMAIL PROTECTED]> wrote :

   

--- Bertrand Mansion <[EMAIL PROTECTED]> wrote:
 

<[EMAIL PROTECTED]> wrote?:

   

$classname::method() === call_user_func(array($classname,'method'));
 

No. $classname::method() is illegal and is in no case === to
call_user_func(array($classname,'method')) as you state it.

Class foo {
   function bar() {
   echo $this->param;
   }
}

Class MyObject {
   var $param;
   function MyObject($param) {
   $this->param = $param;
   foo::bar();
   }
}

$obj = new MyObject('out of this');

will print 'from MyObject'.
   

This SHOULDN'T print 'out of this', This seems like a bug, and you
 

SHOULDN'T
   

depend on this functionality. The scope of $this inside class foo method
 

bar,
   

Should be to foo::bar NOT MyObject::MyObject. Which if my memory serves me
right $this inside a static method will just be the string of the current
class?
 

Hi Brad,

Are you sure about that ? The manual states that this is the normal
behaviour which I find very handy and useful in many cases. I see a lot of
possibilities with this feature, for instance a way to develop some kind of
plug-ins for existing classes without having to extend them.
   


Where in the manual do you see this? 

 

This can probably lead to some dangerous code but this goes far beyond my
knowledge.
   


besides dangerous code if you find yourself doing this, you probally aren't
designing it correct. Your creating a static method of a class to access local
properties of another class thru the use of $this. If you want a way to access
member variables from a class in a static method, pass the object refrence into
the method.

Class foo {
function bar($obj) {
echo $obj->param;
/* $this should referr to the foo refrence, not another class refrence
*/
}
}

Class MyObject {
var $param;
function MyObject($param) {
$this->param = $param;
foo::bar($this);
   }
}

- Brad



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 



--
Can you help out? 
Need Consulting Services or Know of a Job?
http://www.akbkhome.com



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



[PHP-DEV] PHP# - feasibility study so far - for comment

2002-12-15 Thread Alan Knowles
I've just put up a short description of the current state of the 
research on the feasibility on PHP#, developing a .net CIL bytecode 
compiler for PHP. If anyone wants to add 'constructive comments' to it, 
please fire away..

http://www.akbkhome.com/Projects/PHP_Sharp

(you'll have to click through the advert first)

Regards
Alan




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



Re: [PHP-DEV] pecl extensions

2002-12-02 Thread Alan Knowles
Brad LaFountain wrote:


I know I'm going to piss people off by asking this but how do I create a new
pecl package? I think I want going to put php_opengl in there. See if gets
anymore use.



upload it to pear/PECL/opengl.. (You should have karma for that already)

you nead a pear account re: the web site for uploading releases.
http://pear.php.net/?devme=
and then refresh the page.
I think you have to apply for an account on the pear page - (If it 
messes up cause you've already got a CVS account just report it here and 
somebody will fix it:)

after that just set up a package.xml file as per the other PECL folders 
and do
pear package
then upload the resulting file-rev.tar.gz

Regards
Alan
P.S. Hows the SOAP going :)




- Brad

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 




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




Re: [PHP-DEV] Compile error in tokenizer ext with ZE2 4.3 branch

2002-12-01 Thread Alan Knowles
Andi fixed it in CVS, try checking out downloading tokenizer.c again.

Magnus Määttä wrote:


From 4.3 branch with ZE2 i get this compile error:


/bin/sh /opt/DEV/php/php430/php4/libtool --mode=compile gcc  -Iext/tokenizer/ -I/opt/DEV/php/php430/php4/ext/tokenizer/ -DPHP_ATOM_INC -I/opt/DEV/php/php430/php4/include -I/opt/DEV/php/php430/php4/main -I/opt/DEV/php/php430/php4 -I/usr/local/www/httpd2prefork/include -I/opt/DEV/php/php430/php4/Zend -I/usr/include/libxml2 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr//include/mysql -I/usr/include/pspell -I/usr/qt/3/include -I/usr//include  -I/opt/DEV/php/php430/php4/TSRM  -g -Wall  -prefer-pic -c /opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c -o ext/tokenizer/tokenizer.lo
gcc -Iext/tokenizer/ -I/opt/DEV/php/php430/php4/ext/tokenizer/ -DPHP_ATOM_INC -I/opt/DEV/php/php430/php4/include -I/opt/DEV/php/php430/php4/main -I/opt/DEV/php/php430/php4 -I/usr/local/www/httpd2prefork/include -I/opt/DEV/php/php430/php4/Zend -I/usr/include/libxml2 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr//include/mysql -I/usr/include/pspell -I/usr/qt/3/include -I/usr//include -I/opt/DEV/php/php430/php4/TSRM -g -Wall -c /opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c  -fPIC -DPIC -o ext/tokenizer/tokenizer.lo
cpp0: warning: changing search order for system directory "/usr/include"
cpp0: warning:   as it has already been specified as a non-system directory
/opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c: In function `zm_startup_tokenizer':
/opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c:239: `T_OLD_FUNCTION' undeclared (first use in this function)
/opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c:239: (Each undeclared identifier is reported only once
/opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c:239: for each function it appears in.)
/opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c: In function `get_token_type_name':
/opt/DEV/php/php430/php4/ext/tokenizer/tokenizer.c:437: `T_OLD_FUNCTION' undeclared (first use in this function)
make: *** [ext/tokenizer/tokenizer.lo] Error 1


/ Magnus

 




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




Re: [PHP-DEV] is_*

2002-11-13 Thread Alan Knowles
have a look at the validate package in pear.
Regards
Alan





|-Original Message-
|From: [EMAIL PROTECTED] [mailto:nicos@;php.net] 
|Sent: Wednesday, November 13, 2002 9:46 PM
|To: [EMAIL PROTECTED]
|Subject: [PHP-DEV] is_*
|
|
|Hello,
|
|After having helped many users, I just thought of new 
|functions like is_alpha, is_alnum, is_valid_email() that we 
|should make so the new user can do valid form with good 
|verification without knowing how ereg() or preg_* work. We 
|should think about some another functions too...
|
|Any comment?
|
|P.S: they would be based on the same verification than ereg 
|[[:alnum:]] etc..
|
|Regards.
|
|M.CHAILLAN Nicolas
|[EMAIL PROTECTED]
|www.WorldAKT.com Hébergement de sites internets.
|
|
|
|
|-- 
|PHP Development Mailing List 
|To unsubscribe, visit: http://www.php.net/unsub.php
|
|


 




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




Re: [PHP-DEV] prototypes for getters and setters.

2002-11-13 Thread Alan Knowles
Actually looking at this in more detail, the solution PHP has infers 
that using $object->XXX='somevar' is heavily prefered over 
getXXX()/setXXX(), kind of against the grain for a classic OOP language 
(from the impressions have read), As refactoring (which is often the 
logic cited for setXXX()/getXXX() ) is handled by __getXXX() / __setXXX()

Obviously $object->XXX is going to be faster than $object->getXXX(), 
Would you say that the language design inherintly suggests you use 
$object->XXX.  (and basically forget about getXXX() methods?)

Or can any think if there any other reasons why $object->XXX = 'yyy' is 
normally disuaded in classic OO design.. (and I'm not talking about 
private variables :)

Regards
Alan



Andrei Zmievski wrote:

On Wed, 13 Nov 2002, John Coggeshall wrote:
 

I understand what your saying, however I guess I see the tradeoff of
creating a new reserved word to a (IMHO of course) kinda messy new
syntax a good one. 

Besides, having an absolute standard for get/set would be benefital to
all developers.. Knowing that setting $foo is always setfoo() (or
set_foo(), makes no difference) would be nice. 
   


We do have an absolute standard: __get() and __set().

-Andrei   http://www.gravitonic.com/
* I wish life had an UNDO function. *

 




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




Re: [PHP-DEV] prototypes for getters and setters.

2002-11-12 Thread Alan Knowles
the trouble is that you will make pubvar a reserved word, and you force 
the user to use a fixed standard for set/get -- eg. some users may like 
get_orange, others may want getOrange
It also makes the assumtion that the user knows how the syntax works.. - 
eg. searching the file for  getOrange would return nothing...

Regards
Alan

John Coggeshall wrote:

What about something like this...

Class foo {
	
	var $myfoo; 	// "Private" variable
	pubvar $myfoo2;	// "Public" variable


}

Class bar extends foo {

	pubvar $mystuff;

}

$a = new foo();
$a->setmyfoo2(5);
echo $a->getmyfoo2();

$b = new bar();
$b->setmyfoo2(10);
$b->setmystuff(20);

The point here is that pubvar automatically creates get* and set*.. As
far as overloading, etc is concerned, there would be no need to worry
about it -- the point of these functions is not to overload them (they
should simply be used to get and set member variables)... 

John

|-Original Message-
|From: Shane Caraveo [mailto:shane@;caraveo.com] 
|Sent: Tuesday, November 12, 2002 10:04 PM
|To: Alan Knowles
|Cc: [EMAIL PROTECTED]
|Subject: Re: [PHP-DEV] prototypes for getters and setters.
|
|
|Alan Knowles wrote:
|
|> Shane Caraveo wrote:
|>
|> >>
|> >>
|> >> Anyway before I get carried away and actually test this :) -
|> anybody got
|> >> any thoughts.
|> >>
|> >> Regards
|> >> Alan
|> >
|> >
|> >
|> >
|> > What's wrong with how overload does this?
|>
|>
|> it has a slight downside in clarity of code - eg. where is that 
|> method..
|>
|But it (overload) also does not introduce new syntax, requires no 
|changes to the engine, is genericly overrideable in extensions, etc. 
|etc. etc.
|
|Shane
|
|
|-- 
|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] prototypes for getters and setters.

2002-11-12 Thread Alan Knowles
Shane Caraveo wrote:




Anyway before I get carried away and actually test this :) - anybody got
any thoughts.

Regards
Alan




What's wrong with how overload does this? 

it has a slight downside in clarity of code - eg. where is that method.. 



SHane





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




[PHP-DEV] prototypes for getters and setters.

2002-11-12 Thread Alan Knowles
Thanks to a little chat (and a  few beers) with Zak at the conference, I 
got wondering if this syntax would be a sensible addition...

The principle is to enable rapid prototyping of getter and setter 
methods.

class something {
   var getBanana setBanana $banana = 12;
   var getOrange $orange =1;
   function setOrange($value) {
   if ($value == $this->banana) {
   echo "mmh banana's and oranges are the same";  
   }
   }
}
$t = new something;
echo $t->getBanana();
echo $t->setBanana(3);
echo $t->setOrange(3);

syntax:
  var [getter method] [setter method] $variable .;

or any other ideas
  var (getBanana, setBanana) $banana

  function var getBanana, setBanana for  $banana = '12'; // nice bit of 
token recycling.

  var use getBanana and setBanana for $banana = '12';


from a quick play with zend_language_parser.y the additionall code to

class_variable_decleration:

would look a bit like this...


| is_reference T_STRING T_VARIABLE  '=' static_scalar{
   znode tmp;
   znode tmpthis; 
   znode tmpfinalval;

   zend_copy_value(tmpthis, 'this', 5);
   tmpthis->type = IS_STRING;

   zend_do_declare_property(&$3, &$6 TSRMLS_CC);
   function.u.opline_num = CG(zend_lineno);
   zend_do_begin_function_declaration(&function, &$3, 1, 
$2.op_type TSRMLS_CC); }
  
   # get the 'this' part..
   zend_do_fetch_globals(&tmpthis TSRMLS_CC);
   zend_do_begin_variable_parse(TSRMLS_C);
   fetch_simple_variable(&tmp, &tmpthis, 1 TSRMLS_CC);

   zend_do_fetch_property(&tmpfinalval, &tmp, &$6 TSRMLS_CC);}

zend_do_return(&tmpfinalval, 1 TSRMLS_CC);
   zend_do_end_function_declaration(&$1 TSRMLS_CC);
  
   }

Anyway before I get carried away and actually test this :) - anybody got 
any thoughts.

Regards
Alan


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



Re: [PHP-DEV] Karma for php4 and bcompiler

2002-10-29 Thread Alan Knowles
Ernani helped out with bcompiler - so karma on that is ok.

I think for php4 you will have to send patches to php-dev for the time 
being.  until they get used to you :)

Regards
Alan

Ernani Joppert Pontes Martins wrote:

Hi there, with not so much time to dedicate to php improvements and bug
fixes I want to have karma to help fix some bugs/improvements into php and
into bcompiler for win32 that is my speciallity.

I've already did a compile with windows but now I need to add some more
functionalities.

Alan Knowles already said to me to keep in touch.

Thanks,

Ernani



 





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




Re: [PHP-DEV] I hope this is the last email about this :) (was RFC:CLI behave like SH or PERL/RUBY/PYTHON?)

2002-10-23 Thread Alan Knowles
Im +1 for reverting the patch - (for what it's worth)

Why?
Well - most 'average' (and below) PHP programmers when attempting to do 
CLI programming, will get a serious WTF reaction from wondering why when 
they 'echo' stuff, it doesnt appear. The more advanced Users can 
manually turn off flushing, but for most small, quick scripts (eg. 
50%+), this instant flush is going to be perfectly acceptable..

Anyway Just my 2c
Regards
Alan

It's a very _bad_ default. Fortunately, it's not released yet.
That's why I'm against it strongly.

IMO, flushing on every output by default is stupid setting.
If you ever programmed interactive programs, you should know
that unless you're ignorant about efficiency.

I guess my questions are too hard to be understood by you
compare to the last one. Derick, it seems you're alone so far.

http://news.php.net/article.php?group=php.dev&article=89995

Do you finally realize your argument actually did not make sense?
(Unless you need stupid PHP/CLI shell that requires start/end tag
to do anything, of course ;)

I'm going to fix it again unless many people want to make
PHP/CLI behave like a shell rather than programming language.

Alternatively, could you fix it again? (including Makefile.global)
Thank you and I hope this is the last mail about this.

PS: If you would like to write INI independent scripts, I
suggest you to use php.ini-recommended at least. You don't/
didn't know phps crashing and make test does not work well with
php.ini-recommended, nonetheless, you're insisting there is no
problems.

--
Yasuo Ohgaki







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




Re: [PHP-DEV] Re: RFC: CLI behave like SH or PERL/RUBY/PYTHON?

2002-10-22 Thread Alan Knowles
To try and clarify...
(B
(B#!/usr/bin/php -q
(B
(B
(BWould this be affected by the change? - eg. would you need to flush();
(Bbefore the prompt appeared?
(B
(BRegards
(BAlan
(B
(B
(B
(BYasuo Ohgaki wrote:
(B
(B>BTW, this is 2nd time
(B>
(B>http://marc.theaimsgroup.com/?l=php-dev&m=103525481227249&w=2
(B>
(B>Yasuo Ohgaki wrote:
(B>  
(B>
(B>>I thought it's obvious choice, but it seems it's not.
(B>>
(B>>Which one you prefer CLI behave like
(B>>
(B>>SH
(B>>
(B>>or
(B>>
(B>>PERL/RUBY/PYTHON
(B>>
(B>>--
(B>>Yasuo Ohgaki
(B>>
(B>>
(B>>
(B>
(B>
(B>
(B>  
(B>
(B
(B
(B
(B
(B-- 
(BPHP Development Mailing List 
(BTo unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Work is beginning on cURL and PHP again

2002-10-21 Thread Alan Knowles
Non blocking connections would be nice...

- On the generating stuff - why do you want to generate the code on the 
users system? -
all the re2c stuff in CVS is 'pre-genereated'

It would be nice to have extension generator that could be built upon, 
that didnt involve re-reading all those perl/awk manuals, just to add 
features to it. :)
Any idea if  finding 'generic' bits in the php-gtk generator is possible?

Regards
Alan


Sterling Hughes wrote:

Hi,

I'm going to be working on updating the PHP cURL extension in the coming
weeks: 

* adding the multi-interface. 
* ssl session id caching (globally) 
* global dns cache in threaded webservers (same for ssl sesssion id
caching)
* allowing cURL handle re-use.
* allowing "persistent" cURL handles that survive the request, for HTTP
1.1 persistent connections
* Autogenerating much of the interface between cURL and PHP, allowing
PHP to support multiple versions of the underlying cURL library
* Supporting all cURL options/callbacks in one way or another
* Adding a OOP interface to cURL, on the extension level... [undecided]
* Updating the cURL documentation

So, I'm sending this message, to the lists just to get any suggestions,
comments, feature requests, bug reports that you would like me to look
at/consider when revamping the extension.  The changes will be done step
by step to the extension, but the full revamping should be expected
around the time of PHP 5 (PHP 4.3 is too soon for all these changes to
be integrated and tested).

-Sterling

PS: I'll be at the PHP Conference in Frankfurt, and ApacheCon in Las
Vegas, if you're coming to either of those, feel free to talk about it
with me there as well...

 




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




[PHP-DEV] zip extension fixes (cause it's totally borked :)

2002-10-16 Thread Alan Knowles

attached fixes should enable the zip extension to a) build, b) build as 
a module
want to give me Karma (or patch it in)


Regards
Alan


? .libs
? Makefile
? Makefile.fragments
? Makefile.global
? Makefile.objects
? acinclude.m4
? aclocal.m4
? autom4te.cache
? build
? config.cache
? config.guess
? config.h
? config.h.in
? config.log
? config.nice
? config.status
? config.sub
? configure
? configure.in
? include
? install-sh
? libtool
? ltmain.sh
? missing
? mkinstalldirs
? modules
? scan_makefile_in.awk
? zipfix.diff
Index: config.m4
===
RCS file: /repository/php4/ext/zip/config.m4,v
retrieving revision 1.4
diff -u -r1.4 config.m4
--- config.m4   12 Mar 2002 16:39:16 -  1.4
+++ config.m4   17 Oct 2002 04:20:04 -
@@ -6,8 +6,7 @@
 [  --with-zip[=DIR]Include ZIP support (requires zziplib >= 0.10.6).])
 
 if test "$PHP_ZIP" != "no"; then
-  PHP_NEW_EXTENSION(zip, zip.c, $ext_shared)
-  for i in $PHP_ZIP /usr/local /usr ; do
+   for i in $PHP_ZIP /usr/local /usr ; do
 if test -f $i/include/zzlib/zziplib.h; then
   ZZIPLIB_DIR=$i
   ZZIPLIB_INCDIR=$i/include/zzlib
@@ -23,15 +22,13 @@
 
   ZZIPLIB_LIBDIR=$ZZIPLIB_DIR/lib
 
-  PHP_TEMP_LDFLAGS(-L$ZZIPLIB_LIBDIR,[
-  AC_CHECK_LIB(zzip, zzip_open, [AC_DEFINE(HAVE_ZZIPLIB,1,[ ])],
-[AC_MSG_ERROR(zziplib module requires zzlib >= 0.10.6.)])
-  ])
+
+  PHP_ADD_INCLUDE($ZZIPLIB_INCDIR)
 
   PHP_SUBST(ZIP_SHARED_LIBADD)
   PHP_ADD_LIBRARY_WITH_PATH(zzip, $ZZIPLIB_LIBDIR, ZIP_SHARED_LIBADD)
-  
-  PHP_ADD_INCLUDE($ZZIPLIB_INCDIR)
+  AC_CHECK_LIB(zzip, zzip_open, [AC_DEFINE(HAVE_ZZIPLIB,1,[ ])], 
+[AC_MSG_ERROR(zziplib module requires zzlib >= 0.10.6.)],)
 
-  PHP_FOPENCOOKIE
+  PHP_NEW_EXTENSION(zip, zip.c, $ext_shared)
+  
 fi
Index: php_zip.h
===
RCS file: /repository/php4/ext/zip/php_zip.h,v
retrieving revision 1.7
diff -u -r1.7 php_zip.h
--- php_zip.h   11 May 2002 02:12:44 -  1.7
+++ php_zip.h   17 Oct 2002 04:20:05 -
@@ -27,15 +27,23 @@
 #define phpext_zip_ptr &zip_module_entry
 
 #define PHP_ZZIPLIB_API
+
+
 #ifdef PHP_WIN32
+
 #undef PHP_ZZIPLIB_API
 #ifdef ZIP_EXPORTS
 #define PHP_ZZIPLIB_API __declspec(dllexport)
 #else
 #define PHP_ZZIPLIB_API __declspec(dllimport)
 #endif
+
 #endif
 
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+ 
 PHP_MINIT_FUNCTION(zip);
 PHP_MINFO_FUNCTION(zip);
 
@@ -59,7 +67,7 @@
 #define phpext_zziplib_ptr NULL
 #endif
 
-#endif /* PHP_ZZIPLIB_H */
+#endif /* PHP_ZLIB_H */
 
 
 /*
Index: zip.c
===
RCS file: /repository/php4/ext/zip/zip.c,v
retrieving revision 1.32
diff -u -r1.32 zip.c
--- zip.c   20 May 2002 18:33:08 -  1.32
+++ zip.c   17 Oct 2002 04:20:05 -
@@ -17,11 +17,13 @@
  */
 
 /* $Id: zip.c,v 1.32 2002/05/20 18:33:08 mfischer Exp $ */
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif 
 #include "php.h"
 #include "php_ini.h"
 #include "php_zip.h"
-
+  
 #if HAVE_ZZIPLIB
 
 #include "ext/standard/info.h"
@@ -56,15 +58,15 @@
 /* {{{ zip_module_entry
  */
 zend_module_entry zip_module_entry = {
-STANDARD_MODULE_HEADER,
+   STANDARD_MODULE_HEADER,
"zip",
zip_functions,
PHP_MINIT(zip),
NULL,
NULL,
-   NULL,
+   NULL, 
PHP_MINFO(zip),
-NO_VERSION_YET,
+   NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
 };
 /* }}} */



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


Re: [PHP-DEV] zend_compile.h patch

2002-10-16 Thread Alan Knowles

Edin Kadribasic wrote:

>I get linking errors when I tried to compile it on windows. The
>error was that zend_do_inheritance symbol was not found. Are you
>saying that this call is not needed? Could it be removed then?
>  
>
At them moment, you can comment out the bcompiler_inherit call (it's 
never used) = however it will need including eventually...

zce->parent always evaluates to NULL...


>Edin
>
>
>----- Original Message -
>From: "Alan Knowles" <[EMAIL PROTECTED]>
>To: "Edin Kadribasic" <[EMAIL PROTECTED]>
>Cc: "Zeev Suraski" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
>Sent: Wednesday, October 16, 2002 4:03 PM
>Subject: Re: [PHP-DEV] zend_compile.h patch
>
>
>  
>
>>Edin Kadribasic wrote:
>>
>>
>>
>>>Any objections to exporting another function from zend_compile.h
>>>  
>>>
>by
>  
>
>>>applying this patch? I need this in order to compile
>>>pear/PECL/bcompiler on Windows.
>>>
>>>Edin
>>>
>>>  
>>>
>>actually it's not needed 'at present' cause the compiled bytecodes
>>
>>
>do
>  
>
>>not use inheritance (as the compiled bytecode includes the
>>
>>
>'merged' view
>  
>
>>of the class'..,however - if and when I get round to writing
>>
>>
>conditional
>  
>
>>method/var class compiling, it will be needed..
>>
>>Regards
>>Alan
>>
>>
>>
>>>  
>>>
>>---
>>
>>
>-
>  
>
>>>Index: zend_compile.h
>>>  
>>>
>>===
>>
>>
>>>RCS file: /repository/Zend/zend_compile.h,v
>>>retrieving revision 1.144
>>>diff -u -r1.144 zend_compile.h
>>>--- zend_compile.h 4 Aug 2002 06:39:44 - 1.144
>>>+++ zend_compile.h 16 Oct 2002 13:35:35 -
>>>@@ -273,7 +273,7 @@
>>>void zend_do_end_function_call(znode *function_name, znode
>>>  
>>>
>*result, znode *argument_list, int is_method, int is_dynamic_fcall
>TSRMLS_DC);
>  
>
>>>void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
>>>ZEND_API int do_bind_function_or_class(zend_op *opline,
>>>  
>>>
>HashTable *function_table, HashTable *class_table, int
>compile_time);
>  
>
>>>-void zend_do_inheritance(zend_class_entry *ce, zend_class_entry
>>>  
>>>
>*parent_ce);
>  
>
>>>+ZEND_API void zend_do_inheritance(zend_class_entry *ce,
>>>  
>>>
>zend_class_entry *parent_ce);
>  
>
>>>void zend_do_early_binding(TSRMLS_D);
>>>
>>>void zend_do_pass_param(znode *param, int op, int offset
>>>  
>>>
>TSRMLS_DC);
>  
>
>>>
>>>  
>>>
>>
>>
>>
>>
>
>  
>



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




Re: [PHP-DEV] zend_compile.h patch

2002-10-16 Thread Alan Knowles

Edin Kadribasic wrote:

>Any objections to exporting another function from zend_compile.h by
>applying this patch? I need this in order to compile
>pear/PECL/bcompiler on Windows.
>
>Edin
>
actually it's not needed 'at present' cause the compiled bytecodes do 
not use inheritance (as the compiled bytecode includes the 'merged' view 
of the class'..,however - if and when I get round to writing conditional 
method/var class compiling, it will be needed..

Regards
Alan

>  
>
>
>
>Index: zend_compile.h
>===
>RCS file: /repository/Zend/zend_compile.h,v
>retrieving revision 1.144
>diff -u -r1.144 zend_compile.h
>--- zend_compile.h 4 Aug 2002 06:39:44 -   1.144
>+++ zend_compile.h 16 Oct 2002 13:35:35 -
>@@ -273,7 +273,7 @@
> void zend_do_end_function_call(znode *function_name, znode *result, znode 
>*argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC);
> void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
> ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, 
>HashTable *class_table, int compile_time);
>-void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
>+ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
> void zend_do_early_binding(TSRMLS_D);
> 
> void zend_do_pass_param(znode *param, int op, int offset TSRMLS_DC);
>
>  
>



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




Re: [PHP-DEV] Bug handling survey - Tree based models

2002-10-09 Thread Alan Knowles

Jan Lehnardt wrote:

>Hi,
>On Wed, Oct 09, 2002 at 09:38:46AM -0500, Gunes Koru wrote:
>  
>
>>Hello PHP contributors,
>>
>>
>didn't we agree not to do that again?
>
Well he did shorten his signature - so we are getting somewhere - slowly :)

>
>Jan
>  
>



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




Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /main output.c

2002-10-02 Thread Alan Knowles

Yasuo Ohgaki wrote:

> Sebastian Bergmann wrote:
>
>> Yasuo Ohgaki wrote:
>>
>>> yohgaki Mon Sep 30 22:43:33 2002 EDT
>>>
>>>  Modified files:
>>>/php4/main  output.c
>>>  Log:
>>>  Fixed implicit flush.
>>
>>
>>
>>   This commit broke my script, that I mentioned before, again. It now
>>   dumps the contents of a variable to stdout instead of writing it to a
>>   file.
>>
>
> A little history. When 4.1.0 (or 4.2.0?) is released, I've fixed
> crush with deleting wrong buffer with implicit flush. The fix
> disabled implicit flush.
>
> I finally fixed implicit flush. Users should worry about
> implicit flush directive in php.ini now. e.g. implicit_flush=Off
> for normal use.
>
> Apparently, CLI SAPI implicitly enable implicit flush at
> initialization no matter what the php.ini setting is. CLI behavior
> is wrong, since there is no way to change implicit flush directive
> once script is started. I notified this to Edin and he would address
> this issue soon hopefully. 

Is it worth adding a note to the output control page
http://www.php.net/manual/en/ref.outcontrol.php and/or ob_start to say
"Note: When upgrading from PHP 4.1 (& 4.2) to 4.3 that due to a bug in 
earlier versions you must ensure that implict_flush is OFF in your 
php.ini, otherwise any output withing ob_start, will be not be hidden 
from output"

or something similar?
(at least it will be documented, even if nobody reads it :)

Regards
Alan

>
>
> -- 
> Yasuo Ohgaki
>
>




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




Re: [PHP-DEV] php/embed

2002-09-29 Thread Alan Knowles

Going on a 'semi-consistant' naming structure on unix, would 
libphp.so.4.3.0 (softlinked to libphp.so) be an idea.

this should be really good when working with bcompiler_load_exe() :)

Regards
Alan

Edin Kadribasic wrote:

>On Sunday 29 September 2002 11:45, [EMAIL PROTECTED] wrote:
>  
>
>>On Sun, 29 Sep 2002, Edin Kadribasic wrote:
>>
>>
>>>I have just committed initial work on enabling embedding PHP into C/C++
>>>applications. It is mostly complete, but there a few pieces missing,
>>>namely the installation part. The modification of the build system adds
>>>another target, so in order to test the new functionality you need to
>>>configure php in the usual manner, and then do "make", "make install" and
>>>"make libs". Since libs are not installed by "make install" you need to
>>>copy libphp.so manually to appropriate directory.
>>>  
>>>
>>What about a libphp.a? :)
>>
>>
>
>Forgot to mention it, but that one is built as well. Beware, linking the PHP 
>engine staticly will increase your C app binary size by at least 2 MB.
>
>Edin
>
>  
>



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




Re: [PHP-DEV] Apache 1.3, PHP and TSRM question

2002-09-28 Thread Alan Knowles

Are you dl('')'ing and modules,  - I think Zeev pointed me to a known 
bug with this if you have a memory leak from a dl'ed module it will 
crash on this type of debugging code (I think the filename gets freed 
when you unload the module at shutdown, and hence filename points to an 
out of bounds area)
Regards
Alan

Ramesh Shankar wrote:

> I am trying to port PHP and I am running into a problem with Apache 
> 1.3. I am not familiar with the PHP language by itself and I am used 
> to working at the O.S. level and so any help would be greatly 
> appreciated. I tried to read through mailing list archives, the 
> readmes, FAQs etc, but I couldn't find answer for this question:
>
> When PHP is loaded with Apache 1.3 and Apache is shutdown, PHP 4.2.2 
> crashes inside the routine _efree() called from bc_free_num(). I found 
> the problem to be related to linked list corruption and on further 
> investigation, suspected it to be a case of the thread calling 
> bc_free_num() to be different from that of the thread that called 
> bc_new_num(). I verfied this by enabling TSRM_DEBUG while building 
> zend, which enables this detection in _efree(). I also set the 
> tsrm_error_level to TSRM_ERROR_LEVEL_ERROR to enable dispalying of 
> TSRM messages to the screen. And sure enough, I got an error message 
> from _efree() from the following excerpt:
>
> #if defined(ZTS) && TSRM_DEBUG
> if (p->thread_id != tsrm_thread_id()) {
> tsrm_error(TSRM_ERROR_LEVEL_ERROR, "Memory block allocated at 
> %s:(%d) on thread %x freed at %s:(%d) on thread %x, ignoring",
> p->filename, p->lineno, p->thread_id,
> __zend_filename, __zend_lineno, tsrm_thread_id());
> return;
> }
> #endif
>
> I have ZTS defined thread support in Zend.
>
> I am not able to understand and appreciate all the details of the use 
> of the macros to access the globals variables via AG(), CG() etc and 
> from what I could figure out, ts_resource_ex()is some kind of thread 
> specific data mechanism and would work only if threads are dedicated 
> to PHP.
>
> I am not able to understand who is responsible for ensuring that the 
> same thread gets used for a complete request - whether it is some 
> thing that I need to do in Apache or whether I need to enable/disable 
> something while compiling PHP.
>
> Any help would be greatly appreciated. Please copy me on your reply as 
> well.
>
> Thanks in advance,
>
> S.R.
>
>




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




Re: [PHP-DEV] simple question

2002-09-17 Thread Alan Knowles

knight wrote:

>I was wondering if one(not all) of you could tell me how to view the source
>code for a particular php function.
>
>maybe there is somewhere I should look to find this information... I just
>don't know where to start.
>
http://www.php.net/manual/en/zend.php

lxr.php.net

grep for PHP_FUNCTION or ZEND_FUNCTION in the source tree..


regards
Alan

>
>Brendan
>
>
>
>  
>




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




Re: [PHP-DEV] highlight_file modification

2002-09-11 Thread Alan Knowles

I know it's a bit of a radical suggestion, but would depreciating 
highlight_string in favour of a pear package using the tokenizer not be 
a better approach.

is there any reason to keep this in C?

Anyway, just throwing a few stones into the water

Regards
Alan
 



Devon O'Dell wrote:

> Hey,
>
> I don't know if this has been brought up before (you can smack me, I 
> know that's the 3rd time I've said this), but something I (and others) 
> thought would be cool is line numbering for highlight_file (aka 
> show_source).
>
> I've made modifications so that this feature is settable from php.ini 
> (highlight.format, either 0 or 1) and tested my source, looks like it 
> works fine and the only stuff that didn't work in make test was stuff 
> where the EXPECT was wrong.
>
> I guess I'm waiting for karma, lemme know if I should submit the 
> patches in another email.
>
> Devon
>
>




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




Re: [PHP-DEV] DIO dio_tcsetattr problem

2002-09-10 Thread Alan Knowles

 

>>>  
>>>
>>it was added in 4.3 about 3 weeks ago. - If somebody wants to tell me 
>>how to add the 'since 4.3-dev' note to the manual, it might help...
>>
>>
>
>Hmm .. there's not '-dev' .. you either write CVS or 4.3.0 as
>the release it is available in.
>  
>
I added a note about it being available in 4.3.0, but there is a 

(PHP 4 CVS only)

note under something like proc_open, but I could not find where or how 
that gets generated - it's not in the xml docbook files..

>  
>




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




Re: [PHP-DEV] DIO dio_tcsetattr problem

2002-09-10 Thread Alan Knowles

DJ Anubis wrote:

>This is a very interesting function which could help in some developments. 
>But sounds dio_tcsetattr diseappeared from php-4.2.2. I browsed the source but 
>couldn't find it. in the source tree.
>

it was added in 4.3 about 3 weeks ago. - If somebody wants to tell me 
how to add the 'since 4.3-dev' note to the manual, it might help...

try lxr.php.net  /php4/ext/dio/dio.c

Regards
Alan

>
>Has it been merged with something else?
>
>DJ Anubis.
>
>
>
>  
>




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




Re: [PHP-DEV] Re: sockets extension

2002-09-09 Thread Alan Knowles

>
>
>Experminatal 10 to 16 months:
>---
>dio, w32api, xml rpc, ncurses, pcntl, xslt
>
dio - appears mostly stable = hell it's going in an embedded box here:) 
  its a straight map direct unix io stuff to php, so the api will 
probably not change, just grow slightly??
Sounds like it could loose the experimental tag.

pcntl  - have tested the latest changes that jason did. - everything is 
ok here. - the api is stable, and unlikely to have major changes (again 
it's a pretty straight C->php api)

anyway just my 2c

Regards
Alan

>
>
>Extensions not accessible via cvs.php.net !! 
>---
>mailparse, dbplus, muscat
>
>
>It might be nice to get rid of (or pecl it, as suggested by shane) the ones
>that show no (or false) promise of future stable versions to end users. And
>perhaps prioritize a little higher, some of those useful ones.
>
>
>-- Roshan
>
>  
>




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




Re: [PHP-DEV] include function in php source

2002-09-08 Thread Alan Knowles

eminent wrote:

> Hi everyone,
> i have to manipulate include function inside php source code to 
> satisfy my needs. it has to be configured, i think, with something 
> like PHP_FE(include .)
> my problem is that i can't find where it is inside the php source 
> tree. i mean that i don't know in which file it is. can anyone help me? 

include is a parsed into a php opcode at compile time, you will need to 
look at Zend/execute.c in the big case loop, to find it. eg. it's not a 
php function as such.
hint: lxr.php.net is extremely usefull for all this...

Regards
Alan

>
> thanks for the help
> Max
>




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




Re: [PHP-DEV] Persistant global objects: WAS: RE: [PHP-DEV] ZendEngine2availability

2002-09-05 Thread Alan Knowles

I forgot msession extension. http://www.mohawksoft.com/phoenix/msession.html
the rpc extension may also be of interest - (not know the code that 
well, I'm guessing it may be able to provide a more efficient object 
serialization), although I doubt that the current string method is 
really that bad

Just a guess, but trying to isolate the data that needs 'sessionizing' 
and optimizing that, rather than planning object serialization (which 
may be easier to code),  may prove to be quicker to implement, although 
not as clean..

Regards
alan

Tyson Lloyd Thwaites wrote:

>Something like that would be great. Do you mean store the *PHP object in
>smh, after serialization, or do it on the Zend side from within an
>extension? I guess what I am after is the ability to cache certain data
>objects so that they can be retrieved with maximum speed, because there will
>be thousands of them.
>
>
>
>If these data objects could be written in C, and stored in some great global
>washing basket in the sky, then that would just be great. Threaded access
>will be an issue, but we can deal with that by using a single Application
>object. I just have a feeling that all the serialize/deserialization that is
>happening now will be bad for scalability, when it constantly needs to hit
>the disk to create these objects.
>
>Just a few thoughts. I would love to come up with a funky solution to this.
>
>(PS: AFAIK ASP Application vars are actually stored in a seperate,
>single-threaded containter. This is somewhat amusing, as many programmers
>(myself included once :) store database connection objects in the
>Application to save having to reconnect - little did we realise that there
>might 100's of different requests all queueing up to use this single
>connection...heh heh :)
>
>Thanks for your help,
>
>Tyson Lloyd Thwaites
>
>Technical Lead
>I.T&e Limited
>
>  
>
>>-Original Message-
>>From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
>>Sent: Friday, 6 September 2002 12:19
>>To: Tyson Lloyd Thwaites
>>Cc: [EMAIL PROTECTED]
>>Subject: Re: [PHP-DEV] Persistant global objects: WAS: RE: [PHP-DEV]
>>ZendEngine2 availability
>>
>>
>>You could just stick it in shared memory.  Obviously given the standard
>>multi-process Apache architecture application objects ASP-style cannot be
>>implemented the same way.
>>
>>-Rasmus
>>
>>On Fri, 6 Sep 2002, Tyson Lloyd Thwaites wrote:
>>
>>
>>
>>>Hi guys,
>>>
>>>thanks for your help, I was able to get a Z2 build up and running.
>>>Unfortunately it didn't appear to be quite stable enough for
>>>  
>>>
>>what I'm doing
>>
>>
>>>yet, but at least it is cmoing along nicely!
>>>
>>>One question while I'm here: I'm interested in persistant
>>>  
>>>
>>global objects,
>>
>>
>>>like ASP's Application objects. I am sure this has been talked
>>>  
>>>
>>out on the
>>
>>
>>>list before, but I did a quick search and couldn't find anything.
>>>
>>>Is this possible?
>>>
>>>Yesterday I wrote my first PHP test extension (Yay! I'm so
>>>  
>>>
>>happy - until now
>>
>>
>>>I've been terrified of it!) I was able to register a class in the zend
>>>engine (after to looking at the PECL stuff), but I was
>>>  
>>>
>>wondering whether I
>>
>>
>>>could register a live, running object somewhere so that all
>>>  
>>>
>>scripts could
>>
>>
>>>access it across requests? Would this maybe even require access to an
>>>external engine written in C?
>>>
>>>At the moment I have a static Application object in PHP that just writes
>>>serialized objects to disk. This is not quite the same as
>>>  
>>>
>>having the object
>>
>>
>>>staying in ram though. I have implemented a Factory class that
>>>  
>>>
>>creates data
>>
>>
>>>objects and caches them to prevent database hits, and this speeds the
>>>process up by about 400%. But there will be thousands and
>>>  
>>>
>>thousands of these
>>
>>
>>>objects, and I would love to store them in RAM.
>>>
>>>I know this sort of thing should really be written in Java, but
>>>  
>>>
>>I decided to
>>
>>
>>>stick with PHP for this project so there is no going back!
>>>
>>>Any comments, corrections, put-back-in-boxes, or thoughts on
>>>  
>>>
>>how to do this
>>
>>
>>>will be ecstatically (get it? static? never mind) received.
>>>
>>>Cheers
>>>
>>>Tyson Lloyd Thwaites
>>>
>>>Technical Lead
>>>I.T&e Limited
>>>
>>>  
>>>
-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 5 September 2002 5:50
To: Zeev Suraski
Cc: Tyson Lloyd Thwaites; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: [PHP-DEV] ZendEngine2 availability


Or just checkout php4-ze2 instead and you will get everything


>>in one go
>>
>>
named correctly.

On Thu, 5 Sep 2002, Zeev Suraski wrote:



>Not sure why nobody stepped in and said it, but the Engine2 is
>  
>
quite alive

>

Re: [PHP-DEV] Persistant global objects: WAS: RE: [PHP-DEV] ZendEngine2availability

2002-09-05 Thread Alan Knowles

Sounds like a job for srm... http://www.vl-srm.net/

Obviously other options include SOAP servers.. etc.

or just using shm and storing a serialized object in there.

or use a ramdisk.

Something like this is difficult since php normally is not run threaded 
(eg. apache/cgi...) at the moment, so there is no 'central memory store' 
that could be used easily with it. - Apache 2 with thread support (when 
it is ready?) may help..

I'm sure theres a few other ways.
Regards
Alan


Tyson Lloyd Thwaites wrote:

>Hi guys,
>
>thanks for your help, I was able to get a Z2 build up and running.
>Unfortunately it didn't appear to be quite stable enough for what I'm doing
>yet, but at least it is cmoing along nicely!
>
>One question while I'm here: I'm interested in persistant global objects,
>like ASP's Application objects. I am sure this has been talked out on the
>list before, but I did a quick search and couldn't find anything.
>
>Is this possible?
>
>Yesterday I wrote my first PHP test extension (Yay! I'm so happy - until now
>I've been terrified of it!) I was able to register a class in the zend
>engine (after to looking at the PECL stuff), but I was wondering whether I
>could register a live, running object somewhere so that all scripts could
>access it across requests? Would this maybe even require access to an
>external engine written in C?
>
>At the moment I have a static Application object in PHP that just writes
>serialized objects to disk. This is not quite the same as having the object
>staying in ram though. I have implemented a Factory class that creates data
>objects and caches them to prevent database hits, and this speeds the
>process up by about 400%. But there will be thousands and thousands of these
>objects, and I would love to store them in RAM.
>
>I know this sort of thing should really be written in Java, but I decided to
>stick with PHP for this project so there is no going back!
>
>Any comments, corrections, put-back-in-boxes, or thoughts on how to do this
>will be ecstatically (get it? static? never mind) received.
>
>Cheers
>
>Tyson Lloyd Thwaites
>
>Technical Lead
>I.T&e Limited
>
>  
>
>>-Original Message-
>>From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
>>Sent: Thursday, 5 September 2002 5:50
>>To: Zeev Suraski
>>Cc: Tyson Lloyd Thwaites; [EMAIL PROTECTED];
>>[EMAIL PROTECTED]
>>Subject: RE: [PHP-DEV] ZendEngine2 availability
>>
>>
>>Or just checkout php4-ze2 instead and you will get everything in one go
>>named correctly.
>>
>>On Thu, 5 Sep 2002, Zeev Suraski wrote:
>>
>>
>>
>>>Not sure why nobody stepped in and said it, but the Engine2 is
>>>  
>>>
>>quite alive
>>
>>
>>>and kicking.  You just have to work a bit in order to get a
>>>  
>>>
>>fairly recent
>>
>>
>>>version.
>>>
>>>Not so recent version:
>>>http://www.php.net/distributions/php-4.3.0-dev-zend2-alpha2.tar.gz
>>>http://www.php.net/distributions/php-4.3.0-dev-zend2-win32-alpha2.zip
>>>
>>>Getting a recent version - check out the latest version of PHP,
>>>  
>>>
>>erase (or
>>
>>
>>>rename) the Zend/ directory inside it, and then check-out the
>>>  
>>>
>>ZendEngine2
>>
>>
>>>module from cvs.php.net:/repository.  You would have to rename that new
>>>check-out to 'Zend' so that PHP uses it.  Once that's done - build, and
>>>you'd have a ZE2-powered version.  It's pretty much beta
>>>  
>>>
>>quality at this stage.
>>
>>
>>>Zeev
>>>
>>>At 02:29 05/09/2002, Tyson Lloyd Thwaites wrote:
>>>
>>>  
>>>
Oh, ok. Sigh! I'll stick with the old engine then.

Thanks

Tyson Lloyd Thwaites

Technical Lead
I.T&e Limited



>-Original Message-
>From: Dan Hardiker [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, 4 September 2002 6:36
>To: [EMAIL PROTECTED]
>Cc: [EMAIL PROTECTED]
>Subject: Re: [PHP-DEV] ZendEngine2 availability
>
>
>  
>
>>Sorry if this is out of place, but is there any estimates
>>
>>
>>as to when the
>>
>>
>>famous Z2 might be ready?
>>
>>
>There is more (accurate) information in the archives of
>  
>
>>this list, but
>>
>>
>from what I recall, the estimates were about 6 months off.
>
>
>--
>Dan Hardiker [[EMAIL PROTECTED]]
>ADAM Software & Systems Engineer
>First Creative Ltd
>
>
>
>  
>
--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


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




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




Re: [PHP-DEV] largest value of the 2nd parameter in fgets function

2002-09-05 Thread Alan Knowles

Please use the php-general for questions like this.

- see http://www.php.net/fread

Regards
Alan

Terence Lee wrote:

>hello
>
>i've tried to read a line from a text file by  fgets($fp,8192). it work
>fine. however, there is a line over 8192 char and i tried to increase
>the 2nd parameter (e.g. 8193, 16384, 88192) still only 8192 char are
>read to my string variables.
>
>is it a limit of fgets or length of a string? any way to achieve getting
>more than 8192 char from a line in a text file?
>
>pls advice.
>
>terence
>
>
>
>  
>




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




Re: [PHP-DEV] FOR ALAN: bcompiler

2002-09-04 Thread Alan Knowles

[EMAIL PROTECTED] wrote:

> Hi,
> i have tried bcompiler and read the installing instructions. i unpack, 
> run phpize, run buildconf and configure (using --with-bcompiler) but i 
> get a sitax error on line 11094 in configure and the execution aborts. 
> have you any suggest?

It's probably better  to discuss it on [EMAIL PROTECTED]

which version of php are you  building it with - I've mainly tested with 
4.3-dev, not tested in the last few days with php4.2*

Also please use the latest CVS version of bcompiler - I've just fixed 
the decompiling stuff today, so it should all be working. And there is 
an example of a full script compiler in the examples directory

(its easier to build as an extension) - just
download
run phpize in the directory
./configure
make install

no real need to put it in ext/bcompiler

(i need to update the manual to reflect that.)

Regards
Alan

>
> bye
> Massimo
>




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




Re: [PHP-DEV] php script compilation

2002-09-04 Thread Alan Knowles

[EMAIL PROTECTED] wrote:

> hi everybody,
> does anyone know if there is any opensource tool for compiling or 
> bytecoding a php script? i know there is zend compiler but it costs 
> too much. thanks
> Massimo
>
pear.php.net - look for bcompiler (very experimental)
based on the compiler in apc (have a look at that as well.)

http://www.ioncube.com/encoder/ (pay per build)

and Zend encoder.. - buy this when you have money and support Zend :)

Regards
Alan







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




Re: [PHP-DEV] cgi and mod_php (phpize)

2002-08-28 Thread Alan Knowles

On a related subject, one that has been bugging me alot recently is 
phpize & include dir's

I run 4.2* as apache mod, and 4.3-dev as cli, now when it comes to 
building modules I have to go back to the build directories and 
reinstall phpize each time.

I know I could change --prefix=, but it would be a bit nicer if phpize 
installed with a suffix and softlinked it'self to phpize
eg.
phpize-4.2.3   --> softlinked to phpize
phpize-4.3-dev

/usr/include/php4-3-dev
/usr/include/php4.2.3 --> softlinked to /usr/include/php4

anyway - just a thought...

regards
Alan



Marcus Boerger wrote:

> Hi Sascha is ther a waay to build three modules, in particular
> i want to build cli, cgi and the apache module.
>
> regards
> marcus
>
>




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




Re: [PHP-DEV] Bison, Flex To Output PHP parser/compiler.

2002-08-22 Thread Alan Knowles

Johan Jordaan wrote:

>Hi,
>
>  I'm new to this list, so hi to everybody out there :)
>
>  I think this msg would be reaching the intended audience, but if I'm
>wrong let me know :)
>
It's probably not a bad audience :)

>  I've been playing around with flex/bison a little the last couple of
>days. I've got this stupid idea to modify flex/bison to emit a
>compiler/parser as native PHP as opposed to C code. Does anybody know if
>this has been attempted or of there is any value in it except the fact
>that it would be Kewl :)
>
the tokenizer will emit the elements of php code (in a similar way to 
flex/bison)

bcompiler (pear.php.net) has a callback feature that can show you all 
the opcodes in php - I did it to play about with writing a PHP->C 
converter, (not that simple)..

somewhere between the two, you may find what you are looking for.

regards
Alan

>
>  Thanks
>
>Johan Jordaan
>BB&D
>
>  
>




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




Re: [PHP-DEV] Interfaces in PHP

2002-08-21 Thread Alan Knowles

Wez Furlong wrote:

>class C {
>   delegatee $foo = new IFoo(); // "implements" IFoo by delegation
>   delegatee $bar = new IBar(); // "implements" IBar by delegation
>}
>
I didnt see anyone suggest this as an alternative to the delegatee 
syntax, - it just a bit clearer to read (to me anyway..)
class C extends something {
extends IFoo as $foo;
extends IBar as $bar;
var 
function 
}


just a thought..

regards
alan


>
>$c = new C();
>
>if (has_a($c, "IFoo"))
>   $c->foo();
>if (has_a($c, "IBar"))
>   $c->bar();
>
>This "has_a" function/operator is one of the small things missing
>from the current delegation RFC, along with an "as" operator.
>For full details on this stuff, take a look at those archives - theres
>no need to keep going round in circles :-)
>
>--Wez.
>
>  
>




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




Re: [PHP-DEV] Interfaces in PHP

2002-08-20 Thread Alan Knowles

 From my reading of delegation, it's really overloading, worded slightly 
differently.. - but not that related to interfaces...

In the example below, which is a php'ized version of a C# demo, the 
advantages of using interfaces (as far as I know) are primarly useful 
for COM or CORBA, where it would be possible to generate all the 
components for a CORBA/COM/.NET, or even java binding by reading the 
interfaces.

A .NET binding would effectively define all the available interfaces and 
classes, with strong typing!, and then when called (from C# or .NET) 
invoke a C call to call_user_function, to run php exectuter 
(probably the best way to implement a .NET server in php, - compiling a 
loosely typed language into .NET bytecodes, from reading about 
python,perl etcs. experience is not the way to go..)

Other than being nice for documentation, in pure PHP, I cant really see 
them being much use...

Interesting subject anyway..

Regards
Alan

called from C#

PHP_Celcius c = new PHP_Celcius(12.9);
system.out(c.toFarenheight().toString());




Interface temperature {
 function __construct(float $value);
 float function toCelcius();
 float function toFarenheight();
}

class Celcius {
Implements temperature;
var $value=0;
function __construct($value) {
$this->value =0;
}

function toCelcius() {
return $this->value;
}
function toFarenheight($value) {
return $this->value * 1.5;
}
}

class Farenheight{
Implements temperature;
var $value=0;
function __construct($value) {
$this->value =0;
}
function toCelcius() {
return $this->value / 1.5;
}
function toFarenheight($value) {
return $this->value;
}
}
Wez Furlong wrote:

>Hi Ben,
>
>ZE2 will implement something that can used much like interfaces;
>Please see this RFC on Delegation; something very similar to the syntax
>described there will be in PHP 5.
>
>http://cvs.php.net/co.php/ZendEngine2/RFCs/004.txt?r=1.2
>
>Also, review the archives for [EMAIL PROTECTED] list for more
>information about the (long) discussion on the subject.
>(http://zend.com/lists/engine2/200206/maillist.html is a rough start).
>
>--Wez.
>
>On 08/20/02, "Ben Dischinger" <[EMAIL PROTECTED]> wrote:
>  
>
>>What are the thoughts on implementing interfaces (as in object) within 
>>PHP?  Does the work outweigh the benefits?
>>
>>Ben Dischinger
>>
>>
>>-- 
>>PHP Development Mailing List 
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>
>
>  
>




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




Re: [PHP-DEV] PATCH: debug_backtrace() function for 4.3-dev/ZE1

2002-08-18 Thread Alan Knowles

One another suggestion a change in  ZE1 that would ease transition to ZE2.

making
$object->__clone() work on ZE1 (eg. parse equivalant to $object) , 
(without having to add it to all classes that are likely to need it)..

would  at least enable code written for ZE1 work with ZE2.. and visa 
versa...

just my thoughts for the morning

regards
alan




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




Re: [PHP-DEV] Parent _LINE_ Request

2002-08-15 Thread Alan Knowles

have a look at xdebug, or similar which does backtraces

I think PHP5 will do this as well..

regards
alan


Richard Thomas wrote:

>I have a set of universal DB wrappers that I use for most of my
>projects. The great thing about these wrappers, they auto manage your
>connection so connecting to 2 dbs on a single server only require 1 DB
>connection, Keeps track of what DB belongs to what class call and auto
>switches DB's within the functions..
>
>
>However the extra layer of  complication has made troubleshooting of
>events alot harder. When ever there is a error it refers to the line
>within my dblib.php Making it extremely difficult to track the issue
>down in the main script..
>
>What I suggest is a new variable called PARENT_LINE_ which would be
>pretty much the same as _LINE_ but clearly would show the _LINE_ of the
>calling script...It would be extremely easy to create this value any
>time a require/include or similiar function was called and assign a
>value, then close that value when the require/include is done..
>
>You could then add to the error statements a if PARENT_LINE_ echo VALUE
>
>With the increased complexity of PHP, and use of library/modular
>approach to programming such a tool would be invaluable..
>
>
>I would do it myself but im a PHP god and don't know C from a hole in my
>rear ;)
>
>
>  
>




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




Re: [PHP-DEV] Re: adding tcsetattr to dio extenstion

2002-08-15 Thread Alan Knowles

can somebody give me karma to add this..
and probably karma for phpdoc/en/reference/dio/functions (or similar)

regards
alan


regards
alan

Sterling Hughes wrote:

>>attached is a patch to add tcsetattr() to the dio extension
>>
>>any objections/suggestions for it..
>>for some reason if I do O_ASYNC on SET_FL i get  'I/O possible' and
>>dies... ?
>>
>>
>>
>
>Feel free to commit it, my only internet is currently firewalled http and
>ftp, so I can't really do much in that way (actually, can't even test your
>patch, but the interface looks fine).
>
>O_ASYNC should really be removed, its useless from your php script, and php
>really can't do async I/O without using the (un-portable) unix aio_*
>interface, until that is directly support signal based I/O is pretty much
>impossible in php.
>
>-Sterling
>
>  
>
>>usage:
>>
>>dl('dio.so');
>>
>>
>>$fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK);
>>
>>/* signal callbacks
>>
>>*/
>>
>>dio_fcntl($fd,F_SETOWN,posix_getpid());
>>//dio_fcntl($fd,F_SETFL, O_ASYNC ); // <- produces a 'I/O possible' and
>> dies... ?
>>dio_fcntl($fd,F_SETFL, O_SYNC );
>>
>>dio_tcsetattr($fd, array(
>>   'baud' => 9600,
>>   'bits' => 8,
>>   'stop'  =>1,
>>   'parity' => 0
>>));
>>echo "STARTING READ";
>>while (1) {
>>
>>   $data = dio_read($fd,256);
>>
>>   if ($data) {
>>   echo $data;
>>   }
>>}
>>
>>
>
>
>
>
>  
>




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




Re: [PHP-DEV] trans-sid warning?

2002-08-14 Thread Alan Knowles

Can we not document the real issues about this in the manual, and just 
say something like

There are security issues in using any type of sessions with HTTP, 
please read the manual at
http://www.php.net/en/manual/security.sessions.html
for a more detail discussion on this subject..

regards
Alan

Rasmus Lerdorf wrote:

>As much as I think trans-sid sucks from a performance perspective, what's
>with this comment in php.ini-dist?
>
>; trans sid support is disabled by default.
>; Use of trans sid may risk your users security. It may not be
>; feasible to use this option for some sites. Use this option with caution.
>session.use_trans_sid = 0
>
>What security issue is this referring to?
>
>-Rasmus
>
>
>  
>




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




Re: [PHP-DEV] pcntl - class callbacks // dio ASYNC

2002-08-12 Thread Alan Knowles

Jason T. Greene wrote:

>Doesn't this currently work without your patch?
>
it does if we add O_ASYNC to the defines in dio

the pcntl patch just fixes class based callbacks.. *the memory leaks I 
mentioned earlier where due to creating the signal connections before 
forking. - works OK if you connect the signals after forking.

regards
alan


>
>-Jason
>
>
>On Thu, 2002-08-08 at 02:49, Alan Knowles wrote:
>  
>
>>this efree needs removing..
>>
>>
>>
>>>  
>>>+
>>>+efree(*call_name); 
>>>+DEBUG_OUT("done call_user function\n");
>>>+/*call_user_function(EG(function_table), NULL, call_name, &retval, 
>1, ¶m TSRMLS_CC); */
>>> }
>>> 
>>>
>>>  
>>>
>>I can now use the dio with ASYNC like this..
>>
>>>
>>dl('dio.so');
>>
>> 
>>/* signal callbacks
>>
>>*/
>> 
>>function got_data() {
>>global $fd;
>>$data = dio_read($fd,256);
>>   
>>if ($data) {
>>echo $data;
>>}
>>
>>}
>>
>>$fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK);
>>
>>dio_fcntl($fd,F_SETOWN,posix_getpid());
>>dio_fcntl($fd,F_SETFL, O_ASYNC );
>>//dio_fcntl($fd,F_SETFL, O_SYNC );
>>pcntl_signal(SIGIO, 'got_data');
>>
>>dio_tcsetattr($fd, array(
>>'baud' => 9600,
>>'bits' => 8,
>>'stop'  =>1,
>>'parity' => 0
>>));
>>echo "STARTING READ";
>>while (1) {
>>   usleep(1)
>>}
>> 
>>?>
>>
>>
>>
>> 
>>
>>
>>
>
>
>  
>




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




Re: [PHP-DEV] phpthreads - hints anyone...

2002-08-03 Thread Alan Knowles

Ok, had a play with this
updated copy on
http://docs.akbkhome.com/threads.tgz

added a few of pthreads calls to TSRM.c

did most of the testing without this abstraction layer - just to see if 
I could get it to work.

used php_exectute_script, rather than getting clever and copying the 
function/class hashtables.

results:

It worked (with a few caveats - that are just a matter of getting to 
know threading better)...

some of the issues:
-if the child thread finishes before the main one - then the main one 
needs to wait somehow..
** FIX = probably need to keep a count of threads that are running and 
block at MSHUTDOWN on the main thread if stuff is still going.
-the child thread needs to have the modules functions loaded before it 
starts running really - otherwise you get intermitant 'functions not 
available' if you dont dl() the module in the child thread.
** FIX = I need to look at the pthreads equivalant for 
 tsrm_wait_event(thread.start_event,TSRM_INFINITE); will be.. this 
should make sure that the main thread doesnt do anything while the main 
thread is starting up..


- php_request_shutdown(NULL); calls the MSHUTDOWN for all modules - a 
good example of where this cause trouble is the ext/standard/string.c 
MSHUTDOWN, which has a static mutex that is freed. (and would be freed 
twice when the main thread finishes) -
hence  php_request_shutdown(), probably doesnt want to be called on a 
thread completion..
** FIX = not sure? - does this need fixing or should we just ignore 
php_request_shutdown..

due to the nature of thread scheduling, you dont get anything like '1 
opcode from thread A, 1 opcode from thread B', more like about 30-40 
opcodes randomly from each thread..

regards
alan



Shane Caraveo wrote:

> Here is a *very* rough peice of code for starting a thread.  It should 
> get across the idea of how I am thinking threads need to be started, 
> but it doesn't work (I haven't even tried to run it).  More 
> importantly though, as a starter, is getting an api into TSRM that 
> will support the abstraction of any thread calls.  I'm not realy 
> concerned with shared variables at this point, since I think there is 
> a chunk of work to do in just getting threads to work.
>
> I'm not mailing this onto the list, since I'm sure not too many people 
> want to get attachments.
>
> Shane
>
>




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




Re: [PHP-DEV] phpthreads - hints anyone...

2002-08-01 Thread Alan Knowles

>
> It's not about looking at the perl code, that will tell you nothing 
> unless you know perl internals.  It's about the way the interpreter 
> works, some of the architecture, that is simular to PHP.  In PHP, 
> threads are isolated, kind of like seperate processes, but in threads.


 From my understanding they are 'forced to be isolated' by the TSRM 
stuff.  which looks like it stores globals in something like an 
associated array ( thread id => global c variable - eg. compiler_globals 
etc.), when ZTS is enabled..

> Everything in PHP works that way, so in creating threads for php 
> scripts, you have to have a seperate interpreter.  Then you have to 
> create a "bridge" between the threads for shared variables.  shmop 
> comes close to what is needed, but not close enough.

the real use of the threading I guess is for people who want to write 
tcp servers, or desktop gtk apps.

Thoughts on accessing 'threaded shared vars'

$_THREADVAR['gtktext'] type..

php_threads_malloc_lock();
$_THREADVAR['gtktext']->add_text('some data ouput');
php_threads_malloc_unlock();

this would I guess involve rather heavy changes to the ZE engine to 
recogize an lock/unlock, copy (rather than refcount) etc. variables that 
where threaded..


Threaded objects???
 
I guess the other consideration is to have thread variable objects..
$threadvar  = new Thread_Var();
$threadvar->setNewObject('mywidget','GtkWindow');
$threadvar->set('mywidget',$gtkobject);
$var = $threadvar->get('mywidget');
$var = $threadvar->getArray('key','val');
$threadvar->callMethod('mywidget', 'add_text','something');

obviously copying and accessing these would probably be easier to cope 
with ( without having to modify heavily the zend engine) -  we could do 
'real' copying on the data, rather than refcounting them. and reduce the 
headaches...

> You're much closer to what needs to happen now.  But you cannot simply 
> point to the memory for another thread.  Doing that will cause 
> problems like you are running into.  You actually have to copy a bunch 
> of stuff so each thread is completely independent.

Do you mean we will have to really physically copy the all theopcode 
data from one thread to another?

>
>
> I've worked up some code in TSRM to abstract native thread calls, and 
> have started on an extension, but probably won't have it complete 
> until this weekend some time.  What you've done now is fairly simular, 
> but pthread specific.  Given time, I might have enough done to email a 
> diff containing my work tomorrow night if you want to take a look.

Anything I can do to help - testing, understanding - let me know.
Sounds Great.

Regards
Alan

>
>
> Shane
>



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




Re: [PHP-DEV] phpthreads - hints anyone...

2002-07-31 Thread Alan Knowles

 Ok, had a slight play with it again..

I did eventually find the perl code for threading although without an 
lxr server it's pretty much impossible to decipher all the macros they 
use..

The reality is I'm waving in the dark a bit - I've got a bit of spare 
time to play with it, but not really that sure whats going on all the 
time ;)

Working on the premise of thread creation starting another interpreter..
php compiled with --enable-experimental-zts, & debug. the code below 
manages to fire up the thread and run it.. - although it segfaults the 
main process after doing it.

This is a little supprising - I expected it to be the otherway round - 
as the logic kind of said that the new threads 'enviroment' (eg. vars) 
would not be initiated properly and it would fail.. , which could be the 
zval used in the callback causing issues..

The code for this stuff is pretty simple at the moment.. - so i'ts down 
the bottom..

As I said - if you can think of what needs doing, I've got a bit of time 
to play with it - although a little direction/hints do help..

regards
alan



void phpthreads_create(void *ptr) {
zval *myretval; 
 
void  **args = *(void ***) &ptr;
zval *callback;
TSRMLS_FETCH();

php_request_startup(TSRMLS_C); 
callback   =  *(zval **) args[0] ;
EG(class_table)=  *(HashTable **) args[1] ;
EG(function_table) =  *(HashTable **) args[2] ;

if (!call_user_function( EG(function_table), NULL, callback,  myretval, 0, 
NULL TSRMLS_CC ))  { 
zend_error(E_ERROR, "Problem Starting thread with callback");
fflush(stdout);
}
/* runs this perfectly!*/
ts_free_thread( );

}
/* {{{ proto string phpthreads_thread(string function)
   Return a string to confirm that the module is compiled in */
PHP_FUNCTION(phpthreads_create)
{
void **args[2];  
zval *callback;
pthread_t thread;
phpthreads_flag = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callback) == 
FAILURE) {
return;
}
  
args[0] = (void *)  &callback;
args[1] = (void *)  &EG(class_table);
args[2] = (void *)  &EG(function_table);


pthread_create( &thread, NULL, (void *) phpthreads_create, (void*) &args);
  
printf("DONE CREATING THREAD\n"); fflush(stdout);
/* segfaults a little bit after this gets echoed */
RETURN_TRUE;
}



>>>  
>>>
>>Ouch.  While it's an interesting way to deal with the issue, I think 
>>this will be way too slow, and maintenance will be hard (keeping up with 
>>changes in the real zend_execute, and zend engine in general).  As in a 
>>couple other responses, the way this needs to be implemented has been 
>>hashed out, largely based on how the same problem is solved in Perl 
>>(there is a remarkable amount of simularity between PHP and Perl at some 
>>levels).  If you're interested, lets talk.
>>
>>Shane
>>
>>
>>-- 
>>PHP Development Mailing List 
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>
>__
>Do You Yahoo!?
>Yahoo! Health - Feel better, live better
>http://health.yahoo.com
>
>  
>




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




Re: [PHP-DEV] phpthreads - hints anyone...

2002-07-31 Thread Alan Knowles


Shane Caraveo wrote:

> Alan Knowles wrote:
>
>> Im looking at adding threading to php, (for the cgi/cli stuff)..
>>
>> The story so far:
>>
>> I've created an extension which diverts all zend_execute calls into 
>> the extension -> phpthreads_execute.
>> this function is a copy of zend_execute with a few modifications
>> - to copy & restore things like  EG(active_symbol_table);
>> - to malloc lock and unlock the execute loop and release on each opcode.
>
>
> Ouch.  While it's an interesting way to deal with the issue, I think 
> this will be way too slow, and maintenance will be hard (keeping up 
> with changes in the real zend_execute, and zend engine in general). 

Plan A was just to get something that worked - even if it was crude and 
nasty... :)
Agreed - there are lots of issues with this method.. timesliceing and 
yeilding if the application is locked most of the time is problematic.

> As in a couple other responses, the way this needs to be implemented 
> has been hashed out, largely based on how the same problem is solved 
> in Perl (there is a remarkable amount of simularity between PHP and 
> Perl at some levels).  If you're interested, lets talk.

- do we have to do it based on perl - their web site is as easy to 
comprehend as the language - I spent 1/2 hour trying to find any source 
code or CVS server and failed :)
ok - hints would be good.. - pythons source for threading has a url...

I'm guessing this generaly means
a) turning on php's tsrm stuff.
b)on the
pthread_create():
copy the memory address of the function/class tables between threads. 
(eg. so they share the same data).
malloc lock any changes to the function/class table = eg. the compiler 
calls..
do the call_user_func_ex roughly as per before...

c) work out a sharing method for variables...

regards
alan




>
>
> Shane
>
>




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




[PHP-DEV] phpthreads - hints anyone...

2002-07-31 Thread Alan Knowles

Im looking at adding threading to php, (for the cgi/cli stuff)..

The story so far:

I've created an extension which diverts all zend_execute calls into the 
extension -> phpthreads_execute.
this function is a copy of zend_execute with a few modifications
- to copy & restore things like  EG(active_symbol_table);
- to malloc lock and unlock the execute loop and release on each opcode.

I've started testing the phpthreads_create($callback); - it appears to 
work ok, execept it segfaults on completion.. - trying to reduce 
refcounts somewhere.

The fireup code looks something like this..

void phpthreads_create(void *ptr) {
zval myretval;
zval *callback = (zval *) ptr;
  
if (!call_user_function( EG(function_table), NULL, callback, 
&myretval, 0, NULL TSRMLS_CC ))  {
zend_error(E_ERROR, "Problem Starting thread with 
callback");
}
   
pthread_exit(NULL);
   
   
}
/* {{{ proto string phpthreads_thread(string function)
   Return a string to confirm that the module is compiled in */
PHP_FUNCTION(phpthreads_create)
{
 
zval *callback;
pthread_t thread;
   
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", 
&callback) == FAILURE) {
  return;
  }
pthread_create( &thread, NULL, (void *) phpthreads_create, 
(void*) callback);
RETURN_TRUE;
}

and the backtrace of the simple threaded test looks like this..
0x08128f08 in _zval_ptr_dtor (zval_ptr=0x81b5ce8) at 
/usr/src/php/php4/Zend/zend_execute_API.c:275
275 (*zval_ptr)->refcount--;
(gdb) bt
#0  0x08128f08 in _zval_ptr_dtor (zval_ptr=0x81b5ce8) at 
/usr/src/php/php4/Zend/zend_execute_API.c:275
#1  0x424ceba2 in ?? ()
#2  0x424c7c92 in ?? ()
#3  0x08130588 in zend_execute_scripts (type=8, retval=0x0, 
file_count=3) at /usr/src/php/php4/Zend/zend.c:810
#4  0x08110abd in php_execute_script (primary_file=0x40006c71) at 
/usr/src/php/php4/main/main.c:1398
#5  0x08110138 in php_module_shutdown () at 
/usr/src/php/php4/main/main.c:1058
#6  0x2e325f43 in ?? ()

does anyone want to suggest what might be missing - is it worth putting 
this into pecl - and does someone what to lend a hand??

regards
alan






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




Re: [PHP-DEV] returning arrays

2002-07-25 Thread Alan Knowles

Marco Glatz wrote:

>hi there, 
>
>i have an extension with a funtion that should return an array, but my array
>is empty ?.
>
>
>-- snip --
>
>ZEND_FUNCTION(foo)
>{
>   zval *tmp_array;
>
>   MAKE_STD_ZVAL(tmp_array);
>
>   array_init(tmp_array);
>   array_init(return_value);
>
>
>   // a loop to fill the array with some data
>   for(i=0; i < 10; i++) {
>   add_index_string(tmp_array, i, some_data, 1);
>   }
>}
>

is it missing some code - or did you mean to do

add_index_string(return_value, i, some_data, 1);


>
>
> /snip   -
>
>hope someone can tell me whats wrong.
>
>marco
>
>  
>




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




Re: [PHP-DEV] Patch suggestions for PHP 4.2.3 (tokenizer)

2002-07-24 Thread Alan Knowles

This would be nice to get into 4.2.3 - at least the tokenizer would be 
usable in a release version :)

http://cvs.php.net/diff.php/php4/ext/tokenizer/tokenizer.c?r1=1.8&r2=1.9&ty=h&num=10

for bug : http://bugs.php.net/bug.php?id=16939

regards
alan






[PHP-DEV] Re: [Zend Engine 2] can I have my delete back? :) - patch attached

2002-07-06 Thread Alan Knowles

Yeah, one of the main reasons for requesting it was that like shanes 
sybase class midgard also uses delete as the row deletor, - this doesnt 
really affect midgard as the method is defined in the php extension, not 
the php, however when I wrote DB_DataObject, and midgard lite, to take 
advantage of the same style of database access it was a pretty obvious 
method name..

one of the other ones that threw me was that 'list' did not work 
either.. (in ZE1 also obviously)..

looking at the code I would guess that you could support most valid 
keywords as method names

valid_method_names:
T_STRING
  | T_DELETE
  | T_LIST
  | T_NEW

the reasoning for not supporting all keywords?
 - user getting confused and accedentily using a keyword rather than the 
method

on the code side I cant see any major obsticales to supporting them.. - 
or did I miss something.. - the above code would add very little 
slowdown to the parser - especially as I assume it matches the first on 
the list anyway..

I did see it mentioned as a critisium that there where alot of reserved 
words that made defining class methods painfull ( I dont totally agree 
with that, but it would put it to bed)

regards
alan



Andi Gutmans wrote:

> Alan,
>
> There was a discussion about this a long time ago and it was decided 
> not to support this.
> The main reasoning behind this is that we don't want to start 
> supporting all other reserved words.
> It's one of the things you'll need to cope with when moving to the 
> Engine 2 but a very simple search&replace on your project should do 
> the trick.
>
> Thanks anyway,
> Andi
>
>>
>>
>




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




[PHP-DEV] can I have my delete back? :) - patch attached

2002-07-05 Thread Alan Knowles

 Attached hopefully is a patch to allow method names called delete .- 
not functions though..

Speedwise it should not affect performance as its a very small compile 
time issue..

this would save me an a few others a bit of pain :)

thoughts

regards
alan




  


Index: zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.59
diff -u -r1.59 zend_language_parser.y
--- zend_language_parser.y  29 Jun 2002 15:38:40 -  1.59
+++ zend_language_parser.y  6 Jul 2002 06:58:49 -
@@ -429,6 +429,8 @@
class_variable_decleration ';'
|   class_constant_decleration ';'
|   T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference 
T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); } 
'(' 
+   parameter_list ')' '{' inner_statement_list '}' { 
+zend_do_end_function_declaration(&$1 TSRMLS_CC); }
+   |   T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference 
+T_DELETE { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); } 
+'(' 
parameter_list ')' '{' inner_statement_list '}' { 
zend_do_end_function_declaration(&$1 TSRMLS_CC); }
|   T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference 
T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); }
parameter_list '(' inner_statement_list ')' ';' { 
zend_do_end_function_declaration(&$1 TSRMLS_CC); }
alan:/usr/src/php/php4/Zend# cvs diff -u zend_language_scanner.l
Index: zend_language_scanner.l
===
RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.51
diff -u -r1.51 zend_language_scanner.l
--- zend_language_scanner.l 10 Apr 2002 21:33:34 -  1.51
+++ zend_language_scanner.l 6 Jul 2002 06:59:32 -
@@ -626,6 +626,9 @@
 }
 
 "delete" {
+   zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
return T_DELETE;
 }
 



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


Re: [PHP-DEV] PHP Extension Help

2002-06-26 Thread Alan Knowles

this is a good starting place
http://www.php.net/manual/en/zend.php

although it doesnt cover the class stuff that well (which can be done : 
ming, domxml,  gtk, xmms  - to name a few that do it )
- for a nice example have a look at the xmms extension
http://cvs.php.net/cvs.php/pear/PECL/xmms

This illustrates class and functional creation,

as a side suggestion it may be worth calling your class HTML_Template_XX
as this would fit in better with the PEAR naming of classes..

regards
alan


Joao Prado Maia wrote:

>Hi,
>
>Before starting up on this email, please be aware that I'm a newbie in C
>programming and especially in PHP extension coding. I tried researching
>about my doubt (and even talked with Joey Smith) but couldn't really have
>a definite answer.
>
>My ultimate goal for my little PHP extension is to try to learn C
>programming and also try to create a C extension to replace the use of the
>PHPLIB template class. I want to be able to basically create my extension
>and then 'plug-in' into my code and have it work as the PHPLIB template
>class would work.
>
>At first I tried creating an internal class like 'Directory' and have it
>somehow be able to do :
>
>$t = new JTemplate; // or something similar
>
>After speaking with Joey, I learned that you cannot do that (is this
>true?) because the 'new' operator doesn't look for built-in functions.
>
>However, I remember PHP-GTK and how you could do something like this:
>
>$win = &new GtkWindow();
>
>Isn't this 'GtkWindow' an example of how to register a built-in class and
>then have the code instantiate it normally as you would do it with a
>normal PHP based class ? (again, be nice. I'm a newbie :)
>
>Anyway, if someone could answer this simple question it would be very
>appreciated.
>
>Cheers,
>Joao
>
>
>  
>




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




[PHP-DEV] php bytecode compiler

2002-06-26 Thread Alan Knowles

I've just been playing building a php bytecode compiler - based off of 
the apc serialize code. - made it thread safe and made it as a php 
extension that reads/writes streams - so it only works with 4.3-dev..

the tarball is at
http://docs.akbkhome.com/bcompiler-0.1.tgz

source files are here:
http://docs.akbkhome.com/bcompiler/

The current status is:
It can compile a class - example is bcompiler.php.txt
It can load a class - example is bcompiler_read.php.txt

It passes a few simple tests - although it currently segfaults if you 
call a static method of the class and dont use the class instantation 
stuff : eg. $test=new test12;

anyway for you want to play with it - and help fix it :) let me know
 
regards
alan


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




Re: [PHP-DEV] html tokenizer to add to tokenizer?

2002-06-14 Thread Alan Knowles

Stig S. Bakken wrote:

>Good idea.  I assume you want this for WidgetHTML.php? ;-)
>  
>
Yeah, I hopefully it would remove the need for preg_matching in there..

Will get back to this in a few days - want to clear off some other stuff...

regards
alan

> - Stig
>
>On Wed, 2002-06-12 at 14:26, Alan Knowles wrote:
>  
>
>>Attached hopefully is the re2c source for a html tokenizer - I added it 
>>to tokenizer.c - any thoughts on inclusion?
>>
>>regards
>>alan
>>
>>
>>
>>
>>
>
>  
>
>>enum {
>>STATE_PLAIN = 0,
>>STATE_TAG,
>>STATE_NEXT_ARG,
>>STATE_ARG,
>>STATE_BEFORE_VAL,
>>STATE_VAL
>>};
>>
>>/*!re2c
>>any = [\000-\377];
>>N = (any\[<]);
>>alpha = [a-zA-Z];
>>alphanumeric = [a-zA-Z0-9];
>>*/
>>
>>
>>
>>#define YYFILL(n) goto stop
>>#define YYCTYPE unsigned char
>>#define YYCURSOR xp
>>#define YYLIMIT end
>>#define YYMARKER q
>>#define STATE state
>>
>>PHP_FUNCTION(token_html)
>>{
>>  char *source = NULL;
>>  int argc = ZEND_NUM_ARGS();
>>  int source_len;
>>  int state;
>>  char *end, *q;
>>  char *xp;
>>  char *start;
>>  zval *tag, *attribute;
>>  
>>  if (zend_parse_parameters(argc TSRMLS_CC, "s", &source, &source_len) == 
>FAILURE) 
>>  return;
>>  
>>  YYCURSOR = source;
>>  YYLIMIT = source + source_len;
>>  STATE = STATE_PLAIN;
>>  
>>  array_init(return_value);
>>  switch (STATE) {
>>  case STATE_PLAIN:   goto state_plain;
>>  case STATE_TAG: goto state_tag;
>>  case STATE_NEXT_ARG:goto state_next_arg;
>>  case STATE_ARG: goto state_arg;
>>  case STATE_BEFORE_VAL:  goto state_before_val;
>>  case STATE_VAL: goto state_val;
>>  }
>>  
>>  /* 
>>  
>>  I need to split the stuff into:
>>  array ( "TAG", array("name"=>"value","name=>"value"))
>>  or 
>>  string
>>  
>>  
>>  add_next_index_zval(return_value, tag);handle_tag(STD_ARGS); 
>>  */
>>
>>
>>
>>state_plain_begin:
>>  STATE = STATE_PLAIN;
>>  
>>state_plain:
>>  start = YYCURSOR;
>>/*!re2c
>>  "<" { STATE = STATE_TAG; goto state_tag; }
>>  N+  { add_next_index_stringl(return_value, start , xp - 
>start  , 1); goto state_plain; }
>>*/
>>
>>state_tag:
>>  start = YYCURSOR;
>>  
>>// start -> xp contains currunt pos,  
>>// needs to deal with comments !-- and ?xml or php etc.
>>/*!re2c
>>  [/!]? alphanumeric+ { MAKE_STD_ZVAL(tag); array_init(tag); 
>add_next_index_stringl(tag, start, xp - start, 1); goto state_next_arg_begin; }
>>  "!" "-" "-"  { MAKE_STD_ZVAL(tag); array_init(tag); 
>add_next_index_stringl(tag, start, xp - start, 1); goto state_comment_begin; }
>>  any{  add_next_index_stringl(return_value, "<",1 , 1); --YYCURSOR; 
>goto state_plain_begin; }
>>*/
>>
>>
>>
>>state_comment_begin:
>>  start = YYCURSOR;
>>
>>state_comment_next:
>>
>>/*!re2c
>>"-" "-" ">"   { add_next_index_stringl(tag, start, xp - start -3, 1); 
>add_next_index_zval(return_value, tag); goto state_plain_begin; }
>>any { goto state_comment_next; }
>>*/
>>
>>state_next_arg_begin:
>>  STATE = STATE_NEXT_ARG;
>>  
>>// at first bit after < or just after a name or name=''   
>>state_next_arg:
>>  start = YYCURSOR;
>>/*!re2c
>>  ">" { add_next_index_zval(return_value, tag); goto state_plain_begin; }
>>  [ \v\t\n]+  { goto state_next_arg; }
>>  alpha   { --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
>>  "/"   { MAKE_STD_ZVAL(attribute); array_init(attribute); 
>add_next_index_stringl(attribute, start, xp - start, 1);add_next_index_zval(tag, 
>attribute);  goto state_next_arg; }
>>  ["] (any\["])* ["]  { MAKE_STD_ZVAL(attribute); array_init(attribute); 
>add_next_index_stringl(at

Re: [PHP-DEV] understanding resources

2002-06-13 Thread Alan Knowles


http://www.php.net/manual/en/zend.variables.resource.php

- Im sure thats improved alot since I first read it :)

regards
alan

fabwash wrote:

>Something went wrong in the format of my message!
>
>It should read:
>
>  
>
>>ZEND_FETCH_RESOURCE(resource_ptr, resource_struct *, resource_id, -1,
>>"resource", le_resource);
>>
>>
>
>  
>
>>The first argument will be returned to the caller, that will be your
>>resource identification.
>>The second argument is a pointer to your resource (a zval, a struct, or
>>whatever).
>>The third argument is the resource destruction handler type.
>>
>>
>
>Then
>  
>
>>ZEND_FETCH_RESOURCE(resource_ptr, resource_struct *, resource_id, -1,
>>"resource", le_resource);
>>
>>The first parameter will return your resource, the second is the type of
>>your resource, the third is what was returned in "return_value" and passed
>>back to the user, so that should be passed as an argument back to your
>>extension, -1 to say that there is no default resource, "resource" is just
>>
>>
>a
>  
>
>>name that will be displayed if Zend cannot find your resource, and
>>le_resource is the resource type you got back when you registered the
>>resource destructor.
>>
>>
>
>- Original Message -
>From: "fabwash" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>; "Joel Dudley" <[EMAIL PROTECTED]>
>Sent: Thursday, June 13, 2002 5:46 PM
>Subject: Re: [PHP-DEV] understanding resources
>
>
>  
>
>>http://www.php.net/manual/en/zend.variables.resource.php will be a
>>
>>
>starting
>  
>
>>point.
>>
>>Basically you want to do this:
>>
>>1) Create a destruction handler for your resource:
>>
>>void my_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
>>}
>>
>>2) Register the destruction handler:
>>
>>le_resource =
>>zend_register_resource_destructors_ex(my_destruction_handler, NULL,
>>"resource");
>>
>>1) and 2) are done once in the code (usually at startup).
>>
>>3) Register your resource
>>
>>ZEND_REGISTER_RESOURCE(return_value, resource_ptr, le_resource);
>>
>>Then when you need to get your resource, you will get the resource id as a
>>parameter from the caller, then call :
>>
>>ZEND_FETCH_RESOURCE(resource_ptr, resource_struct *, resource_id, -1,
>>"resource", le_resource);
>>
>>The first parameter will return your resource, the second is the type of
>>your resource, the third is what was returned in "return_value" and passed
>>back to the user, so that should be passed as an argument back to your
>>extension, -1 to say that there is no default resource, "resource" is just
>>
>>
>a
>  
>
>>name that will be displayed if Zend cannot find your resource, and
>>le_resource is the resource type you got back when you registered the
>>resource destructor.
>>
>>If you don't want to return the resource to the caller but keep it as a
>>property of your object, that's another story, and I can help on that one
>>too if necessary.
>>
>>Fab.
>>
>>The first argument will be returned to the caller, that will be your
>>resource identification.
>>The second argument is a pointer to your resource (a zval, a struct, or
>>whatever).
>>The third argument is the resource destruction handler type.
>>
>>- Original Message -
>>From: "Joel Dudley" <[EMAIL PROTECTED]>
>>To: <[EMAIL PROTECTED]>
>>Sent: Thursday, June 13, 2002 12:37 PM
>>Subject: [PHP-DEV] understanding resources
>>
>>
>>
>>
>>>Hello all,
>>>  I need to write a molecular visualization extension for PHP to
>>>  
>>>
>complete
>  
>
>>a
>>
>>
>>>project I am working on. It will have to work somewhat like GD by
>>>  
>>>
>creating
>  
>
>>a
>>
>>
>>>resource, having other functions operate on that resource, and then
>>>  
>>>
>output
>  
>
>>>an image. I have trouble finding a good explanation of resources in the
>>>  
>>>
>>PHP
>>
>>
>>>docs. Perhaps I missed a section. Regardless, does anyone here know of a
>>>resource that explains resources in extensions? I think I will go over
>>>  
>>>
>the
>  
>
>>>GD source code for now, and perhaps that is the best answer to my
>>>  
>>>
>>question.
>>
>>
>>>Thank you for reading my post.
>>>
>>>Joel Dudley
>>>Faculty Research Associate
>>>Arizona State University
>>>Kumar Laboratory of Evolutionary Functional Genomics
>>>http://lsweb.la.asu.edu/skumar/
>>>
>>>
>>>  
>>>
>>--
>>PHP Development Mailing List 
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>  
>




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




[PHP-DEV] html tokenizer to add to tokenizer?

2002-06-12 Thread Alan Knowles

Attached hopefully is the re2c source for a html tokenizer - I added it 
to tokenizer.c - any thoughts on inclusion?

regards
alan




enum {
STATE_PLAIN = 0,
STATE_TAG,
STATE_NEXT_ARG,
STATE_ARG,
STATE_BEFORE_VAL,
STATE_VAL
};

/*!re2c
any = [\000-\377];
N = (any\[<]);
alpha = [a-zA-Z];
alphanumeric = [a-zA-Z0-9];
*/



#define YYFILL(n) goto stop
#define YYCTYPE unsigned char
#define YYCURSOR xp
#define YYLIMIT end
#define YYMARKER q
#define STATE state

PHP_FUNCTION(token_html)
{
char *source = NULL;
int argc = ZEND_NUM_ARGS();
int source_len;
int state;
char *end, *q;
char *xp;
char *start;
zval *tag, *attribute;

if (zend_parse_parameters(argc TSRMLS_CC, "s", &source, &source_len) == 
FAILURE) 
return;

YYCURSOR = source;
YYLIMIT = source + source_len;
STATE = STATE_PLAIN;

array_init(return_value);
switch (STATE) {
case STATE_PLAIN:   goto state_plain;
case STATE_TAG: goto state_tag;
case STATE_NEXT_ARG:goto state_next_arg;
case STATE_ARG: goto state_arg;
case STATE_BEFORE_VAL:  goto state_before_val;
case STATE_VAL: goto state_val;
}

/* 

I need to split the stuff into:
array ( "TAG", array("name"=>"value","name=>"value"))
or 
string


add_next_index_zval(return_value, tag);handle_tag(STD_ARGS); 
*/



state_plain_begin:
STATE = STATE_PLAIN;

state_plain:
start = YYCURSOR;
/*!re2c
  "<"   { STATE = STATE_TAG; goto state_tag; }
  N+{ add_next_index_stringl(return_value, start , xp - 
start  , 1); goto state_plain; }
*/

state_tag:  
start = YYCURSOR;

// start -> xp contains currunt pos,
// needs to deal with comments !-- and ?xml or php etc.
/*!re2c
  [/!]? alphanumeric+   { MAKE_STD_ZVAL(tag); array_init(tag); 
add_next_index_stringl(tag, start, xp - start, 1); goto state_next_arg_begin; }
  "!" "-" "-"  { MAKE_STD_ZVAL(tag); array_init(tag); 
add_next_index_stringl(tag, start, xp - start, 1); goto state_comment_begin; }
  any  {  add_next_index_stringl(return_value, "<",1 , 1); --YYCURSOR; 
goto state_plain_begin; }
*/



state_comment_begin:
start = YYCURSOR;

state_comment_next:

/*!re2c
"-" "-" ">"   { add_next_index_stringl(tag, start, xp - start -3, 1); 
add_next_index_zval(return_value, tag); goto state_plain_begin; }
any { goto state_comment_next; }
*/

state_next_arg_begin:
STATE = STATE_NEXT_ARG;

// at first bit after < or just after a name or name='' 
state_next_arg:
start = YYCURSOR;
/*!re2c
  ">"   { add_next_index_zval(return_value, tag); goto state_plain_begin; }
  [ \v\t\n]+{ goto state_next_arg; }
  alpha { --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
  "/"   { MAKE_STD_ZVAL(attribute); array_init(attribute); 
add_next_index_stringl(attribute, start, xp - start, 1);add_next_index_zval(tag, 
attribute);  goto state_next_arg; }
  ["] (any\["])* ["]{ MAKE_STD_ZVAL(attribute); array_init(attribute); 
add_next_index_stringl(attribute, start + 1, xp - start -2, 1); 
add_next_index_stringl(attribute, "\"", 1, 1); add_next_index_zval(tag, attribute); 
goto state_next_arg_begin; }
  ['] (any\['])* [']{ MAKE_STD_ZVAL(attribute); array_init(attribute); 
add_next_index_stringl(attribute, start + 1, xp - start -2, 1); 
add_next_index_stringl(attribute, "'", 1, 1); add_next_index_zval(tag, attribute); 
goto state_next_arg_begin; }
  any   { add_next_index_zval(return_value, tag); goto state_plain_begin; }
*/

state_arg:
start = YYCURSOR;
/*!re2c
  alpha+{  MAKE_STD_ZVAL(attribute); array_init(attribute); 
add_next_index_stringl(attribute, start, xp - start, 1); STATE = STATE_BEFORE_VAL; 
goto state_before_val; }
  any   { --YYCURSOR; STATE = STATE_ARG; goto state_next_arg; }
*/

state_before_val:
start = YYCURSOR;
/*!re2c
  [ ]* "=" [ ]* { STATE = STATE_VAL; goto state_val; }
  any   { add_next_index_zval(tag, attribute); --YYCURSOR; goto 
state_next_arg_begin; }
*/


state_val:
start = YYCURSOR;
/*!re2c
  ["] (any\["])* ["]{ add_next_index_stringl(attribute, start + 1, xp - start -2, 
1); add_next_index_stringl(attribute, "\"", 1, 1); add_next_index_zval(tag, 
attribute); goto state_next_arg_begin; }
  ['] (any\['])* [']{ add_next_index_stringl(attribute, start + 1, xp - start -2, 
1); add_next_index_stringl(attribute, "'", 1, 1); add_next_index_zval(tag, attribute); 
goto state_next_arg_begin; }
  (any\[ \n>"'

Re: [PHP-DEV] feature request for __LINE__, __FILE__ andtrigger_error

2002-04-25 Thread Alan Knowles

__LINE__ , __FILE__ (and now __FUNCTION__ & __CLASS__) are converted at 
compile time into a string - have a look at zend/zend_language_scanner.l 
 for more details.

regards
alan


Michael Virnstein wrote:

>A short question on this:
>how about __LINE__?
>doesn't this also require runtime context or am i wrong?
>if so, why it is a constant then, not a function?
>
>Michael
>
>"Stig S. Bakken" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>>Hi,
>>
>>__FILE__ is compiled into a constant string by Zend.  You can think of
>>it as equivalent of putting a string with the filename there instead.
>>It is constant.  __CFILE__ would require runtime context (which function
>>called us), so it makes no sense as a constant.  Derick's xdebug
>>extension will provide functions for this instead.
>>
>> - Stig
>>
>>On Wed, 2002-04-24 at 21:40, Michael Virnstein wrote:
>>
>>>an additional thought:
>>>if __CFILE__ and __CLINE__ are used outside of
>>>a function/method, both should be NULL. and trigger_error
>>>should only overwrite its __FILE__ and __LINE__ settings, if
>>>they are NOT NULL. And if one of the __FILE__ , __LINE parameters
>>>of trigger_error is NOT NULL, both have to be set.
>>>
>>>My 2 cents ;)
>>>That's how i would prefer it.
>>>
>>><[EMAIL PROTECTED]> schrieb im Newsbeitrag
>>>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>>>
Hello Michael,

I'm working (80% done) on an extension for this. It should be finished

>in
>
a few days. It doesn't feature the __C*__ things yet, but I can add a
function for that too.

I'll keep you posted,

Derick

On Wed, 24 Apr 2002, Michael Virnstein wrote:

>It would be really useful for writing functions/Classes, if
>i were able to determine the __FILE__ and __LINE__ of the
>script, that is calling my function, without the need to send
>__FILE__ and __LINE__ as parameter to my function.
>E.g. __CFILE__ for calling script and __CLINE__ for line in the
>calling script would be really great.
>In addition it'll be useful, if I could use trigger_error in this
>
>>>manner.
>>>
>Most of the time i don't want to know, on which line my
>
>trigger_error
>
>call is located, but on which line in the script that called my
>
>>>function,
>>>
>the
>error occured. it'll be nice, if trigger_error could be extended, so
>
>it
>
>takes
>to more parameters, which overwrite the default __FILE__, __LINE__
>settings of trigger error.
>
>Example:
>
>function somefunction($array) {
>if (!is_array($array)) {
>trigger_error("Not an array", E_USER_ERROR, __CFILE__,
>
>>>__CLINE__);
>>>
>}
>// do something with the array
>}
>
>
>
>
>
>--
>PHP Development Mailing List 
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>>---
>>
 Did I help you? Consider a gift:
  http://www.amazon.co.uk/exec/obidos/registry/SLCB276UZU8B

>>---
>>
  PHP: Scripting the Web - [EMAIL PROTECTED]
All your branches are belong to me!
SRM: Script Running Machine - www.vl-srm.net

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




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




Re: [PHP-DEV] The PHP Platform

2002-04-16 Thread Alan Knowles

I know this is going nowhere :) but anyway - its late here and I've got 
a few secs to kill

Ask your boss, how often has he done a project using microsoft tools, 
and its been seriously delayed because they found a serious bug in the 
microsoft tools, that had to be worked around.- if he answers never i 
would be amazed !

Delayed = late delivery = unsatified customer = bad reputation = no more 
contracts!

The difference with PHP (and perl,pike,python, ruby..etc), is that 
when there is a problem, your project is not delayed, you have full 
access to the source, you can find the problem, fix it and carry on with 
minimal delays.. - no workaround. - no code thats going to break on the 
next MS update!

This is the core to the reason behind why all of these languages are 
better than c#/java - you are empowered to solve your own problems, 
rather than relying on 3 levels of technical support and promises that 
it will be fixed and wont break your code.

the logic is in the philosophy not the marketing = no seminar is ever 
going to solve this problem :)

anyway -  just one angle to try

best regards
alan

Dave Mertens wrote:

>On Tue, Apr 16, 2002 at 07:27:06AM -0700, brad lafountain wrote:
>
>>>And next week i have a special C# traning for PHP developers. Offered free by
>>>Microsoft.
>>>
>> alls i have to say is WOW. This is one pathetic attempt by Microsoft. 
>>
>Yeah, but are there any professional tranings for PHP? Do you hear of PHP? 
>That's the problem i'm facing. I think PHP is great, i really am.
>
>But the fact the PHP don't have a proper XML parser, only a scripting SOAP parser 
>makes it for my boss easy to choose for ASP/Java in stead of PHP. And what can i do 
>about it, absolutely nothing!
>I don't have the knowledge to make PHP itself better. That why i submit as much as i 
>can (and allowed) to PEAR.
>
>Hoping that it will end as a set of foundation classes.
>
>But now, all new projects are done with ASP. And why? Because Microsoft has a damn 
>good marketing machine.
>They even have now commercials for .NET! 
>
>And about the training. Microsoft knows that PHP is getting behind and they are 
>saying that .NET can do almost everything what PHP can and more.
>I can only say that i hope ZE2 will change this. But i have a hard time on my work 
>defending PHP.
>
>Yeah. When a company becomes a Microsoft Partner you get a lot of MS licenses for 
>free! Buy MSDN Universal and you get more programs for Free.
>And the company i work for is a gold partner. We have 100 free licenses for XP! Why 
>use linux??
>
>2 years ago PHP was leading egde. I hope that the ZE2 engine makes it a leading 
>language again.
>
>Dave Mertens
>




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




Re: [PHP-DEV] FRC: pg_metadata, pg_convert, pg_insert, etc

2002-04-10 Thread Alan Knowles

 sounds really nice..
would it be possible to accept objects as well as arrays?
how does it know if the update column should be an integer or string - 
eg. '12' or 12 ? - is that what the meta data is for?
regards
alan

Markus Fischer wrote:

>Can you elaborate more on the mystic 'metadata' and what it
>reallt means to the functions?
>
>On Wed, Apr 10, 2002 at 04:43:21PM +0900, Yasuo Ohgaki wrote : 
>
>>Hi to all database module maintainers,
>>
>>I've committed some new PostgreSQL functions and
>>manual pages for these.
>>
>>pg_metadata() - get medata data
>>pg_convert() - check and convert array accoding to metadata
>>pg_insert()/update()/select()/delete() - does insert, etc by
>>array.
>>
>>With the new function, users can do safely.
>>
>>>
>>$db = pg_connect();
>>pg_insert($db, 'get_value_log', $_GET) or user_sent_malformed_data();
>>
>>?>
>>
>>Since, pg_insert() lookup metadata and convert array values
>>safely used in SQL.
>>
>>Please take a look at API, since you or other person may
>>implement same feature for your database in the future.
>>And API should be consistent whenever it's possible.
>>
>>I can change API if it's before PHP 4.3.0.
>>Thank you.
>>
>>--
>>Yasuo Ohgaki
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>-- 
>>PHP Development Mailing List 
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>




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




Re: [PHP-DEV] __CLASS__ patch - use $__THIS__ or class_get_called_name()?

2002-04-05 Thread Alan Knowles

Zeev Suraski wrote:

> This should really be implemented 100% in compile time, if you touch 
> zend_execute.c, BUZZ :)
> Anyway, incidentally, Jani implemented this very patch a few days 
> ago.  We'll probably import it within a couple of days after we verify 
> that it doesn't cause any gotcha's...
>
> Zeev 



As we chatted breifly on IRC,- Jani's patch implemented __FUNCTION__ and 
__CLASS__ as compile time values, hence in the example below they would 
return "base_class::test", and not extended_class::test





while this is also very usefull, the real desire/need I had was to get 
the 'called' class name (some examples of usage are below), which is a 
bit more complex to retreive: - as it is part of the calling scope of 
zend_execute, but not currently passed down to the running scope...

The implementation of this 'feature' does raise a few issue - should it 
be a constant, function call or a variable?

Constant: __THIS__
Unlike all other magic constants, like __FILE__,_LINE__ etc. it is not 
possible (AFAICS) to 'set' the value at compile time. - hence the rather 
chessy hack to the Constant callback on the execute loop. - The more I 
look at this the worse it looks :)

Function call: class_get_name() or class_get_called_name();
The present implemenation tagged extra information onto the function 
call (a pointer to the classname), I attepted to use a function call, 
this would involve adding an additional item to exectute globals eg. 
EG(active_class_name), and setting and unsetting,  before after each 
function call.

Variable: $_THIS or $THIS  or $__THIS__
This would involve pretty much replicating the current ZE1 code that 
creates '$this' and do something like if EX(called_class_name) ... make 
it as a zval in the called method's scope.
Considering this would __only__ happen on static method calls, and the 
size of the 'Class Name' is not normally Huge..., I think the very minor 
performance hit of creating this on static calls would be worth it. 
and is simple to implement as well.
(This is my favourite candidate at present :)
The last option does not alter any key 'structures', which I found broke 
the ZendAPI, causeing some zend extensions to segfault  :)


---Ok some code that uses it

class database_tools {
/* the normal 'get' method */

function &static_get($k,$v=NULL) {
$obj = new $__THIS__;
$obj->get($k,$v)
return $obj;
}

function get($k,$v=NULL) {
if ($v === NULL) {
$v = $k;
$keys = $this->_get_keys();
$k = $keys[0];
}
$this->$k = $v;
$this->select();
}
   
class db_users extends database_tools {
var $_table = "person";
function get($k,$v) {
$this->$k = $v;
if ($k = "firstname_letter");
$this->where_add("firstname like '$v%'");
$this->select();
}
}
class db_classrooms extends database_tools {
var $_table = "classrooms";
}

--- and the calling code examples...

$classroom = db_classrooms::static_get("number",12304);
$person= db_users::static_get(123);
$person= db_users::static_get("email","[EMAIL PROTECTED]");
$person= db_users::static_get("firstname_letter","a"); /

-- only way to do something similar without $__THIS__
$classroom = database_tools::static_get("db_classrooms","number",12304);
$person= database_tools::static_get("db_users",123);
$person= database_tools::static_get("db_users","email","[EMAIL PROTECTED]");
$person= database_tools::static_get("db_users","firstname_letter","a");

apart from the 'slightly shorter' naming :), the first example reads 
alot better.. - eg. I'm asking the users object for item 123..

whereas the database_tools is supposed to be a 'utility class' not an 
publically visable 'interface class'

that whole code could be simplified again if the get method knew it was 
being called statically.. and could call it'self!







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




Re: [PHP-DEV] __CLASS__ patch - returns called class

2002-04-05 Thread Alan Knowles

Any chance of sneeking this one in :) - patch attached

usage:
test();
?>

prints
testclass2
testclass2

extremely usefull for building mulitiple extendable constructors.

regards
alan




diff -b -B -r -u php-4.2.0RC2/Zend/zend_compile.h ALAN_Zend/zend_compile.h
--- php-4.2.0RC2/Zend/zend_compile.hSun Feb 10 20:52:45 2002
+++ ALAN_Zend/zend_compile.hFri Apr  5 17:26:04 2002
@@ -81,7 +81,7 @@
 
zend_uchar *arg_types;  /* MUST be the second element of this struct! 
*/
char *function_name;/* MUST be the third element of this 
struct! */
-
+ char *class_name;   /* set at execute time to record the active class */
zend_uint *refcount;
 
zend_op *opcodes;
@@ -114,7 +114,7 @@
 
zend_uchar *arg_types;  /* MUST be the second element of this struct */
char *function_name;/* MUST be the third element of this 
struct */
-
+char *class_name;   /* set at execute time to record the active class */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
 } zend_internal_function;
 
@@ -124,7 +124,7 @@
 
zend_uchar *arg_types;  /* MUST be the second element of this struct */
char *function_name;/* MUST be the third element of this struct */
-
+char *class_name;   /* set at execute time to record the active class */
zend_uint var;
 } zend_overloaded_function;
 
@@ -135,6 +135,7 @@
zend_uchar type;  /* never used */
zend_uchar *arg_types;
char *function_name;
+char *class_name;   /* set at execute time to record the active 
+class */
} common;

zend_op_array op_array;
diff -b -B -r -u php-4.2.0RC2/Zend/zend_execute.c ALAN_Zend/zend_execute.c
--- php-4.2.0RC2/Zend/zend_execute.cSun Jan  6 23:21:09 2002
+++ ALAN_Zend/zend_execute.cFri Apr  5 17:26:04 2002
@@ -1485,6 +1485,7 @@
zend_function *function;
HashTable *active_function_table;
zval tmp;
+char *class_name=NULL;
 
zend_ptr_stack_n_push(&EG(arg_types_stack), 2, 
EX(fbc), EX(object).ptr);
if (EX(opline)->extended_value & 
ZEND_CTOR_CALL) {
@@ -1521,6 +1522,7 @@
if 
(zend_hash_find(EG(class_table), EX(opline)->op1.u.constant.value.str.val, 
EX(opline)->op1.u.constant.value.str.len+1, (void **) &ce)==FAILURE) { /* class 
doesn't exist */
zend_error(E_ERROR, 
"Undefined class name '%s'", EX(opline)->op1.u.constant.value.str.val);
}
+class_name =  ce->name;
active_function_table = 
&ce->function_table;
} else { /* used for member function 
calls */
EX(object).ptr = 
_get_object_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1) TSRMLS_CC);
@@ -1564,6 +1566,7 @@
zend_error(E_ERROR, "Call to undefined 
function:  %s()", function_name->value.str.val);
}
zval_dtor(&tmp);
+function->common.class_name = class_name; 
EX(fbc) = function;
 overloaded_function_call_cont:
FREE_OP(EX(Ts), &EX(opline)->op2, 
EG(free_op2));
@@ -1955,11 +1958,29 @@
NEXT_OPCODE();
case ZEND_FETCH_CONSTANT:
if 
(!zend_get_constant(EX(opline)->op1.u.constant.value.str.val, 
EX(opline)->op1.u.constant.value.str.len, &EX(Ts)[EX(opline)->result.u.var].tmp_var 
TSRMLS_CC)) {
+   /*if 
+(!strcmp(EX(opline)->op1.u.constant.value.str.val,"__FUNCTION__")) {
+char *function_name = 
+get_active_function_name(TSRMLS_C);
+if (!function_name) function_name ="";
+
+EX(Ts)[EX(opline)->result.u.var].tmp_var.value.str.val = function_name;
+
+EX(Ts)[EX(opline)->result.u.var].tmp_var.value.str.len = strlen(function_name);
+
+EX(Ts)[EX(opline)->result.u.var].tmp_var.type = IS_STRING;
+
+zval_copy_ctor(&EX(Ts)[EX(opline)->result.u.var].tmp_var);
+ 

[PHP-DEV] getting the called name from a static method - extending zend_function?

2002-04-03 Thread Alan Knowles

This is what I was trying to do,

class master {
function static_test($var) {
$class = get_class() <- this wont work obviously :)
$ret = new $class();
$ret->get($var);
if (!$ret->N) return;
return $ret;
}
}

class slave extends master {
 function get($var) {
   $this->N=1;
}
}

if ($obj = slave::static_test(123))
   $obj->do_stuff();
.

basically there is no way that I can see to get the called class out of 
the so that it would make a slave when called, not a master :)

 From a breif (well at least an hour or so :) look at the zend code - 
this was the solution i came up with - to extend the zend function to 
have an additional called_function_name pointer to store this in and 
have a extra magic define __CALLED_FUNCTION__

--- below are my notes how it might be done - is there any major 
objection/better ideas,  before I waste some time playing with it :)




zend_compile.h

 132  typedef union _zend_function 
 {
133  zend_uchar 
 type ;
*//* MUST be the first element of this struct! *//*
134  struct {
135  zend_uchar 
 type ;  *//* 
never used *//*
136  zend_uchar 
 *arg_types;
137  char 
*function_name;
char *called_function_name;
138  } common 
;
139  
140  zend_op_array 
 op_array;
141  zend_internal_function 
 internal_function;
142  
zend_overloaded_function  
overloaded_function;
143  } zend_function 
;
144  





  zend_execute.c



ZEND_INIT_FCALL_BY_NAME : {
1484   
   zval  *function_name;
1485   
   zend_function  *function 
;
1486   
   HashTable  *active_function_table;
1487   
   zval  tmp;
1488   
   char *called_function_name=NULL;





 if (zend_hash_find 
(EG 
(class_table), EX 
(opline)->op1.u.constant.value 
.str .val 
, EX 
(opline)->op1.u.constant.value 
.str .len 
+1, (void **) &ce)==FAILURE 
) { *//* class doesn't exist *//*
1522   
   zend_error 
(E_ERROR , 
/"Undefined class name '%s'"/, EX 
(opline)->op1.u.constant.value 
.str .val 
);
1523   
   }

called_function_name = (char *) EX 
(opline)->op1.u.constant.value 
.str .val 
;

1524 

Re: [PHP-DEV] DB Abstraction - db_oo - the query builder

2002-03-31 Thread Alan Knowles

As a side note to this, I did another major overhall to my query 
builder/ simplified db access layer, db_oo - and put up a small amount 
of documentation, although there is a small amount of mysql dependance 
in there, it's not impossible to remove...

http://www.akbkhome.com/Projects/db_oo%20-%20an%20object%20based%20Sql%20builder%20and%20wrapper%20for%20peardb/

It is an evolving tool, as its the base I use for a number of projects - 
it can build a object based data access to any mysql database within 
about 2 minutes, anyway if anyone wants to start thinking through 
ideas about sql builders, this does have alot of the 'chore work' done. 
Let us know if anybody is interested - it's API is still pretty flexible..

regards
alan


Stig S. Bakken wrote:

>On Fri, 2002-03-29 at 13:01, Daniel Lorch wrote:
>
>>Hi,
>>
>>I'm a bit confused about the ongoing projects aiming towards a
>>standard for database abstraction in PHP. There is DBA
>>[ http://php.net/dba ], PEAR DB and a project by l0t3k (and
>>many, many more).
>>
>>So what is going to be "the standard" in PHP's future?
>>
>>I think l0t3k is working on a C based solution, but there are several
>>reasons I'd like to see it written in PHP. PHP code could be easily
>>extended to handle mechanisms such as
>>
>>- caching: only a SELECT? then read from cached file (serialized
>>   result set). INSERT/DELETE/UPDATE? then refresh cache.
>>   
>>- safety: server1 down? ok, move to backup server2.
>>
>>- redundancy: randomly spread read-only queries (SELECT) to servers in
>>  a cluster.
>>  
>>(- extensibility (I put this in brackets, as it is only a vague idea):
>>   For example missing features in MySQL such as subselects could be
>>   simulated by using temporary HEAP tables. This would make this
>>   abstraction layer even more powerful than accessing the database
>>   directly)
>>
>>Most important: this all works *transparently* to the user's script.
>>A system administrator could adjust this abstraction
>>layer to fit the system configuration. The users would
>>just include this file in their projects and never get in
>>touch with these things.
>>
>>What do you think? Am I completely wrong/fantasising/talking too much?
>>
>
>When speaking about database abstraction, people (including me) are
>often mixing different concepts, knowingly or not.  The layers involved
>are:
>
>1. common API
>2. feature compatibility layer (easy query rewrites, type abstraction,
>   handling slightly different usage paradigms such as mysql's
>   auto_increment vs. real sequences, etc.)
>3. query builders, schema management, etc. (basically everything that
>   can be done by wrapping existing functions/methods or generating SQL)
>
>All database abstraction layers provide (1).  Most provide (2) to a
>bigger or lesser extent, with Metabase going the furthest, while few
>provide much from (3).
>
>IMHO an efficient database abstraction layer should provide only (1) and
>(2).  The rest like caching, server redundancy, query builders etc. can
>be put on top of the abstraction layer itself and maintained separately.
>
>What PHP really needs is a common C API for (1) and possibly (2) that
>the database extensions themselves provide.  That way there would be no
>need for additional layers written in PHP or piggyback hacks like dbx
>(sorry Marc :).  Come to think of it, ODBC's CLI (Call Level Interface,
>what ext/odbc uses) could be this common C API.
>
> - Stig
>
>




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




[PHP-DEV] Re: Bug #16232 Updated: remalloc FAIL on CURLOPT_HEADERFUNCTION callback

2002-03-23 Thread Alan Knowles

patch attached

regards
alan
[EMAIL PROTECTED] wrote:

> ID:   16232
> Updated by:   [EMAIL PROTECTED]
> Reported By:  [EMAIL PROTECTED]
>-Status:   Open
>+Status:   Feedback
> Bug Type: cURL related
> Operating System: linux
> PHP Version:  4.0CVS-2002-03-23
> New Comment:
>
>Hey Alan,
>
>can you please mail this patch to php-dev?
>
>regards,
>Derick
>
>
>Previous Comments:
>
>
>[2002-03-23 10:11:02] [EMAIL PROTECTED]
>
>Fixes:
>callback to curl_setopt(CURLOPT_HEADERFUNCTION..) always causes this.
>FATAL:  erealloc():  Unable to allocate 1075529781 bytes
>
>Fix:
>Basically a copy of the curl_write to curl_write_header
>
>Affects: 
>all versions (that I know of - including 4.2.0rc1 & 4.2.0-dev)
>
>test code at
>http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpmole-ide/phpmole/tools/web_get.php?rev=1.2&content-type=text/vnd.viewcvs-markup
>
>usage:
>php web_get.php http://www.php.net
>  
> /*  
>



Index: curl.c
===
RCS file: /repository/php4/ext/curl/curl.c,v
retrieving revision 1.103
diff -u -r1.103 curl.c
--- curl.c  24 Dec 2001 13:58:03 -  1.103
+++ curl.c  24 Mar 2002 02:30:04 -
@@ -319,7 +319,7 @@
 
ZVAL_RESOURCE(argv[0], ch->id);
zend_list_addref(ch->id);
-   ZVAL_STRINGL(argv[1], data, (int) length, 1);
+   ZVAL_STRINGL(argv[1], data, length, 1);
 
error = call_user_function(EG(function_table),
   NULL,
@@ -373,7 +373,7 @@
zend_list_addref(ch->id);
ZVAL_RESOURCE(argv[1], t->fd);
zend_list_addref(t->fd);
-   ZVAL_LONG(argv[2], size * nmemb);
+   ZVAL_LONG(argv[2], (int) size * nmemb);
 
error = call_user_function(EG(function_table),
   NULL,
@@ -406,8 +406,7 @@
 {
php_curl   *ch  = (php_curl *) ctx;
php_curl_write *t   = ch->handlers->write_header;
-   int error;
-   int length;
+   size_t  length = size * nmemb;
TSRMLS_FETCH();

switch (t->method) {
@@ -415,33 +414,30 @@
/* Handle special case write when we're returning the entire transfer
 */
if (ch->handlers->write->method == PHP_CURL_RETURN)
-   smart_str_appendl(&ch->handlers->write->buf, data, size * 
nmemb);
+   smart_str_appendl(&ch->handlers->write->buf, data, (int) 
+length);
else
PUTS(data);
-
-   length = size * nmemb;
-
break;
case PHP_CURL_FILE:
-   length = fwrite(data, size, nmemb, t->fp);
-   break;
+   return fwrite(data, size, nmemb, t->fp);
case PHP_CURL_USER: {
zval *argv[2];
zval *retval;
+   int   error;
TSRMLS_FETCH();
-   
+
MAKE_STD_ZVAL(argv[0]);
MAKE_STD_ZVAL(argv[1]);
MAKE_STD_ZVAL(retval);
 
ZVAL_RESOURCE(argv[0], ch->id);
zend_list_addref(ch->id);
-   ZVAL_STRINGL(argv[0], data, size * nmemb, 1);
+   ZVAL_STRINGL(argv[1], data, length, 1);
 
-   error = call_user_function(EG(function_table), 
-  NULL,
+   error = call_user_function(EG(function_table),
+  NULL,
   t->func,
-  retval, 2, argv TSRMLS_CC);
+  retval, 2, argv TSRMLS_CC);
if (error == FAILURE) {
php_error(E_WARNING, "Couldn't call the 
CURLOPT_HEADERFUNCTION");
length = -1;
@@ -449,17 +445,14 @@
else {
length = Z_LVAL_P(retval);
}
-
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&retval);
break;
}
case PHP_CURL_IGNORE:
-   length = size * nmemb;
-   break;
-   }
-   
+   return length;
+   }
return length;
 }
 /* }}} */



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


Re: [PHP-DEV] Floating point comparisons - A fix

2002-03-19 Thread Alan Knowles

wouldnt ~==  ,~>, ~<, ~>=  etc. be relivant here -
from what I remember of maths, (to long ago) ~ was the symbol for 
similar (and 2 together for approximatly equal) - hey even found a 
reference for it...
http://www.gomath.com/htdocs/ToGosheet/algebra/mathsymbols.html

the only thing is it would confuse perl people :) =~ (it;s the regex 
symbol in perl)

regards
alan

Rasmus Lerdorf wrote:

>That'd be a pretty serious performance hit to take.  Do you know of any
>language where floating point comparisons work like that?  Certainly in
>both C and Perl you will never get 0.8 to equal 0.7+0.1 exactly.
>
>Just because nobody else does it is of course not reason enough not to do
>it, but doing 2 sprintf's for every floating point comparison makes me
>cringe.
>
>-Rasmus
>
>On Tue, 19 Mar 2002, George Whiffen wrote:
>
>>Hi Folks,
>>
>>0.8 == 0.7 + 0.1 or does it?
>>
>>I know I've brought this up before, but it's still driving me nuts, and
>>I still don't know how to explain it to a novice, so rather than go on
>>ranting I thought I'd try a fix.
>>
>>I'm no C programmer, and what I know about php source can be written on
>>the back of a very small envelope.  But at least you can laugh at my
>>appalling code, and, hopefully, explain to me why it can't go in the
>>next release ;).
>>
>>Summary
>>===
>>The fix is based on a string convert and comparison. It seems to work,
>>is not too serious from a performance point of view, and only involves
>>two sources, four functions and a 100 lines or so of code.  It does not
>>create cumulative rounding errors, is easily controlled via an existing
>>ini variable i.e. "precision" and improves the consistency of php's use
>>of precision.
>>
>>The Bugs/Undesirable Features
>>=
>>0.8 == 0.7 + 0.1 evaluates to false
>>(int) (8.2 - 0.2) evaluates 7
>>intval(8.2 - 0.2) evaluates to 7
>>floor(10 * (0.7 + 0.1)) evaluates to 7
>>ceil (10 * (-0.7 + -0.1) evaluates to -7
>>
>>Basis of the Fix
>>==
>>In general these would all evaluate correctly if they were evaluated to
>>the precision specified in php.ini (typically 14 for IEEE 64bit).
>>
>>The fix replaces the current equality test on doubles, (a - b == 0),
>>with  a string compare to 'precision' decimal places e.g.
>>sprintf("%.14G",a) == sprintf("%.14G",b).  This is a modification to the
>>doubles section of the Zend/zend_operators.c compare_function, which
>>ultimately handles all comparisons, ==, !=, >=, >, <, <=.
>>
>>Floor, ceil, (int), intval(), are fixed with an equality check of their
>>integer result to one above or below it, (as  appropriate) via the
>>modified compare_function.
>>
>>e.g. floor becomes
>>if  a == floor(a) + 1
>>return floor(a) + 1;
>>else
>>return floor(a)
>>
>>Apart from some performance tweaks, that's about it i.e.
>>Zend/zend_operators.c:compare_function
>>Zend/zend_operators.c:convert_to_long_base
>>ext/standard/math.c:ceil
>>ext/standard/math.c:floor
>>
>>Testing
>>===
>>The fixes seem to work. However, they have only been tested on a 4.1.2
>>source under Linux 2.4.8-26mdk. They solve the problems listed above
>>and  do as well as a basic cgi build of 4.1.2 on run-tests.php (i.e.
>>they pass everything except pow.phpt, pear_registry.phpt and 029.phpt).
>>They also seem to behave identically to an unfixed version if
>>'precision' is set high enough e.g. set_ini('precision',18).
>>
>>
>>Backward Compatibility
>>
>>I've tried and failed to come up with a realistic scenario where this
>>fix compromises existing user code.
>>
>>The main reason is that  string, printf, sprintf already force the
>>precision set in php.ini.  This means it quite difficult for someone to
>>have exploited the fact that compare_function does not.  To hit problems
>>with the fix they would have to have first  decided they care about the
>>digits beyond 'precision',  but do not care enough to use the bc
>>library.  They then have to gone to some trouble to get hold of those
>>extra digits. They could not, for instance, easily get them into a page
>>or database without a conversion to string automatically removing the
>>extra digits along the way.
>>
>>In contrast to a "round to precision after each floating point
>>operation" approach, (which would be a nightmare), these fixes should
>>not create any new issues with cumulative rounding errors.  All the
>>changed functions already return booleans, ints, or integer-rounded
>>floats.
>>
>>In any case, everything can easily be reverted to the old functionality
>>at execution time simply by  increasing the value of precision e.g.
>>set_ini('precision',18).
>>
>>
>>Performance
>>===
>>Only doubles are effected.  Long comparisons, such as integer for-loops
>>(for($i=0;$i<$sizeof($aray);++$i) etc.), are unchanged and run just as
>>fast.
>>
>>The effect on double comparisons is not negligible.  sprintf's are
>>relatively expensive in terms of performance and adding the overhead of
>>two sprintfs to every single double compa

[PHP-DEV] Re: [PEAR-DEV] Improving speed -> caching hash results in zend_execute?

2002-03-18 Thread Alan Knowles

Does anyone want to comment on this (the full threads on PEAR-DEV), 
about the results (2) and (3),  - 2 is a wrapper call to another 
function 3 is directly calling a function/method - I think it was 20,000 
times (1) is the original PEARdb call - with some extra ifs...etc.

anyway - the overhead for wrapping the call was quite high..

I had a look at the code in zend_execute.c (in ZE2 & ZE1) - the question 
goes something like this - I'm guessing that it's the hash table lookups 
being repeatedly called causing this slowdown. (couldnt see anything 
else...)

Would it not be an idea to cache in the opcode for the function call the 
result of the last hashtable lookup, then check if that lookup was valid 
first rather than doing a hashtable lookup on each call?

(or am I talking out my ass :)

regards
alan


Tomas V.V.Cox wrote:

>Alan Knowles wrote:
>
>> Thomas - does it make any difference if you add a fast fetch method?
>>Class DB
>>
>>funcition fastFetchInto(&$arr|,$fetchmode|) {|
>>return  $this->dbh->fetchInto($this->result, $arr, $fetchmode);|
>>}
>>
>
>It makes some difference yeah, but still not all we would want to get:
>Results:
>1 -> 26.209026 seconds
>2 -> 13.831852 seconds
>3 -> 19.579646 seconds
>
>> 
>>
>
>
>
>Tomas V.V.Cox
>




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




Re: [PHP-DEV] Vote on New Build System

2002-03-07 Thread Alan Knowles

I presume that the old
PHP_EXENTSION() still works in V5
so modules outside the php tree can keep using it? ... and put in
dnl PHP_EXENTSION_NEW.
so it's V5 ready...


regards
alan

>
>
>On Thu, 7 Mar 2002, Sascha Schumann wrote:
>
>>I'd like to get some input on the new build system.  If there
>>are enough "yea" voices, I could merge it into 4.3.0..
>>
> 
>go for it (or should I say "yea" :)
>
>Derick
>
>>The current patch against the CVS is here:
>>
>>http://schumann.cx/buildv5.patch
>>
>>This version adds support for the test target and PHP_DEFINE
>>which aims at enabling more fine-grained dependencies and
>>phasing out the 2000 lines php_config.h.  This fine-grained
>>approach has been used by the BSD kernels and Linux for some
>>time and is simply necessary for larger systems.
>>
>>The system preserves quite a lot of disk space and improves
>>the speed of the PHP build.
>>
>>An overview of the system follows:
>>
>>
>>PHP Build System V5 Overview
>>
>>- supports Makefile.ins during transition phase
>>- not-really-portable Makefile includes have been eliminated
>>- supports seperate build directories without VPATH by using
>>  explicit rules only
>>- does not waste disk-space/CPU-time for building temporary libraries
>>  => especially noticeable on slower systems
>>- slow recursive make replaced with one global Makefile
>>- eases integration of proper dependencies
>>- adds PHP_DEFINE(what[, value]) which creates a single include-file
>>  per what.  This will allow more fine-grained dependencies.
>>- abandoning the "one library per directory" concept
>>- improved integration of the CLI
>>- several new targets
>>  build-modules: builds and copies dynamic modules into modules/
>>  install-cli: installs the CLI only, so that the install-sapi
>>   target does only what its name says
>>- finally abandoned automake (still requires aclocal at this time)
>>- changed some configure-time constructs to run at buildconf-time
>>- upgraded shtool to 1.5.4
>>- removed $(moduledir) (use EXTENSION_DIR)
>>
>>The Reason For a New System
>>
>>It became more and more apparent that there is a severe need
>>for addressing the portability concerns and improving the chance
>>that your build is correct (how often have you been told to
>>"make clean"? When this is done, you won't need to anymore).
>>
>>
>>If You Build PHP on a Unix System
>>
>>
>>You, as a user of PHP, will notice no changes.  Of course, the build
>>system will be faster, look better and work smarter.
>>
>>
>>
>>If You Are Developing PHP
>>
>>
>>
>>
>>Extension developers:
>>
>>Makefile.ins are abandoned.  The files which are to be compiled
>>are specified in the config.m4 now using the following macro:
>>
>>PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
>>
>>E.g. this enables the extension foo which consists of three source-code
>>modules, two in C and one in C++.  And dependending on the user's
>>wishes, the extension will even be built as a dynamic module.
>>
>>The full syntax:
>>
>>PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
>>
>>Please have a look at acinclude.m4 for the gory details and meanings
>>of the other parameters.
>>
>>And that's basically it for the extension side.
>>
>>If you previously built sub-libraries for this module, add
>>the source-code files here as well.  If you need to specify
>>separate include directories, do it this way:
>>
>>PHP_NEW_EXTENSION(foo, foo.c mylib/bar.c mylib/gregor.c,,,-I@ext_srcdir@/lib)
>>
>>E.g. this builds the three files which are located relative to the
>>extension source directory and compiles all three files with the
>>special include directive (@ext_srcdir@ is automatically replaced).
>>
>>Now, you need to tell the build system that you want to build files
>>in a directory called $ext_builddir/lib:
>>
>>PHP_ADD_BUILD_DIR($ext_builddir/lib)
>>
>>Make sure to call this after PHP_NEW_EXTENSION, because $ext_builddir
>>is only set by the latter.
>>
>>If you have a complex extension, you might to need add special
>>Make rules.  You can do this by calling PHP_ADD_MAKEFILE_FRAGMENT
>>in your config.m4 after PHP_NEW_EXTENSION.
>>
>>This will read a file in the source-dir of your extension called
>>Makefile.frag.  In this file, $(builddir) and $(srcdir) will be
>>replaced by the values which are correct for your extension
>>and which are again determined by the PHP_NEW_EXTENSION macro.
>>
>>Make sure to prefix *all* relative paths correctly with either
>>$(builddir) or $(subdir).  Because the build system does not
>>change the working directory anymore, we must use either
>>absolute paths or relative ones to the top build-directory.
>>Correct prefixing ensures that.
>>
>>
>>SAPI developers:
>>
>>Instead of using PHP_SAPI=foo/PHP_BUILD_XYZ, you will need to type
>>
>>PHP_SELECT_SAPI(name, type, sources.c)
>>
>>I.e. specify the source-code files as above and also pass the
>>information regarding how PHP is suppos

Re: [PHP-DEV] [PROPOSAL] defense against session takeovers

2002-02-01 Thread Alan Knowles

based on something nasty i did with cookies a while back

Session id
[][bb]
eg. first 32? chars are the standard md5, the remainder is a variable 
length key.

aaa - the standard session id. (eg. the filename)
bbb - an simple key overlay

say the session file contains
'abcd'
and
b contains
 0au2dr
then the resulting sessoin file would contain :
char 1 = (a + 0) mod 256
char 2 = (b + a) mod 256
char 3 = (c + u) mod 256

and so on. -- to decrept you obvious overlay the negative with modulus..

its an incredibly dumb and simple encryption method.. - but it may solve 
alot of the concerns...
- eg. without the full session id, you cant use the session file. or 
guess the full session file..

anyway its early morning so I probably missed something..
 - it doesnt make it impossible - just alot more difficult...

regards
alan





Ivan Ristic wrote:

>>The general philosophy of PHP has always been to make PHP easy for the
>>beginner yet flexible enough for advanced users.  This fits that rule.
>>Give the advanced users the tools to configure PHP to have per-virtualhost
>>session handling, while sessions still work for the guy who just installed
>>PHP on his own little server and really doesn't know what he is doing.
>>
>
>  That is fine for a philosophy. I would still like to try to make
>  the default setup more secure. I agree, the least we can do is to
>  document this.
>
>  How about that we use the SERVER_NAME environment variable when
>  generating session filenames? Instead of name like sess_, the name
>  could be sess__, where  is a server fingerprint? I
>  understand that this is not foolproof (say, for applications
>  that run on the same domain name) but it will solve the most
>  serious cases (shared hosting solutions).
>
>--
>Ivan Ristic, [EMAIL PROTECTED]
>[ Weblog on PHP, Software development, Intranets,
>and Knowledge Management: http://www.webkreator.com ]
>
>




-- 
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]




Re: [PHP-DEV] Optional source scrambeling

2002-01-30 Thread Alan Knowles

Jerrett Taylor wrote:

>I agree.. Also if you have a way of distributing binarys, you can
>release the source with it.. Much like a lot of people do already with
>binaries for *nix .. 
>
>That way you have a binary, that people can use/run without hacking it
>apart, and coming back to you with "I broke it, fix it for me!" , and
>they can look at the source (if you want) to see how its done
>
>
>.. Best of both worlds!
>
modfying the file io layer to deal with encoded (dump of the parsed data 
structs) files, is realitivly simple in theory, so if you have the 
time. :)

what I posted a while back was a method of merging php code into an 
extension. - It was theoretically postible to do that as well.., however 
it was not wonderfully effecient in terms of design. - you basically had 
to recompile the whole php binary just to use the code... - the nicer 
option would be what the old phpcompiler did - just add the code to the 
end of the php binary??? and do some other changes to make it execute 
the binary using the attached data. - If somebody could send me a copy 
:) - I'd love to see how that was done.. - searching google for 'merging 
data into exectutable binaries' doesnt get anywhere... :)
eg.
1. how does the php binary know where it's theoretical end point is, and 
the other data starts.. (guess work and looking for a data sequence?)
2. how does it read data from it's own internal memory, relative to the 
programs loaded memory space! - that one really threw me - otherwise it 
would have to load the file into memory, the re-read the data from it's 
own binary off the disk - sounds as bad as Plan A :)...
3. how can you make it cross platform!

from my aspect - looking at phpgtk apps, the compiled/protected bit is 
not important - its the distribution of a single exe + a few dll's 
rather than getting individual windows users to have a whole load of 
text files lying around.. - as everyone here knows there not much 
difference between the two - but try explaining that to the average 
windows IT manager =  saftey in familarity :)

regards
alan



-- 
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]




[PHP-DEV] pthread & thread support : issues?

2002-01-21 Thread Alan Knowles

After spending yesterday looking at the pcntl library, I did at one 
point attempt to get create_thread going, It didnt get very far, (it 
segfaulted on emalloc - perhaps because thread_init had not been called) 
but I did start wondering about the feasibilty..

Has anybody ever attempted it?

The basic task of creating a set of php functions which wrapped the 
thread library - based perhaps on some of the code in python's thread 
library didnt seem particulary complex, however can anyone think of any 
issues that would occur?

Would it only work as a built in module rather than a loadable module?

anyway, I couldnt find any threads 'on threads:)' on php-dev discussing 
it - has anybody got any comments?

regards
alan


-- 
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]




Re: [PHP-DEV] Fixes for pcntl - class support. (patch attached)

2002-01-21 Thread Alan Knowles

Looks like mozilla buggered up the attachment.

Alan Knowles wrote:

> Well, after half a dozen bug reports that didnt actually work... - 
> this one should, could somebody comment/commit etc.
>
> The patch includes a number of changes... -
> pcntl_zend_extension_active does not appear to be getting set when 
> using modules
> this little magic trick to get the zval stored in the hash table for 
> callbacks
>
> +   MAKE_STD_ZVAL(handle_copy);
> +*handle_copy = **handle;
> +zval_copy_ctor(handle_copy);
>
> I deleted this as it was confusing me alot :) - obviously not 
> essential to the patch
> old_pcntl_signal_handler(int signo)
>
> added a new function
> pcntl_doevents = works a bit like gtk::do_events();
> basically calls any pending signal callbacks. - as the 
> pcntl_zend_extension_statement_handler did not appear to get called 
> when running from a module.
>
>
> best regards
> alan
>
>  
>
>
>
>
>
>
>
>




Index: pcntl.c
===
RCS file: /repository/php4/ext/pcntl/pcntl.c,v
retrieving revision 1.18
diff -u -r1.18 pcntl.c
--- pcntl.c 4 Jan 2002 14:08:25 -   1.18
+++ pcntl.c 21 Jan 2002 08:36:05 -
@@ -18,7 +18,7 @@
 
 /* $Id: pcntl.c,v 1.18 2002/01/04 14:08:25 hholzgra Exp $ */
 
-#define PCNTL_DEBUG 0
+#define PCNTL_DEBUG 0
 
 #if PCNTL_DEBUG
 #define DEBUG_OUT printf("DEBUG: ");printf
@@ -51,6 +51,7 @@
PHP_FE(pcntl_wtermsig, NULL)
PHP_FE(pcntl_wstopsig, NULL)
PHP_FE(pcntl_exec, NULL)
+PHP_FE(pcntl_doevents, NULL)
{NULL, NULL, NULL}  
 };
 
@@ -208,7 +209,7 @@
 PHP_FUNCTION(pcntl_fork)
 {
pid_t id;
-
+pcntl_zend_extension_active=1;
id=fork();
if (id == -1) {
php_error(E_ERROR, "Error %d in %s", errno, 
get_active_function_name(TSRMLS_C));
@@ -463,8 +464,9 @@
 PHP_FUNCTION(pcntl_signal)
 {
zval **signo, **handle;
+zval *handle_copy;
char *func_name;
-
+   
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &signo, &handle) == 
FAILURE) {
WRONG_PARAM_COUNT;
}
@@ -474,7 +476,7 @@
/* Special long value case for SIG_DFL and SIG_IGN */
if (Z_TYPE_PP(handle)==IS_LONG) {
if (Z_LVAL_PP(handle)!= (long) SIG_DFL && Z_LVAL_PP(handle) != (long) 
SIG_IGN) {
-   php_error(E_WARNING, "Invalid value for handle argument 
specifEied in %s", get_active_function_name(TSRMLS_C));
+   php_error(E_WARNING, "Invalid value for handle argument 
+specified in %s", get_active_function_name(TSRMLS_C));
}
if (php_signal(Z_LVAL_PP(signo), (Sigfunc *) 
Z_LVAL_PP(handle))==SIG_ERR) {
php_error(E_WARNING, "Error assigning singal in %s", 
get_active_function_name(TSRMLS_C));
@@ -483,22 +485,18 @@
RETURN_TRUE;
} 

-if (Z_TYPE_PP(handle)!=IS_STRING) {
-   php_error(E_WARNING, "Invalid type specified for handle argument in 
%s", get_active_function_name(TSRMLS_C));
-   RETURN_FALSE;
-   }
-
-   convert_to_string_ex(handle); /* Just in case */
-   if (!zend_is_callable(*handle, 0, &func_name)) {
-   php_error(E_WARNING, "%s: %s is not a callable function name error", 
get_active_function_name(TSRMLS_C), func_name);
+   if (!zend_is_callable(*handle, 0, &func_name)) {
+   php_error(E_WARNING, "%s: Argument is not a callable function or 
+method", get_active_function_name(TSRMLS_C), func_name);
efree(func_name);
RETURN_FALSE;
}
efree(func_name);
-
-/* Add the function name to our signal table */
-   zend_hash_index_update(&PCNTL_G(php_signal_table), Z_LVAL_PP(signo), 
Z_STRVAL_PP(handle),  (Z_STRLEN_PP(handle) + 1) * sizeof(char), NULL);
-   
+MAKE_STD_ZVAL(handle_copy);
+*handle_copy = **handle;
+zval_copy_ctor(handle_copy);
+
+zend_hash_index_update(&PCNTL_G(php_signal_table), Z_LVAL_PP(signo),  
+&handle_copy , sizeof(zval *), NULL);
+ 
if (php_signal(Z_LVAL_PP(signo), pcntl_signal_handler)==SIG_ERR) {
php_error(E_WARNING, "Error assigning singal in %s", 
get_active_function_name(TSRMLS_C));
RETURN_FALSE;
@@ -507,43 +505,14 @@
 }
 /* }}} */
 
-/* Note Old */
-static void old_pcntl_signal_handler(int signo)
-{
-   char *func_name;
-   zval *param, *call_name, *retval;
-   TSRMLS_FETCH();
-
-   DEBUG_OUT("Caught signal: %d\n", signo); 
-   if (zend_hash_index_find(&PCNTL_G(php_signal_table), (long) signo, (void *) 
&fu

[PHP-DEV] Fixes for pcntl - class support.

2002-01-21 Thread Alan Knowles

Well, after half a dozen bug reports that didnt actually work... - this 
one should, could somebody comment/commit etc.

The patch includes a number of changes... -
pcntl_zend_extension_active does not appear to be getting set when using 
modules
this little magic trick to get the zval stored in the hash table for 
callbacks

+   MAKE_STD_ZVAL(handle_copy);
+*handle_copy = **handle;
+zval_copy_ctor(handle_copy);

I deleted this as it was confusing me alot :) - obviously not essential 
to the patch
old_pcntl_signal_handler(int signo)

added a new function
pcntl_doevents = works a bit like gtk::do_events();
basically calls any pending signal callbacks. - as the 
 pcntl_zend_extension_statement_handler did not appear to get called 
when running from a module.


best regards
alan

Index: pcntl.c
===
RCS file: /repository/php4/ext/pcntl/pcntl.c,v
retrieving revision 1.18
diff -u -r1.18 pcntl.c
--- pcntl.c4 Jan 2002 14:08:25 -1.18
+++ pcntl.c21 Jan 2002 08:36:05 -
@@ -18,7 +18,7 @@
 
 /* $Id: pcntl.c,v 1.18 2002/01/04 14:08:25 hholzgra Exp $ */
 
-#define PCNTL_DEBUG 0
+#define PCNTL_DEBUG 0
 
 #if PCNTL_DEBUG
 #define DEBUG_OUT printf("DEBUG: ");printf
@@ -51,6 +51,7 @@
 PHP_FE(pcntl_wtermsig, NULL)
 PHP_FE(pcntl_wstopsig, NULL)
 PHP_FE(pcntl_exec, NULL)
+PHP_FE(pcntl_doevents, NULL)
 {NULL, NULL, NULL}   
 };
 
@@ -208,7 +209,7 @@
 PHP_FUNCTION(pcntl_fork)
 {
 pid_t id;
-
+pcntl_zend_extension_active=1;
 id=fork();
 if (id == -1) {
 php_error(E_ERROR, "Error %d in %s", errno, 
get_active_function_name(TSRMLS_C));
@@ -463,8 +464,9 @@
 PHP_FUNCTION(pcntl_signal)
 {
 zval **signo, **handle;
+zval *handle_copy;
char *func_name;
-
+  
 if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &signo, 
&handle) == FAILURE) {
 WRONG_PARAM_COUNT;
 }
@@ -474,7 +476,7 @@
 /* Special long value case for SIG_DFL and SIG_IGN */
 if (Z_TYPE_PP(handle)==IS_LONG) {
  if (Z_LVAL_PP(handle)!= (long) SIG_DFL && Z_LVAL_PP(handle) != 
(long) SIG_IGN) {
- php_error(E_WARNING, "Invalid value for handle argument 
specifEied in %s", get_active_function_name(TSRMLS_C));
+ php_error(E_WARNING, "Invalid value for handle argument 
specified in %s", get_active_function_name(TSRMLS_C));
 }
 if (php_signal(Z_LVAL_PP(signo), (Sigfunc *) 
Z_LVAL_PP(handle))==SIG_ERR) {
 php_error(E_WARNING, "Error assigning singal in %s", 
get_active_function_name(TSRMLS_C));
@@ -483,22 +485,18 @@
 RETURN_TRUE;
 }

-if (Z_TYPE_PP(handle)!=IS_STRING) {
-php_error(E_WARNING, "Invalid type specified for handle 
argument in %s", get_active_function_name(TSRMLS_C));
-RETURN_FALSE;
-}
-
-convert_to_string_ex(handle); /* Just in case */
-if (!zend_is_callable(*handle, 0, &func_name)) {
-php_error(E_WARNING, "%s: %s is not a callable function name 
error", get_active_function_name(TSRMLS_C), func_name);
+   if (!zend_is_callable(*handle, 0, &func_name)) {
+php_error(E_WARNING, "%s: Argument is not a callable function 
or method", get_active_function_name(TSRMLS_C), func_name);
efree(func_name);
 RETURN_FALSE;
 }
efree(func_name);
-
-/* Add the function name to our signal table */
-zend_hash_index_update(&PCNTL_G(php_signal_table), 
Z_LVAL_PP(signo), Z_STRVAL_PP(handle),  (Z_STRLEN_PP(handle) + 1) * 
sizeof(char), NULL);
-   
+MAKE_STD_ZVAL(handle_copy);
+*handle_copy = **handle;
+zval_copy_ctor(handle_copy);
+   
+zend_hash_index_update(&PCNTL_G(php_signal_table), 
Z_LVAL_PP(signo),  &handle_copy , sizeof(zval *), NULL);
+
 if (php_signal(Z_LVAL_PP(signo), pcntl_signal_handler)==SIG_ERR) {
  php_error(E_WARNING, "Error assigning singal in %s", 
get_active_function_name(TSRMLS_C));
RETURN_FALSE;
@@ -507,43 +505,14 @@
 }
 /* }}} */
 
-/* Note Old */
-static void old_pcntl_signal_handler(int signo)
-{
-char *func_name;
-zval *param, *call_name, *retval;
-TSRMLS_FETCH();
-
-DEBUG_OUT("Caught signal: %d\n", signo);
-if (zend_hash_index_find(&PCNTL_G(php_signal_table), (long) signo, 
(void *) &func_name)==FAILURE) {
-DEBUG_OUT("Signl handler not fount");
-return;
-}
-/* DEBUG_OUT("Signal handler found, Calling %s\n", func_name); */   
-MAKE_STD_ZVAL(param);
-MAKE_STD_ZVAL(call_name);
-MAKE_STD_ZVAL(retval);
-ZVAL_LONG(param, signo);
- ZVAL_STRING(call_name, func_name, 1);
-
-/* Call php singal handler - Note that we do not report errors, and 
we ignore the return value */
-call_user_function(EG(function_table), NULL, call_name, retval, 1, 
¶m TSRMLS_CC);
-   
- zval_dtor(call_name);
-efree(call_name);
-efree(param); 
-efree(retval);
-
-return;

Re: [PHP-DEV] RFC: Moving documents in source

2002-01-20 Thread Alan Knowles

Just a little suggestion :)

>>
>>GETTING MORE INFO
>>
>>General documents are located under /docs/ directory.
>>Develper's documents are located /docs/developer/.
>>For more information, refer to following URLs.
>>
>>PHP: http://www.php.net/
>>PHP Manual:  http://www.php.net/docs.php
>>PHP Support: http://www.php.net/support.php
>>PEAR:http://pear.php.net/(PHP Libraly)
>>PHP GTK: http://gtk.php.net/ (GTK Application)
>>
can I suggest something like.. - I'm guessing =  but not everybody knows 
what GTK is...

PHP GTK: http://gtk.php.net/ (PHP Desktop Applications - Using GTK)

>>
>>PHP Bugs:http://bugs.php.net/(PHP Bug Tracking DB)
>>Zend Engine: http://www.zend.com/(Zend Script Engine and
>>




-- 
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]




Re: [PHP-DEV] Re: [PHP] Re: [PHP-DEV] Re: Computer Science and PHP

2002-01-18 Thread Alan Knowles

This kind of bytes at a nerve when you are hunting for work and almost 
nobody mentions PHP here

Anyway, A quick few ideas to throw in the pot.. - Press releases, for 
PHP5 pre-alpha, PHP-GTK's, (Derick - srm?) upcomming release etc. which 
could be made available - Then a PHP press team??, could be resposnible 
for getting it out to the Press in their local countries..

I'm would hope that there a few people out there who could help out on 
this.. "Call for Volunteers..." - Either writing 'IT Press Friendly' 
release announcements, or gathering IT Press contacts, and faxing + 
emailing + phone followup on releases...

anyway my 2c for today.

regards
alan



-- 
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]




Re: [PHP-DEV] predeclared classes

2002-01-12 Thread Alan Knowles

interesting things that can be done with stdclass

$t = new stdClass();// eg. use it as a dummy class - for use in 
sessions???- guarenteed to work..
$b = (object) array("aa"=>"bb");  // creates $b as a class - type stdClass

not sure where/how to use *OverloadedTestClass

regards
alan
*
Jan Lehnardt wrote:

>Hi,
>I am going to add a manual section about predeclared classes. According
>to http://php.net/manual/de/function.get-declared-classes.php there
>three of them. Can these be used in userspace? What is ther purpose?
>Directory for the dir() funcion is obvious, but the other ones? Can a
>developer give a statement on that?
>
>Thank You.
>
>Jan
>




-- 
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]




Re: [PHP-DEV] References - good or bad

2001-12-28 Thread Alan Knowles

Andi Gutmans wrote:

> As I mentioned on the ZE2 mailing list there general rule of thumb is:
> a) Objects should be passed by reference.
> b) Everything else including arrays should be used by value whenever 
> possible semantically.
>
> In the ZE2 objects will join b).

Is there a proposed sytnax to stop copy by reference (Or did i miss it 
in the ZE2 docs)
old stuff
$object_copy = $object;  //(copy)
$object_copy = &$object;  //(copy reference)

new stuff?
$object_copy = copy_object($object);  //(copy)
$object_copy = $object;  //(copy reference)

regards
alan

>
> Basically what this means, as long as you're not changing the data 
> passing it by value will take the full advantage of reference counting.
>
> Andi
>




-- 
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]




[PHP-DEV] php compiler - (or really) big binary builder

2001-12-28 Thread Alan Knowles

Ok, this may seem totaly crazy :)

I was having a look at the issue of the php compiler (really 
distributing a single executable) of php code. - we are starting to 
develop php-gtk apps and it seemed usefull - it appears that the 
previous effort at doing this has dissappeared of the face of the web...

rather than get into the hard chore of actually building it against the 
bytecode, the idea was just to merge php code (either zipped) or just 
appended to the php binary, and making it execute code from the end of 
it'self..

eg.

| php binary |

| php raw code |


taking a bit of code from all over the place, I created a 'embedded 
extension' the core bit being below..


Now, it currently would assume creating a big '' area (where the 
echo'test' stuff is) which would replaced by php code by  a post 
processing on the binary..

It would be nice if the application could some how work out the memory 
address at the end of the php binary - where some kind of lookup table 
of all attached php files would be located...
other than that, an easy way to do an array rather than this hacked 
embedded_1 variable stuff... would be usefull...

--ideas would be appreciated..

anyway have a happy new year everybody..

regards
alan



PHP_FUNCTION(embedded_run)
{
char *arg = NULL;
int arg_len=0 , len;
char *string = NULL;
char *tmp = "embedded_run";
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, 
&arg_len) == FAILURE) {
return;
}
if (arg) {
   string  =   embedded_get_data(arg);
   tmp=arg;
} else {  
   string  =   embedded_get_data(tmp);
}  
   
if (string)
  embedded_eval_string(string, return_value, tmp CLS_CC ELS_CC);

}


/* auto generated bit */

char *embedded_1 = "embedded_run";
char *embedded_2 = "START_EMBEDDED_2_XX...";
char *embedded_r1 = "echo \"hello there\n\";";
char *embedded_r2 = "START_EMBEDDED_R2_XX...";";


char *embedded_get_data(char *str) {

   if (!strcmp(str,embedded_1))
  return   embedded_r1;
   if (!strcmp(str,embedded_2))
  return  embedded_r2; 
   return NULL;
}


-- 
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]




Re: [PHP-DEV] Bug #12004 Updated: fopen of url results in invlaid file handle

2001-12-17 Thread Alan Knowles

Markus Fischer wrote:

>On Mon, Dec 17, 2001 at 07:08:34PM +0800, Alan Knowles wrote : 
>
>>The whole file needs a bit of an overhall for that :)
>>
>
>As most code does. But why not starting with it right away? 
>
Bit like this? ;)

Index: ftp_fopen_wrapper.c
===
RCS file: /repository/php4/ext/standard/ftp_fopen_wrapper.c,v
retrieving revision 1.11
diff -u -r1.11 ftp_fopen_wrapper.c
--- ftp_fopen_wrapper.c9 Sep 2001 13:29:18 -1.11
+++ ftp_fopen_wrapper.c17 Dec 2001 11:05:47 -
@@ -92,15 +92,23 @@

 resource = php_url_parse((char *) path);
 if (resource == NULL) {
-php_error(E_WARNING, "Invalid URL specified, %s", path);
+php_error(E_WARNING, "%s() Invalid URL specified, %s", 
get_active_function_name(TSRMLS_C), path);
 *issock = BAD_URL;
 return NULL;
 } else if (resource->path == NULL) {
-php_error(E_WARNING, "No file-path specified");
+php_error(E_WARNING, "%s() No file-path 
specified",get_active_function_name(TSRMLS_C));
 php_url_free(resource);
 *issock = BAD_URL;
 return NULL;
 }
+if (strcmp(mode, "r") &&  strcmp(mode, "w")) {
+ php_error(E_WARNING, "%s() Invalid mode, ftp can only 
access files in (r)ead or (w)rite mode",get_active_function_name(TSRMLS_C));
+php_url_free(resource);
+*issock = BAD_URL;
+return NULL;
+}
+   
+   
 /* use port 21 if one wasn't specified */
 if (resource->port == 0)
 resource->port = 21;
@@ -179,7 +187,7 @@
 if (mode[0] == 'r') {
 /* when reading file, it must exist */
 if (result > 299 || result < 200) {
-php_error(E_WARNING, "File not found");
+php_error(E_WARNING, "%s() File not 
found",get_active_function_name(TSRMLS_C));
 php_url_free(resource);
 SOCK_FCLOSE(*socketd);
 *socketd = 0;
@@ -189,7 +197,7 @@
 } else {
 /* when writing file, it must NOT exist */
 if (result <= 299 && result >= 200) {
-php_error(E_WARNING, "File already exists");
+php_error(E_WARNING, "%s() File already 
exists",get_active_function_name(TSRMLS_C));
 php_url_free(resource);
 SOCK_FCLOSE(*socketd);
 *socketd = 0;



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Re: Notification of absence.

2001-12-17 Thread Alan Knowles

Jani Taskinen wrote:

>Well..most of those closed reports have been 'bogus'..
>Or fixed by someone else. It's not that amazing.
>
>--Jani
>
I know :) - but it still takes a long while to go through that many bugs :)

>
>
>
>On Mon, 17 Dec 2001, Alan Knowles wrote:
>
>>>
>>>>Could you post current new bug database status and
>>>>new(?) lead developer?
>>>>
>>>Eh? Could you be more specific and explain what you mean
>>>by these?
>>>
>>Who is closing the bug reports?
>>sniper 3188
>>rasmus 922
>>sas 824
>>derick 585
>>
>>thats an amazing contribution
>>
>>best regards (and many thanks)
>>alan
>>
>>>
>>>--Jani
>>>
>>>
>>>
>>
>>
>
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Bug #12004 Updated: fopen of url results in invlaid file handle

2001-12-17 Thread Alan Knowles

The whole file needs a bit of an overhall for that :)

Markus Fischer wrote:

>On Mon, Dec 17, 2001 at 10:28:36AM -, [EMAIL PROTECTED] wrote : 
>
>>return NULL;
>>}
>>+if (strcmp(mode, "r") &&  strcmp(mode, "w")) {
>>+   php_error(E_WARNING, "Invalid mode : ftp can only access files in 
>(r)ead or (w)rite mode");
>>
>
>Generally I'm always for exposring the context of the current
>function with get_active_functin_name(); just like Andrei
>does it with zend_parse_parameters; "%s() ...",
>get_active_blabla.
>
>- Markus
>




-- 
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]




Re: [PHP-DEV] Re: Notification of absence.

2001-12-17 Thread Alan Knowles

>
>
>>Could you post current new bug database status and
>>new(?) lead developer?
>>
>
>Eh? Could you be more specific and explain what you mean
>by these?
>
Who is closing the bug reports?
sniper 3188
rasmus 922
sas 824
derick 585

thats an amazing contribution

best regards (and many thanks)
alan

>
>
>--Jani
>
>
>




-- 
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]




Re: [PHP-DEV] Bug #10996 Updated: fopen of url results in invlaid file handle

2001-12-16 Thread Alan Knowles

got a bit bored - and started testing some of these bugs - If anyone 
wants to make suggestions on 'ettiquete' of modifying the bug reports - 
please shout at me :)

regards
alan

[EMAIL PROTECTED] wrote:

>ID: 10996
>Updated by: alan_k
>Reported By: [EMAIL PROTECTED]
>Old Status: Analyzed
>Status: Feedback
>Bug Type: Filesystem function related
>Operating System: linux
>PHP Version: 4.0.5
>New Comment:
>
>tested this with 4.2.0-dev and appears to be fixed.
>
>could somebody check with 4.1.0?
>
>
>Previous Comments:
>
>
>[2001-05-21 14:41:53] [EMAIL PROTECTED]
>
>Reproduced with PHP 4.0.6RC1.
>
>--Jani
>
>
>
>
>
>[2001-05-21 14:19:26] [EMAIL PROTECTED]
>
>#!/usr/local/bin/php
>$fp = fopen("php://stdin", "r"); #same result with a file
>$text = fread($fp, 100);
>fclose($fp);
>$fp2 = fopen("http://cnn.com";, "r");
>$text2 = fread($fp2, 100);
>fclose($fp2);
>?>
>
>CGI version of php 4.0.5 (4.0.2 did the same too) with default "./configure"
>
>default php.ini too
>
>The URL fopen usually goes through (meaning the server of the called URL usually gets 
>the request), but the response is unreadable since the file-handle isn't valid. If 
>I'm missing something totally obvious I apologize in advance. Thanks so much. 
>-Graham Warden
>
>
>
>
>
>
>Edit this bug report at http://bugs.php.net/?id=10996&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]




Re: [PHP-DEV] How to compile PHP with cygwin?

2001-11-15 Thread Alan Knowles

Have a look through the mailing list archives (php-dev) - somebody has 
done this.

GRI wrote:

>Hi
>
>I wonder if anyone have managed to compile PHP with cygwin. I get
>several errors when doing this.
>
>I also wonder if I intend to make a dll to extend PHP for windows,
>should I then compile PHP with cygwin or with  MS Visual C++?
>
>Thanks
>
>
>
>



-- 
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]




Re: [PHP-DEV] Re: PHP 4.1.0RC2 - can we roll?

2001-11-12 Thread Alan Knowles

This may sound a bit self interested, but the curl extension has a 
serious (well to me :) bug that prevents https working - If somebody 
wants to patch/test this - it would be one less bug in 4.1.0RC2 :)
-- I have done quite a but if testing here - (with and without openssl 
libraries)

This was due to an api change in libcurl in May - so I think most people 
would have updated their libraries by now.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/curl/curl/lib/easy.c.diff?r1=1.15&r2=1.16


Bug report with tested patch at

http://bugs.php.net/bug.php?id=14023

regards

alan


-- 
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]




Re: [PHP-DEV] Re: [PHP-GTK-DEV] Help - Merging Resource into a call_function array

2001-10-18 Thread Alan Knowles

Probably worth continuing on php-gtk-dev only...

I was getting a bit further with
MAKE_STD_ZVAL(myresource);
ZVAL_RESOURCE(myresource, gs) ;
/*ZEND_REGISTER_RESOURCE(myresource, gs, le_gtkhtmlstream); */
  now the function does not segfault, but does not appear to pass resource around..

then function below is called when the browser is loading a webpage, and wants an 
image, 
it emits a signal 'url_requested', which I have added a method of html 
connect_url_request.

this builds the callback data array in data, and calls this function.. - with a new 
stream.

- theoretically, when you load the web page, you would get  a number of these call for 
each of the images. the callback routine would then either get from the cache or open 
a non-blocking socket to get the file/image..

in theory a number of these streams could be open at one time (assuming the program 
can be taught to multi task well...)


on the php side..
it is supposed to work like this...

$string = implode('',file("http://www.php.net";));
$gtkhtml = &new gtkhtml();
$gtkhtml->connect_url_request("my_url_callback");
$gtkhtml->load_from_string($string);


function my_url_callback($url,$stream) {
  global $gtkhtml;
  $string = implode('',file("http://www.php.net".$url));
  $gtkhtml->write($stream,$string);
}

the code below just segfaults when url_requested is emitted.

with the modification above, $stream does not appear to be a resource... (although Im 
still testing..)

thx
regards
alan





>----- Original Message -
> From: Markus Fischer <[EMAIL PROTECTED]>
> To: Alan Knowles <[EMAIL PROTECTED]>
> Sent: Thu, 18 Oct 2001 18:30:57 +0200
> Subject: [PHP-DEV] Re: [PHP-GTK-DEV] Help - Merging Resource into a call_function 
>array
> 
> Is gs really a newly allocated resource so you have to register
> it? Or is it arleady an existing one? If it does already exist
> (what I assume) you should fetch it from the resource lirst (quick
> look , could be wrong).
> 
> Btw, it would help telling what exactly does not work.
> 
> And, with the extra arguments, ... you really want to 'merge'
> this? I think it should be added to the args, no?
> 
> 
> On Thu, Oct 18, 2001 at 04:17:31PM -, Alan Knowles wrote : 
> > Can someone help me out with this one, - I'm sure that I've not acheived what I 
>was aiming at - adding the Resource, myresource to the array prior to calling the 
>callback function
> > 
> > the code below is from the url_request callback wrapper for gtkhtml - if this 
>works - you can build a working web browser/editor in php.. 
> > 
> > regards
> > 
> > alan
> > 
> > 
> > static void php_gtk_html_url_request_callback (GtkHTML *html, const char *url, 
>GtkHTMLStream *gs, zval* callback_data) 
> > {
> > 
> > 
> > 
> > zval *myresource = NULL; 
> > zval *retval = NULL;
> > zval **callback = NULL, **extra = NULL;
> > zval **callback_filename = NULL, **callback_lineno = NULL;
> > zval ***args, *params;
> > char *callback_name;
> > TSRMLS_FETCH();
> > 
> > zend_hash_index_find(Z_ARRVAL_P(callback_data), 0, (void **)&callback);
> > zend_hash_index_find(Z_ARRVAL_P(callback_data), 1, (void **)&extra);
> > zend_hash_index_find(Z_ARRVAL_P(callback_data), 2, (void 
>**)&callback_filename);
> > zend_hash_index_find(Z_ARRVAL_P(callback_data), 3, (void **)&callback_lineno);
> > 
> > if (!php_gtk_is_callable(*callback, 0, &callback_name)) {
> > php_error(E_WARNING, "Unable to call ctree callback '%s' specified in 
>%s on line %d", callback_name, Z_STRVAL_PP(callback_filename), 
>Z_LVAL_PP(callback_lineno));
> > efree(callback_name);
> > return;
> > }
> > 
> > params = php_gtk_build_value("(s)", url);
> > ZEND_REGISTER_RESOURCE(myresource, gs, le_gtkhtmlstream);
> > zend_hash_next_index_insert(Z_ARRVAL_P(params), (zval *) &myresource, 
>sizeof(zval *), NULL);
> > 
> > if (extra)
> > php_array_merge(Z_ARRVAL_P(params), Z_ARRVAL_PP(extra), 0);
> > 
> > args = php_gtk_hash_as_array(params);
> > 
> > call_user_function_ex(EG(function_table), NULL, *callback, &retval, 
>zend_hash_num_elements(Z_ARRVAL_P(params)), args, 0, NULL TSRMLS_CC);
> > if (retval)
> > zval_ptr_dtor(&retval);
> > efree(args);
> > zval_ptr_dtor(¶ms);
> > 
> > }
> > 
> > -- 
> > PHP-GTK Development Mailing List (http://gtk.php.net/)
>

[PHP-DEV] Help - Merging Resource into a call_function array

2001-10-18 Thread Alan Knowles

Can someone help me out with this one, - I'm sure that I've not acheived what I was 
aiming at - adding the Resource, myresource to the array prior to calling the callback 
function

the code below is from the url_request callback wrapper for gtkhtml - if this works - 
you can build a working web browser/editor in php.. 

regards

alan


static void php_gtk_html_url_request_callback (GtkHTML *html, const char *url, 
GtkHTMLStream *gs, zval* callback_data) 
{



zval *myresource = NULL; 
zval *retval = NULL;
zval **callback = NULL, **extra = NULL;
zval **callback_filename = NULL, **callback_lineno = NULL;
zval ***args, *params;
char *callback_name;
TSRMLS_FETCH();

zend_hash_index_find(Z_ARRVAL_P(callback_data), 0, (void **)&callback);
zend_hash_index_find(Z_ARRVAL_P(callback_data), 1, (void **)&extra);
zend_hash_index_find(Z_ARRVAL_P(callback_data), 2, (void 
**)&callback_filename);
zend_hash_index_find(Z_ARRVAL_P(callback_data), 3, (void **)&callback_lineno);

if (!php_gtk_is_callable(*callback, 0, &callback_name)) {
php_error(E_WARNING, "Unable to call ctree callback '%s' specified in 
%s on line %d", callback_name, Z_STRVAL_PP(callback_filename), 
Z_LVAL_PP(callback_lineno));
efree(callback_name);
return;
}

params = php_gtk_build_value("(s)", url);
ZEND_REGISTER_RESOURCE(myresource, gs, le_gtkhtmlstream);
zend_hash_next_index_insert(Z_ARRVAL_P(params), (zval *) &myresource, 
sizeof(zval *), NULL);

if (extra)
php_array_merge(Z_ARRVAL_P(params), Z_ARRVAL_PP(extra), 0);

args = php_gtk_hash_as_array(params);

call_user_function_ex(EG(function_table), NULL, *callback, &retval, 
zend_hash_num_elements(Z_ARRVAL_P(params)), args, 0, NULL TSRMLS_CC);
if (retval)
zval_ptr_dtor(&retval);
efree(args);
zval_ptr_dtor(¶ms);

}

-- 
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]




Re: [PHP-DEV] PHP 4.0.5 Release & Midgard Problems

2001-04-02 Thread Alan Knowles

> > PHP and midgard is still undergoing heavy development.

Actually it's stable release went out a few days ago? - the midgard team
actually aimed at matching the PHP release cycle.. - all modifications
at present are pure bug fixes..

> >
> > Sascha complains about the stability of PHP and all of our patch levels
yet
> > Rasmus wants to include these extensions that are applications in their
own
> > right, it just isn't practical for the QA team to test something the size
of
> > midgard and thus it doesn't get tested (unless the midgard folks test it
> > which we have to presume doesn't happen as we get no feedback from them),
we
> > then risk getting to a point like this where we are about to release PHP
> > 4.0.5 and it either 1) has to be delayed with another release cycle 2) has
> > to continue with a broken midgarad, neither are great but for the QA team
> > its very annoying when midgard, somewhat of an outside extension means we
> > have to do a whole new cycle.

We are one of the bigger application developers on midgard (having done
nadmin http://www.hklc.com/midgard_manual), and also probably the bigger
bug finder & fixer - Midgard bugs are reported and fixed on it's own
mailing list - outside of php-dev. (considering the traffic here - It
helps everybody...)

In terms classing midgard as an extension, it seems that it is no
difference in terms of maintenance (QA etc.) to other extensions like
ming, xml ... (great work there too..)  

the whole extenstion scheme works very well, however the line between
'core extension' and 'other extension', has and probably will continue to be
vague.

Interestingly, Our test builds of midgard are always done against
packaged systems (arvins work on rpms - many kudos there). As the
generally we need to install midgard into production enviroments. So it
has been important to have midgard compile against earlier versions of
PHP4 - from what we saw, the backwards compatibility issue has caused a
few problems as the API in PHP4 gets modified slightly so it breaks this
compatibility. 

I would urge the PHP development team to support midgard module (just by
keeping it the core dist. under ext.)


> 
> If I'm not mistaken, the midgaurd extension itself, only provides
> functionality to the "midguard" application?  Ie, end-users of midguard
> will not use the functions and classes exported by the extension, only
> midguard will use that functionality?

Isnt that a bit like saying the XML module only provides functionallity
to a XML application.. 

end users - use the midgard functions - we have almost completed a port
of openmerchant to PHP4/midgard - it stores the templates and some
trasent data in midgard datastore, along with the page's - it adds a
level of security, reducing or removing the dependance of file system
write access. 

Regards
Alan Knowles

P.S. Anybody fancy looking at the chinese htmlcharacters bug  + patch :)


> If so, I'm not too sure it would be a good idea to include the midguard
> extension in PEAR either...
> 
> -Sterling
> 
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] chinese patch for htmlspecialchars

2001-02-20 Thread Alan Knowles

hi, 
Just tryed adding chinese parsing ability to html specialchars, 
If you do any webdev in php in chinese, it is one of the annoying 'missing
features'


Can somebody help finish this off, There are 2 issues,
- I get compile time saying 
   html.c:76: warning: comparison is always false due to limited range of data
type
  (I'm not a C expert at all, is a (char *) expect to return < 127 ??)...


- I have no idea what type of wrapper check to check for character set or
locale 

Anyway heres the patch, If someone wants to comment on...

Index: html.c
===
RCS file: /repository/php4/ext/standard/html.c,v
retrieving revision 1.22
diff -u -r1.22 html.c
--- html.c  2000/11/24 16:17:58 1.22
+++ html.c  2001/02/21 06:57:30
@@ -51,8 +51,8 @@
 
 PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int
*newlen, int all, int quote_style)
 {
-   int i, maxlen, len;
-   char *new;
+   int i, maxlen, len, ischinese;
+   char *new, *oldnext, *oldprev;
 
maxlen = 2 * oldlen;
if (maxlen < 128)
@@ -62,6 +62,35 @@
 
i = oldlen;
while (i--) {
+
+/* needs some kind of if LC_CTYPE to check for encoding */ 
+/* if charset=chinese?? */
+  /* check if this is the first character in a chinese pair */
+ ischinese = 0; 
+ if (i > 1) { 
+   oldnext = old+1; 
+   if ((*old >= 0xa1) &&
+   (*old <= 0xf9) &&
+   (((*oldnext >= 0x40) &&
+ (*oldnext <= 0x73)) ||
+((*oldnext >= 0xa1) &&
+ (*oldnext <= 0xfe)))  
+  ) ischinese = 1;
+ }
+ /* check if this is the seconde character in a chinese pair */
+ if ((i != oldlen) && (!ischinese)) {
+   oldprev = old-1;
+   if ((*oldprev >= 0xa1) &&  
+   (*oldprev <= 0xf9) &&
+   (((*old >= 0x40) &&
+ (*old <= 0x73)) ||
+((*old >= 0xa1) &&
+ (*old <= 0xfe)))
+  ) ischinese = 1;
+ }
+
+ if (!ischinese) { 
+   
if (len + 9 > maxlen)
new = erealloc (new, maxlen += 128);
if (38 == *old) {
@@ -87,9 +116,13 @@
} else {
new [len++] = *old;
}
-   old++;
+ } else {
+   /* it is chinese - ignore it */
+   new [len++] = *old;
+ }
+ old++;
}
-new [len] = '\0';
+new [len] = '\0';
*newlen = len;
 
return new;



-- 
Technical Director
Linux Center (HK) Ltd.
www.hklc.com



-- 
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]