php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
console.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Michele Locati <mlocati@gmail.com> |
14 +----------------------------------------------------------------------+
15 */
16
17#include "php.h"
18#include "SAPI.h"
19#include "win32/console.h"
20
21
23{/*{{{*/
25 HANDLE handle = (HANDLE) _get_osfhandle(fileno);
26
27 if (handle != INVALID_HANDLE_VALUE) {
28 DWORD mode;
29 if (GetConsoleMode(handle, &mode)) {
30 result = TRUE;
31 }
32 }
33 return result;
34}/*}}}*/
35
37{/*{{{*/
39 HANDLE handle = (HANDLE) _get_osfhandle(fileno);
40
41 if (handle != INVALID_HANDLE_VALUE) {
42 DWORD events;
43
44 if (fileno != 0 && !GetNumberOfConsoleInputEvents(handle, &events)) {
45 // Not STDIN
46 DWORD mode;
47
48 if (GetConsoleMode(handle, &mode)) {
50 result = TRUE;
51 }
52 }
53 }
54 }
55 return result;
56}/*}}}*/
57
59{/*{{{*/
61 HANDLE handle = (HANDLE) _get_osfhandle(fileno);
62
63 if (handle != INVALID_HANDLE_VALUE) {
64 DWORD events;
65
66 if (fileno != 0 && !GetNumberOfConsoleInputEvents(handle, &events)) {
67 // Not STDIN
68 DWORD mode;
69
70 if (GetConsoleMode(handle, &mode)) {
71 DWORD newMode;
72
73 if (enable) {
75 }
76 else {
78 }
79 if (newMode == mode) {
80 result = TRUE;
81 }
82 else {
83 if (SetConsoleMode(handle, newMode)) {
84 result = TRUE;
85 }
86 }
87 }
88 }
89 }
90 return result;
91}/*}}}*/
92
94{/*{{{*/
95 if (!IsDebuggerPresent()) {
96 CONSOLE_SCREEN_BUFFER_INFO csbi;
97 DWORD pl[1];
98 BOOL ret0 = FALSE, ret1 = FALSE;
99
100 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
101 ret0 = !csbi.dwCursorPosition.X && !csbi.dwCursorPosition.Y;
102 }
103
104 ret1 = GetConsoleProcessList(pl, 1) == 1;
105
106 return ret0 && ret1;
107 }
108
109 return FALSE;
110}/*}}}*/
111
113{/*{{{*/
114 return strlen(sapi_module.name) >= sizeof("cli") - 1 && !strncmp(sapi_module.name, "cli", sizeof("cli") - 1);
115}/*}}}*/
116
SAPI_API sapi_module_struct sapi_module
Definition SAPI.c:65
PHP_WINUTIL_API BOOL php_win32_console_is_cli_sapi(void)
Definition console.c:112
PHP_WINUTIL_API BOOL php_win32_console_fileno_has_vt100(zend_long fileno)
Definition console.c:36
PHP_WINUTIL_API BOOL php_win32_console_is_own(void)
Definition console.c:93
PHP_WINUTIL_API BOOL php_win32_console_fileno_is_console(zend_long fileno)
Definition console.c:22
PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL enable)
Definition console.c:58
#define PHP_WINUTIL_API
Definition console.h:24
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING
Definition console.h:33
#define DWORD
Definition exif.c:1762
DL_HANDLE handle
Definition ffi.c:3028
char * mode
#define TRUE
Definition gd_gd.c:7
#define FALSE
Definition gd_gd.c:8
int BOOL
strlen(string $string)
strncmp(string $string1, string $string2, int $length)
int32_t zend_long
Definition zend_long.h:42
bool result