Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "zend_highlight.h"
#include "zend_exceptions.h"

#include "sapi/cli/cli.h"
#include "main/cli/cli.h"
#include "readline_cli.h"

#if defined(COMPILE_DL_READLINE) && !defined(PHP_WIN32)
Expand Down
4 changes: 4 additions & 0 deletions sapi/cli/cli.h → main/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef CLI_H
#define CLI_H

#include "php.h"

#ifdef PHP_WIN32
# define PHP_CLI_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
Expand All @@ -26,6 +28,8 @@
#endif


extern PHP_CLI_API int do_php_cli(int argc, char *argv[]);

extern PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length);

typedef struct {
Expand Down
File renamed without changes.
14 changes: 3 additions & 11 deletions sapi/cli/php_cli.c → main/cli/php_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,18 +1179,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
}
/* }}} */

/* {{{ main */
#ifdef PHP_CLI_WIN32_NO_CONSOLE
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
#else
int main(int argc, char *argv[])
#endif
/* {{{ do_php_cli */
PHP_CLI_API int do_php_cli(int argc, char *argv[])
{
#if defined(PHP_WIN32)
# ifdef PHP_CLI_WIN32_NO_CONSOLE
int argc = __argc;
char **argv = __argv;
# endif
int num_args;
wchar_t **argv_wide;
char **argv_save = argv;
Expand Down Expand Up @@ -1393,6 +1385,6 @@ int main(int argc, char *argv[])
* exiting.
*/
cleanup_ps_args(argv);
exit(exit_status);
return exit_status;
}
/* }}} */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion sapi/cli/cli_win32.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#define PHP_CLI_WIN32_NO_CONSOLE 1
#include "php_cli.c"
#include "main/cli/php_cli.c"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
return do_php_cli(__argc, __argv);
}
9 changes: 7 additions & 2 deletions sapi/cli/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ if test "$PHP_CLI" != "no"; then
dnl Select SAPI.
PHP_SELECT_SAPI([cli],
[program],
[php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c],
[php_cli_main.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])

PHP_ADD_SOURCES_X([main/cli],
[php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1],
[PHP_CLI_OBJS])

AS_CASE([$host_alias],
[*aix*], [
AS_VAR_IF([php_sapi_module], [shared], [
Expand All @@ -58,5 +63,5 @@ if test "$PHP_CLI" != "no"; then

AC_CONFIG_FILES([sapi/cli/php.1])

PHP_INSTALL_HEADERS([sapi/cli], [cli.h])
PHP_INSTALL_HEADERS([main/cli], [cli.h])
fi
9 changes: 5 additions & 4 deletions sapi/cli/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes');
ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');

if (PHP_CLI == "yes") {
SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
ADD_SOURCES(configure_module_dirname, 'php_cli_process_title.c ps_title.c', 'cli');
SAPI('cli', 'php_cli_main.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
ADD_SOURCES("main/cli", "php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c", "cli");
ADD_FLAG("LIBS_CLI", "ws2_32.lib");
ADD_FLAG("LIBS_CLI", "shell32.lib");
ADD_FLAG("LDFLAGS_CLI", "/stack:67108864");
PHP_INSTALL_HEADERS("sapi/cli", "cli.h");
PHP_INSTALL_HEADERS("main/cli", "cli.h");

if (CHECK_LIB("edit_a.lib;edit.lib", "cli", PHP_CLI) &&
CHECK_HEADER("editline/readline.h", "CFLAGS_CLI")) {
Expand All @@ -19,7 +19,8 @@ if (PHP_CLI == "yes") {

if (PHP_CLI_WIN32 == "yes") {
SAPI('cli_win32', 'cli_win32.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
ADD_SOURCES(configure_module_dirname, ' php_cli_process_title.c ps_title.c', 'cli_win32', undefined, PHP_CLI == "yes");
ADD_SOURCES("main/cli", "php_cli_process_title.c ps_title.c", "cli_win32", undefined, PHP_CLI == "yes");
ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
ADD_FLAG("LIBS_CLI_WIN32", "ws2_32.lib");
ADD_FLAG("LIBS_CLI_WIN32", "shell32.lib");
}
35 changes: 35 additions & 0 deletions sapi/cli/php_cli_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) 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: |
| https://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. |
+----------------------------------------------------------------------+
*/

#include "php.h"
#include "main/cli/cli.h"
#include <stdlib.h>

#ifdef PHP_WIN32
#include <windows.h>
#endif

/* {{{ main */
#ifdef PHP_CLI_WIN32_NO_CONSOLE
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
exit(do_php_cli(__argc, __argv));
}
#else
int main(int argc, char *argv[])
{
exit(do_php_cli(argc, argv));
}
#endif
/* }}} */
30 changes: 30 additions & 0 deletions sapi/embed/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,36 @@ if test "$PHP_EMBED" != "no"; then
[$PHP_EMBED_TYPE],
[php_embed.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
dnl Feature checks for CLI sources.
AC_CHECK_FUNCS([setproctitle])
AC_CHECK_HEADERS([sys/pstat.h])
AC_CACHE_CHECK([for PS_STRINGS], [php_cv_var_PS_STRINGS],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <machine/vmparam.h>
#include <sys/exec.h>
],
[
PS_STRINGS->ps_nargvstr = 1;
PS_STRINGS->ps_argvstr = "foo";
])],
[php_cv_var_PS_STRINGS=yes],
[php_cv_var_PS_STRINGS=no])])
AS_VAR_IF([php_cv_var_PS_STRINGS], [yes],
[AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS exists.])])
dnl When CLI SAPI is also enabled, sources are already compiled into PHP_CLI_OBJS
if test "$PHP_CLI" != "no"; then
PHP_SAPI_OBJS="$PHP_SAPI_OBJS main/cli/php_cli.lo main/cli/php_http_parser.lo main/cli/php_cli_server.lo main/cli/ps_title.lo main/cli/php_cli_process_title.lo"
else
PHP_ADD_SOURCES([main/cli],
[php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1],
[sapi])
fi
PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
])
else
Expand Down
3 changes: 3 additions & 0 deletions sapi/embed/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ var PHP_EMBED_PGO = false;

if (PHP_EMBED != "no") {
SAPI('embed', 'php_embed.c', 'php' + PHP_VERSION + 'embed.lib', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
ADD_SOURCES("main/cli", "php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c", "embed");
ADD_FLAG("LIBS_EMBED", "ws2_32.lib");
ADD_FLAG("LIBS_EMBED", "shell32.lib");
PHP_INSTALL_HEADERS("sapi/embed", "php_embed.h");
}
1 change: 1 addition & 0 deletions sapi/embed/php_embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ BEGIN_EXTERN_C()
EMBED_SAPI_API int php_embed_init(int argc, char **argv);
EMBED_SAPI_API void php_embed_shutdown(void);
extern EMBED_SAPI_API sapi_module_struct php_embed_module;
EMBED_SAPI_API int do_php_cli(int argc, char *argv[]);
END_EXTERN_C()


Expand Down
Loading