php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_cli_process_title.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: Keyur Govande (kgovande@gmail.com) |
14 +----------------------------------------------------------------------+
15*/
16
17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21#include "php.h"
23#include "ps_title.h"
24
25/* {{{ Return a boolean to confirm if the process title was successfully changed or not */
27{
28 char *title = NULL;
29 size_t title_len;
30 int rc;
31
32 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &title, &title_len) == FAILURE) {
34 }
35
36 rc = set_ps_title(title);
37 if (rc == PS_TITLE_SUCCESS) {
39 }
40
41 php_error_docref(NULL, E_WARNING, "cli_set_process_title had an error: %s", ps_title_errno(rc));
43}
44/* }}} */
45
46/* {{{ Return a string with the current process title. NULL if error. */
48{
49 size_t length = 0;
50 const char* title = NULL;
51 int rc;
52
55 }
56
57 rc = get_ps_title(&length, &title);
58 if (rc != PS_TITLE_SUCCESS) {
59 php_error_docref(NULL, E_WARNING, "cli_get_process_title had an error: %s", ps_title_errno(rc));
61 }
62
63 RETURN_STRINGL(title, length);
64}
65/* }}} */
#define NULL
Definition gdcache.h:45
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
#define PHP_FUNCTION
Definition php.h:364
cli_set_process_title(string $title)
const char * ps_title_errno(int rc)
Definition ps_title.c:307
int get_ps_title(size_t *displen, const char **string)
Definition ps_title.c:397
int set_ps_title(const char *title)
Definition ps_title.c:340
#define PS_TITLE_SUCCESS
Definition ps_title.h:20
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define RETURN_STRINGL(s, l)
Definition zend_API.h:1044
#define RETURN_FALSE
Definition zend_API.h:1058
#define RETURN_NULL()
Definition zend_API.h:1036
#define zend_parse_parameters_none()
Definition zend_API.h:353
#define RETURN_THROWS()
Definition zend_API.h:1060
#define RETURN_TRUE
Definition zend_API.h:1059
#define E_WARNING
Definition zend_errors.h:24
@ FAILURE
Definition zend_types.h:61