xref: /PHP-5.5/ext/ext_skel_win32.php (revision 0a34d107)
1<?php
2/* $Id$ */
3
4if (php_sapi_name() != "cli") {
5	echo "Please run this script using the CLI version of PHP\n";
6	exit;
7}
8/*
9	This script can be used on Win32 systems
10
11	1) Make sure you have CygWin installed
12	2) Adjust the $cygwin_path to match your installation
13	3) Change the environment cariable PATHEXT to include .PHP
14	4) run ext_skel --extname=...
15		the first time you run this script you will be asked to
16		associate it with a program. chooses the CLI version of php.
17*/
18
19$cygwin_path = 'c:\cygwin\bin';
20
21$path = getenv("PATH");
22putenv("PATH=$cygwin_path;$path");
23
24array_shift($argv);
25system("sh ext_skel " . implode(" ", $argv));
26
27$extname = "";
28$skel = "skeleton";
29foreach($argv as $arg) {
30	if (strtolower(substr($arg, 0, 9)) == "--extname") {
31		$extname = substr($arg, 10);
32	}
33	if (strtolower(substr($arg, 0, 6)) == "--skel") {
34		$skel = substr($arg, 7);
35	}
36}
37
38$fp = fopen("$skel/skeleton.dsp", "rb");
39if ($fp) {
40	$dsp_file = fread($fp, filesize("$skel/skeleton.dsp"));
41	fclose($fp);
42
43	$dsp_file = str_replace("extname", $extname, $dsp_file);
44	$dsp_file = str_replace("EXTNAME", strtoupper($extname), $dsp_file);
45	$fp = fopen("$extname/$extname.dsp", "wb");
46	if ($fp) {
47		fwrite($fp, $dsp_file);
48		fclose($fp);
49	}
50}
51
52$fp = fopen("$extname/$extname.php", "rb");
53if ($fp) {
54	$php_file = fread($fp, filesize("$extname/$extname.php"));
55	fclose($fp);
56
57	$php_file = str_replace("dl('", "dl('php_", $php_file);
58	$fp = fopen("$extname/$extname.php", "wb");
59	if ($fp) {
60		fwrite($fp, $php_file);
61		fclose($fp);
62	}
63}
64
65?>