Re: Windows ENV['_'] equivalent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Lynch wrote:
On Sat, October 14, 2006 4:09 am, Stut wrote:
Richard: AFAIK there is no way to know this under windows without
writing an extension to tell you.

Sounds like you actually know how to do this... :-)

Would such an extension be cross-platform to all PHP installs, or
Windows-only?

And is this some trivial thing that the PHP Devs just havent' had time
to do, or some monumental task of goofy OSes that nobody wants to
touch?

I'm happy to take a shot at it if it's easy, but if it's something the
PHP Devs don't want to touch, I know I ain't got a shot at it! :-)

I've not looked at the CLI SAPI at all yet, so I don't know if it gets put anywhere, but the SAPI main() function will get what you want passed to it. I guess now's as good a time as any...

Hey, whaddya know, it does. Check out [1]. Not sure how you'd get to that in an extension, but it's there. Since it's not linked that's a pretty good sign that that particular member of the struct is not used anywhere. In fact, looking at the usage of that var [2] it may not be available outside the SAPI code.

However, looking a bit further [3] it's defined as a static var in php_cli.c, so you may be able to get at it with an extern declaration. You should get the full path to the binary from the CLI module, looks like it's NULL for any SAPI that doesn't set it. However, it was never going to be that simple. It looks like that struct has a different name in each SAPI, so you may need to do something to mod the code if it's not building the CLI SAPI.

Should be able to knock something up armed with that. And yes, it should be the same code for all platforms. I'd love to have a go at this myself (just for fun), but unfortunately I don't have a great deal of spare time at the moment. Let me know how you get on.

[1] http://lxr.php.net/source/php-src/sapi/cli/php_cli.c#691
[2] http://lxr.php.net/ident?i=cli_sapi_module
[3] http://lxr.php.net/source/php-src/sapi/cli/php_cli.c#368

-Stut

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux