Back to index

php5  5.3.10
ext_skel_win32.php
Go to the documentation of this file.
00001 <?php
00002 /* $Id: ext_skel_win32.php 242949 2007-09-26 15:44:16Z cvs2svn $ */
00003 
00004 if (php_sapi_name() != "cli") {
00005        echo "Please run this script using the CLI version of PHP\n";
00006        exit;
00007 }
00008 /*
00009        This script can be used on Win32 systems
00010        
00011        1) Make sure you have CygWin installed
00012        2) Adjust the $cygwin_path to match your installation
00013        3) Change the environment cariable PATHEXT to include .PHP
00014        4) run ext_skel --extname=...
00015               the first time you run this script you will be asked to 
00016               associate it with a program. chooses the CLI version of php.
00017 */
00018 
00019 $cygwin_path = 'c:\cygwin\bin';
00020 
00021 $path = getenv("PATH");
00022 putenv("PATH=$cygwin_path;$path");
00023 
00024 array_shift($argv);
00025 system("sh ext_skel " . implode(" ", $argv));
00026 
00027 $extname = "";
00028 $skel = "skeleton";
00029 foreach($argv as $arg) {
00030        if (strtolower(substr($arg, 0, 9)) == "--extname") {
00031               $extname = substr($arg, 10);
00032        }
00033        if (strtolower(substr($arg, 0, 6)) == "--skel") {
00034               $skel = substr($arg, 7);
00035        }
00036 }
00037 
00038 $fp = fopen("$skel/skeleton.dsp", "rb");
00039 if ($fp) {
00040        $dsp_file = fread($fp, filesize("$skel/skeleton.dsp"));
00041        fclose($fp);
00042        
00043        $dsp_file = str_replace("extname", $extname, $dsp_file);
00044        $dsp_file = str_replace("EXTNAME", strtoupper($extname), $dsp_file);
00045        $fp = fopen("$extname/$extname.dsp", "wb");
00046        if ($fp) {
00047               fwrite($fp, $dsp_file);
00048               fclose($fp);
00049        }
00050 }
00051 
00052 $fp = fopen("$extname/$extname.php", "rb");
00053 if ($fp) {
00054        $php_file = fread($fp, filesize("$extname/$extname.php"));
00055        fclose($fp);
00056        
00057        $php_file = str_replace("dl('", "dl('php_", $php_file);
00058        $fp = fopen("$extname/$extname.php", "wb");
00059        if ($fp) {
00060               fwrite($fp, $php_file);
00061               fclose($fp);
00062        }
00063 }
00064 
00065 ?>