MFH:- Added common getopt implementation to core.

MFH:- Added long-option feature to getopt().
MFH:- Made getopt() available on win32 systems.
MFH:  Patch by: David Soria Parra <dsp@php.net>
[DOC]: These changes will be available from 5.3+

# Note: Fixed also tests and synced basic_functions.c with HEAD.
This commit is contained in:
Jani Taskinen 2007-10-01 12:40:54 +00:00
parent 27e8fa0d31
commit 2bc631fb40
22 changed files with 563 additions and 755 deletions

8
NEWS
View file

@ -1,6 +1,9 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 20??, PHP 5.3.0
- Added long-option feature to getopt() and made getopt() available also on
win32 systems by adding a common getopt implementation to core.
(Jani, David Soria Parra)
- Added support for namespaces. (Dmitry, Stas)
- Added support for Late Static Binding. (Dmitry, Etienne Kneuss)
- Added support for __callstatic() magic method. (Sara)
@ -10,7 +13,7 @@ PHP NEWS
- Improved php.ini handling: (Jani)
. Added ".htaccess" style user-defined php.ini files support for CGI/FastCGI
. Added support for special [PATH=/opt/httpd/www.example.com/] sections.
. Added support for special [PATH=/opt/httpd/www.example.com/] sections
All directives set in these sections will not be able to be overridden
in user-defined ini-files or during runtime in the specified path
. Added better error reporting for php.ini syntax errors
@ -18,9 +21,8 @@ PHP NEWS
. Allowed using alphanumeric/variable indexes in "array" ini options
. Added 3rd optional parameter to parse_ini_file() to specify the scanning
mode of INI_SCANNER_NORMAL or INI_SCANNER_RAW. In raw mode option values
and section values are treated as-is.
and section values are treated as-is
. Fixed get_cfg_var() to be able to return "array" ini options
- Improved memory usage by moving constants to read only memory.
(Dmitry, Pierre)
- Improved ext/soap to support element names in context of XMLShema's <any>.

View file

@ -18,18 +18,16 @@ var_dump(constant("TEST_CONST2"));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for constant() in %s on line %d
Warning: constant() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: Wrong parameter count for constant() in %s on line %d
Warning: constant() expects exactly 1 parameter, 2 given in %s on line %d
NULL
Warning: constant(): Couldn't find constant in %s on line %d
NULL
Notice: Array to string conversion in %s on line %d
Warning: constant(): Couldn't find constant Array in %s on line %d
Warning: constant() expects parameter 1 to be string, array given in %s on line %d
NULL
int(1)
string(4) "test"

View file

@ -1146,7 +1146,7 @@ esac
if test "$PHP_CLI" != "no"; then
PHP_CLI_TARGET="\$(SAPI_CLI_PATH)"
PHP_INSTALL_CLI_TARGET="install-cli"
PHP_ADD_SOURCES(sapi/cli, php_cli.c php_cli_readline.c getopt.c,, cli)
PHP_ADD_SOURCES(sapi/cli, php_cli.c php_cli_readline.c,, cli)
PHP_INSTALLED_SAPIS="cli $PHP_SAPI"
else
PHP_INSTALLED_SAPIS="$PHP_SAPI"
@ -1296,7 +1296,7 @@ PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/ regex/])
PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c)
PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \
PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c getopt.c php_sprintf.c \
safe_mode.c fopen_wrappers.c alloca.c php_scandir.c \
php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \

File diff suppressed because it is too large Load diff

View file

@ -140,6 +140,7 @@ PHP_MINIT_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(user_filters);
PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC);
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC);
#if SIZEOF_INT == 4
/* Most 32-bit and 64-bit systems have 32-bit ints */

View file

@ -297,12 +297,6 @@ else
AC_MSG_RESULT(no)
fi
dnl getopt long options disabled for now
dnl as we can't be sure that we get the right getopt.h here
dnl using the standard AC_CHECK macros
dnl AC_CHECK_HEADERS(getopt.h)
dnl AC_CHECK_FUNCS(getopt_long getopt_long_only)
if test "$PHP_SAPI" = "cgi" || test "$PHP_SAPI" = "cli" || test "$PHP_SAPI" = "embed"; then
AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
fi

