PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.0
Defender Security – Malware Scanner, Login Security & Firewall v5.7.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / readline.php

readline.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.0, at vendor/thecodingmachine/safe/generated/readline.php

158 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\ReadlineException;
6
7 /**
8 * This function adds a line to the command line history.
9 *
10 * @param string $line The line to be added in the history.
11 * @throws ReadlineException
12 *
13 */
14 function readline_add_history(string $line): void
15 {
16 error_clear_last();
17 $result = \readline_add_history($line);
18 if ($result === false) {
19 throw ReadlineException::createFromPhpError();
20 }
21 }
22
23
24 /**
25 * Sets up a readline callback interface then prints
26 * prompt and immediately returns.
27 * Calling this function twice without removing the previous
28 * callback interface will automatically and conveniently overwrite the old
29 * interface.
30 *
31 * The callback feature is useful when combined with
32 * stream_select as it allows interleaving of IO and
33 * user input, unlike readline.
34 *
35 *
36 * Readline Callback Interface Example
37 *
38 * 10) {
39 * $prompting = false;
40 * readline_callback_handler_remove();
41 * } else {
42 * readline_callback_handler_install("[$c] Enter something: ", 'rl_callback');
43 * }
44 * }
45 *
46 * $c = 1;
47 * $prompting = true;
48 *
49 * readline_callback_handler_install("[$c] Enter something: ", 'rl_callback');
50 *
51 * while ($prompting) {
52 * $w = NULL;
53 * $e = NULL;
54 * $n = stream_select($r = array(STDIN), $w, $e, null);
55 * if ($n && in_array(STDIN, $r)) {
56 * // read a character, will call the callback when a newline is entered
57 * readline_callback_read_char();
58 * }
59 * }
60 *
61 * echo "Prompting disabled. All done.\n";
62 * ?>
63 * ]]>
64 *
65 *
66 *
67 * @param string $prompt The prompt message.
68 * @param callable $callback The callback function takes one parameter; the
69 * user input returned.
70 * @throws ReadlineException
71 *
72 */
73 function readline_callback_handler_install(string $prompt, callable $callback): void
74 {
75 error_clear_last();
76 $result = \readline_callback_handler_install($prompt, $callback);
77 if ($result === false) {
78 throw ReadlineException::createFromPhpError();
79 }
80 }
81
82
83 /**
84 * This function clears the entire command line history.
85 *
86 * @throws ReadlineException
87 *
88 */
89 function readline_clear_history(): void
90 {
91 error_clear_last();
92 $result = \readline_clear_history();
93 if ($result === false) {
94 throw ReadlineException::createFromPhpError();
95 }
96 }
97
98
99 /**
100 * This function registers a completion function. This is the same kind of
101 * functionality you'd get if you hit your tab key while using Bash.
102 *
103 * @param callable $function You must supply the name of an existing function which accepts a
104 * partial command line and returns an array of possible matches.
105 * @throws ReadlineException
106 *
107 */
108 function readline_completion_function(callable $function): void
109 {
110 error_clear_last();
111 $result = \readline_completion_function($function);
112 if ($result === false) {
113 throw ReadlineException::createFromPhpError();
114 }
115 }
116
117
118 /**
119 * This function reads a command history from a file.
120 *
121 * @param string $filename Path to the filename containing the command history.
122 * @throws ReadlineException
123 *
124 */
125 function readline_read_history(string $filename = null): void
126 {
127 error_clear_last();
128 if ($filename !== null) {
129 $result = \readline_read_history($filename);
130 } else {
131 $result = \readline_read_history();
132 }
133 if ($result === false) {
134 throw ReadlineException::createFromPhpError();
135 }
136 }
137
138
139 /**
140 * This function writes the command history to a file.
141 *
142 * @param string $filename Path to the saved file.
143 * @throws ReadlineException
144 *
145 */
146 function readline_write_history(string $filename = null): void
147 {
148 error_clear_last();
149 if ($filename !== null) {
150 $result = \readline_write_history($filename);
151 } else {
152 $result = \readline_write_history();
153 }
154 if ($result === false) {
155 throw ReadlineException::createFromPhpError();
156 }
157 }
158