*
* Unicode command strings are encoding using filesystem_encoding, returned data is not decoded back to unicode
*/
-int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC)
+PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC)
{
FILE *fp;
char *buf;
if (type != 3) {
b = buf;
-
+
while (php_stream_get_line(stream, ZSTR(b), EXEC_INPUT_BUF, &bufl)) {
/* no new line found, let's read some more */
if (b[bufl - 1] != '\n' && !php_stream_eof(stream)) {
PHPWRITE(buf, bufl);
sapi_flush(TSRMLS_C);
} else if (type == 2) {
- /* strip trailing whitespaces */
+ /* strip trailing whitespaces */
l = bufl;
while (l-- && isspace(((unsigned char *)buf)[l]));
if (l != (bufl - 1)) {
b = buf;
}
if (bufl) {
- /* strip trailing whitespaces if we have not done so already */
+ /* strip trailing whitespaces if we have not done so already */
if (type != 2) {
l = bufl;
while (l-- && isspace(((unsigned char *)buf)[l]));
}
}
- pclose_return = php_stream_close(stream);
+ pclose_return = php_stream_close(stream);
efree(buf);
done:
{
php_exec_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
-
/* }}} */
/* {{{ proto int system(string command [, int &return_value]) U
*NOT* safe for binary strings
*/
-char *php_escape_shell_cmd(char *str) {
+PHPAPI char *php_escape_shell_cmd(char *str)
+{
register int x, y, l = strlen(str);
char *cmd;
char *p = NULL;
size_t estimate = (2 * l) + 1;
cmd = safe_emalloc(2, l, 1);
-
+
for (x = 0, y = 0; x < l; x++) {
switch (str[x]) {
case '"':
/* {{{ php_escape_shell_arg
*/
-char *php_escape_shell_arg(char *str) {
+PHPAPI char *php_escape_shell_arg(char *str)
+{
int x, y = 0, l = strlen(str);
char *cmd;
size_t estimate = (4 * l) + 3;
cmd = safe_emalloc(4, l, 3); /* worst case */
-
+
#ifdef PHP_WIN32
cmd[y++] = '"';
#else
RETURN_FALSE;
}
}
-
+
if (argument) {
cmd = php_escape_shell_arg(argument);
RETVAL_STRING(cmd, 0);
stream = php_stream_fopen_from_pipe(in, "rb");
total_readbytes = php_stream_copy_to_mem(stream, &ret, PHP_STREAM_COPY_ALL, 0);
- php_stream_close(stream);
-
+ php_stream_close(stream);
+
if (total_readbytes > 0) {
RETVAL_STRINGL(ret, total_readbytes, 0);
}
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only a super user may attempt to increase the priority of a process");
RETURN_FALSE;
}
-
+
RETURN_TRUE;
}
/* }}} */