View file

@ -34,24 +34,26 @@ echo "Done\n";
--EXPECTF--
*** Testing Error Conditions ***
Warning: Wrong parameter count for extract() in %s on line %d
Warning: extract() expects at least 1 parameter, 0 given in %s on line %d
NULL
Warning: extract(): Unknown extract type in %s on line %d
Notice: A non well formed numeric value encountered in %s on line %d
Warning: extract(): Invalid extract type in %s on line %d
NULL
Warning: extract(): Unknown extract type in %s on line %d
Warning: extract(): Invalid extract type in %s on line %d
NULL
Warning: extract(): First argument should be an array in %s on line %d
Warning: extract() expects parameter 1 to be array, integer given in %s on line %d
NULL
Warning: extract(): First argument should be an array in %s on line %d
Warning: extract() expects parameter 1 to be array, string given in %s on line %d
NULL
Warning: Wrong parameter count for extract() in %s on line %d
Warning: extract() expects at most 3 parameters, 4 given in %s on line %d
NULL
Warning: extract(): Prefix expected to be specified in %s on line %d
Warning: extract(): specified extract type requires the prefix parameter in %s on line %d
NULL
Done

View file

@ -16,17 +16,17 @@ echo "Done\n";
--EXPECTF--
NULL
Warning: Wrong parameter count for error_get_last() in %s on line %d
Warning: error_get_last() expects exactly 0 parameters, 1 given in %s on line %d
NULL
array(4) {
["type"]=>
int(2)
["message"]=>
string(42) "Wrong parameter count for error_get_last()"
string(54) "error_get_last() expects exactly 0 parameters, 1 given"
["file"]=>
string(%d) "%s"
string(78) "%s"
["line"]=>
int(%d)
int(4)
}
Notice: Undefined variable: b in %s on line %d
@ -36,8 +36,8 @@ array(4) {
["message"]=>
string(21) "Undefined variable: b"
["file"]=>
string(%d) "%s"
string(78) "%s"
["line"]=>
int(%d)
int(7)
}
Done

View file

@ -26,10 +26,8 @@ var_dump($r_a, $r_b, $r_c, $r_ap);
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for import_request_variables() in %s on line %d
Warning: import_request_variables() expects at least 1 parameter, 0 given in %s on line %d
NULL
Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
NULL
Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
@ -39,7 +37,7 @@ Notice: import_request_variables(): No prefix specified - possible security haza
Warning: import_request_variables(): Attempted GLOBALS variable overwrite in %s on line %d
Warning: import_request_variables(): Numeric key detected - possible security hazard. in %s on line %d
Warning: import_request_variables(): Numeric key detected - possible security hazard in %s on line %d
NULL
Notice: Undefined variable: ap in %s on line %d

View file

@ -44,14 +44,14 @@ echo "Done\n";
--EXPECTF--
string(1) "."
Warning: Wrong parameter count for get_include_path() in %s on line %d
Warning: get_include_path() expects exactly 0 parameters, 1 given in %s on line %d
NULL
NULL
Warning: Wrong parameter count for restore_include_path() in %s on line %d
Warning: restore_include_path() expects exactly 0 parameters, 1 given in %s on line %d
NULL
Warning: Wrong parameter count for set_include_path() in %s on line %d
Warning: set_include_path() expects exactly 1 parameter, 0 given in %s on line %d
NULL
string(1) "."
string(1) "."
@ -67,9 +67,9 @@ string(1) "."
NULL
string(1) "."
Notice: Array to string conversion in %s on line %d
Warning: set_include_path() expects parameter 1 to be string, array given in %s on line %d
NULL
string(1) "."
string(5) "Array"
NULL
string(1) "."
Done

View file

@ -47,5 +47,5 @@ array(2) {
}
Warning: ini_get_all() expects at most 1 parameter, 2 given in %s on line %d
bool(false)
NULL
Done

View file

