summaryrefslogtreecommitdiff
path: root/sapi/cli
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:38:07 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:38:07 -0400
commitbb01389fbd53ec1cbcb80d0681a37cca1267891a (patch)
tree4783178fca65a5d9071c8df34f2ddc3d31728673 /sapi/cli
parenteddbbea4325e602ddc87c545531609132d4f0e3b (diff)
downloadphp-bb01389fbd53ec1cbcb80d0681a37cca1267891a.tar.gz
Imported Upstream version 5.2.4upstream/5.2.4
Diffstat (limited to 'sapi/cli')
-rw-r--r--sapi/cli/config.m419
-rw-r--r--sapi/cli/getopt.c17
-rw-r--r--sapi/cli/php_cli.c74
-rw-r--r--sapi/cli/php_cli_readline.c10
-rw-r--r--sapi/cli/tests/015.phpt2
5 files changed, 62 insertions, 60 deletions
diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4
index c38db2fcc..4ea165c46 100644
--- a/sapi/cli/config.m4
+++ b/sapi/cli/config.m4
@@ -1,19 +1,13 @@
dnl
-dnl $Id: config.m4,v 1.22.2.1 2006/02/02 09:59:23 dmitry Exp $
+dnl $Id: config.m4,v 1.22.2.1.2.1 2007/07/11 23:20:36 jani Exp $
dnl
-AC_MSG_CHECKING(for CLI build)
-
-AC_ARG_ENABLE(cli,
+PHP_ARG_ENABLE(cli,,
[ --disable-cli Disable building CLI version of PHP
- (this forces --without-pear)],
-[
- PHP_SAPI_CLI=$enableval
-],[
- PHP_SAPI_CLI=yes
-])
+ (this forces --without-pear)], yes, no)
-if test "$PHP_SAPI_CLI" != "no"; then
+AC_MSG_CHECKING(for CLI build)
+if test "$PHP_CLI" != "no"; then
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/cli/Makefile.frag,$abs_srcdir/sapi/cli,sapi/cli)
SAPI_CLI_PATH=sapi/cli/php
PHP_SUBST(SAPI_CLI_PATH)
@@ -38,5 +32,4 @@ if test "$PHP_SAPI_CLI" != "no"; then
PHP_SUBST(INSTALL_CLI)
PHP_OUTPUT(sapi/cli/php.1)
fi
-
-AC_MSG_RESULT($PHP_SAPI_CLI)
+AC_MSG_RESULT($PHP_CLI)
diff --git a/sapi/cli/getopt.c b/sapi/cli/getopt.c
index fd665d7d3..450de55af 100644
--- a/sapi/cli/getopt.c
+++ b/sapi/cli/getopt.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: getopt.c,v 1.8.2.1.2.5 2007/04/23 11:05:16 tony2001 Exp $ */
+/* $Id: getopt.c,v 1.8.2.1.2.6 2007/06/04 09:47:54 tony2001 Exp $ */
#include <stdio.h>
#include <string.h>
@@ -28,7 +28,7 @@
#define OPTERRARG (3)
-static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int err, int show_err)
+static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int err, int show_err) /* {{{ */
{
if (show_err)
{
@@ -51,8 +51,9 @@ static int php_opt_error(int argc, char * const *argv, int oint, int optchr, int
}
return('?');
}
+/* }}} */
-int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err)
+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 - */
@@ -162,3 +163,13 @@ int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **opta
assert(0);
return(0); /* never reached */
}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
+ */
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 03af8de50..c441835f1 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli.c,v 1.129.2.13.2.20 2007/05/06 12:57:50 johannes Exp $ */
+/* $Id: php_cli.c,v 1.129.2.13.2.22 2007/08/08 23:51:24 stas Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -164,13 +164,14 @@ static const opt_struct OPTIONS[] = {
{'-', 0, NULL} /* end of args */
};
-static int print_module_info(zend_module_entry *module TSRMLS_DC)
+static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */
{
php_printf("%s\n", module->name);
return ZEND_HASH_APPLY_KEEP;
}
+/* }}} */
-static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
+static int module_name_cmp(const void *a, const void *b TSRMLS_DC) /* {{{ */
{
Bucket *f = *((Bucket **) a);
Bucket *s = *((Bucket **) b);
@@ -178,8 +179,9 @@ static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
return strcasecmp(((zend_module_entry *)f->pData)->name,
((zend_module_entry *)s->pData)->name);
}
+/* }}} */
-static void print_modules(TSRMLS_D)
+static void print_modules(TSRMLS_D) /* {{{ */
{
HashTable sorted_registry;
zend_module_entry tmp;
@@ -190,21 +192,23 @@ static void print_modules(TSRMLS_D)
zend_hash_apply(&sorted_registry, (apply_func_t) print_module_info TSRMLS_CC);
zend_hash_destroy(&sorted_registry);
}
+/* }}} */
-static int print_extension_info(zend_extension *ext, void *arg TSRMLS_DC)
+static int print_extension_info(zend_extension *ext, void *arg TSRMLS_DC) /* {{{ */
{
php_printf("%s\n", ext->name);
return ZEND_HASH_APPLY_KEEP;
}
+/* }}} */
-static int extension_name_cmp(const zend_llist_element **f,
- const zend_llist_element **s TSRMLS_DC)
+static int extension_name_cmp(const zend_llist_element **f, const zend_llist_element **s TSRMLS_DC) /* {{{ */
{
return strcmp(((zend_extension *)(*f)->data)->name,
((zend_extension *)(*s)->data)->name);
}
+/* }}} */
-static void print_extensions(TSRMLS_D)
+static void print_extensions(TSRMLS_D) /* {{{ */
{
zend_llist sorted_exts;
@@ -214,12 +218,13 @@ static void print_extensions(TSRMLS_D)
zend_llist_apply(&sorted_exts, (llist_apply_func_t) print_extension_info TSRMLS_CC);
zend_llist_destroy(&sorted_exts);
}
+/* }}} */
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
-static inline size_t sapi_cli_single_write(const char *str, uint str_length)
+static inline size_t sapi_cli_single_write(const char *str, uint str_length) /* {{{ */
{
#ifdef PHP_WRITE_STDOUT
long ret;
@@ -236,8 +241,9 @@ static inline size_t sapi_cli_single_write(const char *str, uint str_length)
return ret;
#endif
}
+/* }}} */
-static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC)
+static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
{
const char *ptr = str;
uint remaining = str_length;
@@ -266,9 +272,9 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC)
return str_length;
}
+/* }}} */
-
-static void sapi_cli_flush(void *server_context)
+static void sapi_cli_flush(void *server_context) /* {{{ */
{
/* Ignore EBADF here, it's caused by the fact that STDIN/STDOUT/STDERR streams
* are/could be closed before fflush() is called.
@@ -279,11 +285,12 @@ static void sapi_cli_flush(void *server_context)
#endif
}
}
+/* }}} */
static char *php_self = "";
static char *script_filename = "";
-static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC)
+static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* {{{ */
{
/* In CGI mode, we consider the environment to be a part of the server
* variables
@@ -299,14 +306,15 @@ static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC)
/* just make it available */
php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC);
}
+/* }}} */
-
-static void sapi_cli_log_message(char *message)
+static void sapi_cli_log_message(char *message) /* {{{ */
{
fprintf(stderr, "%s\n", message);
}
+/* }}} */
-static int sapi_cli_deactivate(TSRMLS_D)
+static int sapi_cli_deactivate(TSRMLS_D) /* {{{ */
{
fflush(stdout);
if(SG(request_info).argv0) {
@@ -315,40 +323,44 @@ static int sapi_cli_deactivate(TSRMLS_D)
}
return SUCCESS;
}
+/* }}} */
-static char* sapi_cli_read_cookies(TSRMLS_D)
+static char* sapi_cli_read_cookies(TSRMLS_D) /* {{{ */
{
return NULL;
}
+/* }}} */
-static int sapi_cli_header_handler(sapi_header_struct *h, sapi_headers_struct *s TSRMLS_DC)
+static int sapi_cli_header_handler(sapi_header_struct *h, sapi_headers_struct *s TSRMLS_DC) /* {{{ */
{
/* free allocated header line */
efree(h->header);
/* avoid pushing headers into SAPI headers list */
return 0;
}
+/* }}} */
-static int sapi_cli_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
+static int sapi_cli_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) /* {{{ */
{
/* We do nothing here, this function is needed to prevent that the fallback
* header handling is called. */
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
+/* }}} */
-static void sapi_cli_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC)
+static void sapi_cli_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC) /* {{{ */
{
}
+/* }}} */
-
-static int php_cli_startup(sapi_module_struct *sapi_module)
+static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */
{
if (php_module_startup(sapi_module, NULL, 0)==FAILURE) {
return FAILURE;
}
return SUCCESS;
}
-
+/* }}} */
/* {{{ sapi_cli_ini_defaults */
@@ -468,7 +480,7 @@ static void php_cli_usage(char *argv0)
static php_stream *s_in_process = NULL;
-static void cli_register_file_handles(TSRMLS_D)
+static void cli_register_file_handles(TSRMLS_D) /* {{{ */
{
zval *zin, *zout, *zerr;
php_stream *s_in, *s_out, *s_err;
@@ -530,6 +542,7 @@ static void cli_register_file_handles(TSRMLS_D)
FREE_ZVAL(zout);
FREE_ZVAL(zerr);
}
+/* }}} */
static const char *param_mode_conflict = "Either execute direct code, process stdin or use a file.\n";
@@ -594,10 +607,6 @@ int main(int argc, char *argv[])
int hide_argv = 0;
/* end of temporary locals */
#ifdef ZTS
- zend_compiler_globals *compiler_globals;
- zend_executor_globals *executor_globals;
- php_core_globals *core_globals;
- sapi_globals_struct *sapi_globals;
void ***tsrm_ls;
#endif
#ifdef PHP_CLI_WIN32_NO_CONSOLE
@@ -635,6 +644,7 @@ int main(int argc, char *argv[])
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
+ tsrm_ls = ts_resource(0);
#endif
cli_sapi_module.ini_defaults = sapi_cli_ini_defaults;
@@ -703,14 +713,6 @@ int main(int argc, char *argv[])
cli_sapi_module.executable_location = argv[0];
-#ifdef ZTS
- compiler_globals = ts_resource(compiler_globals_id);
- executor_globals = ts_resource(executor_globals_id);
- core_globals = ts_resource(core_globals_id);
- sapi_globals = ts_resource(sapi_globals_id);
- tsrm_ls = ts_resource(0);
-#endif
-
/* startup after we get the above ini override se we get things right */
if (cli_sapi_module.startup(&cli_sapi_module)==FAILURE) {
/* there is no way to see if we must call zend_ini_deactivate()
diff --git a/sapi/cli/php_cli_readline.c b/sapi/cli/php_cli_readline.c
index 06903a7db..c0f5d1a1a 100644
--- a/sapi/cli/php_cli_readline.c
+++ b/sapi/cli/php_cli_readline.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli_readline.c,v 1.3.2.5.2.2 2007/02/24 02:17:28 helly Exp $ */
+/* $Id: php_cli_readline.c,v 1.3.2.5.2.3 2007/06/04 09:47:54 tony2001 Exp $ */
#include "php.h"
@@ -59,8 +59,6 @@
#include "zend_highlight.h"
#include "zend_indent.h"
-/* {{{ cli_is_valid_code
- */
typedef enum {
body,
sstring,
@@ -74,7 +72,7 @@ typedef enum {
outside,
} php_code_type;
-int cli_is_valid_code(char *code, int len, char **prompt TSRMLS_DC)
+int cli_is_valid_code(char *code, int len, char **prompt TSRMLS_DC) /* {{{ */
{
int valid_end = 1, last_valid_end;
int brackets_count = 0;
@@ -430,9 +428,7 @@ TODO:
return retval;
} /* }}} */
-/* {{{ cli_code_completion
- */
-char **cli_code_completion(const char *text, int start, int end)
+char **cli_code_completion(const char *text, int start, int end) /* {{{ */
{
return rl_completion_matches(text, cli_completion_generator);
}
diff --git a/sapi/cli/tests/015.phpt b/sapi/cli/tests/015.phpt
index be501d471..4d5226759 100644
--- a/sapi/cli/tests/015.phpt
+++ b/sapi/cli/tests/015.phpt
@@ -31,5 +31,5 @@ Array
)
PHP %d.%d.%d%s(cli) (built: %s)%s
-Usage: php [options] [-f] <file> [--] [args...]
+Usage: %s [options] [-f] <file> [--] [args...]
Done