@ -48,20 +48,20 @@ string(7) "0.0.0.0"
int(1118019956)
string(14) "66.163.161.116"
Warning: Wrong parameter count for ip2long() in %s on line %d
Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d
NULL
bool(false)
bool(false)
int(1869573999)
Notice: Array to string conversion in %s on line %d
bool(false)
Warning: ip2long() expects parameter 1 to be string, array given in %s on line %d
NULL
Warning: Wrong parameter count for long2ip() in %s on line %d
Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d
NULL
string(13) "255.254.82.80"
string(7) "0.0.0.0"
Notice: Array to string conversion in %s on line %d
string(7) "0.0.0.0"
Warning: long2ip() expects parameter 1 to be string, array given in %s on line %d
NULL
Done

View file

@ -23,11 +23,11 @@
#include <assert.h>
#include <stdlib.h>
#include "php_getopt.h"
#define OPTERRCOLON (1)
#define OPTERRNF (2)
#define OPTERRARG (3)
static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int err, int show_err) /* {{{ */
{
if (show_err)
@ -53,13 +53,14 @@ static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int
}
/* }}} */
int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err) /* {{{ */
PHPAPI int php_optidx = -1;
PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start) /* {{{ */
{
static int optchr = 0;
static int dash = 0; /* have already seen the - */
int arg_start = 2;
int opts_idx = -1;
php_optidx = -1;
if (*optind >= argc) {
return(EOF);
@ -86,17 +87,17 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta
}
while (1) {
opts_idx++;
if (opts[opts_idx].opt_char == '-') {
php_optidx++;
if (opts[php_optidx].opt_char == '-') {
(*optind)++;
return(php_opt_error(argc, argv, *optind-1, optchr, OPTERRARG, show_err));
} else if (opts[opts_idx].opt_name && !strcmp(&argv[*optind][2], opts[opts_idx].opt_name)) {
} else if (opts[php_optidx].opt_name && !strcmp(&argv[*optind][2], opts[php_optidx].opt_name)) {
break;
}
}
optchr = 0;
dash = 0;
arg_start = 2 + strlen(opts[opts_idx].opt_name);
arg_start = 2 + strlen(opts[php_optidx].opt_name);
} else {
if (!dash) {
dash = 1;
@ -110,13 +111,13 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta
}
arg_start = 1 + optchr;
}
if (opts_idx < 0) {
if (php_optidx < 0) {
while (1) {
opts_idx++;
if (opts[opts_idx].opt_char == '-') {
php_optidx++;
if (opts[php_optidx].opt_char == '-') {
int errind = *optind;
int errchr = optchr;
if (!argv[*optind][optchr+1]) {
dash = 0;
(*optind)++;
@ -125,16 +126,16 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta
arg_start++;
}
return(php_opt_error(argc, argv, errind, errchr, OPTERRNF, show_err));
} else if (argv[*optind][optchr] == opts[opts_idx].opt_char) {
} else if (argv[*optind][optchr] == opts[php_optidx].opt_char) {
break;
}
}
}
if (opts[opts_idx].need_param) {
if (opts[php_optidx].need_param) {
/* Check for cases where the value of the argument
is in the form -<arg> <val> or in the form -<arg><val> */
dash = 0;
if(!argv[*optind][arg_start]) {
if (!argv[*optind][arg_start]) {
(*optind)++;
if (*optind == argc) {
return(php_opt_error(argc, argv, *optind-1, optchr, OPTERRARG, show_err));
@ -144,7 +145,7 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta
*optarg = &argv[*optind][arg_start];
(*optind)++;
}
return opts[opts_idx].opt_char;
return opts[php_optidx].opt_char;
} else {
/* multiple options specified as one (exclude long opts) */
if (arg_start >= 2 && !((argv[*optind][0] == '-') && (argv[*optind][1] == '-'))) {
@ -158,7 +159,7 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta
} else {
(*optind)++;
}
return opts[opts_idx].opt_char;
return opts[php_optidx].opt_char;
}
assert(0);
return(0); /* never reached */

View file

@ -18,6 +18,9 @@
/* $Id$ */
#ifndef PHP_GETOPT_H
#define PHP_GETOPT_H
#include "php.h"
#ifdef NETWARE
@ -27,13 +30,28 @@ As NetWare LibC has optind and optarg macros defined in unistd.h our local varia
#undef optarg
#undef optind
#endif
/* Define structure for one recognized option (both single char and long name).
* If short_open is '-' this is the last option.
*/
* If short_open is '-' this is the last option. */
typedef struct _opt_struct {
const char opt_char;
const int need_param;
const char * opt_name;
char opt_char;
int need_param;
char * opt_name;
} opt_struct;
int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err);
BEGIN_EXTERN_C()
/* holds the index of the latest fetched element from the opts array */
PHPAPI int php_optidx;
PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start);
END_EXTERN_C()
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View file

@ -1310,7 +1310,7 @@ int main(int argc, char *argv[])
}
}
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
case 'c':
if (cgi_sapi_module.php_ini_path_override) {
@ -1531,7 +1531,7 @@ consult the installation file that came with this distribution, or visit \n\
}
zend_first_try {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 1)) != -1) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 1, 2)) != -1) {
switch (c) {
case 'h':
case '?':
@ -1575,7 +1575,7 @@ consult the installation file that came with this distribution, or visit \n\
goto out;
}
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
case 'a': /* interactive mode */

View file

@ -5,6 +5,6 @@ ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes');
if (PHP_CGI == "yes") {
ADD_FLAG("LDFLAGS_CGI", "/stack:8388608");
SAPI('cgi', 'cgi_main.c getopt.c fastcgi.c', 'php-cgi.exe');
SAPI('cgi', 'cgi_main.c ..\\..\\main\\getopt.c fastcgi.c', 'php-cgi.exe');
ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib');
}

View file

@ -54,7 +54,7 @@ if test "$PHP_SAPI" = "default"; then
dnl Set install target and select SAPI
INSTALL_IT="@echo \"Installing PHP CGI binary: \$(INSTALL_ROOT)\$(bindir)/\"; \$(INSTALL) -m 0755 \$(SAPI_CGI_PATH) \$(INSTALL_ROOT)\$(bindir)/\$(program_prefix)php-cgi\$(program_suffix)\$(EXEEXT)"
PHP_SELECT_SAPI(cgi, program, cgi_main.c getopt.c fastcgi.c,, '$(SAPI_CGI_PATH)')
PHP_SELECT_SAPI(cgi, program, cgi_main.c fastcgi.c,, '$(SAPI_CGI_PATH)')
case $host_alias in
*aix*)

View file

@ -1,164 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include "php_getopt.h"
#define OPTERRCOLON (1)
#define OPTERRNF (2)
#define OPTERRARG (3)
static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int err, int show_err)
{
if (show_err)
{
fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1);
switch(err)
{
case OPTERRCOLON:
fprintf(stderr, ": in flags\n");
break;
case OPTERRNF:
fprintf(stderr, "option not found %c\n", argv[oint][optchr]);
break;
case OPTERRARG:
fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]);
break;
default:
fprintf(stderr, "unknown\n");
break;
}
}
return('?');
}
int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err)
{
static int optchr = 0;
static int dash = 0; /* have already seen the - */
int arg_start = 2;
int opts_idx = -1;
if (*optind >= argc) {
return(EOF);
}
if (!dash) {
if ((argv[*optind][0] != '-')) {
return(EOF);
} else {
if (!argv[*optind][1])
{
/*
* use to specify stdin. Need to let pgm process this and
* the following args
*/
return(EOF);
}
}
}
if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) {
/* '--' indicates end of args if not followed by a known long option name */
if (argv[*optind][2] == '\0') {
(*optind)++;
return(EOF);
}
while (1) {
opts_idx++;
if (opts[opts_idx].opt_char == '-') {
(*optind)++;
return(php_opt_error(argc, argv, *optind-1, optchr, OPTERRARG, show_err));
} else if (opts[opts_idx].opt_name && !strcmp(&argv[*optind][2], opts[opts_idx].opt_name)) {
break;
}
}
optchr = 0;
dash = 0;
arg_start = 2 + strlen(opts[opts_idx].opt_name);
} else {
if (!dash) {
dash = 1;
optchr = 1;
}
/* Check if the guy tries to do a -: kind of flag */
if (argv[*optind][optchr] == ':') {
dash = 0;
(*optind)++;
return (php_opt_error(argc, argv, *optind-1, optchr, OPTERRCOLON, show_err));
}
arg_start = 1 + optchr;
}
if (opts_idx < 0) {
while (1) {
opts_idx++;
if (opts[opts_idx].opt_char == '-') {
int errind = *optind;
int errchr = optchr;
if (!argv[*optind][optchr+1]) {
dash = 0;
(*optind)++;
} else {
optchr++;
arg_start++;
}
return(php_opt_error(argc, argv, errind, errchr, OPTERRNF, show_err));
} else if (argv[*optind][optchr] == opts[opts_idx].opt_char) {
break;
}
}
}
if (opts[opts_idx].need_param) {
/* Check for cases where the value of the argument
is in the form -<arg> <val> or in the form -<arg><val> */
dash = 0;
if(!argv[*optind][arg_start]) {
(*optind)++;
if (*optind == argc) {
return(php_opt_error(argc, argv, *optind-1, optchr, OPTERRARG, show_err));
}
*optarg = argv[(*optind)++];
} else {
*optarg = &argv[*optind][arg_start];
(*optind)++;
}
return opts[opts_idx].opt_char;
} else {
/* multiple options specified as one (exclude long opts) */
if (arg_start >= 2 && !((argv[*optind][0] == '-') && (argv[*optind][1] == '-'))) {
if (!argv[*optind][optchr+1])
{
dash = 0;
(*optind)++;
} else {
optchr++;
}
} else {
(*optind)++;
}
return opts[opts_idx].opt_char;
}
assert(0);
return(0); /* never reached */
}

View file

@ -6,7 +6,7 @@ ARG_ENABLE('crt-debug', 'Extra CRT debugging', 'no');
ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');
if (PHP_CLI == "yes") {
SAPI('cli', 'getopt.c php_cli.c php_cli_readline.c', 'php.exe');
SAPI('cli', '..\\..\\main\\getopt.c php_cli.c php_cli_readline.c', 'php.exe');
if (PHP_CRT_DEBUG == "yes") {
ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP");
}
@ -14,7 +14,7 @@ if (PHP_CLI == "yes") {
}
if (PHP_CLI_WIN32 == "yes") {
SAPI('cli_win32', 'getopt.c cli_win32.c php_cli_readline.c', 'php-win.exe');
SAPI('cli_win32', '..\\..\\main\\getopt.c cli_win32.c php_cli_readline.c', 'php-win.exe');
ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:8388608");
}

View file

@ -664,7 +664,7 @@ int main(int argc, char *argv[])
memcpy(cli_sapi_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
cli_sapi_module.ini_entries[ini_entries_len+1] = 0;
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2))!=-1) {
switch (c) {
case 'c':
if (cli_sapi_module.php_ini_path_override) {
@ -735,7 +735,7 @@ int main(int argc, char *argv[])
goto out_err;
}
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
case 'h': /* help & quit */
@ -806,7 +806,7 @@ int main(int argc, char *argv[])
php_optind = orig_optind;
php_optarg = orig_optarg;
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
case 'a': /* interactive mode */

View file

@ -1,39 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#include "php.h"
#ifdef NETWARE
/*
As NetWare LibC has optind and optarg macros defined in unistd.h our local variables were getting mistakenly preprocessed so undeffing optind and optarg
*/
#undef optarg
#undef optind
#endif
/* Define structure for one recognized option (both single char and long name).
* If short_open is '-' this is the last option.
*/
typedef struct _opt_struct {
const char opt_char;
const int need_param;
const char * opt_name;
} opt_struct;
int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err);

View file

@ -301,7 +301,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
zend_object_handlers.c zend_objects_API.c \
zend_default_classes.c zend_execute.c zend_strtod.c");
ADD_SOURCES("main", "main.c snprintf.c spprintf.c safe_mode.c fopen_wrappers.c \
ADD_SOURCES("main", "main.c snprintf.c spprintf.c safe_mode.c getopt.c fopen_wrappers.c \
php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
php_open_temporary_file.c php_logos.c output.c internal_functions.c php_sprintf.c");